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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1ef5df69574c5404ec3775edf10f3367525ce1a3 | 2,150 | h | C | online_library_system_classes/User.h | AdelBenAshraf/online_library_system | 7b0bab56bb8a4e422812a3f59a70b168580d7bfc | [
"CC0-1.0"
] | null | null | null | online_library_system_classes/User.h | AdelBenAshraf/online_library_system | 7b0bab56bb8a4e422812a3f59a70b168580d7bfc | [
"CC0-1.0"
] | null | null | null | online_library_system_classes/User.h | AdelBenAshraf/online_library_system | 7b0bab56bb8a4e422812a3f59a70b168580d7bfc | [
"CC0-1.0"
] | null | null | null | /*
@author Adel Ashraf
@Explaination: This User.h which have the declaration of the attribute and methods for the class which make type users
which have these attributes (name, age, email, password, id) and It have setters and getters for every attribute,
have the equality operator overloading, input operator overloading and output operator overloading.
.............
*/
#ifndef OOP_ASSIGNMENT2_USER_H
#define OOP_ASSIGNMENT2_USER_H
#include <cstring>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
class User {
private:
string name_;
int age_;
int id_;
string password_;
string email_;
public:
static int count;// This used to increment the ID attribute.
User();// This the default constructor.
User(string, int, string, string);//This is the parameterized constructor.
User(const User&);//This is the copying constructor and it is using reference to avoid copying by value and avoid wasting memory.
bool operator == (const User&);// This is an equality operator overloading to compare to users to each other.
void setName(string); // This function takes one parameter which is string to set the name.
string getName() const;// This function used for getting the name.
void setPassword(string);// This function takes one parameter which is string to set the password.
string getPassword() const;// This function used for getting the password.
void setEmail(string);// This function takes one parameter which is string to set the email.
string getEmail();// This function used for getting the email.
void setAge(int);// This function takes one parameter which is int to set the age.
int getAge();// This function used for getting the age.
void setId();// This function for setting the Id.
void setId(int);
int getId();// // This function used for getting the Id.
friend ostream &operator<<(ostream &output, const User &);// This friend function is the output operator overloading.
friend istream &operator>>(istream &input, User &);// This friend function is the input operator overloading.
};
#endif
| 34.126984 | 133 | 0.726512 |
f0dd612d9adbde93e3eaef2489d7f6554f4cc0fc | 17,002 | h | C | externals/service_rng_mkl.h | h2oai/daal | d49815df3040f3872a1fdb9dc99ee86148e4494e | [
"Apache-2.0"
] | 2 | 2020-05-16T00:57:44.000Z | 2020-05-17T15:56:38.000Z | externals/service_rng_mkl.h | afcarl/daal | d49815df3040f3872a1fdb9dc99ee86148e4494e | [
"Apache-2.0"
] | null | null | null | externals/service_rng_mkl.h | afcarl/daal | d49815df3040f3872a1fdb9dc99ee86148e4494e | [
"Apache-2.0"
] | 3 | 2017-09-29T19:51:42.000Z | 2020-12-03T09:09:48.000Z | /* file: service_rng_mkl.h */
/*******************************************************************************
* Copyright 2014-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.
*******************************************************************************/
/*
//++
// Declaration of math service functions
//--
*/
#ifndef __SERVICE_RNG_MKL_H__
#define __SERVICE_RNG_MKL_H__
#include "vmlvsl.h"
#include "service_defines.h"
#include "service_rng_common.h"
#if !defined(__DAAL_CONCAT5)
#define __DAAL_CONCAT5(a,b,c,d,e) __DAAL_CONCAT51(a,b,c,d,e)
#define __DAAL_CONCAT51(a,b,c,d,e) a##b##c##d##e
#endif
#if defined(_WIN64) || defined(__x86_64__)
#if defined(__APPLE__)
#define __DAAL_MKLVSL_SSE2 u8
#else
#define __DAAL_MKLVSL_SSE2 ex
#endif
#define __DAAL_VSLFN_CALL1(f_pref,f_name,f_args,errcode) \
if(avx512 == cpu) \
{ \
errcode = __DAAL_VSLFN(z0,f_pref,f_name) f_args; \
} \
if(avx512_mic == cpu) \
{ \
errcode = __DAAL_VSLFN(b3,f_pref,f_name) f_args; \
} \
if(avx2 == cpu) \
{ \
errcode = __DAAL_VSLFN(l9,f_pref,f_name) f_args; \
} \
if(avx == cpu) \
{ \
errcode = __DAAL_VSLFN(e9,f_pref,f_name) f_args; \
} \
if(sse42 == cpu) \
{ \
errcode = __DAAL_VSLFN(h8,f_pref,f_name) f_args; \
} \
if(ssse3 == cpu) \
{ \
errcode = __DAAL_VSLFN(u8,f_pref,f_name) f_args; \
} \
if(sse2 == cpu) \
{ \
errcode = __DAAL_VSLFN(__DAAL_MKLVSL_SSE2,f_pref,f_name) f_args; \
} \
if (errcode != 0) { return errcode; }
#define __DAAL_VSLFN_CALL2(f_pref,f_name,f_args,retcode) \
if(avx512 == cpu) \
{ \
retcode = __DAAL_VSLFN(z0,f_pref,f_name) f_args; \
} \
if(avx512_mic == cpu) \
{ \
retcode = __DAAL_VSLFN(b3,f_pref,f_name) f_args; \
} \
if(avx2 == cpu) \
{ \
retcode = __DAAL_VSLFN(l9,f_pref,f_name) f_args; \
} \
if(avx == cpu) \
{ \
retcode = __DAAL_VSLFN(e9,f_pref,f_name) f_args; \
} \
if(sse42 == cpu) \
{ \
retcode = __DAAL_VSLFN(h8,f_pref,f_name) f_args; \
} \
if(ssse3 == cpu) \
{ \
retcode = __DAAL_VSLFN(u8,f_pref,f_name) f_args; \
} \
if(sse2 == cpu) \
{ \
retcode = __DAAL_VSLFN(__DAAL_MKLVSL_SSE2,f_pref,f_name) f_args; \
}
#else
#if defined(__APPLE__)
#define __DAAL_MKLVSL_SSE2 v8
#else
#define __DAAL_MKLVSL_SSE2 w7
#endif
#define __DAAL_VSLFN_CALL1(f_pref,f_name,f_args,errcode) \
if(avx512 == cpu) \
{ \
errcode = __DAAL_VSLFN(x0,f_pref,f_name) f_args; \
} \
if(avx512_mic == cpu) \
{ \
errcode = __DAAL_VSLFN(a3,f_pref,f_name) f_args; \
} \
if(avx2 == cpu) \
{ \
errcode = __DAAL_VSLFN(s9,f_pref,f_name) f_args; \
} \
if(avx == cpu) \
{ \
errcode = __DAAL_VSLFN(g9,f_pref,f_name) f_args; \
} \
if(sse42 == cpu) \
{ \
errcode = __DAAL_VSLFN(n8,f_pref,f_name) f_args; \
} \
if(ssse3 == cpu) \
{ \
errcode = __DAAL_VSLFN(v8,f_pref,f_name) f_args; \
} \
if(sse2 == cpu) \
{ \
errcode = __DAAL_VSLFN(__DAAL_MKLVSL_SSE2,f_pref,f_name) f_args; \
} \
if (errcode != 0) { return errcode; }
#define __DAAL_VSLFN_CALL2(f_pref,f_name,f_args,retcode) \
if(avx512 == cpu) \
{ \
retcode = __DAAL_VSLFN(x0,f_pref,f_name) f_args; \
} \
if(avx512_mic == cpu) \
{ \
retcode = __DAAL_VSLFN(a3,f_pref,f_name) f_args; \
} \
if(avx2 == cpu) \
{ \
retcode = __DAAL_VSLFN(s9,f_pref,f_name) f_args; \
} \
if(avx == cpu) \
{ \
retcode = __DAAL_VSLFN(g9,f_pref,f_name) f_args; \
} \
if(sse42 == cpu) \
{ \
retcode = __DAAL_VSLFN(n8,f_pref,f_name) f_args; \
} \
if(ssse3 == cpu) \
{ \
retcode = __DAAL_VSLFN(v8,f_pref,f_name) f_args; \
} \
if(sse2 == cpu) \
{ \
retcode = __DAAL_VSLFN(__DAAL_MKLVSL_SSE2,f_pref,f_name) f_args; \
}
#endif
#define __DAAL_VSLFN(f_cpu,f_pref,f_name) __DAAL_CONCAT5(f_pref,_,f_cpu,_,f_name)
#define __DAAL_VSLFN_CALL(f_pref,f_name,f_args,errcode) __DAAL_VSLFN_CALL1(f_pref,f_name,f_args,errcode)
#define __DAAL_VSLFN_CALL_NR(f_pref,f_name,f_args,errcode) __DAAL_VSLFN_CALL2(f_pref,f_name,f_args,errcode)
#define __DAAL_VSLFN_CALL_NR_WHILE(f_pref,f_name,f_args,errcode) \
{ \
size_t nn_left = n; \
while( nn_left > 0 ) \
{ \
nn = ( nn_left > 0xFFFFFFFL )? 0xFFFFFFF : (int)( nn_left ); \
\
__DAAL_VSLFN_CALL2(f_pref,f_name,f_args,errcode); \
if( errcode < 0 ) return errcode; \
\
rr += nn; \
nn_left -= nn; \
} \
}
// RNGs
#define __DAAL_BRNG_MT19937 VSL_BRNG_MT19937
#define __DAAL_RNG_METHOD_UNIFORM_STD VSL_RNG_METHOD_UNIFORM_STD
#define __DAAL_RNG_METHOD_BERNOULLI_ICDF VSL_RNG_METHOD_BERNOULLI_ICDF
#define __DAAL_RNG_METHOD_GAUSSIAN_BOXMULLER VSL_RNG_METHOD_GAUSSIAN_BOXMULLER
#define __DAAL_RNG_METHOD_GAUSSIAN_BOXMULLER2 VSL_RNG_METHOD_GAUSSIAN_BOXMULLER2
#define __DAAL_RNG_METHOD_GAUSSIAN_ICDF VSL_RNG_METHOD_GAUSSIAN_ICDF
namespace daal
{
namespace internal
{
namespace mkl
{
/* Uniform distribution generator functions */
template<typename T, CpuType cpu>
int uniformRNG(const size_t n, T* r, void* stream, const T a, const T b, const int method);
template<CpuType cpu>
int uniformRNG(const size_t n, int* r, void* stream, const int a, const int b, const int method)
{
int errcode = 0;
int nn = (int)n;
int* rr = r;
__DAAL_VSLFN_CALL_NR_WHILE(fpk_vsl_kernel, iRngUniform, ( method, stream, nn, rr, a, b ), errcode);
return errcode;
}
template<CpuType cpu>
int uniformRNG(const size_t n, float* r, void* stream, const float a, const float b, const int method)
{
int errcode = 0;
int nn = (int)n;
float* rr = r;
__DAAL_VSLFN_CALL_NR_WHILE(fpk_vsl_kernel, sRngUniform, ( method, stream, nn, rr, a, b ), errcode);
return errcode;
}
template<CpuType cpu>
int uniformRNG(const size_t n, double* r, void* stream, const double a, const double b, const int method)
{
int errcode = 0;
int nn = (int)n;
double* rr = r;
__DAAL_VSLFN_CALL_NR_WHILE(fpk_vsl_kernel, dRngUniform, ( method, stream, nn, rr, a, b ), errcode);
return errcode;
}
/* Gaussian distribution generator functions */
template<typename T, CpuType cpu>
int gaussianRNG(const size_t n, T* r, void* stream, const T a, const T sigma, const int method);
template<CpuType cpu>
int gaussianRNG(const size_t n, float* r, void* stream, const float a, const float sigma, const int method)
{
int errcode = 0;
int nn = (int)n;
float* rr = r;
__DAAL_VSLFN_CALL_NR_WHILE(fpk_vsl_kernel, sRngGaussian, ( method, stream, nn, rr, a, sigma ), errcode);
return errcode;
}
template<CpuType cpu>
int gaussianRNG(const size_t n, double* r, void* stream, const double a, const double sigma, const int method)
{
int errcode = 0;
int nn = (int)n;
double* rr = r;
__DAAL_VSLFN_CALL_NR_WHILE(fpk_vsl_kernel, dRngGaussian, ( method, stream, nn, rr, a, sigma ), errcode);
return errcode;
}
/* Bernoulli distribution generator functions */
template<typename T, CpuType cpu>
int bernoulliRNG(const size_t n, T* r, void *stream, const double p, const int method);
template<CpuType cpu>
int bernoulliRNG(const size_t n, int* r, void *stream, const double p, const int method)
{
int errcode = 0;
int nn = (int)n;
int* rr = r;
__DAAL_VSLFN_CALL_NR_WHILE(fpk_vsl_kernel, iRngBernoulli, (method, stream, nn, rr, p), errcode);
return errcode;
}
template<CpuType cpu>
class BaseRNG : public BaseRNGIface<cpu>
{
public:
BaseRNG(const unsigned int _seed, const int _brngId) : stream(0)
{
int errcode = 0;
__DAAL_VSLFN_CALL_NR(fpk_vsl_sub_kernel, vslNewStreamEx, ( &stream, _brngId, 1, &_seed ), errcode);
}
BaseRNG(const size_t n, const unsigned int* _seed, const int _brngId = __DAAL_BRNG_MT19937) : stream(0)
{
int errcode = 0;
__DAAL_VSLFN_CALL_NR(fpk_vsl_sub_kernel, vslNewStreamEx, ( &stream, _brngId, n, _seed ), errcode);
}
~BaseRNG()
{
int errcode = 0;
__DAAL_VSLFN_CALL_NR(fpk_vsl_sub_kernel, vslDeleteStream, ( &stream ), errcode);
}
int getStateSize()
{
int res = 0;
__DAAL_VSLFN_CALL_NR(fpk_vsl_sub_kernel, vslGetStreamSize, (stream), res);
return res;
}
int saveState(void* dest)
{
int errcode = 0;
__DAAL_VSLFN_CALL_NR(fpk_vsl_sub_kernel, vslSaveStreamM, (stream, (char*)dest), errcode);
return errcode;
}
int loadState(const void* src)
{
int errcode = 0;
__DAAL_VSLFN_CALL_NR(fpk_vsl_sub_kernel, vslDeleteStream, (&stream), errcode);
if(!errcode)
__DAAL_VSLFN_CALL_NR(fpk_vsl_sub_kernel, vslLoadStreamM, (&stream, (const char*)src), errcode);
return errcode;
}
void* getState()
{
return stream;
}
private:
void* stream;
};
/*
// Generator functions definition
*/
template<typename Type, CpuType cpu>
class RNGs
{
public:
typedef DAAL_INT SizeType;
typedef BaseRNG<cpu> BaseType;
RNGs() {}
int uniform(const SizeType n, Type* r, BaseType &brng, const Type a, const Type b, const int method)
{
return uniformRNG<cpu>(n, r, brng.getState(), a, b, method);
}
int uniform(const SizeType n, Type* r, void *state, const Type a, const Type b, const int method)
{
return uniformRNG<cpu>(n, r, state, a, b, method);
}
int bernoulli(const SizeType n, Type* r, BaseType &brng, const double p, const int method)
{
return bernoulliRNG<cpu>(n, r, brng.getState(), p, method);
}
int gaussian(const SizeType n, Type* r, BaseType &brng, const Type a, const Type sigma, const int method)
{
return gaussianRNG<cpu>(n, r, brng.getState(), a, sigma, method);
}
int gaussian(const SizeType n, Type* r, void *state, const Type a, const Type sigma, const int method)
{
return gaussianRNG<cpu>(n, r, state, a, sigma, method);
}
};
}
}
}
#endif
| 44.860158 | 110 | 0.3986 |
214fd86baa122120b3af4f72fe97c4ac367019cd | 9,271 | c | C | src/JouleQueue.c | enjoylife/axon | a944a13c83d2cef7e6ae8dc9cc2cd92a5f3424be | [
"BSD-3-Clause"
] | null | null | null | src/JouleQueue.c | enjoylife/axon | a944a13c83d2cef7e6ae8dc9cc2cd92a5f3424be | [
"BSD-3-Clause"
] | null | null | null | src/JouleQueue.c | enjoylife/axon | a944a13c83d2cef7e6ae8dc9cc2cd92a5f3424be | [
"BSD-3-Clause"
] | null | null | null | /* File: JouleQueue.c
* Version: 1.0
* Purpose: Implementation of a fast thread conscious worker queue.
* Author: Matthew Clemens
* Copyright: Modified BSD, see LICENSE for more details
*/
#ifndef _JouleQueue
#define _JouleQueue
#include <stdlib.h>
#include <string.h> //memset
#include <pthread.h>
#include <assert.h>
#include <sys/time.h>
#include <unistd.h>
#include "JouleQueue.h"
#include "common.h"
// passed to threads on initialization
typedef struct start_type {
jq_t q;
jq_thread_t * thread; // pass our specfic thread data
} start_type_t;
static void * default_app_engine(void * arg);
static void * thread_initilizer(void * arg);
/* Creates and waits for complete setup of threads, then gets out of their way. */
int jq_init(jq_t q, jq_config_t * config){
// pthread stuff
int status;
status = pthread_attr_init (&q->attr);
checkp(status);
status = pthread_attr_setdetachstate (
&q->attr, PTHREAD_CREATE_DETACHED);
checkp(status);
status = pthread_mutex_init (&q->mutex, NULL);
checkp(status);
status = pthread_cond_init (&q->cv, NULL);
checkp(status);
// internal counters
q->counter = 0;
q->running = 0;
q->quit = 0;
// queue
job_t * new = malloc(sizeof(job_t));
new->data = 0;
new->next = NULL;
// first node is always a dummy node
q->head = q->tail = new;
// config stuff
q->app_engine =
(config == NULL) ? default_app_engine : config->app_engine;
q->parallelism =
(config == NULL) ? JQ_DEFAULT_THREAD_COUNT :
(config->max_threads <= JQ_MAX_THREAD_COUNT) ?
config->max_threads : JQ_MAX_THREAD_COUNT;
// we need to hold on to mutex now or else a speedy thread might signal
// before were done seting up
pthread_mutex_lock(&q->mutex);
// setup each thread
q->thread_list = NULL;
start_type_t * start = malloc(sizeof(start_type_t));
for(int i = 0; i< q->parallelism; i++){
jq_thread_t * node = (jq_thread_t *) malloc(sizeof(jq_thread_t));
checkm(node);
node->jqid = i;
node->tstate = TS_ALIVE;
node->next = q->thread_list;
q->thread_list = node;
memset(node->hazards, 0, MAX_HAZ_POINTERS);
//node->rtotal = 0;
//memset(node->rarray, 0, MAX_WASTE);
start->q = q;
start->thread = node; //pass in this threads stuff;
pthread_create(&node->ptid, NULL, thread_initilizer, (void*)start);
log_info("Pid %p", node->ptid);
}
// wait for them to be all setup, and allow them to continue initilizing
while(pthread_cond_wait(&q->cv, &q->mutex));
pthread_mutex_unlock(&q->mutex);
log_info("threads ready %d", q->running);
// commence work
return SUCCESS;
}
int dequeue(queue_t * q, jq_thread_t * h, void ** data){
job_t *head, *tail, *next, *changed;
//log_warn("Start DEQUEUE",1);
for(int i = 0;;i++){
head = q->head;
//h->hazards[0] = head;
if(q->head != head) continue;
tail = q->tail;
next = head->next;
//h->hazards[1] = next;
if(q->head != head) continue;
if(next == NULL) return EMPTY;
if(head == tail) {
while(1){ // help other threads
changed = SYNC_CAS(&q->tail,tail, next);
if(changed == tail){
//log_success("Made change #1: %d",i);
break;
}else {
//log_info("Contention #1: %d",i);
}
}
continue;
}
*data = next->data;
//log_info("DATA IS: %d",*(int*)data);
changed = SYNC_CAS(&q->head,head,next);
if( changed == head){
//log_success("Made change #2: %d",i);
break;
}
}
//remove_box(head);
//log_warn("END DEQUEUE",1);
return SUCCESS;
}
void * thread_initilizer(void * arg){
struct timeval t;
struct timespec timeout;
//jq_t q = (jq_t ) arg;
start_type_t * start = (start_type_t *) arg;
jq_t q = start->q;
jq_thread_t * thread_specific = start->thread;
pthread_mutex_lock(&q->mutex); // can't finish before main
int new = SYNC_ADD(&q->running,1);
pthread_mutex_unlock(&q->mutex);
//log_info("PID %p", (void*)pthread_self());
if(new == q->parallelism){ // were all ready tell main
pthread_cond_signal(&q->cv);
}
// testing
int max_work = 1000;
int * saved_work = malloc(sizeof(void *) * max_work);
int work_counter = 0;
int empty_counter = 0;
int * data = malloc(sizeof(void*));
int status;
// log_success("Got Data %d", *(int*)data);
while(!q->quit){
TRY:
status = dequeue(q,NULL,(void*) &data);
switch(status){
case SUCCESS:
empty_counter = 0;
//log_success("SUCCESS %p",thread_specific->ptid);
log_success("Data %d, Thread %p", *(int*)data, thread_specific->ptid);
if(work_counter > max_work-1){
log_warn("ATE TOO MUCH",1);
// return saved_work;
}
else {
saved_work[work_counter] = *(int*)data;
}
work_counter++;
goto TRY;
case EMPTY:
// log_warn("EMPTY %d",empty_counter);
gettimeofday(&t, NULL);
TIMEVAL_TO_TIMESPEC(&t, &timeout);
timeout.tv_sec += 2;
//pthread_mutex_lock(&q->mutex);
//status = pthread_cond_timedwait(&q->cv, &q->mutex, &timeout);
empty_counter++;
//pthread_mutex_unlock(&q->mutex);
//if (status == ETIMEDOUT) {
//log_warn("Try again %d",empty_counter);
sleep(2);
if( empty_counter >= 3){
log_warn("Worker wait timed out %d",empty_counter);
return saved_work;
// }
//return SUCCESS;
} else if (status == EINVAL){
log_warn("PTHREAD ERROR",1);
} else {
log_warn("WEIRD WAKE",1);
}
break;
case FAILURE:
log_warn("FAILURE",1);
break;
default:
log_warn("UNKONN",1);
break;
}
}
log_warn("I GUESS WERE LEAVING",1);
//return saved_work;
return SUCCESS;
}
int jq_add(jq_t q, void * data){
enqueue(q,NULL, data);
return SUCCESS;
}
int queue_destroy(queue_t * q){
pthread_attr_destroy(&q->attr);
pthread_mutex_destroy(&q->mutex);
pthread_cond_destroy(&q->cv);
jq_thread_t *link = q->thread_list;
jq_thread_t * prev;
while(link != NULL){
prev = link;
link = link->next;
free(prev);
}
return SUCCESS;
}
int enqueue(queue_t * q, jq_thread_t * h, void * data){
//int enqueue_haz(queue_t * q, work_unit_t *data){
job_t * new = malloc(sizeof(job_t));
checkm(new);
new->data = data;
new->flags = 0;
new->next = NULL;
job_t * tail, * next, * changed;
for(int i = 0;;i++){
tail = q->tail;
//h->hazards[0] = h == NULL ? tail : NULL;
if(tail != q->tail) continue;
next = tail->next;
//if(q->tail != tail) continue;
if(next != NULL){
while(1){ // help other threads
changed = SYNC_CAS(&q->tail,tail, next);
if(changed == tail){
//log_success("Made change #1: %d",i);
break;
}else {
//log_info("Contention #1: %d",i);
}
}
continue;
}
changed = SYNC_CAS(&tail->next,NULL,new);
if( changed == NULL){
assert(tail->next == new);
assert(tail->next->data == new->data);
assert(&(tail->next->data) == &new->data);
tail = q->tail;
//log_success("Made change #2: %d",i);
break;
}
while(1){
changed = SYNC_CAS(&q->tail,tail,new);
if(changed == tail){
//log_success("Made change #3: %d",i);
break;
}else {
//log_info("Contention #3: %d",i);
}
}
}
return SUCCESS;
}
int remove_box(job_t * box){
free(box);
return SUCCESS;
}
int job_traverse(job_t *box){
job_t * link = box;
log_info("Traversing",1);
while(link != NULL){
log_info("Data %d", *(int*)(link->data));
link = link->next;
}
return SUCCESS;
}
int jq_thread_traverse(jq_t q){
jq_thread_t *link = q->thread_list;
int i = 0;
while(link != NULL){
log_info("Traverseing id:%d, pthread_t: %p", link->jqid, link->ptid);
link = link->next;
}
return SUCCESS;
}
static void * default_app_engine(void * arg){
sleep(1);
return SUCCESS;
}
#endif // _JouleQueue
| 29.062696 | 86 | 0.518822 |
56c209746c6ab065885f4df3e72c2bac82cdfb71 | 11,604 | c | C | src/luaclie.c | robimp/luaclie | e38b77ada7bafe0705ef6a7c64603d078835efef | [
"MIT"
] | 1 | 2015-08-26T01:53:58.000Z | 2015-08-26T01:53:58.000Z | src/luaclie.c | robimp/luaclie | e38b77ada7bafe0705ef6a7c64603d078835efef | [
"MIT"
] | null | null | null | src/luaclie.c | robimp/luaclie | e38b77ada7bafe0705ef6a7c64603d078835efef | [
"MIT"
] | null | null | null | #include <lua5.3/lua.h>
#include <lua5.3/lauxlib.h>
#include <lua5.3/lualib.h>
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <math.h>
#define COLOR_RED 31
#define COLOR_GREEN 32
#define COLOR_BLUE 34
lua_State *L_c;
int clie_file_completion;
struct str_array
{
char *str;
struct str_array *next;
};
void sa_print(struct str_array *str_array_head);
void sa_append(struct str_array **str_array_head, const char* str);
void sa_free(struct str_array *str_array_head);
int sa_getn(struct str_array *str_array_head);
void bail(lua_State *L, char *msg);
struct str_array *tableminer_c(const char *table_path);
char *get_table_path(const char *text, char **table_key);
char *get_last_key(char* text);
char *completion_gen(const char* text, int state);
void completion_display_hook(char **matches, int num_matches, int max_length);
void add_color(int color, char** str);
void clie_completion_display(char **matches, int num_matches, int max_length);
int help(int a, int b);
////////////////////////////////////////////////////////////////////////////////
// String chained array
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
void sa_print(struct str_array *str_array_head)
{
if(str_array_head != NULL)
{
printf("STR: %s\n", str_array_head->str);
sa_print(str_array_head->next);
}
}
//------------------------------------------------------------------------------
void sa_append(struct str_array **str_array_head, const char* str)
{
struct str_array *str_array_tail;
if(*str_array_head == NULL)
{
*str_array_head = (struct str_array*) malloc(sizeof(struct str_array));
(*str_array_head)->next = NULL;
str_array_tail = *str_array_head;
}
else
{
str_array_tail = *str_array_head;
while(str_array_tail->next != NULL)
str_array_tail = str_array_tail->next;
str_array_tail->next = (struct str_array*) malloc(sizeof(struct str_array));
str_array_tail = str_array_tail->next;
str_array_tail->next = NULL;
}
str_array_tail->str = (char*) malloc(sizeof(char)*(strlen(str) + 1));
strcpy(str_array_tail->str, str);
}
//------------------------------------------------------------------------------
void sa_free(struct str_array *str_array_head)
{
if(str_array_head != NULL)
{
sa_free(str_array_head->next);
free(str_array_head->str);
str_array_head->str = NULL;
free(str_array_head);
str_array_head = NULL;
}
}
//------------------------------------------------------------------------------
int sa_getn(struct str_array *str_array_head)
{
int len = 0;
struct str_array *str_array_traveler;
str_array_traveler = str_array_head;
while(str_array_traveler != NULL)
{
len++;
str_array_traveler = str_array_traveler->next;
}
return len;
}
////////////////////////////////////////////////////////////////////////////////
// Lua interface
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
void bail(lua_State *L, char *msg)
{
fprintf(stderr, "\nFATAL ERROR:\n %s: %s\n\n",
msg, lua_tostring(L, -1));
// exit(1);
}
//------------------------------------------------------------------------------
struct str_array *tableminer_c(const char *table_path)//lua_State *L)
{
lua_State *L = L_c;
const char *table_name;
struct str_array *table_names = NULL;
// L = luaL_newstate();
// luaL_openlibs(L);
// if(luaL_loadfile(L, "tableminer.lua"))
// bail(L, "luaL_loadfile() failed");
// // Prime run
// if (lua_pcall(L, 0, 0, 0))
// bail(L, "lua_pcall() failed");
// Executes luaclie.tableminer(tablepath)
lua_getglobal(L, "luaclie");
lua_pushstring(L, "tableminer");
lua_gettable(L, -2);
lua_pushstring(L, table_path);
if(lua_pcall(L, 1, 1, 0))
bail(L, "lua_pcall() failed");
lua_pushnil(L);
while(lua_next(L, -2))
{
table_name = lua_tostring(L, -1);
sa_append(&table_names, table_name);
lua_pop(L,1);
}
lua_pop(L,2); // lua_close(L);
return table_names;
}
////////////////////////////////////////////////////////////////////////////////
// String management
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
char* get_table_path(const char *text, char **table_key)
{
int i, path_len = 0;
char* table_path;
for(i=0; i<strlen(text); i++)
if(text[i] == '.' || text[i] == ':')
path_len = i;
if(path_len > 0)
{
table_path = (char*) malloc(sizeof(char)*(path_len + 2));
*table_key = (char*) malloc(sizeof(char)*(strlen(text) - path_len + 1));
for(i=0; i < strlen(text); i++)
if(i <= path_len)
table_path[i] = text[i];
else
(*table_key)[i - path_len - 1] = text[i];
table_path[path_len + 1] = '\0';
(*table_key)[strlen(text) - path_len - 1] = '\0';
}
else
{
*table_key = (char*) malloc(sizeof(char)*(strlen(text) + 1));
strcpy(*table_key, text);
table_path = (char*) malloc(sizeof(char));
table_path[0] = '\0';
}
return table_path;
}
//------------------------------------------------------------------------------
// Get last key after '.' or ':'
char* get_last_key(char* text)
{
int i, last_dot = -1;
char *last_key;
int length = (int)strlen(text);
// Find last dot
for(i=0; i < length - 1; i++)
if(text[i] == '.' || text[i] == ':')
last_dot = i;
last_key = (char*) malloc(sizeof(char)*(length - last_dot + 1));
for(i = last_dot + 1; i <= length; i++)
last_key[i - (last_dot + 1)] = text[i];
return last_key;
}
//------------------------------------------------------------------------------
// Add linux style color to string
void add_color(int color, char** str)
{
char* str_color = malloc(sizeof(char) * ((int)strlen(*str) + 11 + 1));
sprintf(str_color, "\e[%d;1m", color);
strcat(str_color, *str);
strcat(str_color, "\e[0m");
free(*str);
*str = str_color;
}
////////////////////////////////////////////////////////////////////////////////
// Readline hooks and callbacks
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
// Completion generator to rl_completion_entry_function
char* completion_gen(const char* text, int state)
{
char *table_key, *str;
static char *table_path;
static struct str_array *table_names_head, *table_names;
static struct str_array *possible_completions_head, *possible_completions;
int is_possible_completion, i;
// If quoted, use file completion.
clie_file_completion = 0;
if(rl_completion_quote_character == '\"')
{
clie_file_completion = 1;
return rl_filename_completion_function(text, state);
}
// Prevents insersion of space at the end of the completed word.
rl_completion_suppress_append = 1;
// First call
if(state == 0)
{
table_path = NULL;
table_key = NULL;
possible_completions_head = NULL;
table_path = get_table_path(text, &table_key);
table_names_head = tableminer_c(table_path);
table_names = table_names_head;
while(table_names != NULL)
{
is_possible_completion = 1;
for(i=0; i < strlen(table_key); i++)
if(table_key[i] != table_names->str[i] && table_names->str[i] != '\0')
{
is_possible_completion = 0;
break;
}
if(is_possible_completion)
sa_append(&possible_completions_head, table_names->str);
table_names = table_names->next;
}
possible_completions = possible_completions_head;
free(table_key);
table_key = NULL;
}
// Return a possible completion at each call
if(possible_completions != NULL)
{
str = (char*) malloc(sizeof(char)*(strlen(possible_completions->str) + strlen(table_path) + 1));
strcpy(str, table_path);
strcat(str, possible_completions->str);
possible_completions = possible_completions->next;
if(sa_getn(possible_completions_head) == 1 && !strcmp(text, str))
{
sa_free(table_names_head);
sa_free(possible_completions_head);
free(table_path);
return NULL;
}
return str;
}
else
{
sa_free(table_names_head);
sa_free(possible_completions_head);
free(table_path);
return NULL;
}
}
//------------------------------------------------------------------------------
// Matches display hook for readline completion
void completion_display_hook(char **matches, int num_matches, int max_length)
{
int i, length, new_max_length = 0;
char **parsed_matches;
if(clie_file_completion == 1)
{
rl_display_match_list(matches, num_matches, max_length);
rl_forced_update_display();
return;
}
parsed_matches = (char**) malloc(sizeof(char*)*num_matches + 1);
for(i=0; i<=num_matches; i++)
{
parsed_matches[i] = get_last_key(matches[i]);
length = (int)strlen(parsed_matches[i]);
if(length > new_max_length)
new_max_length = length;
}
clie_completion_display(parsed_matches, num_matches, new_max_length);
free(parsed_matches);
rl_forced_update_display();
}
//------------------------------------------------------------------------------
// Emulates the rl_display_match_list function
void clie_completion_display(char **matches, int num_matches, int max_length)
{
int terminal_width, col_num, prints_column, i, j, k, match_id, length;
char *terminal_width_env;
printf("\n");
// Length of each printed column
max_length = max_length + 2;
// Get column number
terminal_width_env = getenv("COLUMNS");
if (terminal_width_env != NULL)
terminal_width = atoi(terminal_width_env);
else
terminal_width = 80;
col_num = terminal_width/max_length;
// Get number of prints per column
prints_column = ceil((float)num_matches/(float)col_num);
// Print routine
for(i=0; i<prints_column; i++)
{
for(j=0; j<col_num; j++)
{
match_id = i+j*prints_column + 1;
if(match_id <= num_matches)
{
length = (int)strlen(matches[match_id]);
// Add color if needed
if(matches[match_id][length - 1] == '.' || matches[match_id][length - 1] == ':')
add_color(COLOR_BLUE, &matches[match_id]);
else if (matches[match_id][length - 1] == '(')
add_color(COLOR_GREEN, &matches[match_id]);
// Do the printing stuff
printf("%s", matches[match_id]);
for(k=length; k<max_length; k++)
printf(" ");
}
}
printf("\n");
}
}
////////////////////////////////////////////////////////////////////////////////
// Other
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
int help(int a, int b)
{
lua_State *L = L_c;
// Executes luaclie.tableminer(tablepath)
lua_getglobal(L, "luaclie");
lua_pushstring(L, "funcref");
lua_gettable(L, -2);
// lua_pushnil(L);
lua_pushstring(L, rl_copy_text(0, rl_point));
if(lua_pcall(L, 1, 1, 0))
bail(L, "lua_pcall() failed");
lua_pop(L, 2); // lua_close(L);
rl_forced_update_display();
return 0;
}
//------------------------------------------------------------------------------
int luaopen_luaclie_luaclie_c(lua_State *L)
{
L_c = L;
// lua_register(L, "tableminer_c", tableminer_c);
rl_completion_entry_function = completion_gen;
rl_completer_quote_characters = "\"";
rl_completion_display_matches_hook = completion_display_hook;
rl_bind_keyseq("\\eh", help);
return 0;
}
| 26.312925 | 98 | 0.562392 |
06fbc88a65a5e022b3e79750631095b6bf8a325f | 1,433 | h | C | FontChangeCore/HookApi.h | ray831/FontChangeLib | b2555b40157351b99641cc05ad36b381bb317390 | [
"MIT"
] | null | null | null | FontChangeCore/HookApi.h | ray831/FontChangeLib | b2555b40157351b99641cc05ad36b381bb317390 | [
"MIT"
] | null | null | null | FontChangeCore/HookApi.h | ray831/FontChangeLib | b2555b40157351b99641cc05ad36b381bb317390 | [
"MIT"
] | null | null | null | #pragma once
#ifndef _HOOKAPI_H_
#define _HOOKAPI_H_
#include "stdafx.h"
// ANSI
// Hook CreateFontA
HFONT WINAPI NewCreateFontA(
_In_ int nHeight,
_In_ int nWidth,
_In_ int nEscapement,
_In_ int nOrientation,
_In_ int fnWeight,
_In_ DWORD fdwItalic,
_In_ DWORD fdwUnderline,
_In_ DWORD fdwStrikeOut,
_In_ DWORD fdwCharSet,
_In_ DWORD fdwOutputPrecision,
_In_ DWORD fdwClipPrecision,
_In_ DWORD fdwQuality,
_In_ DWORD fdwPitchAndFamily,
_In_ LPCSTR lpszFace
);
// Hook CreateFontIndirectA
HFONT WINAPI NewCreateFontIndirectA(LOGFONTA *lplf);
// UNICODE
// Hook CreateFontW
HFONT WINAPI NewCreateFontW(
_In_ int nHeight,
_In_ int nWidth,
_In_ int nEscapement,
_In_ int nOrientation,
_In_ int fnWeight,
_In_ DWORD fdwItalic,
_In_ DWORD fdwUnderline,
_In_ DWORD fdwStrikeOut,
_In_ DWORD fdwCharSet,
_In_ DWORD fdwOutputPrecision,
_In_ DWORD fdwClipPrecision,
_In_ DWORD fdwQuality,
_In_ DWORD fdwPitchAndFamily,
_In_ LPCWSTR lpszFace
);
// Hook CreateFontIndirectW
HFONT WINAPI NewCreateFontIndirectW(LOGFONTW *lplf);
// #######################################
// Hook SelectObject
HGDIOBJ WINAPI NewSelectObject(
_In_ HDC hdc,
_In_ HGDIOBJ hgdiobj);
// #######################################
void WINAPI HookFontInit(FCFONTINFO fi);
NTSTATUS WINAPI HookCreateFont();
NTSTATUS WINAPI HookSelectObject();
#endif | 19.902778 | 52 | 0.698535 |
0580d1c1ae7b0de3cd47d52dc5f8fff2ed8f13bb | 5,390 | c | C | examples/protocols/http_server/file_serving/main/mount.c | BU-EC444/esp-idf | 5963de1caf284b14ddfed11e52730a55e3783a3d | [
"Apache-2.0"
] | 4 | 2022-03-15T22:43:28.000Z | 2022-03-28T01:25:08.000Z | examples/protocols/http_server/file_serving/main/mount.c | BU-EC444/esp-idf | 5963de1caf284b14ddfed11e52730a55e3783a3d | [
"Apache-2.0"
] | null | null | null | examples/protocols/http_server/file_serving/main/mount.c | BU-EC444/esp-idf | 5963de1caf284b14ddfed11e52730a55e3783a3d | [
"Apache-2.0"
] | 2 | 2022-02-04T21:36:58.000Z | 2022-02-09T12:22:48.000Z | /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/* HTTP File Server Example, SD card / SPIFFS mount functions.
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <string.h>
#include "esp_log.h"
#include "esp_err.h"
#include "esp_vfs_fat.h"
#include "esp_spiffs.h"
#include "sdkconfig.h"
#include "soc/soc_caps.h"
#include "driver/sdspi_host.h"
#include "driver/spi_common.h"
#if SOC_SDMMC_HOST_SUPPORTED
#include "driver/sdmmc_host.h"
#endif
#include "sdmmc_cmd.h"
#include "file_serving_example_common.h"
static const char *TAG = "example_mount";
#ifdef CONFIG_EXAMPLE_MOUNT_SD_CARD
esp_err_t example_mount_storage(const char* base_path)
{
ESP_LOGI(TAG, "Initializing SD card");
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
#ifdef CONFIG_EXAMPLE_FORMAT_IF_MOUNT_SDCARD_FAILED
.format_if_mount_failed = true,
#else
.format_if_mount_failed = false,
#endif // CONFIG_EXAMPLE_FORMAT_IF_MOUNT_SDCARD_FAILED
.max_files = 5,
.allocation_unit_size = 16 * 1024
};
esp_err_t ret;
sdmmc_card_t* card;
#ifdef CONFIG_EXAMPLE_USE_SDMMC_HOST
ESP_LOGI(TAG, "Using SDMMC peripheral");
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
// This initializes the slot without card detect (CD) and write protect (WP) signals.
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
// To use 1-line SD mode, change this to 1:
slot_config.width = 4;
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
// For chips which support GPIO Matrix for SDMMC peripheral, specify the pins.
slot_config.clk = CONFIG_EXAMPLE_PIN_CLK;
slot_config.cmd = CONFIG_EXAMPLE_PIN_CMD;
slot_config.d0 = CONFIG_EXAMPLE_PIN_D0;
slot_config.d1 = CONFIG_EXAMPLE_PIN_D1;
slot_config.d2 = CONFIG_EXAMPLE_PIN_D2;
slot_config.d3 = CONFIG_EXAMPLE_PIN_D3;
#endif // SOC_SDMMC_USE_GPIO_MATRIX
// Enable internal pullups on enabled pins. The internal pullups
// are insufficient however, please make sure 10k external pullups are
// connected on the bus. This is for debug / example purpose only.
slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
ret = esp_vfs_fat_sdmmc_mount(base_path, &host, &slot_config, &mount_config, &card);
#else // CONFIG_EXAMPLE_USE_SDMMC_HOST
ESP_LOGI(TAG, "Using SPI peripheral");
sdmmc_host_t host = SDSPI_HOST_DEFAULT();
spi_bus_config_t bus_cfg = {
.mosi_io_num = CONFIG_EXAMPLE_PIN_MOSI,
.miso_io_num = CONFIG_EXAMPLE_PIN_MISO,
.sclk_io_num = CONFIG_EXAMPLE_PIN_CLK,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.max_transfer_sz = 4000,
};
ret = spi_bus_initialize(host.slot, &bus_cfg, SDSPI_DEFAULT_DMA);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize bus.");
return ret;
}
// This initializes the slot without card detect (CD) and write protect (WP) signals.
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();
slot_config.gpio_cs = CONFIG_EXAMPLE_PIN_CS;
slot_config.host_id = host.slot;
ret = esp_vfs_fat_sdspi_mount(base_path, &host, &slot_config, &mount_config, &card);
#endif // !CONFIG_EXAMPLE_USE_SDMMC_HOST
if (ret != ESP_OK){
if (ret == ESP_FAIL) {
ESP_LOGE(TAG, "Failed to mount filesystem. "
"If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option.");
} else {
ESP_LOGE(TAG, "Failed to initialize the card (%s). "
"Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret));
}
return ret;
}
sdmmc_card_print_info(stdout, card);
return ESP_OK;
}
#else // CONFIG_EXAMPLE_MOUNT_SD_CARD
/* Function to initialize SPIFFS */
esp_err_t example_mount_storage(const char* base_path)
{
ESP_LOGI(TAG, "Initializing SPIFFS");
esp_vfs_spiffs_conf_t conf = {
.base_path = base_path,
.partition_label = NULL,
.max_files = 5, // This sets the maximum number of files that can be open at the same time
.format_if_mount_failed = true
};
esp_err_t ret = esp_vfs_spiffs_register(&conf);
if (ret != ESP_OK) {
if (ret == ESP_FAIL) {
ESP_LOGE(TAG, "Failed to mount or format filesystem");
} else if (ret == ESP_ERR_NOT_FOUND) {
ESP_LOGE(TAG, "Failed to find SPIFFS partition");
} else {
ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
}
return ret;
}
size_t total = 0, used = 0;
ret = esp_spiffs_info(NULL, &total, &used);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
return ret;
}
ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
return ESP_OK;
}
#endif // !CONFIG_EXAMPLE_MOUNT_SD_CARD
| 33.478261 | 115 | 0.694991 |
05c2b44f2645e1962c4a5258a5b3e1e7900eccba | 66 | h | C | Sources/BoostGammaInvCpp/include/BoostGammaInvCpp.h | nihp-public/boostswift-public | 4ff469c242c240cc1d54fbe67a2f77f7f883c0d9 | [
"MIT"
] | 1 | 2021-02-12T06:34:20.000Z | 2021-02-12T06:34:20.000Z | Sources/BoostGammaInvCpp/include/BoostGammaInvCpp.h | nihp-public/boostswift-public | 4ff469c242c240cc1d54fbe67a2f77f7f883c0d9 | [
"MIT"
] | null | null | null | Sources/BoostGammaInvCpp/include/BoostGammaInvCpp.h | nihp-public/boostswift-public | 4ff469c242c240cc1d54fbe67a2f77f7f883c0d9 | [
"MIT"
] | 1 | 2020-10-29T15:01:26.000Z | 2020-10-29T15:01:26.000Z |
namespace boostswift {
double gamma_p_inv(double a, double p);
}
| 13.2 | 39 | 0.757576 |
05d005796b5bcf37fdeeece9c0115c7df421d35e | 1,387 | h | C | adt/mesin_kar.h | didithilmy/engis-kitchen | a1994e01d2f3bac8025ca2be74f1b7e2314fc6b6 | [
"Apache-2.0"
] | null | null | null | adt/mesin_kar.h | didithilmy/engis-kitchen | a1994e01d2f3bac8025ca2be74f1b7e2314fc6b6 | [
"Apache-2.0"
] | null | null | null | adt/mesin_kar.h | didithilmy/engis-kitchen | a1994e01d2f3bac8025ca2be74f1b7e2314fc6b6 | [
"Apache-2.0"
] | 2 | 2019-11-28T04:31:03.000Z | 2020-01-23T07:20:40.000Z | /**
* Engi's Kitchen Expansion
* Mesin Karakter abstraction
*
* Header file template provided by ITB
* @file mesin_kar.c
*/
#ifndef __MESIN_KAR__
#define __MESIN_KAR__
#include "boolean.h"
#include <stdio.h>
#define MARK 0
/* State Mesin */
extern char CC;
extern boolean EOP;
extern int CCi;
/*
pada implementasi (mesin_kar.c), perlu ditambahkan variabel static
global yang menyimpan pembacaan file pita.
*/
void START(char* string);
/* Mesin siap dioperasikan. Pita disiapkan untuk dibaca.
Karakter pertama yang ada pada pita posisinya adalah pada jendela.
filename merupakan nama file yang berisi pita karakter
I.S. : sembarang
F.S. : CC adalah karakter pertama pada pita
Jika CC != MARK maka EOP akan padam (false)
Jika CC = MARK maka EOP akan menyala (true) */
void ADV();
/* Pita dimajukan satu karakter.
I.S. : Karakter pada jendela = CC, CC != MARK
F.S. : CC adalah karakter berikutnya dari CC yang lama,
CC mungkin = MARK
Jika CC = MARK maka EOP akan menyala (true) */
char GetCC();
/* Mengembalikan karakter yang sedang terbaca di jendela.
I.S. : Karakter pada jendela = CC, CC != MARK
F.S. : mengembalikan karakter yang sedang terbaca di jendela
*/
boolean IsEOP();
/* Mengecek apakah pita telah selesai dibaca
I.S. : Pita telah terbaca
F.S. : Menegmbalikan true jika pita telah selesai terbaca, false jika sebaliknya
*/
char ToUpper(char lower);
#endif | 23.913793 | 80 | 0.736121 |
19727eeaa03293c75eed257c399f2fda95f01879 | 54,625 | h | C | include/scn/reader/string.h | GerHobbelt/scnlib | 3ebb3d02d8c7e704dde754c74dcac52830ae1cdd | [
"Apache-2.0",
"MIT"
] | null | null | null | include/scn/reader/string.h | GerHobbelt/scnlib | 3ebb3d02d8c7e704dde754c74dcac52830ae1cdd | [
"Apache-2.0",
"MIT"
] | null | null | null | include/scn/reader/string.h | GerHobbelt/scnlib | 3ebb3d02d8c7e704dde754c74dcac52830ae1cdd | [
"Apache-2.0",
"MIT"
] | null | null | null | // Copyright 2017 Elias Kosunen
//
// 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
//
// https://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.
//
// This file is a part of scnlib:
// https://github.com/eliaskosunen/scnlib
#ifndef SCN_READER_STRING_H
#define SCN_READER_STRING_H
#include "../util/small_vector.h"
#include "common.h"
namespace scn {
SCN_BEGIN_NAMESPACE
namespace detail {
class set_parser_type {
public:
constexpr set_parser_type() = default;
template <typename ParseCtx>
error parse_set(ParseCtx& pctx, bool& parsed)
{
using char_type = typename ParseCtx::char_type;
SCN_EXPECT(pctx.next_char() == ascii_widen<char_type>('['));
pctx.advance_char();
if (!pctx || pctx.check_arg_end()) {
return {error::invalid_format_string,
"Unexpected end of format string argument"};
}
get_option(flag::enabled) = true;
parsed = true;
if (pctx.next_char() == ascii_widen<char_type>('^')) {
// inverted
get_option(flag::inverted) = true;
pctx.advance_char();
if (!pctx || pctx.check_arg_end()) {
return {error::invalid_format_string,
"Unexpected end of format string argument"};
}
}
if (pctx.next_char() == ascii_widen<char_type>(']')) {
// end of range
get_option(flag::accept_all) = true;
pctx.advance_char();
return {};
}
while (true) {
if (!pctx || pctx.check_arg_end()) {
return {error::invalid_format_string,
"Unexpected end of format string argument"};
}
const auto ch = pctx.next_char();
if (ch == ascii_widen<char_type>(']')) {
break;
}
auto err = parse_next_char(pctx, true);
if (!err) {
return err;
}
err = pctx.advance_cp();
if (!err) {
pctx.advance_char();
}
}
auto err = pctx.advance_cp();
if (!err) {
pctx.advance_char();
}
return {};
}
error sanitize(bool localized)
{
// specifiers -> chars, if not localized
if (get_option(flag::use_specifiers)) {
if ((get_option(specifier::letters) ||
get_option(specifier::alpha)) &&
get_option(specifier::inverted_letters)) {
get_option(flag::accept_all) = true;
}
if (get_option(specifier::alnum_underscore) &&
get_option(specifier::inverted_alnum_underscore)) {
get_option(flag::accept_all) = true;
}
if ((get_option(specifier::whitespace) ||
get_option(specifier::space)) &&
get_option(specifier::inverted_whitespace)) {
get_option(flag::accept_all) = true;
}
if ((get_option(specifier::numbers) ||
get_option(specifier::digit)) &&
get_option(specifier::inverted_numbers)) {
get_option(flag::accept_all) = true;
}
}
if (get_option(flag::use_specifiers) &&
!get_option(flag::accept_all)) {
if (localized) {
if (get_option(specifier::letters)) {
get_option(specifier::letters) = false;
get_option(specifier::alpha) = true;
}
if (get_option(specifier::alnum_underscore)) {
get_option(specifier::alnum_underscore) = false;
get_option(specifier::alnum) = true;
get_option('_') = true;
}
if (get_option(specifier::whitespace)) {
get_option(specifier::whitespace) = false;
get_option(specifier::space) = true;
}
if (get_option(specifier::numbers)) {
get_option(specifier::numbers) = false;
get_option(specifier::digit) = true;
}
}
else {
auto do_range = [&](char a, char b) {
for (; a < b; ++a) {
get_option(a) = true;
}
get_option(b) = true;
};
auto do_lower = [&]() {
// a-z
do_range(0x61, 0x7a);
};
auto do_upper = [&]() {
// A-Z
do_range(0x41, 0x5a);
};
auto do_digit = [&]() {
// 0-9
do_range(0x30, 0x39);
};
if (get_option(specifier::alnum)) {
do_lower();
do_upper();
do_digit();
get_option(specifier::alnum) = false;
}
if (get_option(specifier::alpha)) {
do_lower();
do_upper();
get_option(specifier::alpha) = false;
}
if (get_option(specifier::blank)) {
get_option(' ') = true;
get_option('\t') = true;
get_option(specifier::blank) = false;
}
if (get_option(specifier::cntrl)) {
do_range(0, 0x1f);
get_option(0x7f) = true;
get_option(specifier::cntrl) = false;
}
if (get_option(specifier::digit)) {
do_digit();
get_option(specifier::digit) = false;
}
if (get_option(specifier::graph)) {
do_range(0x21, 0x7e);
get_option(specifier::graph) = false;
}
if (get_option(specifier::lower)) {
do_lower();
get_option(specifier::lower) = false;
}
if (get_option(specifier::print)) {
do_range(0x20, 0x7e);
get_option(specifier::print) = false;
}
if (get_option(specifier::punct)) {
do_range(0x21, 0x2f);
do_range(0x3a, 0x40);
do_range(0x5b, 0x60);
do_range(0x7b, 0x7e);
get_option(specifier::punct) = false;
}
if (get_option(specifier::space)) {
do_range(0x9, 0xd);
get_option(' ') = true;
get_option(specifier::space) = false;
}
if (get_option(specifier::upper)) {
do_upper();
get_option(specifier::upper) = false;
}
if (get_option(specifier::xdigit)) {
do_digit();
do_range(0x41, 0x46);
do_range(0x61, 0x66);
get_option(specifier::xdigit) = false;
}
if (get_option(specifier::letters)) {
do_upper();
do_lower();
get_option(specifier::letters) = false;
}
if (get_option(specifier::inverted_letters)) {
do_range(0x0, 0x2f);
do_range(0x3a, 0x40);
do_range(0x5b, 0x60);
do_range(0x7b, 0x7f);
get_option(specifier::inverted_letters) = false;
}
if (get_option(specifier::alnum_underscore)) {
do_digit();
do_upper();
do_lower();
get_option('_') = true;
get_option(specifier::alnum_underscore) = false;
}
if (get_option(specifier::inverted_alnum_underscore)) {
bool underscore = get_option('_');
do_range(0x0, 0x2f);
do_range(0x3a, 0x40);
do_range(0x5b, 0x60);
do_range(0x7b, 0x7f);
get_option('_') = underscore; // reset back
get_option(specifier::inverted_alnum_underscore) =
false;
}
if (get_option(specifier::whitespace)) {
do_range(0x9, 0xd);
get_option(' ') = true;
get_option(specifier::whitespace) = false;
}
if (get_option(specifier::inverted_whitespace)) {
do_range(0, 0x8);
do_range(0xe, 0x1f);
do_range(0x21, 0x7f);
get_option(specifier::inverted_whitespace) = false;
}
if (get_option(specifier::numbers)) {
do_digit();
get_option(specifier::numbers) = false;
}
if (get_option(specifier::inverted_numbers)) {
do_range(0, 0x2f);
do_range(0x3a, 0x7f);
get_option(specifier::inverted_numbers) = false;
}
{
bool first = get_option(0);
char i = 1;
for (; i < 0x7f; ++i) {
if (first != get_option(i)) {
break;
}
}
if (i == 0x7f && first == get_option(0x7f)) {
get_option(flag::accept_all) = true;
if (!first) {
get_option(flag::inverted) = true;
}
}
}
get_option(flag::use_specifiers) = false;
get_option(flag::use_chars) = true;
}
}
return {};
}
// true = char accepted
template <typename CharT, typename Locale>
bool check_character(CharT ch, bool localized, const Locale& loc)
{
SCN_EXPECT(get_option(flag::enabled));
const bool not_inverted = !get_option(flag::inverted);
if (get_option(flag::accept_all)) {
return not_inverted;
}
if (get_option(flag::use_specifiers)) {
SCN_EXPECT(localized); // ensured by sanitize()
SCN_UNUSED(localized);
SCN_CLANG_PUSH_IGNORE_UNDEFINED_TEMPLATE
if (get_option(specifier::alnum) &&
loc.get_localized().is_alnum(ch)) {
return not_inverted;
}
if (get_option(specifier::alpha) &&
loc.get_localized().is_alpha(ch)) {
return not_inverted;
}
if (get_option(specifier::blank) &&
loc.get_localized().is_blank(ch)) {
return not_inverted;
}
if (get_option(specifier::cntrl) &&
loc.get_localized().is_cntrl(ch)) {
return not_inverted;
}
if (get_option(specifier::digit) &&
loc.get_localized().is_digit(ch)) {
return not_inverted;
}
if (get_option(specifier::graph) &&
loc.get_localized().is_graph(ch)) {
return not_inverted;
}
if (get_option(specifier::lower) &&
loc.get_localized().is_lower(ch)) {
return not_inverted;
}
if (get_option(specifier::print) &&
loc.get_localized().is_print(ch)) {
return not_inverted;
}
if (get_option(specifier::punct) &&
loc.get_localized().is_punct(ch)) {
return not_inverted;
}
if (get_option(specifier::space) &&
loc.get_localized().is_space(ch)) {
return not_inverted;
}
if (get_option(specifier::upper) &&
loc.get_localized().is_upper(ch)) {
return not_inverted;
}
if (get_option(specifier::xdigit) &&
loc.get_localized().is_xdigit(ch)) {
return not_inverted;
}
SCN_CLANG_POP_IGNORE_UNDEFINED_TEMPLATE
}
if (get_option(flag::use_chars) && (ch >= 0 && ch <= 0x7f)) {
if (get_option(static_cast<char>(ch))) {
return not_inverted;
}
}
if (get_option(flag::use_ranges)) {
const auto c = static_cast<uint32_t>(ch);
for (const auto& e : set_extra_ranges) {
if (c >= e.begin && c <= e.end) {
return not_inverted;
}
}
}
return !not_inverted;
}
enum class specifier : size_t {
alnum = 0x80,
alpha,
blank,
cntrl,
digit,
graph,
lower,
print,
punct,
space,
upper,
xdigit,
letters = 0x90, // \l
inverted_letters, // \L
alnum_underscore, // \w
inverted_alnum_underscore, // \W
whitespace, // \s
inverted_whitespace, // \S
numbers, // \d
inverted_numbers, // \D
last = 0x9f
};
enum class flag : size_t {
enabled = 0xa0, // using [set]
accept_all, // empty [set]
inverted, // ^ flag
// 0x00 - 0x7f
use_chars,
// 0x80 - 0x8f
use_specifiers,
// set_extra_ranges
use_ranges,
last = 0xaf
};
bool& get_option(char ch)
{
SCN_GCC_PUSH
SCN_GCC_IGNORE("-Wtype-limits")
SCN_EXPECT(ch >= 0 && ch <= 0x7f);
SCN_GCC_POP
return set_options[static_cast<size_t>(ch)];
}
SCN_NODISCARD bool get_option(char ch) const
{
SCN_GCC_PUSH
SCN_GCC_IGNORE("-Wtype-limits")
SCN_EXPECT(ch >= 0 && ch <= 0x7f);
SCN_GCC_POP
return set_options[static_cast<size_t>(ch)];
}
bool& get_option(specifier s)
{
return set_options[static_cast<size_t>(s)];
}
SCN_NODISCARD bool get_option(specifier s) const
{
return set_options[static_cast<size_t>(s)];
}
bool& get_option(flag f)
{
return set_options[static_cast<size_t>(f)];
}
SCN_NODISCARD bool get_option(flag f) const
{
return set_options[static_cast<size_t>(f)];
}
SCN_NODISCARD bool enabled() const
{
return get_option(flag::enabled);
}
private:
void accept_char(char ch)
{
get_option(ch) = true;
get_option(flag::use_chars) = true;
}
void accept_char(code_point cp)
{
if (cp >= 0 && cp <= 0x7f) {
return accept_char(static_cast<char>(cp));
}
set_extra_ranges.push_back(set_range::single(cp));
get_option(flag::use_ranges) = true;
}
void accept_char(wchar_t ch)
{
SCN_GCC_COMPAT_PUSH
SCN_GCC_COMPAT_IGNORE("-Wtype-limits")
if (ch >= 0 && ch <= 0x7f) {
return accept_char(static_cast<char>(ch));
}
SCN_GCC_COMPAT_POP
set_extra_ranges.push_back(set_range::single(ch));
get_option(flag::use_ranges) = true;
}
void accept_char_range(char first, char last)
{
SCN_EXPECT(first >= 0);
SCN_EXPECT(last >= 0);
SCN_EXPECT(first <= last);
get_option(flag::use_chars) = true;
for (; first != last; ++first) {
get_option(first) = true;
}
SCN_ENSURE(first == last);
get_option(last) = true;
}
void accept_char_range(code_point first, code_point last)
{
SCN_EXPECT(first <= last);
if (first >= 0 && last <= 0x7f) {
return accept_char_range(static_cast<char>(first),
static_cast<char>(last));
}
set_extra_ranges.push_back(set_range::range(first, last));
get_option(flag::use_ranges) = true;
}
void accept_char_range(wchar_t first, wchar_t last)
{
SCN_EXPECT(first <= last);
SCN_GCC_COMPAT_PUSH
SCN_GCC_COMPAT_IGNORE("-Wtype-limits")
if (first >= 0 && last <= 0x7f) {
return accept_char_range(static_cast<char>(first),
static_cast<char>(last));
}
SCN_GCC_COMPAT_POP
set_extra_ranges.push_back(set_range::range(first, last));
get_option(flag::use_ranges) = true;
}
template <typename ParseCtx>
error parse_range(ParseCtx& pctx, code_point begin)
{
using char_type = typename ParseCtx::char_type;
SCN_EXPECT(pctx.next_char() == ascii_widen<char_type>('-'));
if (pctx.can_peek_char() &&
pctx.peek_char() == ascii_widen<char_type>(']')) {
// Just a '-'
accept_char(begin);
accept_char(ascii_widen<char_type>('-'));
return {};
}
pctx.advance_char();
if (!pctx || pctx.check_arg_end()) {
return {error::invalid_format_string,
"Unexpected end of format string argument"};
}
return parse_next_char(pctx, false, begin);
}
template <typename ParseCtx>
error parse_literal(ParseCtx& pctx,
bool allow_range,
code_point begin = make_code_point(0))
{
using char_type = typename ParseCtx::char_type;
if (allow_range) {
auto e = pctx.peek_cp();
if (!e && e.error().code() != error::end_of_range) {
return e.error();
}
if (e && e.value() == ascii_widen<char_type>('-')) {
const auto cp = pctx.next_cp();
if (!cp) {
return cp.error();
}
auto err = pctx.advance_cp();
if (!err) {
return err;
}
return parse_range(pctx, cp.value());
}
}
const auto cp = pctx.next_cp();
if (!cp) {
return cp.error();
}
if (cp.value() >= 0 && cp.value() <= 0x7f) {
if (!allow_range) {
if (static_cast<
typename std::make_unsigned<char_type>::type>(
cp.value()) <
static_cast<
typename std::make_unsigned<char_type>::type>(
begin)) {
return {error::invalid_format_string,
"Last char in [set] range is less than the "
"first"};
}
accept_char_range(begin, cp.value());
}
else {
accept_char(cp.value());
}
}
else {
if (!allow_range) {
if (static_cast<
typename std::make_unsigned<char_type>::type>(
cp.value()) <
static_cast<
typename std::make_unsigned<char_type>::type>(
begin)) {
return {error::invalid_format_string,
"Last char in [set] range is less than the "
"first"};
}
set_extra_ranges.push_back(
set_range::range(begin, cp.value()));
}
else {
set_extra_ranges.push_back(
set_range::single(cp.value()));
}
get_option(flag::use_ranges) = true;
}
return {};
}
template <typename ParseCtx>
error parse_colon_specifier(ParseCtx& pctx)
{
using char_type = typename ParseCtx::char_type;
SCN_EXPECT(pctx.next_char() == ascii_widen<char_type>(':'));
pctx.advance_char();
if (!pctx || pctx.check_arg_end()) {
return {error::invalid_format_string,
"Unexpected end of format string argument"};
}
if (pctx.next_char() == ascii_widen<char_type>(']')) {
return {
error::invalid_format_string,
"Unexpected end of [set] in format string after ':'"};
}
std::basic_string<char_type> buf;
while (true) {
if (!pctx || pctx.check_arg_end()) {
return {error::invalid_format_string,
"Unexpected end of format string argument"};
}
auto ch = pctx.next_char();
if (ch == ascii_widen<char_type>(':')) {
break;
}
if (ch == ascii_widen<char_type>(']')) {
return {error::invalid_format_string,
"Unexpected end of [set] :specifier:, did you "
"forget a terminating colon?"};
}
buf.push_back(ch);
pctx.advance_char();
}
auto ch = pctx.next_char();
if (buf == all_str(ch)) {
get_option(flag::accept_all) = true;
return {};
}
if (buf == alnum_str(ch)) {
get_option(specifier::alnum) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == alpha_str(ch)) {
get_option(specifier::alpha) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == blank_str(ch)) {
get_option(specifier::blank) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == cntrl_str(ch)) {
get_option(specifier::cntrl) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == digit_str(ch)) {
get_option(specifier::digit) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == graph_str(ch)) {
get_option(specifier::graph) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == lower_str(ch)) {
get_option(specifier::lower) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == print_str(ch)) {
get_option(specifier::print) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == punct_str(ch)) {
get_option(specifier::punct) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == space_str(ch)) {
get_option(specifier::space) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == upper_str(ch)) {
get_option(specifier::upper) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (buf == xdigit_str(ch)) {
get_option(specifier::xdigit) = true;
get_option(flag::use_specifiers) = true;
return {};
}
return {error::invalid_format_string,
"Invalid :specifier: in [set]"};
}
template <typename ParseCtx>
error parse_backslash_hex(ParseCtx& pctx,
bool allow_range,
code_point begin = make_code_point(0))
{
using char_type = typename ParseCtx::char_type;
SCN_EXPECT(pctx.next_char() == ascii_widen<char_type>('x') ||
pctx.next_char() == ascii_widen<char_type>('u') ||
pctx.next_char() == ascii_widen<char_type>('U'));
const char_type flag_char = pctx.next_char();
const int chars = [flag_char]() {
auto ch = static_cast<char>(flag_char);
if (ch == 'x') {
return 2;
}
if (ch == 'u') {
return 4;
}
if (ch == 'U') {
return 8;
}
SCN_ENSURE(false);
SCN_UNREACHABLE;
}();
char_type str[8] = {0};
for (int i = 0; i < chars; ++i) {
pctx.advance_char();
if (!pctx || pctx.check_arg_end()) {
return {error::invalid_format_string,
"Unexpected end of format string argument "
"after '\\x', '\\u', or '\\U'"};
}
if (pctx.next_char() == ascii_widen<char_type>(']')) {
return {error::invalid_format_string,
"Unexpected end of [set] in format string "
"after '\\x', '\\u', or '\\U'"};
}
str[i] = pctx.next_char();
}
auto scanner = simple_integer_scanner<uint64_t>{};
uint64_t i;
SCN_CLANG_PUSH_IGNORE_UNDEFINED_TEMPLATE
auto res = scanner.scan(
scn::make_span(str, static_cast<size_t>(chars)).as_const(),
i, 16);
SCN_CLANG_POP_IGNORE_UNDEFINED_TEMPLATE
if (!res) {
return {error::invalid_format_string,
"Failed to parse '\\x', '\\u', or '\\U' flag in "
"format string"};
}
const uint64_t min = 0;
const uint64_t max = [chars]() {
if (chars == 2) {
// \x
return uint64_t{0x7f};
}
if (chars == 4) {
return uint64_t{0xffff};
}
if (chars == 8) {
return uint64_t{0xffffffff};
}
SCN_ENSURE(false);
SCN_UNREACHABLE;
}();
if (i < min || i > max) {
return {error::invalid_format_string,
"'\\x', '\\u', or '\\U' option in format string "
"out of range"};
}
if (allow_range && pctx.can_peek_char() &&
pctx.peek_char() == ascii_widen<char_type>('-')) {
pctx.advance_char();
return parse_range(pctx, make_code_point(i));
}
if (!allow_range) {
accept_char_range(begin, make_code_point(i));
}
else {
accept_char(make_code_point(i));
}
return {};
}
template <typename ParseCtx>
error parse_backslash_specifier(
ParseCtx& pctx,
bool allow_range,
code_point begin = make_code_point(0))
{
using char_type = typename ParseCtx::char_type;
SCN_EXPECT(pctx.next_char() == ascii_widen<char_type>('\\'));
pctx.advance_char();
if (!pctx || pctx.check_arg_end()) {
return {error::invalid_format_string,
"Unexpected end of format string argument"};
}
if (pctx.next_char() == ascii_widen<char_type>(']') &&
pctx.can_peek_char() &&
pctx.peek_char() == ascii_widen<char_type>('}')) {
return {error::invalid_format_string,
"Unexpected end of [set] in format string"};
}
if (pctx.next_char() == ascii_widen<char_type>('\\')) {
// Literal "\\"
accept_char(pctx.next_char());
return {};
}
// specifiers
if (pctx.next_char() == ascii_widen<char_type>('l')) {
// \l
get_option(specifier::letters) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (pctx.next_char() == ascii_widen<char_type>('L')) {
// \L
get_option(specifier::inverted_letters) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (pctx.next_char() == ascii_widen<char_type>('w')) {
// \w
get_option(specifier::alnum_underscore) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (pctx.next_char() == ascii_widen<char_type>('W')) {
// \W
get_option(specifier::inverted_alnum_underscore) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (pctx.next_char() == ascii_widen<char_type>('s')) {
// \s
get_option(specifier::whitespace) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (pctx.next_char() == ascii_widen<char_type>('S')) {
// \S
get_option(specifier::inverted_whitespace) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (pctx.next_char() == ascii_widen<char_type>('d')) {
// \d
get_option(specifier::numbers) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (pctx.next_char() == ascii_widen<char_type>('D')) {
// \D
get_option(specifier::inverted_numbers) = true;
get_option(flag::use_specifiers) = true;
return {};
}
if (pctx.next_char() == ascii_widen<char_type>('x') ||
pctx.next_char() == ascii_widen<char_type>('u') ||
pctx.next_char() == ascii_widen<char_type>('U')) {
// \x__, \u____, or \U________
return parse_backslash_hex(pctx, allow_range, begin);
}
// Literal, e.g. \: -> :
return parse_literal(pctx, true);
}
template <typename ParseCtx>
error parse_next_char(ParseCtx& pctx,
bool allow_range,
code_point begin = make_code_point(0))
{
using char_type = typename ParseCtx::char_type;
const auto ch = pctx.next_char();
if (ch == ascii_widen<char_type>('\\')) {
return parse_backslash_specifier(pctx, allow_range, begin);
}
if (allow_range && ch == ascii_widen<char_type>(':')) {
return parse_colon_specifier(pctx);
}
return parse_literal(pctx, allow_range, begin);
}
SCN_NODISCARD static constexpr const char* all_str(char)
{
return "all";
}
SCN_NODISCARD static constexpr const wchar_t* all_str(wchar_t)
{
return L"all";
}
SCN_NODISCARD static constexpr const char* alnum_str(char)
{
return "alnum";
}
SCN_NODISCARD static constexpr const wchar_t* alnum_str(wchar_t)
{
return L"alnum";
}
SCN_NODISCARD static constexpr const char* alpha_str(char)
{
return "alpha";
}
SCN_NODISCARD static constexpr const wchar_t* alpha_str(wchar_t)
{
return L"alpha";
}
SCN_NODISCARD static constexpr const char* blank_str(char)
{
return "blank";
}
SCN_NODISCARD static constexpr const wchar_t* blank_str(wchar_t)
{
return L"blank";
}
SCN_NODISCARD static constexpr const char* cntrl_str(char)
{
return "cntrl";
}
SCN_NODISCARD static constexpr const wchar_t* cntrl_str(wchar_t)
{
return L"cntrl";
}
SCN_NODISCARD static constexpr const char* digit_str(char)
{
return "digit";
}
SCN_NODISCARD static constexpr const wchar_t* digit_str(wchar_t)
{
return L"digit";
}
SCN_NODISCARD static constexpr const char* graph_str(char)
{
return "graph";
}
SCN_NODISCARD static constexpr const wchar_t* graph_str(wchar_t)
{
return L"graph";
}
SCN_NODISCARD static constexpr const char* lower_str(char)
{
return "lower";
}
SCN_NODISCARD static constexpr const wchar_t* lower_str(wchar_t)
{
return L"lower";
}
SCN_NODISCARD static constexpr const char* print_str(char)
{
return "print";
}
SCN_NODISCARD static constexpr const wchar_t* print_str(wchar_t)
{
return L"print";
}
SCN_NODISCARD static constexpr const char* punct_str(char)
{
return "punct";
}
SCN_NODISCARD static constexpr const wchar_t* punct_str(wchar_t)
{
return L"punct";
}
SCN_NODISCARD static constexpr const char* space_str(char)
{
return "space";
}
SCN_NODISCARD static constexpr const wchar_t* space_str(wchar_t)
{
return L"space";
}
SCN_NODISCARD static constexpr const char* upper_str(char)
{
return "upper";
}
SCN_NODISCARD static constexpr const wchar_t* upper_str(wchar_t)
{
return L"upper";
}
SCN_NODISCARD static constexpr const char* xdigit_str(char)
{
return "xdigit";
}
SCN_NODISCARD static constexpr const wchar_t* xdigit_str(wchar_t)
{
return L"xdigit";
}
// 0x00 - 0x7f, individual chars, true = accept
// 0x80 - 0x9f, specifiers, true = accept (if use_specifiers = true)
// 0xa0 - 0xaf, flags
array<bool, 0xb0> set_options{{false}};
struct set_range {
constexpr set_range(uint32_t b, uint32_t e) : begin(b), end(e)
{
}
uint32_t begin{};
uint32_t end{}; // inclusive
static set_range single(code_point cp)
{
return {static_cast<uint32_t>(cp),
static_cast<uint32_t>(cp)};
}
static set_range single(wchar_t ch)
{
return {static_cast<uint32_t>(ch),
static_cast<uint32_t>(ch)};
}
static set_range range(code_point begin, code_point end)
{
SCN_EXPECT(begin <= end);
return {static_cast<uint32_t>(begin),
static_cast<uint32_t>(end)};
}
static set_range range(wchar_t begin, wchar_t end)
{
SCN_EXPECT(begin <= end);
return {static_cast<uint32_t>(begin),
static_cast<uint32_t>(end)};
}
};
// Used if set_options[use_ranges] = true
small_vector<set_range, 1> set_extra_ranges{};
};
struct string_scanner : common_parser {
static constexpr bool skip_preceding_whitespace()
{
return false;
}
template <typename ParseCtx>
error parse(ParseCtx& pctx)
{
using char_type = typename ParseCtx::char_type;
auto s_flag = detail::ascii_widen<char_type>('s');
bool s_set{};
auto each = [&](ParseCtx& p, bool& parsed) -> error {
if (p.next_char() == ascii_widen<char_type>('[')) {
if (set_parser.get_option(
set_parser_type::flag::enabled)) {
return {error::invalid_format_string,
"[set] already specified for this argument "
"in format string"};
}
return set_parser.parse_set(p, parsed);
}
return {};
};
auto e = parse_common(pctx, span<const char_type>{&s_flag, 1},
span<bool>{&s_set, 1}, each);
if (!e) {
return e;
}
if (set_parser.enabled()) {
bool loc = (common_options & localized) != 0;
return set_parser.sanitize(loc);
}
return {};
}
template <typename Context, typename Allocator>
error scan(
std::basic_string<typename Context::char_type,
std::char_traits<typename Context::char_type>,
Allocator>& val,
Context& ctx)
{
if (set_parser.enabled()) {
bool loc = (common_options & localized) != 0;
bool mb = (loc || set_parser.get_option(
set_parser_type::flag::use_ranges)) &&
is_multichar_type(typename Context::char_type{});
return do_scan(ctx, val,
pred<Context>{ctx, set_parser, loc, mb});
}
auto e = skip_range_whitespace(ctx, false);
if (!e) {
return e;
}
auto is_space_pred = make_is_space_predicate(
ctx.locale(), (common_options & localized) != 0,
field_width);
return do_scan(ctx, val, is_space_pred);
}
set_parser_type set_parser;
protected:
template <typename Context, typename Allocator, typename Pred>
error do_scan(
Context& ctx,
std::basic_string<typename Context::char_type,
std::char_traits<typename Context::char_type>,
Allocator>& val,
Pred&& predicate)
{
using string_type = std::basic_string<
typename Context::char_type,
std::char_traits<typename Context::char_type>, Allocator>;
if (Context::range_type::is_contiguous) {
auto s = read_until_space_zero_copy(
ctx.range(), SCN_FWD(predicate), false);
if (!s) {
return s.error();
}
if (s.value().size() == 0) {
return {error::invalid_scanned_value,
"Empty string parsed"};
}
val.assign(s.value().data(), s.value().size());
return {};
}
string_type tmp(val.get_allocator());
auto outputit = std::back_inserter(tmp);
auto ret = read_until_space(ctx.range(), outputit,
SCN_FWD(predicate), false);
if (SCN_UNLIKELY(!ret)) {
return ret;
}
if (SCN_UNLIKELY(tmp.empty())) {
return {error::invalid_scanned_value,
"Empty string parsed"};
}
val = SCN_MOVE(tmp);
return {};
}
template <typename Context>
struct pred {
Context& ctx;
set_parser_type& set_parser;
bool localized;
bool multibyte;
bool operator()(span<const char> ch) const
{
SCN_EXPECT(ch.size() >= 1);
code_point cp{};
auto it = parse_code_point(ch.begin(), ch.end(), cp);
if (!it) {
// todo: is this really a good idea
return !set_parser.check_character(ch[0], localized,
ctx.locale());
}
return !set_parser.check_character(cp, localized,
ctx.locale());
}
bool operator()(span<const wchar_t> ch) const
{
SCN_EXPECT(ch.size() == 1);
return !set_parser.check_character(ch[0], localized,
ctx.locale());
}
constexpr bool is_localized() const
{
return localized;
}
constexpr bool is_multibyte() const
{
return multibyte;
}
};
};
struct span_scanner : public string_scanner {
template <typename Context>
error scan(span<typename Context::char_type>& val, Context& ctx)
{
if (val.size() == 0) {
return {error::invalid_scanned_value,
"Cannot scan into an empty span"};
}
if (set_parser.enabled()) {
bool loc = (common_options & localized) != 0;
bool mb = (loc || set_parser.get_option(
set_parser_type::flag::use_ranges)) &&
is_multichar_type(typename Context::char_type{});
return do_scan(ctx, val,
string_scanner::pred<Context>{
ctx, set_parser, loc, mb});
}
auto e = skip_range_whitespace(ctx, false);
if (!e) {
return e;
}
auto is_space_pred = make_is_space_predicate(
ctx.locale(), (common_options & localized) != 0,
field_width != 0 ? min(field_width, val.size())
: val.size());
return do_scan(ctx, val, is_space_pred);
}
protected:
template <typename Context, typename Pred>
error do_scan(Context& ctx,
span<typename Context::char_type>& val,
Pred&& predicate)
{
if (Context::range_type::is_contiguous) {
auto s = read_until_space_zero_copy(
ctx.range(), SCN_FWD(predicate), false);
if (!s) {
return s.error();
}
if (s.value().size() == 0) {
return {error::invalid_scanned_value,
"Empty string parsed"};
}
std::copy(s.value().begin(), s.value().end(), val.begin());
val = val.first(s.value().size());
return {};
}
std::basic_string<typename Context::char_type> tmp;
auto outputit = std::back_inserter(tmp);
auto ret = read_until_space(ctx.range(), outputit,
SCN_FWD(predicate), false);
if (SCN_UNLIKELY(!ret)) {
return ret;
}
if (SCN_UNLIKELY(tmp.empty())) {
return {error::invalid_scanned_value,
"Empty string parsed"};
}
std::copy(tmp.begin(), tmp.end(), val.begin());
val = val.first(tmp.size());
return {};
}
};
struct string_view_scanner : string_scanner {
public:
template <typename Context>
error scan(basic_string_view<typename Context::char_type>& val,
Context& ctx)
{
if (!Context::range_type::is_contiguous) {
return {error::invalid_operation,
"Cannot read a string_view from a "
"non-contiguous_range"};
}
if (set_parser.enabled()) {
bool loc = (common_options & localized) != 0;
bool mb = (loc || set_parser.get_option(
set_parser_type::flag::use_ranges)) &&
is_multichar_type(typename Context::char_type{});
return do_scan(ctx, val,
string_scanner::pred<Context>{
ctx, set_parser, loc, mb});
}
auto e = skip_range_whitespace(ctx, false);
if (!e) {
return e;
}
auto is_space_pred = make_is_space_predicate(
ctx.locale(), (common_options & localized) != 0,
field_width);
return do_scan(ctx, val, is_space_pred);
}
protected:
template <typename Context, typename Pred>
error do_scan(Context& ctx,
basic_string_view<typename Context::char_type>& val,
Pred&& predicate)
{
SCN_EXPECT(Context::range_type::is_contiguous);
auto s = read_until_space_zero_copy(ctx.range(),
SCN_FWD(predicate), false);
if (!s) {
return s.error();
}
if (s.value().size() == 0) {
return {error::invalid_scanned_value,
"Empty string parsed"};
}
val = basic_string_view<typename Context::char_type>(
s.value().data(), s.value().size());
return {};
}
};
#if SCN_HAS_STRING_VIEW
struct std_string_view_scanner : string_view_scanner {
template <typename Context>
error scan(std::basic_string_view<typename Context::char_type>& val,
Context& ctx)
{
using char_type = typename Context::char_type;
auto sv =
::scn::basic_string_view<char_type>(val.data(), val.size());
auto e = string_view_scanner::scan(sv, ctx);
if (e) {
val =
std::basic_string_view<char_type>(sv.data(), sv.size());
}
return e;
}
};
#endif
} // namespace detail
SCN_END_NAMESPACE
} // namespace scn
#endif
| 40.856395 | 80 | 0.40443 |
b20f3b424ec3d7da4a50ab6173e7bde0b06673ab | 351 | h | C | sbl/src/sbl.h | mikaelsundin/sbl_saml21 | 4f97eaace801560c01376e3dfdb90e7357b2299a | [
"BSD-3-Clause"
] | null | null | null | sbl/src/sbl.h | mikaelsundin/sbl_saml21 | 4f97eaace801560c01376e3dfdb90e7357b2299a | [
"BSD-3-Clause"
] | null | null | null | sbl/src/sbl.h | mikaelsundin/sbl_saml21 | 4f97eaace801560c01376e3dfdb90e7357b2299a | [
"BSD-3-Clause"
] | null | null | null | /*
* sbl.h
*
* Created: 2018-05-07 21:20:54
* Author: leaf
*/
#ifndef _SBL_H_
#define _SBL_H_
#include <stdint.h>
#define SBL_ADR_INVALID (UINT32_MAX)
uint16_t sbl_hal_rx(uint8_t data[], uint32_t len);
void sbl_hal_tx(uint8_t data[], uint16_t len);
void sbl_hal_init(void);
void sbl_init(void);
void sbl_task(void);
#endif /* SBL_H_ */ | 14.04 | 50 | 0.698006 |
c3b9c833521f84afa5eea3c28dbc967e97e5e58d | 4,671 | c | C | software/servers/9dof_razor_imu/init.c | cgzog/cyborg_sensing | 70ef7f2e3045c9ed99a47a69b0826e2e2b22ec0e | [
"MIT"
] | 1 | 2018-12-03T23:20:30.000Z | 2018-12-03T23:20:30.000Z | software/servers/9dof_razor_imu/init.c | cgzog/cyborg_vision | 70ef7f2e3045c9ed99a47a69b0826e2e2b22ec0e | [
"MIT"
] | 18 | 2018-11-25T04:11:09.000Z | 2019-01-03T22:35:46.000Z | software/servers/9dof_razor_imu/init.c | cgzog/cyborg_vision | 70ef7f2e3045c9ed99a47a69b0826e2e2b22ec0e | [
"MIT"
] | null | null | null | // 9dof init.c
//
// server for 9 degrees of freedom sensor
//
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/time.h>
#include "cv.h"
#include "cv_net.h"
#include "cyborg_lib.h"
#include "sensors.h"
#include "9dof/externs.h"
static void usage(), dumpConfig();
/// \brief process command line and perform other initializations
///
/// -h Host IP:port of database
///
/// -S Host IP: of status server
///
/// -s serial port@speed to read from
///
/// -I Sensor ID
///
/// -i Sensort SubID
///
/// -d Debug output file
///
/// -D Debug level
///
/// -l Log output file
///
/// Also opens UDP socket for sending messages to database and status server
void
init(int argc, char **argv)
{
int c, ttl;
HostInfo.hostIPString = DEF_HOST_IP_STRING;
HostInfo.hostPort = DEF_HOST_PORT_DB_POST;
StatusServer.hostIPString = DEF_HOST_IP_STRING;
StatusServer.hostPort = DEF_HOST_PORT_STATUS;
while ((c = getopt(argc, argv, "h:S:s:D:d:l:I:i:")) != -1) {
switch (c) {
case 'h':
setHostAndPort(optarg, &HostInfo);
break;
case 'S':
setHostAndPort(optarg, &StatusServer);
break;
case 'I':
SensorId = optarg;
break;
case 'i':
SensorSubId = optarg;
break;
case 's':
SerialPort = optarg;
break;
case 'D':
DebugLevel = atoi(optarg);
switch (DebugLevel) {
case DEBUG_OFF:
case DEBUG_INFO:
case DEBUG_DETAIL:
case DEBUG_SUPER:
break; // all valid values
default:
fprintf(stderr, "%s: error: invalid debug value (%d)\n",
MyName, DebugLevel);
usage();
exit(1);
break;
}
break;
case 'd':
if ((DebugFP = fopen(optarg, "w")) == (FILE *)NULL) {
fprintf(stderr, "%s: error: cannot open debug file \"%s\"\n", MyName, optarg);
exit(1);
}
setbuf(DebugFP, (char *)NULL); // no buffering
break;
case 'l':
if ((LogFP = fopen(optarg, "w")) == (FILE *)NULL) {
fprintf(stderr, "%s: error: cannot open log file \"%s\"\n", MyName, optarg);
exit(1);
}
setbuf(LogFP, (char *)NULL); // no buffering
break;
case '?':
usage();
exit(1);
break;
default:
fprintf(stderr, "?? getopt returned character code 0x%x ??\n", c);
}
}
if (SerialPort == NULL) {
fprintf(stderr, "%s: error: serial port (-s) must be specified\n",
MyName);
exit(1);
}
if (strlen(SensorId) == 0) {
fprintf(stderr, "%s: error: SensorID (-I) must be specified\n",
MyName);
exit(1);
}
openOutgoingPort(&HostInfo);
SerialFd = openSerialPort(SerialPort);
if (DebugLevel) { // any debug level
dumpConfig();
}
}
/// Dump command line settings
static void
dumpConfig()
{
fprintf(DebugFP, "DumpConfig():\n");
fprintf(DebugFP, "Network:\n\tDatabase @:\t\t%s:%d\n\tSock fd:\t%d\n",
HostInfo.hostIPString, HostInfo.hostPort,
HostInfo.sock);
fprintf(DebugFP, "\t\tStatus Server @:\t%s:%d\n\tSock fd:\t%d\n",
StatusServer.hostIPString, StatusServer.hostPort,
StatusServer.sock);
fprintf(DebugFP, "Serial:\t\"%s\"\n", SerialPort);
fprintf(DebugFP, "\nDebug:\t%d ", DebugLevel);
switch (DebugLevel) {
case DEBUG_OFF:
fprintf(DebugFP, "(OFF)\n");
break;
case DEBUG_INFO:
fprintf(DebugFP, "(INFO)\n");
break;
case DEBUG_DETAIL:
fprintf(DebugFP, "(DETAIL)\n");
break;
case DEBUG_SUPER:
fprintf(DebugFP, "(DETAIL)\n");
break;
}
fprintf(DebugFP, "--------------------------------------\n\n");
}
/// \brief Usage message
///
/// Shown is any invalid parameters specvified or '-?' on command line
static void
usage()
{
fprintf(stderr,
"%s: usage: %s [-h IP:port] [-S IP:Port] [-I ID] [-i SubID] [-s 9dof comm port@speed] [-d debug file] [-D 0|1|2|3] [ -l log file ]\n",
MyName, MyName);
}
| 22.242857 | 146 | 0.516164 |
c93d4fd7d2c2bd68bfd66390776f51f2044f0def | 1,936 | h | C | servlib/reg/RegistrationInitialLoadThread.h | lauramazzuca21/DTNME | c97b598b09a8c8e97c2e4136879d9f0e157c8df7 | [
"Apache-2.0"
] | 7 | 2021-02-11T16:54:24.000Z | 2021-08-20T06:15:30.000Z | servlib/reg/RegistrationInitialLoadThread.h | lauramazzuca21/DTNME | c97b598b09a8c8e97c2e4136879d9f0e157c8df7 | [
"Apache-2.0"
] | 3 | 2020-09-18T13:48:53.000Z | 2021-05-27T18:28:14.000Z | servlib/reg/RegistrationInitialLoadThread.h | lauramazzuca21/DTNME | c97b598b09a8c8e97c2e4136879d9f0e157c8df7 | [
"Apache-2.0"
] | 10 | 2020-09-26T05:08:40.000Z | 2022-01-25T12:57:55.000Z | /*
* Copyright 2015 United States Government as represented by NASA
* Marshall Space Flight Center. All Rights Reserved.
*
* Released under the NASA Open Source Software Agreement version 1.3;
* You may obtain a copy of the Agreement at:
*
* http://ti.arc.nasa.gov/opensource/nosa/
*
* The subject software is provided "AS IS" WITHOUT ANY WARRANTY of any kind,
* either expressed, implied or statutory and this agreement does not,
* in any manner, constitute an endorsement by government agency of any
* results, designs or products resulting from use of the subject software.
* See the Agreement for the specific language governing permissions and
* limitations.
*/
#ifndef _REGISTRATION_INITIAL_LOAD_H_
#define _REGISTRATION_INITIAL_LOAD_H_
#include "bundling/BundleDaemon.h"
#include <oasys/thread/Thread.h>
namespace dtn {
class Registration;
/**
* Class/thread that runs through the pending bundles and delivers the
* appriate ones to a newly added Registration. This thread offloads
* the work to a background so that the main BundleDaemon processing
* can continue.
*/
class RegistrationInitialLoadThread : public oasys::Thread
{
public:
/**
* Constructor.
*/
RegistrationInitialLoadThread(Registration* registration);
/**
* Destructor (called at shutdown time).
*/
virtual ~RegistrationInitialLoadThread();
protected:
/**
* Main thread function that dispatches events.
*/
virtual void run();
#ifdef PENDING_BUNDLES_IS_MAP
/**
* Find bundles to deliver to this registration (map)
*/
virtual void scan_pending_bundles_map();
#else
/**
* Find bundles to deliver to this registration (list)
*/
virtual void scan_pending_bundles_list();
#endif
/// The Registration being loaded
Registration* reg_;
};
} // namespace dtn
#endif // _REGISTRATION_INITIAL_LOAD_H_
| 26.520548 | 80 | 0.709711 |
45034ae6f734bb023ddeebddc153e19a031ecfa9 | 5,197 | h | C | include/em_assert.h | liwentao2005/osp | dd27d246d68d7952fe63e13894d4d3b06efe6086 | [
"MIT"
] | null | null | null | include/em_assert.h | liwentao2005/osp | dd27d246d68d7952fe63e13894d4d3b06efe6086 | [
"MIT"
] | null | null | null | include/em_assert.h | liwentao2005/osp | dd27d246d68d7952fe63e13894d4d3b06efe6086 | [
"MIT"
] | null | null | null | #ifndef EM_ASSERT_H
# define EM_ASSERT_H
/*===========================================================================*/
/**
* @file em_assert.h
*
* API for Error Management (EM) Assertions
*
* %full_filespec:em_assert.h~1:incl:ctc_ec#59 %
* @version %version:1 %
* @author %derived_by:bz08fr %
* @date %date_modified:Fri Mar 25 12:21:55 2016 %
*
*------------------------------------------------------------------------------
*
* Copyright 2009 Delphi Technologies, Inc., All Rights Reserved.
* Delphi Confidential
*
*------------------------------------------------------------------------------
*
* @section DESC DESCRIPTION:
*
* Defines customizable and memory-efficient assertions applicable to
* embedded systems. This header file can be used in C, C++, and mixed C/C++
* programs.
*
* THIS VERSION HAS ALL TRACE SUPPORT REMOVED
*
* @section ABBR ABBREVIATIONS:
* - EM = Error Management
* - PbC = Programming by Contract
*
* @section TRACE TRACEABILITY INFO:
* - Design Document(s):
* - SDD_BASA_Error_Management.doc (version 0.8)
*
* - Requirements Document(s):
* BASA_SRS_Error_Management_1.2.doc
*
* - Applicable Standards (in order of precedence: highest first):
* - <a href="http://kogespw1.delcoelect.com:8508/passthru/consumer?name=SW%20REF%20264.15D&doctype=K8DBSDoc">
* SW REF 264.15D "Delphi C Coding Standards" [12-Mar-2006]</a>
*
* @section DFS DEVIATIONS FROM STANDARDS:
* - None
*
* @addtogroup pbc Error Management Assertions
* @{
*/
/*==========================================================================*/
/*===========================================================================*
* Header Files
*===========================================================================*/
# include "reuse.h"
/*===========================================================================*
* Exported Preprocessor #define Constants
*===========================================================================*/
/*===========================================================================*
* Exported Preprocessor #define MACROS
*===========================================================================*/
/*===========================================================================*
* Exported Type Declarations
*===========================================================================*/
/*===========================================================================*
* Header Files
*===========================================================================*/
/*===========================================================================*
* Exported Const Object Declarations
*===========================================================================*/
# ifdef __cplusplus
extern "C"
{
# endif /*__cplusplus*/
/*===========================================================================*
* Exported Function Prototypes
*===========================================================================*/
/**
* Performs the actual invocation of the configured EM assert. Unlike the
* EM_Assert_Handler() call, this call does not log any information that
* can be used to identify the source of the assert. For this reason, it
* should only be used in rare situations that require it, such as an assert
* that occurs during the logging of another assert (or an assert fired
* after other specific action was taken to log the cause).
*/
void EM_Perform_Assert(void);
/*===========================================================================*
* Exported Inline Function Definitions and #define Function-Like Macros
*===========================================================================*/
/**
* Compile-time assertion produces a compiler error if invalid; produces no
* code if valid. For use at function scope. from http://www.panelsoft.com/murphyslaw/apr01.htm
*/
# define EM_ASSERT_COMPILE(ex) do {\
typedef uint8_t COMPILE_TIME_ASSERTION_FAILURE[(ex) ? 1 : -1];\
} while(0)
/**
* Compile-time assertion produces a compiler error if invalid; produces no
* code if valid. For use at file scope. From http://www.panelsoft.com/murphyslaw/apr01.htm
*/
# define EM_FS_ASSERT_COMPILE(ex) extern uint8_t COMPILE_TIME_ASSERTION_FAILURE[(ex) ? 1 : -1]
# ifdef __cplusplus
} /* close off extern "C" specification */
# endif /*__cplusplus*/
/*===========================================================================*
* Exported Type Declarations
*===========================================================================*/
/*===========================================================================*/
/*!
* @file em_assert.h
*
* @section RH REVISION HISTORY (top to bottom: last revision to first revision)
*
* - 22-Dec-2008 Dan Carman
* - Task kok_aud 56926: Removed deprecated EM_Disable/Restore assert calls.
*
* - 22-Dec-2008 Dan Carman
* Gutted EM API to remove duplication with PBC / Trace interface
*/
/*===========================================================================*/
/** @} doxygen end group */
#endif /* EM_ASSERT_H */
| 37.934307 | 114 | 0.438715 |
0f8d242551e46e699e30d454b31c7236440ddb46 | 983 | h | C | CEG4166RTS_TestLib/include/testLib.h | Faeriol/SEG4545 | 2852ff6ee8cddf27dd3ae74102244044bc082494 | [
"MIT"
] | null | null | null | CEG4166RTS_TestLib/include/testLib.h | Faeriol/SEG4545 | 2852ff6ee8cddf27dd3ae74102244044bc082494 | [
"MIT"
] | null | null | null | CEG4166RTS_TestLib/include/testLib.h | Faeriol/SEG4545 | 2852ff6ee8cddf27dd3ae74102244044bc082494 | [
"MIT"
] | null | null | null | /****************************************************************************//*!
\file usartSerial.h
Module: USART Async Serial
Description: Provides asynchronous serial communication via any of the four USARTS available in the
AtMega 2560.
Both interrupt driven and polling functions are available.
Uses freeRTOS ring buffers to support interrupt functions.
**********************************************************************************/
/****************************************************************************//*!
* \addtogroup testLibModule
* @{
******************************************************************************/
/*-----------------------------------------------------------*/
//Entry Points - documented in c file
/*-----------------------------------------------------------*/
void runUSARTTestsWithoutInterrupts(void);
void runUSARTTestsWithInterrupts(void);
/*!@}*/ // End of testLibModule Group
| 40.958333 | 105 | 0.386572 |
80a2c3c2ab4d398533208579411a94822984dae5 | 10,337 | h | C | mindspore/ccsrc/minddata/dataset/api/python/de_pipeline.h | huxian123/mindspore | ec5ba10c82bbd6eccafe32d3a1149add90105bc8 | [
"Apache-2.0"
] | 1 | 2021-04-23T06:35:18.000Z | 2021-04-23T06:35:18.000Z | mindspore/ccsrc/minddata/dataset/api/python/de_pipeline.h | nudt-eddie/mindspore | 55372b41fdfae6d2b88d7078971e06d537f6c558 | [
"Apache-2.0"
] | null | null | null | mindspore/ccsrc/minddata/dataset/api/python/de_pipeline.h | nudt-eddie/mindspore | 55372b41fdfae6d2b88d7078971e06d537f6c558 | [
"Apache-2.0"
] | null | null | null | /**
* Copyright 2019 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_API_DE_PIPELINE_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_API_DE_PIPELINE_H_
#include <iostream>
#include <map>
#include <memory>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include "minddata/dataset/core/client.h" // DE client
#include "minddata/dataset/engine/dataset_iterator.h"
#include "minddata/dataset/util/status.h"
#include "pybind11/numpy.h"
#include "pybind11/pybind11.h"
#include "pybind11/stl.h"
namespace py = pybind11;
namespace mindspore {
namespace dataset {
using json = nlohmann::json;
using DsOpPtr = std::shared_ptr<DatasetOp>;
class CacheClient;
// enum for the dataset operator names
enum OpName {
kShuffle,
kMindrecord,
kBatch,
kBucketBatch,
kBarrier,
kCache,
kRepeat,
kSkip,
kTake,
kZip,
kConcat,
kMap,
kFilter,
kDeviceQueue,
kGenerator,
kRename,
kTfReader,
kProject,
kImageFolder,
kMnist,
kManifest,
kVoc,
kCoco,
kCifar10,
kCifar100,
kCelebA,
kRandomData,
kTextFile,
kBuildVocab,
kClue,
kEpochCtrl,
kSentencePieceVocab,
kCsv
};
// The C++ binder class that we expose to the python script.
class DEPipeline {
public:
DEPipeline();
~DEPipeline();
// Function to add a Node to the Execution Tree.
Status AddNodeToTree(const OpName &op_name, const py::dict &args, py::dict *output);
// Function to add a child and parent relationship.
static Status AddChildToParentNode(const DsOpPtr &child_op, const DsOpPtr &parent_op);
// Function to assign the node as root.
Status AssignRootNode(const DsOpPtr &dataset_op);
// Function to get the column names in the last node in the tree in order
Status GetColumnNames(py::list *output);
// Function to prepare the tree for execution
Status PrepareTree(const int32_t num_epochs);
// Function to launch the tree execution.
Status LaunchTreeExec();
// Get a row of data as dictionary of column name to the value.
Status GetNextAsMap(py::dict *output);
// Get a row of data as list.
Status GetNextAsList(py::list *output);
Status GetOutputShapes(py::list *output);
Status GetOutputTypes(py::list *output);
Status SaveDataset(const std::vector<std::string> &file_names, const std::string &file_type);
int GetDatasetSize() const;
int GetBatchSize() const;
int GetRepeatCount() const;
Status ParseShuffleOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseMindRecordOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
template <typename T, typename S>
Status TransfromTensor(const unsigned char *src, const TensorShape &shape, const int64_t num_of_elements,
std::unique_ptr<T> *data, std::unique_ptr<std::vector<uint8_t>> *data_ptr,
std::unique_ptr<S> *s, bool need_convert = false);
Status FetchMetaFromTensorRow(const std::unordered_map<std::string, int32_t> &column_name_id_map,
const TensorRow &row, json *schema, std::vector<std::string> *index_fields);
Status FetchDataFromTensorRow(const TensorRow &row,
const std::unordered_map<std::string, int32_t> &column_name_id_map, json *row_raw_data,
std::map<std::string, std::unique_ptr<std::vector<uint8_t>>> *row_bin_data);
Status BuildMindrecordSamplerChain(const py::handle &handle,
std::vector<std::shared_ptr<mindrecord::ShardOperator>> *operators,
int num_padded);
Status ParseMapOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseFilterOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseRepeatOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseSkipOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseBatchOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseBucketBatchByLengthOp(const py::dict &args, std::shared_ptr<DatasetOp> *top,
std::shared_ptr<DatasetOp> *bottom);
Status ParseEpochCtrlOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseBatchOp(const py::dict &args, std::shared_ptr<DatasetOp> *ptr);
Status ParseBarrierOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseGeneratorOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseRenameOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseTakeOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseZipOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseConcatOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseDeviceQueueOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseTFReaderOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseProjectOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseImageFolderOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseManifestOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseVOCOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseCocoOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseCifar10Op(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseCifar100Op(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseRandomDataOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
void PrintTree();
int32_t GetNumClasses() const;
Status ParseMnistOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status SetBatchParameters(const py::dict &args);
Status ParseCelebAOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseTextFileOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseBuildVocabOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status StopSend();
Status ParseBuildSentencePieceVocabOp(const py::dict &args, std::shared_ptr<DatasetOp> *top,
std::shared_ptr<DatasetOp> *bottom);
Status ParseClueOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
Status ParseCsvOp(const py::dict &args, std::shared_ptr<DatasetOp> *top, std::shared_ptr<DatasetOp> *bottom);
private:
// Execution tree that links the dataset operators.
std::shared_ptr<ExecutionTree> tree_;
std::unique_ptr<DatasetIterator> iterator_;
static Status ParsePadInfo(py::handle value, PadInfo *pad_info);
/// \brief Helper function to inject a cache operator over top of the current operation being built.
/// \param[in] cache_client The client to use for caching
/// \param[in] num_workers The number of workers to use in the cache op
/// \param[in] input_op The operator to build the cache on top of
/// \param[out] cache_op The top node of the created subtree (subtree contains two nodes). In this case it will be
/// the cache operator
/// \return Status return code
Status AddCacheOp(std::shared_ptr<CacheClient> cache_client, int num_workers, std::shared_ptr<DatasetOp> input_op,
std::shared_ptr<DatasetOp> *cache_op);
/// \brief Helper function to inject a shuffle operator over top of the current operation being built.
/// \param[in] shuffle_size The size to use in the shuffle buffer
/// \param[in] input_op The operator to build shuffle on top of
/// \param[out] shuffle_op The top node of the created subtree (subtree contains two nodes). In this case it will be
/// the shuffle operator
/// \return Status return code
Status AddShuffleOp(int64_t shuffle_size, std::shared_ptr<DatasetOp> input_op,
std::shared_ptr<DatasetOp> *shuffle_op);
/// \brief Helper function to compute the shuffle size
/// \param[in] num_files The number of files in the dataset
/// \param[in] num_devices The number of devices in the dataset
/// \param[in] num_rows The number of rows in the dataset
/// \param[in] total_rows An upper bound on the total rows in the dataset
/// \param[out] shuffle_size The resultant computed shuffle size
/// \return Status return code
Status ComputeShuffleSize(int64_t num_files, int64_t num_devices, int64_t num_rows, int64_t total_rows,
int64_t *shuffle_size);
int batch_size_;
int repeat_num_;
int num_rows_;
int num_classes_;
int temp_batch_size_;
bool temp_drop_remainder_;
};
} // namespace dataset
} // namespace mindspore
#endif // MINDSPORE_CCSRC_MINDDATA_DATASET_API_DE_PIPELINE_H_
| 39.605364 | 119 | 0.722163 |
b3f314ef6801a142dda3ca3cceea5660bf659690 | 703 | c | C | dino/attack/c source/000108ae.c | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | a4a0c86c200241494b3f1834cd0aef8dc02f7683 | [
"Apache-2.0"
] | 6 | 2020-10-14T15:29:10.000Z | 2022-02-12T18:58:54.000Z | dino/attack/c source/000108ae.c | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | a4a0c86c200241494b3f1834cd0aef8dc02f7683 | [
"Apache-2.0"
] | null | null | null | dino/attack/c source/000108ae.c | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | a4a0c86c200241494b3f1834cd0aef8dc02f7683 | [
"Apache-2.0"
] | 1 | 2020-12-17T08:59:10.000Z | 2020-12-17T08:59:10.000Z | void UndefinedFunction_000108ae(void)
{
int unaff_A2;
int unaff_A3;
bool in_CF;
FUN_000128f8();
if (in_CF) {
*(undefined2 *)(unaff_A2 + 0x70) = (short)unaff_A3;
*(undefined *)(unaff_A2 + 0x73) = *(undefined *)(unaff_A3 + 0x72);
*(undefined4 *)(unaff_A2 + 0x4) = 0x2040000;
*(undefined *)(unaff_A2 + 0x2e) = 0xc;
*(undefined *)(unaff_A2 + 0x115) = 0x0;
*(undefined2 *)(unaff_A3 + 0x70) = (short)unaff_A2;
*(undefined4 *)(unaff_A3 + 0x4) = 0x2060000;
*(undefined *)(unaff_A3 + 0x2e) = 0xe;
*(undefined *)(unaff_A3 + 0x2) = *(undefined *)(unaff_A2 + 0x2);
*(undefined2 *)(unaff_A3 + 0x6e) = *(undefined2 *)(unaff_A3 + 0x6c);
return;
}
return;
} | 30.565217 | 72 | 0.604552 |
fe9c6bfb9c9a49687cc1c1753ed6017d49828951 | 2,912 | c | C | std_string.c | majingru/c-http | c5acdd289eabbe7e25ba085882d4e7a9b7688d5d | [
"Apache-2.0"
] | null | null | null | std_string.c | majingru/c-http | c5acdd289eabbe7e25ba085882d4e7a9b7688d5d | [
"Apache-2.0"
] | null | null | null | std_string.c | majingru/c-http | c5acdd289eabbe7e25ba085882d4e7a9b7688d5d | [
"Apache-2.0"
] | null | null | null | #include "std_string.h"
#include <string.h>
#include <stdarg.h>
String std_string_malloc(int initial_size)
{
String string;
string.buf = (char*)std_malloc(initial_size * sizeof(char));
if (string.buf == NULL)
{
string.size = 0;
}
else
{
string.size = initial_size;
}
string.used = 0;
return string;
}
void std_string_free(String str)
{
std_free(str.buf);
str.size = 0;
str.buf = NULL;
str.used = 0;
}
bool std_string_equals(const String src, const String dst)
{
return (src.size == dst.size && src.used == dst.used && !memcmp(src.buf, dst.buf, src.size));
}
static bool buffer_grow(String *str, int minimum_size)
{
int factor = str->size;
if (factor < minimum_size)
{
factor = minimum_size;
}
int new_size = factor * 2;
char *tmp = (char*)std_realloc(str->buf, new_size);
if (tmp)
{
str->buf = tmp;
str->size = new_size;
return true;
}
else
{
return false;
}
}
void std_string_append(String *dst, String *src)
{
if (dst->used + src->used > dst->size)
{
bool status = buffer_grow(dst, dst->used + src->used + 1);
if (!status)
{
perror("memory malloc failed.\n");
exit(1);
}
}
int pos = dst->used;
for (int i = 0; i < src->used; i++)
{
dst->buf[i + pos] = src->buf[i];
}
dst->used += src->used;
}
void std_string_appends(String *dst, const char *str, int size)
{
if ((dst->size - dst->used) < size)
{
bool status = buffer_grow(dst, size);
if (!status)
{
perror("memory malloc failed.\n");
exit(1);
}
}
int position = dst->used;
for (int i = 0; i < size; i++)
{
dst->buf[i + position] = str[i];
}
dst->used += size;
}
void std_string_appendf(String *dst, char *format, ...)
{
char tmp[BUFSIZ];
int n;
va_list ap;
va_start(ap, format);
n = vsnprintf(tmp, BUFSIZ, format, ap);
va_end(ap);
std_string_appends(dst, tmp, n);
}
int std_string_index(String *dst, const char * sub)
{
int sub_len = strlen(sub);
if(sub_len == 0)
{
return 0;
}
int dst_len = dst->used;
for(int i = 0; i < dst_len; i++)
{
if(!memcmp(dst->buf + i, sub, sub_len))
{
return i;
}
}
return 0;
}
char * std_string_sub(String *dst, int start, int end)
{
if(dst == NULL || end < start || end > dst->used)
{
return NULL;
}
int size = end - start;
char * tmp = (char*)std_malloc(end - start + 1);
strncpy(tmp, dst->buf + start, size);
tmp[size] = '\0';
return tmp;
}
char *std_string_to_s(String str)
{
char *tmp = (char*)std_malloc(str.used + 1);
strncpy(tmp, str.buf, str.used);
tmp[str.used] = '\0';
return tmp;
}
| 19.675676 | 97 | 0.533654 |
24a337acea3b36d9bcfc422f1201d32794cc56b1 | 1,299 | h | C | teave/tty/tty.h | teave-team/teave | 0effbf60ad5a3bc5f6f79def01bcb6ab04853979 | [
"MIT",
"BSL-1.0",
"Unlicense"
] | null | null | null | teave/tty/tty.h | teave-team/teave | 0effbf60ad5a3bc5f6f79def01bcb6ab04853979 | [
"MIT",
"BSL-1.0",
"Unlicense"
] | null | null | null | teave/tty/tty.h | teave-team/teave | 0effbf60ad5a3bc5f6f79def01bcb6ab04853979 | [
"MIT",
"BSL-1.0",
"Unlicense"
] | null | null | null | /*
* Copyright 2021 Pedram Tiv
*
* Licensed under the Teave Public License (the "License");
* You may obtain a copy of the License at https://www.teave.io/teave-public-license.html
*
* This software is distributed under the License on an "AS IS" BASIS, WITHOUT WARRANTIES
* OF ANY KIND, either express or implied. See the License for the specific language governing
* terms and conditions for use, reproduction, and distribution.
*/
#ifndef TEAVE_TTY_H
#define TEAVE_TTY_H
#include <teave/err/err.h>
#include <teave/sv/sva.h>
#include <teave/tty/vt_fncs.h>
namespace Teave {
class Tty {
public:
using uptr = std::unique_ptr<Tty>;
Tty(Err *const err, Sva *const sva, string vt_path = "/dev/tty0");
~Tty();
int get_run_vt_num();
int get_fd();
long get_org_vt_kd_kb_mode();
unsigned int get_org_vt_kd_mode();
struct vt_mode get_org_vt_mode();
protected:
/*
* save org settings to be able to revert back at cleanup
*/
void load_org_vt_settings();
Err *const err = nullptr;
Sva *const sva = nullptr;
int fd = -1;
int vt_num = -1; /* virtual terminal we run in */
long org_vt_kd_kb_mode = -1;
unsigned int org_vt_kd_mode = KD_TEXT;
struct vt_mode org_vt_mode;
};
} // namespace Teave
#endif /* TEAVE_TTY_H */
| 26.510204 | 95 | 0.686682 |
2bb91591a601f21caaf8c6aed0ab32eed375e02e | 2,433 | h | C | source/renderer/passResources/ShaderManager.h | DaSutt/VolumetricParticles | 6ec9bac4bec4a8757343bb770b23110ef2364dfd | [
"Apache-2.0"
] | 6 | 2017-06-26T11:42:26.000Z | 2018-09-10T17:53:53.000Z | source/renderer/passResources/ShaderManager.h | DaSutt/VolumetricParticles | 6ec9bac4bec4a8757343bb770b23110ef2364dfd | [
"Apache-2.0"
] | 8 | 2017-06-24T20:25:42.000Z | 2017-08-09T10:50:40.000Z | source/renderer/passResources/ShaderManager.h | DaSutt/VolumetricParticles | 6ec9bac4bec4a8757343bb770b23110ef2364dfd | [
"Apache-2.0"
] | null | null | null | /*
MIT License
Copyright(c) 2017 Daniel Suttor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <vector>
#include <array>
#include <map>
#include <vulkan\vulkan.h>
#include "file_includer.h"
#include "..\passes\Passes.h"
namespace Renderer
{
class ShaderManager
{
public:
enum Type
{
TYPE_VERT,
TYPE_FRAG,
TYPE_COMP,
TYPE_GEOM
};
ShaderManager();
//Reload all shaders, the new shaders are only used if all shaders were compiled correctly
bool ReLoad(VkDevice device);
void Release(VkDevice device);
const std::vector<VkPipelineShaderStageCreateInfo>& GetShaderStageInfo(Renderer::SubPassType pass) const;
private:
struct ShaderInfo
{
std::string fileName;
std::string functionName;
Type type;
SubPassType pass;
std::vector<int> defines;
};
enum DefineBits
{
DEFINE_TEST,
DEFINE_MAX
};
shaderc::SpvCompilationResult CompileShader(int shaderIndex);
void AddDefines(shaderc::CompileOptions& compileOptions, int shaderIndex);
shaderc::Compiler compiler_;
shaderc_util::FileFinder fileFinder_;
std::vector<VkShaderModule> shaders_;
std::vector<std::vector<VkPipelineShaderStageCreateInfo>> createInfo_;
//TODO replace this with general option for shader path
std::string shaderSourceFolder_ = "..\\source\\shaders\\";
std::vector<ShaderInfo> shaderInfos_;
std::array<std::string, DEFINE_MAX> defineInfos_;
};
} | 29.670732 | 109 | 0.755446 |
44f4d435438fa28830a42fb5b255844048a667d4 | 3,761 | h | C | extensions/sudoku/sudoku.h | svtrostov/xgserver | 25cbb038502bb6245f162f2a11274643aedee89f | [
"MIT"
] | 2 | 2018-01-26T11:04:31.000Z | 2018-01-26T11:04:42.000Z | extensions/sudoku/sudoku.h | svtrostov/xgserver | 25cbb038502bb6245f162f2a11274643aedee89f | [
"MIT"
] | null | null | null | extensions/sudoku/sudoku.h | svtrostov/xgserver | 25cbb038502bb6245f162f2a11274643aedee89f | [
"MIT"
] | null | null | null | /***********************************************************************
* XG SERVER
* core/darray.h
* Динамический массив
*
* Copyright (с) 2014-2015 Stanislav V. Tretyakov, svtrostov@yandex.ru
**********************************************************************/
#ifndef _XGEXTSUDOKU_H
#define _XGEXTSUDOKU_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************************
* Подключаемые заголовки
**********************************************************************/
#include <limits.h>
#include "core.h"
#define SUDOKU_MAP "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define SUDOKU_MAX_LINE 36
#define SUDOKU_MAX_SIDE 6
/***********************************************************************
* Константы
**********************************************************************/
/***********************************************************************
* Объявления и декларации
**********************************************************************/
//Типы SUDOKU
typedef enum{
SPUZZLE_9X9 = 0, //Классический пазл 9х9 (123456789 в 1 слой)
SPUZZLE_9X93D = 1, //3D пазл 9х9х9 (123456789 в 9 слоев)
SPUZZLE_16X16 = 2, //Пазл 16х16 (0123456789ABCDEF в 1 слой)
SPUZZLE_25X25 = 3, //Пазл 25х25 (0123456789ABCDEFGHIJKLMNO в 1 слой)
SPUZZLE_36X36 = 4 //Расширенный пазл 36х36 (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ в 1 слой)
} puzzle_t;
/***********************************************************************
* Структуры
**********************************************************************/
typedef struct type_sudoku_s sudoku_s; //Структура Sudoku
typedef struct type_bsector_s bsector_s;
typedef struct type_bcell_s bcell_s;
//Ячейка доски
typedef struct type_bcell_s{
uint8_t x; //X координата ячейки на доске
uint8_t y; //Y координата ячейки на доске
uint8_t sector; //ID сектора, в котором находится ячейка
uint8_t sx; //X координата ячейки в секторе
uint8_t sy; //Y координата ячейки в секторе
u_char value; //Заданное значение
u_char mask; //Первоначальное значение для этой ячейки
} bcell_s;
typedef struct type_bmask_s{
uint8_t x; //X координата ячейки в секторе
uint8_t y; //Y координата ячейки в секторе
}bmask_s;
//Структура символа игровой доски
typedef struct type_bsymbol_s{
bcell_s *sets[_SUDOKUMAPSIZE]; //Массив измененных ячеек доски (только указатели)
uint8_t count; //Количество измененных ячеек
u_char ch; //Символ
}bchar_s;
//Структура сектора доски
typedef struct type_bsector_s{
bcell_s cells[SUDOKU_MAX_SIDE][SUDOKU_MAX_SIDE]; //Ячейки блока
uint8_t bx; //X координата начала сектора
uint8_t ex; //X координата окончания сектора
uint8_t by; //Y координата начала сектора
uint8_t ey; //Y координата окончания сектора
} bsector_s;
//Структура судоку
typedef struct type_sudoku_s{
puzzle_t type; //Тип пазла судоку
u_char **board; //Итоговая доска пазла
uint32_t layers; //Количество слоев доски
uint32_t side; //Количество ячеек в блоке и количество блоков на доске
uint32_t line; //Количество ячеек в строке / столбце (side * side)
uint32_t seed; //Начальное значение для генератора случайных чисел
} sudoku_s;
/***********************************************************************
* Функции
**********************************************************************/
sudoku_s * sudokuCreate(puzzle_t type, uint32_t seed); //Создание структуры sudoku_s
void sudokuFree(sudoku_s * sudoku); //Освобождение памяти, занятой sudoku
void sudokuPrintBoard(sudoku_s * sudoku); //
void sudokuFillLayer(sudoku_s * sudoku, uint32_t z); //Заполнение полей
#ifdef __cplusplus
}
#endif
#endif //_XGEXTSUDOKU_H
| 28.492424 | 95 | 0.567136 |
4ddb2c32ff486d307e4756dc0507f3428046d41e | 12,116 | c | C | src/main/eamio/eam-impl.c | Soyandroid/bemanitools | 0fd499266f4d724b8eea7217a6fd4e6a0caba948 | [
"Unlicense"
] | 5 | 2021-12-20T02:57:07.000Z | 2022-02-28T20:19:26.000Z | src/main/eamio/eam-impl.c | Soyandroid/bemanitools | 0fd499266f4d724b8eea7217a6fd4e6a0caba948 | [
"Unlicense"
] | null | null | null | src/main/eamio/eam-impl.c | Soyandroid/bemanitools | 0fd499266f4d724b8eea7217a6fd4e6a0caba948 | [
"Unlicense"
] | 1 | 2021-12-21T18:49:01.000Z | 2021-12-21T18:49:01.000Z | #include <windows.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bemanitools/eamio.h"
#include "eamio/eam-impl.h"
#include "geninput/hid-mgr.h"
#include "util/defs.h"
#include "util/fs.h"
#include "util/hex.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
#define EAM_SENSOR_COOLDOWN 1000
struct eam_unit {
char *card_path;
struct hid_stub *hid;
size_t keypad_ctls[EAM_IO_KEYPAD_COUNT];
size_t sensor_ctl;
bool bound_ctls;
uint8_t drive_no;
uint32_t sensor_time;
bool sensor_hot;
};
struct eam {
/* This lock protects drive_no and sensor_time, which get read/written
respectively by eam_impl_notify_hotplug, which gets called by the Win32
message pump thread. */
CRITICAL_SECTION lock;
struct eam_unit units[EAM_UNIT_COUNT];
bool autogen;
bool alt_10k;
bool mux;
};
static const uint32_t eam_keypad_usages[EAM_IO_KEYPAD_COUNT + 1] = {
/* [EAM_KEYPAD_0] = */ 0x00070062,
/* [EAM_KEYPAD_1] = */ 0x00070059,
/* [EAM_KEYPAD_4] = */ 0x0007005C,
/* [EAM_KEYPAD_7] = */ 0x0007005F,
/* [EAM_KEYPAD_00] = */ 0x00070058, /* Keypad ENTER */
/* [EAM_KEYPAD_2] = */ 0x0007005A,
/* [EAM_KEYPAD_5] = */ 0x0007005D,
/* [EAM_KEYPAD_8] = */ 0x00070060,
/* [EAM_KEYPAD_DECIMAL] = */ 0x00070063,
/* [EAM_KEYPAD_3] = */ 0x0007005B,
/* [EAM_KEYPAD_6] = */ 0x0007005E,
/* [EAM_KEYPAD_9] = */ 0x00070061,
/* Sensor = */ 0x00070057};
static const uint32_t eam_keypad_usages_alt[EAM_IO_KEYPAD_COUNT + 1] = {
/* [EAM_KEYPAD_0] = */ 0x00070027,
/* [EAM_KEYPAD_1] = */ 0x0007001E,
/* [EAM_KEYPAD_4] = */ 0x00070021,
/* [EAM_KEYPAD_7] = */ 0x00070024,
/* [EAM_KEYPAD_00] = */ 0x0007002D, /* - and _ */
/* [EAM_KEYPAD_2] = */ 0x0007001F,
/* [EAM_KEYPAD_5] = */ 0x00070022,
/* [EAM_KEYPAD_8] = */ 0x00070025,
/* [EAM_KEYPAD_DECIMAL] = */ 0x0007002E, /* + and = */
/* [EAM_KEYPAD_3] = */ 0x00070020,
/* [EAM_KEYPAD_6] = */ 0x00070023,
/* [EAM_KEYPAD_9] = */ 0x00070026,
/* Sensor = */ 0x0007002A /* Backspace */
};
static uint8_t eam_impl_get_active_unit(void);
static void eam_impl_bind_keypad(struct eam *eam, uint8_t unit_no);
static bool eam_impl_autogen(struct eam_unit *unit, uint8_t *card_id);
struct eam *eam_impl_create(void)
{
struct eam *eam;
struct eam_unit *unit;
size_t btn_no;
uint8_t unit_no;
eam = xmalloc(sizeof(*eam));
InitializeCriticalSection(&eam->lock);
for (unit_no = 0; unit_no < lengthof(eam->units); unit_no++) {
unit = &eam->units[unit_no];
unit->card_path = NULL;
unit->hid = NULL;
for (btn_no = 0; btn_no < lengthof(unit->keypad_ctls); btn_no++) {
unit->keypad_ctls[btn_no] = (size_t) -1;
}
unit->sensor_ctl = (size_t) -1;
unit->bound_ctls = false;
unit->drive_no = (uint8_t) -1;
unit->sensor_time = 0;
}
eam->autogen = false;
eam->alt_10k = false;
eam->mux = false;
return eam;
}
static uint8_t eam_impl_get_active_unit(void)
{
return GetKeyState(VK_NUMLOCK) & 0x0001;
}
bool eam_impl_get_autogen(struct eam *eam)
{
return eam->autogen;
}
void eam_impl_set_autogen(struct eam *eam, bool autogen)
{
eam->autogen = autogen != false;
}
bool eam_impl_get_alt_10k(struct eam *eam)
{
return eam->alt_10k;
}
void eam_impl_set_alt_10k(struct eam *eam, bool alt_10k)
{
int i;
for (i = 0; i < lengthof(eam->units); i++) {
eam->units[i].bound_ctls = false;
}
eam->alt_10k = alt_10k != false;
}
struct hid_stub *eam_impl_get_keypad_device(struct eam *eam, uint8_t unit_no)
{
log_assert(unit_no < lengthof(eam->units));
return eam->units[unit_no].hid;
}
void eam_impl_set_keypad_device(
struct eam *eam, uint8_t unit_no, struct hid_stub *hid)
{
log_assert(unit_no < lengthof(eam->units));
eam->units[unit_no].hid = hid;
eam->units[unit_no].bound_ctls = false;
eam->mux = hid != NULL && eam->units[0].hid == eam->units[1].hid;
}
const char *eam_impl_get_card_path(struct eam *eam, uint8_t unit_no)
{
log_assert(unit_no < lengthof(eam->units));
return eam->units[unit_no].card_path;
}
void eam_impl_set_card_path(struct eam *eam, uint8_t unit_no, const char *path)
{
log_assert(unit_no < lengthof(eam->units));
EnterCriticalSection(&eam->lock);
free(eam->units[unit_no].card_path);
if (path != NULL) {
eam->units[unit_no].card_path = str_dup(path);
if (isalpha(path[0]) && path[1] == ':') {
eam->units[unit_no].drive_no = toupper(path[0]) - 'A';
} else {
eam->units[unit_no].drive_no = (uint8_t) -1;
}
} else {
eam->units[unit_no].card_path = NULL;
eam->units[unit_no].drive_no = (uint8_t) -1;
}
LeaveCriticalSection(&eam->lock);
}
uint16_t eam_impl_get_keypad_state(struct eam *eam, uint8_t unit_no)
{
struct eam_unit *unit;
uint16_t result;
int32_t value;
size_t i;
log_assert(unit_no < lengthof(eam->units));
if (eam->mux && eam_impl_get_active_unit() != unit_no) {
return 0;
}
eam_impl_bind_keypad(eam, unit_no);
unit = &eam->units[unit_no];
result = 0;
if (unit->bound_ctls) {
for (i = 0; i < lengthof(unit->keypad_ctls); i++) {
if (unit->keypad_ctls[i] == (size_t) -1) {
continue;
}
if (!hid_stub_get_value(unit->hid, unit->keypad_ctls[i], &value)) {
continue;
}
if (value) {
result |= 1 << i;
}
}
}
return result;
}
static void eam_impl_bind_keypad(struct eam *eam, uint8_t unit_no)
{
const uint32_t *usages;
struct hid_control *controls;
struct eam_unit *unit;
size_t ncontrols;
size_t control_no;
size_t btn_no;
unit = &eam->units[unit_no];
if (unit->bound_ctls || unit->hid == NULL ||
!hid_stub_is_attached(unit->hid)) {
return;
}
if (eam->alt_10k) {
usages = eam_keypad_usages_alt;
} else {
usages = eam_keypad_usages;
}
/* Set flag first: don't try again if this fails for whatever reason. */
unit->bound_ctls = true;
hid_mgr_lock();
if (!hid_stub_get_controls(unit->hid, NULL, &ncontrols)) {
goto size_fail;
}
controls = xmalloc(ncontrols * sizeof(*controls));
if (!hid_stub_get_controls(unit->hid, controls, &ncontrols)) {
goto content_fail;
}
for (control_no = 0; control_no < ncontrols; control_no++) {
for (btn_no = 0; btn_no < EAM_IO_KEYPAD_COUNT; btn_no++) {
if (controls[control_no].usage == usages[btn_no]) {
unit->keypad_ctls[btn_no] = control_no;
}
}
if (controls[control_no].usage == usages[EAM_IO_KEYPAD_COUNT]) {
unit->sensor_ctl = control_no;
}
}
free(controls);
hid_mgr_unlock();
return;
content_fail:
free(controls);
size_fail:
hid_mgr_unlock();
}
bool eam_impl_get_sensor_state(struct eam *eam, uint8_t unit_no)
{
struct eam_unit *unit;
uint32_t now;
int32_t value;
bool result;
log_assert(unit_no < lengthof(eam->units));
unit = &eam->units[unit_no];
result = false;
eam_impl_bind_keypad(eam, unit_no);
if (!unit->bound_ctls) {
return false;
}
if (unit->sensor_ctl == (size_t) -1) {
return false;
}
if (!hid_stub_get_value(unit->hid, unit->sensor_ctl, &value)) {
return false;
}
now = GetTickCount();
EnterCriticalSection(&eam->lock);
/* Bump cooldown as long as sensor button is held
(cooldown timer might also be set by a USB hotplug event) */
if (value != 0 && (!eam->mux || eam_impl_get_active_unit() == unit_no)) {
unit->sensor_time = now + EAM_SENSOR_COOLDOWN;
unit->sensor_hot = true;
}
if (unit->sensor_hot) {
if ((int32_t)(unit->sensor_time - now) > 0) {
result = true;
} else {
unit->sensor_time = 0;
unit->sensor_hot = false;
result = false;
}
}
LeaveCriticalSection(&eam->lock);
return result;
}
uint8_t eam_impl_read_card(
struct eam *eam, uint8_t unit_no, uint8_t *card_id, uint8_t nbytes)
{
char line[128];
struct eam_unit *unit;
size_t len;
FILE *f;
log_assert(unit_no < lengthof(eam->units));
log_assert(card_id != NULL);
log_assert(nbytes == EAM_CARD_NBYTES);
unit = &eam->units[unit_no];
if (unit->card_path == NULL) {
goto path_fail;
}
f = fopen(unit->card_path, "r");
if (f == NULL) {
if (eam->autogen) {
if (!eam_impl_autogen(unit, card_id)) {
log_warning(
"Unit %d: Failed to generate card ID into %s",
unit_no,
unit->card_path);
goto fopen_fail;
}
return true;
} else {
log_warning(
"Unit %d: Card file at %s not present",
unit_no,
unit->card_path);
goto fopen_fail;
}
}
if (fgets(line, sizeof(line), f) == NULL) {
log_warning("%s: fgets() failed", unit->card_path);
goto fgets_fail;
}
str_trim(line);
len = strlen(line);
if (len != 2 * EAM_CARD_NBYTES) {
log_warning(
"%s: Expected %u chars (got %u)",
unit->card_path,
2 * EAM_CARD_NBYTES,
(unsigned int) len);
goto len_fail;
}
if (!hex_decode(card_id, nbytes, line, len)) {
log_warning("%s: Invalid hex [%s]", unit->card_path, card_id);
goto decode_fail;
}
log_misc(
"Unit %d: Loaded card ID [%s] from file %s",
unit_no,
line,
unit->card_path);
fclose(f);
if (card_id[0] == 0xe0 && card_id[1] == 0x04) {
return EAM_IO_CARD_ISO15696;
} else {
return EAM_IO_CARD_FELICA;
}
decode_fail:
len_fail:
fgets_fail:
fclose(f);
fopen_fail:
path_fail:
return EAM_IO_CARD_NONE;
}
static bool eam_impl_autogen(struct eam_unit *unit, uint8_t *card_id)
{
char hex[2 * EAM_CARD_NBYTES + 1];
FILE *f;
size_t i;
f = fopen(unit->card_path, "w");
if (f == NULL) {
return false;
}
srand(GetTickCount());
card_id[0] = 0xE0;
card_id[1] = 0x04;
card_id[2] = 0x01;
card_id[3] = 0x00;
for (i = 4; i < 8; i++) {
/* LSBit entropy of typical LFSR RNGs is usually poor */
card_id[i] = rand() >> 7;
}
hex_encode_uc(card_id, EAM_CARD_NBYTES, hex, sizeof(hex));
fwrite(hex, sizeof(hex) - 1, 1, f);
fclose(f);
log_info(
"Generated random card ID [%s] into file %s", hex, unit->card_path);
return true;
}
void eam_impl_notify_hotplug(struct eam *eam, uint8_t drive_no)
{
struct eam_unit *unit;
uint8_t unit_no;
EnterCriticalSection(&eam->lock);
for (unit_no = 0; unit_no < lengthof(eam->units); unit_no++) {
if (eam->units[unit_no].drive_no == drive_no) {
/* MMSYSTEM timeGetTime() is overkill, we don't exactly need super
accurate timestamps here. */
unit = &eam->units[unit_no];
unit->sensor_time = GetTickCount() + EAM_SENSOR_COOLDOWN;
unit->sensor_hot = true;
}
}
LeaveCriticalSection(&eam->lock);
}
void eam_impl_destroy(struct eam *eam)
{
int8_t unit_no;
for (unit_no = lengthof(eam->units) - 1; unit_no >= 0; unit_no--) {
free(eam->units[unit_no].card_path);
}
DeleteCriticalSection(&eam->lock);
free(eam);
}
| 23.710372 | 79 | 0.578821 |
9e0294b70a430c908e9513aa66441d7ab2636b25 | 742 | c | C | lab-03/plugins/echocd.c | drahosj/308labs | 718a02fa943749d906d10085d48dd4b4f69931e9 | [
"MIT"
] | null | null | null | lab-03/plugins/echocd.c | drahosj/308labs | 718a02fa943749d906d10085d48dd4b4f69931e9 | [
"MIT"
] | null | null | null | lab-03/plugins/echocd.c | drahosj/308labs | 718a02fa943749d906d10085d48dd4b4f69931e9 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "cash_api.h"
static int builtin_cd(size_t argc, char ** argv);
static int builtin_echo(size_t argc, char ** argv);
void plugin_load()
{
register_builtin("cd", &builtin_cd);
register_builtin("echo", &builtin_echo);
}
static int builtin_echo(size_t argc, char ** argv)
{
for (size_t i = 1; i < argc; i++) {
printf("%s ", argv[i]);
}
puts("");
return 0;
}
static int builtin_cd(size_t argc, char ** argv)
{
char * dest = NULL;
if (argc < 2) {
dest = getenv("HOME");
} else {
dest = argv[1];
}
/* Default to root if everything else fails */
if (dest == NULL) {
dest = "/";
}
if(chdir(dest) == -1) {
perror("chdir");
return -1;
}
return 0;
}
| 15.787234 | 51 | 0.613208 |
9e02d065b2de099b7948a2cb2a821fda87e718fe | 10,238 | h | C | src/Neo6/NDIS6.h | ghostfather72/SoftEtherVPN | 4f23c7d08a7d38aaf0dd9c81cfa13a0ae4355b04 | [
"Unlicense"
] | 9 | 2017-12-11T05:34:28.000Z | 2022-02-07T11:35:15.000Z | src/Neo6/NDIS6.h | ghostfather72/SoftEtherVPN | 4f23c7d08a7d38aaf0dd9c81cfa13a0ae4355b04 | [
"Unlicense"
] | 1 | 2020-06-29T11:01:53.000Z | 2020-06-29T11:02:59.000Z | src/Neo6/NDIS6.h | ghostfather72/SoftEtherVPN | 4f23c7d08a7d38aaf0dd9c81cfa13a0ae4355b04 | [
"Unlicense"
] | 3 | 2018-09-04T04:17:37.000Z | 2019-09-24T04:12:04.000Z | // SoftEther VPN Source Code - Developer Edition Master Branch
// Kernel Device Driver
//
// SoftEther VPN Server, Client and Bridge are free software under GPLv2.
//
// Copyright (c) Daiyuu Nobori.
// Copyright (c) SoftEther VPN Project, University of Tsukuba, Japan.
// Copyright (c) SoftEther Corporation.
//
// All Rights Reserved.
//
// http://www.softether.org/
//
// Author: Daiyuu Nobori, Ph.D.
// Comments: Tetsuo Sugiyama, Ph.D.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License version 2
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
// AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
//
//
// THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
// UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
// MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
// SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
// SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
// CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
// DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
// MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
// SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
// CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
// EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
// JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
// AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
// THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
//
// USE ONLY IN JAPAN. DO NOT USE THIS SOFTWARE IN ANOTHER COUNTRY UNLESS
// YOU HAVE A CONFIRMATION THAT THIS SOFTWARE DOES NOT VIOLATE ANY
// CRIMINAL LAWS OR CIVIL RIGHTS IN THAT PARTICULAR COUNTRY. USING THIS
// SOFTWARE IN OTHER COUNTRIES IS COMPLETELY AT YOUR OWN RISK. THE
// SOFTETHER VPN PROJECT HAS DEVELOPED AND DISTRIBUTED THIS SOFTWARE TO
// COMPLY ONLY WITH THE JAPANESE LAWS AND EXISTING CIVIL RIGHTS INCLUDING
// PATENTS WHICH ARE SUBJECTS APPLY IN JAPAN. OTHER COUNTRIES' LAWS OR
// CIVIL RIGHTS ARE NONE OF OUR CONCERNS NOR RESPONSIBILITIES. WE HAVE
// NEVER INVESTIGATED ANY CRIMINAL REGULATIONS, CIVIL LAWS OR
// INTELLECTUAL PROPERTY RIGHTS INCLUDING PATENTS IN ANY OF OTHER 200+
// COUNTRIES AND TERRITORIES. BY NATURE, THERE ARE 200+ REGIONS IN THE
// WORLD, WITH DIFFERENT LAWS. IT IS IMPOSSIBLE TO VERIFY EVERY
// COUNTRIES' LAWS, REGULATIONS AND CIVIL RIGHTS TO MAKE THE SOFTWARE
// COMPLY WITH ALL COUNTRIES' LAWS BY THE PROJECT. EVEN IF YOU WILL BE
// SUED BY A PRIVATE ENTITY OR BE DAMAGED BY A PUBLIC SERVANT IN YOUR
// COUNTRY, THE DEVELOPERS OF THIS SOFTWARE WILL NEVER BE LIABLE TO
// RECOVER OR COMPENSATE SUCH DAMAGES, CRIMINAL OR CIVIL
// RESPONSIBILITIES. NOTE THAT THIS LINE IS NOT LICENSE RESTRICTION BUT
// JUST A STATEMENT FOR WARNING AND DISCLAIMER.
//
//
// SOURCE CODE CONTRIBUTION
// ------------------------
//
// Your contribution to SoftEther VPN Project is much appreciated.
// Please send patches to us through GitHub.
// Read the SoftEther VPN Patch Acceptance Policy in advance:
// http://www.softether.org/5-download/src/9.patch
//
//
// DEAR SECURITY EXPERTS
// ---------------------
//
// If you find a bug or a security vulnerability please kindly inform us
// about the problem immediately so that we can fix the security problem
// to protect a lot of users around the world as soon as possible.
//
// Our e-mail address for security reports is:
// softether-vpn-security [at] softether.org
//
// Please note that the above e-mail address is not a technical support
// inquiry address. If you need technical assistance, please visit
// http://www.softether.org/ and ask your question on the users forum.
//
// Thank you for your cooperation.
//
//
// NO MEMORY OR RESOURCE LEAKS
// ---------------------------
//
// The memory-leaks and resource-leaks verification under the stress
// test has been passed before release this source code.
// NDIS6.h
// Header of NDIS6.c
#ifndef NDIS5_H
#define NDIS5_H
// Win32 DDK related
#ifndef CPU_64
#define _X86_
#else // CPU_64
#ifndef NEO_IA64
#define _AMD64_
#define AMD64
#else // NEO_IA64
#define _IA64_
#define IA64
#endif // NEO_IA64
#endif // CPU_64
#define NDIS_MINIPORT_DRIVER
// NDIS 6.2
#define NDIS620_MINIPORT
#define NDIS_SUPPORT_NDIS61 1
#define NDIS_SUPPORT_NDIS620 1
#define NEO_NDIS_MAJOR_VERSION 6
#define NEO_NDIS_MINOR_VERSION 20
#define NDIS_WDM 1
#include <wdm.h>
#include <ndis.h>
#include <stdio.h>
#include <string.h>
// Error checking macro
#define OK(val) ((val) == STATUS_SUCCESS)
#define NG(val) (!OK(val))
// Constant
static UINT SupportedOids[] =
{
OID_GEN_SUPPORTED_LIST,
OID_GEN_HARDWARE_STATUS,
OID_GEN_MEDIA_SUPPORTED,
OID_GEN_MEDIA_IN_USE,
OID_GEN_MAXIMUM_FRAME_SIZE,
OID_GEN_MAXIMUM_TOTAL_SIZE,
OID_GEN_MAC_OPTIONS,
OID_GEN_MAXIMUM_LOOKAHEAD,
OID_GEN_CURRENT_LOOKAHEAD,
OID_GEN_LINK_SPEED,
OID_GEN_MEDIA_CONNECT_STATUS,
OID_GEN_TRANSMIT_BUFFER_SPACE,
OID_GEN_RECEIVE_BUFFER_SPACE,
OID_GEN_TRANSMIT_BLOCK_SIZE,
OID_GEN_RECEIVE_BLOCK_SIZE,
OID_GEN_VENDOR_DESCRIPTION,
OID_GEN_VENDOR_ID,
OID_GEN_DRIVER_VERSION,
OID_GEN_VENDOR_DRIVER_VERSION,
OID_GEN_XMIT_OK,
OID_GEN_RCV_OK,
OID_GEN_XMIT_ERROR,
OID_GEN_RCV_ERROR,
OID_GEN_RCV_NO_BUFFER,
OID_GEN_CURRENT_PACKET_FILTER,
OID_802_3_PERMANENT_ADDRESS,
OID_802_3_CURRENT_ADDRESS,
OID_802_3_MAXIMUM_LIST_SIZE,
OID_802_3_RCV_ERROR_ALIGNMENT,
OID_802_3_XMIT_ONE_COLLISION,
OID_802_3_XMIT_MORE_COLLISIONS,
OID_802_3_MULTICAST_LIST,
//OID_GEN_PROTOCOL_OPTIONS,
OID_GEN_MAXIMUM_SEND_PACKETS,
OID_GEN_STATISTICS,
OID_GEN_INTERRUPT_MODERATION,
OID_GEN_LINK_PARAMETERS,
OID_PNP_SET_POWER,
OID_PNP_QUERY_POWER,
};
#define NEO_MEDIA NdisMedium802_3
#define MAX_MULTICAST 32
#define MAX_PATH 260
#define MAX_SIZE 512
#define STD_SIZE 512
// Unicode string
typedef struct _UNICODE
{
UNICODE_STRING String;
} UNICODE;
typedef struct _PACKET_BUFFER PACKET_BUFFER;
// Function prototype
UNICODE *NewUnicode(char *str);
void FreeUnicode(UNICODE *u);
NDIS_STRING *GetUnicode(UNICODE *u);
PACKET_BUFFER *NeoNewPacketBuffer();
void NeoFreePacketBuffer(PACKET_BUFFER *p);
void NeoInitPacketArray();
void NeoFreePacketArray();
NDIS_STATUS DriverEntry(DRIVER_OBJECT *DriverObject, UNICODE_STRING *RegistryPath);
NDIS_STATUS NeoNdisInitEx(NDIS_HANDLE MiniportAdapterHandle,
NDIS_HANDLE MiniportDriverContext,
PNDIS_MINIPORT_INIT_PARAMETERS MiniportInitParameters);
void NeoNdisHaltEx(NDIS_HANDLE MiniportAdapterContext, NDIS_HALT_ACTION HaltAction);
VOID NeoNdisDriverUnload(PDRIVER_OBJECT DriverObject);
NDIS_STATUS NeoNdisResetEx(NDIS_HANDLE MiniportAdapterContext, PBOOLEAN AddressingReset);
BOOLEAN NeoNdisCheckForHangEx(NDIS_HANDLE MiniportAdapterContext);
NDIS_STATUS NeoNdisQuery(NDIS_HANDLE MiniportAdapterContext,
NDIS_OID Oid,
void *InformationBuffer,
ULONG InformationBufferLength,
ULONG *BytesWritten,
ULONG *BytesNeeded);
NDIS_STATUS NeoNdisSet(
NDIS_HANDLE MiniportAdapterContext,
NDIS_OID Oid,
void *InformationBuffer,
ULONG InformationBufferLength,
ULONG *BytesRead,
ULONG *BytesNeeded);
NDIS_STATUS NeoNdisOidRequest(NDIS_HANDLE MiniportAdapterContext,
PNDIS_OID_REQUEST OidRequest);
void NeoNdisSendNetBufferLists(NDIS_HANDLE MiniportAdapterContext,
NET_BUFFER_LIST *NetBufferLists,
NDIS_PORT_NUMBER PortNumber,
ULONG SendFlags);
void NeoNdisSetNetBufferListsStatus(NET_BUFFER_LIST *nbl, UINT status);
BOOL NeoLoadRegistory();
void NeoInitControlDevice();
void NeoFreeControlDevice();
NTSTATUS NeoNdisDispatch(DEVICE_OBJECT *DeviceObject, IRP *Irp);
void NeoCheckConnectState();
void NeoSetConnectState(BOOL connected);
BOOL NeoNdisOnOpen(IRP *irp, IO_STACK_LOCATION *stack);
BOOL NeoNdisOnClose(IRP *irp, IO_STACK_LOCATION *stack);
void NeoNdisCrash();
void NeoNdisCrash2();
NDIS_STATUS NeoNdisSetOptions(NDIS_HANDLE NdisDriverHandle, NDIS_HANDLE DriverContext);
NDIS_STATUS NeoNdisPause(NDIS_HANDLE MiniportAdapterContext, PNDIS_MINIPORT_PAUSE_PARAMETERS MiniportPauseParameters);
NDIS_STATUS NeoNdisRestart(NDIS_HANDLE MiniportAdapterContext, PNDIS_MINIPORT_RESTART_PARAMETERS MiniportRestartParameters);
void NeoNdisReturnNetBufferLists(NDIS_HANDLE MiniportAdapterContext, PNET_BUFFER_LIST NetBufferLists, ULONG ReturnFlags);
void NeoNdisCancelSend(NDIS_HANDLE MiniportAdapterContext, PVOID CancelId);
void NeoNdisDevicePnPEventNotify(NDIS_HANDLE MiniportAdapterContext, PNET_DEVICE_PNP_EVENT NetDevicePnPEvent);
void NeoNdisShutdownEx(NDIS_HANDLE MiniportAdapterContext, NDIS_SHUTDOWN_ACTION ShutdownAction);
void NeoNdisCancelOidRequest(NDIS_HANDLE MiniportAdapterContext, PVOID RequestId);
// NeoNdisCrash2(__LINE__, __LINE__, __LINE__, __LINE__);
#endif // NDIS5_H
| 38.201493 | 125 | 0.763235 |
9af1bd0726200ae4ad7b2d00ae07904431500e68 | 384 | c | C | csc501-lab3/paging/write_bs.c | zyczyh/OS-Course-Project-3 | d929b87fc678762cdcda7e4aaf328c8e4ad2ba04 | [
"MIT"
] | null | null | null | csc501-lab3/paging/write_bs.c | zyczyh/OS-Course-Project-3 | d929b87fc678762cdcda7e4aaf328c8e4ad2ba04 | [
"MIT"
] | null | null | null | csc501-lab3/paging/write_bs.c | zyczyh/OS-Course-Project-3 | d929b87fc678762cdcda7e4aaf328c8e4ad2ba04 | [
"MIT"
] | null | null | null | #include <conf.h>
#include <kernel.h>
#include <proc.h>
#include <mark.h>
#include <bufpool.h>
#include <paging.h>
int write_bs(char *src, bsd_t bs_id, int page) {
/* write one page of data from src
to the backing store bs_id, page
page.
*/
char * phy_addr = BACKING_STORE_BASE + bs_id*BACKING_STORE_UNIT_SIZE + page*NBPG;
bcopy((void*)src, phy_addr, NBPG);
}
| 20.210526 | 84 | 0.674479 |
b104131ef1a0ea078757c4647cb03447cc957f75 | 43,542 | h | C | Debug/Crash/Windbg/winext/manifest/dplay.h | duchuan1/Tools | c1a881228247753fdcce3b10ba43427c19194858 | [
"Apache-2.0"
] | 1 | 2020-04-24T01:35:32.000Z | 2020-04-24T01:35:32.000Z | Debug/Crash/Windbg/winext/manifest/dplay.h | duchuan1/Tools | c1a881228247753fdcce3b10ba43427c19194858 | [
"Apache-2.0"
] | null | null | null | Debug/Crash/Windbg/winext/manifest/dplay.h | duchuan1/Tools | c1a881228247753fdcce3b10ba43427c19194858 | [
"Apache-2.0"
] | null | null | null | module DPLAYX.DLL:
category DirectPlay:
/*
* GUIDS used by DirectPlay objects
*/
class __declspec(uuid("D1EB6D20-8923-11d0-9D97-00A0C90A43CB")) DirectPlay;
class __declspec(uuid("2b74f7c0-9154-11cf-a9cd-00aa006886e3")) IDirectPlay2;
class __declspec(uuid("9d460580-a822-11cf-960c-0080c7534e82")) IDirectPlay2A;
class __declspec(uuid("133efe40-32dc-11d0-9cfb-00a0c90a43cb")) IDirectPlay3;
class __declspec(uuid("133efe41-32dc-11d0-9cfb-00a0c90a43cb")) IDirectPlay3A;
class __declspec(uuid("0ab1c530-4745-11d1-a7a1-0000f803abfc")) IDirectPlay4;
class __declspec(uuid("0ab1c531-4745-11d1-a7a1-0000f803abfc")) IDirectPlay4A;
struct __declspec(uuid("685BC400-9D2C-11cf-A9CD-00AA006886E3")) DPSPGUID_IPX;
struct __declspec(uuid("36E95EE0-8577-11cf-960C-0080C7534E82")) DPSPGUID_TCPIP;
struct __declspec(uuid("0F1D6860-88D9-11cf-9C4E-00A0C905425E")) DPSPGUID_SERIAL;
struct __declspec(uuid("44EAA760-CB68-11cf-9C4E-00A0C905425E")) DPSPGUID_MODEM;
typedef IUnknown *LPDIRECTPLAY;
typedef IDirectPlay2 *LPDIRECTPLAY2;
typedef IDirectPlay2 *LPDIRECTPLAY2A;
typedef IDirectPlay2 IDirectPlay2A;
typedef IDirectPlay3 *LPDIRECTPLAY3;
typedef IDirectPlay3 *LPDIRECTPLAY3A;
typedef IDirectPlay3 IDirectPlay3A;
typedef IDirectPlay4 *LPDIRECTPLAY4;
typedef IDirectPlay4 *LPDIRECTPLAY4A;
typedef IDirectPlay4 IDirectPlay4A;
/*
* DPID
* DirectPlay player and group ID
*/
typedef DWORD DPID;
typedef DWORD *LPDPID;
/*
#define DPID_SYSMSG 0
#define DPID_ALLPLAYERS 0
#define DPID_SERVERPLAYER 1
#define DPID_UNKNOWN 0xFFFFFFFF
*/
mask DWORD DPlayObjectFlags
{
/*
* This DirectPlay object is the session host. If the host exits the
* session, another application will become the host and receive a
* DPSYS_HOST system message.
*/
#define DPCAPS_ISHOST 0x00000002
/*
* The service provider bound to this DirectPlay object can optimize
* group messaging.
*/
#define DPCAPS_GROUPOPTIMIZED 0x00000008
/*
* The service provider bound to this DirectPlay object can optimize
* keep alives (see DPSESSION_KEEPALIVE)
*/
#define DPCAPS_KEEPALIVEOPTIMIZED 0x00000010
/*
* The service provider bound to this DirectPlay object can optimize
* guaranteed message delivery.
*/
#define DPCAPS_GUARANTEEDOPTIMIZED 0x00000020
/*
* This DirectPlay object supports guaranteed message delivery.
*/
#define DPCAPS_GUARANTEEDSUPPORTED 0x00000040
/*
* This DirectPlay object supports digital signing of messages.
*/
#define DPCAPS_SIGNINGSUPPORTED 0x00000080
/*
* This DirectPlay object supports encryption of messages.
*/
#define DPCAPS_ENCRYPTIONSUPPORTED 0x00000100
};
/*
* DPCAPS
* Used to obtain the capabilities of a DirectPlay object
*/
typedef struct _DPCAPS
{
DWORD dwSize; // Size of structure, in bytes
DPlayObjectFlags dwFlags; // DPCAPS_xxx flags
DWORD dwMaxBufferSize; // Maximum message size, in bytes, for this service provider
DWORD dwMaxQueueSize; // Obsolete.
DWORD dwMaxPlayers; // Maximum players/groups (local + remote)
DWORD dwHundredBaud; // Bandwidth in 100 bits per second units;
// i.e. 24 is 2400, 96 is 9600, etc.
DWORD dwLatency; // Estimated latency; 0 = unknown
DWORD dwMaxLocalPlayers; // Maximum # of locally created players allowed
DWORD dwHeaderLength; // Maximum header length, in bytes, on messages
// added by the service provider
DWORD dwTimeout; // Service provider's suggested timeout value
// This is how long DirectPlay will wait for
// responses to system messages
} DPCAPS;
typedef DPCAPS *LPDPCAPS;
/*
* LPCDPSESSIONDESC2
* A constant pointer to DPSESSIONDESC2
*/
typedef DPSESSIONDESC2 *LPCDPSESSIONDESC2;
mask DWORD DPSESSION_Flags
{
/*
* Applications cannot create new players in this session.
*/
#define DPSESSION_NEWPLAYERSDISABLED 0x00000001
/*
* If the DirectPlay object that created the session, the host,
* quits, then the host will attempt to migrate to another
* DirectPlay object so that new players can continue to be created
* and new applications can join the session.
*/
#define DPSESSION_MIGRATEHOST 0x00000004
/*
* This flag tells DirectPlay not to set the idPlayerTo and idPlayerFrom
* fields in player messages. This cuts two DWORD's off the message
* overhead.
*/
#define DPSESSION_NOMESSAGEID 0x00000008
/*
* This flag tells DirectPlay to not allow any new applications to
* join the session. Applications already in the session can still
* create new players.
*/
#define DPSESSION_JOINDISABLED 0x00000020
/*
* This flag tells DirectPlay to detect when remote players
* exit abnormally (e.g. their computer or modem gets unplugged)
*/
#define DPSESSION_KEEPALIVE 0x00000040
/*
* This flag tells DirectPlay not to send a message to all players
* when a players remote data changes
*/
#define DPSESSION_NODATAMESSAGES 0x00000080
/*
* This flag indicates that the session belongs to a secure server
* and needs user authentication
*/
#define DPSESSION_SECURESERVER 0x00000100
/*
* This flag indicates that the session is private and requirs a password
* for EnumSessions as well as Open.
*/
#define DPSESSION_PRIVATE 0x00000200
/*
* This flag indicates that the session requires a password for joining.
*/
#define DPSESSION_PASSWORDREQUIRED 0x00000400
/*
* This flag tells DirectPlay to route all messages through the server
*/
#define DPSESSION_MULTICASTSERVER 0x00000800
/*
* This flag tells DirectPlay to only download information about the
* DPPLAYER_SERVERPLAYER.
*/
#define DPSESSION_CLIENTSERVER 0x00001000
/*
* This flag tells DirectPlay to use the protocol built into dplay
* for reliability and statistics all the time. When this bit is
* set, only other sessions with this bit set can join or be joined.
*/
#define DPSESSION_DIRECTPLAYPROTOCOL 0x00002000
/*
* This flag tells DirectPlay that preserving order of received
* packets is not important, when using reliable delivery. This
* will allow messages to be indicated out of order if preceding
* messages have not yet arrived. Otherwise DPLAY will wait for
* earlier messages before delivering later reliable messages.
*/
#define DPSESSION_NOPRESERVEORDER 0x00004000
};
/*
* DPSESSIONDESC2
* Used to describe the properties of a DirectPlay
* session instance
*/
typedef struct _DPSESSIONDESC2
{
DWORD dwSize; // Size of structure
DWORD dwFlags; // DPSESSION_xxx flags
GUID guidInstance; // ID for the session instance
GUID guidApplication; // GUID of the DirectPlay application.
// GUID_NULL for all applications.
DWORD dwMaxPlayers; // Maximum # players allowed in session
DWORD dwCurrentPlayers; // Current # players in session (read only)
// union
// { // Name of the session
// LPWSTR lpszSessionName; // Unicode
LPSTR lpszSessionNameA; // ANSI
// };
// union
// { // Password of the session (optional)
// LPWSTR lpszPassword; // Unicode
LPSTR lpszPasswordA; // ANSI
// };
DWORD dwReserved1; // Reserved for future MS use.
DWORD dwReserved2;
DWORD dwUser1; // For use by the application
DWORD dwUser2;
DWORD dwUser3;
DWORD dwUser4;
} DPSESSIONDESC2;
typedef DPSESSIONDESC2 *LPDPSESSIONDESC2;
/*
* DPNAME
* Used to hold the name of a DirectPlay entity
* like a player or a group
*/
typedef struct _DPNAME
{
DWORD dwSize; // Size of structure
DWORD dwFlags; // Not used. Must be zero.
// union
// { // The short or friendly name
// LPWSTR lpszShortName; // Unicode
LPSTR lpszShortNameA; // ANSI
// };
// union
// { // The long or formal name
// LPWSTR lpszLongName; // Unicode
LPSTR lpszLongNameA; // ANSI
// };
} DPNAME;
typedef DPNAME *LPDPNAME;
/*
* LPCDPNAME
* A constant pointer to DPNAME
*/
typedef DPNAME *LPCDPNAME;
/*
* DPCREDENTIALS
* Used to hold the user name and password of a DirectPlay user
*/
typedef struct _DPCREDENTIALS
{
DWORD dwSize; // Size of structure
DWORD dwFlags; // Not used. Must be zero.
// union
// { // User name of the account
// LPWSTR lpszUsername; // Unicode
LPSTR lpszUsernameA; // ANSI
// };
// union
// { // Password of the account
// LPWSTR lpszPassword; // Unicode
LPSTR lpszPasswordA; // ANSI
// };
// union
// { // Domain name of the account
// LPWSTR lpszDomain; // Unicode
LPSTR lpszDomainA; // ANSI
// };
} DPCREDENTIALS;
typedef DPCREDENTIALS *LPDPCREDENTIALS;
typedef DPCREDENTIALS *LPCDPCREDENTIALS;
/*
* DPSECURITYDESC
* Used to describe the security properties of a DirectPlay
* session instance
*/
typedef struct _DPSECURITYDESC
{
DWORD dwSize; // Size of structure
DWORD dwFlags; // Not used. Must be zero.
// union
// { // SSPI provider name
// LPWSTR lpszSSPIProvider; // Unicode
LPSTR lpszSSPIProviderA; // ANSI
// };
// union
// { // CAPI provider name
// LPWSTR lpszCAPIProvider; // Unicode
LPSTR lpszCAPIProviderA; // ANSI
// };
DWORD dwCAPIProviderType; // Crypto Service Provider type
DWORD dwEncryptionAlgorithm; // Encryption Algorithm type
} DPSECURITYDESC;
typedef DPSECURITYDESC *LPDPSECURITYDESC;
typedef DPSECURITYDESC *LPCDPSECURITYDESC;
/*
* DPACCOUNTDESC
* Used to describe a user membership account
*/
typedef struct _DPACCOUNTDESC
{
DWORD dwSize; // Size of structure
DWORD dwFlags; // Not used. Must be zero.
// union
// { // Account identifier
// LPWSTR lpszAccountID; // Unicode
LPSTR lpszAccountIDA; // ANSI
// };
} DPACCOUNTDESC;
typedef DPACCOUNTDESC *LPDPACCOUNTDESC;
typedef DPACCOUNTDESC *LPCDPACCOUNTDESC;
/*
* LPCGUID
* A constant pointer to a guid
*/
typedef GUID *LPCGUID;
/****************************************************************************
*
* DPLCONNECTION flags
*
****************************************************************************/
mask DWORD DPLCONNECTIONFlags
{
/*
* This application should create a new session as
* described by the DPSESIONDESC structure
*/
#define DPLCONNECTION_CREATESESSION 0x00000002
/*
* This application should join the session described by
* the DPSESIONDESC structure with the lpAddress data
*/
#define DPLCONNECTION_JOINSESSION 0x00000001
};
/*
* DPLCONNECTION
* Used to hold all in the informaion needed to connect
* an application to a session or create a session
*/
typedef struct _DPLCONNECTION
{
DWORD dwSize; // Size of this structure
DPLCONNECTIONFlags dwFlags; // Flags specific to this structure
LPDPSESSIONDESC2 lpSessionDesc; // Pointer to session desc to use on connect
LPDPNAME lpPlayerName; // Pointer to Player name structure
GUID guidSP; // GUID of the DPlay SP to use
LPVOID lpAddress; // Address for service provider
DWORD dwAddressSize; // Size of address data
} DPLCONNECTION;
typedef DPLCONNECTION *LPDPLCONNECTION;
/*
* LPCDPLCONNECTION
* A constant pointer to DPLCONNECTION
*/
typedef DPLCONNECTION *LPCDPLCONNECTION;
/*
* DPCHAT
* Used to hold the a DirectPlay chat message
*/
typedef struct _DPCHAT
{
DWORD dwSize;
DWORD dwFlags;
// union
// { // Message string
// LPWSTR lpszMessage; // Unicode
LPSTR lpszMessageA; // ANSI
// };
} DPCHAT;
typedef DPCHAT * LPDPCHAT;
/*
* SGBUFFER
* Scatter Gather Buffer used for SendEx
*/
typedef struct _SGBUFFER
{
UINT len; // length of buffer data
//PUCHAR pData; // pointer to buffer data
CHAR * pData; // pointer to buffer data
} SGBUFFER;
typedef SGBUFFER *PSGBUFFER;
typedef SGBUFFER *LPSGBUFFER;
value DWORD DPRESULT
{
/****************************************************************************
*
* DIRECTPLAY ERRORS
*
* Errors are represented by negative values and cannot be combined.
*
****************************************************************************/
#define DP_OK 0
#define DPERR_ALREADYINITIALIZED 0x88770005L [fail]
#define DPERR_ACCESSDENIED 0x8877000AL [fail]
#define DPERR_ACTIVEPLAYERS 0x88770014L [fail]
#define DPERR_BUFFERTOOSMALL 0x8877001EL [fail]
#define DPERR_CANTADDPLAYER 0x88770028L [fail]
#define DPERR_CANTCREATEGROUP 0x88770032L [fail]
#define DPERR_CANTCREATEPLAYER 0x8877003CL [fail]
#define DPERR_CANTCREATESESSION 0x88770046L [fail]
#define DPERR_CAPSNOTAVAILABLEYET 0x88770050L [fail]
#define DPERR_EXCEPTION 0x8877005AL [fail]
#define DPERR_GENERIC 0x80004005L [fail]
#define DPERR_INVALIDFLAGS 0x88770078L [fail]
#define DPERR_INVALIDOBJECT 0x88770082L [fail]
#define DPERR_INVALIDPARAM 0x80070057L [fail]
#define DPERR_INVALIDPARAMS 0x80070057L [fail]
#define DPERR_INVALIDPLAYER 0x88770096L [fail]
#define DPERR_INVALIDGROUP 0x8877009BL [fail]
#define DPERR_NOCAPS 0x887700A0L [fail]
#define DPERR_NOCONNECTION 0x887700AAL [fail]
#define DPERR_NOMEMORY 0x8007000EL [fail]
#define DPERR_OUTOFMEMORY 0x8007000EL [fail]
#define DPERR_NOMESSAGES 0x887700BEL [fail]
#define DPERR_NONAMESERVERFOUND 0x887700C8L [fail]
#define DPERR_NOPLAYERS 0x887700D2L [fail]
#define DPERR_NOSESSIONS 0x887700DCL [fail]
#define DPERR_PENDING 0x8000000AL [fail]
#define DPERR_SENDTOOBIG 0x887700E6L [fail]
#define DPERR_TIMEOUT 0x887700F0L [fail]
#define DPERR_UNAVAILABLE 0x887700FAL [fail]
#define DPERR_UNSUPPORTED 0x80004001L [fail]
#define DPERR_BUSY 0x8877010EL [fail]
#define DPERR_USERCANCEL 0x88770118L [fail]
#define DPERR_NOINTERFACE 0x80004002L [fail]
#define DPERR_CANNOTCREATESERVER 0x88770122L [fail]
#define DPERR_PLAYERLOST 0x8877012CL [fail]
#define DPERR_SESSIONLOST 0x88770136L [fail]
#define DPERR_UNINITIALIZED 0x88770140L [fail]
#define DPERR_NONEWPLAYERS 0x8877013AL [fail]
#define DPERR_INVALIDPASSWORD 0x88770154L [fail]
#define DPERR_CONNECTING 0x8877015EL [fail]
#define DPERR_CONNECTIONLOST 0x88770168L [fail]
#define DPERR_UNKNOWNMESSAGE 0x88770172L [fail]
#define DPERR_CANCELFAILED 0x8877017CL [fail]
#define DPERR_INVALIDPRIORITY 0x88770186L [fail]
#define DPERR_NOTHANDLED 0x88770190L [fail]
#define DPERR_CANCELLED 0x8877019AL [fail]
#define DPERR_ABORTED 0x887701A4L [fail]
#define DPERR_BUFFERTOOLARGE 0x887703E8L [fail]
#define DPERR_CANTCREATEPROCESS 0x887703F2L [fail]
#define DPERR_APPNOTSTARTED 0x887703FCL [fail]
#define DPERR_INVALIDINTERFACE 0x88770406L [fail]
#define DPERR_NOSERVICEPROVIDER 0x88770410L [fail]
#define DPERR_UNKNOWNAPPLICATION 0x8877041AL [fail]
#define DPERR_NOTLOBBIED 0x8877042EL [fail]
#define DPERR_SERVICEPROVIDERLOADED 0x88770438L [fail]
#define DPERR_ALREADYREGISTERED 0x88770442L [fail]
#define DPERR_NOTREGISTERED 0x8877044CL [fail]
//
// Security related errors
//
#define DPERR_AUTHENTICATIONFAILED 0x887707D0L [fail]
#define DPERR_CANTLOADSSPI 0x887707DAL [fail]
#define DPERR_ENCRYPTIONFAILED 0x887707E4L [fail]
#define DPERR_SIGNFAILED 0x887707EEL [fail]
#define DPERR_CANTLOADSECURITYPACKAGE 0x887707F8L [fail]
#define DPERR_ENCRYPTIONNOTSUPPORTED 0x88770802L [fail]
#define DPERR_CANTLOADCAPI 0x8877080CL [fail]
#define DPERR_NOTLOGGEDIN 0x88770816L [fail]
#define DPERR_LOGONDENIED 0x88770820L [fail]
};
/****************************************************************************
*
* Prototypes for DirectPlay callback functions
*
****************************************************************************/
typedef LPVOID LPDPENUMSESSIONSCALLBACK2;
typedef LPVOID LPDPENUMPLAYERSCALLBACK2;
typedef LPVOID LPDPENUMDPCALLBACK;
typedef LPVOID LPDPENUMDPCALLBACKA;
typedef LPVOID LPDPENUMCONNECTIONSCALLBACK;
/****************************************************************************
*
* EnumConnections API flags
*
****************************************************************************/
mask DWORD EnumConnectionsFlags
{
/*
* Enumerate Service Providers
*/
#define DPCONNECTION_DIRECTPLAY 0x00000001
/*
* Enumerate Lobby Providers
*/
#define DPCONNECTION_DIRECTPLAYLOBBY 0x00000002
};
/****************************************************************************
*
* EnumPlayers API flags
*
****************************************************************************/
mask DWORD EnumPlayersMask
{
/*
* Enumerate all players in the current session
*/
#define DPENUMPLAYERS_ALL 0x00000000
//#define DPENUMGROUPS_ALL DPENUMPLAYERS_ALL
/*
* Enumerate only local (created by this application) players
* or groups
*/
#define DPENUMPLAYERS_LOCAL 0x00000008
//#define DPENUMGROUPS_LOCAL DPENUMPLAYERS_LOCAL
/*
* Enumerate only remote (non-local) players
* or groups
*/
#define DPENUMPLAYERS_REMOTE 0x00000010
//#define DPENUMGROUPS_REMOTE DPENUMPLAYERS_REMOTE
/*
* Enumerate groups along with the players
*/
#define DPENUMPLAYERS_GROUP 0x00000020
/*
* Enumerate players or groups in another session
* (must supply lpguidInstance)
*/
#define DPENUMPLAYERS_SESSION 0x00000080
//#define DPENUMGROUPS_SESSION DPENUMPLAYERS_SESSION
/*
* Enumerate server players
*/
#define DPENUMPLAYERS_SERVERPLAYER 0x00000100
/*
* Enumerate spectator players
*/
#define DPENUMPLAYERS_SPECTATOR 0x00000200
/*
* Enumerate shortcut groups
*/
#define DPENUMGROUPS_SHORTCUT 0x00000400
/*
* Enumerate staging area groups
*/
#define DPENUMGROUPS_STAGINGAREA 0x00000800
/*
* Enumerate hidden groups
*/
#define DPENUMGROUPS_HIDDEN 0x00001000
/*
* Enumerate the group's owner
*/
#define DPENUMPLAYERS_OWNER 0x00002000
};
/****************************************************************************
*
* CreatePlayer API flags
*
****************************************************************************/
mask DWORD CreatePlayerFlags
{
/*
* This flag indicates that this player should be designated
* the server player. The app should specify this at CreatePlayer.
*/
#define DPPLAYER_SERVERPLAYER 0x00000100
/*
* This flag indicates that this player should be designated
* a spectator. The app should specify this at CreatePlayer.
*/
#define DPPLAYER_SPECTATOR 0x00000200
/*
* This flag indicates that this player was created locally.
* (returned from GetPlayerFlags)
*/
#define DPPLAYER_LOCAL 0x00000008
/*
* This flag indicates that this player is the group's owner
* (Only returned in EnumGroupPlayers)
*/
#define DPPLAYER_OWNER 0x00002000
};
/****************************************************************************
*
* CreateGroup API flags
*
****************************************************************************/
mask DWORD CreateGroupFlags
{
/*
* This flag indicates that the StartSession can be called on the group.
* The app should specify this at CreateGroup, or CreateGroupInGroup.
*/
#define DPGROUP_STAGINGAREA 0x00000800
/*
* This flag indicates that this group was created locally.
* (returned from GetGroupFlags)
*/
#define DPGROUP_LOCAL 0x00000008
/*
* This flag indicates that this group was created hidden.
*/
#define DPGROUP_HIDDEN 0x00001000
};
/****************************************************************************
*
* EnumSessions API flags
*
****************************************************************************/
mask DWORD EnumSessionsFlags
{
/*
* Enumerate sessions which can be joined
*/
#define DPENUMSESSIONS_AVAILABLE 0x00000001
/*
* Enumerate all sessions even if they can't be joined.
*/
#define DPENUMSESSIONS_ALL 0x00000002
/*
* Start an asynchronous enum sessions
*/
#define DPENUMSESSIONS_ASYNC 0x00000010
/*
* Stop an asynchronous enum sessions
*/
#define DPENUMSESSIONS_STOPASYNC 0x00000020
/*
* Enumerate sessions even if they require a password
*/
#define DPENUMSESSIONS_PASSWORDREQUIRED 0x00000040
/*
* Return status about progress of enumeration instead of
* showing any status dialogs.
*/
#define DPENUMSESSIONS_RETURNSTATUS 0x00000080
};
/****************************************************************************
*
* GetCaps and GetPlayerCaps API flags
*
****************************************************************************/
mask DWORD GetCapsFlags
{
/*
* The latency returned should be for guaranteed message sending.
* Default is non-guaranteed messaging.
*/
#define DPGETCAPS_GUARANTEED 0x00000001
};
/****************************************************************************
*
* GetGroupData, GetPlayerData API flags
* Remote and local Group/Player data is maintained separately.
* Default is DPGET_REMOTE.
*
****************************************************************************/
mask DWORD GetDataFlags
{
/*
* Get the remote data (set by any DirectPlay object in
* the session using DPSET_REMOTE)
*/
#define DPGET_REMOTE 0x00000000
/*
* Get the local data (set by this DirectPlay object
* using DPSET_LOCAL)
*/
#define DPGET_LOCAL 0x00000001
};
/****************************************************************************
*
* Open API flags
*
****************************************************************************/
mask DWORD OpenFlags
{
/*
* Join the session that is described by the DPSESSIONDESC2 structure
*/
#define DPOPEN_JOIN 0x00000001
/*
* Create a new session as described by the DPSESSIONDESC2 structure
*/
#define DPOPEN_CREATE 0x00000002
/*
* Return status about progress of open instead of showing
* any status dialogs.
*/
#define DPOPEN_RETURNSTATUS 0x00000080L
};
/****************************************************************************
*
* Receive API flags
* Default is DPRECEIVE_ALL
*
****************************************************************************/
mask DWORD ReceiveFlags
{
/*
* Get the first message in the queue
*/
#define DPRECEIVE_ALL 0x00000001
/*
* Get the first message in the queue directed to a specific player
*/
#define DPRECEIVE_TOPLAYER 0x00000002
/*
* Get the first message in the queue from a specific player
*/
#define DPRECEIVE_FROMPLAYER 0x00000004
/*
* Get the message but don't remove it from the queue
*/
#define DPRECEIVE_PEEK 0x00000008
};
/****************************************************************************
*
* Send API flags
*
****************************************************************************/
mask DWORD SendFlags
{
/*
* Send the message using a guaranteed send method.
* Default is non-guaranteed.
*/
#define DPSEND_GUARANTEED 0x00000001
/*
* This flag is obsolete. It is ignored by DirectPlay
*/
#define DPSEND_HIGHPRIORITY 0x00000002
/*
* This flag is obsolete. It is ignored by DirectPlay
*/
#define DPSEND_OPENSTREAM 0x00000008
/*
* This flag is obsolete. It is ignored by DirectPlay
*/
#define DPSEND_CLOSESTREAM 0x00000010
/*
* Send the message digitally signed to ensure authenticity.
*/
#define DPSEND_SIGNED 0x00000020
/*
* Send the message with encryption to ensure privacy.
*/
#define DPSEND_ENCRYPTED 0x00000040
/*
* The message is a lobby system message
*/
#define DPSEND_LOBBYSYSTEMMESSAGE 0x00000080
/*
* Send message asynchronously, must check caps
* before using this flag. It is always provided
* if the protocol flag is set.
*/
#define DPSEND_ASYNC 0x00000200
/*
* When an message is completed, don't tell me.
* by default the application is notified with a system message.
*/
#define DPSEND_NOSENDCOMPLETEMSG 0x00000400
/*
* Maximum priority for sends available to applications
*/
#define DPSEND_MAX_PRIORITY 0x0000FFFF
};
/****************************************************************************
*
* SetGroupData, SetGroupName, SetPlayerData, SetPlayerName,
* SetSessionDesc API flags.
* Default is DPSET_REMOTE.
*
****************************************************************************/
mask DWORD SetDataFlags
{
/*
* Propagate the data to all players in the session
*/
#define DPSET_REMOTE 0x00000000
/*
* Do not propagate the data to other players
*/
#define DPSET_LOCAL 0x00000001
/*
* Used with DPSET_REMOTE, use guaranteed message send to
* propagate the data
*/
#define DPSET_GUARANTEED 0x00000002
};
/****************************************************************************
*
* GetMessageQueue API flags.
* Default is DPMESSAGEQUEUE_SEND
*
****************************************************************************/
mask DWORD GetMessageQueueFlags
{
/*
* Get Send Queue - requires Service Provider Support
*/
#define DPMESSAGEQUEUE_SEND 0x00000001
/*
* Get Receive Queue
*/
#define DPMESSAGEQUEUE_RECEIVE 0x00000002
};
/****************************************************************************
*
* Connect API flags
*
****************************************************************************/
/*
* Start an asynchronous connect which returns status codes
*/
//#define DPCONNECT_RETURNSTATUS 0x00000080
/****************************************************************************
*
* DirectPlay system messages and message data structures
*
* All system message come 'From' player DPID_SYSMSG. To determine what type
* of message it is, cast the lpData from Receive to DPMSG_GENERIC and check
* the dwType member against one of the following DPSYS_xxx constants. Once
* a match is found, cast the lpData to the corresponding of the DPMSG_xxx
* structures to access the data of the message.
*
****************************************************************************/
value DWORD DirectPlayMessages
{
/*
* A new player or group has been created in the session
* Use DPMSG_CREATEPLAYERORGROUP. Check dwPlayerType to see if it
* is a player or a group.
*/
#define DPSYS_CREATEPLAYERORGROUP 0x0003
/*
* A player has been deleted from the session
* Use DPMSG_DESTROYPLAYERORGROUP
*/
#define DPSYS_DESTROYPLAYERORGROUP 0x0005
/*
* A player has been added to a group
* Use DPMSG_ADDPLAYERTOGROUP
*/
#define DPSYS_ADDPLAYERTOGROUP 0x0007
/*
* A player has been removed from a group
* Use DPMSG_DELETEPLAYERFROMGROUP
*/
#define DPSYS_DELETEPLAYERFROMGROUP 0x0021
/*
* This DirectPlay object lost its connection with all the
* other players in the session.
* Use DPMSG_SESSIONLOST.
*/
#define DPSYS_SESSIONLOST 0x0031
/*
* The current host has left the session.
* This DirectPlay object is now the host.
* Use DPMSG_HOST.
*/
#define DPSYS_HOST 0x0101
/*
* The remote data associated with a player or
* group has changed. Check dwPlayerType to see
* if it is a player or a group
* Use DPMSG_SETPLAYERORGROUPDATA
*/
#define DPSYS_SETPLAYERORGROUPDATA 0x0102
/*
* The name of a player or group has changed.
* Check dwPlayerType to see if it is a player
* or a group.
* Use DPMSG_SETPLAYERORGROUPNAME
*/
#define DPSYS_SETPLAYERORGROUPNAME 0x0103
/*
* The session description has changed.
* Use DPMSG_SETSESSIONDESC
*/
#define DPSYS_SETSESSIONDESC 0x0104
/*
* A group has been added to a group
* Use DPMSG_ADDGROUPTOGROUP
*/
#define DPSYS_ADDGROUPTOGROUP 0x0105
/*
* A group has been removed from a group
* Use DPMSG_DELETEGROUPFROMGROUP
*/
#define DPSYS_DELETEGROUPFROMGROUP 0x0106
/*
* A secure player-player message has arrived.
* Use DPMSG_SECUREMESSAGE
*/
#define DPSYS_SECUREMESSAGE 0x0107
/*
* Start a new session.
* Use DPMSG_STARTSESSION
*/
#define DPSYS_STARTSESSION 0x0108
/*
* A chat message has arrived
* Use DPMSG_CHAT
*/
#define DPSYS_CHAT 0x0109
/*
* The owner of a group has changed
* Use DPMSG_SETGROUPOWNER
*/
#define DPSYS_SETGROUPOWNER 0x010A
/*
* An async send has finished, failed or been cancelled
* Use DPMSG_SENDCOMPLETE
*/
#define DPSYS_SENDCOMPLETE 0x010d
};
value DWORD PlayerTypeValue
{
/*
* Used in the dwPlayerType field to indicate if it applies to a group
* or a player
*/
#define DPPLAYERTYPE_GROUP 0x00000000
#define DPPLAYERTYPE_PLAYER 0x00000001
};
/*
* DPMSG_GENERIC
* Generic message structure used to identify the message type.
*/
typedef struct _DPMSG_GENERIC
{
DirectPlayMessages dwType; // Message type
} DPMSG_GENERIC;
typedef DPMSG_GENERIC *LPDPMSG_GENERIC;
/*
* DPMSG_CREATEPLAYERORGROUP
* System message generated when a new player or group
* created in the session with information about it.
*/
typedef struct _DPMSG_CREATEPLAYERORGROUP
{
DWORD dwType; // Message type
PlayerTypeValue dwPlayerType; // Is it a player or group
DPID dpId; // ID of the player or group
DWORD dwCurrentPlayers; // current # players & groups in session
LPVOID lpData; // pointer to remote data
DWORD dwDataSize; // size of remote data
DPNAME dpnName; // structure with name info
// the following fields are only available when using
// the IDirectPlay3 interface or greater
DPID dpIdParent; // id of parent group
DWORD dwFlags; // player or group flags
} DPMSG_CREATEPLAYERORGROUP;
typedef DPMSG_CREATEPLAYERORGROUP *LPDPMSG_CREATEPLAYERORGROUP;
/*
* DPMSG_DESTROYPLAYERORGROUP
* System message generated when a player or group is being
* destroyed in the session with information about it.
*/
typedef struct _DPMSG_DESTROYPLAYERORGROUP
{
DWORD dwType; // Message type
DWORD dwPlayerType; // Is it a player or group
DPID dpId; // player ID being deleted
LPVOID lpLocalData; // copy of players local data
DWORD dwLocalDataSize; // sizeof local data
LPVOID lpRemoteData; // copy of players remote data
DWORD dwRemoteDataSize; // sizeof remote data
// the following fields are only available when using
// the IDirectPlay3 interface or greater
DPNAME dpnName; // structure with name info
DPID dpIdParent; // id of parent group
DWORD dwFlags; // player or group flags
} DPMSG_DESTROYPLAYERORGROUP;
typedef DPMSG_DESTROYPLAYERORGROUP *LPDPMSG_DESTROYPLAYERORGROUP;
/*
* DPMSG_ADDPLAYERTOGROUP
* System message generated when a player is being added
* to a group.
*/
typedef struct _DPMSG_ADDPLAYERTOGROUP
{
DWORD dwType; // Message type
DPID dpIdGroup; // group ID being added to
DPID dpIdPlayer; // player ID being added
} DPMSG_ADDPLAYERTOGROUP;
typedef DPMSG_ADDPLAYERTOGROUP *LPDPMSG_ADDPLAYERTOGROUP;
/*
* DPMSG_DELETEPLAYERFROMGROUP
* System message generated when a player is being
* removed from a group
*/
typedef DPMSG_ADDPLAYERTOGROUP DPMSG_DELETEPLAYERFROMGROUP;
typedef DPMSG_DELETEPLAYERFROMGROUP *LPDPMSG_DELETEPLAYERFROMGROUP;
/*
* DPMSG_ADDGROUPTOGROUP
* System message generated when a group is being added
* to a group.
*/
typedef struct _DPMSG_ADDGROUPTOGROUP
{
DWORD dwType; // Message type
DPID dpIdParentGroup; // group ID being added to
DPID dpIdGroup; // group ID being added
} DPMSG_ADDGROUPTOGROUP;
typedef DPMSG_ADDGROUPTOGROUP *LPDPMSG_ADDGROUPTOGROUP;
/*
* DPMSG_DELETEGROUPFROMGROUP
* System message generated when a GROUP is being
* removed from a group
*/
typedef DPMSG_ADDGROUPTOGROUP DPMSG_DELETEGROUPFROMGROUP;
typedef DPMSG_DELETEGROUPFROMGROUP *LPDPMSG_DELETEGROUPFROMGROUP;
/*
* DPMSG_SETPLAYERORGROUPDATA
* System message generated when remote data for a player or
* group has changed.
*/
typedef struct _DPMSG_SETPLAYERORGROUPDATA
{
DWORD dwType; // Message type
DWORD dwPlayerType; // Is it a player or group
DPID dpId; // ID of player or group
LPVOID lpData; // pointer to remote data
DWORD dwDataSize; // size of remote data
} DPMSG_SETPLAYERORGROUPDATA;
typedef DPMSG_SETPLAYERORGROUPDATA *LPDPMSG_SETPLAYERORGROUPDATA;
/*
* DPMSG_SETPLAYERORGROUPNAME
* System message generated when the name of a player or
* group has changed.
*/
typedef struct _DPMSG_SETPLAYERORGROUPNAME
{
DWORD dwType; // Message type
DWORD dwPlayerType; // Is it a player or group
DPID dpId; // ID of player or group
DPNAME dpnName; // structure with new name info
} DPMSG_SETPLAYERORGROUPNAME;
typedef DPMSG_SETPLAYERORGROUPNAME *LPDPMSG_SETPLAYERORGROUPNAME;
/*
* DPMSG_SETSESSIONDESC
* System message generated when session desc has changed
*/
typedef struct _DPMSG_SETSESSIONDESC
{
DWORD dwType; // Message type
DPSESSIONDESC2 dpDesc; // Session desc
} DPMSG_SETSESSIONDESC;
typedef DPMSG_SETSESSIONDESC *LPDPMSG_SETSESSIONDESC;
/*
* DPMSG_HOST
* System message generated when the host has migrated to this
* DirectPlay object.
*
*/
typedef DPMSG_GENERIC DPMSG_HOST;
typedef DPMSG_HOST *LPDPMSG_HOST;
/*
* DPMSG_SESSIONLOST
* System message generated when the connection to the session is lost.
*
*/
typedef DPMSG_GENERIC DPMSG_SESSIONLOST;
typedef DPMSG_SESSIONLOST *LPDPMSG_SESSIONLOST;
/*
* DPMSG_SECUREMESSAGE
* System message generated when a player requests a secure send
*/
typedef struct _DPMSG_SECUREMESSAGE
{
DWORD dwType; // Message Type
DWORD dwFlags; // Signed/Encrypted
DPID dpIdFrom; // ID of Sending Player
LPVOID lpData; // Player message
DWORD dwDataSize; // Size of player message
} DPMSG_SECUREMESSAGE;
typedef DPMSG_SECUREMESSAGE *LPDPMSG_SECUREMESSAGE;
/*
* DPMSG_STARTSESSION
* System message containing all information required to
* start a new session
*/
typedef struct _DPMSG_STARTSESSION
{
DWORD dwType; // Message type
LPDPLCONNECTION lpConn; // DPLCONNECTION structure
} DPMSG_STARTSESSION;
typedef DPMSG_STARTSESSION *LPDPMSG_STARTSESSION;
/*
* DPMSG_CHAT
* System message containing a chat message
*/
typedef struct _DPMSG_CHAT
{
DWORD dwType; // Message type
DWORD dwFlags; // Message flags
DPID idFromPlayer; // ID of the Sending Player
DPID idToPlayer; // ID of the To Player
DPID idToGroup; // ID of the To Group
LPDPCHAT lpChat; // Pointer to a structure containing the chat message
} DPMSG_CHAT;
typedef DPMSG_CHAT *LPDPMSG_CHAT;
/*
* DPMSG_SETGROUPOWNER
* System message generated when the owner of a group has changed
*/
typedef struct _DPMSG_SETGROUPOWNER
{
DWORD dwType; // Message type
DPID idGroup; // ID of the group
DPID idNewOwner; // ID of the player that is the new owner
DPID idOldOwner; // ID of the player that used to be the owner
} DPMSG_SETGROUPOWNER;
typedef DPMSG_SETGROUPOWNER *LPDPMSG_SETGROUPOWNER;
/*
* DPMSG_SENDCOMPLETE
* System message generated when finished with an Async Send message
*
* NOTE SENDPARMS has an overlay for DPMSG_SENDCOMPLETE, don't
* change this message w/o changing SENDPARMS.
*/
typedef struct _DPMSG_SENDCOMPLETE
{
DWORD dwType;
DPID idFrom;
DPID idTo;
DWORD dwFlags;
DWORD dwPriority;
DWORD dwTimeout;
LPVOID lpvContext;
DWORD dwMsgID;
DPRESULT hr;
DWORD dwSendTime;
} DPMSG_SENDCOMPLETE;
typedef DPMSG_SENDCOMPLETE *LPDPMSG_SENDCOMPLETE;
/****************************************************************************
*
* IDirectPlay2 (and IDirectPlay2A) Interface
*
****************************************************************************/
interface IDirectPlay2 : IUnknown
{
/*** IDirectPlay2 methods ***/
DPRESULT AddPlayerToGroup(DPID idGroup, DPID idPlayer );
DPRESULT Close();
DPRESULT CreateGroup( LPDPID lpidGroup, LPDPNAME lpGroupName, LPVOID lpData, DWORD dwDataSize, CreateGroupFlags dwFlags);
DPRESULT CreatePlayer( LPDPID lpidPlayer, LPDPNAME lpPlayerName, HANDLE hEvent, LPVOID lpData, DWORD dwDataSize, CreatePlayerFlags dwFlags);
DPRESULT DeletePlayerFromGroup(DPID idGroup, DPID idPlayer );
DPRESULT DestroyGroup( DPID idGroup);
DPRESULT DestroyPlayer( DPID idPlayer);
DPRESULT EnumGroupPlayers( DPID idGroup, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags);
DPRESULT EnumGroups( LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, DWORD dwFlags );
DPRESULT EnumPlayers(LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, EnumPlayersMask dwFlags);
DPRESULT EnumSessions(LPDPSESSIONDESC2 lpsd, DWORD dwTimeout, LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2, LPVOID lpContext, EnumSessionsFlags dwFlags );
DPRESULT GetCaps( [out] LPDPCAPS lpDPCaps, GetCapsFlags dwFlags);
DPRESULT GetGroupData( DPID idGroup, [out] LPVOID lpData, [out] LPDWORD lpdwDataSize, GetDataFlags dwFlags);
DPRESULT GetGroupName( DPID idGroup, [out] LPVOID lpData, [out] LPDWORD lpdwDataSize);
DPRESULT GetMessageCount( DPID idPlayer, [out] LPDWORD lpdwCount );
DPRESULT GetPlayerAddress( DPID idPlayer, [out] LPVOID lpData, [out] LPDWORD lpdwDataSize );
DPRESULT GetPlayerCaps( DPID idPlayer, [out] LPDPCAPS lpPlayerCaps , GetCapsFlags dwFlags);
DPRESULT GetPlayerData( DPID idPlayerD, [out] LPVOID lpData, [out] LPDWORD lpdwDataSize, GetDataFlags dwFlags);
DPRESULT GetPlayerName( DPID idPlayerD, [out] LPVOID lpData, [out] LPDWORD lpdwDataSize );
DPRESULT GetSessionDesc( [out] LPVOID lpData, [out] LPDWORD lpdwDataSize );
DPRESULT Initialize( LPGUID lpGUID );
DPRESULT Open( LPDPSESSIONDESC2 lpsd , OpenFlags dwFlags);
DPRESULT Receive( LPDPID lpidFrom, LPDPID lpidTo, ReceiveFlags dwFlags, [out] LPVOID lpData, [out] LPDWORD lpdwDataSize );
DPRESULT Send( DPID idFrom, DPID idTo, SendFlags dwFlags, LPVOID lpData, DWORD dwDataSize);
DPRESULT SetGroupData( DPID idGroup, LPVOID lpData, DWORD dwDataSize, SetDataFlags dwFlags);
DPRESULT SetGroupName( DPID idGroup, LPDPNAME lpGroupName, SetDataFlags dwFlags);
DPRESULT SetPlayerData( DPID idPlayer, LPVOID lpData, DWORD dwDataSize, SetDataFlags dwFlags);
DPRESULT SetPlayerName( DPID idPlayer, LPDPNAME lpPlayerName, SetDataFlags dwFlags);
DPRESULT SetSessionDesc( LPDPSESSIONDESC2 lpSessDesc , SetDataFlags dwFlags);
};
/****************************************************************************
*
* IDirectPlay3 (and IDirectPlay3A) Interface
*
****************************************************************************/
interface IDirectPlay3 : IDirectPlay2
{
/*** IDirectPlay3 methods ***/
DPRESULT AddGroupToGroup(DPID idParentGroup, DPID idGroup);
DPRESULT CreateGroupInGroup(DPID idParentGroup , LPDPID lpidGroup , LPDPNAME lpGroupName , LPVOID lpData, DWORD dwDataSize, CreateGroupFlags dwFlags);
DPRESULT DeleteGroupFromGroup(DPID idParentGroup, DPID idGroup);
DPRESULT EnumConnections( LPCGUID lpguidApplication, LPDPENUMCONNECTIONSCALLBACK lpEnumCallback, LPVOID lpContext, EnumConnectionsFlags dwFlags);
DPRESULT EnumGroupsInGroup( DPID idGroup, LPGUID lpguidInstance, LPDPENUMPLAYERSCALLBACK2 lpEnumPlayersCallback2, LPVOID lpContext, EnumPlayersMask dwFlags);
DPRESULT GetGroupConnectionSettings(DWORD dwFlags, DPID idGroup, [out] LPVOID lpData, [out] LPDWORD dwDataSize);
DPRESULT InitializeConnection(LPVOID lpData, DWORD dwDataSize);
DPRESULT SecureOpen(LPCDPSESSIONDESC2 lpsd, DWORD dwFlags, LPCDPSECURITYDESC lpSecurity, LPCDPCREDENTIALS lpCredentials);
DPRESULT SendChatMessage(DPID idFrom, DPID idTo, SendFlags dwFlags, LPDPCHAT lpChatMessage );
DPRESULT SetGroupConnectionSettings(DWORD dwFlags, DPID idGroup, LPDPLCONNECTION lpConnection );
DPRESULT StartSession(DWORD dwFlags, DPID idGroup );
DPRESULT GetGroupFlags(DPID idGroup, [out] CreateGroupFlags * lpdwFlags );
DPRESULT GetGroupParent(DPID idGroup, [out] LPDPID lpidParentGroup);
DPRESULT GetPlayerAccount(DPID idPlayer, DWORD dwFlags, [out] LPVOID lpData , [out] LPDWORD lpdwDataSize );
DPRESULT GetPlayerFlags(DPID idPlayer, [out] LPDWORD lpdwDataSize );
};
interface IDirectPlay4 : IDirectPlay3
{
/*** IDirectPlay4 methods ***/
DPRESULT GetGroupOwner( DPID idGroup, [out] LPDPID lpidOwner );
DPRESULT SetGroupOwner(DPID idGroup, DPID idOwner);
DPRESULT SendEx( DPID idFrom, DPID idTo, SendFlags dwFlags, LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout, LPVOID lpContext, LPDWORD lpdwMsgID );
DPRESULT GetMessageQueue(DPID idFrom, DPID idTo, GetMessageQueueFlags dwFlags, [out] LPDWORD lpdwNumMsgs, [out] LPDWORD lpdwNumBytes );
DPRESULT CancelMessage( DWORD dwMsgID, DWORD dwFlags );
DPRESULT CancelPriority( DWORD dwMinPriority, DWORD dwMaxPriority, DWORD dwFlags );
};
/*
* API's
*/
DPRESULT DirectPlayEnumerateA( LPDPENUMDPCALLBACKA lpCallback, LPVOID lpContext );
DPRESULT DirectPlayEnumerateW( LPDPENUMDPCALLBACK lpCallback, LPVOID lpContext);
DPRESULT DirectPlayCreate( LPGUID lpGUID, [out] LPDIRECTPLAY *lplpDP, IUnknown *pUnk);
HRESULT DllGetClassObject(
REFCLSID rclsid, //CLSID for the class object
[iid] REFIID riid, //Reference to the identifier of the interface
// that communicates with the class object
[out] COM_INTERFACE_PTR * ppv //Address of output variable that receives the
// interface pointer requested in riid
);
| 31.12366 | 170 | 0.6502 |
d21a00cfdd9c208e9fd667bc1f57d4905e6a21ed | 16,528 | c | C | lib/conncache.c | shikibu-z/curl-serialize | e72f97652df83db9fe4b48fc6a8d2bee4f4bf2d4 | [
"curl"
] | 12 | 2016-10-04T11:36:23.000Z | 2021-04-29T00:15:18.000Z | lib/conncache.c | taihao1125/curl | da3e0f406a8f68db9f7520cb1a611d45313fe48e | [
"curl"
] | 20 | 2016-10-04T11:17:00.000Z | 2017-11-16T03:19:14.000Z | lib/conncache.c | taihao1125/curl | da3e0f406a8f68db9f7520cb1a611d45313fe48e | [
"curl"
] | 7 | 2016-12-14T09:56:11.000Z | 2020-01-07T12:25:34.000Z | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <linus@haxx.se>
* Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curl_setup.h"
#include <curl/curl.h>
#include "urldata.h"
#include "url.h"
#include "progress.h"
#include "multiif.h"
#include "sendf.h"
#include "conncache.h"
#include "share.h"
#include "sigpipe.h"
#include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
#define HASHKEY_SIZE 128
static void conn_llist_dtor(void *user, void *element)
{
struct connectdata *conn = element;
(void)user;
conn->bundle = NULL;
}
static CURLcode bundle_create(struct connectbundle **bundlep)
{
DEBUGASSERT(*bundlep == NULL);
*bundlep = malloc(sizeof(struct connectbundle));
if(!*bundlep)
return CURLE_OUT_OF_MEMORY;
(*bundlep)->num_connections = 0;
(*bundlep)->multiuse = BUNDLE_UNKNOWN;
Curl_llist_init(&(*bundlep)->conn_list, (curl_llist_dtor) conn_llist_dtor);
return CURLE_OK;
}
static void bundle_destroy(struct connectbundle *bundle)
{
if(!bundle)
return;
Curl_llist_destroy(&bundle->conn_list, NULL);
free(bundle);
}
/* Add a connection to a bundle */
static void bundle_add_conn(struct connectbundle *bundle,
struct connectdata *conn)
{
Curl_llist_insert_next(&bundle->conn_list, bundle->conn_list.tail, conn,
&conn->bundle_node);
conn->bundle = bundle;
bundle->num_connections++;
}
/* Remove a connection from a bundle */
static int bundle_remove_conn(struct connectbundle *bundle,
struct connectdata *conn)
{
struct curl_llist_element *curr;
curr = bundle->conn_list.head;
while(curr) {
if(curr->ptr == conn) {
Curl_llist_remove(&bundle->conn_list, curr, NULL);
bundle->num_connections--;
conn->bundle = NULL;
return 1; /* we removed a handle */
}
curr = curr->next;
}
DEBUGASSERT(0);
return 0;
}
static void free_bundle_hash_entry(void *freethis)
{
struct connectbundle *b = (struct connectbundle *) freethis;
bundle_destroy(b);
}
int Curl_conncache_init(struct conncache *connc, int size)
{
int rc;
/* allocate a new easy handle to use when closing cached connections */
connc->closure_handle = curl_easy_init();
if(!connc->closure_handle)
return 1; /* bad */
rc = Curl_hash_init(&connc->hash, size, Curl_hash_str,
Curl_str_key_compare, free_bundle_hash_entry);
if(rc)
Curl_close(&connc->closure_handle);
else
connc->closure_handle->state.conn_cache = connc;
return rc;
}
void Curl_conncache_destroy(struct conncache *connc)
{
if(connc)
Curl_hash_destroy(&connc->hash);
}
/* creates a key to find a bundle for this connection */
static void hashkey(struct connectdata *conn, char *buf,
size_t len, /* something like 128 is fine */
const char **hostp)
{
const char *hostname;
long port = conn->remote_port;
#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
hostname = conn->http_proxy.host.name;
port = conn->port;
}
else
#endif
if(conn->bits.conn_to_host)
hostname = conn->conn_to_host.name;
else
hostname = conn->host.name;
if(hostp)
/* report back which name we used */
*hostp = hostname;
/* put the number first so that the hostname gets cut off if too long */
msnprintf(buf, len, "%ld%s", port, hostname);
}
/* Returns number of connections currently held in the connection cache.
Locks/unlocks the cache itself!
*/
size_t Curl_conncache_size(struct Curl_easy *data)
{
size_t num;
CONNCACHE_LOCK(data);
num = data->state.conn_cache->num_conn;
CONNCACHE_UNLOCK(data);
return num;
}
/* Look up the bundle with all the connections to the same host this
connectdata struct is setup to use.
**NOTE**: When it returns, it holds the connection cache lock! */
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
struct conncache *connc,
const char **hostp)
{
struct connectbundle *bundle = NULL;
CONNCACHE_LOCK(conn->data);
if(connc) {
char key[HASHKEY_SIZE];
hashkey(conn, key, sizeof(key), hostp);
bundle = Curl_hash_pick(&connc->hash, key, strlen(key));
}
return bundle;
}
static bool conncache_add_bundle(struct conncache *connc,
char *key,
struct connectbundle *bundle)
{
void *p = Curl_hash_add(&connc->hash, key, strlen(key), bundle);
return p?TRUE:FALSE;
}
static void conncache_remove_bundle(struct conncache *connc,
struct connectbundle *bundle)
{
struct curl_hash_iterator iter;
struct curl_hash_element *he;
if(!connc)
return;
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
if(he->ptr == bundle) {
/* The bundle is destroyed by the hash destructor function,
free_bundle_hash_entry() */
Curl_hash_delete(&connc->hash, he->key, he->key_len);
return;
}
he = Curl_hash_next_element(&iter);
}
}
CURLcode Curl_conncache_add_conn(struct conncache *connc,
struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct connectbundle *bundle = NULL;
struct Curl_easy *data = conn->data;
/* *find_bundle() locks the connection cache */
bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache, NULL);
if(!bundle) {
int rc;
char key[HASHKEY_SIZE];
result = bundle_create(&bundle);
if(result) {
goto unlock;
}
hashkey(conn, key, sizeof(key), NULL);
rc = conncache_add_bundle(data->state.conn_cache, key, bundle);
if(!rc) {
bundle_destroy(bundle);
result = CURLE_OUT_OF_MEMORY;
goto unlock;
}
}
bundle_add_conn(bundle, conn);
conn->connection_id = connc->next_connection_id++;
connc->num_conn++;
DEBUGF(infof(conn->data, "Added connection %ld. "
"The cache now contains %zu members\n",
conn->connection_id, connc->num_conn));
unlock:
CONNCACHE_UNLOCK(data);
return result;
}
/*
* Removes the connectdata object from the connection cache, but does *not*
* clear the conn->data association. The transfer still owns this connection.
*
* Pass TRUE/FALSE in the 'lock' argument depending on if the parent function
* already holds the lock or not.
*/
void Curl_conncache_remove_conn(struct Curl_easy *data,
struct connectdata *conn, bool lock)
{
struct connectbundle *bundle = conn->bundle;
struct conncache *connc = data->state.conn_cache;
/* The bundle pointer can be NULL, since this function can be called
due to a failed connection attempt, before being added to a bundle */
if(bundle) {
if(lock) {
CONNCACHE_LOCK(data);
}
bundle_remove_conn(bundle, conn);
if(bundle->num_connections == 0)
conncache_remove_bundle(connc, bundle);
conn->bundle = NULL; /* removed from it */
if(connc) {
connc->num_conn--;
DEBUGF(infof(data, "The cache now contains %zu members\n",
connc->num_conn));
}
if(lock) {
CONNCACHE_UNLOCK(data);
}
}
}
/* This function iterates the entire connection cache and calls the function
func() with the connection pointer as the first argument and the supplied
'param' argument as the other.
The conncache lock is still held when the callback is called. It needs it,
so that it can safely continue traversing the lists once the callback
returns.
Returns 1 if the loop was aborted due to the callback's return code.
Return 0 from func() to continue the loop, return 1 to abort it.
*/
bool Curl_conncache_foreach(struct Curl_easy *data,
struct conncache *connc,
void *param,
int (*func)(struct connectdata *conn, void *param))
{
struct curl_hash_iterator iter;
struct curl_llist_element *curr;
struct curl_hash_element *he;
if(!connc)
return FALSE;
CONNCACHE_LOCK(data);
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
struct connectbundle *bundle;
bundle = he->ptr;
he = Curl_hash_next_element(&iter);
curr = bundle->conn_list.head;
while(curr) {
/* Yes, we need to update curr before calling func(), because func()
might decide to remove the connection */
struct connectdata *conn = curr->ptr;
curr = curr->next;
if(1 == func(conn, param)) {
CONNCACHE_UNLOCK(data);
return TRUE;
}
}
}
CONNCACHE_UNLOCK(data);
return FALSE;
}
/* Return the first connection found in the cache. Used when closing all
connections.
NOTE: no locking is done here as this is presumably only done when cleaning
up a cache!
*/
static struct connectdata *
conncache_find_first_connection(struct conncache *connc)
{
struct curl_hash_iterator iter;
struct curl_hash_element *he;
struct connectbundle *bundle;
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
struct curl_llist_element *curr;
bundle = he->ptr;
curr = bundle->conn_list.head;
if(curr) {
return curr->ptr;
}
he = Curl_hash_next_element(&iter);
}
return NULL;
}
/*
* Give ownership of a connection back to the connection cache. Might
* disconnect the oldest existing in there to make space.
*
* Return TRUE if stored, FALSE if closed.
*/
bool Curl_conncache_return_conn(struct Curl_easy *data,
struct connectdata *conn)
{
/* data->multi->maxconnects can be negative, deal with it. */
size_t maxconnects =
(data->multi->maxconnects < 0) ? data->multi->num_easy * 4:
data->multi->maxconnects;
struct connectdata *conn_candidate = NULL;
conn->lastused = Curl_now(); /* it was used up until now */
if(maxconnects > 0 &&
Curl_conncache_size(data) > maxconnects) {
infof(data, "Connection cache is full, closing the oldest one.\n");
conn_candidate = Curl_conncache_extract_oldest(data);
if(conn_candidate) {
/* the winner gets the honour of being disconnected */
(void)Curl_disconnect(data, conn_candidate, /* dead_connection */ FALSE);
}
}
return (conn_candidate == conn) ? FALSE : TRUE;
}
/*
* This function finds the connection in the connection bundle that has been
* unused for the longest time.
*
* Does not lock the connection cache!
*
* Returns the pointer to the oldest idle connection, or NULL if none was
* found.
*/
struct connectdata *
Curl_conncache_extract_bundle(struct Curl_easy *data,
struct connectbundle *bundle)
{
struct curl_llist_element *curr;
timediff_t highscore = -1;
timediff_t score;
struct curltime now;
struct connectdata *conn_candidate = NULL;
struct connectdata *conn;
(void)data;
now = Curl_now();
curr = bundle->conn_list.head;
while(curr) {
conn = curr->ptr;
if(!CONN_INUSE(conn) && !conn->data) {
/* Set higher score for the age passed since the connection was used */
score = Curl_timediff(now, conn->lastused);
if(score > highscore) {
highscore = score;
conn_candidate = conn;
}
}
curr = curr->next;
}
if(conn_candidate) {
/* remove it to prevent another thread from nicking it */
bundle_remove_conn(bundle, conn_candidate);
data->state.conn_cache->num_conn--;
DEBUGF(infof(data, "The cache now contains %zu members\n",
data->state.conn_cache->num_conn));
conn_candidate->data = data; /* associate! */
}
return conn_candidate;
}
/*
* This function finds the connection in the connection cache that has been
* unused for the longest time and extracts that from the bundle.
*
* Returns the pointer to the connection, or NULL if none was found.
*/
struct connectdata *
Curl_conncache_extract_oldest(struct Curl_easy *data)
{
struct conncache *connc = data->state.conn_cache;
struct curl_hash_iterator iter;
struct curl_llist_element *curr;
struct curl_hash_element *he;
timediff_t highscore =- 1;
timediff_t score;
struct curltime now;
struct connectdata *conn_candidate = NULL;
struct connectbundle *bundle;
struct connectbundle *bundle_candidate = NULL;
now = Curl_now();
CONNCACHE_LOCK(data);
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
struct connectdata *conn;
bundle = he->ptr;
curr = bundle->conn_list.head;
while(curr) {
conn = curr->ptr;
if(!CONN_INUSE(conn) && !conn->data && !conn->bits.close &&
!conn->bits.connect_only) {
/* Set higher score for the age passed since the connection was used */
score = Curl_timediff(now, conn->lastused);
if(score > highscore) {
highscore = score;
conn_candidate = conn;
bundle_candidate = bundle;
}
}
curr = curr->next;
}
he = Curl_hash_next_element(&iter);
}
if(conn_candidate) {
/* remove it to prevent another thread from nicking it */
bundle_remove_conn(bundle_candidate, conn_candidate);
connc->num_conn--;
DEBUGF(infof(data, "The cache now contains %zu members\n",
connc->num_conn));
conn_candidate->data = data; /* associate! */
}
CONNCACHE_UNLOCK(data);
return conn_candidate;
}
void Curl_conncache_close_all_connections(struct conncache *connc)
{
struct connectdata *conn;
char buffer[READBUFFER_MIN + 1];
if(!connc->closure_handle)
return;
connc->closure_handle->state.buffer = buffer;
connc->closure_handle->set.buffer_size = READBUFFER_MIN;
conn = conncache_find_first_connection(connc);
while(conn) {
SIGPIPE_VARIABLE(pipe_st);
conn->data = connc->closure_handle;
sigpipe_ignore(conn->data, &pipe_st);
/* This will remove the connection from the cache */
connclose(conn, "kill all");
Curl_conncache_remove_conn(conn->data, conn, TRUE);
(void)Curl_disconnect(connc->closure_handle, conn, FALSE);
sigpipe_restore(&pipe_st);
conn = conncache_find_first_connection(connc);
}
connc->closure_handle->state.buffer = NULL;
if(connc->closure_handle) {
SIGPIPE_VARIABLE(pipe_st);
sigpipe_ignore(connc->closure_handle, &pipe_st);
Curl_hostcache_clean(connc->closure_handle,
connc->closure_handle->dns.hostcache);
Curl_close(&connc->closure_handle);
sigpipe_restore(&pipe_st);
}
}
#if 0
/* Useful for debugging the connection cache */
void Curl_conncache_print(struct conncache *connc)
{
struct curl_hash_iterator iter;
struct curl_llist_element *curr;
struct curl_hash_element *he;
if(!connc)
return;
fprintf(stderr, "=Bundle cache=\n");
Curl_hash_start_iterate(connc->hash, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
struct connectbundle *bundle;
struct connectdata *conn;
bundle = he->ptr;
fprintf(stderr, "%s -", he->key);
curr = bundle->conn_list->head;
while(curr) {
conn = curr->ptr;
fprintf(stderr, " [%p %d]", (void *)conn, conn->inuse);
curr = curr->next;
}
fprintf(stderr, "\n");
he = Curl_hash_next_element(&iter);
}
}
#endif
| 27.273927 | 79 | 0.651258 |
cf9de5b48522fa9f62feb041b50dca60b107ad68 | 994 | h | C | System/Library/PrivateFrameworks/TVRemoteUI.framework/TVRStandardTouchProcessor.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | System/Library/PrivateFrameworks/TVRemoteUI.framework/TVRStandardTouchProcessor.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/TVRemoteUI.framework/TVRStandardTouchProcessor.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, September 27, 2020 at 12:26:45 PM Mountain Standard Time
* Operating System: Version 14.0 (Build 18A373)
* Image Source: /System/Library/PrivateFrameworks/TVRemoteUI.framework/TVRemoteUI
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <TVRemoteUI/TVRemoteUI-Structs.h>
#import <TVRemoteUI/TVRTouchProcessor.h>
@class UITapGestureRecognizer, NSTimer;
@interface TVRStandardTouchProcessor : TVRTouchProcessor {
long long _clickVirtualizerState;
CGPoint _touchBeganLocation;
UITapGestureRecognizer* _tapGestureRecognizer;
NSTimer* _clickVirtualizerTimer;
}
-(void)_tap:(id)arg1 ;
-(void)touchesEnded:(id)arg1 withEvent:(id)arg2 ;
-(void)touchesCancelled:(id)arg1 withEvent:(id)arg2 ;
-(void)touchesMoved:(id)arg1 withEvent:(id)arg2 ;
-(void)touchesBegan:(id)arg1 withEvent:(id)arg2 ;
-(void)setTouchpadView:(id)arg1 ;
-(void)_touchpadClickVirtualizerTimerFired:(id)arg1 ;
@end
| 32.064516 | 81 | 0.785714 |
9a5d4f36f7fa6c1b675d0a9dd78fd9f49b02fc3e | 3,588 | h | C | aws-cpp-sdk-greengrassv2/include/aws/greengrassv2/model/BatchDisassociateClientDeviceFromCoreDeviceResult.h | blinemedical/aws-sdk-cpp | c7c814b2d6862b4cb48f3fb3ac083a9e419674e8 | [
"Apache-2.0"
] | 1 | 2021-12-06T20:36:35.000Z | 2021-12-06T20:36:35.000Z | aws-cpp-sdk-greengrassv2/include/aws/greengrassv2/model/BatchDisassociateClientDeviceFromCoreDeviceResult.h | blinemedical/aws-sdk-cpp | c7c814b2d6862b4cb48f3fb3ac083a9e419674e8 | [
"Apache-2.0"
] | 1 | 2022-01-03T23:59:37.000Z | 2022-01-03T23:59:37.000Z | aws-cpp-sdk-greengrassv2/include/aws/greengrassv2/model/BatchDisassociateClientDeviceFromCoreDeviceResult.h | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 1 | 2021-12-30T04:25:33.000Z | 2021-12-30T04:25:33.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/greengrassv2/GreengrassV2_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/greengrassv2/model/DisassociateClientDeviceFromCoreDeviceErrorEntry.h>
#include <utility>
namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;
namespace Utils
{
namespace Json
{
class JsonValue;
} // namespace Json
} // namespace Utils
namespace GreengrassV2
{
namespace Model
{
class AWS_GREENGRASSV2_API BatchDisassociateClientDeviceFromCoreDeviceResult
{
public:
BatchDisassociateClientDeviceFromCoreDeviceResult();
BatchDisassociateClientDeviceFromCoreDeviceResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
BatchDisassociateClientDeviceFromCoreDeviceResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
/**
* <p>The list of errors (if any) for the entries in the request. Each error entry
* contains the name of the IoT thing that failed to disassociate.</p>
*/
inline const Aws::Vector<DisassociateClientDeviceFromCoreDeviceErrorEntry>& GetErrorEntries() const{ return m_errorEntries; }
/**
* <p>The list of errors (if any) for the entries in the request. Each error entry
* contains the name of the IoT thing that failed to disassociate.</p>
*/
inline void SetErrorEntries(const Aws::Vector<DisassociateClientDeviceFromCoreDeviceErrorEntry>& value) { m_errorEntries = value; }
/**
* <p>The list of errors (if any) for the entries in the request. Each error entry
* contains the name of the IoT thing that failed to disassociate.</p>
*/
inline void SetErrorEntries(Aws::Vector<DisassociateClientDeviceFromCoreDeviceErrorEntry>&& value) { m_errorEntries = std::move(value); }
/**
* <p>The list of errors (if any) for the entries in the request. Each error entry
* contains the name of the IoT thing that failed to disassociate.</p>
*/
inline BatchDisassociateClientDeviceFromCoreDeviceResult& WithErrorEntries(const Aws::Vector<DisassociateClientDeviceFromCoreDeviceErrorEntry>& value) { SetErrorEntries(value); return *this;}
/**
* <p>The list of errors (if any) for the entries in the request. Each error entry
* contains the name of the IoT thing that failed to disassociate.</p>
*/
inline BatchDisassociateClientDeviceFromCoreDeviceResult& WithErrorEntries(Aws::Vector<DisassociateClientDeviceFromCoreDeviceErrorEntry>&& value) { SetErrorEntries(std::move(value)); return *this;}
/**
* <p>The list of errors (if any) for the entries in the request. Each error entry
* contains the name of the IoT thing that failed to disassociate.</p>
*/
inline BatchDisassociateClientDeviceFromCoreDeviceResult& AddErrorEntries(const DisassociateClientDeviceFromCoreDeviceErrorEntry& value) { m_errorEntries.push_back(value); return *this; }
/**
* <p>The list of errors (if any) for the entries in the request. Each error entry
* contains the name of the IoT thing that failed to disassociate.</p>
*/
inline BatchDisassociateClientDeviceFromCoreDeviceResult& AddErrorEntries(DisassociateClientDeviceFromCoreDeviceErrorEntry&& value) { m_errorEntries.push_back(std::move(value)); return *this; }
private:
Aws::Vector<DisassociateClientDeviceFromCoreDeviceErrorEntry> m_errorEntries;
};
} // namespace Model
} // namespace GreengrassV2
} // namespace Aws
| 41.72093 | 201 | 0.752787 |
c9070a264597cf0ffe3bd72824b232207ef0e23b | 1,413 | h | C | FuegoUniversalComponent/fuego/gouct/GoUctAdditiveKnowledgeFuego.h | GSMgeeth/gameofgo | 51563fea15fbdca797afb7cf9a29773a313e5697 | [
"Apache-2.0"
] | 13 | 2016-09-09T13:45:42.000Z | 2021-12-17T08:42:28.000Z | FuegoUniversalComponent/fuego/gouct/GoUctAdditiveKnowledgeFuego.h | GSMgeeth/gameofgo | 51563fea15fbdca797afb7cf9a29773a313e5697 | [
"Apache-2.0"
] | 1 | 2016-06-18T05:19:58.000Z | 2016-09-15T18:21:54.000Z | FuegoUniversalComponent/fuego/gouct/GoUctAdditiveKnowledgeFuego.h | cbordeman/gameofgo | 51563fea15fbdca797afb7cf9a29773a313e5697 | [
"Apache-2.0"
] | 5 | 2016-11-19T03:05:12.000Z | 2022-01-31T12:20:40.000Z | //----------------------------------------------------------------------------
/** @file GoUctAdditiveKnowledgeFuego.h
A simple implementation of additive knowledge using RAVE values.
@todo some details.
*/
//----------------------------------------------------------------------------
#ifndef GOUCT_ADDITIVEKNOWLEDGEFUEGO_H
#define GOUCT_ADDITIVEKNOWLEDGEFUEGO_H
#include "GoUctAdditiveKnowledge.h"
#include "GoUctPlayoutPolicy.h"
//----------------------------------------------------------------------------
const float VALUE_MULTIPLIER = 4.0f;
class GoUctAdditiveKnowledgeFuego
: public GoUctAdditiveKnowledge
{
public:
GoUctAdditiveKnowledgeFuego(const GoBoard& bd);
/** The minimum value allowed by this predictor */
SgUctValue Minimum() const;
bool ProbabilityBased() const;
void ProcessPosition(std::vector<SgUctMoveInfo>& moves);
/** The scaling factor for this predictor */
SgUctValue Scale() const;
};
//----------------------------------------------------------------------------
inline SgUctValue GoUctAdditiveKnowledgeFuego::Minimum() const
{
return 0.0001f;
}
inline bool GoUctAdditiveKnowledgeFuego::ProbabilityBased() const
{
return true;
}
inline SgUctValue GoUctAdditiveKnowledgeFuego::Scale() const
{
return 0.03f;
}
//----------------------------------------------------------------------------
#endif // GOUCT_ADDITIVEKNOWLEDGEFUEGO_H
| 25.232143 | 78 | 0.552725 |
c56ac47cd3189779333acc9e8da89a8f9ad7c5be | 5,162 | c | C | drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | 27 | 2021-10-04T18:56:52.000Z | 2022-03-28T08:23:06.000Z | drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | 1 | 2022-01-12T04:05:36.000Z | 2022-01-16T15:48:42.000Z | drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | fergy/aplit_linux-5 | a6ef4cb0e17e1eec9743c064e65f730c49765711 | [
"MIT"
] | 3 | 2022-01-09T07:53:43.000Z | 2022-03-01T18:33:58.000Z | /*
* Copyright 2014 Advanced Micro Devices, 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.
*/
/*
* KFD Interrupts.
*
* AMD GPUs deliver interrupts by pushing an interrupt description onto the
* interrupt ring and then sending an interrupt. KGD receives the interrupt
* in ISR and sends us a pointer to each new entry on the interrupt ring.
*
* We generally can't process interrupt-signaled events from ISR, so we call
* out to each interrupt client module (currently only the scheduler) to ask if
* each interrupt is interesting. If they return true, then it requires further
* processing so we copy it to an internal interrupt ring and call each
* interrupt client again from a work-queue.
*
* There's no acknowledgment for the interrupts we use. The hardware simply
* queues a new interrupt each time without waiting.
*
* The fixed-size internal queue means that it's possible for us to lose
* interrupts because we have no back-pressure to the hardware.
*/
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/kfifo.h>
#include "kfd_priv.h"
#define KFD_IH_NUM_ENTRIES 8192
static void interrupt_wq(struct work_struct *);
int kfd_interrupt_init(struct kfd_dev *kfd)
{
int r;
r = kfifo_alloc(&kfd->ih_fifo,
KFD_IH_NUM_ENTRIES * kfd->device_info->ih_ring_entry_size,
GFP_KERNEL);
if (r) {
dev_err(kfd_chardev(), "Failed to allocate IH fifo\n");
return r;
}
kfd->ih_wq = alloc_workqueue("KFD IH", WQ_HIGHPRI, 1);
spin_lock_init(&kfd->interrupt_lock);
INIT_WORK(&kfd->interrupt_work, interrupt_wq);
kfd->interrupts_active = true;
/*
* After this function returns, the interrupt will be enabled. This
* barrier ensures that the interrupt running on a different processor
* sees all the above writes.
*/
smp_wmb();
return 0;
}
void kfd_interrupt_exit(struct kfd_dev *kfd)
{
/*
* Stop the interrupt handler from writing to the ring and scheduling
* workqueue items. The spinlock ensures that any interrupt running
* after we have unlocked sees interrupts_active = false.
*/
unsigned long flags;
spin_lock_irqsave(&kfd->interrupt_lock, flags);
kfd->interrupts_active = false;
spin_unlock_irqrestore(&kfd->interrupt_lock, flags);
/*
* flush_work ensures that there are no outstanding
* work-queue items that will access interrupt_ring. New work items
* can't be created because we stopped interrupt handling above.
*/
flush_workqueue(kfd->ih_wq);
kfifo_free(&kfd->ih_fifo);
}
/*
* Assumption: single reader/writer. This function is not re-entrant
*/
bool enqueue_ih_ring_entry(struct kfd_dev *kfd, const void *ih_ring_entry)
{
int count;
count = kfifo_in(&kfd->ih_fifo, ih_ring_entry,
kfd->device_info->ih_ring_entry_size);
if (count != kfd->device_info->ih_ring_entry_size) {
dev_err_ratelimited(kfd_chardev(),
"Interrupt ring overflow, dropping interrupt %d\n",
count);
return false;
}
return true;
}
/*
* Assumption: single reader/writer. This function is not re-entrant
*/
static bool dequeue_ih_ring_entry(struct kfd_dev *kfd, void *ih_ring_entry)
{
int count;
count = kfifo_out(&kfd->ih_fifo, ih_ring_entry,
kfd->device_info->ih_ring_entry_size);
WARN_ON(count && count != kfd->device_info->ih_ring_entry_size);
return count == kfd->device_info->ih_ring_entry_size;
}
static void interrupt_wq(struct work_struct *work)
{
struct kfd_dev *dev = container_of(work, struct kfd_dev,
interrupt_work);
uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE];
if (dev->device_info->ih_ring_entry_size > sizeof(ih_ring_entry)) {
dev_err_once(kfd_chardev(), "Ring entry too small\n");
return;
}
while (dequeue_ih_ring_entry(dev, ih_ring_entry))
dev->device_info->event_interrupt_class->interrupt_wq(dev,
ih_ring_entry);
}
bool interrupt_is_wanted(struct kfd_dev *dev,
const uint32_t *ih_ring_entry,
uint32_t *patched_ihre, bool *flag)
{
/* integer and bitwise OR so there is no boolean short-circuiting */
unsigned int wanted = 0;
wanted |= dev->device_info->event_interrupt_class->interrupt_isr(dev,
ih_ring_entry, patched_ihre, flag);
return wanted != 0;
}
| 31.096386 | 79 | 0.747966 |
c597b851c8a3b490f9ea82a3fb71778558e53ae7 | 1,847 | h | C | src/core/logging/grouplogger.h | karagog/gutil | 43936af9bc4be1945e4f1a3656e91dfbf42cc35b | [
"Apache-2.0"
] | null | null | null | src/core/logging/grouplogger.h | karagog/gutil | 43936af9bc4be1945e4f1a3656e91dfbf42cc35b | [
"Apache-2.0"
] | 2 | 2015-01-30T21:47:55.000Z | 2015-02-10T00:22:27.000Z | src/core/logging/grouplogger.h | karagog/gutil | 43936af9bc4be1945e4f1a3656e91dfbf42cc35b | [
"Apache-2.0"
] | null | null | null | /*Copyright 2010-2015 George Karagoulis
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 GUTIL_GROUPLOGGER_H
#define GUTIL_GROUPLOGGER_H
#include <gutil/ilog.h>
#include <gutil/vector.h>
#include <initializer_list>
NAMESPACE_GUTIL;
/** A logger class that logs to a group of loggers.
It owns all the logs in the group, and will delete them when finished.
*/
class GroupLogger : public ILog
{
Vector<ILog *> m_loggers;
public:
/** Constructs a null group logger that doesn't log to anything.
* Call AddLogger() to add a logger to the group.
*/
GroupLogger() {}
virtual ~GroupLogger(){ for(auto l : m_loggers) delete l; }
/** Constructs a group logger with the given set of loggers.
* \param n The number of loggers
*/
GroupLogger(std::initializer_list<ILog *> il)
:m_loggers(il.size()){
for(auto l : il)
AddLogger(l);
}
/** Log the message to all loggers in the group. */
virtual void Log(const LoggingData &d) noexcept{
for(auto &l : m_loggers) l->Log(d);
}
/** Adds a logger to the group.
This class takes ownership of the memory. There is no way to remove it
from the group. Would that ever be useful?
*/
inline void AddLogger(ILog *l){ m_loggers.PushBack(l); }
};
END_NAMESPACE_GUTIL;
#endif // GUTIL_GROUPLOGGER_H
| 27.984848 | 78 | 0.695723 |
cf8aed4f0857cd2b1e7eb83dbe91b03f9cf28ccf | 1,065 | h | C | TextRPG/src/UIManager.h | UniqueVN/TextRPG | 78c585a61692c8470145d755d2da3f1a3586af88 | [
"MIT",
"Unlicense"
] | 1 | 2021-03-12T09:47:20.000Z | 2021-03-12T09:47:20.000Z | TextRPG/src/UIManager.h | UniqueVN/TextRPG | 78c585a61692c8470145d755d2da3f1a3586af88 | [
"MIT",
"Unlicense"
] | null | null | null | TextRPG/src/UIManager.h | UniqueVN/TextRPG | 78c585a61692c8470145d755d2da3f1a3586af88 | [
"MIT",
"Unlicense"
] | null | null | null | // UIManager - manage the game's UI system: import, update ...
#pragma once
#include <map>
using namespace std;
#include "Singleton.h"
#include "UIComponent.h"
#include "UIScreen.h"
class UIManager : public Singleton<UIManager>
{
public:
friend class Singleton<UIManager>;
// Import the UI from an xml file
bool Import(const char* filePath);
// Update the UI screens/components
void Update(long period);
void Render();
bool HandleInput(); // Return true if the component handled the input, return false if not
// Create an UI component from a xml node
UIComponent* CreateComponent(const xml_node& xmlNode, UIComponent* parent = nullptr);
void CloseTopScreen();
bool ShowScreen(const string& screenID);
void RegisterScreen(UIScreen* newScreen);
protected:
UIManager(void);
~UIManager(void);
UIComponent* ConstructComponent(const char* type, UIComponent* parent = nullptr);
UIScreen* CurrentScreen; // Current screen that are showing on the screen
map<string, UIScreen*> Screens;
}; | 27.307692 | 94 | 0.70892 |
5ceb2668380fc9cc947b9c9c9af50f66577aab0b | 849 | h | C | SHScrollScreen/SHScrollScreenView.h | bill19/SHScrollScreen | 9bce922d24d3e005e1a779489fe34fbd9e0ac666 | [
"Apache-2.0"
] | null | null | null | SHScrollScreen/SHScrollScreenView.h | bill19/SHScrollScreen | 9bce922d24d3e005e1a779489fe34fbd9e0ac666 | [
"Apache-2.0"
] | null | null | null | SHScrollScreen/SHScrollScreenView.h | bill19/SHScrollScreen | 9bce922d24d3e005e1a779489fe34fbd9e0ac666 | [
"Apache-2.0"
] | null | null | null | //
// SHScrollScreenView.h
// SHScrollScreen
//
// Created by hao sun on 2022/3/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, SHScrollScreenViewScrollIndicatorDirection) {
//水平指示器
HorizontalScrollIndicator = 0,
///竖直指示器
VerticalScrollIndicator = 1,
};
@interface SHScrollScreenView : UIView
/// scrollview
@property (nonatomic, strong, readonly) UIScrollView *mainScrollView;
/// 配置控制器
/// @param controllers 控制器
- (void)configWithViewControllers:(NSArray <UIViewController *>*)controllers;
/// 配置UIView
/// @param views 页面
- (void)configWithViews:(NSArray <UIView *>*)views;
/// 设置当前展示的页面
/// @param page 页面
- (void)setCurrentPage:(NSInteger)page;
/// 指向方向 需要先设置再 配置数据源
@property (nonatomic, assign) SHScrollScreenViewScrollIndicatorDirection direction;
@end
NS_ASSUME_NONNULL_END
| 19.744186 | 83 | 0.742049 |
65c072ed0bcd55476fe8602097f1314256d895e8 | 12,681 | c | C | firmware/bluenodes_s132_sdk13_085_nrf52/Src/rbc_mesh/src/radio_control.c | codezork/BlueNodes | 6393fa5cbe8798f983eab6ca50afdfcf4050df29 | [
"Apache-2.0"
] | null | null | null | firmware/bluenodes_s132_sdk13_085_nrf52/Src/rbc_mesh/src/radio_control.c | codezork/BlueNodes | 6393fa5cbe8798f983eab6ca50afdfcf4050df29 | [
"Apache-2.0"
] | null | null | null | firmware/bluenodes_s132_sdk13_085_nrf52/Src/rbc_mesh/src/radio_control.c | codezork/BlueNodes | 6393fa5cbe8798f983eab6ca50afdfcf4050df29 | [
"Apache-2.0"
] | null | null | null | /***********************************************************************************
Copyright (c) Nordic Semiconductor ASA
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 Nordic Semiconductor ASA nor the names of other
contributors to this software 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.
************************************************************************************/
#include "radio_control.h"
#include "rbc_mesh_common.h"
#include "timeslot.h"
#include "trickle.h"
#include "fifo.h"
#include "nrf.h"
#include "nrf_sdm.h"
#include "app_error.h"
#include "toolchain.h"
#include "rbc_mesh.h"
#include "mesh_packet.h"
#include <stdbool.h>
#include <string.h>
/** The default access address the radio operates on. Represented as logical address 0. */
#define RADIO_DEFAULT_ADDRESS (0x8E89BED6)
#define LIGHTWEIGHT_RADIO (1)
#define RADIO_RX_TIMEOUT (150 + 80)
#define RADIO_EVENT(evt) (NRF_RADIO->evt == 1)
#define PPI_CH_STOP_RX_ABORT (TIMER_PPI_CH_START + 4)
#define DEBUG_RADIO_SET_STATE(state) do {\
DEBUG_RADIO_CLEAR_PIN(PIN_RADIO_STATE_TX);\
DEBUG_RADIO_CLEAR_PIN(PIN_RADIO_STATE_RX);\
DEBUG_RADIO_CLEAR_PIN(PIN_RADIO_STATE_IDLE);\
DEBUG_RADIO_SET_PIN(state);\
}while (0)
/**
* Internal enum denoting radio state.
*/
typedef enum
{
RADIO_STATE_RX,
RADIO_STATE_TX,
RADIO_STATE_DISABLED,
RADIO_STATE_NEVER_USED
} radio_state_t;
/*****************************************************************************
* Static globals
*****************************************************************************/
/** Global radio state */
static radio_state_t m_radio_state = RADIO_STATE_NEVER_USED;
static fifo_t m_radio_fifo;
static radio_event_t m_radio_fifo_queue[RBC_MESH_RADIO_QUEUE_LENGTH];
static radio_idle_cb_t m_idle_cb;
static radio_rx_cb_t m_rx_cb;
static radio_tx_cb_t m_tx_cb;
static uint32_t m_alt_aa = RADIO_DEFAULT_ADDRESS;
/*****************************************************************************
* Static functions
*****************************************************************************/
static void purge_preemptable(void)
{
uint32_t events_in_queue = fifo_get_len(&m_radio_fifo);
while (events_in_queue > 1)
{
radio_event_t current_evt;
if (fifo_peek(&m_radio_fifo, ¤t_evt) == NRF_SUCCESS &&
current_evt.event_type == RADIO_EVENT_TYPE_RX_PREEMPTABLE)
{
/* event is preemptable, stop it */
fifo_pop(&m_radio_fifo, NULL);
radio_disable();
while (NRF_RADIO->STATE != RADIO_STATE_STATE_Disabled);
NRF_RADIO->EVENTS_END = 0;
/* propagate failed rx event */
m_rx_cb(current_evt.packet_ptr, false, 0xFFFFFFFF, 100);
--events_in_queue;
}
else
{
break;
}
}
}
static void radio_channel_set(uint8_t ch)
{
if (ch <= 10)
{
NRF_RADIO->FREQUENCY = 4 + ch * 2;
}
else if (ch <= 36)
{
NRF_RADIO->FREQUENCY = 6 + ch * 2;
}
else
{
uint32_t adv_freqs[] = {2, 26, 80};
NRF_RADIO->FREQUENCY = adv_freqs[(ch - 37)];
}
NRF_RADIO->DATAWHITEIV = ch & RADIO_DATAWHITEIV_DATAWHITEIV_Msk;
}
static void setup_event(radio_event_t* p_evt)
{
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_DISABLE_Msk | RADIO_SHORTS_ADDRESS_RSSISTART_Msk;
radio_channel_set(p_evt->channel);
NRF_RADIO->PACKETPTR = (uint32_t) p_evt->packet_ptr;
NRF_RADIO->INTENSET = RADIO_INTENSET_END_Msk;
NRF_RADIO->EVENTS_END = 0;
NRF_RADIO->PREFIX0 |= (((m_alt_aa >> 24) << 8) & 0x0000FF00);
NRF_RADIO->BASE1 = ((m_alt_aa << 8) & 0xFFFFFF00);
if (p_evt->event_type == RADIO_EVENT_TYPE_TX)
{
DEBUG_RADIO_SET_STATE(PIN_RADIO_STATE_TX);
NRF_RADIO->TXADDRESS = p_evt->access_address;
NRF_RADIO->TXPOWER = p_evt->tx_power;
NRF_RADIO->TASKS_TXEN = 1;
m_radio_state = RADIO_STATE_TX;
}
else
{
DEBUG_RADIO_SET_STATE(PIN_RADIO_STATE_RX);
if (m_alt_aa != RADIO_DEFAULT_ADDRESS)
{
/* only enable alt-addr if it's different */
NRF_RADIO->RXADDRESSES = 0x03;
}
else
{
NRF_RADIO->RXADDRESSES = 0x01;
}
NRF_RADIO->TASKS_RXEN = 1;
m_radio_state = RADIO_STATE_RX;
}
}
/*****************************************************************************
* Interface functions
*****************************************************************************/
void radio_init(radio_idle_cb_t idle_cb,
radio_rx_cb_t rx_cb,
radio_tx_cb_t tx_cb)
{
/* Reset all states in the radio peripheral */
NRF_RADIO->POWER = ((RADIO_POWER_POWER_Disabled << RADIO_POWER_POWER_Pos) & RADIO_POWER_POWER_Msk);
NRF_RADIO->POWER = ((RADIO_POWER_POWER_Enabled << RADIO_POWER_POWER_Pos) & RADIO_POWER_POWER_Msk);
/* Set radio configuration parameters */
NRF_RADIO->TXPOWER = ((RADIO_TXPOWER_TXPOWER_0dBm << RADIO_TXPOWER_TXPOWER_Pos) & RADIO_TXPOWER_TXPOWER_Msk);
NRF_RADIO->MODE = ((RADIO_MODE_MODE_Ble_1Mbit << RADIO_MODE_MODE_Pos) & RADIO_MODE_MODE_Msk);
NRF_RADIO->FREQUENCY = 2; // Frequency bin 2, 2402MHz, channel 37.
NRF_RADIO->DATAWHITEIV = 37; // NOTE: This value needs to correspond to the frequency being used
/* Configure Access Address */
NRF_RADIO->PREFIX0 = ((RADIO_DEFAULT_ADDRESS >> 24) & 0x000000FF);
NRF_RADIO->BASE0 = ((RADIO_DEFAULT_ADDRESS << 8) & 0xFFFFFF00);
NRF_RADIO->PREFIX0 |= (((m_alt_aa >> 24) << 8) & 0x0000FF00);
NRF_RADIO->BASE1 = ((m_alt_aa << 8) & 0xFFFFFF00);
NRF_RADIO->TXADDRESS = 0x00; // Use logical address 0 (prefix0 + base0) = 0x8E89BED6 when transmitting
NRF_RADIO->RXADDRESSES = 0x01; // Enable reception on logical address 0 (PREFIX0 + BASE0)
/* PCNF-> Packet Configuration. Now we need to configure the sizes S0, S1 and length field to match the datapacket format of the advertisement packets. */
NRF_RADIO->PCNF0 = (
(((1UL) << RADIO_PCNF0_S0LEN_Pos) & RADIO_PCNF0_S0LEN_Msk) // length of S0 field in bytes 0-1.
| (((2UL) << RADIO_PCNF0_S1LEN_Pos) & RADIO_PCNF0_S1LEN_Msk) // length of S1 field in bits 0-8.
| (((6UL) << RADIO_PCNF0_LFLEN_Pos) & RADIO_PCNF0_LFLEN_Msk) // length of length field in bits 0-8.
);
/* Packet configuration */
NRF_RADIO->PCNF1 = (
(((37UL) << RADIO_PCNF1_MAXLEN_Pos) & RADIO_PCNF1_MAXLEN_Msk) // maximum length of payload in bytes [0-255]
| (((0UL) << RADIO_PCNF1_STATLEN_Pos) & RADIO_PCNF1_STATLEN_Msk) // expand the payload with N bytes in addition to LENGTH [0-255]
| (((3UL) << RADIO_PCNF1_BALEN_Pos) & RADIO_PCNF1_BALEN_Msk) // base address length in number of bytes.
| (((RADIO_PCNF1_ENDIAN_Little) << RADIO_PCNF1_ENDIAN_Pos) & RADIO_PCNF1_ENDIAN_Msk) // endianess of the S0, LENGTH, S1 and PAYLOAD fields.
| (((RADIO_PCNF1_WHITEEN_Enabled) << RADIO_PCNF1_WHITEEN_Pos) & RADIO_PCNF1_WHITEEN_Msk) // enable packet whitening
);
/* CRC config */
NRF_RADIO->CRCPOLY = ((0x00065B << RADIO_CRCPOLY_CRCPOLY_Pos) & RADIO_CRCPOLY_CRCPOLY_Msk); // CRC polynomial function
NRF_RADIO->CRCCNF = (((RADIO_CRCCNF_SKIPADDR_Skip) << RADIO_CRCCNF_SKIPADDR_Pos) & RADIO_CRCCNF_SKIPADDR_Msk)
| (((RADIO_CRCCNF_LEN_Three) << RADIO_CRCCNF_LEN_Pos) & RADIO_CRCCNF_LEN_Msk);
NRF_RADIO->CRCINIT = ((0x555555 << RADIO_CRCINIT_CRCINIT_Pos) & RADIO_CRCINIT_CRCINIT_Msk); // Initial value of CRC
/* Lock interframe spacing, so that the radio won't send too soon / start RX too early */
NRF_RADIO->TIFS = 148;
/* init radio packet fifo */
if (m_radio_state == RADIO_STATE_NEVER_USED)
{
/* this flushes the queue */
m_radio_fifo.array_len = RBC_MESH_RADIO_QUEUE_LENGTH;
m_radio_fifo.elem_array = m_radio_fifo_queue;
m_radio_fifo.elem_size = sizeof(radio_event_t);
m_radio_fifo.memcpy_fptr = NULL;
fifo_init(&m_radio_fifo);
}
m_radio_state = RADIO_STATE_DISABLED;
NRF_RADIO->EVENTS_END = 0;
NVIC_ClearPendingIRQ(RADIO_IRQn);
NVIC_EnableIRQ(RADIO_IRQn);
m_idle_cb = idle_cb;
m_rx_cb = rx_cb;
m_tx_cb = tx_cb;
DEBUG_RADIO_CLEAR_PIN(PIN_RADIO_STATE_RX);
DEBUG_RADIO_CLEAR_PIN(PIN_RADIO_STATE_TX);
if (fifo_is_empty(&m_radio_fifo))
{
m_idle_cb();
}
else
{
if (timeslot_is_in_ts())
{
NVIC_SetPendingIRQ(RADIO_IRQn);
}
}
}
void radio_alt_aa_set(uint32_t access_address)
{
m_alt_aa = access_address;
}
uint32_t radio_order(radio_event_t* p_radio_event)
{
if (p_radio_event == NULL)
{
return NRF_ERROR_NULL;
}
if (p_radio_event->event_type == RADIO_EVENT_TYPE_TX &&
p_radio_event->access_address > 1)
{
return NRF_ERROR_INVALID_ADDR;
}
if (fifo_push(&m_radio_fifo, p_radio_event) != NRF_SUCCESS)
{
return NRF_ERROR_NO_MEM;
}
uint32_t was_masked;
_DISABLE_IRQS(was_masked);
if (timeslot_is_in_ts())
{
NVIC_SetPendingIRQ(RADIO_IRQn);
}
_ENABLE_IRQS(was_masked);
return NRF_SUCCESS;
}
void radio_disable(void)
{
NRF_RADIO->SHORTS = 0;
NRF_RADIO->INTENCLR = 0xFFFFFFFF;
NRF_RADIO->TASKS_DISABLE = 1;
m_radio_state = RADIO_STATE_DISABLED;
DEBUG_RADIO_SET_STATE(PIN_RADIO_STATE_IDLE);
}
/**
* IRQ handler for radio. Sends the radio around the state machine, ensuring secure radio state changes
*/
void radio_event_handler(void)
{
if (NRF_RADIO->EVENTS_END)
{
bool crc_status = NRF_RADIO->CRCSTATUS;
uint32_t crc = NRF_RADIO->RXCRC;
uint8_t rssi = 100;
if (NRF_RADIO->EVENTS_RSSIEND)
{
NRF_RADIO->EVENTS_RSSIEND = 0;
rssi = NRF_RADIO->RSSISAMPLE;
}
radio_event_t prev_evt;
NRF_RADIO->EVENTS_END = 0;
/* pop the event that just finished */
uint32_t error_code = fifo_pop(&m_radio_fifo, &prev_evt);
APP_ERROR_CHECK(error_code);
/* send to super space */
if (prev_evt.event_type == RADIO_EVENT_TYPE_RX ||
prev_evt.event_type == RADIO_EVENT_TYPE_RX_PREEMPTABLE)
{
m_rx_cb(prev_evt.packet_ptr, crc_status, crc, rssi);
}
else
{
m_tx_cb(prev_evt.packet_ptr);
}
DEBUG_RADIO_SET_STATE(PIN_RADIO_STATE_IDLE);
m_radio_state = RADIO_STATE_DISABLED;
}
else
{
purge_preemptable();
}
if (m_radio_state == RADIO_STATE_DISABLED ||
m_radio_state == RADIO_STATE_NEVER_USED)
{
radio_event_t evt;
if (fifo_peek(&m_radio_fifo, &evt) == NRF_SUCCESS)
{
setup_event(&evt);
}
else
{
m_idle_cb();
}
}
}
| 34.837912 | 179 | 0.622191 |
65c70c46e8b6e7c9356af47a0664b0a15dd88c13 | 693 | h | C | td/telegram/MessageLinkInfo.h | lccxz/td | 6cdda6a2f3be4d0379f00a07fcd49f330da731fb | [
"BSL-1.0"
] | 82 | 2019-02-19T15:00:19.000Z | 2022-03-24T20:22:43.000Z | td/telegram/MessageLinkInfo.h | lccxz/td | 6cdda6a2f3be4d0379f00a07fcd49f330da731fb | [
"BSL-1.0"
] | 47 | 2019-03-07T13:07:36.000Z | 2022-03-27T14:32:09.000Z | td/telegram/MessageLinkInfo.h | lccxz/td | 6cdda6a2f3be4d0379f00a07fcd49f330da731fb | [
"BSL-1.0"
] | 12 | 2019-03-06T18:58:41.000Z | 2022-03-26T17:41:31.000Z | //
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/ChannelId.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/MessageId.h"
#include "td/utils/common.h"
namespace td {
struct MessageLinkInfo {
string username;
// or
ChannelId channel_id;
MessageId message_id;
bool is_single = false;
int32 media_timestamp = 0;
DialogId comment_dialog_id;
MessageId comment_message_id;
bool for_comment = false;
};
} // namespace td | 22.354839 | 96 | 0.74026 |
c5f0efccdc11f7bccf8af713f99532ad1137f92c | 373 | h | C | contrib/GambitREPL/intf.h | daviwil/gambit | a3a2f895c36d567ba70f8720371772c5301771e3 | [
"Apache-2.0"
] | 4 | 2019-11-04T21:28:15.000Z | 2021-11-29T00:17:47.000Z | contrib/GambitREPL/intf.h | daviwil/gambit | a3a2f895c36d567ba70f8720371772c5301771e3 | [
"Apache-2.0"
] | 1 | 2019-11-07T11:13:57.000Z | 2019-11-10T21:14:54.000Z | contrib/GambitREPL/intf.h | udem-dlteam/gambit | 776ccd958acc36b86397767c159c6ac526f14319 | [
"Apache-2.0"
] | null | null | null | /* File: "intf.h" */
/*
* Scheme functions which can be called from C. These functions are
* declared with a c-define in "intf.scm".
*/
extern NSString *eval_string(NSString *);
extern void send_input(NSString *);
extern void send_event(NSString *);
extern void send_text_input(NSString *);
extern void send_key_input(NSString *);
extern double heartbeat(void);
| 19.631579 | 68 | 0.723861 |
c5f596e71faa71f9cf03d127119f5599653fe11e | 25,516 | h | C | dir600b_v2.03/kernels/rt305x/include/asm-x86_64/unistd.h | ghsecuritylab/DIR600B2 | 78510ce13e037c430c84b4cdc7f49939481fe894 | [
"BSD-2-Clause"
] | 1 | 2019-07-21T01:58:19.000Z | 2019-07-21T01:58:19.000Z | dir600b_v2.03/kernels/rt305x/include/asm-x86_64/unistd.h | ghsecuritylab/DIR600B2 | 78510ce13e037c430c84b4cdc7f49939481fe894 | [
"BSD-2-Clause"
] | null | null | null | dir600b_v2.03/kernels/rt305x/include/asm-x86_64/unistd.h | ghsecuritylab/DIR600B2 | 78510ce13e037c430c84b4cdc7f49939481fe894 | [
"BSD-2-Clause"
] | 3 | 2016-06-13T13:20:56.000Z | 2019-12-05T02:31:23.000Z | #ifndef _ASM_X86_64_UNISTD_H_
#define _ASM_X86_64_UNISTD_H_
#ifndef __SYSCALL
#define __SYSCALL(a,b)
#endif
/*
* This file contains the system call numbers.
*
* Note: holes are not allowed.
*/
/* at least 8 syscall per cacheline */
#define __NR_read 0
__SYSCALL(__NR_read, sys_read)
#define __NR_write 1
__SYSCALL(__NR_write, sys_write)
#define __NR_open 2
__SYSCALL(__NR_open, sys_open)
#define __NR_close 3
__SYSCALL(__NR_close, sys_close)
#define __NR_stat 4
__SYSCALL(__NR_stat, sys_newstat)
#define __NR_fstat 5
__SYSCALL(__NR_fstat, sys_newfstat)
#define __NR_lstat 6
__SYSCALL(__NR_lstat, sys_newlstat)
#define __NR_poll 7
__SYSCALL(__NR_poll, sys_poll)
#define __NR_lseek 8
__SYSCALL(__NR_lseek, sys_lseek)
#define __NR_mmap 9
__SYSCALL(__NR_mmap, sys_mmap)
#define __NR_mprotect 10
__SYSCALL(__NR_mprotect, sys_mprotect)
#define __NR_munmap 11
__SYSCALL(__NR_munmap, sys_munmap)
#define __NR_brk 12
__SYSCALL(__NR_brk, sys_brk)
#define __NR_rt_sigaction 13
__SYSCALL(__NR_rt_sigaction, sys_rt_sigaction)
#define __NR_rt_sigprocmask 14
__SYSCALL(__NR_rt_sigprocmask, sys_rt_sigprocmask)
#define __NR_rt_sigreturn 15
__SYSCALL(__NR_rt_sigreturn, stub_rt_sigreturn)
#define __NR_ioctl 16
__SYSCALL(__NR_ioctl, sys_ioctl)
#define __NR_pread64 17
__SYSCALL(__NR_pread64, sys_pread64)
#define __NR_pwrite64 18
__SYSCALL(__NR_pwrite64, sys_pwrite64)
#define __NR_readv 19
__SYSCALL(__NR_readv, sys_readv)
#define __NR_writev 20
__SYSCALL(__NR_writev, sys_writev)
#define __NR_access 21
__SYSCALL(__NR_access, sys_access)
#define __NR_pipe 22
__SYSCALL(__NR_pipe, sys_pipe)
#define __NR_select 23
__SYSCALL(__NR_select, sys_select)
#define __NR_sched_yield 24
__SYSCALL(__NR_sched_yield, sys_sched_yield)
#define __NR_mremap 25
__SYSCALL(__NR_mremap, sys_mremap)
#define __NR_msync 26
__SYSCALL(__NR_msync, sys_msync)
#define __NR_mincore 27
__SYSCALL(__NR_mincore, sys_mincore)
#define __NR_madvise 28
__SYSCALL(__NR_madvise, sys_madvise)
#define __NR_shmget 29
__SYSCALL(__NR_shmget, sys_shmget)
#define __NR_shmat 30
__SYSCALL(__NR_shmat, sys_shmat)
#define __NR_shmctl 31
__SYSCALL(__NR_shmctl, sys_shmctl)
#define __NR_dup 32
__SYSCALL(__NR_dup, sys_dup)
#define __NR_dup2 33
__SYSCALL(__NR_dup2, sys_dup2)
#define __NR_pause 34
__SYSCALL(__NR_pause, sys_pause)
#define __NR_nanosleep 35
__SYSCALL(__NR_nanosleep, sys_nanosleep)
#define __NR_getitimer 36
__SYSCALL(__NR_getitimer, sys_getitimer)
#define __NR_alarm 37
__SYSCALL(__NR_alarm, sys_alarm)
#define __NR_setitimer 38
__SYSCALL(__NR_setitimer, sys_setitimer)
#define __NR_getpid 39
__SYSCALL(__NR_getpid, sys_getpid)
#define __NR_sendfile 40
__SYSCALL(__NR_sendfile, sys_sendfile64)
#define __NR_socket 41
__SYSCALL(__NR_socket, sys_socket)
#define __NR_connect 42
__SYSCALL(__NR_connect, sys_connect)
#define __NR_accept 43
__SYSCALL(__NR_accept, sys_accept)
#define __NR_sendto 44
__SYSCALL(__NR_sendto, sys_sendto)
#define __NR_recvfrom 45
__SYSCALL(__NR_recvfrom, sys_recvfrom)
#define __NR_sendmsg 46
__SYSCALL(__NR_sendmsg, sys_sendmsg)
#define __NR_recvmsg 47
__SYSCALL(__NR_recvmsg, sys_recvmsg)
#define __NR_shutdown 48
__SYSCALL(__NR_shutdown, sys_shutdown)
#define __NR_bind 49
__SYSCALL(__NR_bind, sys_bind)
#define __NR_listen 50
__SYSCALL(__NR_listen, sys_listen)
#define __NR_getsockname 51
__SYSCALL(__NR_getsockname, sys_getsockname)
#define __NR_getpeername 52
__SYSCALL(__NR_getpeername, sys_getpeername)
#define __NR_socketpair 53
__SYSCALL(__NR_socketpair, sys_socketpair)
#define __NR_setsockopt 54
__SYSCALL(__NR_setsockopt, sys_setsockopt)
#define __NR_getsockopt 55
__SYSCALL(__NR_getsockopt, sys_getsockopt)
#define __NR_clone 56
__SYSCALL(__NR_clone, stub_clone)
#define __NR_fork 57
__SYSCALL(__NR_fork, stub_fork)
#define __NR_vfork 58
__SYSCALL(__NR_vfork, stub_vfork)
#define __NR_execve 59
__SYSCALL(__NR_execve, stub_execve)
#define __NR_exit 60
__SYSCALL(__NR_exit, sys_exit)
#define __NR_wait4 61
__SYSCALL(__NR_wait4, sys_wait4)
#define __NR_kill 62
__SYSCALL(__NR_kill, sys_kill)
#define __NR_uname 63
__SYSCALL(__NR_uname, sys_uname)
#define __NR_semget 64
__SYSCALL(__NR_semget, sys_semget)
#define __NR_semop 65
__SYSCALL(__NR_semop, sys_semop)
#define __NR_semctl 66
__SYSCALL(__NR_semctl, sys_semctl)
#define __NR_shmdt 67
__SYSCALL(__NR_shmdt, sys_shmdt)
#define __NR_msgget 68
__SYSCALL(__NR_msgget, sys_msgget)
#define __NR_msgsnd 69
__SYSCALL(__NR_msgsnd, sys_msgsnd)
#define __NR_msgrcv 70
__SYSCALL(__NR_msgrcv, sys_msgrcv)
#define __NR_msgctl 71
__SYSCALL(__NR_msgctl, sys_msgctl)
#define __NR_fcntl 72
__SYSCALL(__NR_fcntl, sys_fcntl)
#define __NR_flock 73
__SYSCALL(__NR_flock, sys_flock)
#define __NR_fsync 74
__SYSCALL(__NR_fsync, sys_fsync)
#define __NR_fdatasync 75
__SYSCALL(__NR_fdatasync, sys_fdatasync)
#define __NR_truncate 76
__SYSCALL(__NR_truncate, sys_truncate)
#define __NR_ftruncate 77
__SYSCALL(__NR_ftruncate, sys_ftruncate)
#define __NR_getdents 78
__SYSCALL(__NR_getdents, sys_getdents)
#define __NR_getcwd 79
__SYSCALL(__NR_getcwd, sys_getcwd)
#define __NR_chdir 80
__SYSCALL(__NR_chdir, sys_chdir)
#define __NR_fchdir 81
__SYSCALL(__NR_fchdir, sys_fchdir)
#define __NR_rename 82
__SYSCALL(__NR_rename, sys_rename)
#define __NR_mkdir 83
__SYSCALL(__NR_mkdir, sys_mkdir)
#define __NR_rmdir 84
__SYSCALL(__NR_rmdir, sys_rmdir)
#define __NR_creat 85
__SYSCALL(__NR_creat, sys_creat)
#define __NR_link 86
__SYSCALL(__NR_link, sys_link)
#define __NR_unlink 87
__SYSCALL(__NR_unlink, sys_unlink)
#define __NR_symlink 88
__SYSCALL(__NR_symlink, sys_symlink)
#define __NR_readlink 89
__SYSCALL(__NR_readlink, sys_readlink)
#define __NR_chmod 90
__SYSCALL(__NR_chmod, sys_chmod)
#define __NR_fchmod 91
__SYSCALL(__NR_fchmod, sys_fchmod)
#define __NR_chown 92
__SYSCALL(__NR_chown, sys_chown)
#define __NR_fchown 93
__SYSCALL(__NR_fchown, sys_fchown)
#define __NR_lchown 94
__SYSCALL(__NR_lchown, sys_lchown)
#define __NR_umask 95
__SYSCALL(__NR_umask, sys_umask)
#define __NR_gettimeofday 96
__SYSCALL(__NR_gettimeofday, sys_gettimeofday)
#define __NR_getrlimit 97
__SYSCALL(__NR_getrlimit, sys_getrlimit)
#define __NR_getrusage 98
__SYSCALL(__NR_getrusage, sys_getrusage)
#define __NR_sysinfo 99
__SYSCALL(__NR_sysinfo, sys_sysinfo)
#define __NR_times 100
__SYSCALL(__NR_times, sys_times)
#define __NR_ptrace 101
__SYSCALL(__NR_ptrace, sys_ptrace)
#define __NR_getuid 102
__SYSCALL(__NR_getuid, sys_getuid)
#define __NR_syslog 103
__SYSCALL(__NR_syslog, sys_syslog)
/* at the very end the stuff that never runs during the benchmarks */
#define __NR_getgid 104
__SYSCALL(__NR_getgid, sys_getgid)
#define __NR_setuid 105
__SYSCALL(__NR_setuid, sys_setuid)
#define __NR_setgid 106
__SYSCALL(__NR_setgid, sys_setgid)
#define __NR_geteuid 107
__SYSCALL(__NR_geteuid, sys_geteuid)
#define __NR_getegid 108
__SYSCALL(__NR_getegid, sys_getegid)
#define __NR_setpgid 109
__SYSCALL(__NR_setpgid, sys_setpgid)
#define __NR_getppid 110
__SYSCALL(__NR_getppid, sys_getppid)
#define __NR_getpgrp 111
__SYSCALL(__NR_getpgrp, sys_getpgrp)
#define __NR_setsid 112
__SYSCALL(__NR_setsid, sys_setsid)
#define __NR_setreuid 113
__SYSCALL(__NR_setreuid, sys_setreuid)
#define __NR_setregid 114
__SYSCALL(__NR_setregid, sys_setregid)
#define __NR_getgroups 115
__SYSCALL(__NR_getgroups, sys_getgroups)
#define __NR_setgroups 116
__SYSCALL(__NR_setgroups, sys_setgroups)
#define __NR_setresuid 117
__SYSCALL(__NR_setresuid, sys_setresuid)
#define __NR_getresuid 118
__SYSCALL(__NR_getresuid, sys_getresuid)
#define __NR_setresgid 119
__SYSCALL(__NR_setresgid, sys_setresgid)
#define __NR_getresgid 120
__SYSCALL(__NR_getresgid, sys_getresgid)
#define __NR_getpgid 121
__SYSCALL(__NR_getpgid, sys_getpgid)
#define __NR_setfsuid 122
__SYSCALL(__NR_setfsuid, sys_setfsuid)
#define __NR_setfsgid 123
__SYSCALL(__NR_setfsgid, sys_setfsgid)
#define __NR_getsid 124
__SYSCALL(__NR_getsid, sys_getsid)
#define __NR_capget 125
__SYSCALL(__NR_capget, sys_capget)
#define __NR_capset 126
__SYSCALL(__NR_capset, sys_capset)
#define __NR_rt_sigpending 127
__SYSCALL(__NR_rt_sigpending, sys_rt_sigpending)
#define __NR_rt_sigtimedwait 128
__SYSCALL(__NR_rt_sigtimedwait, sys_rt_sigtimedwait)
#define __NR_rt_sigqueueinfo 129
__SYSCALL(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo)
#define __NR_rt_sigsuspend 130
__SYSCALL(__NR_rt_sigsuspend, stub_rt_sigsuspend)
#define __NR_sigaltstack 131
__SYSCALL(__NR_sigaltstack, stub_sigaltstack)
#define __NR_utime 132
__SYSCALL(__NR_utime, sys_utime)
#define __NR_mknod 133
__SYSCALL(__NR_mknod, sys_mknod)
/* Only needed for a.out */
#define __NR_uselib 134
__SYSCALL(__NR_uselib, sys_ni_syscall)
#define __NR_personality 135
__SYSCALL(__NR_personality, sys_personality)
#define __NR_ustat 136
__SYSCALL(__NR_ustat, sys_ustat)
#define __NR_statfs 137
__SYSCALL(__NR_statfs, sys_statfs)
#define __NR_fstatfs 138
__SYSCALL(__NR_fstatfs, sys_fstatfs)
#define __NR_sysfs 139
__SYSCALL(__NR_sysfs, sys_sysfs)
#define __NR_getpriority 140
__SYSCALL(__NR_getpriority, sys_getpriority)
#define __NR_setpriority 141
__SYSCALL(__NR_setpriority, sys_setpriority)
#define __NR_sched_setparam 142
__SYSCALL(__NR_sched_setparam, sys_sched_setparam)
#define __NR_sched_getparam 143
__SYSCALL(__NR_sched_getparam, sys_sched_getparam)
#define __NR_sched_setscheduler 144
__SYSCALL(__NR_sched_setscheduler, sys_sched_setscheduler)
#define __NR_sched_getscheduler 145
__SYSCALL(__NR_sched_getscheduler, sys_sched_getscheduler)
#define __NR_sched_get_priority_max 146
__SYSCALL(__NR_sched_get_priority_max, sys_sched_get_priority_max)
#define __NR_sched_get_priority_min 147
__SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min)
#define __NR_sched_rr_get_interval 148
__SYSCALL(__NR_sched_rr_get_interval, sys_sched_rr_get_interval)
#define __NR_mlock 149
__SYSCALL(__NR_mlock, sys_mlock)
#define __NR_munlock 150
__SYSCALL(__NR_munlock, sys_munlock)
#define __NR_mlockall 151
__SYSCALL(__NR_mlockall, sys_mlockall)
#define __NR_munlockall 152
__SYSCALL(__NR_munlockall, sys_munlockall)
#define __NR_vhangup 153
__SYSCALL(__NR_vhangup, sys_vhangup)
#define __NR_modify_ldt 154
__SYSCALL(__NR_modify_ldt, sys_modify_ldt)
#define __NR_pivot_root 155
__SYSCALL(__NR_pivot_root, sys_pivot_root)
#define __NR__sysctl 156
__SYSCALL(__NR__sysctl, sys_sysctl)
#define __NR_prctl 157
__SYSCALL(__NR_prctl, sys_prctl)
#define __NR_arch_prctl 158
__SYSCALL(__NR_arch_prctl, sys_arch_prctl)
#define __NR_adjtimex 159
__SYSCALL(__NR_adjtimex, sys_adjtimex)
#define __NR_setrlimit 160
__SYSCALL(__NR_setrlimit, sys_setrlimit)
#define __NR_chroot 161
__SYSCALL(__NR_chroot, sys_chroot)
#define __NR_sync 162
__SYSCALL(__NR_sync, sys_sync)
#define __NR_acct 163
__SYSCALL(__NR_acct, sys_acct)
#define __NR_settimeofday 164
__SYSCALL(__NR_settimeofday, sys_settimeofday)
#define __NR_mount 165
__SYSCALL(__NR_mount, sys_mount)
#define __NR_umount2 166
__SYSCALL(__NR_umount2, sys_umount)
#define __NR_swapon 167
__SYSCALL(__NR_swapon, sys_swapon)
#define __NR_swapoff 168
__SYSCALL(__NR_swapoff, sys_swapoff)
#define __NR_reboot 169
__SYSCALL(__NR_reboot, sys_reboot)
#define __NR_sethostname 170
__SYSCALL(__NR_sethostname, sys_sethostname)
#define __NR_setdomainname 171
__SYSCALL(__NR_setdomainname, sys_setdomainname)
#define __NR_iopl 172
__SYSCALL(__NR_iopl, stub_iopl)
#define __NR_ioperm 173
__SYSCALL(__NR_ioperm, sys_ioperm)
#define __NR_create_module 174
__SYSCALL(__NR_create_module, sys_ni_syscall)
#define __NR_init_module 175
__SYSCALL(__NR_init_module, sys_init_module)
#define __NR_delete_module 176
__SYSCALL(__NR_delete_module, sys_delete_module)
#define __NR_get_kernel_syms 177
__SYSCALL(__NR_get_kernel_syms, sys_ni_syscall)
#define __NR_query_module 178
__SYSCALL(__NR_query_module, sys_ni_syscall)
#define __NR_quotactl 179
__SYSCALL(__NR_quotactl, sys_quotactl)
#define __NR_nfsservctl 180
__SYSCALL(__NR_nfsservctl, sys_nfsservctl)
#define __NR_getpmsg 181 /* reserved for LiS/STREAMS */
__SYSCALL(__NR_getpmsg, sys_ni_syscall)
#define __NR_putpmsg 182 /* reserved for LiS/STREAMS */
__SYSCALL(__NR_putpmsg, sys_ni_syscall)
#define __NR_afs_syscall 183 /* reserved for AFS */
__SYSCALL(__NR_afs_syscall, sys_ni_syscall)
#define __NR_tuxcall 184 /* reserved for tux */
__SYSCALL(__NR_tuxcall, sys_ni_syscall)
#define __NR_security 185
__SYSCALL(__NR_security, sys_ni_syscall)
#define __NR_gettid 186
__SYSCALL(__NR_gettid, sys_gettid)
#define __NR_readahead 187
__SYSCALL(__NR_readahead, sys_readahead)
#define __NR_setxattr 188
__SYSCALL(__NR_setxattr, sys_setxattr)
#define __NR_lsetxattr 189
__SYSCALL(__NR_lsetxattr, sys_lsetxattr)
#define __NR_fsetxattr 190
__SYSCALL(__NR_fsetxattr, sys_fsetxattr)
#define __NR_getxattr 191
__SYSCALL(__NR_getxattr, sys_getxattr)
#define __NR_lgetxattr 192
__SYSCALL(__NR_lgetxattr, sys_lgetxattr)
#define __NR_fgetxattr 193
__SYSCALL(__NR_fgetxattr, sys_fgetxattr)
#define __NR_listxattr 194
__SYSCALL(__NR_listxattr, sys_listxattr)
#define __NR_llistxattr 195
__SYSCALL(__NR_llistxattr, sys_llistxattr)
#define __NR_flistxattr 196
__SYSCALL(__NR_flistxattr, sys_flistxattr)
#define __NR_removexattr 197
__SYSCALL(__NR_removexattr, sys_removexattr)
#define __NR_lremovexattr 198
__SYSCALL(__NR_lremovexattr, sys_lremovexattr)
#define __NR_fremovexattr 199
__SYSCALL(__NR_fremovexattr, sys_fremovexattr)
#define __NR_tkill 200
__SYSCALL(__NR_tkill, sys_tkill)
#define __NR_time 201
__SYSCALL(__NR_time, sys_time)
#define __NR_futex 202
__SYSCALL(__NR_futex, sys_futex)
#define __NR_sched_setaffinity 203
__SYSCALL(__NR_sched_setaffinity, sys_sched_setaffinity)
#define __NR_sched_getaffinity 204
__SYSCALL(__NR_sched_getaffinity, sys_sched_getaffinity)
#define __NR_set_thread_area 205
__SYSCALL(__NR_set_thread_area, sys_ni_syscall) /* use arch_prctl */
#define __NR_io_setup 206
__SYSCALL(__NR_io_setup, sys_io_setup)
#define __NR_io_destroy 207
__SYSCALL(__NR_io_destroy, sys_io_destroy)
#define __NR_io_getevents 208
__SYSCALL(__NR_io_getevents, sys_io_getevents)
#define __NR_io_submit 209
__SYSCALL(__NR_io_submit, sys_io_submit)
#define __NR_io_cancel 210
__SYSCALL(__NR_io_cancel, sys_io_cancel)
#define __NR_get_thread_area 211
__SYSCALL(__NR_get_thread_area, sys_ni_syscall) /* use arch_prctl */
#define __NR_lookup_dcookie 212
__SYSCALL(__NR_lookup_dcookie, sys_lookup_dcookie)
#define __NR_epoll_create 213
__SYSCALL(__NR_epoll_create, sys_epoll_create)
#define __NR_epoll_ctl_old 214
__SYSCALL(__NR_epoll_ctl_old, sys_ni_syscall)
#define __NR_epoll_wait_old 215
__SYSCALL(__NR_epoll_wait_old, sys_ni_syscall)
#define __NR_remap_file_pages 216
__SYSCALL(__NR_remap_file_pages, sys_remap_file_pages)
#define __NR_getdents64 217
__SYSCALL(__NR_getdents64, sys_getdents64)
#define __NR_set_tid_address 218
__SYSCALL(__NR_set_tid_address, sys_set_tid_address)
#define __NR_restart_syscall 219
__SYSCALL(__NR_restart_syscall, sys_restart_syscall)
#define __NR_semtimedop 220
__SYSCALL(__NR_semtimedop, sys_semtimedop)
#define __NR_fadvise64 221
__SYSCALL(__NR_fadvise64, sys_fadvise64)
#define __NR_timer_create 222
__SYSCALL(__NR_timer_create, sys_timer_create)
#define __NR_timer_settime 223
__SYSCALL(__NR_timer_settime, sys_timer_settime)
#define __NR_timer_gettime 224
__SYSCALL(__NR_timer_gettime, sys_timer_gettime)
#define __NR_timer_getoverrun 225
__SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun)
#define __NR_timer_delete 226
__SYSCALL(__NR_timer_delete, sys_timer_delete)
#define __NR_clock_settime 227
__SYSCALL(__NR_clock_settime, sys_clock_settime)
#define __NR_clock_gettime 228
__SYSCALL(__NR_clock_gettime, sys_clock_gettime)
#define __NR_clock_getres 229
__SYSCALL(__NR_clock_getres, sys_clock_getres)
#define __NR_clock_nanosleep 230
__SYSCALL(__NR_clock_nanosleep, sys_clock_nanosleep)
#define __NR_exit_group 231
__SYSCALL(__NR_exit_group, sys_exit_group)
#define __NR_epoll_wait 232
__SYSCALL(__NR_epoll_wait, sys_epoll_wait)
#define __NR_epoll_ctl 233
__SYSCALL(__NR_epoll_ctl, sys_epoll_ctl)
#define __NR_tgkill 234
__SYSCALL(__NR_tgkill, sys_tgkill)
#define __NR_utimes 235
__SYSCALL(__NR_utimes, sys_utimes)
#define __NR_vserver 236
__SYSCALL(__NR_vserver, sys_ni_syscall)
#define __NR_mbind 237
__SYSCALL(__NR_mbind, sys_mbind)
#define __NR_set_mempolicy 238
__SYSCALL(__NR_set_mempolicy, sys_set_mempolicy)
#define __NR_get_mempolicy 239
__SYSCALL(__NR_get_mempolicy, sys_get_mempolicy)
#define __NR_mq_open 240
__SYSCALL(__NR_mq_open, sys_mq_open)
#define __NR_mq_unlink 241
__SYSCALL(__NR_mq_unlink, sys_mq_unlink)
#define __NR_mq_timedsend 242
__SYSCALL(__NR_mq_timedsend, sys_mq_timedsend)
#define __NR_mq_timedreceive 243
__SYSCALL(__NR_mq_timedreceive, sys_mq_timedreceive)
#define __NR_mq_notify 244
__SYSCALL(__NR_mq_notify, sys_mq_notify)
#define __NR_mq_getsetattr 245
__SYSCALL(__NR_mq_getsetattr, sys_mq_getsetattr)
#define __NR_kexec_load 246
__SYSCALL(__NR_kexec_load, sys_kexec_load)
#define __NR_waitid 247
__SYSCALL(__NR_waitid, sys_waitid)
#define __NR_add_key 248
__SYSCALL(__NR_add_key, sys_add_key)
#define __NR_request_key 249
__SYSCALL(__NR_request_key, sys_request_key)
#define __NR_keyctl 250
__SYSCALL(__NR_keyctl, sys_keyctl)
#define __NR_ioprio_set 251
__SYSCALL(__NR_ioprio_set, sys_ioprio_set)
#define __NR_ioprio_get 252
__SYSCALL(__NR_ioprio_get, sys_ioprio_get)
#define __NR_inotify_init 253
__SYSCALL(__NR_inotify_init, sys_inotify_init)
#define __NR_inotify_add_watch 254
__SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch)
#define __NR_inotify_rm_watch 255
__SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch)
#define __NR_migrate_pages 256
__SYSCALL(__NR_migrate_pages, sys_migrate_pages)
#define __NR_openat 257
__SYSCALL(__NR_openat, sys_openat)
#define __NR_mkdirat 258
__SYSCALL(__NR_mkdirat, sys_mkdirat)
#define __NR_mknodat 259
__SYSCALL(__NR_mknodat, sys_mknodat)
#define __NR_fchownat 260
__SYSCALL(__NR_fchownat, sys_fchownat)
#define __NR_futimesat 261
__SYSCALL(__NR_futimesat, sys_futimesat)
#define __NR_newfstatat 262
__SYSCALL(__NR_newfstatat, sys_newfstatat)
#define __NR_unlinkat 263
__SYSCALL(__NR_unlinkat, sys_unlinkat)
#define __NR_renameat 264
__SYSCALL(__NR_renameat, sys_renameat)
#define __NR_linkat 265
__SYSCALL(__NR_linkat, sys_linkat)
#define __NR_symlinkat 266
__SYSCALL(__NR_symlinkat, sys_symlinkat)
#define __NR_readlinkat 267
__SYSCALL(__NR_readlinkat, sys_readlinkat)
#define __NR_fchmodat 268
__SYSCALL(__NR_fchmodat, sys_fchmodat)
#define __NR_faccessat 269
__SYSCALL(__NR_faccessat, sys_faccessat)
#define __NR_pselect6 270
__SYSCALL(__NR_pselect6, sys_pselect6)
#define __NR_ppoll 271
__SYSCALL(__NR_ppoll, sys_ppoll)
#define __NR_unshare 272
__SYSCALL(__NR_unshare, sys_unshare)
#define __NR_set_robust_list 273
__SYSCALL(__NR_set_robust_list, sys_set_robust_list)
#define __NR_get_robust_list 274
__SYSCALL(__NR_get_robust_list, sys_get_robust_list)
#define __NR_splice 275
__SYSCALL(__NR_splice, sys_splice)
#define __NR_tee 276
__SYSCALL(__NR_tee, sys_tee)
#define __NR_sync_file_range 277
__SYSCALL(__NR_sync_file_range, sys_sync_file_range)
#define __NR_vmsplice 278
__SYSCALL(__NR_vmsplice, sys_vmsplice)
#define __NR_move_pages 279
__SYSCALL(__NR_move_pages, sys_move_pages)
#define __NR_syscall_max __NR_move_pages
#ifndef __NO_STUBS
#define __ARCH_WANT_OLD_READDIR
#define __ARCH_WANT_OLD_STAT
#define __ARCH_WANT_SYS_ALARM
#define __ARCH_WANT_SYS_GETHOSTNAME
#define __ARCH_WANT_SYS_PAUSE
#define __ARCH_WANT_SYS_SGETMASK
#define __ARCH_WANT_SYS_SIGNAL
#define __ARCH_WANT_SYS_UTIME
#define __ARCH_WANT_SYS_WAITPID
#define __ARCH_WANT_SYS_SOCKETCALL
#define __ARCH_WANT_SYS_FADVISE64
#define __ARCH_WANT_SYS_GETPGRP
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_SYS_RT_SIGACTION
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
#define __ARCH_WANT_SYS_TIME
#define __ARCH_WANT_COMPAT_SYS_TIME
#ifdef __KERNEL__
#ifndef __ASSEMBLY__
#include <linux/linkage.h>
#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/ptrace.h>
asmlinkage long sys_iopl(unsigned int level, struct pt_regs *regs);
asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on);
struct sigaction;
asmlinkage long sys_rt_sigaction(int sig,
const struct sigaction __user *act,
struct sigaction __user *oact,
size_t sigsetsize);
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* __NO_STUBS */
/*
* "Conditional" syscalls
*
* What we want is __attribute__((weak,alias("sys_ni_syscall"))),
* but it doesn't work on all toolchains, so we just do it by hand
*/
#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
#endif /* _ASM_X86_64_UNISTD_H_ */
| 37.634218 | 81 | 0.690586 |
c5f62e41f758e5ebd98a74d79614b5a75b4647ee | 2,515 | h | C | mindspore/lite/minddata/wrapper/MDToDApi.h | kungfu-team/mindspore-bert | 71501cf52ae01db9d6a73fb64bcfe68a6509dc32 | [
"Apache-2.0"
] | 2 | 2021-07-08T13:10:42.000Z | 2021-11-08T02:48:57.000Z | mindspore/lite/minddata/wrapper/MDToDApi.h | peixinhou/mindspore | fcb2ec2779b753e95c762cf292b23bd81d1f561b | [
"Apache-2.0"
] | null | null | null | mindspore/lite/minddata/wrapper/MDToDApi.h | peixinhou/mindspore | fcb2ec2779b753e95c762cf292b23bd81d1f561b | [
"Apache-2.0"
] | null | null | null | /**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DATASET_MDTODAPI_H_
#define DATASET_MDTODAPI_H_
#include <stdint.h>
#include <sys/types.h>
class MDToDApi;
typedef struct MDToDBuff {
void *Buff;
size_t DataSize;
size_t TensorSize[4];
size_t MaxBuffSize;
} MDToDBuff_t;
typedef struct MDToDConf {
const char *pFolderPath;
const char *pSchemFile;
const char *pStoragePath;
MDToDBuff_t columnsToReadBuff;
float MEAN[3];
float STD[3];
int ResizeSizeWH[2];
int fixOrientation;
int CropSizeWH[2];
int64_t fileid; // -1 All files, otherwise get a single specific file
} MDToDConf_t;
typedef struct MDToDResult {
int64_t fileid;
int32_t isForTrain;
int32_t noOfFaces;
int32_t orientation;
MDToDBuff_t fileNameBuff;
MDToDBuff_t labelBuff;
MDToDBuff_t imageBuff;
MDToDBuff_t embeddingBuff;
MDToDBuff_t boundingBoxesBuff;
MDToDBuff_t confidencesBuff;
MDToDBuff_t landmarksBuff;
MDToDBuff_t faceFileNamesBuff;
MDToDBuff_t imageQualitiesBuff;
MDToDBuff_t faceEmbeddingsBuff;
} MDToDResult_t;
typedef int (*MDToDApi_pathTest_t)(const char *path);
typedef int (*MDToDApi_testAlbum_t)();
typedef MDToDApi *(*MDToDApi_createPipeLine_t)(MDToDConf_t MDConf);
typedef int (*MDToDApi_GetNext_t)(MDToDApi *pMDToDApi, MDToDResult_t *results);
typedef int (*MDToDApi_UpdateEmbeding_t)(MDToDApi *pMDToDApi, const char *column, float *emmbeddings,
size_t emmbeddingsSize);
typedef int (*MDToDApi_UpdateStringArray_t)(MDToDApi *pMDToDApi, const char *column, MDToDBuff_t MDbuff);
typedef int (*MDToDApi_UpdateFloatArray_t)(MDToDApi *pMDToDApi, const char *column, MDToDBuff_t MDbuff);
typedef int (*MDToDApi_UpdateIsForTrain_t)(MDToDApi *pMDToDApi, uint8_t isForTrain);
typedef int (*MDToDApi_UpdateNoOfFaces_t)(MDToDApi *pMDToDApi, int32_t noOfFaces);
typedef int (*MDToDApi_Stop_t)(MDToDApi *pMDToDApi);
typedef int (*MDToDApi_Destroy_t)(MDToDApi *pMDToDApi);
#endif
| 33.533333 | 105 | 0.766998 |
a94a69c157d660a87040e54c777f2de955d5d942 | 5,184 | h | C | components/heap_profiling/multi_process/supervisor.h | chromium/chromium | df46e572c3449a4b108d6e02fbe4f6d24cf98381 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668 | 2015-01-01T01:57:10.000Z | 2022-03-31T23:33:32.000Z | components/heap_profiling/multi_process/supervisor.h | chromium/chromium | df46e572c3449a4b108d6e02fbe4f6d24cf98381 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 86 | 2015-10-21T13:02:42.000Z | 2022-03-14T07:50:50.000Z | components/heap_profiling/multi_process/supervisor.h | chromium/chromium | df46e572c3449a4b108d6e02fbe4f6d24cf98381 | [
"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 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_HEAP_PROFILING_MULTI_PROCESS_SUPERVISOR_H_
#define COMPONENTS_HEAP_PROFILING_MULTI_PROCESS_SUPERVISOR_H_
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "base/process/process.h"
#include "components/services/heap_profiling/public/mojom/heap_profiling_client.mojom.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
namespace heap_profiling {
class ClientConnectionManager;
class Controller;
enum class Mode;
// This class presents a single interface for both tests and embedders to use
// the HeapProfilingService. This class is intended to be used from the
// browser/privileged process of the embedder.
//
// This class must be accessed from the UI thread.
//
// Internally, this class:
// * Starts the HeapProfilingService.
// * Hooks up all the connections so that the appropriate processes get
// profiled.
class Supervisor {
public:
static Supervisor* GetInstance();
Supervisor(const Supervisor&) = delete;
Supervisor& operator=(const Supervisor&) = delete;
// When this returns |false|, no method other than Start() or
// SetClientConnectionManagerConstructor() can be called.
bool HasStarted();
// Embedders can use this method to force the Supervisor to instantiate a
// ClientConnectionManager subclass during Start(). The function will be
// called on the UI thread.
using ClientConnectionManagerConstructor =
std::unique_ptr<ClientConnectionManager> (*)(
base::WeakPtr<Controller> controller_weak_ptr,
Mode mode);
void SetClientConnectionManagerConstructor(
ClientConnectionManagerConstructor constructor);
// Must be called at most once.
// The first method is a convenience method that calls the second with
// default parameters.
// Start is an asynchronous operation that must hop to the IO thread and then
// back to the UI thread. |callback| will be invoked on the UI thread after
// this is finished.
//
// This is a brief period of time when this object is in a semi-initialized
// state - when Start has been called, but the thread hops haven't finished.
// We avoid this side case by:
// * Providing a |callback| for callers to use, if they need to do anything
// shortly after Start().
// * Relying on the assumption that in all other cases, the object is either
// fully initialized or not initialized. There are DCHECKs to enforce this
// assumption.
void Start(base::OnceClosure callback);
void Start(Mode mode,
mojom::StackMode stack_mode,
uint32_t sampling_rate,
base::OnceClosure callback);
Mode GetMode();
// Starts profiling the process with the given id.
void StartManualProfiling(base::ProcessId pid);
// Returns the pids of all profiled processes. The callback is posted on the
// UI thread.
using GetProfiledPidsCallback =
base::OnceCallback<void(std::vector<base::ProcessId> pids)>;
void GetProfiledPids(GetProfiledPidsCallback callback);
uint32_t GetSamplingRate();
using TraceFinishedCallback =
base::OnceCallback<void(bool success, std::string trace_json)>;
// This method must be called from the UI thread. |callback| will be called
// asynchronously on the UI thread.
//
// This function does the following:
// 1. Starts tracing with no categories enabled.
// 2. Requests and waits for memory_instrumentation service to dump to
// trace.
// 3. Stops tracing.
void RequestTraceWithHeapDump(TraceFinishedCallback callback, bool anonymize);
private:
friend class base::NoDestructor<Supervisor>;
Supervisor();
~Supervisor();
// Initialization stage 1: Start the Service on the IO thread.
void StartServiceOnIOThread(
mojo::PendingReceiver<memory_instrumentation::mojom::HeapProfiler>
receiver,
mojo::PendingRemote<memory_instrumentation::mojom::HeapProfilerHelper>
remote_helper,
Mode mode,
mojom::StackMode stack_mode,
uint32_t sampling_rate,
base::OnceClosure callback);
// Initialization stage 2: Start the ClientConnectManager on the UI thread.
void FinishInitializationOnUIhread(
Mode mode,
base::OnceClosure closure,
base::WeakPtr<Controller> controller_weak_ptr);
void GetProfiledPidsOnIOThread(GetProfiledPidsCallback callback);
void StartProfilingOnMemoryInfraThread(Mode mode,
mojom::StackMode stack_mode,
uint32_t sampling_rate,
base::OnceClosure closure);
// Bound to the IO thread.
std::unique_ptr<Controller> controller_;
// Bound to the UI thread.
std::unique_ptr<ClientConnectionManager> client_connection_manager_;
ClientConnectionManagerConstructor constructor_ = nullptr;
bool started_ = false;
};
} // namespace heap_profiling
#endif // COMPONENTS_HEAP_PROFILING_MULTI_PROCESS_SUPERVISOR_H_
| 36.507042 | 107 | 0.728395 |
653f7e1cd6f54f11f238b1321cf7303317532512 | 559 | h | C | src/util.h | interma/toy_db | 9b8ba8f85fa789df59995a93647f8e932d194f64 | [
"Apache-2.0"
] | null | null | null | src/util.h | interma/toy_db | 9b8ba8f85fa789df59995a93647f8e932d194f64 | [
"Apache-2.0"
] | null | null | null | src/util.h | interma/toy_db | 9b8ba8f85fa789df59995a93647f8e932d194f64 | [
"Apache-2.0"
] | null | null | null | #ifndef UTIL_H_
#define UTIL_H_
#include <algorithm>
#include <stdio.h>
#include <stdint.h>
#include <sys/time.h>
#include <time.h>
/**
* copy from leveldb
*/
class PosixLogger {
private:
FILE* file_;
PosixLogger(const PosixLogger&);
void operator=(const PosixLogger&);
public:
PosixLogger(FILE* f) : file_(f) { }
~PosixLogger() { fclose(file_); }
void Logv(const char* format, ...);
};
uint64_t hash(const void *key, int len);
uint32_t crc(const void *buf, size_t len, uint32_t cr=0);
int GetFileSize(const char *fname, uint64_t* size);
#endif
| 18.633333 | 57 | 0.695886 |
ca8cd05ec67ecbbd39fc71d22ab23759e583f1d6 | 3,230 | h | C | Code/Octree.h | JaumeMontagut/CITM_3_GameEngine | 57a85b89a72723ce555a4eec3830e6bf00499de9 | [
"MIT"
] | 1 | 2020-07-09T00:38:40.000Z | 2020-07-09T00:38:40.000Z | Code/Octree.h | YessicaSD/CITM_3_GameEngine | 57a85b89a72723ce555a4eec3830e6bf00499de9 | [
"MIT"
] | null | null | null | Code/Octree.h | YessicaSD/CITM_3_GameEngine | 57a85b89a72723ce555a4eec3830e6bf00499de9 | [
"MIT"
] | null | null | null | #ifndef OCTREE_H_
#define OCTREE_H_
#include "MathGeoLib/include/Geometry/AABB.h"
#include "CubeLine.h"
#include "GameObject.h"
#include "ComponentTransform.h"
#include <list>
#include <map>
#define MAX_BUCKET_SIZE 6
#define MAX_SUBDIVISION 15
/*
----------- MaxPoint
| NW | NE |
|---------|
| SW | SE |
-----------
MinPoint
*/
enum OctreeIndix
{
TOP_NW,
TOP_NE,
TOP_SW,
TOP_SE,
BOTTOM_NW,
BOTTOM_NE,
BOTTOM_SW,
BOTTOM_SE,
};
class OctreeNode
{
public:
OctreeNode(const AABB& limits);
void Insert(ComponentTransform* transform);
void Erase(ComponentTransform* transform);
template<typename TYPE>
void CollectIntersections(std::vector<ComponentTransform*>& objects, const TYPE& primitive) const;
template<typename TYPE>
void CollectIntersections(std::map<float, ComponentTransform*>& objects, const TYPE& primitive) const;
private:
AABB limits;
CubeLine box;
uint division_level = 0;
bool is_divided = false;
std::list<ComponentTransform*> objects;
OctreeNode* childs[8];
void CreateChildsNodes();
void RedistributeObjects();
void Draw();
friend class Octree;
};
class Octree
{
public:
void SetLimits(const AABB& box);
void Insert(ComponentTransform* go);
void Erase(ComponentTransform* go);
void Clear();
void Draw();
template<typename TYPE>
void CollectIntersections(std::vector<ComponentTransform*>& objects, const TYPE& primitive) const;
//This funtion is thought to be used with raycasting
template<typename TYPE>
void CollectIntersections(std::map<float, ComponentTransform*>& objects, const TYPE& primitive) const;
private:
OctreeNode* root_node = nullptr;
};
template<typename TYPE>
inline void Octree::CollectIntersections(std::vector<ComponentTransform*>& objects, const TYPE & primitive) const
{
if (root_node != nullptr)
{
root_node->CollectIntersections(objects, primitive);
}
}
template<typename TYPE>
inline void Octree::CollectIntersections(std::map<float, ComponentTransform*>& objects, const TYPE & primitive) const
{
if (root_node != nullptr)
{
root_node->CollectIntersections(objects, primitive);
}
}
template<typename TYPE>
inline void OctreeNode::CollectIntersections(std::vector<ComponentTransform*>& objects, const TYPE & primitive) const
{
if (primitive.Intersects(limits))
{
for (std::list<ComponentTransform*>::const_iterator it = this->objects.begin(); it != this->objects.end(); ++it)
{
if (primitive.Intersects((*it)->bounding_box.GetOBB()))
{
objects.push_back(*it);
}
}
if (is_divided)
{
for (int i = 0; i < 8; ++i)
{
childs[i]->CollectIntersections(objects, primitive);
}
}
}
}
template<typename TYPE>
inline void OctreeNode::CollectIntersections(std::map<float, ComponentTransform*>& objects, const TYPE & primitive) const
{
if (primitive.Intersects(limits))
{
float hit_near, hit_far;
for (std::list<ComponentTransform*>::const_iterator it = this->objects.begin(); it != this->objects.end(); ++it)
{
if (primitive.Intersects((*it)->bounding_box.GetOBB(), hit_near, hit_far))
objects[hit_near] = *it;
}
if (is_divided)
{
for (uint i = 0u; i < 8; i++)
{
childs[i]->CollectIntersections(objects, primitive);
}
}
}
}
#endif // !OCTREE_H_
| 21.972789 | 121 | 0.710836 |
a63f15f5de942a3398b1c8852af18a3ef74f9b2d | 1,039 | h | C | qqtw/qqheaders7.2/QQVipPicEditBaseMenuBar.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 5 | 2018-02-20T14:24:17.000Z | 2020-08-06T09:31:21.000Z | qqtw/qqheaders7.2/QQVipPicEditBaseMenuBar.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 1 | 2020-06-10T07:49:16.000Z | 2020-06-12T02:08:35.000Z | qqtw/qqheaders7.2/QQVipPicEditBaseMenuBar.h | onezens/SmartQQ | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | null | null | null | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "UIView.h"
@class NSArray, PicEditBaseMenuBarItem;
@interface QQVipPicEditBaseMenuBar : UIView
{
UIView *_mainBar;
NSArray *_itemArr;
PicEditBaseMenuBarItem *_selectedItem;
id <QQVipPicEditMenuBarDelegate> _delegate;
}
+ (id)defaultMenuBar;
+ (id)defaultMenuBarItemArr;
- (void).cxx_destruct;
- (void)barItemClick:(id)arg1;
@property(nonatomic) __weak id <QQVipPicEditMenuBarDelegate> delegate; // @synthesize delegate=_delegate;
- (void)hideItemsByKeys:(id)arg1;
@property(retain, nonatomic) NSArray *itemArr; // @synthesize itemArr=_itemArr;
- (id)itemForKey:(id)arg1;
@property(retain, nonatomic) UIView *mainBar; // @synthesize mainBar=_mainBar;
@property(retain, nonatomic) PicEditBaseMenuBarItem *selectedItem; // @synthesize selectedItem=_selectedItem;
- (void)setBarItemArray:(id)arg1;
- (void)setSelected:(_Bool)arg1 forItem:(id)arg2;
- (void)showAllItems;
@end
| 29.685714 | 109 | 0.74591 |
43a7022502d09f87ad3d7781abf56a03a30a97af | 3,261 | h | C | p5jsws281x/index_html.h | david510c/p5-js-ws281x | 0298ad2d4212850778432b60358639e00474dd37 | [
"MIT"
] | 6 | 2018-03-13T03:52:33.000Z | 2021-12-23T21:58:28.000Z | p5jsws281x/index_html.h | david510c/p5-js-ws281x | 0298ad2d4212850778432b60358639e00474dd37 | [
"MIT"
] | null | null | null | p5jsws281x/index_html.h | david510c/p5-js-ws281x | 0298ad2d4212850778432b60358639e00474dd37 | [
"MIT"
] | 4 | 2018-05-27T14:05:01.000Z | 2021-01-27T18:51:47.000Z | // This contains the HTML and JavaScript for the client browser.
// Note p5.js setup() and draw() are here. PROGMEM is a way
// in Arduino speak to save RAM. PROGMEM puts this string in
// program memory which means FLASH. The R"=====(...)====="
// construct is called a C++ raw liternal and is used so
// characters such as double quotes do not have to be escaped.
const char INDEX_HTML[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
<title>p5.js LED grid demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name = "viewport" content = "width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable=0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.14/p5.min.js"></script>
<script>
var websock;
var WebSockOpen=0; //0=close,1=opening,2=open
var SCALER;
var r, g, b;
function start() {
websock = new WebSocket("ws://" + window.location.hostname + ":81/");
WebSockOpen=1;
websock.onopen = function(evt) {
console.log('websock open');
WebSockOpen=2;
var e = document.getElementById('webSockStatus');
e.style.backgroundColor = 'green';
};
websock.onclose = function(evt) {
console.log('websock close');
WebSockOpen=0;
var e = document.getElementById('webSockStatus');
e.style.backgroundColor = 'red';
};
websock.onerror = function(evt) { console.log(evt); };
websock.onmessage = function(evt) {
// Messages from the client browser arrive here.
console.log('websock message ' + evt.data);
Buttons = JSON.parse(evt.data);
};
}
function setup() {
// ledgrid = createGraphics(16, 8);
ledgrid = createGraphics(8, 16);
ledgrid.background(0);
ledgrid.stroke(0, 255, 0);
ledgrid.strokeWeight(1);
ledgrid.pixelDensity(1);
SCALER = windowHeight/ledgrid.height;
createCanvas(ledgrid.width*SCALER, ledgrid.height*SCALER);
background(0);
frameRate(25);
// Pick colors randomly
r = random(255);
g = random(255);
b = random(255);
}
function draw() {
ledgrid.background(0);
ledgrid.strokeWeight(0);
ledgrid.fill(r, g, b);
ledgrid.ellipse(mouseX/SCALER, mouseY/SCALER, 5);
image(ledgrid, 0, 0, width, height);
if (WebSockOpen === 2) {
ledgrid.loadPixels();
var d = ledgrid.pixelDensity();
//console.log("pixelDensity", d);
var fullImage = 4 * (ledgrid.width * d) * (ledgrid.height * d);
//console.log("fullImage", fullImage);
var ledobj = {};
ledobj.nLEDs = ledgrid.width * ledgrid.height;
ledobj.rgb = new Array(ledobj.nLEDs*3);
for (var i = 0, j = 0; i < fullImage; i += 4, j += 3) {
//console.log(ledgrid.pixels[i], ledgrid.pixels[i+1], ledgrid.pixels[i+2]);
ledobj.rgb[j] = ledgrid.pixels[i];
ledobj.rgb[j+1] = ledgrid.pixels[i+1];
ledobj.rgb[j+2] = ledgrid.pixels[i+2];
}
websock.send(JSON.stringify(ledobj));
}
}
// When the user clicks the mouse
function mousePressed() {
// Pick new random color values
r = random(255);
g = random(255);
b = random(255);
}
</script>
</head>
<body onload="javascript:start();">
<h3>p5.js LED grid demo</h3>
<button id="webSockStatus" type="button" onclick="window.location.reload();">Connect</button>
<p>
</body>
</html>
)=====";
| 30.764151 | 120 | 0.646121 |
2c4848c770186f28184358b6a8e0e1c5a1c4fbdb | 10,812 | c | C | sys/src/cmd/gs/gp_unifs.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | 1 | 2021-03-23T22:40:43.000Z | 2021-03-23T22:40:43.000Z | sys/src/cmd/gs/gp_unifs.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | null | null | null | sys/src/cmd/gs/gp_unifs.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | 1 | 2021-12-21T06:19:58.000Z | 2021-12-21T06:19:58.000Z | /* Copyright (C) 1993, 1994 Aladdin Enterprises. All rights reserved.
This file is part of Aladdin Ghostscript.
Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing. Refer to the Aladdin Ghostscript Free Public
License (the "License") for full details.
Every copy of Aladdin Ghostscript must include a copy of the License,
normally in a plain ASCII text file named PUBLIC. The License grants you
the right to copy, modify and redistribute Aladdin Ghostscript, but only
under certain conditions described in the License. Among other things, the
License requires that the copyright notice and this notice be preserved on
all copies.
*/
/* gp_unifs.c */
/* "Unix-like" file system platform routines for Ghostscript */
#include "memory_.h"
#include "string_.h"
#include "gx.h"
#include "gp.h"
#include "gsstruct.h"
#include "gsutil.h" /* for string_match */
#include "stat_.h"
#include "dirent_.h"
#include <sys/param.h> /* for MAXPATHLEN */
/* Some systems (Interactive for example) don't define MAXPATHLEN,
* so we define it here. (This probably should be done via a Config-Script.)
*/
#ifndef MAXPATHLEN
# define MAXPATHLEN 1024
#endif
/* Library routines not declared in a standard header */
extern char *getenv(P1(const char *));
extern char *mktemp(P1(char *));
/* ------ File names ------ */
/* Define the default scratch file name prefix. */
const char gp_scratch_file_name_prefix[] = "gs_";
/* Define the name of the null output file. */
const char gp_null_file_name[] = "/dev/null";
/* Define the name that designates the current directory. */
const char gp_current_directory_name[] = ".";
/* Create and open a scratch file with a given name prefix. */
/* Write the actual file name at fname. */
FILE *
gp_open_scratch_file(const char *prefix, char *fname, const char *mode)
{ char *temp;
if ( (temp = getenv("TEMP")) == NULL )
strcpy(fname, "/tmp/");
else
{ strcpy(fname, temp);
if ( strlen(fname) != 0 && fname[strlen(fname) - 1] != '/' )
strcat(fname, "/");
}
strcat(fname, prefix);
/* Prevent trailing X's in path from being converted by mktemp. */
if ( *fname != 0 && fname[strlen(fname) - 1] == 'X' )
strcat(fname, "-");
strcat(fname, "XXXXXX");
mktemp(fname);
return fopen(fname, mode);
}
/* ------ File enumeration ------ */
/* Thanks to Fritz Elfert (Fritz_Elfert@wue.maus.de) for */
/* the original version of the following code, and Richard Mlynarik */
/* (mly@adoc.xerox.com) for an improved version. */
typedef struct dirstack_s dirstack;
struct dirstack_s {
dirstack *next;
DIR *entry;
};
gs_private_st_ptrs1(st_dirstack, dirstack, "dirstack",
dirstack_enum_ptrs, dirstack_reloc_ptrs, next);
struct file_enum_s {
DIR *dirp; /* pointer to current open directory */
char *pattern; /* original pattern */
char *work; /* current path */
int worklen; /* strlen (work) */
dirstack *dstack; /* directory stack */
int patlen;
int pathead; /* how much of pattern to consider
* when listing files in current directory */
bool first_time;
gs_memory_t *memory;
};
gs_private_st_ptrs3(st_file_enum, struct file_enum_s, "file_enum",
file_enum_enum_ptrs, file_enum_reloc_ptrs, pattern, work, dstack);
/* Private procedures */
/* Do a wild-card match. */
#define wildmat(str,pat)\
string_match((const byte *)str, strlen(str),\
(const byte *)pat, strlen(pat), NULL)
/* Search a string backward for a character. */
/* (This substitutes for strrchr, which some systems don't provide.) */
private char *
rchr(char *str, char ch, int len)
{ register char *p = str + len;
while ( p > str )
if ( *--p == ch ) return p;
return 0;
}
/* Push a directory onto the enumeration stack. */
private void
pushdir(file_enum *pfen)
{ dirstack *d =
gs_alloc_struct(pfen->memory, dirstack,
&st_dirstack, "gp_enumerate_files(pushdir)");
if ( d != 0 )
{ d->next = pfen->dstack;
d->entry = pfen->dirp;
pfen->dstack = d;
}
}
/* Pop a directory from the enumeration stack. */
private bool
popdir(file_enum *pfen)
{ dirstack *d = pfen->dstack;
if ( d == 0 )
return false;
pfen->dirp = d->entry;
pfen->dstack = d->next;
gs_free_object(pfen->memory, d, "gp_enumerate_files(popdir)");
return true;
}
/* Initialize an enumeration. */
file_enum *
gp_enumerate_files_init(const char *pat, uint patlen, gs_memory_t *mem)
{ file_enum *pfen;
char *p;
char *work;
/* Reject attempts to enumerate paths longer than the */
/* system-dependent limit. */
if ( patlen > MAXPATHLEN )
return 0;
/* Reject attempts to enumerate with a pattern containing zeroes. */
{ const char *p1;
for (p1 = pat; p1 < pat + patlen; p1++)
if (*p1 == 0) return 0;
}
/* >>> Should crunch strings of repeated "/"'s in pat to a single "/"
* >>> to match stupid unix filesystem "conventions" */
pfen = gs_alloc_struct(mem, file_enum, &st_file_enum,
"gp_enumerate_files");
if (pfen == 0)
return 0;
/* pattern and work could be allocated as strings, */
/* but it's simpler for GC and freeing to allocate them as bytes. */
pfen->pattern =
(char *)gs_alloc_bytes(mem, patlen + 1,
"gp_enumerate_files(pattern)");
if (pfen->pattern == 0)
return 0;
memcpy(pfen->pattern, pat, patlen);
pfen->pattern[patlen] = 0;
work = (char *)gs_alloc_bytes(mem, MAXPATHLEN+1,
"gp_enumerate_files(work)");
if (work == 0)
return 0;
pfen->work = work;
p = work;
memcpy(p, pat, patlen);
p += patlen;
*p = 0;
/* Remove directory specifications beyond the first wild card. */
/* Some systems don't have strpbrk, so we code it open. */
p = pfen->work;
while ( !(*p == '*' || *p == '?' || *p == 0) ) p++;
while ( !(*p == '/' || *p == 0) ) p++;
if ( *p == '/' )
*p = 0;
/* Substring for first wildcard match */
pfen->pathead = p - work;
/* Select the next higher directory-level. */
p = rchr(work, '/', p - work);
if (!p)
{ /* No directory specification */
work[0] = 0;
pfen->worklen = 0;
}
else
{ if (p == work)
{ /* Root directory -- don't turn "/" into "" */
p++;
}
*p = 0;
pfen->worklen = p - work;
}
pfen->memory = mem;
pfen->dstack = 0;
pfen->first_time = true;
pfen->patlen = patlen;
return pfen;
}
/* Enumerate the next file. */
uint
gp_enumerate_files_next(file_enum *pfen, char *ptr, uint maxlen)
{ dir_entry *de;
char *work = pfen->work;
int worklen = pfen->worklen;
char *pattern = pfen->pattern;
int pathead = pfen->pathead;
int len;
struct stat stbuf;
if ( pfen->first_time )
{ pfen->dirp = ((worklen == 0) ? opendir(".") : opendir(work));
if_debug1('0', "[0]file_enum:First-Open '%s'\n", work);
pfen->first_time = false;
if (pfen->dirp == 0) /* first opendir failed */
{ gp_enumerate_files_close(pfen);
return ~(uint)0;
}
}
top: de = readdir(pfen->dirp);
if (de == 0)
{ /* No more entries in this directory */
char *p;
if_debug0('0', "[0]file_enum:Closedir\n");
closedir(pfen->dirp);
/* Back working directory and matching pattern up one level */
p = rchr(work,'/', worklen);
if (p != 0)
{ if (p == work) p++;
*p = 0;
worklen = p - work;
}
p = rchr(pattern,'/', pathead);
if (p != 0)
pathead = p - pattern;
else
pathead = 0;
if (popdir(pfen))
{ /* Back up the directory tree. */
if_debug1('0', "[0]file_enum:Dir popped '%s'\n", work);
goto top;
}
else
{ if_debug0('0', "file_enum:Dirstack empty\n");
gp_enumerate_files_close(pfen);
return ~(uint)0;
}
}
/* Skip . and .. */
len = strlen(de->d_name);
if (len <= 2 && (!strcmp(de->d_name,".") || !strcmp(de->d_name,"..") ))
goto top;
if (len + worklen + 1 > MAXPATHLEN)
/* Should be an error, I suppose */
goto top;
if (worklen == 0)
{ /* "Current" directory (evil un*x kludge) */
memcpy(work, de->d_name, len + 1);
}
else if (worklen == 1 && work[0] == '/')
{ /* Root directory */
memcpy(work + 1, de->d_name, len + 1);
len = len + 1;
}
else
{ work[worklen] = '/';
memcpy(work + worklen + 1, de->d_name, len + 1);
len = worklen + 1 + len;
}
/* Test for a match at this directory level */
if (!string_match((byte *)work, len, (byte *)pattern, pathead, NULL))
goto top;
/* Perhaps descend into subdirectories */
if (pathead < pfen->patlen)
{ DIR *dp;
if (((stat(work,&stbuf) >= 0)
? !stat_is_dir(stbuf)
/* Couldn't stat it.
* Well, perhaps it's a directory and
* we'll be able to list it anyway.
* If it isn't or we can't, no harm done. */
: 0))
goto top;
if (pfen->patlen == pathead + 1)
{ /* Listing "foo/?/" -- return this entry */
/* if it's a directory. */
if (!stat_is_dir (stbuf))
{ /* Do directoryp test the hard way */
dp = opendir(work);
if (!dp) goto top;
closedir(dp);
}
work[len++] = '/';
goto winner;
}
/* >>> Should optimise the case in which the next level */
/* >>> of directory has no wildcards. */
dp = opendir(work);
#ifdef DEBUG
{ char save_end = pattern[pathead];
pattern[pathead] = 0;
if_debug2('0', "[0]file_enum:fname='%s', p='%s'\n",
work, pattern);
pattern[pathead] = save_end;
}
#endif /* DEBUG */
if (!dp)
/* Can't list this one */
goto top;
else
{ /* Advance to the next directory-delimiter */
/* in pattern */
char *p;
for (p = pattern + pathead + 1; ; p++)
{ if (*p == 0)
{ /* No more subdirectories to match */
pathead = pfen->patlen;
break;
}
else if (*p == '/')
{ pathead = p - pattern;
break;
}
}
pushdir(pfen);
if_debug1('0', "file_enum:Dir pushed '%s'\n",
work);
worklen = len;
pfen->dirp = dp;
goto top;
}
}
winner:
/* We have a winner! */
pfen->worklen = worklen;
pfen->pathead = pathead;
memcpy(ptr, work, len);
return len;
}
/* Clean up the file enumeration. */
void
gp_enumerate_files_close(file_enum *pfen)
{ gs_memory_t *mem = pfen->memory;
if_debug0('0', "[0]file_enum:Cleanup\n");
while (popdir(pfen)) ; /* clear directory stack */
gs_free_object(mem, (byte *)pfen->work,
"gp_enumerate_close(work)");
gs_free_object(mem, (byte *)pfen->pattern,
"gp_enumerate_files_close(pattern)");
gs_free_object(mem, pfen, "gp_enumerate_files_close");
}
/* Test-cases:
(../?*r*?/?*.ps) {==} 100 string filenameforall
(../?*r*?/?*.ps*) {==} 100 string filenameforall
(../?*r*?/) {==} 100 string filenameforall
(/t*?/?*.ps) {==} 100 string filenameforall
*/
| 27.165829 | 77 | 0.617647 |
2c501c24fb904c0b122f6791081ece09c5d28837 | 2,084 | h | C | DQM/SiStripMonitorSummary/plugins/SiStripPlotGain.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | DQM/SiStripMonitorSummary/plugins/SiStripPlotGain.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | DQM/SiStripMonitorSummary/plugins/SiStripPlotGain.h | pasmuss/cmssw | 566f40c323beef46134485a45ea53349f59ae534 | [
"Apache-2.0"
] | null | null | null | // -*- C++ -*-
//
// Package: SiStripPlotGain
// Class: SiStripPlotGain
//
/**\class SiStripPlotGain SiStripPlotGain.cc DQM/SiStripMonitorSummary/plugins/SiStripPlotGain.cc
Description: <one line class summary>
Implementation:
<Notes on implementation>
*/
//
// Original Author: Domenico GIORDANO
// Created: Mon Aug 10 10:42:04 CEST 2009
//
//
// system include files
#include <memory>
// user include files
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "CondFormats/SiStripObjects/interface/SiStripApvGain.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CalibTracker/Records/interface/SiStripDependentRecords.h"
#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
#include "CommonTools/TrackerMap/interface/TrackerMap.h"
#include "TH2F.h"
#include "TH1F.h"
#include "TFile.h"
//
// class decleration
//
class TrackerTopology;
class SiStripPlotGain : public edm::EDAnalyzer {
public:
explicit SiStripPlotGain(const edm::ParameterSet&);
~SiStripPlotGain();
private:
virtual void beginRun(const edm::Run& run, const edm::EventSetup& es);
virtual void analyze(const edm::Event&, const edm::EventSetup&){};
virtual void endJob();
void DoAnalysis(const edm::EventSetup& es, const SiStripApvGain&);
void getHistos(const uint32_t & detid, const TrackerTopology* tTopo, std::vector<TH1F*>& histos);
TH1F* getHisto(const long unsigned int& index);
unsigned long long getCache(const edm::EventSetup & eSetup){ return eSetup.get<SiStripApvGainRcd>().cacheIdentifier();}
// ----------member data ---------------------------
SiStripDetInfoFileReader * fr;
edm::ESHandle<SiStripApvGain> Handle_;
TFile* file;
std::vector<TH1F*> vTH1;
TrackerMap *tkmap;
unsigned long long cacheID;
};
| 24.517647 | 121 | 0.731286 |
c8853b42e7c1915eaa3314fb00eba8c86c85b0c5 | 15,568 | h | C | include/esb.h | odwraca/nrf9160-dk-aws-fota-secure | ca56782313b6a91e795d614be40b071b33936737 | [
"MIT-0",
"MIT"
] | 1 | 2021-07-24T14:58:23.000Z | 2021-07-24T14:58:23.000Z | include/esb.h | odwraca/nrf9160-dk-aws-fota-secure | ca56782313b6a91e795d614be40b071b33936737 | [
"MIT-0",
"MIT"
] | 1 | 2020-04-07T16:59:58.000Z | 2020-04-07T16:59:58.000Z | include/esb.h | odwraca/nrf9160-dk-aws-fota-secure | ca56782313b6a91e795d614be40b071b33936737 | [
"MIT-0",
"MIT"
] | 1 | 2020-05-12T13:33:52.000Z | 2020-05-12T13:33:52.000Z | /*
* Copyright (c) 2018 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/
#ifndef __ESB_H
#define __ESB_H
#include <errno.h>
#include <sys/util.h>
#include <nrf.h>
#include <stdbool.h>
#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup esb Enhanced ShockBurst
* @{
* @ingroup proprietary_api
*
* @brief Enhanced ShockBurst (ESB) is a basic protocol that supports two-way
* data packet communication including packet buffering, packet
* acknowledgment, and automatic retransmission of lost packets.
*/
/** The ESB event IRQ number when running on an nRF5 device. */
#define ESB_EVT_IRQ SWI0_IRQn
/** The handler for @ref ESB_EVT_IRQ when running on an nRF5 device. */
#define ESB_EVT_IRQHandler SWI0_IRQHandler
/** @brief Default radio parameters.
*
* Roughly equal to the nRF24Lxx default parameters except for CRC,
* which is set to 16 bit, and protocol, which is set to DPL.
*/
#define ESB_DEFAULT_CONFIG \
{ \
.protocol = ESB_PROTOCOL_ESB_DPL, \
.mode = ESB_MODE_PTX, \
.event_handler = 0, \
.bitrate = ESB_BITRATE_2MBPS, \
.crc = ESB_CRC_16BIT, \
.tx_output_power = ESB_TX_POWER_0DBM, \
.retransmit_delay = 600, \
.retransmit_count = 3, \
.tx_mode = ESB_TXMODE_AUTO, \
.radio_irq_priority = 1, \
.event_irq_priority = 2, \
.payload_length = 32, \
.selective_auto_ack = false \
}
/** @brief Default legacy radio parameters.
*
* Identical to the nRF24Lxx defaults.
*/
#define ESB_LEGACY_CONFIG \
{ \
.protocol = ESB_PROTOCOL_ESB, \
.mode = ESB_MODE_PTX, \
.event_handler = 0, \
.bitrate = ESB_BITRATE_2MBPS, \
.crc = ESB_CRC_8BIT, \
.tx_output_power = ESB_TX_POWER_0DBM, \
.retransmit_delay = 600, \
.retransmit_count = 3, \
.tx_mode = ESB_TXMODE_AUTO, \
.radio_irq_priority = 1, \
.event_irq_priority = 2, \
.payload_length = 32, \
.selective_auto_ack = false \
}
/** @brief Macro to create an initializer for a TX data packet.
*
* This macro generates an initializer.
*
* @param[in] _pipe The pipe to use for the data packet.
* @param[in] ... Comma separated list of character data to put in the
* TX buffer. Supported values consist of 1 to 63
* characters.
*
* @return Initializer that sets up the pipe, length, and byte array for
* content of the TX data.
*/
#define ESB_CREATE_PAYLOAD(_pipe, ...) \
{ \
.pipe = _pipe, \
.length = NUM_VA_ARGS_LESS_1(_pipe, __VA_ARGS__), \
.data = { \
__VA_ARGS__ \
} \
}
/** @brief Enhanced ShockBurst protocols. */
enum esb_protocol {
ESB_PROTOCOL_ESB, /**< Fixed payload length. */
ESB_PROTOCOL_ESB_DPL /**< Dynamic payload length. */
};
/** @brief Enhanced ShockBurst modes. */
enum esb_mode {
ESB_MODE_PTX, /**< Primary transmitter mode. */
ESB_MODE_PRX /**< Primary receiver mode. */
};
/** @brief Enhanced ShockBurst bitrate modes. */
enum esb_bitrate {
/** 1 Mb radio mode. */
ESB_BITRATE_1MBPS = RADIO_MODE_MODE_Nrf_1Mbit,
/** 2 Mb radio mode. */
ESB_BITRATE_2MBPS = RADIO_MODE_MODE_Nrf_2Mbit,
#if !(defined(CONFIG_SOC_NRF52840) || defined(CONFIG_SOC_NRF52810) || \
defined(CONFIG_SOC_NRF52811))
/** 250 Kb radio mode. */
ESB_BITRATE_250KBPS = RADIO_MODE_MODE_Nrf_250Kbit,
#endif
/** 1 Mb radio mode using @e Bluetooth low energy radio parameters. */
ESB_BITRATE_1MBPS_BLE = RADIO_MODE_MODE_Ble_1Mbit,
#if defined(CONFIG_SOC_SERIES_NRF52X)
/** 2 Mb radio mode using @e Bluetooth low energy radio parameters. */
ESB_BITRATE_2MBPS_BLE = 4,
#endif
};
/** @brief Enhanced ShockBurst CRC modes. */
enum esb_crc {
ESB_CRC_16BIT = RADIO_CRCCNF_LEN_Two, /**< Use two-byte CRC. */
ESB_CRC_8BIT = RADIO_CRCCNF_LEN_One, /**< Use one-byte CRC. */
ESB_CRC_OFF = RADIO_CRCCNF_LEN_Disabled /**< Disable CRC. */
};
/** @brief Enhanced ShockBurst radio transmission power modes. */
enum esb_tx_power {
/** 4 dBm radio transmit power. */
ESB_TX_POWER_4DBM = RADIO_TXPOWER_TXPOWER_Pos4dBm,
#if defined(CONFIG_SOC_SERIES_NRF52X)
/** 3 dBm radio transmit power. */
ESB_TX_POWER_3DBM = RADIO_TXPOWER_TXPOWER_Pos3dBm,
#endif
/** 0 dBm radio transmit power. */
ESB_TX_POWER_0DBM = RADIO_TXPOWER_TXPOWER_0dBm,
/** -4 dBm radio transmit power. */
ESB_TX_POWER_NEG4DBM = RADIO_TXPOWER_TXPOWER_Neg4dBm,
/** -8 dBm radio transmit power. */
ESB_TX_POWER_NEG8DBM = RADIO_TXPOWER_TXPOWER_Neg8dBm,
/** -12 dBm radio transmit power. */
ESB_TX_POWER_NEG12DBM = RADIO_TXPOWER_TXPOWER_Neg12dBm,
/** -16 dBm radio transmit power. */
ESB_TX_POWER_NEG16DBM = RADIO_TXPOWER_TXPOWER_Neg16dBm,
/** -20 dBm radio transmit power. */
ESB_TX_POWER_NEG20DBM = RADIO_TXPOWER_TXPOWER_Neg20dBm,
/** -30 dBm radio transmit power. */
ESB_TX_POWER_NEG30DBM = RADIO_TXPOWER_TXPOWER_Neg30dBm,
/** -40 dBm radio transmit power. */
ESB_TX_POWER_NEG40DBM = RADIO_TXPOWER_TXPOWER_Neg40dBm
};
/** @brief Enhanced ShockBurst transmission modes. */
enum esb_tx_mode {
/** Automatic TX mode: When the TX FIFO contains packets and the
* radio is idle, packets are sent automatically.
*/
ESB_TXMODE_AUTO,
/** Manual TX mode: Packets are not sent until @ref esb_start_tx
* is called. This mode can be used to ensure consistent packet timing.
*/
ESB_TXMODE_MANUAL,
/** Manual start TX mode: Packets are not sent until
* @ref esb_start_tx is called. Then, transmission continues
* automatically until the TX FIFO is empty.
*/
ESB_TXMODE_MANUAL_START
};
/** @brief Enhanced ShockBurst event IDs. */
enum esb_evt_id {
ESB_EVENT_TX_SUCCESS, /**< Event triggered on TX success. */
ESB_EVENT_TX_FAILED, /**< Event triggered on TX failure. */
ESB_EVENT_RX_RECEIVED /**< Event triggered on RX received. */
};
/** @brief Enhanced ShockBurst payload.
*
* The payload is used both for transmissions and for acknowledging a
* received packet with a payload.
*/
struct esb_payload {
u8_t length; /**< Length of the packet when not in DPL mode. */
u8_t pipe; /**< Pipe used for this payload. */
s8_t rssi; /**< RSSI for the received packet. */
u8_t noack; /**< Flag indicating that this packet will not be
* acknowledged. Flag is ignored when selective auto
* ack is enabled.
*/
u8_t pid; /**< PID assigned during communication. */
u8_t data[CONFIG_ESB_MAX_PAYLOAD_LENGTH]; /**< The payload data. */
};
/** @brief Enhanced ShockBurst event. */
struct esb_evt {
enum esb_evt_id evt_id; /**< Enhanced ShockBurst event ID. */
u32_t tx_attempts; /**< Number of TX retransmission attempts. */
};
/** @brief Event handler prototype. */
typedef void (*esb_event_handler)(const struct esb_evt *event);
/** @brief Main configuration structure for the module. */
struct esb_config {
enum esb_protocol protocol; /**< Protocol. */
enum esb_mode mode; /**< Mode. */
esb_event_handler event_handler; /**< Event handler. */
/* General RF parameters */
enum esb_bitrate bitrate; /**< Bitrate mode. */
enum esb_crc crc; /**< CRC mode. */
enum esb_tx_power tx_output_power; /**< Radio TX power. */
u16_t retransmit_delay; /**< The delay between each retransmission of
* unacknowledged packets.
*/
u16_t retransmit_count; /**< The number of retransmission attempts
* before transmission fail.
*/
/* Control settings */
enum esb_tx_mode tx_mode; /**< Transmission mode. */
u8_t radio_irq_priority; /**< nRF radio interrupt priority. */
u8_t event_irq_priority; /**< ESB event interrupt priority. */
u8_t payload_length; /**< Length of the payload (maximum length depends
* on the platforms that are used on each side).
*/
bool selective_auto_ack; /**< Selective auto acknowledgement.
* When this feature is disabled, all packets
* will be acknowledged ignoring the noack
* field.
*/
};
/** @brief Initialize the Enhanced ShockBurst module.
*
* @param config Parameters for initializing the module.
*
* @return Zero on success or (negative) error code otherwise.
*/
int esb_init(const struct esb_config *config);
/** @brief Suspend the Enhanced ShockBurst module.
*
* Calling this function stops ongoing communications without changing the
* queues.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_suspend(void);
/** @brief Disable the Enhanced ShockBurst module.
*
* Calling this function disables the Enhanced ShockBurst module immediately.
* Doing so might stop ongoing communications.
*
* @note All queues are flushed by this function.
*
*/
void esb_disable(void);
/** @brief Check if the Enhanced ShockBurst module is idle.
*
* @return True if the module is idle, false otherwise.
*/
bool esb_is_idle(void);
/** @brief Write a payload for transmission or acknowledgement.
*
* This function writes a payload that is added to the queue. When the module
* is in PTX mode, the payload is queued for a regular transmission. When the
* module is in PRX mode, the payload is queued for when a packet is received
* that requires an acknowledgement with payload.
*
* @param[in] payload The payload.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_write_payload(const struct esb_payload *payload);
/** @brief Read a payload.
*
* @param[in,out] payload The payload to be received.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_read_rx_payload(struct esb_payload *payload);
/** @brief Start transmitting data.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_start_tx(void);
/** @brief Start receiving data.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_start_rx(void);
/** @brief Stop data reception.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_stop_rx(void);
/** @brief Flush the TX buffer.
*
* This function clears the TX FIFO buffer.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_flush_tx(void);
/** @brief Pop the first item from the TX buffer.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_pop_tx(void);
/** @brief Flush the RX buffer.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_flush_rx(void);
/** @brief Set the length of the address.
*
* @param[in] length Length of the ESB address (in bytes).
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_address_length(u8_t length);
/** @brief Set the base address for pipe 0.
*
* @param[in] addr Address.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_base_address_0(const u8_t *addr);
/** @brief Set the base address for pipe 1 to pipe 7.
*
* @param[in] addr Address.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_base_address_1(const u8_t *addr);
/** @brief Set the number of pipes and the pipe prefix addresses.
*
* This function configures the number of available pipes, enables the pipes,
* and sets their prefix addresses.
*
* @param[in] prefixes Prefixes for each pipe.
* @param[in] num_pipes Number of pipes. Must be less than or equal to
* @ref CONFIG_ESB_PIPE_COUNT.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_prefixes(const u8_t *prefixes, u8_t num_pipes);
/** @brief Enable select pipes.
*
* The @p enable_mask parameter must contain the same number of pipes as has
* been configured with @ref esb_set_prefixes. This number may not be
* greater than the number defined by @ref CONFIG_ESB_PIPE_COUNT
*
* @param enable_mask Bitfield mask to enable or disable pipes.
* Setting a bit to 0 disables the pipe.
* Setting a bit to 1 enables the pipe.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_enable_pipes(u8_t enable_mask);
/** @brief Update pipe prefix.
*
* @param pipe Pipe for which to set the prefix.
* @param prefix Prefix to set for the pipe.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_update_prefix(u8_t pipe, u8_t prefix);
/** @brief Set the channel to use for the radio.
*
* The module must be in an idle state to call this function. As a PTX, the
* application must wait for an idle state and as a PRX, the application must
* stop RX before changing the channel. After changing the channel, operation
* can be resumed.
*
* @param[in] channel Channel to use for radio.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_rf_channel(u32_t channel);
/** @brief Get the current radio channel.
*
* @param[in, out] channel Channel number.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_get_rf_channel(u32_t *channel);
/** @brief Set the radio output power.
*
* @param[in] tx_output_power Output power.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_tx_power(enum esb_tx_power tx_output_power);
/** @brief Set the packet retransmit delay.
*
* @param[in] delay Delay between retransmissions.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_retransmit_delay(u16_t delay);
/** @brief Set the number of retransmission attempts.
*
* @param[in] count Number of retransmissions.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_retransmit_count(u16_t count);
/** @brief Set the radio bitrate.
*
* @param[in] bitrate Radio bitrate.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_set_bitrate(enum esb_bitrate bitrate);
/** @brief Reuse a packet ID for a specific pipe.
*
* The ESB protocol uses a 2-bit sequence number (packet ID) to identify
* retransmitted packets. By default, the packet ID is incremented for every
* uploaded packet. Use this function to prevent this and send two different
* packets with the same packet ID.
*
* @param[in] pipe Pipe.
*
* @retval 0 If successful.
* Otherwise, a (negative) error code is returned.
*/
int esb_reuse_pid(u8_t pipe);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ESB */
| 31.642276 | 80 | 0.654997 |
bdea33fdfe9b59ec72f940e9e1f28f52c7cc8a3f | 701 | h | C | include/dg/llvm/analysis/PointsTo/LLVMPointerAnalysisOptions.h | xvitovs1/dg | 5cbd66e20e2235195b45446efb3528f3422d07d4 | [
"MIT"
] | 1 | 2019-09-16T07:36:46.000Z | 2019-09-16T07:36:46.000Z | include/dg/llvm/analysis/PointsTo/LLVMPointerAnalysisOptions.h | Machiry/dg | f87c84ebe01a5de911df817302e7144fc9a3269e | [
"MIT"
] | null | null | null | include/dg/llvm/analysis/PointsTo/LLVMPointerAnalysisOptions.h | Machiry/dg | f87c84ebe01a5de911df817302e7144fc9a3269e | [
"MIT"
] | null | null | null | #ifndef _DG_LLVM_POINTER_ANALYSIS_OPTIONS_H_
#define _DG_LLVM_POINTER_ANALYSIS_OPTIONS_H_
#include "dg/llvm/analysis/LLVMAnalysisOptions.h"
#include "dg/analysis/PointsTo/PointerAnalysisOptions.h"
namespace dg {
namespace analysis {
struct LLVMPointerAnalysisOptions : public LLVMAnalysisOptions, PointerAnalysisOptions
{
enum class AnalysisType { fi, fs, inv } analysisType{AnalysisType::fi};
bool isFS() const { return analysisType == AnalysisType::fs; }
bool isFSInv() const { return analysisType == AnalysisType::inv; }
bool isFI() const { return analysisType == AnalysisType::fi; }
};
} // namespace analysis
} // namespace dg
#endif // _DG_LLVM_POINTER_ANALYSIS_OPTIONS_H_
| 30.478261 | 86 | 0.773181 |
084dad277c78511d6b4e837f1784cff6f87e1b15 | 18,413 | c | C | test/manual/passfd.c | master-elodin/appscope | 17253d191f30d5ef31d7d78412940bf93a82d26f | [
"Apache-2.0"
] | null | null | null | test/manual/passfd.c | master-elodin/appscope | 17253d191f30d5ef31d7d78412940bf93a82d26f | [
"Apache-2.0"
] | null | null | null | test/manual/passfd.c | master-elodin/appscope | 17253d191f30d5ef31d7d78412940bf93a82d26f | [
"Apache-2.0"
] | null | null | null | /*
* passfd.c - Test to see that Scope is handling the passing of fd access
* rights between processes correctly
*
* gcc -g -Wall test/manual/passfd.c -lpthread -o test/linux/passfd
*
* 1) passfd is a parent that sends access rights to a child process over a UNIX socket.
*
* 2) In order to send a file or socket descriptor, the parent opens
* a file and creates a TCP socket. In order to get a TCP socket descriptor,
* the parent creates a thread which implements the server-side (accept) socket.
*
* 3) The parent sends the access rights of the file &/or socket descriptor
* to the child over the UNIX socket.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <pthread.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/wait.h>
#define TESTFILE "/tmp/pass.txt"
#define EVENTFILE "/tmp/scope_events.log"
#define TESTPORT "9009"
#define TESTPORTNO 9009
#define HOST "localhost"
#define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && \
(cmsg)->cmsg_len <= (unsigned long) \
((mhdr)->msg_controllen - \
((char *)(cmsg) - (char *)(mhdr)->msg_control)))
char *pfile;
void
usage(char *prog) {
fprintf(stderr,"usage: %s [-v] -f pipe/file\n", prog);
exit(-1);
}
int
check_event(char **validation, int numval)
{
int fd, i, rc = 0;
char *buf;
struct stat sbuf;
if ((fd = open(EVENTFILE, O_RDONLY)) == -1) {
perror("open:check_event");
return -1;
}
if (fstat(fd, &sbuf) == -1) {
perror("fstat:check_event");
return -1;
}
if ((buf = calloc(1, sbuf.st_size)) == NULL) {
perror("calloc:check_event");
return -1;
}
if ((read(fd, buf, sbuf.st_size)) <= 0) {
perror("read:check_event");
return -1;
}
// look for validation strings within the same event line
if (numval > 0) {
char *thisval;
if ((thisval = strstr(buf, validation[0])) != NULL) {
for (i = 1; i < numval; i++) {
if ((thisval = strstr(thisval, validation[i])) == NULL) {
rc = -1;
break;
}
}
} else {
rc = -1;
}
}
if (close(fd) == -1) {
perror("close:check_event");
return -1;
}
if (unlink(EVENTFILE) == -1) {
perror("unlink:check_event");
return -1;
}
if (buf) free(buf);
return rc;
}
int
send_array_rights(int sd, int *sendfds, int numfds)
{
int clen;
struct msghdr msg;
struct iovec iov[1];
struct cmsghdr *cmptr;
char control[CMSG_SPACE(sizeof(int) * numfds)];
char tdata[] = "test";
msg.msg_control = control;
msg.msg_controllen = sizeof(control);
cmptr = CMSG_FIRSTHDR(&msg);
cmptr->cmsg_len = CMSG_LEN(sizeof(int) * numfds);
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
memcpy(CMSG_DATA(cmptr), sendfds, sizeof(int) * numfds);
fprintf(stderr, "Parent:numfds %d controllen %ld cmsg_len %ld\n",
numfds, msg.msg_controllen, cmptr->cmsg_len);
msg.msg_name = NULL;
msg.msg_namelen = 0;
iov[0].iov_base = tdata;
iov[0].iov_len = strlen(tdata);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
fprintf(stderr, "Parent:send_array_rights\n");
if ((clen = sendmsg(sd, &msg, 0)) == -1) {
perror("sendmsg:send_array_rights");
return -1;
}
fprintf(stderr, "Parent:sent %d bytes\n", clen);
return 0;
}
/*
* This is not used. Left it here in case
* we find that this changes or other UNIX
* releases do support this.
*
* The Linux kernel does not allow multiple
* cmsg headers sent in a single message.
* Ref Linux source:
* net/unix/af_unix.c:unix_stream_sendmsg()
*
*/
int
send_multiple_rights(int sd, int *sendfds, int numfds)
{
int clen;
size_t csize;
struct msghdr msg;
struct iovec iov;
struct cmsghdr *cmptr;
//char control[CMSG_SPACE(sizeof(int) * numfds)];
char *control;
char tdata[] = "test";
csize = CMSG_SPACE(sizeof(int)) + CMSG_SPACE(sizeof(int));
if ((control = malloc(CMSG_LEN(csize))) == NULL) return -1;
memset(control, 0, CMSG_LEN(csize));
memset(&iov, 0, sizeof(iov));
msg.msg_control = control;
msg.msg_controllen = csize;
cmptr = CMSG_FIRSTHDR(&msg);
if (!cmptr) {
fprintf(stderr, "Can't get a first header\n");
free(control);
return -1;
}
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
*(int *) CMSG_DATA(cmptr) = sendfds[0];
if (!CMSG_OK(&msg, cmptr)) {
fprintf(stderr, "ERROR: self test1: invalid argument\n");
free(control);
return -1;
}
CMSG_NXTHDR(&msg, cmptr);
if (!cmptr) {
fprintf(stderr, "Can't get a second header\n");
free(control);
return -1;
}
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
*(int *) CMSG_DATA(cmptr) = sendfds[1];
if (!CMSG_OK(&msg, cmptr)) {
fprintf(stderr, "ERROR: self test2: invalid argument\n");
free(control);
return -1;
}
msg.msg_name = NULL;
msg.msg_namelen = 0;
iov.iov_base = tdata;
iov.iov_len = strlen(tdata);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
fprintf(stderr, "cmsghdr %ld control 0x%p ctl len %ld msg1 0x%p msg2 0x%p\n",
sizeof(struct cmsghdr), msg.msg_control, msg.msg_controllen,
CMSG_FIRSTHDR(&msg), CMSG_NXTHDR(&msg, cmptr));
fprintf(stderr, "Parent:send_multiple_rights\n");
if ((clen = sendmsg(sd, &msg, 0)) == -1) {
perror("sendmsg:send_multiple_rights");
free(control);
return -1;
}
fprintf(stderr, "Parent:sent %d bytes\n", clen);
free(control);
return 0;
}
int
send_access_rights(int sd, int sendfd)
{
int clen;
struct msghdr msg;
struct iovec iov[1];
struct cmsghdr *cmptr;
char control[CMSG_SPACE(sizeof(int))];
char tdata[] = "test";
msg.msg_control = control;
msg.msg_controllen = sizeof(control);
cmptr = CMSG_FIRSTHDR(&msg);
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
*((int *) CMSG_DATA(cmptr)) = sendfd;
msg.msg_name = NULL;
msg.msg_namelen = 0;
iov[0].iov_base = tdata;
iov[0].iov_len = strlen(tdata);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
fprintf(stderr, "Parent:send_access_rights\n");
if ((clen = sendmsg(sd, &msg, 0)) == -1) {
perror("sendmsg:send_access_rights");
return -1;
}
fprintf(stderr, "Parent:sent %d bytes\n", clen);
return 0;
}
int
send_ttl_rights(int sd, int sendfd)
{
int clen;
struct msghdr msg;
struct iovec iov[1];
struct cmsghdr *cmptr;
char control[CMSG_SPACE(sizeof(int))];
char tdata[] = "test";
msg.msg_control = control;
msg.msg_controllen = sizeof(control);
cmptr = CMSG_FIRSTHDR(&msg);
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
cmptr->cmsg_level = IPPROTO_IP;
cmptr->cmsg_type = IP_TTL;
*((int *) CMSG_DATA(cmptr)) = sendfd;
msg.msg_name = NULL;
msg.msg_namelen = 0;
iov[0].iov_base = tdata;
iov[0].iov_len = strlen(tdata);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
fprintf(stderr, "Parent:sending TTL\n");
if ((clen = sendmsg(sd, &msg, 0)) == -1) {
perror("sendmsg:send_access_rights");
return -1;
}
fprintf(stderr, "Parent:sent %d bytes\n", clen);
return 0;
}
int
get_send_sock(void)
{
int sd;
struct addrinfo hints, *res, *ressave;
char port[] = TESTPORT;
char host[] = HOST;
char test_data[] = "Start from the server, the source\n";
bzero(&hints, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
if (getaddrinfo(host, port, &hints, &res) != 0) {
perror("getaddrinfo:get_send_sock");
return -1;
}
ressave = res;
do {
if ((sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) {
continue;
}
if (connect(sd, res->ai_addr, res->ai_addrlen) == 0)
break; /* success */
close(sd); /* ignore this one */
} while ((res = res->ai_next) != NULL);
if (res == NULL) {
fprintf(stderr, "Connect error: get_send_sock\n");
freeaddrinfo(ressave);
return -1;
}
freeaddrinfo(ressave);
if (send(sd, test_data, strlen(test_data), 0) == -1) {
perror("send");
return -1;
}
return(sd);
}
int
get_send_fd()
{
int fd;
char test_data[] = "Start from the server, the source\n";
if ((fd = open(TESTFILE, O_CREAT|O_WRONLY|O_APPEND|O_CLOEXEC, 0666)) == -1) {
perror("open:get_send_fd");
return -1;
}
if (write(fd, test_data, strlen(test_data)) == -1) {
perror("write:get_send_fd");
return -1;
}
return fd;
}
void *
recv_thread(void *param)
{
int sd, rsd, optval;
unsigned short port = TESTPORTNO;
struct sockaddr_in serveraddr;
struct sockaddr_in clientaddr;
socklen_t clientlen = sizeof(clientaddr);
sd = socket(AF_INET, SOCK_STREAM, 0);
if (sd < 0) {
perror("ERROR:recv_thread:opening socket");
exit(-1);
}
optval = 1;
setsockopt(sd, SOL_SOCKET, SO_REUSEADDR,
(const void *)&optval , sizeof(int));
bzero((char *)&serveraddr, sizeof(serveraddr));
serveraddr.sin_family = AF_INET;
serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
serveraddr.sin_port = htons(port);
if (bind(sd, (struct sockaddr *)&serveraddr,
sizeof(serveraddr)) < 0) {
perror("ERROR:recv_thread:bind");
exit(-1);
}
if (listen(sd, 5) < 0) { /* allow 5 requests to queue up */
perror("ERROR:recv_thread:listen");
exit(-1);
}
while (1) {
int rc;
char buf[64];
rsd = accept(sd, (struct sockaddr *)&clientaddr, &clientlen);
if (rsd < 0) {
perror("ERROR:recv_thread:accept");
continue;
}
if ((rc = recv(rsd, buf, 64, 0)) <= 0) {
perror("ERROR:recv_thread:recv");
continue;
}
// echo
write(1, buf, rc);
close(rsd);
}
return NULL;
}
int
unruly_kid()
{
int clientsock;
int *recvfd;
int i, rc;
int numfds;
struct cmsghdr *cmptr;
struct iovec iov[1];
struct sockaddr_un clientaddr;
struct msghdr msg;
struct stat sbuf;
char control[CMSG_SPACE(sizeof(int))];
char test_data[] = "Passing the buck\n";
// socket: create the parent socket
clientsock = socket(AF_UNIX, SOCK_STREAM, 0);
if (clientsock < 0) {
perror("ERROR opening child socket");
exit(-1);
}
bzero((char *)&clientaddr, sizeof(clientaddr));
clientaddr.sun_family = AF_UNIX;
// pfile is the socket path
strncpy(clientaddr.sun_path, pfile, sizeof(clientaddr.sun_path)-1);
if (connect(clientsock, (const struct sockaddr *)&clientaddr,
sizeof(struct sockaddr_un)) == -1) {
perror("connect child");
exit(-1);
}
msg.msg_control = control;
msg.msg_controllen = sizeof(control);
msg.msg_name = NULL;
msg.msg_namelen = 0;
iov[0].iov_base = NULL;
iov[0].iov_len = 0;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
if ((rc = recvmsg(clientsock, &msg, 0)) == -1) {
perror("recvmsg child");
exit(-1);
}
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr != NULL; cmptr = CMSG_NXTHDR(&msg, cmptr)) {
if (cmptr->cmsg_len >= CMSG_LEN(sizeof(int))) {
if (cmptr->cmsg_level != SOL_SOCKET) {
fprintf(stderr, "Child:control level != SOL_SOCKET\n");
exit(-1);
}
if (cmptr->cmsg_type != SCM_RIGHTS) {
fprintf(stderr, "Child:control type != SCM_RIGHTS\n");
exit(-1);
}
recvfd = ((int *) CMSG_DATA(cmptr));
fprintf(stdout, "Child:Received len %ld\n", cmptr->cmsg_len);
numfds = (cmptr->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) / sizeof(int);
fprintf(stdout, "Child:Received %d fds %ld\n", numfds, sizeof(int));
for (i = 0; i < numfds; i++) {
// on the new fd
fprintf(stdout, "Child:Sending on %d\n", recvfd[i]);
if (fstat(recvfd[i], &sbuf) != -1) {
if ((sbuf.st_mode & S_IFMT) == S_IFSOCK) {
if (send(recvfd[i], test_data, strlen(test_data), 0) == -1) {
perror("send child");
continue;
}
} else {
if (write(recvfd[i], test_data, strlen(test_data)) == -1) {
perror("write child");
continue;
}
}
} else {
perror("fstat child");
exit(-1);
}
close(recvfd[i]);
}
} else {
fprintf(stderr, "Child:Did not receive access rights\n");
}
}
exit(0);
}
int
main(int argc, char **argv) {
pid_t child;
int servsock, child_stat;
int optval, opt;
int ttype = 0;
int verbose = 0;
pthread_t testTID;
struct sockaddr_un serveraddr;
if (argc < 2) {
usage(argv[0]);
}
while ((opt = getopt(argc, argv, "vhf:1234")) > 0) {
switch (opt) {
case 'v': verbose++; break;
case 'f': pfile=strdup(optarg); break;
case '1': ttype=1; break;
case '2': ttype=2; break;
case '3': ttype=3; break;
case '4': ttype=4; break;
case 'h': default: usage(argv[0]); break;
}
}
// socket: create the parent socket
servsock = socket(AF_UNIX, SOCK_STREAM, 0);
if (servsock < 0) {
perror("ERROR opening socket");
exit(1);
}
/* setsockopt: Handy debugging trick that lets
* us rerun the server immediately after we kill it;
* otherwise we have to wait about 20 secs.
* Eliminates "ERROR on binding: Address already in use" error.
*/
optval = 1;
setsockopt(servsock, SOL_SOCKET, SO_REUSEADDR,
(const void *)&optval , sizeof(int));
bzero((char *)&serveraddr, sizeof(serveraddr));
serveraddr.sun_family = AF_UNIX;
// pfile is the socket path
strncpy(serveraddr.sun_path, pfile, sizeof(serveraddr.sun_path)-1);
if (unlink(pfile) == -1) {
fprintf(stderr, "pfile: %s\n", pfile);
perror("unlink");
}
if (bind(servsock, (struct sockaddr *) &serveraddr,
sizeof(serveraddr)) < 0) {
perror("ERROR on binding");
exit(1);
}
if (listen(servsock, 15) < 0) { /* allow 15 requests to queue up */
perror("ERROR on listen");
exit(1);
}
if (chmod(pfile, 0777) == -1) {
perror("chmod");
exit(-1);
}
// start a thread to receive test messages
if (pthread_create(&testTID, NULL, recv_thread, NULL) != 0) {
perror("pthread_create");
exit(-1);
}
struct timespec ts = {.tv_sec=0, .tv_nsec=010000000}; // 10 ms
nanosleep(&ts, NULL);
// start the child that receives the access rights
if ((child = fork()) == 0) {
//We are the child proc
unruly_kid();
}
// loop on this until we are told to quit
// do we want or need to loop?
while(1) {
int sd, sendfd, sendsock;
struct sockaddr caddr;
socklen_t clen = sizeof(struct sockaddr);
int sendfds[2];
// wait for the child to tell us it's ready
fprintf(stderr, "Parent:accepting\n");
sd = accept(servsock, (struct sockaddr *)&caddr, &clen);
if (sd < 0) {
perror("ERROR on accept");
continue;
}
// get the send fd
if ((sendfd = get_send_fd()) == -1) exit(-1);
// get a socket to send
if ((sendsock = get_send_sock()) == -1) exit(-1);
// send fd access rights
switch (ttype) {
case 1:
if (send_access_rights(sd, sendfd) == -1) exit(-1);
break;
case 2:
if (send_access_rights(sd, sendsock) == -1) exit(-1);
break;
case 3:
sendfds[0] = sendfd;
sendfds[1] = sendsock;
if (send_array_rights(sd, sendfds, 2) == -1) exit(-1);
break;
case 4:
if (send_ttl_rights(sd, sendsock) == -1) exit(-1);
break;
default:
fprintf(stderr, "Parent: no test type\n");
exit(-1);
}
close(sd);
close(sendfd);
close(sendsock);
break;
}
waitpid(child, &child_stat, 0);
switch (ttype) {
char *verify[2];
case 1:
verify[0] = "fs.open";
verify[1] = "recvmsg";
verify[2] = "Received_File_Descriptor";
if (check_event(verify, 3) == -1) {
fprintf(stderr, "Parent:ERROR:no event for write to a file\n");
exit(-1);
}
break;
case 2:
verify[0] = "net.tx";
verify[1] = "remotep";
verify[2] = "9009";
if (check_event(verify, 3) == -1) {
fprintf(stderr, "Parent:ERROR:no event for send on socket\n");
exit(-1);
}
break;
case 3:
verify[0] = "fs.open";
verify[1] = "recvmsg";
verify[2] = "Received_File_Descriptor";
verify[3] = "net.tx";
verify[4] = "remotep";
verify[5] = "9009";
if (check_event(verify, 6) == -1) {
fprintf(stderr, "Parent:ERROR:no event for write an array of rights\n");
exit(-1);
}
break;
case 4:
sleep(1);
verify[0] = "net.tx";
if (check_event(verify, 1) == -1) {
fprintf(stderr, "Parent:ERROR:should not have an event for sending TTL\n");
exit(-1);
}
break;
default:
fprintf(stderr, "Parent: no test type\n");
exit(-1);
}
return WEXITSTATUS(child_stat);
}
| 25.43232 | 89 | 0.562429 |
aeb89f1030865ebe4ecbc5a3083979c35767ed0e | 1,600 | h | C | app/mdebug/swd.h | heatd/lk | 80285128333971221b532b6b2669fc38cafe7e55 | [
"MIT"
] | 2,644 | 2016-01-05T21:32:57.000Z | 2022-03-31T19:58:19.000Z | app/mdebug/swd.h | themelic/lk | 3c4a0b96c161b97fadbe496fd94faaf30bf76fc6 | [
"MIT"
] | 182 | 2016-01-18T01:28:41.000Z | 2022-03-19T20:22:39.000Z | app/mdebug/swd.h | themelic/lk | 3c4a0b96c161b97fadbe496fd94faaf30bf76fc6 | [
"MIT"
] | 529 | 2016-01-07T06:49:08.000Z | 2022-03-30T02:35:19.000Z | /* swd.h
*
* Copyright 2011 Brian Swetland <swetland@frotz.net>
*
* 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 _SWDP_H_
#define _SWDP_H_
void swd_init(void);
void swd_reset(unsigned kind);
int swd_write(unsigned reg, unsigned val);
int swd_read(unsigned reg, unsigned *val);
unsigned swd_set_clock(unsigned khz);
unsigned swo_set_clock(unsigned khz);
void swd_hw_reset(int assert);
void jtag_init(void);
int jtag_io(unsigned count, unsigned tms, unsigned tdi, unsigned *tdo);
// swdp_read/write() register codes
// Park Stop Parity Addr3 Addr2 RnW APnDP Start
#define RD_IDCODE 0b10100101
#define RD_DPCTRL 0b10001101
#define RD_RESEND 0b10010101
#define RD_BUFFER 0b10111101
#define WR_ABORT 0b10000001
#define WR_DPCTRL 0b10101001
#define WR_SELECT 0b10110001
#define WR_BUFFER 0b10011001
#define RD_AP0 0b10000111
#define RD_AP1 0b10101111
#define RD_AP2 0b10110111
#define RD_AP3 0b10011111
#define WR_AP0 0b10100011
#define WR_AP1 0b10001011
#define WR_AP2 0b10010011
#define WR_AP3 0b10111011
#endif
| 27.118644 | 75 | 0.7525 |
232eb9c66702b8adbe25935b8cc43b5b5a889e15 | 277 | h | C | Geometry/include/Geometry/Shape.h | edson-a-soares/geometric_acyclic_visitor | b2aff910d8606d4ad264d53f6e66aa03141e5cf6 | [
"Apache-2.0"
] | null | null | null | Geometry/include/Geometry/Shape.h | edson-a-soares/geometric_acyclic_visitor | b2aff910d8606d4ad264d53f6e66aa03141e5cf6 | [
"Apache-2.0"
] | null | null | null | Geometry/include/Geometry/Shape.h | edson-a-soares/geometric_acyclic_visitor | b2aff910d8606d4ad264d53f6e66aa03141e5cf6 | [
"Apache-2.0"
] | null | null | null | // Copyright 2017.
// All rights reserved.
//
#ifndef ACYCLIC_VISITOR_GEOMETRY_SHAPE_H
#define ACYCLIC_VISITOR_GEOMETRY_SHAPE_H
namespace Geometry
{
class Shape
{
public:
virtual ~Shape()
{ };
virtual void draw() = 0;
};
}
#endif
| 11.541667 | 40 | 0.620939 |
8615062b5464f228204e6a59ca5415dc2f8bd839 | 3,191 | h | C | macOS/10.12/AppKit.framework/NSSearchField.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 30 | 2016-10-09T20:13:00.000Z | 2022-01-24T04:14:57.000Z | macOS/10.12/AppKit.framework/NSSearchField.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | null | null | null | macOS/10.12/AppKit.framework/NSSearchField.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 7 | 2017-08-29T14:41:25.000Z | 2022-01-19T17:14:54.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
*/
@interface NSSearchField : NSTextField {
unsigned int _reserved2;
unsigned int _reserved3;
unsigned int _reserved4;
struct {
unsigned int _inTransition : 1;
unsigned int _reselecting : 1;
unsigned int _isSearching : 1;
unsigned int _reserved : 29;
} _sfFlags;
}
@property (atomic, readwrite) BOOL centersPlaceholder;
@property (atomic, readwrite) <NSSearchFieldDelegate> *delegate;
@property (atomic, readwrite) long long maximumRecents;
@property (atomic, readwrite, copy) NSArray *recentSearches;
@property (atomic, readwrite, copy) NSString *recentsAutosaveName;
@property (atomic, readwrite, retain) NSMenu *searchMenuTemplate;
@property (atomic, readwrite) BOOL sendsSearchStringImmediately;
@property (atomic, readwrite) BOOL sendsWholeSearchString;
+ (void)initialize;
- (void)_addEventToBeRepostedAfterTransition:(id)arg1;
- (void)_addPostAnimationBlock:(id)arg1;
- (id)_animationCompletionBlocks;
- (void)_createPostAnimationQueueWithBlock:(id)arg1;
- (id)_eventsNeedingReposting;
- (void)_invokePostAnimationBlocks;
- (id)_previousResponder;
- (void)_setAnimationCompletionBlocks:(id)arg1;
- (void)_setEventsNeedingReposting:(id)arg1;
- (void)_setPreviousResponder:(id)arg1;
- (BOOL)_shouldDoLayerPerformanceUpdates;
- (void)_transitionForFirstResponder:(BOOL)arg1 completion:(id)arg2;
- (void)_updateSearchingState;
- (void)_windowDidOrderOffScreen;
- (void)_windowResignedKeyStatus:(id)arg1;
- (BOOL)becomeFirstResponder;
- (BOOL)centersPlaceholder;
- (void)dealloc;
- (id)delegate;
- (void)encodeWithCoder:(id)arg1;
- (id)initWithCoder:(id)arg1;
- (void)keyDown:(id)arg1;
- (void)keyUp:(id)arg1;
- (long long)maximumRecents;
- (void)mouseDown:(id)arg1;
- (void)mouseUp:(id)arg1;
- (id)recentSearches;
- (id)recentsAutosaveName;
- (struct CGRect { struct CGPoint { double x_1_1_1; double x_1_1_2; } x1; struct CGSize { double x_2_1_1; double x_2_1_2; } x2; })rectForCancelButtonWhenCentered:(BOOL)arg1;
- (struct CGRect { struct CGPoint { double x_1_1_1; double x_1_1_2; } x1; struct CGSize { double x_2_1_1; double x_2_1_2; } x2; })rectForSearchButtonWhenCentered:(BOOL)arg1;
- (struct CGRect { struct CGPoint { double x_1_1_1; double x_1_1_2; } x1; struct CGSize { double x_2_1_1; double x_2_1_2; } x2; })rectForSearchTextWhenCentered:(BOOL)arg1;
- (BOOL)searchFieldCell:(id)arg1 shouldChangeCancelButtonVisibility:(BOOL)arg2;
- (id)searchMenuTemplate;
- (void)selectText:(id)arg1;
- (BOOL)sendAction:(SEL)arg1 to:(id)arg2;
- (BOOL)sendsSearchStringImmediately;
- (BOOL)sendsWholeSearchString;
- (void)setCentersPlaceholder:(BOOL)arg1;
- (void)setDelegate:(id)arg1;
- (void)setEnabled:(BOOL)arg1;
- (void)setMaximumRecents:(long long)arg1;
- (void)setRecentSearches:(id)arg1;
- (void)setRecentsAutosaveName:(id)arg1;
- (void)setSearchMenuTemplate:(id)arg1;
- (void)setSendsSearchStringImmediately:(BOOL)arg1;
- (void)setSendsWholeSearchString:(BOOL)arg1;
- (void)textDidEndEditing:(id)arg1;
- (void)viewWillMoveToWindow:(id)arg1;
// NSSearchField (NSIBSearchFieldIntegration)
- (id)ns_widgetType;
@end
| 38.914634 | 173 | 0.76277 |
14411003f0cdfd25b6721169921f0edc41d1754c | 209 | h | C | firmware/src/bitband.h | hazelnusse/robot.bicycle | b8d7c67290497577c96167dac123765efc4e08f8 | [
"BSD-2-Clause"
] | 9 | 2016-01-14T14:58:27.000Z | 2021-03-23T16:45:17.000Z | firmware/src/bitband.h | hazelnusse/robot.bicycle | b8d7c67290497577c96167dac123765efc4e08f8 | [
"BSD-2-Clause"
] | null | null | null | firmware/src/bitband.h | hazelnusse/robot.bicycle | b8d7c67290497577c96167dac123765efc4e08f8 | [
"BSD-2-Clause"
] | 1 | 2019-11-28T15:28:46.000Z | 2019-11-28T15:28:46.000Z | #ifndef BITBAND_H
#define BITBAND_H
#define BITBAND(addr,bitnum) ((addr & 0xF0000000) + 0x02000000 + ((addr & 0x000FFFFF) << 5) + (bitnum << 2))
#define MEM_ADDR(addr) *((volatile uint32_t *) (addr))
#endif
| 26.125 | 108 | 0.679426 |
8c0e6aa08439c4c181e0fcee116f1a234fc2a1eb | 848 | h | C | CG/FinalAssignmentTim/src/Model.h | jjkramok/ICTGP | fbe45cc5ebbc5095353512cbe0f0db61e2c95042 | [
"MIT"
] | 1 | 2018-04-20T07:11:50.000Z | 2018-04-20T07:11:50.000Z | CG/FinalAssignmentTim/src/Model.h | jjkramok/ICTGP | fbe45cc5ebbc5095353512cbe0f0db61e2c95042 | [
"MIT"
] | null | null | null | CG/FinalAssignmentTim/src/Model.h | jjkramok/ICTGP | fbe45cc5ebbc5095353512cbe0f0db61e2c95042 | [
"MIT"
] | null | null | null | //
// Created by Tim on 2018-04-09.
//
#ifndef FINALASSIGNMENTTIM_MODEL_H
#define FINALASSIGNMENTTIM_MODEL_H
#include <glm.hpp>
#include "VertexBuffer.h"
#include "VertexArray.h"
#include "VertexBufferLayout.h"
#include <iostream>
#include "vendor/objloader.h"
using namespace std;
class VertexBuffer; // forward declaration
class VertexArray; // forward declaration
class Model
{
public:
explicit Model(const std::string &modelPath);
virtual ~Model();
void Bind() const;
inline unsigned int GetCount() const { return m_Vertices.size(); }
private:
std::vector<glm::vec3> m_Vertices;
std::vector<glm::vec3> m_Normals;
std::vector<glm::vec2> m_UVs;
VertexBuffer *m_VBOVertices;
VertexBuffer *m_VBONormals;
VertexBuffer *m_VBOUVs;
VertexArray *m_VAO;
};
#endif //FINALASSIGNMENTTIM_MODEL_H
| 18.844444 | 70 | 0.71934 |
1b5cb7630de821c50ec0c5a0dd1959e03320a8d7 | 1,008 | h | C | lib/flow/Interpolator.h | yyr/vapor | cdebac81212ffa3f811064bbd7625ffa9089782e | [
"BSD-3-Clause"
] | null | null | null | lib/flow/Interpolator.h | yyr/vapor | cdebac81212ffa3f811064bbd7625ffa9089782e | [
"BSD-3-Clause"
] | null | null | null | lib/flow/Interpolator.h | yyr/vapor | cdebac81212ffa3f811064bbd7625ffa9089782e | [
"BSD-3-Clause"
] | null | null | null | /*************************************************************************
* OSU Flow Vector Field *
* *
* *
* Created: Han-Wei Shen, Liya Li *
* The Ohio State University *
* Date: 06/2005 *
* *
* Interpolator *
*************************************************************************/
#ifndef _INTERPOLATOR_H_
#define _INTERPOLATOR_H_
#include <vapor/MyBase.h>
#include <vapor/common.h>
namespace VAPoR
{
// linear interpolation
FLOW_API float Lerp(float x, float y, float ratio);
// bilinear interpolation
FLOW_API float BiLerp(float ll, float hl, float lh, float hh, float coeff[2]);
// barycentric interpolation
FLOW_API float BaryInterp(float dataValue[4], float coeff[3]);
// trilinear interpolation
FLOW_API float TriLerp(float lll, float hll, float lhl, float hhl, float llh, float hlh, float lhh, float hhh, float coeff[3]);
};
#endif
| 29.647059 | 129 | 0.508929 |
1860ba1fcc09e8ea757162003d4b0b94449a7e9e | 5,459 | c | C | hw/mcu/dialog/cmac/src/hal_timer.c | tt1pjm/mynewt-core | e579008c676fe2d56141eb8c3add36c57296a007 | [
"Apache-2.0"
] | 1 | 2019-04-12T12:22:53.000Z | 2019-04-12T12:22:53.000Z | hw/mcu/dialog/cmac/src/hal_timer.c | tt1pjm/mynewt-core | e579008c676fe2d56141eb8c3add36c57296a007 | [
"Apache-2.0"
] | 3 | 2018-10-25T15:12:51.000Z | 2020-01-21T11:38:39.000Z | hw/mcu/dialog/cmac/src/hal_timer.c | tt1pjm/mynewt-core | e579008c676fe2d56141eb8c3add36c57296a007 | [
"Apache-2.0"
] | 1 | 2021-11-27T09:24:26.000Z | 2021-11-27T09:24:26.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <assert.h>
#include <stdint.h>
#include "syscfg/syscfg.h"
#include "mcu/mcu.h"
#include "mcu/cmac_hal.h"
#include "mcu/cmac_timer.h"
#include "hal/hal_timer.h"
#include "sys/queue.h"
#include "defs/error.h"
#include "os/os_arch.h"
#include "os/util.h"
#define TICKS_GT(_t1, _t2) ((int64_t)((_t1) - (_t2)) > 0)
#define TICKS_GTE(_t1, _t2) ((int64_t)((_t1) - (_t2)) >= 0)
#define TICKS_LT(_t1, _t2) ((int64_t)((_t1) - (_t2)) < 0)
#define TICKS_LTE(_t1, _t2) ((int64_t)((_t1) - (_t2)) <= 0)
static TAILQ_HEAD(hal_timer_qhead, hal_timer) g_hal_timer_queue;
/*
* To avoid converting back and forth between uint64_t values returned by
* cmac_timer and uint32_t representing hal_timer ticks, we compare cmac_timer
* ticks everywhere. For this we need to store expiry value as uint64_t, so we
* use bsp_timer (which is not used here since we only have one timer) pointer
* to store high word of value.
*/
static inline uint64_t
hal_timer_expiry_get(struct hal_timer *timer)
{
uint64_t ret;
ret = (uint64_t)POINTER_TO_UINT(timer->bsp_timer) << 32;
ret |= timer->expiry;
return ret;
}
static inline void
hal_timer_expiry_set(struct hal_timer *timer, uint64_t val)
{
timer->expiry = val;
timer->bsp_timer = UINT_TO_POINTER(val >> 32);
}
static void
hal_timer_check_queue(void)
{
os_sr_t sr;
struct hal_timer *e;
uint64_t ll_timer_val;
OS_ENTER_CRITICAL(sr);
while ((e = TAILQ_FIRST(&g_hal_timer_queue)) != NULL) {
ll_timer_val = cmac_timer_read64();
if (TICKS_GT(hal_timer_expiry_get(e), ll_timer_val)) {
break;
}
TAILQ_REMOVE(&g_hal_timer_queue, e, link);
e->link.tqe_prev = NULL;
e->cb_func(e->cb_arg);
}
if (e != NULL) {
cmac_timer_write_eq_hal_timer(hal_timer_expiry_get(e));
} else {
cmac_timer_disable_eq_hal_timer();
}
OS_EXIT_CRITICAL(sr);
}
static void
hal_timer_cmac_timer_cb(void)
{
#if MYNEWT_VAL(TIMER_0)
hal_timer_check_queue();
#endif
}
int
hal_timer_init(int timer_num, void *cfg)
{
assert(timer_num == 0);
cmac_timer_int_hal_timer_register(hal_timer_cmac_timer_cb);
TAILQ_INIT(&g_hal_timer_queue);
return 0;
}
int
hal_timer_config(int timer_num, uint32_t freq_hz)
{
assert(timer_num == 0);
assert(freq_hz == 32768);
return 0;
}
int
hal_timer_set_cb(int timer_num, struct hal_timer *timer, hal_timer_cb func,
void *arg)
{
assert(timer_num == 0);
timer->cb_func = func;
timer->cb_arg = arg;
timer->link.tqe_prev = NULL;
return 0;
}
int
hal_timer_start_at(struct hal_timer *timer, uint32_t tick)
{
struct hal_timer *e;
os_sr_t sr;
uint64_t expiry;
assert(timer);
assert(timer->link.tqe_prev == NULL);
assert(timer->cb_func);
expiry = cmac_timer_convert_hal2llt(tick);
hal_timer_expiry_set(timer, expiry);
OS_ENTER_CRITICAL(sr);
if (TAILQ_EMPTY(&g_hal_timer_queue)) {
TAILQ_INSERT_HEAD(&g_hal_timer_queue, timer, link);
} else {
TAILQ_FOREACH(e, &g_hal_timer_queue, link) {
if (TICKS_LT(expiry, hal_timer_expiry_get(e))) {
TAILQ_INSERT_BEFORE(e, timer, link);
break;
}
}
if (!e) {
TAILQ_INSERT_TAIL(&g_hal_timer_queue, timer, link);
}
}
if (timer == TAILQ_FIRST(&g_hal_timer_queue)) {
cmac_timer_write_eq_hal_timer(expiry);
}
OS_EXIT_CRITICAL(sr);
return 0;
}
int
hal_timer_stop(struct hal_timer *timer)
{
os_sr_t sr;
bool reset_timer;
assert(timer);
if (timer->link.tqe_prev == NULL) {
return 0;
}
OS_ENTER_CRITICAL(sr);
reset_timer = (timer == TAILQ_FIRST(&g_hal_timer_queue));
TAILQ_REMOVE(&g_hal_timer_queue, timer, link);
timer->link.tqe_prev = NULL;
if (reset_timer) {
timer = TAILQ_FIRST(&g_hal_timer_queue);
if (timer != NULL) {
cmac_timer_write_eq_hal_timer(hal_timer_expiry_get(timer));
} else {
cmac_timer_disable_eq_hal_timer();
}
}
OS_EXIT_CRITICAL(sr);
return 0;
}
uint32_t
hal_timer_read(int timer_num)
{
uint64_t llt;
uint32_t val;
assert(timer_num == 0);
llt = cmac_timer_read64();
val = cmac_timer_convert_llt2hal(llt);
__disable_irq();
/*
* Store current LLT value and converted HAL timer value, we'll use it as
* a base for subsequent HAL->LLT conversions.
*/
g_cmac_timer_ctrl.hal_last_val = val;
g_cmac_timer_ctrl.hal_to_llt_corr = llt;
__enable_irq();
return val;
}
| 23.530172 | 78 | 0.664041 |
12086ed6e8aac681c0cf36a5394a697ff048d3d9 | 599 | h | C | qqtw/qqheaders7.2/QQGroupRobotKeySection.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 5 | 2018-02-20T14:24:17.000Z | 2020-08-06T09:31:21.000Z | qqtw/qqheaders7.2/QQGroupRobotKeySection.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 1 | 2020-06-10T07:49:16.000Z | 2020-06-12T02:08:35.000Z | qqtw/qqheaders7.2/QQGroupRobotKeySection.h | onezens/SmartQQ | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | null | null | null | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "QQGroupPropertyModel.h"
@class NSArray, NSString;
@interface QQGroupRobotKeySection : QQGroupPropertyModel
{
NSString *_title;
NSArray *_offItems;
NSArray *_onItems;
}
- (void).cxx_destruct;
@property(retain, nonatomic) NSArray *offItems; // @synthesize offItems=_offItems;
@property(retain, nonatomic) NSArray *onItems; // @synthesize onItems=_onItems;
@property(retain, nonatomic) NSString *title; // @synthesize title=_title;
@end
| 23.96 | 83 | 0.719533 |
29f2befde14ebd81bc13541f6b841f7ed7668a8d | 343 | h | C | firmware/Tokens.h | ajcord/WIFI-84 | e4860f47c12a38e8f9b0a765e9f2b9cfd66e8e62 | [
"MIT"
] | 8 | 2019-05-13T19:24:20.000Z | 2022-03-11T05:05:08.000Z | firmware/Tokens.h | ajcord/WIFI-84 | e4860f47c12a38e8f9b0a765e9f2b9cfd66e8e62 | [
"MIT"
] | 1 | 2017-01-07T03:54:40.000Z | 2017-01-07T03:54:40.000Z | firmware/Tokens.h | ajcord/WIFI-84 | e4860f47c12a38e8f9b0a765e9f2b9cfd66e8e62 | [
"MIT"
] | 1 | 2022-03-11T05:05:02.000Z | 2022-03-11T05:05:02.000Z | #pragma once
namespace Token {
enum Token {
Invalid = 0x00,
Connected = 0x7e06,
Select = 0xbb58,
For = 0xd3,
Stop = 0xd9,
IS = 0xda,
DS = 0xdb,
Menu = 0xe6,
Send = 0xe7,
Get = 0xe8,
};
};
| 20.176471 | 29 | 0.35277 |
af6433a13f526ee939dc9d6de44f68c366508eb2 | 1,041 | h | C | Userland/Libraries/LibWeb/DOM/NonElementParentNode.h | shubhdev/serenity | 9321d9d83d366ad4cf686c856063ff9ac97c18a4 | [
"BSD-2-Clause"
] | 4 | 2021-02-23T05:35:25.000Z | 2021-06-08T06:11:06.000Z | Userland/Libraries/LibWeb/DOM/NonElementParentNode.h | shubhdev/serenity | 9321d9d83d366ad4cf686c856063ff9ac97c18a4 | [
"BSD-2-Clause"
] | 4 | 2021-04-27T20:44:44.000Z | 2021-06-30T18:07:10.000Z | Userland/Libraries/LibWeb/DOM/NonElementParentNode.h | shubhdev/serenity | 9321d9d83d366ad4cf686c856063ff9ac97c18a4 | [
"BSD-2-Clause"
] | 1 | 2022-01-10T08:02:34.000Z | 2022-01-10T08:02:34.000Z | /*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/AttributeNames.h>
#include <LibWeb/TreeNode.h>
namespace Web::DOM {
template<typename NodeType>
class NonElementParentNode {
public:
RefPtr<Element> get_element_by_id(const FlyString& id) const
{
RefPtr<Element> found_element;
static_cast<const NodeType*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
if (element.attribute(HTML::AttributeNames::id) == id) {
found_element = &element;
return IterationDecision::Break;
}
return IterationDecision::Continue;
});
return found_element;
}
RefPtr<Element> get_element_by_id(const FlyString& id)
{
return const_cast<const NonElementParentNode*>(this)->get_element_by_id(id);
}
protected:
NonElementParentNode() { }
};
}
| 25.390244 | 120 | 0.664745 |
764885837adca4cd4fb958e8a7a8628d016e8ae8 | 1,355 | c | C | src/RIOT/sys/shell/commands/sc_random.c | ARte-team/ARte | 19f17f57522e1b18ba390718fc94be246451837b | [
"MIT"
] | 2 | 2020-04-30T08:17:45.000Z | 2020-05-23T08:46:54.000Z | src/RIOT/sys/shell/commands/sc_random.c | ARte-team/ARte | 19f17f57522e1b18ba390718fc94be246451837b | [
"MIT"
] | null | null | null | src/RIOT/sys/shell/commands/sc_random.c | ARte-team/ARte | 19f17f57522e1b18ba390718fc94be246451837b | [
"MIT"
] | 1 | 2020-02-21T09:21:45.000Z | 2020-02-21T09:21:45.000Z | /*
* Copyright (C) 2013 Freie Universität Berlin
* 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup sys_shell_commands
* @{
*
* @file
* @brief Shell commands for random generators
*
* @author Christian Mehlis <mehlis@inf.fu-berlin.de>
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @}
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#ifdef MODULE_XTIMER
#include "xtimer.h"
#endif
#include "random.h"
int _random_init(int argc, char **argv)
{
int initval;
if (argc == 1) {
#ifdef MODULE_XTIMER
initval = _xtimer_now();
printf("PRNG initialized to current time: %d\n", initval);
#else
(void)initval;
puts("xtimer module not compiled in, can't initialize by time.\n"
"Please provide a seed.\n");
return 1;
#endif
}
else {
initval = atoi(argv[1]);
printf("PRNG initialized given value: %d\n", initval);
}
random_init(initval);
return 0;
}
int _random_get(int argc, char **argv)
{
(void) argc;
(void) argv;
printf("%" PRIu32 "\n", random_uint32());
return 0;
}
| 20.223881 | 73 | 0.619188 |
17ba4ae7dee00e1b37460ecbbb347dc27eb49086 | 1,389 | h | C | Parse/Internal/PFBlockRetryer.h | huamichaelchen/Parse-SDK-iOS-OSX | f02bd53c9d113d45c7bf7fde85d752fe2dd4f01c | [
"MIT",
"BSD-3-Clause"
] | null | null | null | Parse/Internal/PFBlockRetryer.h | huamichaelchen/Parse-SDK-iOS-OSX | f02bd53c9d113d45c7bf7fde85d752fe2dd4f01c | [
"MIT",
"BSD-3-Clause"
] | null | null | null | Parse/Internal/PFBlockRetryer.h | huamichaelchen/Parse-SDK-iOS-OSX | f02bd53c9d113d45c7bf7fde85d752fe2dd4f01c | [
"MIT",
"BSD-3-Clause"
] | null | null | null | /**
* Copyright (c) 2015-present, Parse, LLC.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
@class BFTask;
NS_ASSUME_NONNULL_BEGIN
typedef BFTask * __nonnull (^PFBlockRetryerBlock)();
/*!
This class will retry block for a specified number of times.
*/
@interface PFBlockRetryer : NSObject
/*!
@abstract Runs the given block repeatedly.
@discussion Runs the given block repeatedly until either:
- the block returns a successful task
- the block returns a cancelled task
- the block has been run attempts time.
After every run of the block, it waits twice as long as the previous time,
starting with the default initial delay.
@returns `BFTask` which is the result of last run of the block.
*/
+ (BFTask *)retryBlock:(PFBlockRetryerBlock)block forAttempts:(NSUInteger)attempts;
+ (BFTask *)retryBlock:(PFBlockRetryerBlock)block forAttempts:(NSUInteger)attempts delay:(NSTimeInterval)delay;
///--------------------------------------
/// @name Initial Retry Delay
///--------------------------------------
+ (void)setInitialRetryDelay:(NSTimeInterval)delay;
+ (NSTimeInterval)initialRetryDelay;
@end
NS_ASSUME_NONNULL_END
| 28.9375 | 111 | 0.718503 |
ebc357bc771c5cc8664ce5c17ce54cfd4ee73828 | 2,869 | h | C | Gui/PreCompiled.h | haisenzhao/CarpentryCompiler | c9714310b7ce7523a25becd397265bfaa3ab7ea3 | [
"FSFAP"
] | 21 | 2019-12-06T09:57:10.000Z | 2021-09-22T12:58:09.000Z | Gui/PreCompiled.h | haisenzhao/CarpentryCompiler | c9714310b7ce7523a25becd397265bfaa3ab7ea3 | [
"FSFAP"
] | null | null | null | Gui/PreCompiled.h | haisenzhao/CarpentryCompiler | c9714310b7ce7523a25becd397265bfaa3ab7ea3 | [
"FSFAP"
] | 5 | 2020-11-18T00:09:30.000Z | 2021-01-13T04:40:47.000Z | /***************************************************************************
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef __PRECOMPILED_GUI__
#define __PRECOMPILED_GUI__
#include <FCConfig.h>
// Importing of App classes
#ifdef FC_OS_WIN32
# define PartDesignExport __declspec(dllimport)
# define PartDesignGuiExport __declspec(dllexport)
# define PartExport __declspec(dllimport)
# define PartGuiExport __declspec(dllimport)
# define SketcherExport __declspec(dllimport)
# define SketcherGuiExport __declspec(dllimport)
#else // for Linux
# define PartDesignExport
# define PartDesignGuiExport
# define PartExport
# define PartGuiExport
# define SketcherExport
# define SketcherGuiExport
#endif
#ifdef _MSC_VER
# pragma warning(disable : 4005)
#endif
#ifdef _PreComp_
// Python
#include <Python.h>
// standard
#include <iostream>
#include <assert.h>
#include <cmath>
// OCC
#include <Standard_math.hxx>
// STL
#include <vector>
#include <map>
#include <string>
#include <list>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <bitset>
#ifdef FC_OS_WIN32
# include <windows.h>
#endif
// Qt Toolkit
#ifndef __Qt4All__
# include <Gui/Qt4All.h>
#endif
// Inventor
#ifndef __InventorAll__
# include <Gui/InventorAll.h>
#endif
#endif // _PreComp_
#endif // __PRECOMPILED_GUI__
| 31.184783 | 77 | 0.555594 |
6f8f1198659f24883ffe3d8ed398abae4f29e93b | 6,596 | c | C | stack/apps/efm32_sensor/app.c | octa-connect/Octa-stack | 19cc45a65b5b0a5adcd37f35aa0a22e381cf519a | [
"Apache-2.0"
] | null | null | null | stack/apps/efm32_sensor/app.c | octa-connect/Octa-stack | 19cc45a65b5b0a5adcd37f35aa0a22e381cf519a | [
"Apache-2.0"
] | null | null | null | stack/apps/efm32_sensor/app.c | octa-connect/Octa-stack | 19cc45a65b5b0a5adcd37f35aa0a22e381cf519a | [
"Apache-2.0"
] | null | null | null | /* * OSS-7 - An opensource implementation of the DASH7 Alliance Protocol for ultra
* lowpower wireless sensor communication
*
* Copyright 2015 University of Antwerp
*
* 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 "hwleds.h"
#include "hwsystem.h"
#include "scheduler.h"
#include "timer.h"
#include "assert.h"
#include "platform.h"
#include <stdio.h>
#include <stdlib.h>
#include "hwlcd.h"
#include "hwadc.h"
#include "d7ap_stack.h"
#include "fs.h"
#include "log.h"
#if (!defined PLATFORM_EFM32GG_STK3700 && !defined PLATFORM_EFM32HG_STK3400 && !defined PLATFORM_EZR32LG_WSTK6200A)
#error Mismatch between the configured platform and the actual platform.
#endif
#include "userbutton.h"
#include "platform_sensors.h"
#include "platform_lcd.h"
#define SENSOR_FILE_ID 0x40
#define SENSOR_FILE_SIZE 8
#define ACTION_FILE_ID 0x41
#define SENSOR_UPDATE TIMER_TICKS_PER_SEC * 1
// Toggle different operational modes
void userbutton_callback(button_id_t button_id)
{
#ifdef PLATFORM_EFM32GG_STK3700
lcd_write_string("Butt %d", button_id);
#else
lcd_write_string("button: %d\n", button_id);
#endif
}
void execute_sensor_measurement()
{
#ifdef PLATFORM_EFM32GG_STK3700
float internal_temp = hw_get_internal_temperature();
lcd_write_temperature(internal_temp*10, 1);
uint32_t vdd = hw_get_battery();
fs_write_file(SENSOR_FILE_ID, 0, (uint8_t*)&internal_temp, sizeof(internal_temp)); // File 0x40 is configured to use D7AActP trigger an ALP action which broadcasts this file data on Access Class 0
#endif
#if (defined PLATFORM_EFM32HG_STK3400 || defined PLATFORM_EZR32LG_WSTK6200A)
char str[30];
float internal_temp = hw_get_internal_temperature();
sprintf(str, "Int T: %2d.%d C", (int)internal_temp, (int)(internal_temp*10)%10);
lcd_write_line(2,str);
log_print_string(str);
uint32_t rhData;
uint32_t tData;
getHumidityAndTemperature(&rhData, &tData);
sprintf(str, "Ext T: %d.%d C", (tData/1000), (tData%1000)/100);
lcd_write_line(3,str);
log_print_string(str);
sprintf(str, "Ext H: %d.%d", (rhData/1000), (rhData%1000)/100);
lcd_write_line(4,str);
log_print_string(str);
uint32_t vdd = hw_get_battery();
sprintf(str, "Batt %d mV", vdd);
lcd_write_line(5,str);
log_print_string(str);
//TODO: put sensor values in array
uint8_t sensor_values[8];
uint16_t *pointer = (uint16_t*) sensor_values;
*pointer++ = (uint16_t) (internal_temp * 10);
*pointer++ = (uint16_t) (tData /100);
*pointer++ = (uint16_t) (rhData /100);
*pointer++ = (uint16_t) (vdd /10);
fs_write_file(SENSOR_FILE_ID, 0, (uint8_t*)&sensor_values,8);
#endif
timer_post_task_delay(&execute_sensor_measurement, SENSOR_UPDATE);
}
void init_user_files()
{
// file 0x40: contains our sensor data + configure an action file to be executed upon write
fs_file_header_t file_header = (fs_file_header_t){
.file_properties.action_protocol_enabled = 1,
.file_properties.action_file_id = ACTION_FILE_ID,
.file_properties.action_condition = ALP_ACT_COND_WRITE,
.file_properties.storage_class = FS_STORAGE_VOLATILE,
.file_properties.permissions = 0, // TODO
.length = SENSOR_FILE_SIZE
};
fs_init_file(SENSOR_FILE_ID, &file_header, NULL);
// configure file notification using D7AActP: write ALP command to broadcast changes made to file 0x40 in file 0x41
// first generate ALP command consisting of ALP Control header, ALP File Data Request operand and D7ASP interface configuration
alp_control_t alp_ctrl = {
.group = false,
.response_requested = false,
.operation = ALP_OP_READ_FILE_DATA
};
alp_operand_file_data_request_t file_data_request_operand = {
.file_offset = {
.file_id = SENSOR_FILE_ID,
.offset = 0
},
.requested_data_length = SENSOR_FILE_SIZE,
};
d7asp_fifo_config_t d7asp_fifo_config = {
.fifo_ctrl_nls = false,
.fifo_ctrl_stop_on_error = false,
.fifo_ctrl_preferred = false,
.fifo_ctrl_state = SESSION_STATE_PENDING,
.qos = {
.qos_ctrl_resp_mode = SESSION_RESP_MODE_NONE
},
.dormant_timeout = 0,
.start_id = 0,
.addressee = {
.addressee_ctrl_has_id = false,
.addressee_ctrl_virtual_id = false,
.addressee_ctrl_access_class = 0,
.addressee_id = 0
}
};
// finally, register D7AActP file
fs_init_file_with_D7AActP(ACTION_FILE_ID, &d7asp_fifo_config, &alp_ctrl, (uint8_t*)&file_data_request_operand);
}
void bootstrap()
{
log_print_string("Device booted\n");
dae_access_profile_t access_classes[1] = {
{
.control_scan_type_is_foreground = false,
.control_csma_ca_mode = CSMA_CA_MODE_UNC,
.control_number_of_subbands = 1,
.subnet = 0x00,
.scan_automation_period = 0,
.transmission_timeout_period = 0xFF, // TODO compressed time value
.subbands[0] = (subband_t){
.channel_header = {
.ch_coding = PHY_CODING_PN9,
.ch_class = PHY_CLASS_NORMAL_RATE,
#ifdef PLATFORM_EZR32LG_WSTK6200A
.ch_freq_band = PHY_BAND_868
#else
.ch_freq_band = PHY_BAND_433
#endif
},
.channel_index_start = 16,
.channel_index_end = 16,
.eirp = 10,
.ccao = 0
}
}
};
fs_init_args_t fs_init_args = (fs_init_args_t){
.fs_user_files_init_cb = &init_user_files,
.access_profiles_count = 1,
.access_profiles = access_classes
};
d7ap_stack_init(&fs_init_args, NULL, false);
initSensors();
ubutton_register_callback(0, &userbutton_callback);
ubutton_register_callback(1, &userbutton_callback);
sched_register_task((&execute_sensor_measurement));
timer_post_task_delay(&execute_sensor_measurement, TIMER_TICKS_PER_SEC);
lcd_write_string("EFM32 Sensor\n");
}
| 30.82243 | 198 | 0.684809 |
172d2b39a468d03b5a6946420d4a977626e3b8d2 | 6,281 | h | C | src/cunumeric/cunumeric_c.h | mferreravila/cunumeric | 87901174d0ecb1719bbccb98201dc19034973834 | [
"Apache-2.0"
] | null | null | null | src/cunumeric/cunumeric_c.h | mferreravila/cunumeric | 87901174d0ecb1719bbccb98201dc19034973834 | [
"Apache-2.0"
] | null | null | null | src/cunumeric/cunumeric_c.h | mferreravila/cunumeric | 87901174d0ecb1719bbccb98201dc19034973834 | [
"Apache-2.0"
] | null | null | null | /* Copyright 2021-2022 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef __CUNUMERIC_C_H__
#define __CUNUMERIC_C_H__
#include "legate_preamble.h"
// Match these to CuNumericOpCode in config.py
// Also, sort these alphabetically except the first one for easy lookup later
enum CuNumericOpCode {
_CUNUMERIC_OP_CODE_BASE = 0,
CUNUMERIC_ADVANCED_INDEXING,
CUNUMERIC_ARANGE,
CUNUMERIC_BINARY_OP,
CUNUMERIC_BINARY_RED,
CUNUMERIC_BINCOUNT,
CUNUMERIC_CHOOSE,
CUNUMERIC_CONTRACT,
CUNUMERIC_CONVERT,
CUNUMERIC_CONVOLVE,
CUNUMERIC_DIAG,
CUNUMERIC_DOT,
CUNUMERIC_EYE,
CUNUMERIC_FFT,
CUNUMERIC_FILL,
CUNUMERIC_FLIP,
CUNUMERIC_GEMM,
CUNUMERIC_LOAD_CUDALIBS,
CUNUMERIC_MATMUL,
CUNUMERIC_MATVECMUL,
CUNUMERIC_NONZERO,
CUNUMERIC_POTRF,
CUNUMERIC_RAND,
CUNUMERIC_READ,
CUNUMERIC_REPEAT,
CUNUMERIC_SCALAR_UNARY_RED,
CUNUMERIC_SORT,
CUNUMERIC_SYRK,
CUNUMERIC_TILE,
CUNUMERIC_TRANSPOSE_COPY_2D,
CUNUMERIC_TRILU,
CUNUMERIC_TRSM,
CUNUMERIC_UNARY_OP,
CUNUMERIC_UNARY_RED,
CUNUMERIC_UNIQUE,
CUNUMERIC_UNIQUE_REDUCE,
CUNUMERIC_UNLOAD_CUDALIBS,
CUNUMERIC_WHERE,
CUNUMERIC_WINDOW,
CUNUMERIC_WRITE,
CUNUMERIC_ZIP,
};
// Match these to UnaryOpCode in config.py
// Also, sort these alphabetically for easy lookup later
enum CuNumericUnaryOpCode {
CUNUMERIC_UOP_ABSOLUTE = 1,
CUNUMERIC_UOP_ARCCOS,
CUNUMERIC_UOP_ARCCOSH,
CUNUMERIC_UOP_ARCSIN,
CUNUMERIC_UOP_ARCSINH,
CUNUMERIC_UOP_ARCTAN,
CUNUMERIC_UOP_ARCTANH,
CUNUMERIC_UOP_CBRT,
CUNUMERIC_UOP_CEIL,
CUNUMERIC_UOP_CLIP,
CUNUMERIC_UOP_CONJ,
CUNUMERIC_UOP_COPY,
CUNUMERIC_UOP_COS,
CUNUMERIC_UOP_COSH,
CUNUMERIC_UOP_DEG2RAD,
CUNUMERIC_UOP_EXP,
CUNUMERIC_UOP_EXP2,
CUNUMERIC_UOP_EXPM1,
CUNUMERIC_UOP_FLOOR,
CUNUMERIC_UOP_GETARG,
CUNUMERIC_UOP_IMAG,
CUNUMERIC_UOP_INVERT,
CUNUMERIC_UOP_ISFINITE,
CUNUMERIC_UOP_ISINF,
CUNUMERIC_UOP_ISNAN,
CUNUMERIC_UOP_LOG,
CUNUMERIC_UOP_LOG10,
CUNUMERIC_UOP_LOG1P,
CUNUMERIC_UOP_LOG2,
CUNUMERIC_UOP_LOGICAL_NOT,
CUNUMERIC_UOP_NEGATIVE,
CUNUMERIC_UOP_POSITIVE,
CUNUMERIC_UOP_RAD2DEG,
CUNUMERIC_UOP_REAL,
CUNUMERIC_UOP_RECIPROCAL,
CUNUMERIC_UOP_RINT,
CUNUMERIC_UOP_SIGN,
CUNUMERIC_UOP_SIGNBIT,
CUNUMERIC_UOP_SIN,
CUNUMERIC_UOP_SINH,
CUNUMERIC_UOP_SQRT,
CUNUMERIC_UOP_SQUARE,
CUNUMERIC_UOP_TAN,
CUNUMERIC_UOP_TANH,
CUNUMERIC_UOP_TRUNC,
};
// Match these to UnaryRedCode in config.py
// Also, sort these alphabetically for easy lookup later
enum CuNumericUnaryRedCode {
CUNUMERIC_RED_ALL = 1,
CUNUMERIC_RED_ANY,
CUNUMERIC_RED_ARGMAX,
CUNUMERIC_RED_ARGMIN,
CUNUMERIC_RED_CONTAINS,
CUNUMERIC_RED_COUNT_NONZERO,
CUNUMERIC_RED_MAX,
CUNUMERIC_RED_MIN,
CUNUMERIC_RED_PROD,
CUNUMERIC_RED_SUM,
};
// Match these to BinaryOpCode in config.py
// Also, sort these alphabetically for easy lookup later
enum CuNumericBinaryOpCode {
CUNUMERIC_BINOP_ADD = 1,
CUNUMERIC_BINOP_ALLCLOSE,
CUNUMERIC_BINOP_ARCTAN2,
CUNUMERIC_BINOP_BITWISE_AND,
CUNUMERIC_BINOP_BITWISE_OR,
CUNUMERIC_BINOP_BITWISE_XOR,
CUNUMERIC_BINOP_COPYSIGN,
CUNUMERIC_BINOP_DIVIDE,
CUNUMERIC_BINOP_EQUAL,
CUNUMERIC_BINOP_FLOAT_POWER,
CUNUMERIC_BINOP_FLOOR_DIVIDE,
CUNUMERIC_BINOP_FMOD,
CUNUMERIC_BINOP_GCD,
CUNUMERIC_BINOP_GREATER,
CUNUMERIC_BINOP_GREATER_EQUAL,
CUNUMERIC_BINOP_HYPOT,
CUNUMERIC_BINOP_LCM,
CUNUMERIC_BINOP_LEFT_SHIFT,
CUNUMERIC_BINOP_LESS,
CUNUMERIC_BINOP_LESS_EQUAL,
CUNUMERIC_BINOP_LOGADDEXP,
CUNUMERIC_BINOP_LOGADDEXP2,
CUNUMERIC_BINOP_LOGICAL_AND,
CUNUMERIC_BINOP_LOGICAL_OR,
CUNUMERIC_BINOP_LOGICAL_XOR,
CUNUMERIC_BINOP_MAXIMUM,
CUNUMERIC_BINOP_MINIMUM,
CUNUMERIC_BINOP_MOD,
CUNUMERIC_BINOP_MULTIPLY,
CUNUMERIC_BINOP_NEXTAFTER,
CUNUMERIC_BINOP_NOT_EQUAL,
CUNUMERIC_BINOP_POWER,
CUNUMERIC_BINOP_RIGHT_SHIFT,
CUNUMERIC_BINOP_SUBTRACT,
};
// Match these to WindowOpCode in config.py
// Also, sort these alphabetically for easy lookup later
enum CuNumericWindowOpCode {
CUNUMERIC_WINDOW_BARLETT = 1,
CUNUMERIC_WINDOW_BLACKMAN,
CUNUMERIC_WINDOW_HAMMING,
CUNUMERIC_WINDOW_HANNING,
CUNUMERIC_WINDOW_KAISER,
};
// Match these to CuNumericRedopCode in config.py
enum CuNumericRedopID {
CUNUMERIC_ARGMAX_REDOP = 1,
CUNUMERIC_ARGMIN_REDOP = 2,
};
// Match these to CuNumericTunable in config.py
enum CuNumericTunable {
CUNUMERIC_TUNABLE_NUM_GPUS = 1,
CUNUMERIC_TUNABLE_NUM_PROCS = 2,
CUNUMERIC_TUNABLE_MAX_EAGER_VOLUME = 3,
CUNUMERIC_TUNABLE_HAS_NUMAMEM = 4,
};
enum CuNumericBounds {
CUNUMERIC_MAX_MAPPERS = 1,
CUNUMERIC_MAX_REDOPS = 1024,
CUNUMERIC_MAX_TASKS = 1048576,
};
// These fft types match CuNumericFFTType in config.py and cufftType
enum CuNumericFFTType {
CUNUMERIC_FFT_R2C = 0x2a, // Real to complex (interleaved)
CUNUMERIC_FFT_C2R = 0x2c, // Complex (interleaved) to real
CUNUMERIC_FFT_C2C = 0x29, // Complex to complex (interleaved)
CUNUMERIC_FFT_D2Z = 0x6a, // Double to double-complex (interleaved)
CUNUMERIC_FFT_Z2D = 0x6c, // Double-complex (interleaved) to double
CUNUMERIC_FFT_Z2Z = 0x69 // Double-complex to double-complex (interleaved)
};
// These fft types match CuNumericFFTDirection in config.py and cufftDirection
enum CuNumericFFTDirection { CUNUMERIC_FFT_FORWARD = -1, CUNUMERIC_FFT_INVERSE = 1 };
// Match these to CuNumericTypeCodes in config.py
enum CuNumericTypeCodes {
CUNUMERIC_TYPE_POINT1 = MAX_TYPE_NUMBER + 1,
CUNUMERIC_TYPE_POINT2,
CUNUMERIC_TYPE_POINT3,
CUNUMERIC_TYPE_POINT4,
CUNUMERIC_TYPE_POINT5,
CUNUMERIC_TYPE_POINT6,
CUNUMERIC_TYPE_POINT7,
CUNUMERIC_TYPE_POINT8,
CUNUMERIC_TYPE_POINT9,
};
#ifdef __cplusplus
extern "C" {
#endif
void cunumeric_perform_registration();
#ifdef __cplusplus
}
#endif
#endif // __CUNUMERIC_C_H__
| 26.280335 | 85 | 0.799077 |
3fd45f1ae8b540557ae5bd9055ab57a518c054ec | 715 | h | C | platform/darwin/src/MGLAccountManager_Private.h | RobertSasak/mapbox-gl-native | dabf5d0c3a76f9fbe8b866f64f51accf12d1a2a6 | [
"BSL-1.0",
"Apache-2.0"
] | 2 | 2019-04-18T21:25:22.000Z | 2019-04-18T21:25:24.000Z | platform/darwin/src/MGLAccountManager_Private.h | RobertSasak/mapbox-gl-native | dabf5d0c3a76f9fbe8b866f64f51accf12d1a2a6 | [
"BSL-1.0",
"Apache-2.0"
] | null | null | null | platform/darwin/src/MGLAccountManager_Private.h | RobertSasak/mapbox-gl-native | dabf5d0c3a76f9fbe8b866f64f51accf12d1a2a6 | [
"BSL-1.0",
"Apache-2.0"
] | null | null | null | #import "MGLAccountManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface MGLAccountManager (Private)
/// Returns the shared instance of the `MGLAccountManager` class.
@property (class, nonatomic, readonly) MGLAccountManager *sharedManager;
/// The current global access token.
@property (atomic, nullable) NSString *accessToken;
/// The API base URL that is used to access Mapbox resources. The default base URL is `https://api.mapbox.com`. If `nil`, the Mapbox default base API URL is in use.
@property (atomic, readwrite, nullable) NSURL *apiBaseURL;
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
/// The current global SKU.
@property (class, atomic, readonly) NSString *skuToken;
#endif
@end
NS_ASSUME_NONNULL_END
| 29.791667 | 164 | 0.773427 |
e90066bda0722c1c902351a39749b99c94a01d01 | 3,030 | h | C | slib_core/include/engine_core.h | KarlJansson/ecs_game_engine | c76b7379d8ff913cd7773d0a9f55535996abdf35 | [
"MIT"
] | 1 | 2018-05-18T10:42:35.000Z | 2018-05-18T10:42:35.000Z | slib_core/include/engine_core.h | KarlJansson/ecs_game_engine | c76b7379d8ff913cd7773d0a9f55535996abdf35 | [
"MIT"
] | null | null | null | slib_core/include/engine_core.h | KarlJansson/ecs_game_engine | c76b7379d8ff913cd7773d0a9f55535996abdf35 | [
"MIT"
] | null | null | null | #pragma once
#include <atomic>
#include <memory>
#include "core_commands.h"
#include "engine_debug_output.h"
#include "renderer.h"
#include "window.h"
namespace lib_gui {
class TextSystem;
class RectSystem;
} // namespace lib_gui
namespace lib_graphics {
class Renderer;
class ParticleSystem;
class Window;
class MaterialSystem;
class MeshSystem;
class CullingSystem;
class CameraSystem;
class TransformSystem;
class LightSystem;
} // namespace lib_graphics
namespace lib_input {
class InputSystem;
}
namespace lib_physics {
class PhysicsSystem;
}
namespace lib_sound {
class SoundSystem;
}
namespace lib_core {
class EngineCore {
public:
EngineCore();
~EngineCore() = default;
int StartEngine();
void SetTimeMultiplier(float multiplier);
float TimeMultiplier();
[[nodiscard]] lib_graphics::Renderer* GetRenderer() const;
[[nodiscard]] lib_physics::PhysicsSystem* GetPhysics() const;
[[nodiscard]] lib_input::InputSystem* GetInput() const;
[[nodiscard]] lib_graphics::MaterialSystem* GetMaterial() const;
[[nodiscard]] lib_gui::TextSystem* GetText() const;
[[nodiscard]] lib_gui::RectSystem* GetRect() const;
[[nodiscard]] lib_graphics::MeshSystem* GetMesh() const;
[[nodiscard]] lib_graphics::Window* GetWindow() const;
[[nodiscard]] lib_graphics::CullingSystem* GetCulling() const;
[[nodiscard]] lib_sound::SoundSystem* GetSound() const;
[[nodiscard]] lib_graphics::TransformSystem* TransformSystem() const;
[[nodiscard]] lib_graphics::ParticleSystem* ParticleSystem() const;
[[nodiscard]] lib_graphics::CameraSystem* CameraSystem() const;
[[nodiscard]] EngineDebugOutput* GetDebugOutput() const;
static size_t stock_box_mesh, stock_sphere_mesh, stock_material_textured,
stock_texture, stock_material_untextured;
private:
void InitEngine();
std::unique_ptr<lib_graphics::Window> window_;
std::unique_ptr<lib_graphics::Renderer> renderer_;
std::unique_ptr<EngineDebugOutput> debug_output_;
lib_input::InputSystem* input_system_ = nullptr;
lib_physics::PhysicsSystem* physics_system_ = nullptr;
lib_gui::TextSystem* text_system_ = nullptr;
lib_gui::RectSystem* rect_system_ = nullptr;
lib_graphics::MeshSystem* mesh_system_ = nullptr;
lib_graphics::CameraSystem* camera_system_ = nullptr;
lib_graphics::TransformSystem* transform_system_ = nullptr;
lib_graphics::MaterialSystem* material_system_ = nullptr;
lib_graphics::CullingSystem* culling_system_ = nullptr;
lib_graphics::LightSystem* light_system_ = nullptr;
lib_sound::SoundSystem* sound_system_ = nullptr;
lib_graphics::ParticleSystem* particle_system_ = nullptr;
size_t particle_system_id_;
size_t input_system_id_;
size_t physics_system_id_;
size_t text_system_id_;
size_t rect_system_id_;
size_t mesh_system_id_;
size_t camera_system_id_;
size_t transform_system_id_;
size_t material_system_id_;
size_t culling_system_id_;
size_t light_system_id_;
size_t sound_system_id_;
std::atomic<float> time_multiplier_ = {1.f};
};
} // namespace lib_core
| 29.417476 | 75 | 0.773597 |
e9650a546d36b07d7ba0fbcc8082967dda9bc83c | 2,048 | h | C | import/delegatesmodel.h | PureTryOut/mycroft-gui | eb72bcfe1a748cd3e6de3c0ea72a317db695c129 | [
"Apache-2.0"
] | 122 | 2018-11-19T07:32:06.000Z | 2022-02-05T02:39:55.000Z | import/delegatesmodel.h | PureTryOut/mycroft-gui | eb72bcfe1a748cd3e6de3c0ea72a317db695c129 | [
"Apache-2.0"
] | 39 | 2018-12-11T09:36:31.000Z | 2022-03-24T03:34:19.000Z | import/delegatesmodel.h | PureTryOut/mycroft-gui | eb72bcfe1a748cd3e6de3c0ea72a317db695c129 | [
"Apache-2.0"
] | 42 | 2018-11-23T02:47:59.000Z | 2021-09-06T14:35:43.000Z | /*
* Copyright 2018 by Marco Martin <mart@kde.org>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#pragma once
#include <QAbstractListModel>
#include <QHash>
#include <QUrl>
class QTimer;
class AbstractDelegate;
class DelegateLoader;
class DelegatesModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int currentIndex MEMBER m_currentIndex NOTIFY currentIndexChanged)
public:
enum Roles {
DelegateUi = Qt::UserRole + 1
};
explicit DelegatesModel(QObject *parent = nullptr);
virtual ~DelegatesModel();
/**
* Insert one or more delegates at position
*/
void insertDelegateLoaders(int position, QList<DelegateLoader *> loaders);
/**
* clears the whole model
*/
void clear();
/**
* @returns the complete delegate set
*/
QList<AbstractDelegate *> delegates() const;
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = DelegateUi) const override;
QHash<int, QByteArray> roleNames() const override;
Q_SIGNALS:
void currentIndexChanged();
private:
QList<DelegateLoader *> m_delegateLoaders;
QList<DelegateLoader *> m_delegateLoadersToDelete;
QTimer *m_deleteTimer;
int m_currentIndex = 0;
};
| 28.444444 | 146 | 0.719727 |
8f352e0f9a89d032281cb5a1f9e5989b91bc355a | 318 | h | C | nvxs/nv_num/nv_num.h | makevoid/animeface-2009 | d4824f49282547456bc71e4735f46c4eea1926f3 | [
"MIT"
] | 281 | 2017-02-18T04:28:11.000Z | 2022-02-28T11:37:34.000Z | nvxs/nv_num/nv_num.h | makevoid/animeface-2009 | d4824f49282547456bc71e4735f46c4eea1926f3 | [
"MIT"
] | 8 | 2017-02-22T09:27:44.000Z | 2021-10-03T07:52:10.000Z | nvxs/nv_num/nv_num.h | makevoid/animeface-2009 | d4824f49282547456bc71e4735f46c4eea1926f3 | [
"MIT"
] | 39 | 2017-03-11T17:42:54.000Z | 2022-01-19T11:46:03.000Z | #ifndef __NV_NUM_H
#define __NV_NUM_H
#include "nv_num_vector.h"
#include "nv_num_matrix.h"
#include "nv_num_cov.h"
#include "nv_num_eigen.h"
#include "nv_num_distance.h"
#if !NV_XS
#include "nv_num_munkres.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
| 13.826087 | 29 | 0.701258 |
6a91cf4672b88648b253fc055fee5d2381ef20bc | 594 | h | C | mainwindow.h | casey-c/egg-frontend | d6f02cca94fb48eaa26f2c3accf94b1dceaa1c37 | [
"MIT"
] | null | null | null | mainwindow.h | casey-c/egg-frontend | d6f02cca94fb48eaa26f2c3accf94b1dceaa1c37 | [
"MIT"
] | null | null | null | mainwindow.h | casey-c/egg-frontend | d6f02cca94fb48eaa26f2c3accf94b1dceaa1c37 | [
"MIT"
] | null | null | null | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "canvas.h"
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_actionExit_triggered();
void on_actionNew_triggered();
void on_actionLight_triggered();
void on_actionDark_triggered();
void toggleTheme();
void on_actionTutorial_triggered();
void on_actionAbout_triggered();
private:
Ui::MainWindow *ui;
Canvas* canvas;
};
#endif // MAINWINDOW_H
| 16.5 | 45 | 0.717172 |
b9e547c1207a54408a8abdea80d9b740bc4c26f8 | 15,294 | c | C | ext/khetai/khetai_lib.c | jkugs/khetai | e0c807e62f3aa4b72324455f675d6dbdc3f34ce3 | [
"MIT"
] | null | null | null | ext/khetai/khetai_lib.c | jkugs/khetai | e0c807e62f3aa4b72324455f675d6dbdc3f34ce3 | [
"MIT"
] | null | null | null | ext/khetai/khetai_lib.c | jkugs/khetai | e0c807e62f3aa4b72324455f675d6dbdc3f34ce3 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include "khetai_lib.h"
Square board[120] = {0};
int pharaoh_loc[2] = {0};
enum Player whose_turn;
enum Player starter;
Move undo_moves[MAX_DEPTH] = {0};
int undo_capture_indices[MAX_DEPTH] = {0};
Square undo_capture_squares[MAX_DEPTH] = {0};
HashEntry table[TABLE_SIZE] = {0};
uint64_t hashes[MAX_DEPTH] = {0};
uint64_t keys[0xFF][120] = {0};
uint64_t turn_key = 0;
int undo_index = 0;
int move_num = 0;
bool checkmate = false;
Move alphabeta_root(int depth, enum Player player)
{
whose_turn = player;
starter = player;
int best_score = -MAX_SCORE;
Move best_move = (Move)0;
int alpha = -MAX_SCORE;
int beta = MAX_SCORE;
Move valid_moves[NUM_VALID_MOVES] = {0};
int vi = 0;
find_valid_moves(valid_moves, &vi);
for (int i = 0; i < NUM_VALID_MOVES; i++)
{
if (valid_moves[i] == 0)
break;
make_move(valid_moves[i]);
int score = -alphabeta(depth - 1, opposite_player(player), -beta, -alpha);
undo_move();
whose_turn = player;
if (score > best_score)
{
best_score = score;
best_move = valid_moves[i];
}
if (best_score > alpha)
alpha = best_score;
if (alpha >= beta)
break;
}
return best_move;
}
int alphabeta(int depth, enum Player player, int alpha, int beta)
{
whose_turn = player;
if (depth == 0 || checkmate)
{
return player == Red ? calculate_score() : -calculate_score();
}
int alpha_orig = alpha;
Move valid_moves[NUM_VALID_MOVES] = {0};
int vi = 0;
HashEntry *entry = search_table(hashes[move_num]);
if (entry->key == hashes[move_num] && entry->depth >= depth)
{
if (entry->flag == EXACT)
return entry->score;
else if (entry->flag == ALPHA)
{
if (entry->score > alpha)
alpha = entry->score;
}
else
{
if (entry->score < beta)
beta = entry->score;
}
if (alpha >= beta)
return entry->score;
if (is_move_legal(entry->move))
valid_moves[vi++] = entry->move;
}
find_valid_moves(valid_moves, &vi);
int best_score = -MAX_SCORE;
Move best_move = (Move)0;
for (int i = 0; (i < NUM_VALID_MOVES && (time(NULL) - start_time < max_time)); i++)
{
if (valid_moves[i] == 0)
break;
make_move(valid_moves[i]);
int score = -alphabeta(depth - 1, opposite_player(player), -beta, -alpha);
undo_move();
whose_turn = player;
if (score > best_score)
{
best_score = score;
best_move = valid_moves[i];
}
if (best_score > alpha)
alpha = best_score;
if (alpha >= beta)
break;
}
int flag = EXACT;
if (best_score <= alpha_orig)
flag = BETA;
else if (best_score >= beta)
flag = ALPHA;
insert_table(hashes[move_num], depth, flag, best_score, best_move);
return best_score;
}
void insert_table(uint64_t key, int depth, int flag, int score, Move move)
{
HashEntry *entry = search_table(key);
if (entry->key != 0)
{
if (depth > entry->depth)
{
entry->key = key;
entry->depth = depth;
entry->flag = flag;
entry->score = score;
entry->move = move;
}
}
else
{
entry->key = key;
entry->depth = depth;
entry->flag = flag;
entry->score = score;
entry->move = move;
}
}
int calculate_score()
{
int score = 0;
int anubis_score = 500;
int pyramid_score = 1000;
int pharaoh_score = 100000;
for (int i = 0; i < 120; i++)
{
Square s = board[i];
if (is_piece(s))
{
int value = 0;
switch (get_piece(s))
{
case Anubis:
value += anubis_score;
value -= distance_from_pharaoh(i, pharaoh_loc[get_owner(s)]) * 10;
break;
case Pyramid:
value += pyramid_score;
value += rand() % 20;
break;
case Scarab:
value += (100 / distance_from_pharaoh(i, pharaoh_loc[opposite_player(get_owner(s))])) * 10;
value += rand() % 10;
break;
case Pharaoh:
value += pharaoh_score;
break;
default:
break;
}
score += get_owner(s) == Red ? value : -value;
}
}
return score;
}
int distance_from_pharaoh(int i, int p)
{
int px = p / 12;
int py = p % 12;
int ix = i / 12;
int iy = i % 12;
int m_distance = abs(px - ix) + abs(py - iy);
return m_distance;
}
void make_move(Move move)
{
uint64_t hash = hashes[move_num++];
int start = get_start(move);
// remove starting piece
hash ^= keys[board[start]][start];
int end = get_end(move);
int rotation = get_rotation(move);
if (rotation != 0)
{
board[start] = rotate(board[start], rotation);
// add starting piece back with rotation
hash ^= keys[board[start]][start];
}
else
{
// remove ending piece if swapping
if (is_piece(board[end]))
hash ^= keys[board[end]][end];
Square moving_piece = board[start];
board[start] = board[end];
board[end] = moving_piece;
// add starting piece to end location
hash ^= keys[board[end]][end];
// add ending piece to start location if swapping
if (is_piece(board[start]))
hash ^= keys[board[start]][start];
if (get_piece(moving_piece) == Pharaoh)
pharaoh_loc[get_owner(moving_piece)] = end;
}
undo_moves[undo_index] = new_move(end, start, -rotation);
fire_laser(&hash);
hash ^= turn_key;
// testing that hashing works properly
// printf("\nHASH:\t%lu\nBOARD:\t%lu\n", hash, get_board_hash());
hashes[move_num] = hash;
undo_index++;
}
void fire_laser(uint64_t *hash)
{
int i = sphinx_loc[whose_turn];
int laser_dir = get_orientation(board[i]);
bool traversing = true;
while (traversing)
{
i = i + directions[laser_dir];
if (i >= 0 && i < 120 && on_board[i] == 1)
{
Square s = board[i];
if (is_piece(s))
{
int piece = get_piece(s) - 1;
int orientation = get_orientation(s);
int result = reflections[laser_dir][piece][orientation];
if (result == Dead)
{
if (get_piece(s) == Pharaoh)
checkmate = true;
// remove piece
*hash ^= keys[s][i];
undo_capture_indices[undo_index] = i;
undo_capture_squares[undo_index] = s;
board[i] = (Square)0;
traversing = false;
}
else if (result == Absorbed)
{
traversing = false;
}
else
{
laser_dir = result;
}
}
}
else
{
traversing = false;
}
}
}
void undo_move()
{
move_num--;
undo_index--;
Square captured = (Square)undo_capture_squares[undo_index];
undo_capture_squares[undo_index] = 0;
if (captured > 0)
{
board[undo_capture_indices[undo_index]] = captured;
undo_capture_indices[undo_index] = 0;
}
Move move = undo_moves[undo_index];
undo_moves[undo_index] = 0;
int start = get_start(move);
int end = get_end(move);
int rotation = get_rotation(move);
if (rotation != 0)
{
board[start] = rotate(board[start], rotation);
}
else
{
Square moving_piece = board[start];
board[start] = board[end];
board[end] = moving_piece;
if (get_piece(moving_piece) == Pharaoh)
pharaoh_loc[get_owner(moving_piece)] = end;
}
checkmate = false;
}
void find_valid_moves(Move *valid_moves, int *vi)
{
for (int i = 0; i < 120; i++)
{
Square s = board[i];
enum Player piece_color = get_owner(s);
if (is_piece(s) && piece_color == whose_turn)
{
enum Piece piece = get_piece(s);
switch (piece)
{
case Anubis:
find_valid_anubis_pyramid_moves(i, valid_moves, vi);
break;
case Pyramid:
find_valid_anubis_pyramid_moves(i, valid_moves, vi);
break;
case Scarab:
find_valid_scarab_moves(i, valid_moves, vi);
break;
case Pharaoh:
find_valid_pharaoh_moves(i, valid_moves, vi);
break;
case Sphinx:
find_valid_sphinx_moves(i, valid_moves, vi);
break;
default:
break;
}
}
}
}
void find_valid_anubis_pyramid_moves(int i, Move *valid_moves, int *vi)
{
for (int j = 0; j < 8; j++)
{
int dest = i + directions[j];
if (!is_piece(board[dest]) && can_move[whose_turn][dest])
{
valid_moves[(*vi)++] = new_move(i, dest, 0);
}
}
for (int j = 0; j < 2; j++)
{
valid_moves[(*vi)++] = new_move(i, i, rotations[j]);
}
}
void find_valid_scarab_moves(int i, Move *valid_moves, int *vi)
{
for (int j = 0; j < 8; j++)
{
int dest = i + directions[j];
if (can_move[whose_turn][dest])
{
if (is_piece(board[dest]))
{
if (get_piece(board[dest]) == Anubis || get_piece(board[dest]) == Pyramid)
{
valid_moves[(*vi)++] = new_move(i, dest, 0);
}
}
else
{
valid_moves[(*vi)++] = new_move(i, dest, 0);
}
}
}
for (int j = 0; j < 2; j++)
{
valid_moves[(*vi)++] = new_move(i, i, rotations[j]);
}
}
void find_valid_pharaoh_moves(int i, Move *valid_moves, int *vi)
{
for (int j = 0; j < 8; j++)
{
int dest = i + directions[j];
if (!is_piece(board[dest]) && can_move[whose_turn][dest])
{
valid_moves[(*vi)++] = new_move(i, dest, 0);
}
}
}
void find_valid_sphinx_moves(int i, Move *valid_moves, int *vi)
{
enum Player player = get_owner(board[i]);
enum Orientation orientation = get_orientation(board[i]);
int rotation = player == Silver ? (orientation == North ? -1 : 1) : (orientation == South ? -1 : 1);
valid_moves[(*vi)++] = new_move(i, i, rotation);
}
void init_zobrist()
{
for (int i = 0; i < 0xFF; i++)
{
for (int j = 0; j < 120; j++)
{
keys[i][j] = random_number();
}
}
turn_key = random_number();
}
uint64_t get_board_hash()
{
uint64_t hash = 0;
for (int i = 0; i < 120; i++)
{
if (is_piece(board[i]))
hash ^= keys[board[i]][i];
}
if (whose_turn == starter)
hash ^= turn_key;
return hash;
}
bool is_move_legal(Move move)
{
int start = get_start(move);
int end = get_end(move);
if (is_piece(board[start]) && get_owner(board[start]) == whose_turn)
{
if (!is_piece(board[end]) || get_rotation(move) != 0)
return true;
else if (is_piece(board[end]) && get_piece(board[start]) == Scarab && get_piece(board[end]) < 3)
return true;
}
return false;
}
void reset_undo()
{
undo_index = 0;
for (int i = 0; i < MAX_DEPTH; i++)
{
undo_moves[i] = 0;
undo_capture_indices[i] = 0;
undo_capture_squares[i] = 0;
}
}
void setup_board(char *init_board[120])
{
uint64_t hash = 0;
for (int i = 0; i < 120; i++)
{
board[i] = str_to_square(init_board[i]);
Square s = board[i];
if (is_piece(s))
{
hash ^= keys[s][i];
if (get_piece(s) == Pharaoh)
{
if (get_owner(s) == Silver)
pharaoh_loc[Silver] = i;
else if (get_owner(s) == Red)
pharaoh_loc[Red] = i;
}
}
}
hashes[0] = hash;
for (int i = 0; i < TABLE_SIZE; i++)
{
table[i].key = 0;
table[i].depth = 0;
table[i].flag = 0;
table[i].score = 0;
table[i].move = 0;
}
}
Square str_to_square(char *str)
{
enum Player player;
enum Piece piece;
enum Orientation orientation;
if (str[0] != '-')
{
if (islower(str[0]))
player = Silver;
else
player = Red;
char p = tolower(str[0]);
if (p == 'a')
piece = Anubis;
else if (p == 'p')
piece = Pyramid;
else if (p == 's')
piece = Scarab;
else if (p == 'x')
piece = Pharaoh;
else
piece = Sphinx;
char o = str[1];
if (o == '0')
orientation = North;
else if (o == '1')
orientation = East;
else if (o == '2')
orientation = South;
else
orientation = West;
return (Square)((int)player << 1 | (int)piece << 2 | (int)orientation << 5);
}
return (Square)0;
}
void print_board()
{
for (int i = 0; i < 120; i++)
{
print_piece(board[i]);
if ((i + 1) % 12 == 0)
printf("\n");
}
}
void print_piece(Square s)
{
enum Player player = get_owner(s);
if (is_piece(s))
{
enum Piece piece = get_piece(s);
enum Orientation orientation = get_orientation(s);
switch (piece)
{
case Anubis:
if (player == Silver)
printf("a");
else
printf("A");
break;
case Pyramid:
if (player == Silver)
printf("p");
else
printf("P");
break;
case Scarab:
if (player == Silver)
printf("s");
else
printf("S");
break;
case Pharaoh:
if (player == Silver)
printf("x");
else
printf("X");
break;
case Sphinx:
if (player == Silver)
printf("l");
else
printf("L");
break;
default:
printf("-");
break;
}
switch (orientation)
{
case North:
printf("0");
break;
case East:
printf("1");
break;
case South:
printf("2");
break;
case West:
printf("3");
break;
default:
printf("-");
break;
}
}
else
printf("--");
}
| 24.747573 | 107 | 0.487054 |
b1ab86bdc20caef0d14a3e35799698913012a81a | 333 | h | C | XVim2/XcodeHeader/IDESourceEditor/IDEComparisonEditorScrollerAreaView-Protocol.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 2,453 | 2017-09-07T00:07:49.000Z | 2022-03-29T22:32:10.000Z | XVim2/XcodeHeader/IDESourceEditor/IDEComparisonEditorScrollerAreaView-Protocol.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 373 | 2017-09-20T04:16:11.000Z | 2022-03-26T17:01:37.000Z | XVim2/XcodeHeader/IDESourceEditor/IDEComparisonEditorScrollerAreaView-Protocol.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 260 | 2017-09-16T15:31:41.000Z | 2022-02-07T02:52:29.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 30 2020 21:18:12).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <IDESourceEditor/NSObject-Protocol.h>
@class NSView;
@protocol IDEComparisonEditorScrollerAreaView <NSObject>
@property(nonatomic, readonly) NSView *viewToInstallScrollerIn;
@end
| 22.2 | 90 | 0.744745 |
5906e09631d9492e8521641a6f4d4129ede06b8b | 627 | h | C | sdk/WeexSDK/Sources/Bridge/WXComponentMethod.h | kissnger/MSWeexViewController | 009f77d41b86473e700e3638eddde6957f214b4f | [
"MIT"
] | 3 | 2020-08-30T07:03:44.000Z | 2021-08-06T07:52:40.000Z | contents/iOS/Weex/sdk/WeexSDK/Sources/Bridge/WXComponentMethod.h | carptainhao/Halfrost-Field | 1d2b44489f730c240092159e3c3c6c7b85aa1f56 | [
"CC-BY-4.0"
] | 22 | 2016-09-24T11:13:22.000Z | 2017-05-18T02:14:51.000Z | contents/iOS/Weex/sdk/WeexSDK/Sources/Bridge/WXComponentMethod.h | carptainhao/Halfrost-Field | 1d2b44489f730c240092159e3c3c6c7b85aa1f56 | [
"CC-BY-4.0"
] | 2 | 2017-02-13T06:09:19.000Z | 2017-03-07T07:39:59.000Z | /**
* Created by Weex.
* Copyright (c) 2016, Alibaba, Inc. All rights reserved.
*
* This source code is licensed under the Apache Licence 2.0.
* For the full copyright and license information,please view the LICENSE file in the root directory of this source tree.
*/
#import "WXBridgeMethod.h"
@class WXComponent;
@interface WXComponentMethod : WXBridgeMethod
- (instancetype)initWithComponentRef:(NSString *)ref
methodName:(NSString *)methodName
arguments:(NSArray *)arguments
instance:(WXSDKInstance *)instance;
- (void)invoke;
@end
| 28.5 | 121 | 0.660287 |
0dd5cdd45971840f6448c889c0218f9891dd2197 | 2,691 | h | C | src/C/libpqcrypto/crypto_sign/dilithium3/avx2/polyvec.h | GaloisInc/hacrypto | 5c99d7ac73360e9b05452ac9380c1c7dc6784849 | [
"BSD-3-Clause"
] | 34 | 2015-02-04T18:03:14.000Z | 2020-11-10T06:45:28.000Z | src/C/libpqcrypto/crypto_sign/dilithium3/ref/polyvec.h | GaloisInc/hacrypto | 5c99d7ac73360e9b05452ac9380c1c7dc6784849 | [
"BSD-3-Clause"
] | 5 | 2015-06-30T21:17:00.000Z | 2016-06-14T22:31:51.000Z | src/C/libpqcrypto/crypto_sign/dilithium4/avx2/polyvec.h | GaloisInc/hacrypto | 5c99d7ac73360e9b05452ac9380c1c7dc6784849 | [
"BSD-3-Clause"
] | 15 | 2015-10-29T14:21:58.000Z | 2022-01-19T07:33:14.000Z | #ifndef POLYVEC_H
#define POLYVEC_H
#include <stdint.h>
#include "params.h"
#include "poly.h"
/* Vectors of polynomials of length L */
typedef struct {
poly vec[L];
} polyvecl;
#define expand_mat DILITHIUM_NAMESPACE(expand_mat)
void expand_mat(polyvecl mat[K], const uint8_t rho[SEEDBYTES]);
#define polyvecl_freeze DILITHIUM_NAMESPACE(polyvecl_freeze)
void polyvecl_freeze(polyvecl *v);
#define polyvecl_add DILITHIUM_NAMESPACE(polyvecl_add)
void polyvecl_add(polyvecl *w, const polyvecl *u, const polyvecl *v);
#define polyvecl_ntt DILITHIUM_NAMESPACE(polyvecl_ntt)
void polyvecl_ntt(polyvecl *v);
#define polyvecl_pointwise_acc_montgomery \
DILITHIUM_NAMESPACE(polyvecl_pointwise_acc_montgomery)
void polyvecl_pointwise_acc_montgomery(poly *w,
const polyvecl *u,
const polyvecl *v);
#define polyvecl_chknorm DILITHIUM_NAMESPACE(polyvecl_chknorm)
int polyvecl_chknorm(const polyvecl *v, uint32_t B);
/* Vectors of polynomials of length K */
typedef struct {
poly vec[K];
} polyveck;
#define polyveck_reduce DILITHIUM_NAMESPACE(polyveck_reduce)
void polyveck_reduce(polyveck *v);
#define polyveck_csubq DILITHIUM_NAMESPACE(polyveck_csubq)
void polyveck_csubq(polyveck *v);
#define polyveck_freeze DILITHIUM_NAMESPACE(polyveck_freeze)
void polyveck_freeze(polyveck *v);
#define polyveck_add DILITHIUM_NAMESPACE(polyveck_add)
void polyveck_add(polyveck *w, const polyveck *u, const polyveck *v);
#define polyveck_sub DILITHIUM_NAMESPACE(polyveck_sub)
void polyveck_sub(polyveck *w, const polyveck *u, const polyveck *v);
#define polyveck_shiftl DILITHIUM_NAMESPACE(polyveck_shiftl)
void polyveck_shiftl(polyveck *v);
#define polyveck_ntt DILITHIUM_NAMESPACE(polyveck_ntt)
void polyveck_ntt(polyveck *v);
#define polyveck_invntt_tomont DILITHIUM_NAMESPACE(polyveck_invntt_tomont)
void polyveck_invntt_tomont(polyveck *v);
#define polyveck_chknorm DILITHIUM_NAMESPACE(polyveck_chknorm)
int polyveck_chknorm(const polyveck *v, uint32_t B);
#define polyveck_power2round DILITHIUM_NAMESPACE(polyveck_power2round)
void polyveck_power2round(polyveck *v1, polyveck *v0, const polyveck *v);
#define polyveck_decompose DILITHIUM_NAMESPACE(polyveck_decompose)
void polyveck_decompose(polyveck *v1, polyveck *v0, const polyveck *v);
#define polyveck_make_hint DILITHIUM_NAMESPACE(polyveck_make_hint)
unsigned int polyveck_make_hint(polyveck *h,
const polyveck *v0,
const polyveck *v1);
#define polyveck_use_hint DILITHIUM_NAMESPACE(polyveck_use_hint)
void polyveck_use_hint(polyveck *w, const polyveck *v, const polyveck *h);
#endif
| 35.88 | 74 | 0.780751 |
d4c0154851b3911b40e17ae7a93a310d050a8f09 | 122,543 | h | C | bochs-cli/cpu/decoder/fetchdecode_opmap.h | emacslisp/cpp | 8230f81117d6f64adaa1696b0943cdb47505335a | [
"Apache-2.0"
] | null | null | null | bochs-cli/cpu/decoder/fetchdecode_opmap.h | emacslisp/cpp | 8230f81117d6f64adaa1696b0943cdb47505335a | [
"Apache-2.0"
] | null | null | null | bochs-cli/cpu/decoder/fetchdecode_opmap.h | emacslisp/cpp | 8230f81117d6f64adaa1696b0943cdb47505335a | [
"Apache-2.0"
] | null | null | null | /////////////////////////////////////////////////////////////////////////
// $Id: fetchdecode_opmap.h 13387 2017-12-13 18:44:13Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2017 Stanislav Shwartsman
// Written by Stanislav Shwartsman [sshwarts at sourceforge net]
//
// 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 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
//
/////////////////////////////////////////////////////////////////////////
#ifndef BX_FETCHDECODE_OPMAP_H
#define BX_FETCHDECODE_OPMAP_H
// opcode 00
static const BxOpcodeInfo_t BxOpcodeTable00[] = {
/* 00 /w */ { 0, BX_IA_ADD_EbGb },
/* 00 /d */ { 0, BX_IA_ADD_EbGb },
#if BX_SUPPORT_X86_64
/* 00 /q */ { 0, BX_IA_ADD_EbGb },
#endif
};
// opcode 01
static const BxOpcodeInfo_t BxOpcodeTable01[] = {
/* 01 /w */ { 0, BX_IA_ADD_EwGw },
/* 01 /d */ { 0, BX_IA_ADD_EdGd },
#if BX_SUPPORT_X86_64
/* 01 /q */ { 0, BX_IA_ADD_EqGq },
#endif
};
// opcode 02
static const BxOpcodeInfo_t BxOpcodeTable02[] = {
/* 02 /w */ { 0, BX_IA_ADD_GbEb },
/* 02 /d */ { 0, BX_IA_ADD_GbEb },
#if BX_SUPPORT_X86_64
/* 02 /q */ { 0, BX_IA_ADD_GbEb },
#endif
};
// opcode 03
static const BxOpcodeInfo_t BxOpcodeTable03[] = {
/* 03 /w */ { 0, BX_IA_ADD_GwEw },
/* 03 /d */ { 0, BX_IA_ADD_GdEd },
#if BX_SUPPORT_X86_64
/* 03 /q */ { 0, BX_IA_ADD_GqEq },
#endif
};
// opcode 04
static const BxOpcodeInfo_t BxOpcodeTable04[] = {
/* 04 /w */ { BxImmediate_Ib, BX_IA_ADD_ALIb },
/* 04 /d */ { BxImmediate_Ib, BX_IA_ADD_ALIb },
#if BX_SUPPORT_X86_64
/* 04 /q */ { BxImmediate_Ib, BX_IA_ADD_ALIb },
#endif
};
// opcode 05
static const BxOpcodeInfo_t BxOpcodeTable05[] = {
/* 05 /w */ { BxImmediate_Iw, BX_IA_ADD_AXIw },
/* 05 /d */ { BxImmediate_Id, BX_IA_ADD_EAXId },
#if BX_SUPPORT_X86_64
/* 05 /q */ { BxImmediate_Id, BX_IA_ADD_RAXId },
#endif
};
// opcode 06
static const BxOpcodeInfo_t BxOpcodeTable06_32[] = {
/* 06 /w */ { 0, BX_IA_PUSH_Op16_Sw },
/* 06 /d */ { 0, BX_IA_PUSH_Op32_Sw },
};
// opcode 07
static const BxOpcodeInfo_t BxOpcodeTable07_32[] = {
/* 07 /w */ { 0, BX_IA_POP_Op16_Sw },
/* 07 /d */ { 0, BX_IA_POP_Op32_Sw },
};
// opcode 08
static const BxOpcodeInfo_t BxOpcodeTable08[] = {
/* 08 /w */ { 0, BX_IA_OR_EbGb },
/* 08 /d */ { 0, BX_IA_OR_EbGb },
#if BX_SUPPORT_X86_64
/* 08 /q */ { 0, BX_IA_OR_EbGb },
#endif
};
// opcode 09
static const BxOpcodeInfo_t BxOpcodeTable09[] = {
/* 09 /w */ { 0, BX_IA_OR_EwGw },
/* 09 /d */ { 0, BX_IA_OR_EdGd },
#if BX_SUPPORT_X86_64
/* 09 /q */ { 0, BX_IA_OR_EqGq },
#endif
};
// opcode 0A
static const BxOpcodeInfo_t BxOpcodeTable0A[] = {
/* 0A /w */ { 0, BX_IA_OR_GbEb },
/* 0A /d */ { 0, BX_IA_OR_GbEb },
#if BX_SUPPORT_X86_64
/* 0A /q */ { 0, BX_IA_OR_GbEb },
#endif
};
// opcode 0B
static const BxOpcodeInfo_t BxOpcodeTable0B[] = {
/* 0B /w */ { 0, BX_IA_OR_GwEw },
/* 0B /d */ { 0, BX_IA_OR_GdEd },
#if BX_SUPPORT_X86_64
/* 0B /q */ { 0, BX_IA_OR_GqEq },
#endif
};
// opcode 0C
static const BxOpcodeInfo_t BxOpcodeTable0C[] = {
/* 0C /w */ { BxImmediate_Ib, BX_IA_OR_ALIb },
/* 0C /d */ { BxImmediate_Ib, BX_IA_OR_ALIb },
#if BX_SUPPORT_X86_64
/* 0C /q */ { BxImmediate_Ib, BX_IA_OR_ALIb },
#endif
};
// opcode 0D
static const BxOpcodeInfo_t BxOpcodeTable0D[] = {
/* 0D /w */ { BxImmediate_Iw, BX_IA_OR_AXIw },
/* 0D /d */ { BxImmediate_Id, BX_IA_OR_EAXId },
#if BX_SUPPORT_X86_64
/* 0D /q */ { BxImmediate_Id, BX_IA_OR_RAXId },
#endif
};
// opcode 0E
static const BxOpcodeInfo_t BxOpcodeTable0E_32[] = {
/* 0E /w */ { 0, BX_IA_PUSH_Op16_Sw },
/* 0E /d */ { 0, BX_IA_PUSH_Op32_Sw },
};
// opcode 10
static const BxOpcodeInfo_t BxOpcodeTable10[] = {
/* 10 /w */ { 0, BX_IA_ADC_EbGb },
/* 10 /d */ { 0, BX_IA_ADC_EbGb },
#if BX_SUPPORT_X86_64
/* 10 /q */ { 0, BX_IA_ADC_EbGb },
#endif
};
// opcode 11
static const BxOpcodeInfo_t BxOpcodeTable11[] = {
/* 11 /w */ { 0, BX_IA_ADC_EwGw },
/* 11 /d */ { 0, BX_IA_ADC_EdGd },
#if BX_SUPPORT_X86_64
/* 11 /q */ { 0, BX_IA_ADC_EqGq },
#endif
};
// opcode 12
static const BxOpcodeInfo_t BxOpcodeTable12[] = {
/* 12 /w */ { 0, BX_IA_ADC_GbEb },
/* 12 /d */ { 0, BX_IA_ADC_GbEb },
#if BX_SUPPORT_X86_64
/* 12 /q */ { 0, BX_IA_ADC_GbEb },
#endif
};
// opcode 13
static const BxOpcodeInfo_t BxOpcodeTable13[] = {
/* 13 /w */ { 0, BX_IA_ADC_GwEw },
/* 13 /d */ { 0, BX_IA_ADC_GdEd },
#if BX_SUPPORT_X86_64
/* 13 /q */ { 0, BX_IA_ADC_GqEq },
#endif
};
// opcode 14
static const BxOpcodeInfo_t BxOpcodeTable14[] = {
/* 14 /w */ { BxImmediate_Ib, BX_IA_ADC_ALIb },
/* 14 /d */ { BxImmediate_Ib, BX_IA_ADC_ALIb },
#if BX_SUPPORT_X86_64
/* 14 /q */ { BxImmediate_Ib, BX_IA_ADC_ALIb },
#endif
};
// opcode 15
static const BxOpcodeInfo_t BxOpcodeTable15[] = {
/* 15 /w */ { BxImmediate_Iw, BX_IA_ADC_AXIw },
/* 15 /d */ { BxImmediate_Id, BX_IA_ADC_EAXId },
#if BX_SUPPORT_X86_64
/* 15 /q */ { BxImmediate_Id, BX_IA_ADC_RAXId },
#endif
};
// opcode 16
static const BxOpcodeInfo_t BxOpcodeTable16_32[] = {
/* 16 /w */ { 0, BX_IA_PUSH_Op16_Sw },
/* 16 /d */ { 0, BX_IA_PUSH_Op32_Sw },
};
// opcode 17
static const BxOpcodeInfo_t BxOpcodeTable17_32[] = {
/* 17 /w */ { 0, BX_IA_POP_Op16_Sw },
/* 17 /d */ { 0, BX_IA_POP_Op32_Sw },
};
// opcode 18
static const BxOpcodeInfo_t BxOpcodeTable18[] = {
/* 18 /w */ { 0, BX_IA_SBB_EbGb },
/* 18 /d */ { 0, BX_IA_SBB_EbGb },
#if BX_SUPPORT_X86_64
/* 18 /q */ { 0, BX_IA_SBB_EbGb },
#endif
};
// opcode 19
static const BxOpcodeInfo_t BxOpcodeTable19[] = {
/* 19 /w */ { 0, BX_IA_SBB_EwGw },
/* 19 /d */ { 0, BX_IA_SBB_EdGd },
#if BX_SUPPORT_X86_64
/* 19 /q */ { 0, BX_IA_SBB_EqGq },
#endif
};
// opcode 1A
static const BxOpcodeInfo_t BxOpcodeTable1A[] = {
/* 1A /w */ { 0, BX_IA_SBB_GbEb },
/* 1A /d */ { 0, BX_IA_SBB_GbEb },
#if BX_SUPPORT_X86_64
/* 1A /q */ { 0, BX_IA_SBB_GbEb },
#endif
};
// opcode 1B
static const BxOpcodeInfo_t BxOpcodeTable1B[] = {
/* 1B /w */ { 0, BX_IA_SBB_GwEw },
/* 1B /d */ { 0, BX_IA_SBB_GdEd },
#if BX_SUPPORT_X86_64
/* 1B /q */ { 0, BX_IA_SBB_GqEq },
#endif
};
// opcode 1C
static const BxOpcodeInfo_t BxOpcodeTable1C[] = {
/* 1C /w */ { BxImmediate_Ib, BX_IA_SBB_ALIb },
/* 1C /d */ { BxImmediate_Ib, BX_IA_SBB_ALIb },
#if BX_SUPPORT_X86_64
/* 1C /q */ { BxImmediate_Ib, BX_IA_SBB_ALIb },
#endif
};
// opcode 1D
static const BxOpcodeInfo_t BxOpcodeTable1D[] = {
/* 1D /w */ { BxImmediate_Iw, BX_IA_SBB_AXIw },
/* 1D /d */ { BxImmediate_Id, BX_IA_SBB_EAXId },
#if BX_SUPPORT_X86_64
/* 1D /q */ { BxImmediate_Id, BX_IA_SBB_RAXId },
#endif
};
// opcode 1E
static const BxOpcodeInfo_t BxOpcodeTable1E_32[] = {
/* 1E /w */ { 0, BX_IA_PUSH_Op16_Sw },
/* 1E /d */ { 0, BX_IA_PUSH_Op32_Sw },
};
// opcode 1F
static const BxOpcodeInfo_t BxOpcodeTable1F_32[] = {
/* 1F /w */ { 0, BX_IA_POP_Op16_Sw },
/* 1F /d */ { 0, BX_IA_POP_Op32_Sw },
};
// opcode 20
static const BxOpcodeInfo_t BxOpcodeTable20[] = {
/* 20 /w */ { 0, BX_IA_AND_EbGb },
/* 20 /d */ { 0, BX_IA_AND_EbGb },
#if BX_SUPPORT_X86_64
/* 20 /q */ { 0, BX_IA_AND_EbGb },
#endif
};
// opcode 21
static const BxOpcodeInfo_t BxOpcodeTable21[] = {
/* 21 /w */ { 0, BX_IA_AND_EwGw },
/* 21 /d */ { 0, BX_IA_AND_EdGd },
#if BX_SUPPORT_X86_64
/* 21 /q */ { 0, BX_IA_AND_EqGq },
#endif
};
// opcode 22
static const BxOpcodeInfo_t BxOpcodeTable22[] = {
/* 22 /w */ { 0, BX_IA_AND_GbEb },
/* 22 /d */ { 0, BX_IA_AND_GbEb },
#if BX_SUPPORT_X86_64
/* 22 /q */ { 0, BX_IA_AND_GbEb },
#endif
};
// opcode 23
static const BxOpcodeInfo_t BxOpcodeTable23[] = {
/* 23 /w */ { 0, BX_IA_AND_GwEw },
/* 23 /d */ { 0, BX_IA_AND_GdEd },
#if BX_SUPPORT_X86_64
/* 23 /q */ { 0, BX_IA_AND_GqEq },
#endif
};
// opcode 24
static const BxOpcodeInfo_t BxOpcodeTable24[] = {
/* 24 /w */ { BxImmediate_Ib, BX_IA_AND_ALIb },
/* 24 /d */ { BxImmediate_Ib, BX_IA_AND_ALIb },
#if BX_SUPPORT_X86_64
/* 24 /q */ { BxImmediate_Ib, BX_IA_AND_ALIb },
#endif
};
// opcode 25
static const BxOpcodeInfo_t BxOpcodeTable25[] = {
/* 25 /w */ { BxImmediate_Iw, BX_IA_AND_AXIw },
/* 25 /d */ { BxImmediate_Id, BX_IA_AND_EAXId },
#if BX_SUPPORT_X86_64
/* 25 /q */ { BxImmediate_Id, BX_IA_AND_RAXId },
#endif
};
// opcode 27
static const BxOpcodeInfo_t BxOpcodeTable27_32[] = {
/* 27 */ { 0, BX_IA_DAA },
};
// opcode 28
static const BxOpcodeInfo_t BxOpcodeTable28[] = {
/* 28 /w */ { 0, BX_IA_SUB_EbGb },
/* 28 /d */ { 0, BX_IA_SUB_EbGb },
#if BX_SUPPORT_X86_64
/* 28 /q */ { 0, BX_IA_SUB_EbGb },
#endif
};
// opcode 29
static const BxOpcodeInfo_t BxOpcodeTable29[] = {
/* 29 /w */ { 0, BX_IA_SUB_EwGw },
/* 29 /d */ { 0, BX_IA_SUB_EdGd },
#if BX_SUPPORT_X86_64
/* 29 /q */ { 0, BX_IA_SUB_EqGq },
#endif
};
// opcode 2A
static const BxOpcodeInfo_t BxOpcodeTable2A[] = {
/* 2A /w */ { 0, BX_IA_SUB_GbEb },
/* 2A /d */ { 0, BX_IA_SUB_GbEb },
#if BX_SUPPORT_X86_64
/* 2A /q */ { 0, BX_IA_SUB_GbEb },
#endif
};
// opcode 2B
static const BxOpcodeInfo_t BxOpcodeTable2B[] = {
/* 2B /w */ { 0, BX_IA_SUB_GwEw },
/* 2B /d */ { 0, BX_IA_SUB_GdEd },
#if BX_SUPPORT_X86_64
/* 2B /q */ { 0, BX_IA_SUB_GqEq },
#endif
};
// opcode 2C
static const BxOpcodeInfo_t BxOpcodeTable2C[] = {
/* 2C /w */ { BxImmediate_Ib, BX_IA_SUB_ALIb },
/* 2C /d */ { BxImmediate_Ib, BX_IA_SUB_ALIb },
#if BX_SUPPORT_X86_64
/* 2C /q */ { BxImmediate_Ib, BX_IA_SUB_ALIb },
#endif
};
// opcode 2D
static const BxOpcodeInfo_t BxOpcodeTable2D[] = {
/* 2D /w */ { BxImmediate_Iw, BX_IA_SUB_AXIw },
/* 2D /d */ { BxImmediate_Id, BX_IA_SUB_EAXId },
#if BX_SUPPORT_X86_64
/* 2D /q */ { BxImmediate_Id, BX_IA_SUB_RAXId },
#endif
};
// opcode 2F
static const BxOpcodeInfo_t BxOpcodeTable2F_32[] = {
/* 2F */ { 0, BX_IA_DAS },
};
// opcode 30
static const BxOpcodeInfo_t BxOpcodeTable30[] = {
/* 30 /w */ { 0, BX_IA_XOR_EbGb },
/* 30 /d */ { 0, BX_IA_XOR_EbGb },
#if BX_SUPPORT_X86_64
/* 30 /q */ { 0, BX_IA_XOR_EbGb },
#endif
};
// opcode 31
static const BxOpcodeInfo_t BxOpcodeTable31[] = {
/* 31 /w */ { 0, BX_IA_XOR_EwGw },
/* 31 /d */ { 0, BX_IA_XOR_EdGd },
#if BX_SUPPORT_X86_64
/* 31 /q */ { 0, BX_IA_XOR_EqGq },
#endif
};
// opcode 32
static const BxOpcodeInfo_t BxOpcodeTable32[] = {
/* 32 /w */ { 0, BX_IA_XOR_GbEb },
/* 32 /d */ { 0, BX_IA_XOR_GbEb },
#if BX_SUPPORT_X86_64
/* 32 /q */ { 0, BX_IA_XOR_GbEb },
#endif
};
// opcode 33
static const BxOpcodeInfo_t BxOpcodeTable33[] = {
/* 33 /w */ { 0, BX_IA_XOR_GwEw },
/* 33 /d */ { 0, BX_IA_XOR_GdEd },
#if BX_SUPPORT_X86_64
/* 33 /q */ { 0, BX_IA_XOR_GqEq },
#endif
};
// opcode 34
static const BxOpcodeInfo_t BxOpcodeTable34[] = {
/* 34 /w */ { BxImmediate_Ib, BX_IA_XOR_ALIb },
/* 34 /d */ { BxImmediate_Ib, BX_IA_XOR_ALIb },
#if BX_SUPPORT_X86_64
/* 34 /q */ { BxImmediate_Ib, BX_IA_XOR_ALIb },
#endif
};
// opcode 35
static const BxOpcodeInfo_t BxOpcodeTable35[] = {
/* 35 /w */ { BxImmediate_Iw, BX_IA_XOR_AXIw },
/* 35 /d */ { BxImmediate_Id, BX_IA_XOR_EAXId },
#if BX_SUPPORT_X86_64
/* 35 /q */ { BxImmediate_Id, BX_IA_XOR_RAXId },
#endif
};
// opcode 37
static const BxOpcodeInfo_t BxOpcodeTable37_32[] = {
/* 37 */ { 0, BX_IA_AAA },
};
// opcode 38
static const BxOpcodeInfo_t BxOpcodeTable38[] = {
/* 38 /w */ { 0, BX_IA_CMP_EbGb },
/* 38 /d */ { 0, BX_IA_CMP_EbGb },
#if BX_SUPPORT_X86_64
/* 38 /q */ { 0, BX_IA_CMP_EbGb },
#endif
};
// opcode 39
static const BxOpcodeInfo_t BxOpcodeTable39[] = {
/* 39 /w */ { 0, BX_IA_CMP_EwGw },
/* 39 /d */ { 0, BX_IA_CMP_EdGd },
#if BX_SUPPORT_X86_64
/* 39 /q */ { 0, BX_IA_CMP_EqGq },
#endif
};
// opcode 3A
static const BxOpcodeInfo_t BxOpcodeTable3A[] = {
/* 3A /w */ { 0, BX_IA_CMP_GbEb },
/* 3A /d */ { 0, BX_IA_CMP_GbEb },
#if BX_SUPPORT_X86_64
/* 3A /q */ { 0, BX_IA_CMP_GbEb },
#endif
};
// opcode 3B
static const BxOpcodeInfo_t BxOpcodeTable3B[] = {
/* 3B /w */ { 0, BX_IA_CMP_GwEw },
/* 3B /d */ { 0, BX_IA_CMP_GdEd },
#if BX_SUPPORT_X86_64
/* 3B /q */ { 0, BX_IA_CMP_GqEq },
#endif
};
// opcode 3C
static const BxOpcodeInfo_t BxOpcodeTable3C[] = {
/* 3C /w */ { BxImmediate_Ib, BX_IA_CMP_ALIb },
/* 3C /d */ { BxImmediate_Ib, BX_IA_CMP_ALIb },
#if BX_SUPPORT_X86_64
/* 3C /q */ { BxImmediate_Ib, BX_IA_CMP_ALIb },
#endif
};
// opcode 3D
static const BxOpcodeInfo_t BxOpcodeTable3D[] = {
/* 3D /w */ { BxImmediate_Iw, BX_IA_CMP_AXIw },
/* 3D /d */ { BxImmediate_Id, BX_IA_CMP_EAXId },
#if BX_SUPPORT_X86_64
/* 3D /q */ { BxImmediate_Id, BX_IA_CMP_RAXId },
#endif
};
// opcode 3F
static const BxOpcodeInfo_t BxOpcodeTable3F_32[] = {
/* 3F */ { 0, BX_IA_AAS },
};
// opcode 40 - 47
static const BxOpcodeInfo_t BxOpcodeTable40x47_32[] = {
/* 40 /w */ { 0, BX_IA_INC_Ew },
/* 40 /d */ { 0, BX_IA_INC_Ed },
};
// opcode 48 - 4F
static const BxOpcodeInfo_t BxOpcodeTable48x4F_32[] = {
/* 49 /w */ { 0, BX_IA_DEC_Ew },
/* 49 /d */ { 0, BX_IA_DEC_Ed },
};
// opcode 50 - 57
static const BxOpcodeInfo_t BxOpcodeTable50x57_32[] = {
/* 50 /w */ { 0, BX_IA_PUSH_Ew },
/* 50 /d */ { 0, BX_IA_PUSH_Ed },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable50x57_64[] = {
/* 50 /w */ { 0, BX_IA_PUSH_Ew },
/* 50 /d */ { 0, BX_IA_PUSH_Eq },
/* 50 /q */ { 0, BX_IA_PUSH_Eq },
};
#endif
// opcode 58 - 5F
static const BxOpcodeInfo_t BxOpcodeTable58x5F_32[] = {
/* 58 /w */ { 0, BX_IA_POP_Ew },
/* 58 /d */ { 0, BX_IA_POP_Ed },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable58x5F_64[] = {
/* 58 /w */ { 0, BX_IA_POP_Ew },
/* 58 /d */ { 0, BX_IA_POP_Eq },
/* 58 /q */ { 0, BX_IA_POP_Eq },
};
#endif
// opcode 60
static const BxOpcodeInfo_t BxOpcodeTable60_32[] = {
/* 60 /w */ { 0, BX_IA_PUSHA_Op16 },
/* 60 /d */ { 0, BX_IA_PUSHA_Op32 },
};
// opcode 61
static const BxOpcodeInfo_t BxOpcodeTable61_32[] = {
/* 61 /w */ { 0, BX_IA_POPA_Op16 },
/* 61 /d */ { 0, BX_IA_POPA_Op32 },
};
// opcode 62
static const BxOpcodeInfo_t BxOpcodeTable62_32[] = {
/* 62 /w */ { 0, BX_IA_BOUND_GwMa },
/* 62 /d */ { 0, BX_IA_BOUND_GdMa },
};
// opcode 63
static const BxOpcodeInfo_t BxOpcodeTable63_32[] = {
/* 63 /w */ { 0, BX_IA_ARPL_EwGw },
/* 63 /d */ { 0, BX_IA_ARPL_EwGw },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable63_64[] = {
/* 63 /w */ { 0, BX_IA_MOV_GwEw }, // MOVSX_GwEw
/* 63 /d */ { 0, BX_IA_MOV_Op64_GdEd }, // MOVSX_GdEd
/* 63 /q */ { 0, BX_IA_MOVSXD_GqEd },
};
#endif
// opcode 68
static const BxOpcodeInfo_t BxOpcodeTable68_32[] = {
/* 68 /w */ { BxImmediate_Iw, BX_IA_PUSH_Iw },
/* 68 /d */ { BxImmediate_Id, BX_IA_PUSH_Id },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable68_64[] = {
/* 68 /w */ { BxImmediate_Iw, BX_IA_PUSH_Iw },
/* 68 /d */ { BxImmediate_Id, BX_IA_PUSH_Op64_Id },
/* 68 /q */ { BxImmediate_Id, BX_IA_PUSH_Op64_Id },
};
#endif
// opcode 69
static const BxOpcodeInfo_t BxOpcodeTable69[] = {
/* 69 /w */ { BxImmediate_Iw, BX_IA_IMUL_GwEwIw },
/* 69 /d */ { BxImmediate_Id, BX_IA_IMUL_GdEdId },
#if BX_SUPPORT_X86_64
/* 69 /q */ { BxImmediate_Id, BX_IA_IMUL_GqEqId },
#endif
};
// opcode 6A
static const BxOpcodeInfo_t BxOpcodeTable6A_32[] = {
/* 6A /w */ { BxImmediate_Ib_SE, BX_IA_PUSH_Iw },
/* 6A /d */ { BxImmediate_Ib_SE, BX_IA_PUSH_Id },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable6A_64[] = {
/* 6A /w */ { BxImmediate_Ib_SE, BX_IA_PUSH_Iw },
/* 6A /d */ { BxImmediate_Ib_SE, BX_IA_PUSH_Op64_Id },
/* 6A /q */ { BxImmediate_Ib_SE, BX_IA_PUSH_Op64_Id },
};
#endif
// opcode 6B
static const BxOpcodeInfo_t BxOpcodeTable6B[] = {
/* 6B /w */ { BxImmediate_Ib_SE, BX_IA_IMUL_GwEwIw },
/* 6B /d */ { BxImmediate_Ib_SE, BX_IA_IMUL_GdEdId },
#if BX_SUPPORT_X86_64
/* 6B /q */ { BxImmediate_Ib_SE, BX_IA_IMUL_GqEqId },
#endif
};
// opcode 6C
static const BxOpcodeInfo_t BxOpcodeTable6C[] = {
/* 6C /w */ { 0, BX_IA_REP_INSB_YbDX },
/* 6C /d */ { 0, BX_IA_REP_INSB_YbDX },
#if BX_SUPPORT_X86_64
/* 6C /q */ { 0, BX_IA_REP_INSB_YbDX },
#endif
};
// opcode 6D
static const BxOpcodeInfo_t BxOpcodeTable6D[] = {
/* 6D /w */ { 0, BX_IA_REP_INSW_YwDX },
/* 6D /d */ { 0, BX_IA_REP_INSD_YdDX },
#if BX_SUPPORT_X86_64
/* 6D /q */ { 0, BX_IA_REP_INSD_YdDX },
#endif
};
// opcode 6E
static const BxOpcodeInfo_t BxOpcodeTable6E[] = {
/* 6E /w */ { 0, BX_IA_REP_OUTSB_DXXb },
/* 6E /d */ { 0, BX_IA_REP_OUTSB_DXXb },
#if BX_SUPPORT_X86_64
/* 6E /q */ { 0, BX_IA_REP_OUTSB_DXXb },
#endif
};
// opcode 6F
static const BxOpcodeInfo_t BxOpcodeTable6F[] = {
/* 6F /w */ { 0, BX_IA_REP_OUTSW_DXXw },
/* 6F /d */ { 0, BX_IA_REP_OUTSD_DXXd },
#if BX_SUPPORT_X86_64
/* 6F /q */ { 0, BX_IA_REP_OUTSD_DXXd },
#endif
};
// opcode 70
static const BxOpcodeInfo_t BxOpcodeTable70_32[] = {
/* 70 /w */ { BxImmediate_BrOff8, BX_IA_JO_Jw },
/* 70 /d */ { BxImmediate_BrOff8, BX_IA_JO_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable70_64[] = {
/* 70 /w */ { BxImmediate_BrOff8, BX_IA_JO_Jq },
/* 70 /d */ { BxImmediate_BrOff8, BX_IA_JO_Jq },
/* 70 /q */ { BxImmediate_BrOff8, BX_IA_JO_Jq },
};
#endif
// opcode 71
static const BxOpcodeInfo_t BxOpcodeTable71_32[] = {
/* 71 /w */ { BxImmediate_BrOff8, BX_IA_JNO_Jw },
/* 71 /d */ { BxImmediate_BrOff8, BX_IA_JNO_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable71_64[] = {
/* 71 /w */ { BxImmediate_BrOff8, BX_IA_JNO_Jq },
/* 71 /d */ { BxImmediate_BrOff8, BX_IA_JNO_Jq },
/* 71 /q */ { BxImmediate_BrOff8, BX_IA_JNO_Jq },
};
#endif
// opcode 72
static const BxOpcodeInfo_t BxOpcodeTable72_32[] = {
/* 72 /w */ { BxImmediate_BrOff8, BX_IA_JB_Jw },
/* 72 /d */ { BxImmediate_BrOff8, BX_IA_JB_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable72_64[] = {
/* 72 /w */ { BxImmediate_BrOff8, BX_IA_JB_Jq },
/* 72 /d */ { BxImmediate_BrOff8, BX_IA_JB_Jq },
/* 72 /q */ { BxImmediate_BrOff8, BX_IA_JB_Jq },
};
#endif
// opcode 73
static const BxOpcodeInfo_t BxOpcodeTable73_32[] = {
/* 73 /w */ { BxImmediate_BrOff8, BX_IA_JNB_Jw },
/* 73 /d */ { BxImmediate_BrOff8, BX_IA_JNB_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable73_64[] = {
/* 73 /w */ { BxImmediate_BrOff8, BX_IA_JNB_Jq },
/* 73 /d */ { BxImmediate_BrOff8, BX_IA_JNB_Jq },
/* 73 /q */ { BxImmediate_BrOff8, BX_IA_JNB_Jq },
};
#endif
// opcode 74
static const BxOpcodeInfo_t BxOpcodeTable74_32[] = {
/* 74 /w */ { BxImmediate_BrOff8, BX_IA_JZ_Jw },
/* 74 /d */ { BxImmediate_BrOff8, BX_IA_JZ_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable74_64[] = {
/* 74 /w */ { BxImmediate_BrOff8, BX_IA_JZ_Jq },
/* 74 /d */ { BxImmediate_BrOff8, BX_IA_JZ_Jq },
/* 74 /q */ { BxImmediate_BrOff8, BX_IA_JZ_Jq },
};
#endif
// opcode 75
static const BxOpcodeInfo_t BxOpcodeTable75_32[] = {
/* 75 /w */ { BxImmediate_BrOff8, BX_IA_JNZ_Jw },
/* 75 /d */ { BxImmediate_BrOff8, BX_IA_JNZ_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable75_64[] = {
/* 75 /w */ { BxImmediate_BrOff8, BX_IA_JNZ_Jq },
/* 75 /d */ { BxImmediate_BrOff8, BX_IA_JNZ_Jq },
/* 75 /q */ { BxImmediate_BrOff8, BX_IA_JNZ_Jq },
};
#endif
// opcode 76
static const BxOpcodeInfo_t BxOpcodeTable76_32[] = {
/* 76 /w */ { BxImmediate_BrOff8, BX_IA_JBE_Jw },
/* 76 /d */ { BxImmediate_BrOff8, BX_IA_JBE_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable76_64[] = {
/* 76 /w */ { BxImmediate_BrOff8, BX_IA_JBE_Jq },
/* 76 /d */ { BxImmediate_BrOff8, BX_IA_JBE_Jq },
/* 76 /q */ { BxImmediate_BrOff8, BX_IA_JBE_Jq },
};
#endif
// opcode 77
static const BxOpcodeInfo_t BxOpcodeTable77_32[] = {
/* 77 /w */ { BxImmediate_BrOff8, BX_IA_JNBE_Jw },
/* 77 /d */ { BxImmediate_BrOff8, BX_IA_JNBE_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable77_64[] = {
/* 77 /w */ { BxImmediate_BrOff8, BX_IA_JNBE_Jq },
/* 77 /d */ { BxImmediate_BrOff8, BX_IA_JNBE_Jq },
/* 77 /q */ { BxImmediate_BrOff8, BX_IA_JNBE_Jq },
};
#endif
// opcode 78
static const BxOpcodeInfo_t BxOpcodeTable78_32[] = {
/* 78 /w */ { BxImmediate_BrOff8, BX_IA_JS_Jw },
/* 78 /d */ { BxImmediate_BrOff8, BX_IA_JS_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable78_64[] = {
/* 78 /w */ { BxImmediate_BrOff8, BX_IA_JS_Jq },
/* 78 /d */ { BxImmediate_BrOff8, BX_IA_JS_Jq },
/* 78 /q */ { BxImmediate_BrOff8, BX_IA_JS_Jq },
};
#endif
// opcode 79
static const BxOpcodeInfo_t BxOpcodeTable79_32[] = {
/* 79 /w */ { BxImmediate_BrOff8, BX_IA_JNS_Jw },
/* 79 /d */ { BxImmediate_BrOff8, BX_IA_JNS_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable79_64[] = {
/* 79 /w */ { BxImmediate_BrOff8, BX_IA_JNS_Jq },
/* 79 /d */ { BxImmediate_BrOff8, BX_IA_JNS_Jq },
/* 79 /q */ { BxImmediate_BrOff8, BX_IA_JNS_Jq },
};
#endif
// opcode 7A
static const BxOpcodeInfo_t BxOpcodeTable7A_32[] = {
/* 7A /w */ { BxImmediate_BrOff8, BX_IA_JP_Jw },
/* 7A /d */ { BxImmediate_BrOff8, BX_IA_JP_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable7A_64[] = {
/* 7A /w */ { BxImmediate_BrOff8, BX_IA_JP_Jq },
/* 7A /d */ { BxImmediate_BrOff8, BX_IA_JP_Jq },
/* 7A /q */ { BxImmediate_BrOff8, BX_IA_JP_Jq },
};
#endif
// opcode 7B
static const BxOpcodeInfo_t BxOpcodeTable7B_32[] = {
/* 7B /w */ { BxImmediate_BrOff8, BX_IA_JNP_Jw },
/* 7B /d */ { BxImmediate_BrOff8, BX_IA_JNP_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable7B_64[] = {
/* 7B /w */ { BxImmediate_BrOff8, BX_IA_JNP_Jq },
/* 7B /d */ { BxImmediate_BrOff8, BX_IA_JNP_Jq },
/* 7B /q */ { BxImmediate_BrOff8, BX_IA_JNP_Jq },
};
#endif
// opcode 7C
static const BxOpcodeInfo_t BxOpcodeTable7C_32[] = {
/* 7C /w */ { BxImmediate_BrOff8, BX_IA_JL_Jw },
/* 7C /d */ { BxImmediate_BrOff8, BX_IA_JL_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable7C_64[] = {
/* 7C /w */ { BxImmediate_BrOff8, BX_IA_JL_Jq },
/* 7C /d */ { BxImmediate_BrOff8, BX_IA_JL_Jq },
/* 7C /q */ { BxImmediate_BrOff8, BX_IA_JL_Jq },
};
#endif
// opcode 7D
static const BxOpcodeInfo_t BxOpcodeTable7D_32[] = {
/* 7D /w */ { BxImmediate_BrOff8, BX_IA_JNL_Jw },
/* 7D /d */ { BxImmediate_BrOff8, BX_IA_JNL_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable7D_64[] = {
/* 7D /w */ { BxImmediate_BrOff8, BX_IA_JNL_Jq },
/* 7D /d */ { BxImmediate_BrOff8, BX_IA_JNL_Jq },
/* 7D /q */ { BxImmediate_BrOff8, BX_IA_JNL_Jq },
};
#endif
// opcode 7E
static const BxOpcodeInfo_t BxOpcodeTable7E_32[] = {
/* 7E /w */ { BxImmediate_BrOff8, BX_IA_JLE_Jw },
/* 7E /d */ { BxImmediate_BrOff8, BX_IA_JLE_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable7E_64[] = {
/* 7E /w */ { BxImmediate_BrOff8, BX_IA_JLE_Jq },
/* 7E /d */ { BxImmediate_BrOff8, BX_IA_JLE_Jq },
/* 7E /q */ { BxImmediate_BrOff8, BX_IA_JLE_Jq },
};
#endif
// opcode 7F
static const BxOpcodeInfo_t BxOpcodeTable7F_32[] = {
/* 7F /w */ { BxImmediate_BrOff8, BX_IA_JNLE_Jw },
/* 7F /d */ { BxImmediate_BrOff8, BX_IA_JNLE_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable7F_64[] = {
/* 7F /w */ { BxImmediate_BrOff8, BX_IA_JNLE_Jq },
/* 7F /d */ { BxImmediate_BrOff8, BX_IA_JNLE_Jq },
/* 7F /q */ { BxImmediate_BrOff8, BX_IA_JNLE_Jq },
};
#endif
// opcode 80
static const BxOpcodeInfo_t BxOpcodeTable80_G1Eb[8] = {
/* /0 */ { BxImmediate_Ib, BX_IA_ADD_EbIb },
/* /1 */ { BxImmediate_Ib, BX_IA_OR_EbIb },
/* /2 */ { BxImmediate_Ib, BX_IA_ADC_EbIb },
/* /3 */ { BxImmediate_Ib, BX_IA_SBB_EbIb },
/* /4 */ { BxImmediate_Ib, BX_IA_AND_EbIb },
/* /5 */ { BxImmediate_Ib, BX_IA_SUB_EbIb },
/* /6 */ { BxImmediate_Ib, BX_IA_XOR_EbIb },
/* /7 */ { BxImmediate_Ib, BX_IA_CMP_EbIb }
};
// opcode 81
static const BxOpcodeInfo_t BxOpcodeTable81_G1Ev[] = {
// osize = 16 bit
/* /0 /w */ { BxImmediate_Iw, BX_IA_ADD_EwIw },
/* /1 /w */ { BxImmediate_Iw, BX_IA_OR_EwIw },
/* /2 /w */ { BxImmediate_Iw, BX_IA_ADC_EwIw },
/* /3 /w */ { BxImmediate_Iw, BX_IA_SBB_EwIw },
/* /4 /w */ { BxImmediate_Iw, BX_IA_AND_EwIw },
/* /5 /w */ { BxImmediate_Iw, BX_IA_SUB_EwIw },
/* /6 /w */ { BxImmediate_Iw, BX_IA_XOR_EwIw },
/* /7 /w */ { BxImmediate_Iw, BX_IA_CMP_EwIw },
// osize = 32 bit
/* /0 /d */ { BxImmediate_Id, BX_IA_ADD_EdId },
/* /1 /d */ { BxImmediate_Id, BX_IA_OR_EdId },
/* /2 /d */ { BxImmediate_Id, BX_IA_ADC_EdId },
/* /3 /d */ { BxImmediate_Id, BX_IA_SBB_EdId },
/* /4 /d */ { BxImmediate_Id, BX_IA_AND_EdId },
/* /5 /d */ { BxImmediate_Id, BX_IA_SUB_EdId },
/* /6 /d */ { BxImmediate_Id, BX_IA_XOR_EdId },
/* /7 /d */ { BxImmediate_Id, BX_IA_CMP_EdId },
#if BX_SUPPORT_X86_64
/* /0 /q */ { BxImmediate_Id, BX_IA_ADD_EqId },
/* /1 /q */ { BxImmediate_Id, BX_IA_OR_EqId },
/* /2 /q */ { BxImmediate_Id, BX_IA_ADC_EqId },
/* /3 /q */ { BxImmediate_Id, BX_IA_SBB_EqId },
/* /4 /q */ { BxImmediate_Id, BX_IA_AND_EqId },
/* /5 /q */ { BxImmediate_Id, BX_IA_SUB_EqId },
/* /6 /q */ { BxImmediate_Id, BX_IA_XOR_EqId },
/* /7 /q */ { BxImmediate_Id, BX_IA_CMP_EqId },
#endif
};
// opcode 83
static const BxOpcodeInfo_t BxOpcodeTable83_G1Ev[] = {
// osize = 16 bit
/* /0 /w */ { BxImmediate_Ib_SE, BX_IA_ADD_EwIw },
/* /1 /w */ { BxImmediate_Ib_SE, BX_IA_OR_EwIw },
/* /2 /w */ { BxImmediate_Ib_SE, BX_IA_ADC_EwIw },
/* /3 /w */ { BxImmediate_Ib_SE, BX_IA_SBB_EwIw },
/* /4 /w */ { BxImmediate_Ib_SE, BX_IA_AND_EwIw },
/* /5 /w */ { BxImmediate_Ib_SE, BX_IA_SUB_EwIw },
/* /6 /w */ { BxImmediate_Ib_SE, BX_IA_XOR_EwIw },
/* /7 /w */ { BxImmediate_Ib_SE, BX_IA_CMP_EwIw },
// osize = 32 bit
/* /0 /d */ { BxImmediate_Ib_SE, BX_IA_ADD_EdId },
/* /1 /d */ { BxImmediate_Ib_SE, BX_IA_OR_EdId },
/* /2 /d */ { BxImmediate_Ib_SE, BX_IA_ADC_EdId },
/* /3 /d */ { BxImmediate_Ib_SE, BX_IA_SBB_EdId },
/* /4 /d */ { BxImmediate_Ib_SE, BX_IA_AND_EdId },
/* /5 /d */ { BxImmediate_Ib_SE, BX_IA_SUB_EdId },
/* /6 /d */ { BxImmediate_Ib_SE, BX_IA_XOR_EdId },
/* /7 /d */ { BxImmediate_Ib_SE, BX_IA_CMP_EdId },
#if BX_SUPPORT_X86_64
// osize = 64 bit
/* /0 /q */ { BxImmediate_Ib_SE, BX_IA_ADD_EqId },
/* /1 /q */ { BxImmediate_Ib_SE, BX_IA_OR_EqId },
/* /2 /q */ { BxImmediate_Ib_SE, BX_IA_ADC_EqId },
/* /3 /q */ { BxImmediate_Ib_SE, BX_IA_SBB_EqId },
/* /4 /q */ { BxImmediate_Ib_SE, BX_IA_AND_EqId },
/* /5 /q */ { BxImmediate_Ib_SE, BX_IA_SUB_EqId },
/* /6 /q */ { BxImmediate_Ib_SE, BX_IA_XOR_EqId },
/* /7 /q */ { BxImmediate_Ib_SE, BX_IA_CMP_EqId },
#endif
};
// opcode 84
static const BxOpcodeInfo_t BxOpcodeTable84[] = {
/* 84 /w */ { 0, BX_IA_TEST_EbGb },
/* 84 /d */ { 0, BX_IA_TEST_EbGb },
#if BX_SUPPORT_X86_64
/* 84 /q */ { 0, BX_IA_TEST_EbGb },
#endif
};
// opcode 85
static const BxOpcodeInfo_t BxOpcodeTable85[] = {
/* 85 /w */ { 0, BX_IA_TEST_EwGw },
/* 85 /d */ { 0, BX_IA_TEST_EdGd },
#if BX_SUPPORT_X86_64
/* 85 /q */ { 0, BX_IA_TEST_EqGq },
#endif
};
// opcode 86
static const BxOpcodeInfo_t BxOpcodeTable86[] = {
/* 86 /w */ { 0, BX_IA_XCHG_EbGb },
/* 86 /d */ { 0, BX_IA_XCHG_EbGb },
#if BX_SUPPORT_X86_64
/* 86 /q */ { 0, BX_IA_XCHG_EbGb },
#endif
};
// opcode 87
static const BxOpcodeInfo_t BxOpcodeTable87[] = {
/* 87 /w */ { 0, BX_IA_XCHG_EwGw },
/* 87 /d */ { 0, BX_IA_XCHG_EdGd },
#if BX_SUPPORT_X86_64
/* 87 /q */ { 0, BX_IA_XCHG_EqGq },
#endif
};
// opcode 88
static const BxOpcodeInfo_t BxOpcodeTable88[] = {
/* 88 /w */ { 0, BX_IA_MOV_EbGb },
/* 88 /d */ { 0, BX_IA_MOV_EbGb },
#if BX_SUPPORT_X86_64
/* 88 /q */ { 0, BX_IA_MOV_EbGb },
#endif
};
// opcode 89 - split for better emulation performance
static const BxOpcodeInfo_t BxOpcodeTable89_32[] = {
/* 89 /w */ { 0, BX_IA_MOV_EwGw },
/* 89 /d */ { 0, BX_IA_MOV_Op32_EdGd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable89_64[] = {
/* 89 /w */ { 0, BX_IA_MOV_EwGw },
/* 89 /d */ { 0, BX_IA_MOV_Op64_EdGd },
/* 89 /q */ { 0, BX_IA_MOV_EqGq },
};
#endif
// opcode 8A
static const BxOpcodeInfo_t BxOpcodeTable8A[] = {
/* 8A /w */ { 0, BX_IA_MOV_GbEb },
/* 8A /d */ { 0, BX_IA_MOV_GbEb },
#if BX_SUPPORT_X86_64
/* 8A /q */ { 0, BX_IA_MOV_GbEb },
#endif
};
// opcode 8B - split for better emulation performance
static const BxOpcodeInfo_t BxOpcodeTable8B_32[] = {
/* 8B /w */ { 0, BX_IA_MOV_GwEw },
/* 8B /d */ { 0, BX_IA_MOV_Op32_GdEd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable8B_64[] = {
/* 8B /w */ { 0, BX_IA_MOV_GwEw },
/* 8B /d */ { 0, BX_IA_MOV_Op64_GdEd },
/* 8B /q */ { 0, BX_IA_MOV_GqEq },
};
#endif
// opcode 8C
static const BxOpcodeInfo_t BxOpcodeTable8C[] = {
/* 8C /w */ { 0, BX_IA_MOV_EwSw },
/* 8C /d */ { 0, BX_IA_MOV_EwSw },
#if BX_SUPPORT_X86_64
/* 8C /q */ { 0, BX_IA_MOV_EwSw },
#endif
};
// opcode 8D
static const BxOpcodeInfo_t BxOpcodeTable8D[] = {
/* 8D /w */ { 0, BX_IA_LEA_GwM },
/* 8D /d */ { 0, BX_IA_LEA_GdM },
#if BX_SUPPORT_X86_64
/* 8D /q */ { 0, BX_IA_LEA_GqM },
#endif
};
// opcode 8E
static const BxOpcodeInfo_t BxOpcodeTable8E[] = {
/* 8E /w */ { 0, BX_IA_MOV_SwEw },
/* 8E /d */ { 0, BX_IA_MOV_SwEw },
#if BX_SUPPORT_X86_64
/* 8E /q */ { 0, BX_IA_MOV_SwEw },
#endif
};
// opcode 8F - GroupN / XOP prefix
static const BxOpcodeInfo_t BxOpcodeTable8F[] = {
/* 8F /w */ { 0, BX_IA_POP_Ew },
/* 8F /d */ { 0, BX_IA_POP_Ed },
#if BX_SUPPORT_X86_64
/* 8F /q */ { 0, BX_IA_POP_Eq },
#endif
};
// opcode 90 - 97
static const BxOpcodeInfo_t BxOpcodeTable90x97[] = {
/* 91 /w */ { 0, BX_IA_XCHG_RXAX }, // handles also XCHG R8w, AX
/* 91 /d */ { 0, BX_IA_XCHG_ERXEAX }, // handles also XCHG R8d, EAX
#if BX_SUPPORT_X86_64
/* 91 /q */ { 0, BX_IA_XCHG_RRXRAX }, // handles also XCHG R8, RAX
#endif
};
// opcode 98
static const BxOpcodeInfo_t BxOpcodeTable98[] = {
/* 98 /w */ { 0, BX_IA_CBW },
/* 98 /d */ { 0, BX_IA_CWDE },
#if BX_SUPPORT_X86_64
/* 98 /q */ { 0, BX_IA_CDQE },
#endif
};
// opcode 99
static const BxOpcodeInfo_t BxOpcodeTable99[] = {
/* 99 /w */ { 0, BX_IA_CWD },
/* 99 /d */ { 0, BX_IA_CDQ },
#if BX_SUPPORT_X86_64
/* 99 /q */ { 0, BX_IA_CQO },
#endif
};
// opcode 9A
static const BxOpcodeInfo_t BxOpcodeTable9A_32[] = {
/* 9A /w */ { BxImmediate_Iw | BxImmediate_Iw2, BX_IA_CALLF_Op16_Ap },
/* 9A /d */ { BxImmediate_Id | BxImmediate_Iw2, BX_IA_CALLF_Op32_Ap },
};
// opcode 9B
static const BxOpcodeInfo_t BxOpcodeTable9B[] = {
/* 9B */ { 0, BX_IA_FWAIT },
};
// opcode 9C
static const BxOpcodeInfo_t BxOpcodeTable9C_32[] = {
/* 9C /w */ { 0, BX_IA_PUSHF_Fw },
/* 9C /d */ { 0, BX_IA_PUSHF_Fd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable9C_64[] = {
/* 9C /w */ { 0, BX_IA_PUSHF_Fw },
/* 9C /d */ { 0, BX_IA_PUSHF_Fq },
/* 9C /q */ { 0, BX_IA_PUSHF_Fq },
};
#endif
// opcode 9D
static const BxOpcodeInfo_t BxOpcodeTable9D_32[] = {
/* 9D /w */ { 0, BX_IA_POPF_Fw },
/* 9D /d */ { 0, BX_IA_POPF_Fd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable9D_64[] = {
/* 9D /w */ { 0, BX_IA_POPF_Fw },
/* 9D /d */ { 0, BX_IA_POPF_Fq },
/* 9D /q */ { 0, BX_IA_POPF_Fq },
};
#endif
// opcode 9E
static const BxOpcodeInfo_t BxOpcodeTable9E_32[] = {
/* 9E */ { 0, BX_IA_SAHF },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable9E_64[] = {
/* 9E */ { 0, BX_IA_SAHF_LM },
};
#endif
// opcode 9F
static const BxOpcodeInfo_t BxOpcodeTable9F_32[] = {
/* 9F */ { 0, BX_IA_LAHF },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable9F_64[] = {
/* 9F */ { 0, BX_IA_LAHF_LM },
};
#endif
// opcode A0
static const BxOpcodeInfo_t BxOpcodeTableA0_32[] = {
/* A0 /w */ { BxImmediate_O, BX_IA_MOV_ALOd },
/* A0 /d */ { BxImmediate_O, BX_IA_MOV_ALOd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableA0_64[] = {
/* A0 /w */ { BxImmediate_O, BX_IA_MOV_ALOq },
/* A0 /d */ { BxImmediate_O, BX_IA_MOV_ALOq },
/* A0 /q */ { BxImmediate_O, BX_IA_MOV_ALOq },
};
#endif
// opcode A1
static const BxOpcodeInfo_t BxOpcodeTableA1_32[] = {
/* A1 /w */ { BxImmediate_O, BX_IA_MOV_AXOd },
/* A1 /d */ { BxImmediate_O, BX_IA_MOV_EAXOd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableA1_64[] = {
/* A1 /w */ { BxImmediate_O, BX_IA_MOV_AXOq },
/* A1 /d */ { BxImmediate_O, BX_IA_MOV_EAXOq },
/* A1 /q */ { BxImmediate_O, BX_IA_MOV_RAXOq },
};
#endif
// opcode A2
static const BxOpcodeInfo_t BxOpcodeTableA2_32[] = {
/* A2 /w */ { BxImmediate_O, BX_IA_MOV_OdAL },
/* A2 /d */ { BxImmediate_O, BX_IA_MOV_OdAL },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableA2_64[] = {
/* A2 /w */ { BxImmediate_O, BX_IA_MOV_OqAL },
/* A2 /d */ { BxImmediate_O, BX_IA_MOV_OqAL },
/* A2 /q */ { BxImmediate_O, BX_IA_MOV_OqAL },
};
#endif
// opcode A3
static const BxOpcodeInfo_t BxOpcodeTableA3_32[] = {
/* A3 /w */ { BxImmediate_O, BX_IA_MOV_OdAX },
/* A3 /d */ { BxImmediate_O, BX_IA_MOV_OdEAX },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableA3_64[] = {
/* A3 /w */ { BxImmediate_O, BX_IA_MOV_OqAX },
/* A3 /d */ { BxImmediate_O, BX_IA_MOV_OqEAX },
/* A3 /q */ { BxImmediate_O, BX_IA_MOV_OqRAX },
};
#endif
// opcode A4
static const BxOpcodeInfo_t BxOpcodeTableA4[] = {
/* A4 /w */ { 0, BX_IA_REP_MOVSB_YbXb },
/* A4 /d */ { 0, BX_IA_REP_MOVSB_YbXb },
#if BX_SUPPORT_X86_64
/* A4 /q */ { 0, BX_IA_REP_MOVSB_YbXb },
#endif
};
// opcode A5
static const BxOpcodeInfo_t BxOpcodeTableA5[] = {
/* A5 /w */ { 0, BX_IA_REP_MOVSW_YwXw },
/* A5 /d */ { 0, BX_IA_REP_MOVSD_YdXd },
#if BX_SUPPORT_X86_64
/* A5 /q */ { 0, BX_IA_REP_MOVSQ_YqXq },
#endif
};
// opcode A6
static const BxOpcodeInfo_t BxOpcodeTableA6[] = {
/* A6 /w */ { 0, BX_IA_REP_CMPSB_XbYb },
/* A6 /d */ { 0, BX_IA_REP_CMPSB_XbYb },
#if BX_SUPPORT_X86_64
/* A6 /q */ { 0, BX_IA_REP_CMPSB_XbYb },
#endif
};
// opcode A7
static const BxOpcodeInfo_t BxOpcodeTableA7[] = {
/* A7 /w */ { 0, BX_IA_REP_CMPSW_XwYw },
/* A7 /d */ { 0, BX_IA_REP_CMPSD_XdYd },
#if BX_SUPPORT_X86_64
/* A7 /q */ { 0, BX_IA_REP_CMPSQ_XqYq },
#endif
};
// opcode A8
static const BxOpcodeInfo_t BxOpcodeTableA8[] = {
/* A8 /w */ { BxImmediate_Ib, BX_IA_TEST_ALIb },
/* A8 /d */ { BxImmediate_Ib, BX_IA_TEST_ALIb },
#if BX_SUPPORT_X86_64
/* A8 /q */ { BxImmediate_Ib, BX_IA_TEST_ALIb },
#endif
};
// opcode A9
static const BxOpcodeInfo_t BxOpcodeTableA9[] = {
/* A9 /w */ { BxImmediate_Iw, BX_IA_TEST_AXIw },
/* A9 /d */ { BxImmediate_Id, BX_IA_TEST_EAXId },
#if BX_SUPPORT_X86_64
/* A9 /q */ { BxImmediate_Id, BX_IA_TEST_RAXId },
#endif
};
// opcode AA
static const BxOpcodeInfo_t BxOpcodeTableAA[] = {
/* AA /w */ { 0, BX_IA_REP_STOSB_YbAL },
/* AA /d */ { 0, BX_IA_REP_STOSB_YbAL },
#if BX_SUPPORT_X86_64
/* AA /q */ { 0, BX_IA_REP_STOSB_YbAL },
#endif
};
// opcode AB
static const BxOpcodeInfo_t BxOpcodeTableAB[] = {
/* AB /w */ { 0, BX_IA_REP_STOSW_YwAX },
/* AB /d */ { 0, BX_IA_REP_STOSD_YdEAX },
#if BX_SUPPORT_X86_64
/* AB /q */ { 0, BX_IA_REP_STOSQ_YqRAX },
#endif
};
// opcode AC
static const BxOpcodeInfo_t BxOpcodeTableAC[] = {
/* AC /w */ { 0, BX_IA_REP_LODSB_ALXb },
/* AC /d */ { 0, BX_IA_REP_LODSB_ALXb },
#if BX_SUPPORT_X86_64
/* AC /q */ { 0, BX_IA_REP_LODSB_ALXb },
#endif
};
// opcode AD
static const BxOpcodeInfo_t BxOpcodeTableAD[] = {
/* AD /w */ { 0, BX_IA_REP_LODSW_AXXw },
/* AD /d */ { 0, BX_IA_REP_LODSD_EAXXd },
#if BX_SUPPORT_X86_64
/* AD /q */ { 0, BX_IA_REP_LODSQ_RAXXq },
#endif
};
// opcode AE
static const BxOpcodeInfo_t BxOpcodeTableAE[] = {
/* AE /w */ { 0, BX_IA_REP_SCASB_ALYb },
/* AE /d */ { 0, BX_IA_REP_SCASB_ALYb },
#if BX_SUPPORT_X86_64
/* AE /q */ { 0, BX_IA_REP_SCASB_ALYb },
#endif
};
// opcode AF
static const BxOpcodeInfo_t BxOpcodeTableAF[] = {
/* AF /w */ { 0, BX_IA_REP_SCASW_AXYw },
/* AF /d */ { 0, BX_IA_REP_SCASD_EAXYd },
#if BX_SUPPORT_X86_64
/* AF /q */ { 0, BX_IA_REP_SCASQ_RAXYq },
#endif
};
// opcode B0 - B7
static const BxOpcodeInfo_t BxOpcodeTableB0xB7[] = {
/* B0 /w */ { BxImmediate_Ib, BX_IA_MOV_EbIb },
/* B0 /d */ { BxImmediate_Ib, BX_IA_MOV_EbIb },
#if BX_SUPPORT_X86_64
/* B0 /q */ { BxImmediate_Ib, BX_IA_MOV_EbIb },
#endif
};
// opcode B8 - BF
static const BxOpcodeInfo_t BxOpcodeTableB8xBF[] = {
/* B8 /w */ { BxImmediate_Iw, BX_IA_MOV_EwIw },
/* B8 /d */ { BxImmediate_Id, BX_IA_MOV_EdId },
#if BX_SUPPORT_X86_64
/* B8 /q */ { BxImmediate_Iq, BX_IA_MOV_RRXIq },
#endif
};
// opcode C0
static const BxOpcodeInfo_t BxOpcodeTableC0_G2EbIb[8] = {
/* /0 */ { BxImmediate_Ib, BX_IA_ROL_EbIb },
/* /1 */ { BxImmediate_Ib, BX_IA_ROR_EbIb },
/* /2 */ { BxImmediate_Ib, BX_IA_RCL_EbIb },
/* /3 */ { BxImmediate_Ib, BX_IA_RCR_EbIb },
/* /4 */ { BxImmediate_Ib, BX_IA_SHL_EbIb },
/* /5 */ { BxImmediate_Ib, BX_IA_SHR_EbIb },
/* /6 */ { BxImmediate_Ib, BX_IA_SHL_EbIb },
/* /7 */ { BxImmediate_Ib, BX_IA_SAR_EbIb }
};
// opcode C1
static const BxOpcodeInfo_t BxOpcodeTableC1_G2EvIb[] = {
// osize = 16 bit
/* /0 /w */ { BxImmediate_Ib, BX_IA_ROL_EwIb },
/* /1 /w */ { BxImmediate_Ib, BX_IA_ROR_EwIb },
/* /2 /w */ { BxImmediate_Ib, BX_IA_RCL_EwIb },
/* /3 /w */ { BxImmediate_Ib, BX_IA_RCR_EwIb },
/* /4 /w */ { BxImmediate_Ib, BX_IA_SHL_EwIb },
/* /5 /w */ { BxImmediate_Ib, BX_IA_SHR_EwIb },
/* /6 /w */ { BxImmediate_Ib, BX_IA_SHL_EwIb },
/* /7 /w */ { BxImmediate_Ib, BX_IA_SAR_EwIb },
// osize = 32 bit
/* /0 /d */ { BxImmediate_Ib, BX_IA_ROL_EdIb },
/* /1 /d */ { BxImmediate_Ib, BX_IA_ROR_EdIb },
/* /2 /d */ { BxImmediate_Ib, BX_IA_RCL_EdIb },
/* /3 /d */ { BxImmediate_Ib, BX_IA_RCR_EdIb },
/* /4 /d */ { BxImmediate_Ib, BX_IA_SHL_EdIb },
/* /5 /d */ { BxImmediate_Ib, BX_IA_SHR_EdIb },
/* /6 /d */ { BxImmediate_Ib, BX_IA_SHL_EdIb },
/* /7 /d */ { BxImmediate_Ib, BX_IA_SAR_EdIb },
#if BX_SUPPORT_X86_64
// osize = 64 bit
/* /0 /q */ { BxImmediate_Ib, BX_IA_ROL_EqIb },
/* /1 /q */ { BxImmediate_Ib, BX_IA_ROR_EqIb },
/* /2 /q */ { BxImmediate_Ib, BX_IA_RCL_EqIb },
/* /3 /q */ { BxImmediate_Ib, BX_IA_RCR_EqIb },
/* /4 /q */ { BxImmediate_Ib, BX_IA_SHL_EqIb },
/* /5 /q */ { BxImmediate_Ib, BX_IA_SHR_EqIb },
/* /6 /q */ { BxImmediate_Ib, BX_IA_SHL_EqIb },
/* /7 /q */ { BxImmediate_Ib, BX_IA_SAR_EqIb },
#endif
};
// opcode C2
static const BxOpcodeInfo_t BxOpcodeTableC2_32[] = {
/* C2 /w */ { BxImmediate_Iw, BX_IA_RET_Op16_Iw },
/* C2 /d */ { BxImmediate_Iw, BX_IA_RET_Op32_Iw },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableC2_64[] = {
/* C2 /w */ { BxImmediate_Iw, BX_IA_RET_Op64_Iw },
/* C2 /d */ { BxImmediate_Iw, BX_IA_RET_Op64_Iw },
/* C2 /q */ { BxImmediate_Iw, BX_IA_RET_Op64_Iw },
};
#endif
// opcode C3
static const BxOpcodeInfo_t BxOpcodeTableC3_32[] = {
/* C3 /w */ { 0, BX_IA_RET_Op16 },
/* C3 /d */ { 0, BX_IA_RET_Op32 },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableC3_64[] = {
/* C3 /w */ { 0, BX_IA_RET_Op64 },
/* C3 /d */ { 0, BX_IA_RET_Op64 },
/* C3 /q */ { 0, BX_IA_RET_Op64 },
};
#endif
// opcode C4
static const BxOpcodeInfo_t BxOpcodeTableC4_32[] = {
/* C4 /w */ { 0, BX_IA_LES_GwMp },
/* C4 /d */ { 0, BX_IA_LES_GdMp },
};
// opcode C5
static const BxOpcodeInfo_t BxOpcodeTableC5_32[] = {
/* C5 /w */ { 0, BX_IA_LDS_GwMp },
/* C5 /d */ { 0, BX_IA_LDS_GdMp },
};
// opcode C6
static const BxOpcodeInfo_t BxOpcodeTableC6_G11EbIb[8] = {
/* /0 */ { BxImmediate_Ib, BX_IA_MOV_EbIb },
/* /1 */ { 0, BX_IA_ERROR },
/* /2 */ { 0, BX_IA_ERROR },
/* /3 */ { 0, BX_IA_ERROR },
/* /4 */ { 0, BX_IA_ERROR },
/* /5 */ { 0, BX_IA_ERROR },
/* /6 */ { 0, BX_IA_ERROR },
/* /7 */ { 0, BX_IA_ERROR }
};
// opcode C7
static const BxOpcodeInfo_t BxOpcodeTableC7_G11EvIv[] = {
// osize = 16 bit
/* /0 /w */ { BxImmediate_Iw, BX_IA_MOV_EwIw },
/* /1 /w */ { 0, BX_IA_ERROR },
/* /2 /w */ { 0, BX_IA_ERROR },
/* /3 /w */ { 0, BX_IA_ERROR },
/* /4 /w */ { 0, BX_IA_ERROR },
/* /5 /w */ { 0, BX_IA_ERROR },
/* /6 /w */ { 0, BX_IA_ERROR },
/* /7 /w */ { 0, BX_IA_ERROR },
// osize = 32 bit
/* /0 /d */ { BxImmediate_Id, BX_IA_MOV_EdId },
/* /1 /d */ { 0, BX_IA_ERROR },
/* /2 /d */ { 0, BX_IA_ERROR },
/* /3 /d */ { 0, BX_IA_ERROR },
/* /4 /d */ { 0, BX_IA_ERROR },
/* /5 /d */ { 0, BX_IA_ERROR },
/* /6 /d */ { 0, BX_IA_ERROR },
/* /7 /d */ { 0, BX_IA_ERROR },
#if BX_SUPPORT_X86_64
// osize = 64 bit
/* /0 /q */ { BxImmediate_Id, BX_IA_MOV_EqId },
/* /1 /q */ { 0, BX_IA_ERROR },
/* /2 /q */ { 0, BX_IA_ERROR },
/* /3 /q */ { 0, BX_IA_ERROR },
/* /4 /q */ { 0, BX_IA_ERROR },
/* /5 /q */ { 0, BX_IA_ERROR },
/* /6 /q */ { 0, BX_IA_ERROR },
/* /7 /q */ { 0, BX_IA_ERROR },
#endif
};
// opcode C8
static const BxOpcodeInfo_t BxOpcodeTableC8_32[] = {
/* C8 /w */ { BxImmediate_Iw | BxImmediate_Ib2, BX_IA_ENTER_Op16_IwIb },
/* C8 /d */ { BxImmediate_Iw | BxImmediate_Ib2, BX_IA_ENTER_Op32_IwIb },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableC8_64[] = {
/* C8 /w */ { BxImmediate_Iw | BxImmediate_Ib2, BX_IA_ENTER_Op64_IwIb },
/* C8 /d */ { BxImmediate_Iw | BxImmediate_Ib2, BX_IA_ENTER_Op64_IwIb },
/* C8 /q */ { BxImmediate_Iw | BxImmediate_Ib2, BX_IA_ENTER_Op64_IwIb },
};
#endif
// opcode C9
static const BxOpcodeInfo_t BxOpcodeTableC9_32[] = {
/* C9 /w */ { 0, BX_IA_LEAVE_Op16 },
/* C9 /d */ { 0, BX_IA_LEAVE_Op32 },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableC9_64[] = {
/* C9 /w */ { 0, BX_IA_LEAVE_Op64 },
/* C9 /d */ { 0, BX_IA_LEAVE_Op64 },
/* C9 /q */ { 0, BX_IA_LEAVE_Op64 },
};
#endif
// opcode CA
static const BxOpcodeInfo_t BxOpcodeTableCA[] = {
/* CA /w */ { BxImmediate_Iw, BX_IA_RETF_Op16_Iw },
/* CA /d */ { BxImmediate_Iw, BX_IA_RETF_Op32_Iw },
#if BX_SUPPORT_X86_64
/* CA /q */ { BxImmediate_Iw, BX_IA_RETF_Op64_Iw },
#endif
};
// opcode CB
static const BxOpcodeInfo_t BxOpcodeTableCB[] = {
/* CB /w */ { 0, BX_IA_RETF_Op16 },
/* CB /d */ { 0, BX_IA_RETF_Op32 },
#if BX_SUPPORT_X86_64
/* CB /q */ { 0, BX_IA_RETF_Op64 },
#endif
};
// opcode CC
static const BxOpcodeInfo_t BxOpcodeTableCC[] = {
/* CC */ { 0, BX_IA_INT3 },
};
// opcode CD
static const BxOpcodeInfo_t BxOpcodeTableCD[] = {
/* CD /w */ { BxImmediate_Ib, BX_IA_INT_Ib },
/* CD /d */ { BxImmediate_Ib, BX_IA_INT_Ib },
#if BX_SUPPORT_X86_64
/* CD /q */ { BxImmediate_Ib, BX_IA_INT_Ib },
#endif
};
// opcode CE
static const BxOpcodeInfo_t BxOpcodeTableCE_32[] = {
/* CE */ { 0, BX_IA_INTO },
};
// opcode CF
static const BxOpcodeInfo_t BxOpcodeTableCF_32[] = {
/* CF /w */ { 0, BX_IA_IRET_Op16 },
/* CF /d */ { 0, BX_IA_IRET_Op32 },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableCF_64[] = {
/* CF /w */ { 0, BX_IA_IRET_Op64 },
/* CF /d */ { 0, BX_IA_IRET_Op64 },
/* CF /q */ { 0, BX_IA_IRET_Op64 },
};
#endif
// opcode D0
static const BxOpcodeInfo_t BxOpcodeTableD0_G2EbI1[8] = {
/* /0 */ { BxImmediate_I1, BX_IA_ROL_EbIb },
/* /1 */ { BxImmediate_I1, BX_IA_ROR_EbIb },
/* /2 */ { BxImmediate_I1, BX_IA_RCL_EbIb },
/* /3 */ { BxImmediate_I1, BX_IA_RCR_EbIb },
/* /4 */ { BxImmediate_I1, BX_IA_SHL_EbIb },
/* /5 */ { BxImmediate_I1, BX_IA_SHR_EbIb },
/* /6 */ { BxImmediate_I1, BX_IA_SHL_EbIb },
/* /7 */ { BxImmediate_I1, BX_IA_SAR_EbIb }
};
// opcode D1
static const BxOpcodeInfo_t BxOpcodeTableD1_G2EvI1[] = {
// osize = 16 bit
/* /0 /w */ { BxImmediate_I1, BX_IA_ROL_EwIb },
/* /1 /w */ { BxImmediate_I1, BX_IA_ROR_EwIb },
/* /2 /w */ { BxImmediate_I1, BX_IA_RCL_EwIb },
/* /3 /w */ { BxImmediate_I1, BX_IA_RCR_EwIb },
/* /4 /w */ { BxImmediate_I1, BX_IA_SHL_EwIb },
/* /5 /w */ { BxImmediate_I1, BX_IA_SHR_EwIb },
/* /6 /w */ { BxImmediate_I1, BX_IA_SHL_EwIb },
/* /7 /w */ { BxImmediate_I1, BX_IA_SAR_EwIb },
// osize = 32 bit
/* /0 /d */ { BxImmediate_I1, BX_IA_ROL_EdIb },
/* /1 /d */ { BxImmediate_I1, BX_IA_ROR_EdIb },
/* /2 /d */ { BxImmediate_I1, BX_IA_RCL_EdIb },
/* /3 /d */ { BxImmediate_I1, BX_IA_RCR_EdIb },
/* /4 /d */ { BxImmediate_I1, BX_IA_SHL_EdIb },
/* /5 /d */ { BxImmediate_I1, BX_IA_SHR_EdIb },
/* /6 /d */ { BxImmediate_I1, BX_IA_SHL_EdIb },
/* /7 /d */ { BxImmediate_I1, BX_IA_SAR_EdIb },
#if BX_SUPPORT_X86_64
// osize = 64 bit
/* /0 /q */ { BxImmediate_I1, BX_IA_ROL_EqIb },
/* /1 /q */ { BxImmediate_I1, BX_IA_ROR_EqIb },
/* /2 /q */ { BxImmediate_I1, BX_IA_RCL_EqIb },
/* /3 /q */ { BxImmediate_I1, BX_IA_RCR_EqIb },
/* /4 /q */ { BxImmediate_I1, BX_IA_SHL_EqIb },
/* /5 /q */ { BxImmediate_I1, BX_IA_SHR_EqIb },
/* /6 /q */ { BxImmediate_I1, BX_IA_SHL_EqIb },
/* /7 /q */ { BxImmediate_I1, BX_IA_SAR_EqIb },
#endif
};
// opcode D2
static const BxOpcodeInfo_t BxOpcodeTableD2_G2Eb[8] = {
/* /0 */ { 0, BX_IA_ROL_Eb },
/* /1 */ { 0, BX_IA_ROR_Eb },
/* /2 */ { 0, BX_IA_RCL_Eb },
/* /3 */ { 0, BX_IA_RCR_Eb },
/* /4 */ { 0, BX_IA_SHL_Eb },
/* /5 */ { 0, BX_IA_SHR_Eb },
/* /6 */ { 0, BX_IA_SHL_Eb },
/* /7 */ { 0, BX_IA_SAR_Eb }
};
// opcode D3
static const BxOpcodeInfo_t BxOpcodeTableD3_G2Ev[] = {
// osize = 16 bit
/* /0 /w */ { 0, BX_IA_ROL_Ew },
/* /1 /w */ { 0, BX_IA_ROR_Ew },
/* /2 /w */ { 0, BX_IA_RCL_Ew },
/* /3 /w */ { 0, BX_IA_RCR_Ew },
/* /4 /w */ { 0, BX_IA_SHL_Ew },
/* /5 /w */ { 0, BX_IA_SHR_Ew },
/* /6 /w */ { 0, BX_IA_SHL_Ew },
/* /7 /w */ { 0, BX_IA_SAR_Ew },
// osize = 32 bit
/* /0 /d */ { 0, BX_IA_ROL_Ed },
/* /1 /d */ { 0, BX_IA_ROR_Ed },
/* /2 /d */ { 0, BX_IA_RCL_Ed },
/* /3 /d */ { 0, BX_IA_RCR_Ed },
/* /4 /d */ { 0, BX_IA_SHL_Ed },
/* /5 /d */ { 0, BX_IA_SHR_Ed },
/* /6 /d */ { 0, BX_IA_SHL_Ed },
/* /7 /d */ { 0, BX_IA_SAR_Ed },
#if BX_SUPPORT_X86_64
// osize = 64 bit
/* /0 /q */ { 0, BX_IA_ROL_Eq },
/* /1 /q */ { 0, BX_IA_ROR_Eq },
/* /2 /q */ { 0, BX_IA_RCL_Eq },
/* /3 /q */ { 0, BX_IA_RCR_Eq },
/* /4 /q */ { 0, BX_IA_SHL_Eq },
/* /5 /q */ { 0, BX_IA_SHR_Eq },
/* /6 /q */ { 0, BX_IA_SHL_Eq },
/* /7 /q */ { 0, BX_IA_SAR_Eq },
#endif
};
// opcode D4
static const BxOpcodeInfo_t BxOpcodeTableD4_32[] = {
/* D4 /w */ { BxImmediate_Ib, BX_IA_AAM },
/* D4 /d */ { BxImmediate_Ib, BX_IA_AAM },
};
// opcode D5
static const BxOpcodeInfo_t BxOpcodeTableD5_32[] = {
/* D5 /w */ { BxImmediate_Ib, BX_IA_AAD },
/* D5 /d */ { BxImmediate_Ib, BX_IA_AAD },
};
// opcode D6
static const BxOpcodeInfo_t BxOpcodeTableD6_32[] = {
/* D6 */ { 0, BX_IA_SALC },
};
// opcode D7
static const BxOpcodeInfo_t BxOpcodeTableD7[] = {
/* D7 */ { 0, BX_IA_XLAT },
};
// opcode E0
static const BxOpcodeInfo_t BxOpcodeTableE0_32[] = {
/* E0 /w */ { BxImmediate_BrOff8, BX_IA_LOOPNE_Op16_Jb },
/* E0 /d */ { BxImmediate_BrOff8, BX_IA_LOOPNE_Op32_Jb },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableE0_64[] = {
/* E0 /w */ { BxImmediate_BrOff8, BX_IA_LOOPNE_Op64_Jb },
/* E0 /d */ { BxImmediate_BrOff8, BX_IA_LOOPNE_Op64_Jb },
/* E0 /q */ { BxImmediate_BrOff8, BX_IA_LOOPNE_Op64_Jb },
};
#endif
// opcode E1
static const BxOpcodeInfo_t BxOpcodeTableE1_32[] = {
/* E1 /w */ { BxImmediate_BrOff8, BX_IA_LOOPE_Op16_Jb },
/* E1 /d */ { BxImmediate_BrOff8, BX_IA_LOOPE_Op32_Jb },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableE1_64[] = {
/* E1 /w */ { BxImmediate_BrOff8, BX_IA_LOOPE_Op64_Jb },
/* E1 /d */ { BxImmediate_BrOff8, BX_IA_LOOPE_Op64_Jb },
/* E1 /q */ { BxImmediate_BrOff8, BX_IA_LOOPE_Op64_Jb },
};
#endif
// opcode E2
static const BxOpcodeInfo_t BxOpcodeTableE2_32[] = {
/* E2 /w */ { BxImmediate_BrOff8, BX_IA_LOOP_Op16_Jb },
/* E2 /d */ { BxImmediate_BrOff8, BX_IA_LOOP_Op32_Jb },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableE2_64[] = {
/* E2 /w */ { BxImmediate_BrOff8, BX_IA_LOOP_Op64_Jb },
/* E2 /d */ { BxImmediate_BrOff8, BX_IA_LOOP_Op64_Jb },
/* E2 /q */ { BxImmediate_BrOff8, BX_IA_LOOP_Op64_Jb },
};
#endif
// opcode E3
static const BxOpcodeInfo_t BxOpcodeTableE3_32[] = {
/* E3 /w */ { BxImmediate_BrOff8, BX_IA_JCXZ_Jb },
/* E3 /d */ { BxImmediate_BrOff8, BX_IA_JECXZ_Jb },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableE3_64[] = {
/* E3 /w */ { BxImmediate_BrOff8, BX_IA_JRCXZ_Jb },
/* E3 /d */ { BxImmediate_BrOff8, BX_IA_JRCXZ_Jb },
/* E3 /q */ { BxImmediate_BrOff8, BX_IA_JRCXZ_Jb },
};
#endif
// opcode E4
static const BxOpcodeInfo_t BxOpcodeTableE4[] = {
/* E4 /w */ { BxImmediate_Ib, BX_IA_IN_ALIb },
/* E4 /d */ { BxImmediate_Ib, BX_IA_IN_ALIb },
#if BX_SUPPORT_X86_64
/* E4 /q */ { BxImmediate_Ib, BX_IA_IN_ALIb },
#endif
};
// opcode E5
static const BxOpcodeInfo_t BxOpcodeTableE5[] = {
/* E5 /w */ { BxImmediate_Ib, BX_IA_IN_AXIb },
/* E5 /d */ { BxImmediate_Ib, BX_IA_IN_EAXIb },
#if BX_SUPPORT_X86_64
/* E5 /q */ { BxImmediate_Ib, BX_IA_IN_EAXIb },
#endif
};
// opcode E6
static const BxOpcodeInfo_t BxOpcodeTableE6[] = {
/* E6 /w */ { BxImmediate_Ib, BX_IA_OUT_IbAL },
/* E6 /d */ { BxImmediate_Ib, BX_IA_OUT_IbAL },
#if BX_SUPPORT_X86_64
/* E6 /q */ { BxImmediate_Ib, BX_IA_OUT_IbAL },
#endif
};
// opcode E7
static const BxOpcodeInfo_t BxOpcodeTableE7[] = {
/* E7 /w */ { BxImmediate_Ib, BX_IA_OUT_IbAX },
/* E7 /d */ { BxImmediate_Ib, BX_IA_OUT_IbEAX },
#if BX_SUPPORT_X86_64
/* E7 /q */ { BxImmediate_Ib, BX_IA_OUT_IbEAX },
#endif
};
// opcode E8
static const BxOpcodeInfo_t BxOpcodeTableE8_32[] = {
/* E8 /w */ { BxImmediate_BrOff16, BX_IA_CALL_Jw },
/* E8 /d */ { BxImmediate_BrOff32, BX_IA_CALL_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableE8_64[] = {
/* E8 /w */ { BxImmediate_BrOff32, BX_IA_CALL_Jq },
/* E8 /d */ { BxImmediate_BrOff32, BX_IA_CALL_Jq },
/* E8 /q */ { BxImmediate_BrOff32, BX_IA_CALL_Jq },
};
#endif
// opcode E9
static const BxOpcodeInfo_t BxOpcodeTableE9_32[] = {
/* E9 /w */ { BxImmediate_BrOff16, BX_IA_JMP_Jw },
/* E9 /d */ { BxImmediate_BrOff32, BX_IA_JMP_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableE9_64[] = {
/* E9 /w */ { BxImmediate_BrOff32, BX_IA_JMP_Jq },
/* E9 /d */ { BxImmediate_BrOff32, BX_IA_JMP_Jq },
/* E9 /q */ { BxImmediate_BrOff32, BX_IA_JMP_Jq },
};
#endif
// opcode EA
static const BxOpcodeInfo_t BxOpcodeTableEA_32[] = {
/* EA /w */ { BxImmediate_Iw | BxImmediate_Iw2, BX_IA_JMPF_Ap },
/* EA /d */ { BxImmediate_Id | BxImmediate_Iw2, BX_IA_JMPF_Ap },
};
// opcode EB
static const BxOpcodeInfo_t BxOpcodeTableEB_32[] = {
/* EB /w */ { BxImmediate_BrOff8, BX_IA_JMP_Jw },
/* EB /d */ { BxImmediate_BrOff8, BX_IA_JMP_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableEB_64[] = {
/* EB /w */ { BxImmediate_BrOff8, BX_IA_JMP_Jq },
/* EB /d */ { BxImmediate_BrOff8, BX_IA_JMP_Jq },
/* EB /q */ { BxImmediate_BrOff8, BX_IA_JMP_Jq },
};
#endif
// opcode EC
static const BxOpcodeInfo_t BxOpcodeTableEC[] = {
/* EC /w */ { 0, BX_IA_IN_ALDX },
/* EC /d */ { 0, BX_IA_IN_ALDX },
#if BX_SUPPORT_X86_64
/* EC /q */ { 0, BX_IA_IN_ALDX },
#endif
};
// opcode ED
static const BxOpcodeInfo_t BxOpcodeTableED[] = {
/* ED /w */ { 0, BX_IA_IN_AXDX },
/* ED /d */ { 0, BX_IA_IN_EAXDX },
#if BX_SUPPORT_X86_64
/* ED /q */ { 0, BX_IA_IN_EAXDX },
#endif
};
// opcode EE
static const BxOpcodeInfo_t BxOpcodeTableEE[] = {
/* EE /w */ { 0, BX_IA_OUT_DXAL },
/* EE /d */ { 0, BX_IA_OUT_DXAL },
#if BX_SUPPORT_X86_64
/* EE /q */ { 0, BX_IA_OUT_DXAL },
#endif
};
// opcode EF
static const BxOpcodeInfo_t BxOpcodeTableEF[] = {
/* EF /w */ { 0, BX_IA_OUT_DXAX },
/* EF /d */ { 0, BX_IA_OUT_DXEAX },
#if BX_SUPPORT_X86_64
/* EF /q */ { 0, BX_IA_OUT_DXEAX },
#endif
};
// opcode F1
static const BxOpcodeInfo_t BxOpcodeTableF1[] = {
/* F1 */ { 0, BX_IA_INT1 },
};
// opcode F4
static const BxOpcodeInfo_t BxOpcodeTableF4[] = {
/* F4 */ { 0, BX_IA_HLT },
};
// opcode F5
static const BxOpcodeInfo_t BxOpcodeTableF5[] = {
/* F5 */ { 0, BX_IA_CMC },
};
// opcode F6
static const BxOpcodeInfo_t BxOpcodeTableF6_G3Eb[8] = {
/* /0 */ { BxImmediate_Ib, BX_IA_TEST_EbIb },
/* /1 */ { BxImmediate_Ib, BX_IA_TEST_EbIb },
/* /2 */ { 0, BX_IA_NOT_Eb },
/* /3 */ { 0, BX_IA_NEG_Eb },
/* /4 */ { 0, BX_IA_MUL_ALEb },
/* /5 */ { 0, BX_IA_IMUL_ALEb },
/* /6 */ { 0, BX_IA_DIV_ALEb },
/* /7 */ { 0, BX_IA_IDIV_ALEb }
};
// opcode F7
static const BxOpcodeInfo_t BxOpcodeTableF7_G3Ev[] = {
// osize = 16 bit
/* /0 /w */ { BxImmediate_Iw, BX_IA_TEST_EwIw },
/* /1 /w */ { BxImmediate_Iw, BX_IA_TEST_EwIw },
/* /2 /w */ { 0, BX_IA_NOT_Ew },
/* /3 /w */ { 0, BX_IA_NEG_Ew },
/* /4 /w */ { 0, BX_IA_MUL_AXEw },
/* /5 /w */ { 0, BX_IA_IMUL_AXEw },
/* /6 /w */ { 0, BX_IA_DIV_AXEw },
/* /7 /w */ { 0, BX_IA_IDIV_AXEw },
// osize = 32 bit
/* /0 /d */ { BxImmediate_Id, BX_IA_TEST_EdId },
/* /1 /d */ { BxImmediate_Id, BX_IA_TEST_EdId },
/* /2 /d */ { 0, BX_IA_NOT_Ed },
/* /3 /d */ { 0, BX_IA_NEG_Ed },
/* /4 /d */ { 0, BX_IA_MUL_EAXEd },
/* /5 /d */ { 0, BX_IA_IMUL_EAXEd },
/* /6 /d */ { 0, BX_IA_DIV_EAXEd },
/* /7 /d */ { 0, BX_IA_IDIV_EAXEd },
#if BX_SUPPORT_X86_64
// osize = 64 bit
/* /0 /q */ { BxImmediate_Id, BX_IA_TEST_EqId },
/* /1 /q */ { BxImmediate_Id, BX_IA_TEST_EqId },
/* /2 /q */ { 0, BX_IA_NOT_Eq },
/* /3 /q */ { 0, BX_IA_NEG_Eq },
/* /4 /q */ { 0, BX_IA_MUL_RAXEq },
/* /5 /q */ { 0, BX_IA_IMUL_RAXEq },
/* /6 /q */ { 0, BX_IA_DIV_RAXEq },
/* /7 /q */ { 0, BX_IA_IDIV_RAXEq },
#endif
};
// opcode F8
static const BxOpcodeInfo_t BxOpcodeTableF8[] = {
/* F8 */ { 0, BX_IA_CLC },
};
// opcode F9
static const BxOpcodeInfo_t BxOpcodeTableF9[] = {
/* F9 */ { 0, BX_IA_STC },
};
// opcode FA
static const BxOpcodeInfo_t BxOpcodeTableFA[] = {
/* FA */ { 0, BX_IA_CLI },
};
// opcode FB
static const BxOpcodeInfo_t BxOpcodeTableFB[] = {
/* FB */ { 0, BX_IA_STI },
};
// opcode FC
static const BxOpcodeInfo_t BxOpcodeTableFC[] = {
/* FC */ { 0, BX_IA_CLD },
};
// opcode FD
static const BxOpcodeInfo_t BxOpcodeTableFD[] = {
/* FD */ { 0, BX_IA_STD },
};
// opcode FE
static const BxOpcodeInfo_t BxOpcodeTableG4[8] = {
/* /0 */ { 0, BX_IA_INC_Eb },
/* /1 */ { 0, BX_IA_DEC_Eb },
/* /2 */ { 0, BX_IA_ERROR },
/* /3 */ { 0, BX_IA_ERROR },
/* /4 */ { 0, BX_IA_ERROR },
/* /5 */ { 0, BX_IA_ERROR },
/* /6 */ { 0, BX_IA_ERROR },
/* /7 */ { 0, BX_IA_ERROR }
};
// opcode FF
static const BxOpcodeInfo_t BxOpcodeTableFF_32G5v[8*2] = {
// osize = 16 bit
/* /0 /w */ { 0, BX_IA_INC_Ew },
/* /1 /w */ { 0, BX_IA_DEC_Ew },
/* /2 /w */ { 0, BX_IA_CALL_Ew },
/* /3 /w */ { 0, BX_IA_CALLF_Op16_Ep },
/* /4 /w */ { 0, BX_IA_JMP_Ew },
/* /5 /w */ { 0, BX_IA_JMPF_Op16_Ep },
/* /6 /w */ { 0, BX_IA_PUSH_Ew },
/* /7 /w */ { 0, BX_IA_ERROR },
// osize = 32 bit
/* /0 /d */ { 0, BX_IA_INC_Ed },
/* /1 /d */ { 0, BX_IA_DEC_Ed },
/* /2 /d */ { 0, BX_IA_CALL_Ed },
/* /3 /d */ { 0, BX_IA_CALLF_Op32_Ep },
/* /4 /d */ { 0, BX_IA_JMP_Ed },
/* /5 /d */ { 0, BX_IA_JMPF_Op32_Ep },
/* /6 /d */ { 0, BX_IA_PUSH_Ed },
/* /7 /d */ { 0, BX_IA_ERROR },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableFF_64G5v[8*3] = {
// osize = 16 bit
/* /0 */ { 0, BX_IA_INC_Ew },
/* /1 */ { 0, BX_IA_DEC_Ew },
/* /2 */ { 0, BX_IA_CALL_Eq },
/* /3 */ { 0, BX_IA_CALLF_Op16_Ep },
/* /4 */ { 0, BX_IA_JMP_Eq },
/* /5 */ { 0, BX_IA_JMPF_Op16_Ep },
/* /6 */ { 0, BX_IA_PUSH_Ew },
/* /7 */ { 0, BX_IA_ERROR },
// osize = 32 bit
/* /0 */ { 0, BX_IA_INC_Ed },
/* /1 */ { 0, BX_IA_DEC_Ed },
/* /2 */ { 0, BX_IA_CALL_Eq },
/* /3 */ { 0, BX_IA_CALLF_Op32_Ep },
/* /4 */ { 0, BX_IA_JMP_Eq },
/* /5 */ { 0, BX_IA_JMPF_Op32_Ep },
/* /6 */ { 0, BX_IA_PUSH_Eq },
/* /7 */ { 0, BX_IA_ERROR },
// osize = 64 bit
/* /0 */ { 0, BX_IA_INC_Eq },
/* /1 */ { 0, BX_IA_DEC_Eq },
/* /2 */ { 0, BX_IA_CALL_Eq },
/* /3 */ { 0, BX_IA_CALLF_Op64_Ep }, // TODO: 64-bit offset for Intel
/* /4 */ { 0, BX_IA_JMP_Eq },
/* /5 */ { 0, BX_IA_JMPF_Op64_Ep }, // TODO: 64-bit offset for Intel
/* /6 */ { 0, BX_IA_PUSH_Eq },
/* /7 */ { 0, BX_IA_ERROR },
};
#endif
// opcode 0F 00
static const BxOpcodeInfo_t BxOpcodeTableG6[8] = {
/* /0 */ { 0, BX_IA_SLDT_Ew },
/* /1 */ { 0, BX_IA_STR_Ew },
/* /2 */ { 0, BX_IA_LLDT_Ew },
/* /3 */ { 0, BX_IA_LTR_Ew },
/* /4 */ { 0, BX_IA_VERR_Ew },
/* /5 */ { 0, BX_IA_VERW_Ew },
/* /6 */ { 0, BX_IA_ERROR },
/* /7 */ { 0, BX_IA_ERROR }
};
// opcode 0F 01
static const BxOpcodeInfo_t BxOpcodeTable0F01_32[] = {
/* /0 */ { 0, BX_IA_SGDT_Ms },
/* /1 */ { 0, BX_IA_SIDT_Ms },
/* /2 */ { 0, BX_IA_LGDT_Ms },
/* /3 */ { 0, BX_IA_LIDT_Ms },
/* /4 */ { 0, BX_IA_SMSW_Ew },
/* /5 */ { 0, BX_IA_ERROR },
/* /6 */ { 0, BX_IA_LMSW_Ew },
/* /7 */ { 0, BX_IA_INVLPG },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F01_64[] = {
/* /0 */ { 0, BX_IA_SGDT_Op64_Ms },
/* /1 */ { 0, BX_IA_SIDT_Op64_Ms },
/* /2 */ { 0, BX_IA_LGDT_Op64_Ms },
/* /3 */ { 0, BX_IA_LIDT_Op64_Ms },
/* /4 */ { 0, BX_IA_SMSW_Ew },
/* /5 */ { 0, BX_IA_ERROR },
/* /6 */ { 0, BX_IA_LMSW_Ew },
/* /7 */ { 0, BX_IA_INVLPG },
};
#endif
static const BxOpcodeInfo_t BxOpcodeTable0F01[64] = {
/* 0F 01 C0 */ { 0, BX_IA_ERROR },
/* 0F 01 C1 */ { BxNoPrefixSSE, BX_IA_VMCALL },
/* 0F 01 C2 */ { BxNoPrefixSSE, BX_IA_VMLAUNCH },
/* 0F 01 C3 */ { BxNoPrefixSSE, BX_IA_VMRESUME },
/* 0F 01 C4 */ { BxNoPrefixSSE, BX_IA_VMXOFF },
/* 0F 01 C5 */ { 0, BX_IA_ERROR },
/* 0F 01 C6 */ { 0, BX_IA_ERROR },
/* 0F 01 C7 */ { 0, BX_IA_ERROR },
/* 0F 01 C8 */ { BxNoPrefixSSE, BX_IA_MONITOR },
/* 0F 01 C9 */ { BxNoPrefixSSE, BX_IA_MWAIT },
/* 0F 01 CA */ { BxNoPrefixSSE, BX_IA_CLAC },
/* 0F 01 CB */ { BxNoPrefixSSE, BX_IA_STAC },
/* 0F 01 CC */ { 0, BX_IA_ERROR },
/* 0F 01 CD */ { 0, BX_IA_ERROR },
/* 0F 01 CE */ { 0, BX_IA_ERROR },
/* 0F 01 CF */ { 0, BX_IA_ERROR },
/* 0F 01 D0 */ { BxNoPrefixSSE, BX_IA_XGETBV },
/* 0F 01 D1 */ { BxNoPrefixSSE, BX_IA_XSETBV },
/* 0F 01 D2 */ { 0, BX_IA_ERROR },
/* 0F 01 D3 */ { 0, BX_IA_ERROR },
/* 0F 01 D4 */ { BxNoPrefixSSE, BX_IA_VMFUNC },
/* 0F 01 D5 */ { 0, BX_IA_ERROR },
/* 0F 01 D6 */ { 0, BX_IA_ERROR },
/* 0F 01 D7 */ { 0, BX_IA_ERROR },
/* 0F 01 D8 */ { 0, BX_IA_VMRUN },
/* 0F 01 D9 */ { 0, BX_IA_VMMCALL },
/* 0F 01 DA */ { 0, BX_IA_VMLOAD },
/* 0F 01 DB */ { 0, BX_IA_VMSAVE },
/* 0F 01 DC */ { 0, BX_IA_STGI },
/* 0F 01 DD */ { 0, BX_IA_CLGI },
/* 0F 01 DE */ { 0, BX_IA_SKINIT },
/* 0F 01 DF */ { 0, BX_IA_INVLPGA },
/* 0F 01 E0 */ { 0, BX_IA_SMSW_Ew },
/* 0F 01 E1 */ { 0, BX_IA_SMSW_Ew },
/* 0F 01 E2 */ { 0, BX_IA_SMSW_Ew },
/* 0F 01 E3 */ { 0, BX_IA_SMSW_Ew },
/* 0F 01 E4 */ { 0, BX_IA_SMSW_Ew },
/* 0F 01 E5 */ { 0, BX_IA_SMSW_Ew },
/* 0F 01 E6 */ { 0, BX_IA_SMSW_Ew },
/* 0F 01 E7 */ { 0, BX_IA_SMSW_Ew },
/* 0F 01 E8 */ { 0, BX_IA_ERROR },
/* 0F 01 E9 */ { 0, BX_IA_ERROR },
/* 0F 01 EA */ { 0, BX_IA_ERROR },
/* 0F 01 EB */ { 0, BX_IA_ERROR },
/* 0F 01 EC */ { 0, BX_IA_ERROR },
/* 0F 01 ED */ { 0, BX_IA_ERROR },
#if BX_SUPPORT_PKEYS
/* 0F 01 EE */ { BxNoPrefixSSE, BX_IA_RDPKRU },
/* 0F 01 EF */ { BxNoPrefixSSE, BX_IA_WRPKRU },
#else
/* 0F 01 EE */ { 0, BX_IA_ERROR },
/* 0F 01 EF */ { 0, BX_IA_ERROR },
#endif
/* 0F 01 F0 */ { 0, BX_IA_LMSW_Ew },
/* 0F 01 F1 */ { 0, BX_IA_LMSW_Ew },
/* 0F 01 F2 */ { 0, BX_IA_LMSW_Ew },
/* 0F 01 F3 */ { 0, BX_IA_LMSW_Ew },
/* 0F 01 F4 */ { 0, BX_IA_LMSW_Ew },
/* 0F 01 F5 */ { 0, BX_IA_LMSW_Ew },
/* 0F 01 F6 */ { 0, BX_IA_LMSW_Ew },
/* 0F 01 F7 */ { 0, BX_IA_LMSW_Ew },
#if BX_SUPPORT_X86_64
/* 0F 01 F8 */ { 0, BX_IA_SWAPGS },
#else
/* 0F 01 F8 */ { 0, BX_IA_ERROR },
#endif
/* 0F 01 F9 */ { 0, BX_IA_RDTSCP }, // end trace to avoid multiple TSC samples in one cycle
/* 0F 01 FA */ { 0, BX_IA_MONITORX },
/* 0F 01 FB */ { 0, BX_IA_MWAITX },
/* 0F 01 FC */ { 0, BX_IA_CLZERO },
/* 0F 01 FD */ { 0, BX_IA_ERROR },
/* 0F 01 FE */ { 0, BX_IA_ERROR },
/* 0F 01 FF */ { 0, BX_IA_ERROR },
};
// opcode 0F 02
static const BxOpcodeInfo_t BxOpcodeTable0F02[] = {
/* 0F 02 /w */ { 0, BX_IA_LAR_GwEw },
/* 0F 02 /d */ { 0, BX_IA_LAR_GdEw },
#if BX_SUPPORT_X86_64
/* 0F 02 /q */ { 0, BX_IA_LAR_GdEw },
#endif
};
// opcode 0F 03
static const BxOpcodeInfo_t BxOpcodeTable0F03[] = {
/* 0F 03 /w */ { 0, BX_IA_LSL_GwEw },
/* 0F 03 /d */ { 0, BX_IA_LSL_GdEw },
#if BX_SUPPORT_X86_64
/* 0F 03 /q */ { 0, BX_IA_LSL_GdEw },
#endif
};
// opcode 0F 05
static const BxOpcodeInfo_t BxOpcodeTable0F05_32[] = {
/* 0F 05 */ { 0, BX_IA_SYSCALL_LEGACY },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F05_64[] = {
/* 0F 05 */ { 0, BX_IA_SYSCALL },
};
#endif
// opcode 0F 06
static const BxOpcodeInfo_t BxOpcodeTable0F06[] = {
/* 0F 06 */ { 0, BX_IA_CLTS },
};
// opcode 0F 07
static const BxOpcodeInfo_t BxOpcodeTable0F07_32[] = {
/* 0F 07 */ { 0, BX_IA_SYSRET_LEGACY },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F07_64[] = {
/* 0F 07 */ { 0, BX_IA_SYSRET },
};
#endif
// opcode 0F 08
static const BxOpcodeInfo_t BxOpcodeTable0F08[] = {
/* 0F 08 */ { 0, BX_IA_INVD },
};
// opcode 0F 09
static const BxOpcodeInfo_t BxOpcodeTable0F09[] = {
/* 0F 09 */ { 0, BX_IA_WBINVD },
};
// opcode 0F 0B
static const BxOpcodeInfo_t BxOpcodeTable0F0B[] = {
/* 0F 0B */ { 0, BX_IA_UD2 },
};
// opcode 0F 0D - 3DNow! PREFETCHW on AMD, NOP on older Intel CPUs
static const BxOpcodeInfo_t BxOpcodeTable0F0D[] = {
/* 0F 0D /w */ { 0, BX_IA_PREFETCHW_Mb },
/* 0F 0D /d */ { 0, BX_IA_PREFETCHW_Mb },
#if BX_SUPPORT_X86_64
/* 0F 0D /q */ { 0, BX_IA_PREFETCHW_Mb },
#endif
};
// opcode 0F 0E - 3DNow! FEMMS
static const BxOpcodeInfo_t BxOpcodeTable0F0E[] = {
/* 0F 0E */ { 0, BX_IA_FEMMS },
};
// opcode 0F 0F - 3DNow! Opcode Table
static const BxOpcodeInfo_t BxOpcodeTable0F0F[] = {
/* 0F 0F /w */ { BxImmediate_Ib, BX_IA_ERROR },
/* 0F 0F /d */ { BxImmediate_Ib, BX_IA_ERROR },
#if BX_SUPPORT_X86_64
/* 0F 0F /q */ { BxImmediate_Ib, BX_IA_ERROR },
#endif
};
// opcode 0F 10
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F10[4] = {
/* -- */ { 0, BX_IA_MOVUPS_VpsWps },
/* 66 */ { 0, BX_IA_MOVUPD_VpdWpd },
/* F3 */ { 0, BX_IA_MOVSS_VssWss },
/* F2 */ { 0, BX_IA_MOVSD_VsdWsd },
};
// opcode 0F 11
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F11[4] = {
/* -- */ { 0, BX_IA_MOVUPS_WpsVps },
/* 66 */ { 0, BX_IA_MOVUPD_WpdVpd },
/* F3 */ { 0, BX_IA_MOVSS_WssVss },
/* F2 */ { 0, BX_IA_MOVSD_WsdVsd },
};
// opcode 0F 12
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F12[4] = {
/* -- */ { 0, BX_IA_MOVLPS_VpsMq },
/* 66 */ { 0, BX_IA_MOVLPD_VsdMq },
/* F3 */ { 0, BX_IA_MOVSLDUP_VpsWps },
/* F2 */ { 0, BX_IA_MOVDDUP_VpdWq },
};
// opcode 0F 13
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F13[4] = {
/* -- */ { 0, BX_IA_MOVLPS_MqVps },
/* 66 */ { 0, BX_IA_MOVLPD_MqVsd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 14
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F14[4] = {
/* -- */ { 0, BX_IA_UNPCKLPS_VpsWdq },
/* 66 */ { 0, BX_IA_UNPCKLPD_VpdWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 15
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F15[4] = {
/* -- */ { 0, BX_IA_UNPCKHPS_VpsWdq },
/* 66 */ { 0, BX_IA_UNPCKHPD_VpdWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 16
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F16[4] = {
/* -- */ { 0, BX_IA_MOVHPS_VpsMq },
/* 66 */ { 0, BX_IA_MOVHPD_VsdMq },
/* F3 */ { 0, BX_IA_MOVSHDUP_VpsWps },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 17
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F17[4] = {
/* -- */ { 0, BX_IA_MOVHPS_MqVps },
/* 66 */ { 0, BX_IA_MOVHPD_MqVsd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 18 - opcode group G16, PREFETCH hints
#if BX_CPU_LEVEL >= 6
static const BxOpcodeInfo_t BxOpcodeTable0F18_G16[8] = {
/* /0 */ { 0, BX_IA_PREFETCHNTA_Mb },
/* /1 */ { 0, BX_IA_PREFETCHT0_Mb },
/* /2 */ { 0, BX_IA_PREFETCHT1_Mb },
/* /3 */ { 0, BX_IA_PREFETCHT2_Mb },
/* /4 */ { 0, BX_IA_PREFETCH_Mb },
/* /5 */ { 0, BX_IA_PREFETCH_Mb },
/* /6 */ { 0, BX_IA_PREFETCH_Mb },
/* /7 */ { 0, BX_IA_PREFETCH_Mb}
};
#endif
// opcode 0F 19 - 0F 1F
static const BxOpcodeInfo_t BxOpcodeTableMultiByteNOP[] = {
/* 0F 19 /w */ { 0, BX_IA_NOP }, // multi-byte NOP
/* 0F 19 /d */ { 0, BX_IA_NOP }, // multi-byte NOP
#if BX_SUPPORT_X86_64
/* 0F 19 /q */ { 0, BX_IA_NOP }, // multi-byte NOP
#endif
};
// opcode 0F 20
static const BxOpcodeInfo_t BxOpcodeTableMOV_RdCd[8] = {
/* /0 */ { 0, BX_IA_MOV_RdCR0 },
/* /1 */ { 0, BX_IA_ERROR },
/* /2 */ { 0, BX_IA_MOV_RdCR2 },
/* /3 */ { 0, BX_IA_MOV_RdCR3 },
/* /4 */ { 0, BX_IA_MOV_RdCR4 },
/* /5 */ { 0, BX_IA_ERROR },
/* /6 */ { 0, BX_IA_ERROR },
/* /7 */ { 0, BX_IA_ERROR },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableMOV_RqCq[8] = {
/* /0 */ { 0, BX_IA_MOV_RqCR0 },
/* /1 */ { 0, BX_IA_ERROR },
/* /2 */ { 0, BX_IA_MOV_RqCR2 },
/* /3 */ { 0, BX_IA_MOV_RqCR3 },
/* /4 */ { 0, BX_IA_MOV_RqCR4 },
/* /5 */ { 0, BX_IA_ERROR },
/* /6 */ { 0, BX_IA_ERROR },
/* /7 */ { 0, BX_IA_ERROR },
};
#endif
// opcode 0F 21
static const BxOpcodeInfo_t BxOpcodeTable0F21_32[] = {
/* 0F 21 */ { 0, BX_IA_MOV_RdDd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F21_64[] = {
/* 0F 21 */ { 0, BX_IA_MOV_RqDq },
};
#endif
// opcode 0F 22
static const BxOpcodeInfo_t BxOpcodeTableMOV_CdRd[8] = {
/* /0 */ { 0, BX_IA_MOV_CR0Rd },
/* /1 */ { 0, BX_IA_ERROR },
/* /2 */ { 0, BX_IA_MOV_CR2Rd },
/* /3 */ { 0, BX_IA_MOV_CR3Rd },
/* /4 */ { 0, BX_IA_MOV_CR4Rd },
/* /5 */ { 0, BX_IA_ERROR },
/* /6 */ { 0, BX_IA_ERROR },
/* /7 */ { 0, BX_IA_ERROR },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTableMOV_CqRq[8] = {
/* /0 */ { 0, BX_IA_MOV_CR0Rq },
/* /1 */ { 0, BX_IA_ERROR },
/* /2 */ { 0, BX_IA_MOV_CR2Rq },
/* /3 */ { 0, BX_IA_MOV_CR3Rq },
/* /4 */ { 0, BX_IA_MOV_CR4Rq },
/* /5 */ { 0, BX_IA_ERROR },
/* /6 */ { 0, BX_IA_ERROR },
/* /7 */ { 0, BX_IA_ERROR },
};
#endif
// opcode 0F 23
static const BxOpcodeInfo_t BxOpcodeTable0F23_32[] = {
/* 0F 23 */ { 0, BX_IA_MOV_DdRd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F23_64[] = {
/* 0F 23 */ { 0, BX_IA_MOV_DqRq },
};
#endif
// opcode 0F 24
static const BxOpcodeInfo_t BxOpcodeTable0F24_32[] = {
/* 0F 24 */ { 0, BX_IA_ERROR }, // BX_IA_MOV_RdTd not implemented
};
// opcode 0F 26
static const BxOpcodeInfo_t BxOpcodeTable0F26_32[] = {
/* 0F 26 */ { 0, BX_IA_ERROR }, // BX_IA_MOV_TdRd not implemented
};
// opcode 0F 28
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F28[4] = {
/* -- */ { 0, BX_IA_MOVAPS_VpsWps },
/* 66 */ { 0, BX_IA_MOVAPD_VpdWpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 29
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F29[4] = {
/* -- */ { 0, BX_IA_MOVAPS_WpsVps },
/* 66 */ { 0, BX_IA_MOVAPD_WpdVpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 2A
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F2A[] = {
/* -- */ { 0, BX_IA_CVTPI2PS_VpsQq },
/* 66 */ { 0, BX_IA_CVTPI2PD_VpdQq },
/* F3 */ { 0, BX_IA_CVTSI2SS_VssEd },
/* F2 */ { 0, BX_IA_CVTSI2SD_VsdEd },
#if BX_SUPPORT_X86_64
/* -- /q */ { 0, BX_IA_CVTPI2PS_VpsQq },
/* 66 /q */ { 0, BX_IA_CVTPI2PD_VpdQq },
/* F3 /q */ { 0, BX_IA_CVTSI2SS_VssEq },
/* F2 /q */ { 0, BX_IA_CVTSI2SD_VsdEq },
#endif
};
// opcode 0F 2B
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F2B[4] = {
/* -- */ { 0, BX_IA_MOVNTPS_MpsVps },
/* 66 */ { 0, BX_IA_MOVNTPD_MpdVpd },
/* F3 */ { 0, BX_IA_MOVNTSS_MssVss },
/* F2 */ { 0, BX_IA_MOVNTSD_MsdVsd },
};
// opcode 0F 2C
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F2C[] = {
/* -- */ { 0, BX_IA_CVTTPS2PI_PqWps },
/* 66 */ { 0, BX_IA_CVTTPD2PI_PqWpd },
/* F3 */ { 0, BX_IA_CVTTSS2SI_GdWss },
/* F2 */ { 0, BX_IA_CVTTSD2SI_GdWsd },
#if BX_SUPPORT_X86_64
/* -- /q */ { 0, BX_IA_CVTTPS2PI_PqWps },
/* 66 /q */ { 0, BX_IA_CVTTPD2PI_PqWpd },
/* F3 /q */ { 0, BX_IA_CVTTSS2SI_GqWss },
/* F2 /q */ { 0, BX_IA_CVTTSD2SI_GqWsd },
#endif
};
// opcode 0F 2D
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F2D[] = {
/* -- */ { 0, BX_IA_CVTPS2PI_PqWps },
/* 66 */ { 0, BX_IA_CVTPD2PI_PqWpd },
/* F3 */ { 0, BX_IA_CVTSS2SI_GdWss },
/* F2 */ { 0, BX_IA_CVTSD2SI_GdWsd },
#if BX_SUPPORT_X86_64
/* -- /q */ { 0, BX_IA_CVTPS2PI_PqWps },
/* 66 /q */ { 0, BX_IA_CVTPD2PI_PqWpd },
/* F3 /q */ { 0, BX_IA_CVTSS2SI_GqWss },
/* F2 /q */ { 0, BX_IA_CVTSD2SI_GqWsd },
#endif
};
// opcode 0F 2E
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F2E[4] = {
/* -- */ { 0, BX_IA_UCOMISS_VssWss },
/* 66 */ { 0, BX_IA_UCOMISD_VsdWsd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 2F
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F2F[4] = {
/* -- */ { 0, BX_IA_COMISS_VssWss },
/* 66 */ { 0, BX_IA_COMISD_VsdWsd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 30
static const BxOpcodeInfo_t BxOpcodeTable0F30[] = {
/* 0F 30 */ { 0, BX_IA_WRMSR },
};
// opcode 0F 31
static const BxOpcodeInfo_t BxOpcodeTable0F31[] = {
// end trace to avoid multiple TSC samples in one cycle
/* 0F 31 */ { 0, BX_IA_RDTSC },
};
// opcode 0F 32
static const BxOpcodeInfo_t BxOpcodeTable0F32[] = {
// end trace to avoid multiple TSC samples in one cycle
/* 0F 32 */ { 0, BX_IA_RDMSR },
};
// opcode 0F 33
static const BxOpcodeInfo_t BxOpcodeTable0F33[] = {
/* 0F 33 */ { 0, BX_IA_RDPMC },
};
// opcode 0F 34
static const BxOpcodeInfo_t BxOpcodeTable0F34[] = {
/* 0F 34 */ { 0, BX_IA_SYSENTER },
};
// opcode 0F 35
static const BxOpcodeInfo_t BxOpcodeTable0F35[] = {
/* 0F 35 */ { 0, BX_IA_SYSEXIT },
};
// opcode 0F 37
static const BxOpcodeInfo_t BxOpcodeTable0F37[] = {
/* 0F 37 */ { 0, BX_IA_GETSEC },
};
// opcode 0F 40
static const BxOpcodeInfo_t BxOpcodeTable0F40[] = {
/* 0F 40 /w */ { 0, BX_IA_CMOVO_GwEw },
/* 0F 40 /d */ { 0, BX_IA_CMOVO_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 40 /q */ { 0, BX_IA_CMOVO_GqEq },
#endif
};
// opcode 0F 41
static const BxOpcodeInfo_t BxOpcodeTable0F41[] = {
/* 0F 41 /w */ { 0, BX_IA_CMOVNO_GwEw },
/* 0F 41 /d */ { 0, BX_IA_CMOVNO_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 41 /q */ { 0, BX_IA_CMOVNO_GqEq },
#endif
};
// opcode 0F 42
static const BxOpcodeInfo_t BxOpcodeTable0F42[] = {
/* 0F 42 /w */ { 0, BX_IA_CMOVB_GwEw },
/* 0F 42 /d */ { 0, BX_IA_CMOVB_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 42 /q */ { 0, BX_IA_CMOVB_GqEq },
#endif
};
// opcode 0F 43
static const BxOpcodeInfo_t BxOpcodeTable0F43[] = {
/* 0F 43 /w */ { 0, BX_IA_CMOVNB_GwEw },
/* 0F 43 /d */ { 0, BX_IA_CMOVNB_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 43 /q */ { 0, BX_IA_CMOVNB_GqEq },
#endif
};
// opcode 0F 44
static const BxOpcodeInfo_t BxOpcodeTable0F44[] = {
/* 0F 44 /w */ { 0, BX_IA_CMOVZ_GwEw },
/* 0F 44 /d */ { 0, BX_IA_CMOVZ_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 44 /q */ { 0, BX_IA_CMOVZ_GqEq },
#endif
};
// opcode 0F 45
static const BxOpcodeInfo_t BxOpcodeTable0F45[] = {
/* 0F 45 /w */ { 0, BX_IA_CMOVNZ_GwEw },
/* 0F 45 /d */ { 0, BX_IA_CMOVNZ_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 45 /q */ { 0, BX_IA_CMOVNZ_GqEq },
#endif
};
// opcode 0F 46
static const BxOpcodeInfo_t BxOpcodeTable0F46[] = {
/* 0F 46 /w */ { 0, BX_IA_CMOVBE_GwEw },
/* 0F 46 /d */ { 0, BX_IA_CMOVBE_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 46 /q */ { 0, BX_IA_CMOVBE_GqEq },
#endif
};
// opcode 0F 47
static const BxOpcodeInfo_t BxOpcodeTable0F47[] = {
/* 0F 47 /w */ { 0, BX_IA_CMOVNBE_GwEw },
/* 0F 47 /d */ { 0, BX_IA_CMOVNBE_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 47 /q */ { 0, BX_IA_CMOVNBE_GqEq },
#endif
};
// opcode 0F 48
static const BxOpcodeInfo_t BxOpcodeTable0F48[] = {
/* 0F 48 /w */ { 0, BX_IA_CMOVS_GwEw },
/* 0F 48 /d */ { 0, BX_IA_CMOVS_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 48 /q */ { 0, BX_IA_CMOVS_GqEq },
#endif
};
// opcode 0F 49
static const BxOpcodeInfo_t BxOpcodeTable0F49[] = {
/* 0F 49 /w */ { 0, BX_IA_CMOVNS_GwEw },
/* 0F 49 /d */ { 0, BX_IA_CMOVNS_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 49 /q */ { 0, BX_IA_CMOVNS_GqEq },
#endif
};
// opcode 0F 4A
static const BxOpcodeInfo_t BxOpcodeTable0F4A[] = {
/* 0F 4A /w */ { 0, BX_IA_CMOVP_GwEw },
/* 0F 4A /d */ { 0, BX_IA_CMOVP_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 4A /q */ { 0, BX_IA_CMOVP_GqEq },
#endif
};
// opcode 0F 4B
static const BxOpcodeInfo_t BxOpcodeTable0F4B[] = {
/* 0F 4B /w */ { 0, BX_IA_CMOVNP_GwEw },
/* 0F 4B /d */ { 0, BX_IA_CMOVNP_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 4B /q */ { 0, BX_IA_CMOVNP_GqEq },
#endif
};
// opcode 0F 4C
static const BxOpcodeInfo_t BxOpcodeTable0F4C[] = {
/* 0F 4C /w */ { 0, BX_IA_CMOVL_GwEw },
/* 0F 4C /d */ { 0, BX_IA_CMOVL_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 4C /q */ { 0, BX_IA_CMOVL_GqEq },
#endif
};
// opcode 0F 4D
static const BxOpcodeInfo_t BxOpcodeTable0F4D[] = {
/* 0F 4D /w */ { 0, BX_IA_CMOVNL_GwEw },
/* 0F 4D /d */ { 0, BX_IA_CMOVNL_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 4D /q */ { 0, BX_IA_CMOVNL_GqEq },
#endif
};
// opcode 0F 4E
static const BxOpcodeInfo_t BxOpcodeTable0F4E[] = {
/* 0F 4E /w */ { 0, BX_IA_CMOVLE_GwEw },
/* 0F 4E /d */ { 0, BX_IA_CMOVLE_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 4E /q */ { 0, BX_IA_CMOVLE_GqEq },
#endif
};
// opcode 0F 4F
static const BxOpcodeInfo_t BxOpcodeTable0F4F[] = {
/* 0F 4F /w */ { 0, BX_IA_CMOVNLE_GwEw },
/* 0F 4F /d */ { 0, BX_IA_CMOVNLE_GdEd },
#if BX_SUPPORT_X86_64
/* 0F 4F /q */ { 0, BX_IA_CMOVNLE_GqEq },
#endif
};
// opcode 0F 50
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F50[4] = {
/* -- */ { 0, BX_IA_MOVMSKPS_GdUps },
/* 66 */ { 0, BX_IA_MOVMSKPD_GdUpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 51
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F51[4] = {
/* -- */ { 0, BX_IA_SQRTPS_VpsWps },
/* 66 */ { 0, BX_IA_SQRTPD_VpdWpd },
/* F3 */ { 0, BX_IA_SQRTSS_VssWss },
/* F2 */ { 0, BX_IA_SQRTSD_VsdWsd },
};
// opcode 0F 52
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F52[4] = {
/* -- */ { 0, BX_IA_RSQRTPS_VpsWps },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_RSQRTSS_VssWss },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 53
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F53[4] = {
/* -- */ { 0, BX_IA_RCPPS_VpsWps },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_RCPSS_VssWss },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 54
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F54[4] = {
/* -- */ { 0, BX_IA_ANDPS_VpsWps },
/* 66 */ { 0, BX_IA_ANDPD_VpdWpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 55
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F55[4] = {
/* -- */ { 0, BX_IA_ANDNPS_VpsWps },
/* 66 */ { 0, BX_IA_ANDNPD_VpdWpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 56
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F56[4] = {
/* -- */ { 0, BX_IA_ORPS_VpsWps },
/* 66 */ { 0, BX_IA_ORPD_VpdWpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 57
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F57[4] = {
/* -- */ { 0, BX_IA_XORPS_VpsWps },
/* 66 */ { 0, BX_IA_XORPD_VpdWpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 58
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F58[] = {
/* -- */ { 0, BX_IA_ADDPS_VpsWps },
/* 66 */ { 0, BX_IA_ADDPD_VpdWpd },
/* F3 */ { 0, BX_IA_ADDSS_VssWss },
/* F2 */ { 0, BX_IA_ADDSD_VsdWsd },
};
// opcode 0F 59
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F59[] = {
/* -- */ { 0, BX_IA_MULPS_VpsWps },
/* 66 */ { 0, BX_IA_MULPD_VpdWpd },
/* F3 */ { 0, BX_IA_MULSS_VssWss },
/* F2 */ { 0, BX_IA_MULSD_VsdWsd },
};
// opcode 0F 5A
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F5A[] = {
/* -- */ { 0, BX_IA_CVTPS2PD_VpdWps },
/* 66 */ { 0, BX_IA_CVTPD2PS_VpsWpd },
/* F3 */ { 0, BX_IA_CVTSS2SD_VsdWss },
/* F2 */ { 0, BX_IA_CVTSD2SS_VssWsd },
};
// opcode 0F 5B
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F5B[4] = {
/* -- */ { 0, BX_IA_CVTDQ2PS_VpsWdq },
/* 66 */ { 0, BX_IA_CVTPS2DQ_VdqWps },
/* F3 */ { 0, BX_IA_CVTTPS2DQ_VdqWps },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 5C
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F5C[4] = {
/* -- */ { 0, BX_IA_SUBPS_VpsWps },
/* 66 */ { 0, BX_IA_SUBPD_VpdWpd },
/* F3 */ { 0, BX_IA_SUBSS_VssWss },
/* F2 */ { 0, BX_IA_SUBSD_VsdWsd },
};
// opcode 0F 5D
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F5D[4] = {
/* -- */ { 0, BX_IA_MINPS_VpsWps },
/* 66 */ { 0, BX_IA_MINPD_VpdWpd },
/* F3 */ { 0, BX_IA_MINSS_VssWss },
/* F2 */ { 0, BX_IA_MINSD_VsdWsd },
};
// opcode 0F 5E
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F5E[4] = {
/* -- */ { 0, BX_IA_DIVPS_VpsWps },
/* 66 */ { 0, BX_IA_DIVPD_VpdWpd },
/* F3 */ { 0, BX_IA_DIVSS_VssWss },
/* F2 */ { 0, BX_IA_DIVSD_VsdWsd },
};
// opcode 0F 5F
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F5F[4] = {
/* -- */ { 0, BX_IA_MAXPS_VpsWps },
/* 66 */ { 0, BX_IA_MAXPD_VpdWpd },
/* F3 */ { 0, BX_IA_MAXSS_VssWss },
/* F2 */ { 0, BX_IA_MAXSD_VsdWsd },
};
// opcode 0F 60
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F60[4] = {
/* -- */ { 0, BX_IA_PUNPCKLBW_PqQd },
/* 66 */ { 0, BX_IA_PUNPCKLBW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 61
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F61[4] = {
/* -- */ { 0, BX_IA_PUNPCKLWD_PqQd },
/* 66 */ { 0, BX_IA_PUNPCKLWD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 62
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F62[4] = {
/* -- */ { 0, BX_IA_PUNPCKLDQ_PqQd },
/* 66 */ { 0, BX_IA_PUNPCKLDQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 63
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F63[4] = {
/* -- */ { 0, BX_IA_PACKSSWB_PqQq },
/* 66 */ { 0, BX_IA_PACKSSWB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 64
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F64[4] = {
/* -- */ { 0, BX_IA_PCMPGTB_PqQq },
/* 66 */ { 0, BX_IA_PCMPGTB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 65
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F65[4] = {
/* -- */ { 0, BX_IA_PCMPGTW_PqQq },
/* 66 */ { 0, BX_IA_PCMPGTW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 66
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F66[4] = {
/* -- */ { 0, BX_IA_PCMPGTD_PqQq },
/* 66 */ { 0, BX_IA_PCMPGTD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 67
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F67[4] = {
/* -- */ { 0, BX_IA_PACKUSWB_PqQq },
/* 66 */ { 0, BX_IA_PACKUSWB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 68
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F68[4] = {
/* -- */ { 0, BX_IA_PUNPCKHBW_PqQq },
/* 66 */ { 0, BX_IA_PUNPCKHBW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 69
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F69[4] = {
/* -- */ { 0, BX_IA_PUNPCKHWD_PqQq },
/* 66 */ { 0, BX_IA_PUNPCKHWD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 6A
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F6A[4] = {
/* -- */ { 0, BX_IA_PUNPCKHDQ_PqQq },
/* 66 */ { 0, BX_IA_PUNPCKHDQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 6B
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F6B[4] = {
/* -- */ { 0, BX_IA_PACKSSDW_PqQq },
/* 66 */ { 0, BX_IA_PACKSSDW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 6C
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F6C[4] = {
/* -- */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_PUNPCKLQDQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 6D
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F6D[4] = {
/* -- */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_PUNPCKHQDQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 6E
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F6E[] = {
/* -- */ { 0, BX_IA_MOVD_PqEd },
/* 66 */ { 0, BX_IA_MOVD_VdqEd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
#if BX_SUPPORT_X86_64
/* -- /q */ { 0, BX_IA_MOVQ_PqEq },
/* 66 /q */ { 0, BX_IA_MOVQ_VdqEq },
/* F3 /q */ { 0, BX_IA_ERROR },
/* F2 /q */ { 0, BX_IA_ERROR },
#endif
};
// opcode 0F 6F
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F6F[4] = {
/* -- */ { 0, BX_IA_MOVQ_PqQq },
/* 66 */ { 0, BX_IA_MOVDQA_VdqWdq },
/* F3 */ { 0, BX_IA_MOVDQU_VdqWdq },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 70
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F70[4] = {
/* -- */ { BxImmediate_Ib, BX_IA_PSHUFW_PqQqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSHUFD_VdqWdqIb },
/* F3 */ { BxImmediate_Ib, BX_IA_PSHUFHW_VdqWdqIb },
/* F2 */ { BxImmediate_Ib, BX_IA_PSHUFLW_VdqWdqIb },
};
// opcode 0F 71
static const BxOpcodeInfo_t BxOpcodeTable0F71_G12[] = {
/* -- /0 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /1 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /2 */ { BxImmediate_Ib, BX_IA_PSRLW_NqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSRLW_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /3 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /4 */ { BxImmediate_Ib, BX_IA_PSRAW_NqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSRAW_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /5 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /6 */ { BxImmediate_Ib, BX_IA_PSLLW_NqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSLLW_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /7 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 72
static const BxOpcodeInfo_t BxOpcodeTable0F72_G13[] = {
/* -- /0 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /1 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /2 */ { BxImmediate_Ib, BX_IA_PSRLD_NqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSRLD_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /3 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /4 */ { BxImmediate_Ib, BX_IA_PSRAD_NqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSRAD_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /5 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /6 */ { BxImmediate_Ib, BX_IA_PSLLD_NqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSLLD_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /7 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 73
static const BxOpcodeInfo_t BxOpcodeTable0F73_G14[] = {
/* -- /0 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /1 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /2 */ { BxImmediate_Ib, BX_IA_PSRLQ_NqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSRLQ_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /3 */ { 0, BX_IA_ERROR },
/* 66 */ { BxImmediate_Ib, BX_IA_PSRLDQ_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /4 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /5 */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /6 */ { BxImmediate_Ib, BX_IA_PSLLQ_NqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PSLLQ_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /7 */ { 0, BX_IA_ERROR },
/* 66 */ { BxImmediate_Ib, BX_IA_PSLLDQ_UdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 74
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F74[4] = {
/* -- */ { 0, BX_IA_PCMPEQB_PqQq },
/* 66 */ { 0, BX_IA_PCMPEQB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 75
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F75[4] = {
/* -- */ { 0, BX_IA_PCMPEQW_PqQq },
/* 66 */ { 0, BX_IA_PCMPEQW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 76
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F76[4] = {
/* -- */ { 0, BX_IA_PCMPEQD_PqQq },
/* 66 */ { 0, BX_IA_PCMPEQD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 77
static const BxOpcodeInfo_t BxOpcodeTable0F77[] = {
/* 0F 77 /w */ { BxNoPrefixSSE, BX_IA_EMMS },
/* 0F 77 /d */ { BxNoPrefixSSE, BX_IA_EMMS },
#if BX_SUPPORT_X86_64
/* 0F 77 /q */ { BxNoPrefixSSE, BX_IA_EMMS },
#endif
};
// opcode 0F 78
static const BxOpcodeInfo_t BxOpcodeTable0F78[] = {
/* 0F 78 /32 */ { 0, BX_IA_VMREAD_EdGd }, // SSE prefix handled inside decode method
#if BX_SUPPORT_X86_64
/* 0F 78 /64 */ { 0, BX_IA_VMREAD_EqGq }, // SSE prefix handled inside decode method
#endif
};
// opcode 0F 79
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F79_32[4] = {
/* -- */ { 0, BX_IA_VMWRITE_GdEd },
/* 66 */ { 0, BX_IA_EXTRQ_VdqUq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_INSERTQ_VdqUdq },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F79_64[4] = {
/* -- */ { 0, BX_IA_VMWRITE_GqEq },
/* 66 */ { 0, BX_IA_EXTRQ_VdqUq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_INSERTQ_VdqUdq },
};
#endif
// opcode 0F 7C
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F7C[4] = {
/* -- */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_HADDPD_VpdWpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_HADDPS_VpsWps },
};
// opcode 0F 7D
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F7D[4] = {
/* -- */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_HSUBPD_VpdWpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_HSUBPS_VpsWps },
};
// opcode 0F 7E
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F7E[] = {
/* -- */ { 0, BX_IA_MOVD_EdPq },
/* 66 */ { 0, BX_IA_MOVD_EdVd },
/* F3 */ { 0, BX_IA_MOVQ_VqWq },
/* F2 */ { 0, BX_IA_ERROR },
#if BX_SUPPORT_X86_64
/* -- /q */ { 0, BX_IA_MOVQ_EqPq },
/* 66 /q */ { 0, BX_IA_MOVQ_EqVq },
/* F3 /q */ { 0, BX_IA_MOVQ_VqWq },
/* F2 /q */ { 0, BX_IA_ERROR },
#endif
};
// opcode 0F 7F
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0F7F[4] = {
/* -- */ { 0, BX_IA_MOVQ_QqPq },
/* 66 */ { 0, BX_IA_MOVDQA_WdqVdq },
/* F3 */ { 0, BX_IA_MOVDQU_WdqVdq },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F 80
static const BxOpcodeInfo_t BxOpcodeTable0F80_32[] = {
/* 0F 80 /w */ { BxImmediate_BrOff16, BX_IA_JO_Jw },
/* 0F 80 /d */ { BxImmediate_BrOff32, BX_IA_JO_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F80_64[] = {
/* 0F 80 /w */ { BxImmediate_BrOff32, BX_IA_JO_Jq },
/* 0F 80 /d */ { BxImmediate_BrOff32, BX_IA_JO_Jq },
/* 0F 80 /q */ { BxImmediate_BrOff32, BX_IA_JO_Jq },
};
#endif
// opcode 0F 81
static const BxOpcodeInfo_t BxOpcodeTable0F81_32[] = {
/* 0F 81 /w */ { BxImmediate_BrOff16, BX_IA_JNO_Jw },
/* 0F 81 /d */ { BxImmediate_BrOff32, BX_IA_JNO_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F81_64[] = {
/* 0F 81 /w */ { BxImmediate_BrOff32, BX_IA_JNO_Jq },
/* 0F 81 /d */ { BxImmediate_BrOff32, BX_IA_JNO_Jq },
/* 0F 81 /q */ { BxImmediate_BrOff32, BX_IA_JNO_Jq },
};
#endif
// opcode 0F 82
static const BxOpcodeInfo_t BxOpcodeTable0F82_32[] = {
/* 0F 82 /w */ { BxImmediate_BrOff16, BX_IA_JB_Jw },
/* 0F 82 /d */ { BxImmediate_BrOff32, BX_IA_JB_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F82_64[] = {
/* 0F 82 /w */ { BxImmediate_BrOff32, BX_IA_JB_Jq },
/* 0F 82 /d */ { BxImmediate_BrOff32, BX_IA_JB_Jq },
/* 0F 82 /q */ { BxImmediate_BrOff32, BX_IA_JB_Jq },
};
#endif
// opcode 0F 83
static const BxOpcodeInfo_t BxOpcodeTable0F83_32[] = {
/* 0F 83 /w */ { BxImmediate_BrOff16, BX_IA_JNB_Jw },
/* 0F 83 /d */ { BxImmediate_BrOff32, BX_IA_JNB_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F83_64[] = {
/* 0F 83 /w */ { BxImmediate_BrOff32, BX_IA_JNB_Jq },
/* 0F 83 /d */ { BxImmediate_BrOff32, BX_IA_JNB_Jq },
/* 0F 83 /q */ { BxImmediate_BrOff32, BX_IA_JNB_Jq },
};
#endif
// opcode 0F 84
static const BxOpcodeInfo_t BxOpcodeTable0F84_32[] = {
/* 0F 84 /w */ { BxImmediate_BrOff16, BX_IA_JZ_Jw },
/* 0F 84 /d */ { BxImmediate_BrOff32, BX_IA_JZ_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F84_64[] = {
/* 0F 84 /w */ { BxImmediate_BrOff32, BX_IA_JZ_Jq },
/* 0F 84 /d */ { BxImmediate_BrOff32, BX_IA_JZ_Jq },
/* 0F 84 /q */ { BxImmediate_BrOff32, BX_IA_JZ_Jq },
};
#endif
// opcode 0F 85
static const BxOpcodeInfo_t BxOpcodeTable0F85_32[] = {
/* 0F 85 /w */ { BxImmediate_BrOff16, BX_IA_JNZ_Jw },
/* 0F 85 /d */ { BxImmediate_BrOff32, BX_IA_JNZ_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F85_64[] = {
/* 0F 85 /w */ { BxImmediate_BrOff32, BX_IA_JNZ_Jq },
/* 0F 85 /d */ { BxImmediate_BrOff32, BX_IA_JNZ_Jq },
/* 0F 85 /q */ { BxImmediate_BrOff32, BX_IA_JNZ_Jq },
};
#endif
// opcode 0F 86
static const BxOpcodeInfo_t BxOpcodeTable0F86_32[] = {
/* 0F 86 /w */ { BxImmediate_BrOff16, BX_IA_JBE_Jw },
/* 0F 86 /d */ { BxImmediate_BrOff32, BX_IA_JBE_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F86_64[] = {
/* 0F 86 /w */ { BxImmediate_BrOff32, BX_IA_JBE_Jq },
/* 0F 86 /d */ { BxImmediate_BrOff32, BX_IA_JBE_Jq },
/* 0F 86 /q */ { BxImmediate_BrOff32, BX_IA_JBE_Jq },
};
#endif
// opcode 0F 87
static const BxOpcodeInfo_t BxOpcodeTable0F87_32[] = {
/* 0F 87 /w */ { BxImmediate_BrOff16, BX_IA_JNBE_Jw },
/* 0F 87 /d */ { BxImmediate_BrOff32, BX_IA_JNBE_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F87_64[] = {
/* 0F 87 /w */ { BxImmediate_BrOff32, BX_IA_JNBE_Jq },
/* 0F 87 /d */ { BxImmediate_BrOff32, BX_IA_JNBE_Jq },
/* 0F 87 /q */ { BxImmediate_BrOff32, BX_IA_JNBE_Jq },
};
#endif
// opcode 0F 88
static const BxOpcodeInfo_t BxOpcodeTable0F88_32[] = {
/* 0F 88 /w */ { BxImmediate_BrOff16, BX_IA_JS_Jw },
/* 0F 88 /d */ { BxImmediate_BrOff32, BX_IA_JS_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F88_64[] = {
/* 0F 88 /w */ { BxImmediate_BrOff32, BX_IA_JS_Jq },
/* 0F 88 /d */ { BxImmediate_BrOff32, BX_IA_JS_Jq },
/* 0F 88 /q */ { BxImmediate_BrOff32, BX_IA_JS_Jq },
};
#endif
// opcode 0F 89
static const BxOpcodeInfo_t BxOpcodeTable0F89_32[] = {
/* 0F 89 /w */ { BxImmediate_BrOff16, BX_IA_JNS_Jw },
/* 0F 89 /d */ { BxImmediate_BrOff32, BX_IA_JNS_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F89_64[] = {
/* 0F 89 /w */ { BxImmediate_BrOff32, BX_IA_JNS_Jq },
/* 0F 89 /d */ { BxImmediate_BrOff32, BX_IA_JNS_Jq },
/* 0F 89 /q */ { BxImmediate_BrOff32, BX_IA_JNS_Jq },
};
#endif
// opcode 0F 8A
static const BxOpcodeInfo_t BxOpcodeTable0F8A_32[] = {
/* 0F 8A /w */ { BxImmediate_BrOff16, BX_IA_JP_Jw },
/* 0F 8A /d */ { BxImmediate_BrOff32, BX_IA_JP_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F8A_64[] = {
/* 0F 8A /w */ { BxImmediate_BrOff32, BX_IA_JP_Jq },
/* 0F 8A /d */ { BxImmediate_BrOff32, BX_IA_JP_Jq },
/* 0F 8A /q */ { BxImmediate_BrOff32, BX_IA_JP_Jq },
};
#endif
// opcode 0F 8B
static const BxOpcodeInfo_t BxOpcodeTable0F8B_32[] = {
/* 0F 8B /w */ { BxImmediate_BrOff16, BX_IA_JNP_Jw },
/* 0F 8B /d */ { BxImmediate_BrOff32, BX_IA_JNP_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F8B_64[] = {
/* 0F 8B /w */ { BxImmediate_BrOff32, BX_IA_JNP_Jq },
/* 0F 8B /d */ { BxImmediate_BrOff32, BX_IA_JNP_Jq },
/* 0F 8B /q */ { BxImmediate_BrOff32, BX_IA_JNP_Jq },
};
#endif
// opcode 0F 8C
static const BxOpcodeInfo_t BxOpcodeTable0F8C_32[] = {
/* 0F 8C /w */ { BxImmediate_BrOff16, BX_IA_JL_Jw },
/* 0F 8C /d */ { BxImmediate_BrOff32, BX_IA_JL_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F8C_64[] = {
/* 0F 8C /w */ { BxImmediate_BrOff32, BX_IA_JL_Jq },
/* 0F 8C /d */ { BxImmediate_BrOff32, BX_IA_JL_Jq },
/* 0F 8C /q */ { BxImmediate_BrOff32, BX_IA_JL_Jq },
};
#endif
// opcode 0F 8D
static const BxOpcodeInfo_t BxOpcodeTable0F8D_32[] = {
/* 0F 8D /w */ { BxImmediate_BrOff16, BX_IA_JNL_Jw },
/* 0F 8D /d */ { BxImmediate_BrOff32, BX_IA_JNL_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F8D_64[] = {
/* 0F 8D /w */ { BxImmediate_BrOff32, BX_IA_JNL_Jq },
/* 0F 8D /d */ { BxImmediate_BrOff32, BX_IA_JNL_Jq },
/* 0F 8D /q */ { BxImmediate_BrOff32, BX_IA_JNL_Jq },
};
#endif
// opcode 0F 8E
static const BxOpcodeInfo_t BxOpcodeTable0F8E_32[] = {
/* 0F 8E /w */ { BxImmediate_BrOff16, BX_IA_JLE_Jw },
/* 0F 8E /d */ { BxImmediate_BrOff32, BX_IA_JLE_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F8E_64[] = {
/* 0F 8E /w */ { BxImmediate_BrOff32, BX_IA_JLE_Jq },
/* 0F 8E /d */ { BxImmediate_BrOff32, BX_IA_JLE_Jq },
/* 0F 8E /q */ { BxImmediate_BrOff32, BX_IA_JLE_Jq },
};
#endif
// opcode 0F 8F
static const BxOpcodeInfo_t BxOpcodeTable0F8F_32[] = {
/* 0F 8F /w */ { BxImmediate_BrOff16, BX_IA_JNLE_Jw },
/* 0F 8F /d */ { BxImmediate_BrOff32, BX_IA_JNLE_Jd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0F8F_64[] = {
/* 0F 8F /w */ { BxImmediate_BrOff32, BX_IA_JNLE_Jq },
/* 0F 8F /d */ { BxImmediate_BrOff32, BX_IA_JNLE_Jq },
/* 0F 8F /q */ { BxImmediate_BrOff32, BX_IA_JNLE_Jq },
};
#endif
// opcode 0F 90
static const BxOpcodeInfo_t BxOpcodeTable0F90[] = {
/* 0F 90 /w */ { 0, BX_IA_SETO_Eb },
/* 0F 90 /d */ { 0, BX_IA_SETO_Eb },
#if BX_SUPPORT_X86_64
/* 0F 90 /q */ { 0, BX_IA_SETO_Eb },
#endif
};
// opcode 0F 91
static const BxOpcodeInfo_t BxOpcodeTable0F91[] = {
/* 0F 91 /w */ { 0, BX_IA_SETNO_Eb },
/* 0F 91 /d */ { 0, BX_IA_SETNO_Eb },
#if BX_SUPPORT_X86_64
/* 0F 91 /q */ { 0, BX_IA_SETNO_Eb },
#endif
};
// opcode 0F 92
static const BxOpcodeInfo_t BxOpcodeTable0F92[] = {
/* 0F 92 /w */ { 0, BX_IA_SETB_Eb },
/* 0F 92 /d */ { 0, BX_IA_SETB_Eb },
#if BX_SUPPORT_X86_64
/* 0F 92 /q */ { 0, BX_IA_SETB_Eb },
#endif
};
// opcode 0F 93
static const BxOpcodeInfo_t BxOpcodeTable0F93[] = {
/* 0F 93 /w */ { 0, BX_IA_SETNB_Eb },
/* 0F 93 /d */ { 0, BX_IA_SETNB_Eb },
#if BX_SUPPORT_X86_64
/* 0F 93 /q */ { 0, BX_IA_SETNB_Eb },
#endif
};
// opcode 0F 94
static const BxOpcodeInfo_t BxOpcodeTable0F94[] = {
/* 0F 94 /w */ { 0, BX_IA_SETZ_Eb },
/* 0F 94 /d */ { 0, BX_IA_SETZ_Eb },
#if BX_SUPPORT_X86_64
/* 0F 94 /q */ { 0, BX_IA_SETZ_Eb },
#endif
};
// opcode 0F 95
static const BxOpcodeInfo_t BxOpcodeTable0F95[] = {
/* 0F 95 /w */ { 0, BX_IA_SETNZ_Eb },
/* 0F 95 /d */ { 0, BX_IA_SETNZ_Eb },
#if BX_SUPPORT_X86_64
/* 0F 95 /q */ { 0, BX_IA_SETNZ_Eb },
#endif
};
// opcode 0F 96
static const BxOpcodeInfo_t BxOpcodeTable0F96[] = {
/* 0F 96 /w */ { 0, BX_IA_SETBE_Eb },
/* 0F 96 /d */ { 0, BX_IA_SETBE_Eb },
#if BX_SUPPORT_X86_64
/* 0F 96 /q */ { 0, BX_IA_SETBE_Eb },
#endif
};
// opcode 0F 97
static const BxOpcodeInfo_t BxOpcodeTable0F97[] = {
/* 0F 97 /w */ { 0, BX_IA_SETNBE_Eb },
/* 0F 97 /d */ { 0, BX_IA_SETNBE_Eb },
#if BX_SUPPORT_X86_64
/* 0F 97 /q */ { 0, BX_IA_SETNBE_Eb },
#endif
};
// opcode 0F 98
static const BxOpcodeInfo_t BxOpcodeTable0F98[] = {
/* 0F 98 /w */ { 0, BX_IA_SETS_Eb },
/* 0F 98 /d */ { 0, BX_IA_SETS_Eb },
#if BX_SUPPORT_X86_64
/* 0F 98 /q */ { 0, BX_IA_SETS_Eb },
#endif
};
// opcode 0F 99
static const BxOpcodeInfo_t BxOpcodeTable0F99[] = {
/* 0F 99 /w */ { 0, BX_IA_SETNS_Eb },
/* 0F 99 /d */ { 0, BX_IA_SETNS_Eb },
#if BX_SUPPORT_X86_64
/* 0F 99 /q */ { 0, BX_IA_SETNS_Eb },
#endif
};
// opcode 0F 9A
static const BxOpcodeInfo_t BxOpcodeTable0F9A[] = {
/* 0F 9A /w */ { 0, BX_IA_SETP_Eb },
/* 0F 9A /d */ { 0, BX_IA_SETP_Eb },
#if BX_SUPPORT_X86_64
/* 0F 9A /q */ { 0, BX_IA_SETP_Eb },
#endif
};
// opcode 0F 9B
static const BxOpcodeInfo_t BxOpcodeTable0F9B[] = {
/* 0F 9B /w */ { 0, BX_IA_SETNP_Eb },
/* 0F 9B /d */ { 0, BX_IA_SETNP_Eb },
#if BX_SUPPORT_X86_64
/* 0F 9B /q */ { 0, BX_IA_SETNP_Eb },
#endif
};
// opcode 0F 9C
static const BxOpcodeInfo_t BxOpcodeTable0F9C[] = {
/* 0F 9C /w */ { 0, BX_IA_SETL_Eb },
/* 0F 9C /d */ { 0, BX_IA_SETL_Eb },
#if BX_SUPPORT_X86_64
/* 0F 9C /q */ { 0, BX_IA_SETL_Eb },
#endif
};
// opcode 0F 9D
static const BxOpcodeInfo_t BxOpcodeTable0F9D[] = {
/* 0F 9D /w */ { 0, BX_IA_SETNL_Eb },
/* 0F 9D /d */ { 0, BX_IA_SETNL_Eb },
#if BX_SUPPORT_X86_64
/* 0F 9D /q */ { 0, BX_IA_SETNL_Eb },
#endif
};
// opcode 0F 9E
static const BxOpcodeInfo_t BxOpcodeTable0F9E[] = {
/* 0F 9E /w */ { 0, BX_IA_SETLE_Eb },
/* 0F 9E /d */ { 0, BX_IA_SETLE_Eb },
#if BX_SUPPORT_X86_64
/* 0F 9E /q */ { 0, BX_IA_SETLE_Eb },
#endif
};
// opcode 0F 9F
static const BxOpcodeInfo_t BxOpcodeTable0F9F[] = {
/* 0F 9F /w */ { 0, BX_IA_SETNLE_Eb },
/* 0F 9F /d */ { 0, BX_IA_SETNLE_Eb },
#if BX_SUPPORT_X86_64
/* 0F 9F /q */ { 0, BX_IA_SETNLE_Eb },
#endif
};
// opcode 0F A0
static const BxOpcodeInfo_t BxOpcodeTable0FA0_32[] = {
/* 0F A0 /w */ { 0, BX_IA_PUSH_Op16_Sw },
/* 0F A0 /d */ { 0, BX_IA_PUSH_Op32_Sw },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0FA0_64[] = {
/* 0F A0 /w */ { 0, BX_IA_PUSH_Op16_Sw },
/* 0F A0 /d */ { 0, BX_IA_PUSH_Op64_Sw },
/* 0F A0 /q */ { 0, BX_IA_PUSH_Op64_Sw },
};
#endif
// opcode 0F A1
static const BxOpcodeInfo_t BxOpcodeTable0FA1_32[] = {
/* 0F A1 /w */ { 0, BX_IA_POP_Op16_Sw },
/* 0F A1 /d */ { 0, BX_IA_POP_Op32_Sw },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0FA1_64[] = {
/* 0F A1 /w */ { 0, BX_IA_POP_Op16_Sw },
/* 0F A1 /d */ { 0, BX_IA_POP_Op64_Sw },
/* 0F A1 /q */ { 0, BX_IA_POP_Op64_Sw },
};
#endif
// opcode 0F A2
static const BxOpcodeInfo_t BxOpcodeTable0FA2[] = {
/* 0F A2 */ { 0, BX_IA_CPUID },
};
// opcode 0F A3
static const BxOpcodeInfo_t BxOpcodeTable0FA3[] = {
/* 0F A3 /w */ { 0, BX_IA_BT_EwGw },
/* 0F A3 /d */ { 0, BX_IA_BT_EdGd },
#if BX_SUPPORT_X86_64
/* 0F A3 /q */ { 0, BX_IA_BT_EqGq },
#endif
};
// opcode 0F A4
static const BxOpcodeInfo_t BxOpcodeTable0FA4[] = {
/* 0F A4 /w */ { BxImmediate_Ib, BX_IA_SHLD_EwGwIb },
/* 0F A4 /d */ { BxImmediate_Ib, BX_IA_SHLD_EdGdIb },
#if BX_SUPPORT_X86_64
/* 0F A4 /q */ { BxImmediate_Ib, BX_IA_SHLD_EqGqIb },
#endif
};
// opcode 0F A5
static const BxOpcodeInfo_t BxOpcodeTable0FA5[] = {
/* 0F A5 /w */ { 0, BX_IA_SHLD_EwGw },
/* 0F A5 /d */ { 0, BX_IA_SHLD_EdGd },
#if BX_SUPPORT_X86_64
/* 0F A5 /q */ { 0, BX_IA_SHLD_EqGq },
#endif
};
// opcode 0F A8
static const BxOpcodeInfo_t BxOpcodeTable0FA8_32[] = {
/* 0F A8 /w */ { 0, BX_IA_PUSH_Op16_Sw },
/* 0F A8 /d */ { 0, BX_IA_PUSH_Op32_Sw },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0FA8_64[] = {
/* 0F A8 /w */ { 0, BX_IA_PUSH_Op16_Sw },
/* 0F A8 /d */ { 0, BX_IA_PUSH_Op64_Sw },
/* 0F A8 /q */ { 0, BX_IA_PUSH_Op64_Sw },
};
#endif
// opcode 0F A9
static const BxOpcodeInfo_t BxOpcodeTable0FA9_32[] = {
/* 0F A9 /w */ { 0, BX_IA_POP_Op16_Sw },
/* 0F A9 /d */ { 0, BX_IA_POP_Op32_Sw },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0FA9_64[] = {
/* 0F A9 /w */ { 0, BX_IA_POP_Op16_Sw },
/* 0F A9 /d */ { 0, BX_IA_POP_Op64_Sw },
/* 0F A9 /q */ { 0, BX_IA_POP_Op64_Sw },
};
#endif
// opcode 0F AA
static const BxOpcodeInfo_t BxOpcodeTable0FAA[] = {
/* 0F AA */ { 0, BX_IA_RSM },
};
// opcode 0F AB
static const BxOpcodeInfo_t BxOpcodeTable0FAB[] = {
/* 0F AB /w */ { 0, BX_IA_BTS_EwGw },
/* 0F AB /d */ { 0, BX_IA_BTS_EdGd },
#if BX_SUPPORT_X86_64
/* 0F AB /q */ { 0, BX_IA_BTS_EqGq },
#endif
};
// opcode 0F AC
static const BxOpcodeInfo_t BxOpcodeTable0FAC[] = {
/* 0F AC /w */ { BxImmediate_Ib, BX_IA_SHRD_EwGwIb },
/* 0F AC /d */ { BxImmediate_Ib, BX_IA_SHRD_EdGdIb },
#if BX_SUPPORT_X86_64
/* 0F AC /q */ { BxImmediate_Ib, BX_IA_SHRD_EqGqIb },
#endif
};
// opcode 0F AD
static const BxOpcodeInfo_t BxOpcodeTable0FAD[] = {
/* 0F AD /w */ { 0, BX_IA_SHRD_EwGw },
/* 0F AD /d */ { 0, BX_IA_SHRD_EdGd },
#if BX_SUPPORT_X86_64
/* 0F AD /q */ { 0, BX_IA_SHRD_EqGq },
#endif
};
// opcode 0F AE
static const BxOpcodeInfo_t BxOpcodeTable0FAE_G15_R32[] = {
/* /r form */
/* /0 */ { 0, BX_IA_ERROR },
/* /1 */ { 0, BX_IA_ERROR },
/* /2 */ { 0, BX_IA_ERROR },
/* /3 */ { 0, BX_IA_ERROR },
/* /4 */ { 0, BX_IA_ERROR },
/* /5 */ { BxNoPrefixSSE, BX_IA_LFENCE },
/* /6 */ { BxNoPrefixSSE, BX_IA_MFENCE },
/* /7 */ { BxNoPrefixSSE, BX_IA_SFENCE },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0FAE_G15d_R64[8] = {
/* /r form */
/* /0 */ { BxPrefixSSEF3, BX_IA_RDFSBASE_Ed },
/* /1 */ { BxPrefixSSEF3, BX_IA_RDGSBASE_Ed },
/* /2 */ { BxPrefixSSEF3, BX_IA_WRFSBASE_Ed },
/* /3 */ { BxPrefixSSEF3, BX_IA_WRGSBASE_Ed },
/* /4 */ { 0, BX_IA_ERROR },
/* /5 */ { BxNoPrefixSSE, BX_IA_LFENCE },
/* /6 */ { BxNoPrefixSSE, BX_IA_MFENCE },
/* /7 */ { BxNoPrefixSSE, BX_IA_SFENCE },
};
static const BxOpcodeInfo_t BxOpcodeTable0FAE_G15q_R64[8] = {
/* /r form */
/* /0 */ { BxPrefixSSEF3, BX_IA_RDFSBASE_Eq },
/* /1 */ { BxPrefixSSEF3, BX_IA_RDGSBASE_Eq },
/* /2 */ { BxPrefixSSEF3, BX_IA_WRFSBASE_Eq },
/* /3 */ { BxPrefixSSEF3, BX_IA_WRGSBASE_Eq },
/* /4 */ { 0, BX_IA_ERROR },
/* /5 */ { BxNoPrefixSSE, BX_IA_LFENCE },
/* /6 */ { BxNoPrefixSSE, BX_IA_MFENCE },
/* /7 */ { BxNoPrefixSSE, BX_IA_SFENCE },
};
#endif
static const BxOpcodeInfo_t BxOpcodeTable0FAE_G15M[] = {
/* /m form */
/* -- /0 */ { 0, BX_IA_FXSAVE },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /1 */ { 0, BX_IA_FXRSTOR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /2 */ { 0, BX_IA_LDMXCSR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /3 */ { 0, BX_IA_STMXCSR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /4 */ { 0, BX_IA_XSAVE },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /5 */ { 0, BX_IA_XRSTOR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /6 */ { 0, BX_IA_XSAVEOPT },
/* 66 */ { 0, BX_IA_CLWB },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
/* -- /7 */ { 0, BX_IA_CLFLUSH },
/* 66 */ { 0, BX_IA_CLFLUSHOPT },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F AF
static const BxOpcodeInfo_t BxOpcodeTable0FAF[] = {
/* 0F AF /w */ { 0, BX_IA_IMUL_GwEw },
/* 0F AF /d */ { 0, BX_IA_IMUL_GdEd },
#if BX_SUPPORT_X86_64
/* 0F AF /q */ { 0, BX_IA_IMUL_GqEq },
#endif
};
// opcode 0F B0
static const BxOpcodeInfo_t BxOpcodeTable0FB0[] = {
/* 0F B0 /w */ { 0, BX_IA_CMPXCHG_EbGb },
/* 0F B0 /d */ { 0, BX_IA_CMPXCHG_EbGb },
#if BX_SUPPORT_X86_64
/* 0F B0 /q */ { 0, BX_IA_CMPXCHG_EbGb },
#endif
};
// opcode 0F B1
static const BxOpcodeInfo_t BxOpcodeTable0FB1[] = {
/* 0F B1 /w */ { 0, BX_IA_CMPXCHG_EwGw },
/* 0F B1 /d */ { 0, BX_IA_CMPXCHG_EdGd },
#if BX_SUPPORT_X86_64
/* 0F B1 /q */ { 0, BX_IA_CMPXCHG_EqGq },
#endif
};
// opcode 0F B2
static const BxOpcodeInfo_t BxOpcodeTable0FB2[] = {
/* 0F B2 /w */ { 0, BX_IA_LSS_GwMp },
/* 0F B2 /d */ { 0, BX_IA_LSS_GdMp },
#if BX_SUPPORT_X86_64
/* 0F B2 /q */ { 0, BX_IA_LSS_GqMp }, // TODO: LSS_GdMp for AMD CPU
#endif
};
// opcode 0F B3
static const BxOpcodeInfo_t BxOpcodeTable0FB3[] = {
/* 0F B3 /w */ { 0, BX_IA_BTR_EwGw },
/* 0F B3 /d */ { 0, BX_IA_BTR_EdGd },
#if BX_SUPPORT_X86_64
/* 0F B3 /q */ { 0, BX_IA_BTR_EqGq },
#endif
};
// opcode 0F B4
static const BxOpcodeInfo_t BxOpcodeTable0FB4[] = {
/* 0F B4 /w */ { 0, BX_IA_LFS_GwMp },
/* 0F B4 /d */ { 0, BX_IA_LFS_GdMp },
#if BX_SUPPORT_X86_64
/* 0F B4 /q */ { 0, BX_IA_LFS_GqMp }, // TODO: LFS_GdMp for AMD CPU
#endif
};
// opcode 0F B5
static const BxOpcodeInfo_t BxOpcodeTable0FB5[] = {
/* 0F B5 /w */ { 0, BX_IA_LGS_GwMp },
/* 0F B5 /d */ { 0, BX_IA_LGS_GdMp },
#if BX_SUPPORT_X86_64
/* 0F B5 /q */ { 0, BX_IA_LGS_GqMp }, // TODO: LGS_GdMp for AMD CPU
#endif
};
// opcode 0F B6
static const BxOpcodeInfo_t BxOpcodeTable0FB6[] = {
/* 0F B6 /w */ { 0, BX_IA_MOVZX_GwEb },
/* 0F B6 /d */ { 0, BX_IA_MOVZX_GdEb },
#if BX_SUPPORT_X86_64
/* 0F B6 /q */ { 0, BX_IA_MOVZX_GqEb },
#endif
};
// opcode 0F B7
static const BxOpcodeInfo_t BxOpcodeTable0FB7[] = {
/* 0F B7 /w */ { 0, BX_IA_MOV_GwEw }, // MOVZX_GwEw
/* 0F B7 /d */ { 0, BX_IA_MOVZX_GdEw },
#if BX_SUPPORT_X86_64
/* 0F B7 /q */ { 0, BX_IA_MOVZX_GqEw },
#endif
};
// opcode 0F B8
static const BxOpcodeInfo_t BxOpcodeTable0FB8[] = {
/* 0F B8 /w */ { BxPrefixSSEF3, BX_IA_POPCNT_GwEw },
/* 0F B8 /d */ { BxPrefixSSEF3, BX_IA_POPCNT_GdEd },
#if BX_SUPPORT_X86_64
/* 0F B8 /q */ { BxPrefixSSEF3, BX_IA_POPCNT_GqEq },
#endif
};
// opcode 0F B9
static const BxOpcodeInfo_t BxOpcodeTable0FB9[] = {
/* 0F B9 /w */ { 0, BX_IA_UD1 },
/* 0F B9 /d */ { 0, BX_IA_UD1 },
#if BX_SUPPORT_X86_64
/* 0F B9 /q */ { 0, BX_IA_UD1 },
#endif
};
// opcode 0F BA
static const BxOpcodeInfo_t BxOpcodeTable0FBA_G8EvIv[] = {
// osize = 16 bit
/* /0 /w */ { 0, BX_IA_ERROR },
/* /1 /w */ { 0, BX_IA_ERROR },
/* /2 /w */ { 0, BX_IA_ERROR },
/* /3 /w */ { 0, BX_IA_ERROR },
/* /4 /w */ { BxImmediate_Ib, BX_IA_BT_EwIb },
/* /5 /w */ { BxImmediate_Ib, BX_IA_BTS_EwIb },
/* /6 /w */ { BxImmediate_Ib, BX_IA_BTR_EwIb },
/* /7 /w */ { BxImmediate_Ib, BX_IA_BTC_EwIb },
// osize = 32 bit
/* /0 /d */ { 0, BX_IA_ERROR },
/* /1 /d */ { 0, BX_IA_ERROR },
/* /2 /d */ { 0, BX_IA_ERROR },
/* /3 /d */ { 0, BX_IA_ERROR },
/* /4 /d */ { BxImmediate_Ib, BX_IA_BT_EdIb },
/* /5 /d */ { BxImmediate_Ib, BX_IA_BTS_EdIb },
/* /6 /d */ { BxImmediate_Ib, BX_IA_BTR_EdIb },
/* /7 /d */ { BxImmediate_Ib, BX_IA_BTC_EdIb },
#if BX_SUPPORT_X86_64
// osize = 64 bit
/* /0 /q */ { 0, BX_IA_ERROR },
/* /1 /q */ { 0, BX_IA_ERROR },
/* /2 /q */ { 0, BX_IA_ERROR },
/* /3 /q */ { 0, BX_IA_ERROR },
/* /4 /q */ { BxImmediate_Ib, BX_IA_BT_EqIb },
/* /5 /q */ { BxImmediate_Ib, BX_IA_BTS_EqIb },
/* /6 /q */ { BxImmediate_Ib, BX_IA_BTR_EqIb },
/* /7 /q */ { BxImmediate_Ib, BX_IA_BTC_EqIb },
#endif
};
// opcode 0F BB
static const BxOpcodeInfo_t BxOpcodeTable0FBB[] = {
/* 0F BB /w */ { 0, BX_IA_BTC_EwGw },
/* 0F BB /d */ { 0, BX_IA_BTC_EdGd },
#if BX_SUPPORT_X86_64
/* 0F BB /q */ { 0, BX_IA_BTC_EqGq },
#endif
};
// opcode 0F BC
static const BxOpcodeInfo_t BxOpcodeTable0FBC[] = {
/* 0F BC /w */ { 0, BX_IA_BSF_GwEw },
/* 0F BC /d */ { 0, BX_IA_BSF_GdEd },
#if BX_SUPPORT_X86_64
/* 0F BC /q */ { 0, BX_IA_BSF_GqEq },
#endif
};
static const BxOpcodeInfo_t BxOpcodeTable0FBC_TZCNT[] = {
/* F3 0F BC /w */ { 0, BX_IA_TZCNT_GwEw },
/* F3 0F BC /d */ { 0, BX_IA_TZCNT_GdEd },
#if BX_SUPPORT_X86_64
/* F3 0F BC /q */ { 0, BX_IA_TZCNT_GqEq },
#endif
};
// opcode 0F BD
static const BxOpcodeInfo_t BxOpcodeTable0FBD[] = {
/* 0F BD /w */ { 0, BX_IA_BSR_GwEw },
/* 0F BD /d */ { 0, BX_IA_BSR_GdEd },
#if BX_SUPPORT_X86_64
/* 0F BD /q */ { 0, BX_IA_BSR_GqEq },
#endif
};
static const BxOpcodeInfo_t BxOpcodeTable0FBD_LZCNT[] = {
/* F3 0F BD /w */ { 0, BX_IA_LZCNT_GwEw },
/* F3 0F BD /d */ { 0, BX_IA_LZCNT_GdEd },
#if BX_SUPPORT_X86_64
/* F3 0F BD /q */ { 0, BX_IA_LZCNT_GqEq },
#endif
};
// opcode 0F BE
static const BxOpcodeInfo_t BxOpcodeTable0FBE[] = {
/* 0F BE /w */ { 0, BX_IA_MOVSX_GwEb },
/* 0F BE /d */ { 0, BX_IA_MOVSX_GdEb },
#if BX_SUPPORT_X86_64
/* 0F BE /q */ { 0, BX_IA_MOVSX_GqEb },
#endif
};
// opcode 0F BF
static const BxOpcodeInfo_t BxOpcodeTable0FBF[] = {
/* 0F BF /w */ { 0, BX_IA_MOV_GwEw }, // MOVSX_GwEw
/* 0F BF /d */ { 0, BX_IA_MOVSX_GdEw },
#if BX_SUPPORT_X86_64
/* 0F BF /q */ { 0, BX_IA_MOVSX_GqEw },
#endif
};
// opcode 0F C0
static const BxOpcodeInfo_t BxOpcodeTable0FC0[] = {
/* 0F C0 /w */ { 0, BX_IA_XADD_EbGb },
/* 0F C0 /d */ { 0, BX_IA_XADD_EbGb },
#if BX_SUPPORT_X86_64
/* 0F C0 /q */ { 0, BX_IA_XADD_EbGb },
#endif
};
// opcode 0F C1
static const BxOpcodeInfo_t BxOpcodeTable0FC1[] = {
/* 0F C1 /w */ { 0, BX_IA_XADD_EwGw },
/* 0F C1 /d */ { 0, BX_IA_XADD_EdGd },
#if BX_SUPPORT_X86_64
/* 0F C1 /q */ { 0, BX_IA_XADD_EqGq },
#endif
};
// opcode 0F C2
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FC2[4] = {
/* -- */ { BxImmediate_Ib, BX_IA_CMPPS_VpsWpsIb },
/* 66 */ { BxImmediate_Ib, BX_IA_CMPPD_VpdWpdIb },
/* F3 */ { BxImmediate_Ib, BX_IA_CMPSS_VssWssIb },
/* F2 */ { BxImmediate_Ib, BX_IA_CMPSD_VsdWsdIb },
};
// opcode 0F C3
static const BxOpcodeInfo_t BxOpcodeTable0FC3_32[] = {
/* 0F C3 /w */ { BxNoPrefixSSE, BX_IA_MOVNTI_Op32_MdGd },
/* 0F C3 /d */ { BxNoPrefixSSE, BX_IA_MOVNTI_Op32_MdGd },
};
#if BX_SUPPORT_X86_64
static const BxOpcodeInfo_t BxOpcodeTable0FC3_64[] = {
/* 0F C3 /w */ { BxNoPrefixSSE, BX_IA_MOVNTI_Op64_MdGd },
/* 0F C3 /d */ { BxNoPrefixSSE, BX_IA_MOVNTI_Op64_MdGd },
/* 0F C3 /q */ { BxNoPrefixSSE, BX_IA_MOVNTI_MqGq },
};
#endif
// opcode 0F C4
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FC4[4] = {
/* -- */ { BxImmediate_Ib, BX_IA_PINSRW_PqEwIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PINSRW_VdqEwIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F C5
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FC5[4] = {
/* -- */ { BxImmediate_Ib, BX_IA_PEXTRW_GdNqIb },
/* 66 */ { BxImmediate_Ib, BX_IA_PEXTRW_GdUdqIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F C6
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FC6[4] = {
/* -- */ { BxImmediate_Ib, BX_IA_SHUFPS_VpsWpsIb },
/* 66 */ { BxImmediate_Ib, BX_IA_SHUFPD_VpdWpdIb },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F C7 - handled through separate decode method
// opcode 0F C8 - 0F CF
static const BxOpcodeInfo_t BxOpcodeTable0FC8x0FCF[] = {
/* 0F C8 /w */ { 0, BX_IA_BSWAP_RX },
/* 0F C8 /d */ { 0, BX_IA_BSWAP_ERX },
#if BX_SUPPORT_X86_64
/* 0F C8 /q */ { 0, BX_IA_BSWAP_RRX },
#endif
};
// opcode 0F D0
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD0[4] = {
/* -- */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ADDSUBPD_VpdWpd },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ADDSUBPS_VpsWps },
};
// opcode 0F D1
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD1[4] = {
/* -- */ { 0, BX_IA_PSRLW_PqQq },
/* 66 */ { 0, BX_IA_PSRLW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F D2
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD2[4] = {
/* -- */ { 0, BX_IA_PSRLD_PqQq },
/* 66 */ { 0, BX_IA_PSRLD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F D3
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD3[4] = {
/* -- */ { 0, BX_IA_PSRLQ_PqQq },
/* 66 */ { 0, BX_IA_PSRLQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F D4
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD4[4] = {
/* -- */ { 0, BX_IA_PADDQ_PqQq },
/* 66 */ { 0, BX_IA_PADDQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F D5
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD5[4] = {
/* -- */ { 0, BX_IA_PMULLW_PqQq },
/* 66 */ { 0, BX_IA_PMULLW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F D6
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD6[4] = {
/* -- */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_MOVQ_WqVq },
/* F3 */ { 0, BX_IA_MOVQ2DQ_VdqQq },
/* F2 */ { 0, BX_IA_MOVDQ2Q_PqUdq },
};
// opcode 0F D7
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD7[4] = {
/* -- */ { 0, BX_IA_PMOVMSKB_GdNq },
/* 66 */ { 0, BX_IA_PMOVMSKB_GdUdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F D8
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD8[4] = {
/* -- */ { 0, BX_IA_PSUBUSB_PqQq },
/* 66 */ { 0, BX_IA_PSUBUSB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F D9
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FD9[4] = {
/* -- */ { 0, BX_IA_PSUBUSW_PqQq },
/* 66 */ { 0, BX_IA_PSUBUSW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F DA
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FDA[4] = {
/* -- */ { 0, BX_IA_PMINUB_PqQq },
/* 66 */ { 0, BX_IA_PMINUB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F DB
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FDB[4] = {
/* -- */ { 0, BX_IA_PAND_PqQq },
/* 66 */ { 0, BX_IA_PAND_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F DC
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FDC[4] = {
/* -- */ { 0, BX_IA_PADDUSB_PqQq },
/* 66 */ { 0, BX_IA_PADDUSB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F DD
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FDD[4] = {
/* -- */ { 0, BX_IA_PADDUSW_PqQq },
/* 66 */ { 0, BX_IA_PADDUSW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F DE
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FDE[4] = {
/* -- */ { 0, BX_IA_PMAXUB_PqQq },
/* 66 */ { 0, BX_IA_PMAXUB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F DF
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FDF[4] = {
/* -- */ { 0, BX_IA_PANDN_PqQq },
/* 66 */ { 0, BX_IA_PANDN_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E0
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE0[4] = {
/* -- */ { 0, BX_IA_PAVGB_PqQq },
/* 66 */ { 0, BX_IA_PAVGB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E1
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE1[4] = {
/* -- */ { 0, BX_IA_PSRAW_PqQq },
/* 66 */ { 0, BX_IA_PSRAW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E2
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE2[4] = {
/* -- */ { 0, BX_IA_PSRAD_PqQq },
/* 66 */ { 0, BX_IA_PSRAD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E3
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE3[4] = {
/* -- */ { 0, BX_IA_PAVGW_PqQq },
/* 66 */ { 0, BX_IA_PAVGW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E4
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE4[4] = {
/* -- */ { 0, BX_IA_PMULHUW_PqQq },
/* 66 */ { 0, BX_IA_PMULHUW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E5
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE5[4] = {
/* -- */ { 0, BX_IA_PMULHW_PqQq },
/* 66 */ { 0, BX_IA_PMULHW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E6
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE6[4] = {
/* -- */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_CVTTPD2DQ_VqWpd },
/* F3 */ { 0, BX_IA_CVTDQ2PD_VpdWq },
/* F2 */ { 0, BX_IA_CVTPD2DQ_VqWpd },
};
// opcode 0F E7
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE7[4] = {
/* -- */ { 0, BX_IA_MOVNTQ_MqPq },
/* 66 */ { 0, BX_IA_MOVNTDQ_MdqVdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E8
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE8[4] = {
/* -- */ { 0, BX_IA_PSUBSB_PqQq },
/* 66 */ { 0, BX_IA_PSUBSB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F E9
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FE9[4] = {
/* -- */ { 0, BX_IA_PSUBSW_PqQq },
/* 66 */ { 0, BX_IA_PSUBSW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F EA
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FEA[4] = {
/* -- */ { 0, BX_IA_PMINSW_PqQq },
/* 66 */ { 0, BX_IA_PMINSW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F EB
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FEB[4] = {
/* -- */ { 0, BX_IA_POR_PqQq },
/* 66 */ { 0, BX_IA_POR_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F EC
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FEC[4] = {
/* -- */ { 0, BX_IA_PADDSB_PqQq },
/* 66 */ { 0, BX_IA_PADDSB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F ED
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FED[4] = {
/* -- */ { 0, BX_IA_PADDSW_PqQq },
/* 66 */ { 0, BX_IA_PADDSW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F EE
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FEE[4] = {
/* -- */ { 0, BX_IA_PMAXSW_PqQq },
/* 66 */ { 0, BX_IA_PMAXSW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F EF
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FEF[4] = {
/* -- */ { 0, BX_IA_PXOR_PqQq },
/* 66 */ { 0, BX_IA_PXOR_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F0
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF0[4] = {
/* -- */ { 0, BX_IA_ERROR },
/* 66 */ { 0, BX_IA_ERROR },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_LDDQU_VdqMdq },
};
// opcode 0F F1
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF1[4] = {
/* -- */ { 0, BX_IA_PSLLW_PqQq },
/* 66 */ { 0, BX_IA_PSLLW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F2
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF2[4] = {
/* -- */ { 0, BX_IA_PSLLD_PqQq },
/* 66 */ { 0, BX_IA_PSLLD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F3
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF3[4] = {
/* -- */ { 0, BX_IA_PSLLQ_PqQq },
/* 66 */ { 0, BX_IA_PSLLQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F4
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF4[4] = {
/* -- */ { 0, BX_IA_PMULUDQ_PqQq },
/* 66 */ { 0, BX_IA_PMULUDQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F5
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF5[4] = {
/* -- */ { 0, BX_IA_PMADDWD_PqQq },
/* 66 */ { 0, BX_IA_PMADDWD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F6
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF6[4] = {
/* -- */ { 0, BX_IA_PSADBW_PqQq },
/* 66 */ { 0, BX_IA_PSADBW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F7
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF7[4] = {
/* -- */ { 0, BX_IA_MASKMOVQ_PqNq },
/* 66 */ { 0, BX_IA_MASKMOVDQU_VdqUdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F8
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF8[4] = {
/* -- */ { 0, BX_IA_PSUBB_PqQq },
/* 66 */ { 0, BX_IA_PSUBB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F F9
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FF9[4] = {
/* -- */ { 0, BX_IA_PSUBW_PqQq },
/* 66 */ { 0, BX_IA_PSUBW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F FA
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FFA[4] = {
/* -- */ { 0, BX_IA_PSUBD_PqQq },
/* 66 */ { 0, BX_IA_PSUBD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F FB
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FFB[4] = {
/* -- */ { 0, BX_IA_PSUBQ_PqQq },
/* 66 */ { 0, BX_IA_PSUBQ_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F FC
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FFC[4] = {
/* -- */ { 0, BX_IA_PADDB_PqQq },
/* 66 */ { 0, BX_IA_PADDB_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F FD
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FFD[4] = {
/* -- */ { 0, BX_IA_PADDW_PqQq },
/* 66 */ { 0, BX_IA_PADDW_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F FE
static const BxOpcodeInfo_t BxOpcodeGroupSSE_0FFE[4] = {
/* -- */ { 0, BX_IA_PADDD_PqQq },
/* 66 */ { 0, BX_IA_PADDD_VdqWdq },
/* F3 */ { 0, BX_IA_ERROR },
/* F2 */ { 0, BX_IA_ERROR },
};
// opcode 0F FF
static const BxOpcodeInfo_t BxOpcodeTable0FFF[] = {
/* 0F FF */ { 0, BX_IA_UD0 },
};
#endif // BX_FETCHDECODE_OPMAP_H
| 28.452055 | 93 | 0.611434 |
be07aa1acb8c1f8c6639a4d8291aa2b5b0de5611 | 1,039 | h | C | packets/play/CBChunkData.h | WorkingRobot/CMine | c4d8b3988487c7dc480b0f252cba1eab53555bb7 | [
"MIT"
] | 3 | 2021-05-20T15:21:39.000Z | 2021-06-23T18:08:41.000Z | packets/play/CBChunkData.h | WorkingRobot/CMine | c4d8b3988487c7dc480b0f252cba1eab53555bb7 | [
"MIT"
] | null | null | null | packets/play/CBChunkData.h | WorkingRobot/CMine | c4d8b3988487c7dc480b0f252cba1eab53555bb7 | [
"MIT"
] | 1 | 2021-05-27T08:54:54.000Z | 2021-05-27T08:54:54.000Z | #pragma once
#include "../types/SocketPrimitives.h"
struct CBChunkData {
static const int Id = 0x22;
SocketInt ChunkX;
SocketInt ChunkZ;
SocketBool FullChunk;
SocketVarInt Bitmask;
SocketNBT Heightmaps;
std::optional<std::vector<SocketInt>> Biomes;
SocketString Data; // byte array with varint before it
std::vector<SocketNBT> BlockEntities;
friend SocketOStream& operator<<(SocketOStream& sock, const CBChunkData& out) {
sock
<< out.ChunkX << out.ChunkZ
<< out.FullChunk
<< out.Bitmask
<< out.Heightmaps;
if (out.FullChunk) {
sock << SocketVarInt(out.Biomes.value().size()); // unsure if this is added, wiki.vg states it's always 1024
for (auto& biome : out.Biomes.value()) {
sock << biome;
}
}
sock << out.Data;
sock << SocketVarInt(out.BlockEntities.size());
for (auto& block : out.BlockEntities) {
sock << block;
}
}
}; | 29.685714 | 120 | 0.580366 |
8a103be6dbd0b7b2f80b58b6c82683c8581ab194 | 2,138 | c | C | criu/test/zdtm/static/tempfs.c | depaul-dice/provenance-to-use | e16e2824fbbe0b4e09cc50f0d2bcec3400bf4b87 | [
"BSD-3-Clause"
] | null | null | null | criu/test/zdtm/static/tempfs.c | depaul-dice/provenance-to-use | e16e2824fbbe0b4e09cc50f0d2bcec3400bf4b87 | [
"BSD-3-Clause"
] | null | null | null | criu/test/zdtm/static/tempfs.c | depaul-dice/provenance-to-use | e16e2824fbbe0b4e09cc50f0d2bcec3400bf4b87 | [
"BSD-3-Clause"
] | null | null | null | #include <stdbool.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <linux/limits.h>
#include "zdtmtst.h"
const char *test_doc = "Check tmpfs mount";
const char *test_author = "Pavel Emelianov <xemul@parallels.com>";
char *dirname;
TEST_OPTION(dirname, string, "directory name", 1);
#define TEST_WORD "testtest"
#define TEST_WORD2 "TESTTEST"
int main(int argc, char **argv)
{
int fd, fdo, ret = 1;
char buf[1024], fname[PATH_MAX], overmount[PATH_MAX];
test_init(argc, argv);
mkdir(dirname, 0700);
if (mount("none", dirname, "tmpfs", 0, "") < 0) {
fail("Can't mount tmpfs");
return 1;
}
ssprintf(fname, "%s/test.file", dirname);
fdo = open(fname, O_RDWR | O_CREAT, 0644);
if (fdo < 0) {
pr_perror("open failed");
goto err;
}
if (write(fdo, TEST_WORD, sizeof(TEST_WORD)) != sizeof(TEST_WORD)) {
pr_perror("write() failed");
goto err;
}
ssprintf(overmount, "%s/test", dirname);
mkdir(overmount, 0700);
ssprintf(fname, "%s/test.file", overmount);
fd = open(fname, O_RDWR | O_CREAT, 0644);
if (fd < 0) {
pr_perror("open failed");
goto err;
}
if (write(fd, TEST_WORD2, sizeof(TEST_WORD2)) != sizeof(TEST_WORD2)) {
pr_perror("write() failed");
goto err;
}
close(fd);
if (mount("none", overmount, "tmpfs", 0, "") < 0) {
fail("Can't mount tmpfs");
goto err;
}
test_daemon();
test_waitsig();
if (umount(overmount) < 0) {
fail("Can't mount tmpfs");
goto err;
}
lseek(fdo, 0, SEEK_SET);
buf[sizeof(TEST_WORD) + 1] = '\0';
if (read(fdo, buf, sizeof(TEST_WORD)) != sizeof(TEST_WORD)) {
fail("Read failed");
goto err;
}
close(fdo);
if (strcmp(buf, TEST_WORD)) {
fail("File corrupted");
goto err;
}
fd = open(fname, O_RDONLY);
if (fd < 0) {
pr_perror("open failed");
goto err;
}
buf[sizeof(TEST_WORD2) + 1] = '\0';
if (read(fd, buf, sizeof(TEST_WORD2)) != sizeof(TEST_WORD2)) {
fail("Read failed");
goto err;
}
close(fd);
if (strcmp(buf, TEST_WORD2)) {
fail("File corrupted");
goto err;
}
pass();
ret = 0;
err:
umount2(dirname, MNT_DETACH);
rmdir(dirname);
return ret;
}
| 19.089286 | 71 | 0.635641 |
5c244a3a101b1a7c41c447a3e389630ee99faaa5 | 247 | c | C | libc/pthread/pthread_exit.c | MSathieu/OS | 7b91d9ebf2acbfeee09dd8736089c449b0a5746e | [
"Unlicense"
] | null | null | null | libc/pthread/pthread_exit.c | MSathieu/OS | 7b91d9ebf2acbfeee09dd8736089c449b0a5746e | [
"Unlicense"
] | null | null | null | libc/pthread/pthread_exit.c | MSathieu/OS | 7b91d9ebf2acbfeee09dd8736089c449b0a5746e | [
"Unlicense"
] | null | null | null | #include <__/rpmalloc.h>
#include <__/syscall.h>
#include <stdbool.h>
// TODO: Free thread
_Noreturn void pthread_exit(void* value) {
rpmalloc_thread_finalize(1);
_syscall(_SYSCALL_EXIT, (uintptr_t) value, 0, 0, 0, 0);
while (true) {
}
}
| 20.583333 | 57 | 0.692308 |
a80fb45537ffff871c6c0e6481dca8b9473dd76a | 1,158 | h | C | projects/compass/src/util/C-API/C-API.h | maurizioabba/rose | 7597292cf14da292bdb9a4ef573001b6c5b9b6c0 | [
"BSD-3-Clause"
] | 488 | 2015-01-09T08:54:48.000Z | 2022-03-30T07:15:46.000Z | projects/compass/src/util/C-API/C-API.h | sujankh/rose-matlab | 7435d4fa1941826c784ba97296c0ec55fa7d7c7e | [
"BSD-3-Clause"
] | 174 | 2015-01-28T18:41:32.000Z | 2022-03-31T16:51:05.000Z | projects/compass/src/util/C-API/C-API.h | sujankh/rose-matlab | 7435d4fa1941826c784ba97296c0ec55fa7d7c7e | [
"BSD-3-Clause"
] | 146 | 2015-04-27T02:48:34.000Z | 2022-03-04T07:32:53.000Z | // -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
/**
* \file C-API.h
* \brief Declares utility functions for describing a C-based API.
*/
#if !defined (INC_C_API_H)
#define INC_C_API_H //!< C-API.h included.
#include <map>
#include <string>
#include <istream>
#include <C-API/SigBase.h>
#include <C-API/FuncSig.h>
#include <C-API/ConstSig.h>
#include <C-API/TypeSig.h>
namespace C_API
{
//! Defines a name-to-signature look-up table.
typedef std::map<std::string, SigBase *> SigMap_t;
/*!
* \brief Reads signature maps from a file.
* \returns 'true' on success, and populates 'sigs' with valid
* signatures.
*
* The input file should be a sequence of lines, where each line is
* one of:
*
* <CONST> name-of-constant
* <TYPE> name-of-type
* <SIG> name-of-function name-of-arg-1 name-of-arg-2 ... name-of-arg-n
*
* Blank lines or lines beginning with '#' are ignored. Leaves the
* file-pointer at the end of the file on return.
*
* \pre 'sigs' is not NULL.
*/
bool readSigs (std::istream& infile, SigMap_t* sigs);
}
#endif // !defined (INC_C_API_H)
// eof
| 24.638298 | 80 | 0.634715 |
69d34b279866757875e42b5eb200388e86c5ea3f | 562 | h | C | src/lib/Core/Utils.h | vinhig/selfmake | 5159b532aff3744f655c7374f0c18b334b4f5070 | [
"MIT"
] | 11 | 2021-04-19T14:48:09.000Z | 2022-03-11T18:52:06.000Z | src/lib/Core/Utils.h | vinhig/selfmake | 5159b532aff3744f655c7374f0c18b334b4f5070 | [
"MIT"
] | 1 | 2022-03-10T00:01:29.000Z | 2022-03-10T00:08:28.000Z | src/lib/Core/Utils.h | vinhig/selfmake | 5159b532aff3744f655c7374f0c18b334b4f5070 | [
"MIT"
] | 3 | 2021-09-20T10:28:20.000Z | 2021-12-26T19:48:00.000Z | #ifndef SM_UTILS_H
#define SM_UTILS_H
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/**
* selfmake - Script Language
* Copyright (C) 2021 The selfmake Authors
* Published under MIT
*/
#include "../Common/Result.h"
#include "../Common/Types.h"
#include <stddef.h>
#endif
/** @addtogroup selfmakeFunctions
* @{
*/
const SM_BYTE *sm_getHomeDir(
);
SM_RESULT sm_createDir(
SM_BYTE *path_p
);
SM_RESULT sm_removeDir(
SM_BYTE *path_p
);
SM_BOOL sm_canRunCommand(
const SM_BYTE *cmd
);
/** @} */
#endif
| 13.707317 | 42 | 0.629893 |
6db596e0d78519eb954df9e95b8042c0e06d9511 | 1,239 | h | C | include/drivers/arm/cryptocell/secureboot_base_func.h | prashanthkk/imx-atf | e57efc67daf604d7ecd5b89cbfdc5df37472562f | [
"BSD-3-Clause"
] | 1,408 | 2015-01-26T17:15:15.000Z | 2022-03-31T12:54:11.000Z | include/drivers/arm/cryptocell/secureboot_base_func.h | prashanthkk/imx-atf | e57efc67daf604d7ecd5b89cbfdc5df37472562f | [
"BSD-3-Clause"
] | 1,177 | 2015-01-07T12:55:46.000Z | 2022-01-19T10:49:12.000Z | include/drivers/arm/cryptocell/secureboot_base_func.h | prashanthkk/imx-atf | e57efc67daf604d7ecd5b89cbfdc5df37472562f | [
"BSD-3-Clause"
] | 959 | 2015-01-08T09:12:45.000Z | 2022-03-28T03:07:50.000Z | /*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _SECURE_BOOT_BASE_FUNC_H
#define _SECURE_BOOT_BASE_FUNC_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "cc_pal_types.h"
#include "secureboot_gen_defs.h"
/*----------------------------
PUBLIC FUNCTIONS
-----------------------------------*/
/**
* @brief This function calculates the HASH over the given data and than verify
* RSA signature on that hashed data
*
* @param[in] hwBaseAddr - CryptoCell base address
* @param[in] pData - pointer to the data to be verified
* @param[in] pNParams - a pointer to the public key parameters
* @param[in] pSignature - a pointer to the signature structure
* @param[in] sizeOfData - size of the data to calculate the HASH on (in bytes)
* @param[in] RSAAlg - RSA algorithm to use
*
* @return CCError_t - On success the value CC_OK is returned,
* on failure - a value from BootImagesVerifier_error.h
*/
CCError_t CCSbVerifySignature(unsigned long hwBaseAddress,
uint32_t *pData,
CCSbNParams_t *pNParams,
CCSbSignature_t *pSignature,
uint32_t sizeOfData,
CCSbRsaAlg_t RSAAlg);
#ifdef __cplusplus
}
#endif
#endif
| 24.78 | 79 | 0.688458 |
ef217af2aee4d822e18e22501d370d74f6197fd6 | 19,173 | c | C | src/main.c | rahscs/sct | f5ad273fe1da8f42c4eff68b647c2fedea83e83b | [
"Unlicense"
] | null | null | null | src/main.c | rahscs/sct | f5ad273fe1da8f42c4eff68b647c2fedea83e83b | [
"Unlicense"
] | null | null | null | src/main.c | rahscs/sct | f5ad273fe1da8f42c4eff68b647c2fedea83e83b | [
"Unlicense"
] | null | null | null | /**
* SCT Sciences Creamy Text Editor(c) 2016 Jeron Lau RAHS Computer Science Club.
* LICENSED UNDER THE UNLICENSE
**/
#include <stdio.h> // For using printf()
#include <string.h> // For using strlen()
#include <stdlib.h> // For exit()
#include "sct.h"
#define UNTITLED "UN-TITLED"
#define KEYWORD_COUNT 55
typedef struct {
WINDOW *w;
int8_t cursorx, cursory;
int8_t selectx, selecty;
uint8_t lh;
chunk_t kw[KEYWORD_COUNT];
} sct_context_t;
static textlist_t* init_textlist(void) {
textlist_t* rtn = malloc(sizeof(textlist_t));
rtn->prev = NULL;
memset(rtn->text, '\0', 81);
rtn->next = NULL;
rtn->tabs = 0;
return rtn;
}
void textlist_insert(textlist_t* afterwhat) {
textlist_t* new_next = afterwhat->next;
textlist_t* new_item = malloc(sizeof(textlist_t));
// Sandwich
afterwhat->next = new_item;
if(new_next) new_next->prev = new_item;
// Set item
new_item->prev = afterwhat;
new_item->next = new_next;
memset(new_item->text, '\0', 81);
new_item->tabs = 0;
}
static textlist_t* textlist_delete(textlist_t* deletewhat) {
textlist_t* next_item = deletewhat->next;
next_item->prev = NULL;
free(deletewhat);
return next_item;
}
static textlist_t* sct_nextline(sct_context_t* context, textlist_t* line,
textlist_t** text, int8_t* y, uint32_t* sln)
{
if(*y == context->lh - 1) {
*sln = *sln + 1;
*text = (*text)->next;
return line->next;
}
*y = *y + 1;
return line->next;
}
static textlist_t* sct_prevline(textlist_t* line, textlist_t** text, int8_t* y,
uint32_t* sln)
{
if(*y == 0) {
if(*sln) {
*sln = *sln - 1;
*text = (*text)->prev;
return line->prev;
}
return line;
}
*y = *y - 1;
return line->prev;
}
static void sct_exit(uint8_t* running, const char* message) {
*running = 0;
endwin();
}
static void sct_draw(sct_context_t* context, textlist_t* text, textlist_t* line,
uint32_t sln)
{
int i;
uint8_t infile = 1;
for(i = 0; i < context->lh; i++) {
if(infile) {
for(int j = 0; j < text->tabs; j++) {
mvprintw(i + 1, (j+1) * 8, " ");
}
attron(A_DIM);
mvprintw(i + 1, 0, "%5d | ", sln + i + 1);
attroff(A_DIM);
mvprintw(i + 1, 8 + text->tabs * 8, "%s\n", text->text);
sct_chunk(context->w, text->text, context->kw,
KEYWORD_COUNT, i + 1, text->tabs);
if(text->next) {
text = text->next;
}else{
infile = 0;
}
}else{
attron(A_DIM);
mvprintw(i + 1, 0, " |\n");
attroff(A_DIM);
}
}
wmove(context->w, 1 + context->cursory, 8 + context->cursorx + (line->tabs * 8));
if(context->selecty)
chgat(79, A_REVERSE, 0, NULL);
else
chgat(context->selectx ? context->selectx : 1, A_REVERSE, 0, NULL);
refresh();
}
/*static void sct_rendermultiselect(WINDOW* w, textlist_t text, int8_t* x, int8_t* y,
int8_t* lx, int8_t* ly)
{
wmove(w, 1 + *y, *x + (line->tabs * 8));
chgat(1, A_REVERSE, 0, NULL);
refresh();
}*/
static void sct_renderlineselect(sct_context_t* context, textlist_t* line, int8_t x,
int8_t y, int8_t lx)
{
wmove(context->w, 1 + y, x + (line->tabs * 8));
chgat(lx - x, A_REVERSE, 0, NULL);
refresh();
}
void sct_insert(sct_context_t* context, textlist_t* text, textlist_t* line,
int8_t* x, int8_t* y, char c, uint32_t sln)
{
uint8_t max = 79 - (line->tabs * 8);
if(*x > max) *x = max;
if(strlen(line->text) >= max) return;
memmove(line->text + *x + 1, line->text + *x, strlen(line->text + *x) + 1);
line->text[*x] = c;
*x = *x + 1;
sct_draw(context, text, line, sln);
}
static int8_t sct_mouseinputx(textlist_t* line, int8_t x) {
int rx = x - ((line->tabs + 1)* 8);
if(rx < 0) rx = 0;
if(rx > strlen(line->text)) rx = strlen(line->text);
if(x > 79) x = 79;
return rx;
}
static int8_t sct_mouseinputy(int8_t y) {
int ry = y - 1;
if(ry < 0) ry = 0;
return ry;
}
static textlist_t* sct_cursorup(sct_context_t* context, textlist_t** text,
textlist_t* line, uint32_t* sln)
{
if(line->prev) {
line = sct_prevline(line, text, &context->cursory, sln);
context->cursorx = strlen(line->text);
sct_draw(context, *text, line, *sln);
}
return line;
}
static textlist_t* sct_cursordn(sct_context_t* context, textlist_t** text,
textlist_t* line, uint32_t* sln, uint8_t end)
{
if(line->next) {
line = sct_nextline(context, line, text, &context->cursory, sln);
context->cursorx = end ? strlen(line->text) : 0;
sct_draw(context, *text, line, *sln);
}
return line;
}
static textlist_t* sct_backspace(sct_context_t* context, textlist_t** text,
textlist_t* line, uint32_t* sln)
{
textlist_t* prev_item = line->prev;
textlist_t* next_item = line->next;
if(next_item) next_item->prev = prev_item;
prev_item->next = next_item;
free(line);
// Scroll Up if Needed
if(*sln) {
int end;
textlist_t* temp = *text;
for(int i = 0; i < context->lh; i++) {
temp = temp->next;
if(temp == NULL && (*text)->prev) {
*sln = *sln - 1;
context->cursory++;
*text = (*text)->prev;
break;
}
}
}
if(next_item) {
return next_item;
}else{
sct_cursorup(context, text, line, sln);
return prev_item;
}
}
static void sct_title(int32_t w, int32_t h, const char* f, uint8_t s) {
attron(A_BOLD | COLOR_PAIR(1));
mvprintw(0,0,"Science's Creamy Text Editor - SCT %03dx%03d %45s",w,h,f);
if(!s) mvprintw(0,86 - strlen(f), "*");
attroff(A_BOLD | COLOR_PAIR(1));
}
static void sct_notify(sct_context_t* context, const char* message) {
attron(A_DIM);
mvprintw(1 + context->lh, 0, "|-----|");
attroff(A_DIM);
attron(A_BOLD | COLOR_PAIR(1));
mvprintw(1 + context->lh, 8, "%80s", message);
attroff(A_BOLD | COLOR_PAIR(1));
}
static uint8_t sct_popup(sct_context_t* context, const char* message, char input[]) {
uint8_t cancel = 0;
memset(input, '\0', strlen(input));
mvprintw(2,14," ");
mvprintw(3,14," ____________________________________________________ ");
mvprintw(4,14," |%50s| ", message);
mvprintw(5,14," |__________________________________________________| ");
mvprintw(6,14," | >: | ");
mvprintw(7,14," |__________________________________________________| ");
mvprintw(8,14," ");
mvprintw(6,20,"%s", input);
while(1) {
int in = getch();
const char* key = keyname(in);
if(in == ERR) continue;
if(strcmp(key, "KEY_BACKSPACE") == 0) {
input[strlen(input) - 1] = '\0';
}else if(strcmp(key, "^J") == 0) {
cancel = 0;
break;
}else if(strlen(key) == 1) {
if(strlen(input) > 44) continue;
input[strlen(input)] = key[0];
input[strlen(input) + 1] = '\0';
}else{
sct_notify(context, "Canceled.");
cancel = 1;
memcpy(input, UNTITLED, strlen(UNTITLED) + 1);
break;
}
mvprintw(6, 20, "%s ", input);
}
return cancel;
}
static void
addkeyword(sct_context_t* context, uint8_t i, const char* name, uint8_t color) {
memcpy(context->kw[i].chunk, name, strlen(name) + 1);
context->kw[i].color = color;
}
// Main function.
int main(int argc, char *argv[]) {
sct_context_t context;
context.w = initscr();
context.cursorx = 0;
context.cursory = 0;
context.selectx = 0;
context.selecty = 0;
context.lh = 10;
// Variable to store character name in.
textlist_t* text = init_textlist();
textlist_t* line = text;
uint8_t running = 1;
uint8_t mouseHeldDown = 0;
char filename[1024];
uint32_t sln = 0; // Starting Line Number
int16_t width = getmaxx(context.w);
int16_t height = getmaxy(context.w);
uint8_t saved = 1;
context.lh = height - 2;
// Variable Types Syntax Highlighting
addkeyword(&context, 0, "void", 3);
addkeyword(&context, 1, "uint8_t", 3);
addkeyword(&context, 2, "uint16_t", 3);
addkeyword(&context, 3, "uint32_t", 3);
addkeyword(&context, 4, "uint64_t", 3);
addkeyword(&context, 5, "int8_t", 3);
addkeyword(&context, 6, "int16_t", 3);
addkeyword(&context, 7, "int32_t", 3);
addkeyword(&context, 8, "int64_t", 3);
addkeyword(&context, 9, "int", 3);
addkeyword(&context, 10, "short", 3);
addkeyword(&context, 11, "char", 3);
addkeyword(&context, 12, "long", 3);
addkeyword(&context, 13, "static", 3);
addkeyword(&context, 14, "inline", 3);
addkeyword(&context, 15, "const", 3);
// Functionality
addkeyword(&context, 16, "break", 1);
addkeyword(&context, 17, "return", 1);
addkeyword(&context, 18, "typedef", 1);
addkeyword(&context, 19, "struct", 1);
addkeyword(&context, 20, "if", 1);
addkeyword(&context, 21, "else", 1);
addkeyword(&context, 22, "switch", 1);
addkeyword(&context, 23, "while", 1);
addkeyword(&context, 24, "for", 1);
addkeyword(&context, 25, "case", 1);
addkeyword(&context, 26, "default", 1);
addkeyword(&context, 27, "sizeof", 1);
// Macro
addkeyword(&context, 28, "#include", 7);
addkeyword(&context, 29, "#define", 7);
addkeyword(&context, 30, "#undef", 7);
addkeyword(&context, 31, "#ifdef", 7);
addkeyword(&context, 32, "#endif", 7);
// Constants
addkeyword(&context, 33, "NULL", 2);
addkeyword(&context, 34, "true", 2);
addkeyword(&context, 35, "false", 2);
addkeyword(&context, 36, "TRUE", 2);
addkeyword(&context, 37, "FALSE", 2);
addkeyword(&context, 38, "INFINITY", 2);
// Comments
addkeyword(&context, 39, "//", 5);
// Standard Functions:
addkeyword(&context, 40, "realloc", 4 + 7);
addkeyword(&context, 41, "malloc", 4 + 7);
addkeyword(&context, 42, "free", 4 + 7);
addkeyword(&context, 43, "memcpy", 4 + 7);
addkeyword(&context, 44, "memmove", 4 + 7);
addkeyword(&context, 45, "memset", 4 + 7);
addkeyword(&context, 46, "strcmp", 4 + 7);
addkeyword(&context, 47, "strncmp", 4 + 7);
addkeyword(&context, 48, "printf", 4 + 7);
addkeyword(&context, 49, "scanf", 4 + 7);
addkeyword(&context, 50, "exit", 4 + 7);
addkeyword(&context, 51, "nanosleep", 4 + 7);
addkeyword(&context, 52, "sleep", 4 + 7);
addkeyword(&context, 53, "strlen", 4 + 7);
addkeyword(&context, 54, "strcat", 4 + 7);
memset(filename, 0, 1024);
if(argc == 2) {
memcpy(filename, argv[1], strlen(argv[1]));
sct_file_load(filename, text);
}else{
memcpy(filename, UNTITLED, strlen(UNTITLED));
}
cbreak();
noecho();
nodelay(context.w, TRUE);
keypad(context.w, TRUE);
meta(context.w, TRUE);
nodelay(context.w, TRUE);
curs_set(FALSE);
raw();
mousemask(ALL_MOUSE_EVENTS, NULL);
// Colors
start_color();
init_color(COLOR_BLACK, 0, 0, 0);
/* init_color(COLOR_WHITE, 1000, 1000, 1000);
init_color(COLOR_RED, 1000, 0, 0);
init_color(COLOR_GREEN, 0, 1000, 0);
init_color(COLOR_BLUE, 0, 0, 1000);
init_color(COLOR_YELLOW, 0, 1000, 0);
init_color(COLOR_CYAN, 0, 1000, 1000);
init_color(COLOR_MAGENTA, 1000, 1000, 0);*/
init_pair(1, COLOR_WHITE, COLOR_BLACK);
init_pair(2, COLOR_RED, COLOR_BLACK);
init_pair(3, COLOR_GREEN, COLOR_BLACK);
init_pair(4, COLOR_YELLOW, COLOR_BLACK);
init_pair(5, COLOR_BLUE, COLOR_BLACK);
init_pair(6, COLOR_CYAN, COLOR_BLACK);
init_pair(7, COLOR_MAGENTA, COLOR_BLACK);
sct_title(width, height, filename, saved);
sct_draw(&context, text, line, sln);
sct_notify(&context, "Started Science's Creamy Text Editor!");
while(running) {
int32_t chr = getch();
if(chr != ERR) {
const char* name = keyname(chr);
SCT_DETECT:;
// Close
if(strcmp(name, "^Q") == 0) {
sct_exit(&running, "EXITING ON QUIT");
} else if(strcmp(name, "^W") == 0) {
sct_exit(&running, "EXITING ON FILE CLOSE");
// Clipboard
} else if(strcmp(name, "^C") == 0) {
sct_notify(&context, "Copy.");
} else if(strcmp(name, "^V") == 0) {
sct_notify(&context, "Paste.");
} else if(strcmp(name, "^X") == 0) {
sct_notify(&context, "Cut.");
// Save
}else if(strcmp(name,"^S")==0 || strcmp(name,"^E")==0) {
if(strcmp(filename, UNTITLED) == 0) {
if(sct_popup(&context, "Save As...", filename))
{
sct_draw(&context, text, line, sln);
continue;
}
// Redraw screen
sct_draw(&context, text, line, sln);
}
sct_file_save(filename, text);
saved = 1;
sct_title(width,height,filename,saved);
sct_notify(&context, "Saved file.");
if(strcmp(name, "^E") == 0)
sct_exit(&running, "SAVE & QUIT");
} else if(strcmp(name, "^O") == 0) {
if(sct_popup(&context, "Open What File?", filename)) {
sct_draw(&context, text, line, sln);
continue;
}
while(text->prev != NULL)
text = text->prev;
if(sct_file_load(filename, text)) {
sct_notify(&context, "Failed to open file.");
}else{
sct_notify(&context, "Successfully loaded file.");
}
saved = 1, sln = 0, context.cursorx = 0,
context.cursory = 0,
context.selectx = 0,
context.selecty = 0, line = text;
sct_title(width, height, filename, saved);
// Redraw screen
sct_draw(&context, text, line, sln);
// Functions
} else if(strcmp(name, "KEY_BACKSPACE") == 0) {
context.cursorx--;
if(context.cursorx < 0) {
if(line->tabs > 0) {
line->tabs--;
context.cursorx = 0;
}else if(line->prev != NULL) {
line = sct_backspace(&context,
&text, line, &sln);
context.cursorx = strlen(line->text);
}else{
context.cursorx = 0;
}
}else{
line->text[context.cursorx] = '\0';
if(line->text[context.cursorx + 1])
memmove(line->text +
context.cursorx,
line->text +
context.cursorx +1,
strlen(line->text +
context.cursorx + 1)+1);
}
sct_draw(&context, text, line, sln);
// Changed
if(saved) {
saved = 0;
sct_title(width,height,filename,saved);
}
sct_notify(&context, "Edit.");
} else if(strcmp(name, "KEY_DC") == 0) {
sct_exit(&running, "Delete");
// line = sct_backspace(line->next);
if(saved) {
saved = 0;
sct_title(width,height,filename,saved);
}
sct_notify(&context, "Edit.");
} else if(strcmp(name, "^D") == 0) {
if(line->prev != NULL) {
// Delete non-first line
line = sct_backspace(&context, &text,
line, &sln);
// if(line->next)
// line = line->next;
// else
// sct_cursorup();
context.cursorx = strlen(line->text);
}else if(line->next != NULL) {
// Delete 1st line
text = textlist_delete(line);
line = text;
context.cursorx = 0;
}else{
// Delete last line left
memset(text->text, '\0', 81);
context.cursorx = 0;
}
sct_draw(&context, text, line, sln);
// Changed
if(saved) {
saved = 0;
sct_title(width,height,filename,saved);
}
sct_notify(&context, "Edit.");
} else if(strcmp(name, "^I") == 0) {
// Tab
line->tabs++;
if(line->tabs > 8) line->tabs = 8;
sct_draw(&context, text, line, sln);
// Input
if(saved) {
saved = 0;
sct_title(width,height,filename,saved);
}
sct_notify(&context, "Edit.");
} else if(strcmp(name, "KEY_BTAB") == 0) {
// Shift - Tab
line->tabs--;
if(line->tabs < 0) line->tabs = 0;
sct_draw(&context, text, line, sln);
// Input
if(saved) {
saved = 0;
sct_title(width,height,filename,saved);
}
sct_notify(&context, "Edit.");
} else if(strcmp(name, "^J") == 0) {
// Newline
textlist_insert(line);
line = sct_nextline(&context, line, &text, &context.cursory, &sln);
context.cursorx = 0;
sct_draw(&context, text, line, sln);
// Input
if(saved) {
saved = 0;
sct_title(width,height,filename,saved);
}
sct_notify(&context, "Edit.");
} else if(strcmp(name, "^[") == 0) {
int32_t chrtr;
const char* which = NULL;
sct_notify(&context, "w or s - save, q - quit, e - save &"
" quit, o - open, d - delete line");
while(1) {
chrtr = getch();
which = keyname(chrtr);
if(strlen(which) == 1 && chrtr != ERR)
break;
}
if(which[0] == 'w' || which[0] == 's') {
name = "^S";
goto SCT_DETECT;
}else if(which[0] == 'q') {
name = "^Q";
goto SCT_DETECT;
}else if(which[0] == 'e') {
name = "^E";
goto SCT_DETECT;
}else if(which[0] == 'o') {
name = "^O";
goto SCT_DETECT;
}else if(which[0] == '^') {
continue;
}else if(which[0] == 'd') {
name = "^D";
goto SCT_DETECT;
}else{
sct_notify(&context, "unknown function.");
}
// Alt + other
} else if(strcmp(name, "KEY_UP") == 0) {
line = sct_cursorup(&context, &text, line, &sln);
context.selectx = 0;
} else if(strcmp(name, "KEY_DOWN") == 0) {
line = sct_cursordn(&context, &text, line, &sln, 1);
context.selectx = 0;
} else if(strcmp(name, "KEY_RIGHT") == 0) {
if(context.cursorx >= strlen(line->text)) {
line = sct_cursordn(&context, &text, line, &sln, 0);
}else{
context.cursorx++;
sct_draw(&context, text, line, sln);
}
context.selectx = 0;
context.selecty = 0;
} else if(strcmp(name, "KEY_LEFT") == 0) {
if(context.cursorx <= 0) {
line = sct_cursorup(&context, &text, line, &sln);
}else{
context.cursorx--;
sct_draw(&context, text, line, sln);
}
context.selectx = 0;
context.selecty = 0;
} else if(strcmp(name, "KEY_PPAGE") == 0) {
// Page UP
} else if(strcmp(name, "KEY_NPAGE") == 0) {
// Page DN
} else if(strcmp(name, "KEY_MOUSE") == 0) {
MEVENT event;
getmouse(&event);
if(event.bstate & BUTTON4_PRESSED) {
name = "KEY_UP";
goto SCT_DETECT;
}else if(event.bstate & BUTTON2_PRESSED ||
event.bstate == 0x8000000 ||
event.bstate == 0x0200000)
{
name = "KEY_DOWN";
goto SCT_DETECT;
}
context.cursory = sct_mouseinputy(event.y);
line = text;
for(int i = 0; i < context.cursory; i++) {
if(line->next) {
line = line->next;
}else{
context.cursory = i;
}
}
context.cursorx = sct_mouseinputx(line,event.x);
if(event.bstate==BUTTON1_DOUBLE_CLICKED) {
uint8_t erase = 1;
context.selecty = 0;
// Select Word
while(context.cursorx > 0) {
char c = line->text[context.cursorx];
if(c == ' ' || c == ',') {
erase = 0;
break;
}
context.cursorx--;
}
context.cursorx++;
for(int i = context.cursorx;;i++) {
char c = line->text[i];
if(c == ' ' || c == '\0' ||
c == ',')
{
context.selectx =
i - context.cursorx;
break;
}
}
context.cursorx -= erase;
context.selectx += erase;
}else if(event.bstate==BUTTON1_TRIPLE_CLICKED) {
// Select Line
context.selecty = 1;
context.cursorx = 0;
context.selectx = 0;
}else{
context.selectx = 0;
context.selecty = 0;
}
sct_draw(&context, text, line, sln);
} else if(strcmp(name, "KEY_RESIZE") == 0) {
width = getmaxx(context.w);
height = getmaxy(context.w);
context.lh = height - 2;
sct_title(width, height, filename, saved);
sct_draw(&context, text, line, sln);
sct_notify(&context, "Resized.");
} else {
sct_insert(&context, text, line, &context.cursorx, &context.cursory,
name[0], sln);
if(saved) {
saved = 0;
sct_title(width,height,filename,saved);
}
sct_notify(&context, "Edit.");
// Character Insert
// printf("NAME: %s", name);
}
}
}
endwin();
// Return 0 on success.
return 0;
}
| 26.966245 | 85 | 0.599854 |
d4520924973ef1dfab40fab8046c24b4aa0b5b5b | 6,553 | c | C | bsp/upd70f3454/drivers/uart.c | BreederBai/rt-thread | 53ed0314982556dfa9c5db75d4f3e02485d16ab5 | [
"Apache-2.0"
] | 7,482 | 2015-01-01T09:23:08.000Z | 2022-03-31T19:34:05.000Z | bsp/upd70f3454/drivers/uart.c | ArdaFu/rt-thread | eebb2561ec166e0016187c7b7998ada4f8212b3a | [
"Apache-2.0"
] | 2,543 | 2015-01-09T02:01:34.000Z | 2022-03-31T23:10:14.000Z | bsp/upd70f3454/drivers/uart.c | ArdaFu/rt-thread | eebb2561ec166e0016187c7b7998ada4f8212b3a | [
"Apache-2.0"
] | 4,645 | 2015-01-06T07:05:31.000Z | 2022-03-31T18:21:50.000Z | /*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2010-03-08 Bernard The first version for LPC17xx
* 2010-06-29 lgnq Modified for V850
*/
#include <rthw.h>
#include <rtthread.h>
#include "io70f3454.h"
#include "uart.h"
#if defined(RT_USING_UART0) && defined(RT_USING_DEVICE)
struct rt_uart_v850
{
struct rt_device parent;
/* buffer for reception */
rt_uint8_t read_index, save_index;
rt_uint8_t rx_buffer[RT_UART_RX_BUFFER_SIZE];
}uart_device;
void uarta1_receive_handler(void)
{
rt_ubase_t level;
rt_uint8_t c;
struct rt_uart_v850 *uart = &uart_device;
// while(ri_u0c1 == 0)
// ;
c = (char) UA1RX;
/* Receive Data Available */
uart->rx_buffer[uart->save_index] = c;
level = rt_hw_interrupt_disable();
uart->save_index ++;
if (uart->save_index >= RT_UART_RX_BUFFER_SIZE)
uart->save_index = 0;
rt_hw_interrupt_enable(level);
/* invoke callback */
if (uart->parent.rx_indicate != RT_NULL)
{
rt_size_t length;
if (uart->read_index > uart->save_index)
length = RT_UART_RX_BUFFER_SIZE - uart->read_index + uart->save_index;
else
length = uart->save_index - uart->read_index;
uart->parent.rx_indicate(&uart->parent, length);
}
}
static rt_err_t rt_uart_init (rt_device_t dev)
{
UA1TXE = 0U; /* disable UARTA1 transmission operation */
UA1RXE = 0U; /* disable UARTA1 reception operation */
UA1PWR = 0U; /* disable UARTA1 operation */
UA1TMK = 1U; /* disable INTUA1T interrupt */
UA1TIF = 0U; /* clear INTUA1T interrupt flag */
UA1RMK = 1U; /* disable INTUA1R interrupt */
UA1RIF = 0U; /* clear INTUA1R interrupt flag */
/* Set INTUA1T level low priority */
UA1TIC |= 0x07U;
/* Set INTUA1R level low priority */
UA1RIC |= 0x07U;
//BAUDRATE = 9600
UA1CTL1 = _03_UARTA_BASECLK_FXX_16;
UA1CTL2 = _11_UARTA1_BASECLK_DIVISION;
UA1CTL0 = _10_UARTA_TRANSFDIR_LSB | _00_UARTA_PARITY_NONE | _02_UARTA_DATALENGTH_8BIT | _00_UARTA_STOPLENGTH_1BIT;
UA1OPT0 = _14_UARTA_UAnOPT0_INITIALVALUE | _00_UARTA_TRAN_DATALEVEL_NORMAL | _00_UARTA_REC_DATALEVEL_NORMAL;
UA1PWR = 1U; /* enable UARTA1 operation */
/* Set TXDA1 pin */
/* Set RXDA1 pin */
PFC3_bit.no0 = 0;
PFCE3_bit.no0 = 0;
PMC3_bit.no0 = 1;
PFC3_bit.no1 = 0;
PFCE3_bit.no1 = 0;
PMC3_bit.no1 = 1;
return RT_EOK;
}
static rt_err_t rt_uart_open(rt_device_t dev, rt_uint16_t oflag)
{
RT_ASSERT(dev != RT_NULL);
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
{
/* Enable the UART Interrupt */
UA1TIF = 0U; /* clear INTUA1T interrupt flag */
UA1TMK = 1U; /* disable INTUA1T interrupt */
UA1RIF = 0U; /* clear INTUA1R interrupt flag */
UA1RMK = 0U; /* enable INTUA1R interrupt */
UA1TXE = 1U; /* enable UARTA1 transmission operation */
UA1RXE = 1U; /* enable UARTA1 reception operation */
}
return RT_EOK;
}
static rt_err_t rt_uart_close(rt_device_t dev)
{
RT_ASSERT(dev != RT_NULL);
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
{
/* Disable the UART Interrupt */
UA1TXE = 0U; /* disable UARTA1 transmission operation */
UA1RXE = 0U; /* disable UARTA1 reception operation */
UA1TMK = 1U; /* disable INTUA1T interrupt */
UA1TIF = 0U; /* clear INTUA1T interrupt flag */
UA1RMK = 1U; /* disable INTUA1R interrupt */
UA1RIF = 0U; /* clear INTUA1R interrupt flag */
}
return RT_EOK;
}
static rt_size_t rt_uart_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
{
rt_uint8_t *ptr;
struct rt_uart_v850 *uart = (struct rt_uart_v850 *)dev;
RT_ASSERT(uart != RT_NULL);
/* point to buffer */
ptr = (rt_uint8_t *)buffer;
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
{
while (size)
{
/* interrupt receive */
rt_base_t level;
/* disable interrupt */
level = rt_hw_interrupt_disable();
if (uart->read_index != uart->save_index)
{
*ptr = uart->rx_buffer[uart->read_index];
uart->read_index ++;
if (uart->read_index >= RT_UART_RX_BUFFER_SIZE)
uart->read_index = 0;
}
else
{
/* no data in rx buffer */
/* enable interrupt */
rt_hw_interrupt_enable(level);
break;
}
/* enable interrupt */
rt_hw_interrupt_enable(level);
ptr ++;
size --;
}
return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
}
return 0;
}
static rt_size_t rt_uart_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
{
char *ptr;
ptr = (char*)buffer;
if (dev->flag & RT_DEVICE_FLAG_STREAM)
{
/* stream mode */
while (size)
{
if (*ptr == '\n')
{
while (UA1TSF == 1U)
;
UA1TX = '\r';
}
/* THRE status, contain valid data */
while (UA1TSF == 1U)
;
UA1TX = *ptr;
ptr ++;
size --;
}
}
else
{
while (size != 0)
{
/* THRE status, contain valid data */
while (UA1TSF == 1U)
;
UA1TX = *ptr;
ptr ++;
size --;
}
}
return (rt_size_t)ptr - (rt_size_t)buffer;
}
void rt_hw_uart_init(void)
{
struct rt_uart_v850 *uart;
/* get uart device */
uart = &uart_device;
/* device initialization */
uart->parent.type = RT_Device_Class_Char;
rt_memset(uart->rx_buffer, 0, sizeof(uart->rx_buffer));
uart->read_index = uart->save_index = 0;
/* device interface */
uart->parent.init = rt_uart_init;
uart->parent.open = rt_uart_open;
uart->parent.close = rt_uart_close;
uart->parent.read = rt_uart_read;
uart->parent.write = rt_uart_write;
uart->parent.control = RT_NULL;
uart->parent.user_data = RT_NULL;
rt_device_register(&uart->parent,
"uart0", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX);
}
#endif /* end of UART */
/*@}*/
| 26.856557 | 118 | 0.575004 |
9867964acbc3dddd393b8636058069427eb49b43 | 7,121 | h | C | core/core_types.h | jeffpanici75/ryu | 5a6ce78918932bbd236bfa29112f11907d782655 | [
"MIT"
] | 35 | 2018-02-01T20:53:13.000Z | 2022-02-28T18:41:05.000Z | core/core_types.h | jeffpanici75/ryu | 5a6ce78918932bbd236bfa29112f11907d782655 | [
"MIT"
] | 7 | 2018-09-18T22:09:25.000Z | 2018-09-18T22:21:14.000Z | core/core_types.h | jeffpanici75/ryu | 5a6ce78918932bbd236bfa29112f11907d782655 | [
"MIT"
] | 5 | 2021-05-14T10:27:47.000Z | 2021-12-01T13:28:07.000Z | //
// Ryu
//
// Copyright (C) 2017 Jeff Panici
// All Rights Reserved.
//
#pragma once
#include <map>
#include <list>
#include <stack>
#include <functional>
#include <fmt/format.h>
#include <SDL_FontCache.h>
#include <boost/variant.hpp>
namespace ryu::core {
// --------------------
// id pool
// --------------------
using id_t = uint32_t;
// --------------------
// timers
// --------------------
class timer;
using timer_list = std::vector<timer*>;
using timer_callable = std::function<void (timer*)>;
// --------------------
// engine
// --------------------
class engine;
// --------------------
// project & project_file
// --------------------
class project;
using project_shared_ptr = std::shared_ptr<core::project>;
using project_props_dict = std::map<std::string, std::string>;
class project_file;
using project_file_shared_ptr = std::shared_ptr<project_file>;
using project_file_list = std::vector<project_file_shared_ptr>;
// --------------------
// context
// state
// --------------------
class context;
using context_dict = std::map<int, context*>;
struct context_window {
enum sizes {
split,
expanded,
collapsed
};
};
class state;
struct state_t {
state* instance;
};
using state_dict = std::map<int, state_t>;
using blackboard = std::map<std::string, std::string>;
// --------------------
// colors & palettes
// --------------------
using palette_index = uint8_t;
// --------------------
// view
// --------------------
class view;
using view_list = std::vector<view*>;
struct pick_list_option_t {
uint32_t key;
std::string text;
};
using option_list = std::vector<pick_list_option_t>;
struct alignment {
struct horizontal {
enum types : uint8_t {
none,
left,
right,
center
};
};
struct vertical {
enum types : uint8_t {
none,
top,
middle,
bottom
};
};
static FC_AlignEnum to_font_align(horizontal::types value) {
FC_AlignEnum align = FC_AlignEnum::FC_ALIGN_LEFT;
switch (value) {
case horizontal::none:
case horizontal::left:
align = FC_AlignEnum::FC_ALIGN_LEFT;
break;
case horizontal::right:
align = FC_AlignEnum::FC_ALIGN_RIGHT;
break;
case horizontal::center:
align = FC_AlignEnum::FC_ALIGN_CENTER;
break;
}
return align;
}
};
struct border {
enum types : uint8_t {
none,
solid,
dashed,
rounded
};
};
struct dock {
enum styles : uint8_t {
none,
bottom,
fill,
left,
right,
top
};
};
struct vertex_t {
int16_t x {};
int16_t y {};
};
struct span_t {
int16_t left {};
int16_t right {};
};
using border_type = uint8_t;
using dock_style = uint8_t;
using span_list = std::vector<span_t>;
using vertex_list = std::vector<vertex_t>;
// --------------------
// attributed text
// --------------------
struct attr_t {
palette_index color = 0;
uint8_t style = 0;
uint8_t flags = 0;
bool operator== (const attr_t& rhs) const {
return color == rhs.color && style == rhs.style && flags == rhs.flags;
}
bool operator!= (const attr_t& rhs) const {
return color != rhs.color || style != rhs.style || flags != rhs.flags;
}
};
struct attr_chunk_t {
attr_t attr;
std::string text {};
};
using attr_chunks = std::vector<attr_chunk_t>;
using code_to_attr_callable = std::function<void (attr_t&)>;
using code_to_attr_dict = std::map<std::string, code_to_attr_callable>;
// --------------------
// data tables
// --------------------
struct data_table_column_t {
enum format_options : uint8_t {
none = 0b00000000,
style_codes = 0b00000001,
word_wrap = 0b00000010,
};
std::string text {};
uint16_t min_width {};
uint16_t max_width {};
core::alignment::horizontal::types alignment = core::alignment::horizontal::types::left;
uint8_t padding = 1;
uint8_t options = format_options::none;
uint16_t width {};
};
struct data_table_row_t {
std::vector<std::string> columns {};
};
struct data_table_t {
std::vector<data_table_column_t> headers {};
std::vector<data_table_column_t> footers {};
std::vector<data_table_row_t> rows {};
uint8_t line_spacing = 0;
};
struct once_value_t {
bool show = true;
void add_once_column(
data_table_row_t& row,
const std::string& value) {
if (show) {
row.columns.push_back(value);
show = false;
} else {
row.columns.emplace_back("");
}
}
};
// --------------------
// ide
// --------------------
struct system_commands {
enum types {
unknown,
quit,
clear,
edit_source,
edit_memory,
list_machine,
edit_project,
edit_machine,
edit_component,
edit_tiles,
edit_sprites,
edit_backgrounds,
edit_music,
edit_sounds,
edit_palette,
edit_actor,
edit_cpu,
read_text,
write_text,
find_text,
goto_line,
save_project_file,
update_working_directory
};
};
// --------------------
// environment parameters
// --------------------
using parameter_variant_t = boost::variant<data_table_t, std::string, uint32_t, bool, system_commands::types>;
enum parameter_dict_types {
table = 0,
string,
integer32,
boolean,
system_command
};
using state_transition_command = uint32_t;
using parameter_dict = std::map<std::string, parameter_variant_t>;
using state_transition_callable = std::function<bool (state_transition_command, const parameter_dict&)>;
using byte_list = std::vector<uint8_t>;
using address_list = std::vector<uint32_t>;
// --------------------
// observable types
// --------------------
struct observables {
enum types : uint32_t {
unknown = 0,
project
};
};
}; | 23.736667 | 114 | 0.481253 |
377e19e7ed0bf92693e923770ecea860de9bfc3c | 4,046 | c | C | dynld/src/dynld.c | madd-games/glidix | 1510d9c3f159bee9d4aa942e715aedc78b7f827c | [
"BSD-2-Clause"
] | 98 | 2015-08-05T22:20:19.000Z | 2022-03-11T08:49:24.000Z | dynld/src/dynld.c | madd-games/glidix | 1510d9c3f159bee9d4aa942e715aedc78b7f827c | [
"BSD-2-Clause"
] | 5 | 2016-02-23T12:49:24.000Z | 2019-10-11T18:09:47.000Z | dynld/src/dynld.c | madd-games/glidix | 1510d9c3f159bee9d4aa942e715aedc78b7f827c | [
"BSD-2-Clause"
] | 11 | 2015-12-02T05:01:28.000Z | 2021-06-25T16:54:18.000Z | /*
Glidix dynamic linker
Copyright (c) 2014-2017, Madd Games.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
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.
*/
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include "dynld.h"
char dynld_errmsg[1024];
Dl_Library chainHead;
const char *libraryPath = "";
int debugMode = 0;
int bindNow = 0;
int dynld_errno;
void dynld_enter(void *retstack, Elf64_Addr entry);
int dynld_main(int argc, char *argv[], char *envp[], void *retstack)
{
if (sizeof(Dl_Library) > 0x1000)
{
dynld_printf("sizeof(Library) exceeds page size!\n");
return 1;
};
char **envscan;
for (envscan=envp; *envscan!=NULL; envscan++)
{
if (memcmp(*envscan, "LD_LIBRARY_PATH=", strlen("LD_LIBRARY_PATH=")) == 0)
{
libraryPath = (*envscan) + strlen("LD_LIBRARY_PATH=");
};
if (strcmp(*envscan, "LD_DEBUG=1") == 0)
{
debugMode = 1;
};
if (strcmp(*envscan, "LD_BIND_NOW=1") == 0)
{
bindNow = 1;
};
};
// get the auxiliary vector
char **auxvp;
for (auxvp=envp; *auxvp!=NULL; auxvp++);
Elf64_Auxv *auxv = (Elf64_Auxv*) &auxvp[1];
// see if we can get the executable file descriptor
for (; auxv->a_type != AT_NULL; auxv++)
{
if (auxv->a_type == AT_EXECFD) break;
};
const char *progname;
int execfd;
if (auxv->a_type == AT_EXECFD)
{
execfd = (int) auxv->a_un.a_val;
progname = argv[0];
}
else
{
if (argc < 2)
{
dynld_printf("dynld: no AT_EXECFD and no arguments given, see dynld(1)\n");
return 1;
};
execfd = open(argv[1], O_RDONLY);
if (execfd == -1)
{
dynld_printf("dynld: failed to open %s\n", argv[1]);
return 1;
};
progname = argv[1];
};
struct stat st;
if (fstat(execfd, &st) == 0)
{
if ((st.st_mode & 06000) != 0)
{
if (debugMode)
{
dynld_printf("dynld: program is suid/sgid; running in safe-execution mode\n");
};
libraryPath = "";
};
if (st.st_oxperm != 0)
{
if (debugMode)
{
dynld_printf("dynld: program has own permissions; running in safe-execution mode\n");
};
libraryPath = "";
};
};
if (debugMode)
{
dynld_printf("dynld: invoked with pid %d\n", dynld_getpid());
};
char exepath[256];
exepath[readlink("/proc/self/exe", exepath, 256)] = 0;
chainHead.prev = chainHead.next = NULL;
if (dynld_mapobj(&chainHead, execfd, 0, progname, RTLD_LAZY | RTLD_GLOBAL, exepath) == 0)
{
dynld_printf("dynld: failed to load executable: %s\n", dynld_errmsg);
return 1;
};
Elf64_Ehdr elfHeader;
if (pread(execfd, &elfHeader, sizeof(Elf64_Ehdr), 0) != sizeof(Elf64_Ehdr))
{
dynld_printf("dynld: failed to read ELF header of executable\n");
return 1;
};
close(execfd);
dynld_initlib(&chainHead);
if (debugMode)
{
dynld_printf("dynld: passing control to program\n");
};
dynld_enter(retstack, elfHeader.e_entry);
return 0;
};
| 24.822086 | 90 | 0.683885 |
882e97ecdd5b94b30fa788a871bce8d69868c553 | 678 | h | C | include/Matrix2D.h | lothas/CodingPractice | 1a837c38c1d5ac897d93d3cb9c33347c663db2ac | [
"MIT"
] | null | null | null | include/Matrix2D.h | lothas/CodingPractice | 1a837c38c1d5ac897d93d3cb9c33347c663db2ac | [
"MIT"
] | null | null | null | include/Matrix2D.h | lothas/CodingPractice | 1a837c38c1d5ac897d93d3cb9c33347c663db2ac | [
"MIT"
] | null | null | null | #ifndef MATRIX2D_H
#define MATRIX2D_H
#include <iostream>
#include <cstring>
class Matrix2D
{
public:
Matrix2D(void) {};
Matrix2D(unsigned int m_rows, unsigned int m_cols, int init_val);
Matrix2D(const Matrix2D& obj);
virtual ~Matrix2D();
bool is_valid_pos(unsigned int row, unsigned int col);
void print();
int* get_row(unsigned int row_pos);
Matrix2D* convolute(Matrix2D* kernel); // TODO: Test that this thing actually works
int** data = nullptr;
unsigned int rows = 1;
unsigned int cols = 1;
protected:
private:
};
#endif // MATRIX2D_H
| 21.870968 | 92 | 0.600295 |
fd2767c7681d3897d09a197d601bfc8bd0942740 | 1,520 | h | C | Programs/TestBed/Sources/Tests/StaticTextTest.h | stinvi/dava.engine | 2b396ca49cdf10cdc98ad8a9ffcf7768a05e285e | [
"BSD-3-Clause"
] | 26 | 2018-09-03T08:48:22.000Z | 2022-02-14T05:14:50.000Z | Programs/TestBed/Sources/Tests/StaticTextTest.h | ANHELL-blitz/dava.engine | ed83624326f000866e29166c7f4cccfed1bb41d4 | [
"BSD-3-Clause"
] | null | null | null | Programs/TestBed/Sources/Tests/StaticTextTest.h | ANHELL-blitz/dava.engine | ed83624326f000866e29166c7f4cccfed1bb41d4 | [
"BSD-3-Clause"
] | 45 | 2018-05-11T06:47:17.000Z | 2022-02-03T11:30:55.000Z | #ifndef __TEXT_ALIGH_TEST_H__
#define __TEXT_ALIGH_TEST_H__
#include "Infrastructure/BaseScreen.h"
class TestBed;
class StaticTextTest : public BaseScreen
{
public:
StaticTextTest(TestBed& app);
void LoadResources() override;
void UnloadResources() override;
void SetPreviewText(const DAVA::WideString& text);
void SetPreviewAlign(DAVA::int32 align);
void SetPreviewFitting(DAVA::int32 fitting);
void SetPreviewRequiredTextSize(bool enable);
void SetPreviewMultiline(DAVA::int32 multilineType);
private:
DAVA::UIButton* CreateButton(const DAVA::WideString& caption, const DAVA::Rect& rect, DAVA::int32 tag, DAVA::Font* font, const DAVA::Message& msg);
void OnAlignButtonClick(BaseObject* sender, void* data, void* callerData);
void OnFittingButtonClick(BaseObject* sender, void* data, void* callerData);
void OnRequireTextSizeButtonClick(BaseObject* sender, void* data, void* callerData);
void OnMultilineButtonClick(BaseObject* sender, void* data, void* callerData);
void UpdateDebugLabel();
DAVA::UIStaticText* previewText = nullptr;
DAVA::UIStaticText* debugLabel = nullptr;
DAVA::UITextField* inputText = nullptr;
DAVA::UITextFieldDelegate* inputDelegate = nullptr;
DAVA::UIButton* requireTextSizeButton = nullptr;
DAVA::List<DAVA::UIButton*> alignButtons;
DAVA::List<DAVA::UIButton*> fittingButtons;
DAVA::List<DAVA::UIButton*> multilineButtons;
bool needRequiredSize = false;
};
#endif //__MULTILINETEST_TEST_H__
| 35.348837 | 151 | 0.750658 |
f76deecaeedfa5187251a85ba6386fdef4854261 | 296 | h | C | hellowebview/hellowebview/ViewController.h | skyujilong/ioswebview | 84f08ea23fc852cd6e3e93faa08e0e2a753922b4 | [
"MIT"
] | null | null | null | hellowebview/hellowebview/ViewController.h | skyujilong/ioswebview | 84f08ea23fc852cd6e3e93faa08e0e2a753922b4 | [
"MIT"
] | null | null | null | hellowebview/hellowebview/ViewController.h | skyujilong/ioswebview | 84f08ea23fc852cd6e3e93faa08e0e2a753922b4 | [
"MIT"
] | null | null | null | //
// ViewController.h
// hellowebview
//
// Created by jilong5 on 2017/11/1.
// Copyright © 2017年 jilong5. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
UIWebView *myWebView;
}
@property (nonatomic, retain) UIWebView *myWebView;
@end
| 15.578947 | 51 | 0.702703 |
5a194bfb2b20ef968e3730a4ef7f617e2a9945e7 | 1,593 | h | C | client/stt_dbus.h | tizenorg/platform.core.uifw.stt | 28c2636a98b4e42ced25e7c62185e3ed60aa07e4 | [
"Apache-2.0"
] | null | null | null | client/stt_dbus.h | tizenorg/platform.core.uifw.stt | 28c2636a98b4e42ced25e7c62185e3ed60aa07e4 | [
"Apache-2.0"
] | null | null | null | client/stt_dbus.h | tizenorg/platform.core.uifw.stt | 28c2636a98b4e42ced25e7c62185e3ed60aa07e4 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __STT_DBUS_H_
#define __STT_DBUS_H_
#include "stt.h"
#include "stt_main.h"
#ifdef __cplusplus
extern "C" {
#endif
int stt_dbus_open_connection();
int stt_dbus_close_connection();
int stt_dbus_request_hello();
int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanity_supported, bool* punctuation_supported);
int stt_dbus_request_finalize(int uid);
int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_language_cb callback, void* user_data);
int stt_dbus_request_get_default_lang(int uid, char** language);
int stt_dbus_request_get_audio_volume(int uid, float* volume);
int stt_dbus_request_is_partial_result_supported(int uid, bool* partial_result);
int stt_dbus_request_start(int uid, const char* lang, const char* type, int profanity, int punctuation, int silence);
int stt_dbus_request_stop(int uid);
int stt_dbus_request_cancel(int uid);
#ifdef __cplusplus
}
#endif
#endif /* __STT_DBUS_H_ */
| 28.446429 | 122 | 0.785311 |
eecb0f75e6dfe542457f6644b5925b114d7a00dc | 518 | h | C | App/Model/PPModel+DB.h | xphaijj/App | a0dfba40103cdf133837d6955d3c47d735fb0c81 | [
"MIT"
] | null | null | null | App/Model/PPModel+DB.h | xphaijj/App | a0dfba40103cdf133837d6955d3c47d735fb0c81 | [
"MIT"
] | null | null | null | App/Model/PPModel+DB.h | xphaijj/App | a0dfba40103cdf133837d6955d3c47d735fb0c81 | [
"MIT"
] | null | null | null | //
// PPModel+DB.h
//
// Created By 项普华 Version: 2.0
// Copyright (C) 2019/11/04 By AlexXiang All rights reserved.
// email:// xiangpuhua@126.com tel:// +86 13316987488
//
//
#import <FMDB/FMDB.h>
#import <YLT_BaseLib/YLT_BaseLib.h>
#import "PPModel.h"
//数据库操作完成回调
typedef void(^YLT_DBComplete)(id response);
@interface User(DB) {
}
@end
@interface Normal(DB) {
}
@end
@interface Banner(DB) {
}
@end
@interface Menu(DB) {
}
@end
@interface Course(DB) {
}
@end
@interface Teacher(DB) {
}
@end
| 9.773585 | 63 | 0.642857 |
f6f70e490ef94b1a1b1870af46f010e108e1b1d8 | 303 | h | C | src/include/crypt.h | krzem5/C-Kl_Compiler | 3f4338230e68d99499889b29fbf4fe1e07380bce | [
"BSD-3-Clause"
] | null | null | null | src/include/crypt.h | krzem5/C-Kl_Compiler | 3f4338230e68d99499889b29fbf4fe1e07380bce | [
"BSD-3-Clause"
] | null | null | null | src/include/crypt.h | krzem5/C-Kl_Compiler | 3f4338230e68d99499889b29fbf4fe1e07380bce | [
"BSD-3-Clause"
] | null | null | null | #ifndef CRYPT_H
#define CRYPT_H
#include <shared.h>
struct SHA256 KlCrypt_init_sha256(void);
void KlCrypt_update_sha256(struct SHA256 sha,unsigned char* s,size_t ln);
uint256_t KlCrypt_finalize_sha256(struct SHA256 sha);
uint256_t KlCrypt_quick_sha256(unsigned char* s,size_t ln);
#endif
| 12.625 | 73 | 0.785479 |
671987a59d49751f975c0d09918e568fb46a984e | 2,945 | c | C | example/demo.c | quanshousio/CompilerInterrupts | 67e72514a90c76c7106e4202001003b9ef359a5e | [
"MIT"
] | null | null | null | example/demo.c | quanshousio/CompilerInterrupts | 67e72514a90c76c7106e4202001003b9ef359a5e | [
"MIT"
] | null | null | null | example/demo.c | quanshousio/CompilerInterrupts | 67e72514a90c76c7106e4202001003b9ef359a5e | [
"MIT"
] | null | null | null | #include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include "ci_lib.h"
#define BASE_VAL 10000
#define MAX_THREADS 64
// define this flag to check ci_enable functionality
// #define CHECK_ENABLE
// define this flag to check de-register functionality
// #define CHECK_DEREGISTER
/* the handler should only be called in the CI-integrated binary */
void interrupt_handler(long ic) {
static __thread long previous_ic = 0;
printf("CI: last interval = %ld IR\n", ic - previous_ic);
previous_ic = ic;
}
void pre_disable() {
printf("This function is being called before ci_disable()\n");
}
void post_enable() {
printf("This function is being called after ci_enable()\n");
}
void *increment(void *arg) {
int i;
int counter = 0;
int thr_no = (int)(size_t)arg;
int iterations = BASE_VAL + (rand() % 10);
register_ci(10000, 10000, interrupt_handler);
for (i = 0; i < iterations; i++) {
counter += rand() % 10;
}
printf("increment(): thread: %d -> counter: %d\n", thr_no, counter);
return NULL;
}
void *decrement(void *arg) {
int i;
int counter = 0;
int thr_no = (int)(size_t)arg;
int iterations = BASE_VAL + (rand() % 10);
register_ci(10000, 10000, interrupt_handler);
/* temporarily disable CI for the remaining code */
ci_disable();
#ifdef CHECK_ENABLE
/* register CI hooks */
register_ci_disable_hook(pre_disable);
register_ci_enable_hook(post_enable);
/* there must be as many enable calls after a fixed number of disable calls
* to re-enable CI, more number of enable calls will not make a difference */
ci_disable(); /* will make no difference since CI is already disabled */
ci_enable(); /* won't be enabled yet as there were two disable calls before */
ci_enable(); /* will enable CI again */
#endif
#ifdef CHECK_DEREGISTER
deregister_ci(); /* deregisters CI */
#endif
for (i = 0; i < iterations; i++) {
counter -= rand() % 10;
}
printf("decrement(): thread: %d -> counter: %d\n", thr_no, counter);
return NULL;
}
int main(int argc, char **argv) {
/* register the interrupt handler */
register_ci(1000, 1000, interrupt_handler);
pthread_t t1[MAX_THREADS - 1];
pthread_t t2[MAX_THREADS - 1];
int num_threads = MAX_THREADS;
if (argc == 2) {
num_threads = atoi(argv[1]);
if (num_threads > MAX_THREADS) {
printf("Maximum thread count exceeded. Aborting...\n");
exit(1);
}
}
printf("Starting %d increment threads\n", num_threads);
for (int i = 0; i < (num_threads - 1); i++) {
pthread_create(&t1[i], NULL, increment, (void *)(uintptr_t)i);
}
printf("Starting %d decrement threads\n", num_threads);
for (int i = 0; i < (num_threads - 1); i++) {
pthread_create(&t2[i], NULL, decrement, (void *)(uintptr_t)i);
}
for (int i = 0; i < (num_threads - 1); i++) {
pthread_join(t1[i], NULL);
}
for (int i = 0; i < (num_threads - 1); i++) {
pthread_join(t2[i], NULL);
}
return 0;
}
| 26.061947 | 80 | 0.656706 |
6793046957047f71d71856e5361c52c133ffead2 | 2,264 | h | C | bs_bos_core/include/member_accessor.h | bs-eagle/bs-eagle | b1017a4f6ac2dcafba2deafec84052ddde792671 | [
"BSD-3-Clause"
] | 7 | 2015-07-16T22:30:36.000Z | 2020-02-06T10:16:42.000Z | bs_bos_core/include/member_accessor.h | bs-eagle/bs-eagle | b1017a4f6ac2dcafba2deafec84052ddde792671 | [
"BSD-3-Clause"
] | null | null | null | bs_bos_core/include/member_accessor.h | bs-eagle/bs-eagle | b1017a4f6ac2dcafba2deafec84052ddde792671 | [
"BSD-3-Clause"
] | 3 | 2017-01-05T20:06:28.000Z | 2021-12-20T16:19:10.000Z | /**
* \file member_accessor.h
* \brief Helpers to adapt vector of calc_model_data to save via
* tools::save_seq_vector, only for debug purposes
* \author Sergey Miryanov (sergey-miryanov), sergey.miryanov@gmail.com
* \date 31.10.2008
* \copyright This source code is released under the terms of
* the BSD License. See LICENSE for more details.
* \todo Obsolete, should be removed
* */
#ifndef BS_TOOLS_MEMBER_ACCESSOR_H_
#define BS_TOOLS_MEMBER_ACCESSOR_H_
namespace blue_sky
{
namespace tools
{
template <typename data_array_t, typename item_t>
struct member_accessor
{
typedef item_t value_type;
member_accessor (const data_array_t &data_, const item_t *data_begin_, const item_t *data_offset_, size_t size_)
: data_ (data_)
, data_begin_ (data_begin_)
, data_offset_ (data_offset_)
, size_ (size_)
{
}
size_t
size_i () const
{
return data_.size ();
}
size_t
size_j () const
{
return size_;
}
item_t
get (size_t i, size_t j) const
{
const item_t *data = (const item_t *)&data_[i];
size_t count = data_offset_ - data_begin_;
return data [count + j];
}
private:
const data_array_t &data_;
const item_t *data_begin_;
const item_t *data_offset_;
size_t size_;
};
// use like
//
//#define SAVE_BOOST_ARRAY(name) \
// tools::save_seq_vector (BOOST_PP_CAT (BOOST_PP_STRINGIZE(name), ".bs.txt")) \
// .save_via_fn (member_accessor (data, (item_t *)&data[0], &data[0].name[0], data[0].name.size ()));
//
//#define SAVE_ITEM(name) \
// tools::save_seq_vector (BOOST_PP_CAT (BOOST_PP_STRINGIZE(name), ".bs.txt")) \
// .save_via_fn (member_accessor (data, (item_t *)&data[0], &data[0].name, 1));
} // namespace tools
} // namespace blue_sky
#endif // #ifndef BS_TOOLS_MEMBER_ACCESSOR_H_
| 29.789474 | 120 | 0.548587 |
c69b279ef9af3138c15be7be094894c696d5db88 | 4,211 | h | C | captcha/include/tencentcloud/captcha/v20190722/model/CaptchaOperDataTryTimesUnit.h | li5ch/tencentcloud-sdk-cpp | 12ebfd75a399ee2791f6ac1220a79ce8a9faf7c4 | [
"Apache-2.0"
] | 43 | 2019-08-14T08:14:12.000Z | 2022-03-30T12:35:09.000Z | captcha/include/tencentcloud/captcha/v20190722/model/CaptchaOperDataTryTimesUnit.h | li5ch/tencentcloud-sdk-cpp | 12ebfd75a399ee2791f6ac1220a79ce8a9faf7c4 | [
"Apache-2.0"
] | 12 | 2019-07-15T10:44:59.000Z | 2021-11-02T12:35:00.000Z | captcha/include/tencentcloud/captcha/v20190722/model/CaptchaOperDataTryTimesUnit.h | li5ch/tencentcloud-sdk-cpp | 12ebfd75a399ee2791f6ac1220a79ce8a9faf7c4 | [
"Apache-2.0"
] | 28 | 2019-07-12T09:06:22.000Z | 2022-03-30T08:04:18.000Z | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TENCENTCLOUD_CAPTCHA_V20190722_MODEL_CAPTCHAOPERDATATRYTIMESUNIT_H_
#define TENCENTCLOUD_CAPTCHA_V20190722_MODEL_CAPTCHAOPERDATATRYTIMESUNIT_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
#include <tencentcloud/core/AbstractModel.h>
namespace TencentCloud
{
namespace Captcha
{
namespace V20190722
{
namespace Model
{
/**
* DescribeCaptchaOperData操作数据查询尝试次数 type = 3
*/
class CaptchaOperDataTryTimesUnit : public AbstractModel
{
public:
CaptchaOperDataTryTimesUnit();
~CaptchaOperDataTryTimesUnit() = default;
void ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const;
CoreInternalOutcome Deserialize(const rapidjson::Value &value);
/**
* 获取时间
* @return DateKey 时间
*/
std::string GetDateKey() const;
/**
* 设置时间
* @param DateKey 时间
*/
void SetDateKey(const std::string& _dateKey);
/**
* 判断参数 DateKey 是否已赋值
* @return DateKey 是否已赋值
*/
bool DateKeyHasBeenSet() const;
/**
* 获取平均尝试次数
* @return CntPerPass 平均尝试次数
*/
std::vector<double> GetCntPerPass() const;
/**
* 设置平均尝试次数
* @param CntPerPass 平均尝试次数
*/
void SetCntPerPass(const std::vector<double>& _cntPerPass);
/**
* 判断参数 CntPerPass 是否已赋值
* @return CntPerPass 是否已赋值
*/
bool CntPerPassHasBeenSet() const;
/**
* 获取market平均尝试次数
* @return MarketCntPerPass market平均尝试次数
*/
double GetMarketCntPerPass() const;
/**
* 设置market平均尝试次数
* @param MarketCntPerPass market平均尝试次数
*/
void SetMarketCntPerPass(const double& _marketCntPerPass);
/**
* 判断参数 MarketCntPerPass 是否已赋值
* @return MarketCntPerPass 是否已赋值
*/
bool MarketCntPerPassHasBeenSet() const;
private:
/**
* 时间
*/
std::string m_dateKey;
bool m_dateKeyHasBeenSet;
/**
* 平均尝试次数
*/
std::vector<double> m_cntPerPass;
bool m_cntPerPassHasBeenSet;
/**
* market平均尝试次数
*/
double m_marketCntPerPass;
bool m_marketCntPerPassHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_CAPTCHA_V20190722_MODEL_CAPTCHAOPERDATATRYTIMESUNIT_H_
| 32.392308 | 116 | 0.49252 |
1bf4d257d73f422bb831cee58a18758b2a05cf83 | 20,396 | c | C | common/http_ev.c | crosstocci/postage | 7ac080c4cb3cb939427a4368b5c5b9fe57f77a9a | [
"Apache-2.0"
] | 2 | 2017-05-27T19:44:19.000Z | 2020-05-27T01:33:46.000Z | common/http_ev.c | crosstocci/postage | 7ac080c4cb3cb939427a4368b5c5b9fe57f77a9a | [
"Apache-2.0"
] | null | null | null | common/http_ev.c | crosstocci/postage | 7ac080c4cb3cb939427a4368b5c5b9fe57f77a9a | [
"Apache-2.0"
] | 1 | 2020-05-27T01:33:50.000Z | 2020-05-27T01:33:50.000Z | #include "http_ev.h"
#ifndef _WIN32
#else
#ifndef EV_SELECT_IS_WINSOCKET
#define EV_SELECT_IS_WINSOCKET 1
#endif
#endif
#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
typedef ev_watcher *W;
typedef ev_watcher_list *WL;
typedef ev_watcher_time *WT;
// a heap element
typedef struct {
ev_tstamp at;
WT w;
} ANHE;
// file descriptor info structure
typedef struct {
WL head;
unsigned char events; // the events watched for
unsigned char reify; // flag set when this ANFD needs reification
// (NFD_REIFY, EV__IOFDSET)
unsigned char emask; // the epoll backend stores the actual kernel mask in here
unsigned char unused;
#if EV_USE_EPOLL
unsigned int egen; // generation counter to counter epoll bugs
#endif
#if EV_SELECT_IS_WINSOCKET || EV_USE_IOCP
SOCKET handle;
#endif
#if EV_USE_IOCP
OVERLAPPED or, ow;
#endif
} ANFD;
typedef struct {
W w;
int events; // the pending event set for the given watcher
} ANPENDING;
struct ev_global_loop {
ev_tstamp ev_rt_now;
#define ev_rt_now ((global_loop)->ev_rt_now)
#undef VAR
#define VAR(name, decl) decl;
#include "ev_vars.h"
#undef VAR
};
#ifdef _WIN32
void my_invalid_parameter(
const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t pReserved) {
}
#endif
char *cb_to_name(void *cb);
void http_ev_step1(struct sock_ev_client *client) {
char *str_response = NULL;
size_t int_response_len = 0;
size_t int_query_length = 0;
size_t int_action_length = 0;
size_t int_w_length = 0;
struct sock_ev_client_copy_io *client_copy_io = NULL;
struct sock_ev_client_copy_check *client_copy_check = NULL;
struct ev_global_loop *_loop = (struct ev_global_loop *)global_loop;
SDEFINE_VAR_ALL(str_args, str_action, str_w);
char str_int_i[256] = {0};
char str_current_address[256] = {0};
char str_current_priority[256] = {0};
char str_current_events[256] = {0};
bool bol_kill = false;
bool bol_killed = false;
str_args = query(client->str_request, client->int_request_len, &int_query_length);
SFINISH_CHECK(str_args != NULL, "query() failed");
str_action = getpar(str_args, "action", int_query_length, &int_action_length);
SFINISH_CHECK(str_action != NULL && int_action_length > 0, "Invalid action");
SDEBUG("str_action: %s", str_action);
if (strcmp(str_action, "list") == 0) {
bol_kill = false;
} else if (strcmp(str_action, "kill") == 0) {
str_w = getpar(str_args, "w", int_query_length, &int_w_length);
SFINISH_CHECK(str_w != NULL && int_w_length > 0, "Invalid w");
bol_kill = true;
} else {
SFINISH("Invalid action");
}
SFINISH_SALLOC(client_copy_io, sizeof(struct sock_ev_client_copy_io));
SFINISH_SALLOC(client_copy_check, sizeof(struct sock_ev_client_copy_check));
client_copy_io->client_copy_check = client_copy_check;
client->cur_request = create_request(client, NULL, NULL, NULL, NULL, 0, POSTAGE_REQ_STANDARD);
SFINISH_CHECK(client->cur_request != NULL, "create_request failed!");
client_copy_check->client_request = client->cur_request;
SFINISH_SNCAT(client_copy_check->str_response, &int_response_len, "HTTP 200 OK\r\n\r\n", (size_t)15);
ssize_t pendingpri = NUMPRI - 1;
while (pendingpri >= 0 && (bol_kill == false || bol_killed == false)) {
ssize_t int_i = _loop->pendingcnt[pendingpri] - 1;
while (int_i >= 0 && (bol_kill == false || bol_killed == false)) {
if (_loop->pendings[pendingpri] == NULL) {
int_i -= 1;
continue;
}
snprintf(str_current_address, 255, "%p", _loop->pendings[pendingpri][int_i].w);
snprintf(str_current_priority, 255, "%zu", pendingpri);
snprintf(str_current_events, 255, "0x%x", _loop->pendings[pendingpri][int_i].events);
if (bol_kill) {
if (strcmp(str_current_address, str_w) == 0) {
ev_check_stop(global_loop, (ev_check *)_loop->pendings[pendingpri][int_i].w);
bol_killed = true;
}
} else {
char *ptr_cb_name = cb_to_name(_loop->pendings[pendingpri][int_i].w->cb);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" watcher at ", (size_t)12,
str_current_address, strlen(str_current_address),
" with priority ", (size_t)15,
str_current_priority, strlen(str_current_priority),
" with callback ", (size_t)15,
ptr_cb_name, strlen(ptr_cb_name),
":\n", (size_t)2
);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" events: ", (size_t)10,
str_current_events, strlen(str_current_events),
"\n", (size_t)1
);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" EV_IDLE : ", (size_t)15,
_loop->pendings[pendingpri][int_i].events == EV_IDLE ? "true\n" : "false\n", (size_t)(_loop->pendings[pendingpri][int_i].events == EV_IDLE ? 5 : 6)
);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" EV_PREPARE : ", (size_t)17,
_loop->pendings[pendingpri][int_i].events == EV_PREPARE ? "true\n" : "false\n", (size_t)(_loop->pendings[pendingpri][int_i].events == EV_PREPARE ? 5 : 6)
);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" EV_CHECK : ", (size_t)15,
_loop->pendings[pendingpri][int_i].events == EV_CHECK ? "true\n\n" : "false\n\n", (size_t)(_loop->pendings[pendingpri][int_i].events == EV_CHECK ? 6 : 7)
);
}
int_i -= 1;
SDEBUG("client_copy_check->str_response: %s", client_copy_check->str_response);
}
pendingpri -= 1;
}
#ifdef _WIN32
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(my_invalid_parameter);
#endif
ssize_t int_i = _loop->anfdmax;
while (int_i >= 0 && (bol_kill == false || bol_killed == false)) {
ANFD *anfd = &_loop->anfds[int_i];
#ifdef _WIN32
unsigned long arg = 0;
if (ioctlsocket(anfd->handle, FIONREAD, &arg) != 0) {
int_i -= 1;
continue;
}
#else
unsigned long arg = 0;
// All of our sockets are non-blocking
if ((fcntl((int)int_i, F_GETFL, &arg) & O_NONBLOCK) == O_NONBLOCK) {
int_i -= 1;
continue;
}
#endif
ev_io *node = (ev_io *)anfd->head;
while (node != NULL && (bol_kill == false || bol_killed == false)) {
snprintf(str_int_i, 255, "%zu", int_i);
snprintf(str_current_address, 255, "%p", node);
snprintf(str_current_events, 255, "0x%x", node->events);
if (bol_kill) {
if (strcmp(str_current_address, str_w) == 0) {
ev_io_stop(global_loop, node);
bol_killed = true;
break;
}
} else {
char *ptr_cb_name = cb_to_name(node->cb);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" watcher at ", (size_t)12,
str_current_address, strlen(str_current_address),
" on fd ", (size_t)7,
str_int_i, strlen(str_int_i),
" with callback ", (size_t)15,
ptr_cb_name, strlen(ptr_cb_name),
":\n", (size_t)2
);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" events: ", (size_t)10,
str_current_events, strlen(str_current_events),
"\n", (size_t)1
);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" EV_READ : ", (size_t)15,
(node->events & EV_READ) == EV_READ ? "true\n" : "false\n", (size_t)((node->events & EV_READ) == EV_READ ? 5 : 6)
);
SFINISH_SNFCAT(
client_copy_check->str_response, &int_response_len,
" EV_WRITE : ", (size_t)15,
(node->events & EV_WRITE) == EV_WRITE ? "true\n\n" : "false\n\n", (size_t)((node->events & EV_WRITE) == EV_WRITE ? 6 : 7)
);
}
SDEBUG("client_copy_check->str_response: %s", client_copy_check->str_response);
node = (ev_io *)((WL)node)->next;
}
int_i -= 1;
}
#ifdef _WIN32
_set_invalid_parameter_handler(oldHandler);
#endif
client_copy_check->int_response_len = (ssize_t)int_response_len;
ev_io_init(&client_copy_io->io, http_ev_step2, GET_CLIENT_SOCKET(client), EV_WRITE);
ev_io_start(global_loop, &client_copy_io->io);
bol_error_state = false;
finish:
if (bol_error_state) {
bol_error_state = false;
char *_str_response = str_response;
char *str_temp =
"HTTP/1.1 500 Internal Server Error\015\012"
"Server: " SUN_PROGRAM_LOWER_NAME "\015\012\015\012";
SFINISH_SNCAT(str_response, &int_response_len, str_temp, strlen(str_temp), _str_response, strlen(_str_response));
SFREE(_str_response);
}
SFREE_ALL();
ssize_t int_len_response = 0;
if (str_response != NULL && (int_len_response = CLIENT_WRITE(client, str_response, strlen(str_response))) < 0) {
SFREE(str_response);
if (bol_tls) {
SERROR_NORESPONSE_LIBTLS_CONTEXT(client->tls_postage_io_context, "tls_write() failed");
} else {
SERROR_NORESPONSE("write() failed");
}
ev_io_stop(global_loop, &client->io);
SFREE(client->str_request);
SERROR_CHECK_NORESPONSE(client_close(client), "Error closing Client");
}
SFREE(str_response);
}
void http_ev_step2(EV_P, ev_io *w, int revents) {
if (revents != 0) {
} // get rid of unused parameter warning
struct sock_ev_client_copy_io *client_copy_io = (struct sock_ev_client_copy_io *)w;
struct sock_ev_client_copy_check *client_copy_check = client_copy_io->client_copy_check;
struct sock_ev_client_request *client_request = client_copy_check->client_request;
char *str_response = NULL;
char *_str_response = NULL;
SDEBUG("client_copy_check->str_response: %s", client_copy_check->str_response);
ssize_t int_response_len =
CLIENT_WRITE(client_request->parent, client_copy_check->str_response + client_copy_check->int_written,
(size_t)(client_copy_check->int_response_len - client_copy_check->int_written));
SDEBUG("write(%i, %p, %i): %z", client_request->parent->int_sock,
client_copy_check->str_response + client_copy_check->int_written,
client_copy_check->int_response_len - client_copy_check->int_written, int_response_len);
if (int_response_len == -1 && errno != EAGAIN) {
if (bol_tls) {
SFINISH_LIBTLS_CONTEXT(client_request->parent->tls_postage_io_context, "tls_write() failed");
} else {
SFINISH("write(%i, %p, %i) failed: %i", client_request->parent->int_sock,
client_copy_check->str_response + client_copy_check->int_written,
client_copy_check->int_response_len - client_copy_check->int_written, int_response_len);
}
} else if (int_response_len == TLS_WANT_POLLIN) {
ev_io_stop(EV_A, w);
ev_io_set(w, GET_CLIENT_SOCKET(client_request->parent), EV_READ);
ev_io_start(EV_A, w);
bol_error_state = false;
errno = 0;
return;
} else if (int_response_len == TLS_WANT_POLLOUT) {
ev_io_stop(EV_A, w);
ev_io_set(w, GET_CLIENT_SOCKET(client_request->parent), EV_WRITE);
ev_io_start(EV_A, w);
bol_error_state = false;
errno = 0;
return;
} else {
// int_response_len can't be negative at this point
client_copy_check->int_written += (ssize_t)int_response_len;
}
if (client_copy_check->int_written == client_copy_check->int_response_len) {
ev_io_stop(EV_A, w);
SFREE(client_copy_check->str_response);
SFREE(client_copy_check);
SFREE(client_copy_io);
SDEBUG("DONE");
struct sock_ev_client *client = client_request->parent;
SFINISH_CLIENT_CLOSE(client);
client_request = NULL;
}
bol_error_state = false;
finish:
_str_response = str_response;
if (bol_error_state) {
if (client_copy_check != NULL) {
ev_io_stop(EV_A, w);
SFREE(client_copy_check->str_response);
SFREE(client_copy_check);
SFREE(client_copy_io);
}
str_response = NULL;
bol_error_state = false;
char *str_temp =
"HTTP/1.1 500 Internal Server Error\015\012"
"Server: " SUN_PROGRAM_LOWER_NAME "\015\012\015\012";
SFINISH_SNCAT(str_response, (size_t *)&int_response_len,
str_temp, strlen(str_temp),
_str_response, strlen(_str_response));
SFREE(_str_response);
}
if (str_response != NULL) {
int_response_len = CLIENT_WRITE(client_request->parent, str_response, strlen(str_response));
SDEBUG("int_response_len: %d", int_response_len);
if (int_response_len < 0) {
if (bol_tls) {
SERROR_NORESPONSE_LIBTLS_CONTEXT(client_request->parent->tls_postage_io_context, "tls_write() failed");
} else {
SERROR_NORESPONSE("write() failed");
}
}
ev_io_stop(EV_A, &client_request->parent->io);
SFREE(client_request->parent->str_request);
SDEBUG("ERROR");
SERROR_CHECK_NORESPONSE(client_close(client_request->parent), "Error closing Client");
}
SFREE(str_response);
}
char *cb_to_name(void *cb) {
// clang-format off
return
(cb == http_auth_login_step2) ? "http_auth_login_step2"
: (cb == http_auth_login_step3) ? "http_auth_login_step3"
: (cb == http_auth_change_pw_step2) ? "http_auth_change_pw_step2"
: (cb == http_auth_change_pw_step3) ? "http_auth_change_pw_step3"
: (cb == http_auth_change_database_step2) ? "http_auth_change_database_step2"
: (cb == http_file_step2) ? "http_file_step2"
: (cb == http_file_step3) ? "http_file_step3"
: (cb == http_file_write_cb) ? "http_file_write_cb"
: (cb == http_upload_step2) ? "http_upload_step2"
: (cb == http_upload_step3) ? "http_upload_step3"
: (cb == client_cb) ? "client_cb"
: (cb == client_frame_cb) ? "client_frame_cb"
: (cb == client_send_from_cb) ? "client_send_from_cb"
: (cb == client_request_queue_cb) ? "client_request_queue_cb"
: (cb == cnxn_cb) ? "cnxn_cb"
: (cb == ws_client_info_cb) ? "ws_client_info_cb"
: (cb == client_cmd_cb) ? "client_cmd_cb"
: (cb == client_close_timeout_prepare_cb) ? "client_close_timeout_prepare_cb"
: (cb == server_cb) ? "server_cb"
: (cb == ws_copy_check_cb) ? "ws_copy_check_cb"
: (cb == http_copy_check_cb) ? "http_copy_check_cb"
: (cb == _WS_readFrame) ? "_WS_readFrame"
: (cb == WS_readFrame_step2) ? "WS_readFrame_step2"
: (cb == WS_sendFrame) ? "WS_sendFrame"
: (cb == WS_sendFrame_step2) ? "WS_sendFrame_step2"
: (cb == ws_delete_step2) ? "ws_delete_step2"
: (cb == ws_delete_step4) ? "ws_delete_step4"
: (cb == ws_delete_step5) ? "ws_delete_step5"
: (cb == ws_delete_step6) ? "ws_delete_step6"
#ifdef ENVELOPE
: (cb == ws_file_list_step2) ? "ws_file_list_step2"
: (cb == ws_file_read_step2) ? "ws_file_read_step2"
: (cb == ws_file_read_step3) ? "ws_file_read_step3"
: (cb == ws_file_read_step4) ? "ws_file_read_step4"
: (cb == ws_file_write_step2) ? "ws_file_write_step2"
: (cb == ws_file_write_step3) ? "ws_file_write_step3"
: (cb == ws_file_write_step4) ? "ws_file_write_step4"
: (cb == ws_file_move_step2) ? "ws_file_move_step2"
: (cb == ws_file_move_step3) ? "ws_file_move_step3"
: (cb == ws_file_copy_step4) ? "ws_file_copy_step4"
: (cb == ws_file_copy_step5) ? "ws_file_copy_step5"
: (cb == ws_file_delete_step2) ? "ws_file_delete_step2"
: (cb == ws_file_delete_step3) ? "ws_file_delete_step3"
: (cb == ws_file_delete_step4) ? "ws_file_delete_step4"
: (cb == ws_file_create_step2) ? "ws_file_create_step2"
: (cb == ws_file_search_step2) ? "ws_file_search_step2"
: (cb == ws_file_search_step3) ? "ws_file_search_step3"
#ifndef POSTAGE_INTERFACE_LIBPQ
: (cb == ws_insert_step15_sql_server) ? "ws_insert_step15_sql_server"
: (cb == ws_update_step15_sql_server) ? "ws_update_step15_sql_server"
: (cb == ws_delete_step15_sql_server) ? "ws_delete_step15_sql_server"
#endif
: (cb == ws_file_search_step4) ? "ws_file_search_step4"
: (cb == ws_file_search_step5) ? "ws_file_search_step5"
: (cb == ws_insert_step2) ? "ws_insert_step2"
: (cb == ws_insert_step4) ? "ws_insert_step4"
: (cb == ws_insert_step5) ? "ws_insert_step5"
: (cb == ws_insert_step6) ? "ws_insert_step6"
: (cb == ws_insert_step7) ? "ws_insert_step7"
: (cb == http_accept_step2) ? "http_accept_step2"
: (cb == http_action_step2) ? "http_action_step2"
: (cb == http_delete_step2) ? "http_delete_step2"
: (cb == http_delete_step3) ? "http_delete_step3"
: (cb == http_delete_step4) ? "http_delete_step4"
: (cb == http_insert_step2) ? "http_insert_step2"
: (cb == http_insert_step3) ? "http_insert_step3"
: (cb == http_insert_step4) ? "http_insert_step4"
: (cb == http_insert_step5) ? "http_insert_step5"
: (cb == http_insert_step6) ? "http_insert_step6"
: (cb == http_select_step2) ? "http_select_step2"
: (cb == http_select_step3) ? "http_select_step3"
: (cb == http_select_step4) ? "http_select_step4"
: (cb == http_select_step5) ? "http_select_step5"
: (cb == http_update_step2) ? "http_update_step2"
: (cb == http_update_step3) ? "http_update_step3"
: (cb == http_update_step4) ? "http_update_step4"
: (cb == http_update_step5) ? "http_update_step5"
: (cb == canonical_recurse_directory) ? "canonical_recurse_directory"
: (cb == permissions_check) ? "permissions_check"
: (cb == permissions_write_check) ? "permissions_write_check"
#else
: (cb == ws_raw_step2) ? "ws_raw_step2"
: (cb == ws_raw_step3) ? "ws_raw_step3"
: (cb == _raw_tuples_callback) ? "_raw_tuples_callback"
: (cb == _raw_tuples_check_callback) ? "_raw_tuples_check_callback"
: (cb == ws_tab_list_step2) ? "ws_tab_list_step2"
: (cb == ws_tab_read_step2) ? "ws_tab_read_step2"
: (cb == ws_tab_read_step3) ? "ws_tab_read_step3"
: (cb == ws_tab_read_step4) ? "ws_tab_read_step4"
: (cb == ws_tab_write_step2) ? "ws_tab_write_step2"
: (cb == ws_tab_write_step3) ? "ws_tab_write_step3"
: (cb == ws_tab_write_step4) ? "ws_tab_write_step4"
: (cb == ws_tab_move_step2) ? "ws_tab_move_step2"
#endif
: (cb == ws_select_step4) ? "ws_select_step4"
: (cb == ws_update_step2) ? "ws_update_step2"
: (cb == ws_update_step4) ? "ws_update_step4"
: (cb == ws_update_step5) ? "ws_update_step5"
: (cb == ws_update_step6) ? "ws_update_step6"
: (cb == DB_connect) ? "DB_connect"
: (cb == DB_get_column_types_for_query) ? "DB_get_column_types_for_query"
: (cb == DB_get_column_types) ? "DB_get_column_types"
: (cb == _increment_idle) ? "_increment_idle"
: (cb == _decrement_idle) ? "_decrement_idle"
: (cb == idle_cb) ? "idle_cb"
: (cb == ddl_readable) ? "ddl_readable"
: (cb == ev_now) ? "ev_now"
: (cb == ev_feed_event) ? "ev_feed_event"
: (cb == ev_feed_fd_event) ? "ev_feed_fd_event"
: (cb == ev_backend) ? "ev_backend"
: (cb == ev_iteration) ? "ev_iteration"
: (cb == ev_depth) ? "ev_depth"
: (cb == ev_set_io_collect_interval) ? "ev_set_io_collect_interval"
: (cb == ev_set_timeout_collect_interval) ? "ev_set_timeout_collect_interval"
: (cb == ev_set_userdata) ? "ev_set_userdata"
: (cb == ev_userdata) ? "ev_userdata"
: (cb == ev_set_invoke_pending_cb) ? "ev_set_invoke_pending_cb"
: (cb == ev_set_loop_release_cb) ? "ev_set_loop_release_cb"
: (cb == ev_loop_destroy) ? "ev_loop_destroy"
: (cb == ev_verify) ? "ev_verify"
: (cb == ev_loop_fork) ? "ev_loop_fork"
: (cb == ev_invoke) ? "ev_invoke"
: (cb == ev_pending_count) ? "ev_pending_count"
: (cb == ev_invoke_pending) ? "ev_invoke_pending"
: (cb == ev_run) ? "ev_run"
: (cb == ev_break) ? "ev_break"
: (cb == ev_ref) ? "ev_ref"
: (cb == ev_unref) ? "ev_unref"
: (cb == ev_now_update) ? "ev_now_update"
: (cb == ev_suspend) ? "ev_suspend"
: (cb == ev_resume) ? "ev_resume"
: (cb == ev_clear_pending) ? "ev_clear_pending"
: (cb == ev_io_start) ? "ev_io_start"
: (cb == ev_io_stop) ? "ev_io_stop"
: (cb == ev_timer_start) ? "ev_timer_start"
: (cb == ev_timer_stop) ? "ev_timer_stop"
: (cb == ev_timer_again) ? "ev_timer_again"
: (cb == ev_timer_remaining) ? "ev_timer_remaining"
: (cb == ev_periodic_start) ? "ev_periodic_start"
: (cb == ev_periodic_stop) ? "ev_periodic_stop"
: (cb == ev_periodic_again) ? "ev_periodic_again"
: (cb == ev_signal_start) ? "ev_signal_start"
: (cb == ev_signal_stop) ? "ev_signal_stop"
: (cb == ev_stat_stat) ? "ev_stat_stat"
: (cb == ev_stat_start) ? "ev_stat_start"
: (cb == ev_stat_stop) ? "ev_stat_stop"
: (cb == ev_idle_start) ? "ev_idle_start"
: (cb == ev_idle_stop) ? "ev_idle_stop"
: (cb == ev_prepare_start) ? "ev_prepare_start"
: (cb == ev_prepare_stop) ? "ev_prepare_stop"
: (cb == ev_check_start) ? "ev_check_start"
: (cb == ev_check_stop) ? "ev_check_stop"
: (cb == ev_embed_sweep) ? "ev_embed_sweep"
: (cb == ev_embed_start) ? "ev_embed_start"
: (cb == ev_embed_stop) ? "ev_embed_stop"
: (cb == ev_fork_start) ? "ev_fork_start"
: (cb == ev_fork_stop) ? "ev_fork_stop"
: (cb == ev_cleanup_start) ? "ev_cleanup_start"
: (cb == ev_cleanup_stop) ? "ev_cleanup_stop"
: (cb == ev_async_start) ? "ev_async_start"
: (cb == ev_async_stop) ? "ev_async_stop"
: (cb == ev_async_send) ? "ev_async_send"
: (cb == ev_once) ? "ev_once"
: "unknown watcher";
// clang-format on
}
| 37.981378 | 158 | 0.699647 |
1bfe6dd08071845a4a2cbf79c7323f076bc044b3 | 93 | c | C | tests/postests/global_reflexivity.c | ucsd-progsys/csolve-bak | 89cfeb5403e617f45ece4bae9f88f8e6cd7ca934 | [
"BSD-3-Clause"
] | null | null | null | tests/postests/global_reflexivity.c | ucsd-progsys/csolve-bak | 89cfeb5403e617f45ece4bae9f88f8e6cd7ca934 | [
"BSD-3-Clause"
] | 1 | 2018-04-24T10:43:07.000Z | 2018-04-24T10:43:07.000Z | tests/postests/global_reflexivity.c | ucsd-progsys/csolve-bak | 89cfeb5403e617f45ece4bae9f88f8e6cd7ca934 | [
"BSD-3-Clause"
] | null | null | null | #include <csolve.h>
int x;
void main () {
x = nondet ();
csolve_assert (x == x);
}
| 10.333333 | 27 | 0.516129 |
bc91b49a06bca0ca2779c62f44401aa386e869bb | 126 | h | C | PayrollSystem/PayrollSystem/HoldMethod.h | sxxlearn2rock/Payroll | dedc3f892268cb56d9e9263cc7f1f8d8576ac546 | [
"Apache-2.0"
] | null | null | null | PayrollSystem/PayrollSystem/HoldMethod.h | sxxlearn2rock/Payroll | dedc3f892268cb56d9e9263cc7f1f8d8576ac546 | [
"Apache-2.0"
] | null | null | null | PayrollSystem/PayrollSystem/HoldMethod.h | sxxlearn2rock/Payroll | dedc3f892268cb56d9e9263cc7f1f8d8576ac546 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "PaymentMethod.h"
class HoldMethod : public PaymentMethod
{
public:
HoldMethod();
~HoldMethod();
};
| 11.454545 | 39 | 0.722222 |
51579d4a947a17b3d1098e1663b057e38214b3d4 | 439 | h | C | client2.h | manachyn/udt4-node-addon | 173220d2fd37b5671e96a2fe9eaa86731dc521ef | [
"MIT"
] | null | null | null | client2.h | manachyn/udt4-node-addon | 173220d2fd37b5671e96a2fe9eaa86731dc521ef | [
"MIT"
] | null | null | null | client2.h | manachyn/udt4-node-addon | 173220d2fd37b5671e96a2fe9eaa86731dc521ef | [
"MIT"
] | null | null | null | #include <node.h>
#include <nan.h>
namespace udt4 {
class Client : public node::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> exports);
Client ();
~Client ();
private:
static NAN_METHOD(New);
static NAN_METHOD(FireMetrics);
static NAN_METHOD(Connect);
static NAN_METHOD(Write);
static NAN_METHOD(End);
static v8::Persistent<v8::Function> constructor;
};
}
| 23.105263 | 55 | 0.630979 |
867c072427796d68ce131638eaa8de3acfda2ee0 | 293 | h | C | SobotKit/SobotKit/UI/cell/ZCRichTextChatCell.h | ZCSDK/Sobot_iOS_SDK_Source | f9015e54283ba9ed5186deadb1e2e4d89df91e4a | [
"MIT"
] | 1 | 2018-08-23T11:30:21.000Z | 2018-08-23T11:30:21.000Z | SobotKit/SobotKit/UI/cell/ZCRichTextChatCell.h | ZCSDK/Sobot_iOS_SDK_Source | f9015e54283ba9ed5186deadb1e2e4d89df91e4a | [
"MIT"
] | 1 | 2019-10-15T08:23:54.000Z | 2019-10-15T08:23:54.000Z | SobotKit/SobotKit/UI/cell/ZCRichTextChatCell.h | ZCSDK/Sobot_iOS_SDK_Source | f9015e54283ba9ed5186deadb1e2e4d89df91e4a | [
"MIT"
] | null | null | null | //
// ZCTextChatCell.h
// SobotApp
//
// Created by 张新耀 on 15/9/15.
// Copyright (c) 2015年 com.sobot.chat. All rights reserved.
//
#import "ZCChatBaseCell.h"
#import "ZCMLEmojiLabel.h"
/**
* 富媒体cell
* 图片放大 电话链接 cell大小根据内容自适应
*/
@interface ZCRichTextChatCell : ZCChatBaseCell
@end
| 14.65 | 60 | 0.682594 |
220948abe5e281e0aac3712422b725097bc4c521 | 4,923 | h | C | Shared/Utility/include/TextConversionTables.h | wayfinder/Wayfinder-Server | a688546589f246ee12a8a167a568a9c4c4ef8151 | [
"BSD-3-Clause"
] | 4 | 2015-08-17T20:12:22.000Z | 2020-05-30T19:53:26.000Z | Shared/Utility/include/TextConversionTables.h | wayfinder/Wayfinder-Server | a688546589f246ee12a8a167a568a9c4c4ef8151 | [
"BSD-3-Clause"
] | null | null | null | Shared/Utility/include/TextConversionTables.h | wayfinder/Wayfinder-Server | a688546589f246ee12a8a167a568a9c4c4ef8151 | [
"BSD-3-Clause"
] | null | null | null | /*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Vodafone Group Services Ltd 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.
*/
/*
* NOTE! This file is machine generated - do not edit directly!!!
* cmdline: ./Shared/src/genTextConvTables.py
* http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
* http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
* Shared/include/TextConversionTables.h
* Shared/include/TextConversionTables.h Shared/src/TextConversionTables.cpp
*/
#ifndef TEXT_CONVERSUIONT_AATBLES_H
#define TEXT_CONVERSUIONT_AATBLES_H
#include "config.h"
#include <algorithm>
class TextConversionTables {
public:
/**
* One entry in a conv table.
*/
struct convTable_entry {
/// The unicode character to be converted
const uint32 unicodeChar;
/// The utf-8 string of the converted character
const char* const utf8String;
/// Length of the utf-8 string.
const int utf8Length;
};
/**
* A table of convTable_entry. Also contains the number
* of entries in the table.
*/
struct convTable {
uint32 nbrEntries;
const convTable_entry* const entries;
};
class ConvEntryComp {
public:
bool operator()(const convTable_entry& a, const convTable_entry& b) {
return a.unicodeChar < b.unicodeChar;
}
bool operator()(const convTable_entry& a, uint32 code ) {
return a.unicodeChar < code;
}
};
/// Result of a findInTable operation.
struct convTableFindRes {
convTableFindRes( const char* aStr, int aLen ) : resString(aStr),
resStringLength(aLen) {}
const char* resString;
int resStringLength;
};
/**
* Looks for the code <code>code</code> in the table <code>table</code>.
* @param table Table to search.
* @param code Code to look for.
* @return Result with string set to NULL and length set to zero
* if not found.
*/
static convTableFindRes findInTable( const convTable& table,
uint32 code ) {
const convTable_entry* begin = table.entries;
const convTable_entry* end = table.entries + table.nbrEntries;
const convTable_entry* found = std::lower_bound( begin, end,
code,
ConvEntryComp() );
if ( found->unicodeChar == code ) {
return convTableFindRes(found->utf8String,
found->utf8Length );
} else {
return convTableFindRes(NULL, 0);
}
}
/*
* Table to convert from upper to lower case. If a character does not
* exist in the table, it should be kept as is
*/
static convTable c_lowerTable;
/*
* Table to convert from lower to uppercase. If a character does not
* exist in the table, it should be kept as is.
*/
static convTable c_upperTable;
/*
* Table remove strange characters and convert accented characters to
* non-accented ones. For use in the SM. If a character does not exist
* in the table, it should be removed. If a space is returned, the
* character corresponds to a space.
*/
static convTable c_removeStrange;
private:
static convTable_entry c_lowerTableEntries [825];
static convTable_entry c_upperTableEntries [834];
static convTable_entry c_removeStrangeEntries [30254];
};
#endif
| 40.02439 | 755 | 0.678448 |
618e7882c4b3083a4b51375f9196fa922bbf79ec | 2,879 | h | C | source/gameengine/Ketsji/KX_BlenderMaterial.h | lordloki/upbge | 18d0f5419cc1338ecf739362afef56bd96b42cfb | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 1 | 2022-01-11T10:02:21.000Z | 2022-01-11T10:02:21.000Z | source/gameengine/Ketsji/KX_BlenderMaterial.h | lordloki/upbge | 18d0f5419cc1338ecf739362afef56bd96b42cfb | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | source/gameengine/Ketsji/KX_BlenderMaterial.h | lordloki/upbge | 18d0f5419cc1338ecf739362afef56bd96b42cfb | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null |
/** \file KX_BlenderMaterial.h
* \ingroup ketsji
*/
#pragma once
#include "BL_Texture.h"
#include "EXP_Value.h"
#include "MT_Vector3.h"
#include "MT_Vector4.h"
#include "RAS_IPolygonMaterial.h"
class SCA_IScene;
class KX_Scene;
class RAS_Rasterizer;
class KX_MaterialShader;
struct Material;
struct GPUMaterial;
class KX_BlenderMaterial : public CValue, public RAS_IPolyMaterial {
Py_Header
public : KX_BlenderMaterial(RAS_Rasterizer *rasty,
KX_Scene *scene,
Material *mat,
const std::string &name,
GameSettings *game,
int lightlayer,
bool converting_during_runtime);
virtual ~KX_BlenderMaterial();
virtual RAS_MaterialShader *GetShader() const;
virtual const std::string GetTextureName() const;
virtual Material *GetBlenderMaterial() const;
virtual bool UsesLighting() const;
virtual void GetRGBAColor(unsigned char *rgba) const;
virtual Scene *GetBlenderScene() const;
virtual SCA_IScene *GetScene() const;
virtual void ReleaseMaterial();
unsigned int *GetBlendFunc()
{
return m_blendFunc;
}
// for ipos
virtual void UpdateIPO(MT_Vector4 rgba,
MT_Vector3 specrgb,
MT_Scalar hard,
MT_Scalar spec,
MT_Scalar ref,
MT_Scalar emit,
MT_Scalar ambient,
MT_Scalar alpha,
MT_Scalar specalpha);
void ReplaceScene(KX_Scene *scene);
// Stuff for cvalue related things.
virtual std::string GetName();
#ifdef WITH_PYTHON
static PyObject *pyattr_get_materialIndex(PyObjectPlus *self_v,
const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject *pyattr_get_textures(PyObjectPlus *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
KX_PYMETHOD_DOC(KX_BlenderMaterial, getShader);
KX_PYMETHOD_DOC(KX_BlenderMaterial, setBlending);
#endif // WITH_PYTHON
virtual void OnConstruction();
static void EndFrame(RAS_Rasterizer *rasty);
private:
GPUMaterial *m_gpuMat;
Material *m_material;
std::unique_ptr<KX_MaterialShader> m_shader;
RAS_Rasterizer *m_rasterizer;
KX_Scene *m_scene;
bool m_userDefBlend;
unsigned int m_blendFunc[2];
bool m_constructed; // if false, don't clean on exit
int m_lightLayer;
void InitTextures();
void SetShaderData(RAS_Rasterizer *ras);
// cleanup stuff
void OnExit();
};
#ifdef WITH_PYTHON
bool ConvertPythonToMaterial(PyObject *value,
KX_BlenderMaterial **material,
bool py_none_ok,
const char *error_prefix);
#endif // WITH_PYTHON
| 27.160377 | 96 | 0.626259 |
c324c2fc05f55f9349e9a39464e2d331f34b9c2f | 2,701 | h | C | src/prod/src/Reliability/LoadBalancing/ScaleoutCountConstraint.h | AnthonyM/service-fabric | c396ea918714ea52eab9c94fd62e018cc2e09a68 | [
"MIT"
] | 2,542 | 2018-03-14T21:56:12.000Z | 2019-05-06T01:18:20.000Z | src/prod/src/Reliability/LoadBalancing/ScaleoutCountConstraint.h | AnthonyM/service-fabric | c396ea918714ea52eab9c94fd62e018cc2e09a68 | [
"MIT"
] | 994 | 2019-05-07T02:39:30.000Z | 2022-03-31T13:23:04.000Z | src/prod/src/Reliability/LoadBalancing/ScaleoutCountConstraint.h | AnthonyM/service-fabric | c396ea918714ea52eab9c94fd62e018cc2e09a68 | [
"MIT"
] | 300 | 2018-03-14T21:57:17.000Z | 2019-05-06T20:07:00.000Z | // ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------
#pragma once
#include "IConstraint.h"
namespace Reliability
{
namespace LoadBalancingComponent
{
class ApplicationEntry;
class ScaleoutCountSubspace : public ISubspace
{
DENY_COPY(ScaleoutCountSubspace);
public:
ScaleoutCountSubspace(std::map<ApplicationEntry const*, std::set<NodeEntry const*>> && applicationNodes, bool relaxed);
virtual void GetTargetNodes(
TempSolution const& tempSolution,
PlacementReplica const* replica,
NodeSet & candidateNodes,
bool useNodeBufferCapacity,
NodeToConstraintDiagnosticsDataMapSPtr const nodeToConstraintDiagnosticsDataMapSPtr = nullptr) const;
virtual IConstraint::Enum get_Type() const { return IConstraint::ScaleoutCount; }
virtual ~ScaleoutCountSubspace() {}
private:
std::map<ApplicationEntry const*, std::set<NodeEntry const *>> applicationNodes_;
bool relaxed_;
};
class ScaleoutCountConstraint : public IDynamicConstraint
{
DENY_COPY(ScaleoutCountConstraint);
public:
ScaleoutCountConstraint(int priority);
virtual Enum get_Type() const { return Enum::ScaleoutCount; }
virtual IViolationUPtr GetViolations(
TempSolution const& solution,
bool changedOnly,
bool relaxed,
bool useNodeBufferCapacity,
Common::Random& random) const;
virtual ConstraintCheckResult CheckSolutionAndGenerateSubspace(
TempSolution const& tempSolution,
bool changedOnly,
bool relaxed,
bool useNodeBufferCapacity,
Common::Random & random,
std::shared_ptr<IConstraintDiagnosticsData> const diagnosticsDataPtr = nullptr) const;
virtual ~ScaleoutCountConstraint(){}
private:
PlacementReplicaSet GetInvalidReplicas(
TempSolution const& tempSolution,
bool changedOnly,
bool relaxed,
Common::Random & random,
std::map<ApplicationEntry const*, std::set<NodeEntry const *>> & appNodes,
std::shared_ptr<IConstraintDiagnosticsData> const diagnosticsDataPtr = nullptr) const;
};
}
}
| 37 | 131 | 0.594224 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.