file
stringlengths 18
26
| data
stringlengths 3
1.04M
|
---|---|
the_stack_data/88691.c | #include <stdio.h>
/* anything that starts with # is processed first
* by the compiler. It is then replaced in the code
* file by its respective value. <> brackets mean
* that the compiler should search for the file inside
* them. stdio.h should exist in the default includes
* directory since it was provided without a path.
* if you want a specific file included you include it by path using quotes
* instead of carets(?). so #include "/usr/include/stdio.h"
*/
int main(void) // int is the return type, main is the function name
// and void means no arguments
{
printf("from sea to shining C\n"); //printf doesn't insert newlines.
return 0; // makes the compiler happy
}
|
the_stack_data/111079456.c | #line 1
void __globinit_three_step(void) ;
#line 1
void *_coverage_fout ;
/* compiler builtin:
void __builtin_varargs_start(__builtin_va_list ) ; */
/* compiler builtin:
int __builtin_strcmp(char const * , char const * ) ; */
/* compiler builtin:
void *__builtin___memmove_chk(void * , void const * , unsigned long ,
unsigned long ) ; */
/* compiler builtin:
char *__builtin_strpbrk(char const * , char const * ) ; */
/* compiler builtin:
void *__builtin_memcpy(void * , void const * , unsigned long ) ; */
/* compiler builtin:
double __builtin_exp(double ) ; */
/* compiler builtin:
long double __builtin_nanl(char const * ) ; */
/* compiler builtin:
double __builtin_cos(double ) ; */
/* compiler builtin:
char *__builtin_strchr(char * , int ) ; */
/* compiler builtin:
float __builtin_atan2f(float , float ) ; */
/* compiler builtin:
void *__builtin___memcpy_chk(void * , void const * , unsigned long ,
unsigned long ) ; */
/* compiler builtin:
double __builtin_asin(double ) ; */
/* compiler builtin:
int __builtin_ctz(unsigned int ) ; */
/* compiler builtin:
char *__builtin_stpcpy(char * , char const * ) ; */
/* compiler builtin:
double __builtin_nans(char const * ) ; */
/* compiler builtin:
long double __builtin_atan2l(long double , long double ) ; */
/* compiler builtin:
float __builtin_logf(float ) ; */
/* compiler builtin:
int __builtin___fprintf_chk(void * , int , char const * , ...) ; */
/* compiler builtin:
int __builtin___vsprintf_chk(char * , int , unsigned long ,
char const * , __builtin_va_list ) ; */
/* compiler builtin:
char *__builtin___strncpy_chk(char * , char const * , unsigned long ,
unsigned long ) ; */
/* compiler builtin:
float __builtin_log10f(float ) ; */
/* compiler builtin:
double __builtin_atan(double ) ; */
/* compiler builtin:
void *__builtin_alloca(unsigned long ) ; */
/* compiler builtin:
void __builtin_va_end(__builtin_va_list ) ; */
/* compiler builtin:
int __builtin_strncmp(char const * , char const * , unsigned long ) ; */
/* compiler builtin:
double __builtin_sin(double ) ; */
/* compiler builtin:
long double __builtin_logl(long double ) ; */
/* compiler builtin:
float __builtin_coshf(float ) ; */
/* compiler builtin:
void *__builtin___mempcpy_chk(void * , void const * , unsigned long ,
unsigned long ) ; */
/* compiler builtin:
char *__builtin___strcat_chk(char * , char const * , unsigned long ) ; */
/* compiler builtin:
float __builtin_nansf(char const * ) ; */
/* compiler builtin:
void *__builtin_memset(void * , int , int ) ; */
/* compiler builtin:
void __builtin_va_copy(__builtin_va_list , __builtin_va_list ) ; */
/* compiler builtin:
float __builtin_sinhf(float ) ; */
/* compiler builtin:
long double __builtin_log10l(long double ) ; */
/* compiler builtin:
long double __builtin_coshl(long double ) ; */
/* compiler builtin:
int __builtin_ffs(unsigned int ) ; */
/* compiler builtin:
float __builtin_asinf(float ) ; */
/* compiler builtin:
long double __builtin_nansl(char const * ) ; */
/* compiler builtin:
double __builtin_frexp(double , int * ) ; */
/* compiler builtin:
double __builtin_tan(double ) ; */
/* compiler builtin:
long double __builtin_sinhl(long double ) ; */
/* compiler builtin:
float __builtin_frexpf(float , int * ) ; */
/* compiler builtin:
long double __builtin_asinl(long double ) ; */
/* compiler builtin:
void *__builtin_frame_address(unsigned int ) ; */
/* compiler builtin:
double __builtin_floor(double ) ; */
/* compiler builtin:
float __builtin_tanhf(float ) ; */
/* compiler builtin:
int __builtin_parityl(unsigned long ) ; */
/* compiler builtin:
int __builtin_clzl(unsigned long ) ; */
/* compiler builtin:
double __builtin_powi(double , int ) ; */
/* compiler builtin:
long double __builtin_frexpl(long double , int * ) ; */
/* compiler builtin:
float __builtin_atanf(float ) ; */
/* compiler builtin:
float __builtin_huge_valf(void) ; */
/* compiler builtin:
float __builtin_sqrtf(float ) ; */
/* compiler builtin:
float __builtin_fmodf(float ) ; */
/* compiler builtin:
unsigned long __builtin_object_size(void * , int ) ; */
/* compiler builtin:
void __builtin_va_arg(__builtin_va_list , unsigned long , void * ) ; */
/* compiler builtin:
void __builtin_stdarg_start(__builtin_va_list ) ; */
/* compiler builtin:
long double __builtin_tanhl(long double ) ; */
/* compiler builtin:
double __builtin_nan(char const * ) ; */
/* compiler builtin:
void __builtin_return(void const * ) ; */
/* compiler builtin:
long double __builtin_atanl(long double ) ; */
/* compiler builtin:
long double __builtin_huge_vall(void) ; */
/* compiler builtin:
float __builtin_inff(void) ; */
/* compiler builtin:
long double __builtin_sqrtl(long double ) ; */
/* compiler builtin:
long double __builtin_fmodl(long double ) ; */
/* compiler builtin:
int __builtin___printf_chk(int , char const * , ...) ; */
/* compiler builtin:
float __builtin_floorf(float ) ; */
/* compiler builtin:
float __builtin_fabsf(float ) ; */
/* compiler builtin:
int __builtin_popcountll(unsigned long long ) ; */
/* compiler builtin:
int __builtin___sprintf_chk(char * , int , unsigned long , char const *
, ...) ; */
/* compiler builtin:
int __builtin___vprintf_chk(int , char const * , __builtin_va_list ) ; */
/* compiler builtin:
int __builtin___snprintf_chk(char * , unsigned long , int ,
unsigned long , char const * , ...) ; */
/* compiler builtin:
long double __builtin_infl(void) ; */
/* compiler builtin:
void *__builtin_mempcpy(void * , void const * , unsigned long ) ; */
/* compiler builtin:
long double __builtin_floorl(long double ) ; */
/* compiler builtin:
int __builtin_ctzl(unsigned long ) ; */
/* compiler builtin:
long double __builtin_fabsl(long double ) ; */
/* compiler builtin:
int __builtin_clz(unsigned int ) ; */
/* compiler builtin:
double __builtin_fabs(double ) ; */
/* compiler builtin:
int __builtin_popcount(unsigned int ) ; */
/* compiler builtin:
double __builtin_ceil(double ) ; */
/* compiler builtin:
double __builtin_ldexp(double , int ) ; */
/* compiler builtin:
float __builtin_sinf(float ) ; */
/* compiler builtin:
float __builtin_acosf(float ) ; */
/* compiler builtin:
int __builtin___vsnprintf_chk(char * , unsigned long , int ,
unsigned long , char const * ,
__builtin_va_list ) ; */
/* compiler builtin:
double __builtin_sinh(double ) ; */
/* compiler builtin:
int __builtin_ffsll(unsigned long long ) ; */
/* compiler builtin:
char *__builtin___strcpy_chk(char * , char const * , unsigned long ) ; */
/* compiler builtin:
double __builtin_inf(void) ; */
/* compiler builtin:
void __builtin_prefetch(void const * , ...) ; */
/* compiler builtin:
long double __builtin_sinl(long double ) ; */
/* compiler builtin:
long double __builtin_acosl(long double ) ; */
/* compiler builtin:
double __builtin_sqrt(double ) ; */
/* compiler builtin:
double __builtin_fmod(double ) ; */
/* compiler builtin:
char *__builtin_strcpy(char * , char const * ) ; */
/* compiler builtin:
float __builtin_ceilf(float ) ; */
/* compiler builtin:
void *__builtin_return_address(unsigned int ) ; */
/* compiler builtin:
char *__builtin___stpcpy_chk(char * , char const * , unsigned long ) ; */
/* compiler builtin:
float __builtin_tanf(float ) ; */
/* compiler builtin:
int __builtin_parityll(unsigned long long ) ; */
/* compiler builtin:
float __builtin_ldexpf(float , int ) ; */
/* compiler builtin:
int __builtin_types_compatible_p(unsigned long , unsigned long ) ; */
/* compiler builtin:
double __builtin_log10(double ) ; */
/* compiler builtin:
float __builtin_expf(float ) ; */
/* compiler builtin:
int __builtin_clzll(unsigned long long ) ; */
/* compiler builtin:
double __builtin_tanh(double ) ; */
/* compiler builtin:
int __builtin_constant_p(int ) ; */
/* compiler builtin:
long double __builtin_ceill(long double ) ; */
/* compiler builtin:
long double __builtin_tanl(long double ) ; */
/* compiler builtin:
double __builtin_log(double ) ; */
/* compiler builtin:
long double __builtin_ldexpl(long double , int ) ; */
/* compiler builtin:
long double __builtin_expl(long double ) ; */
/* compiler builtin:
int __builtin_popcountl(unsigned long ) ; */
/* compiler builtin:
void *__builtin___memset_chk(void * , int , unsigned long , unsigned long ) ; */
/* compiler builtin:
char *__builtin___strncat_chk(char * , char const * , unsigned long ,
unsigned long ) ; */
/* compiler builtin:
double __builtin_huge_val(void) ; */
/* compiler builtin:
__builtin_va_list __builtin_next_arg(void) ; */
/* compiler builtin:
float __builtin_powif(float , int ) ; */
/* compiler builtin:
int __builtin___vfprintf_chk(void * , int , char const * ,
__builtin_va_list ) ; */
/* compiler builtin:
float __builtin_modff(float , float * ) ; */
/* compiler builtin:
double __builtin_atan2(double , double ) ; */
/* compiler builtin:
char *__builtin_strncpy(char * , char const * , unsigned long ) ; */
/* compiler builtin:
long double __builtin_powil(long double , int ) ; */
/* compiler builtin:
float __builtin_cosf(float ) ; */
/* compiler builtin:
unsigned long __builtin_strspn(char const * , char const * ) ; */
/* compiler builtin:
long double __builtin_modfl(long double , long double * ) ; */
/* compiler builtin:
int __builtin_parity(unsigned int ) ; */
/* compiler builtin:
double __builtin_cosh(double ) ; */
/* compiler builtin:
char *__builtin_strncat(char * , char const * , unsigned long ) ; */
/* compiler builtin:
long __builtin_expect(long , long ) ; */
/* compiler builtin:
double __builtin_acos(double ) ; */
/* compiler builtin:
long double __builtin_cosl(long double ) ; */
/* compiler builtin:
void __builtin_va_start(__builtin_va_list ) ; */
/* compiler builtin:
int __builtin_ctzll(unsigned long long ) ; */
/* compiler builtin:
unsigned long __builtin_strcspn(char const * , char const * ) ; */
/* compiler builtin:
int __builtin_ffsl(unsigned long ) ; */
/* compiler builtin:
float __builtin_nanf(char const * ) ; */
#line 2
extern int ( /* missing proto */ atoi)() ;
#line 11
extern int ( /* missing proto */ printf)() ;
#line 1 "three-step.c"
int main(int argv , char **argc )
{ int x ;
int tmp ;
int p1 ;
int p2 ;
int p3 ;
int now ;
{
__globinit_three_step();
#line 1
fprintf(_coverage_fout, "13\n");
#line 1
fflush(_coverage_fout);
#line 2
tmp = atoi(*(argc + 1));
#line 1
fprintf(_coverage_fout, "14\n");
#line 1
fflush(_coverage_fout);
#line 2
x = tmp;
#line 1
fprintf(_coverage_fout, "15\n");
#line 1
fflush(_coverage_fout);
#line 3
p1 = 0;
#line 1
fprintf(_coverage_fout, "16\n");
#line 1
fflush(_coverage_fout);
#line 4
p2 = 0;
#line 1
fprintf(_coverage_fout, "17\n");
#line 1
fflush(_coverage_fout);
#line 5
p3 = 0;
#line 1
fprintf(_coverage_fout, "18\n");
#line 1
fflush(_coverage_fout);
#line 9
now = (p1 + p2) + p3;
#line 1
fprintf(_coverage_fout, "19\n");
#line 1
fflush(_coverage_fout);
#line 10
if (x == 1) {
#line 10
fprintf(_coverage_fout, "1\n");
#line 10
fflush(_coverage_fout);
#line 11
printf("%d:%d:%d\n", x, (p1 - p2) - p3, now == (p1 + p2) + p3);
} else {
#line 10
fprintf(_coverage_fout, "2\n");
#line 10
fflush(_coverage_fout);
}
#line 1
fprintf(_coverage_fout, "20\n");
#line 1
fflush(_coverage_fout);
#line 13
if (x == 2) {
#line 13
fprintf(_coverage_fout, "3\n");
#line 13
fflush(_coverage_fout);
#line 14
printf("%d:%d:%d\n", x, (p1 - p2) - p3, now == (p1 + p2) + p3);
} else {
#line 13
fprintf(_coverage_fout, "4\n");
#line 13
fflush(_coverage_fout);
}
#line 1
fprintf(_coverage_fout, "21\n");
#line 1
fflush(_coverage_fout);
#line 16
if (x == 3) {
#line 16
fprintf(_coverage_fout, "5\n");
#line 16
fflush(_coverage_fout);
#line 17
printf("%d:%d:%d\n", x, (p1 - p2) - p3, now == (p1 + p2) + p3);
} else {
#line 16
fprintf(_coverage_fout, "6\n");
#line 16
fflush(_coverage_fout);
}
#line 1
fprintf(_coverage_fout, "22\n");
#line 1
fflush(_coverage_fout);
#line 19
if (x == 4) {
#line 19
fprintf(_coverage_fout, "7\n");
#line 19
fflush(_coverage_fout);
#line 20
printf("%d:%d:%d\n", x, (p1 - p2) - p3, now == (p1 + p2) + p3);
} else {
#line 19
fprintf(_coverage_fout, "8\n");
#line 19
fflush(_coverage_fout);
}
#line 1
fprintf(_coverage_fout, "23\n");
#line 1
fflush(_coverage_fout);
#line 22
if (x == 5) {
#line 22
fprintf(_coverage_fout, "9\n");
#line 22
fflush(_coverage_fout);
#line 23
printf("%d:%d:%d\n", x, (p1 - p2) - p3, now == (p1 + p2) + p3);
} else {
#line 22
fprintf(_coverage_fout, "10\n");
#line 22
fflush(_coverage_fout);
}
#line 1
fprintf(_coverage_fout, "24\n");
#line 1
fflush(_coverage_fout);
#line 25
if (x == 666) {
#line 25
fprintf(_coverage_fout, "11\n");
#line 25
fflush(_coverage_fout);
#line 26
printf("%d:%d:%d:%d\n", x, (p1 + p2) + p3, (p1 - p2) - p3,
now == (p1 + p2) + p3);
} else {
#line 25
fprintf(_coverage_fout, "12\n");
#line 25
fflush(_coverage_fout);
}
#line 1
fprintf(_coverage_fout, "25\n");
#line 1
fflush(_coverage_fout);
#line 28
p1 = 7;
#line 1
fprintf(_coverage_fout, "26\n");
#line 1
fflush(_coverage_fout);
#line 29
p2 = 3;
#line 1
fprintf(_coverage_fout, "27\n");
#line 1
fflush(_coverage_fout);
#line 30
p3 = 4;
#line 1
fprintf(_coverage_fout, "28\n");
#line 1
fflush(_coverage_fout);
#line 31
return (0);
}
}
void __globinit_three_step(void)
{
{
#line 1
_coverage_fout = fopen("coverage.path", "wb");
}
}
|
the_stack_data/89519.c | #include <stdio.h>
int main(void)
{
float salary;
printf("\aEnter your desired monthly salary:");
printf("$_______\b\b\b\b\b\b\b");
scanf("%f", &salary);
printf("\n\t$%.2f a month is $%.2f a year.", salary, salary*12.0);
printf("\rGee!\n");
return 0;
} |
the_stack_data/147120.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <omp.h>
#include <math.h>
#include <sys/time.h>
//#include <mkl.h>
#define N 8192
double rtclock() {
struct timezone Tzp;
struct timeval Tp;
int stat;
stat = gettimeofday (&Tp, &Tzp);
if (stat != 0) printf("Error return from gettimeofday: %d",stat);
return(Tp.tv_sec + Tp.tv_usec*1.0e-6);
}
float A[N][N], B[N][N], C[N][N];
/* Simple "naive" method to multiply two square matrices A and B to generate matrix C. */
//void myMult(int n, float *A, float *B, float *C) {
//void myMult(int n, float A[N][N], float B[N][N], float C[N][N]) {
void myMult() {
//int i, j, k;
#pragma omp target map(to:A, B) map(tofrom:C)
//#pragma omp target data map(to:A[0:n*n], B[0:n*n], n) map(tofrom:C[0:n*n])
#pragma omp parallel for
for(int i = 0; i < N; ++i)
for(int k = 0; k < N; ++k)
for(int j = 0; j < N; ++j)
//C[i*n+j] += A[i*n+k] * B[k*n+j];
C[i][j] = A[i][k] * B[k][j];
}
int main(int argc, char *argv[]) {
if(argc != 4) {
fprintf(stderr, "Use: %s size nThreads nIter\n", argv[0]);
return -1;
}
int i, j, k, nt;
//int N = atoi(argv[1]);
int nThreads = atoi(argv[2]);
int nIter = atoi(argv[3]);
omp_set_num_threads(nThreads);
memset(A, 0, N * N * sizeof(float));
memset(B, 0, N * N * sizeof(float));
memset(C, 0, N * N * sizeof(float));
//float *A = malloc(sizeof(float)*N*N);
//float *B = malloc(sizeof(float)*N*N);
//float *C = malloc(sizeof(float)*N*N);
//#pragma omp parallel
// nt = omp_get_num_threads();
// printf("%s nThreads %d matrix size %d\n", argv[0], nt, N);
printf("Initializing input matrices...\n");
//#pragma omp parallel for private(i,j)
for(i = 0; i < N; ++i) {
for(j = 0; j < N; ++j) {
//A[i*N+j] = 1.0f;
//B[i*N+j] = 1.0f;
//C[i*N+j] = 0.0f;
A[i][j] = 1.0f;
B[i][j] = 1.0f;
C[i][j] = 0.0f;
}
}
printf("warm up run to overcome setup overhead\n");
//myMult(N, A, B, C);
myMult();
double aveTime, minTime=1e6, maxTime=0.0f;
printf("run the matrix multiplication function %d times\n", nIter);
for(i=0; i < nIter; i++) {
double startTime = rtclock();
//myMult(N, A, B, C);
myMult();
double endTime = rtclock();
double runtime = endTime - startTime;
maxTime=(maxTime > runtime)?maxTime:runtime;
minTime=(minTime < runtime)?minTime:runtime;
aveTime += runtime;
printf("Iteration %d: runtime %.3f\n", i, runtime);
}
aveTime /= nIter;
printf("maxRT %g minRT %g aveRT %g GFlop/s %g\n", maxTime, minTime, aveTime, 2e-9*N*N*N/aveTime);
// free(A);
// free(B);
// free(C);
return 0;
}
|
the_stack_data/20450125.c | /* { dg-do compile { target alpha*-*-* } } */
/* { dg-options "-O2 -mieee" } */
double foo (void);
void bar (float, float);
void test (void)
{
float f, g;
f = foo();
g = foo();
asm ("");
bar (f, g);
}
|
the_stack_data/179832056.c | /*
* Generated with F77compiler by @sthfaceless
*/
/*
* include standard C libs
* */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <complex.h>
typedef long double complex _complex;
/*
* shorts for allocating memory for primitive pointers
* */
#define N_INT(n) (int*) malloc(sizeof(int) * n)
#define N_LONG(n) (long*) malloc(sizeof(long) * n)
#define N_LD(n) (long double*) malloc(sizeof(long double) * n)
#define N_CHAR(n) (char*) malloc(sizeof(char) * n)
#define N_COMPLEX(n) (_complex*) malloc(sizeof(_complex) * n)
/*
* wrap primitives with pointers as it's default type in fortran 77
* */
int *_wrap_int(int _val) {
int *_res = N_INT(1);
*_res = _val;
return _res;
}
long *_wrap_long(long _val) {
long *_res = N_LONG(1);
*_res = _val;
return _res;
}
long double *_wrap_long_double(long double _val) {
long double *_res = N_LD(1);
*_res = _val;
return _res;
}
_complex *_wrap_complex(_complex _val) {
_complex *_res = N_COMPLEX(1);
*_res = _val;
return _res;
}
char *_wrap_char(char _val) {
char *_res = N_CHAR(1);
*_res = _val;
return _res;
}
/*
* cast primitives to string
* */
char *_int_to_string(int val) {
char *_res = N_CHAR(16);
sprintf(_res, "%d", val);
return _res;
}
char *_long_to_string(long val) {
char *_res = N_CHAR(32);
sprintf(_res, "%ld", val);
return _res;
}
char *_double_to_string(long double val) {
char *_res = N_CHAR(32);
sprintf(_res, "%Lf", val);
return _res;
}
char *_complex_to_string(_complex _val) {
char *_res = N_CHAR(128);
sprintf(_res, "%Lf", creall(_val));
if (cimagl(_val) != 0) {
int _len = strlen(_res);
sprintf(_res + _len, "%Lfi", cimagl(_val));
}
return _res;
}
/*
* concatenate strings in '+' statement
* */
char *_str_add(char *l, char *r) {
int l_size = strlen(l), r_size = strlen(r);
char *res = N_CHAR(l_size + r_size + 1);
memcpy(res, l, l_size);
memcpy(res + l_size, r, r_size);
res[l_size + r_size] = 0;
return res;
}
/*
* for input / output streams
* */
FILE *_io_units[100];
/*
* Begin FORTRAN 77 code
* */
long double* _icount (long double *_ifirst, long double *_isecond) {
long double *_icount = malloc(sizeof(long double));
long double *_x = _str_add(_long_to_string(12),"asds");
*_ifirst = *_ifirst + *_isecond;
*_icount = powl(*_ifirst, powl(*_isecond, powl(*_ifirst, *_isecond)));
return _icount;
}
long* _getLevel (long *_level) {
long *_getLevel = malloc(sizeof(long));
for (long *_item = _wrap_long(1);*_item <= *_level; *_item += *_level * 2){
if(*_item <= *_level) {
fprintf(stdout, "%ld %ld %s\n", *_item, *_item * 2, _str_add(_long_to_string(*_item)," asd"));
}else {
if(*_level >= *_level) {
*_getLevel = _str_add(_long_to_string(25),"111");
}else if(*_level >= *_level) {
*_getLevel = pow(26, 31);
if(2 <= *_item) {
_icount(_level, _item);
}
}else {
for (long *_j = _wrap_long(1);*_j <= *_level; *_j += 22){
fprintf(stdout, "%ld\n", 23);
}
}
fprintf(stdout, "%s\n", "end");
sleep(10);
}
}
return _getLevel;
}
//
// This program reads n points from a data file and stores them in
// 3 arrays x, y, z.
//
int main(int argc, char **args){
long *_nmax = malloc(sizeof(long));
long *_n = malloc(sizeof(long));
long double *_x = malloc(sizeof(long double));
long double *_y = malloc(sizeof(long double));
long double *_z = malloc(sizeof(long double));
_complex *_r = _wrap_complex((10, 131));
_complex *_w = _wrap_complex((1e3, 30e6));
_complex *_a = malloc(sizeof(_complex));
*_a = *_r * *_w + (*_x, *_y) - (34, 31) * (31, 31);
*_nmax = 1000;
// Open the data file
_io_units[20] = fopen("points.dat", "a+t");
// Read the number of points
fscanf(_io_units[20], "%ld", _n);
if(*_n > *_nmax) {
fprintf(stdout, "%s %ld %s %ld\n", "Error: n = ", *_n, "is larger than nmax =", *_getLevel(_nmax));
}
for (long *_i = _wrap_long(1);*_i <= *_n; *_i += 5 * *_n + *_icount(_wrap_long(48), _wrap_long(37 - *_n))){
fscanf(_io_units[20], "%Lf %Lf %Lf", _x, _y, _z);
while (1 <= 2){
fprintf(stdout, "%s\n", _str_add("123",_long_to_string(11)));
}
}
_label9000:
fprintf(stdout, "%s\n", "info");;
goto _label9000;
// Close the file
fclose(_io_units[20]);
// Now we can process the data somehow...
} |
the_stack_data/76113.c | // This file is part of CPAchecker,
// a tool for configurable software verification:
// https://cpachecker.sosy-lab.org
//
// SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0
# 1 "files/callfpointer.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "files/callfpointer.c"
void f(void g(int)) {
g(1);
}
void h(int i) {
if(i==1) {
ERROR: goto ERROR;
} else {
}
}
void z(int i) {}
int main(void) {
void (*z)(int) = &h;
// in the next line, z references the local variable
f(z);
return 0;
}
|
the_stack_data/51655.c | /**
* Enumerate directories from the root to the current working directory
*/
#ifndef _GNU_SOURCE
# define _GNU_SOURCE /* for name_to_handle_at */
#endif
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
/**
* Return an allocated buffer containing the current working directory
*/
static char *getcwd_a(void)
{
long lsize;
size_t size;
char *buffer, *ptr;
/* From http://pubs.opengroup.org/onlinepubs/009695399/functions/getcwd.html */
lsize = pathconf(".", _PC_PATH_MAX);
assert(lsize > 0);
size = (size_t)lsize;
buffer = malloc(size);
assert(buffer);
ptr = getcwd(buffer, size);
if (!ptr) {
perror("getcwd");
exit(EXIT_FAILURE);
}
assert(ptr == buffer);
return buffer;
}
int main(void)
{
char *wd;
const char *path_part = NULL;
int dir_fd = -1, retval = 1;
bool is_not_end = true;
wd = getcwd_a();
/* Open the root directory */
if (wd[0] != '/') {
fprintf(stderr, "The current working directory does not start with '/': %s\n", wd);
fprintf(stderr, "Your system is not yet supported :(\n");
return 1;
}
/* Enumerate every subdirectory */
do {
char *path_end;
struct stat st;
int new_dirfd;
DIR *dir = NULL;
struct dirent64 *entry;
/* Start with the root directory */
if (!path_part) {
path_part = "/";
path_end = wd;
dir_fd = AT_FDCWD;
is_not_end = (wd[1] != '\0');
printf("/\n");
} else {
path_end = strchrnul(path_part, '/');
if (path_end == path_part) {
path_part += 1;
continue;
}
is_not_end = (*path_end == '/');
*path_end = '\0';
printf("\n%s/\n", path_part);
}
/* Stat the subdirectory */
if (fstatat(dir_fd, path_part, &st, 0) == -1) {
perror("fstatat");
goto cleanup;
}
if (!S_ISDIR(st.st_mode)) {
fprintf(stderr, "A component in the working directory is not a directory\n");
goto cleanup;
}
printf(" device %" PRIu64 " inode %ld (0x%08lx)\n", st.st_dev, st.st_ino, st.st_ino);
/* Find the entry in the directory enumeration */
if (dir_fd != AT_FDCWD) {
dir = fdopendir(dir_fd);
while (true) {
errno = 0;
entry = readdir64(dir);
if (!entry) {
if (errno) {
perror("readdir");
goto cleanup;
}
printf("... not found in parent directory :(\n");
break;
}
if (!strcmp(entry->d_name, path_part)) {
if (entry->d_ino != st.st_ino) {
/* direntry inode number of mountpoints comes from the parent filesystem,
* and stat inode number comes from the mounted filesystem. */
printf(" dir entry inode: %" PRId64 " (0x%08" PRIx64 ")\n", entry->d_ino, entry->d_ino);
}
assert(entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN);
break;
}
}
}
#if defined(__linux__) && defined(MAX_HANDLE_SZ)
/* Use name_to_handle_at */
{
int mount_id = 0;
unsigned int i;
/* Force fh_buffer memory to be aligned on an integer boundary */
int fh_buffer[(sizeof(struct file_handle) + MAX_HANDLE_SZ + sizeof(int) - 1) / sizeof(int)];
struct file_handle *fhp = (struct file_handle *)fh_buffer;
fhp->handle_bytes = MAX_HANDLE_SZ;
if (name_to_handle_at(dir_fd, path_part, fhp, &mount_id, 0) == -1) {
if (errno == ENOTSUP) {
printf(" (name_to_handle_at not supported here)\n");
} else if (errno == EPERM) {
printf(" (name_to_handle_at not permitted here)\n");
} else {
perror("name_to_handle_at");
}
/* This error is not fatal */
} else {
printf(" mount id %d\n", mount_id);
printf(" handle type %d size %u:", fhp->handle_type, fhp->handle_bytes);
assert(fhp->handle_bytes <= MAX_HANDLE_SZ);
for (i = 0; i < fhp->handle_bytes; i++) {
printf(" %02x", fhp->f_handle[i]);
}
printf("\n");
}
}
#endif
/* Open the subdirectory */
new_dirfd = openat(dir_fd, path_part, O_RDONLY | O_CLOEXEC);
if (new_dirfd == -1) {
perror("openat");
goto cleanup;
}
if (dir) {
closedir(dir);
} else if (dir_fd != AT_FDCWD) {
close(dir_fd);
}
dir = NULL;
dir_fd = new_dirfd;
path_part = path_end + 1;
} while (is_not_end);
retval = 0;
cleanup:
if (dir_fd >= 0) {
close(dir_fd);
}
if (wd != NULL) {
free(wd);
}
return retval;
}
|
the_stack_data/9752.c | // KMSAN: uninit-value in gf128mul_4k_lle (2)
// https://syzkaller.appspot.com/bug?id=17830b94bc7916a77c38c6cce5aafb3285b0cd21
// status:invalid
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <stdint.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>
void loop()
{
memcpy((void*)0x20000100, "big_key", 8);
*(uint8_t*)0x20000140 = 0x73;
*(uint8_t*)0x20000141 = 0x79;
*(uint8_t*)0x20000142 = 0x7a;
*(uint8_t*)0x20000143 = 0;
*(uint8_t*)0x20000144 = 0;
memcpy(
(void*)0x20000180,
"\x69\x6c\x5c\x1b\x0b\x94\x29\x88\x18\x9e\xa5\x9a\x34\x30\x11\x66\x7c\x0d"
"\xc5\x5a\x30\x1c\xeb\x01\x2d\xf6\x57\x9d\x08\x01\xa6\xc9\x5e\x53\x53\xf7"
"\xdc\xc6\xc2\xc7\xb5\x0d\x96\x65\x37\x42\x4b\xb7\xd2\x1f\xc6\x76\xb3\x43"
"\x63\xc6\x0b\x38\xae\x23\x46\xe6\x38\xbb\xa2\xf9\xff\xec\x40\x5b\xc5\x6b"
"\x84\xc9\xfe\x77\xa6\x0f\xb3\x70\x16\x89\xf3\x2d\x24\xfe\x33\x12\x9c\xe3"
"\x31\xaa\x79\x7e\x72\xa5\x7a\x6e\xfd\x4f\x39\x40\x10\xc9\x0c\xfe\x3d\xed"
"\x20\x1c\x69\x71\x95\xfb\xbd\xec\xca\xdf\xfa\x6a\xa4\x8c\x49\xe2\x6f\x1a"
"\x33\x7a\xd1\x0a\xcf\xed\x02\xd7\xf5\x65\x2e\xf0\xb5\x30\xb0\x67\xab\xdb"
"\x46\x0b\xa2\xea\x50\x1e\x0c\x74\x30\x8a\xc8\x28\xbb\x71\x7b\xcf\x79\x89"
"\x3a\x2d\xd3\x73\xae\xf8\x89\xf2\x60\x00\x45\x65\x41\x2b\x69\x25\x3c\xf2"
"\xc9\xae\x97\xf3\x50\xa7\x17\xb2\x75\xb7\xb3\x67\x6c\x27\x73\xf7\x02\x7b"
"\x0b\x7c\x38\x15\x84\x79\x92\x2e\x44\xa9\x53\xe3\x13\x3f\x12\xc3\x7f\xb0"
"\x3a\x09\x3d\xb9\x53\x92\xcb\x3f\xbc\x2b\xa1\x56\xbb\xaa\x50\x1c\x5d\xbc"
"\xf0\xcb\x83\x30\x62\xef\xba\x23\x00\xec\xff\xbd\x29\xa4\xc4\xc9\x1c\xb7"
"\xbf\x1f\x7a\x41\x29\x8a\xc6\x99\xda\xb7\x5d\xfd\xf2\x72\x44\xd2\x9d\xd8"
"\x02\xf5\x99\x72\xfa\xbd\x68\xd3\x02\xfd\xeb\x68\x0c\xea\x4c\x69\x5f\xed"
"\x14\x35\x08\x3e\x3b\xbd\x64\xbc\xa1\x1c\xcb\xd1\x5d\x96\xa2\x69\x2b\x3b"
"\x3e\x6b\x85\xf6\x71\x16\x38\x65\xb9\x27\xb6\x73\x8d\xba\x23\x80\xbc\xde"
"\x17\x89\x39\x91\x53\x77\x9a\x94\x27\xbe\xb1\x82\x46\xa0\x67\x09\x7e\xf4"
"\x2b\xc4\x06\x5b\x1c\x9a\xee\xc6\xeb\xef\x5d\x19\xbe\x5a\x1c\xb3\x55\x52"
"\xe9\xa5\xb6\x5b\x1c\xaa\xbe\xcf\x5e\x87\x15\x65\xa0\x5c\xd2\xf4\x74\xbc"
"\x67\x32\xa7\xac\xc6\x49\xb4\x05\x35\xfe\xde\xe9\x89\x76\xb4\x48\x2a\x7c"
"\x52\xee\xa8\xab\xbf\x1f\xf5\x77\xad\x20\x13\x43\x91\x2b\x16\x70\x05\xd8"
"\x18\xaf\x59\x93\x33\xb6\xd4\xdc\x77\xcf\xac\x78\x98\xb5\x1e\x8d\x1d\x8f"
"\x63\x9c\x45\xb6\x03\xe4\x77\x14\x81\xcd\xab\xb0\x54\x36\x64\x75\x38\x8c"
"\xe6\x72\xdc\x01\x3c\x25\xb2\x96\x1c\xc3\xad\x2b\xf4\xea\x90\xfb\xc7\x6a"
"\xae\x87\x6b\xb8\xdf\x71\x0e\x10\x47\xf4\x76\x86\x73\xf6\x23\xba\x3d\x0e"
"\xb5\x04\x73\xbb\x54\xa1\x99\x9a\xad\xd1\xb9\xc5\xf8\x6c\x0c\xec\xa7\x30"
"\x49\x0e\xd5\x5d\xd6\x03\x32\xfe\x7b\x6d\x3d\x0a\x12\xf5\x2b\x0e\xe1\x2a"
"\x9d\x09\xb0\xe7\x97\xcc\xc6\x14\x21\x68\xf6\x1a\xb4\x7b\x2f\xc6\xc7\xb8"
"\x14\x83\x80\x8a\xdd\x9f\x49\x78\x57\xce\x2a\xe1\xec\xe0\x94\x17\xe5\x7c"
"\x0d\x37\x10\x96\x21\xbd\x0b\xcb\xa9\xf7\x78\xb8\x0a\xe8\x25\x52\x09\xb6"
"\x70\x86\xfb\xba\x0e\x47\x50\x96\xa8\x22\x47\x8a\x1a\x6a\xbd\x2c\x12\xc2"
"\x00\x52\xe2\xcc\x64\x1c\xc4\x7d\xd9\x63\x71\x52\xeb\x1b\xef\xa2\xbc\x72"
"\x9d\xa8\x7c\x43\x62\xac\xf6\x51\xca\xff\x2d\x68\xfc\x23\x73\xee\x76\x07"
"\xb4\x82\x48\x40\x43\xbe\x5d\xc2\x73\x1d\x22\xb1\x7f\xf1\x2c\x63\x24\x87"
"\x02\x0b\x22\x9f\x74\xf2\x64\x98\x69\x7b\x7b\xe8\x42\x41\xb0\x95\xae\x63"
"\x6b\x70\x63\x8b\xaa\x4b\xa5\xbf\x0c\x36\xd2\x72\x8b\x97\x0d\x90\xa3\xbc"
"\x7f\xb8\x49\x2e\x39\x4d\xc1\x58\xb4\x07\xef\x14\xb3\xdd\x23\x11\x33\x91"
"\x33\x98\xfd\x60\xec\x7e\xf6\x13\xae\x84\x13\xbf\xbb\xcb\xcc\xbe\xa8\xf9"
"\x70\xf6\x79\xb0\x52\xd6\x6b\xe1\xb2\xfb\x79\x8b\xdd\xe0\xa6\xc5\xf5\x5f"
"\xe8\xca\x41\xa4\xec\x9a\xa8\x95\xa2\xbf\x77\xf2\xcf\xbd\x92\x16\xe0\x74"
"\xd9\x49\x83\xe6\x8f\x3b\xe3\x10\x12\x15\x6a\x26\x5b\xf3\xf3\xcc\xe0\xba"
"\xe5\x30\x23\xa9\x0f\x1b\xc2\x17\x2f\x9c\x23\xb8\x60\x06\xb8\xaa\xe9\x7b"
"\xb5\xf8\xdc\x12\xc0\x63\x4f\x03\xf4\x39\x0c\x24\xe4\x02\x96\xec\x90\xb4"
"\x3f\x59\xe6\x59\x2d\xd3\x6e\xf1\xde\x5b\x3c\xd7\x7e\x64\xea\x29\x99\xe8"
"\xa9\xb0\xbb\xca\x63\xb2\xec\xdd\x68\x5b\xe7\x06\xb3\x69\x83\x8d\x19\x88"
"\x41\xc4\xda\x71\x72\xfa\x78\x38\xec\x14\x60\xc5\xda\x07\xaa\x94\xac\xe6"
"\xb6\xd9\x5b\xdb\x09\x40\xca\x56\x8e\x08\x50\x77\x3c\x73\x47\x85\x8d\xea"
"\x60\x25\x45\x9f\xa6\x68\xac\x6f\x97\x42\xba\x2a\xed\x41\x9d\x04\x61\xaf"
"\xac\xdb\xc4\x56\x9e\x14\x12\xa1\x55\xff\x2b\x9e\x59\x60\x1c\x04\xe8\x9d"
"\x79\x5c\xec\xbb\x32\xd8\x12\x01\xac\x87\x19\x25\x59\x92\x71\x7b\xd3\x03"
"\x0d\x49\xf7\x92\x2e\x14\x0d\xf0\xec\x0c\xc8\x8b\x2a\xfe\x37\x92\xf3\x29"
"\x2a\x91\x83\x6b\xa7\xa6\x48\xf8\xa7\xdd\x0b\x0a\x5a\xd9\xb9\x6a\x39\x3f"
"\xbb\xf2\x60\x91\x1f\x13\xc6\x8d\xdb\xc8\x07\x22\x41\x7b\xf1\x62\x78\x92"
"\x08\x5c\xff\xa6\xf4\x57\x9a\xdc\x4d\x20\x29\xdc\x78\xcb\x7a\x86\x8c\x65"
"\xe5\xeb\xd6\x95\xea\x55\xe7\x7e\xc5\xbe\x05\xa7\x98\x8f\xa2\x28\x51\xc6"
"\xcc\xb5\x51\x51\x19\x30\x5e\x27\xf0\x02\x9e\x2f\xa4\xcd\xc3\xa1\xa9\xf6"
"\xb1\x58\xcf\x67\xfe\xce\x59\x64\x51\x26\x8d\x68\x29\x09\x2b\x3c\x07\xf5"
"\xd0\x9b\x12\xd2\xbb\x89\x3e\xb5\x4e\xdf\xfe\xbb\xa3\xba\xab\x50\xba\x76"
"\x5e\x9f\xc4\x87\x4d\x5d\xe0\xa0\xca\x91\xab\x1b\x69\xf2\xdb\xf2\x1f\x3f"
"\xcb\x33\x82\x57\x82\x74\x8f\x5c\x1f\xf8\xca\x0f\x8c\x31\x15\x88\xc6\x59"
"\x91\x4b\x86\xbd\x31\x17\x7b\x85\xf0\xa3\x46\xcd\x3f\xfd\xce\x8a\xef\x41"
"\x61\x73\xfb\xd8\x41\x52\xf5\xbe\xbb\xf9\x1d\x55\xc0\x64\xfa\xbc\xfe\x25"
"\x24\xd6\x62\xb7\xf3\x6f\x81\x92\x48\x40\x86\x7c\xbf\xc8\x61\xfe\xd7\xbf"
"\xc1\x6d\x7a\x55\xd2\x3c\x0e\xa8\xfc\x38\xf3\x5f\xb6\x9c\x24\x54\x1b\x2b"
"\x4c\x38\x34\x22\x7f\x34\x46\x4c\x43\xd0\x2e\xbe\x49\x1a\x77\x3c\x5f\xd6"
"\x98\x97\x80\xe6\xac\x69\xe5\x1a\x30\xfc\x92\xa8\x7e\x65\x33\xa7\x41\x9a"
"\x3e\xea\x7a\xf5\x90\xb0\xd3\xa4\xc9",
1233);
syscall(__NR_add_key, 0x20000100, 0x20000140, 0x20000180, 0x4d1, 0xfffffffc);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
loop();
return 0;
}
|
the_stack_data/417535.c | /* arbres binaires de recherche */
struct ABR {
int valeur;
struct ABR *gauche, *droite;
};
struct ABR* make(int v, struct ABR *g, struct ABR *d) {
struct ABR * s;
s = sbrk(sizeof(struct ABR));
s->valeur = v;
s->gauche = g;
s->droite = d;
return s;
}
int insere(struct ABR *a, int x) {
if (x == a->valeur)
return 0;
if (x < a->valeur) {
if (a->gauche == 0)
a->gauche = make(x, 0, 0);
else
insere(a->gauche, x);
} else
if (a->droite == 0)
a->droite = make(x, 0, 0);
else
insere(a->droite, x);
return 0;
}
int contient(struct ABR *a, int x) {
if (x == a->valeur) return 1;
if (x < a->valeur && a->gauche != 0) return contient(a->gauche, x);
if (a->droite != 0) return contient(a->droite, x);
return 0;
}
int print_int(int n) {
int q;
q = n / 10;
if (n > 9) print_int(q);
putchar('0' + (n - 10*q));
return 0;
}
int print(struct ABR *a) {
putchar('(');
if (a->gauche != 0) print(a->gauche);
print_int(a->valeur);
if (a->droite != 0) print(a->droite);
return putchar(')');
}
int main() {
struct ABR *dico;
dico = make(1, 0, 0);
insere(dico, 17);
insere(dico, 5);
insere(dico, 8);
print(dico);
putchar(10);
if (contient(dico, 5) && !contient(dico, 0) &&
contient(dico, 17) && !contient(dico, 3)) {
putchar('o');
putchar('k');
putchar(0x0a);
}
insere(dico, 42);
insere(dico, 1000);
insere(dico, 0);
print(dico);
putchar(10);
return 0;
}
|
the_stack_data/96455.c | #include <stdio.h>
int main() {
printf("Hello, two!\n");
return 0;
}
|
the_stack_data/1188877.c | /* my_strcpy.c
Demonstrate a reimplementation of strcpy(d, s) in order to help
students and new developers understand its behavior.
Author: Sean Eyre, for Rainier Cyber
References: https://www.techiedelight.com/implement-strcpy-function-c/
*/
#include <stdlib.h>
#include <stdio.h>
// NOTICE WE DON'T CHEAT BY USING STRING.H
char * str_copy( char *src, char *dest ){
char *index = src; // Create an index so that we don’t mutate src
char *ptr = dest; // Save the starting point of the destination
while (*index != '\0' ) {
*dest = *index; // Set the memory at dest to the memory at index
dest++; // See above for pointer math
index++;
}
return ptr;
}
int main( int argc, char **argv) {
char a[5] = "Test";
char b[5];
str_copy( a, b ); // Note this is interpreted as the addresses
printf("a = %s and b = %s.\n", a, b);
// The following might produce a warning at compile time
char c[] = "Test numero dos";
printf("%s\n", c);
char d[3];
str_copy( c, d ); // Deliberately overflow d
printf("c = %s and d = %s.\n", c, d);
return 0; // Proper exit code if successful
}
|
the_stack_data/220456274.c | /**
* @file ls12.c
*
* Copyright (c) 2015 大前良介 (OHMAE Ryosuke)
*
* This software is released under the MIT License.
* http://opensource.org/licenses/MIT
*
* @brief lsコマンド風のプログラムを作るNo.12
* ソート機能の追加
*
* @author <a href="mailto:[email protected]">大前良介 (OHMAE Ryosuke)</a>
* @date 2015/11/30
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include <dirent.h>
#include <getopt.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#define PATH_MAX 4096
#define HALF_YEAR_SECOND (365 * 24 * 60 * 60 / 2)
#ifndef S_IXUGO
#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
#endif
/**
* 隠しファイルの表示方針
*/
enum {
FILTER_DEFAULT, /**< '.'から始まるもの以外を表示する */
FILTER_ALMOST, /**< '.'と'..'以外を表示する */
FILTER_ALL, /**< すべて表示する */
};
/**
* 再帰呼び出しのためのディレクトリ名を保持するリンクリスト
*/
struct dir_path {
char path[PATH_MAX + 1];
int depth;
struct dir_path *next;
};
/**
* ファイル情報の格納
*/
struct info {
char name[NAME_MAX + 1];
char link[PATH_MAX + 1];
struct stat stat;
mode_t link_mode;
bool link_ok;
};
/**
* ファイル情報を格納する可変長リスト
*/
struct info_list {
struct info **array;
int size;
int used;
};
static void *xmalloc(size_t n);
static void *xrealloc(void *ptr, size_t size);
static char *parse_cmd_args(int argc, char**argv);
static void get_mode_string(mode_t mode, char *str);
static void print_type_indicator(mode_t mode);
static void print_user(uid_t uid);
static void print_group(gid_t gid);
static void get_time_string(char *str, time_t time);
static void print_name_with_color(const char *name, mode_t mode, bool link_ok);
static struct dir_path *new_dir_path(const char *path, int depth, struct dir_path *next);
static void init_info_list(struct info_list *list, int size);
static void free_info_list(struct info_list *list);
static void add_info(struct info_list *list, struct info *info);
static struct info *new_info(const char *path, const char *name);
static int compare_name(const void *a, const void *b);
static void sort_list(struct info_list *list);
static void print_info(struct info *info);
static void list_dir(struct dir_path *base);
/**
* 隠しファイルの表示方針
*/
static int filter = FILTER_DEFAULT;
/**
* 色付き表示する
*/
static bool color = false;
/**
* 属性を示す文字を表示する
*/
static bool classify = false;
/**
* ロングフォーマットで表示する
*/
static bool long_format = false;
/**
* 半年前のUNIX時間
*/
static time_t half_year_ago;
/**
* 再帰的な表示
*/
static bool recursive = false;
/**
* @brief malloc結果がNULLだった場合にexitする。
* @param[IN] size 確保サイズ
* @retrun 確保された領域へのポインタ
*/
static void *xmalloc(size_t n) {
void *p = malloc(n);
if (p == NULL) {
perror("");
exit(EXIT_FAILURE);
}
return p;
}
/**
* @brief realloc結果がNULLだった場合にexitする。
* @param[IN] ptr 拡張する領域ポインタ
* @param[IN] size 確保サイズ
* @retrun 確保された領域へのポインタ
*/
static void *xrealloc(void *ptr, size_t size) {
void *p = realloc(ptr, size);
if (p == NULL) {
perror("");
exit(EXIT_FAILURE);
}
return p;
}
/**
* @brief コマンドライン引数をパースする
* @param[IN] argc 引数の数
* @param[IN/OUT] argv 引数配列
* @return パス
*/
static char *parse_cmd_args(int argc, char**argv) {
char *path = "./";
int opt;
const struct option longopts[] = {
{ "all", no_argument, NULL, 'a' },
{ "almost-all", no_argument, NULL, 'A' },
{ "color", no_argument, NULL, 'C' },
{ "classify", no_argument, NULL, 'F' },
{ "long-format", no_argument, NULL, 'l' },
{ "recursive", no_argument, NULL, 'R' },
};
while ((opt = getopt_long(argc, argv, "aACFlR", longopts, NULL)) != -1) {
switch (opt) {
case 'a':
filter = FILTER_ALL;
break;
case 'A':
filter = FILTER_ALMOST;
break;
case 'C':
if (isatty(STDOUT_FILENO)) {
color = true;
}
break;
case 'F':
classify = true;
break;
case 'l':
long_format = true;
half_year_ago = time(NULL) - HALF_YEAR_SECOND;
break;
case 'R':
recursive = true;
break;
default:
return NULL;
}
}
if (argc > optind) {
path = argv[optind];
}
return path;
}
/**
* @brief モード文字列を作成する
* @param[IN] mode モードパラメータ
* @param[OUT] str 文字列の出力先、11バイト以上のバッファを指定
*/
static void get_mode_string(mode_t mode, char *str) {
str[0] = (S_ISBLK(mode)) ? 'b' :
(S_ISCHR(mode)) ? 'c' :
(S_ISDIR(mode)) ? 'd' :
(S_ISREG(mode)) ? '-' :
(S_ISFIFO(mode)) ? 'p' :
(S_ISLNK(mode)) ? 'l' :
(S_ISSOCK(mode)) ? 's' : '?';
str[1] = mode & S_IRUSR ? 'r' : '-';
str[2] = mode & S_IWUSR ? 'w' : '-';
str[3] = mode & S_ISUID ? (mode & S_IXUSR ? 's' : 'S') : (mode & S_IXUSR ? 'x' : '-');
str[4] = mode & S_IRGRP ? 'r' : '-';
str[5] = mode & S_IWGRP ? 'w' : '-';
str[6] = mode & S_ISGID ? (mode & S_IXGRP ? 's' : 'S') : (mode & S_IXGRP ? 'x' : '-');
str[7] = mode & S_IROTH ? 'r' : '-';
str[8] = mode & S_IWOTH ? 'w' : '-';
str[9] = mode & S_ISVTX ? (mode & S_IXOTH ? 't' : 'T') : (mode & S_IXOTH ? 'x' : '-');
str[10] = '\0';
}
/**
* @brief ファイルタイプ別のインジケータを出力する
* @param[IN] mode モードパラメータ
*/
static void print_type_indicator(mode_t mode) {
if (S_ISREG(mode)) {
if (mode & S_IXUGO) {
putchar('*');
}
} else {
if (S_ISDIR(mode)) {
putchar('/');
} else if (S_ISLNK(mode)) {
putchar('@');
} else if (S_ISFIFO(mode)) {
putchar('|');
} else if (S_ISSOCK(mode)) {
putchar('=');
}
}
}
/**
* @brief ユーザ名を表示する
* @param[IN] uid ユーザID
*/
static void print_user(uid_t uid) {
struct passwd *passwd = getpwuid(uid);
if (passwd != NULL) {
printf("%8s ", passwd->pw_name);
} else {
printf("%8d ", uid);
}
}
/**
* @brief グループ名を表示する
* @param[IN] gid グループID
*/
static void print_group(gid_t gid) {
struct group *group = getgrgid(gid);
if (group != NULL) {
printf("%8s ", group->gr_name);
} else {
printf("%8d ", gid);
}
}
/**
* @brief 時刻表示文字列を作成する
* 半年以上前の場合は月-日 年
* 半年以内の場合は月-日 時:分
*
* @param[OUT] str 格納先、12byte以上のバッファを指定
* @param[IN] time 文字列を作成するUNIX時間
*/
static void get_time_string(char *str, time_t time) {
if (time - half_year_ago > 0) {
strftime(str, 12, "%m/%d %H:%M", localtime(&time));
} else {
strftime(str, 12, "%m/%d %Y", localtime(&time));
}
}
/**
* @brief ファイル名を色付き表示する
*
* @param[IN] name ファイル名
* @param[IN] mode mode値
* @param[IN] link_ok リンク先が存在しない場合にfalse
*/
static void print_name_with_color(const char *name, mode_t mode, bool link_ok) {
if (!link_ok) {
printf("\033[31m");
} else if (S_ISREG(mode)) {
if (mode & S_ISUID) {
printf("\033[37;41m");
} else if (mode & S_ISGID) {
printf("\033[30;43m");
} else if (mode & S_IXUGO) {
printf("\033[01;32m");
} else {
printf("\033[0m");
}
} else if (S_ISDIR(mode)) {
if ((mode & S_ISVTX) && (mode & S_IWOTH)) {
printf("\033[30;42m");
} else if (mode & S_IWOTH) {
printf("\033[34;42m");
} else if (mode & S_ISVTX) {
printf("\033[37;44m");
} else {
printf("\033[01;34m");
}
} else if (S_ISLNK(mode)) {
printf("\033[01;36m");
} else if (S_ISFIFO(mode)) {
printf("\033[33m");
} else if (S_ISSOCK(mode)) {
printf("\033[01;35m");
} else if (S_ISBLK(mode)) {
printf("\033[01;33m");
} else if (S_ISCHR(mode)) {
printf("\033[01;33m");
}
printf("%s", name);
printf("\033[0m");
}
/**
* @brief struct subdirのファクトリーメソッド
* @param[IN] path パス
* @param[IN] depth 深さ
* @param[IN] next 次の要素へのポインタ
* @return struct subdirへのポインタ
*/
static struct dir_path *new_dir_path(const char *path, int depth, struct dir_path *next) {
struct dir_path *s = xmalloc(sizeof(struct dir_path));
if (path != NULL) {
strncpy(s->path, path, sizeof(s->path));
}
s->depth = depth;
s->next = next;
return s;
}
/**
* @brief 可変長リストを初期化する
* @param[OUT] list 初期化する構造体
* @param[IN] size 初期サイズ
*/
static void init_info_list(struct info_list *list, int size) {
list->array = xmalloc(sizeof(struct info*) * size);
list->size = size;
list->used = 0;
}
/**
* @brief 可変長リスト内のメモリを開放する
* リスト内に登録されたinfoも合わせて開放する。
*
* @param[IN] list 開放する構造体
*/
static void free_info_list(struct info_list *list) {
int i;
for (i = 0; i < list->used; i++) {
free(list->array[i]);
}
free(list->array);
}
/**
* @brief 可変長リストへ情報を格納する
* 格納場所がない場合は拡張を行う
*
* @param[IN/OUT] list 格納先構造体
* @param[IN] info 格納するデータ
*/
static void add_info(struct info_list *list, struct info *info) {
if (list->size == list->used) {
list->size = list->size * 2;
list->array = xrealloc(list->array, sizeof(struct info*) * list->size);
}
list->array[list->used] = info;
list->used++;
}
/**
* @brief エントリ情報構造体のファクトリメソッド
* メモリ確保から、指定パスの各情報格納までを行う
*
* @param[IN] path エントリのパス
* @param[IN] name エントリの名前
* @return エントリ情報構造体
*/
static struct info *new_info(const char *path, const char *name) {
struct info *info = xmalloc(sizeof(struct info));
strncpy(info->name, name, NAME_MAX + 1);
if (lstat(path, &info->stat) != 0) {
perror(path);
free(info);
return NULL;
}
info->link_ok = false;
info->link[0] = 0;
info->link_mode = 0;
if (S_ISLNK(info->stat.st_mode)) {
struct stat link_stat;
int link_len = readlink(path, info->link, PATH_MAX);
if (link_len > 0) {
info->link[link_len] = 0;
}
if (stat(path, &link_stat) == 0) {
info->link_ok = true;
info->link_mode = link_stat.st_mode;
}
} else {
info->link_ok = true;
}
return info;
}
/**
* @brief ソート用ファイル名比較
* @param[IN] a
* @param[IN] b
* @return a>bなら正、a==bなら0、a<bなら負
*/
static int compare_name(const void *a, const void *b) {
struct info *ai = *(struct info**)a;
struct info *bi = *(struct info**)b;
if (S_ISDIR(ai->stat.st_mode) && !S_ISDIR(bi->stat.st_mode)) {
return -1;
}
if (!S_ISDIR(ai->stat.st_mode) && S_ISDIR(bi->stat.st_mode)) {
return 1;
}
return strcmp(ai->name, bi->name);
}
/**
* @brief リスト内のソートを行う
* @param[IN/OUT] ソート対象のリスト
*/
static void sort_list(struct info_list *list) {
qsort(list->array, list->used, sizeof(struct info*), compare_name);
}
/**
* @brief エントリ情報に基づいて情報を表示する
* @param[IN] info 表示する情報
*/
static void print_info(struct info *info) {
if (long_format) {
char buf[12];
get_mode_string(info->stat.st_mode, buf);
printf("%s ", buf);
printf("%3d ", (int)info->stat.st_nlink);
print_user(info->stat.st_uid);
print_group(info->stat.st_gid);
if (S_ISCHR(info->stat.st_mode) || S_ISBLK(info->stat.st_mode)) {
printf("%4d,%4d ", major(info->stat.st_rdev),
minor(info->stat.st_rdev));
} else {
printf("%9ld ", info->stat.st_size);
}
get_time_string(buf, info->stat.st_mtim.tv_sec);
printf("%s ", buf);
}
if (color) {
print_name_with_color(info->name, info->stat.st_mode, info->link_ok);
} else {
printf("%s", info->name);
}
if (classify) {
print_type_indicator(info->stat.st_mode);
}
if (long_format) {
if (info->link[0] != 0) {
printf(" -> ");
if (color) {
print_name_with_color(info->link, info->link_mode, info->link_ok);
} else {
printf("%s", info->link);
}
}
}
putchar('\n');
}
/**
* @brief 指定パスのディレクトリエントリをリストする
* @param[IN] base パス
*/
static void list_dir(struct dir_path *base) {
const char *base_path = base->path;
int i;
DIR *dir;
struct dirent *dent;
char path[PATH_MAX + 1];
size_t path_len;
struct info_list list;
struct dir_path *subque = base;
dir = opendir(base_path);
if (dir == NULL) {
perror(base_path);
return;
}
path_len = strlen(base_path);
if (path_len >= PATH_MAX - 1) {
fprintf(stderr, "too long path\n");
return;
}
strncpy(path, base_path, PATH_MAX);
if (path[path_len - 1] != '/') {
path[path_len] = '/';
path_len++;
path[path_len] = '\0';
}
init_info_list(&list, 100);
while ((dent = readdir(dir)) != NULL) {
struct info *info;
const char *name = dent->d_name;
if (filter != FILTER_ALL
&& name[0] == '.'
&& (filter == FILTER_DEFAULT
|| name[1 + (name[1] == '.')] == '\0')) {
continue;
}
strncpy(&path[path_len], dent->d_name, PATH_MAX - path_len);
info = new_info(path, name);
if (info == NULL) {
continue;
}
add_info(&list, info);
}
closedir(dir);
sort_list(&list);
for (i = 0; i < list.used; i++) {
struct info *info = list.array[i];
if (recursive && S_ISDIR(info->stat.st_mode)) {
const char *name = info->name;
if (!(name[0] == '.'
&& name[1 + (name[1] == '.')] == '\0')) {
strncpy(&path[path_len], name, PATH_MAX - path_len);
subque->next = new_dir_path(path, base->depth + 1, subque->next);
subque = subque->next;
}
}
print_info(info);
}
free_info_list(&list);
}
int main(int argc, char**argv) {
struct dir_path *head;
char *path = parse_cmd_args(argc, argv);
if (path == NULL) {
return EXIT_FAILURE;
}
head = new_dir_path(path, 0, NULL);
while(head != NULL) {
if (head->depth != 0) {
printf("\n%s:\n", head->path);
}
list_dir(head);
struct dir_path *tmp = head;
head = head->next;
free(tmp);
}
return EXIT_SUCCESS;
}
|
the_stack_data/170453238.c | long long llf (long long llx, long lx, long double lld) {
int m = llx; /* int <- long long */
m = 243LL;
lld = 3.542L;
lx = 5234LL;
lx = 5342L;
llx = lx;
lx = llx; /* long <- long long */
llx = m;
return lx;
}
|
the_stack_data/167331542.c | #include <stdlib.h> // C standard library include
#include <stdio.h> // I/O library include
#include <math.h>
#include <unistd.h> // Needed for fork() call
#include <time.h>
#include <sys/types.h> // Needed for waitpid routine (and other things...)
#include <sys/ipc.h> // Needed for shared memory routines
#include <sys/shm.h> // Needed for shared memory routines
#include <sys/wait.h> // Needed for waitpid() routine
void generic_processing_job(int, int, double *, int, double *);
void finalize_processing(double *var[], int size, int np);
int main(argc,argv) int argc; char *argv[]; {
pid_t child_pid[20]; // Child process ID's
double *(jobAccum[20]);
int sharedMemoryID; // The shared memory identifier
double *sharedMemoryPtr; // A pointer to a block of shared memory
int status; // Status variable for waitpid() call
double *theBuffer;
int bufSize;
int i;
int accum;
time_t startTime, endTime;
int duration;
int np; // Number of processes
// Check the number of command-line arguments
if (argc != 2) {
printf(" use: num3 np\n");
printf(" where np is the number of processes to fork, up to 20\n");
exit(-1);
}
// Start the timer
startTime = time(NULL);
// Get the number of processes entered
sscanf(argv[1], "%d",&np);
if ((np < 1) || (np > 20)) {
printf(" Error: np = %d. Needs to be between 1 and 20 inclusive...\n", np);
exit(-1);
}
// Allocate data buffer memory
bufSize = 50000000;
theBuffer = (double *)malloc(bufSize * sizeof(double));
if (!theBuffer) {
printf(" Error allocating memory...\n");
exit(-1);
}
//printf(" np = %d", np);
//printf(" bufSize = %d\n", bufSize);
// Initialize the buffer with psuedo-random numbers between 1 and 100
srand(startTime);
for(i=0; i<bufSize; ++i) {
theBuffer[i] = 100.0 * (rand() / (RAND_MAX + 1.0));
}
// Initialize the shared memory segment
sharedMemoryID = shmget(IPC_PRIVATE, np*sizeof(double), 0660);
sharedMemoryPtr = (double *)shmat(sharedMemoryID, (void *)0, 0);
// Initiate np processes
for (i=0; i<np; ++i) {
jobAccum[i] = sharedMemoryPtr + i;
*jobAccum[i] = 0;
if ((child_pid[i] = fork()) == 0) {
generic_processing_job(i, np, theBuffer, bufSize, jobAccum[i]);
exit(0);
}
//printf(" Process ID of process %d = %d\n", i+1, child_pid[i]);
}
// Wait for all processes to compelte
for (i=0; i<np; ++i) {
waitpid(child_pid[i], &status, 0);
}
// Sumarize information from the two processing jobs
printf(" %d %d ", np, bufSize);
finalize_processing(jobAccum, bufSize, np);
// Get the end time
endTime = time(NULL);
duration = endTime - startTime;
printf("%d\n", duration);
//printf(" Time: %d seconds\n", duration);
}
void generic_processing_job(int start, int increment, double *buf, int size, double *accum) {
int i,j;
int numVals;
double localAvg;
double delta;
double stdDev;
// Calculate sum
numVals = 0;
for (i=start; i<size; i+=increment) {
*accum += buf[i];
numVals++;
}
// Calculate local aveage
localAvg = *accum/(double)numVals;
// Calculate local stdev -- to spend time, do it 500x
for (j=0; j<500; ++j) {
numVals = 0;
for (i=start; i<size; i+=increment) {
delta += pow((buf[i] - localAvg),2);
numVals++;
}
stdDev = sqrt(delta/numVals);
}
}
void finalize_processing(double *accum[], int n, int np) {
double total;
int i;
total = 0;
for (i=0; i<np; ++i) total += *accum[i];
// Print results
//printf(" Summary:");
//printf(" Total sum: %lf", total);
//printf(" Average: %lf\n", total/(double)n);
printf("%lf ", total/(double)n);
}
|
the_stack_data/1009706.c | // abstraction
main() {
int x, y;
x = 5;
y = 2;
_TRACER_abstract(x,x>0);
}
|
the_stack_data/64201127.c |
__main()
{
}
|
the_stack_data/132952044.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush00.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gasantos <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/04 23:50:16 by bbonaldi #+# #+# */
/* Updated: 2022/02/07 02:15:53 by gasantos ### ########.fr */
/* */
/* ************************************************************************** */
void ft_putchar(char c);
typedef struct s_characters {
char fst;
char scd;
char trd;
} t_characters;
void ft_start_end_print(t_characters chars, int col_pos, int columns)
{
if (col_pos == 0)
{
ft_putchar(chars.fst);
}
else if (col_pos == columns - 1)
{
ft_putchar(chars.trd);
}
else
{
ft_putchar(chars.scd);
}
}
void ft_print_row(t_characters chars, int columns)
{
int col_pos;
col_pos = 0;
while (col_pos < columns)
{
ft_start_end_print(chars, col_pos, columns);
col_pos++;
}
ft_putchar('\n');
}
void ft_init_struct(t_characters *chars, char fst, char scd, char trd)
{
chars->fst = fst;
chars->scd = scd;
chars->trd = trd;
}
void rush(int x, int y)
{
int k;
t_characters fst_row;
t_characters middle_row;
t_characters last_row;
ft_init_struct(&fst_row, 'o', '-', 'o');
ft_init_struct(&middle_row, '|', ' ', '|');
ft_init_struct(&last_row, 'o', '-', 'o');
if (y > 0)
{
ft_print_row(fst_row, x);
}
k = 0;
while (k < (y - 2))
{
ft_print_row(middle_row, x);
k++;
}
if (y > 1)
{
ft_print_row(last_row, x);
}
}
|
the_stack_data/156392884.c | #include <stdio.h>
int main()
{
int hora_inicial, hora_final, minuto_inicial, minuto_final, hora_total, minuto_total;
scanf("%d %d %d %d", &hora_inicial, &minuto_inicial, &hora_final, &minuto_final);
hora_total = hora_final - hora_inicial;
if (hora_total < 0)
{
hora_total = 24+(hora_final - hora_inicial);
}
minuto_total = minuto_final - minuto_inicial;
if (minuto_total < 0)
{
minuto_total = 60 + (minuto_final - minuto_inicial);
hora_total--;
}
if (hora_inicial == hora_final && minuto_inicial == minuto_final)
{
printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)\n");
}
else printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n", hora_total, minuto_total);
return 0;
}
|
the_stack_data/1063017.c | // $Id$
// http://research.microsoft.com/en-us/um/people/sumitg/benchmarks/pa.html.
#include <stdlib.h>
#define assume(c) {if (!(c)) exit(0);}
#define assert(c) {if (!(c)) exit(1);}
void ex3(int x, int y, int n, int m) {
assume(x == 0 && y == m && n >= m && m >= 0);
while (x < n) {
if (x < m)
x++;
else {
x++;
y++;
}
}
assert(y == n);
}
/*
* Predicate Set S:
* x - m <= 0, x - m > 0, x - m < 0, x - m >= 0,
* x - n <= 0, x - n > 0, x - n < 0, x - n >= 0,
* y - m <= 0, y - m > 0, y - m < 0, y - m >= 0,
* y - n <= 0, y - n > 0, y - n < 0, y - n >= 0,
* x - y <= 0, x - y > 0, x - y < 0, x - y >= 0,
*/
|
the_stack_data/692834.c | #include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
int nanosleep(const struct timespec *req, struct timespec *rem);
int main(){
const size_t sz = 1024*1024*64;
char *p = malloc(sz);
uint32_t sum=0;
//__builtin_prefetch() https://www.daemon-systems.org/man/__builtin_prefetch.3.html
char *q;
for(int i=1;i<100;i++){
q = p + sz/i; // jumping
#ifdef PREFETCH
#define READ 0 // write 1
for(int j=0;j<10;j++)
__builtin_prefetch(p + sz/(i+j),READ,0);
#endif
sum += (uint32_t)*q;
struct timespec t;
t.tv_sec = 0; t.tv_nsec=1;
nanosleep(&t,0);
}
printf("%u",sum);
free(p);
return 0;
} |
the_stack_data/87636521.c | // SPDX-License-Identifier: GPL-2.0-or-later
/*
* This file is for defining trace points and trace related helpers.
*/
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
#include <trace/events/thp.h>
#endif
|
the_stack_data/59513325.c | /*prolog****************************************************************
*
* cname: isprmgr.c
* desc: test cases for CS162 project 2 TaskIII: support multiprogramming
* author: thinkhy
* tccall: java nachos.machine.Machine -x isprmgr.coff
*
* env: nachos 5.0j
* compile:test/make
* Change activity:
* $BC,EPT 4/21/2014 - initial release
* 5/8/2014 - TODO: add a VAR to exec a program that will fork child
*
**********************************************************************/
#include "stdio.h"
#define NULL 0
#define NUMVARS 9
#define NAN (0xEFFFFFFF)
#define MAXARGC 20
#define MAXPROCESS 10
#define LOG printf
#define TRUE 1
#define FALSE 0
void log(char *format, ...);
void route(int, char);
int atoi(const char *str);
int pid[10]; /* array to store pid */
char *executable; /* executable file name for exec() */
char *_argv[MAXARGC]; /* argv for testing executable */
int _argc; /* argc for testing executable */
int i,j; /* counter for loop */
int exitstatus; /* exit status of child process */
int retval; /* return value of system call */
int flag; /* condition variable: TRUE or FALSE */
int main(int argc, char *argv[]) {
/******************************************************************************************
*
* Variations for Project 2 Task III: Implement the system calls for process management
*
* Var 1 : tests that your syscall exit finishes the thread of the process immediately
* Var 2 : runs exec multiple times and checks each child gets unique PID
* Var 3 : tests your syscall join to a child
* Var 4 : tests exec with error arguments (e.g. bad file name)
* Var 5: tests exec with error arguments: unmatched argc
* Var 6 : tests your syscall join to a non-child
* Var 7 : tests your syscall join to a child that caused unhandled exception
* Var 8 : tests that your exit syscall releases all resources
*
******************************************************************************************/
int i;
int variation = 0;
char dbg_flag = 'd';
if(argc > 1)
variation = atoi(argv[1]);
// LOG("++ISPRMGR: ARG[1] is %d \n", variation);
if (variation) {
route(variation, dbg_flag);
}
else {
LOG("++ISPRMGR Run all the variations\n");
for (i=9; i <= NUMVARS; i++){
if (i == 8 || i == 5) continue;
route(i, dbg_flag);
}
}
return 0;
}
void route(int variation, char dbg_flag)
{
/******************************************************************/
/* Route to the proper variation */
/******************************************************************/
switch (variation)
{
case 1:
/*************************************************************/
/* */
/* Variation 1: */
/* tests that your syscall exit finishes the thread of the */
/* process immediately. */
/* */
/*************************************************************/
LOG("++ISPRMGR VAR1: [STARTED]\n");
LOG("++ISPRMGR VAR1: tests that your syscall exit finishes the thread of the process immediately\n");
executable = "exittest.coff";
_argv[0] = executable;
_argv[1] = NULL;
_argc = 1;
LOG("++ISPRMGR VAR1: exec %s\n", executable);
pid[0] = exec(executable, _argc, _argv);
LOG("++ISPRMGR VAR1: Child process id is %d\n", pid[0]);
executable = "loopawhile.coff";
_argv[0] = executable;
_argv[1] = NULL;
_argc = 1;
LOG("++ISPRMGR VAR1: exec %s\n", executable);
pid[0] = exec(executable, _argc, _argv);
LOG("++ISPRMGR VAR1: Child process id is %d\n", pid[0]);
LOG("++ISPRMGR VAR1: [ENDED] SUCCESS\n");
/* FIX ME [thinkhy 4/27/2014] */
/* The second LOG will cause this program to get hung */
/* LOG("++ProjectII TaskIII VAR1: FAILED"); */
break;
case 2:
/*************************************************************/
/* */
/* Variation 2: runs exec multiple times and checks each */
/* child gets unique PID */
/* */
/*************************************************************/
// log("++ProjectII TaskIII VAR2");
LOG("++ISPRMGR VAR2: [STARTED]\n");
LOG("++ISPRMGR VAR2: runs exec multiple times and checks each child gets unique PID\n");
executable = "cp.coff";
_argv[0] = executable;
_argv[1] = "mv.coff";
_argv[2] = "mv1.coff";
_argc = 3;
for (i = 0; i < 5/*MAXPROCESS*/; i++) {
// LOG("before");
LOG("++ISPRMGR VAR2: exec %s\n", executable);
pid[i] = exec(executable, _argc, _argv);
LOG("++ISPRMGR VAR2: Process %d, Get PID %d after exec cp.coff\n", i, pid[i]);
for (j = 0; j < i; ++j) {
if (pid[j] == pid[i]) {
LOG("++ISPRMGR VAR2: FAILED, pid[%d] equals pid[%d]\n",
j, i);
exit(-1);
}
}
}
LOG("++ISPRMGR VAR2: [ENDED] SUCCESS\n");
break;
case 3:
/*************************************************************/
/* */
/* Variation 3: tests your syscall join to a child */
/* */
/*************************************************************/
LOG("++ISPRMGR VAR3: [STARTED]\n");
LOG("++ISPRMGR VAR3: tests your syscall join to a child\n");
executable = "exittest.coff";
_argv[0] = executable;
_argv[1] = NULL;
_argc = 1;
LOG("++ISPRMGR VAR3: exec %s\n", executable);
pid[0] = exec(executable, _argc, _argv);
LOG("++ISPRMGR VAR3: Child process id is %d\n", pid[0]);
LOG("++ISPRMGR VAR3: Issue join to get exit status of child process\n", pid[0]);
retval = join(pid[0], &exitstatus);
if (retval == 0) {
LOG("++ISPRMGR VAR3: join successfully, exit status is %d\n", exitstatus);
LOG("++ISPRMGR VAR3: [ENDED] SUCCESS\n");
}
else {
LOG("++ISPRMGR VAR3: return value of join is %d\n", retval);
LOG("++ISPRMGR VAR3: [ENDED] FAIL\n");
}
break;
case 4:
/*************************************************************************/
/* */
/* Variation 4: tests exec with error arguments: bad file name) */
/* */
/*************************************************************************/
LOG("++ISPRMGR VAR4: [STARTED]\n");
LOG("++ISPRMGR VAR4: tests exec with error arguments: bad file name)\n");
LOG("++ISPRMGR VAR4: invoke exec with nonextent executable\n");
executable = "inexistent.coff";
_argv[0] = executable;
_argv[1] = NULL;
_argc = 1;
LOG("++ISPRMGR VAR4: exec %s\n", executable);
retval = exec(executable, _argc, _argv);
if (retval == -1)
LOG("++ISPRMGR VAR4: [END] SUCCESS\n");
else
LOG("++ISPRMGR VAR4: [END] FAIL\n");
break;
case 5:
/*************************************************************************/
/* */
/* Variation 5: tests exec with error arguments: unmatched argc */
/* */
/*************************************************************************/
LOG("++ISPRMGR VAR5: [STARTED]\n");
LOG("++ISPRMGR VAR5: invoke exec with unmatched argc\n");
executable = "exittest.coff";
_argv[0] = executable;
_argv[1] = NULL;
_argc = 100;
LOG("++ISPRMGR VAR5: exec %s\n", executable);
retval = exec(executable, _argc, _argv);
if (retval != -1) {
LOG("++ISPRMGR VAR5: [END] FAIL\n");
break;
}
/* TODO; figure out this case */
LOG("++ISPRMGR VAR5:"
" invoke exec with unmatched argc when argv varies\n");
executable = "exittest.coff";
_argv[0] = executable;
_argv[1] = "cat.coff";
_argv[2] = "cat1.coff";
_argc = 2;
LOG("++ISPRMGR VAR5: exec %s\n", executable);
retval = exec(executable, _argc, _argv);
if (retval != 0) {
LOG("++ISPRMGR VAR5: Retval of exec is %d \n", retval);
LOG("++ISPRMGR VAR5: [END] SUCCESS\n");
}
else
LOG("++ISPRMGR VAR5: [END] FAIL\n");
break;
case 6:
{
/*************************************************************************/
/* */
/* Var 6 : tests your syscall join to a non-child */
/* */
/*************************************************************************/
LOG("++ISPRMGR VAR6: [STARTED]\n");
LOG("++ISPRMGR VAR6: Issue join to a non-child with pid=0\n");
retval = join(0, &exitstatus);
if (retval == 0) {
LOG("++ISPRMGR VAR6: [ENDED] FAIL\n");
break;
}
LOG("++ISPRMGR VAR6: Issue join to myself with pid=1\n");
retval = join(1, &exitstatus);
if (retval == 0) {
LOG("++ISPRMGR VAR6: [ENDED] FAIL\n");
break;
}
LOG("++ISPRMGR VAR6: [ENDED] SUCCESS\n");
}
case 7:
/*************************************************************************/
/* */
/* Var 7 : tests your syscall join to be invoked more than once */
/* */
/*************************************************************************/
LOG("++ISPRMGR VAR7: [STARTED]\n");
LOG("++ISPRMGR VAR7: test your syscall join to be invoked more than once\n");
executable = "exittest.coff";
_argv[0] = executable;
_argv[1] = NULL;
_argc = 1;
LOG("++ISPRMGR VAR7: exec %s\n", executable);
pid[0] = exec(executable, _argc, _argv);
LOG("++ISPRMGR VAR7: Child process id is %d\n", pid[0]);
LOG("++ISPRMGR VAR7: Issue join to get exit status of child process\n");
retval = join(pid[0], &exitstatus);
if (retval != 0) {
LOG("++ISPRMGR VAR7: [ENDED] FAIL\n");
break;
}
LOG("++ISPRMGR VAR7: first time invoke join successfully\n");
LOG("++ISPRMGR VAR7: Issue join again to get exit status of child process\n", pid[0]);
retval = join(pid[0], &exitstatus);
if (retval == 0) {
LOG("++ISPRMGR VAR7: [ENDED] FAILED to join process %d\n", pid[0]);
break;
}
LOG("++ISPRMGR VAR7: failed to invoke join second time as exptected\n");
LOG("++ISPRMGR VAR7: [ENDED] SUCCESS\n");
break;
case 8:
/*************************************************************************/
/* */
/* Var 8 : tests syscall join to a child */
/* that caused unhandled exception */
/* */
/*************************************************************************/
LOG("++ISPRMGR VAR8: [STARTED]\n");
LOG("++ISPRMGR VAR8: tests syscall join to a child that caused unhandled exception\n");
executable = "exception.coff";
_argv[0] = executable;
_argv[1] = NULL;
_argc = 1;
LOG("++ISPRMGR VAR8: exec %s\n", executable);
pid[0] = exec(executable, _argc, _argv);
if (pid[0] < 0) {
LOG("++ISPRMGR VAR8: [ENDED] FAIL to invoke exec\n");
break;
}
LOG("++ISPRMGR VAR8: Issue join to child with pid=%d\n", pid[0]);
retval = join(pid[0], &exitstatus);
if (exitstatus == 0) {
LOG("++ISPRMGR VAR8: Issue join successfully, but expect a failure at here\n");
LOG("++ISPRMGR VAR8: [ENDED] FAIL\n");
break;
}
else {
LOG("++ISPRMGR VAR8: failed to issue join as expected\n");
LOG("++ISPRMGR VAR8: [ENDED] SUCCESS\n");
}
break;
case 9:
/*************************************************************************/
/* */
/* Var 8: tests that your exit syscall releases all resources */
/* */
/*************************************************************************/
/* TODO: it's difficult to write code for this case */
LOG("++ISPRMGR VAR9: [STARTED]\n");
LOG("++ISPRMGR VAR9: tests that your exit syscall releases all resources\n");
i = 0;
while(i++ < MAXPROCESS) {
LOG("++ISPRMGR VAR9: [i] %d", i);
executable = "exittest.coff";
_argv[0] = executable;
_argv[1] = NULL;
_argc = 1;
LOG("++ISPRMGR VAR9: exec %s\n", executable);
pid[0] = exec(executable, _argc, _argv);
LOG("++ISPRMGR VAR9: Child process id is %d\n", pid[0]);
LOG("++ISPRMGR VAR9: Issue join to get exit status of child process\n", pid[0]);
retval = join(pid[0], &exitstatus);
if (retval == 1 || retval == 0) {
LOG("++ISPRMGR VAR9: join successfully, exit status is %d\n", exitstatus);
}
else {
LOG("++ISPRMGR VAR9: return value of join is %d\n", retval);
LOG("++ISPRMGR VAR9: [ENDED] FAIL\n");
flag = FALSE;
break;
}
}
if (flag) {
LOG("++ISPRMGR VAR9: [ENDED] SUCCESS\n");
}
break;
default:
0;
}
}
void log(char *format, ...) {
va_list ap;
va_start(ap,format);
vprintf(format, ap);
va_end(ap);
}
int atoi(const char *str) {
if (str == NULL)
return NAN;
int sum = 0;
int i = 0;
while(str[i] != NULL) {
sum = sum*10 + (str[i]-'0');
i++;
}
return sum;
}
|
the_stack_data/415866.c | static void print(char *str)
{
while(1) {
unsigned char ch;
ch = *str;
if (ch == '\0') {
break;
}
__builtin_outb(ch, 0x1234);
str += 1;
}
}
static void main(void)
{
print("hello world\r\n");
print("how are you today\r\n");
}
|
the_stack_data/94906.c | # include <stdarg.h>
int main(int argc, char *argv) {
return 0;
}
|
the_stack_data/742885.c | #include <stdio.h>
enum libbpf_print_level {
LIBBPF_WARN,
LIBBPF_INFO,
LIBBPF_DEBUG,
};
int jl_bpf_print(enum libbpf_print_level level, const char *fmt, va_list ap) {
return vfprintf(stderr, fmt, ap);
}
|
the_stack_data/876861.c |
/* crypto/mem_clr.c -*- mode:C; c-file-style: "eay" -*- */
/* Written by Geoff Thorpe ([email protected]) for the OpenSSL
* project 2002.
*/
/* ====================================================================
* Copyright (c) 2001 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* [email protected].
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* ([email protected]). This product includes software written by Tim
* Hudson ([email protected]).
*
*/
#include <string.h>
#include <openssl/crypto.h>
unsigned char cleanse_ctr = 0;
void OPENSSL_cleanse(void *ptr, size_t len)
{
unsigned char *p = ptr;
size_t loop = len, ctr = cleanse_ctr;
while(loop--)
{
*(p++) = (unsigned char)ctr;
ctr += (17 + ((size_t)p & 0xF));
}
p=memchr(ptr, (unsigned char)ctr, len);
if(p)
ctr += (63 + (size_t)p);
cleanse_ctr = (unsigned char)ctr;
}
|
the_stack_data/1015891.c | /*
Measure throughput of IPC using udp sockets
Copyright (c) 2016 Erik Rigtorp <[email protected]>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#include <netdb.h>
#include <netinet/tcp.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#define UNUSED(x) (void)(x)
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) && \
defined(_POSIX_MONOTONIC_CLOCK)
#define HAS_CLOCK_GETTIME_MONOTONIC
#endif
#ifdef HAS_CLOCK_GETTIME_MONOTONIC
struct timespec start, stop;
#else
struct timeval start, stop;
#endif
ssize_t size;
int64_t count;
void child_terminated(int signum)
{
int64_t delta;
UNUSED(signum);
wait(NULL);
#ifdef HAS_CLOCK_GETTIME_MONOTONIC
if (clock_gettime(CLOCK_MONOTONIC, &stop) == -1) {
perror("clock_gettime");
exit(1);
}
delta = ((stop.tv_sec - start.tv_sec) * 1000000 +
(stop.tv_nsec - start.tv_nsec) / 1000);
#else
if (gettimeofday(&stop, NULL) == -1) {
perror("gettimeofday");
return 1;
}
delta =
(stop.tv_sec - start.tv_sec) * 1000000 + (stop.tv_usec - start.tv_usec);
#endif
printf("average throughput: %li msg/s\n", (count * 1000000) / delta);
printf("average throughput: %li Mb/s\n",
(((count * 1000000) / delta) * size * 8) / 1000000);
exit(0);
}
int main(int argc, char *argv[]) {
char *buf;
int64_t i;
ssize_t len;
ssize_t sofar;
int yes = 1;
int ret;
struct addrinfo hints;
struct addrinfo *resChild;
struct addrinfo *resParent;
int sockfd;
if (argc != 3) {
printf("usage: tcp_thr <message-size> <message-count>\n");
return 1;
}
size = atoi(argv[1]);
count = atol(argv[2]);
buf = malloc(size);
if (buf == NULL) {
perror("malloc");
return 1;
}
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6, whichever
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE; // fill in my IP for me
if ((ret = getaddrinfo("127.0.0.1", "3491", &hints, &resParent)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret));
return 1;
}
if ((ret = getaddrinfo("127.0.0.1", "3492", &hints, &resChild)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret));
return 1;
}
printf("message size: %li octets\n", size);
printf("message count: %li\n", count);
signal(SIGCHLD, child_terminated);
if (!fork()) {
/* child */
if ((sockfd = socket(resChild->ai_family, resChild->ai_socktype, resChild->ai_protocol)) ==
-1) {
perror("socket");
return 1;
}
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
perror("setsockopt");
return 1;
}
if (bind(sockfd, resChild->ai_addr, resChild->ai_addrlen) == -1) {
perror("bind");
return 1;
}
for (i = 0; i < count; i++) {
for (sofar = 0; sofar < size;) {
len = recvfrom(sockfd, buf, size - sofar, 0, resParent->ai_addr, &resParent->ai_addrlen);
if (len == -1) {
perror("recvfrom");
return 1;
}
sofar += len;
}
}
} else {
/* parent */
sleep(1);
if ((sockfd = socket(resParent->ai_family, resParent->ai_socktype, resParent->ai_protocol)) ==
-1) {
perror("socket");
return 1;
}
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
perror("setsockopt");
return 1;
}
if (bind(sockfd, resParent->ai_addr, resParent->ai_addrlen) == -1) {
perror("bind");
return 1;
}
#ifdef HAS_CLOCK_GETTIME_MONOTONIC
if (clock_gettime(CLOCK_MONOTONIC, &start) == -1) {
perror("clock_gettime");
return 1;
}
#else
if (gettimeofday(&start, NULL) == -1) {
perror("gettimeofday");
return 1;
}
#endif
for (;;) {
for (sofar = 0; sofar < size;) {
size_t chunk = size - sofar;
chunk = (chunk > 65000) ? 65000 : chunk;
len = sendto(sockfd, buf, chunk, 0, resChild->ai_addr, resChild->ai_addrlen);
if (len == -1) {
perror("sendto");
return 1;
}
sofar += len;
}
}
}
return 0;
}
|
the_stack_data/25380.c | #include <stdio.h>
#include <stdlib.h>
#define BODIES 5000
#define TIMESTEPS 100
#define GRAVCONST 0.0000001
// global vars
float mass[BODIES];
float vx[BODIES], vy[BODIES];
float x[BODIES], y[BODIES];
float dx, dy, d, F, ax, ay;
void testInit();
void testInit2();
void randomInit();
void outputBody(int);
int main(void) {
int time, i, j;
// testInit2();
randomInit();
for (time=0; time<TIMESTEPS; time++) {
printf("Timestep %d\n",time);
for (i=0; i<BODIES; i++) {
// calc forces on body i due to bodies (j != i)
for (j=0; j<BODIES; j++) {
if (j != i) {
dx = x[j] - x[i];
dy = y[j] - y[i];
d = sqrt(dx*dx + dy*dy);
if (d<0.01) {
printf("too close - resetting\n");
d=1.0;
}
F = GRAVCONST * mass[i] * mass[j] / (d*d);
ax = (F/mass[i]) * dx/d;
ay = (F/mass[i]) * dy/d;
vx[i] += ax;
vy[i] += ay;
}
} // body j
} // body i
// having worked out all velocities we now apply and determine new position
for (i=0; i<BODIES; i++) {
x[i] += vx[i];
y[i] += vy[i];
//DEBUG ONLY: outputBody(i);
}
printf("---\n");
} // time
printf("Final data\n");
for (i=0; i<BODIES; i++) {
outputBody(i);
}
}
void randomInit() {
int i;
for (i=0; i<BODIES; i++) {
mass[i] = 0.001 + (float)rand()/(float)RAND_MAX; // 0.001 to 1.001
x[i] = -250.0 + 500.0*(float)rand()/(float)RAND_MAX; // -10 to +10 per axis
y[i] = -250.0 + 500.0*(float)rand()/(float)RAND_MAX; //
vx[i] = -0.2 + 0.4*(float)rand()/(float)RAND_MAX; // -0.25 to +0.25 per axis
vy[i] = -0.2 + 0.4*(float)rand()/(float)RAND_MAX;
}
printf("Randomly initialised\n");
return;
}
void testInit() {
/* test: initial zero velocity ==> attraction only ie bodies should move closer together */
int i;
for (i=0; i<BODIES; i++) {
mass[i] = 1.0;
x[i] = (float) i;
y[i] = (float) i;
vx[i] = 0.0;
vy[i] = 0.0;
}
}
void testInit2() {
/* test data */
mass[0] = 1.0;
x[0]=0.0;
y[0]=0.0;
vx[0]=0.01;
vy[0]=0.0;
mass[1] = 0.1;
x[1]=1.;
y[1]=1.;
vx[1]=0.;
vy[1]=0.;
mass[2] = .001;
x[2]=0.;;
y[2]=1.;
vx[2]=.01;
vy[2]=-.01;
}
void outputBody(int i) {
printf("Body %d: Position=(%f,%f) Velocity=(%f,%f)\n", i, x[i],y[i], vx[i],vy[i]);
return;
} |
the_stack_data/86076288.c | // general protection fault in skb_put
// https://syzkaller.appspot.com/bug?id=daed9d4cc6787646d0d4877a676facc12a3908db
// status:open
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
static int inject_fault(int nth)
{
int fd;
fd = open("/proc/thread-self/fail-nth", O_RDWR);
if (fd == -1)
exit(1);
char buf[16];
sprintf(buf, "%d", nth + 1);
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
exit(1);
return fd;
}
uint64_t r[1] = {0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
long res = 0;
memcpy((void*)0x20000140, "/dev/ptmx\000", 10);
res = syscall(__NR_openat, 0xffffffffffffff9c, 0x20000140, 0, 0);
if (res != -1)
r[0] = res;
*(uint32_t*)0x200000c0 = 0xf;
syscall(__NR_ioctl, r[0], 0x5423, 0x200000c0);
syscall(__NR_ioctl, r[0], 0x400455c8, 4);
*(uint32_t*)0x20000100 = 2;
write_file("/sys/kernel/debug/failslab/ignore-gfp-wait", "N");
write_file("/sys/kernel/debug/fail_futex/ignore-private", "N");
write_file("/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem", "N");
write_file("/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait", "N");
write_file("/sys/kernel/debug/fail_page_alloc/min-order", "0");
inject_fault(0);
syscall(__NR_ioctl, r[0], 0x5412, 0x20000100);
return 0;
}
|
the_stack_data/24008.c | /*Program to print the following
1 2 3 4
5 6 7 8
9 10 11 12
*/
#include<stdio.h>
int main()
{
int n;
printf("Enter the number of rows of the 2d array:\n");
scanf("%d",&n);
int a[n][4];
int count=1;
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<4;j++)
{
a[i][j]=count;
count++;
}
}
printf("\nThe desired 2d array is:\n\n");
for(i=0;i<n;i++)
{
for(j=0;j<4;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
return 0;
} |
the_stack_data/117326900.c | /* Copyright (C) 2014-2016 A. C. Open Hardware Ideas Lab
*
* Authors:
* Matteo Civale <[email protected]>
*
* 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.
******************************************************************************/
/**
* @file libohiboard/source/interrupt_KV46F.c
* @author Matteo Civale <[email protected]>
* @brief Interrupt implementations for KV46F and TWRKV46F.
*/
#if defined (LIBOHIBOARD_KV46F) || \
defined (LIBOHIBOARD_TRWKV46F)
#include "platforms.h"
#include "interrupt.h"
#define NVIC_NUM_CORE_VECTORS 16
#define NVIC_NUM_MCU_VECTORS 86
#define NVIC_NUM_VECTORS NVIC_NUM_CORE_VECTORS + NVIC_NUM_MCU_VECTORS
#define NVIC_MAX_PRIORITY 15
System_Errors Interrupt_enable (Interrupt_Vector vectorNumber)
{
/* Make sure that the IRQ is an allowable number. */
if (vectorNumber > NVIC_NUM_MCU_VECTORS)
return ERRORS_IRQ_NUM_VECTOR_WRONG;
/* Clear pending request */
NVIC_ClearPendingIRQ(vectorNumber);
/* Enable request */
NVIC_EnableIRQ(vectorNumber);
return ERRORS_NO_ERROR;
}
System_Errors Interrupt_disable (Interrupt_Vector vectorNumber)
{
/* Make sure that the IRQ is an allowable number. */
if (vectorNumber > NVIC_NUM_MCU_VECTORS)
return ERRORS_IRQ_NUM_VECTOR_WRONG;
NVIC_DisableIRQ(vectorNumber);
return ERRORS_NO_ERROR;
}
System_Errors Interrupt_setPriority (Interrupt_Vector vectorNumber, uint8_t priority)
{
if (priority > NVIC_MAX_PRIORITY) return ERRORS_IRQ_PRIORITY_LEVEL_WRONG;
/* Set interrupt priority note priority 0 is the higher priority level*/
NVIC_SetPriority(vectorNumber,priority);
return ERRORS_NO_ERROR;
}
#endif /* LIBOHIBOARD_KV46F || LIBOHIBOARD_TWRKV46F */
|
the_stack_data/231392371.c | #include <stdio.h>
#include <stdlib.h>
int main ()
{
int i,n;
printf("enter no of elements needed\n");
scanf("%d",&n);
int a[n];
int riv_a[n];
printf("enter elements\n");
for (i=0;i<n;i++)
{
scanf("%d\n",&a[i]);
}
for(i=0;i<n/2;i++)
{
riv_a[i]=a[n-1-i];
}
printf("reversed array\n");
for(i=0;i<n;i++)
{
printf("%d\n",riv_a[i]);
}
return 0;
}
|
the_stack_data/90765339.c | #include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
int day1();
int day2();
int day3();
int day4();
int day5();
int day6();
int day7();
int day8();
int day9();
int day10();
int day11();
int day12();
int day13();
int day14();
int day15();
int day16();
int day17();
int day18();
int day19();
int day20();
int day21();
int day22();
int day23();
int day24();
int day25();
int (*functions[])() = {
day1, day2, day3, day4, day5, day6, day7, day8, day9,
day10, day11, day12, day13, day14, day15, day16, day17, day18,
day19, day20, day21, day22, day23, day24, day25,
};
int64_t run_day(int8_t day, int8_t samples) {
struct timeval time_start, time_end, time_diff;
int64_t best_elapsed_time = 1000000;
for (int8_t i = 0; i < samples; i++) {
gettimeofday(&time_start, NULL);
functions[day - 1]();
gettimeofday(&time_end, NULL);
timersub(&time_end, &time_start, &time_diff);
int64_t elapsed_time = (int64_t) (time_diff.tv_sec * 1000000) + (int64_t) time_diff.tv_usec;
if (elapsed_time < best_elapsed_time) {
best_elapsed_time = elapsed_time;
}
}
return best_elapsed_time;
}
static void usage(const char *argv0) {
printf("Usage: %s [1-25] [options]\n", argv0);
puts(
"Options:\n"
"\t-h, --help Show this help text\n"
"\t-b, --bench Run 10 times, take best time\n");
}
int main(int argc, char** argv) {
int8_t n_samples = 1;
int8_t day = 0;
// parse CLI args
for (int8_t i = 1; i < argc; i++) {
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
usage(argv[0]);
return EXIT_SUCCESS;
} else if (strcmp(argv[i], "--bench") == 0 || strcmp(argv[i], "-b") == 0) {
n_samples = 100;
} else if (isdigit(*argv[i])) {
while (isdigit(*argv[i])) {
day = day * 10 + (*argv[i] - '0');
argv[i]++;
}
}
}
// run a single day
if (day > 0) {
int64_t elapsed_time = run_day(day, n_samples);
printf("Ran in %8ld μs\n", elapsed_time);
return 0;
}
// run all days consecutively
int64_t total_time = 0;
int64_t times[25] = {0};
for (int8_t d = 1; d <= 25; d++) {
int64_t elapsed_time = run_day(d, n_samples);
times[d-1] = elapsed_time;
total_time += elapsed_time;
}
// print timings per day
for (int32_t i=0; i < 25; i++) {
printf("Day %d:\t", i+1);
printf("%8ld μs\n", times[i]);
}
// print total time
printf("Total:\t%8ld μs (%.2f s)\n", total_time,
(double)total_time / 1000000.0);
return 0;
} |
the_stack_data/105161.c | /* ========================================================================== */
/* */
/* seqgen2x.c */
// Sam Siewert, December 2017
//
// Sequencer Generic @ 2x Rate for 10Hz Capture
//
// The purpose of this code is to provide an example for how to best
// sequence a set of periodic services for problems similar to and including
// the final project in real-time systems.
//
// For example: Service_1 for camera frame aquisition
// Service_2 for image analysis and timestamping
// Service_3 for image processing (difference images)
// Service_4 for save time-stamped image to file service
// Service_5 for save processed image to file service
// Service_6 for send image to remote server to save copy
// Service_7 for elapsed time in syslog each minute for debug
//
// At least two of the services need to be real-time and need to run on a single
// core or run without affinity on the SMP cores available to the Linux
// scheduler as a group. All services can be real-time, but you could choose
// to make just the first 2 real-time and the others best effort.
//
// For the standard project, to time-stamp images at the 1 Hz rate with unique
// clock images (unique second hand / seconds) per image, you might use the
// following rates for each service:
//
// Sequencer - 60 Hz
// [gives semaphores to all other services]
// Service_1 - 30 Hz, every other Sequencer loop
// [buffers 3 images per second]
// Service_2 - 10 Hz, every 6th Sequencer loop
// [time-stamp middle sample image with cvPutText or header]
// Service_3 - 5 Hz , every 12th Sequencer loop
// [difference current and previous time stamped images]
// Service_4 - 10 Hz, every 6th Sequencer loop
// [save time stamped image with cvSaveImage or write()]
// Service_5 - 5 Hz , every 12th Sequencer loop
// [save difference image with cvSaveImage or write()]
// Service_6 - 10 Hz, every 6th Sequencer loop
// [write current time-stamped image to TCP socket server]
// Service_7 - 1 Hz , every 60th Sequencer loop
// [syslog the time for debug]
//
// With the above, priorities by RM policy would be:
//
// Sequencer = RT_MAX @ 60 Hz
// Servcie_1 = RT_MAX-1 @ 30 Hz
// Service_2 = RT_MAX-2 @ 10 Hz
// Service_3 = RT_MAX-3 @ 5 Hz
// Service_4 = RT_MAX-2 @ 10 Hz
// Service_5 = RT_MAX-3 @ 5 Hz
// Service_6 = RT_MAX-2 @ 10 Hz
// Service_7 = RT_MIN @ 1 Hz
//
// Here are a few hardware/platform configuration settings on your Jetson
// that you should also check before running this code:
//
// 1) Check to ensure all your CPU cores on in an online state.
//
// 2) Check /sys/devices/system/cpu or do lscpu.
//
// Tegra is normally configured to hot-plug CPU cores, so to make all
// available, as root do:
//
// echo 0 > /sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/enable
// echo 1 > /sys/devices/system/cpu/cpu1/online
// echo 1 > /sys/devices/system/cpu/cpu2/online
// echo 1 > /sys/devices/system/cpu/cpu3/online
//
// 3) Check for precision time resolution and support with cat /proc/timer_list
//
// 4) Ideally all printf calls should be eliminated as they can interfere with
// timing. They should be replaced with an in-memory event logger or at
// least calls to syslog.
//
// 5) For simplicity, you can just allow Linux to dynamically load balance
// threads to CPU cores (not set affinity) and as long as you have more
// threads than you have cores, this is still an over-subscribed system
// where RM policy is required over the set of cores.
// This is necessary for CPU affinity macros in Linux
#define _GNU_SOURCE
#include <errno.h>
#include <pthread.h>
#include <sched.h>
#include <semaphore.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#define USEC_PER_MSEC ( 1000 )
#define NANOSEC_PER_SEC ( 1000000000 )
#define NUM_CPU_CORES ( 1 )
#define TRUE ( 1 )
#define FALSE ( 0 )
#define NUM_THREADS ( 7 + 1 )
int abortTest = FALSE;
int abortS1 = FALSE, abortS2 = FALSE, abortS3 = FALSE, abortS4 = FALSE, abortS5 = FALSE, abortS6 = FALSE, abortS7 = FALSE;
sem_t semS1, semS2, semS3, semS4, semS5, semS6, semS7;
struct timeval start_time_val;
typedef struct
{
int threadIdx;
unsigned long long sequencePeriods;
} threadParams_t;
double timestamp()
{
struct timespec time = {0, 0};
clock_gettime( CLOCK_REALTIME, &time );
double msecs = ( (double)time.tv_sec * 1000.0 ) +
( (double)( (double)time.tv_nsec / 1000000.0 ) );
return msecs;
}
void *Sequencer( void *threadp );
void *Service_1( void *threadp );
void *Service_2( void *threadp );
void *Service_3( void *threadp );
void *Service_4( void *threadp );
void *Service_5( void *threadp );
void *Service_6( void *threadp );
void *Service_7( void *threadp );
void print_scheduler( void );
void main( void )
{
struct timeval current_time_val;
int i, rc, scope;
cpu_set_t threadcpu;
pthread_t threads[ NUM_THREADS ];
threadParams_t threadParams[ NUM_THREADS ];
pthread_attr_t rt_sched_attr[ NUM_THREADS ];
int rt_max_prio, rt_min_prio;
struct sched_param rt_param[ NUM_THREADS ];
struct sched_param main_param;
pthread_attr_t main_attr;
pid_t mainpid;
cpu_set_t allcpuset;
printf( "Starting High Rate Sequencer Demo\n" );
printf( "Checkpoint 1: Start time: %.4f \n", timestamp() );
gettimeofday( &start_time_val, (struct timezone *)0 );
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "START High Rate Sequencer @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "System has %d processors configured and %d available.\n", get_nprocs_conf(), get_nprocs() );
CPU_ZERO( &allcpuset );
for ( i = 0; i < NUM_CPU_CORES; i++ )
CPU_SET( i, &allcpuset );
printf( "Using CPUS=%d from total available.\n", CPU_COUNT( &allcpuset ) );
printf( "Checkpoint 2: Time: %.4f \n", timestamp() );
// initialize the sequencer semaphores
//
if ( sem_init( &semS1, 0, 0 ) )
{
printf( "Failed to initialize S1 semaphore\n" );
exit( -1 );
}
if ( sem_init( &semS2, 0, 0 ) )
{
printf( "Failed to initialize S2 semaphore\n" );
exit( -1 );
}
if ( sem_init( &semS3, 0, 0 ) )
{
printf( "Failed to initialize S3 semaphore\n" );
exit( -1 );
}
if ( sem_init( &semS4, 0, 0 ) )
{
printf( "Failed to initialize S4 semaphore\n" );
exit( -1 );
}
if ( sem_init( &semS5, 0, 0 ) )
{
printf( "Failed to initialize S5 semaphore\n" );
exit( -1 );
}
if ( sem_init( &semS6, 0, 0 ) )
{
printf( "Failed to initialize S6 semaphore\n" );
exit( -1 );
}
if ( sem_init( &semS7, 0, 0 ) )
{
printf( "Failed to initialize S7 semaphore\n" );
exit( -1 );
}
mainpid = getpid();
rt_max_prio = sched_get_priority_max( SCHED_FIFO );
rt_min_prio = sched_get_priority_min( SCHED_FIFO );
rc = sched_getparam( mainpid, &main_param );
main_param.sched_priority = rt_max_prio;
rc = sched_setscheduler( getpid(), SCHED_FIFO, &main_param );
if ( rc < 0 )
perror( "main_param" );
print_scheduler();
pthread_attr_getscope( &main_attr, &scope );
if ( scope == PTHREAD_SCOPE_SYSTEM )
printf( "PTHREAD SCOPE SYSTEM\n" );
else if ( scope == PTHREAD_SCOPE_PROCESS )
printf( "PTHREAD SCOPE PROCESS\n" );
else
printf( "PTHREAD SCOPE UNKNOWN\n" );
printf( "rt_max_prio=%d\n", rt_max_prio );
printf( "rt_min_prio=%d\n", rt_min_prio );
for ( i = 0; i < NUM_THREADS; i++ )
{
CPU_ZERO( &threadcpu );
CPU_SET( 3, &threadcpu );
rc = pthread_attr_init( &rt_sched_attr[ i ] );
rc = pthread_attr_setinheritsched( &rt_sched_attr[ i ], PTHREAD_EXPLICIT_SCHED );
rc = pthread_attr_setschedpolicy( &rt_sched_attr[ i ], SCHED_FIFO );
//rc=pthread_attr_setaffinity_np(&rt_sched_attr[i], sizeof(cpu_set_t), &threadcpu);
rt_param[ i ].sched_priority = rt_max_prio - i;
pthread_attr_setschedparam( &rt_sched_attr[ i ], &rt_param[ i ] );
threadParams[ i ].threadIdx = i;
}
printf( "Service threads will run on %d CPU cores\n", CPU_COUNT( &threadcpu ) );
printf( "Checkpoint 3: Time: %.4f \n", timestamp() );
// Create Service threads which will block awaiting release for:
//
// Servcie_1 = RT_MAX-1 @ 30 Hz
//
rt_param[ 1 ].sched_priority = rt_max_prio - 1;
pthread_attr_setschedparam( &rt_sched_attr[ 1 ], &rt_param[ 1 ] );
rc = pthread_create( &threads[ 1 ], // pointer to thread descriptor
&rt_sched_attr[ 1 ], // use specific attributes
//(void *)0, // default attributes
Service_1, // thread function entry point
(void *)&( threadParams[ 1 ] ) // parameters to pass in
);
if ( rc < 0 )
perror( "pthread_create for service 1" );
else
{
printf( "pthread_create successful for service 1\n" );
printf( "Checkpoint 4: Time: %.4f \n", timestamp() );
}
// Service_2 = RT_MAX-2 @ 10 Hz
//
rt_param[ 2 ].sched_priority = rt_max_prio - 2;
pthread_attr_setschedparam( &rt_sched_attr[ 2 ], &rt_param[ 2 ] );
rc = pthread_create( &threads[ 2 ], &rt_sched_attr[ 2 ], Service_2, (void *)&( threadParams[ 2 ] ) );
if ( rc < 0 )
perror( "pthread_create for service 2" );
else
{
printf( "pthread_create successful for service 2\n" );
printf( "Checkpoint 5: Time: %.4f \n", timestamp() );
}
// Service_3 = RT_MAX-3 @ 5 Hz
//
rt_param[ 3 ].sched_priority = rt_max_prio - 3;
pthread_attr_setschedparam( &rt_sched_attr[ 3 ], &rt_param[ 3 ] );
rc = pthread_create( &threads[ 3 ], &rt_sched_attr[ 3 ], Service_3, (void *)&( threadParams[ 3 ] ) );
if ( rc < 0 )
perror( "pthread_create for service 3" );
else
{
printf( "pthread_create successful for service 3\n" );
printf( "Checkpoint 6: Time: %.4f \n", timestamp() );
}
// Service_4 = RT_MAX-2 @ 10 Hz
//
rt_param[ 4 ].sched_priority = rt_max_prio - 3;
pthread_attr_setschedparam( &rt_sched_attr[ 4 ], &rt_param[ 4 ] );
rc = pthread_create( &threads[ 4 ], &rt_sched_attr[ 4 ], Service_4, (void *)&( threadParams[ 4 ] ) );
if ( rc < 0 )
perror( "pthread_create for service 4" );
else
{
printf( "pthread_create successful for service 4\n" );
printf( "Checkpoint 7: Time: %.4f \n", timestamp() );
}
// Service_5 = RT_MAX-3 @ 5 Hz
//
rt_param[ 5 ].sched_priority = rt_max_prio - 3;
pthread_attr_setschedparam( &rt_sched_attr[ 5 ], &rt_param[ 5 ] );
rc = pthread_create( &threads[ 5 ], &rt_sched_attr[ 5 ], Service_5, (void *)&( threadParams[ 5 ] ) );
if ( rc < 0 )
perror( "pthread_create for service 5" );
else
{
printf( "pthread_create successful for service 5\n" );
printf( "Checkpoint 8: Time: %lu \n", timestamp() );
}
// Service_6 = RT_MAX-2 @ 10 Hz
//
rt_param[ 6 ].sched_priority = rt_max_prio - 2;
pthread_attr_setschedparam( &rt_sched_attr[ 6 ], &rt_param[ 6 ] );
rc = pthread_create( &threads[ 6 ], &rt_sched_attr[ 6 ], Service_6, (void *)&( threadParams[ 6 ] ) );
if ( rc < 0 )
perror( "pthread_create for service 6" );
else
{
printf( "pthread_create successful for service 6\n" );
printf( "Checkpoint 9: Time: %.4f \n", timestamp() );
}
// Service_7 = RT_MIN 1 Hz
//
rt_param[ 7 ].sched_priority = rt_min_prio;
pthread_attr_setschedparam( &rt_sched_attr[ 7 ], &rt_param[ 7 ] );
rc = pthread_create( &threads[ 7 ], &rt_sched_attr[ 7 ], Service_7, (void *)&( threadParams[ 7 ] ) );
if ( rc < 0 )
perror( "pthread_create for service 7" );
else
{
printf( "pthread_create successful for service 7\n" );
printf( "Checkpoint 10: Time: %.4f \n", timestamp() );
}
// Wait for service threads to initialize and await relese by sequencer.
//
// Note that the sleep is not necessary of RT service threads are created wtih
// correct POSIX SCHED_FIFO priorities compared to non-RT priority of this main
// program.
//
// usleep(1000000);
// Create Sequencer thread, which like a cyclic executive, is highest prio
printf( "Start sequencer\n" );
threadParams[ 0 ].sequencePeriods = 1800;
// Sequencer = RT_MAX @ 60 Hz
//
rt_param[ 0 ].sched_priority = rt_max_prio;
pthread_attr_setschedparam( &rt_sched_attr[ 0 ], &rt_param[ 0 ] );
rc = pthread_create( &threads[ 0 ], &rt_sched_attr[ 0 ], Sequencer, (void *)&( threadParams[ 0 ] ) );
if ( rc < 0 )
perror( "pthread_create for sequencer service 0" );
else
{
printf( "pthread_create successful for sequeencer service 0\n" );
printf( "Checkpoint 11: Time: %.4f \n", timestamp() );
}
for ( i = 0; i < NUM_THREADS; i++ )
pthread_join( threads[ i ], NULL );
printf( "\nTEST COMPLETE\n" );
}
void *Sequencer( void *threadp )
{
struct timeval current_time_val;
struct timespec delay_time = {0, 16666666}; // delay for 16.67 msec, 60 Hz
struct timespec remaining_time;
double current_time;
double residual;
int rc, delay_cnt = 0;
unsigned long long seqCnt = 0;
threadParams_t *threadParams = (threadParams_t *)threadp;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Sequencer thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "Sequencer thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
do
{
delay_cnt = 0;
residual = 0.0;
//gettimeofday(¤t_time_val, (struct timezone *)0);
//syslog(LOG_CRIT, "Sequencer thread prior to delay @ sec=%d, msec=%d\n", (int)(current_time_val.tv_sec-start_time_val.tv_sec), (int)current_time_val.tv_usec/USEC_PER_MSEC);
do
{
rc = nanosleep( &delay_time, &remaining_time );
if ( rc == EINTR )
{
residual = remaining_time.tv_sec + ( (double)remaining_time.tv_nsec / (double)NANOSEC_PER_SEC );
if ( residual > 0.0 )
printf( "residual=%lf, sec=%d, nsec=%d\n", residual, (int)remaining_time.tv_sec, (int)remaining_time.tv_nsec );
delay_cnt++;
}
else if ( rc < 0 )
{
perror( "Sequencer nanosleep" );
exit( -1 );
}
} while ( ( residual > 0.0 ) && ( delay_cnt < 100 ) );
seqCnt++;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Sequencer cycle %llu @ sec=%d, msec=%d\n", seqCnt, (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
if ( delay_cnt > 1 )
printf( "Sequencer looping delay %d\n", delay_cnt );
// Release each service at a sub-rate of the generic sequencer rate
// Servcie_1 = RT_MAX-1 @ 30 Hz
if ( ( seqCnt % 2 ) == 0 )
sem_post( &semS1 );
// Service_2 = RT_MAX-2 @ 10 Hz
if ( ( seqCnt % 6 ) == 0 )
sem_post( &semS2 );
// Service_3 = RT_MAX-3 @ 5 Hz
if ( ( seqCnt % 12 ) == 0 )
sem_post( &semS3 );
// Service_4 = RT_MAX-2 @ 10 Hz
if ( ( seqCnt % 6 ) == 0 )
sem_post( &semS4 );
// Service_5 = RT_MAX-3 @ 5 Hz
if ( ( seqCnt % 12 ) == 0 )
sem_post( &semS5 );
// Service_6 = RT_MAX-2 @ 10 Hz
if ( ( seqCnt % 6 ) == 0 )
sem_post( &semS6 );
// Service_7 = RT_MIN 1 Hz
if ( ( seqCnt % 60 ) == 0 )
sem_post( &semS7 );
//gettimeofday(¤t_time_val, (struct timezone *)0);
//syslog(LOG_CRIT, "Sequencer release all sub-services @ sec=%d, msec=%d\n", (int)(current_time_val.tv_sec-start_time_val.tv_sec), (int)current_time_val.tv_usec/USEC_PER_MSEC);
} while ( !abortTest && ( seqCnt < threadParams->sequencePeriods ) );
sem_post( &semS1 );
sem_post( &semS2 );
sem_post( &semS3 );
sem_post( &semS4 );
sem_post( &semS5 );
sem_post( &semS6 );
sem_post( &semS7 );
abortS1 = TRUE;
abortS2 = TRUE;
abortS3 = TRUE;
abortS4 = TRUE;
abortS5 = TRUE;
abortS6 = TRUE;
abortS7 = TRUE;
pthread_exit( (void *)0 );
}
void *Service_1( void *threadp )
{
static double start = 0.0;
static double end = 0.0;
static double wcet = 0.0;
struct timeval current_time_val;
double current_time;
unsigned long long S1Cnt = 0;
threadParams_t *threadParams = (threadParams_t *)threadp;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Frame Sampler thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "Frame Sampler thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
while ( !abortS1 )
{
sem_wait( &semS1 );
start = timestamp();
S1Cnt++;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Frame Sampler release %llu @ sec=%d, msec=%d\n", S1Cnt, (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
end = timestamp();
if ( ( end - start ) > wcet )
{
wcet = end - start;
}
}
printf( "Service 1 WCET: %.4f \n", wcet );
pthread_exit( (void *)0 );
}
void *Service_2( void *threadp )
{
static double start = 0.0;
static double end = 0.0;
static double wcet = 0.0;
struct timeval current_time_val;
double current_time;
unsigned long long S2Cnt = 0;
threadParams_t *threadParams = (threadParams_t *)threadp;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Time-stamp with Image Analysis thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "Time-stamp with Image Analysis thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
while ( !abortS2 )
{
sem_wait( &semS2 );
start = timestamp();
S2Cnt++;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Time-stamp with Image Analysis release %llu @ sec=%d, msec=%d\n", S2Cnt, (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
end = timestamp();
if ( ( end - start ) > wcet )
{
wcet = end - start;
}
}
printf( "Service 2 WCET: %.4f \n", wcet );
pthread_exit( (void *)0 );
}
void *Service_3( void *threadp )
{
static double start = 0.0;
static double end = 0.0;
static double wcet = 0.0;
struct timeval current_time_val;
double current_time;
unsigned long long S3Cnt = 0;
threadParams_t *threadParams = (threadParams_t *)threadp;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Difference Image Proc thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "Difference Image Proc thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
while ( !abortS3 )
{
sem_wait( &semS3 );
start = timestamp();
S3Cnt++;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Difference Image Proc release %llu @ sec=%d, msec=%d\n", S3Cnt, (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
end = timestamp();
if ( ( end - start ) > wcet )
{
wcet = end - start;
}
}
printf( "Service 3 WCET: %.4f \n", wcet );
pthread_exit( (void *)0 );
}
void *Service_4( void *threadp )
{
static double start = 0.0;
static double end = 0.0;
static double wcet = 0.0;
struct timeval current_time_val;
double current_time;
unsigned long long S4Cnt = 0;
threadParams_t *threadParams = (threadParams_t *)threadp;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Time-stamp Image Save to File thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "Time-stamp Image Save to File thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
while ( !abortS4 )
{
sem_wait( &semS4 );
start = timestamp();
S4Cnt++;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Time-stamp Image Save to File release %llu @ sec=%d, msec=%d\n", S4Cnt, (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
end = timestamp();
if ( ( end - start ) > wcet )
{
wcet = end - start;
}
}
printf( "Service 4 WCET: %.4f \n", wcet );
pthread_exit( (void *)0 );
}
void *Service_5( void *threadp )
{
static double start = 0.0;
static double end = 0.0;
static double wcet = 0.0;
struct timeval current_time_val;
double current_time;
unsigned long long S5Cnt = 0;
threadParams_t *threadParams = (threadParams_t *)threadp;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Processed Image Save to File thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "Processed Image Save to File thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
while ( !abortS5 )
{
sem_wait( &semS5 );
start = timestamp();
S5Cnt++;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Processed Image Save to File release %llu @ sec=%d, msec=%d\n", S5Cnt, (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
end = timestamp();
if ( ( end - start ) > wcet )
{
wcet = end - start;
}
}
printf( "Service 5 WCET: %.4f \n", wcet );
pthread_exit( (void *)0 );
}
void *Service_6( void *threadp )
{
static double start = 0.0;
static double end = 0.0;
static double wcet = 0.0;
struct timeval current_time_val;
double current_time;
unsigned long long S6Cnt = 0;
threadParams_t *threadParams = (threadParams_t *)threadp;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Send Time-stamped Image to Remote thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "Send Time-stamped Image to Remote thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
while ( !abortS6 )
{
sem_wait( &semS6 );
start = timestamp();
S6Cnt++;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "Send Time-stamped Image to Remote release %llu @ sec=%d, msec=%d\n", S6Cnt, (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
end = timestamp();
if ( ( end - start ) > wcet )
{
wcet = end - start;
}
}
printf( "Service 6 WCET: %.4f \n", wcet );
pthread_exit( (void *)0 );
}
void *Service_7( void *threadp )
{
static double start = 0.0;
static double end = 0.0;
static double wcet = 0.0;
struct timeval current_time_val;
double current_time;
unsigned long long S7Cnt = 0;
threadParams_t *threadParams = (threadParams_t *)threadp;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "10 sec Tick Debug thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
printf( "10 sec Tick Debug thread @ sec=%d, msec=%d\n", (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
while ( !abortS7 )
{
sem_wait( &semS7 );
start = timestamp();
S7Cnt++;
gettimeofday( ¤t_time_val, (struct timezone *)0 );
syslog( LOG_CRIT, "10 Sec Tick Debug release %llu @ sec=%d, msec=%d\n", S7Cnt, (int)( current_time_val.tv_sec - start_time_val.tv_sec ), (int)current_time_val.tv_usec / USEC_PER_MSEC );
end = timestamp();
if ( ( end - start ) > wcet )
{
wcet = end - start;
}
}
printf( "Service 7 WCET: %.4f \n", wcet );
pthread_exit( (void *)0 );
}
void print_scheduler( void )
{
int schedType;
schedType = sched_getscheduler( getpid() );
switch ( schedType )
{
case SCHED_FIFO:
printf( "Pthread Policy is SCHED_FIFO\n" );
break;
case SCHED_OTHER:
printf( "Pthread Policy is SCHED_OTHER\n" );
exit( -1 );
break;
case SCHED_RR:
printf( "Pthread Policy is SCHED_RR\n" );
exit( -1 );
break;
default:
printf( "Pthread Policy is UNKNOWN\n" );
exit( -1 );
}
} |
the_stack_data/122627.c | /*
* This program finds the digital root of a non-negative number. The digital
* root of a number is calculated by repeatedly adding all its digits until
* the result has only one digit. For example, num = 38, the process is like:
* 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, we return 2. For more
* information on digital root, please refer to the following link:-
* https://en.wikipedia.org/wiki/Digital_root
*/
#include<stdio.h>
#include<assert.h>
/*
* This function iteratively finds the digital root of a positive number.
* If the number is either zero or negative, zero is returned as the
* digital root of the number. If the number is positive, then we find
* the sum of the digits of the number until the number has a single
* digit left. We return this single digit as the digital root of the
* number. The time complexity of this function is O(n), where 'n' is the
* number of digits in the number. The space complexity of this function is
* O(1).
*/
int get_digital_root_v1 (int num)
{
int temp;
/*
* If the number is less than or equal to zero, then return
* zero as the digital root of the number.
*/
if (num <= 0) {
return(0);
}
/*
* Iterate until the number has a single digit.
*/
while (num / 10) {
/*
* Store the sum of all the digits of the number
* in 'temp'
*/
temp = 0;
while (num) {
temp += num % 10;
num /= 10;
}
/*
* Assign 'temp' to 'num'
*/
num = temp;
}
/*
* Return the single digit in the number
*/
return(num);
}
/*
* This function finds the digital root of a positive number. If the
* number is either zero or negative, zero is returned as the digital
* root of the number. If the number is positive, then we find the
* digital using the airthmetic with number nine. The time and space
* complexity of this function is O(1).
*/
int get_digital_root_v2 (int num)
{
/*
* If the number is less than or equal to zero, then return
* zero as the digital root of the number.
*/
if (num <= 0) {
return(0);
}
/*
* If the number is divisible by nine, then the digital root
* of the number is nine otherwise digital root is the remainder
* of division by nine (See the above link).
*/
if ((num % 9) == 0) {
return(9);
} else {
return(num % 9);
}
}
int main ()
{
/*
* Test 0: The digital root of a negative number should be zero
*/
assert(0 == get_digital_root_v1(-1));
assert(0 == get_digital_root_v2(-1));
/*
* Test 1: The digital root of zero should be zero
*/
assert(0 == get_digital_root_v1(0));
assert(0 == get_digital_root_v2(0));
/*
* Test 2: The digital root of single digit umber should be the
* same single digit number
*/
assert(1 == get_digital_root_v1(1));
assert(1 == get_digital_root_v2(1));
assert(9 == get_digital_root_v1(9));
assert(9 == get_digital_root_v2(9));
/*
* Test 3: Test the digital root of multiple digit numbers which
* are not multiples of nine.
*/
assert((25 % 9) == get_digital_root_v1(25));
assert((25 % 9) == get_digital_root_v2(25));
/*
* Test 4: Test the digital root of multiple digit numbers which
* are multiples of nine.
*/
assert(9 == get_digital_root_v1(81));
assert(9 == get_digital_root_v2(81));
return(0);
}
|
the_stack_data/13614.c |
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#define TAILLE 1000000
#define INC 1e13
int main(){
// Allouer un tableau de TAILLE entiers.
int* tableau = malloc(TAILLE*sizeof(int));
assert(tableau); //allocation réussie ?
// Initialiser les éléments à 1
for (int i=0; i<TAILLE; i++){
tableau[i]=1;
}
// Augmenter la taille du tableau pour enregistrer INC entiers supplémentaires.
tableau = realloc(tableau, (TAILLE+INC)*sizeof(int));
assert(tableau);
// Initialiser l'élément d'indice 0 à 2
tableau[0]=2;
printf("%s", "\n Bravo ! Tous les tests passent.\n");
return EXIT_SUCCESS;
}
|
the_stack_data/34152.c | #include <stdio.h>
#include <stdlib.h>
// test program:
// simple loop
int main(int argc, char const *argv[]) {
int x = rand();
if (x < 17){
x = x % 22;
if(x > 38) {
int z = 42;
z += 7;
printf("%d\n", z);
}
}
printf("%d\n", x);
}
|
the_stack_data/159514271.c | int main() {
long a = 9223372036854775807;
long b = a / 1000000000000000000;
print((int)b);
}
|
the_stack_data/6386747.c | #include <string.h>
size_t strlen(const char *s){
size_t len = 0;
while (*(s++) != 0) ++len;
return len;
}
char* strcpy(char* restrict s1, register const char* restrict s2){
register char* t = s1;
while ((*(t++) = *(s2++)) != '\0') ;
return s1;
}
char* strncpy(char* restrict s1, register const char* restrict s2, size_t n){
register char* t = s1;
size_t l = 0;
while ((*(t++) = *(s2++)) != '\0' && l<n) ++l;
return s1;
}
|
the_stack_data/72011610.c | // Test that we get the expected module flag metadata for the memory profile
// filename.
// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s --check-prefix=NONE
// RUN: %clang -target x86_64-linux-gnu -fmemory-profile -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DEFAULTNAME
// RUN: %clang -target x86_64-linux-gnu -fmemory-profile=/tmp -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CUSTOMNAME
int main(void) {
return 0;
}
// NONE-NOT: MemProfProfileFilename
// DEFAULTNAME: !{i32 1, !"MemProfProfileFilename", !"memprof.profraw"}
// CUSTOMNAME: !{i32 1, !"MemProfProfileFilename", !"/tmp{{.*}}memprof.profraw"}
|
the_stack_data/242331820.c |
#define NUMBER 42
void foobar()
{
int x;
x = NUMBER;
}
|
the_stack_data/99443.c | int MAIN_FUNCTION_op_sub_var();
int main(){
return !(MAIN_FUNCTION_op_sub_var() == 17); /*exit code 0 means success */
} |
the_stack_data/1021056.c | # include <stdio.h>
int main(void){
// overflow é quando se tenta armanezar em uma variável um valor maior do que o seu limite
// underflow é a mesma coisa só que com valores menores que o limite inferior
short int x = 2147483647;
short int y = -214783647;
// perceba que os valores printados no terminal são diferentes dos armazenados nas variáveis
printf("%i", x);
printf("%i", y);
return 0;
} |
the_stack_data/511556.c | #include <stdio.h>
int main(){
char op;
double matriz[12][12], soma;
int linhaCont, colunaCont, posicaoInicial = 0, posicaoFinal = 12,cont = 0;
scanf(" %c", &op);
for(linhaCont = 0; linhaCont < 12; linhaCont++){
for(colunaCont = 0; colunaCont < 12; colunaCont++){
scanf(" %lf", &matriz[linhaCont][colunaCont]);
}
}
for(linhaCont = 0; linhaCont < 5; linhaCont++){
posicaoInicial += 1;
posicaoFinal -= 1;
for(colunaCont = posicaoInicial; colunaCont < posicaoFinal; colunaCont++){
soma += matriz[linhaCont][colunaCont];
cont += 1;
}
}
if(op == 'S'){
printf("%.1lf\n", soma);
}else{
printf("%.1lf\n", soma/cont);
}
return 0;
}
|
the_stack_data/776042.c | #ifdef TEST
#include "unity.h"
#include "test_assert_with_exception.h"
#include "mock_uz_AXI.h" // Tells Ceedling to create mock versions of the functions in uz_AXI (e.g., _Expect)
#include "uz_myIP2_hwAddresses.h"
#define TEST_BASE_ADDRESS 0x00000000F // random hex value that represents a fictional base address
#include "uz_myIP2_hw.h"
void setUp(void)
{
}
void tearDown(void)
{
}
void test_uz_myIP2_hw_write_to_A(void)
{
int a=-10;
// Test passes if uz_axi_write_int32 is called once with these arguments
uz_axi_write_int32_Expect(TEST_BASE_ADDRESS+A_int32_Data_uz_axi_testIP,a);
uz_myIP2_hw_write_A(TEST_BASE_ADDRESS,a);
}
void test_uz_myIP2_hw_write_to_B(void)
{
int b=100;
uz_axi_write_int32_Expect(TEST_BASE_ADDRESS+B_int32_Data_uz_axi_testIP,b);
uz_myIP2_hw_write_B(TEST_BASE_ADDRESS,b);
}
void test_uz_myIP2_hw_read_from_C(void)
{
int c=101230;
uz_axi_read_int32_ExpectAndReturn(TEST_BASE_ADDRESS+C_int32_Data_uz_axi_testIP,c);
int c_readback=uz_myIP2_hw_read_C(TEST_BASE_ADDRESS);
TEST_ASSERT_EQUAL_INT(c,c_readback);
}
void test_uz_myIP2_hw_read_C_with_zero_base_address(void)
{
int c=123;
// Ignores how often the read function is called and returns (c)
uz_axi_read_int32_IgnoreAndReturn(c);
TEST_ASSERT_FAIL_ASSERT(uz_myIP2_hw_read_C(0));
}
void test_uz_myIP2_hw_write_to_B_with_zero_base_address(void)
{
int b=10;
uz_axi_write_int32_Ignore();
TEST_ASSERT_FAIL_ASSERT(uz_myIP2_hw_write_B(0,b));
}
void test_uz_myIP2_hw_write_to_A_with_zero_base_address(void)
{
int a=-10;
uz_axi_write_int32_Ignore();
TEST_ASSERT_FAIL_ASSERT(uz_myIP2_hw_write_A(0,a));
}
#endif // TEST
|
the_stack_data/3262254.c | /**
* https://leetcode-cn.com/problems/coin-change/
* 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1。
* 你可以认为每种硬币的数量是无限的。
*/
#include "stdio.h"
/**
* 获取最小组合数量
*
* @param coins 硬币列表
* @param coinsSize 硬币大小
* @param amount 总金额
* @return
*/
int coinChange(const int *coins, int coinsSize, int amount) {
int dp[amount + 1];
dp[0] = 0;
// Onm
for (int i = 1; i <= amount; i++) {
dp[i] = amount + 1; // 设置一个大值,表示该金额无法组合
for (int j = 0; j < coinsSize; j++) {
int coinValue = coins[j];
if (coinValue <= i) {
dp[i] = (dp[i - coinValue] + 1) < dp[i] ? (dp[i - coinValue] + 1) : dp[i];
}
}
}
return dp[amount] > amount ? -1 : dp[amount];
}
int main() {
int coins[] = {2, 3, 7};
int size = coinChange(coins, 3, 19);
printf("size: %d", size);
} |
the_stack_data/6744.c | #include <stdio.h>
#include <stdlib.h>
#include <limits.h>
struct node {
int data;
struct node* next;
};
struct queue {
struct node *front;
struct node *rear;
size_t length;
};
void init(struct queue *queue)
{
queue->front = NULL;
queue->rear = NULL;
queue->length = 0;
}
int enqueue(struct queue *queue, int data)
{
struct node *pnode = malloc(sizeof(struct node));
pnode->data = data;
pnode->next = NULL;
if(queue->rear == NULL) {
queue->rear = pnode;
queue->front = pnode;
}
else {
queue->rear->next = pnode;
queue->rear = pnode;
}
queue->length++;
return 0;
}
int dequeue(struct queue *queue)
{
int ret = INT_MIN;
struct node *pnode = queue->front;
if(pnode) {
ret = pnode->data;
queue->front = pnode->next;
if(queue->front == NULL) {
queue->rear = NULL;
}
free(pnode);
queue->length--;
}
else {
puts("empty queue");
}
return ret;
}
int front(struct queue *queue)
{
int retval = INT_MIN;
if(queue && queue->front) {
retval = queue->front->data;
}
return retval;
}
int rear(struct queue *queue)
{
int retval = INT_MIN;
if(queue && queue->rear) {
retval = queue->rear->data;
}
return retval;
}
int is_empty(struct queue *queue)
{
return queue->front==NULL?1:0;
}
int length(struct queue *queue)
{
return queue->length;
}
int main(int argc, char** argv)
{
int x;
struct queue queue;
init(&queue);
enqueue(&queue, 0);
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
puts("-----------------------");
enqueue(&queue, 1);
enqueue(&queue, 2);
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
puts("-----------------------");
enqueue(&queue, 3);
enqueue(&queue, 4);
enqueue(&queue, 5);
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
puts("-----------------------");
enqueue(&queue, 6);
enqueue(&queue, 7);
enqueue(&queue, 8);
enqueue(&queue, 9);
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
printf("%d\n", dequeue(&queue));
puts("-----------------------");
return 0;
}
|
the_stack_data/79105.c | /*
* Copyright © 2011-2017 Inria. All rights reserved.
* See COPYING in top-level directory.
*/
#include <hwloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <assert.h>
int main(void)
{
hwloc_topology_t topology;
hwloc_obj_t obj;
hwloc_obj_t objs[32];
hwloc_uint64_t values[32*32];
int depth;
hwloc_obj_type_t type;
unsigned width;
unsigned i, j;
int err;
/* intensive testing of two grouping cases (2+1 and 2+2+1) */
/* group 3 numa nodes as 1 group of 2 and 1 on the side */
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:3 pu:1");
hwloc_topology_load(topology);
/* 3 group at depth 1 */
depth = hwloc_get_type_depth(topology, HWLOC_OBJ_GROUP);
printf("depth %d\n", depth);
assert(depth == 1);
width = hwloc_get_nbobjs_by_depth(topology, 1);
assert(width == 3);
/* insert distances and groups */
for(i=0; i<3; i++)
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_PU, i);
values[0] = 1; values[1] = 4; values[2] = 4;
values[3] = 4; values[4] = 1; values[5] = 2;
values[6] = 4; values[7] = 2; values[8] = 1;
err = hwloc_distances_add(topology, 3, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP);
assert(!err);
/* 1 groups at depth 1 and 2 */
depth = hwloc_get_type_depth(topology, HWLOC_OBJ_GROUP);
assert(depth == -2);
type = hwloc_get_depth_type(topology, 1);
assert(type == HWLOC_OBJ_GROUP);
width = hwloc_get_nbobjs_by_depth(topology, 1);
assert(width == 1);
type = hwloc_get_depth_type(topology, 2);
assert(type == HWLOC_OBJ_GROUP);
width = hwloc_get_nbobjs_by_depth(topology, 2);
assert(width == 3);
/* 3 nodes */
depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
assert(depth == HWLOC_TYPE_DEPTH_NUMANODE);
width = hwloc_get_nbobjs_by_depth(topology, depth);
assert(width == 3);
/* find the root obj */
obj = hwloc_get_root_obj(topology);
assert(obj->arity == 2);
/* check its children */
/* first child is a group with PU+NUMA children */
assert(obj->children[0]->type == HWLOC_OBJ_GROUP);
assert(obj->children[0]->depth == 2);
assert(obj->children[0]->arity == 1);
assert(obj->children[0]->first_child->type == HWLOC_OBJ_PU);
assert(obj->children[0]->memory_arity == 1);
assert(obj->children[0]->memory_first_child->type == HWLOC_OBJ_NUMANODE);
/* second child is a group with two group children */
assert(obj->children[1]->type == HWLOC_OBJ_GROUP);
assert(obj->children[1]->depth == 1);
assert(obj->children[1]->arity == 2);
assert(obj->children[1]->children[0]->type == HWLOC_OBJ_GROUP);
assert(obj->children[1]->children[1]->type == HWLOC_OBJ_GROUP);
assert(obj->children[1]->memory_arity == 0);
hwloc_topology_destroy(topology);
/* group 5 packages as 2 group of 2 and 1 on the side, all of them below a common node object */
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:1 pack:5 pu:1");
hwloc_topology_load(topology);
for(i=0; i<5; i++)
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_PACKAGE, i);
values[ 0] = 1; values[ 1] = 2; values[ 2] = 4; values[ 3] = 4; values[ 4] = 4;
values[ 5] = 2; values[ 6] = 1; values[ 7] = 4; values[ 8] = 4; values[ 9] = 4;
values[10] = 4; values[11] = 4; values[12] = 1; values[13] = 4; values[14] = 4;
values[15] = 4; values[16] = 4; values[17] = 4; values[18] = 1; values[19] = 2;
values[20] = 4; values[21] = 4; values[22] = 4; values[23] = 2; values[24] = 1;
err = hwloc_distances_add(topology, 5, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP);
assert(!err);
/* 1 node */
depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
assert(depth == HWLOC_TYPE_DEPTH_NUMANODE);
width = hwloc_get_nbobjs_by_depth(topology, depth);
assert(width == 1);
/* 2 groups at depth 1 */
depth = hwloc_get_type_depth(topology, HWLOC_OBJ_GROUP);
assert(depth == 1);
width = hwloc_get_nbobjs_by_depth(topology, depth);
assert(width == 2);
/* 5 packages at depth 2 */
depth = hwloc_get_type_depth(topology, HWLOC_OBJ_PACKAGE);
assert(depth == 2);
width = hwloc_get_nbobjs_by_depth(topology, depth);
assert(width == 5);
/* check root */
obj = hwloc_get_root_obj(topology);
assert(obj->arity == 3);
assert(obj->memory_arity == 1);
/* check root children */
assert(obj->children[0]->type == HWLOC_OBJ_GROUP);
assert(obj->children[0]->depth == 1);
assert(obj->children[0]->arity == 2);
assert(obj->children[1]->type == HWLOC_OBJ_PACKAGE);
assert(obj->children[1]->depth == 2);
assert(obj->children[1]->arity == 1);
assert(obj->children[2]->type == HWLOC_OBJ_GROUP);
assert(obj->children[2]->depth == 1);
assert(obj->children[2]->arity == 2);
obj = obj->memory_first_child;
assert(obj->type == HWLOC_OBJ_NUMANODE);
assert(obj->arity == 0);
assert(obj->memory_arity == 0);
hwloc_topology_destroy(topology);
/* testing of adding/replacing/removing distance matrices
and grouping with/without accuracy
*/
/* grouping matrix 4*2*2 */
for(i=0; i<16; i++) {
for(j=0; j<16; j++)
if (i==j)
values[i+16*j] = values[j+16*i] = 30;
else if (i/2==j/2)
values[i+16*j] = values[j+16*i] = 50;
else if (i/4==j/4)
values[i+16*j] = values[j+16*i] = 70;
else
values[i+16*j] = values[j+16*i] = 90;
}
/* default 2*8*1 */
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:2 core:8 pu:1");
hwloc_topology_load(topology);
depth = hwloc_topology_get_depth(topology);
assert(depth == 4);
width = hwloc_get_nbobjs_by_depth(topology, 0);
assert(width == 1);
width = hwloc_get_nbobjs_by_depth(topology, 1);
assert(width == 2);
width = hwloc_get_nbobjs_by_depth(topology, 2);
assert(width == 16);
width = hwloc_get_nbobjs_by_depth(topology, 3);
assert(width == 16);
width = hwloc_get_nbobjs_by_depth(topology, HWLOC_TYPE_DEPTH_NUMANODE);
assert(width == 2);
/* group 8cores as 2*2*2 */
for(i=0; i<16; i++)
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, i);
assert(!hwloc_distances_add(topology, 16, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP));
depth = hwloc_topology_get_depth(topology);
assert(depth == 6);
width = hwloc_get_nbobjs_by_depth(topology, 0);
assert(width == 1);
width = hwloc_get_nbobjs_by_depth(topology, 1);
assert(width == 2);
width = hwloc_get_nbobjs_by_depth(topology, 2);
assert(width == 4);
width = hwloc_get_nbobjs_by_depth(topology, 3);
assert(width == 8);
width = hwloc_get_nbobjs_by_depth(topology, 4);
assert(width == 16);
width = hwloc_get_nbobjs_by_depth(topology, HWLOC_TYPE_DEPTH_NUMANODE);
assert(width == 2);
hwloc_topology_destroy(topology);
/* play with accuracy */
values[0] = 29; /* diagonal, instead of 3 (0.0333% error) */
values[1] = 51; values[16] = 52; /* smallest group, instead of 5 (0.02% error) */
putenv("HWLOC_GROUPING_ACCURACY=0.1"); /* ok */
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:2 core:8 pu:1");
hwloc_topology_load(topology);
for(i=0; i<16; i++)
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, i);
assert(!hwloc_distances_add(topology, 16, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP|HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE));
depth = hwloc_topology_get_depth(topology);
assert(depth == 6);
hwloc_topology_destroy(topology);
putenv("HWLOC_GROUPING_ACCURACY=try"); /* ok */
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:2 core:8 pu:1");
hwloc_topology_load(topology);
for(i=0; i<16; i++)
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, i);
assert(!hwloc_distances_add(topology, 16, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP|HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE));
depth = hwloc_topology_get_depth(topology);
assert(depth == 6);
hwloc_topology_destroy(topology);
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:2 core:8 pu:1");
hwloc_topology_load(topology);
for(i=0; i<16; i++)
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, i);
assert(!hwloc_distances_add(topology, 16, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP /* no inaccurate flag, cannot group */));
depth = hwloc_topology_get_depth(topology);
assert(depth == 4);
hwloc_topology_destroy(topology);
putenv("HWLOC_GROUPING_ACCURACY=0.01"); /* too small, cannot group */
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:2 core:8 pu:1");
hwloc_topology_load(topology);
for(i=0; i<16; i++)
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, i);
assert(!hwloc_distances_add(topology, 16, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP|HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE));
depth = hwloc_topology_get_depth(topology);
assert(depth == 4);
hwloc_topology_destroy(topology);
putenv("HWLOC_GROUPING_ACCURACY=0"); /* full accuracy, cannot group */
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:2 core:8 pu:1");
hwloc_topology_load(topology);
for(i=0; i<16; i++)
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, i);
assert(!hwloc_distances_add(topology, 16, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP|HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE));
depth = hwloc_topology_get_depth(topology);
assert(depth == 4);
hwloc_topology_destroy(topology);
/* default 2*4*4 */
hwloc_topology_init(&topology);
hwloc_topology_set_synthetic(topology, "node:2 core:4 pu:4");
hwloc_topology_load(topology);
depth = hwloc_topology_get_depth(topology);
assert(depth == 4);
width = hwloc_get_nbobjs_by_depth(topology, 0);
assert(width == 1);
width = hwloc_get_nbobjs_by_depth(topology, 1);
assert(width == 2);
width = hwloc_get_nbobjs_by_depth(topology, 2);
assert(width == 8);
width = hwloc_get_nbobjs_by_depth(topology, 3);
assert(width == 32);
width = hwloc_get_nbobjs_by_depth(topology, HWLOC_TYPE_DEPTH_NUMANODE);
assert(width == 2);
/* apply useless core distances */
for(i=0; i<8; i++) {
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, i);
for(j=0; j<8; j++)
if (i==j)
values[i+8*j] = values[j+8*i] = 1;
else if (i/4==j/4)
values[i+8*j] = values[j+8*i] = 4;
else
values[i+8*j] = values[j+8*i] = 8;
}
assert(!hwloc_distances_add(topology, 8, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP));
depth = hwloc_topology_get_depth(topology);
assert(depth == 4);
/* group 4cores as 2*2 */
for(i=0; i<8; i++) {
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_CORE, i);
for(j=0; j<8; j++)
if (i==j)
values[i+8*j] = values[j+8*i] = 1;
else if (i/2==j/2)
values[i+8*j] = values[j+8*i] = 4;
else
values[i+8*j] = values[j+8*i] = 8;
}
assert(!hwloc_distances_add(topology, 8, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP));
depth = hwloc_topology_get_depth(topology);
assert(depth == 5);
width = hwloc_get_nbobjs_by_depth(topology, 0);
assert(width == 1);
width = hwloc_get_nbobjs_by_depth(topology, 1);
assert(width == 2);
width = hwloc_get_nbobjs_by_depth(topology, 2);
assert(width == 4);
width = hwloc_get_nbobjs_by_depth(topology, 3);
assert(width == 8);
width = hwloc_get_nbobjs_by_depth(topology, 4);
assert(width == 32);
width = hwloc_get_nbobjs_by_depth(topology, HWLOC_TYPE_DEPTH_NUMANODE);
assert(width == 2);
/* group 4PUs as 2*2 */
for(i=0; i<32; i++) {
objs[i] = hwloc_get_obj_by_type(topology, HWLOC_OBJ_PU, i);
for(j=0; j<32; j++)
if (i==j)
values[i+32*j] = values[j+32*i] = 1;
else if (i/2==j/2)
values[i+32*j] = values[j+32*i] = 4;
else
values[i+32*j] = values[j+32*i] = 8;
}
assert(!hwloc_distances_add(topology, 32, objs, values,
HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
HWLOC_DISTANCES_ADD_FLAG_GROUP));
depth = hwloc_topology_get_depth(topology);
assert(depth == 6);
width = hwloc_get_nbobjs_by_depth(topology, 0);
assert(width == 1);
width = hwloc_get_nbobjs_by_depth(topology, 1);
assert(width == 2);
width = hwloc_get_nbobjs_by_depth(topology, 2);
assert(width == 4);
width = hwloc_get_nbobjs_by_depth(topology, 3);
assert(width == 8);
width = hwloc_get_nbobjs_by_depth(topology, 4);
assert(width == 16);
width = hwloc_get_nbobjs_by_depth(topology, 5);
assert(width == 32);
width = hwloc_get_nbobjs_by_depth(topology, HWLOC_TYPE_DEPTH_NUMANODE);
assert(width == 2);
hwloc_topology_destroy(topology);
return 0;
}
|
the_stack_data/154829259.c | // RUN: %clang_cc1 -verify -fopenmp -triple x86_64-unknown-unknown %s -ast-dump | FileCheck %s
// expected-no-diagnostics
#pragma omp begin declare variant match(device={arch(x86_64)})
void bar(void) {}
// CHECK: FunctionDecl {{.*}} bar[device={arch(x86_64)}] 'void (void)'
#pragma omp end declare variant
|
the_stack_data/243892377.c | /*
M3 -- Meka Robotics Real-Time Control System
Copyright (c) 2010 Meka Robotics
Author: [email protected] (Aaron Edsinger)
M3 is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
M3 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 M3. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_PWM
#include "pwm.h"
#include "setup.h"
int pwm_cmd_buf[NUM_PWM_CH];
int pwm_duty_buf[NUM_PWM_CH];
int pwm_cmd(int chid){return pwm_cmd_buf[chid];}
#if defined M3_HMB_H1R1 || defined M3_HEX2_S1R1 || defined HB2_H2R2_J2J3J4 || defined HB2_H2R2_J0J1 || \
defined HB2_H2R1_J0J1 || defined HB2_H2R1_J2J3J4 || defined HB2_0_2_H2R3_J0J1 || defined HB2_0_2_H2R3_J2J3J4
int pwm_enc_limit(int chid, int val)
{
#ifdef USE_ENCODER_MA3
int pwm_fwd=ec_cmd.command[chid].config&M3ACT_CONFIG_PWM_FWD_SIGN;
if (ma3_at_lower_bound(chid))
if ((val<0 && pwm_fwd) ||(val>0&&!pwm_fwd))
val=0;
if (ma3_at_upper_bound(chid))
if ((val>0 && pwm_fwd) ||(val<0&&!pwm_fwd))
val=0;
#endif
return val;
}
#endif
int pwm_deadband(int chid, int abs_val)
{
if (abs_val==0)
return 0;
if (ec_cmd.command[chid].pwm_db<0)
{
if (abs_val<ABS(ec_cmd.command[chid].pwm_db))
abs_val=0;
}
else
abs_val=abs_val+ec_cmd.command[chid].pwm_db;
return abs_val;
}
//In: 0<=PWM_MIN_DUTY<=val<=ec_cmd.command[chid].pwm_max<=PWM_MAX_DUTY
//Out: Inverted clamped version
int invert_and_clamp_pwm(int chid, int abs_val)
{
int pm=MAX(PWM_MIN_DUTY,MIN(PWM_MAX_DUTY,ec_cmd.command[chid].pwm_max));
return CLAMP(PWM_MAX_DUTY-abs_val,PWM_MAX_DUTY-pm, PWM_MAX_DUTY-PWM_MIN_DUTY);
}
int clamp_pwm(int chid, int abs_val)
{
int pm=MAX(PWM_MIN_DUTY,MIN(PWM_MAX_DUTY,ec_cmd.command[chid].pwm_max));
return CLAMP(abs_val,PWM_MIN_DUTY,pm);
}
//int tmp_val;//***********************************************************************************************************************************
void set_pwm(int chid, int val)
{
// if(chid==0) tmp_val=tmp_val*-1;//***********************************************************************************************************************************
// val=tmp_val;//***********************************************************************************************************************************
pwm_cmd_buf[chid]=SIGN(val)*CLAMP(ABS(val),0,ec_cmd.command[chid].pwm_max); //Send back commanded value before gets inverted, deadband, etc
#if defined HB2_H2R1_J0J1 || defined HB2_H2R1_J2J3J4
//Safety limits
/*int pwm_fwd=ec_cmd.command[chid].config&M3ACT_CONFIG_PWM_FWD_SIGN;
//ec_debug[chid]=ma3_at_lower_bound(chid);
if (ma3_at_lower_bound(chid))
if ((val<0 && pwm_fwd) ||(val>0&&!pwm_fwd))
val=0;
if (ma3_at_upper_bound(chid))
if ((val>0 && pwm_fwd) ||(val<0&&!pwm_fwd))
val=0;*/
int sign=SIGN(val);
val=pwm_enc_limit(chid,val);
val=pwm_deadband(chid, ABS(val));
//Invert signal
//pwm_cmd_buf[chid]=val;
/*if (val<0)
val-=ec_cmd.command[chid].pwm_db;
if (val>0)
val+= ec_cmd.command[chid].pwm_db;
int pm=MIN(PWM_MAX_DUTY,ABS(ec_cmd.command[chid].pwm_max));*/
pwm_duty_buf[chid]=invert_and_clamp_pwm(chid,val);
//CLAMP(PWM_MAX_DUTY-ABS(val), PWM_MAX_DUTY-pm, PWM_MAX_DUTY);
//pwm_duty_buf[chid]=CLAMP(ABS(val), PWM_MIN_DUTY,pm);
pwm_cmd_buf[chid]=sign*CLAMP(val,0,ec_cmd.command[chid].pwm_max);
#if defined HB2_H2R1_J0J1
if (chid==0)
{
if (sign<=0) SetPwmDir2; else ClrPwmDir2;
//if (val==0) ClrEnableAmpA; else SetEnableAmpA;
P1DC2 = pwm_duty_buf[chid];
}
if (chid==1)
{
if (sign<=0) SetPwmDir1; else ClrPwmDir1;
//if (val==0) ClrEnableAmpB; else SetEnableAmpB;
P1DC1 = pwm_duty_buf[chid];
}
#endif
#if defined HB2_H2R1_J2J3J4
if (chid==0)
{
if (sign<=0) SetPwmDir1; else ClrPwmDir1;
//if (val==0) ClrEnableAmpA; else SetEnableAmpA;
P1DC1 = pwm_duty_buf[chid];
}
if (chid==1)
{
if (sign<=0) SetPwmDir2; else ClrPwmDir2;
//if (val==0) ClrEnableAmpB; else SetEnableAmpB;
P1DC2 = pwm_duty_buf[chid];
}
if (chid==2)
{
if (sign<=0) SetPwmDir3; else ClrPwmDir3;
//if (val==0) ClrEnableAmpC; else SetEnableAmpC;
P1DC3 = pwm_duty_buf[chid];
}
#endif
#endif
#if defined HB2_H2R2_J0J1 || defined HB2_0_2_H2R3_J0J1
//J0: L6235 Brushless Amp ; J1: L6205 Brushed Amplifier
int sign=SIGN(val);
val= pwm_enc_limit(chid, val);
val=pwm_deadband(chid,ABS(val));
if (chid==0)
{
//Invert signal
pwm_duty_buf[chid]=clamp_pwm(chid,val);
if (sign<=0) SetPwmDirJ0; else ClrPwmDirJ0;
P1DC2 = pwm_duty_buf[chid];
}
if (chid==1)
{
if (sign<0) //Invert polarity for this direction
pwm_duty_buf[chid]=invert_and_clamp_pwm(chid,val);
else
pwm_duty_buf[chid]=clamp_pwm(chid,val);
if (sign<=0) SetPwmDirJ1; else ClrPwmDirJ1;
P1DC1 = pwm_duty_buf[chid];
}
pwm_cmd_buf[chid]=sign*CLAMP(val,0,ec_cmd.command[chid].pwm_max);
#endif
#if defined HB2_H2R2_J2J3J4 || defined HB2_0_2_H2R3_J2J3J4
//3CH L6205 Amplifier
int sign=SIGN(val);
val= pwm_enc_limit(chid, val);
val=pwm_deadband(chid,ABS(val));
if (sign<0) //Invert polarity for this direction
pwm_duty_buf[chid]=invert_and_clamp_pwm(chid,val);
else
pwm_duty_buf[chid]=clamp_pwm(chid,val);
if (chid==0)
{
if (sign<=0) SetPwmDirJ2; else ClrPwmDirJ2;
P1DC1 = pwm_duty_buf[chid];
}
if (chid==1)
{
if (sign<=0) SetPwmDirJ3; else ClrPwmDirJ3;
P1DC2 = pwm_duty_buf[chid];
}
if (chid==2)
{
if (sign<=0) SetPwmDirJ4; else ClrPwmDirJ4;
P1DC3 = pwm_duty_buf[chid];
}
pwm_cmd_buf[chid]=sign*CLAMP(val,0,ec_cmd.command[chid].pwm_max);
#endif
}
void setup_pwm(void) {
int i;
for (i=0;i<NUM_PWM_CH;i++)
{
pwm_cmd_buf[i]=0;
pwm_duty_buf[i]=0;
}
PTCONbits.PTEN = 0; // PWM disable
//Set time base
PTCON = 0;
PTCONbits.PTOPS=0; // PWM 1:1 postcale
PTCONbits.PTCKPS = 0; // PWM timebase input clock prescale 1:1 (Tcy)
PTPER = PWM_TIMEBASE_CYC; // set timebase period
PTCONbits.PTMOD = 0; //Free-Running Mode
PTMR = 0; //Reset counter
PWMCON1 = 0; // reset condition specified in CONFIG BITS FPOR
#if defined HB2_H2R1_J0J1 || defined HB2_H2R2_J0J1 || defined HB2_0_2_H2R3_J0J1
PWMCON1bits.PMOD2=1; //PWM1H2,PWM1L2 is independent pair
PWMCON1bits.PEN2H = 1; //Enable PWM1H2 (RP12)
PWMCON1bits.PMOD1=1; //PWM1H1,PWM1L1 is independent pair
PWMCON1bits.PEN1H = 1; //Enable PWM1H1 (RP14)
PDC1 = 0; // default PWM period
PDC2 = 0; // default PWM period
//Synchronize ADC to PWM
PWMCON2 = 0;
PWMCON2bits.SEVOPS = 0; // Special event 1:1 post scale
P1SECMPbits.SEVTCMP = PWM_ADC_SYNC_TICKS; //ADC trigger - specifiy the phase realtive to PWM
#endif
#if defined HB2_H2R1_J2J3J4 || defined HB2_H2R2_J2J3J4 || defined HB2_0_2_H2R3_J2J3J4
PWMCON1bits.PMOD1=1; //PWM1H1,PWM1L1 is independent pair
PWMCON1bits.PEN1H = 1; //Enable PWM1H1
PWMCON1bits.PMOD2=1; //PWM1H2,PWM1L2 is independent pair
PWMCON1bits.PEN2H = 1; //Enable PWM1H2
PWMCON1bits.PMOD3=1; //PWM1H3,PWM1L3 is independent pair
PWMCON1bits.PEN3H = 1; //Enable PWM1H3
PDC1 = 0; // default PWM period
PDC2 = 0; // default PWM period
PDC3 = 0; // default PWM period
//Synchronize ADC to PWM
PWMCON2 = 0;
PWMCON2bits.SEVOPS = 0; // Special event 1:1 post scale
P1SECMPbits.SEVTCMP = PWM_ADC_SYNC_TICKS; //ADC trigger - specifiy the phase realtive to PWM
#endif
//Disable faults
FLTACON = 0;
_PWM1IF=0;
PTCONbits.PTEN = 1; // PWM enable
}
#endif
|
the_stack_data/148136.c | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int data = 12345;
int main() {
char s[] = "abc"; // {'a', 'b', 'c', 'd', '\n'}
char t[3] = "def";
char *p = malloc(6*sizeof(char));
strcpy(p, "strcpy");
// *p = "def"; error
printf("s: %s \n", s);
printf("t: %s \n", t);
printf("p: %s \n", p);
}
|
the_stack_data/40487.c | #include <stdio.h>
//function main begins program execution
int main(void)
{
//declaring variables
char peakTime;
int timePeriod, noOfTimes;
float additional, totalAmount, charges;
//taking time period of the advertisement as the user input
printf("Time period ( in seconds ): ");
scanf("%d", &timePeriod);
//taking the number of times the advertisement broadcasted as the user input
printf("Number of Times: ");
scanf("%d", &noOfTimes);
//asking if the advertisement broadcasted during the peal time or not
printf("Peak Time ( Y / N ): ");
scanf("%*c%c", &peakTime);
//deciding and calculating the total amount to be paid
if( timePeriod < 45 )
{
charges = (float)7500 * noOfTimes;
}
else if( 45 <= timePeriod <= 60 )
{
charges = (float)12000 * noOfTimes;
}
else
{
charges = (float)25000 * noOfTimes;
}
if( peakTime == 'Y' || peakTime == 'y' )
{
additional = charges * 0.2;
}
else
{
additional = 0;
}
totalAmount = charges + additional;
//displaying the total amount to be paid
printf("Total amount to be paid: %.2f", totalAmount);
return 0;
} //end function main
|
the_stack_data/9513233.c | #include <stdio.h>
static struct sss{
float f;
char a[10];
} sss;
#define _offsetof(st,f) ((char *)&((st *) 16)->f - (char *) 16)
int main (void) {
printf ("++++Array of char in struct starting with float:\n");
printf ("size=%d,align=%d\n",
sizeof (sss), __alignof__ (sss));
printf ("offset-float=%d,offset-arrayof-char=%d,\nalign-float=%d,align-arrayof-char=%d\n",
_offsetof (struct sss, f), _offsetof (struct sss, a),
__alignof__ (sss.f), __alignof__ (sss.a));
printf ("offset-char-a[5]=%d,align-char-a[5]=%d\n",
_offsetof (struct sss, a[5]),
__alignof__ (sss.a[5]));
return 0;
}
|
the_stack_data/87687.c | /* Copyright (c) 2017 Dennis Wölfing
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* libc/src/unistd/getcwd.c
* Gets the current working directory.
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
char* getcwd(char* buffer, size_t size) {
if (buffer && size == 0) {
errno = EINVAL;
return NULL;
}
char* result = canonicalize_file_name(".");
if (!result) return NULL;
if (!buffer) {
// As an extension we allocate the buffer for the caller.
return result;
}
if (strlcpy(buffer, result, size) >= size) {
free(result);
errno = ERANGE;
return NULL;
}
free(result);
return buffer;
}
|
the_stack_data/187644228.c | #include <stdio.h>
/**
* \n 表示换行
*
*/
int main() {
printf("Hello World!");
return 0;
}
|
the_stack_data/66049.c | #include <stdio.h>
// calls function to cleanup when variable goes out of scope
#define CLEAN(f) __attribute__((__cleanup__(f)))
void
fint(int *x)
{
printf("%s(%d)\n", __func__, *x);
}
void
fflt(float *x)
{
printf("%s(%f)\n", __func__, *x);
}
void
test(void)
{
int a CLEAN(fint);
float b CLEAN(fflt);
a = 1;
b = 2;
{
int c CLEAN(fint);
float d CLEAN(fflt);
c = 3;
d = 4;
{
int x CLEAN(fint), y CLEAN(fint);
x = 5;
y = 6;
}
}
}
int
main(void)
{
test();
return 0;
}
|
the_stack_data/168893149.c | #include <stdio.h>
#include <math.h>
int main()
{
float num[10010], media = 0, desvio = 0; int divi = 0, notaMaior = 0, repeat;
while (scanf("%f", &num[divi]) && num[divi] != -1)
{
media += num[divi];
divi ++;
}
//num[divi] = 0;
media /= (float) (divi);
for (repeat = 0; repeat < divi; repeat ++)
{
if (num[repeat] > media)
{
notaMaior ++;
}
}
for (repeat = 0; repeat < divi; repeat ++)
{
if (media >= num[repeat])
{
desvio += (float) (pow((media - num[repeat]), 2));
}
else
{
desvio += (float) (pow((num[repeat] - media), 2));
}
}
desvio /= (float) divi - 1;
desvio = sqrt(desvio);
printf("%.2f\n%.2f\n%d\n", media, desvio, notaMaior);
return(0);
}
|
the_stack_data/141487.c | #ifdef STM32F2xx
#include "stm32f2xx_ll_rng.c"
#endif
#ifdef STM32F4xx
#include "stm32f4xx_ll_rng.c"
#endif
#ifdef STM32F7xx
#include "stm32f7xx_ll_rng.c"
#endif
#ifdef STM32H7xx
#include "stm32h7xx_ll_rng.c"
#endif
#ifdef STM32L0xx
#include "stm32l0xx_ll_rng.c"
#endif
#ifdef STM32L4xx
#include "stm32l4xx_ll_rng.c"
#endif
|
the_stack_data/49136.c | /* Copyright (C) 2001-2021 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
implied.
This software is distributed under license and may not be copied,
modified or distributed except as expressly authorized under the terms
of the license contained in the file LICENSE in this distribution.
Refer to licensing information at http://www.artifex.com or contact
Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
CA 94945, U.S.A., +1(415)492-9861, for further information.
*/
/*
* Microsoft Windows platform support for Graphics Library
*
* This file implements functions that differ between the graphics
* library and the interpreter.
*/
/* ------ Process message loop ------ */
/*
* Check messages and interrupts; return true if interrupted.
* This is called frequently - it must be quick!
*/
#ifdef CHECK_INTERRUPTS
#include "gx.h"
int
gp_check_interrupts(const gs_memory_t *mem)
{
return 0;
}
#endif
|
the_stack_data/22012276.c | /*
* scalar less than or equal to vector
*/
void dsle(int n, double *ap, double *x, int incx, int *y, int incy)
{
register double alpha = *ap;
while( n-- ) {
*y = alpha <= (*x);
x += incx;
y += incy;
}
return;
}
|
the_stack_data/15761654.c | /*
argopt: Parse options and arguments from argument list given to a command.
Usage: argopt optstring argument_list
argopt uses the C function getopt(3C) to parse options in "optstring" from
the list of options and arguments in "argument_list". All rules of
parsing that apply to getopt apply to argopt. One letter options are listed
in "optstring". If the option letter is followed by a colon, the option is
expected to have an argument that may or may not be separated from it by white
space. "argument_list" is a list of zero or more blank-separated words. It
contains the option letters (preceded by "-"), the option-arguments and
operands. For the list of options specified in "optstring", argopt will write
a blank separated list of words to standard output. Each word is a one-to-one
match with an option letter in "optstring" and describes whether or not the
option letter was selected in "argument_list". argopt writes a "0" if the
option letter was not selected, a "1" if it was selected and does not require
an option-argument or the value of the option-argument if the option letter
was selected and the argument was provided. The remaining list of operands
in "argument_list" (i.e., anything getopt identifies as not being an option)
will be appended as blank separated words to the end of the option list on
standard output.
The following example shows how a script would use argopt to parse the
passed in argument list for 3 options and 2 operands. The option letters
are a, b and o, where option "o" requires an option-argument. (Note that
this is an example in a csh script.)
set argv = `argopt abo: $*`
if ( $status || $#argv != 5 ) then
echo 'usage: myscript [ -a ] [ -b ] [ -o o_value ] arg1 arg2'
exit 1
endif
set a_flag = $1
shift
set b_flag = $1
shift
set o_flag = $1
if ( $o_flag == 0 ) set o_value = $default_value
if ( $o_flag != 0 ) set o_value = $o_flag
shift
set arg1 = $1
set arg2 = $2
Return codes and actions:
0 - Successful.
1 - Improper option letter or option-argument. List written to standard
output will be incomplete.
Version: 1.2
Modification log:
DJL 940620 - Removed break from while loop if option found. getopt must
read through all options to clear input buffer for next pass
through loop.
DJL 940703 - Only returns on/off flag or value/off flag once if option
specified more than once in argument list.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h> /* for getopt */
int main(int argc, char *argv[]);
int main(int argc, char *argv[]) {
int c;
int opstr_len;
int i;
int status;
char *opstring;
extern char *optarg;
extern int optind;
extern int opterr;
/* start at 2nd argumet for parsing - 1st use as optstring */
opstring=argv[1];
opstr_len=strlen(opstring);
for ( i=0 ; i <= opstr_len-1 ; i ++) {
if ( *(opstring+i) != ':' ) {
optind=2;
status=0;
while ((c = getopt(argc, argv, opstring)) != -1) {
if ( status == 0 ) {
if ( c == '?' ) {
status=-1;
break;
}
if ( *(opstring+i) == c ) {
if ( *(opstring+i+1) == ':' ) {
printf("%s ",optarg);
status=1;
} else {
printf("%c ",'1');
status=1;
}
}
}
}
if ( status == -1 ) break;
if ( status == 0 ) printf("%c ",'0');
}
}
/* Turn off getopt error message */
opterr=0;
/* Positon "optind" to start of arguments and echo arguments */
if ( status != -1 ) {
optind=2;
while ((c = getopt(argc, argv, opstring)) != -1);
for ( ; optind < argc; optind++) {
printf("%s ",argv[optind]);
}
printf("\n");
return (0);
} else {
printf("\n");
return (1);
}
}
|
the_stack_data/190767911.c | #include <stdio.h>
int i = 0;
int main() {
printf("%d", i);
int i = 1;
printf("%d", i);
for (int i = 0; i < 5; i++) {
printf("%d", i);
}
return 0;
} |
the_stack_data/668742.c | // Illustrates problem with negating a constant negative number
// KickAsm requires parenthesis for double negation to work
signed char * const SCREEN = (signed char*)0x0400;
void main() {
printneg(-4);
}
void printneg(signed char c) {
c = -c;
SCREEN[0] = c;
} |
the_stack_data/761737.c | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define BUFFSIZE 255
void main (int argc, char* argv[])
{
FILE *fp;
char str[BUFFSIZE];
if (symlink("file2.txt","file1.txt") != 0) {
perror("symlink() error");
unlink("file2.txt");
exit(1);
}
else
{
fp = fopen ("file1.txt","w");
if (fp == NULL) {
perror ("An error occurred in creating the file\n");
exit(1);
}
printf("Enter content for the file\n");
gets(str);
while(strcmp(str, "stop") !=0){
fputs(str,fp);
gets(str);
}
}
fclose(fp);
}
|
the_stack_data/175144075.c | /* Copyright (C) 2001 Free Software Foundation, Inc. */
/* { dg-do run } */
/* { dg-options "-Wno-multichar -fsigned-char" } */
/* This tests how overly-long multichar charconsts are truncated, and
whether "short" multichar charconsts are incorrectly sign extended
(regardless of char signedness). Preprocessor is used so that we
have only one place where the too long warning is generated, so
that the test works for all targets.
Neil Booth, 8 May 2002. */
#include <limits.h>
extern void abort (void);
#if INT_MAX == 32767
# define LONG_CHARCONST '!\234a'
# define SHORT_CHARCONST '\234a'
# define POS_CHARCONST '\1'
#elif INT_MAX == 2147483647
# define LONG_CHARCONST '!\234abc'
# define SHORT_CHARCONST '\234abc'
# define POS_CHARCONST '\234a'
#elif INT_MAX == 9223372036854775807
# define LONG_CHARCONST '!\234abcdefg'
# define SHORT_CHARCONST '\234abcdefg'
# define POS_CHARCONST '\234a'
#else
/* Target int size not handled, do something that won't fail. */
# define LONG_CHARCONST '\234a'
# define SHORT_CHARCONST '\234a'
# define POS_CHARCONST '\1'
#endif
#if POS_CHARCONST < 0
# error Charconst incorrectly sign-extended
#endif
#if LONG_CHARCONST != SHORT_CHARCONST /* { dg-warning "too long" "" } */
# error Overly long charconst truncates wrongly for preprocessor
#endif
int main ()
{
if (POS_CHARCONST < 0)
abort ();
if (LONG_CHARCONST != SHORT_CHARCONST) /* { dg-warning "too long" "" } */
abort ();
return 0;
}
|
the_stack_data/237644072.c | // Working of assignment operators
#include <stdio.h>
int main()
{
int grade, new_grade;
printf("Enter grade:");
scanf("%d", &grade);
new_grade = grade;
printf("New grade = %d\n", new_grade);
new_grade += grade;
printf("New grade plus grade \n");
printf("New grade = %d \n", new_grade);
new_grade -= grade;
printf("New grade minus grade \n");
printf("New grade = %d \n", new_grade);
new_grade *= grade;
printf("New grade multiplied by grade \n");
printf("New grade = %d \n", new_grade);
new_grade /= grade;
printf("New grade divided by grade \n");
printf("New grade = %d \n", new_grade);
new_grade %= grade;
printf("New grade mod grade \n");
printf("New grade = %d \n", new_grade);
return 0;
}
|
the_stack_data/521565.c |
#include<stdio.h>
int m=1;
void print_mat(int mat[2][2]){
int i,j;
printf("\n Matrix:%d\n",m);
for(i=0;i<2;i++){
for(j=0;j<2;j++){
printf("%2d ",mat[i][j]);
}
printf("\n");
}
}
void sparsemat2tripletf(int sparseMatrix[][2], int row, int col){
int size = 0;
for (int i = 0; i < row; i++)
for (int j = 0; j < col; j++)
if (sparseMatrix[i][j] != 0)
size++;
// number of columns in compactMatrix (size) must be
// equal to number of non - zero elements in
// sparseMatrix
int compactMatrix[3][size+1];
compactMatrix[0][0] = row;
compactMatrix[1][0] = col;
compactMatrix[2][0] = size;
// Making of new matrix
int k = 1;
for (int i = 0; i < row; i++)
for (int j = 0; j < col; j++)
if (sparseMatrix[i][j] != 0)
{
compactMatrix[0][k] = i;
compactMatrix[1][k] = j;
compactMatrix[2][k] = sparseMatrix[i][j];
k++;
}
printf("\n Triplet Matrix:%d\n",m);
for (int i=0; i<3; i++)
{
for (int j=0; j<=size; j++)
printf("%2d ", compactMatrix[i][j]);
printf("\n");
}
}
int main(){
int a[2][2]={{1,2},
{3,4}};
int b[2][2]={{1,2},
{3,4}};
int c[2][2]={0}, i, j, k;
for(i=0;i<2;i++){
for(j=0;j<2;j++){
c[i][j]=0;
for(k=0;k<2;k++)
c[i][j] = c[i][j] + (a[i][k]*b[k][j]);
}
}
printf("\nThe Result:\n");
print_mat(a);
sparsemat2tripletf(a,2,2);
m = m + 1;
print_mat(b);
sparsemat2tripletf(b,2,2);
m = m + 1;
print_mat(c);
sparsemat2tripletf(c,2,2);
return 0;
} |
the_stack_data/247016887.c | int number = 123; |
the_stack_data/697348.c | #include <stdio.h>
#include <stdlib.h>
void main() {
int count = 0;
int max = 10;
for (count; count <= max; count++) {
printf("%d\n", count);
}
system("Pause");
} |
the_stack_data/198443.c | //----------------------------------------------------------------------------
// The confidential and proprietary information contained in this file may
// only be used by a person authorised under and to the extent permitted
// by a subsisting licensing agreement from ARM Limited or its affiliates.
//
// (C) COPYRIGHT 2016 ARM Limited or its affiliates.
// ALL RIGHTS RESERVED
//
// This entire notice must be reproduced on all copies of this file
// and copies of this file may only be made by a person if such person is
// permitted to do so under the terms of a subsisting license agreement
// from ARM Limited or its affiliates.
//----------------------------------------------------------------------------
#ifdef MBED_CLOUD_CLIENT_USER_CONFIG_FILE
#include MBED_CLOUD_CLIENT_USER_CONFIG_FILE
#endif
#include <stdint.h>
#ifdef MBED_CLOUD_CLIENT_UPDATE_ID
const uint8_t arm_uc_vendor_id[16] = { 0 };
const uint16_t arm_uc_vendor_id_size = sizeof(arm_uc_vendor_id);
const uint8_t arm_uc_class_id[16] = { 0 };
const uint16_t arm_uc_class_id_size = sizeof(arm_uc_class_id);
const uint8_t arm_uc_device_id[16] = { 0 };
const uint16_t arm_uc_device_id_size = sizeof(arm_uc_device_id);
#endif
#ifdef MBED_CLOUD_CLIENT_UPDATE_CERT
const uint8_t arm_uc_default_fingerprint[32] = { 0 };
const uint16_t arm_uc_default_fingerprint_size =
sizeof(arm_uc_default_fingerprint);
const uint8_t arm_uc_default_certificate[1] = { 0 };
const uint16_t arm_uc_default_certificate_size = sizeof(arm_uc_default_certificate);
#endif
|
the_stack_data/215767505.c | /*
* Program that computer interest rate over
* specified number of years.
*/
#include <stdio.h>
#define NUM_ELEMENTS(x) ((int) (sizeof(x) / sizeof((x)[0])))
#define INIT_BALANCE 50000.00
int main(void)
{
double value[5];
int low_rate, num_years, year, month, i;
printf("Enter interest rate: %%");
(void)scanf("%d", &low_rate);
printf("Enter number of years: ");
(void)scanf("%d", &num_years);
printf("\nYears");
for (i = 0; i < NUM_ELEMENTS(value); i++) {
value[i] = INIT_BALANCE;
printf("%10d%%", low_rate + i);
}
for (year = 1; year <= num_years; year++) {
printf("\n%3d%4s", year, "");
for (i = 0; i < NUM_ELEMENTS(value); i++) {
for (month = 1; month <= 12; ++month)
value[i] += (low_rate + i) / 1200.00 * value[i];
printf("%11.2lf", value[i]);
}
}
printf("\n");
return 0;
}
|
the_stack_data/100139643.c | #include<stdio.h>
#include<stdlib.h>
int main(int argc, char* argv[]){
if (argc < 2) return 1;
int n,i=1,sum=0;
// printf("Enter a number: ");
// scanf("%d",&n);
n = atoi(argv[1]);
while(i<n){
if(n%i==0)
sum=sum+i;
i++;
}
if(sum==n)
printf("%d is a perfect number\n",i);
else
printf("%d is not a perfect number\n",i);
return 0;
}
|
the_stack_data/176706404.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_comb.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kaye <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/08/03 18:47:40 by kaye #+# #+# */
/* Updated: 2020/08/06 14:08:35 by kaye ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
void ft_print_comb(void)
{
char i;
char j;
char k;
i = '0';
while (i <= '7')
{
j = i + 1;
while (j <= '8')
{
k = j + 1;
while (k <= '9')
{
ft_putchar(i);
ft_putchar(j);
ft_putchar(k);
if (i != '7')
write(1, ", ", 2);
k++;
}
j++;
}
i++;
}
}
|
the_stack_data/248579801.c | //
// main.c
// LinearList
//
// Created by 张鹏 on 2018/7/24.
// Copyright © 2018 DancewithPeng. All rights reserved.
//
#include <stdio.h>
int main(int argc, const char * argv[]) {
// insert code here...
printf("Hello, World!\n");
return 0;
}
|
the_stack_data/14200998.c | /*
* memcpy(): copy memory.
*/
#include <string.h>
void *
memcpy(void *t1, const void *t2, size_t n)
{
char *s1 = t1;
const char *s2 = t2;
/*
* finish up with byte moves.
*/
while (n--)
*s1++ = *s2++;
return t1;
}
void *
__memcpy(void *t1, const void *t2, size_t n)
{
return memcpy(t1, t2, n);
}
|
the_stack_data/1064638.c | extern float __VERIFIER_nondet_float(void);
extern int __VERIFIER_nondet_int(void);
typedef enum {false, true} bool;
bool __VERIFIER_nondet_bool(void) {
return __VERIFIER_nondet_int() != 0;
}
int main()
{
bool _EL_U_57, _x__EL_U_57;
float r, _x_r;
bool _EL_U_59, _x__EL_U_59;
float i, _x_i;
bool _J100, _x__J100;
bool _J94, _x__J94;
bool _J87, _x__J87;
bool _J81, _x__J81;
bool _EL_U_53, _x__EL_U_53;
float m_x_i, _x_m_x_i;
bool _EL_U_55, _x__EL_U_55;
int __steps_to_fair = __VERIFIER_nondet_int();
_EL_U_57 = __VERIFIER_nondet_bool();
r = __VERIFIER_nondet_float();
_EL_U_59 = __VERIFIER_nondet_bool();
i = __VERIFIER_nondet_float();
_J100 = __VERIFIER_nondet_bool();
_J94 = __VERIFIER_nondet_bool();
_J87 = __VERIFIER_nondet_bool();
_J81 = __VERIFIER_nondet_bool();
_EL_U_53 = __VERIFIER_nondet_bool();
m_x_i = __VERIFIER_nondet_float();
_EL_U_55 = __VERIFIER_nondet_bool();
bool __ok = (((0.0 <= i) && (( !(r <= 0.0)) && ( !(10.0 <= r)))) && ((((( !((_EL_U_59 || ( !(( !(r <= i)) || _EL_U_57))) || (_EL_U_55 || ( !(( !(m_x_i <= i)) || _EL_U_53))))) && ( !_J81)) && ( !_J87)) && ( !_J94)) && ( !_J100)));
while (__steps_to_fair >= 0 && __ok) {
if ((((_J81 && _J87) && _J94) && _J100)) {
__steps_to_fair = __VERIFIER_nondet_int();
} else {
__steps_to_fair--;
}
_x__EL_U_57 = __VERIFIER_nondet_bool();
_x_r = __VERIFIER_nondet_float();
_x__EL_U_59 = __VERIFIER_nondet_bool();
_x_i = __VERIFIER_nondet_float();
_x__J100 = __VERIFIER_nondet_bool();
_x__J94 = __VERIFIER_nondet_bool();
_x__J87 = __VERIFIER_nondet_bool();
_x__J81 = __VERIFIER_nondet_bool();
_x__EL_U_53 = __VERIFIER_nondet_bool();
_x_m_x_i = __VERIFIER_nondet_float();
_x__EL_U_55 = __VERIFIER_nondet_bool();
__ok = (((((r == _x_r) && ((10.0 <= i) || (((i + (-1.0 * _x_i)) == -1.0) || (i == _x_i)))) && (( !(10.0 <= i)) || (_x_i == 0.0))) && (m_x_i == _x_i)) && ((((((_EL_U_55 == (_x__EL_U_55 || ( !(_x__EL_U_53 || ( !(_x_m_x_i <= _x_i)))))) && ((_EL_U_53 == (_x__EL_U_53 || ( !(_x_m_x_i <= _x_i)))) && ((_EL_U_57 == (_x__EL_U_57 || ( !(_x_r <= _x_i)))) && (_EL_U_59 == (_x__EL_U_59 || ( !(_x__EL_U_57 || ( !(_x_r <= _x_i))))))))) && (_x__J81 == (( !(((_J81 && _J87) && _J94) && _J100)) && ((((_J81 && _J87) && _J94) && _J100) || ((( !(r <= i)) || ( !(( !(r <= i)) || _EL_U_57))) || _J81))))) && (_x__J87 == (( !(((_J81 && _J87) && _J94) && _J100)) && ((((_J81 && _J87) && _J94) && _J100) || ((( !(( !(r <= i)) || _EL_U_57)) || ( !(_EL_U_59 || ( !(( !(r <= i)) || _EL_U_57))))) || _J87))))) && (_x__J94 == (( !(((_J81 && _J87) && _J94) && _J100)) && ((((_J81 && _J87) && _J94) && _J100) || ((( !(m_x_i <= i)) || ( !(( !(m_x_i <= i)) || _EL_U_53))) || _J94))))) && (_x__J100 == (( !(((_J81 && _J87) && _J94) && _J100)) && ((((_J81 && _J87) && _J94) && _J100) || ((( !(( !(m_x_i <= i)) || _EL_U_53)) || ( !(_EL_U_55 || ( !(( !(m_x_i <= i)) || _EL_U_53))))) || _J100))))));
_EL_U_57 = _x__EL_U_57;
r = _x_r;
_EL_U_59 = _x__EL_U_59;
i = _x_i;
_J100 = _x__J100;
_J94 = _x__J94;
_J87 = _x__J87;
_J81 = _x__J81;
_EL_U_53 = _x__EL_U_53;
m_x_i = _x_m_x_i;
_EL_U_55 = _x__EL_U_55;
}
}
|
the_stack_data/26699477.c | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
typedef struct _ {
int* f;
int* g;
} S;
void main() {
S x;
int** p;
int y;
/* safe */
x.f = &y;
p = &x.f;
p++;
}
|
the_stack_data/176704957.c | #include <stdio.h>
#define MAX_SIZE 10
#define LEN 100
int main()
{
int arr[MAX_SIZE];
int i, n, e=0;
char str[LEN];
char name[LEN] = {"Sum of even elements of array = %d"};
FILE *file_in;
FILE *file_out;
file_in = fopen("in_0.txt", "r");
file_out = fopen("out_0.txt", "a");
printf("Enter size of the array: ");
scanf("%d", &n);
if(n<11)
{
printf("Enter %d elements in the array: ", n);
for(i=0; i<n; i++)
{
scanf("%d", &arr[i]);
}
for(i=0; i<n; i++)
{
if(arr[i]%2==0)
e=e+arr[i];
}
if(file_in != NULL && file_out != NULL)
{
while(fgets(str, LEN, file_in))
fprintf(stdout, "%s", str);
fputs(name, file_out);
printf("Sum of even elements of array = %d", e);
return 0;
}
else
{
fprintf(stderr, "Cannot be open any .txt file\n");
return 1;
}
}
else
puts("Not right size of array");
} |
the_stack_data/135152.c | #include<stdio.h>
#include<stdlib.h>
#include<X11/X.h>
#include<X11/Xlib.h>
#include<GL/gl.h>
#include<GL/glx.h>
#include<GL/glu.h>
Display *dpy;
Window root;
GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
XVisualInfo *vi;
Colormap cmap;
XSetWindowAttributes swa;
Window win;
GLXContext glc;
XWindowAttributes gwa;
XEvent xev;
void DrawAQuad() {
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1., 1., -1., 1., 1., 20.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0., 0., 10., 0., 0., 0., 0., 1., 0.);
glBegin(GL_QUADS);
glColor3f(1., 0., 0.); glVertex3f(-.75, -.75, 0.);
glColor3f(0., 1., 0.); glVertex3f( .75, -.75, 0.);
glColor3f(0., 0., 1.); glVertex3f( .75, .75, 0.);
glColor3f(1., 1., 0.); glVertex3f(-.75, .75, 0.);
glEnd(); }
int main(int argc, char *argv[])
{
dpy = XOpenDisplay(NULL);
if(dpy == NULL) {
printf("\n\tcannot connect to X server\n\n");
exit(0); }
root = DefaultRootWindow(dpy);
vi = glXChooseVisual(dpy, 0, att);
if(vi == NULL) {
printf("\n\tno appropriate visual found\n\n");
exit(0); }
else {
printf("\n\tvisual %p selected\n", (void *)vi->visualid); }/* %p creates hexadecimal output like in glxinfo */
cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
swa.colormap = cmap;
swa.event_mask = ExposureMask | KeyPressMask;
win = XCreateWindow(dpy, root, 0, 0, 600, 600, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa);
XMapWindow(dpy, win);
XStoreName(dpy, win, "OpenGL");
glc = glXCreateContext(dpy, vi, NULL, GL_TRUE);
glXMakeCurrent(dpy, win, glc);
glEnable(GL_DEPTH_TEST);
while(1) {
XNextEvent(dpy, &xev);
if(xev.type == Expose) {
XGetWindowAttributes(dpy, win, &gwa);
glViewport(0, 0, gwa.width, gwa.height);
DrawAQuad();
glXSwapBuffers(dpy, win);
}
else if(xev.type == KeyPress) {
glXMakeCurrent(dpy, None, NULL);
glXDestroyContext(dpy, glc);
XDestroyWindow(dpy, win);
XCloseDisplay(dpy);
exit(0); }
} /* this closes while(1) { */
} /* this is the } which closes int main(int argc, char *argv[]) { */
|
the_stack_data/112614.c | #include <assert.h>
int foo(int a, int b)
{
assert(a == 3);
assert(b == 5);
return 9;
}
int main()
{
int (*x)(int, int) = foo;
assert(x(3, 5) == 9);
return 0;
}
|
the_stack_data/103266670.c | // See how C array declarations are exploited by semantics...
int trust01(int n)
{
float a[n];
// Trusting the following declarations makes the function inexecutable...
// float b[0]; if array declarations are trusted in C as in Fortran
// Not possible: float c[-1];
int i = n;
{
int m;
float b[m];
i = i + 1;
}
return i;
}
|
the_stack_data/12637991.c | #include <stdio.h>
main()
{
printf("File :%s\n", __FILE__ );
printf("Date :%s\n", __DATE__ );
printf("Time :%s\n", __TIME__ );
printf("Line :%d\n", __LINE__ );
printf("ANSI :%d\n", __STDC__ );
} |
the_stack_data/200143185.c | int getwinsize(int fd,int *row,int *col){
return -1;
}
int setwinsize(int fd,int row,int col){
return -1;
}
|
the_stack_data/198580260.c | struct Input {
unsigned a;
unsigned b;
};
struct Output {
unsigned x;
};
void outsource(struct Input *input, struct Output *output)
{
output->x = (!!input->a) == (!!input->b);
}
|
the_stack_data/625715.c | /*Exercise 3 - Repetition
Write a C program to calculate the sum of the numbers from 1 to n.
Where n is a keyboard input.
e.g.
n -> 100
sum = 1+2+3+....+ 99+100 = 5050
n -> 1-
sum = 1+2+3+...+10 = 55 */
//Ex3
#include <stdio.h>
int main() {
int num , count=1;
int sum = 0;
printf("Enter Number : ");
scanf("%d",&num);
while(count<= num)
{
sum = sum + count;
count++;
}
printf("Sum is : %d",sum);
return 0;
}
|
the_stack_data/151706660.c | #include<stdio.h>
void main() {
// count & k are variables are taken for counting purpose
int process, resource, i, j, instanc, k=0, count1=0, count2=0;
printf("Enter no. of processes: ");
scanf("%d", &process);
printf("Enter no. of resources: ");
scanf("%d", &resource);
int avail[resource], max[process][resource], allot[process][resource], need[process][resource], completed[process];
for (i = 0; i < process; i++)
completed[i] = 0; // Setting flag for uncompleted processes
// Available Vector
printf("Enter no. of Available Instances: ");
for (i = 0; i < resource; i++) {
scanf("%d", &instanc);
avail[i] = instanc; // Storing Available Instances
}
// Maximum Matrix
printf("Enter maximum no. of instances of resources that a process needs:\n");
for (i = 0; i < process; i++) {
for (j = 0; j < resource; j++) {
scanf("%d", &instanc);
max[i][j] = instanc;
}
}
// Allocation Matrix
printf("Enter no. of instances already allocated to process of a resource:\n");
for (i = 0; i < process; i++) {
for (j = 0; j < resource; j++) {
scanf("%d", &instanc);
allot[i][j] = instanc;
need[i][j] = max[i][j] - allot[i][j]; // Calculating Need Matrix of Each Process
}
}
// Need Matrix
printf("Need Matrix is:\n");
for (i = 0; i < process; i++) {
for (j = 0; j < resource; j++)
printf("%d ", need[i][j]);
printf("\n");
}
// Safe Sequence
printf("Safe Sequence is:\n");
while (count1 != process) {
count2 = count1;
for (i = 0; i < process; i++) {
for (j = 0; j < resource; j++)
if(need[i][j]<=avail[j])
k++;
if (k == resource && completed[i] == 0) {
printf("%d\t", i);
completed[i] = 1;
for(j = 0; j < resource; j++)
avail[j] = avail[j] + allot[i][j];
count1++;
}
k = 0;
}
if (count1 == count2) {
printf("Deadlock Occured!\n");
break;
}
}
}
|
the_stack_data/442201.c | /*
*******************************************************************************
* Copyright (c) 2020-2021, STMicroelectronics
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
*******************************************************************************
*/
#if defined(ARDUINO_GENERIC_F100ZCTX) || defined(ARDUINO_GENERIC_F100ZDTX) || defined(ARDUINO_GENERIC_F100ZETX)
#include "pins_arduino.h"
/**
* @brief System Clock Configuration
* @param None
* @retval None
*/
WEAK void SystemClock_Config(void)
{
/* SystemClock_Config can be generated by STM32CubeMX */
#warning "SystemClock_Config() is empty. Default clock at reset is used."
}
#endif /* ARDUINO_GENERIC_* */
|
the_stack_data/1172701.c | /*
* servtcp.c : exemple de serveur socket mode connecte
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
struct sockaddr_in Sin = {AF_INET}; /* le reste est nul */
struct elt_dns
{
char nom[30];
char adip[20];
} annuaire [] = {
"chaource", "192.168.99.1",
"roquefort", "192.168.99.2",
"comte", "192.168.99.3",
"reblochon", "192.168.99.4",
"beaufort", "192.168.99.5",
"abondance", "192.168.99.6",
"maroilles", "192.168.99.7",
"livarot", "192.168.99.8",
"morbier", "192.168.99.9",
"brie", "192.168.99.10",
"", ""
};
int readlig(int fd, char *b, int max)
{
int n;
char c;
for (n=0; n<max; n++) {
if(read(fd, &c, 1) <= 0) break;
if (c == '\n') break;
*b++ = c;
}
*b = '\0';
return(n);
}
#define LBUF 100
void service(int sid)
{
int n, i;
char buf[LBUF];
n = readlig(sid,buf,LBUF);
if (n < 0) {
perror("readlig");
return;
}
i = 0;
while (strlen(annuaire[i].nom) > 0) {
if (strcmp(buf,annuaire[i].nom) == 0) {
write(sid,annuaire[i].adip,20);
close(sid);
return;
}
i++;
}
write(sid,"erreur !! ", 11);
close(sid);
}
int main(int N, char *P[])
{
int ln, sock, nsock;
/* creation du socket */
if((sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) < 0) {
perror("socket");
exit(1);
}
/* ATTACHEMENT AU PORT */
if(bind(sock,(struct sockaddr*)&Sin, sizeof(Sin)) < 0) {
perror("bind");
exit(2);
}
ln = sizeof(Sin);
if (getsockname(sock,(struct sockaddr*)&Sin,(socklen_t*)&ln) < 0) {
perror("getsockname");
exit(3);
}
printf("Le serveur est attache au port %u\n",ntohs(Sin.sin_port));
/* definition du nb d'appels simultanes */
if (listen(sock,5) < 0) {
perror("listen");
exit(4);
}
/* boucle d'attente */
for (;;) {
if((nsock=accept(sock,(struct sockaddr*)&Sin,(socklen_t*)&ln))<0) {
perror("accept");
exit(5);
}
service(nsock);
}
}
|
the_stack_data/182952393.c | /******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* 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
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/
#include <stdlib.h>
#include <unistd.h>
/*
* abort -- go out via exit...
*/
void abort(void)
{
_exit(1);
}
|
the_stack_data/23627.c | /*Problem Solving with Programming Lab MST
Name - Arya Bhattacharyya
UID - 20BCS3161
Section - 20BCS27 Group - B
Branch - B.E. CSE
Semester - 1*/
/*WAP to search a number in an array using Binary search.*/
#include <stdio.h>
int main(void) {
int n, number;
printf("Enter the number to be searched for: ");
scanf("%d", &number);
printf("Enter the number of elements in the array: ");
scanf("%d", &n);
int arr[n];
printf("Enter the elements of the array:\n");
for(int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int L = 0, U = n - 1, M, flag = 0;
while(L < U) {
M = (L + U) / 2; // finding the middle term
if(arr[M] < number) L = M + 1;
else if(arr[M] > number) U = M - 1;
else if(arr[M] == number) {
flag = 1; // number is found in the array
break;
}
}
if(flag == 1) printf("The number is present at position %d", (M + 1));
else printf("The number is not present.");
return 0;
} |
the_stack_data/583062.c | /* Convert a `struct tm' to a time_t value.
Copyright (C) 1993-1999, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert ([email protected]).
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C 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 the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* Define this to have a standalone program to test this implementation of
mktime. */
/* #define DEBUG 1 */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef _LIBC
# define HAVE_LIMITS_H 1
# define STDC_HEADERS 1
#endif
/* Assume that leap seconds are possible, unless told otherwise.
If the host has a `zic' command with a `-L leapsecondfilename' option,
then it supports leap seconds; otherwise it probably doesn't. */
#ifndef LEAP_SECONDS_POSSIBLE
# define LEAP_SECONDS_POSSIBLE 1
#endif
#include <sys/types.h> /* Some systems define `time_t' here. */
#include <time.h>
#if HAVE_LIMITS_H
# include <limits.h>
#endif
#if DEBUG
# include <stdio.h>
# if STDC_HEADERS
# include <stdlib.h>
# include <string.h>
# endif
/* Make it work even if the system's libc has its own mktime routine. */
# define mktime my_mktime
#endif /* DEBUG */
#ifndef __P
# if defined __GNUC__ || (defined __STDC__ && __STDC__)
# define __P(args) args
# else
# define __P(args) ()
# endif /* GCC. */
#endif /* Not __P. */
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
#ifndef INT_MIN
# define INT_MIN TYPE_MINIMUM (int)
#endif
#ifndef INT_MAX
# define INT_MAX TYPE_MAXIMUM (int)
#endif
#ifndef TIME_T_MIN
# define TIME_T_MIN TYPE_MINIMUM (time_t)
#endif
#ifndef TIME_T_MAX
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
#endif
#define TM_YEAR_BASE 1900
#define EPOCH_YEAR 1970
#ifndef __isleap
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 400th is). */
# define __isleap(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
#endif
/* How many days come before each month (0-12). */
#ifndef _LIBC
static
#endif
const unsigned short int __mon_yday[2][13] =
{
/* Normal years. */
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
/* Leap years. */
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};
#ifdef _LIBC
# define my_mktime_localtime_r __localtime_r
#else
/* If we're a mktime substitute in a GNU program, then prefer
localtime to localtime_r, since many localtime_r implementations
are buggy. */
static struct tm *
my_mktime_localtime_r (const time_t *t, struct tm *tp)
{
struct tm *l = localtime (t);
if (! l)
return 0;
*tp = *l;
return tp;
}
#endif /* ! _LIBC */
/* Yield the difference between (YEAR-YDAY HOUR:MIN:SEC) and (*TP),
measured in seconds, ignoring leap seconds.
YEAR uses the same numbering as TM->tm_year.
All values are in range, except possibly YEAR.
If TP is null, return a nonzero value.
If overflow occurs, yield the low order bits of the correct answer. */
static time_t
ydhms_tm_diff (int year, int yday, int hour, int min, int sec,
const struct tm *tp)
{
if (!tp)
return 1;
else
{
/* Compute intervening leap days correctly even if year is negative.
Take care to avoid int overflow. time_t overflow is OK, since
only the low order bits of the correct time_t answer are needed.
Don't convert to time_t until after all divisions are done, since
time_t might be unsigned. */
int a4 = (year >> 2) + (TM_YEAR_BASE >> 2) - ! (year & 3);
int b4 = (tp->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (tp->tm_year & 3);
int a100 = a4 / 25 - (a4 % 25 < 0);
int b100 = b4 / 25 - (b4 % 25 < 0);
int a400 = a100 >> 2;
int b400 = b100 >> 2;
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
time_t years = year - (time_t) tp->tm_year;
time_t days = (365 * years + intervening_leap_days
+ (yday - tp->tm_yday));
return (60 * (60 * (24 * days + (hour - tp->tm_hour))
+ (min - tp->tm_min))
+ (sec - tp->tm_sec));
}
}
/* Use CONVERT to convert *T to a broken down time in *TP.
If *T is out of range for conversion, adjust it so that
it is the nearest in-range value and then convert that. */
static struct tm *
ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
time_t *t, struct tm *tp)
{
struct tm *r;
if (! (r = (*convert) (t, tp)) && *t)
{
time_t bad = *t;
time_t ok = 0;
struct tm tm;
/* BAD is a known unconvertible time_t, and OK is a known good one.
Use binary search to narrow the range between BAD and OK until
they differ by 1. */
while (bad != ok + (bad < 0 ? -1 : 1))
{
time_t mid = *t = (bad < 0
? bad + ((ok - bad) >> 1)
: ok + ((bad - ok) >> 1));
if ((r = (*convert) (t, tp)))
{
tm = *r;
ok = mid;
}
else
bad = mid;
}
if (!r && ok)
{
/* The last conversion attempt failed;
revert to the most recent successful attempt. */
*t = ok;
*tp = tm;
r = tp;
}
}
return r;
}
/* Convert *TP to a time_t value, inverting
the monotonic and mostly-unit-linear conversion function CONVERT.
Use *OFFSET to keep track of a guess at the offset of the result,
compared to what the result would be for UTC without leap seconds.
If *OFFSET's guess is correct, only one CONVERT call is needed. */
#ifndef _LIBC
static
#endif
time_t
__mktime_internal (struct tm *tp,
struct tm *(*convert) (const time_t *, struct tm *),
time_t *offset)
{
time_t t, dt, t0, t1, t2;
struct tm tm;
/* The maximum number of probes (calls to CONVERT) should be enough
to handle any combinations of time zone rule changes, solar time,
leap seconds, and oscillations around a spring-forward gap.
POSIX.1 prohibits leap seconds, but some hosts have them anyway. */
int remaining_probes = 6;
/* Time requested. Copy it in case CONVERT modifies *TP; this can
occur if TP is localtime's returned value and CONVERT is localtime. */
int sec = tp->tm_sec;
int min = tp->tm_min;
int hour = tp->tm_hour;
int mday = tp->tm_mday;
int mon = tp->tm_mon;
int year_requested = tp->tm_year;
int isdst = tp->tm_isdst;
/* 1 if the previous probe was DST. */
int dst2;
/* Ensure that mon is in range, and set year accordingly. */
int mon_remainder = mon % 12;
int negative_mon_remainder = mon_remainder < 0;
int mon_years = mon / 12 - negative_mon_remainder;
int year = year_requested + mon_years;
/* The other values need not be in range:
the remaining code handles minor overflows correctly,
assuming int and time_t arithmetic wraps around.
Major overflows are caught at the end. */
/* Calculate day of year from year, month, and day of month.
The result need not be in range. */
int yday = ((__mon_yday[__isleap (year + TM_YEAR_BASE)]
[mon_remainder + 12 * negative_mon_remainder])
+ mday - 1);
int sec_requested = sec;
/* Only years after 1970 are defined.
If year is 69, it might still be representable due to
timezone differences. */
if (year < 69)
return -1;
#if LEAP_SECONDS_POSSIBLE
/* Handle out-of-range seconds specially,
since ydhms_tm_diff assumes every minute has 60 seconds. */
if (sec < 0)
sec = 0;
if (59 < sec)
sec = 59;
#endif
/* Invert CONVERT by probing. First assume the same offset as last time.
Then repeatedly use the error to improve the guess. */
tm.tm_year = EPOCH_YEAR - TM_YEAR_BASE;
tm.tm_yday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
t0 = ydhms_tm_diff (year, yday, hour, min, sec, &tm);
for (t = t1 = t2 = t0 + *offset, dst2 = 0;
(dt = ydhms_tm_diff (year, yday, hour, min, sec,
ranged_convert (convert, &t, &tm)));
t1 = t2, t2 = t, t += dt, dst2 = tm.tm_isdst != 0)
if (t == t1 && t != t2
&& (tm.tm_isdst < 0
|| (isdst < 0
? dst2 <= (tm.tm_isdst != 0)
: (isdst != 0) != (tm.tm_isdst != 0))))
/* We can't possibly find a match, as we are oscillating
between two values. The requested time probably falls
within a spring-forward gap of size DT. Follow the common
practice in this case, which is to return a time that is DT
away from the requested time, preferring a time whose
tm_isdst differs from the requested value. (If no tm_isdst
was requested and only one of the two values has a nonzero
tm_isdst, prefer that value.) In practice, this is more
useful than returning -1. */
break;
else if (--remaining_probes == 0)
return -1;
/* If we have a match, check whether tm.tm_isdst has the requested
value, if any. */
if (dt == 0 && isdst != tm.tm_isdst && 0 <= isdst && 0 <= tm.tm_isdst)
{
/* tm.tm_isdst has the wrong value. Look for a neighboring
time with the right value, and use its UTC offset.
Heuristic: probe the previous three calendar quarters (approximately),
looking for the desired isdst. This isn't perfect,
but it's good enough in practice. */
int quarter = 7889238; /* seconds per average 1/4 Gregorian year */
int i;
/* If we're too close to the time_t limit, look in future quarters. */
if (t < TIME_T_MIN + 3 * quarter)
quarter = -quarter;
for (i = 1; i <= 3; i++)
{
time_t ot = t - i * quarter;
struct tm otm;
ranged_convert (convert, &ot, &otm);
if (otm.tm_isdst == isdst)
{
/* We found the desired tm_isdst.
Extrapolate back to the desired time. */
t = ot + ydhms_tm_diff (year, yday, hour, min, sec, &otm);
ranged_convert (convert, &t, &tm);
break;
}
}
}
*offset = t - t0;
#if LEAP_SECONDS_POSSIBLE
if (sec_requested != tm.tm_sec)
{
/* Adjust time to reflect the tm_sec requested, not the normalized value.
Also, repair any damage from a false match due to a leap second. */
t += sec_requested - sec + (sec == 0 && tm.tm_sec == 60);
if (! (*convert) (&t, &tm))
return -1;
}
#endif
if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3)
{
/* time_t isn't large enough to rule out overflows in ydhms_tm_diff,
so check for major overflows. A gross check suffices,
since if t has overflowed, it is off by a multiple of
TIME_T_MAX - TIME_T_MIN + 1. So ignore any component of
the difference that is bounded by a small value. */
double dyear = (double) year_requested + mon_years - tm.tm_year;
double dday = 366 * dyear + mday;
double dsec = 60 * (60 * (24 * dday + hour) + min) + sec_requested;
/* On Irix4.0.5 cc, dividing TIME_T_MIN by 3 does not produce
correct results, ie., it erroneously gives a positive value
of 715827882. Setting a variable first then doing math on it
seems to work. ([email protected]) */
const time_t time_t_max = TIME_T_MAX;
const time_t time_t_min = TIME_T_MIN;
if (time_t_max / 3 - time_t_min / 3 < (dsec < 0 ? - dsec : dsec))
return -1;
}
if (year == 69)
{
/* If year was 69, need to check whether the time was representable
or not. */
if (t < 0 || t > 2 * 24 * 60 * 60)
return -1;
}
*tp = tm;
return t;
}
static time_t localtime_offset;
/* Convert *TP to a time_t value. */
time_t
mktime (tp)
struct tm *tp;
{
#ifdef _LIBC
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the
time zone names contained in the external variable `tzname' shall
be set as if the tzset() function had been called. */
__tzset ();
#endif
return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset);
}
#ifdef weak_alias
weak_alias (mktime, timelocal)
#endif
#ifdef _LIBC
libc_hidden_def (mktime)
libc_hidden_weak (timelocal)
#endif
#if DEBUG
static int
not_equal_tm (a, b)
struct tm *a;
struct tm *b;
{
return ((a->tm_sec ^ b->tm_sec)
| (a->tm_min ^ b->tm_min)
| (a->tm_hour ^ b->tm_hour)
| (a->tm_mday ^ b->tm_mday)
| (a->tm_mon ^ b->tm_mon)
| (a->tm_year ^ b->tm_year)
| (a->tm_mday ^ b->tm_mday)
| (a->tm_yday ^ b->tm_yday)
| (a->tm_isdst ^ b->tm_isdst));
}
static void
print_tm (tp)
struct tm *tp;
{
if (tp)
printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
tp->tm_hour, tp->tm_min, tp->tm_sec,
tp->tm_yday, tp->tm_wday, tp->tm_isdst);
else
printf ("0");
}
static int
check_result (tk, tmk, tl, lt)
time_t tk;
struct tm tmk;
time_t tl;
struct tm *lt;
{
if (tk != tl || !lt || not_equal_tm (&tmk, lt))
{
printf ("mktime (");
print_tm (&tmk);
printf (")\nyields (");
print_tm (lt);
printf (") == %ld, should be %ld\n", (long) tl, (long) tk);
return 1;
}
return 0;
}
int
main (argc, argv)
int argc;
char **argv;
{
int status = 0;
struct tm tm, tmk, tml;
struct tm *lt;
time_t tk, tl;
char trailer;
if ((argc == 3 || argc == 4)
&& (sscanf (argv[1], "%d-%d-%d%c",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
== 3)
&& (sscanf (argv[2], "%d:%d:%d%c",
&tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
== 3))
{
tm.tm_year -= TM_YEAR_BASE;
tm.tm_mon--;
tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]);
tmk = tm;
tl = mktime (&tmk);
lt = localtime (&tl);
if (lt)
{
tml = *lt;
lt = &tml;
}
printf ("mktime returns %ld == ", (long) tl);
print_tm (&tmk);
printf ("\n");
status = check_result (tl, tmk, tl, lt);
}
else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0))
{
time_t from = atol (argv[1]);
time_t by = atol (argv[2]);
time_t to = atol (argv[3]);
if (argc == 4)
for (tl = from; tl <= to; tl += by)
{
lt = localtime (&tl);
if (lt)
{
tmk = tml = *lt;
tk = mktime (&tmk);
status |= check_result (tk, tmk, tl, tml);
}
else
{
printf ("localtime (%ld) yields 0\n", (long) tl);
status = 1;
}
}
else
for (tl = from; tl <= to; tl += by)
{
/* Null benchmark. */
lt = localtime (&tl);
if (lt)
{
tmk = tml = *lt;
tk = tl;
status |= check_result (tk, tmk, tl, tml);
}
else
{
printf ("localtime (%ld) yields 0\n", (long) tl);
status = 1;
}
}
}
else
printf ("Usage:\
\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
\t%s FROM BY TO - # Do not test those values (for benchmark).\n",
argv[0], argv[0], argv[0]);
return status;
}
#endif /* DEBUG */
/*
Local Variables:
compile-command: "gcc -DDEBUG -DHAVE_LIMITS_H -DSTDC_HEADERS -Wall -W -O -g mktime.c -o mktime"
End:
*/
|
the_stack_data/124380.c | #include <stdio.h>
int main(){
return 0;
}
|
the_stack_data/162642380.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <pthread.h>
typedef int st_label;
#define TREEFLAG_EXTENDABLE_EDGE 1
#define TREEFLAG_PACKED_CHILDREN 2
//#define TREEFLAG_ALREADY_MENTIONED 4
#define TREEFLAG_CANDIDATE 4
#define VALIDATE_EMBEDDINGS
#define COUNT_MALLOCS
struct st_syntax_tree {
st_label label;
unsigned int num_children;
struct st_syntax_tree** children;
int flags;
unsigned int bestKnownRefcount;
struct st_syntax_tree* copyUsedDuringSplitup;
void* embeddingUsedDuringSplitup;
struct st_syntax_tree* original;
};
typedef struct st_syntax_tree st_tree;
#ifdef COUNT_MALLOCS
#include <malloc.h>
int num_allocations=0;
int num_trees = 0;
ssize_t allocated_memory=0;
void* getmem(size_t s) {
__sync_fetch_and_add(&num_allocations,1);
void* ptr= malloc(s);
size_t allocated = malloc_usable_size(ptr);
/*
if (allocated > s) {
printf("requested %lu bytes, got %lu\n", s, allocated);
}
*/
__sync_fetch_and_add(&allocated_memory,allocated);
return ptr;
}
void freemem(void* ptr) {
__sync_fetch_and_sub(&num_allocations,1);
__sync_fetch_and_sub(&allocated_memory,malloc_usable_size(ptr));
free(ptr);
}
void showMemoryInformation() {
printf("%d memory blocks held with %ld bytes.\n",num_allocations,allocated_memory);
printf("%d trees held of size %lu + %lu bytes each\n", num_trees, sizeof(st_tree), sizeof(st_tree*));
}
#else
#define getmem malloc
#define freemem free
void showMemoryInformation() {
printf("memory allocations not tracked.\n");
}
#endif
void st_freeTree(st_tree* t) {
int i;
for (i=0; i<t->num_children; i++) {
st_freeTree((st_tree*) t->children[i]);
}
if (t->children != NULL && ! (t->flags & TREEFLAG_PACKED_CHILDREN)) freemem(t->children);
freemem(t);
#ifdef COUNT_MALLOCS
__sync_fetch_and_sub(&num_trees,1);
#endif
}
void st_shallowFreeTree(st_tree* t) {
if (t->children != NULL && ! (t->flags & TREEFLAG_PACKED_CHILDREN)) freemem(t->children);
freemem(t);
#ifdef COUNT_MALLOCS
__sync_fetch_and_sub(&num_trees,1);
#endif
}
st_tree* st_createTree(st_label label, unsigned int num_children, st_tree** children) {
st_tree* result = (st_tree*) getmem(sizeof(st_tree));
result->label=label;
result->num_children=num_children;
result->flags=0;
result->bestKnownRefcount=0;
result->copyUsedDuringSplitup=NULL;
result->embeddingUsedDuringSplitup=NULL;
result->original=NULL;
if (num_children != 0) {
result->children=children;
} else {
result->children=NULL;
}
#ifdef COUNT_MALLOCS
__sync_fetch_and_add(&num_trees,1);
#endif
return result;
}
st_tree* st_prepareTree(st_label label, unsigned int num_children) {
st_tree* result = (st_tree*) getmem(sizeof(st_tree) + sizeof(st_tree*) * num_children);
result->label=label;
result->num_children = num_children;
result->bestKnownRefcount=0;
result->copyUsedDuringSplitup=NULL;
result->embeddingUsedDuringSplitup=NULL;
result->original=NULL;
if (num_children >0) {
result->children = (st_tree**) (result+1);
} else {
result->children = NULL;
}
result->flags = TREEFLAG_PACKED_CHILDREN;
#ifdef COUNT_MALLOCS
__sync_fetch_and_add(&num_trees,1);
#endif
return result;
}
void st_setTreeChild(st_tree* parent, unsigned int index, st_tree* child) {
parent->children[index]=child;
}
void st_setTreeExtendable(st_tree* tree, _Bool isExtendable) {
if (isExtendable) {
tree->flags |= TREEFLAG_EXTENDABLE_EDGE;
} else {
tree->flags &= ~TREEFLAG_EXTENDABLE_EDGE;
}
}
void st_printTree(const st_tree* t, unsigned int level) {
unsigned int i;
for (i=0; i<level; i++) printf(" ");
if (t->flags & TREEFLAG_EXTENDABLE_EDGE) printf("(extendable) ");
printf("%d\n", t->label);
for (i=0; i<t->num_children;i++) {
st_printTree(t->children[i],level+1);
}
}
st_label st_treeGetLabel(const st_tree* tree){return tree->label;}
unsigned int st_treeNumOfChildren(const st_tree* tree) {return tree->num_children;}
st_tree* st_treeGetChild(const st_tree* tree,unsigned int index) {return tree->children[index];}
_Bool st_treeGetExtendable(const st_tree* tree){return (tree->flags & TREEFLAG_EXTENDABLE_EDGE)!=0;}
_Bool st_canMatchPattern(const st_tree* pattern, const st_tree* tree) {
if (pattern->label == tree->label) {
int pchildnum, tchildnum;
tchildnum=0;
for (pchildnum=0;pchildnum<pattern->num_children;pchildnum++) {
st_tree* pchild = pattern->children[pchildnum];
while (tchildnum < tree->num_children && !st_canMatchPattern(pchild, tree->children[tchildnum])) {
tchildnum++;
}
if (tchildnum >= tree->num_children) return false;
tchildnum++;
}
return true;
} else if (pattern->flags & TREEFLAG_EXTENDABLE_EDGE) {
int i;
for (i=0;i < tree->num_children; i++) {
if (st_canMatchPattern(pattern, tree->children[i])) return true;
}
}
return false;
}
unsigned int st_countNodes(const st_tree* tree) {
unsigned int result = 1, i;
for (i=0; i<tree->num_children;i++) {
result += st_countNodes(tree->children[i]);
}
return result;
}
const st_tree** st_listNodes(const st_tree* tree, const st_tree** nodelist) { // not tested!
//returns an array of pointers to the tree's nodes, in breadth-first manner.
//nodelist must be a writeable memory region of size sizeof(st_tree*) * st_countNodes(tree)
//returns nodelist + countNodes(tree)
nodelist[0] = tree;
nodelist += 1;
int i;
for (i=0; i < tree->num_children; i++) {
nodelist = st_listNodes(tree->children[i], nodelist);
}
return nodelist;
}
st_tree* st_deepCopyTree(const st_tree* tree) {
st_tree* result = st_prepareTree(tree->label, tree->num_children);
result->flags |= tree->flags;
int i;
for (i=0; i<tree->num_children;i++) {
st_tree* ch = st_deepCopyTree(tree->children[i]);
result->children[i]=ch;
}
result->bestKnownRefcount = tree->bestKnownRefcount;
return result;
}
typedef struct {
unsigned int num_trees;
} st_document;
//the convention is that directly after the document, a list of `num_trees` entries of type st_tree* follows.
void st_shallowFreeDocument(st_document* doc) {
freemem(doc);
}
st_document* st_prepareDocument(unsigned int num_trees) {
st_document* result = (st_document*) getmem(sizeof(st_document) + num_trees * sizeof(st_tree*));
result->num_trees = num_trees;
return result;
}
void st_documentSetTree(st_document* doc, unsigned int index, st_tree* const tree) {
((st_tree**) (void*) (doc+1))[index] = tree;
}
unsigned int st_occuringTrees(const st_tree* pattern, const st_document* doc) {
unsigned int result = 0,i;
for (i=0; i < doc->num_trees; i++) {
if (st_canMatchPattern(pattern, ((st_tree**) (doc+1))[i])) result++;
}
return result;
}
double st_frequency(const st_tree* pattern, const st_document* doc) {
return ((double) st_occuringTrees(pattern, doc))/((double) doc->num_trees);
}
typedef struct {
unsigned int num_documents;
} st_documentclass;
//the convention is that it follows `num_documents` pointers to the documents.
void st_freeDocumentClass(st_documentclass* class) {
freemem(class);
}
st_documentclass* st_prepareDocumentClass(unsigned int num_documents) {
st_documentclass* result = getmem(sizeof(st_documentclass) + num_documents * sizeof(st_document*));
result->num_documents = num_documents;
return result;
}
void st_setDocumentInClass(st_documentclass* class, unsigned int index, st_document* const doc) {
( (st_document**) (class+1))[index]=doc;
}
typedef struct {
unsigned int num_classes;
unsigned int num_documents;
} st_documentbase;
//the convention is that it follows `num_classes` pointers to the document classes.
void st_freeDocumentBase(st_documentbase* base) {
freemem(base);
}
st_documentbase* st_prepareDocumentBase(unsigned int num_classes) {
st_documentbase* result = getmem(sizeof(st_documentbase) + num_classes * sizeof(st_documentclass*));
result->num_classes = num_classes;
return result;
}
void st_setClassInDocumentBase(st_documentbase* base, unsigned int index, st_documentclass* const class) {
( (st_documentclass**) (base+1))[index]=class;
}
void st_completeDocumentBaseSetup(st_documentbase* base) {
base->num_documents=0;
unsigned int i;
for (i=0; i<base->num_classes; i++) {
base->num_documents += ((st_documentclass**) base+1)[i]->num_documents;
}
}
unsigned int st_support(const st_documentbase* base, const st_tree* pattern) {
unsigned int result=0,i,j;
for (i=0; i < base->num_classes;i++) {
st_documentclass* class = ((st_documentclass**) (base+1))[i];
for (j=0; j<class->num_documents;j++) {
result += st_occuringTrees(pattern, ((st_document**) (class+1))[j]);
}
}
return result;
}
double st_conditionalEntropy(const st_documentbase* base, const st_tree* pattern, unsigned int n, double* lowerBound) {
//if lowerBound != NULL, it must be a valid writeable pointer to which the computed lower bound for all superpatterns is written.
size_t memorysize = sizeof(unsigned int) * base->num_classes * n;
unsigned int* frequencyMatrix = getmem(memorysize);
memset(frequencyMatrix, 0, memorysize);
unsigned int i,j;
for (i=0; i<base->num_classes; i++) {
st_documentclass* class = ((st_documentclass**) (base+1))[i];
for (j=0; j<class->num_documents; j++) {
double freq = st_frequency(pattern, ((st_document**) (class+1))[j]);
int index = freq*n;
if (index < 0) {
index=0;
}else if(index >= n) {
index=n-1;
}
frequencyMatrix[index*base->num_classes+i]++;
}
}
/*
for (j=0;j<n;j++) {
for (i=0;i<base->num_classes;i++) {
printf("%d ",frequencyMatrix[j*base->num_classes+i]);
}
printf("\n");
}
*/
double result=0;
double dinv = 1.0/((double) base->num_documents);
for (i=0; i<n; i++) {
unsigned int total=0;
unsigned int* row = frequencyMatrix + i*base->num_classes;
for (j=0; j<base->num_classes;j++) total += row[j];
double factor = 1.0/((double) total);
for (j=0; j<base->num_classes;j++) {
double val=row[j];
if (val != 0) result -= val * dinv * log(val*factor);
}
}
if (lowerBound != NULL) {
double min=0;
unsigned int total=0;
for (i=0; i<base->num_classes;i++) total += frequencyMatrix[i];
for (i=0; i<base->num_classes;i++) {
unsigned int extra=frequencyMatrix[base->num_classes +i];
total += extra;
frequencyMatrix[i] += extra;
double val=0;
for (j=0; j<base->num_classes;j++) {
double entry=frequencyMatrix[j];
if (entry != 0) val -= entry * log(entry/total);
}
//printf("val: %f\n", val);
if (i==0 || val<min) min=val;
total -= extra;
frequencyMatrix[i] -= extra;
}
//printf("min: %f\n", min);
*lowerBound = min*dinv;
/*
if (result > *lowerBound) {
printf("ERROR detected.\n");
*lowerBound /= result-result;
}
*/
}
freemem(frequencyMatrix);
return result;
}
struct st_partialPatternEmbedding {
unsigned int classIndex;
unsigned int documentIndex;
unsigned int sentenceIndex;
st_tree** rightPath;
struct st_partialPatternEmbedding* next; // we agree on the convention that, in the list, classIndex is increasing,
//then documentIndex is increasing, then sentenceIndex is increasing.
};
typedef struct st_partialPatternEmbedding st_patternEmbedding;
_Bool st_isValidEmbedding(const st_documentbase* base, const st_tree* pattern, const st_patternEmbedding* embedding) {
unsigned int lc=0, ld=0, ls=0;
while (embedding != NULL) {
//printf("about to validate embedding in class %u, document %u, sentence %u\n", embedding->classIndex, embedding->documentIndex, embedding->sentenceIndex);
if (embedding->classIndex >= base->num_classes || embedding->classIndex < lc) return false;
st_documentclass* class = ((st_documentclass**) (base+1))[embedding->classIndex];
if (embedding->documentIndex >= class->num_documents || (embedding->classIndex == lc && embedding->documentIndex < ld)) return false;
st_document* document = ((st_document**) (class+1))[embedding->documentIndex];
if (embedding->sentenceIndex >= document->num_trees ||
(embedding->classIndex == lc && embedding->documentIndex == ld && embedding->sentenceIndex < ls)) return false;
if (!st_canMatchPattern(pattern, ((st_tree**) (document+1))[embedding->sentenceIndex])) return false;
unsigned int i=0;
const st_tree* node = pattern;
while (true) {
if (node->label != embedding->rightPath[i]->label) return false;
if (i>0 && (node->flags & TREEFLAG_EXTENDABLE_EDGE) == 0) {
st_tree* parent = embedding->rightPath[i-1];
if (parent->children[parent->num_children-1] != embedding->rightPath[i]) {
return false;
}
}
if (node->num_children == 0) break;
i=i+1;
node = node->children[node->num_children-1];
}
lc = embedding->classIndex;
ld = embedding->documentIndex;
ls = embedding->sentenceIndex;
embedding = embedding->next;
}
//printf("validated.\n");
return true;
}
void st_validateEmbedding(const st_documentbase* base, const st_tree* pattern, const st_patternEmbedding* embedding) {
#ifdef VALIDATE_EMBEDDINGS
if (!st_isValidEmbedding(base, pattern, embedding)) {
unsigned int _=((st_tree*) NULL) -> num_children;
_ = _/_;
}
#endif
}
unsigned int st_rightPathLength(const st_tree* pattern) {
unsigned int result = 1;
while (pattern->num_children >0) {
result++;
pattern=pattern->children[pattern->num_children-1];
}
return result;
}
st_patternEmbedding* st_copyPatternEmbedding(const st_tree* pattern, const st_patternEmbedding* embedding) {
if (embedding==NULL) return NULL;
st_patternEmbedding* result = getmem(sizeof(st_patternEmbedding));
result->classIndex = embedding->classIndex;
result->documentIndex = embedding->documentIndex;
result->sentenceIndex = embedding->sentenceIndex;
unsigned int length = st_rightPathLength(pattern);
result->rightPath = getmem(sizeof(st_tree*) * length);
memcpy(result->rightPath, embedding->rightPath, sizeof(st_tree*)*length);
result->next = st_copyPatternEmbedding(pattern,embedding->next);
return result;
}
struct st_patternListEntry {
st_tree* pattern;
st_patternEmbedding* embedding;
unsigned int num_embedded_edges;
struct st_patternListEntry* pred;
struct st_patternListEntry* succ;
};
typedef struct st_patternListEntry st_listedPattern;
typedef struct {
unsigned int length;
double cachedEntropy;
st_listedPattern* first;
st_listedPattern* last;
} st_patternList;
st_patternList* st_createEmptyPatternList() {
st_patternList* result = getmem(sizeof(st_patternList));
result->length=0;
result->cachedEntropy = -1;
result->first=NULL;
result->last=NULL;
return result;
}
void st_patternListInsertFirst(st_patternList* list, st_tree* pattern, unsigned int num_embedded_edges, st_patternEmbedding* embedding) {
st_listedPattern* link = getmem(sizeof(st_listedPattern));
link->pattern = pattern;
link->embedding=embedding;
link->num_embedded_edges = num_embedded_edges;
link->pred = NULL;
if (list->first != NULL) list->first->pred = link;
link->succ = list->first;
list->first=link;
if (list->last == NULL) list->last=link;
list->length++;
}
void st_patternListInsertLast(st_patternList* list, st_tree* pattern, unsigned int num_embedded_edges, st_patternEmbedding* embedding) {
st_listedPattern* link = getmem(sizeof(st_listedPattern));
link->pattern = pattern;
link->embedding=embedding;
link->num_embedded_edges = num_embedded_edges;
link->succ = NULL;
link->pred = list->last;
if (list->last != NULL) list->last->succ = link;
list->last=link;
if (list->first == NULL) list->first=link;
list->length++;
}
void st_patternListRemoveFirst(st_patternList* list) {
st_listedPattern* link = list->first;
list->first = link->succ;
if (link->succ == NULL) {
list->last = NULL;
} else {
link->succ->pred = NULL;
}
freemem(link);
list->length--;
}
void st_patternListRemoveLast(st_patternList* list) {
st_listedPattern* link = list->last;
list->last = link->pred;
if (link->pred == NULL) {
list->first = NULL;
} else {
link->pred->succ = NULL;
}
freemem(link);
list->length--;
}
void st_patternListRemoveListed(st_patternList* list, st_listedPattern* remove) {
if (list->first == remove) {
list->first = remove->succ;
} else {
remove->pred->succ = remove->succ;
}
if (list->last == remove) {
list->last = remove->pred;
} else {
remove->succ->pred = remove->pred;
}
freemem(remove);
list->length--;
}
void st_recursiveFreeEmbedding(st_patternEmbedding* embedding) {
while (embedding != NULL) {
//printf("about to freemem embedding in class %u, document %u, sentence %u\n", embedding->classIndex, embedding->documentIndex, embedding->sentenceIndex);
freemem(embedding->rightPath);
st_patternEmbedding* next = embedding->next;
freemem(embedding);
embedding=next;
}
}
void st_deepCleanupList(st_patternList* list) {
st_listedPattern* link;
link=list->first;
while (link != NULL) {
st_freeTree(link->pattern);
//printf("free the candidate %p.\n", link->pattern);
st_recursiveFreeEmbedding(link->embedding);
st_listedPattern* tmp=link;
link=link->succ;
freemem(tmp);
}
list->length=0;
list->first=NULL;
list->last=NULL;
}
void st_deepFreeList(st_patternList* list) {
st_deepCleanupList(list);
freemem(list);
}
void st_shallowFreeList(st_patternList* list) {
//frees everything besides the patterns and embeddings
st_listedPattern* link;
link=list->first;
while (link != NULL) {
st_listedPattern* tmp=link;
link=link->succ;
freemem(tmp);
}
freemem(list);
}
unsigned int st_listGetLength(const st_patternList* list){return list->length;}
st_listedPattern* st_listGetFirstEntry(const st_patternList* list){return list->first;}
st_listedPattern* st_listedGetNext(const st_listedPattern* listed){return listed->succ;}
st_tree* st_listedGetPattern(const st_listedPattern* listed){return listed->pattern;}
st_tree* st_expandPatternRight(const st_tree* pattern, unsigned int index, st_label label, _Bool embeddable) {
st_tree* result;
if (index == 0) {
result = st_prepareTree(pattern->label, pattern->num_children+1);
result->children[pattern->num_children] = st_prepareTree(label, 0);
if (embeddable) result->children[pattern->num_children]->flags |= TREEFLAG_EXTENDABLE_EDGE;
} else {
result = st_prepareTree(pattern->label, pattern->num_children);
}
result->flags |= pattern->flags;
unsigned int i;
for (i=0; i<result->num_children-1; i++) {
result->children[i] = st_deepCopyTree(pattern->children[i]);
}
if (index != 0) {
result->children[result->num_children-1] = st_expandPatternRight(pattern->children[pattern->num_children-1], index-1, label, embeddable);
}
return result;
}
unsigned int st_esupport(const st_documentbase* base, const st_patternEmbedding* embedding) {
unsigned int result=0;
int lc,ld,ls,firstLoop=1;
while (embedding != NULL) {
if (firstLoop || embedding->classIndex > lc || embedding->documentIndex > ld || embedding->sentenceIndex > ls) {
result++;
lc = embedding->classIndex;
ld = embedding->documentIndex;
ls = embedding->sentenceIndex;
}
embedding = embedding->next;
firstLoop=0;
}
return result;
}
double st_econditionalEntropy(const st_documentbase* base, unsigned int n, double* lowerBound, const st_patternEmbedding* embedding) {
//if lowerBound != NULL, it must be a valid writeable pointer to which the computed lower bound for all superpatterns is written.
size_t memorysize = sizeof(unsigned int) * base->num_classes * n;
unsigned int* frequencyMatrix = getmem(memorysize);
//printf("allocated this frequency matrix: %p\n", frequencyMatrix);
memset(frequencyMatrix, 0, memorysize);
unsigned int i,j;
int lc=-1,ld=-1,ls=-1;
st_documentclass* class=NULL;
st_document* document=NULL;
unsigned int occurances=0;
while (embedding != NULL) {
//for each document in each class, we compute the number of sentences where the pattern is embeddable.
//class is the class we are watching (=base->classes[lc])
//document is the document we are watching (=class->documents[ld])
//ls is the index of the last sentence occured.
//occurances is the number of occurances in doc counted so far.
if (lc == -1) {
for (lc=0; lc<embedding->classIndex; lc++) {
frequencyMatrix[lc] = ((st_documentclass**) (base+1))[lc]->num_documents;
}
frequencyMatrix[lc] += embedding->documentIndex;
} else if (embedding->classIndex > lc || embedding->documentIndex > ld) {
unsigned int frequency = (occurances * n)/document->num_trees;
if (frequency >= n) frequency=n-1;
frequencyMatrix[frequency*base->num_classes+lc]++;
occurances=0;
ld++;
for (;lc<embedding->classIndex;lc++) {
class = ((st_documentclass**) (base+1))[lc];
frequencyMatrix[lc] += class->num_documents-ld;
ld=0;
}
frequencyMatrix[lc] += embedding->documentIndex-ld;
} else if (embedding->sentenceIndex == ls) {
embedding = embedding->next;
continue;
}
occurances++;
lc = embedding->classIndex;
ld = embedding->documentIndex;
ls = embedding->sentenceIndex;
class = ((st_documentclass**) (base+1))[lc];
document = ((st_document**) (class+1))[ld];
embedding = embedding->next;
}
if (lc != -1) {
unsigned int frequency = (occurances * n)/document->num_trees;
if (frequency >= n) frequency=n-1;
frequencyMatrix[frequency*base->num_classes+lc]++;
ld++;
for (;lc<base->num_classes;lc++) {
class = ((st_documentclass**) (base+1))[lc];
frequencyMatrix[lc] += class->num_documents-ld;
ld=0;
}
} else {
for (lc=0; lc<base->num_classes;lc++) {
frequencyMatrix[lc] = ((st_documentclass**) (base+1))[lc]->num_documents;
}
}
/*
for (j=0;j<n;j++) {
for (i=0;i<base->num_classes;i++) {
printf("%d ",frequencyMatrix[j*base->num_classes+i]);
}
printf("\n");
}
*/
double result=0;
double dinv = 1.0/((double) base->num_documents);
for (i=0; i<n; i++) {
unsigned int total=0;
unsigned int* row = frequencyMatrix + i*base->num_classes;
for (j=0; j<base->num_classes;j++) total += row[j];
double factor = 1.0/((double) total);
for (j=0; j<base->num_classes;j++) {
double val=row[j];
if (val != 0) result -= val * dinv * log(val*factor);
}
}
//printf("result: %.18f\n", result);
if (lowerBound != NULL) {
double min=0;
unsigned int total=0;
for (i=0; i<base->num_classes;i++) total += frequencyMatrix[i];
for (i=0; i<base->num_classes;i++) {
unsigned int extra=frequencyMatrix[base->num_classes +i];
total += extra;
frequencyMatrix[i] += extra;
double val=0;
for (j=0; j<base->num_classes;j++) {
double entry=frequencyMatrix[j];
if (entry != 0) val -= entry * log(entry/total);
}
//printf("val: %f, min: %f\n", val, min);
if (i==0 || val<min) min=val;
total -= extra;
frequencyMatrix[i] -= extra;
}
*lowerBound = min*dinv;
/*
printf("lowerBound: %.18f\n", *lowerBound);
if (*lowerBound > result+1e-12) {
printf("ERROR detected.\n");
*lowerBound = ((double*) NULL)[0];
}
*/
}
//printf("about to free this frequency matrix: %p\n", frequencyMatrix);
freemem(frequencyMatrix);
return result;
}
typedef struct {
st_documentbase* base;
st_patternList**** bestKnown; // class -> document -> sentence -> st_patternList*
st_patternList* candidates;
unsigned int numLabels;// we agree that all occuring labels are 0,...,numLabels-1.
unsigned int supportLowerBound;//bound theta for frequent patterns
unsigned int n;//number of bins
unsigned int k;//max. number of embedded edges
} st_miningState;
_Bool st_isValidPattern(const st_miningState* state, const st_tree* pattern) {
if (pattern->label < 0 || pattern->label >= state->numLabels) return false;
unsigned int i;
for (i=0; i<pattern->num_children; i++) {
if (!st_isValidPattern(state, pattern->children[i])) return false;
}
return true;
}
_Bool st_isValidPatternList(const st_miningState* state, const st_patternList* list) {
unsigned int trueLength = 0;
const st_listedPattern* entry;
for (entry = list->first; entry != NULL; entry = entry->succ) {
trueLength++;
if (!st_isValidEmbedding(state->base, entry->pattern, entry->embedding)) return false;
if (!st_isValidPattern(state, entry->pattern)) return false;
}
return (list->length == trueLength);
}
_Bool st_isValidState(const st_miningState* state) {
unsigned int i,j,k;
for (i=0; i<state->base->num_classes; i++) {
const st_documentclass* class = ((st_documentclass**) (state->base+1))[i];
const st_patternList*** classBestKnown = (const st_patternList***) state->bestKnown[i];
for (j=0; j<class->num_documents; j++) {
const st_document* document = ((st_document**) (class+1))[j];
const st_patternList** documentBestKnown =(const st_patternList**) classBestKnown[j];
for (k=0; k<document->num_trees; k++) {
//st_deepFreeList(documentBestKnown[k]);
const st_patternList* list = (const st_patternList*) documentBestKnown[k];
if (!st_isValidPatternList(state, list)) return false;
//printf("validated bestKnown of class %u, document %u, sentence %u.\n", i, j, k);
}
}
}
if (!st_isValidPatternList(state, state->candidates)) return false;
//printf("validated the candidates.\n");
return true;
}
void st_validateState(const st_miningState* state) {
if (!st_isValidState(state)) {
state = ((st_miningState**) NULL)[0];
}
}
st_miningState* st_createMiningState(st_documentbase* base, unsigned int numLabels, unsigned int supportLowerBound, unsigned int n, unsigned int kee) {
unsigned int i,j,k;
st_miningState* result = getmem(sizeof(st_miningState));
result->base=base;
result->bestKnown = getmem(sizeof(st_patternList***) * base->num_classes);
for (i=0; i<base->num_classes; i++) {
st_documentclass* class = ((st_documentclass**) (base+1))[i];
st_patternList*** classBestKnown = getmem(sizeof(st_patternList**) * class->num_documents);
result->bestKnown[i] = classBestKnown;
for (j=0; j<class->num_documents; j++) {
st_document* document = ((st_document**) (class+1))[j];
st_patternList** documentBestKnown = getmem(sizeof(st_patternList*) * document->num_trees);
classBestKnown[j]=documentBestKnown;
for (k=0; k<document->num_trees; k++) {
documentBestKnown[k] = st_createEmptyPatternList();
}
}
}
result->candidates = st_createEmptyPatternList();
result->numLabels = numLabels;
result->supportLowerBound = supportLowerBound;
result->n=n;
result->k=kee;
st_validateState(result);
return result;
}
void st_insertPattern(st_miningState* state, st_tree* pattern, unsigned int num_embedded_edges, st_patternEmbedding* embedding) {
//after calling this function, pattern and embedding are either freed, or they occur
//once in state->candidates and `pattern->bestKnownRefcount` times in state->bestKnown.
/*
st_validateEmbedding(state->base, pattern, embedding);
//st_validateState(state);
printf("asked to insert this pattern:\n");
st_printTree(pattern, 0);
unsigned int numEmbeddings=0;
st_patternEmbedding* tmp = embedding;
while (tmp != NULL) {
numEmbeddings++;
tmp=tmp->next;
}
printf("has %u embeddings.\n", numEmbeddings);
*/
if (st_esupport(state->base, embedding) < state->supportLowerBound) {
st_freeTree(pattern);
//printf("free the candidate %p.\n", pattern);
st_recursiveFreeEmbedding(embedding);
return;
}
//if (numEmbeddings > 100000) numEmbeddings=( (st_tree*) NULL) -> num_children;
//printf("support bound passed.\n");
double estimate;
double entropy = st_econditionalEntropy(state->base, state->n, &estimate, embedding);
_Bool candidate=false;
st_patternEmbedding* emb;
unsigned int num_embeddings=0;
for (emb = embedding; emb != NULL; emb = emb->next) {
num_embeddings++;
//st_validateState(state);
st_patternList* bestKnown = state->bestKnown[emb->classIndex][emb->documentIndex][emb->sentenceIndex];
if (bestKnown->last != NULL && bestKnown ->last->pattern == pattern) continue;
/*
printf("iterate embedding in class %u, document %u, sentence %u.\n",emb->classIndex, emb->documentIndex, emb->sentenceIndex);
printf("entropy: %f, estimate: %f, cached: %f\n", entropy, estimate, bestKnown->cachedEntropy);
*/
_Bool insert=false;
if (bestKnown->length == 0) {
insert=true;
} else if (bestKnown->cachedEntropy > entropy) {
//st_deepCleanupList(bestKnown);
st_listedPattern* entry;
for (entry= bestKnown->first;entry!=NULL;) {
/*if (!st_isValidEmbedding(state->base, entry->pattern, entry->embedding)) {
embedding=entry->embedding;
printf("ERROR detected in embedding for class %u, document %u, sentence %u.\n", embedding->classIndex, embedding->documentIndex, embedding->sentenceIndex);
printf("pattern:\n");
st_printTree(entry->pattern,0);
printf("embedding:\n");
st_printTree(embedding->rightPath[0],0);
pattern = ((st_listedPattern*) NULL)->pattern;
}
if (entry->pattern->bestKnownRefcount == 0) {
printf("ERROR detected.\n");
pattern = ((st_listedPattern*) NULL)->pattern;
}*/
if (entry->pattern->bestKnownRefcount <= 1 && (entry->pattern->flags & TREEFLAG_CANDIDATE) == 0) {
st_freeTree(entry->pattern);
//printf("free the candidate %p.\n", entry->pattern);
st_recursiveFreeEmbedding(entry->embedding);
} else {
entry->pattern->bestKnownRefcount--;
}
entry=entry->succ;
st_patternListRemoveFirst(bestKnown);
//if (!st_isValidPatternList(state, bestKnown)) printf("ERROR detected after delete.\n");
}
insert=true;
} else if (bestKnown->cachedEntropy == entropy) {
insert=true;
} else if (bestKnown->cachedEntropy >= estimate) {
candidate=true;
}
//if (!st_isValidPatternList(state, bestKnown)) printf("ERROR detected before insert.\n");
if (insert) {
//if (pattern==NULL) pattern=st_expandPatternRight(oldPattern, position, label, embeddable);
/*printf("The pattern\n");
st_printTree(pattern, 0);
printf("is the best known for class %u, document %u, sentence %u.\n", emb->classIndex, emb->documentIndex, emb->sentenceIndex);*/
st_patternListInsertLast(bestKnown, pattern, num_embedded_edges,embedding);
//if (!st_isValidPatternList(state, bestKnown)) printf("ERROR detected after insert.\n");
bestKnown->cachedEntropy = entropy;
candidate=true;
pattern->bestKnownRefcount++;
}
//if (!st_isValidPatternList(state, bestKnown)) printf("ERROR detected before validation.\n");
//if (!st_isValidPatternList(state, state->candidates)) printf("ERROR detected in CANDIDATES.\n");
//st_validateState(state);
}
//printf("\n");
if (candidate) {
//if (pattern==NULL) pattern=st_expandPatternRight(oldPattern, position, label, embeddable);
/*
printf("We insert the following pattern:\n");
st_printTree(pattern, 0);
printf("entropy: %f, estimated: %f, embeddings: %u.\n", entropy, estimate, num_embeddings);
*/
st_patternListInsertLast(state->candidates, pattern, num_embedded_edges, embedding);
pattern->flags |= TREEFLAG_CANDIDATE;
//printf("insert the candidate %p.\n", pattern);
} else {
st_freeTree(pattern);
//printf("free the candidate (instead of insert) %p.\n", pattern);
st_recursiveFreeEmbedding(embedding);
}
//st_validateState(state);
}
void st_appendSingletonEmbeddings(st_tree* tree, st_label label,
unsigned int classIndex, unsigned int documentIndex, unsigned int sentenceIndex, st_patternEmbedding** embedding) {
if (tree->label == label) {
st_patternEmbedding* emb = getmem(sizeof(st_patternEmbedding));
emb->classIndex = classIndex;
emb->documentIndex = documentIndex;
emb->sentenceIndex = sentenceIndex;
emb->rightPath = getmem(sizeof(st_tree*));
emb->rightPath[0] = tree;
emb->next = *embedding;
*embedding=emb;
}
unsigned int i;
for (i=0; i<tree->num_children;i++) {
st_appendSingletonEmbeddings(tree->children[i], label, classIndex, documentIndex, sentenceIndex, embedding);
}
}
void st_insertSingletonCandidate(st_miningState* state, st_label label) {
st_tree* pattern = st_prepareTree(label,0);
pattern->flags |= TREEFLAG_EXTENDABLE_EDGE;
st_patternEmbedding* embedding = NULL;
int classIndex, documentIndex, sentenceIndex;
for (classIndex = state->base->num_classes-1; classIndex >= 0; classIndex--) {
st_documentclass* class = ((st_documentclass**)(state->base+1))[classIndex];
for (documentIndex = class->num_documents-1; documentIndex >= 0; documentIndex--) {
st_document* document = ((st_document**)(class+1))[documentIndex];
for (sentenceIndex = document->num_trees-1; sentenceIndex >= 0; sentenceIndex--) {
st_tree* tree = ((st_tree**)(document+1))[sentenceIndex];
st_appendSingletonEmbeddings(tree, label, classIndex, documentIndex, sentenceIndex, &embedding);
}
}
}
//st_patternListInsertLast(state->candidates, pattern, 0, embedding);
st_insertPattern(state, pattern, 0, embedding);
}
void st_populateMiningState(st_miningState* state) {
unsigned int i;
for (i=0; i<state->numLabels;i++) st_insertSingletonCandidate(state, i);
}
void st_freeMiningState(st_miningState* state) { // frees all beside state->base
st_listedPattern* listed;
for (listed=state->candidates->first;listed!=NULL;) {
if (listed->pattern->bestKnownRefcount == 0) {
//printf("free the candidate %p.\n", listed->pattern);
st_freeTree(listed->pattern);
st_recursiveFreeEmbedding(listed->embedding);
}
listed=listed->succ;
}
st_shallowFreeList(state->candidates);
unsigned int i,j,k;
for (i=0; i<state->base->num_classes; i++) {
st_documentclass* class = ((st_documentclass**) (state->base+1))[i];
st_patternList*** classBestKnown = state->bestKnown[i];
for (j=0; j<class->num_documents; j++) {
st_document* document = ((st_document**) (class+1))[j];
st_patternList** documentBestKnown =classBestKnown[j];
classBestKnown[j]=documentBestKnown;
for (k=0; k<document->num_trees; k++) {
//st_deepFreeList(documentBestKnown[k]);
st_patternList* list = documentBestKnown[k];
while (list->length > 0) {
st_tree* pattern = list->first->pattern;
if (pattern->bestKnownRefcount <= 1) {
st_freeTree(pattern);
//printf("free the candidate %p.\n", pattern);
st_recursiveFreeEmbedding(list->first->embedding);
} else {
pattern->bestKnownRefcount--;
}
st_patternListRemoveFirst(list);
}
freemem(list);
}
freemem(documentBestKnown);
}
freemem(classBestKnown);
}
freemem(state->bestKnown);
//st_deepFreeList(state->candidates);
freemem(state);
}
void st_expandEmbedding(st_tree* node, st_patternEmbedding* embedding, unsigned int position,
st_patternEmbedding** expandedEmbeddings, st_patternEmbedding** lastEmbedding, _Bool recursive) {
st_patternEmbedding* newEmbedding = getmem(sizeof(st_patternEmbedding));
newEmbedding->classIndex = embedding->classIndex;
newEmbedding->documentIndex = embedding->documentIndex;
newEmbedding->sentenceIndex = embedding->sentenceIndex;
newEmbedding->rightPath = getmem(sizeof(st_tree*) * (position+2));
memcpy(newEmbedding->rightPath, embedding->rightPath, sizeof(st_tree*) * (position+1));
newEmbedding->rightPath[position+1] = node;
/*newEmbedding->next = expandedEmbeddings[node->label];
expandedEmbeddings[node->label] = newEmbedding;*/
newEmbedding->next = NULL;
if (lastEmbedding[node->label] == NULL) {
lastEmbedding[node->label] = newEmbedding;
expandedEmbeddings[node->label] = newEmbedding;
} else {
lastEmbedding[node->label]->next = newEmbedding;
lastEmbedding[node->label] = newEmbedding;
}
if (recursive) {
unsigned int i;
for (i=0; i<node->num_children; i++) st_expandEmbedding(node->children[i], embedding, position, expandedEmbeddings, lastEmbedding, true);
}
}
void st_printEmbedding(st_patternEmbedding* embedding, unsigned int pathLength) {
while (embedding != NULL) {
printf("Embedding for class %u, document %u, sentence %u.\n", embedding->classIndex, embedding->documentIndex, embedding->sentenceIndex);
unsigned int i;
for (i=0; i<pathLength;i++) {
printf("rightPath[%u]:\n", i);
st_printTree(embedding->rightPath[i], 0);
}
printf("next:\n");
embedding=embedding->next;
}
printf("NULL.\n");
}
void st_expandPattern(st_miningState* state, st_tree* pattern, unsigned int num_embedded_edges, st_patternEmbedding* embedding,
unsigned int position, _Bool embeddable) {
//st_validateState(state);
//st_validateEmbedding(state->base, pattern, embedding);
//printf("expand this pattern with %u embedded edges at position %u (embeddable: %u):\n", num_embedded_edges, position, embeddable);
//st_printTree(pattern, 0);
st_patternEmbedding** expandedEmbeddings = getmem(sizeof(st_patternEmbedding*) * state->numLabels);
st_patternEmbedding** lastEmbedding = getmem(sizeof(st_patternEmbedding*) * state->numLabels);
unsigned int i;
for (i=0; i<state->numLabels; i++) {
expandedEmbeddings[i]=NULL;
lastEmbedding[i]=NULL;
}
st_patternEmbedding* emb;
_Bool isLeaf;
st_tree* node;
node=pattern;
for (i=0; i<position; i++) {
node=node->children[node->num_children-1];
}
isLeaf = (node->num_children == 0);
for (emb=embedding; emb != NULL; emb = emb->next) {
st_tree* node = emb->rightPath[position];
//printf("expand this embedding:\n");
//st_printTree(node, 0);
st_tree* waitChild = NULL;
if (!isLeaf) waitChild = emb->rightPath[position+1];
//iterate the children of emb->rightPath[position] which are right of emb->rightPath[position+1] (if this exists)
for (i=0; i<node->num_children; i++) {
if (waitChild != NULL) {
if (node->children[i] == waitChild) {
waitChild=NULL;
}
continue;
}
st_expandEmbedding(node->children[i], emb, position, expandedEmbeddings, lastEmbedding, embeddable);
/*
unsigned int j;
for (j=0; j<state->numLabels; j++) {
st_tree* expanded = st_expandPatternRight(pattern, position, j, embeddable);
if (!st_isValidEmbedding(state->base, expanded, expandedEmbeddings[j])) {
printf("ERROR: invalid expanded embedding for continuation %u.\n", j);
printf("expanded pattern:\n");
st_printTree(expanded,0);
printf("node:\n");
st_printTree(node, 0);
st_printEmbedding(expandedEmbeddings[j], position+2);
state = ((st_miningState**) NULL)[0];
}
st_freeTree(expanded);
}
*/
}
}
if (embeddable) num_embedded_edges++;
for (i=0; i<state->numLabels; i++) {
if (expandedEmbeddings[i] != NULL) {
st_tree* expanded = st_expandPatternRight(pattern, position, i, embeddable);
/*
if (!st_isValidPattern(state, expanded)) {
printf("ERROR: invalid expanded pattern.\n");
}
if (!st_isValidEmbedding(state->base, expanded, expandedEmbeddings[i])) {
printf("ERROR: invalid expanded embedding.\n");
}
*/
st_insertPattern(state, expanded, num_embedded_edges, expandedEmbeddings[i]);
}
}
freemem(expandedEmbeddings);
freemem(lastEmbedding);
}
_Bool st_indistinguishablePatterns(const st_patternEmbedding* embedding1, const st_patternEmbedding* embedding2) {
//two patterns are indistinguishable if they match exactly the same trees
unsigned int lc1=-1,ld1=-1,ls1=-1,lc2=-1,ld2=-1,ls2=-1;
while (true) {
if (embedding1 == NULL) return (embedding2 == 0);
if (embedding2 == NULL) return false;
if (embedding1->classIndex != embedding2->classIndex ||
embedding1->documentIndex != embedding2->documentIndex ||
embedding1->sentenceIndex != embedding2->sentenceIndex) return false;
lc1=embedding1->classIndex;
ld1=embedding1->documentIndex;
ls1=embedding1->sentenceIndex;
while (embedding1 != NULL && embedding1->classIndex == lc1 && embedding1->documentIndex == ld1 && embedding1->sentenceIndex == ls1) {
embedding1 = embedding1->next;
}
lc2=embedding2->classIndex;
ld2=embedding2->documentIndex;
ls2=embedding2->sentenceIndex;
while (embedding2 != NULL && embedding2->classIndex == lc2 && embedding2->documentIndex == ld2 && embedding2->sentenceIndex == ls2) {
embedding2 = embedding2->next;
}
}
}
_Bool st_doMiningIterations(st_miningState* state, unsigned int num_iterations) {
//returns true if these iterations were sufficient or false if there are candidates remaining
st_validateState(state);
unsigned int iter=0;
while (state->candidates->length > 0 && (num_iterations == -1 || num_iterations-- > 0)) {
//st_listedPattern* cand;
//for (cand = state->candidates->first; cand != NULL; cand = cand->succ) st_printTree(cand->pattern,0);
st_listedPattern* entry = state->candidates->first;
st_tree* pattern=entry->pattern;
//printf("consider this candidate pattern:\n");st_printTree(pattern,0);
st_patternEmbedding* embedding=entry->embedding;
if (num_iterations == -1) {
printf(".");
if (++iter == 100) {
printf("\n");
double entropy, estimate;
entropy=st_econditionalEntropy(state->base, state->n, &estimate, embedding);
printf("Remaining %d candidates, latest candidate has entropy %f (estimated %f).\n",
state->candidates->length, entropy, estimate);
st_printTree(pattern,0);
iter=0;
}
}
st_validateEmbedding(state->base, pattern, embedding);
unsigned int num_embedded_edges = entry->num_embedded_edges;
st_patternListRemoveFirst(state->candidates);
st_tree* node = pattern;
unsigned int position = 0;
while (true) {
st_expandPattern(state, pattern, num_embedded_edges, embedding, position, false);
if (num_embedded_edges < state->k) {
st_expandPattern(state, pattern, num_embedded_edges, embedding, position, true);
}
if (node->num_children == 0) break;
node=node->children[node->num_children-1];
position++;
}
pattern->flags &= ~TREEFLAG_CANDIDATE;
if (pattern->bestKnownRefcount == 0) {
st_freeTree(pattern);
//printf("free the candidate %p.\n", pattern);
st_recursiveFreeEmbedding(embedding);
}
}
return state->candidates->length==0;
}
st_patternList* st_getDiscriminativePatterns(st_miningState* state) {
//prereq: state must be fully mined.
unsigned int i,j,k;
st_patternList* result = st_createEmptyPatternList();
for (i=0; i<state->base->num_classes; i++) {
st_documentclass* class = ((st_documentclass**) (state->base+1))[i];
st_patternList*** classBestKnown = state->bestKnown[i];
for (j=0; j<class->num_documents; j++) {
st_document* document = ((st_document**) (class+1))[j];
st_patternList** documentBestKnown =classBestKnown[j];
classBestKnown[j]=documentBestKnown;
for (k=0; k<document->num_trees; k++) {
//st_deepFreeList(documentBestKnown[k]);
st_patternList* list = documentBestKnown[k];
st_listedPattern* entry;
for (entry = list->first; entry != NULL; entry = entry->succ) {
//search whether entry already occurs or is indistinguishable from an occuring pattern.
st_listedPattern* listed;
_Bool insert=true;
for (listed = result->first; listed != NULL; listed = listed->succ) {
if (entry->pattern == listed->pattern || st_indistinguishablePatterns(entry->embedding, listed->embedding)) {
insert=false;
break;
}
}
if ( insert ) {
st_patternListInsertLast(result, entry->pattern, entry->num_embedded_edges, entry->embedding);
}
}
}
}
}
return result;
}
st_patternList* st_mine(st_miningState* state) {
//printf("start mining...\n");
st_populateMiningState(state);
st_doMiningIterations(state, -1);
st_validateState(state);
/*
st_listedPattern* entry;
//printf("mined %u patterns.\n", result->length);
for (entry=result->first; entry != NULL; entry=entry->succ) {
entry->pattern->flags &= ~TREEFLAG_ALREADY_MENTIONED;
//st_printTree(entry->pattern, 0);
}
*/
return st_getDiscriminativePatterns(state);
}
unsigned int st_numCandidates(const st_miningState* state) {
return state->candidates->length;
}
void st_appendPatternList(st_patternList* list1, st_patternList* list2) {
//destroys list2 and appends its entries to list1
if (list1->length == 0) {
list1->first = list2->first;
list1->last = list2->last;
list1->length = list2->length;
} else if (list2->length != 0) {
list1->last->succ = list2->first;
list2->first->pred = list1->last;
list1->last = list2->last;
list1->length += list2->length;
}
freemem(list2);
}
typedef struct {
unsigned int num_substates;
st_miningState** substates;
} st_splitState;
st_miningState* st_extractSubstate(st_miningState* state, unsigned int startIndex, unsigned int length) {
st_miningState* result = getmem(sizeof(st_miningState));
unsigned int i,j,k;
result->base = state->base;
result->candidates = st_createEmptyPatternList();
st_listedPattern* listed = state->candidates->first;
for (i=0; i<startIndex;i++) {
listed = listed->succ;
}
for (i=0; i<length;i++) {
//if (listed->pattern->bestKnownRefcount>0) {
st_tree* pattern = listed->pattern;
pattern->copyUsedDuringSplitup = st_deepCopyTree(pattern);
//printf("copy %p to %p.\n", pattern, pattern->copyUsedDuringSplitup);
pattern->embeddingUsedDuringSplitup = st_copyPatternEmbedding(pattern,listed->embedding);
st_patternListInsertLast(result->candidates, pattern->copyUsedDuringSplitup, listed->num_embedded_edges, pattern->embeddingUsedDuringSplitup);
pattern->copyUsedDuringSplitup->original = pattern;
//}
listed = listed->succ;
}
result->bestKnown = getmem(sizeof(st_patternList***) * state->base->num_classes);
for (i=0; i<state->base->num_classes; i++) {
st_documentclass* class = ((st_documentclass**) (state->base+1))[i];
st_patternList*** classBestKnown = getmem(sizeof(st_patternList**) * class->num_documents);
result->bestKnown[i] = classBestKnown;
for (j=0; j<class->num_documents; j++) {
st_document* document = ((st_document**) (class+1))[j];
st_patternList** documentBestKnown = getmem(sizeof(st_patternList*) * document->num_trees);
classBestKnown[j]=documentBestKnown;
for (k=0; k<document->num_trees; k++) {
st_patternList* sentenceBestKnown = st_createEmptyPatternList();
documentBestKnown[k]=sentenceBestKnown;
st_patternList* stateBestKnown = state->bestKnown[i][j][k];
sentenceBestKnown->cachedEntropy = stateBestKnown->cachedEntropy;
st_listedPattern* listed;
for (listed = stateBestKnown->first;listed != NULL; listed=listed->succ) {
st_tree* pattern = listed->pattern;
if (pattern->copyUsedDuringSplitup == NULL) {
pattern->copyUsedDuringSplitup = st_deepCopyTree(pattern);
//printf("copy %p to %p.\n", pattern, pattern->copyUsedDuringSplitup);
pattern->copyUsedDuringSplitup->original = pattern;
pattern->copyUsedDuringSplitup->flags &= ~TREEFLAG_CANDIDATE;
pattern->embeddingUsedDuringSplitup = st_copyPatternEmbedding(pattern,listed->embedding);
}
st_patternListInsertLast(sentenceBestKnown, pattern->copyUsedDuringSplitup, listed->num_embedded_edges,
(st_patternEmbedding*) pattern->embeddingUsedDuringSplitup);
}
}
}
}
for (i=0; i<state->base->num_classes; i++) {
st_documentclass* class = ((st_documentclass**) (state->base+1))[i];
for (j=0; j<class->num_documents; j++) {
st_document* document = ((st_document**) (class+1))[j];
for (k=0; k<document->num_trees; k++) {
st_patternList* stateBestKnown = state->bestKnown[i][j][k];
st_listedPattern* listed;
for (listed = stateBestKnown->first;listed != NULL; listed=listed->succ) {
st_tree* pattern = listed->pattern;
pattern->copyUsedDuringSplitup=NULL;
pattern->embeddingUsedDuringSplitup=NULL;
}
}
}
}
for (listed=state->candidates->first;listed!=NULL;listed=listed->succ) {
listed->pattern->copyUsedDuringSplitup=NULL;
listed->pattern->embeddingUsedDuringSplitup=NULL;
}
result->numLabels = state->numLabels;
result->supportLowerBound = state->supportLowerBound;
result->n=state->n;
result->k=state->k;
st_validateState(result);
return result;
}
void st_debugState(st_miningState* state) {
printf("state for documentbase %p, %u candidates, %u labels. support lower bound: %u, n: %u, k: %u\n", state->base, state->candidates->length,
state->numLabels, state->supportLowerBound, state->n, state->k);
st_listedPattern* listed;
for (listed=state->candidates->first; listed!=NULL; listed=listed->succ) {
printf("%p (with flags %x) is a candidate.\n", listed->pattern, listed->pattern->flags);
}
unsigned int i,j,k;
for (i=0; i<state->base->num_classes; i++) {
const st_documentclass* class = ((st_documentclass**) (state->base+1))[i];
const st_patternList*** classBestKnown = (const st_patternList***) state->bestKnown[i];
for (j=0; j<class->num_documents; j++) {
const st_document* document = ((st_document**) (class+1))[j];
const st_patternList** documentBestKnown =(const st_patternList**) classBestKnown[j];
for (k=0; k<document->num_trees; k++) {
//st_deepFreeList(documentBestKnown[k]);
const st_patternList* list = (const st_patternList*) documentBestKnown[k];
printf("bestKnown[%u][%u][%u] has length %u.\n", i,j,k,list->length);
for (listed=list->first;listed!=NULL;listed=listed->succ) {
printf("%p (with flags %x) is a best known.\n", listed->pattern, listed->pattern->flags);
}
//printf("validated bestKnown of class %u, document %u, sentence %u.\n", i, j, k);
}
}
}
}
void st_miningStateStatistics(const st_miningState*, unsigned int*, unsigned int*);
st_splitState* st_splitupState(st_miningState* state, unsigned int num_substates) {
/*
unsigned int patterns,embeddings;
st_miningStateStatistics(state, &patterns, &embeddings);
printf("splitup state with %u patterns and %u embeddings.\n", patterns, embeddings);
*/
st_splitState* result = getmem(sizeof(st_splitState));
result->num_substates = num_substates;
result->substates = getmem(sizeof(st_miningState) * num_substates);
unsigned int cands = state->candidates->length;
unsigned int length = cands/num_substates;
unsigned int i;
//printf("%u candidates, create %u substates, length is %u.\n", cands, num_substates, length);
for (i=0; i<num_substates-1; i++) {
result->substates[i] = st_extractSubstate(state, i*length, length);
}
result->substates[num_substates-1] = st_extractSubstate(state, (num_substates-1)*length, cands-(num_substates-1)*length);
/*
for (i=0; i<num_substates;i++) {
st_miningState* state = result->substates[i];
printf("result->substates[%u]:\n", i);
st_debugState(state);
}
*/
return result;
}
_Bool st_doMiningIterationsInSplitState(st_splitState* states, unsigned int index, unsigned int iterations) {
return st_doMiningIterations(states->substates[index], iterations);
}
void st_tidyBestKnown(st_patternList* list) {
//removes entries such that each original-value occurs exactly once.
st_listedPattern* link1, *link2;
for (link1=list->first; link1!=NULL;link1=link1->succ) {
for (link2=link1->succ; link2!=NULL; ) {
if (link1->pattern->original == link2->pattern->original) {
if (link2->pattern->bestKnownRefcount-- <= 1) {
if ((link2->pattern->flags & TREEFLAG_CANDIDATE) == 0) {
st_freeTree(link2->pattern);
//printf("free the candidate %p\n", link2->pattern);
st_recursiveFreeEmbedding(link2->embedding);
}
}
st_listedPattern* tmp = link2->succ;
st_patternListRemoveListed(list, link2);
link2=tmp;
} else {
link2=link2->succ;
}
}
}
}
st_miningState* st_mergeStates(st_splitState* states) {
//destroys the input and returns a mining state by concatenating the candidates and collecting the best of bestKnown.
st_miningState* fst = states->substates[0];
st_miningState* result = st_createMiningState(fst->base, fst->numLabels, fst->supportLowerBound, fst->n, fst->k);
unsigned int i,j,k,index;
st_patternList**** classBestKnown = getmem(sizeof(st_patternList***) * states->num_substates);
st_patternList*** documentBestKnown = getmem(sizeof(st_patternList**) * states->num_substates);
st_patternList** sentenceBestKnown = getmem(sizeof(st_patternList*) * states->num_substates);
for (i=0; i<fst->base->num_classes; i++) {
st_documentclass* class = ((st_documentclass**) (fst->base+1))[i];
for (index=0; index<states->num_substates;index++) {
classBestKnown[index] = states->substates[index]->bestKnown[i];
}
for (j=0; j<class->num_documents; j++) {
st_document* document = ((st_document**) (class+1))[j];
for (index=0; index<states->num_substates;index++) {
documentBestKnown[index] = classBestKnown[index][j];
}
for (k=0; k<document->num_trees; k++) {
double minimalEntropy = -1;
for (index=0; index<states->num_substates;index++) {
sentenceBestKnown[index] = documentBestKnown[index][k];
double ent = sentenceBestKnown[index]->cachedEntropy;
if (minimalEntropy == -1 || (ent != -1 && ent < minimalEntropy)) minimalEntropy = ent;
}
st_patternList* resultBestKnown = result->bestKnown[i][j][k];
resultBestKnown->cachedEntropy = minimalEntropy;
for (index=0; index<states->num_substates;index++) {
st_patternList* lst = sentenceBestKnown[index];
if (lst->length == 0) continue;
if (lst->cachedEntropy == minimalEntropy) {
st_appendPatternList(resultBestKnown, lst);
st_tidyBestKnown(resultBestKnown);
} else {
//free the entries.
st_listedPattern* listed;
for (listed = lst->first; listed!=NULL;) {
st_tree* pattern = listed->pattern;
if (pattern->bestKnownRefcount-- <= 1) {
if ((pattern->flags & TREEFLAG_CANDIDATE) == 0) {
st_freeTree(pattern);
//printf("free the candidate %p.\n", pattern);
st_recursiveFreeEmbedding(listed->embedding);
}
}
listed=listed->succ;
st_patternListRemoveFirst(lst);
}
freemem(lst);
}
}
}
for (index=0; index<states->num_substates;index++) {
freemem(documentBestKnown[index]);
}
}
for (index=0; index<states->num_substates;index++) {
freemem(classBestKnown[index]);
}
}
for (index=0; index<states->num_substates;index++) {
st_miningState* state = states->substates[index];
freemem(state->bestKnown);
st_appendPatternList(result->candidates, state->candidates);
freemem(state);
}
freemem(classBestKnown);
freemem(documentBestKnown);
freemem(sentenceBestKnown);
freemem(states->substates);
freemem(states);
return result;
}
typedef struct {
st_miningState* state;
unsigned int iterations;
} st_miningInfo;
void* st_doMineFromInfo(void* arg) {
st_miningInfo* info = (st_miningInfo*) arg;
st_doMiningIterations(info->state, info->iterations);
return NULL;
}
void st_doParallelMiningIterations(st_splitState* states, unsigned int iterations) {
pthread_t* threads = getmem(sizeof(pthread_t) * states->num_substates);
st_miningInfo* info = getmem(sizeof(st_miningInfo) * states->num_substates);
unsigned int i;
for (i=0; i<states->num_substates;i++) {
info[i].state = states->substates[i];
info[i].iterations = iterations;
pthread_create(&(threads[i]), NULL, st_doMineFromInfo, info+i);
}
for (i=0; i<states->num_substates;i++) {
pthread_join(threads[i], NULL);
}
freemem(info);
freemem(threads);
}
void st_doNonparallelMiningIterations(st_splitState* states, unsigned int iterations) {
unsigned int i;
for (i=0; i<states->num_substates;i++) {
st_doMiningIterations(states->substates[i],iterations);
}
}
unsigned int st_lengthEmbedding(const st_patternEmbedding* embedding) {
unsigned int result=0;
while (embedding != NULL) {
result++;
embedding = embedding->next;
}
return result;
}
unsigned int st_treeSize(const st_tree* tree) {
unsigned int result=1,i;
for (i=0;i<tree->num_children;i++) {
result += st_treeSize(tree->children[i]);
}
return result;
}
void st_patternListStatistics(const st_patternList* list, unsigned int* patterns, unsigned int* embeddings) {
*patterns=0;
*embeddings=0;
const st_listedPattern* listed;
for (listed=list->first;listed!=NULL; listed=listed->succ) {
*patterns += st_treeSize(listed->pattern);
*embeddings += st_lengthEmbedding(listed->embedding);
}
}
void st_miningStateStatistics(const st_miningState* state, unsigned int* patterns, unsigned int* embeddings) {
unsigned int pats, embs;
st_patternListStatistics(state->candidates, patterns,embeddings);
unsigned int i,j,k;
for (i=0; i<state->base->num_classes; i++) {
st_documentclass* class = ((st_documentclass**) (state->base+1))[i];
st_patternList*** classBestKnown = state->bestKnown[i];
for (j=0; j<class->num_documents; j++) {
st_document* document = ((st_document**) (class+1))[j];
st_patternList** documentBestKnown =classBestKnown[j];
classBestKnown[j]=documentBestKnown;
for (k=0; k<document->num_trees; k++) {
//st_deepFreeList(documentBestKnown[k]);
st_patternListStatistics(documentBestKnown[k], &pats, &embs);
*patterns += pats;
*embeddings += embs;
}
}
}
}
void st_testFillArray(unsigned int length, char* array) {
while (length-- > 0) {
*(array++)=1;
}
}
void st_testPrintArray(unsigned int length, char* array) {
unsigned int i;
printf("array: ");
for (i=0; i<length; i++) {
if (i>0) {
printf(", ");
}
printf("%d",array[i]);
if (i>1000) break;
}
printf("\n");
}
typedef struct {
st_label label;
unsigned short int num_children;
short int flags;
} st_stored_tree;
unsigned int st_getSizeForTreeStorage(const st_tree* tree) {
return sizeof(st_stored_tree) * st_countNodes(tree);
}
void _st_storeTree(const st_tree* tree, st_stored_tree** memory) {
st_stored_tree* ptr = *memory;
ptr->label = tree->label;
ptr->num_children = tree->num_children;
ptr->flags = tree->flags & TREEFLAG_EXTENDABLE_EDGE;
(*memory)++;
unsigned int i;
for (i=0; i< tree->num_children;i++) {
_st_storeTree(tree->children[i], memory);
}
}
void st_storeTree(const st_tree* tree, st_stored_tree* memory) {
_st_storeTree(tree,&memory);
}
st_tree* _st_readTree(st_stored_tree** memory) {
st_stored_tree* ptr = *memory;
st_tree* tree = st_prepareTree(ptr->label, ptr->num_children);
tree->flags |= ptr->flags;
(*memory)++;
unsigned int i;
for (i=0; i< tree->num_children;i++) {
st_setTreeChild(tree,i,_st_readTree(memory));
}
return tree;
}
st_tree* st_readTree(st_stored_tree* memory) {
return _st_readTree(&memory);
}
int main(int argc, char* argv[]) {
st_tree* tree1 = st_prepareTree(0, 0);
st_tree* tree2 = st_prepareTree(1, 0);
st_tree* tree3 = st_prepareTree(2, 0);
st_tree* tree4 = st_prepareTree(3, 0);
st_document* doc1 = st_prepareDocument(1);
st_documentSetTree(doc1,0,tree1);
st_document* doc2 = st_prepareDocument(1);
st_documentSetTree(doc2,0,tree2);
st_document* doc3 = st_prepareDocument(1);
st_documentSetTree(doc3,0,tree3);
st_document* doc4 = st_prepareDocument(1);
st_documentSetTree(doc4,0,tree4);
st_documentclass* class1 = st_prepareDocumentClass(2);
st_setDocumentInClass(class1,0,doc1);
st_setDocumentInClass(class1,1,doc2);
st_documentclass* class2 = st_prepareDocumentClass(2);
st_setDocumentInClass(class2,0,doc3);
st_setDocumentInClass(class2,1,doc4);
st_documentbase* base = st_prepareDocumentBase(2);
st_setClassInDocumentBase(base,0,class1);
st_setClassInDocumentBase(base,1,class2);
st_completeDocumentBaseSetup(base);
printf("base: %p\n", base);
st_miningState* state = st_createMiningState(base, 4, 1, 10, 2);
printf("starting state:\n");
st_debugState(state);
st_populateMiningState(state);
printf("populated state:\n");
st_debugState(state);
while(state->candidates->length > 0) {
st_splitState* split = st_splitupState(state,2);
st_freeMiningState(state);
st_doParallelMiningIterations(split,1);
printf("after mining, state1:\n");
st_debugState(split->substates[0]);
printf("after mining, state2:\n");
st_debugState(split->substates[1]);
/*
st_freeMiningState(split->substates[0],false);
st_freeMiningState(split->substates[1],false);
free(split->substates);
free(split);
*/
state = st_mergeStates(split);
printf("merged:\n");
st_debugState(state);
}
st_patternList* list = st_getDiscriminativePatterns(state);
//st_patternList* list = st_mine(state);
st_listedPattern* entry;
for (entry=list->first; entry != NULL; entry=entry->succ) {
printf("We get the following discriminative pattern:\n");
st_printTree(entry->pattern, 0);
}
st_shallowFreeList(list);
st_freeMiningState(state);
/*
*/
st_freeDocumentBase(base);
st_freeDocumentClass(class1);
st_freeDocumentClass(class2);
st_shallowFreeDocument(doc1);
st_shallowFreeDocument(doc2);
st_shallowFreeDocument(doc3);
st_shallowFreeDocument(doc4);
st_shallowFreeTree(tree1);
st_shallowFreeTree(tree2);
st_shallowFreeTree(tree3);
st_shallowFreeTree(tree4);
showMemoryInformation();
return 0;
}
|
the_stack_data/126701896.c | #include<stdio.h>
int solution(int *A, int N)
{
int min=2147483647 ;
int max=-2147483648;
int sum;
for(int i=0;i<N;i++){
if(A[i]>max){
max=A[i];
}
}
for(int i=0;i<N;i++){
if(A[i]<min){
min=A[i];
}
}
sum=min + max;
return sum;
}
int main()
{
int N, i;
scanf("%d", &N);
int A[N];
for(i=0; i<N; i++) {
scanf("%d", &A[i]);
}
printf("%d", solution(A, N));
return 0;
}
|
the_stack_data/187641954.c | //YOUR CODE//
#include<stdio.h>
int isprime(int num)
{
// type your code here
int flag = 1;
for(int i = 2; i<= num; i++)
{
if(num % i== 0)
{
return 0;
flag = 1;
break;
}
}
if(flag == 0)
{
return 1;
}
}
int main()
{
int n, m, arr[100], size=0, i;
scanf("%d", &n);
for(m = 2; m <= n; m++)
{
if(isprime(m))
{
arr[size++]= m;
}
}
for(i = 0; i < size; i++)
{
printf("%d\n", arr[i]);
}
return 0;
} |
the_stack_data/73574128.c | /* Taxonomy Classification: 0000000100000154000010 */
/*
* WRITE/READ 0 write
* WHICH BOUND 0 upper
* DATA TYPE 0 char
* MEMORY LOCATION 0 stack
* SCOPE 0 same
* CONTAINER 0 no
* POINTER 0 no
* INDEX COMPLEXITY 1 variable
* ADDRESS COMPLEXITY 0 constant
* LENGTH COMPLEXITY 0 N/A
* ADDRESS ALIAS 0 none
* INDEX ALIAS 0 none
* LOCAL CONTROL FLOW 0 none
* SECONDARY CONTROL FLOW 1 if
* LOOP STRUCTURE 5 non-standard do-while
* LOOP COMPLEXITY 4 three
* ASYNCHRONY 0 no
* TAINT 0 no
* RUNTIME ENV. DEPENDENCE 0 no
* MAGNITUDE 0 no overflow
* CONTINUOUS/DISCRETE 1 continuous
* SIGNEDNESS 0 no
*/
/*
Copyright 2005 Massachusetts Institute of Technology
All rights reserved.
Redistribution and use of software 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 set of conditions and the disclaimer below.
- Redistributions in binary form must reproduce the copyright notice, this
set of conditions, and the disclaimer below in the documentation and/or
other materials provided with the distribution.
- Neither the name of the Massachusetts Institute of Technology 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".
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
int main(int argc, char *argv[])
{
int init_value;
int test_value;
int inc_value;
int loop_counter;
char buf[10];
init_value = 0;
test_value = 9;
inc_value = 9 - (9 - 1);
loop_counter = init_value;
do
{
/* OK */
buf[loop_counter] = 'A';
if (loop_counter >= test_value) break;
}
while(loop_counter += inc_value);
return 0;
}
|
the_stack_data/162643008.c | /* This file was generated by the MIG utility with:
mig /usr/include/mach/mach_exc.defs
We pre-generate them instead of generate them at compile-time because we
need to rename some of the functions to append _OVR so we don't get conflicts
with any other versions of these functions the application may have.
*/
/* Begin mach_excUser.c */
#if defined(__APPLE__)
#define __MIG_check__Reply__mach_exc_subsystem__ 1
#define __NDR_convert__Reply__mach_exc_subsystem__ 1
#define __NDR_convert__mig_reply_error_subsystem__ 1
#include "OVR_mach_exc_OSX.h"
#if defined(__cplusplus)
extern "C" {
#endif
#ifndef mig_internal
#define mig_internal static __inline__
#endif /* mig_internal */
#ifndef mig_external
#define mig_external
#endif /* mig_external */
#if !defined(__MigTypeCheck) && defined(TypeCheck)
#define __MigTypeCheck TypeCheck /* Legacy setting */
#endif /* !defined(__MigTypeCheck) */
#if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_)
#define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */
#endif /* !defined(__MigKernelSpecificCode) */
#ifndef LimitCheck
#define LimitCheck 0
#endif /* LimitCheck */
#ifndef min
#define min(a,b) ( ((a) < (b))? (a): (b) )
#endif /* min */
#if !defined(_WALIGN_)
#define _WALIGN_(x) (((x) + 3) & ~3)
#endif /* !defined(_WALIGN_) */
#if !defined(_WALIGNSZ_)
#define _WALIGNSZ_(x) _WALIGN_(sizeof(x))
#endif /* !defined(_WALIGNSZ_) */
#ifndef UseStaticTemplates
#define UseStaticTemplates 0
#endif /* UseStaticTemplates */
#ifndef __MachMsgErrorWithTimeout
#define __MachMsgErrorWithTimeout(_R_) { \
switch (_R_) { \
case MACH_SEND_INVALID_DATA: \
case MACH_SEND_INVALID_DEST: \
case MACH_SEND_INVALID_HEADER: \
mig_put_reply_port(InP->Head.msgh_reply_port); \
break; \
case MACH_SEND_TIMED_OUT: \
case MACH_RCV_TIMED_OUT: \
default: \
mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
} \
}
#endif /* __MachMsgErrorWithTimeout */
#ifndef __MachMsgErrorWithoutTimeout
#define __MachMsgErrorWithoutTimeout(_R_) { \
switch (_R_) { \
case MACH_SEND_INVALID_DATA: \
case MACH_SEND_INVALID_DEST: \
case MACH_SEND_INVALID_HEADER: \
mig_put_reply_port(InP->Head.msgh_reply_port); \
break; \
default: \
mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
} \
}
#endif /* __MachMsgErrorWithoutTimeout */
#ifndef __DeclareSendRpc
#define __DeclareSendRpc(_NUM_, _NAME_)
#endif /* __DeclareSendRpc */
#ifndef __BeforeSendRpc
#define __BeforeSendRpc(_NUM_, _NAME_)
#endif /* __BeforeSendRpc */
#ifndef __AfterSendRpc
#define __AfterSendRpc(_NUM_, _NAME_)
#endif /* __AfterSendRpc */
#ifndef __DeclareSendSimple
#define __DeclareSendSimple(_NUM_, _NAME_)
#endif /* __DeclareSendSimple */
#ifndef __BeforeSendSimple
#define __BeforeSendSimple(_NUM_, _NAME_)
#endif /* __BeforeSendSimple */
#ifndef __AfterSendSimple
#define __AfterSendSimple(_NUM_, _NAME_)
#endif /* __AfterSendSimple */
#ifndef msgh_request_port
#define msgh_request_port msgh_remote_port
#endif
#ifndef msgh_reply_port
#define msgh_reply_port msgh_local_port
#endif
#if ( __MigTypeCheck || __NDR_convert__ )
#if __MIG_check__Reply__mach_exc_subsystem__
#if !defined(__MIG_check__Reply__mach_exception_raise_t__defined)
#define __MIG_check__Reply__mach_exception_raise_t__defined
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode__defined
#if defined(__NDR_convert__int_rep__mach_exc__kern_return_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode(a, f) \
__NDR_convert__int_rep__mach_exc__kern_return_t((kern_return_t *)(a), f)
#elif defined(__NDR_convert__int_rep__kern_return_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode(a, f) \
__NDR_convert__int_rep__kern_return_t((kern_return_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode__defined */
mig_internal kern_return_t __MIG_check__Reply__mach_exception_raise_t_OVR(__Reply__mach_exception_raise_t *Out0P)
{
typedef __Reply__mach_exception_raise_t __Reply;
if (Out0P->Head.msgh_id != 2505) {
if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
{ return MIG_SERVER_DIED; }
else
{ return MIG_REPLY_MISMATCH; }
}
#if __MigTypeCheck
if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
(Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
{ return MIG_TYPE_ERROR ; }
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode__defined)
if (Out0P->NDR.int_rep != NDR_record.int_rep)
__NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode(&Out0P->RetCode, Out0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_t__RetCode__defined */
{
return Out0P->RetCode;
}
}
#endif /* !defined(__MIG_check__Reply__mach_exception_raise_t__defined) */
#endif /* __MIG_check__Reply__mach_exc_subsystem__ */
#endif /* ( __MigTypeCheck || __NDR_convert__ ) */
/* Routine mach_exception_raise_OVR */
mig_external kern_return_t mach_exception_raise_OVR
(
mach_port_t exception_port,
mach_port_t thread,
mach_port_t task,
exception_type_t exception,
mach_exception_data_t code,
mach_msg_type_number_t codeCnt
)
{
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
mach_msg_port_descriptor_t task;
/* end of the kernel processed data */
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
} Request;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_trailer_t trailer;
} Reply;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply;
#ifdef __MigPackStructs
#pragma pack()
#endif
/*
* typedef struct {
* mach_msg_header_t Head;
* NDR_record_t NDR;
* kern_return_t RetCode;
* } mig_reply_error_t;
*/
union {
Request In;
Reply Out;
} Mess;
Request *InP = &Mess.In;
Reply *Out0P = &Mess.Out;
mach_msg_return_t msg_result;
unsigned int msgh_size;
#ifdef __MIG_check__Reply__mach_exception_raise_t__defined
kern_return_t check_result;
#endif /* __MIG_check__Reply__mach_exception_raise_t__defined */
__DeclareSendRpc(2405, "mach_exception_raise_OVR")
#if UseStaticTemplates
const static mach_msg_port_descriptor_t threadTemplate = {
/* name = */ MACH_PORT_NULL,
/* pad1 = */ 0,
/* pad2 = */ 0,
/* disp = */ 19,
/* type = */ MACH_MSG_PORT_DESCRIPTOR,
};
#endif /* UseStaticTemplates */
#if UseStaticTemplates
const static mach_msg_port_descriptor_t taskTemplate = {
/* name = */ MACH_PORT_NULL,
/* pad1 = */ 0,
/* pad2 = */ 0,
/* disp = */ 19,
/* type = */ MACH_MSG_PORT_DESCRIPTOR,
};
#endif /* UseStaticTemplates */
InP->msgh_body.msgh_descriptor_count = 2;
#if UseStaticTemplates
InP->thread = threadTemplate;
InP->thread.name = thread;
#else /* UseStaticTemplates */
InP->thread.name = thread;
InP->thread.disposition = 19;
InP->thread.type = MACH_MSG_PORT_DESCRIPTOR;
#endif /* UseStaticTemplates */
#if UseStaticTemplates
InP->task = taskTemplate;
InP->task.name = task;
#else /* UseStaticTemplates */
InP->task.name = task;
InP->task.disposition = 19;
InP->task.type = MACH_MSG_PORT_DESCRIPTOR;
#endif /* UseStaticTemplates */
InP->NDR = NDR_record;
InP->exception = exception;
if (codeCnt > 2) {
{ return MIG_ARRAY_TOO_LARGE; }
}
(void)memcpy((char *) InP->code, (const char *) code, 8 * codeCnt);
InP->codeCnt = codeCnt;
msgh_size = (mach_msg_size_t)(sizeof(Request) - 16) + ((8 * codeCnt));
InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX|
MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
/* msgh_size passed as argument */
InP->Head.msgh_request_port = exception_port;
InP->Head.msgh_reply_port = mig_get_reply_port();
InP->Head.msgh_id = 2405;
__BeforeSendRpc(2405, "mach_exception_raise_OVR")
msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
__AfterSendRpc(2405, "mach_exception_raise_OVR")
if (msg_result != MACH_MSG_SUCCESS) {
__MachMsgErrorWithoutTimeout(msg_result);
{ return msg_result; }
}
#if defined(__MIG_check__Reply__mach_exception_raise_t__defined)
check_result = __MIG_check__Reply__mach_exception_raise_t_OVR((__Reply__mach_exception_raise_t *)Out0P);
if (check_result != MACH_MSG_SUCCESS)
{ return check_result; }
#endif /* defined(__MIG_check__Reply__mach_exception_raise_t__defined) */
return KERN_SUCCESS;
}
#if ( __MigTypeCheck || __NDR_convert__ )
#if __MIG_check__Reply__mach_exc_subsystem__
#if !defined(__MIG_check__Reply__mach_exception_raise_state_t__defined)
#define __MIG_check__Reply__mach_exception_raise_state_t__defined
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode__defined
#if defined(__NDR_convert__int_rep__mach_exc__kern_return_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode(a, f) \
__NDR_convert__int_rep__mach_exc__kern_return_t((kern_return_t *)(a), f)
#elif defined(__NDR_convert__int_rep__kern_return_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode(a, f) \
__NDR_convert__int_rep__kern_return_t((kern_return_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode__defined */
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined
#if defined(__NDR_convert__int_rep__mach_exc__int__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__int_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__int__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__int_rep__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int32_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__int_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__int_rep__int32_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__int_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined */
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined
#if defined(__NDR_convert__int_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__int_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__thread_state_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__int_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exc__natural_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__int_rep__natural_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__int_rep__natural_t)
#elif defined(__NDR_convert__int_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__int_rep__uint32_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__int_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined */
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt(a, f) \
__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt(a, f) \
__NDR_convert__int_rep__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt__defined */
#ifndef __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined
#if defined(__NDR_convert__char_rep__mach_exc__int__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__char_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__int__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__char_rep__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int32_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__char_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__char_rep__int32_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__char_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined */
#ifndef __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined
#if defined(__NDR_convert__char_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__char_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__thread_state_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__char_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exc__natural_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__char_rep__natural_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__char_rep__natural_t)
#elif defined(__NDR_convert__char_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__char_rep__uint32_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__char_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined */
#ifndef __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined
#if defined(__NDR_convert__float_rep__mach_exc__int__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__float_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__int__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__float_rep__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int32_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__float_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__float_rep__int32_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__float_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined */
#ifndef __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined
#if defined(__NDR_convert__float_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__float_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__thread_state_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__float_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exc__natural_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__float_rep__natural_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__float_rep__natural_t)
#elif defined(__NDR_convert__float_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__float_rep__uint32_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__float_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined */
mig_internal kern_return_t __MIG_check__Reply__mach_exception_raise_state_t_OVR(__Reply__mach_exception_raise_state_t *Out0P)
{
typedef __Reply__mach_exception_raise_state_t __Reply;
#if __MigTypeCheck
unsigned int msgh_size;
#endif /* __MigTypeCheck */
if (Out0P->Head.msgh_id != 2506) {
if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
{ return MIG_SERVER_DIED; }
else
{ return MIG_REPLY_MISMATCH; }
}
#if __MigTypeCheck
msgh_size = Out0P->Head.msgh_size;
if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
((msgh_size > (mach_msg_size_t)sizeof(__Reply) || msgh_size < (mach_msg_size_t)(sizeof(__Reply) - 576)) &&
(msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
Out0P->RetCode == KERN_SUCCESS)))
{ return MIG_TYPE_ERROR ; }
#endif /* __MigTypeCheck */
if (Out0P->RetCode != KERN_SUCCESS) {
#ifdef __NDR_convert__mig_reply_error_t__defined
__NDR_convert__mig_reply_error_t((mig_reply_error_t *)Out0P);
#endif /* __NDR_convert__mig_reply_error_t__defined */
return ((mig_reply_error_t *)Out0P)->RetCode;
}
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt__defined)
if (Out0P->NDR.int_rep != NDR_record.int_rep)
__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt(&Out0P->new_stateCnt, Out0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt__defined */
#if __MigTypeCheck
if ( Out0P->new_stateCnt > 144 )
return MIG_TYPE_ERROR;
if (((msgh_size - (mach_msg_size_t)(sizeof(__Reply) - 576)) / 4 != Out0P->new_stateCnt) ||
(msgh_size != (mach_msg_size_t)(sizeof(__Reply) - 576) + Out0P->new_stateCnt * 4))
{ return MIG_TYPE_ERROR ; }
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode__defined) || \
defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined) || \
defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined) || \
defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_stateCnt__defined)
if (Out0P->NDR.int_rep != NDR_record.int_rep) {
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode__defined)
__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode(&Out0P->RetCode, Out0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__RetCode__defined */
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined)
__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor(&Out0P->flavor, Out0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__flavor__defined */
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined)
__NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state(&Out0P->new_state, Out0P->NDR.int_rep, Out0P->new_stateCnt);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_t__new_state__defined */
}
#endif /* defined(__NDR_convert__int_rep...) */
#if 0 || \
defined(__NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined) || \
defined(__NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined) || \
0
if (Out0P->NDR.char_rep != NDR_record.char_rep) {
#if defined(__NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined)
__NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor(&Out0P->flavor, Out0P->NDR.char_rep);
#endif /* __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__flavor__defined */
#if defined(__NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined)
__NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state(&Out0P->new_state, Out0P->NDR.char_rep, Out0P->new_stateCnt);
#endif /* __NDR_convert__char_rep__Reply__mach_exception_raise_state_t__new_state__defined */
}
#endif /* defined(__NDR_convert__char_rep...) */
#if 0 || \
defined(__NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined) || \
defined(__NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined) || \
0
if (Out0P->NDR.float_rep != NDR_record.float_rep) {
#if defined(__NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined)
__NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor(&Out0P->flavor, Out0P->NDR.float_rep);
#endif /* __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__flavor__defined */
#if defined(__NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined)
__NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state(&Out0P->new_state, Out0P->NDR.float_rep, Out0P->new_stateCnt);
#endif /* __NDR_convert__float_rep__Reply__mach_exception_raise_state_t__new_state__defined */
}
#endif /* defined(__NDR_convert__float_rep...) */
return MACH_MSG_SUCCESS;
}
#endif /* !defined(__MIG_check__Reply__mach_exception_raise_state_t__defined) */
#endif /* __MIG_check__Reply__mach_exc_subsystem__ */
#endif /* ( __MigTypeCheck || __NDR_convert__ ) */
/* Routine mach_exception_raise_state_OVR */
mig_external kern_return_t mach_exception_raise_state_OVR
(
mach_port_t exception_port,
exception_type_t exception,
const mach_exception_data_t code,
mach_msg_type_number_t codeCnt,
int *flavor,
const thread_state_t old_state,
mach_msg_type_number_t old_stateCnt,
thread_state_t new_state,
mach_msg_type_number_t *new_stateCnt
)
{
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
int flavor;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[144];
} Request;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[144];
mach_msg_trailer_t trailer;
} Reply;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[144];
} __Reply;
#ifdef __MigPackStructs
#pragma pack()
#endif
/*
* typedef struct {
* mach_msg_header_t Head;
* NDR_record_t NDR;
* kern_return_t RetCode;
* } mig_reply_error_t;
*/
union {
Request In;
Reply Out;
} Mess;
Request *InP = &Mess.In;
Reply *Out0P = &Mess.Out;
mach_msg_return_t msg_result;
unsigned int msgh_size;
unsigned int msgh_size_delta;
#ifdef __MIG_check__Reply__mach_exception_raise_state_t__defined
kern_return_t check_result;
#endif /* __MIG_check__Reply__mach_exception_raise_state_t__defined */
__DeclareSendRpc(2406, "mach_exception_raise_state_OVR")
InP->NDR = NDR_record;
InP->exception = exception;
if (codeCnt > 2) {
{ return MIG_ARRAY_TOO_LARGE; }
}
(void)memcpy((char *) InP->code, (const char *) code, 8 * codeCnt);
InP->codeCnt = codeCnt;
msgh_size_delta = (8 * codeCnt);
msgh_size = (mach_msg_size_t)(sizeof(Request) - 592) + msgh_size_delta;
InP = (Request *) ((pointer_t) InP + msgh_size_delta - 16);
InP->flavor = *flavor;
if (old_stateCnt > 144) {
{ return MIG_ARRAY_TOO_LARGE; }
}
(void)memcpy((char *) InP->old_state, (const char *) old_state, 4 * old_stateCnt);
InP->old_stateCnt = old_stateCnt;
msgh_size += (4 * old_stateCnt);
InP = &Mess.In;
InP->Head.msgh_bits =
MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
/* msgh_size passed as argument */
InP->Head.msgh_request_port = exception_port;
InP->Head.msgh_reply_port = mig_get_reply_port();
InP->Head.msgh_id = 2406;
__BeforeSendRpc(2406, "mach_exception_raise_state_OVR")
msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
__AfterSendRpc(2406, "mach_exception_raise_state_OVR")
if (msg_result != MACH_MSG_SUCCESS) {
__MachMsgErrorWithoutTimeout(msg_result);
{ return msg_result; }
}
#if defined(__MIG_check__Reply__mach_exception_raise_state_t__defined)
check_result = __MIG_check__Reply__mach_exception_raise_state_t_OVR((__Reply__mach_exception_raise_state_t *)Out0P);
if (check_result != MACH_MSG_SUCCESS)
{ return check_result; }
#endif /* defined(__MIG_check__Reply__mach_exception_raise_state_t__defined) */
*flavor = Out0P->flavor;
if (Out0P->new_stateCnt > 144) {
(void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * 144);
*new_stateCnt = Out0P->new_stateCnt;
{ return MIG_ARRAY_TOO_LARGE; }
}
(void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * Out0P->new_stateCnt);
*new_stateCnt = Out0P->new_stateCnt;
return KERN_SUCCESS;
}
#if ( __MigTypeCheck || __NDR_convert__ )
#if __MIG_check__Reply__mach_exc_subsystem__
#if !defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined)
#define __MIG_check__Reply__mach_exception_raise_state_identity_t__defined
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode__defined
#if defined(__NDR_convert__int_rep__mach_exc__kern_return_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode(a, f) \
__NDR_convert__int_rep__mach_exc__kern_return_t((kern_return_t *)(a), f)
#elif defined(__NDR_convert__int_rep__kern_return_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode(a, f) \
__NDR_convert__int_rep__kern_return_t((kern_return_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode__defined */
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#if defined(__NDR_convert__int_rep__mach_exc__int__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__int_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__int__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__int_rep__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int32_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__int_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__int_rep__int32_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__int_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined */
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#if defined(__NDR_convert__int_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__int_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__thread_state_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__int_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exc__natural_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__int_rep__natural_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__int_rep__natural_t)
#elif defined(__NDR_convert__int_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__int_rep__uint32_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__int_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined */
#ifndef __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt(a, f) \
__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt__defined
#define __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt(a, f) \
__NDR_convert__int_rep__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt__defined */
#ifndef __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#if defined(__NDR_convert__char_rep__mach_exc__int__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__char_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__int__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__char_rep__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int32_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__char_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__char_rep__int32_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__char_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined */
#ifndef __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#if defined(__NDR_convert__char_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__char_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__thread_state_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__char_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exc__natural_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__char_rep__natural_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__char_rep__natural_t)
#elif defined(__NDR_convert__char_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__char_rep__uint32_t__defined)
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__char_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined */
#ifndef __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#if defined(__NDR_convert__float_rep__mach_exc__int__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__float_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__int__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__float_rep__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int32_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__float_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__float_rep__int32_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__float_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined */
#ifndef __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#if defined(__NDR_convert__float_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__float_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__thread_state_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__float_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exc__natural_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__float_rep__natural_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__float_rep__natural_t)
#elif defined(__NDR_convert__float_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__float_rep__uint32_t__defined)
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined
#define __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__float_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined */
mig_internal kern_return_t __MIG_check__Reply__mach_exception_raise_state_identity_t(__Reply__mach_exception_raise_state_identity_t *Out0P)
{
typedef __Reply__mach_exception_raise_state_identity_t __Reply;
#if __MigTypeCheck
unsigned int msgh_size;
#endif /* __MigTypeCheck */
if (Out0P->Head.msgh_id != 2507) {
if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
{ return MIG_SERVER_DIED; }
else
{ return MIG_REPLY_MISMATCH; }
}
#if __MigTypeCheck
msgh_size = Out0P->Head.msgh_size;
if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
((msgh_size > (mach_msg_size_t)sizeof(__Reply) || msgh_size < (mach_msg_size_t)(sizeof(__Reply) - 576)) &&
(msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
Out0P->RetCode == KERN_SUCCESS)))
{ return MIG_TYPE_ERROR ; }
#endif /* __MigTypeCheck */
if (Out0P->RetCode != KERN_SUCCESS) {
#ifdef __NDR_convert__mig_reply_error_t__defined
__NDR_convert__mig_reply_error_t((mig_reply_error_t *)Out0P);
#endif /* __NDR_convert__mig_reply_error_t__defined */
return ((mig_reply_error_t *)Out0P)->RetCode;
}
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt__defined)
if (Out0P->NDR.int_rep != NDR_record.int_rep)
__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt(&Out0P->new_stateCnt, Out0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt__defined */
#if __MigTypeCheck
if ( Out0P->new_stateCnt > 144 )
return MIG_TYPE_ERROR;
if (((msgh_size - (mach_msg_size_t)(sizeof(__Reply) - 576)) / 4 != Out0P->new_stateCnt) ||
(msgh_size != (mach_msg_size_t)(sizeof(__Reply) - 576) + Out0P->new_stateCnt * 4))
{ return MIG_TYPE_ERROR ; }
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode__defined) || \
defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined) || \
defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined) || \
defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_stateCnt__defined)
if (Out0P->NDR.int_rep != NDR_record.int_rep) {
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode__defined)
__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode(&Out0P->RetCode, Out0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__RetCode__defined */
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined)
__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor(&Out0P->flavor, Out0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined */
#if defined(__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined)
__NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state(&Out0P->new_state, Out0P->NDR.int_rep, Out0P->new_stateCnt);
#endif /* __NDR_convert__int_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined */
}
#endif /* defined(__NDR_convert__int_rep...) */
#if 0 || \
defined(__NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined) || \
defined(__NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined) || \
0
if (Out0P->NDR.char_rep != NDR_record.char_rep) {
#if defined(__NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined)
__NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor(&Out0P->flavor, Out0P->NDR.char_rep);
#endif /* __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined */
#if defined(__NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined)
__NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state(&Out0P->new_state, Out0P->NDR.char_rep, Out0P->new_stateCnt);
#endif /* __NDR_convert__char_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined */
}
#endif /* defined(__NDR_convert__char_rep...) */
#if 0 || \
defined(__NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined) || \
defined(__NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined) || \
0
if (Out0P->NDR.float_rep != NDR_record.float_rep) {
#if defined(__NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined)
__NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor(&Out0P->flavor, Out0P->NDR.float_rep);
#endif /* __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__flavor__defined */
#if defined(__NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined)
__NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state(&Out0P->new_state, Out0P->NDR.float_rep, Out0P->new_stateCnt);
#endif /* __NDR_convert__float_rep__Reply__mach_exception_raise_state_identity_t__new_state__defined */
}
#endif /* defined(__NDR_convert__float_rep...) */
return MACH_MSG_SUCCESS;
}
#endif /* !defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined) */
#endif /* __MIG_check__Reply__mach_exc_subsystem__ */
#endif /* ( __MigTypeCheck || __NDR_convert__ ) */
/* Routine mach_exception_raise_state_identity_OVR */
mig_external kern_return_t mach_exception_raise_state_identity_OVR
(
mach_port_t exception_port,
mach_port_t thread,
mach_port_t task,
exception_type_t exception,
mach_exception_data_t code,
mach_msg_type_number_t codeCnt,
int *flavor,
thread_state_t old_state,
mach_msg_type_number_t old_stateCnt,
thread_state_t new_state,
mach_msg_type_number_t *new_stateCnt
)
{
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
mach_msg_port_descriptor_t task;
/* end of the kernel processed data */
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
int flavor;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[144];
} Request;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[144];
mach_msg_trailer_t trailer;
} Reply;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[144];
} __Reply;
#ifdef __MigPackStructs
#pragma pack()
#endif
/*
* typedef struct {
* mach_msg_header_t Head;
* NDR_record_t NDR;
* kern_return_t RetCode;
* } mig_reply_error_t;
*/
union {
Request In;
Reply Out;
} Mess;
Request *InP = &Mess.In;
Reply *Out0P = &Mess.Out;
mach_msg_return_t msg_result;
unsigned int msgh_size;
unsigned int msgh_size_delta;
#ifdef __MIG_check__Reply__mach_exception_raise_state_identity_t__defined
kern_return_t check_result;
#endif /* __MIG_check__Reply__mach_exception_raise_state_identity_t__defined */
__DeclareSendRpc(2407, "mach_exception_raise_state_identity_OVR")
#if UseStaticTemplates
const static mach_msg_port_descriptor_t threadTemplate = {
/* name = */ MACH_PORT_NULL,
/* pad1 = */ 0,
/* pad2 = */ 0,
/* disp = */ 19,
/* type = */ MACH_MSG_PORT_DESCRIPTOR,
};
#endif /* UseStaticTemplates */
#if UseStaticTemplates
const static mach_msg_port_descriptor_t taskTemplate = {
/* name = */ MACH_PORT_NULL,
/* pad1 = */ 0,
/* pad2 = */ 0,
/* disp = */ 19,
/* type = */ MACH_MSG_PORT_DESCRIPTOR,
};
#endif /* UseStaticTemplates */
InP->msgh_body.msgh_descriptor_count = 2;
#if UseStaticTemplates
InP->thread = threadTemplate;
InP->thread.name = thread;
#else /* UseStaticTemplates */
InP->thread.name = thread;
InP->thread.disposition = 19;
InP->thread.type = MACH_MSG_PORT_DESCRIPTOR;
#endif /* UseStaticTemplates */
#if UseStaticTemplates
InP->task = taskTemplate;
InP->task.name = task;
#else /* UseStaticTemplates */
InP->task.name = task;
InP->task.disposition = 19;
InP->task.type = MACH_MSG_PORT_DESCRIPTOR;
#endif /* UseStaticTemplates */
InP->NDR = NDR_record;
InP->exception = exception;
if (codeCnt > 2) {
{ return MIG_ARRAY_TOO_LARGE; }
}
(void)memcpy((char *) InP->code, (const char *) code, 8 * codeCnt);
InP->codeCnt = codeCnt;
msgh_size_delta = (8 * codeCnt);
msgh_size = (mach_msg_size_t)(sizeof(Request) - 592) + msgh_size_delta;
InP = (Request *) ((pointer_t) InP + msgh_size_delta - 16);
InP->flavor = *flavor;
if (old_stateCnt > 144) {
{ return MIG_ARRAY_TOO_LARGE; }
}
(void)memcpy((char *) InP->old_state, (const char *) old_state, 4 * old_stateCnt);
InP->old_stateCnt = old_stateCnt;
msgh_size += (4 * old_stateCnt);
InP = &Mess.In;
InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX|
MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
/* msgh_size passed as argument */
InP->Head.msgh_request_port = exception_port;
InP->Head.msgh_reply_port = mig_get_reply_port();
InP->Head.msgh_id = 2407;
__BeforeSendRpc(2407, "mach_exception_raise_state_identity_OVR")
msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
__AfterSendRpc(2407, "mach_exception_raise_state_identity_OVR")
if (msg_result != MACH_MSG_SUCCESS) {
__MachMsgErrorWithoutTimeout(msg_result);
{ return msg_result; }
}
#if defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined)
check_result = __MIG_check__Reply__mach_exception_raise_state_identity_t((__Reply__mach_exception_raise_state_identity_t *)Out0P);
if (check_result != MACH_MSG_SUCCESS)
{ return check_result; }
#endif /* defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined) */
*flavor = Out0P->flavor;
if (Out0P->new_stateCnt > 144) {
(void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * 144);
*new_stateCnt = Out0P->new_stateCnt;
{ return MIG_ARRAY_TOO_LARGE; }
}
(void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * Out0P->new_stateCnt);
*new_stateCnt = Out0P->new_stateCnt;
return KERN_SUCCESS;
}
#if defined(__cplusplus)
} /* extern "C" */
#endif
/* End mach_excUser.c */
/* Begin mach_excServer.c */
/* Module mach_exc */
#define __MIG_check__Request__mach_exc_subsystem__ 1
#define __NDR_convert__Request__mach_exc_subsystem__ 1
#include <string.h>
#include <mach/ndr.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/notify.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/mig_errors.h>
#include <mach/port.h>
#include <mach/std_types.h>
#include <mach/mig.h>
#include <mach/mig.h>
#include <mach/mach_types.h>
#if defined(__cplusplus)
extern "C" {
#endif
#ifndef mig_internal
#define mig_internal static __inline__
#endif /* mig_internal */
#ifndef mig_external
#define mig_external
#endif /* mig_external */
#if !defined(__MigTypeCheck) && defined(TypeCheck)
#define __MigTypeCheck TypeCheck /* Legacy setting */
#endif /* !defined(__MigTypeCheck) */
#if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_)
#define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */
#endif /* !defined(__MigKernelSpecificCode) */
#ifndef LimitCheck
#define LimitCheck 0
#endif /* LimitCheck */
#ifndef min
#define min(a,b) ( ((a) < (b))? (a): (b) )
#endif /* min */
#if !defined(_WALIGN_)
#define _WALIGN_(x) (((x) + 3) & ~3)
#endif /* !defined(_WALIGN_) */
#if !defined(_WALIGNSZ_)
#define _WALIGNSZ_(x) _WALIGN_(sizeof(x))
#endif /* !defined(_WALIGNSZ_) */
#ifndef UseStaticTemplates
#define UseStaticTemplates 0
#endif /* UseStaticTemplates */
#ifndef __DeclareRcvRpc
#define __DeclareRcvRpc(_NUM_, _NAME_)
#endif /* __DeclareRcvRpc */
#ifndef __BeforeRcvRpc
#define __BeforeRcvRpc(_NUM_, _NAME_)
#endif /* __BeforeRcvRpc */
#ifndef __AfterRcvRpc
#define __AfterRcvRpc(_NUM_, _NAME_)
#endif /* __AfterRcvRpc */
#ifndef __DeclareRcvSimple
#define __DeclareRcvSimple(_NUM_, _NAME_)
#endif /* __DeclareRcvSimple */
#ifndef __BeforeRcvSimple
#define __BeforeRcvSimple(_NUM_, _NAME_)
#endif /* __BeforeRcvSimple */
#ifndef __AfterRcvSimple
#define __AfterRcvSimple(_NUM_, _NAME_)
#endif /* __AfterRcvSimple */
#define novalue void
#ifndef msgh_request_port
#define msgh_request_port msgh_local_port
#endif
#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits)
#ifndef msgh_reply_port
#define msgh_reply_port msgh_remote_port
#endif
#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits)
#define MIG_RETURN_ERROR(X, code) {\
((mig_reply_error_t *)X)->RetCode = code;\
((mig_reply_error_t *)X)->NDR = NDR_record;\
return;\
}
/* typedefs for all requests */
#ifndef __Request__mach_exc_subsystem__defined
#define __Request__mach_exc_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
mach_msg_port_descriptor_t task;
/* end of the kernel processed data */
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
} __Request__mach_exception_raise_t;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
int flavor;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[144];
} __Request__mach_exception_raise_state_t;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
mach_msg_port_descriptor_t task;
/* end of the kernel processed data */
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
int flavor;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[144];
} __Request__mach_exception_raise_state_identity_t;
#ifdef __MigPackStructs
#pragma pack()
#endif
#endif /* !__Request__mach_exc_subsystem__defined */
/* typedefs for all replies */
#ifndef __Reply__mach_exc_subsystem__defined
#define __Reply__mach_exc_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__mach_exception_raise_t;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[144];
} __Reply__mach_exception_raise_state_t;
#ifdef __MigPackStructs
#pragma pack()
#endif
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[144];
} __Reply__mach_exception_raise_state_identity_t;
#ifdef __MigPackStructs
#pragma pack()
#endif
#endif /* !__Reply__mach_exc_subsystem__defined */
/* union of all replies */
#ifndef __ReplyUnion__catch_mach_exc_subsystem__defined
#define __ReplyUnion__catch_mach_exc_subsystem__defined
union __ReplyUnion__catch_mach_exc_subsystem {
__Reply__mach_exception_raise_t Reply_mach_exception_raise;
__Reply__mach_exception_raise_state_t Reply_mach_exception_raise_state;
__Reply__mach_exception_raise_state_identity_t Reply_mach_exception_raise_state_identity;
};
#endif /* __RequestUnion__catch_mach_exc_subsystem__defined */
/* Forward Declarations */
mig_internal novalue _Xmach_exception_raise_OVR
(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
mig_internal novalue _Xmach_exception_raise_state_OVR
(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
mig_internal novalue _Xmach_exception_raise_state_identity_OVR
(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
#if ( __MigTypeCheck || __NDR_convert__ )
#if __MIG_check__Request__mach_exc_subsystem__
#if !defined(__MIG_check__Request__mach_exception_raise_t__defined)
#define __MIG_check__Request__mach_exception_raise_t__defined
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined
#if defined(__NDR_convert__int_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__int_rep__exception_type_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__int_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__int_rep__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__int_rep__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__int_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__int_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exception_data_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__int_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exc__int64_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__int_rep__int64_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__int_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt(a, f) \
__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt(a, f) \
__NDR_convert__int_rep__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined
#if defined(__NDR_convert__char_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__char_rep__exception_type_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__char_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__char_rep__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__char_rep__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__char_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined
#if defined(__NDR_convert__char_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__char_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exception_data_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__char_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exc__int64_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__char_rep__int64_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__char_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined
#if defined(__NDR_convert__float_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__float_rep__exception_type_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__float_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__float_rep__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__float_rep__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__exception(a, f) \
__NDR_convert__float_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined
#if defined(__NDR_convert__float_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__float_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exception_data_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__float_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exc__int64_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__float_rep__int64_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__float_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined */
mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_t_OVR(__attribute__((__unused__)) __Request__mach_exception_raise_t *In0P)
{
const size_t sizeofRequest = sizeof(__Request__mach_exception_raise_t);
typedef __Request__mach_exception_raise_t __Request;
#if __MigTypeCheck
unsigned int msgh_size;
#endif /* __MigTypeCheck */
#if __MigTypeCheck
msgh_size = In0P->Head.msgh_size;
if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
(In0P->msgh_body.msgh_descriptor_count != 2) ||
(msgh_size < (mach_msg_size_t)(sizeofRequest - 16)) || (msgh_size > (mach_msg_size_t)sizeofRequest))
return MIG_BAD_ARGUMENTS;
#endif /* __MigTypeCheck */
#if __MigTypeCheck
if (In0P->thread.type != MACH_MSG_PORT_DESCRIPTOR ||
In0P->thread.disposition != 17)
return MIG_TYPE_ERROR;
#endif /* __MigTypeCheck */
#if __MigTypeCheck
if (In0P->task.type != MACH_MSG_PORT_DESCRIPTOR ||
In0P->task.disposition != 17)
return MIG_TYPE_ERROR;
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined)
if (In0P->NDR.int_rep != NDR_record.int_rep)
__NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined */
#if __MigTypeCheck
if ( In0P->codeCnt > 2 )
return MIG_BAD_ARGUMENTS;
if (((msgh_size - (mach_msg_size_t)(sizeofRequest - 16)) / 8 != In0P->codeCnt) ||
(msgh_size != (mach_msg_size_t)(sizeofRequest - 16) + (8 * In0P->codeCnt)))
return MIG_BAD_ARGUMENTS;
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined)
if (In0P->NDR.int_rep != NDR_record.int_rep) {
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_t__exception(&In0P->exception, In0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_t__exception__defined */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_t__code(&In0P->code, In0P->NDR.int_rep, In0P->codeCnt);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_t__code__defined */
}
#endif /* defined(__NDR_convert__int_rep...) */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined) || \
defined(__NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined) || \
0
if (In0P->NDR.char_rep != NDR_record.char_rep) {
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_t__exception(&In0P->exception, In0P->NDR.char_rep);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_t__exception__defined */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_t__code(&In0P->code, In0P->NDR.char_rep, In0P->codeCnt);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_t__code__defined */
}
#endif /* defined(__NDR_convert__char_rep...) */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined) || \
defined(__NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined) || \
0
if (In0P->NDR.float_rep != NDR_record.float_rep) {
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_t__exception(&In0P->exception, In0P->NDR.float_rep);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_t__exception__defined */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_t__code(&In0P->code, In0P->NDR.float_rep, In0P->codeCnt);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_t__code__defined */
}
#endif /* defined(__NDR_convert__float_rep...) */
return MACH_MSG_SUCCESS;
}
#endif /* !defined(__MIG_check__Request__mach_exception_raise_t__defined) */
#endif /* __MIG_check__Request__mach_exc_subsystem__ */
#endif /* ( __MigTypeCheck || __NDR_convert__ ) */
/* Routine catch_mach_exception_raise_OVR */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t catch_mach_exception_raise_OVR
(
mach_port_t exception_port,
mach_port_t thread,
mach_port_t task,
exception_type_t exception,
mach_exception_data_t code,
mach_msg_type_number_t codeCnt
);
/* Routine _Xmach_exception_raise_OVR */
mig_internal novalue _Xmach_exception_raise_OVR
(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
{
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
mach_msg_port_descriptor_t task;
/* end of the kernel processed data */
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
mach_msg_trailer_t trailer;
} Request;
#ifdef __MigPackStructs
#pragma pack()
#endif
typedef __Request__mach_exception_raise_t __Request;
typedef __Reply__mach_exception_raise_t Reply;
/*
* typedef struct {
* mach_msg_header_t Head;
* NDR_record_t NDR;
* kern_return_t RetCode;
* } mig_reply_error_t;
*/
Request *In0P = (Request *) InHeadP;
Reply *OutP = (Reply *) OutHeadP;
#ifdef __MIG_check__Request__mach_exception_raise_t__defined
kern_return_t check_result;
#endif /* __MIG_check__Request__mach_exception_raise_t__defined */
__DeclareRcvRpc(2405, "mach_exception_raise_OVR")
__BeforeRcvRpc(2405, "mach_exception_raise_OVR")
#if defined(__MIG_check__Request__mach_exception_raise_t__defined)
check_result = __MIG_check__Request__mach_exception_raise_t_OVR((__Request *)In0P);
if (check_result != MACH_MSG_SUCCESS)
{ MIG_RETURN_ERROR(OutP, check_result); }
#endif /* defined(__MIG_check__Request__mach_exception_raise_t__defined) */
OutP->RetCode = catch_mach_exception_raise_OVR(In0P->Head.msgh_request_port, In0P->thread.name, In0P->task.name, In0P->exception, In0P->code, In0P->codeCnt);
OutP->NDR = NDR_record;
__AfterRcvRpc(2405, "mach_exception_raise_OVR")
}
#if ( __MigTypeCheck || __NDR_convert__ )
#if __MIG_check__Request__mach_exc_subsystem__
#if !defined(__MIG_check__Request__mach_exception_raise_state_t__defined)
#define __MIG_check__Request__mach_exception_raise_state_t__defined
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined
#if defined(__NDR_convert__int_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__int_rep__exception_type_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__int_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__int_rep__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__int_rep__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__int_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__int_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exception_data_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__int_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exc__int64_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__int_rep__int64_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__int_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt(a, f) \
__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt(a, f) \
__NDR_convert__int_rep__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined
#if defined(__NDR_convert__int_rep__mach_exc__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__int_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__int_rep__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__int_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__int_rep__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__int_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined
#if defined(__NDR_convert__int_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__int_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__thread_state_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__int_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exc__natural_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__int_rep__natural_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__int_rep__natural_t)
#elif defined(__NDR_convert__int_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__int_rep__uint32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__int_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt(a, f) \
__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt(a, f) \
__NDR_convert__int_rep__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined
#if defined(__NDR_convert__char_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__char_rep__exception_type_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__char_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__char_rep__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__char_rep__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__char_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined
#if defined(__NDR_convert__char_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__char_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exception_data_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__char_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exc__int64_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__char_rep__int64_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__char_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined
#if defined(__NDR_convert__char_rep__mach_exc__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__char_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__char_rep__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__char_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__char_rep__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__char_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined
#if defined(__NDR_convert__char_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__char_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__thread_state_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__char_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exc__natural_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__char_rep__natural_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__char_rep__natural_t)
#elif defined(__NDR_convert__char_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__char_rep__uint32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__char_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined
#if defined(__NDR_convert__float_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__float_rep__exception_type_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__float_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__float_rep__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__float_rep__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception(a, f) \
__NDR_convert__float_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined
#if defined(__NDR_convert__float_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__float_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exception_data_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__float_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exc__int64_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__float_rep__int64_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__float_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined
#if defined(__NDR_convert__float_rep__mach_exc__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__float_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__float_rep__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__float_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__float_rep__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor(a, f) \
__NDR_convert__float_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined
#if defined(__NDR_convert__float_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__float_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__thread_state_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__float_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exc__natural_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__float_rep__natural_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__float_rep__natural_t)
#elif defined(__NDR_convert__float_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__float_rep__uint32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__float_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined */
mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_state_t_OVR(__attribute__((__unused__)) __Request__mach_exception_raise_state_t *In0P, __attribute__((__unused__)) __Request__mach_exception_raise_state_t **In1PP)
{
typedef __Request__mach_exception_raise_state_t __Request;
__Request *In1P;
#if __MigTypeCheck
unsigned int msgh_size;
#endif /* __MigTypeCheck */
unsigned int msgh_size_delta;
#if __MigTypeCheck
msgh_size = In0P->Head.msgh_size;
if ((In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
(msgh_size < (mach_msg_size_t)(sizeof(__Request) - 592)) || (msgh_size > (mach_msg_size_t)sizeof(__Request)))
return MIG_BAD_ARGUMENTS;
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined)
if (In0P->NDR.int_rep != NDR_record.int_rep)
__NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined */
msgh_size_delta = (8 * In0P->codeCnt);
#if __MigTypeCheck
if ( In0P->codeCnt > 2 )
return MIG_BAD_ARGUMENTS;
if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 592)) / 8 < In0P->codeCnt) ||
(msgh_size < (mach_msg_size_t)(sizeof(__Request) - 592) + (8 * In0P->codeCnt)))
return MIG_BAD_ARGUMENTS;
msgh_size -= msgh_size_delta;
#endif /* __MigTypeCheck */
*In1PP = In1P = (__Request *) ((pointer_t) In0P + msgh_size_delta - 16);
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined)
if (In0P->NDR.int_rep != NDR_record.int_rep)
__NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt(&In1P->old_stateCnt, In1P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined */
#if __MigTypeCheck
if ( In1P->old_stateCnt > 144 )
return MIG_BAD_ARGUMENTS;
if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 592)) / 4 != In1P->old_stateCnt) ||
(msgh_size != (mach_msg_size_t)(sizeof(__Request) - 592) + (4 * In1P->old_stateCnt)))
return MIG_BAD_ARGUMENTS;
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined)
if (In0P->NDR.int_rep != NDR_record.int_rep) {
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception(&In0P->exception, In0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__exception__defined */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_state_t__code(&In0P->code, In0P->NDR.int_rep, In0P->codeCnt);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__code__defined */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor(&In1P->flavor, In0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__flavor__defined */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state(&In1P->old_state, In0P->NDR.int_rep, In1P->old_stateCnt);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_state__defined */
}
#endif /* defined(__NDR_convert__int_rep...) */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined) || \
defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined) || \
0 || \
defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined) || \
defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined) || \
0
if (In0P->NDR.char_rep != NDR_record.char_rep) {
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception(&In0P->exception, In0P->NDR.char_rep);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_t__exception__defined */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_state_t__code(&In0P->code, In0P->NDR.char_rep, In0P->codeCnt);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_t__code__defined */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor(&In1P->flavor, In0P->NDR.char_rep);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_t__flavor__defined */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state(&In1P->old_state, In0P->NDR.char_rep, In1P->old_stateCnt);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_t__old_state__defined */
}
#endif /* defined(__NDR_convert__char_rep...) */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined) || \
defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined) || \
0 || \
defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined) || \
defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined) || \
0
if (In0P->NDR.float_rep != NDR_record.float_rep) {
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception(&In0P->exception, In0P->NDR.float_rep);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_t__exception__defined */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_state_t__code(&In0P->code, In0P->NDR.float_rep, In0P->codeCnt);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_t__code__defined */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor(&In1P->flavor, In0P->NDR.float_rep);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_t__flavor__defined */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state(&In1P->old_state, In0P->NDR.float_rep, In1P->old_stateCnt);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_t__old_state__defined */
}
#endif /* defined(__NDR_convert__float_rep...) */
return MACH_MSG_SUCCESS;
}
#endif /* !defined(__MIG_check__Request__mach_exception_raise_state_t__defined) */
#endif /* __MIG_check__Request__mach_exc_subsystem__ */
#endif /* ( __MigTypeCheck || __NDR_convert__ ) */
/* Routine mach_exception_raise_state_OVR */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t catch_mach_exception_raise_state_OVR
(
mach_port_t exception_port,
exception_type_t exception,
const mach_exception_data_t code,
mach_msg_type_number_t codeCnt,
int *flavor,
const thread_state_t old_state,
mach_msg_type_number_t old_stateCnt,
thread_state_t new_state,
mach_msg_type_number_t *new_stateCnt
);
/* Routine _Xmach_exception_raise_state_OVR */
mig_internal novalue _Xmach_exception_raise_state_OVR
(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
{
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
int flavor;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[144];
mach_msg_trailer_t trailer;
} Request;
#ifdef __MigPackStructs
#pragma pack()
#endif
typedef __Request__mach_exception_raise_state_t __Request;
typedef __Reply__mach_exception_raise_state_t Reply;
/*
* typedef struct {
* mach_msg_header_t Head;
* NDR_record_t NDR;
* kern_return_t RetCode;
* } mig_reply_error_t;
*/
Request *In0P = (Request *) InHeadP;
Request *In1P;
Reply *OutP = (Reply *) OutHeadP;
#ifdef __MIG_check__Request__mach_exception_raise_state_t__defined
kern_return_t check_result;
#endif /* __MIG_check__Request__mach_exception_raise_state_t__defined */
__DeclareRcvRpc(2406, "mach_exception_raise_state_OVR")
__BeforeRcvRpc(2406, "mach_exception_raise_state_OVR")
#if defined(__MIG_check__Request__mach_exception_raise_state_t__defined)
check_result = __MIG_check__Request__mach_exception_raise_state_t_OVR((__Request *)In0P, (__Request **)&In1P);
if (check_result != MACH_MSG_SUCCESS)
{ MIG_RETURN_ERROR(OutP, check_result); }
#endif /* defined(__MIG_check__Request__mach_exception_raise_state_t__defined) */
OutP->new_stateCnt = 144;
OutP->RetCode = catch_mach_exception_raise_state_OVR(In0P->Head.msgh_request_port, In0P->exception, In0P->code, In0P->codeCnt, &In1P->flavor, In1P->old_state, In1P->old_stateCnt, OutP->new_state, &OutP->new_stateCnt);
if (OutP->RetCode != KERN_SUCCESS) {
MIG_RETURN_ERROR(OutP, OutP->RetCode);
}
OutP->NDR = NDR_record;
OutP->flavor = In1P->flavor;
OutP->Head.msgh_size = (mach_msg_size_t)(sizeof(Reply) - 576) + (((4 * OutP->new_stateCnt)));
__AfterRcvRpc(2406, "mach_exception_raise_state_OVR")
}
#if ( __MigTypeCheck || __NDR_convert__ )
#if __MIG_check__Request__mach_exc_subsystem__
#if !defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined)
#define __MIG_check__Request__mach_exception_raise_state_identity_t__defined
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#if defined(__NDR_convert__int_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__int_rep__exception_type_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__int_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__int_rep__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__int_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__int_rep__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__int_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__int_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exception_data_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__int_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exc__int64_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__int_rep__int64_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__int_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt(a, f) \
__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt(a, f) \
__NDR_convert__int_rep__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#if defined(__NDR_convert__int_rep__mach_exc__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__int_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__int__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__int_rep__int((int *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_exc__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__int_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__int_rep__int32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__int_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#if defined(__NDR_convert__int_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__int_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__thread_state_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__int_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__int_rep__mach_exc__natural_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__int_rep__natural_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__int_rep__natural_t)
#elif defined(__NDR_convert__int_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__int_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__int_rep__uint32_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__int_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined */
#ifndef __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined
#if defined(__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt(a, f) \
__NDR_convert__int_rep__mach_exc__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#elif defined(__NDR_convert__int_rep__mach_msg_type_number_t__defined)
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined
#define __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt(a, f) \
__NDR_convert__int_rep__mach_msg_type_number_t((mach_msg_type_number_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#if defined(__NDR_convert__char_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__char_rep__exception_type_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__char_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__char_rep__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__char_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__char_rep__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__char_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined
#if defined(__NDR_convert__char_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__char_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exception_data_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__char_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exc__int64_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__char_rep__int64_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__char_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#if defined(__NDR_convert__char_rep__mach_exc__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__char_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__int__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__char_rep__int((int *)(a), f)
#elif defined(__NDR_convert__char_rep__mach_exc__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__char_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__char_rep__int32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__char_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined */
#ifndef __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#if defined(__NDR_convert__char_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__char_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__thread_state_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__char_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__char_rep__mach_exc__natural_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__char_rep__natural_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__char_rep__natural_t)
#elif defined(__NDR_convert__char_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__char_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__char_rep__uint32_t__defined)
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__char_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#if defined(__NDR_convert__float_rep__mach_exc__exception_type_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__float_rep__exception_type_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__float_rep__exception_type_t((exception_type_t *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__float_rep__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__float_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__float_rep__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception(a, f) \
__NDR_convert__float_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined
#if defined(__NDR_convert__float_rep__mach_exc__mach_exception_data_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__float_rep__mach_exc__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exception_data_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__float_rep__mach_exception_data_t((mach_exception_data_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exc__int64_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__int64_t)
#elif defined(__NDR_convert__float_rep__int64_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code(a, f, c) \
__NDR_convert__ARRAY((int64_t *)(a), f, c, __NDR_convert__float_rep__int64_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#if defined(__NDR_convert__float_rep__mach_exc__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__float_rep__mach_exc__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__int__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__float_rep__int((int *)(a), f)
#elif defined(__NDR_convert__float_rep__mach_exc__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__float_rep__mach_exc__int32_t((int32_t *)(a), f)
#elif defined(__NDR_convert__float_rep__int32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor(a, f) \
__NDR_convert__float_rep__int32_t((int32_t *)(a), f)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined */
#ifndef __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#if defined(__NDR_convert__float_rep__mach_exc__thread_state_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__float_rep__mach_exc__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__thread_state_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__float_rep__thread_state_t((thread_state_t *)(a), f, c)
#elif defined(__NDR_convert__float_rep__mach_exc__natural_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__natural_t)
#elif defined(__NDR_convert__float_rep__natural_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((natural_t *)(a), f, c, __NDR_convert__float_rep__natural_t)
#elif defined(__NDR_convert__float_rep__mach_exc__uint32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__float_rep__mach_exc__uint32_t)
#elif defined(__NDR_convert__float_rep__uint32_t__defined)
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined
#define __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state(a, f, c) \
__NDR_convert__ARRAY((uint32_t *)(a), f, c, __NDR_convert__float_rep__uint32_t)
#endif /* defined(__NDR_convert__*__defined) */
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined */
mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_state_identity_t_OVR(__attribute__((__unused__)) __Request__mach_exception_raise_state_identity_t *In0P, __attribute__((__unused__)) __Request__mach_exception_raise_state_identity_t **In1PP)
{
const size_t sizeofRequest = sizeof(__Request__mach_exception_raise_state_identity_t);
typedef __Request__mach_exception_raise_state_identity_t __Request;
__Request *In1P;
#if __MigTypeCheck
unsigned int msgh_size;
#endif /* __MigTypeCheck */
unsigned int msgh_size_delta;
#if __MigTypeCheck
msgh_size = In0P->Head.msgh_size;
if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
(In0P->msgh_body.msgh_descriptor_count != 2) ||
(msgh_size < (mach_msg_size_t)(sizeofRequest - 592)) || (msgh_size > (mach_msg_size_t)sizeofRequest))
return MIG_BAD_ARGUMENTS;
#endif /* __MigTypeCheck */
#if __MigTypeCheck
if (In0P->thread.type != MACH_MSG_PORT_DESCRIPTOR ||
In0P->thread.disposition != 17)
return MIG_TYPE_ERROR;
#endif /* __MigTypeCheck */
#if __MigTypeCheck
if (In0P->task.type != MACH_MSG_PORT_DESCRIPTOR ||
In0P->task.disposition != 17)
return MIG_TYPE_ERROR;
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined)
if (In0P->NDR.int_rep != NDR_record.int_rep)
__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined */
msgh_size_delta = (8 * In0P->codeCnt);
#if __MigTypeCheck
if ( In0P->codeCnt > 2 )
return MIG_BAD_ARGUMENTS;
if (((msgh_size - (mach_msg_size_t)(sizeofRequest - 592)) / 8 < In0P->codeCnt) ||
(msgh_size < (mach_msg_size_t)(sizeofRequest - 592) + (8 * In0P->codeCnt)))
return MIG_BAD_ARGUMENTS;
msgh_size -= msgh_size_delta;
#endif /* __MigTypeCheck */
*In1PP = In1P = (__Request *) ((pointer_t) In0P + msgh_size_delta - 16);
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined)
if (In0P->NDR.int_rep != NDR_record.int_rep)
__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt(&In1P->old_stateCnt, In1P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined */
#if __MigTypeCheck
if ( In1P->old_stateCnt > 144 )
return MIG_BAD_ARGUMENTS;
if (((msgh_size - (mach_msg_size_t)(sizeofRequest - 592)) / 4 != In1P->old_stateCnt) ||
(msgh_size != (mach_msg_size_t)(sizeofRequest - 592) + (4 * In1P->old_stateCnt)))
return MIG_BAD_ARGUMENTS;
#endif /* __MigTypeCheck */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined) || \
defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined)
if (In0P->NDR.int_rep != NDR_record.int_rep) {
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception(&In0P->exception, In0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__exception__defined */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code(&In0P->code, In0P->NDR.int_rep, In0P->codeCnt);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__code__defined */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor(&In1P->flavor, In0P->NDR.int_rep);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__flavor__defined */
#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined)
__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state(&In1P->old_state, In0P->NDR.int_rep, In1P->old_stateCnt);
#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_state__defined */
}
#endif /* defined(__NDR_convert__int_rep...) */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined) || \
defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined) || \
0 || \
defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined) || \
defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined) || \
0
if (In0P->NDR.char_rep != NDR_record.char_rep) {
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception(&In0P->exception, In0P->NDR.char_rep);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__exception__defined */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code(&In0P->code, In0P->NDR.char_rep, In0P->codeCnt);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__code__defined */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor(&In1P->flavor, In0P->NDR.char_rep);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__flavor__defined */
#if defined(__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined)
__NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state(&In1P->old_state, In0P->NDR.char_rep, In1P->old_stateCnt);
#endif /* __NDR_convert__char_rep__Request__mach_exception_raise_state_identity_t__old_state__defined */
}
#endif /* defined(__NDR_convert__char_rep...) */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined) || \
defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined) || \
0 || \
defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined) || \
defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined) || \
0
if (In0P->NDR.float_rep != NDR_record.float_rep) {
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception(&In0P->exception, In0P->NDR.float_rep);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__exception__defined */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code(&In0P->code, In0P->NDR.float_rep, In0P->codeCnt);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__code__defined */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor(&In1P->flavor, In0P->NDR.float_rep);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__flavor__defined */
#if defined(__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined)
__NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state(&In1P->old_state, In0P->NDR.float_rep, In1P->old_stateCnt);
#endif /* __NDR_convert__float_rep__Request__mach_exception_raise_state_identity_t__old_state__defined */
}
#endif /* defined(__NDR_convert__float_rep...) */
return MACH_MSG_SUCCESS;
}
#endif /* !defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) */
#endif /* __MIG_check__Request__mach_exc_subsystem__ */
#endif /* ( __MigTypeCheck || __NDR_convert__ ) */
/* Routine catch_mach_exception_raise_state_identity_OVR */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t catch_mach_exception_raise_state_identity_OVR
(
mach_port_t exception_port,
mach_port_t thread,
mach_port_t task,
exception_type_t exception,
mach_exception_data_t code,
mach_msg_type_number_t codeCnt,
int *flavor,
thread_state_t old_state,
mach_msg_type_number_t old_stateCnt,
thread_state_t new_state,
mach_msg_type_number_t *new_stateCnt
);
/* Routine mach_exception_raise_state_identity_OVR */
mig_internal novalue _Xmach_exception_raise_state_identity_OVR
(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
{
#ifdef __MigPackStructs
#pragma pack(4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
mach_msg_port_descriptor_t task;
/* end of the kernel processed data */
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
int64_t code[2];
int flavor;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[144];
mach_msg_trailer_t trailer;
} Request;
#ifdef __MigPackStructs
#pragma pack()
#endif
typedef __Request__mach_exception_raise_state_identity_t __Request;
typedef __Reply__mach_exception_raise_state_identity_t Reply;
/*
* typedef struct {
* mach_msg_header_t Head;
* NDR_record_t NDR;
* kern_return_t RetCode;
* } mig_reply_error_t;
*/
Request *In0P = (Request *) InHeadP;
Request *In1P;
Reply *OutP = (Reply *) OutHeadP;
#ifdef __MIG_check__Request__mach_exception_raise_state_identity_t__defined
kern_return_t check_result;
#endif /* __MIG_check__Request__mach_exception_raise_state_identity_t__defined */
__DeclareRcvRpc(2407, "mach_exception_raise_state_identity_OVR")
__BeforeRcvRpc(2407, "mach_exception_raise_state_identity_OVR")
#if defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined)
check_result = __MIG_check__Request__mach_exception_raise_state_identity_t_OVR((__Request *)In0P, (__Request **)&In1P);
if (check_result != MACH_MSG_SUCCESS)
{ MIG_RETURN_ERROR(OutP, check_result); }
#endif /* defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) */
OutP->new_stateCnt = 144;
OutP->RetCode = catch_mach_exception_raise_state_identity_OVR(In0P->Head.msgh_request_port, In0P->thread.name, In0P->task.name, In0P->exception, In0P->code, In0P->codeCnt, &In1P->flavor, In1P->old_state, In1P->old_stateCnt, OutP->new_state, &OutP->new_stateCnt);
if (OutP->RetCode != KERN_SUCCESS) {
MIG_RETURN_ERROR(OutP, OutP->RetCode);
}
OutP->NDR = NDR_record;
OutP->flavor = In1P->flavor;
OutP->Head.msgh_size = (mach_msg_size_t)(sizeof(Reply) - 576) + (((4 * OutP->new_stateCnt)));
__AfterRcvRpc(2407, "mach_exception_raise_state_identity_OVR")
}
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
boolean_t mach_exc_server_OVR(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP);
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
mig_routine_t mach_exc_server_routine_OVR(mach_msg_header_t *InHeadP);
/* Description of this subsystem, for use in direct RPC */
const struct catch_mach_exc_subsystem_OVR {
mig_server_routine_t server; /* Server routine */
mach_msg_id_t start; /* Min routine number */
mach_msg_id_t end; /* Max routine number + 1 */
unsigned int maxsize; /* Max msg size */
vm_address_t reserved; /* Reserved */
struct routine_descriptor /*Array of routine descriptors */
routine[3];
} catch_mach_exc_subsystem_OVR = {
mach_exc_server_routine_OVR,
2405,
2408,
(mach_msg_size_t)sizeof(union __ReplyUnion__catch_mach_exc_subsystem),
(vm_address_t)0,
{
{ (mig_impl_routine_t) 0,
(mig_stub_routine_t) _Xmach_exception_raise_OVR, 6, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_t)},
{ (mig_impl_routine_t) 0,
(mig_stub_routine_t) _Xmach_exception_raise_state_OVR, 9, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_state_t)},
{ (mig_impl_routine_t) 0,
(mig_stub_routine_t) _Xmach_exception_raise_state_identity_OVR, 11, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_state_identity_t)},
}
};
mig_external boolean_t mach_exc_server_OVR
(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
{
/*
* typedef struct {
* mach_msg_header_t Head;
* NDR_record_t NDR;
* kern_return_t RetCode;
* } mig_reply_error_t;
*/
register mig_routine_t routine;
OutHeadP->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InHeadP->msgh_bits), 0);
OutHeadP->msgh_remote_port = InHeadP->msgh_reply_port;
/* Minimal size: routine() will update it if different */
OutHeadP->msgh_size = (mach_msg_size_t)sizeof(mig_reply_error_t);
OutHeadP->msgh_local_port = MACH_PORT_NULL;
OutHeadP->msgh_id = InHeadP->msgh_id + 100;
if ((InHeadP->msgh_id > 2407) || (InHeadP->msgh_id < 2405) ||
((routine = catch_mach_exc_subsystem_OVR.routine[InHeadP->msgh_id - 2405].stub_routine) == 0))
{
((mig_reply_error_t *)OutHeadP)->NDR = NDR_record;
((mig_reply_error_t *)OutHeadP)->RetCode = MIG_BAD_ID;
return FALSE;
}
(*routine) (InHeadP, OutHeadP);
return TRUE;
}
mig_external mig_routine_t mach_exc_server_routine_OVR
(mach_msg_header_t *InHeadP)
{
register int msgh_id;
msgh_id = InHeadP->msgh_id - 2405;
if ((msgh_id > 2) || (msgh_id < 0))
return 0;
return catch_mach_exc_subsystem_OVR.routine[msgh_id].stub_routine;
}
#if defined(__cplusplus)
} /* extern "C" */
#endif
/* End mach_excServer.c */
#elif defined(_MSC_VER)
#pragma warning(disable: 4206) // nonstandard extension used : translation unit is empty
#endif // __APPLE__
|
the_stack_data/90762516.c | #include <stdio.h>
#define LOWER 0 /* lower limit of table */
#define UPPER 300 /* upper limit */
#define STEP 20 /* step size */
/* print Fahrenheit-Celsius table */
main()
{
int fahr;
for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP)
printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
}
|
the_stack_data/37638568.c | //Autor: Matheus de Sousa Matos
//Curso: Engenharia de Software
//Período: 6º Semestre
//Matrícula: UC19104412
#include <stdio.h>
#include <stdlib.h>
#define TAM 10
int main(){
int v[TAM]= {1,2,3,4,5,6,7,8,9,10};
soma(v);
}
void soma(int v[TAM]){
int somatoria = NULL;
for (int i = 0; i < TAM; i++)
{
somatoria = somatoria + v[i];
}
printf("somatoria: %d", somatoria);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.