file
stringlengths
18
26
data
stringlengths
2
1.05M
the_stack_data/95449759.c
#include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; #ifdef _MSC_VER static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} #else static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #endif #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #ifdef _MSC_VER #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);} #else #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #endif #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimagf(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #ifdef _MSC_VER static _Fcomplex cpow_ui(complex x, integer n) { complex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i; for(u = n; ; ) { if(u & 01) pow.r *= x.r, pow.i *= x.i; if(u >>= 1) x.r *= x.r, x.i *= x.i; else break; } } _Fcomplex p={pow.r, pow.i}; return p; } #else static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif #ifdef _MSC_VER static _Dcomplex zpow_ui(_Dcomplex x, integer n) { _Dcomplex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1]; for(u = n; ; ) { if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1]; if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1]; else break; } } _Dcomplex p = {pow._Val[0], pow._Val[1]}; return p; } #else static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* > \brief \b ZLAPMR rearranges rows of a matrix as specified by a permutation vector. */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download ZLAPMR + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlapmr. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlapmr. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlapmr. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE ZLAPMR( FORWRD, M, N, X, LDX, K ) */ /* LOGICAL FORWRD */ /* INTEGER LDX, M, N */ /* INTEGER K( * ) */ /* COMPLEX*16 X( LDX, * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > ZLAPMR rearranges the rows of the M by N matrix X as specified */ /* > by the permutation K(1),K(2),...,K(M) of the integers 1,...,M. */ /* > If FORWRD = .TRUE., forward permutation: */ /* > */ /* > X(K(I),*) is moved X(I,*) for I = 1,2,...,M. */ /* > */ /* > If FORWRD = .FALSE., backward permutation: */ /* > */ /* > X(I,*) is moved to X(K(I),*) for I = 1,2,...,M. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] FORWRD */ /* > \verbatim */ /* > FORWRD is LOGICAL */ /* > = .TRUE., forward permutation */ /* > = .FALSE., backward permutation */ /* > \endverbatim */ /* > */ /* > \param[in] M */ /* > \verbatim */ /* > M is INTEGER */ /* > The number of rows of the matrix X. M >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The number of columns of the matrix X. N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] X */ /* > \verbatim */ /* > X is COMPLEX*16 array, dimension (LDX,N) */ /* > On entry, the M by N matrix X. */ /* > On exit, X contains the permuted matrix X. */ /* > \endverbatim */ /* > */ /* > \param[in] LDX */ /* > \verbatim */ /* > LDX is INTEGER */ /* > The leading dimension of the array X, LDX >= MAX(1,M). */ /* > \endverbatim */ /* > */ /* > \param[in,out] K */ /* > \verbatim */ /* > K is INTEGER array, dimension (M) */ /* > On entry, K contains the permutation vector. K is used as */ /* > internal workspace, but reset to its original value on */ /* > output. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup complex16OTHERauxiliary */ /* ===================================================================== */ /* Subroutine */ int zlapmr_(logical *forwrd, integer *m, integer *n, doublecomplex *x, integer *ldx, integer *k) { /* System generated locals */ integer x_dim1, x_offset, i__1, i__2, i__3, i__4; /* Local variables */ doublecomplex temp; integer i__, j, jj, in; /* -- LAPACK auxiliary routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Parameter adjustments */ x_dim1 = *ldx; x_offset = 1 + x_dim1 * 1; x -= x_offset; --k; /* Function Body */ if (*m <= 1) { return 0; } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { k[i__] = -k[i__]; /* L10: */ } if (*forwrd) { /* Forward permutation */ i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { if (k[i__] > 0) { goto L40; } j = i__; k[j] = -k[j]; in = k[j]; L20: if (k[in] > 0) { goto L40; } i__2 = *n; for (jj = 1; jj <= i__2; ++jj) { i__3 = j + jj * x_dim1; temp.r = x[i__3].r, temp.i = x[i__3].i; i__3 = j + jj * x_dim1; i__4 = in + jj * x_dim1; x[i__3].r = x[i__4].r, x[i__3].i = x[i__4].i; i__3 = in + jj * x_dim1; x[i__3].r = temp.r, x[i__3].i = temp.i; /* L30: */ } k[in] = -k[in]; j = in; in = k[in]; goto L20; L40: /* L50: */ ; } } else { /* Backward permutation */ i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { if (k[i__] > 0) { goto L80; } k[i__] = -k[i__]; j = k[i__]; L60: if (j == i__) { goto L80; } i__2 = *n; for (jj = 1; jj <= i__2; ++jj) { i__3 = i__ + jj * x_dim1; temp.r = x[i__3].r, temp.i = x[i__3].i; i__3 = i__ + jj * x_dim1; i__4 = j + jj * x_dim1; x[i__3].r = x[i__4].r, x[i__3].i = x[i__4].i; i__3 = j + jj * x_dim1; x[i__3].r = temp.r, x[i__3].i = temp.i; /* L70: */ } k[j] = -k[j]; j = k[j]; goto L60; L80: /* L90: */ ; } } return 0; /* End of ZLAPMT */ } /* zlapmr_ */
the_stack_data/120751.c
#include<stdio.h> int main() { int i,n,k[120],j,x; int avg,a=1; while(scanf("%d", &n) && n) { j = 0; for(i=0; i<n; i++) { scanf("%d", &k[i]); j += k[i]; } avg = j/n; x = 0; for(i=0; i<n; i++) { if(k[i]>avg) { x+=(k[i]-avg); } } printf("Set #%d\nThe minimum number of moves is %d.\n\n",a,x); a++; } return 0; }
the_stack_data/646990.c
/* * $PROFITABLE_MOVES: 0 */ #define READ(v_) tmp = v_ #define WRITE(v_) v_ = 1 int war_1; int war_2; int main(void) { int tmp; READ(war_1); WRITE(war_1); // Dependency, no move war_2 = war_1; READ(war_2); WRITE(war_2); return tmp; }
the_stack_data/1135019.c
/* * (C) Copyright 2005- ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ #if defined(__GNUC__) || defined(__PGI) /* pthread_attr_init() interception to reset guard region size between thread stacks, by S.Saarinen, 30-Sep-2016 */ /* See : man pthread_attr_init A custom pthread_attr_init() mainly to control the memory "gap" or protected "guard size" between slave threads Slave threads allocate memory from the heap -- only master thread allocates from (genuine) stack Guard region is usually very small and it is possible that a slave thread may (accidentally) overwrite to the adjacent slave threads memory arena. By setting the guard size big enough, usually a few MiB suffice, then an overwrite could hit this protected memory area easier triggering usually a SIGSEGV. The traceback that follows usually shows the code location and allows to fix the issue for good. To set the guard size use : export EC_THREAD_GUARDSIZE=<value>[G|M|K] Caveat: Some MPI drivers may not like this -- check especially the Mellanox HPC-X/OpenMPI */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <signal.h> #include <sys/types.h> #include <sys/time.h> #include <unistd.h> #include <limits.h> #include <errno.h> #include <time.h> #include <pthread.h> #include <dlfcn.h> #include <sys/types.h> #undef RNDUP_DIV #define RNDUP_DIV(i,n) (( (i) + (n) - 1 ) / (n)) #undef RNDUP #define RNDUP(i,n) ( RNDUP_DIV(i,n) * (n)) #if defined(RTLD_NEXT) #define PTR_LIBC RTLD_NEXT #else #define PTR_LIBC ((void*) -1L) #endif static int (*ptr_pthread_attr_init)(pthread_attr_t *attr) = NULL; int pthread_attr_init(pthread_attr_t *attr) { int rc; static int done = 0; FILE *fp = NULL; extern int ec_mpirank(), ec_gettid(); // ec_env.c int me = ec_mpirank(); // Could be called before the MPI_Init*() or w/o presence of MPI (i.e. rank 0) pid_t pid = getpid(); pid_t tid = ec_gettid(); int master = (pid == tid) ? 1 : 0; if (!ptr_pthread_attr_init) { ptr_pthread_attr_init = (int (*)(pthread_attr_t *a))dlsym(PTR_LIBC, "pthread_attr_init"); if (!ptr_pthread_attr_init) { fprintf(stderr,"***Error: Dynamic linking to pthread_attr_init() failed : errno = %d\n",errno); abort(); } /* We intend to output only from MPI-task 0, master thread */ if (!done && me == 0 && master) fp = stderr; done = 1; } rc = ptr_pthread_attr_init(attr); { char *env_gs = getenv("EC_THREAD_GUARDSIZE"); if (!env_gs) env_gs = getenv("THREAD_GUARDSIZE"); // Compatibility if (env_gs) { size_t pgsize = getpagesize(); size_t guardsize = atoll(env_gs); if (strchr(env_gs,'G')) guardsize *= 1073741824; /* hence, in GiB */ else if (strchr(env_gs,'M')) guardsize *= 1048576; /* hence, in MiB */ else if (strchr(env_gs,'K')) guardsize *= 1024; /* hence, in KiB */ guardsize = RNDUP(guardsize,pgsize); if (guardsize > pgsize) { /* Now we *DO* bother */ char *env_omp = getenv("OMP_STACKSIZE"); size_t omp_stacksize = env_omp ? atoll(env_omp) : 0; size_t stacksize = 0; int iret = pthread_attr_getstacksize(attr,&stacksize); #if 1 if (fp) fprintf(fp, "[%s@%s:%d] [pid=%ld:tid=%ld]: Requesting guard region size " "between thread stacks : %lld bytes (%s PAGESIZE = %ld)\n", __FUNCTION__,__FILE__,__LINE__, (long int)pid,(long int)tid, (long long int)guardsize, (guardsize > pgsize) ? ">" : "<=", (long)pgsize); #endif if (env_omp) { if (strchr(env_omp,'G')) omp_stacksize *= 1073741824; /* hence, in GiB */ else if (strchr(env_omp,'M')) omp_stacksize *= 1048576; /* hence, in MiB */ else if (strchr(env_omp,'K')) omp_stacksize *= 1024; /* hence, in KiB */ } if (fp) fprintf(fp, "[%s@%s:%d] [pid=%ld:tid=%ld]: Stack size(s) : %lld bytes (def), %lld bytes (OMP) : [iret=%d]\n", __FUNCTION__,__FILE__,__LINE__, (long int)pid,(long int)tid, (long long int)stacksize, (long long int)omp_stacksize, iret); if (iret == 0 && omp_stacksize > guardsize) { iret = pthread_attr_setguardsize(attr,guardsize); (void) pthread_attr_getguardsize(attr,&guardsize); if (fp) fprintf(fp, "[%s@%s:%d] [pid=%ld:tid=%ld]: Guard region size now : %lld bytes : [iret=%d]\n", __FUNCTION__,__FILE__,__LINE__, (long int)pid,(long int)tid, (long long int)guardsize,iret); } } } } if (fp) fflush(fp); return rc; } #endif /* defined(__GNUC__) || defined(__PGI) */
the_stack_data/405519.c
#include <stdio.h> int main() { char input[64]; int ch; int x = 0; printf("Type in LOW CAPS: "); fgets(input, 63, stdin); while(input[x] != '\n') { ch = input[x] & 223; putchar(ch); x++; } putchar('\n'); return(0); }
the_stack_data/84479.c
#include <stdio.h> #include <stdbool.h> int ligasao(int *saldo,int tmp) { ///variavel local int custo = 10; if (*saldo < custo *tmp) { return printf("Seu saldo é insuficiente\n"); }else{ *saldo += -(custo *tmp); return printf("Voce efetuou uma ligação de %d min por um valor de %d reais por minuto,ficou em %d Reais.\n Seu saldo atual de: %d\n",tmp,custo,tmp*custo,*saldo); } } int sms(int *saldo) { //variavel local int custoSms = 5; if (*saldo < custoSms) { ///variavel local return printf("Seu saldo é insuficiente\n"); }else{ *saldo += -custoSms; return printf("mandou um sms no valor de %d para mandar uma mensagem.\n Seu saldo atual é de: %d\n",custoSms, *saldo); } } int main(void) { ///variavel local int saldo = 50; printf("Seu Saldo Inicial: %d\n", saldo); ////////////// começa a gastar kkkk ///////// ligasao(&saldo,3);// primeiro numero saldo que vai descontar && segundo digito é tempo sms(&saldo);// somente o saldo para descontar ///////////////////////////////////////////// printf("Seu Saldo Final: %d\n", saldo); }
the_stack_data/203267.c
/* プログラミング講習会 */ #include <stdio.h> int main(void){ int counter = 10; printf("count down\n"); while(1){ /* 条件が真(True)の時に以下を実行 */ /* breakはループを脱出する */ if(counter < 0) break; printf("%d\n", counter); counter = counter - 1; } return 0; }
the_stack_data/43679.c
#include<stdio.h> int main(){ int s0,s1,t0,t1; printf("digite a distancia inicial em metros\n"); scanf("%d",&s0); printf("digite a distancia final em metros\n"); scanf("%d",&s1); printf("digite o tempo inicial em segundos\n"); scanf("%d",&t0); printf("digite o tempo final em segundos\n"); scanf("%d",&t1); printf("a velocidade media do objeto e %d metros/segundo\n",(s1-s0)/(t1-t0)); }
the_stack_data/70449356.c
// Program to find su of even numbers until n // date : 4 december 2020 #include <stdio.h> int main() { // variable declarations int n, summationEven = 0; // taking input7 printf("Enter the value for n "); scanf("%d", &n); // logic for (int i = 2; i <= n; i += 2) { summationEven += i; } // printing output printf(" The sum of all even numbers till %d is %d ", n, summationEven); return 0; }
the_stack_data/57949651.c
#include <stdio.h> #include <string.h> #include <stdlib.h> /* * Strips spaces from both the front and back of a string, * leaving any internal spaces alone. */ char* strip(char* str) { int size; int num_spaces; int first_non_space, last_non_space, i; char* result; size = strlen(str); // This counts the number of leading and trailing spaces // so we can figure out how big the result array should be. num_spaces = 0; first_non_space = 0; while (first_non_space<size && str[first_non_space] == ' ') { ++num_spaces; ++first_non_space; } last_non_space = size-1; while (last_non_space>=0 && str[last_non_space] == ' ') { ++num_spaces; --last_non_space; } // If num_spaces >= size then that means that the string // consisted of nothing but spaces, so we'll return the // empty string. if (num_spaces >= size) { return ""; } // Allocate a slot for all the "saved" characters // plus one extra for the null terminator. result = calloc(size-num_spaces+1, sizeof(char)); // Copy in the "saved" characters. for (i=first_non_space; i<=last_non_space; ++i) { result[i-first_non_space] = str[i]; } // Place the null terminator at the end of the result string. result[i-first_non_space] = '\0'; return result; } /* * Return true (1) if the given string is "clean", i.e., has * no spaces at the front or the back of the string. */ int is_clean(char* str) { char* cleaned; int result; // We check if it's clean by calling strip and seeing if the // result is the same as the original string. cleaned = strip(str); // strcmp compares two strings, returning a negative value if // the first is less than the second (in alphabetical order), // 0 if they're equal, and a positive value if the first is // greater than the second. result = strcmp(str, cleaned); if(strlen(cleaned) > 0) { free(cleaned); } return result == 0; } int main() { int i; int NUM_STRINGS = 7; // Makes an array of 7 string constants for testing. char* strings[] = { "Morris", " stuff", "Minnesota", "nonsense ", "USA", " ", " silliness " }; for (i=0; i<NUM_STRINGS; ++i) { if (is_clean(strings[i])) { printf("The string '%s' is clean.\n", strings[i]); } else { printf("The string '%s' is NOT clean.\n", strings[i]); } } return 0; }
the_stack_data/165766012.c
#include <stdio.h> int fib(int n) { if (n < 2) return n; return fib(n - 2) + fib(n - 1); } int main() { printf("%d\n", fib(38)); }
the_stack_data/72013766.c
#include <stdlib.h> # define x 23 void * utl_calloc ( const size_t num, const size_t size ) { void *newblock = NULL; newblock = calloc(num, size); # return newblock; }
the_stack_data/43888394.c
void keep(int *p) { *p = 0; } void kill(int *p, int i) { if (i && 0) *p = 0; } void dead(int *p, int i) { int v = i++; if (i && 0) p[v] = 0; } /* * check-name: kill-store * check-command: test-linearize -Wno-decl $file * check-description: * Check that stores are optimized away but only * when needed: * - bb unreachable. * * check-output-ignore * check-output-pattern-1-times: store\\. */
the_stack_data/193894139.c
/* Copyright (C) 2008-2016 Ryan Klingler. An example illustrating how C indexes work. */ #include <stdio.h> int main(void) { if ( "what"[0] == *("what" + 0) ) printf("Pass 1\n"); if ( "what"[0] == *(0 + "what") ) printf("Pass 2\n"); if ( 0["what"] == *("what" + 0) ) printf("Pass 3\n"); if ( 0["what"] == *(0 + "what") ) printf("Pass 4\n"); if ( 0["what"] == 'w' ) printf("Pass 5\n"); if ( "what"[0] == 0["what"] ) printf("Pass 6\n"); if ( *("what" + 1) == *(1 + "what") ) printf("Pass 7\n"); return 0; }
the_stack_data/154284.c
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <math.h> #include <sys/time.h> #include <omp.h> /* * C = [n, q] = A[n, m] * B[m, q] */ enum { N = 10000, M = 10000, Q = 10000, NREPS = 3, }; double wtime() { struct timeval t; gettimeofday(&t, NULL); return (double)t.tv_sec + (double)t.tv_usec * 1E-6; } /* Matrix multiplication C[n, q] = A[n, m] * B[m, q] */ void sgemm_phi(float *a, float *b, float *c, int n, int m, int q) { #pragma offload target(mic) in(a:length(n * m)) in(b:length(m * q)) out(c:length(n * q)) { #pragma omp parallel { int k = 0; #pragma omp for for (int i = 0; i < n; i++) for (int j = 0; j < q; j++) c[k++] = 0.0; #pragma omp for for (int i = 0; i < n; i++) { for (int k = 0; k < m; k++) { for (int j = 0; j < q; j++) c[i * q + j] += a[i * m + k] * b[k * q + j]; } } } } } double run_phi(const char *msg, void (*sgemm_fun)(float *, float *, float *, int, int, int)) { double gflop = 2.0 * N * Q * M * 1E-9; float *a, *b, *c; a = _mm_malloc(sizeof(*a) * N * M, 4096); b = _mm_malloc(sizeof(*b) * M * Q, 4096); c = _mm_malloc(sizeof(*c) * N * Q, 4096); if (a == NULL || b == NULL || c == NULL) { fprintf(stderr, "No enough memory\n"); exit(EXIT_FAILURE); } srand(0); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) a[i * M + j] = rand() % 100; // 1.0; } for (int i = 0; i < M; i++) { for (int j = 0; j < Q; j++) b[i * Q + j] = rand() % 100; // 2.0; } /* Warmup */ double twarmup = wtime(); sgemm_fun(a, b, c, N, M, Q); twarmup = wtime() - twarmup; /* Measures */ double tavg = 0.0; double tmin = 1E6; double tmax = 0.0; for (int i = 0; i < NREPS; i++) { double t = wtime(); sgemm_fun(a, b, c, N, M, Q); t = wtime() - t; tavg += t; tmin = (tmin > t) ? t : tmin; tmax = (tmax < t) ? t : tmax; } tavg /= NREPS; printf("%s (%d runs): perf %.2f GFLOPS; time: tavg %.6f, tmin %.6f, tmax %.6f, twarmup %.6f\n", msg, NREPS, gflop / tavg, tavg, tmin, tmax, twarmup); _mm_free(c); _mm_free(b); _mm_free(a); return tavg; } int main(int argc, char **argv) { printf("SGEMM N = %d, M = %d, Q = %d\n", N, M, Q); char buf[256]; sprintf(buf, "Phi OMP %s", getenv("MIC_OMP_NUM_THREADS")); run_phi(buf, &sgemm_phi); return 0; }
the_stack_data/4632.c
/*---------------------------------------------------------------------------* * <RCS keywords> * * C++ Library * * Copyright 1992-1994, David Gottner * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice, this permission notice and * the following disclaimer notice appear unmodified in all copies. * * I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL I * BE LIABLE FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Nevertheless, I would like to know about bugs in this library or * suggestions for improvment. Send bug reports and feedback to * [email protected]. *---------------------------------------------------------------------------*/ /* Modified to support --help and --version, as well as /? on Windows * by Georg Brandl. */ #include <stdio.h> #include <string.h> #ifdef __cplusplus extern "C" { #endif int _PyOS_opterr = 1; /* generate error messages */ int _PyOS_optind = 1; /* index into argv array */ char *_PyOS_optarg = NULL; /* optional argument */ int _PyOS_GetOpt(int argc, char **argv, char *optstring) { static char *opt_ptr = ""; char *ptr; int option; if (*opt_ptr == '\0') { if (_PyOS_optind >= argc) return -1; #ifdef MS_WINDOWS else if (strcmp(argv[_PyOS_optind], "/?") == 0) { ++_PyOS_optind; return 'h'; } #endif else if (argv[_PyOS_optind][0] != '-' || argv[_PyOS_optind][1] == '\0' /* lone dash */ ) return -1; else if (strcmp(argv[_PyOS_optind], "--") == 0) { ++_PyOS_optind; return -1; } else if (strcmp(argv[_PyOS_optind], "--help") == 0) { ++_PyOS_optind; return 'h'; } else if (strcmp(argv[_PyOS_optind], "--version") == 0) { ++_PyOS_optind; return 'V'; } opt_ptr = &argv[_PyOS_optind++][1]; } if ( (option = *opt_ptr++) == '\0') return -1; if (option == 'J') { fprintf(stderr, "-J is reserved for Jython\n"); return '_'; } if (option == 'X') { fprintf(stderr, "-X is reserved for implementation-specific arguments\n"); return '_'; } if ((ptr = strchr(optstring, option)) == NULL) { if (_PyOS_opterr) fprintf(stderr, "Unknown option: -%c\n", option); return '_'; } /* The * modifier says that this option _can_ take an argument, but not necessarily (unlike :, which requires the argument). If no argument was passed, _PyOS_optarg will be \0. The * modifier requires the option's argument to be cuddled up to the flag, for example: -O2 is legal, -O 2 is not. */ if (*(ptr + 1) == '*') { _PyOS_optarg = opt_ptr; opt_ptr = ""; } else if (*(ptr + 1) == ':') { if (*opt_ptr != '\0') { _PyOS_optarg = opt_ptr; opt_ptr = ""; } else { if (_PyOS_optind >= argc) { if (_PyOS_opterr) fprintf(stderr, "Argument expected for the -%c option\n", option); return '_'; } _PyOS_optarg = argv[_PyOS_optind++]; } } return option; } #ifdef __cplusplus } #endif
the_stack_data/87636904.c
/* * This file is part of the libohiboard project. * * Copyright (C) 2018-2019 A. C. Open Hardware Ideas Lab * * Authors: * Marco Giammarini <[email protected]> * Leonardo Morichelli <[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/STM32L4/spi_STM32L4.c * @author Marco Giammarini <[email protected]> * @author Leonardo Morichelli <[email protected]> * @brief SPI implementations for STM32L4 Series. */ #ifdef LIBOHIBOARD_SPI #ifdef __cplusplus extern "C" { #endif #include "spi.h" #include "platforms.h" #include "utility.h" #include "gpio.h" #include "clock.h" #if defined (LIBOHIBOARD_STM32L4) /** * @brief Enable the SPI peripheral */ #define SPI_DEVICE_ENABLE(REGMAP) (REGMAP->CR1 |= SPI_CR1_SPE) /** * @brief Disable the SPI peripheral */ #define SPI_DEVICE_DISABLE(REGMAP) (REGMAP->CR1 &= ~SPI_CR1_SPE) #define SPI_CLOCK_ENABLE(REG,MASK) do { \ UTILITY_SET_REGISTER_BIT(REG,MASK); \ asm("nop"); \ (void) UTILITY_READ_REGISTER_BIT(REG,MASK); \ } while (0) /** * Checks if SPI Serial clock steady state parameter is in allowed range. */ #define SPI_VALID_CPOL(CPOL) (((CPOL) == SPI_SCK_INACTIVE_STATE_LOW) || \ ((CPOL) == SPI_SCK_INACTIVE_STATE_HIGH)) /** * Checks if SPI Clock Phase parameter is in allowed range. */ #define SPI_VALID_CPHA(CPHA) (((CPHA) == SPI_SCK_LEADING_EDGE_DATA_CAPTURED) || \ ((CPHA) == SPI_SCK_LEADING_EDGE_DATA_CHANGED)) /** * Checks if the SPI Mode value is in allowed range. * This parameter can be a value of @ref Spi_DeviceType */ #define SPI_VALID_MODE(MODE) (((MODE) == SPI_MASTER_MODE) || \ ((MODE) == SPI_SLAVE_MODE)) /** * Checks if SPI Data Size parameter is in allowed range. * This parameter can be a value of @ref Spi_DataSize */ #define SPI_VALID_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \ ((DATASIZE) == SPI_DATASIZE_15BIT) || \ ((DATASIZE) == SPI_DATASIZE_14BIT) || \ ((DATASIZE) == SPI_DATASIZE_13BIT) || \ ((DATASIZE) == SPI_DATASIZE_12BIT) || \ ((DATASIZE) == SPI_DATASIZE_11BIT) || \ ((DATASIZE) == SPI_DATASIZE_10BIT) || \ ((DATASIZE) == SPI_DATASIZE_9BIT) || \ ((DATASIZE) == SPI_DATASIZE_8BIT) || \ ((DATASIZE) == SPI_DATASIZE_7BIT) || \ ((DATASIZE) == SPI_DATASIZE_6BIT) || \ ((DATASIZE) == SPI_DATASIZE_5BIT) || \ ((DATASIZE) == SPI_DATASIZE_4BIT)) /** * Check if SPI direction is in allowed range. * This parameter can be a value of @ref Spi_Direction */ #define SPI_VALID_DIRECTION(DIRECTION) (((DIRECTION) == SPI_DIRECTION_FULL_DUPLEX) || \ ((DIRECTION) == SPI_DIRECTION_HALF_DUPLEX) || \ ((DIRECTION) == SPI_DIRECTION_RX_ONLY) || \ ((DIRECTION) == SPI_DIRECTION_TX_ONLY)) #define SPI_VALID_TX_DIRECTION(DIRECTION) (((DIRECTION) == SPI_DIRECTION_FULL_DUPLEX) || \ ((DIRECTION) == SPI_DIRECTION_HALF_DUPLEX) || \ ((DIRECTION) == SPI_DIRECTION_TX_ONLY)) /** * Checks if the SPI first bit type value is in allowed range. * This parameter can be a value of @ref Spi_FirstBit */ #define SPI_VALID_FIRST_BIT(FIRSTBIT) (((FIRSTBIT) == SPI_FIRSTBIT_MSB) || \ ((FIRSTBIT) == SPI_FIRSTBIT_LSB)) /** * Checks if the SPI frame format value is in allowed range. * This parameter can be a value of @ref Spi_FrameFormat */ #define SPI_VALID_FRAME_FORMAT(FORMAT) (((FORMAT) == SPI_FRAMEFORMAT_MOTOROLA) || \ ((FORMAT) == SPI_FRAMEFORMAT_TI)) /** * Checks if the SPI Slave Select management value is in allowed range. * This parameter can be a value of @ref Spi_SSManagement */ #define SPI_VALID_SSMANAGEMENT(NSS) (((NSS) == SPI_SSMANAGEMENT_SOFTWARE) || \ ((NSS) == SPI_SSMANAGEMENT_HARDWARE_INPUT) || \ ((NSS) == SPI_SSMANAGEMENT_HARDWARE_OUTPUT) || \ ((NSS) == SPI_SSMANAGEMENT_HARDWARE_OUTPUT_PULSE)) // WLCSP72 ballout // LQFP64 #if defined (LIBOHIBOARD_STM32L476Jx) || \ defined (LIBOHIBOARD_STM32L476Rx) #define SPI_IS_DEVICE(DEVICE) (((DEVICE) == OB_SPI1) || \ ((DEVICE) == OB_SPI2) || \ ((DEVICE) == OB_SPI3)) #endif #define SPI_MAX_PINS 8 typedef struct _Spi_Device { SPI_TypeDef* regmap; /**< Device memory pointer */ volatile uint32_t* rccRegisterPtr; /**< Register for clock enabling. */ uint32_t rccRegisterEnable; /**< Register mask for current device. */ Spi_SinPins sinPins[SPI_MAX_PINS]; Spi_SoutPins soutPins[SPI_MAX_PINS]; Spi_SckPins sckPins[SPI_MAX_PINS]; Spi_PcsPins nssPins[SPI_MAX_PINS]; Gpio_Pins sinPinsGpio[SPI_MAX_PINS]; Gpio_Pins soutPinsGpio[SPI_MAX_PINS]; Gpio_Pins sckPinsGpio[SPI_MAX_PINS]; Gpio_Pins nssPinsGpio[SPI_MAX_PINS]; Gpio_Alternate sinPinsMux[SPI_MAX_PINS]; Gpio_Alternate soutPinsMux[SPI_MAX_PINS]; Gpio_Alternate sckPinsMux[SPI_MAX_PINS]; Gpio_Alternate nssPinsMux[SPI_MAX_PINS]; Spi_DeviceType devType; uint32_t baudrate; Spi_Direction direction; Spi_DataSize datasize; Spi_FirstBit firstBit; Spi_FrameFormat frameFormat; Spi_SSManagement ssManagement; } Spi_Device; // WLCSP72 ballout // LQFP64 #if defined (LIBOHIBOARD_STM32L476Jx) || \ defined (LIBOHIBOARD_STM32L476Rx) static Spi_Device spi1 = { .regmap = SPI1, .rccRegisterPtr = &RCC->APB2ENR, .rccRegisterEnable = RCC_APB2ENR_SPI1EN, .sinPins = { SPI_PINS_PA6, SPI_PINS_PB4, }, .sinPinsGpio = { GPIO_PINS_PA6, GPIO_PINS_PB4, }, .sinPinsMux = { GPIO_ALTERNATE_5, GPIO_ALTERNATE_5, }, .soutPins = { SPI_PINS_PA7, SPI_PINS_PB5, }, .soutPinsGpio = { GPIO_PINS_PA7, GPIO_PINS_PB5, }, .soutPinsMux = { GPIO_ALTERNATE_5, GPIO_ALTERNATE_5, }, .sckPins = { SPI_PINS_PA5, SPI_PINS_PB3, }, .sckPinsGpio = { GPIO_PINS_PA5, GPIO_PINS_PB3, }, .sckPinsMux = { GPIO_ALTERNATE_5, GPIO_ALTERNATE_5, }, .nssPins = { SPI_PINS_PA4, SPI_PINS_PA15, }, .nssPinsGpio = { GPIO_PINS_PA4, GPIO_PINS_PA15, }, .nssPinsMux = { GPIO_ALTERNATE_5, GPIO_ALTERNATE_5, }, }; Spi_DeviceHandle OB_SPI1 = &spi1; static Spi_Device spi2 = { .regmap = SPI2, .rccRegisterPtr = &RCC->APB1ENR1, .rccRegisterEnable = RCC_APB1ENR1_SPI2EN, .sinPins = { SPI_PINS_PB14, SPI_PINS_PC2, }, .sinPinsGpio = { GPIO_PINS_PB14, GPIO_PINS_PC2, }, .sinPinsMux = { GPIO_ALTERNATE_5, GPIO_ALTERNATE_5, }, .soutPins = { SPI_PINS_PB15, SPI_PINS_PC3, }, .soutPinsGpio = { GPIO_PINS_PB15, GPIO_PINS_PC3, }, .soutPinsMux = { GPIO_ALTERNATE_5, GPIO_ALTERNATE_5, }, .sckPins = { SPI_PINS_PB10, SPI_PINS_PB13, }, .sckPinsGpio = { GPIO_PINS_PB10, GPIO_PINS_PB13, }, .sckPinsMux = { GPIO_ALTERNATE_5, GPIO_ALTERNATE_5, }, .nssPins = { SPI_PINS_PB9, SPI_PINS_PB12, }, .nssPinsGpio = { GPIO_PINS_PB9, GPIO_PINS_PB12, }, .nssPinsMux = { GPIO_ALTERNATE_5, GPIO_ALTERNATE_5, }, }; Spi_DeviceHandle OB_SPI2 = &spi2; static Spi_Device spi3 = { .regmap = SPI3, .rccRegisterPtr = &RCC->APB1ENR1, .rccRegisterEnable = RCC_APB1ENR1_SPI3EN, .sinPins = { SPI_PINS_PB4, SPI_PINS_PC11, #if defined (LIBOHIBOARD_STM32L476Jx) SPI_PINS_PG10, #endif }, .sinPinsGpio = { GPIO_PINS_PB4, GPIO_PINS_PC11, #if defined (LIBOHIBOARD_STM32L476Jx) GPIO_PINS_PG10, #endif }, .sinPinsMux = { GPIO_ALTERNATE_6, GPIO_ALTERNATE_6, #if defined (LIBOHIBOARD_STM32L476Jx) GPIO_ALTERNATE_6, #endif }, .soutPins = { SPI_PINS_PB5, SPI_PINS_PC11, #if defined (LIBOHIBOARD_STM32L476Jx) SPI_PINS_PG11, #endif }, .soutPinsGpio = { GPIO_PINS_PB5, GPIO_PINS_PC11, #if defined (LIBOHIBOARD_STM32L476Jx) GPIO_PINS_PG11, #endif }, .soutPinsMux = { GPIO_ALTERNATE_6, GPIO_ALTERNATE_6, #if defined (LIBOHIBOARD_STM32L476Jx) GPIO_ALTERNATE_6, #endif }, .sckPins = { SPI_PINS_PB3, SPI_PINS_PC10, #if defined (LIBOHIBOARD_STM32L476Jx) SPI_PINS_PG9, #endif }, .sckPinsGpio = { GPIO_PINS_PB3, GPIO_PINS_PC10, #if defined (LIBOHIBOARD_STM32L476Jx) GPIO_PINS_PG9, #endif }, .sckPinsMux = { GPIO_ALTERNATE_6, GPIO_ALTERNATE_6, #if defined (LIBOHIBOARD_STM32L476Jx) GPIO_ALTERNATE_6, #endif }, .nssPins = { SPI_PINS_PA4, SPI_PINS_PA15, #if defined (LIBOHIBOARD_STM32L476Jx) SPI_PINS_PG12, #endif }, .nssPinsGpio = { GPIO_PINS_PA4, GPIO_PINS_PA15, #if defined (LIBOHIBOARD_STM32L476Jx) GPIO_PINS_PG12, #endif }, .nssPinsMux = { GPIO_ALTERNATE_6, GPIO_ALTERNATE_6, #if defined (LIBOHIBOARD_STM32L476Jx) GPIO_ALTERNATE_6, #endif }, }; Spi_DeviceHandle OB_SPI3 = &spi3; #endif static System_Errors Spi_setSoutPin(Spi_DeviceHandle dev, Spi_SoutPins soutPin) { uint8_t devPinIndex; // if (dev->devInitialized == 0) // return ERRORS_SPI_DEVICE_NOT_INIT; for (devPinIndex = 0; devPinIndex < SPI_MAX_PINS; ++devPinIndex) { if (dev->soutPins[devPinIndex] == soutPin) { Gpio_configAlternate(dev->soutPinsGpio[devPinIndex], dev->soutPinsMux[devPinIndex], 0); return ERRORS_NO_ERROR; } } return ERRORS_SPI_NO_PIN_FOUND; } static System_Errors Spi_setSinPin(Spi_DeviceHandle dev, Spi_SinPins sinPin) { uint8_t devPinIndex; // if (dev->devInitialized == 0) // return ERRORS_SPI_DEVICE_NOT_INIT; for (devPinIndex = 0; devPinIndex < SPI_MAX_PINS; ++devPinIndex) { if (dev->sinPins[devPinIndex] == sinPin) { Gpio_configAlternate(dev->sinPinsGpio[devPinIndex], dev->sinPinsMux[devPinIndex], 0); return ERRORS_NO_ERROR; } } return ERRORS_SPI_NO_PIN_FOUND; } static System_Errors Spi_setSckPin(Spi_DeviceHandle dev, Spi_SckPins sckPin) { uint8_t devPinIndex; // if (dev->devInitialized == 0) // return ERRORS_SPI_DEVICE_NOT_INIT; for (devPinIndex = 0; devPinIndex < SPI_MAX_PINS; ++devPinIndex) { if (dev->sckPins[devPinIndex] == sckPin) { Gpio_configAlternate(dev->sckPinsGpio[devPinIndex], dev->sckPinsMux[devPinIndex], 0); return ERRORS_NO_ERROR; } } return ERRORS_SPI_NO_PIN_FOUND; } static System_Errors Spi_setNssPin(Spi_DeviceHandle dev, Spi_PcsPins nssPin) { uint8_t devPinIndex; // if (dev->devInitialized == 0) // return ERRORS_SPI_DEVICE_NOT_INIT; for (devPinIndex = 0; devPinIndex < SPI_MAX_PINS; ++devPinIndex) { if (dev->nssPins[devPinIndex] == nssPin) { Gpio_configAlternate(dev->nssPinsGpio[devPinIndex], dev->nssPinsMux[devPinIndex], 0); return ERRORS_NO_ERROR; } } return ERRORS_SPI_NO_PIN_FOUND; } /** * Useful constant to compute baudrate prescaler (see SPIx_CR1 register, BR bits) */ static const uint16_t Spi_brDiv[] = { /*00*/ 2, /*01*/ 4, /*02*/ 8, /*03*/ 16, /*04*/ 32, /*05*/ 64, /*06*/ 128, /*07*/ 256 }; System_Errors Spi_setBaudrate (Spi_DeviceHandle dev, uint32_t speed) { uint32_t frequency = 0u; uint32_t computeSpeed = 0u; uint32_t diff = 0xFFFFFFFFu; uint8_t br = 0u; #if defined (LIBOHIBOARD_STM32L476) if (dev == OB_SPI1) frequency = Clock_getOutputValue(CLOCK_OUTPUT_PCLK2); else frequency = Clock_getOutputValue(CLOCK_OUTPUT_PCLK1); #endif if (frequency != 0u) { for (uint8_t i = 0; i < 8; i++) { computeSpeed = (frequency / Spi_brDiv[i]); if (speed < computeSpeed) { if ((computeSpeed - speed) < diff) { diff = computeSpeed - speed; br = i; } } else { if ((speed - computeSpeed) < diff) { diff = speed - computeSpeed; br = i; } } } if (diff == 0xFFFFFFFFu) return ERRORS_SPI_BAUDRATE_NOT_FOUND; dev->regmap->CR1 = dev->regmap->CR1 & (~(SPI_CR1_BR_Msk)); dev->regmap->CR1 |= (br << SPI_CR1_BR_Pos); } else { return ERRORS_SPI_CLOCKSOURCE_FREQUENCY_TOO_LOW; } return ERRORS_NO_ERROR; } /** * */ static System_Errors Spi_config (Spi_DeviceHandle dev, Spi_Config* config) { System_Errors err = ERRORS_NO_ERROR; // Check all parameters with asserts // The OR is to detect an error: it is not important where is, the important is that there is! err = ohiassert(SPI_VALID_MODE(config->devType)); err |= ohiassert(SPI_VALID_DIRECTION(config->direction)); err |= ohiassert(SPI_VALID_DATASIZE(config->datasize)); err |= ohiassert(SPI_VALID_SSMANAGEMENT(config->ssManagement)); err |= ohiassert(SPI_VALID_FIRST_BIT(config->firstBit)); err |= ohiassert(SPI_VALID_FRAME_FORMAT(config->frameFormat)); if (err != ERRORS_NO_ERROR) return ERRORS_SPI_WRONG_PARAM; // Disable the peripheral SPI_DEVICE_DISABLE(dev->regmap); // Configure peripheral // Configure Mode dev->regmap->CR1 = dev->regmap->CR1 & (~(SPI_CR1_MSTR_Msk | SPI_CR1_SSI_Msk)); dev->devType = config->devType; if (config->devType == SPI_MASTER_MODE) { dev->regmap->CR1 |= SPI_CR1_MSTR_Msk | SPI_CR1_SSI_Msk; } // Configure direction dev->regmap->CR1 = dev->regmap->CR1 & (~(SPI_CR1_BIDIMODE_Msk | SPI_CR1_RXONLY_Msk | SPI_CR1_BIDIOE_Msk)); dev->direction = config->direction; switch (config->direction) { case SPI_DIRECTION_FULL_DUPLEX: // Nothing to do! break; case SPI_DIRECTION_HALF_DUPLEX: dev->regmap->CR1 |= SPI_CR1_BIDIMODE_Msk; break; case SPI_DIRECTION_RX_ONLY: dev->regmap->CR1 |= SPI_CR1_RXONLY_Msk; break; case SPI_DIRECTION_TX_ONLY: // Nothing to do! break; } // Configure First Bit type dev->regmap->CR1 = dev->regmap->CR1 & (~(SPI_CR1_LSBFIRST_Msk)); dev->firstBit = config->firstBit; if (config->firstBit == SPI_FIRSTBIT_LSB) { dev->regmap->CR1 |= SPI_CR1_LSBFIRST_Msk; } // Configure CPOL and CPHA dev->regmap->CR1 = dev->regmap->CR1 & (~(SPI_CR1_CPOL_Msk | SPI_CR1_CPHA_Msk)); if (config->sckPolarity == SPI_SCK_INACTIVE_STATE_HIGH) { dev->regmap->CR1 |= SPI_CR1_CPOL_Msk; } if (config->sckPhase == SPI_SCK_LEADING_EDGE_DATA_CHANGED) { dev->regmap->CR1 |= SPI_CR1_CPHA_Msk; } // Configure datasize dev->regmap->CR2 = dev->regmap->CR2 & (~(SPI_CR2_DS_Msk)); dev->datasize = config->datasize; dev->regmap->CR2 |= ((config->datasize - 1) << SPI_CR2_DS_Pos); // Configure Frame Format Type (Motorola or TI) dev->regmap->CR2 = dev->regmap->CR2 & (~(SPI_CR2_FRF_Msk)); dev->frameFormat = config->frameFormat; if (config->frameFormat == SPI_FRAMEFORMAT_TI) { dev->regmap->CR2 |= SPI_CR2_FRF_Msk; } // Configure SS management dev->regmap->CR1 = dev->regmap->CR1 & (~(SPI_CR1_SSM_Msk)); dev->regmap->CR2 = dev->regmap->CR2 & (~(SPI_CR2_SSOE_Msk | SPI_CR2_NSSP_Msk)); if(dev->datasize <= SPI_DATASIZE_8BIT) { dev->regmap->CR2 |= SPI_CR2_FRXTH_Msk; } dev->ssManagement = config->ssManagement; switch (config->ssManagement) { case SPI_SSMANAGEMENT_SOFTWARE: dev->regmap->CR1 |= SPI_CR1_SSM_Msk; break; case SPI_SSMANAGEMENT_HARDWARE_INPUT: // Nothing to do! break; case SPI_SSMANAGEMENT_HARDWARE_OUTPUT: dev->regmap->CR2 |= SPI_CR2_SSOE_Msk; break; case SPI_SSMANAGEMENT_HARDWARE_OUTPUT_PULSE: dev->regmap->CR2 |= SPI_CR2_SSOE_Msk | SPI_CR2_NSSP_Msk; break; } // Set baudrate err = Spi_setBaudrate(dev,config->baudrate); if (err != ERRORS_NO_ERROR) { return err; } // The device will be enable only during transmission... // When the device was enable, the SS pin is set low automatically. // SPI_DEVICE_ENABLE(dev->regmap); return ERRORS_NO_ERROR; } System_Errors Spi_init (Spi_DeviceHandle dev, Spi_Config *config) { System_Errors err = ERRORS_NO_ERROR; // Check the SPI device if (dev == NULL) { return ERRORS_SPI_NO_DEVICE; } // Check the SPI instance err = ohiassert(SPI_IS_DEVICE(dev)); if (err != ERRORS_NO_ERROR) { return ERRORS_SPI_WRONG_DEVICE; } // Enable peripheral clock SPI_CLOCK_ENABLE(*dev->rccRegisterPtr,dev->rccRegisterEnable); // Enable pins if (config->sinPin != SPI_PINS_SINNONE) Spi_setSinPin(dev, config->sinPin); if (config->soutPin != SPI_PINS_SOUTNONE) Spi_setSoutPin(dev, config->soutPin); if (config->sckPin != SPI_PINS_SCKNONE) Spi_setSckPin(dev, config->sckPin); if ((config->pcs0Pin != SPI_PINS_PCSNONE) && (config->ssManagement != SPI_SSMANAGEMENT_SOFTWARE)) Spi_setNssPin(dev, config->pcs0Pin); // Configure the peripheral err = Spi_config(dev,config); if (err != ERRORS_NO_ERROR) { // FIXME: Call deInit? return err; } return ERRORS_NO_ERROR; } System_Errors Spi_readByte (Spi_DeviceHandle dev, uint8_t * data) { // deprecated return ohiassert(0); } System_Errors Spi_writeByte (Spi_DeviceHandle dev, uint8_t data) { // deprecated return ohiassert(0); } #if 0 // Not used anymore! static System_Errors Spi_exchange(Spi_DeviceHandle dev, const uint8_t *data_tx, uint8_t *data_rx, uint16_t size, uint32_t timeout) { uint16_t counterTx = 0; uint16_t counterRx = 0; uint32_t tickEnd = 0; /* Variable used to alternate Rx and Tx during transfer */ System_Errors errorcode = ERRORS_NO_ERROR; /* Check Direction parameter */ if (dev->direction == SPI_DIRECTION_HALF_DUPLEX) { UTILITY_CLEAR_REGISTER_BIT(dev->regmap->CR1,SPI_CR1_BIDIOE); } else { UTILITY_SET_REGISTER_BIT(dev->regmap->CR1,SPI_CR1_BIDIOE); } /* Init tickEnd for timeout management*/ tickEnd = System_currentTick() + timeout; if ((data_tx == NULL) || (data_rx == NULL) || (size == 0U)) { errorcode = ERRORS_PARAM_VALUE; goto spierror; } /* Set the Rx Fifo threshold */ if (dev->datasize > SPI_DATASIZE_8BIT) { /* Set fiforxthreshold according the reception data length: 16bit */ UTILITY_CLEAR_REGISTER_BIT(dev->regmap->CR2,SPI_CR2_FRXTH_Msk); } else { /* Set fiforxthreshold according the reception data length: 8bit */ UTILITY_SET_REGISTER_BIT(dev->regmap->CR2,SPI_CR2_FRXTH_Msk); } /* Check if the SPI is already enabled */ if (!UTILITY_READ_REGISTER_BIT(dev->regmap->CR1,SPI_CR1_SPE)) { /* Enable SPI peripheral */ SPI_DEVICE_ENABLE(dev->regmap); } /* Transmit and Receive data in 16 Bit mode */ if (dev->datasize > SPI_DATASIZE_8BIT) { if (dev->devType == SPI_SLAVE_MODE) { *((volatile uint16_t *)&dev->regmap->DR) = *((uint16_t *)&data_tx[counterTx]); counterTx += sizeof(uint16_t); } while (counterTx < size) { /* Check TXE flag */ if (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_TXE)) { *((volatile uint16_t *)&dev->regmap->DR) = *((uint16_t *)&data_tx[counterTx]); counterTx += sizeof(uint16_t); } if (dev->direction == SPI_DIRECTION_FULL_DUPLEX) { /* Wait until RXNE flag is reset */ while (!UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_RXNE)) { if (System_currentTick() > tickEnd) { errorcode = ERRORS_SPI_TIMEOUT_RX; goto spierror; } } *((uint16_t *)&data_rx[counterRx]) = *((volatile uint16_t *)&dev->regmap->DR); counterRx += sizeof(uint16_t); } else { /* Wait until TNE flag is reset */ while (!UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_TXE)); } } } /* Transmit and Receive data in 8 Bit mode */ else { if (dev->devType == SPI_SLAVE_MODE) { *((volatile uint8_t *)&dev->regmap->DR) = *((uint8_t *)&data_tx[counterTx]); counterTx += sizeof(uint8_t); } while (counterTx < size) { /* Check TXE flag */ if (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_TXE)) { *((volatile uint8_t *)&dev->regmap->DR) = *((uint8_t *)&data_tx[counterTx]); counterTx += sizeof(uint8_t); } if (dev->direction == SPI_DIRECTION_FULL_DUPLEX) { /* Wait until RXNE flag is reset */ while (!UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_RXNE)) { if (System_currentTick() > tickEnd) { errorcode = ERRORS_SPI_TIMEOUT_RX; goto spierror; } } *((uint8_t *)&data_rx[counterRx]) = *((volatile uint8_t *)&dev->regmap->DR); counterRx += sizeof(uint8_t); } else { /* Wait until TNE flag is reset */ while (!UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_TXE)); } } } if (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_OVR)) { // Clear overrun flag in two lines direction mode // The received data is not read if (dev->direction == SPI_DIRECTION_FULL_DUPLEX) { uint32_t black_hole = 0; black_hole = (uint32_t)dev->regmap->DR; black_hole = (uint32_t)dev->regmap->SR; (void) black_hole; } } spierror : return errorcode; } #endif System_Errors Spi_read (Spi_DeviceHandle dev, uint8_t* data, uint32_t timeout) { System_Errors err = ERRORS_NO_ERROR; // Set FIFO RX threshold if (dev->datasize > SPI_DATASIZE_8BIT) { UTILITY_CLEAR_REGISTER_BIT(dev->regmap->CR2,SPI_CR2_FRXTH_Msk); } else { UTILITY_SET_REGISTER_BIT(dev->regmap->CR2,SPI_CR2_FRXTH_Msk); } // If one line transmission, setup the device if (dev->direction == SPI_DIRECTION_HALF_DUPLEX) { UTILITY_CLEAR_REGISTER_BIT(dev->regmap->CR1,SPI_CR1_BIDIOE); } // Check if the device is enabled if (UTILITY_READ_REGISTER_BIT(dev->regmap->CR1,SPI_CR1_SPE) == 0) { SPI_DEVICE_ENABLE(dev->regmap); } // Save timeout uint32_t timeoutEnd = System_currentTick() + timeout; // Check the connection type if ((dev->devType == SPI_MASTER_MODE) && (dev->direction == SPI_DIRECTION_FULL_DUPLEX)) { // Send dummy data // Wait until the buffer is empty while (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_TXE) == 0) { if (System_currentTick() > timeoutEnd) { err = ERRORS_SPI_TIMEOUT_TX; // Release the device. goto spierror; } } // In case of datasize is grater the 8B cast the relative value if (dev->datasize > SPI_DATASIZE_8BIT) { *((volatile uint16_t *)&dev->regmap->DR) = SPI_EMPTY_WORD; } else { *((volatile uint8_t *)&dev->regmap->DR) = SPI_EMPTY_BYTE; } // Now read the data // Wait until the buffer is not empty while (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_RXNE) == 0) { if (System_currentTick() > timeoutEnd) { err = ERRORS_SPI_TIMEOUT_RX; // Release the device. goto spierror; } } // In case of datasize is grater the 8B cast the relative value if (dev->datasize > SPI_DATASIZE_8BIT) { *((uint16_t *)data) = *((volatile uint16_t *)&dev->regmap->DR); } else { *((uint8_t *)data) = *((volatile uint8_t *)&dev->regmap->DR); } } else { // Wait until the buffer is not empty while (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_RXNE) == 0) { if (System_currentTick() > timeoutEnd) { err = ERRORS_SPI_TIMEOUT_RX; // Release the device. goto spierror; } } // In case of datasize is grater the 8B cast the relative value if (dev->datasize > SPI_DATASIZE_8BIT) { *((uint16_t *)data) = *((volatile uint16_t *)&dev->regmap->DR); } else { *((uint8_t *)data) = *((volatile uint8_t *)&dev->regmap->DR); } } spierror: // FIXME: Disable SPI? return err; } System_Errors Spi_write (Spi_DeviceHandle dev, const uint8_t* data, uint32_t timeout) { System_Errors err = ERRORS_NO_ERROR; // Check the chosen direction for the peripheral err = ohiassert(SPI_VALID_TX_DIRECTION(dev->direction)); if (err != ERRORS_NO_ERROR) { return ERRORS_SPI_WRONG_PARAM; } // Save timeout uint32_t timeoutEnd = System_currentTick() + timeout; // If one line transmission, setup the device if (dev->direction == SPI_DIRECTION_HALF_DUPLEX) { UTILITY_SET_REGISTER_BIT(dev->regmap->CR1,SPI_CR1_BIDIOE); } // Check if the device is enabled if (UTILITY_READ_REGISTER_BIT(dev->regmap->CR1,SPI_CR1_SPE) == 0) { SPI_DEVICE_ENABLE(dev->regmap); } // In case of datasize is grater the 8B cast the relative value if (dev->datasize > SPI_DATASIZE_8BIT) { if (dev->devType == SPI_SLAVE_MODE) { *((volatile uint16_t *)&dev->regmap->DR) = *((uint16_t *)data); } // Wait until the buffer is empty while (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_TXE) == 0) { if (System_currentTick() > timeoutEnd) { err = ERRORS_SPI_TIMEOUT_TX; // Release the device. goto spierror; } } *((volatile uint16_t *)&dev->regmap->DR) = *((uint16_t *)data); } else { if (dev->devType == SPI_SLAVE_MODE) { *((volatile uint8_t *)&dev->regmap->DR) = *((uint8_t *)data); } // Wait until the buffer is empty while (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_TXE) == 0) { if (System_currentTick() > timeoutEnd) { err = ERRORS_SPI_TIMEOUT_TX; // Release the device. goto spierror; } } *((volatile uint8_t *)&dev->regmap->DR) = *((uint8_t *)data); } // In case of full-duplex transmission, wait until RXNE flag is set if (dev->direction == SPI_DIRECTION_FULL_DUPLEX) { uint16_t dummy = 0; while (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_RXNE_Msk) == 0) { if (System_currentTick() > timeoutEnd) { err = ERRORS_SPI_TIMEOUT_TX; // Release the device. goto spierror; } } // Read dummy element from RX FIFO if (dev->datasize > SPI_DATASIZE_8BIT) { *((uint16_t *)&dummy) = *((volatile uint16_t *)&dev->regmap->DR); } else { *((uint8_t *)&dummy) = *((volatile uint8_t *)&dev->regmap->DR); } } if (UTILITY_READ_REGISTER_BIT(dev->regmap->SR,SPI_SR_OVR_Msk)) { // Clear overrun flag in two lines direction mode // The received data is not read if (dev->direction == SPI_DIRECTION_FULL_DUPLEX) { (void) dev->regmap->DR; (void) dev->regmap->SR; } } spierror: // FIXME: Disable SPI? return err; } #endif // LIBOHIBOARD_STM32L4 #ifdef __cplusplus } #endif #endif // LIBOHIBOARD_SPI
the_stack_data/74065.c
#include <stdio.h> struct ListNode { int val; struct ListNode *next; }; int c=0; struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2){ if(l1==NULL && l2==NULL && c==0)return NULL; l1 = l1!=NULL ? (c += l1->val, l1->next) : l1; l2 = l2!=NULL ? (c += l2->val, l2->next) : l2; struct ListNode *cur = (struct ListNode *)malloc(sizeof(struct ListNode)); cur->val = c%10; c /= 10; cur->next = addTwoNumbers(l1,l2); return cur; }
the_stack_data/179830120.c
#include <stdio.h> #define MAXBUFF 10 int buffpos=0; int buff[MAXBUFF]; int getch(void){ return (buffpos>0)?buff[--buffpos]:getchar(); } void ungetch(int c){ if(buffpos>=MAXBUFF) printf("Buffer overload"); else buff[buffpos++]=c; }
the_stack_data/53723.c
// write a function named capitalize that capitalizes all letters in its argument // the argument will be a null terminated string. #include <stdio.h> #include <stdint.h> #include <ctype.h> #define LENGTH 80 int read_line(char s[], int n); void capitalize(char *s); int main(void) { char s[LENGTH]; printf("Enter the string: "); read_line(s, LENGTH); capitalize(s); printf("And here is your string in capital letters: \n"); puts(s); return 0; } int read_line(char s[], int n) { int ch, i = 0; while ((ch = getchar()) == ' ') ; // Skipping whitespaces. But stores the first letter. // Do while loop so that it gets the first char still. do { if (i < n) s[i++] = ch; s[i] = '\0'; } while ((ch = getchar()) != '\n'); return i; } void capitalize(char *s) { for (; *s != '\0'; s++) *s = toupper(*s); }
the_stack_data/161081161.c
int main() { int a = 45 / -9*6; return a ; }
the_stack_data/43887382.c
#include <stdio.h> #include <stdlib.h> typedef int object_t; typedef int key_t; typedef struct tr_n_t { key_t key; struct tr_n_t* left; struct tr_n_t* right; enum {red, black} color; /* possibly other information */ } tree_node_t; // _____________________________________________________________________________ #define BLOCKSIZE 256 tree_node_t* currentblock = NULL; int size_left; tree_node_t* free_list = NULL; tree_node_t* get_node() { tree_node_t* tmp; if ( free_list != NULL ) { tmp = free_list; free_list = free_list -> left; } else { if ( currentblock == NULL || size_left == 0) { currentblock = (tree_node_t*) malloc( BLOCKSIZE * sizeof(tree_node_t) ); size_left = BLOCKSIZE; } tmp = currentblock++; size_left -= 1; } return ( tmp ); } void return_node(tree_node_t* node) { node->left = free_list; free_list = node; } tree_node_t* create_tree(void) { tree_node_t* tmp_node; tmp_node = get_node(); tmp_node->left = NULL; tmp_node->color = black; return ( tmp_node ); } void left_rotation(tree_node_t* n) { tree_node_t* tmp_node; key_t tmp_key; tmp_node = n->left; tmp_key = n->key; n->left = n->right; n->key = n->right->key; n->right = n->left->right; n->left->right = n->left->left; n->left->left = tmp_node; n->left->key = tmp_key; } void right_rotation(tree_node_t* n) { tree_node_t* tmp_node; key_t tmp_key; tmp_node = n->right; tmp_key = n->key; n->right = n->left; n->key = n->left->key; n->left = n->right->left; n->right->left = n->right->right; n->right->right = tmp_node; n->right->key = tmp_key; } object_t* find(tree_node_t* tree, key_t query_key) { tree_node_t* tmp_node; if ( tree->left == NULL ) { return (NULL); } else { tmp_node = tree; while ( tmp_node->right != NULL ) { if ( tmp_node->color == red ) { printf("r"); } else { printf("b"); } if ( query_key < tmp_node->key ) { tmp_node = tmp_node->left; } else { tmp_node = tmp_node->right; } } if ( tmp_node->color == red ) { printf("r\n"); } else { printf("b\n"); } if ( tmp_node->key == query_key ) { return ( (object_t*) tmp_node->left ); } else { return ( NULL ); } } } int insert(tree_node_t* tree, key_t new_key, object_t* new_object) { if ( tree->left == NULL ) { tree->left = (tree_node_t*) new_object; tree->key = new_key; tree->color = black; /* root is always black */ tree->right = NULL; } else { tree_node_t* current, *next_node, *upper; current = tree; upper = NULL; while ( current->right != NULL ) { if ( new_key < current->key ) { next_node = current->left; } else { next_node = current->right; } if ( current->color == black ) { if ( current->left->color == black || current->right->color == black ) { upper = current; current = next_node; } else { /* current->left and current->right red */ /* need rebalance */ if ( upper == NULL ) { /* current is root */ current->left->color = black; current->right->color = black; upper = current; } else if (current->key < upper->key ) { /* current left of upper */ if ( current == upper->left ) { current->left->color = black; current->right->color = black; current->color = red; } else if ( current == upper->left->left ) { right_rotation( upper ); upper->left->color = red; upper->right->color = red; upper->left->left->color = black; upper->left->right->color = black; } else { /* current == upper->left->right */ left_rotation( upper->left ); right_rotation( upper ); upper->left->color = red; upper->right->color = red; upper->right->left->color = black; upper->left->right->color = black; } } else { /* current->key >= upper->key */ /* current right of upper */ if ( current == upper->right ) { current->left->color = black; current->right->color = black; current->color = red; } else if ( current == upper->right->right ) { left_rotation( upper ); upper->left->color = red; upper->right->color = red; upper->right->left->color = black; upper->right->right->color = black; } else { /* current == upper->right->left */ right_rotation( upper->right ); left_rotation( upper ); upper->left->color = red; upper->right->color = red; upper->right->left->color = black; upper->left->right->color = black; } } /* end rebalancing */ current = next_node; upper = current; /*two black lower neighbors*/ } } else { /* current red */ current = next_node; /*move down */ } } /* end while; reached leaf. always arrive on black leaf*/ /* found the candidate leaf. Test whether key distinct */ if ( current->key == new_key ) { return ( -1 ); } /* key is distinct, now perform the insert */ { tree_node_t* old_leaf, *new_leaf; old_leaf = get_node(); old_leaf->left = current->left; old_leaf->key = current->key; old_leaf->right = NULL; old_leaf->color = red; new_leaf = get_node(); new_leaf->left = (tree_node_t*) new_object; new_leaf->key = new_key; new_leaf->right = NULL; new_leaf->color = red; if ( current->key < new_key ) { current->left = old_leaf; current->right = new_leaf; current->key = new_key; } else { current->left = new_leaf; current->right = old_leaf; } } } return ( 0 ); } object_t* delete (tree_node_t* tree, key_t delete_key) { object_t* deleted_object; int finished = 0; if ( tree->left == NULL ) { return ( NULL ); } else if ( tree->right == NULL ) { if ( tree->key == delete_key ) { deleted_object = (object_t*) tree->left; tree->left = NULL; return ( deleted_object ); } else { return ( NULL ); } } else { tree_node_t* current, *upper; tree->color = black; /* root is always black*/ upper = tree; if ( upper->left->color == black && upper->right->color == black ) { /* need to give upper ared lower neighbor */ if ( delete_key < upper->key ) { if ( upper->left->right == NULL ) { if ( upper->right->right == NULL ) { upper->left->color = red; upper->right->color = red; } else { upper->right->left->color = black; upper->right->right->color = black; upper->right->color = red; } } else { if ( upper->left->left->color == red || upper->left->right->color == red ) { upper = upper->left; } else if ( upper->right->right->color == red ) { left_rotation( upper ); upper->right->color = black; upper->left->color = black; upper->left->left->color = red; upper = upper->left; } else if ( upper->right->left->color == red ) { right_rotation( upper->right ); left_rotation( upper ); upper->right->color = black; upper->left->color = black; upper->left->left->color = red; upper = upper->left; } else { /* left and right have only black lower neighbors */ upper->left->color = red; upper->right->color = red; } } } else { /* delete_key >= upper->key */ if ( upper->right->left == NULL ) { if ( upper->left->right == NULL ) { upper->left->color = red; upper->right->color = red; } else { upper->left->left->color = black; upper->left->right->color = black; upper->left->color = red; } } else { if ( upper->right->right->color == red || upper->right->left->color == red ) { upper = upper->right; } else if ( upper->left->left->color == red ) { right_rotation( upper ); upper->right->color = black; upper->left->color = black; upper->right->right->color = red; upper = upper->right; } else if ( upper->left->right->color == red ) { left_rotation( upper->left ); right_rotation( upper ); upper->right->color = black; upper->left->color = black; upper->right->right->color = red; upper = upper->right; } else { /* left and right have only black lower neighbors */ upper->left->color = red; upper->right->color = red; } } } } /* upper has at least one red lower neighbor */ current = upper; while ( current->right != NULL ) { if ( delete_key < current->key ) { current = current->left; } else { current = current->right; } if ( current->color == red || current->right == NULL ) { continue; } /* go on down, or stop if leaf found */ else { /* current->color == black, not leaf, rebalance */ if ( current->left->color == red || current->right->color == red ) { upper = current; /* condition satisfied */ } else { /* current->left and current->right black */ /* need rebalance */ if (current->key < upper->key ) { /* Case 2: current left of upper */ if ( current == upper->left ) { if ( upper->right->left->left->color == black && upper->right->left->right->color == black ) { /* Case 2.1.1 */ left_rotation( upper ); upper->left->color = black; upper->left->left->color = red; upper->left->right->color = red; current = upper = upper->left; } else if ( upper->right->left->left->color == red ) { /* Case 2.1.2 */ right_rotation( upper->right->left ); right_rotation( upper->right ); left_rotation( upper ); upper->left->color = black; upper->right->left->color = black; upper->right->color = red; upper->left->left->color = red; current = upper = upper->left; } else /* upper->right->left->left->color == black && upper->right->left->right->color == red */ { /* Case 2.1.3 */ right_rotation( upper->right ); left_rotation( upper ); upper->left->color = black; upper->right->left->color = black; upper->right->color = red; upper->left->left->color = red; current = upper = upper->left; } } /*end Case 2.1: current==upper->left */ else if ( current == upper->left->left ) { if ( upper->left->right->left->color == black && upper->left->right->right->color == black ) { /* Case 2.2.1 */ upper->left->color = black; upper->left->left->color = red; upper->left->right->color = red; current = upper = upper->left; } else if ( upper->left->right->right->color == red ) { /* Case 2.2.2 */ left_rotation( upper->left ); upper->left->left->color = black; upper->left->right->color = black; upper->left->color = red; upper->left->left->left->color = red; current = upper = upper->left->left; } else /* upper->left->right->left->color == red && upper->left->right->right->color == black */ { /* Case 2.2.3 */ right_rotation( upper->left->right ); left_rotation( upper->left ); upper->left->left->color = black; upper->left->right->color = black; upper->left->color = red; upper->left->left->left->color = red; current = upper = upper->left->left; } } /*end Case 2.2: current==upper->left->left */ else { /* current == upper->left->right */ if ( upper->left->left->left->color == black && upper->left->left->right->color == black ) { /* Case 2.3.1 */ upper->left->color = black; upper->left->left->color = red; upper->left->right->color = red; current = upper = upper->left; } else if ( upper->left->left->left->color == red ) { /* Case 2.3.2 */ right_rotation( upper->left ); upper->left->left->color = black; upper->left->right->color = black; upper->left->color = red; upper->left->right->right->color = red; current = upper = upper->left->right; } else /* upper->left->left->left->color == black && upper->left->left->right->color == red */ { /* Case 2.3.3 */ left_rotation( upper->left->left ); right_rotation( upper->left ); upper->left->left->color = black; upper->left->right->color = black; upper->left->color = red; upper->left->right->right->color = red; current = upper = upper->left->right; } } /*end Case 2.3: current==upper->left->right */ } /* end Case 2: current->key < upper-> key */ else { /* Case 3: current->key >= upper->key */ if ( current == upper->right ) { if ( upper->left->right->right->color == black && upper->left->right->left->color == black ) { /* Case 3.1.1 */ right_rotation( upper ); upper->right->color = black; upper->right->right->color = red; upper->right->left->color = red; current = upper = upper->right; } else if ( upper->left->right->right->color == red ) { /* Case 3.1.2 */ left_rotation( upper->left->right ); left_rotation( upper->left ); right_rotation( upper ); upper->right->color = black; upper->left->right->color = black; upper->left->color = red; upper->right->right->color = red; current = upper = upper->right; } else /* upper->left->right->right->color == black && upper->left->right->left->color == red */ { /* Case 3.1.3 */ left_rotation( upper->left ); right_rotation( upper ); upper->right->color = black; upper->left->right->color = black; upper->left->color = red; upper->right->right->color = red; current = upper = upper->right; } } /*end Case 3.1: current==upper->left */ else if ( current == upper->right->right ) { if ( upper->right->left->right->color == black && upper->right->left->left->color == black ) { /* Case 3.2.1 */ upper->right->color = black; upper->right->left->color = red; upper->right->right->color = red; current = upper = upper->right; } else if ( upper->right->left->left->color == red ) { /* Case 3.2.2 */ right_rotation( upper->right ); upper->right->left->color = black; upper->right->right->color = black; upper->right->color = red; upper->right->right->right->color = red; current = upper = upper->right->right; } else /* upper->right->left->right->color == red && upper->right->left->left->color == black */ { /* Case 3.2.3 */ left_rotation( upper->right->left ); right_rotation( upper->right ); upper->right->right->color = black; upper->right->left->color = black; upper->right->color = red; upper->right->right->right->color = red; current = upper = upper->right->right; } } /*end Case 3.2: current==upper->right->right */ else { /* current == upper->right->left */ if ( upper->right->right->right->color == black && upper->right->right->left->color == black ) { /* Case 3.3.1 */ upper->right->color = black; upper->right->left->color = red; upper->right->right->color = red; current = upper = upper->right; } else if ( upper->right->right->right->color == red ) { /* Case 3.3.2 */ left_rotation( upper->right ); upper->right->left->color = black; upper->right->right->color = black; upper->right->color = red; upper->right->left->left->color = red; current = upper = upper->right->left; } else /* upper->right->right->right->color == black && upper->right->right->left->color == red */ { /* Case 3.3.3 */ right_rotation( upper->right->right ); left_rotation( upper->right ); upper->right->left->color = black; upper->right->right->color = black; upper->right->color = red; upper->right->left->left->color = red; current = upper = upper->right->left; } } /*end Case 3.3: current==upper->right->left */ } /* end Case 3: current->key >= upper-> key */ } /* end rebalance, upper has a red lower neighbor */ } } /* end while */ /* found the candidate leaf. Test whether key correct */ if ( current->key != delete_key ) { return ( NULL ); } else { /* want to delete node current */ tree_node_t* tmp_node; deleted_object = (object_t*) current->left; if ( current->key < upper->key ) { if ( current == upper->left ) { /* upper->right is red */ tmp_node = upper->right; upper->key = tmp_node->key; upper->left = tmp_node->left; upper->right = tmp_node->right; } else if ( current == upper->left->left ) { /* upper->left is red */ tmp_node = upper->left; upper->left = tmp_node->right; } else { /* current == upper->left->right */ /* upper->left is red */ tmp_node = upper->left; upper->left = tmp_node->left; } } /* end current->key < upper->key */ else { /* leaf to the right, current->key >= upper->key */ if ( current == upper->right ) { /* upper->left is red */ tmp_node = upper->left; upper->key = tmp_node->key; upper->left = tmp_node->left; upper->right = tmp_node->right; } else if ( current == upper->right->right ) { /* upper->right is red */ tmp_node = upper->right; upper->right = tmp_node->left; } else { /* current == upper->right->left */ /* upper->right is red */ tmp_node = upper->right; upper->right = tmp_node->right; } } /* end current->key >= upper->key */ return_node( tmp_node ); return_node( current ); } return ( deleted_object ); } } void check_tree(tree_node_t* tr, int count, int lower, int upper) { if ( tr->left == NULL ) { printf("Tree Empty\n"); return; } if ( tr->key < lower || tr->key >= upper ) { printf("Wrong Key Order: node key %d, lower %d, upper %d \n", tr->key, lower, upper); } if ( tr->right == NULL ) { /* leaf */ if ( *( (int*) tr->left) == 10 * tr->key + 2 ) { printf("%d(%d) ", tr->key, count + (tr->color == black) ); } else { printf("Wrong Object \n"); } } else { /* not leaf */ if ( tr->color == red ) { if ( tr->left->color == red ) { printf("wrong color below red key %d on the left\n", tr->key ); } if ( tr->right->color == red ) { printf("wrong color below red key %d on the right\n", tr->key ); } } check_tree(tr->left, count + (tr->color == black), lower, tr->key ); check_tree(tr->right, count + (tr->color == black), tr->key, upper ); } } // _____________________________________________________________________________ // Sample test int main() { tree_node_t* searchtree; char nextop; searchtree = create_tree(); printf("Made Tree: Red-Black Tree with Top-Down Rebalancing\n"); while ( (nextop = getchar()) != 'q' ) { if ( nextop == 'i' ) { int inskey, *insobj, success; insobj = (int*) malloc(sizeof(int)); scanf(" %d", &inskey); *insobj = 10 * inskey + 2; success = insert( searchtree, inskey, insobj ); if ( success == 0 ) printf(" insert successful, key = %d, object value = %d,\n", inskey, *insobj ); else { printf(" insert failed, success = %d\n", success); } } if ( nextop == 'f' ) { int findkey, *findobj; scanf(" %d", &findkey); findobj = find( searchtree, findkey); if ( findobj == NULL ) { printf(" find failed, for key %d\n", findkey); } else { printf(" find successful, found object %d\n", *findobj); } } if ( nextop == 'd' ) { int delkey, *delobj; scanf(" %d", &delkey); delobj = delete ( searchtree, delkey); if ( delobj == NULL ) { printf(" delete failed for key %d\n", delkey); } else printf(" delete successful, deleted object %d\n", *delobj); } if ( nextop == '?' ) { printf(" Checking tree\n"); check_tree(searchtree, 0, -100000, 100000); printf("\n"); if ( searchtree->left != NULL ) { printf("key in root is %d,\n", searchtree->key); } printf(" Finished Checking tree\n"); } } return (0); }
the_stack_data/94523.c
/* v3_akey_asn1.c */ /* * Written by Dr Stephen N Henson ([email protected]) for the OpenSSL project * 1999. */ /* ==================================================================== * Copyright (c) 1999 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 "stdio.h" #include "openssl/asn1.h" #include "openssl/asn1t.h" #include "openssl/conf.h" #include "openssl/x509v3.h" ASN1_SEQUENCE(AUTHORITY_KEYID) = { ASN1_IMP_OPT(AUTHORITY_KEYID, keyid, ASN1_OCTET_STRING, 0), ASN1_IMP_SEQUENCE_OF_OPT(AUTHORITY_KEYID, issuer, GENERAL_NAME, 1), ASN1_IMP_OPT(AUTHORITY_KEYID, serial, ASN1_INTEGER, 2) } ASN1_SEQUENCE_END(AUTHORITY_KEYID) IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_KEYID)
the_stack_data/1083974.c
#include <stdio.h> #include <stdlib.h> int main() { int n, num1, num2, result; char option; do { printf("\nwhat operation do you want to do?\n"); printf("press 1 for addition\n"); printf("press 2 for subtraction\n"); printf("press 3 for multiplication\n"); printf("press 4 for division\n"); scanf("%d", &n); printf("Please enter a number\n"); scanf("%d", &num1); printf("Please enter a second number\n"); scanf("%d", &num2); switch(n) { case 1:result=num1+num2; printf("Addition of two numbers is %d", result); break; case 2:result=num1-num2; printf("Subtraction of two numbers is %d", result); break; case 3:result=num1*num2; printf("Multiplication of two numbers is %d", result); break; case 4:result=num1/num2; printf("Division of two numbers is %d", result); break; default:printf("Wrong input!"); } printf("\n do you want to continue y/n?\n"); option=getche(); } while(option=='y'); return 0; }
the_stack_data/68889027.c
#include <pthread.h> #include <signal.h> #include <stdlib.h> #include <fcntl.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/time.h> #include <sys/wait.h> #include <setjmp.h> #include <time.h> #define MAX_THREADS 128 #define MAX_QUEUE 129 #define INTERVAL 50 enum STATE { ACTIVE, READY, EXITED }; struct ThreadControlBlock { pthread_t ThreadID; unsigned long *ESP; enum STATE Status; void *(*start_routine)(void *); void *arg; jmp_buf Registers; }; struct TCBPool { /* Maximum 129 concurrent running threads including main thread whose TCB Index is 0 */ struct ThreadControlBlock TCB[MAX_THREADS + 1]; }; struct queue { int front; /* Init 0 */ int rear; /* Init -1 */ int itemCount; /* Init 0 */ int IndexQueue[MAX_QUEUE]; }; int peekfront(struct queue *Queue); int size(struct queue *Queue); void pushback(struct queue *Queue, int Index); void pushsecond(struct queue *Queue, int Index); int popfront(struct queue *Queue); void Scheduler(); void WrapperFunction(); static long int i64_ptr_mangle(long int p); struct queue SchedulerThreadPoolIndexQueue = {0, -1, 0}; struct TCBPool ThreadPool; static int Initialized = 0; static int NextCreateTCBIndex = 1; static unsigned long ThreadID = 1; static struct sigaction sigact; static struct itimerval Timer; static struct itimerval Zero_Timer = {0}; void WrapperFunction() { int TCBIndex = peekfront(&SchedulerThreadPoolIndexQueue); ThreadPool.TCB[TCBIndex].start_routine(ThreadPool.TCB[TCBIndex].arg); pthread_exit(0); } void main_thread_init() { int i; for (i = 1; i < MAX_THREADS + 1; i++) { ThreadPool.TCB[i].Status = EXITED; } Initialized = 1; /* Main thread TCB Index is 0 and Main thread ID is 99999 */ ThreadPool.TCB[0].ThreadID = 99999; ThreadPool.TCB[0].Status = ACTIVE; ThreadPool.TCB[0].ESP = NULL; ThreadPool.TCB[0].start_routine = NULL; ThreadPool.TCB[0].arg = NULL; setjmp(ThreadPool.TCB[0].Registers); pushback(&SchedulerThreadPoolIndexQueue, 0); sigact.sa_handler = Scheduler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = SA_NODEFER; if (sigaction(SIGALRM, &sigact, NULL) == -1) { perror("Unable to catch SIGALRM!"); exit(1); } Timer.it_value.tv_sec = INTERVAL / 1000; Timer.it_value.tv_usec = (INTERVAL * 1000) % 1000000; Timer.it_interval = Timer.it_value; if (setitimer(ITIMER_REAL, &Timer, NULL) == -1) { perror("Error calling setitimer()"); exit(1); } } int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { /* If not initialized, initialize thread pool */ if (!Initialized) { /* Initialize the main thread pool */ main_thread_init(); } if (size(&SchedulerThreadPoolIndexQueue) < MAX_QUEUE) { /* Pause Timer */ setitimer(ITIMER_REAL, &Zero_Timer, &Timer); /* Find the next available Thread Pool slot */ int i; for (i = 1; i < MAX_QUEUE; i++) { if (ThreadPool.TCB[i].Status == EXITED) { NextCreateTCBIndex = i; break; } } /* Initialize for the chosen slot */ ThreadPool.TCB[NextCreateTCBIndex].ThreadID = ThreadID++; ThreadPool.TCB[NextCreateTCBIndex].ESP = (unsigned long *)malloc(32767); ThreadPool.TCB[NextCreateTCBIndex].Status = ACTIVE; ThreadPool.TCB[NextCreateTCBIndex].start_routine = start_routine; ThreadPool.TCB[NextCreateTCBIndex].arg = arg; *thread = ThreadPool.TCB[NextCreateTCBIndex].ThreadID; /* Setjmp */ setjmp(ThreadPool.TCB[NextCreateTCBIndex].Registers); /* Save the address of Wrapper Function to a pointer */ void (*WrapperFunctionPointer)() = &WrapperFunction; /* Change External Stack Pointer in the jmp_buf */ ThreadPool.TCB[NextCreateTCBIndex].Registers[0].__jmpbuf[6] = i64_ptr_mangle((unsigned long)(ThreadPool.TCB[NextCreateTCBIndex].ESP + 32759 / 8 - 2)); /* Change External Instruction Pointer to Wrapper Function in the jmp_buf */ ThreadPool.TCB[NextCreateTCBIndex].Registers[0].__jmpbuf[7] = i64_ptr_mangle((unsigned long)WrapperFunctionPointer); /* Add the New Thread Thread Pool Index to the second place in the Queue in case of segfault when freeing esp of last thread with high index*/ pushsecond(&SchedulerThreadPoolIndexQueue, NextCreateTCBIndex); /* Resume Timer */ setitimer(ITIMER_REAL, &Timer, NULL); return 0; } /* Reach the Max number of concurrent threads and return -1 as error */ else { return -1; } } pthread_t pthread_self(void) { return (pthread_t)ThreadPool.TCB[peekfront(&SchedulerThreadPoolIndexQueue)].ThreadID; } void pthread_exit(void *value_ptr) { /* If no pthread_create call, only main */ if (Initialized == 0) { exit(0); } int Index = popfront(&SchedulerThreadPoolIndexQueue); /* Stop Timer */ setitimer(ITIMER_REAL, &Zero_Timer, NULL); /* If exit last thread, first free, and then exit */ if (size(&SchedulerThreadPoolIndexQueue) == 0) { if (Index != 0) { free((unsigned long *)ThreadPool.TCB[Index].ESP); } exit(0); } /* Clean Up */ if (Index != 0) { free((unsigned long *)ThreadPool.TCB[Index].ESP); } ThreadPool.TCB[Index].ThreadID = 0; ThreadPool.TCB[Index].ESP = NULL; ThreadPool.TCB[Index].start_routine = NULL; ThreadPool.TCB[Index].arg = NULL; ThreadPool.TCB[Index].Status = EXITED; /* Start Timer */ setitimer(ITIMER_REAL, &Timer, NULL); /* Longjmp to the front(next) thread registers */ longjmp(ThreadPool.TCB[peekfront(&SchedulerThreadPoolIndexQueue)].Registers, 1); } void Scheduler() { /* If only one main thread, just return */ if (size(&SchedulerThreadPoolIndexQueue) <= 1) { return; } if (setjmp(ThreadPool.TCB[peekfront(&SchedulerThreadPoolIndexQueue)].Registers) == 0) { /* Pushback the poped front Thread Pool Index of the saved thread to the end of queue */ int Index = peekfront(&SchedulerThreadPoolIndexQueue); pushback(&SchedulerThreadPoolIndexQueue, Index); popfront(&SchedulerThreadPoolIndexQueue); /* Longjmp to the front(next) thread registers */ longjmp(ThreadPool.TCB[peekfront(&SchedulerThreadPoolIndexQueue)].Registers, 1); } return; } int peekfront(struct queue *Queue) { return Queue->IndexQueue[Queue->front]; } int size(struct queue *Queue) { return Queue->itemCount; } void pushback(struct queue *Queue, int Index) { if (Queue->rear == MAX_QUEUE - 1) { Queue->rear = -1; } Queue->rear += 1; Queue->IndexQueue[Queue->rear] = Index; Queue->itemCount += 1; } void pushsecond(struct queue *Queue, int Index) { if (Queue->rear == MAX_QUEUE - 1) { Queue->rear = -1; } Queue->rear += 1; int i; for (i = Queue->rear; i > Queue->front + 1; i--) { Queue->IndexQueue[i] = Queue->IndexQueue[i-1]; } Queue->IndexQueue[Queue->front + 1] = Index; Queue->itemCount += 1; } int popfront(struct queue *Queue) { int Index = Queue->IndexQueue[Queue->front]; Queue->front += 1; if (Queue->front == MAX_QUEUE) { Queue->front = 0; } Queue->itemCount -= 1; return Index; } static long int i64_ptr_mangle(long int p) { long int ret; asm(" mov %1, %%rax;\n" " xor %%fs:0x30, %%rax;" " rol $0x11, %%rax;" " mov %%rax, %0;" : "=r"(ret) : "r"(p) : "%rax"); return ret; }
the_stack_data/156393729.c
// RUN: clang-cc -dM -undef -Dfoo=1 -E %s | FileCheck %s // CHECK-NOT: #define __clang__ // CHECK: #define foo 1
the_stack_data/26700040.c
#include <stdlib.h> int main(void) { void *ptr1 = realloc(NULL, sizeof(char)); if (ptr1 == NULL) return EXIT_SUCCESS; char *ptr2 = realloc(ptr1, 2 * sizeof(char)); *ptr2 = 'A'; /* error */ free(ptr2 != NULL ? ptr2 : ptr1); } /** * @file 0049-test.c * * @brief Usage of pointer after possible realloc failure. */
the_stack_data/876444.c
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <pthread.h> #include <sys/types.h> #include <sys/syscall.h> #define VMAX 5 #define INCREMENT_THREAD_NUMBER 3 #define RESET_THREAD_NUMBER 1 pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; int x = 0; void* increment(void* thread_number) { pthread_mutex_lock(&lock); int i = *(int*) thread_number; printf("increment%d : before x=%d\n", i+1, x); x++; printf("after x=%d\n", x); sleep(1); pthread_mutex_unlock(&lock); pthread_exit(NULL); } void* reset(void* thread_number) { pthread_mutex_lock(&lock); int i = *(int*) thread_number; printf("reset%d : before x=%d\n", i+1, x); if (x >= VMAX) { x = 0; } printf("after x=%d\n", x); sleep(1); pthread_mutex_unlock(&lock); pthread_exit(NULL); } int main(int argc, char** argv) { int i; pthread_t increment_thread[INCREMENT_THREAD_NUMBER]; pthread_t reset_thread[RESET_THREAD_NUMBER]; while (1) { for (i = 0; i < INCREMENT_THREAD_NUMBER; i++) { printf("--- this is increment%d ---\n", i+1); pthread_create(&increment_thread[i], NULL, increment, (void*)&i); } for (i = 0; i < RESET_THREAD_NUMBER; i++) { printf("=== this is reset%d ===\n", i+1); pthread_create(&reset_thread[i], NULL, reset, (void*)&i); } pthread_join(increment_thread[0], NULL); } return EXIT_SUCCESS; }
the_stack_data/165769004.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <getopt.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> #include <signal.h> #include <poll.h> #include <string.h> #define PRINT_STREAM_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) int verbose_flag = 0; FILE* log_stream; FILE* debug_stream; FILE* print_stream_in; FILE* print_stream_out; //void onExit(int p); //const struct sigaction on_exit_act = { // .sa_handler = onExit, //.sa_sigaction = NULL, //.sa_mask = 0, //.sa_flags = 0, //.sa_restorer = NULL, //}; int main(int argc, char* argv[]) { int i; int rv; int c; int err; int status = 0; int pipefd[2]; pid_t child; log_stream = stdout; debug_stream = stderr; char *printer_name_r = NULL; char *printer_name_w = NULL; char *line = NULL; char *temp = NULL; char *arguments[4]; FILE *write_end; while((c = getopt(argc, argv, "f:d:n:v?")) != -1) { switch(c) { case 'f': // log stream file log_stream = freopen(optarg, "w", stdout); if(log_stream == NULL){ perror("freopen"); abort(); } break; case 'd': // debug stream file debug_stream = freopen(optarg, "w", stderr); break; case 'n': // printer name printer_name_r = calloc(13 + strlen(optarg), sizeof(char)); if(printer_name_r == NULL){ perror("calloc"); abort(); } printer_name_w = calloc(13 + strlen(optarg), sizeof(char)); if(printer_name_w == NULL){ perror("calloc"); abort(); } strncat(printer_name_r, "./drivers/", 10); strncat(printer_name_r, optarg, strlen(optarg)); strncat(printer_name_r, "-r", 2); strncat(printer_name_w, "./drivers/", 10); strncat(printer_name_w, optarg, strlen(optarg)); strncat(printer_name_w, "-w", 2); break; case 'v': // turn on verbose mode verbose_flag = 1; break; case '?': // print help information fprintf(stderr, "%s\n", argv[0]); break; } } line = calloc(1024, sizeof(char)); if(line == NULL){ perror("calloc"); abort(); } // replace the constant string with `printer_name` later rv = mkfifo(printer_name_r, PRINT_STREAM_MODE); if(rv) { perror("mkfifo()"); abort(); } rv = mkfifo(printer_name_w, PRINT_STREAM_MODE); if(rv){ perror("mkfifo()"); abort(); } //sigaction(9,&on_exit_act, NULL); printf("Switching to background\n");fflush(stdout); daemon(1, 1); print_stream_in = fopen(printer_name_r, "r"); if(!print_stream_in) { perror("fopen()"); abort(); } print_stream_out = fopen(printer_name_w, "w"); if(!print_stream_out){ perror("fopen()"); abort(); } // 1. watch the fifo/print stream // 2. when the print stream is not empty, assume the first line is meta data // 3. create an unnamed pipe // 4. fork // 5. change stdin of the child to be the pipe // 6. call `ps2pdf - job_name` // 7. copy data from the fifo to the pipe until `##END##` is reached // 8. wait for the next job while(!feof(print_stream_in)){ // read the first line fgets(line, 1024, print_stream_in); // if it returns, that means something was sent to the fifo if(verbose_flag) printf("line recieved\n"); fflush(stdout); printf("%s", line); fflush(stdout); // see if the line is "##NAME##" if(!strncmp(line, "##NAME##\n", 9)){ if(verbose_flag){ printf("found ##NAME##\n"); fflush(stdout); } fprintf(print_stream_out, "%s\n", printer_name_r); fflush(print_stream_out); }else if(!strncmp(line, "##DESCRIPTION##\n", 16)){ if(verbose_flag){ printf("found ##DESCRIPTION##\n"); fflush(stdout); } fprintf(print_stream_out, "a generic printer\n"); fflush(print_stream_out); }else if(!strncmp(line, "##LOCATION##\n", 13)){ if(verbose_flag){ printf("found ##LOCATION##\n"); fflush(stdout); } fprintf(print_stream_out, "center of a black hole\n"); fflush(print_stream_out); }else if(!strncmp(line, "##END##\n", 8)){ continue; }else{ // parse out the file name from the first line temp = strtok(line, ": "); if(temp == NULL){ printf("invalid format\n"); fflush(stdout); continue; } if(verbose_flag) printf("temp: %s\n", temp); fflush(stdout); temp = strtok(NULL, ": "); if(temp != NULL){ temp[strlen(temp) - 3] = '\0'; if(verbose_flag) printf("temp: %s\n", temp); fflush(stdout); }else{ fprintf(stderr, "invalid name for output file\n"); fflush(stderr); continue; } // create the argument array arguments[0] = "ps2pdf"; arguments[1] = "-"; arguments[2] = strdup(temp); arguments[3] = NULL; if(verbose_flag){ printf("created the argument array, it's contents:\n"); for(i = 0; i < 4; i++){ printf("arguments[%d]: %s\n", i, arguments[i]); fflush(stdout); } } // create an unnamed pipe err = pipe(pipefd); if(err){ perror("pipe"); abort(); } if(verbose_flag) printf("created an unnamed pipe\n"); fflush(stdout); // fork a child child = fork(); // if child if(child == 0){ // close the write end of pipe file descriptor for the read side close(pipefd[1]); // reopen stdin file handle using the read end of the pipe dup2(pipefd[0], fileno(stdin)); if(verbose_flag) printf("duplicated read end of pipe to stdin\n"); fflush(stdout); // call `ps2pdf - job_name` execvp(arguments[0], arguments); // if execvp fails perror("execvp"); close(pipefd[0]); close(pipefd[1]); // if parent }else{ // close the read end close(pipefd[0]); // read data from print_stream and write it to the write end of the pipe // but only until the line "##END##" is reached write_end = fdopen(pipefd[1], "w"); if(write_end == NULL){ perror("fdopen"); abort(); } if(verbose_flag) printf("opened the write end of the pipe as FILE *\n"); fflush(stdout); fgets(line, 1024, print_stream_in); if(verbose_flag) printf("line: %s", line); fflush(stdout); while(strncmp(line, "##END##", 7)){ fprintf(write_end, "%s", line); fflush(write_end); fgets(line, 1024, print_stream_in); if(verbose_flag) printf("line: %s", line); fflush(stdout); } // once "##END##" is reached, read one last time, and close the write end of pipe if(verbose_flag) printf("reached the ##END##\n"); fflush(stdout); fclose(write_end); write_end = 0; // wait for child to exit wait(&status); //fclose(write_end); } } } free(line); if(-1 != lseek(fileno(print_stream_in), 1, SEEK_CUR)){ fclose(print_stream_in); } fclose(print_stream_out); unlink(printer_name_r); unlink(printer_name_w); free(printer_name_r); free(printer_name_w); return 0; } //void onExit(int p) //{ //fclose(print_stream_in); //fclose(print_stream_out); //remove("./drivers/printer1"); //}
the_stack_data/145056.c
char aoutcode[] = {0x7f, 0x45, 0x4c, 0x46, 0x1, 0x2, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x8, 0x0, 0x0, 0x0, 0x1, 0x0, 0x40, 0x0, 0xb0, 0x0, 0x0, 0x0, 0x34, 0x0, 0x0, 0xf, 0xb0, 0x50, 0x0, 0x10, 0x1, 0x0, 0x34, 0x0, 0x20, 0x0, 0x3, 0x0, 0x28, 0x0, 0xd, 0x0, 0xa, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x94, 0x0, 0x40, 0x0, 0x94, 0x0, 0x40, 0x0, 0x94, 0x0, 0x0, 0x0, 0x18, 0x0, 0x0, 0x0, 0x18, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x94, 0x0, 0x40, 0x0, 0x94, 0x0, 0x40, 0x0, 0x94, 0x0, 0x0, 0xc, 0xb2, 0x0, 0x0, 0xc, 0xb2, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0xd, 0x50, 0x10, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x10, 0xa0, 0x1, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x7f,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, 0x6, 0x60, 0x0, 0x40, 0x4, 0xd4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x70, 0x61, 0x6e, 0x69, 0x63, 0x20, 0x61, 0x74, 0x20, 0x25, 0x73, 0x3a, 0x25, 0x64, 0x3a, 0x20, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x47, 0x43, 0x43, 0x3a, 0x20, 0x28, 0x47, 0x4e, 0x55, 0x29, 0x20, 0x34, 0x2e, 0x30, 0x2e, 0x30, 0x20, 0x28, 0x44, 0x45, 0x4e, 0x58, 0x20, 0x45, 0x4c, 0x44, 0x4b, 0x20, 0x34, 0x2e, 0x31, 0x20, 0x34, 0x2e, 0x30, 0x2e, 0x30, 0x29, 0x0, 0x0, 0x47, 0x43, 0x43, 0x3a, 0x20, 0x28, 0x47, 0x4e, 0x55, 0x29, 0x20, 0x34, 0x2e, 0x30, 0x2e, 0x30, 0x20, 0x28, 0x44, 0x45, 0x4e, 0x58, 0x20, 0x45, 0x4c, 0x44, 0x4b, 0x20, 0x34, 0x2e, 0x31, 0x20, 0x34, 0x2e, 0x30, 0x2e, 0x30, 0x29, 0x0, 0x0, 0x47, 0x43, 0x43, 0x3a, 0x20, 0x28, 0x47, 0x4e, 0x55, 0x29, 0x20, 0x34, 0x2e, 0x30, 0x2e, 0x30, 0x20, 0x28, 0x44, 0x45, 0x4e, 0x58, 0x20, 0x45, 0x4c, 0x44, 0x4b, 0x20, 0x34, 0x2e, 0x31, 0x20, 0x34, 0x2e, 0x30, 0x2e, 0x30, 0x29, 0x0, 0x0, 0x47, 0x43, 0x43, 0x3a, 0x20, 0x28, 0x47, 0x4e, 0x55, 0x29, 0x20, 0x34, 0x2e, 0x30, 0x2e, 0x30, 0x20, 0x28, 0x44, 0x45, 0x4e, 0x58, 0x20, 0x45, 0x4c, 0x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5f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x0, 0x5f, 0x70, 0x61, 0x6e, 0x69, 0x63, 0x0, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x73, 0x74, 0x72, 0x0, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x0, 0x5f, 0x66, 0x64, 0x61, 0x74, 0x61, 0x0, 0x5f, 0x67, 0x70, 0x0, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x4e, 0x75, 0x6d, 0x0, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x63, 0x68, 0x61, 0x72, 0x63, 0x0, 0x5f, 0x66, 0x74, 0x65, 0x78, 0x74, 0x0, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0, 0x5f, 0x5f, 0x62, 0x73, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x0, 0x6d, 0x61, 0x69, 0x6e, 0x0, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x43, 0x68, 0x61, 0x72, 0x0, 0x5f, 0x65, 0x64, 0x61, 0x74, 0x61, 0x0, 0x5f, 0x65, 0x6e, 0x64, 0x0, 0x68, 0x61, 0x6c, 0x74, 0x0, 0x5f, 0x66, 0x62, 0x73, 0x73, 0x0}; char boutcode[] = {0x7f, 0x45, 0x4c, 0x46, 0x1, 0x2, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x8, 0x0, 0x0, 0x0, 0x1, 0x0, 0x40, 0x0, 0xb0, 0x0, 0x0, 0x0, 0x34, 0x0, 0x0, 0xf, 0xb0, 0x50, 0x0, 0x10, 0x1, 0x0, 0x34, 0x0, 0x20, 0x0, 0x3, 0x0, 0x28, 0x0, 0xd, 0x0, 0xa, 0x70, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x94, 0x0, 0x40, 0x0, 0x94, 0x0, 0x40, 0x0, 0x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0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x3, 0x68, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x3, 0xec, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x4, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x5, 0x48, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40, 0x6, 0x60, 0x0, 0x40,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10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0xff, 0xf1, 0x0, 0x0, 0x0, 0xaf, 0x0, 0x40, 0x0, 0xf4, 0x0, 0x0, 0x0, 0x14, 0x12, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0xb4, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0xff, 0xf1, 0x0, 0x69, 0x6e, 0x2e, 0x63, 0x0, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x63, 0x0, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x2e, 0x63, 0x0, 0x74, 0x68, 0x65, 0x46, 0x61, 0x74, 0x61, 0x6c, 0x4d, 0x73, 0x67, 0x0, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x2e, 0x63, 0x0, 0x6d, 0x79, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x0, 0x6c, 0x70, 0x5f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x0, 0x5f, 0x70, 0x61, 0x6e, 0x69, 0x63, 0x0, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x73, 0x74, 0x72, 0x0, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x0, 0x5f, 0x66, 0x64, 0x61, 0x74, 0x61, 0x0, 0x5f, 0x67, 0x70, 0x0, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x4e, 0x75, 0x6d, 0x0, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x63, 0x68, 0x61, 0x72, 0x63, 0x0, 0x5f, 0x66, 0x74, 0x65, 0x78, 0x74, 0x0, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0, 0x5f, 0x5f, 0x62, 0x73, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x0, 0x6d, 0x61, 0x69, 0x6e, 0x0, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x43, 0x68, 0x61, 0x72, 0x0, 0x5f, 0x65, 0x64, 0x61, 0x74, 0x61, 0x0, 0x5f, 0x65, 0x6e, 0x64, 0x0, 0x68, 0x61, 0x6c, 0x74, 0x0, 0x5f, 0x66, 0x62, 0x73, 0x73, 0x0};
the_stack_data/305204.c
#include <curses.h> int main(void) { initscr(); waddstr(curscr, "test thingy"); // refresh(); getch(); endwin(); return 0; }
the_stack_data/61076429.c
#define E0 ((type *)10000000) #define reg0 r0 #define indreg0 (*p0) #define imm0 22 #define limm0 ((type)(int)&glob0) #define adr0 (*E0) #define adrreg0 (p0[10000000]) #define adrx0 (E0[x0]) #define regx0 (p0[x0]) #define E1 ((type *)11111111) #define reg1 r1 #define indreg1 (*p1) #define imm1 33 #define limm1 ((type)(int)&glob1) #define adr1 (*E1) #define adrreg1 (p1[1111111/4]) #define adrx1 (E1[x1]) #define regx1 (p1[x1]) int glob0, glob1; #define type short reg0reg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {reg0 = reg1; } reg0indreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {reg0 = indreg1; } reg0imm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {reg0 = imm1; } reg0limm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {reg0 = limm1; } reg0adr1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {reg0 = adr1; } reg0adrreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {reg0 = adrreg1; } reg0adrx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {reg0 = adrx1; } reg0regx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {reg0 = regx1; } indreg0reg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {indreg0 = reg1; } indreg0indreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {indreg0 = indreg1; } indreg0imm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {indreg0 = imm1; } indreg0limm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {indreg0 = limm1; } indreg0adr1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {indreg0 = adr1; } indreg0adrreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {indreg0 = adrreg1; } indreg0adrx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {indreg0 = adrx1; } indreg0regx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {indreg0 = regx1; } adr0reg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adr0 = reg1; } adr0indreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adr0 = indreg1; } adr0imm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adr0 = imm1; } adr0limm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adr0 = limm1; } adr0adr1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adr0 = adr1; } adr0adrreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adr0 = adrreg1; } adr0adrx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adr0 = adrx1; } adr0regx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adr0 = regx1; } adrreg0reg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrreg0 = reg1; } adrreg0indreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrreg0 = indreg1; } adrreg0imm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrreg0 = imm1; } adrreg0limm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrreg0 = limm1; } adrreg0adr1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrreg0 = adr1; } adrreg0adrreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrreg0 = adrreg1; } adrreg0adrx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrreg0 = adrx1; } adrreg0regx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrreg0 = regx1; } adrx0reg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrx0 = reg1; } adrx0indreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrx0 = indreg1; } adrx0imm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrx0 = imm1; } adrx0limm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrx0 = limm1; } adrx0adr1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrx0 = adr1; } adrx0adrreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrx0 = adrreg1; } adrx0adrx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrx0 = adrx1; } adrx0regx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {adrx0 = regx1; } regx0reg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {regx0 = reg1; } regx0indreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {regx0 = indreg1; } regx0imm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {regx0 = imm1; } regx0limm1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {regx0 = limm1; } regx0adr1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {regx0 = adr1; } regx0adrreg1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {regx0 = adrreg1; } regx0adrx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {regx0 = adrx1; } regx0regx1_set (r0, r1, x0, x1, p0, p1) type r0, r1; type *p0, *p1; {regx0 = regx1; }
the_stack_data/896102.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_replace.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: abenaiss <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/10/16 23:48:54 by abenaiss #+# #+# */ /* Updated: 2018/10/16 23:48:57 by abenaiss ### ########.fr */ /* */ /* ************************************************************************** */ char *ft_replace(char *str, char a, char b) { int i; i = 0; while (str[i]) { if (str[i] == a) str[i] = b; i++; } return (str); }
the_stack_data/743728.c
// // Created by James Miles on 31/08/2021. // #include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { char *delivery = ""; int thick = 0; int count = 0; char ch; while ( (ch = getopt(argc, argv, "d:t")) != EOF) // 'd' is followed by : as it takes an argument switch (ch) { case 'd': delivery = optarg; // delivery variable points to the argument supplied with the 'd' option break; case 't': // in C setting something to '1' is the same as setting it to true thick = 1; break; default: fprintf(stderr, "Unknown option: '%s'\n", optarg); return 1; } argc -= optind; argv += optind; if (thick) puts("Thick crust."); if (delivery[0]) printf("To be delivered %s.\n", delivery); puts("Ingredients:"); for (count = 0; count < argc; count++ ) puts(argv[count]); return 0; }
the_stack_data/248580589.c
char *ft_strupcase(char *str) { int i; i = 0; while (str[i] != '\0') { if (str[i] >= 'a' && str[i] <= 'z') { str[i] = str[i] - 32; } i++; } return (str); }
the_stack_data/86075076.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_ANZAHL 8 #define MAX_ZEICHEN 13 void ausgabe(char txt[MAX_ANZAHL][MAX_ZEICHEN]) { for(int i = 0; i < MAX_ANZAHL; i++){ printf("%s, ", txt[i]); } } void sortieren(char txt[MAX_ANZAHL][MAX_ZEICHEN]) { char tmp[15]; for(int i = 0; i < MAX_ANZAHL; i++){ for(int j = 0; j < MAX_ANZAHL - 1 - i; j++){ if(strcmp(txt[j], txt[j+1]) > 0){ strcpy(tmp, txt[j]); strcpy(txt[j], txt[j+1]); strcpy(txt[j+1], tmp); } } } } int main() { char namelist[8][13] = {"Sebastian", "Matteo", "Oliver", "Jakob", "Elias", "Jan", "Tobias", "Erik"}; printf("Unsortiert: \n"); ausgabe(namelist); printf("\nSortiert:\n"); sortieren(namelist); ausgabe(namelist); return 0; }
the_stack_data/108001.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_is_sort.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lteresia <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/09/15 17:07:34 by lteresia #+# #+# */ /* Updated: 2021/09/15 21:47:51 by lteresia ### ########.fr */ /* */ /* ************************************************************************** */ int ft_is_sort(int *tab, int length, int(*f)(int, int)) { int i; int sorted_asc; int sorted_des; i = 0; sorted_asc = 1; sorted_des = 1; while (i < length - 1) { if ((*f)(tab[i], tab[i + 1]) > 0) sorted_asc = 0; if ((*f)(tab[i], tab[i + 1]) < 0) sorted_des = 0; i++; } if (sorted_asc || sorted_des) return (1); return (0); }
the_stack_data/153268376.c
/* * Copyright (c) 1998 by The XFree86 Project, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE XFREE86 PROJECT 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 XFree86 Project shall * not be used in advertising or otherwise to promote the sale, use or other * dealings in this Software without prior written authorization from the * XFree86 Project. */ /* $XFree86: xc/lib/Xmu/Clip.c,v 1.1 1998/08/16 10:25:03 dawes Exp $ */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> #include <X11/IntrinsicP.h> #include <X11/Xmu/Xmu.h> #define XmuMax(a, b) ((a) > (b) ? (a) : (b)) #define XmuMin(a, b) ((a) < (b) ? (a) : (b)) /* * Function: * XmuNewArea * * Parameters: * x1 - Coordinates of the rectangle * y1 - "" * x2 - "" * y2 - "" * * Description: * Creates a new rectangular clipping area */ XmuArea * XmuNewArea(int x1, int y1, int x2, int y2) { XmuArea *area; area = (XmuArea *)XtMalloc(sizeof(XmuArea)); if (x2 > x1 && y2 > y1) { area->scanline = XmuNewScanline(y1, x1, x2); area->scanline->next = XmuNewScanline(y2, 0, 0); } else area->scanline = (XmuScanline *)NULL; return (area); } /* * Function: * XmuAreaDup * * Parameters: * area - Area to copy * * Description: * Returns a copy of its argument */ XmuArea * XmuAreaDup(XmuArea *area) { XmuArea *dst; if (!area) return ((XmuArea *)NULL); dst = XmuCreateArea(); XmuAreaCopy(dst, area); return (dst); } /* * Function: * XmuAreaCopy * * Parameters: * dst - destination area * src - source area * * Description: * Minimizes memory alocation, trying to use already alocated memory * in dst, freeing what is not required anymore. */ XmuArea * XmuAreaCopy(XmuArea *dst, XmuArea *src) { XmuScanline *z, *p, *Z; if (!dst || !src || dst == src) return (dst); z = p = dst->scanline; Z = src->scanline; /*CONSTCOND*/ while (1) { if (!Z) { if (z == dst->scanline) { XmuDestroyScanlineList(dst->scanline); dst->scanline = (XmuScanline *)NULL; } else { XmuDestroyScanlineList(p->next); p->next = (XmuScanline *)NULL; } return (dst); } if (z) { XmuScanlineCopy(z, Z); z->y = Z->y; } else { z = XmuNewScanline(Z->y, 0, 0); XmuScanlineCopy(z, Z); if (p == dst->scanline && !dst->scanline) p = dst->scanline = z; else p->next = z; } p = z; z = z->next; Z = Z->next; } return (dst); } /* * Function: * XmuAreaNot * * Parameters: * area - area to operate * x1 - retangle to clip the result against * y1 - "" * x2 - "" * y2 - "" * * Description: * (Input) * (x1, y1) (x2, y1) * +-------------+ * +------------+ +----+ * | +--------------+ * +----------------+ * (x1, y2) (x2, y2) * * (Output) * (x1, y1) (x2, y1) * +--------------+ +--------------------------+ * | +------------+ +----+ | * | | +--------------+ | * +-+ +------------------------------------+ * (x1, y2) (x2, y2) */ XmuArea * XmuAreaNot(XmuArea *area, int x1, int y1, int x2, int y2) { XmuScanline *z; XmuArea *and; if (!area) return (area); if (x1 > x2) { x1 ^= x2; x2 ^= x1; x1 ^= x2; } if (y1 > y2) { y1 ^= y2; y2 ^= y1; y1 ^= y2; } if (!area->scanline) { if ((area->scanline = XmuNewScanline(y1, x1, x2)) != NULL) area->scanline->next = XmuNewScanline(y2, 0, 0); return (area); } and = XmuNewArea(x1, y1, x2, y2); XmuAreaAnd(area, and); XmuDestroyArea(and); z = area->scanline; if (z->y != y1) { XmuScanline *q = XmuNewScanline(y1, x1, x2); q->next = z; area->scanline = q; } else { area->scanline = area->scanline->next; XmuDestroyScanline(z); XmuOptimizeArea(area); if((z = area->scanline) == (XmuScanline *)NULL) return (area); } /* CONSTCOND */ while (1) { XmuScanlineNot(z, x1, x2); if (!z->next) { z->next = XmuNewScanline(y2, 0, 0); break; } if (z->next->y == y2) { XmuDestroyScanlineList(z->next); z->next = XmuNewScanline(y2, 0, 0); break; } z = z->next; } return (area); } /* * Function: * XmuAreaOrXor * * Parameters: * dst - destination area * src - source area * or - or operation if true, else xor operation * * Description: * Executes Or (Union) or Xor (Reverse intesection) of the areas */ XmuArea * XmuAreaOrXor(XmuArea *dst, XmuArea *src, Bool or) { XmuScanline *z, *p, *Z, *P, *ins, *top; if (!dst || !src) return (dst); if (dst == src) { if (or) return (dst); XmuDestroyScanlineList(dst->scanline); dst->scanline = (XmuScanline *)NULL; return (dst); } if (!XmuValidArea(src)) return (dst); if (!XmuValidArea(dst)) { XmuAreaCopy(dst, src); return (dst); } p = z = dst->scanline; P = Z = src->scanline; ins = XmuNewScanline(dst->scanline->y, 0, 0); top = XmuNewScanline(dst->scanline->y, 0, 0); XmuScanlineCopy(ins, dst->scanline); XmuScanlineCopy(top, dst->scanline); /*CONSTCOND*/ while (1) { if (!Z) break; else if (Z->y < z->y) { XmuScanline *q = XmuNewScanline(Z->y, 0, 0); XmuScanlineCopy(q, Z); if (z == dst->scanline) { dst->scanline = p = q; q->next = z; } else { p->next = q; q->next = z; if (Z->y >= p->y) { if (ins->y >= top->y && (p->y != P->y || !XmuScanlineEqu(p, P) || (ins->y <= P->y && !XmuScanlineEqu(ins, P)))) { if (or) XmuScanlineOr(q, ins); else XmuScanlineXor(q, ins); } else if (Z->y >= top->y && (top->y == p->y || top->y > ins->y || !XmuValidScanline(Z) || (p->y == P->y && XmuValidScanline(p) && XmuValidScanline(P)) || XmuScanlineEqu(ins, top))) { if (or) XmuScanlineOr(q, top); else XmuScanlineXor(q, top); } if (ins->y != p->y && p->y != P->y) { XmuScanlineCopy(ins, p); ins->y = p->y; } } if (!XmuValidScanline(p) || Z->y <= p->y) { XmuScanlineCopy(top, p); top->y = p->y; } p = q; } P = Z; Z = Z->next; continue; } else if (Z->y == z->y) { if (top->y != z->y) { XmuScanlineCopy(top, z); top->y = z->y; } if (or) XmuScanlineOr(z, Z); else XmuScanlineXor(z, Z); P = Z; Z = Z->next; } else if (P != Z) /* && Z->y > z->y */ { if (top->y == ins->y && top->y != z->y) { XmuScanlineCopy(top, z); top->y = z->y; } if (ins->y != z->y) { XmuScanlineCopy(ins, z); ins->y = z->y; } if (or) XmuScanlineOr(z, P); else XmuScanlineXor(z, P); } else if (ins->y != z->y) { XmuScanlineCopy(ins, z); ins->y = z->y; } p = z; z = z->next; if (!z) { while (Z) { p->next = XmuNewScanline(Z->y, 0, 0); XmuScanlineCopy(p->next, Z); p = p->next; Z = Z->next; } break; } else if (ins->y > top->y && !XmuValidScanline(z) && XmuValidScanline(ins)) { XmuScanlineCopy(top, ins); top->y = ins->y; } } XmuOptimizeArea(dst); XmuDestroyScanline(ins); XmuDestroyScanline(top); return (dst); } /* * Function: * XmuAreaAnd(dst, src) * * Parameters: * dst - destination area * src - source area * * Description: * Executes And (intersection) of the areas */ XmuArea * XmuAreaAnd(XmuArea *dst, XmuArea *src) { XmuScanline *z, *p, *Z, *P, *top; if (!dst || !src || dst == src) return (dst); if (!XmuValidArea(dst) || !XmuValidArea(src)) { XmuDestroyScanlineList(dst->scanline); dst->scanline = (XmuScanline *)NULL; return (dst); } z = p = dst->scanline; Z = P = src->scanline; top = XmuNewScanline(dst->scanline->y, 0, 0); XmuScanlineCopy(top, dst->scanline); while (z) { while (Z->next && Z->next->y < z->y) { P = Z; Z = Z->next; if (Z->y >= p->y) { XmuScanline *q = XmuNewScanline(Z->y, 0, 0); XmuScanlineCopy(q, Z); XmuScanlineAnd(q, top); if (p->y != P->y) { XmuScanlineAnd(p, P); p->y = XmuMax(p->y, P->y); } p->next = q; q->next = z; p = q; } } if (!z->next) { z->y = XmuMax(z->y, Z->y); break; } while (Z->y >= z->next->y) { if (z == dst->scanline) { p = dst->scanline = dst->scanline->next; XmuDestroyScanline(z); z = dst->scanline; } else { p->next = z->next; XmuDestroyScanline(z); z = p; } if (!z || !z->next) { XmuOptimizeArea(dst); XmuDestroyScanline(top); return (dst); } } if (Z->y > p->y) z->y = XmuMax(z->y, Z->y); if (top->y != z->y) { XmuScanlineCopy(top, z); top->y = z->y; } XmuScanlineAnd(z, Z); p = z; z = z->next; } XmuOptimizeArea(dst); XmuDestroyScanline(top); return (dst); } /* * Function: * XmuValidArea(area) * * Parameters: * area - area to verify * * Description: * Verifies if the area is valid and/or useful */ Bool XmuValidArea(XmuArea *area) { XmuScanline *at; if (!area || !area->scanline) return (False); at = area->scanline; while (at) { if (XmuValidScanline(at)) return (True); at = at->next; } return (False); } /* * Function: * XmuValidScanline * * Parameters: * scanline - scanline to verify * * Description: * Verifies if a scanline is useful */ Bool XmuValidScanline(XmuScanline *scanline) { XmuSegment *z; if (!scanline) return (False); z = scanline->segment; while (z) { if (XmuValidSegment(z)) return (True); z = z->next; } return (False); } /* * Function: * XmuScanlineEqu * * Parameters: * s1 - scanline 1 * s2 - scanline 2 * * Description: * Checks if s1 and s2 are equal */ Bool XmuScanlineEqu(XmuScanline *s1, XmuScanline *s2) { XmuSegment *z, *Z; if ((!s1 && !s2) || s1 == s2) return (True); if (!s1 || !s2) return (False); z = s1->segment; Z = s2->segment; /*CONSTCOND*/ while (1) { if (!z && !Z) return (True); if (!z || !Z) return (False); if (!XmuSegmentEqu(z, Z)) return (False); z = z->next; Z = Z->next; } /*NOTREACHED*/ } /* * Function: * XmuNewSegment * * Parameters: * x1 - coordinates of the segment * x2 - "" * * Description: * Creates a new segments with the coordinates x1 and x2 * * Returns: * New Segment of NULL */ XmuSegment * XmuNewSegment(int x1, int x2) { XmuSegment *segment; if ((segment = (XmuSegment *)XtMalloc(sizeof(XmuSegment))) == NULL) return (segment); segment->x1 = x1; segment->x2 = x2; segment->next = (XmuSegment *)NULL; return (segment); } /* * Function: * XmuDestroySegmentList * * Parameters: * segment - Segment to destroy * * Description: * Frees the memory used by the list headed by segment */ void XmuDestroySegmentList(XmuSegment *segment) { XmuSegment *z; if (!segment) return; while (segment) { z = segment; segment = segment->next; XmuDestroySegment(z); } } /* * Function: * XmuScanlineCopy * * Parameters: * dst - destination scanline * src - source scanline * * Description: * Makes dst contain the same data as src */ XmuScanline * XmuScanlineCopy(XmuScanline *dst, XmuScanline *src) { XmuSegment *z, *p, *Z; if (!dst || !src || dst == src) return (dst); z = p = dst->segment; Z = src->segment; /*CONSTCOND*/ while (1) { if (!Z) { if (z == dst->segment) dst->segment = (XmuSegment *)NULL; else p->next = (XmuSegment *)NULL; XmuDestroySegmentList(z); return (dst); } if (z) { z->x1 = Z->x1; z->x2 = Z->x2; } else { z = XmuNewSegment(Z->x1, Z->x2); if (p == dst->segment && !dst->segment) p = dst->segment = z; else p->next = z; } p = z; z = z->next; Z = Z->next; } /*NOTREACHED*/ } /* * Function: * XmuAppendSegment * * Parameters: * segment - destination segment * append - segment to add * * Description: * Adds a copy of the append list at the end of the segment list */ Bool XmuAppendSegment(XmuSegment *segment, XmuSegment *append) { if (!segment || !append) return (False); if (segment->next) /* Should not happen! */ XmuDestroySegmentList(segment->next); while (append) { if (XmuValidSegment(append)) { if ((segment->next = XmuNewSegment(append->x1, append->x2)) == NULL) return (False); segment = segment->next; } append = append->next; } return (True); } /* * Function: * XmuOptimizeScanline * * Parameters: * scanline - scanline to optimize * * Description: * Some functions, when transforming Segments of Scanlines, left these * with unnecessary data (that may cause error in these same functions). * This function corrects these incorrect segments. */ XmuScanline * XmuOptimizeScanline(XmuScanline *scanline) { XmuSegment *z, *p; while (scanline->segment && !XmuValidSegment(scanline->segment)) { XmuSegment *s = scanline->segment; scanline->segment = scanline->segment->next; XmuDestroySegment(s); } for (z = p = scanline->segment; z; p = z, z = z->next) { if (!XmuValidSegment(z)) { p->next = z->next; XmuDestroySegment(z); z = p; } } return (scanline); } /* * Name: * XmuScanlineNot(scanline, minx, maxx) * * Parameters: * scanline - scanlines operate * minx - minimum x coordinate * maxx - maximum x coordinate * * Description: * (minx) (maxx) * + + * (input) +---------+ +--------+ +--------+ * (output) +-----+ +-----+ +--------+ +------------+ */ XmuScanline * XmuScanlineNot(XmuScanline *scanline, int minx, int maxx) { XmuSegment *z; static XmuSegment x = { 0, 0, 0 }; static XmuScanline and = { 0, &x, 0 }; if (!scanline) return (scanline); XmuOptimizeScanline(scanline); if (minx > maxx) { minx ^= maxx; maxx ^= minx; minx ^= maxx; } and.segment->x1 = minx; and.segment->x2 = maxx; XmuScanlineAnd(scanline, &and); if (!scanline->segment) { scanline->segment = XmuNewSegment(minx, maxx); return (scanline); } z = scanline->segment; if (z->x1 != minx) { XmuSegment *q = XmuNewSegment(minx, z->x1); q->next = z; scanline->segment = q; } /*CONSTCOND*/ while (1) { z->x1 = z->x2; if (!z->next) { z->x2 = maxx; break; } z->x2 = z->next->x1; if (z->next->x2 == maxx) { XmuDestroySegment(z->next); z->next = (XmuSegment *)NULL; break; } z = z->next; } return (scanline); } #ifndef notdef /* * Function: * XmuScanlineOrSegment * * Parameters: * dst - destionation scanline * src - source segment * * Description: * (input) +-----------+ +--------+ +---------+ * (src) +-------------------+ * (output) +-------------------------+ +---------+ */ XmuScanline * XmuScanlineOrSegment(XmuScanline *dst, XmuSegment *src) { XmuSegment *z, *p, ins; if (!src || !dst || !XmuValidSegment(src)) return (dst); if (!dst->segment) { dst->segment = XmuNewSegment(src->x1, src->x2); return (dst); } z = p = dst->segment; ins.x1 = src->x1; ins.x2 = src->x2; /*CONSTCOND*/ while (1) { if (!z) { XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); if (p == dst->segment && z == p) dst->segment = q; else p->next = q; break; } else if (ins.x2 < z->x1) { XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); if (p == dst->segment && z == p) { q->next = dst->segment; dst->segment = q; } else { p->next = q; q->next = z; } break; } else if (ins.x2 <= z->x2) { z->x1 = XmuMin(z->x1, ins.x1); break; } else if (ins.x1 <= z->x2) { ins.x1 = XmuMin(z->x1, ins.x1); if (!z->next) { z->x1 = ins.x1; z->x2 = ins.x2; break; } else { if (z == dst->segment) { p = dst->segment = dst->segment->next; XmuDestroySegment(z); z = dst->segment; continue; } else { p->next = z->next; XmuDestroySegment(z); z = p; } } } p = z; z = z->next; } return (dst); } /* * Function: * XmuScanlineAndSegment * * Parameters: * dst - destination scanline * src - source segment * * Description: * (input) +------------+ +------+ +----------+ * (src) +---------------------+ * (output) +-------+ +------+ */ XmuScanline * XmuScanlineAndSegment(XmuScanline *dst, XmuSegment *src) { XmuSegment *z, *p; if (!dst || !src) return (dst); if (!XmuValidSegment(src)) { XmuDestroySegmentList(dst->segment); dst->segment = (XmuSegment *)NULL; return (dst); } if (!dst->segment) return (dst); z = p = dst->segment; while (z) { if (src->x2 <= z->x1 || src->x1 >= z->x2) { if (z == dst->segment) { p = dst->segment = dst->segment->next; XmuDestroySegment(z); z = dst->segment; continue; } else { p->next = z->next; XmuDestroySegment(z); z = p; } } else { z->x1 = XmuMax(z->x1, src->x1); z->x2 = XmuMin(z->x2, src->x2); } p = z; z = z->next; } return (dst); } /* * Function: * XmuScanlineXorSegment * * Parameters: * dst - destionation scanline * src - source segment * * Descriptipn: * (input) +------------+ +----------+ +-----------+ * (src) +------------------------+ * (output) +---+ +--+ +-+ +-----------+ */ XmuScanline * XmuScanlineXorSegment(XmuScanline *dst, XmuSegment *src) { XmuSegment *p, *z, ins; int tmp1, tmp2; if (!dst || !src || !XmuValidSegment(src)) return (dst); if (!dst->segment) { dst->segment = XmuNewSegment(src->x1, src->x2); return (dst); } p = z = dst->segment; ins.x1 = src->x1; ins.x2 = src->x2; /*CONSTCOND*/ while (1) { if (!XmuValidSegment((&ins))) break; if (!z || ins.x2 < z->x1) { XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); q->next = z; if (z == dst->segment) dst->segment = q; else p->next = q; break; } else if (ins.x2 == z->x1) { z->x1 = ins.x1; break; } else if (ins.x1 < z->x2) { if (ins.x1 < z->x1) { tmp1 = ins.x2; tmp2 = z->x2; ins.x2 = XmuMax(ins.x2, z->x2); z->x2 = z->x1; z->x1 = ins.x1; ins.x1 = XmuMin(tmp1, tmp2); } else if (ins.x1 > z->x1) { tmp1 = ins.x1; ins.x1 = XmuMin(ins.x2, z->x2); ins.x2 = XmuMax(z->x2, ins.x2); z->x2 = tmp1; } else /* ins.x1 == z->x1 */ { if (ins.x2 < z->x2) { z->x1 = ins.x2; break; } else { ins.x1 = z->x2; if (z == dst->segment) p = dst->segment = dst->segment->next; else p->next = z->next; XmuDestroySegment(z); z = p; continue; } } } else if (ins.x1 == z->x2) { ins.x1 = z->x1; if (z == dst->segment) p = dst->segment = dst->segment->next; else p->next = z->next; XmuDestroySegment(z); z = p; continue; } p = z; z = z->next; } return (dst); } #endif /* notdef */ /* * Function: * ScanlineOr * * Parameters: * dst - destionation scanline * src - source scanline * * Description: * (input) +--------------+ +-----+ +----------+ * (src) +---------------------+ +-----------+ * (output) +-------------------------+ +----------------+ */ XmuScanline * XmuScanlineOr(XmuScanline *dst, XmuScanline *src) { XmuSegment *z, *p, *Z, ins; if (!src || !src->segment || !dst || dst == src) return (dst); if (!dst->segment) { XmuScanlineCopy(dst, src); return (dst); } z = p = dst->segment; Z = src->segment; ins.x1 = Z->x1; ins.x2 = Z->x2; /*CONSTCOND*/ while (1) { while (!XmuValidSegment((&ins))) { if ((Z = Z->next) == (XmuSegment *)NULL) return (dst); ins.x1 = Z->x1; ins.x2 = Z->x2; } if (!z) { XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); if (p == dst->segment && z == p) dst->segment = p = q; else { p->next = q; p = q; } Z = Z->next; XmuAppendSegment(p, Z); break; } else if (ins.x2 < z->x1) { XmuSegment *r = XmuNewSegment(ins.x1, ins.x2); if (p == dst->segment && z == p) { r->next = dst->segment; dst->segment = p = r; } else { p->next = r; r->next = z; p = r; } Z = Z->next; if (!Z) break; else { ins.x1 = Z->x1; ins.x2 = Z->x2; continue; } } else if (ins.x2 <= z->x2) { z->x1 = XmuMin(z->x1, ins.x1); Z = Z->next; if (!Z) break; else { ins.x1 = Z->x1; ins.x2 = Z->x2; continue; } } else if (ins.x1 <= z->x2) { ins.x1 = XmuMin(z->x1, ins.x1); if (!z->next) { z->x1 = ins.x1; z->x2 = ins.x2; p = z; Z = Z->next; XmuAppendSegment(p, Z); break; } else { if (z == dst->segment) { p = dst->segment = dst->segment->next; XmuDestroySegment(z); z = p; continue; } else { p->next = z->next; XmuDestroySegment(z); z = p; } } } p = z; z = z->next; } return (dst); } /* * Function: * XmuScanlineAnd * * Parameters: * dst - destination scanline * src - source scanline * * Description: * (input) +--------------+ +-----+ +----------+ * (src) +---------------------+ +-----------+ * (output) +----------+ +-----+ +-----+ */ XmuScanline * XmuScanlineAnd(XmuScanline *dst, XmuScanline *src) { XmuSegment *z, *p, *Z; if (!dst || !src || dst == src || !dst->segment) { return (dst); } if (!src->segment) { XmuDestroySegmentList(dst->segment); dst->segment = (XmuSegment *)NULL; return (dst); } z = p = dst->segment; Z = src->segment; while (z) { while (!XmuValidSegment(Z) || Z->x2 <= z->x1) { Z = Z->next; if (!Z) { if (z == dst->segment) dst->segment = (XmuSegment *)NULL; else p->next = (XmuSegment *)0; XmuDestroySegmentList(z); return (dst); } } if (Z->x1 >= z->x2) { if (z == dst->segment) { p = dst->segment = dst->segment->next; XmuDestroySegment(z); z = dst->segment; } else { p->next = z->next; XmuDestroySegment(z); z = p->next; } if (!z) return (dst); else continue; } z->x1 = XmuMax(z->x1, Z->x1); if (z->x2 > Z->x2) { if (Z->next) { XmuSegment *q = XmuNewSegment(Z->x2, z->x2); q->next = z->next; z->next = q; } z->x2 = Z->x2; } p = z; z = z->next; } return (dst); } /* * Function: * ScanlineXor * * Parameters: * dst - destination scanline * src - source scanline * * Description: * (input) +--------------+ +-----+ +----------+ * (src) +---------------------+ +-----------+ * (output) +---+ +--+ +-+ +----+ +-----+ */ XmuScanline * XmuScanlineXor(XmuScanline *dst, XmuScanline *src) { XmuSegment *z, *p, *Z, ins; int tmp1, tmp2; if (!src || !dst || !src->segment) return (dst); if (src == dst) { XmuDestroySegmentList(dst->segment); dst->segment = (XmuSegment *)NULL; return (dst); } if (!dst->segment) { XmuScanlineCopy(dst, src); return (dst); } z = p = dst->segment; Z = src->segment; ins.x1 = Z->x1; ins.x2 = Z->x2; /*CONSTCOND*/ while (1) { while (!XmuValidSegment((&ins))) { if ((Z = Z->next) == (XmuSegment *)NULL) return (dst); ins.x1 = Z->x1; ins.x2 = Z->x2; } if (!z) { XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); if (!dst->segment) dst->segment = q; else p->next = q; p = q; Z = Z->next; XmuAppendSegment(p, Z); break; } else if (ins.x2 < z->x1) { XmuSegment *q = XmuNewSegment(ins.x1, ins.x2); q->next = z; if (z == dst->segment) dst->segment = q; else p->next = q; if ((Z = Z->next) == (XmuSegment *)NULL) return (dst); p = q; ins.x1 = Z->x1; ins.x2 = Z->x2; continue; } else if (ins.x2 == z->x1) { z->x1 = ins.x1; if ((Z = Z->next) == (XmuSegment *)NULL) break; ins.x1 = Z->x1; ins.x2 = Z->x2; continue; } else if (ins.x1 < z->x2) { if (ins.x1 == z->x1) { if (ins.x2 < z->x2) { z->x1 = ins.x2; if ((Z = Z->next) == (XmuSegment *)NULL) break; ins.x1 = Z->x1; ins.x2 = Z->x2; continue; } else { ins.x1 = z->x2; if (z == dst->segment) p = dst->segment = dst->segment->next; else p->next = z->next; XmuDestroySegment(z); z = p; continue; } } else { if (Z->x2 < z->x2) { XmuSegment *q = XmuNewSegment(XmuMin(ins.x1, z->x1), XmuMax(z->x1, ins.x1)); q->next = z; if (z == dst->segment) dst->segment = q; else p->next = q; ins.x1 = z->x2; z->x1 = ins.x2; p = q; continue; } else { tmp1 = ins.x2; tmp2 = z->x2; ins.x2 = XmuMax(ins.x2, z->x2); z->x2 = XmuMax(z->x1, ins.x1); z->x1 = XmuMin(ins.x1, z->x1); ins.x1 = XmuMin(tmp1, tmp2); } } } else if (ins.x1 == z->x2) { ins.x1 = z->x1; if (z == dst->segment) p = dst->segment = dst->segment->next; else p->next = z->next; XmuDestroySegment(z); z = p; continue; } p = z; z = z->next; } return (dst); } /* * Function: * XmuNewScanline * * Parameters: * y - y coordinate * x1 - left coordinate * x2 - right coordinate * * Description: * Creates a new Scanline */ XmuScanline * XmuNewScanline(int y, int x1, int x2) { XmuScanline *scanline; scanline = (XmuScanline *)XtMalloc(sizeof(XmuScanline)); scanline->y = y; if (x1 < x2) scanline->segment = XmuNewSegment(x1, x2); else scanline->segment = (XmuSegment *)NULL; scanline->next = (XmuScanline *)NULL; return (scanline); } /* * Function: * XmuDestroyScanlineList * * Parameters: * scanline - scanline list to destroy * * Description: * Destroy a scanline list * * Observation: * Use as follow: * XmuDestroyScanlineList(area->scanline); * area->scanline = (XmuScanline *)NULL; */ void XmuDestroyScanlineList(XmuScanline *scanline) { XmuScanline *z; if (!scanline) return; while (scanline) { z = scanline; scanline = scanline->next; XmuDestroyScanline(z); } } /* * Function: * XmuOptimizeArea * * Parameters: * area - area to optimize * * Description: * Optimizes an area. This function is called when finishing a * operation between areas, since they can end with redundant data, * and the algorithms for area combination waits a area with * correct data (but can left unnecessary data in the area, to avoid * to much paranoia tests). */ XmuArea *XmuOptimizeArea(XmuArea *area) { XmuScanline *pr, *at; if (!area || !area->scanline) return (area); if (!area->scanline->next) { XmuDestroyScanlineList(area->scanline); area->scanline = (XmuScanline *)0; return (area); } pr = area->scanline; at = area->scanline->next; while (area->scanline && (!XmuValidScanline(area->scanline) || (area->scanline->next && area->scanline->y >= area->scanline->next->y))) { area->scanline = area->scanline->next; XmuDestroyScanline(pr); pr = area->scanline; if (pr) at = pr->next; } for (; at; pr = at, at = at->next) { if (XmuScanlineEqu(at, pr) || (!XmuValidScanline(at) && !XmuValidScanline(pr)) || (at->next && at->y >= at->next->y)) { pr->next = at->next; XmuDestroyScanline(at); at = pr; } } if (pr && XmuValidScanline(pr)) { XmuDestroySegmentList(pr->segment); pr->segment = (XmuSegment *)NULL; } if (area->scanline && !area->scanline->next) { XmuDestroyScanlineList(area->scanline); area->scanline = (XmuScanline *)NULL; } return (area); }
the_stack_data/248581601.c
#ifdef STM32F0xx #include "stm32f0xx_hal_cortex.c" #endif #ifdef STM32F1xx #include "stm32f1xx_hal_cortex.c" #endif #ifdef STM32F2xx #include "stm32f2xx_hal_cortex.c" #endif #ifdef STM32F3xx #include "stm32f3xx_hal_cortex.c" #endif #ifdef STM32F4xx #include "stm32f4xx_hal_cortex.c" #endif #ifdef STM32F7xx #include "stm32f7xx_hal_cortex.c" #endif #ifdef STM32H7xx #include "stm32h7xx_hal_cortex.c" #endif #ifdef STM32L0xx #include "stm32l0xx_hal_cortex.c" #endif #ifdef STM32L1xx #include "stm32l1xx_hal_cortex.c" #endif #ifdef STM32L4xx #include "stm32l4xx_hal_cortex.c" #endif
the_stack_data/109389.c
// // liste implementasyonu // Created by Nurefsan Sertbas on 11/10/2017. // #include <stdio.h> #include <stdlib.h> struct node { int data; struct node *next; }; struct node *head = NULL; //listenin basi struct node *last = NULL; //listenin sonu void displayList(); void insertNode(int); void deleteNode(int); void searchNode(int); int isEmpty(); int main () { int selection; while (1) { printf ("*** *** ***\n"); printf (" 1 --> insert \n"); printf (" 2 --> remove \n"); printf (" 3 --> display \n"); printf (" 4 --> search \n"); printf (" 5 --> EXIT \n"); printf ("*** *** ***\n"); int x,flag; printf ("Seçiminizi girin: "); scanf ("%d", &selection); switch (selection){ case 1: printf("Eklemek istediginiz sayiyi giriniz:"); scanf("%d", &x); insertNode(x); break; case 2: flag=isEmpty(); if(flag!=1){ //listede eleman varsa printf("Silmek istediginiz elemani giriniz:"); scanf("%d", &x); deleteNode(x);} break; case 3: displayList(); break; case 4: flag=isEmpty(); if(flag!=1){ //listede eleman varsa printf("Aramak istediginiz sayiyi giriniz:"); scanf("%d", &x); searchNode(x);} break; case 5: return 0; } } return 0; } //fonskiyonlar void displayList() { struct node *ptr = head; if(isEmpty()==1)//listede eleman yok return; //else kismi printf("\n[ "); while(ptr != NULL) { printf("%d ",ptr->data); ptr = ptr->next; } printf(" ]\n"); } void insertNode(int data) { struct node *ptr = (struct node*) malloc(sizeof(struct node)); if (ptr == NULL) { printf("Bellekte yeterli alan yok !\n"); return; } ptr->data = data; ptr->next=NULL; if(head==NULL) //ilk node head=last=ptr; else{ last->next=ptr; last=ptr; } } void deleteNode(int x) { if(head==NULL) {printf("Listede hic eleman yok !\n"); return;} else{ struct node *p; struct node *previous=head; for(p=head;p!=NULL;p=p->next) //listeyi geziyoruz { if(p->data==x) //eleman bulundu { //case1:ilk eleman silinmek isteniyor if(p==head) { head=head->next; free(p); printf("%d basariyla listeden silindi\n",x); return; } //case2:son eleman silinmek isteniyor if(p==last){ previous->next=p->next; //p->next=NULL zaten last=previous; free(p); printf("%d basariyla listeden silindi\n",x); return; } //case3:aradan eleman silinmek isteniyor previous->next=p->next; free(p); printf("%d basariyla listeden silindi\n",x); return; } previous=p; } //for bitti ama hala return etmedi yani eleman bulunamadi printf("Aranan eleman listede bulunamadi\n"); return; } } void searchNode(int x) { int counter=0; struct node* ptr = head; if(isEmpty()==1)//listede eleman yok return; counter=1; while(ptr->data != x) { if(ptr->next == NULL) { //son node a geldi hala bulamadi printf("Listede aranan eleman yok\n"); return;} else { ptr = ptr->next; counter=counter+1; } } printf("Aranan eleman listede %d. sirada\n",counter); } int isEmpty(){ if(head==NULL){ printf("Listede hic eleman yok !\n"); return 1;} else return 0; }
the_stack_data/31387384.c
/* * Copyright 2015 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifdef DRV_MEDIATEK // clang-format off #include <fcntl.h> #include <poll.h> #include <stdio.h> #include <string.h> #include <sys/mman.h> #include <unistd.h> #include <xf86drm.h> #include <mediatek_drm.h> // clang-format on #include "drv_priv.h" #include "helpers.h" #include "util.h" #define TILE_TYPE_LINEAR 0 struct mediatek_private_map_data { void *cached_addr; void *gem_addr; int prime_fd; }; static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888 }; static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID }; static int mediatek_init(struct driver *drv) { struct format_metadata metadata; drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats), &LINEAR_METADATA, BO_USE_RENDER_MASK); drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats), &LINEAR_METADATA, BO_USE_TEXTURE_MASK); /* Android CTS tests require this. */ drv_add_combination(drv, DRM_FORMAT_BGR888, &LINEAR_METADATA, BO_USE_SW_MASK); /* Support BO_USE_HW_VIDEO_DECODER for protected content minigbm allocations. */ metadata.tiling = TILE_TYPE_LINEAR; metadata.priority = 1; metadata.modifier = DRM_FORMAT_MOD_LINEAR; drv_modify_combination(drv, DRM_FORMAT_YVU420, &metadata, BO_USE_HW_VIDEO_DECODER); drv_modify_combination(drv, DRM_FORMAT_YVU420_ANDROID, &metadata, BO_USE_HW_VIDEO_DECODER); return drv_modify_linear_combinations(drv); } static int mediatek_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, uint64_t use_flags) { int ret; size_t plane; uint32_t stride; struct drm_mtk_gem_create gem_create; /* * Since the ARM L1 cache line size is 64 bytes, align to that as a * performance optimization. */ stride = drv_stride_from_format(format, width, 0); stride = ALIGN(stride, 64); drv_bo_from_format(bo, stride, height, format); memset(&gem_create, 0, sizeof(gem_create)); gem_create.size = bo->total_size; ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MTK_GEM_CREATE, &gem_create); if (ret) { drv_log("DRM_IOCTL_MTK_GEM_CREATE failed (size=%llu)\n", gem_create.size); return ret; } for (plane = 0; plane < bo->num_planes; plane++) bo->handles[plane].u32 = gem_create.handle; return 0; } static void *mediatek_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) { int ret, prime_fd; struct drm_mtk_gem_map_off gem_map; struct mediatek_private_map_data *priv; memset(&gem_map, 0, sizeof(gem_map)); gem_map.handle = bo->handles[0].u32; ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MTK_GEM_MAP_OFFSET, &gem_map); if (ret) { drv_log("DRM_IOCTL_MTK_GEM_MAP_OFFSET failed\n"); return MAP_FAILED; } ret = drmPrimeHandleToFD(bo->drv->fd, gem_map.handle, DRM_CLOEXEC, &prime_fd); if (ret) { drv_log("Failed to get a prime fd\n"); return MAP_FAILED; } void *addr = mmap(0, bo->total_size, drv_get_prot(map_flags), MAP_SHARED, bo->drv->fd, gem_map.offset); vma->length = bo->total_size; priv = calloc(1, sizeof(*priv)); priv->prime_fd = prime_fd; vma->priv = priv; if (bo->use_flags & BO_USE_RENDERSCRIPT) { priv->cached_addr = calloc(1, bo->total_size); priv->gem_addr = addr; addr = priv->cached_addr; } return addr; } static int mediatek_bo_unmap(struct bo *bo, struct vma *vma) { if (vma->priv) { struct mediatek_private_map_data *priv = vma->priv; if (priv->cached_addr) { vma->addr = priv->gem_addr; free(priv->cached_addr); } close(priv->prime_fd); free(priv); vma->priv = NULL; } return munmap(vma->addr, vma->length); } static int mediatek_bo_invalidate(struct bo *bo, struct mapping *mapping) { struct mediatek_private_map_data *priv = mapping->vma->priv; if (priv) { struct pollfd fds = { .fd = priv->prime_fd, }; if (mapping->vma->map_flags & BO_MAP_WRITE) fds.events |= POLLOUT; if (mapping->vma->map_flags & BO_MAP_READ) fds.events |= POLLIN; poll(&fds, 1, -1); if (fds.revents != fds.events) drv_log("poll prime_fd failed\n"); if (priv->cached_addr) memcpy(priv->cached_addr, priv->gem_addr, bo->total_size); } return 0; } static int mediatek_bo_flush(struct bo *bo, struct mapping *mapping) { struct mediatek_private_map_data *priv = mapping->vma->priv; if (priv && priv->cached_addr && (mapping->vma->map_flags & BO_MAP_WRITE)) memcpy(priv->gem_addr, priv->cached_addr, bo->total_size); return 0; } static uint32_t mediatek_resolve_format(uint32_t format, uint64_t use_flags) { switch (format) { case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED: /*HACK: See b/28671744 */ return DRM_FORMAT_XBGR8888; case DRM_FORMAT_FLEX_YCbCr_420_888: return DRM_FORMAT_YVU420; default: return format; } } const struct backend backend_mediatek = { .name = "mediatek", .init = mediatek_init, .bo_create = mediatek_bo_create, .bo_destroy = drv_gem_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = mediatek_bo_map, .bo_unmap = mediatek_bo_unmap, .bo_invalidate = mediatek_bo_invalidate, .bo_flush = mediatek_bo_flush, .resolve_format = mediatek_resolve_format, }; #endif
the_stack_data/915320.c
// General tests that ld invocations on Linux targets sane. Note that we use // sysroot to make these tests independent of the host system. // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD-32 %s // CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o" // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0" // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." // CHECK-LD-32: "-L[[SYSROOT]]/lib" // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-unknown-linux \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD-64 %s // CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-LD-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0" // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." // CHECK-LD-64: "-L[[SYSROOT]]/lib" // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -m32 \ // RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-32-TO-32 %s // CHECK-32-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-32-TO-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o" // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0" // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib32" // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib32" // CHECK-32-TO-32: "-L[[SYSROOT]]/lib/../lib32" // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32" // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." // CHECK-32-TO-32: "-L[[SYSROOT]]/lib" // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -m64 \ // RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-32-TO-64 %s // CHECK-32-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-32-TO-64: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o" // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/64" // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib64" // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib64" // CHECK-32-TO-64: "-L[[SYSROOT]]/lib/../lib64" // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64" // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0" // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." // CHECK-32-TO-64: "-L[[SYSROOT]]/lib" // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-unknown-linux -m64 \ // RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-64-TO-64 %s // CHECK-64-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-64-TO-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0" // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib64" // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib64" // CHECK-64-TO-64: "-L[[SYSROOT]]/lib/../lib64" // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64" // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." // CHECK-64-TO-64: "-L[[SYSROOT]]/lib" // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-unknown-linux -m32 \ // RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-64-TO-32 %s // CHECK-64-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-64-TO-32: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib32" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib32" // CHECK-64-TO-32: "-L[[SYSROOT]]/lib/../lib32" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." // CHECK-64-TO-32: "-L[[SYSROOT]]/lib" // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-unknown-linux -m32 \ // RUN: -gcc-toolchain %S/Inputs/multilib_64bit_linux_tree/usr \ // RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-64-TO-32-SYSROOT %s // CHECK-64-TO-32-SYSROOT: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-64-TO-32-SYSROOT: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o" // CHECK-64-TO-32-SYSROOT: "-L{{[^"]*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32" // CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/lib/../lib32" // CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/usr/lib/../lib32" // CHECK-64-TO-32-SYSROOT: "-L{{[^"]*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0" // CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/lib" // CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -m32 \ // RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-32 %s // CHECK-INSTALL-DIR-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-INSTALL-DIR-32: "{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o" // CHECK-INSTALL-DIR-32: "-L{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0" // // Check that with 64-bit builds, we don't actually use the install directory // as its version of GCC is lower than our sysrooted version. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-unknown-linux -m64 \ // RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-64 %s // CHECK-INSTALL-DIR-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-INSTALL-DIR-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" // CHECK-INSTALL-DIR-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0" // // Check that we support unusual patch version formats, including missing that // component. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -m32 \ // RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing1/bin \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION1 %s // CHECK-GCC-VERSION1: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-GCC-VERSION1: "{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7/crtbegin.o" // CHECK-GCC-VERSION1: "-L{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -m32 \ // RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing2/bin \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION2 %s // CHECK-GCC-VERSION2: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-GCC-VERSION2: "{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o" // CHECK-GCC-VERSION2: "-L{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -m32 \ // RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing3/bin \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION3 %s // CHECK-GCC-VERSION3: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-GCC-VERSION3: "{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o" // CHECK-GCC-VERSION3: "-L{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -m32 \ // RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing4/bin \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION4 %s // CHECK-GCC-VERSION4: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-GCC-VERSION4: "{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o" // CHECK-GCC-VERSION4: "-L{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99" // // Test a very broken version of multiarch that shipped in Ubuntu 11.04. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: --sysroot=%S/Inputs/ubuntu_11.04_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-UBUNTU-11-04 %s // CHECK-UBUNTU-11-04: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-UBUNTU-11-04: "{{.*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o" // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5" // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu" // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu" // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.." // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/lib" // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib" // // Check multi arch support on Ubuntu 12.04 LTS. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-unknown-linux-gnueabihf \ // RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM-HF %s // CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crt1.o" // CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crti.o" // CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o" // CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3" // CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf" // CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/lib/arm-linux-gnueabihf" // CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/arm-linux-gnueabihf" // CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../.." // CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o" // CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crtn.o" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-unknown-linux-gnueabi \ // RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM %s // CHECK-UBUNTU-12-04-ARM: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crt1.o" // CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crti.o" // CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o" // CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1" // CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi" // CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/lib/arm-linux-gnueabi" // CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/arm-linux-gnueabi" // CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../.." // CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o" // CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crtn.o" // // Test the setup that shipped in SUSE 10.3 on ppc64. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target powerpc64-suse-linux \ // RUN: --sysroot=%S/Inputs/suse_10.3_ppc64_tree \ // RUN: | FileCheck --check-prefix=CHECK-SUSE-10-3-PPC64 %s // CHECK-SUSE-10-3-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-SUSE-10-3-PPC64: "{{.*}}/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o" // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64" // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-suse-linux/4.1.2/../../../../lib64" // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/lib/../lib64" // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/../lib64" // // Check dynamic-linker for different archs // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-gnueabi \ // RUN: | FileCheck --check-prefix=CHECK-ARM %s // CHECK-ARM: "{{.*}}ld{{(.exe)?}}" // CHECK-ARM: "-m" "armelf_linux_eabi" // CHECK-ARM: "-dynamic-linker" "{{.*}}/lib/ld-linux.so.3" // // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-gnueabihf \ // RUN: | FileCheck --check-prefix=CHECK-ARM-HF %s // CHECK-ARM-HF: "{{.*}}ld{{(.exe)?}}" // CHECK-ARM-HF: "-m" "armelf_linux_eabi" // CHECK-ARM-HF: "-dynamic-linker" "{{.*}}/lib/ld-linux-armhf.so.3" // // Check that we do not pass --hash-style=gnu and --hash-style=both to linker // and provide correct path to the dynamic linker and emulation mode when build // for MIPS platforms. // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: -target mips-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-MIPS %s // CHECK-MIPS: "{{.*}}ld{{(.exe)?}}" // CHECK-MIPS: "-m" "elf32btsmip" // CHECK-MIPS: "-dynamic-linker" "{{.*}}/lib/ld.so.1" // CHECK-MIPS-NOT: "--hash-style={{gnu|both}}" // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: -target mipsel-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-MIPSEL %s // CHECK-MIPSEL: "{{.*}}ld{{(.exe)?}}" // CHECK-MIPSEL: "-m" "elf32ltsmip" // CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/lib/ld.so.1" // CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}" // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: -target mips64-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64 %s // CHECK-MIPS64: "{{.*}}ld{{(.exe)?}}" // CHECK-MIPS64: "-m" "elf64btsmip" // CHECK-MIPS64: "-dynamic-linker" "{{.*}}/lib64/ld.so.1" // CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}" // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: -target mips64el-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64EL %s // CHECK-MIPS64EL: "{{.*}}ld{{(.exe)?}}" // CHECK-MIPS64EL: "-m" "elf64ltsmip" // CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/lib64/ld.so.1" // CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}" // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: -target mips64-linux-gnu -mabi=n32 \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64-N32 %s // CHECK-MIPS64-N32: "{{.*}}ld{{(.exe)?}}" // CHECK-MIPS64-N32: "-m" "elf32btsmipn32" // CHECK-MIPS64-N32: "-dynamic-linker" "{{.*}}/lib32/ld.so.1" // CHECK-MIPS64-N32-NOT: "--hash-style={{gnu|both}}" // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: -target mips64el-linux-gnu -mabi=n32 \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-N32 %s // CHECK-MIPS64EL-N32: "{{.*}}ld{{(.exe)?}}" // CHECK-MIPS64EL-N32: "-m" "elf32ltsmipn32" // CHECK-MIPS64EL-N32: "-dynamic-linker" "{{.*}}/lib32/ld.so.1" // CHECK-MIPS64EL-N32-NOT: "--hash-style={{gnu|both}}" // // Thoroughly exercise the Debian multiarch environment. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i686-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86 %s // CHECK-DEBIAN-X86: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-X86: "{{.*}}/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o" // CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5" // CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../i386-linux-gnu" // CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu" // CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../.." // CHECK-DEBIAN-X86: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86-64 %s // CHECK-DEBIAN-X86-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-X86-64: "{{.*}}/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o" // CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5" // CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../x86_64-linux-gnu" // CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/x86_64-linux-gnu" // CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../.." // CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target powerpc-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC %s // CHECK-DEBIAN-PPC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-PPC: "{{.*}}/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o" // CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5" // CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../powerpc-linux-gnu" // CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/powerpc-linux-gnu" // CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../.." // CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target powerpc64-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC64 %s // CHECK-DEBIAN-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-PPC64: "{{.*}}/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o" // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5" // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../powerpc64-linux-gnu" // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/powerpc64-linux-gnu" // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../.." // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mips-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS %s // CHECK-DEBIAN-MIPS: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-MIPS: "{{.*}}/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o" // CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5" // CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../../mips-linux-gnu" // CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/mips-linux-gnu" // CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../.." // CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mipsel-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPSEL %s // CHECK-DEBIAN-MIPSEL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-MIPSEL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o" // CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5" // CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../../mipsel-linux-gnu" // CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/mipsel-linux-gnu" // CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.." // CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mips64-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64 %s // CHECK-DEBIAN-MIPS64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-MIPS64: "{{.*}}/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o" // CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/64" // CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5" // CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../.." // CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mips64el-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64EL %s // CHECK-DEBIAN-MIPS64EL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-MIPS64EL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o" // CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/64" // CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5" // CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.." // CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mips64-linux-gnu -mabi=n32 \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64-N32 %s // CHECK-DEBIAN-MIPS64-N32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-MIPS64-N32: "{{.*}}/usr/lib/gcc/mips-linux-gnu/4.5/n32/crtbegin.o" // CHECK-DEBIAN-MIPS64-N32: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/n32" // CHECK-DEBIAN-MIPS64-N32: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5" // CHECK-DEBIAN-MIPS64-N32: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../.." // CHECK-DEBIAN-MIPS64-N32: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-MIPS64-N32: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mips64el-linux-gnu -mabi=n32 \ // RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64EL-N32 %s // CHECK-DEBIAN-MIPS64EL-N32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-MIPS64EL-N32: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.5/n32/crtbegin.o" // CHECK-DEBIAN-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/n32" // CHECK-DEBIAN-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5" // CHECK-DEBIAN-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.." // CHECK-DEBIAN-MIPS64EL-N32: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib" // // Test linker invocation on Android. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID %s // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-android \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID %s // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mipsel-linux-android \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID %s // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-ANDROID: "{{.*}}/crtbegin_dynamic.o" // CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib" // CHECK-ANDROID-NOT: "gcc_s" // CHECK-ANDROID: "-lgcc" // CHECK-ANDROID-NOT: "gcc_s" // CHECK-ANDROID: "{{.*}}/crtend_android.o" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -shared \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-SO %s // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-android \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -shared \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-SO %s // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mipsel-linux-android \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -shared \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-SO %s // CHECK-ANDROID-SO: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-ANDROID-SO: "{{.*}}/crtbegin_so.o" // CHECK-ANDROID-SO: "-L[[SYSROOT]]/usr/lib" // CHECK-ANDROID-SO-NOT: "gcc_s" // CHECK-ANDROID-SO: "-lgcc" // CHECK-ANDROID-SO-NOT: "gcc_s" // CHECK-ANDROID-SO: "{{.*}}/crtend_so.o" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -static \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-android \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -static \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mipsel-linux-android \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -static \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s // CHECK-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-ANDROID-STATIC: "{{.*}}/crtbegin_static.o" // CHECK-ANDROID-STATIC: "-L[[SYSROOT]]/usr/lib" // CHECK-ANDROID-STATIC-NOT: "gcc_s" // CHECK-ANDROID-STATIC: "-lgcc" // CHECK-ANDROID-STATIC-NOT: "gcc_s" // CHECK-ANDROID-STATIC: "{{.*}}/crtend_android.o" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -pie \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-PIE %s // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-android \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -pie \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-PIE %s // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mipsel-linux-android \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -pie \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-PIE %s // CHECK-ANDROID-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-ANDROID-PIE: "{{.*}}/crtbegin_dynamic.o" // CHECK-ANDROID-PIE: "-L[[SYSROOT]]/usr/lib" // CHECK-ANDROID-PIE-NOT: "gcc_s" // CHECK-ANDROID-PIE: "-lgcc" // CHECK-ANDROID-PIE-NOT: "gcc_s" // CHECK-ANDROID-PIE: "{{.*}}/crtend_android.o" // // Check linker invocation on Debian 6 MIPS 32/64-bit. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mipsel-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_6_mips_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPSEL %s // CHECK-DEBIAN-ML-MIPSEL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-ML-MIPSEL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib/crt1.o" // CHECK-DEBIAN-ML-MIPSEL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib/crti.o" // CHECK-DEBIAN-ML-MIPSEL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/crtbegin.o" // CHECK-DEBIAN-ML-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4" // CHECK-DEBIAN-ML-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib" // CHECK-DEBIAN-ML-MIPSEL: "-L[[SYSROOT]]/lib/../lib" // CHECK-DEBIAN-ML-MIPSEL: "-L[[SYSROOT]]/usr/lib/../lib" // CHECK-DEBIAN-ML-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4/../../.." // CHECK-DEBIAN-ML-MIPSEL: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-ML-MIPSEL: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mips64el-linux-gnu \ // RUN: --sysroot=%S/Inputs/debian_6_mips_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPS64EL %s // CHECK-DEBIAN-ML-MIPS64EL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-ML-MIPS64EL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib64/crt1.o" // CHECK-DEBIAN-ML-MIPS64EL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib64/crti.o" // CHECK-DEBIAN-ML-MIPS64EL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/64/crtbegin.o" // CHECK-DEBIAN-ML-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4/64" // CHECK-DEBIAN-ML-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib64" // CHECK-DEBIAN-ML-MIPS64EL: "-L[[SYSROOT]]/lib/../lib64" // CHECK-DEBIAN-ML-MIPS64EL: "-L[[SYSROOT]]/usr/lib/../lib64" // CHECK-DEBIAN-ML-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4/../../.." // CHECK-DEBIAN-ML-MIPS64EL: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-ML-MIPS64EL: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target mips64el-linux-gnu -mabi=n32 \ // RUN: --sysroot=%S/Inputs/debian_6_mips_tree \ // RUN: | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPS64EL-N32 %s // CHECK-DEBIAN-ML-MIPS64EL-N32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-DEBIAN-ML-MIPS64EL-N32: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib32/crt1.o" // CHECK-DEBIAN-ML-MIPS64EL-N32: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib32/crti.o" // CHECK-DEBIAN-ML-MIPS64EL-N32: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.4/n32/crtbegin.o" // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4/n32" // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4/../../../../lib32" // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/lib/../lib32" // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib/../lib32" // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.4/../../.." // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib" // // Test linker invocation for Freescale SDK (OpenEmbedded). // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target powerpc-fsl-linux \ // RUN: --sysroot=%S/Inputs/freescale_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-FSL-PPC %s // CHECK-FSL-PPC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-FSL-PPC: "-m" "elf32ppclinux" // CHECK-FSL-PPC: "{{.*}}/crt1.o" // CHECK-FSL-PPC: "{{.*}}/crtbegin.o" // CHECK-FSL-PPC: "-L[[SYSROOT]]/usr/lib" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target powerpc64-fsl-linux \ // RUN: --sysroot=%S/Inputs/freescale_ppc64_tree \ // RUN: | FileCheck --check-prefix=CHECK-FSL-PPC64 %s // CHECK-FSL-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" // CHECK-FSL-PPC64: "-m" "elf64ppc" // CHECK-FSL-PPC64: "{{.*}}/crt1.o" // CHECK-FSL-PPC64: "{{.*}}/crtbegin.o" // CHECK-FSL-PPC64: "-L[[SYSROOT]]/usr/lib64/powerpc64-fsl-linux/4.6.2/../.." // // Check that crtfastmath.o is linked with -ffast-math. // RUN: %clang -target x86_64-unknown-linux -### %s \ // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s // RUN: %clang -target x86_64-unknown-linux -### %s -ffast-math \ // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH %s // RUN: %clang -target x86_64-unknown-linux -### %s -funsafe-math-optimizations\ // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH %s // RUN: %clang -target x86_64-unknown-linux -### %s -ffast-math -fno-fast-math \ // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s // We don't have crtfastmath.o in the i386 tree, use it to check that file // detection works. // RUN: %clang -target i386-unknown-linux -### %s -ffast-math \ // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtfastmath.o // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
the_stack_data/173576725.c
#include <assert.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> #include <string.h> typedef enum { PERMISSION_GRANT = 1, PERMISSION_WRITE = 2, PERMISSION_READ = 4 } Permission; static Permission getPermissionValue(const char* const string) { assert(string && *string); switch(*string) { case 'g': return PERMISSION_GRANT; case 'w': return PERMISSION_WRITE; case 'r': return PERMISSION_READ; } assert(false); return 0; } int main(const int argc, const char* const argv[]) { // Getting away with no error checking throughout because CodeEval makes some // strong guarantees about our runtime environment. No need to pay when we're // being benchmarked. Don't forget to define NDEBUG prior to submitting! assert(argc >= 2 && "Expecting at least one command-line argument."); static char stdoutBuffer[256] = ""; // Turn on full output buffering for stdout. setvbuf(stdout, stdoutBuffer, _IOFBF, sizeof stdoutBuffer); FILE* inputStream = fopen(argv[1], "r"); assert(inputStream && "Failed to open input stream."); // Base access control list as per the problem statement. static const unsigned char defaultAcl[][3] = { /* 0: none 1: grant 2: write 3: write, grant 4: read 5: read, grant 6: read, write 7: read, write, grant */ // file_1 file_2 file_3 /* user_1 */ {7, 3, 0}, /* user_2 */ {6, 2, 4}, /* user_3 */ {5, 1, 5}, /* user_4 */ {3, 7, 1}, /* user_5 */ {6, 0, 2}, /* user_6 */ {4, 2, 6} }; for(char lineBuffer[512] = ""; fgets(lineBuffer, sizeof lineBuffer, inputStream);) { unsigned char acl[sizeof defaultAcl / sizeof *defaultAcl] [sizeof *defaultAcl / sizeof **defaultAcl] = {""}; // Revert to stock ACL for each test case. memcpy(acl, defaultAcl, sizeof defaultAcl); bool isValidActionChain = true; for(const char* chunk = strtok(lineBuffer, " "); chunk; chunk = strtok(NULL, " ")) { /* Representing either: - "userId=>fileId=>rule", or; - "userId=>fileId=>rule=>newRule=>subjectId" */ unsigned userId = 0, fileId = 0, rule = 0, newRule = 0, subjectId = 0; char ruleBuffer[8] = "", newRuleBuffer[8] = ""; #define ARGUMENT_PACK \ &userId, &fileId, ruleBuffer, newRuleBuffer, &subjectId static const char* const scanFormat = "user_%u=>file_%u=>%7[^=]=>%7[^=]=>user_%u"; // Should be 3 or 5, really. if(sscanf(chunk, scanFormat, ARGUMENT_PACK) < 3) { assert(false); } rule = getPermissionValue(ruleBuffer); // Trailing data is only present if this is a grant operation. if(rule == PERMISSION_GRANT) { newRule = getPermissionValue(newRuleBuffer); } #undef ARGUMENT_PACK // IDs are 1-based in the input. const unsigned char ownerRights = acl[userId - 1][fileId - 1]; // Self-administer supplied permission. if(!subjectId) { if(!(ownerRights & rule)) { isValidActionChain = false; break; } // Already have this permission, so NOP. continue; } // Insufficient rights. if(!(ownerRights & PERMISSION_GRANT)) { isValidActionChain = false; break; } // Apply supplied permission to another user. acl[subjectId - 1][fileId - 1] |= newRule; } puts(isValidActionChain ? "True" : "False"); } // The CRT takes care of cleanup. }
the_stack_data/461196.c
/* Fibonacci number generation The program takes an input N from the command line It uses a non-recursive technique to generate the value of N Checks for conditions mentioned in the coding challenge. */ #include <stdio.h> #include <stdlib.h> #include <math.h> // Checks if a number is prime int isPrime(long long n){ if(n < 2){ return 0; } else if(n == 2){ return 1; } else if(n % 2){ return 0; } else{ for(long long i = 3; i < n; i += 2){ if(n % i == 0){ return 0; } } } return 1; } // Generate N fibonacci numbers void fibonacci(unsigned long long n){ long long a = 0, b = 1, c = 0; printf("%llu\n", a); printf("%llu\n", b); for(long long i = 2; i < (n + 1); i++){ c = a + b; a = b; b = c; if(c % 3 == 0 && c % 5 == 0){ printf("FizzBuzz\n"); } else if(c % 3 == 0){ printf("Buzz\n"); } else if(c % 5 == 0){ printf("Fizz\n"); } else if(isPrime(c) == 1){ printf("BuzzFizz\n"); } else{ printf("%llu\n", c); } } } int main(int argc, char *argv[]){ if(argc < 2){ printf("Program expects the value of N"); return -1; } long long n = strtoul(argv[1], NULL, 10); fibonacci(n); return 0; }
the_stack_data/150142518.c
#include <stdio.h> #include <stdlib.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netdb.h> #include <ifaddrs.h> #include <string.h> #include <malloc.h> #include <errno.h> #include <string.h> #include <stdint.h> #define BUF_SIZE 1500 /* * This software is licensed under the CC0. * * This is a _basic_ DNS Server for educational use. * It does not prevent invalid packets from crashing * the server. * * To test start the program and issue a DNS request: * dig @127.0.0.1 -p 9000 foo.bar.com */ /* * Masks and constants. */ static const uint32_t QR_MASK = 0x8000; static const uint32_t OPCODE_MASK = 0x7800; static const uint32_t AA_MASK = 0x0400; static const uint32_t TC_MASK = 0x0200; static const uint32_t RD_MASK = 0x0100; static const uint32_t RA_MASK = 0x8000; static const uint32_t RCODE_MASK = 0x000F; /* Response Type */ enum { Ok_ResponseType = 0, FormatError_ResponseType = 1, ServerFailure_ResponseType = 2, NameError_ResponseType = 3, NotImplemented_ResponseType = 4, Refused_ResponseType = 5 }; /* Resource Record Types */ enum { A_Resource_RecordType = 1, NS_Resource_RecordType = 2, CNAME_Resource_RecordType = 5, SOA_Resource_RecordType = 6, PTR_Resource_RecordType = 12, MX_Resource_RecordType = 15, TXT_Resource_RecordType = 16, AAAA_Resource_RecordType = 28, SRV_Resource_RecordType = 33 }; /* Operation Code */ enum { QUERY_OperationCode = 0, /* standard query */ IQUERY_OperationCode = 1, /* inverse query */ STATUS_OperationCode = 2, /* server status request */ NOTIFY_OperationCode = 4, /* request zone transfer */ UPDATE_OperationCode = 5 /* change resource records */ }; /* Response Code */ enum { NoError_ResponseCode = 0, FormatError_ResponseCode = 1, ServerFailure_ResponseCode = 2, NameError_ResponseCode = 3 }; /* Query Type */ enum { IXFR_QueryType = 251, AXFR_QueryType = 252, MAILB_QueryType = 253, MAILA_QueryType = 254, STAR_QueryType = 255 }; /* * Types. */ /* Question Section */ struct Question { char *qName; uint16_t qType; uint16_t qClass; struct Question* next; // for linked list }; /* Data part of a Resource Record */ union ResourceData { struct { char *txt_data; } txt_record; struct { uint8_t addr[4]; } a_record; struct { char* MName; char* RName; uint32_t serial; uint32_t refresh; uint32_t retry; uint32_t expire; uint32_t minimum; } soa_record; struct { char *name; } name_server_record; struct { char name; } cname_record; struct { char *name; } ptr_record; struct { uint16_t preference; char *exchange; } mx_record; struct { uint8_t addr[16]; } aaaa_record; struct { uint16_t priority; uint16_t weight; uint16_t port; char *target; } srv_record; }; /* Resource Record Section */ struct ResourceRecord { char *name; uint16_t type; uint16_t class; uint16_t ttl; uint16_t rd_length; union ResourceData rd_data; struct ResourceRecord* next; // for linked list }; struct Message { uint16_t id; /* Identifier */ /* Flags */ uint16_t qr; /* Query/Response Flag */ uint16_t opcode; /* Operation Code */ uint16_t aa; /* Authoritative Answer Flag */ uint16_t tc; /* Truncation Flag */ uint16_t rd; /* Recursion Desired */ uint16_t ra; /* Recursion Available */ uint16_t rcode; /* Response Code */ uint16_t qdCount; /* Question Count */ uint16_t anCount; /* Answer Record Count */ uint16_t nsCount; /* Authority Record Count */ uint16_t arCount; /* Additional Record Count */ /* At least one question; questions are copied to the response 1:1 */ struct Question* questions; /* * Resource records to be send back. * Every resource record can be in any of the following places. * But every place has a different semantic. */ struct ResourceRecord* answers; struct ResourceRecord* authorities; struct ResourceRecord* additionals; }; int get_A_Record(uint8_t addr[4], const char domain_name[]) { if (strcmp("geekofia.com", domain_name) == 0) { addr[0] = 192; addr[1] = 168; addr[2] = 1; addr[3] = 1; return 0; } else { return -1; } } int get_AAAA_Record(uint8_t addr[16], const char domain_name[]) { if (strcmp("geekofia.com", domain_name) == 0) { addr[0] = 0xfe; addr[1] = 0x80; addr[2] = 0x00; addr[3] = 0x00; addr[4] = 0x00; addr[5] = 0x00; addr[6] = 0x00; addr[7] = 0x00; addr[8] = 0x00; addr[9] = 0x00; addr[10] = 0x00; addr[11] = 0x00; addr[12] = 0x00; addr[13] = 0x00; addr[14] = 0x00; addr[15] = 0x01; return 0; } else { return -1; } } /* * Debugging functions. */ void print_hex(uint8_t* buf, size_t len) { int i; printf("%zu bytes:\n", len); for(i = 0; i < len; ++i) printf("%02x ", buf[i]); printf("\n"); } void print_resource_record(struct ResourceRecord* rr) { int i; while (rr) { printf(" ResourceRecord { name '%s', type %u, class %u, ttl %u, rd_length %u, ", rr->name, rr->type, rr->class, rr->ttl, rr->rd_length ); union ResourceData *rd = &rr->rd_data; switch (rr->type) { case A_Resource_RecordType: printf("Address Resource Record { address "); for(i = 0; i < 4; ++i) printf("%s%u", (i ? "." : ""), rd->a_record.addr[i]); printf(" }"); break; case NS_Resource_RecordType: printf("Name Server Resource Record { name %s }", rd->name_server_record.name ); break; case CNAME_Resource_RecordType: printf("Canonical Name Resource Record { name %u }", rd->cname_record.name ); break; case SOA_Resource_RecordType: printf("SOA { MName '%s', RName '%s', serial %u, refresh %u, retry %u, expire %u, minimum %u }", rd->soa_record.MName, rd->soa_record.RName, rd->soa_record.serial, rd->soa_record.refresh, rd->soa_record.retry, rd->soa_record.expire, rd->soa_record.minimum ); break; case PTR_Resource_RecordType: printf("Pointer Resource Record { name '%s' }", rd->ptr_record.name ); break; case MX_Resource_RecordType: printf("Mail Exchange Record { preference %u, exchange '%s' }", rd->mx_record.preference, rd->mx_record.exchange ); break; case TXT_Resource_RecordType: printf("Text Resource Record { txt_data '%s' }", rd->txt_record.txt_data ); break; case AAAA_Resource_RecordType: printf("AAAA Resource Record { address "); for(i = 0; i < 16; ++i) printf("%s%02x", (i ? ":" : ""), rd->aaaa_record.addr[i]); printf(" }"); break; default: printf("Unknown Resource Record { ??? }"); } printf("}\n"); rr = rr->next; } } void print_query(struct Message* msg) { printf("QUERY { ID: %02x", msg->id); printf(". FIELDS: [ QR: %u, OpCode: %u ]", msg->qr, msg->opcode); printf(", QDcount: %u", msg->qdCount); printf(", ANcount: %u", msg->anCount); printf(", NScount: %u", msg->nsCount); printf(", ARcount: %u,\n", msg->arCount); struct Question* q = msg->questions; while (q) { printf(" Question { qName '%s', qType %u, qClass %u }\n", q->qName, q->qType, q->qClass ); q = q->next; } print_resource_record(msg->answers); print_resource_record(msg->authorities); print_resource_record(msg->additionals); printf("}\n"); } /* * Basic memory operations. */ size_t get16bits(const uint8_t** buffer) { uint16_t value; memcpy(&value, *buffer, 2); *buffer += 2; return ntohs(value); } void put8bits(uint8_t** buffer, uint8_t value) { memcpy(*buffer, &value, 1); *buffer += 1; } void put16bits(uint8_t** buffer, uint16_t value) { value = htons(value); memcpy(*buffer, &value, 2); *buffer += 2; } void put32bits(uint8_t** buffer, uint32_t value) { value = htons(value); memcpy(*buffer, &value, 4); *buffer += 4; } /* * Deconding/Encoding functions. */ // 3foo3bar3com0 => foo.bar.com char* decode_domain_name(const uint8_t** buffer) { char name[256]; const uint8_t* buf = *buffer; int j = 0; int i = 0; while (buf[i] != 0) { //if (i >= buflen || i > sizeof(name)) // return NULL; if (i != 0) { name[j] = '.'; j += 1; } int len = buf[i]; i += 1; memcpy(name+j, buf+i, len); i += len; j += len; } name[j] = '\0'; *buffer += i + 1; //also jump over the last 0 return strdup(name); } // foo.bar.com => 3foo3bar3com0 void encode_domain_name(uint8_t** buffer, const char* domain) { uint8_t* buf = *buffer; const char* beg = domain; const char* pos; int len = 0; int i = 0; while ((pos = strchr(beg, '.'))) { len = pos - beg; buf[i] = len; i += 1; memcpy(buf+i, beg, len); i += len; beg = pos + 1; } len = strlen(domain) - (beg - domain); buf[i] = len; i += 1; memcpy(buf + i, beg, len); i += len; buf[i] = 0; i += 1; *buffer += i; } void decode_header(struct Message* msg, const uint8_t** buffer) { msg->id = get16bits(buffer); uint32_t fields = get16bits(buffer); msg->qr = (fields & QR_MASK) >> 15; msg->opcode = (fields & OPCODE_MASK) >> 11; msg->aa = (fields & AA_MASK) >> 10; msg->tc = (fields & TC_MASK) >> 9; msg->rd = (fields & RD_MASK) >> 8; msg->ra = (fields & RA_MASK) >> 7; msg->rcode = (fields & RCODE_MASK) >> 0; msg->qdCount = get16bits(buffer); msg->anCount = get16bits(buffer); msg->nsCount = get16bits(buffer); msg->arCount = get16bits(buffer); } void encode_header(struct Message* msg, uint8_t** buffer) { put16bits(buffer, msg->id); int fields = 0; fields |= (msg->qr << 15) & QR_MASK; fields |= (msg->rcode << 0) & RCODE_MASK; // TODO: insert the rest of the fields put16bits(buffer, fields); put16bits(buffer, msg->qdCount); put16bits(buffer, msg->anCount); put16bits(buffer, msg->nsCount); put16bits(buffer, msg->arCount); } int decode_msg(struct Message* msg, const uint8_t* buffer, int size) { int i; decode_header(msg, &buffer); if (msg->anCount != 0 || msg->nsCount != 0) { printf("Only questions expected!\n"); return -1; } // parse questions uint32_t qcount = msg->qdCount; struct Question* qs = msg->questions; for (i = 0; i < qcount; ++i) { struct Question* q = malloc(sizeof(struct Question)); q->qName = decode_domain_name(&buffer); q->qType = get16bits(&buffer); q->qClass = get16bits(&buffer); // prepend question to questions list q->next = qs; msg->questions = q; } // We do not expect any resource records to parse here. return 0; } // For every question in the message add a appropiate resource record // in either section 'answers', 'authorities' or 'additionals'. void resolver_process(struct Message* msg) { struct ResourceRecord* beg; struct ResourceRecord* rr; struct Question* q; int rc; // leave most values intact for response msg->qr = 1; // this is a response msg->aa = 1; // this server is authoritative msg->ra = 0; // no recursion available msg->rcode = Ok_ResponseType; // should already be 0 msg->anCount = 0; msg->nsCount = 0; msg->arCount = 0; // for every question append resource records q = msg->questions; while (q) { rr = malloc(sizeof(struct ResourceRecord)); memset(rr, 0, sizeof(struct ResourceRecord)); rr->name = strdup(q->qName); rr->type = q->qType; rr->class = q->qClass; rr->ttl = 60*60; // in seconds; 0 means no caching printf("Query for '%s'\n", q->qName); // We only can only answer two question types so far // and the answer (resource records) will be all put // into the answers list. // This behavior is probably non-standard! switch (q->qType) { case A_Resource_RecordType: rr->rd_length = 4; rc = get_A_Record(rr->rd_data.a_record.addr, q->qName); if (rc < 0) { free(rr->name); free(rr); goto next; } break; case AAAA_Resource_RecordType: rr->rd_length = 16; rc = get_AAAA_Record(rr->rd_data.aaaa_record.addr, q->qName); if (rc < 0) { free(rr->name); free(rr); goto next; } break; /* case NS_Resource_RecordType: case CNAME_Resource_RecordType: case SOA_Resource_RecordType: case PTR_Resource_RecordType: case MX_Resource_RecordType: case TXT_Resource_RecordType: */ default: free(rr); msg->rcode = NotImplemented_ResponseType; printf("Cannot answer question of type %d.\n", q->qType); goto next; } msg->anCount++; // prepend resource record to answers list beg = msg->answers; msg->answers = rr; rr->next = beg; // jump here to omit question next: // process next question q = q->next; } } /* @return 0 upon failure, 1 upon success */ int encode_resource_records(struct ResourceRecord* rr, uint8_t** buffer) { int i; while (rr) { // Answer questions by attaching resource sections. encode_domain_name(buffer, rr->name); put16bits(buffer, rr->type); put16bits(buffer, rr->class); put32bits(buffer, rr->ttl); put16bits(buffer, rr->rd_length); switch (rr->type) { case A_Resource_RecordType: for(i = 0; i < 4; ++i) put8bits(buffer, rr->rd_data.a_record.addr[i]); break; case AAAA_Resource_RecordType: for(i = 0; i < 16; ++i) put8bits(buffer, rr->rd_data.aaaa_record.addr[i]); break; default: fprintf(stderr, "Unknown type %u. => Ignore resource record.\n", rr->type); return 1; } rr = rr->next; } return 0; } /* @return 0 upon failure, 1 upon success */ int encode_msg(struct Message* msg, uint8_t** buffer) { struct Question* q; int rc; encode_header(msg, buffer); q = msg->questions; while (q) { encode_domain_name(buffer, q->qName); put16bits(buffer, q->qType); put16bits(buffer, q->qClass); q = q->next; } rc = 0; rc |= encode_resource_records(msg->answers, buffer); rc |= encode_resource_records(msg->authorities, buffer); rc |= encode_resource_records(msg->additionals, buffer); return rc; } void free_resource_records(struct ResourceRecord* rr) { struct ResourceRecord* next; while (rr) { free(rr->name); next = rr->next; free(rr); rr = next; } } void free_questions(struct Question* qq) { struct Question* next; while (qq) { free(qq->qName); next = qq->next; free(qq); qq = next; } } int main() { // buffer for input/output binary packet uint8_t buffer[BUF_SIZE]; struct sockaddr_in client_addr; socklen_t addr_len = sizeof(struct sockaddr_in); struct sockaddr_in addr; int nbytes, rc; int sock; int port = 9000; struct Message msg; memset(&msg, 0, sizeof(struct Message)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; addr.sin_port = htons(port); sock = socket(AF_INET, SOCK_DGRAM, 0); rc = bind(sock, (struct sockaddr*) &addr, addr_len); if (rc != 0) { printf("Could not bind: %s\n", strerror(errno)); return 1; } printf("Listening on port %u.\n", port); while (1) { free_questions(msg.questions); free_resource_records(msg.answers); free_resource_records(msg.authorities); free_resource_records(msg.additionals); memset(&msg, 0, sizeof(struct Message)); nbytes = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr *) &client_addr, &addr_len); if (decode_msg(&msg, buffer, nbytes) != 0) { continue; } /* Print query */ print_query(&msg); resolver_process(&msg); /* Print response */ print_query(&msg); uint8_t *p = buffer; if (encode_msg(&msg, &p) != 0) { continue; } int buflen = p - buffer; sendto(sock, buffer, buflen, 0, (struct sockaddr*) &client_addr, addr_len); } }
the_stack_data/28264046.c
//此程序演示结构体的数组 #include <stdio.h> struct time { int hour; int minutes; int seconds; }; int main(void) { struct time timeUpdate(struct time now); struct time testTimes[5] = { {11, 59, 59}, {12, 0, 0}, {1, 29, 59}, {23, 59, 59}, {19, 12, 27} }; int i; for(i = 0; i < 5; ++i){ printf("Time is %.2i:%.2i:%.2i", testTimes[i].hour, testTimes[i].minutes, testTimes[i].seconds); testTimes[i] = timeUpdate(testTimes[i]); printf(" ...One second later it's %.2i:%.2i:%.2i\n", testTimes[i].hour, testTimes[i].minutes, testTimes[i].seconds); } return 0; } struct time timeUpdate(struct time now) { ++now.seconds; if(now.seconds == 60){ //下一分钟 now.seconds = 0; ++now.minutes; if(now.minutes == 60){ //下一小时 now.minutes = 0; ++now.hour; if(now.hour == 24) //午夜 now.hour = 0; } } return now; }
the_stack_data/40762372.c
/* * file for 28_buggy_simple_loop1_vf_false-unreach-call.c */ // P() {0==-1} /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* This header is separate from features.h so that the compiler can include it implicitly at the start of every compilation. It must not itself include <features.h> or any other header that includes <features.h> because the implicit include comes before any feature test macros that may be defined in a source file before it first explicitly includes a system header. GCC knows the name of this header in order to preinclude it. */ /* glibc's intent is to support the IEC 559 math functionality, real and complex. If the GCC (4.9 and later) predefined macros specifying compiler intent are available, use them to determine whether the overall intent is to support these features; otherwise, presume an older compiler has intent to support these features and define these macros by default. */ /* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) / Unicode 6.0. */ /* We do not support C11 <threads.h>. */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.20 General utilities <stdlib.h> */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* These are defined by the user (or the compiler) to specify the desired environment: __STRICT_ANSI__ ISO Standard C. _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. _POSIX_SOURCE IEEE Std 1003.1. _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; if >=199309L, add IEEE Std 1003.1b-1993; if >=199506L, add IEEE Std 1003.1c-1995; if >=200112L, all of IEEE 1003.1-2004 if >=200809L, all of IEEE 1003.1-2008 _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if Single Unix conformance is wanted, to 600 for the sixth revision, to 700 for the seventh revision. _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. _LARGEFILE_SOURCE Some more functions for correct standard I/O. _LARGEFILE64_SOURCE Additional functionality from LFS for large files. _FILE_OFFSET_BITS=N Select default filesystem interface. _BSD_SOURCE ISO C, POSIX, and 4.3BSD things. _SVID_SOURCE ISO C, POSIX, and SVID things. _ATFILE_SOURCE Additional *at interfaces. _GNU_SOURCE All of the above, plus GNU extensions. _DEFAULT_SOURCE The default set of features (taking precedence over __STRICT_ANSI__). _REENTRANT Select additionally reentrant object. _THREAD_SAFE Same as _REENTRANT, often used by other systems. _FORTIFY_SOURCE If set to numeric value > 0 additional security measures are defined, according to level. The `-ansi' switch to the GNU C compiler, and standards conformance options such as `-std=c99', define __STRICT_ANSI__. If none of these are defined, or if _DEFAULT_SOURCE is defined, the default is to have _SVID_SOURCE, _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to 200809L. If more than one of these are defined, they accumulate. For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together give you ISO C, 1003.1, and 1003.2, but nothing else. These are defined by this file and are used by the header files to decide what to declare or define: __USE_ISOC11 Define ISO C11 things. __USE_ISOC99 Define ISO C99 things. __USE_ISOC95 Define ISO C90 AMD1 (C95) things. __USE_POSIX Define IEEE Std 1003.1 things. __USE_POSIX2 Define IEEE Std 1003.2 things. __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. __USE_XOPEN Define XPG things. __USE_XOPEN_EXTENDED Define X/Open Unix things. __USE_UNIX98 Define Single Unix V2 things. __USE_XOPEN2K Define XPG6 things. __USE_XOPEN2KXSI Define XPG6 XSI things. __USE_XOPEN2K8 Define XPG7 things. __USE_XOPEN2K8XSI Define XPG7 XSI things. __USE_LARGEFILE Define correct standard I/O things. __USE_LARGEFILE64 Define LFS things with separate names. __USE_FILE_OFFSET64 Define 64bit interface as default. __USE_BSD Define 4.3BSD things. __USE_SVID Define SVID things. __USE_MISC Define things common to BSD and System V Unix. __USE_ATFILE Define *at interfaces and AT_* constants for them. __USE_GNU Define GNU extensions. __USE_REENTRANT Define reentrant/thread-safe *_r functions. __USE_FORTIFY_LEVEL Additional security measures used, according to level. The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are defined by this file unconditionally. `__GNU_LIBRARY__' is provided only for compatibility. All new code should use the other symbols to test for features. All macros listed above as possibly being defined by this file are explicitly undefined if they are not explicitly defined. Feature-test macros that are not defined by the user or compiler but are implied by the other feature-test macros defined (or by the lack of any definitions) are defined by the file. */ /* Undefine everything, so we get a clean slate. */ /* Suppress kernel-name space pollution unless user expressedly asks for it. */ /* Convenience macros to test the versions of glibc and gcc. Use them like this: #if __GNUC_PREREQ (2,8) ... code requiring gcc 2.8 or later ... #endif Note - they won't work for gcc1 or glibc1, since the _MINOR macros were not defined then. */ /* If _GNU_SOURCE was defined by the user, turn on all the other features. */ /* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, define _DEFAULT_SOURCE, _BSD_SOURCE and _SVID_SOURCE. */ /* This is to enable the ISO C11 extension. */ /* This is to enable the ISO C99 extension. */ /* This is to enable the ISO C90 Amendment 1:1995 extension. */ /* This is to enable compatibility for ISO C++11. So far g++ does not provide a macro. Check the temporary macro for now, too. */ /* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE is defined, use POSIX.1-2008 (or another version depending on _XOPEN_SOURCE). */ /* Get definitions of __STDC_* predefined macros, if the compiler has not preincluded this header automatically. */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* This macro indicates that the installed library is the GNU C Library. For historic reasons the value now is 6 and this will stay from now on. The use of this variable is deprecated. Use __GLIBC__ and __GLIBC_MINOR__ now (see below) when you want to test for a specific GNU C library version and use the values in <gnu/lib-names.h> to get the sonames of the shared libraries. */ /* Major and minor version number of the GNU C library package. Use these macros to test for features in specific releases. */ /* This is here only because every header file already includes this one. */ /* Copyright (C) 1992-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* We are almost always included from features.h. */ /* The GNU libc does not support any K&R compilers or the traditional mode of ISO C compilers anymore. Check for some of the combinations not anymore supported. */ /* Some user header file might have defined this before. */ /* These two macros are not used in glibc anymore. They are kept here only because some other projects expect the macros to be defined. */ /* For these things, GCC behaves the ANSI way normally, and the non-ANSI way under -traditional. */ /* This is not a typedef so `const __ptr_t' does the right thing. */ /* C++ needs to know that types and declarations are C, not C++. */ /* The standard library needs the functions from the ISO C90 standard in the std namespace. At the same time we want to be safe for future changes and we include the ISO C99 code in the non-standard namespace __c99. The C++ wrapper header take case of adding the definitions to the global namespace. */ /* For compatibility we do not add the declarations into any namespace. They will end up in the global namespace which is what old code expects. */ /* Fortify support. */ /* Support for flexible arrays. */ /* __asm__ ("xyz") is used throughout the headers to rename functions at the assembly language level. This is wrapped by the __REDIRECT macro, in order to support compilers that can do this some other way. When compilers don't support asm-names at all, we have to do preprocessor tricks instead (which don't have exactly the right semantics, but it's the best we can do). Example: int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ /* GCC has various useful declarations that can be made with the `__attribute__' syntax. All of the ways we use this do fine if they are omitted for compilers that don't understand it. */ /* At some point during the gcc 2.96 development the `malloc' attribute for functions was introduced. We don't want to use it unconditionally (although this would be possible) since it generates warnings. */ /* Tell the compiler which arguments to an allocation function indicate the size of the allocation. */ /* At some point during the gcc 2.96 development the `pure' attribute for functions was introduced. We don't want to use it unconditionally (although this would be possible) since it generates warnings. */ /* This declaration tells the compiler that the value is constant. */ /* At some point during the gcc 3.1 development the `used' attribute for functions was introduced. We don't want to use it unconditionally (although this would be possible) since it generates warnings. */ /* gcc allows marking deprecated functions. */ /* At some point during the gcc 2.8 development the `format_arg' attribute for functions was introduced. We don't want to use it unconditionally (although this would be possible) since it generates warnings. If several `format_arg' attributes are given for the same function, in gcc-3.0 and older, all but the last one are ignored. In newer gccs, all designated arguments are considered. */ /* At some point during the gcc 2.97 development the `strfmon' format attribute for functions was introduced. We don't want to use it unconditionally (although this would be possible) since it generates warnings. */ /* The nonull function attribute allows to mark pointer parameters which must not be NULL. */ /* If fortification mode, we warn about unused results of certain function calls which can lead to problems. */ /* Forces a function to be always inlined. */ /* Associate error messages with the source location of the call site rather than with the source location inside the function. */ /* GCC 4.3 and above allow passing all anonymous arguments of an __extern_always_inline function to some other vararg function. */ /* It is possible to compile containing GCC extensions even if GCC is run in pedantic mode if the uses are carefully marked using the `__extension__' keyword. But this is not generally available before version 2.8. */ /* __restrict is known in EGCS 1.2 and above. */ /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is array_name[restrict] GCC 3.1 supports this. */ /* Determine the wordsize from the preprocessor defines. */ /* Both x86-64 and x32 use the 64-bit system call interface. */ /* If we don't have __REDIRECT, prototypes will be missing if __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */ /* Decide whether we can define 'extern inline' functions in headers. */ /* This is here only because every header file already includes this one. Get the definitions of all the appropriate `__stub_FUNCTION' symbols. <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub that will always return failure (and set errno to ENOSYS). */ /* This file is automatically generated. This file selects the right generated file of `__stub_FUNCTION' macros based on the architecture being compiled for. */ /* This file is automatically generated. It defines a symbol `__stub_FUNCTION' for each function in the C library which is a stub, meaning it will fail every time called, usually setting errno to ENOSYS. */ /* Get size_t, wchar_t and NULL from <stddef.h>. */ /* Copyright (C) 1989-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ /* * ISO C Standard: 7.17 Common definitions <stddef.h> */ /* Any one of these symbols __need_* means that GNU libc wants us just to define one data type. So don't define the symbols that indicate this file's entire job has been done. */ /* This avoids lossage on SunOS but only if stdtypes.h comes first. There's no way to win with the other order! Sun lossage. */ /* On 4.3bsd-net2, make sure ansi.h is included, so we have one less case to deal with in the following. */ /* On FreeBSD 5, machine/ansi.h does not exist anymore... */ /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are defined if the corresponding type is *not* defined. FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */ /* Sequent's header files use _PTRDIFF_T_ in some conflicting way. Just ignore it. */ /* On VxWorks, <type/vxTypesBase.h> may have defined macros like _TYPE_size_t which will typedef size_t. fixincludes patched the vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is not defined, and so that defining this macro defines _GCC_SIZE_T. If we find that the macros are still defined at this point, we must invoke them so that the type is defined as expected. */ /* In case nobody has defined these types, but we aren't running under GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and __WCHAR_TYPE__ have reasonable values. This can happen if the parts of GCC is compiled by an older compiler, that actually include gstddef.h, such as collect2. */ /* Signed type of difference of two pointers. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ /* Unsigned type of `sizeof' something. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ // P() {0==-1} typedef unsigned long int size_t; /* Wide character type. Locale-writers should change this as necessary to be big enough to hold unique values not between 0 and 127, and not (wchar_t) -1, for each defined multibyte character. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other symbols in the _FOO_T_ family, stays defined even after its corresponding type is defined). If we define wchar_t, then we must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if we undef _WCHAR_T_, then we must also define rune_t, since headers like runetype.h assume that if machine/ansi.h is included, and _BSD_WCHAR_T_ is not defined, then rune_t is available. machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of the same type." */ /* FreeBSD 5 can't be handled well using "traditional" logic above since it no longer defines _BSD_RUNE_T_ yet still desires to export rune_t in some cases... */ // P() {0==-1} typedef int wchar_t; /* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. are already defined. */ /* BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. */ /* NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. */ /* A null pointer constant. */ /* Returned by `div'. */ /* Quotient. */ /* Remainder. */ // P() {0==-1} typedef struct { int quot; int rem; } div_t; /* Returned by `ldiv'. */ /* Quotient. */ /* Remainder. */ // P() {0==-1} typedef struct { long int quot; long int rem; } ldiv_t; /* Returned by `lldiv'. */ /* Quotient. */ /* Remainder. */ // P() {0==-1} typedef struct { long long int quot; long long int rem; } lldiv_t; /* The largest number rand will return (same as INT_MAX). */ /* We define these the same for all machines. Changes from this to the outside world should be done in `_exit'. */ /* Maximum length of a multibyte character in the current locale. */ // P() {0==-1} size_t __ctype_get_mb_cur_max(void); /* Convert a string to a floating-point number. */ // P() {0==-1} extern double atof(const char *__nptr); /* Convert a string to an integer. */ // P() {0==-1} extern int atoi(const char *__nptr); /* Convert a string to a long integer. */ // P() {0==-1} extern long int atol(const char *__nptr); /* Convert a string to a long long integer. */ // P() {0==-1} extern long long int atoll(const char *__nptr); /* Convert a string to a floating-point number. */ // P() {0==-1} extern double strtod(const char *__nptr, char **__endptr); /* Likewise for `float' and `long double' sizes of floating-point numbers. */ // P() {0==-1} extern float strtof(const char *__nptr, char **__endptr); // P() {0==-1} extern long double strtold(const char *__nptr, char **__endptr); /* Convert a string to a long integer. */ // P() {0==-1} extern long int strtol(const char *__nptr, char **__endptr, int __base); /* Convert a string to an unsigned long integer. */ // P() {0==-1} extern unsigned long int strtoul(const char *__nptr, char **__endptr, int __base); /* Convert a string to a quadword integer. */ // P() {0==-1} extern long long int strtoll(const char *__nptr, char **__endptr, int __base); /* Convert a string to an unsigned quadword integer. */ // P() {0==-1} extern unsigned long long int strtoull(const char *__nptr, char **__endptr, int __base); /* Return a random integer between 0 and RAND_MAX inclusive. */ // P() {0==-1} extern int rand(void); /* Seed the random number generator with the given number. */ // P() {0==-1} extern void srand(unsigned int __seed); /* Allocate SIZE bytes of memory. */ // P() {0==-1} extern void *malloc(size_t __size); /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ // P() {0==-1} extern void *calloc(size_t __nmemb, size_t __size); /* Re-allocate the previously allocated block in PTR, making the new block SIZE bytes long. */ /* __attribute_malloc__ is not used, because if realloc returns the same pointer that was passed to it, aliasing needs to be allowed between objects pointed by the old and new pointers. */ // P() {0==-1} extern void *realloc(void *__ptr, size_t __size); /* Free a block allocated by `malloc', `realloc' or `calloc'. */ // P() {0==-1} extern void free(void *__ptr); /* Abort execution and generate a core-dump. */ // P() {0==-1} extern void abort(void); /* Register a function to be called when `exit' is called. */ // P() {0==-1} extern int atexit(void (*__func)(void)); /* Call all functions registered with `atexit' and `on_exit', in the reverse of the order in which they were registered, perform stdio cleanup, and terminate program execution with STATUS. */ // P() {0==-1} extern void exit(int __status); /* Terminate the program with STATUS without calling any of the functions registered with `atexit' or `on_exit'. */ // P() {0==-1} void _Exit(int __status); /* Return the value of envariable NAME, or NULL if it doesn't exist. */ // P() {0==-1} extern char *getenv(const char *__name); /* Execute the given line as a shell command. This function is a cancellation point and therefore not marked with __THROW. */ // P() {0==-1} extern int system(const char *__command); /* Shorthand for type of comparison functions. */ // P() {0==-1} typedef int (*__compar_fn_t)(void *, void *); /* Do a binary search for KEY in BASE, which consists of NMEMB elements of SIZE bytes each, using COMPAR to perform the comparisons. */ // P() {0==-1} extern void *bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar); /* Sort NMEMB elements of BASE, of SIZE bytes each, using COMPAR to perform the comparisons. */ // P() {0==-1} extern void qsort(void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar); /* Return the absolute value of X. */ // P() {0==-1} extern int abs(int __x); // P() {0==-1} extern long int labs(long int __x); // P() {0==-1} extern long long int llabs(long long int __x); /* Return the `div_t', `ldiv_t' or `lldiv_t' representation of the value of NUMER over DENOM. */ /* GCC may have built-ins for these someday. */ // P() {0==-1} extern div_t div(int __numer, int __denom); // P() {0==-1} extern ldiv_t ldiv(long int __numer, long int __denom); // P() {0==-1} extern lldiv_t lldiv(long long int __numer, long long int __denom); /* Return the length of the multibyte character in S, which is no longer than N. */ // P() {0==-1} extern int mblen(const char *__s, size_t __n); /* Return the length of the given multibyte character, putting its `wchar_t' representation in *PWC. */ // P() {0==-1} extern int mbtowc(wchar_t *__pwc, const char *__s, size_t __n); /* Put the multibyte character represented by WCHAR in S, returning its length. */ // P() {0==-1} extern int wctomb(char *__s, wchar_t __wchar); /* Convert a multibyte string to a wide char string. */ // P() {0==-1} extern size_t mbstowcs(wchar_t *__pwcs, const char *__s, size_t __n); /* Convert a wide char string to multibyte string. */ // P() {0==-1} extern size_t wcstombs(char *__s, const wchar_t *__pwcs, size_t __n); /* X/Open pseudo terminal handling. */ /* Floating-point inline functions for stdlib.h. Copyright (C) 2012-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Define some macros helping to catch buffer overflows. */ // P() {0==-1} void __VERIFIER_error(); /* Copyright (C) 2002-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Copyright (C) 1992-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Definitions for byte order, according to significance of bytes, from low addresses to high addresses. The value is what you get by putting '4' in the most significant byte, '3' in the second most significant byte, '2' in the second least significant byte, and '1' in the least significant byte, and then writing down one digit for each byte, starting with the byte at the lowest address at the left, and proceeding to the byte with the highest address at the right. */ /* This file defines `__BYTE_ORDER' for the particular machine. */ /* i386/x86_64 are little-endian. */ /* Some machines may need to use a different endianness for floating point values. */ /* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Get type definitions. */ /* bits/types.h -- definitions of __*_t types underlying *_t types. Copyright (C) 2002-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* * Never include this file directly; use <sys/types.h> instead. */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Determine the wordsize from the preprocessor defines. */ /* Both x86-64 and x32 use the 64-bit system call interface. */ /* Convenience types. */ // P() {0==-1} typedef unsigned char __u_char; // P() {0==-1} typedef unsigned short __u_short; // P() {0==-1} typedef unsigned int __u_int; // P() {0==-1} typedef unsigned long int __u_long; /* Fixed-size types, underlying types depend on word size and compiler. */ // P() {0==-1} typedef signed char __int8_t; // P() {0==-1} typedef unsigned char __uint8_t; // P() {0==-1} typedef signed short __int16_t; // P() {0==-1} typedef unsigned short __uint16_t; // P() {0==-1} typedef signed int __int32_t; // P() {0==-1} typedef unsigned int __uint32_t; // P() {0==-1} typedef signed long int __int64_t; // P() {0==-1} typedef unsigned long int __uint64_t; /* quad_t is also 64 bits. */ // P() {0==-1} typedef long int __quad_t; // P() {0==-1} typedef unsigned long int __u_quad_t; /* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE macros for each of the OS types we define below. The definitions of those macros must use the following macros for underlying types. We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned variants of each of the following integer types on this machine. 16 -- "natural" 16-bit type (always short) 32 -- "natural" 32-bit type (always int) 64 -- "natural" 64-bit type (long or long long) LONG32 -- 32-bit type, traditionally long QUAD -- 64-bit type, always long long WORD -- natural type of __WORDSIZE bits (int or long) LONGWORD -- type of __WORDSIZE bits, traditionally long We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the conventional uses of `long' or `long long' type modifiers match the types we define, even when a less-adorned type would be the same size. This matters for (somewhat) portably writing printf/scanf formats for these types, where using the appropriate l or ll format modifiers can make the typedefs and the formats match up across all GNU platforms. If we used `long' when it's 64 bits where `long long' is expected, then the compiler would warn about the formats not matching the argument types, and the programmer changing them to shut up the compiler would break the program's portability. Here we assume what is presently the case in all the GCC configurations we support: long long is always 64 bits, long is always word/address size, and int is always 32 bits. */ /* No need to mark the typedef with __extension__. */ /* bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version. Copyright (C) 2012-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* See <bits/types.h> for the meaning of these macros. This file exists so that <bits/types.h> need not vary across different GNU platforms. */ /* X32 kernel interface is 64-bit. */ /* Tell the libc code that off_t and off64_t are actually the same type for all ABI purposes, even if possibly expressed as different base types for C type-checking purposes. */ /* Same for ino_t and ino64_t. */ /* Number of descriptors that can fit in an `fd_set'. */ // P() {0==-1} typedef unsigned long int __dev_t; /* Type of device numbers. */ // P() {0==-1} typedef unsigned int __uid_t; /* Type of user identifications. */ // P() {0==-1} typedef unsigned int __gid_t; /* Type of group identifications. */ // P() {0==-1} typedef unsigned long int __ino_t; /* Type of file serial numbers. */ // P() {0==-1} typedef unsigned long int __ino64_t; /* Type of file serial numbers (LFS).*/ // P() {0==-1} typedef unsigned int __mode_t; /* Type of file attribute bitmasks. */ // P() {0==-1} typedef unsigned long int __nlink_t; /* Type of file link counts. */ // P() {0==-1} typedef long int __off_t; /* Type of file sizes and offsets. */ // P() {0==-1} typedef long int __off64_t; /* Type of file sizes and offsets (LFS). */ // P() {0==-1} typedef int __pid_t; /* Type of process identifications. */ // P() {0==-1} typedef struct { int __val[2]; } __fsid_t; /* Type of file system IDs. */ // P() {0==-1} typedef long int __clock_t; /* Type of CPU usage counts. */ // P() {0==-1} typedef unsigned long int __rlim_t; /* Type for resource measurement. */ // P() {0==-1} typedef unsigned long int __rlim64_t; /* Type for resource measurement (LFS). */ // P() {0==-1} typedef unsigned int __id_t; /* General type for IDs. */ // P() {0==-1} typedef long int __time_t; /* Seconds since the Epoch. */ // P() {0==-1} typedef unsigned int __useconds_t; /* Count of microseconds. */ // P() {0==-1} typedef long int __suseconds_t; /* Signed count of microseconds. */ // P() {0==-1} typedef int __daddr_t; /* The type of a disk address. */ // P() {0==-1} typedef int __key_t; /* Type of an IPC key. */ /* Clock ID used in clock and timer functions. */ // P() {0==-1} typedef int __clockid_t; /* Timer ID returned by `timer_create'. */ // P() {0==-1} typedef void *__timer_t; /* Type to represent block size. */ // P() {0==-1} typedef long int __blksize_t; /* Types from the Large File Support interface. */ /* Type to count number of disk blocks. */ // P() {0==-1} typedef long int __blkcnt_t; // P() {0==-1} typedef long int __blkcnt64_t; /* Type to count file system blocks. */ // P() {0==-1} typedef unsigned long int __fsblkcnt_t; // P() {0==-1} typedef unsigned long int __fsblkcnt64_t; /* Type to count file system nodes. */ // P() {0==-1} typedef unsigned long int __fsfilcnt_t; // P() {0==-1} typedef unsigned long int __fsfilcnt64_t; /* Type of miscellaneous file system fields. */ // P() {0==-1} typedef long int __fsword_t; // P() {0==-1} typedef long int __ssize_t; /* Type of a byte count, or error. */ /* Signed long type used in system calls. */ // P() {0==-1} typedef long int __syscall_slong_t; /* Unsigned long type used in system calls. */ // P() {0==-1} typedef unsigned long int __syscall_ulong_t; /* These few don't really vary by system, they always correspond to one of the other defined types. */ // P() {0==-1} typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */ // P() {0==-1} typedef __quad_t *__qaddr_t; // P() {0==-1} typedef char *__caddr_t; /* Duplicates info from stdint.h but this is used in unistd.h. */ // P() {0==-1} typedef long int __intptr_t; /* Duplicate info from sys/socket.h. */ // P() {0==-1} typedef unsigned int __socklen_t; /* Copyright (C) 1989-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ /* * ISO C Standard: 7.17 Common definitions <stddef.h> */ /* Any one of these symbols __need_* means that GNU libc wants us just to define one data type. So don't define the symbols that indicate this file's entire job has been done. */ /* This avoids lossage on SunOS but only if stdtypes.h comes first. There's no way to win with the other order! Sun lossage. */ /* On 4.3bsd-net2, make sure ansi.h is included, so we have one less case to deal with in the following. */ /* On FreeBSD 5, machine/ansi.h does not exist anymore... */ /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are defined if the corresponding type is *not* defined. FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */ /* Sequent's header files use _PTRDIFF_T_ in some conflicting way. Just ignore it. */ /* On VxWorks, <type/vxTypesBase.h> may have defined macros like _TYPE_size_t which will typedef size_t. fixincludes patched the vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is not defined, and so that defining this macro defines _GCC_SIZE_T. If we find that the macros are still defined at this point, we must invoke them so that the type is defined as expected. */ /* In case nobody has defined these types, but we aren't running under GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and __WCHAR_TYPE__ have reasonable values. This can happen if the parts of GCC is compiled by an older compiler, that actually include gstddef.h, such as collect2. */ /* Signed type of difference of two pointers. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ /* Unsigned type of `sizeof' something. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ /* Wide character type. Locale-writers should change this as necessary to be big enough to hold unique values not between 0 and 127, and not (wchar_t) -1, for each defined multibyte character. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ /* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. are already defined. */ /* BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. */ /* NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. */ /* A null pointer constant. */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.23 Date and time <time.h> */ /* bits/types.h -- definitions of __*_t types underlying *_t types. Copyright (C) 2002-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* * Never include this file directly; use <sys/types.h> instead. */ /* Returned by `time'. */ // P() {0==-1} typedef __time_t time_t; /* bits/types.h -- definitions of __*_t types underlying *_t types. Copyright (C) 2002-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* * Never include this file directly; use <sys/types.h> instead. */ /* POSIX.1b structure for a time value. This is like a `struct timeval' but has nanoseconds instead of microseconds. */ /* Seconds. */ /* Nanoseconds. */ // P() {0==-1} struct timespec { __time_t tv_sec; __syscall_slong_t tv_nsec; }; // P() {0==-1} typedef __pid_t pid_t; /* Get system specific constant and data structure definitions. */ /* Definitions of constants and data structure for POSIX 1003.1b-1993 scheduling interface. Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Scheduling algorithms. */ /* The official definition. */ // P() {0==-1} struct sched_param { int __sched_priority; }; /* Data structure to describe a process' schedulability. */ // P() {0==-1} struct __sched_param { int __sched_priority; }; /* Size definition for CPU sets. */ /* Type for array elements in 'cpu_set_t'. */ // P() {0==-1} typedef unsigned long int __cpu_mask; // P() {0==-1} typedef struct { __cpu_mask __bits[1024/(8*sizeof(__cpu_mask))]; } cpu_set_t; /* Access functions for CPU masks. */ // P() {0==-1} int __sched_cpucount(size_t __setsize, const cpu_set_t *__setp); // P() {0==-1} cpu_set_t *__sched_cpualloc(size_t __count); // P() {0==-1} void __sched_cpufree(cpu_set_t *__set); /* Define the real names for the elements of `struct sched_param'. */ /* Set scheduling parameters for a process. */ // P() {0==-1} int sched_setparam(__pid_t __pid, const struct sched_param *__param); /* Retrieve scheduling parameters for a particular process. */ // P() {0==-1} int sched_getparam(__pid_t __pid, struct sched_param *__param); /* Set scheduling algorithm and/or parameters for a process. */ // P() {0==-1} int sched_setscheduler(__pid_t __pid, int __policy, const struct sched_param *__param); /* Retrieve scheduling algorithm for a particular purpose. */ // P() {0==-1} int sched_getscheduler(__pid_t __pid); /* Yield the processor. */ // P() {0==-1} int sched_yield(void); /* Get maximum priority value for a scheduler. */ // P() {0==-1} int sched_get_priority_max(int __algorithm); /* Get minimum priority value for a scheduler. */ // P() {0==-1} int sched_get_priority_min(int __algorithm); /* Get the SCHED_RR interval for the named process. */ // P() {0==-1} int sched_rr_get_interval(__pid_t __pid, struct timespec *__t); /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.23 Date and time <time.h> */ /* Copyright (C) 1991-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Get size_t and NULL from <stddef.h>. */ /* Copyright (C) 1989-2013 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ /* * ISO C Standard: 7.17 Common definitions <stddef.h> */ /* Any one of these symbols __need_* means that GNU libc wants us just to define one data type. So don't define the symbols that indicate this file's entire job has been done. */ /* This avoids lossage on SunOS but only if stdtypes.h comes first. There's no way to win with the other order! Sun lossage. */ /* On 4.3bsd-net2, make sure ansi.h is included, so we have one less case to deal with in the following. */ /* On FreeBSD 5, machine/ansi.h does not exist anymore... */ /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are defined if the corresponding type is *not* defined. FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */ /* Sequent's header files use _PTRDIFF_T_ in some conflicting way. Just ignore it. */ /* On VxWorks, <type/vxTypesBase.h> may have defined macros like _TYPE_size_t which will typedef size_t. fixincludes patched the vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is not defined, and so that defining this macro defines _GCC_SIZE_T. If we find that the macros are still defined at this point, we must invoke them so that the type is defined as expected. */ /* In case nobody has defined these types, but we aren't running under GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and __WCHAR_TYPE__ have reasonable values. This can happen if the parts of GCC is compiled by an older compiler, that actually include gstddef.h, such as collect2. */ /* Signed type of difference of two pointers. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ /* Unsigned type of `sizeof' something. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ /* Wide character type. Locale-writers should change this as necessary to be big enough to hold unique values not between 0 and 127, and not (wchar_t) -1, for each defined multibyte character. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ /* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. are already defined. */ /* BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. */ /* NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. */ /* A null pointer constant. */ /* This defines CLOCKS_PER_SEC, which is the number of processor clock ticks per second. */ /* System-dependent timing definitions. Linux version. Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* * Never include this file directly; use <time.h> instead. */ /* ISO/IEC 9899:1990 7.12.1: <time.h> The macro `CLOCKS_PER_SEC' is the number per second of the value returned by the `clock' function. */ /* CAE XSH, Issue 4, Version 2: <time.h> The value of CLOCKS_PER_SEC is required to be 1 million on all XSI-conformant systems. */ /* This is the obsolete POSIX.1-1988 name for the same constant. */ /* bits/types.h -- definitions of __*_t types underlying *_t types. Copyright (C) 2002-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* * Never include this file directly; use <sys/types.h> instead. */ /* Returned by `clock'. */ // P() {0==-1} typedef __clock_t clock_t; /* Used by other time functions. */ /* Seconds. [0-60] (1 leap second) */ /* Minutes. [0-59] */ /* Hours. [0-23] */ /* Day. [1-31] */ /* Month. [0-11] */ /* Year - 1900. */ /* Day of week. [0-6] */ /* Days in year.[0-365] */ /* DST. [-1/0/1]*/ /* Seconds east of UTC. */ /* Timezone abbreviation. */ // P() {0==-1} struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long int __tm_gmtoff; const char *__tm_zone; }; /* Time used by the program so far (user time + system time). The result / CLOCKS_PER_SECOND is program time in seconds. */ // P() {0==-1} extern clock_t clock(void); /* Return the current time and put it in *TIMER if TIMER is not NULL. */ // P() {0==-1} extern time_t time(time_t *__timer); /* Return the difference between TIME1 and TIME0. */ // P() {0==-1} extern double difftime(time_t __time1, time_t __time0); /* Return the `time_t' representation of TP and normalize TP. */ // P() {0==-1} time_t mktime(struct tm *__tp); /* Format TP into S according to FORMAT. Write no more than MAXSIZE characters and return the number of characters written, or 0 if it would exceed MAXSIZE. */ // P() {0==-1} size_t strftime(char *__s, size_t __maxsize, const char *__format, const struct tm *__tp); /* Return the `struct tm' representation of *TIMER in Universal Coordinated Time (aka Greenwich Mean Time). */ // P() {0==-1} struct tm *gmtime(const time_t *__timer); /* Return the `struct tm' representation of *TIMER in the local timezone. */ // P() {0==-1} extern struct tm *localtime(const time_t *__timer); /* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n" that is the representation of TP in this format. */ // P() {0==-1} char *asctime(const struct tm *__tp); /* Equivalent to `asctime (localtime (timer))'. */ // P() {0==-1} char *ctime(const time_t *__timer); /* Defined in localtime.c. */ // P() {0==-1} extern char *__tzname[2]; /* Current timezone names. */ // P() {0==-1} extern int __daylight; /* If daylight-saving time is ever in use. */ // P() {0==-1} extern long int __timezone; /* Seconds west of UTC. */ /* Nonzero if YEAR is a leap year (every 4 years, except every 100th isn't, and every 400th is). */ /* Copyright (C) 2002-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Determine the wordsize from the preprocessor defines. */ /* Both x86-64 and x32 use the 64-bit system call interface. */ /* Thread identifiers. The structure of the attribute type is not exposed on purpose. */ // P() {0==-1} typedef unsigned long int pthread_t; // P() {0==-1} union pthread_attr_t { char __size[56]; long int __align; }; // P() {0==-1} typedef union pthread_attr_t pthread_attr_t; // P() {0==-1} typedef struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __pthread_list_t; // P() {0==-1} typedef union { struct __pthread_mutex_s {int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; __pthread_list_t __list;} __data; char __size[40]; long int __align; } pthread_mutex_t; // P() {0==-1} typedef union { char __size[4]; int __align; } pthread_mutexattr_t; // P() {0==-1} typedef union { struct {int __lock; unsigned int __futex; unsigned long long int __total_seq; unsigned long long int __wakeup_seq; unsigned long long int __woken_seq; void *__mutex; unsigned int __nwaiters; unsigned int __broadcast_seq;} __data; char __size[48]; long long int __align; } pthread_cond_t; // P() {0==-1} typedef union { char __size[4]; int __align; } pthread_condattr_t; /* Keys for thread-specific data */ // P() {0==-1} typedef unsigned int pthread_key_t; /* Once-only execution */ // P() {0==-1} typedef int pthread_once_t; /* Copyright (C) 2001-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. 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, see <http://www.gnu.org/licenses/>. */ /* Define the machine-dependent type `jmp_buf'. x86-64 version. */ /* Determine the wordsize from the preprocessor defines. */ /* Both x86-64 and x32 use the 64-bit system call interface. */ // P() {0==-1} typedef long int __jmp_buf[8]; /* Determine the wordsize from the preprocessor defines. */ /* Both x86-64 and x32 use the 64-bit system call interface. */ /* Detach state. */ // P() {0==-1} enum {PTHREAD_CREATE_JOINABLE, PTHREAD_CREATE_DETACHED}; /* Mutex types. */ // P() {0==-1} enum {PTHREAD_MUTEX_TIMED_NP, PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_ADAPTIVE_NP}; /* Mutex initializers. */ /* Read-write lock types. */ /* Scheduler inheritance. */ // P() {0==-1} enum {PTHREAD_INHERIT_SCHED, PTHREAD_EXPLICIT_SCHED}; /* Scope handling. */ // P() {0==-1} enum {PTHREAD_SCOPE_SYSTEM, PTHREAD_SCOPE_PROCESS}; /* Process shared or private flag. */ // P() {0==-1} enum {PTHREAD_PROCESS_PRIVATE, PTHREAD_PROCESS_SHARED}; /* Conditional variable handling. */ /* Cleanup buffers */ /* Function to call. */ /* Its argument. */ /* Saved cancellation type. */ /* Chaining of cleanup functions. */ // P() {0==-1} struct _pthread_cleanup_buffer { void (*__routine)(void *); void *__arg; int __canceltype; struct _pthread_cleanup_buffer *__prev; }; /* Cancellation */ // P() {0==-1} enum {PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE}; // P() {0==-1} enum {PTHREAD_CANCEL_DEFERRED, PTHREAD_CANCEL_ASYNCHRONOUS}; /* Single execution handling. */ /* Create a new thread, starting with execution of START-ROUTINE getting passed ARG. Creation attributed come from ATTR. The new handle is stored in *NEWTHREAD. */ // P() {0==-1} int pthread_create(pthread_t *__newthread, const pthread_attr_t *__attr, void *(*__start_routine)(void *), void *__arg); /* Terminate calling thread. The registered cleanup handlers are called via exception handling so we cannot mark this function with __THROW.*/ // P() {0==-1} void pthread_exit(void *__retval); /* Make calling thread wait for termination of the thread TH. The exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN is not NULL. This function is a cancellation point and therefore not marked with __THROW. */ // P() {0==-1} int pthread_join(pthread_t __th, void **__thread_return); /* Indicate that the thread TH is never to be joined with PTHREAD_JOIN. The resources of TH will therefore be freed immediately when it terminates, instead of waiting for another thread to perform PTHREAD_JOIN on it. */ // P() {0==-1} int pthread_detach(pthread_t __th); /* Obtain the identifier of the current thread. */ // P() {0==-1} pthread_t pthread_self(void); /* Compare two thread identifiers. */ // P() {0==-1} int pthread_equal(pthread_t __thread1, pthread_t __thread2); /* Thread attribute handling. */ /* Initialize thread attribute *ATTR with default attributes (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER, no user-provided stack). */ // P() {0==-1} int pthread_attr_init(pthread_attr_t *__attr); /* Destroy thread attribute *ATTR. */ // P() {0==-1} int pthread_attr_destroy(pthread_attr_t *__attr); /* Get detach state attribute. */ // P() {0==-1} int pthread_attr_getdetachstate(const pthread_attr_t *__attr, int *__detachstate); /* Set detach state attribute. */ // P() {0==-1} int pthread_attr_setdetachstate(pthread_attr_t *__attr, int __detachstate); /* Get the size of the guard area created for stack overflow protection. */ // P() {0==-1} int pthread_attr_getguardsize(const pthread_attr_t *__attr, size_t *__guardsize); /* Set the size of the guard area created for stack overflow protection. */ // P() {0==-1} int pthread_attr_setguardsize(pthread_attr_t *__attr, size_t __guardsize); /* Return in *PARAM the scheduling parameters of *ATTR. */ // P() {0==-1} int pthread_attr_getschedparam(const pthread_attr_t *__attr, struct sched_param *__param); /* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */ // P() {0==-1} int pthread_attr_setschedparam(pthread_attr_t *__attr, const struct sched_param *__param); /* Return in *POLICY the scheduling policy of *ATTR. */ // P() {0==-1} int pthread_attr_getschedpolicy(const pthread_attr_t *__attr, int *__policy); /* Set scheduling policy in *ATTR according to POLICY. */ // P() {0==-1} int pthread_attr_setschedpolicy(pthread_attr_t *__attr, int __policy); /* Return in *INHERIT the scheduling inheritance mode of *ATTR. */ // P() {0==-1} int pthread_attr_getinheritsched(const pthread_attr_t *__attr, int *__inherit); /* Set scheduling inheritance mode in *ATTR according to INHERIT. */ // P() {0==-1} int pthread_attr_setinheritsched(pthread_attr_t *__attr, int __inherit); /* Return in *SCOPE the scheduling contention scope of *ATTR. */ // P() {0==-1} int pthread_attr_getscope(const pthread_attr_t *__attr, int *__scope); /* Set scheduling contention scope in *ATTR according to SCOPE. */ // P() {0==-1} int pthread_attr_setscope(pthread_attr_t *__attr, int __scope); /* Return the previously set address for the stack. */ // P() {0==-1} int pthread_attr_getstackaddr(const pthread_attr_t *__attr, void **__stackaddr); /* Set the starting address of the stack of the thread to be created. Depending on whether the stack grows up or down the value must either be higher or lower than all the address in the memory block. The minimal size of the block must be PTHREAD_STACK_MIN. */ // P() {0==-1} int pthread_attr_setstackaddr(pthread_attr_t *__attr, void *__stackaddr); /* Return the currently used minimal stack size. */ // P() {0==-1} int pthread_attr_getstacksize(const pthread_attr_t *__attr, size_t *__stacksize); /* Add information about the minimum stack size needed for the thread to be started. This size must never be less than PTHREAD_STACK_MIN and must also not exceed the system limits. */ // P() {0==-1} int pthread_attr_setstacksize(pthread_attr_t *__attr, size_t __stacksize); /* Functions for scheduling control. */ /* Set the scheduling parameters for TARGET_THREAD according to POLICY and *PARAM. */ // P() {0==-1} int pthread_setschedparam(pthread_t __target_thread, int __policy, const struct sched_param *__param); /* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */ // P() {0==-1} int pthread_getschedparam(pthread_t __target_thread, int *__policy, struct sched_param *__param); /* Set the scheduling priority for TARGET_THREAD. */ // P() {0==-1} int pthread_setschedprio(pthread_t __target_thread, int __prio); /* Functions for handling initialization. */ /* Guarantee that the initialization function INIT_ROUTINE will be called only once, even if pthread_once is executed several times with the same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or extern variable initialized to PTHREAD_ONCE_INIT. The initialization functions might throw exception which is why this function is not marked with __THROW. */ // P() {0==-1} int pthread_once(pthread_once_t *__once_control, void (*__init_routine)(void)); /* Functions for handling cancellation. Note that these functions are explicitly not marked to not throw an exception in C++ code. If cancellation is implemented by unwinding this is necessary to have the compiler generate the unwind information. */ /* Set cancelability state of current thread to STATE, returning old state in *OLDSTATE if OLDSTATE is not NULL. */ // P() {0==-1} int pthread_setcancelstate(int __state, int *__oldstate); /* Set cancellation state of current thread to TYPE, returning the old type in *OLDTYPE if OLDTYPE is not NULL. */ // P() {0==-1} int pthread_setcanceltype(int __type, int *__oldtype); /* Cancel THREAD immediately or at the next possibility. */ // P() {0==-1} int pthread_cancel(pthread_t __th); /* Test for pending cancellation for the current thread and terminate the thread as per pthread_exit(PTHREAD_CANCELED) if it has been cancelled. */ // P() {0==-1} void pthread_testcancel(void); // P() {0==-1} typedef struct { struct {__jmp_buf __cancel_jmp_buf; int __mask_was_saved;} __cancel_jmp_buf[1]; void *__pad[4]; } __pthread_unwind_buf_t; /* No special attributes by default. */ /* Structure to hold the cleanup handler information. */ // P() {0==-1} struct __pthread_cleanup_frame { void (*__cancel_routine)(void *); void *__cancel_arg; int __do_it; int __cancel_type; }; /* Install a cleanup handler: ROUTINE will be called with arguments ARG when the thread is canceled or calls pthread_exit. ROUTINE will also be called with arguments ARG when the matching pthread_cleanup_pop is executed with non-zero EXECUTE argument. pthread_cleanup_push and pthread_cleanup_pop are macros and must always be used in matching pairs at the same nesting level of braces. */ // P() {0==-1} void __pthread_register_cancel(__pthread_unwind_buf_t *__buf); /* Remove a cleanup handler installed by the matching pthread_cleanup_push. If EXECUTE is non-zero, the handler function is called. */ // P() {0==-1} void __pthread_unregister_cancel(__pthread_unwind_buf_t *__buf); /* Internal interface to initiate cleanup. */ // P() {0==-1} void __pthread_unwind_next(__pthread_unwind_buf_t *__buf); /* Function used in the macros. */ // P() {0==-1} int __sigsetjmp(struct __jmp_buf_tag *__env, int __savemask); /* Mutex handling. */ /* Initialize a mutex. */ // P() {0==-1} int pthread_mutex_init(pthread_mutex_t *__mutex, const pthread_mutexattr_t *__mutexattr); /* Destroy a mutex. */ // P() {0==-1} int pthread_mutex_destroy(pthread_mutex_t *__mutex); /* Try locking a mutex. */ // P() {0==-1} int pthread_mutex_trylock(pthread_mutex_t *__mutex); /* Lock a mutex. */ // P() {0==-1} int pthread_mutex_lock(pthread_mutex_t *__mutex); /* Unlock a mutex. */ // P() {0==-1} int pthread_mutex_unlock(pthread_mutex_t *__mutex); /* Get the priority ceiling of MUTEX. */ // P() {0==-1} int pthread_mutex_getprioceiling(const pthread_mutex_t *__mutex, int *__prioceiling); /* Set the priority ceiling of MUTEX to PRIOCEILING, return old priority ceiling value in *OLD_CEILING. */ // P() {0==-1} int pthread_mutex_setprioceiling(pthread_mutex_t *__mutex, int __prioceiling, int *__old_ceiling); /* Functions for handling mutex attributes. */ /* Initialize mutex attribute object ATTR with default attributes (kind is PTHREAD_MUTEX_TIMED_NP). */ // P() {0==-1} int pthread_mutexattr_init(pthread_mutexattr_t *__attr); /* Destroy mutex attribute object ATTR. */ // P() {0==-1} int pthread_mutexattr_destroy(pthread_mutexattr_t *__attr); /* Get the process-shared flag of the mutex attribute ATTR. */ // P() {0==-1} int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__attr, int *__pshared); /* Set the process-shared flag of the mutex attribute ATTR. */ // P() {0==-1} int pthread_mutexattr_setpshared(pthread_mutexattr_t *__attr, int __pshared); /* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */ // P() {0==-1} int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__attr, int *__protocol); /* Set the mutex protocol attribute in *ATTR to PROTOCOL (either PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */ // P() {0==-1} int pthread_mutexattr_setprotocol(pthread_mutexattr_t *__attr, int __protocol); /* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */ // P() {0==-1} int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__attr, int *__prioceiling); /* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */ // P() {0==-1} int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *__attr, int __prioceiling); /* Functions for handling conditional variables. */ /* Initialize condition variable COND using attributes ATTR, or use the default values if later is NULL. */ // P() {0==-1} int pthread_cond_init(pthread_cond_t *__cond, const pthread_condattr_t *__cond_attr); /* Destroy condition variable COND. */ // P() {0==-1} int pthread_cond_destroy(pthread_cond_t *__cond); /* Wake up one thread waiting for condition variable COND. */ // P() {0==-1} int pthread_cond_signal(pthread_cond_t *__cond); /* Wake up all threads waiting for condition variables COND. */ // P() {0==-1} int pthread_cond_broadcast(pthread_cond_t *__cond); /* Wait for condition variable COND to be signaled or broadcast. MUTEX is assumed to be locked before. This function is a cancellation point and therefore not marked with __THROW. */ // P() {0==-1} int pthread_cond_wait(pthread_cond_t *__cond, pthread_mutex_t *__mutex); /* Wait for condition variable COND to be signaled or broadcast until ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an absolute time specification; zero is the beginning of the epoch (00:00:00 GMT, January 1, 1970). This function is a cancellation point and therefore not marked with __THROW. */ // P() {0==-1} int pthread_cond_timedwait(pthread_cond_t *__cond, pthread_mutex_t *__mutex, const struct timespec *__abstime); /* Functions for handling condition variable attributes. */ /* Initialize condition variable attribute ATTR. */ // P() {0==-1} int pthread_condattr_init(pthread_condattr_t *__attr); /* Destroy condition variable attribute ATTR. */ // P() {0==-1} int pthread_condattr_destroy(pthread_condattr_t *__attr); /* Get the process-shared flag of the condition variable attribute ATTR. */ // P() {0==-1} int pthread_condattr_getpshared(const pthread_condattr_t *__attr, int *__pshared); /* Set the process-shared flag of the condition variable attribute ATTR. */ // P() {0==-1} int pthread_condattr_setpshared(pthread_condattr_t *__attr, int __pshared); /* Functions for handling thread-specific data. */ /* Create a key value identifying a location in the thread-specific data area. Each thread maintains a distinct thread-specific data area. DESTR_FUNCTION, if non-NULL, is called with the value associated to that key when the key is destroyed. DESTR_FUNCTION is not called if the value associated is NULL when the key is destroyed. */ // P() {0==-1} int pthread_key_create(pthread_key_t *__key, void (*__destr_function)(void *)); /* Destroy KEY. */ // P() {0==-1} int pthread_key_delete(pthread_key_t __key); /* Return current value of the thread-specific data slot identified by KEY. */ // P() {0==-1} void *pthread_getspecific(pthread_key_t __key); /* Store POINTER in the thread-specific data slot identified by KEY. */ // P() {0==-1} int pthread_setspecific(pthread_key_t __key, const void *__pointer); /* Install handlers to be called when a new process is created with FORK. The PREPARE handler is called in the parent process just before performing FORK. The PARENT handler is called in the parent process just after FORK. The CHILD handler is called in the child process. Each of the three handlers can be NULL, meaning that no handler needs to be called at that point. PTHREAD_ATFORK can be called several times, in which case the PREPARE handlers are called in LIFO order (last added with PTHREAD_ATFORK, first called before FORK), and the PARENT and CHILD handlers are called in FIFO (first added, first called). */ // P() {0==-1} int pthread_atfork(void (*__prepare)(void), void (*__parent)(void), void (*__child)(void)); // P() {0==-1} void *thr1(void *arg); // P() {0==-1} int main(); // P() {0==-1} void __VERIFIER_error() { // P() {0==-1} exit(-1); } // P() {0==-1} void * thr1(void *arg) { // P() {0==-1} unsigned int x, y, z; // P() {0==-1} int i, j, k; // P() {0==-1} i = 0; l99993: ; // P() {0==-1} if (!(i<x)) goto l99999; // P() {0==-1} j = i+1; l99994: ; // P() {0==-1} if (!(j<y)) goto l99998; // P() {0==-1} k = j; l99996: ; // P() {0==-1} if (!(k<z)) goto l99997; // P() {0==-1} if (!(k>i)) goto ERROR; // P() {0==-1} k++; goto l99996; // P() {0==-1} ERROR: __VERIFIER_error(); // P() {0==-1} (void) 0; goto l99995; l99997: ; // P() {0==-1} j++; goto l99994; l99998: ; // P() {0==-1} i++; goto l99993; l99999: ; // P() {0==-1} /* uncomment to make error go away: x == 0 ||*/ if (!(i==x&&(j==y||y<=x+1)&&(x==0||y<=x+1||k==z||z<y))) goto ERROR; l99995: ; // P() {0==-1} return 0; } // P() {} int main() { // P() {} pthread_t t; // P(t) {} while (1) { // P(t) {} pthread_create(&t, 0, thr1, 0); } }
the_stack_data/1046627.c
#include <stdio.h> #include <time.h> #include <stdlib.h> #include <math.h> #include <stdint.h> #define PROFILE_COUNT 1000000 /** * Returns the modulo such that a = b (mod n) * @param a The dividend * @param n The divisor */ int mod1(int a, int n) { return ((a % n)+n) % n; } /** * Returns the modulo such that a = b (mod n) * @param a The dividend * @param n The divisor */ int mod2(int a, int n) { return (int) (a - n * floor((double) a / n)); } /** * Sets `seconds` to the number of seconds since Unix epoch including the * fractional value. Returns 0 if successful else returns the error value from * clock_gettime and errno is set appropriately. * @param seconds Pointer to value to be set * @return 0 on success */ int get_time(double *seconds) { double value; struct timespec ts; int err = clock_gettime(CLOCK_REALTIME, &ts); if (err) { return err; } value = (double) ts.tv_sec; value += ts.tv_nsec * 1e-9; if (seconds != NULL) { *seconds = value; } return 0; } /** * Returns the number of seconds (including fractional part) elapsed after * running `f` `count` times with arguments `a` and `n`. On error the errno * statement will be printed to stderr and the application will terminate with * an exit code of 1. * @param count Number of times to run `f` * @param f Pointer to function to run * @param a First argument to pass into the function * @param n Second argument to pass into the function * @return Number of elapsed seconds. */ double profile(uint32_t count, int (*f)(int a, int n), int a, int n) { double t0; double t1; if (get_time(&t0)) { perror("Failed to get time"); exit(1); } if (f != NULL) { for (uint32_t i = 0; i < count; i++) { f(a, n); } } if (get_time(&t1)) { perror("Failed to get time"); exit(1); } return t1 - t0; } /** * Profiles the different ways to calculate modulo */ int main(int argc, char *argv[]) { int a = 1; int n = 3; if (argc > 1) { sscanf(argv[1], "%d", &a); sscanf(argv[2], "%d", &n); } printf("(mod1) %d %% %d = %d\n", a, n, mod1(a, n)); printf("(mod2) %d %% %d = %d\n", a, n, mod2(a, n)); printf("--- Profile ---\n"); double val1 = profile(PROFILE_COUNT, &mod1, a, n); printf("%f\n", val1); double val2 = profile(PROFILE_COUNT, &mod2, a, n); printf("%f\n", val2); return 0; }
the_stack_data/7949747.c
#include <stdio.h> #include <stdlib.h> #include <string.h> const int maxSize = 1000; int main() { char s1[maxSize], s2[maxSize]; for (int i = 0; i < maxSize; ++i) { s1[i] = '0'; s2[i] = '0'; } printf("Enter each string on a separate line:\n"); fgets(s1, maxSize, stdin); fgets(s2, maxSize, stdin); int numberOfOccurrences = 0; int firstStringSize = strlen(s1) - 1, secondStringSize = strlen(s2) - 1; for (int i = 0; i < firstStringSize; ++i) { for (int j = 0; j < secondStringSize && i + j < firstStringSize; ++j) { if (s1[i + j] != s2[j]) break; if (j + 1 == secondStringSize) ++numberOfOccurrences; } } printf("%d", numberOfOccurrences); return 0; }
the_stack_data/690942.c
#include <stdio.h> #include <math.h> #include <malloc.h> #include <string.h> #define PI 3.141592653589793 #define SQH 0.707106781186547 /* square root of 2 */ #define SWAP(a,b) tempr=(a); (a) = (b); (b) = tempr #define IMAGE_SIZE 512 #define MSB(a) a < 0 ? 1:0 static void fft1(); void dct1(x,n) float *x; int n; { int i,ii,nn,mm; float tc,ts,sqn,temp2; double temp1; float *v; void fft1(); nn = n >> 1; mm = n << 1; sqn = (float)sqrt((double)n); v = (float *) calloc (mm,sizeof(float)); if (v == NULL) { printf("allocation failure\n"); exit(1); } for (i=0;i<nn;i++) { ii = i << 1; v[ii] = x[ii]; v[ii+1] = 0.0; } for (i=nn;i<n;i++) { ii = i << 1; v[ii] = x[mm-ii-1]; v[ii+1] = 0.0; } fft1(v-1,n,1); temp2 = SQH/sqn; x[0] = v[0]/sqn; for (i=1;i<=nn;i++) { ii = i << 1; temp1 = (double)(PI*i/mm); tc = (float) cos(temp1); ts = (float) sin(temp1); x[i] = 2.0*(tc*v[ii] + ts*v[ii+1])*temp2; x[n-i] = 2.0*(ts*v[ii] - tc*v[ii+1])*temp2; } free(v); } /* -------------------------------------------------- */ void idct1(x,n) float *x; int n; { int i,ii,mm,nn; float *v; float temp2,tc,ts,sqn; double temp1; void fft1(); nn = n >> 1; mm = n << 1; sqn = (float)sqrt((double)n); v = (float *) calloc (mm,sizeof(float)); if (v == NULL) { printf("allocation failure\n"); exit(1); } temp2 = sqn/SQH; v[0] = x[0]*sqn; v[1] = 0.0; for (i=1;i<n;i++) { ii = i << 1; temp1 = (double)(PI*i/mm); tc = (float)cos(temp1); ts = (float)sin(temp1); v[ii] = 0.5*(tc*x[i] + ts*x[n-i])*temp2; v[ii+1] = 0.5*(ts*x[i] - tc*x[n-i])*temp2; } fft1(v-1,n,-1); for (i=0;i<nn;i++) { ii = i << 1; x[ii] = v[ii]; } for (i=nn;i<n;i++) { ii = i << 1; x[mm-ii-1] = v[ii]; } free(v); } /* -------------------------------------------------- */ /* 1-D fft program */ /* Replace data by its discrete Fourier ransform if isign is input as 1, or replace data by its inverse discrete Fourier transform if isign is input as -1. "data" is a complex array of length nn, input as a real array data [1..2*nn], nn must be an integer power of 2. */ /* If your data array is zero-offset, that is the range of data is [0..2*nn-1], you have to decrease the pointer to data by one when fft1 is invoked, for example fft1(data-1,256,1). The real part of the first output will now be return in data[0], the imaginary part in data[1] and so on. */ static void fft1(data,nn,isign) float *data; int nn,isign; { int n,mmax,m,j,istep,i; double wtemp,wr,wpr,wpi,wi,theta; float tempr,tempi; n = nn << 1; j = 1; for (i=1;i<n;i+=2) { if (j>i) { SWAP(data[j],data[i]); SWAP(data[j+1],data[i+1]); } m = n >> 1; while (m>=2 && j>m) { j -= m; m >>= 1; } j += m; } mmax = 2; while (n>mmax) { istep = 2*mmax; theta = 6.28318530717959/(-isign*mmax); wtemp = sin(0.5*theta); wpr = -2.0*wtemp*wtemp; wpi = sin(theta); wr = 1.0; wi = 0.0; for (m=1;m<mmax;m+=2) { for (i=m;i<=n;i+=istep) { j = i+mmax; tempr = wr*data[j]-wi*data[j+1]; tempi = wr*data[j+1]+wi*data[j]; data[j] = data[i]-tempr; data[j+1] = data[i+1]-tempi; data[i] += tempr; data[i+1] += tempi; } wr = (wtemp=wr)*wpr-wi*wpi+wr; wi = wi*wpr+wtemp*wpi+wi; } mmax = istep; } if (isign == -1) { for (i=1;i<=n;++i) data[i] = data[i]/nn; } } void dct2(x,n) float **x; int n; { int i,j; float *y; void dct1(); y = (float *) calloc (n,sizeof(float)); if (y == NULL) { printf("allocation failure\n"); exit(1); } for (i=0;i<n;i++) { for (j=0;j<n;j++) y[j] = x[j][i]; dct1(y,n); for (j=0;j<n;j++) x[j][i] = y[j]; } /* end of loop i */ for (i=0;i<n;i++) { for (j=0;j<n;j++) y[j] = x[i][j]; dct1(y,n); for (j=0;j<n;j++) x[i][j] = y[j]; } /* end of loop i */ free(y); } /* ----------------------------------------------- */ void idct2(x,n) float **x; int n; { int i,j; float *y; void idct1(); y = (float *) calloc (n,sizeof(float)); if (y == NULL) { printf("allocation failure\n"); exit(1); } for (i=0;i<n;i++) { for (j=0;j<n;j++) y[j] = x[j][i]; idct1(y,n); for (j=0;j<n;j++) x[j][i] = y[j]; } /* end of loop i */ for (i=0;i<n;i++) { for (j=0;j<n;j++) y[j] = x[i][j]; idct1(y,n); for (j=0;j<n;j++) x[i][j] = y[j]; } /* end of loop i */ free(y); } void _2d_free(float** ptr){ int i; for( i = 0 ; i < 8 ; i++){ free(ptr[i]); } free(ptr); } void printBlock(float** block){ int i,j; for(i = 0; i < 8 ; i++){ for(j = 0 ; j < 8 ; j++){ printf("%d\t",(int)round(* (*(block+i)+j))); } printf("\n"); } } /* ----------------------------------------------- */ unsigned char image_byte[IMAGE_SIZE][IMAGE_SIZE]; int QF = 0; FILE *fout; FILE *fin; char temp_byte; int read_counter = 0; int dpcm_pre_val = 0; const int dcHuffmanValues[12] = { 0,2,3,4,5,6,14,30,62,126,254,510 }; const int dcHuffmanLength[12] = { 2,3,3,3,3,3,4,5,6,7,8,9 }; const int acHuffmanLength[256] = { 4, 2, 2, 3, 4, 5, 7, 8, 10,16,16, 0, 0, 0, 0, 0, 0, 4, 5, 7, 9,11,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 5, 8,10,12,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 6, 9,12,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 6,10,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 7,11,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 7,12,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 8,12,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 9,15,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 9,16,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0, 9,16,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0,10,16,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0,10,16,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0,11,16,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 0,16,16,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0, 11,16,16,16,16,16,16,16, 16,16,16, 0, 0, 0, 0, 0 }; const int acHuffmanTable[256] = { 0x000a,0x0000,0x0001,0x0004,0x000b,0x001a,0x0078,0x00f8, 0x03f6,0xff82,0xff83,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x000c,0x001b,0x0079,0x01f6,0x07f6,0xff84,0xff85, 0xff86,0xff87,0xff88,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x001c,0x00f9,0x03f7,0x0ff4,0xff89,0xff8a,0xff8b, 0xff8c,0xff8d,0xff8e,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x003a,0x01f7,0x0ff5,0xff8f,0xff90,0xff91,0xff92, 0xff93,0xff94,0xff95,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x003b,0x03f8,0xff96,0xff97,0xff98,0xff99,0xff9a, 0xff9b,0xff9c,0xff9d,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x007a,0x07f7,0xff9e,0xff9f,0xffa0,0xffa1,0xffa2, 0xffa3,0xffa4,0xffa5,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x007b,0x0ff6,0xffa6,0xffa7,0xffa8,0xffa9,0xffaa, 0xffab,0xffac,0xffad,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x00fa,0x0ff7,0xffae,0xffaf,0xffb0,0xffb1,0xffb2, 0xffb3,0xffb4,0xffb5,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x01f8,0x7fc0,0xffb6,0xffb7,0xffb8,0xffb9,0xffba, 0xffbb,0xffbc,0xffbd,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x01f9,0xffbe,0xffbf,0xffc0,0xffc1,0xffc2,0xffc3, 0xffc4,0xffc5,0xffc6,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x01fa,0xffc7,0xffc8,0xffc9,0xffca,0xffcb,0xffcc, 0xffcd,0xffce,0xffcf,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x03f9,0xffd0,0xffd1,0xffd2,0xffd3,0xffd4,0xffd5, 0xffd6,0xffd7,0xffd8,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x03fa,0xffd9,0xffda,0xffdb,0xffdc,0xffdd,0xffde, 0xffdf,0xffe0,0xffe1,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x07f8,0xffe2,0xffe3,0xffe4,0xffe5,0xffe6,0xffe7, 0xffe8,0xffe9,0xffea,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0xffeb,0xffec,0xffed,0xffee,0xffef,0xfff0,0xfff1, 0xfff2,0xfff3,0xfff4,0x0000,0x0000,0x0000,0x0000,0x0000, 0x07f9,0xfff5,0xfff6,0xfff7,0xfff8,0xfff9,0xfffa,0xfffb, 0xfffc,0xfffd,0xfffe,0x0000,0x0000,0x0000,0x0000,0x0000 }; const int zigZagOrder[64] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 }; unsigned char s_matrix[8][8] = {{16,11,10,16,24,40,51,61}, {12,12,14,19,26,58,60,55}, {14,13,16,24,40,57,69,56}, {14,17,22,29,51,87,80,62}, {18,22,37,56,68,109,103,77}, {24,36,55,64,81,104,113,92}, {49,64,78,87,103,121,120,101}, {72,92,95,98,112,100,103,99}}; char get_bit(); int dc_get_ssss(); int get_diff_val(int); int get_dc_val(int diff_val); int find_count_by_len(int len); int find_index_by_order_and_len(int len,int order); float** ac_decode_proc(int dc); int search_codeword_ac(); void setBlock(float**,int,int); int get_next_dc(); void write_file(); void de_quantization(float** block); int main(int argc,char **argv){ QF = atoi(argv[3]); char* input_fname = argv[1]; fin = fopen(input_fname,"rb"); fout = fopen(argv[2],"wb"); int i,j; for(i = 0 ; i < IMAGE_SIZE/8 ; i++){ for( j = 0 ; j < IMAGE_SIZE/8 ; j++){ int dc = get_next_dc(); float **block = ac_decode_proc(dc); //printBlock(block); de_quantization(block); idct2(block,8); setBlock(block,j,i); _2d_free(block); } } write_file(); /* //ac_decode_proc(0); for(i = 0 ; i< 14 ;i ++){ int index_of_ac = search_codeword_ac(); int run = index_of_ac / 16; int size = index_of_ac % 16; printf("run:%x size : %x\n",run ,size); int t = get_diff_val(size); //printf("diff_val:%d\n",t); } */ } void de_quantization(float** block){ float factor; if(QF < 50) factor = 5000 / QF; else if (QF >= 50) factor = 200 - 2 * QF; float q_matrix[8][8]; int i,j; for(i = 0; i < 8 ; i++){ for(j = 0 ; j < 8 ; j++){ q_matrix[i][j] = s_matrix[i][j] * factor / 100; block[i][j] = block[i][j] * q_matrix [i][j]; } } } void write_file(){ int i,j; for(i = 0 ; i < IMAGE_SIZE ; i++){ for( j = 0 ; j < IMAGE_SIZE ; j++){ unsigned char byte = image_byte[i][j]; fwrite(&byte,1,sizeof(byte),fout); } } } int get_next_dc(){ int ssss = dc_get_ssss(); int diff_val = get_diff_val(ssss); int dc_val = get_dc_val(diff_val); return dc_val; } float** ac_decode_proc(int dc){ //malloc block float **block; block = (float **) malloc(sizeof(float *)*8); int i,j; for(i = 0 ; i < 8 ; i++){ block[i] = (float *) malloc(sizeof(float) * 8); } block[0][0] = dc; int count = 1; for( ;;){ int index_of_ac = search_codeword_ac(); //printf("%d\n",index_of_ac); //printf("HERE\n"); int run = index_of_ac / 16; int size = index_of_ac % 16; int type = 0;//default = 0 ZRL = 1 EOB = 2 if(run == 0xf && size == 0x0){ type = 1; } else if (run == 0x0 && size == 0x0){ type = 2; } //printf("run:%d size:%d\n",run,size); if(type == 0){ int k; for(k = 0 ; k < run ; k++){ block[zigZagOrder[count]/8][zigZagOrder[count]%8] = 0; count++; } int diff_val = get_diff_val(size); block[zigZagOrder[count]/8][zigZagOrder[count]%8] = diff_val; count++; } else if(type == 1){ int k; for(k = 0 ; k < 15 ; k++){ block[zigZagOrder[count]/8][zigZagOrder[count]%8] = 0; count++; } } else if(type == 2){ int res = 64 - count; int k; for(k = 0 ; k < res ; k++){ block[zigZagOrder[count]/8][zigZagOrder[count]%8] = 0; count++; } break; } } /*print block for(i = 0; i < 8 ; i++){ for(j = 0 ; j < 8 ; j++){ printf("%d\t",(* (*(block+i)+j))); } printf("\n"); } */ return block; } void setBlock(float** block,int x,int y){ int i,j; for(i = 0; i < 8 ; i++){ for(j = 0 ; j < 8 ; j++){ image_byte[8*y+i][8*x+j] = (unsigned char)round(block[i][j] + 128) ; } } } int search_codeword_ac(){ int val = 0; int code_len = 0; while(1) { val += get_bit(); code_len++; int count = find_count_by_len(code_len); int i; for(i = 0 ; i < count ; i++){ if (val == acHuffmanTable[find_index_by_order_and_len(code_len,i)]){ //printf("index:%d\n",find_index_by_order_and_len(code_len,i)); return find_index_by_order_and_len(code_len,i); } } val <<= 1; } } int get_dc_val(int diff_val){ int dc_val = dpcm_pre_val + diff_val; dpcm_pre_val = dc_val; return dc_val; } char get_bit(){ if(read_counter == 0){ fread(&temp_byte, sizeof(char), 1, fin); } char result = MSB( temp_byte ); temp_byte <<= 1; read_counter++; if(read_counter == 8){ read_counter = 0; } return result; } int dc_get_ssss(){ int tmp = 0; int code_len = 0; int arr_ptr = 0; int FLAG_SUCESS = 0; while(1) { tmp += get_bit(); code_len++; while( code_len == dcHuffmanLength[arr_ptr]){ if(tmp == dcHuffmanValues[arr_ptr]){ FLAG_SUCESS = 1; break; } arr_ptr++; } tmp <<=1; if(FLAG_SUCESS) break; } return arr_ptr; } int get_diff_val(int ssss){ int diff_tab_len = 1 << ssss; int diff_index = 0; int diff_val; int i; for(i = 0 ; i < ssss ; i++){ diff_index <<= 1; diff_index += get_bit(); } if( diff_index >= (diff_tab_len / 2) ){ diff_val = diff_index; } else{ diff_val = diff_index - diff_tab_len + 1; } if(ssss == 0){ if(get_bit() == 0){ return 0; } } else return diff_val; } int find_count_by_len(int len){ int count = 0,i; for( i = 0 ; i < 256 ; i++){ if(acHuffmanLength[i] == len) count++; } return count; } int find_index_by_order_and_len(int len,int order){ int i; int count = 0; for(i = 0 ; i < 256 ; i++){ if(acHuffmanLength[i] == len){ if(count == order){ return i; } count++; } } }
the_stack_data/167331967.c
// setjmp_ex.c : setjmp() - longjmp() example // ------------------------------------------------------------- #include <setjmp.h> // int setjmp( jmp_buf env ); // void longjmp( jmp_buf environment, // int returnval ); #include <stdlib.h> #include <stdio.h> #include <errno.h> double calculate1( double x); // Functions defined double calculate2( double x); // in calculate.c. jmp_buf jmp_dest; // Destination for longjmp() int main() { double x = 0, y1, y2; int n = 0; puts("--- Demonstrating non-local jumps ---\n"); switch( setjmp( jmp_dest)) // Jump to here for error handling { case 0: // The original setjmp() call break; case EDOM: // Arrived via longjmp() call with EDOM puts("Domain error. " "Negative numbers are not permitted."); break; case ERANGE: // Arrived via longjmp() call with ERANGE puts("Range error. " "The number you entered is too big."); break; default: // We should never arrive here. puts("Unknown error."); exit( EXIT_FAILURE ); } printf("Enter a number: "); do { if ( (n = scanf("%lf", &x)) < 0) // Read in a number. exit( EXIT_FAILURE ); // Read end of file. while ( getchar() != '\n') // Clear the input buffer. ; if ( n == 0 ) printf("Invalid entry. Try again: "); }while ( n == 0 ); y1 = calculate1(x); y2 = calculate2(x); printf("\nResult of Calculation 1: %G\n", y1); printf( "Result of Calculation 2: %G\n", y2); return 0; }
the_stack_data/212643697.c
/* { dg-skip-if "non-SI pointers" { m32c-*-* } { "*" } { "" } } */ /* This testcase tests whether GCC can produce static initialized data that references addresses of size 'unsigned long', even if that's not the same as __SIZE_TYPE__. (See 20011114-1.c for the same test of size __SIZE_TYPE__.) Some rare environments might not have the required relocs to support this; they should have this test disabled in the .x file. */ extern void _text; static unsigned long x = (unsigned long) &_text - 0x10000000L - 1;
the_stack_data/23575438.c
#include <stdio.h> int exists(int *arr, int size, int value) { while (size > 0) { if (*arr == value) return 1; arr++; size--; } return 0; } void printCode(int *arr) { int temp[10]; int min_index = 0; for (int i=2; i<10; i+=2) { if (arr[i] < arr[min_index]) { min_index = i; } } for (int i=0; i<10; i++) { temp[i] = arr[(i+min_index)%10]; } for (int i=0; i<10; i+=2) { printf("%d", temp[i]); printf("%d", temp[(i+1)%10]); printf("%d", temp[(i+3)%10]); } printf("\n"); } void showSolution10(int *arr) { printf(" %2d\n", arr[2]); printf(" \\\n"); printf(" _%2d %2d\n", arr[3], arr[4]); printf(" _%2d \\ /\n", arr[1]); printf("%2d | %2d\n", arr[0], arr[5]); printf(" %2d _ /\n", arr[9]); printf(" | %2d _\n", arr[7]); printf(" %2d %2d\n", arr[8], arr[6]); printf("\n"); printCode(arr); } /* * 2 a * \ \ * _ 3 4 _ b d * _ 1 \ / _ X \ / * 0 | 5 X | c * 9 _ / g _ / * | 7 _ | e _ * 8 6 h f */ int main() { int gon[10]; gon[0] = 10; for (int a=9; a>0; a--) { gon[2] = a; for (int b=9; b>0; b--) { if (b == a) continue; gon[3] = b; for (int c=9; c>0; c--) { if (exists(gon+2, 2, c)) continue; gon[5] = c; int sum = a + b + c; gon[1] = sum - 10 - b; if (gon[1] < 1 || gon[1] > 9) continue; if (gon[1] == c) continue; if (exists(gon+2, 2, gon[1])) continue; for (int d=9; d>0; d--) { if (d == c) continue; if (exists(gon+1, 3, d)) continue; gon[4] = d; int e = sum - d - c; if (e < 1 || e > 9) continue; if (exists(gon+1, 5, e)) continue; gon[7] = e; for (int f=9; f>0; f--) { if (f == e) continue; if (exists(gon+1, 5, f)) continue; gon[6] = f; int g = sum - e - f; if (g < 1 || g > 9) continue; if (exists(gon+1, 7, g)) continue; gon[9] = g; int h = sum - gon[1] - g; if (h < 1 || h > 9) continue; if (exists(gon+1, 7, h)) continue; if (h == g) continue; gon[8] = h; showSolution10(gon); } } } } } printf("Given all these codes, you choose which one you like best.\n"); return 0; }
the_stack_data/150143690.c
/* Kansas City Standard encoder * Encodes standard input to an 8-bit PCM 22,050 Hz WAV on standard output. * This is free and unencumbered software released into the public domain. */ #include <stdio.h> #ifndef BAUD # define BAUD 300 // 300, 600, or 1200 #endif #ifndef STOPBITS # define STOPBITS 2 // 1 or 2 #endif static const short lengths[] = {19, 18, 18, 18, 18, 18, 19, 19}; static const unsigned char samples[2][8][19] = { { {0x7f, 0xaa, 0xd0, 0xec, 0xfc, 0xfd, 0xf0, 0xd6, 0xb1, 0x87, 0x5c, 0x35, 0x16, 0x04, 0x00, 0x0a, 0x22, 0x45, 0x6f}, {0xa5, 0xcb, 0xe9, 0xfb, 0xfe, 0xf2, 0xda, 0xb6, 0x8d, 0x61, 0x39, 0x1a, 0x06, 0x00, 0x08, 0x1f, 0x40, 0x69}, {0x9f, 0xc7, 0xe6, 0xf9, 0xfe, 0xf5, 0xdd, 0xbb, 0x92, 0x67, 0x3e, 0x1d, 0x07, 0x00, 0x06, 0x1b, 0x3c, 0x64}, {0x9a, 0xc2, 0xe3, 0xf8, 0xfe, 0xf7, 0xe1, 0xc0, 0x97, 0x6c, 0x43, 0x21, 0x09, 0x00, 0x05, 0x18, 0x37, 0x5f}, {0x95, 0xbe, 0xdf, 0xf6, 0xfe, 0xf8, 0xe4, 0xc5, 0x9d, 0x71, 0x48, 0x24, 0x0c, 0x00, 0x03, 0x15, 0x33, 0x59}, {0x8f, 0xb9, 0xdc, 0xf4, 0xfe, 0xfa, 0xe8, 0xc9, 0xa2, 0x77, 0x4d, 0x28, 0x0e, 0x01, 0x02, 0x12, 0x2e, 0x54}, {0x8a, 0xb4, 0xd8, 0xf1, 0xfe, 0xfb, 0xeb, 0xcd, 0xa7, 0x7c, 0x52, 0x2c, 0x11, 0x02, 0x01, 0x0f, 0x2a, 0x4f, 0x7a}, {0x84, 0xaf, 0xd4, 0xef, 0xfd, 0xfc, 0xed, 0xd2, 0xac, 0x82, 0x57, 0x31, 0x13, 0x03, 0x00, 0x0d, 0x26, 0x4a, 0x74} }, { {0x7f, 0xd0, 0xfc, 0xf0, 0xb1, 0x5c, 0x16, 0x00, 0x22, 0x6f, 0xc2, 0xf8, 0xf7, 0xc0, 0x6c, 0x21, 0x00, 0x18, 0x5f}, {0xc7, 0xf9, 0xf5, 0xbb, 0x67, 0x1d, 0x00, 0x1b, 0x64, 0xb9, 0xf4, 0xfa, 0xc9, 0x77, 0x28, 0x01, 0x12, 0x54}, {0xbe, 0xf6, 0xf8, 0xc5, 0x71, 0x24, 0x00, 0x15, 0x59, 0xaf, 0xef, 0xfc, 0xd2, 0x82, 0x31, 0x03, 0x0d, 0x4a}, {0xb4, 0xf1, 0xfb, 0xcd, 0x7c, 0x2c, 0x02, 0x0f, 0x4f, 0xa5, 0xe9, 0xfe, 0xda, 0x8d, 0x39, 0x06, 0x08, 0x40}, {0xaa, 0xec, 0xfd, 0xd6, 0x87, 0x35, 0x04, 0x0a, 0x45, 0x9a, 0xe3, 0xfe, 0xe1, 0x97, 0x43, 0x09, 0x05, 0x37}, {0x9f, 0xe6, 0xfe, 0xdd, 0x92, 0x3e, 0x07, 0x06, 0x3c, 0x8f, 0xdc, 0xfe, 0xe8, 0xa2, 0x4d, 0x0e, 0x02, 0x2e}, {0x95, 0xdf, 0xfe, 0xe4, 0x9d, 0x48, 0x0c, 0x03, 0x33, 0x84, 0xd4, 0xfd, 0xed, 0xac, 0x57, 0x13, 0x00, 0x26, 0x74}, {0x8a, 0xd8, 0xfe, 0xeb, 0xa7, 0x52, 0x11, 0x01, 0x2a, 0x7a, 0xcb, 0xfb, 0xf2, 0xb6, 0x61, 0x1a, 0x00, 0x1f, 0x69} } }; static const unsigned char header[] = { 0x52, 0x49, 0x46, 0x46, 0xff, 0xff, 0xff, 0xff, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x22, 0x56, 0x00, 0x00, 0x22, 0x56, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61, 0xff, 0xff, 0xff, 0xff }; static const unsigned char blank[16]; static void bit(int b) { static int phase = 0; for (int i = 0; i < 1200/BAUD; i++) { fwrite(samples[b][phase], lengths[phase], 1, stdout); phase = (phase + 3) & 7; } } int main(void) { #ifdef _WIN32 int _setmode(int, int); _setmode(0, 0x8000); _setmode(1, 0x8000); #endif fwrite(header, sizeof(header), 1, stdout); fwrite(blank, sizeof(blank), 1, stdout); for (int c = getchar(); c != EOF; c = getchar()) { bit(0); for (int i = 0; i < 8; i++) { bit(c>>i & 1); } for (int i = 0; i < STOPBITS; i++) { bit(1); } } fwrite(blank, sizeof(blank), 1, stdout); fflush(stdout); return ferror(stdout); }
the_stack_data/96870.c
#include <stdio.h> #include <stdlib.h> char * banner = "\n" " .';,. ....;;;. \n" " .ll,:o, ':c,. \n" " .dd;co' .cl, \n" " .:o:;,. 'o: \n" " co. .oc \n" " ,o' .coddoc. 'd, \n" " lc .lXMMMMMMXl. ll \n" " .o: ;KMMMMMMMMK, :o. \n" " .o: 'OMMMMMMMMO. :o. \n" " co. .o0XNNX0o. .oc \n" " .o: ..''.. :o. \n" " 'o: :o' \n" " .lc. .ll. \n" " ,lc' 'cl, \n" " 'cc:,.. ..,:c:' \n" " .;::::;;;;::::;. \n" " .... \n" " ____ _________ _______ __ __ \n" " / __ \\/ _/ ___// ____/ | / / ____ _/ /_____ ____ ___ \n" " / /_/ // / \\__ \\/ / | | / / / __ `/ __/ __ \\/ __ `__ \\ \n" " / _, _// / ___/ / /___ | |/ / / /_/ / /_/ /_/ / / / / / / \n" " /_/ |_/___//____/\\____/ |___/ \\__,_/\\__/\\____/_/ /_/ /_/ \n" "/=========By: Saurabh Singh ([email protected])====/\n\n"; int main() { puts(banner); char c[50]; gets(c, 50, 1, NULL); int n = atoi(c); printf("8th multiple of %d is %d", n, n*3); return 0; }
the_stack_data/39032.c
// wrapper for dlldata.c #ifdef _MERGE_PROXYSTUB // merge proxy stub DLL #define REGISTER_PROXY_DLL //DllRegisterServer, etc. #define _WIN32_WINNT 0x0500 //for WinNT 4.0 or Win95 with DCOM #define USE_STUBLESS_PROXY //defined only with MIDL switch /Oicf #pragma comment(lib, "rpcns4.lib") #pragma comment(lib, "rpcrt4.lib") #define ENTRY_PREFIX Prx #include "dlldata.c" #include "Player_p.c" #endif //_MERGE_PROXYSTUB
the_stack_data/131583.c
#include <stdio.h> void FibonacciSeq (int InputNumber); int main() { int Integer; printf("Input Integer: "); scanf("%d", &Integer); FibonacciSeq(Integer); return 0; } void FibonacciSeq(int InputNumber) { int Value[2]; int NextNumber; Value[0] = 0; Value [1] = 1; if(InputNumber == 1) { printf("%d\n", (Value[0])); } else if(InputNumber == 2) { printf("%d, %d\n", (Value[0]), (Value[1])); } else { int i; printf("%d, %d", (Value[0]), (Value[1])); for(i=2; i<InputNumber-1; i++) { NextNumber = Value[0] + Value[1]; Value[0] = Value[1]; Value[1] = NextNumber; printf(", %d", (Value[1])); } Value[1] = Value[0] + Value[1]; printf(", %d\n", (Value[1])); } }
the_stack_data/356097.c
/* Exercise 1-5. Modify the temperature conversion program to print the table in reverse order, that is, from 300 degrees to 0. */ #include <stdio.h> /* print Fahrenheit-Celsius table (in reverse order) */ int main(void) { int fahr; printf(" F C\n"); for (fahr = 300; fahr >= 0; fahr = fahr - 20) printf("%3d %6.1f\n", fahr, (5.0/9.0) * (fahr-32.0)); }
the_stack_data/24123.c
#include <stdio.h> #define NotAVertex (-1) typedef int TwoDimArray[4][4]; /* START: fig10_53.txt */ /* Compute All-Shortest Paths */ /* A[ ] contains the adjacency matrix */ /* with A[ i ][ i ] presumed to be zero */ /* D[ ] contains the values of the shortest path */ /* N is the number of vertices */ /* A negative cycle exists iff */ /* D[ i ][ i ] is set to a negative value */ /* Actual path can be computed using Path[ ] */ /* All arrays are indexed starting at 0 */ /* NotAVertex is -1 */ void AllPairs (TwoDimArray A, TwoDimArray D, TwoDimArray Path, int N) { int i, j, k; /* Initialize D and Path */ /* 1*/ for (i = 0; i < N; i++) /* 2*/ for (j = 0; j < N; j++) { /* 3*/ D[i][j] = A[i][j]; /* 4*/ Path[i][j] = NotAVertex; } /* 5*/ for (k = 0; k < N; k++) /* Conider each vertex as an intermediate */ /* 6*/ for (i = 0; i < N; i++) /* 7*/ for (j = 0; j < N; j++) /* 8*/ if (D[i][k] + D[k][j] < D[i][j]) { /* Update shortest path */ /* 9*/ D[i][j] = D[i][k] + D[k][j]; /*10*/ Path[i][j] = k; } } /* END */ main () { TwoDimArray A = { {0, 2, -2, 2} , {1000, 0, -3, 1000} , {4, 1000, 0, 1000} , {1000, -2, 3, 0} }; TwoDimArray D, Path; int i, j; AllPairs (A, D, Path, 4); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) printf ("%6d ", D[i][j]); printf ("\n"); } for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) printf ("%6d ", Path[i][j]); printf ("\n"); } return 0; }
the_stack_data/89199781.c
/* mbed Microcontroller Library * Copyright (c) 2006-2018 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if DEVICE_SPI #include "mbed_assert.h" #include <math.h> #include "spi_api.h" #include "rda_ccfg_api.h" #include "cmsis.h" #include "pinmap.h" /*------------- Wlan Monitor (WLANMON) ---------------------------------------*/ typedef struct { __IO uint32_t PHYSEL_3_0; /* 0x00 : PHY select register 0 - 3 */ } RDA_WLANMON_TypeDef; /* * Macros */ #define RDA_MON ((RDA_WLANMON_TypeDef *)RDA_MON_BASE) #define ENABLE_RDA_SPI_MODE 0 #define SPI_CLKGATE_REG (RDA_SCU->CLKGATE2) #define SPI_MODESEL_REG (RDA_GPIO->CTRL) #define SPI_PINSEL_REG0 (RDA_GPIO->MEMCFG) #define SPI_PINSEL_REG1 (RDA_MON->PHYSEL_3_0) #define SPI_PINSEL_REG2 (RDA_EXIF->MISCCFG) /* * Global Variables */ static const PinMap PinMap_SPI_SCLK[] = { {PB_4, SPI_0, 4}, {PD_0, SPI_0, 1}, {NC , NC , 0} }; static const PinMap PinMap_SPI_MOSI[] = { {PB_6, SPI_0, 3}, {PC_0, SPI_0, 6}, {PD_2, SPI_0, 1}, {PB_3, SPI_0, 2}, {NC , NC , 0} }; static const PinMap PinMap_SPI_MISO[] = { {PB_7, SPI_0, 3}, {PC_1, SPI_0, 6}, {PD_3, SPI_0, 1}, {PB_8, SPI_0, 3}, {NC , NC , 0} }; static const PinMap PinMap_SPI_SSEL[] = { {PD_1, SPI_0, 1}, {PB_5, SPI_0, 4}, {PA_0, SPI_0, 3}, {PA_1, SPI_0, 3}, {NC , NC , 0} }; /* * Inline Functions */ static inline int spi_pin_cs_num(PinName ssel); static inline void spi_write(spi_t *obj, int value); static inline int spi_read(spi_t *obj); /* * Functions */ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) { uint32_t reg_val; /* Determine the SPI to use */ SPIName spi_mosi = (SPIName)pinmap_peripheral(mosi, PinMap_SPI_MOSI); SPIName spi_miso = (SPIName)pinmap_peripheral(miso, PinMap_SPI_MISO); SPIName spi_sclk = (SPIName)pinmap_peripheral(sclk, PinMap_SPI_SCLK); SPIName spi_ssel = (SPIName)pinmap_peripheral(ssel, PinMap_SPI_SSEL); SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso); SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (RDA_SPI_TypeDef*)pinmap_merge(spi_data, spi_cntl); MBED_ASSERT((int)obj->spi != NC); /* Enable power and clocking */ SPI_CLKGATE_REG |= (0x01UL << 18); /* Select 4-wire SPI mode */ SPI_MODESEL_REG &= ~(0x01UL << 14); /* Set Config Reg */ reg_val = obj->spi->CFG; #if ENABLE_RDA_SPI_MODE /* RDA SPI mode */ reg_val |= (0x01UL << 2); #else /* ENABLE_RDA_SPI_MODE */ /* Normal SPI mode */ reg_val &= ~(0x01UL << 2); /* Set read flag */ reg_val |= (0x01UL << 3); #endif /* ENABLE_RDA_SPI_MODE */ /* Set core cfg for mosi, miso */ if (PB_6 == mosi) { rda_ccfg_gp(6U, 0x01U); } if (PB_7 == miso) { rda_ccfg_gp(7U, 0x01U); } /* Config gpio/wlan_mon regs */ if (PB_3 == mosi) { SPI_MODESEL_REG &= ~(0x0FUL); SPI_PINSEL_REG1 &= ~(0x3FUL << 24); SPI_PINSEL_REG2 &= ~(0x0FUL << 12); SPI_MODESEL_REG |= (0x0BUL); SPI_PINSEL_REG1 |= (0x02UL << 24); SPI_PINSEL_REG2 |= (0x01UL << 12); } if (PB_8 == miso) { SPI_PINSEL_REG0 &= ~(0x01UL << 11); } /* Pin out the SPI pins */ pinmap_pinout(mosi, PinMap_SPI_MOSI); pinmap_pinout(miso, PinMap_SPI_MISO); pinmap_pinout(sclk, PinMap_SPI_SCLK); if (ssel != NC) { int cs_num = spi_pin_cs_num(ssel); reg_val &= ~(0x03UL << 23); reg_val |= (((uint32_t)cs_num & 0x03UL) << 23); pinmap_pinout(ssel, PinMap_SPI_SSEL); } obj->spi->CFG = reg_val; } void spi_free(spi_t *obj) { /* Disable SPI clock gating */ SPI_CLKGATE_REG &= ~(0x01UL << 18); } void spi_format(spi_t *obj, int bits, int mode, int slave) { uint32_t polarity = (mode & 0x2) ? (0x01UL) : (0x00UL); uint32_t reg_val; #if ENABLE_RDA_SPI_MODE MBED_ASSERT(((bits >= 4) && (bits <= 64)) && (mode >= 0 && mode <= 3)); #else /* ENABLE_RDA_SPI_MODE */ MBED_ASSERT(((bits >= 4) && (bits <= 32)) && (mode >= 0 && mode <= 3)); #endif /* ENABLE_RDA_SPI_MODE */ /* Set number of frame bits and clock phase */ reg_val = obj->spi->CFG & ~(0x7FUL << 16) & ~(0x01UL << 1); obj->spi->CFG = reg_val | ((uint32_t)bits << 16) | (polarity << 1); #if ENABLE_RDA_SPI_MODE /* Set bit offset value */ obj->bit_ofst[0] = 0; obj->bit_ofst[1] = 0; if (2 > (bits >> 5)) { obj->bit_ofst[bits >> 5] = (uint8_t)(32 - (bits & 0x1F)); } #else /* ENABLE_RDA_SPI_MODE */ obj->bit_ofst[0] = (uint8_t)(32 - bits); #endif /* ENABLE_RDA_SPI_MODE */ } void spi_frequency(spi_t *obj, int hz) { uint32_t clk_rate = ((AHBBusClock / (uint32_t)hz) >> 2) - 1U; uint32_t reg_val; /* Check for valid frequency */ MBED_ASSERT(clk_rate <= 0x3FUL); /* Set clk rate field */ reg_val = obj->spi->CFG & ~(0x3FUL << 4); obj->spi->CFG = reg_val | ((clk_rate & 0x3FUL) << 4); } int spi_master_write(spi_t *obj, int value) { spi_write(obj, value); return spi_read(obj); } int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, char write_fill) { int total = (tx_length > rx_length) ? tx_length : rx_length; for (int i = 0; i < total; i++) { char out = (i < tx_length) ? tx_buffer[i] : write_fill; char in = spi_master_write(obj, out); if (i < rx_length) { rx_buffer[i] = in; } } return total; } int spi_busy(spi_t *obj) { return (obj->spi->CFG & (0x01UL << 31)) ? (1) : (0); } static inline int spi_pin_cs_num(PinName ssel) { int idx = 0; while (PinMap_SPI_SSEL[idx].pin != NC) { if (PinMap_SPI_SSEL[idx].pin == ssel) return idx; idx++; } return (int)NC; } static inline void spi_write(spi_t *obj, int value) { #if ENABLE_RDA_SPI_MODE /* Write data register */ if (obj->bit_ofst[0] != 0) { obj->spi->D1CMD = (uint32_t)value << obj->bit_ofst[0]; } else { obj->spi->D1CMD = (uint32_t)value; obj->spi->D0CMD = (uint32_t)value << obj->bit_ofst[1]; } /* Set write bit & start bit */ obj->spi->CFG = (obj->spi->CFG & ~(0x01UL << 3)) | 0x01UL; #else /* ENABLE_RDA_SPI_MODE */ /* Write data reg */ if (obj->bit_ofst[0] != 0) { obj->spi->D1CMD = ((uint32_t)value << obj->bit_ofst[0]) | (0xFFFFFFFFUL >> (32 - obj->bit_ofst[0])); } else { obj->spi->D1CMD = (uint32_t)value; obj->spi->D0CMD = 0xFFFFFFFFUL; } /* Set start bit */ obj->spi->CFG |= 0x01UL; #endif /* ENABLE_RDA_SPI_MODE */ __DSB(); while (spi_busy(obj)); } static inline int spi_read(spi_t *obj) { uint32_t ret_val; #if ENABLE_RDA_SPI_MODE /* Set read bit & start bit */ obj->spi->CFG |= ((0x01UL << 3) | 0x01UL); __DSB(); while (spi_busy(obj)); /* Read data register */ if (obj->bit_ofst[0] != 0) { ret_val = obj->spi->D0CMD & ((0x01UL << (32UL - obj->bit_ofst[0])) - 1UL); } else { ret_val = obj->spi->D0CMD; ret_val = obj->spi->D1CMD & ((0x01UL << (32UL - obj->bit_ofst[1])) - 1UL); } #else /* ENABLE_RDA_SPI_MODE */ /* Read data register */ ret_val = obj->spi->D0CMD & ((0x01UL << (32UL - obj->bit_ofst[0])) - 1UL); #endif /* ENABLE_RDA_SPI_MODE */ return (int)ret_val; } const PinMap *spi_master_mosi_pinmap() { return PinMap_SPI_MOSI; } const PinMap *spi_master_miso_pinmap() { return PinMap_SPI_MISO; } const PinMap *spi_master_clk_pinmap() { return PinMap_SPI_SCLK; } const PinMap *spi_master_cs_pinmap() { return PinMap_SPI_SSEL; } const PinMap *spi_slave_mosi_pinmap() { return PinMap_SPI_MOSI; } const PinMap *spi_slave_miso_pinmap() { return PinMap_SPI_MISO; } const PinMap *spi_slave_clk_pinmap() { return PinMap_SPI_SCLK; } const PinMap *spi_slave_cs_pinmap() { return PinMap_SPI_SSEL; } #endif
the_stack_data/178265306.c
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> #include <ctype.h> int main(void){ pid_t hijo; int tuberia[2]; FILE *datos; char respuesta; //Se convierte el array a tubería. Lo hace unistd.h pipe(tuberia); hijo = fork(); if(hijo>0) { /*Proceso PADRE. * Lee la respuesta del usuario y se la manda al hijo. * Escribe un dato en la tuberia.*/ close(tuberia[0]); printf("Introduce h para hola y a para adios. \n"); scanf("%c", &respuesta); datos = fdopen(tuberia[1], "w"); fprintf(datos, "%c", respuesta); //Envio de datos fclose(datos); //Cerrar flujo de datos wait(NULL); puts("Mi hijo ha muerto cumpliendo con su deber. \n"); } if(hijo == 0) { /*Proceso HIJO, * Recibimos el lado 0 de la tuberia, por lo que hay * que cerrar el lado 1. * Después se hace un fscanf para leer la info y se imprime * con un printf para saber el caracter intruducido en el proceso * padre. Después el flcose se limpia la memoria usada en la tuberia.*/ close(tuberia[1]); //abrimos el fichero e imprimimos la info datos = fdopen(tuberia[0], "r"); fscanf(datos, "%c", &respuesta); printf("He leido de la tuberia el carácter: %c. \n", respuesta); fclose(datos); exit(0); } return 0; }
the_stack_data/67324934.c
/* { dg-do compile } */ /* { dg-options "-O2 -funroll-loops" } */ extern void bar () __attribute__ ((noreturn)); inline double baz (double *x, unsigned int y) { if (y >= 6) bar (); return x[y]; } double *a, *b; void foo () { unsigned int r, s, t; for (r = 0; r < 2; r++) for (t = 0; t < 2; t++) { for (s = 0; s < 3; s++) b[r * 2 + t] += baz (a, 3 * s + t); } }
the_stack_data/114298.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2013 Free Software Foundation, Inc. Contributed by Intel Corp. <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ void fun1 (void) { /* fun1.1 */ } /* fun1.2 */ void fun2 (void) { /* fun2.1 */ fun1 (); /* fun2.2 */ } /* fun2.3 */ void fun3 (void) { /* fun3.1 */ fun1 (); /* fun3.2 */ fun2 (); /* fun3.3 */ } /* fun3.4 */ void fun4 (void) { /* fun4.1 */ fun1 (); /* fun4.2 */ fun2 (); /* fun4.3 */ fun3 (); /* fun4.4 */ } /* fun4.5 */ int main (void) { /* main.1 */ fun4 (); /* main.2 */ return 0; /* main.3 */ } /* main.4 */
the_stack_data/87637782.c
#ifndef TH_GENERIC_FILE #define TH_GENERIC_FILE "generic/VolumetricConvolution.c" #else static int nn_(VolumetricConvolution_updateOutput)(lua_State *L) { THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); int dT = luaT_getfieldcheckint(L, 1, "dT"); int dW = luaT_getfieldcheckint(L, 1, "dW"); int dH = luaT_getfieldcheckint(L, 1, "dH"); THTensor *weight = luaT_getfieldcheckudata(L, 1, "weight", torch_(Tensor_id)); THTensor *bias = luaT_getfieldcheckudata(L, 1, "bias", torch_(Tensor_id)); THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); luaL_argcheck(L, input->nDimension == 4, 2, "4D tensor expected"); long nOutputPlane = weight->size[0]; long kT = weight->size[2]; long kH = weight->size[3]; long kW = weight->size[4]; long inputDepth = input->size[1]; long inputHeight = input->size[2]; long inputWidth = input->size[3]; long outputDepth = (inputDepth - kT) / dT + 1; long outputWidth = (inputWidth - kW) / dW + 1; long outputHeight = (inputHeight - kH) / dH + 1; THTensor_(resize4d)(output, nOutputPlane, outputDepth, outputHeight, outputWidth); /* add bias */ long i; THTensor *outn = THTensor_(new)(); for (i=0; i<bias->size[0]; i++) { THTensor_(select)(outn,output,0,i); THTensor_(fill)(outn, THTensor_(get1d)(bias, i)); } THTensor_(free)(outn); /* do convolutions */ THTensor_(conv3Dmv)(output, 1.0, 1.0, input, weight, dT, dH, dW, "V", "X"); return 1; } static int nn_(VolumetricConvolution_updateGradInput)(lua_State *L) { THTensor *gradOutput = luaT_checkudata(L, 3, torch_(Tensor_id)); int dT = luaT_getfieldcheckint(L, 1, "dT"); int dW = luaT_getfieldcheckint(L, 1, "dW"); int dH = luaT_getfieldcheckint(L, 1, "dH"); int nOutputPlane = luaT_getfieldcheckint(L, 1, "nOutputPlane"); THTensor *weight = luaT_getfieldcheckudata(L, 1, "weight", torch_(Tensor_id)); THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); THArgCheck( nOutputPlane == gradOutput->size[0], 1, "Number of output features is not equal to nOutputPlane" ); /* gradient to input */ THTensor *tweight = THTensor_(newTranspose)(weight,0,1); THTensor_(conv3Dmv)(gradInput, 0.0, 1.0, gradOutput, tweight, dT, dH, dW, "F", "C"); THTensor_(free)(tweight); return 1; } static int nn_(VolumetricConvolution_accGradParameters)(lua_State *L) { THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); THTensor *gradOutput = luaT_checkudata(L, 3, torch_(Tensor_id)); real scale = luaL_optnumber(L, 4, 1); int dT = luaT_getfieldcheckint(L, 1, "dT"); int dW = luaT_getfieldcheckint(L, 1, "dW"); int dH = luaT_getfieldcheckint(L, 1, "dH"); int nOutputPlane = luaT_getfieldcheckint(L, 1, "nOutputPlane"); THTensor *gradWeight = luaT_getfieldcheckudata(L, 1, "gradWeight", torch_(Tensor_id)); THTensor *gradBias = luaT_getfieldcheckudata(L, 1, "gradBias", torch_(Tensor_id)); THArgCheck( nOutputPlane == gradOutput->size[0], 1, "Number of output features is not equal to nOutputPlane" ); long k; /* gradient to bias */ real *gradBias_data = THTensor_(data)(gradBias); THTensor* gradOutSlice = THTensor_(new)(); for(k = 0; k < nOutputPlane; k++) { THTensor_(select)(gradOutSlice, gradOutput, 0, k); gradBias_data[k] += scale*THTensor_(sumall)(gradOutSlice); } THTensor_(free)(gradOutSlice); /* gradient to kernels */ THTensor_(conv3DRevger)(gradWeight, 1.0, scale, input, gradOutput, dT, dH, dW); return 0; } static const struct luaL_Reg nn_(VolumetricConvolution__) [] = { {"VolumetricConvolution_updateOutput", nn_(VolumetricConvolution_updateOutput)}, {"VolumetricConvolution_updateGradInput", nn_(VolumetricConvolution_updateGradInput)}, {"VolumetricConvolution_accGradParameters", nn_(VolumetricConvolution_accGradParameters)}, {NULL, NULL} }; static void nn_(VolumetricConvolution_init)(lua_State *L) { luaT_pushmetaclass(L, torch_(Tensor_id)); luaT_registeratname(L, nn_(VolumetricConvolution__), "nn"); lua_pop(L,1); } #endif
the_stack_data/64200384.c
float Q_rsqrt(float number) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = *(long *)&y; // evil floating point bit level hacking i = 0x5f3759df - (i >> 1); // what the fuck? y = *(float *)&i; y = y * (threehalfs - (x2 * y * y)); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be // removed #ifndef Q3_VM #ifdef __linux__ assert(!isnan(y)); // bk010122 - FPE? #endif #endif return y; }
the_stack_data/654897.c
//file: _insn_test_andi_Y0.c //op=30 #include <stdio.h> #include <stdlib.h> void func_exit(void) { printf("%s\n", __func__); exit(0); } void func_call(void) { printf("%s\n", __func__); exit(0); } unsigned long mem[2] = { 0xd5c03dafaeab4e7e, 0xbca200a47bf08fef }; int main(void) { unsigned long a[4] = { 0, 0 }; asm __volatile__ ( "moveli r46, -22782\n" "shl16insli r46, r46, -24188\n" "shl16insli r46, r46, -5494\n" "shl16insli r46, r46, 12791\n" "moveli r3, -24353\n" "shl16insli r3, r3, 7605\n" "shl16insli r3, r3, -19417\n" "shl16insli r3, r3, 15971\n" "{ andi r46, r3, 96 ; fnop ; ld r63, r54 }\n" "move %0, r46\n" "move %1, r3\n" :"=r"(a[0]),"=r"(a[1])); printf("%016lx\n", a[0]); printf("%016lx\n", a[1]); return 0; }
the_stack_data/132656.c
// WARNING in wiphy_register (3) // https://syzkaller.appspot.com/bug?id=5f7eb1ca4f4c65bbea3215c8f3925c8f979306ac // status:fixed // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <pthread.h> #include <sched.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/futex.h> #include <linux/if_addr.h> #include <linux/if_ether.h> #include <linux/if_link.h> #include <linux/if_tun.h> #include <linux/in6.h> #include <linux/ip.h> #include <linux/neighbour.h> #include <linux/net.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/tcp.h> #include <linux/veth.h> unsigned long long procid; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && (addr < prog_start || addr > prog_end)) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ { \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); if (pthread_create(&th, &attr, fn, arg)) exit(1); pthread_attr_destroy(&attr); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } 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 struct { char* pos; int nesting; struct nlattr* nested[8]; char buf[1024]; } nlmsg; static void netlink_init(int typ, int flags, const void* data, int size) { memset(&nlmsg, 0, sizeof(nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg.buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg.pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg.pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; memcpy(attr + 1, data, size); nlmsg.pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(int typ) { struct nlattr* attr = (struct nlattr*)nlmsg.pos; attr->nla_type = typ; nlmsg.pos += sizeof(*attr); nlmsg.nested[nlmsg.nesting++] = attr; } static void netlink_done(void) { struct nlattr* attr = nlmsg.nested[--nlmsg.nesting]; attr->nla_len = nlmsg.pos - (char*)attr; } static int netlink_send(int sock) { if (nlmsg.pos > nlmsg.buf + sizeof(nlmsg.buf) || nlmsg.nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg.buf; hdr->nlmsg_len = nlmsg.pos - nlmsg.buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; unsigned n = sendto(sock, nlmsg.buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != hdr->nlmsg_len) exit(1); n = recv(sock, nlmsg.buf, sizeof(nlmsg.buf), 0); if (n < sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr)) exit(1); if (hdr->nlmsg_type != NLMSG_ERROR) exit(1); return -((struct nlmsgerr*)(hdr + 1))->error; } static void netlink_add_device_impl(const char* type, const char* name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); netlink_init(RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(IFLA_IFNAME, name, strlen(name)); netlink_nest(IFLA_LINKINFO); netlink_attr(IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(int sock, const char* type, const char* name) { netlink_add_device_impl(type, name); netlink_done(); int err = netlink_send(sock); (void)err; } static void netlink_add_veth(int sock, const char* name, const char* peer) { netlink_add_device_impl("veth", name); netlink_nest(IFLA_INFO_DATA); netlink_nest(VETH_INFO_PEER); nlmsg.pos += sizeof(struct ifinfomsg); netlink_attr(IFLA_IFNAME, peer, strlen(peer)); netlink_done(); netlink_done(); netlink_done(); int err = netlink_send(sock); (void)err; } static void netlink_add_hsr(int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl("hsr", name); netlink_nest(IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(); netlink_done(); int err = netlink_send(sock); (void)err; } static void netlink_device_change(int sock, const char* name, bool up, const char* master, const void* mac, int macsize) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; netlink_init(RTM_NEWLINK, 0, &hdr, sizeof(hdr)); netlink_attr(IFLA_IFNAME, name, strlen(name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(IFLA_ADDRESS, mac, macsize); int err = netlink_send(sock); (void)err; } static int netlink_add_addr(int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(IFA_LOCAL, addr, addrsize); netlink_attr(IFA_ADDRESS, addr, addrsize); return netlink_send(sock); } static void netlink_add_addr4(int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(sock, dev, &in_addr, sizeof(in_addr)); (void)err; } static void netlink_add_addr6(int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(sock, dev, &in6_addr, sizeof(in6_addr)); (void)err; } static void netlink_add_neigh(int sock, const char* name, const void* addr, int addrsize, const void* mac, int macsize) { struct ndmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ndm_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ndm_ifindex = if_nametoindex(name); hdr.ndm_state = NUD_PERMANENT; netlink_init(RTM_NEWNEIGH, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); netlink_attr(NDA_DST, addr, addrsize); netlink_attr(NDA_LLADDR, mac, macsize); int err = netlink_send(sock); (void)err; } static int tunfd = -1; static int tun_frags_enabled; #define SYZ_TUN_MAX_PACKET_SIZE 1000 #define TUN_IFACE "syz_tun" #define LOCAL_MAC 0xaaaaaaaaaaaa #define REMOTE_MAC 0xaaaaaaaaaabb #define LOCAL_IPV4 "172.20.20.170" #define REMOTE_IPV4 "172.20.20.187" #define LOCAL_IPV6 "fe80::aa" #define REMOTE_IPV6 "fe80::bb" #define IFF_NAPI 0x0010 #define IFF_NAPI_FRAGS 0x0020 static void initialize_tun(void) { tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, TUN_IFACE, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_NAPI | IFF_NAPI_FRAGS; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) exit(1); } if (ioctl(tunfd, TUNGETIFF, (void*)&ifr) < 0) exit(1); tun_frags_enabled = (ifr.ifr_flags & IFF_NAPI_FRAGS) != 0; char sysctl[64]; sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/accept_dad", TUN_IFACE); write_file(sysctl, "0"); sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/router_solicitations", TUN_IFACE); write_file(sysctl, "0"); int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); netlink_add_addr4(sock, TUN_IFACE, LOCAL_IPV4); netlink_add_addr6(sock, TUN_IFACE, LOCAL_IPV6); uint64_t macaddr = REMOTE_MAC; struct in_addr in_addr; inet_pton(AF_INET, REMOTE_IPV4, &in_addr); netlink_add_neigh(sock, TUN_IFACE, &in_addr, sizeof(in_addr), &macaddr, ETH_ALEN); struct in6_addr in6_addr; inet_pton(AF_INET6, REMOTE_IPV6, &in6_addr); netlink_add_neigh(sock, TUN_IFACE, &in6_addr, sizeof(in6_addr), &macaddr, ETH_ALEN); macaddr = LOCAL_MAC; netlink_device_change(sock, TUN_IFACE, true, 0, &macaddr, ETH_ALEN); close(sock); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02hx" #define DEV_MAC 0x00aaaaaaaaaa static void initialize_netdevices(void) { char netdevsim[16]; sprintf(netdevsim, "netdevsim%d", (int)procid); struct { const char* type; const char* dev; } devtypes[] = { {"ip6gretap", "ip6gretap0"}, {"bridge", "bridge0"}, {"vcan", "vcan0"}, {"bond", "bond0"}, {"team", "team0"}, {"dummy", "dummy0"}, {"nlmon", "nlmon0"}, {"caif", "caif0"}, {"batadv", "batadv0"}, {"vxcan", "vxcan1"}, {"netdevsim", netdevsim}, {"veth", 0}, }; const char* devmasters[] = {"bridge", "bond", "team"}; struct { const char* name; int macsize; bool noipv6; } devices[] = { {"lo", ETH_ALEN}, {"sit0", 0}, {"bridge0", ETH_ALEN}, {"vcan0", 0, true}, {"tunl0", 0}, {"gre0", 0}, {"gretap0", ETH_ALEN}, {"ip_vti0", 0}, {"ip6_vti0", 0}, {"ip6tnl0", 0}, {"ip6gre0", 0}, {"ip6gretap0", ETH_ALEN}, {"erspan0", ETH_ALEN}, {"bond0", ETH_ALEN}, {"veth0", ETH_ALEN}, {"veth1", ETH_ALEN}, {"team0", ETH_ALEN}, {"veth0_to_bridge", ETH_ALEN}, {"veth1_to_bridge", ETH_ALEN}, {"veth0_to_bond", ETH_ALEN}, {"veth1_to_bond", ETH_ALEN}, {"veth0_to_team", ETH_ALEN}, {"veth1_to_team", ETH_ALEN}, {"veth0_to_hsr", ETH_ALEN}, {"veth1_to_hsr", ETH_ALEN}, {"hsr0", 0}, {"dummy0", ETH_ALEN}, {"nlmon0", 0}, {"vxcan1", 0, true}, {"caif0", ETH_ALEN}, {"batadv0", ETH_ALEN}, {netdevsim, ETH_ALEN}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) netlink_add_device(sock, devtypes[i].type, devtypes[i].dev); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { char master[32], slave0[32], veth0[32], slave1[32], veth1[32]; sprintf(slave0, "%s_slave_0", devmasters[i]); sprintf(veth0, "veth0_to_%s", devmasters[i]); netlink_add_veth(sock, slave0, veth0); sprintf(slave1, "%s_slave_1", devmasters[i]); sprintf(veth1, "veth1_to_%s", devmasters[i]); netlink_add_veth(sock, slave1, veth1); sprintf(master, "%s0", devmasters[i]); netlink_device_change(sock, slave0, false, master, 0, 0); netlink_device_change(sock, slave1, false, master, 0, 0); } netlink_device_change(sock, "bridge_slave_0", true, 0, 0, 0); netlink_device_change(sock, "bridge_slave_1", true, 0, 0, 0); netlink_add_veth(sock, "hsr_slave_0", "veth0_to_hsr"); netlink_add_veth(sock, "hsr_slave_1", "veth1_to_hsr"); netlink_add_hsr(sock, "hsr0", "hsr_slave_0", "hsr_slave_1"); netlink_device_change(sock, "hsr_slave_0", true, 0, 0, 0); netlink_device_change(sock, "hsr_slave_1", true, 0, 0, 0); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { char addr[32]; sprintf(addr, DEV_IPV4, i + 10); netlink_add_addr4(sock, devices[i].name, addr); if (!devices[i].noipv6) { sprintf(addr, DEV_IPV6, i + 10); netlink_add_addr6(sock, devices[i].name, addr); } uint64_t macaddr = DEV_MAC + ((i + 10ull) << 40); netlink_device_change(sock, devices[i].name, true, 0, &macaddr, devices[i].macsize); } close(sock); } static void initialize_netdevices_init(void) { int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); struct { const char* type; int macsize; bool noipv6; bool noup; } devtypes[] = { {"nr", 7, true}, {"rose", 5, true, true}, }; unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) { char dev[32], addr[32]; sprintf(dev, "%s%d", devtypes[i].type, (int)procid); sprintf(addr, "172.30.%d.%d", i, (int)procid + 1); netlink_add_addr4(sock, dev, addr); if (!devtypes[i].noipv6) { sprintf(addr, "fe88::%02hx:%02hx", i, (int)procid + 1); netlink_add_addr6(sock, dev, addr); } int macsize = devtypes[i].macsize; uint64_t macaddr = 0xbbbbbb + ((unsigned long long)i << (8 * (macsize - 2))) + (procid << (8 * (macsize - 1))); netlink_device_change(sock, dev, !devtypes[i].noup, 0, &macaddr, macsize); } close(sock); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; if (errno == EBADFD) return -1; exit(1); } return rv; } static void flush_tun() { char data[SYZ_TUN_MAX_PACKET_SIZE]; while (read_tun(&data[0], sizeof(data)) != -1) { } } #define XT_TABLE_SIZE 1536 #define XT_MAX_ENTRIES 10 struct xt_counters { uint64_t pcnt, bcnt; }; struct ipt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_entries; unsigned int size; }; struct ipt_get_entries { char name[32]; unsigned int size; void* entrytable[XT_TABLE_SIZE / sizeof(void*)]; }; struct ipt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_counters; struct xt_counters* counters; char entrytable[XT_TABLE_SIZE]; }; struct ipt_table_desc { const char* name; struct ipt_getinfo info; struct ipt_replace replace; }; static struct ipt_table_desc ipv4_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; static struct ipt_table_desc ipv6_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; #define IPT_BASE_CTL 64 #define IPT_SO_SET_REPLACE (IPT_BASE_CTL) #define IPT_SO_GET_INFO (IPT_BASE_CTL) #define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) struct arpt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_entries; unsigned int size; }; struct arpt_get_entries { char name[32]; unsigned int size; void* entrytable[XT_TABLE_SIZE / sizeof(void*)]; }; struct arpt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_counters; struct xt_counters* counters; char entrytable[XT_TABLE_SIZE]; }; struct arpt_table_desc { const char* name; struct arpt_getinfo info; struct arpt_replace replace; }; static struct arpt_table_desc arpt_tables[] = { {.name = "filter"}, }; #define ARPT_BASE_CTL 96 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) #define ARPT_SO_GET_INFO (ARPT_BASE_CTL) #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { struct ipt_get_entries entries; socklen_t optlen; int fd, i; fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); optlen = sizeof(table->info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { struct xt_counters counters[XT_MAX_ENTRIES]; struct ipt_get_entries entries; struct ipt_getinfo info; socklen_t optlen; int fd, i; fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; if (table->info.valid_hooks == 0) continue; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); optlen = sizeof(info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, level, IPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_arptables(void) { struct arpt_get_entries entries; socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); optlen = sizeof(table->info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_arptables() { struct xt_counters counters[XT_MAX_ENTRIES]; struct arpt_get_entries entries; struct arpt_getinfo info; socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; if (table->info.valid_hooks == 0) continue; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); optlen = sizeof(info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } else { } table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, SOL_IP, ARPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } #define NF_BR_NUMHOOKS 6 #define EBT_TABLE_MAXNAMELEN 32 #define EBT_CHAIN_MAXNAMELEN 32 #define EBT_BASE_CTL 128 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) #define EBT_SO_GET_INFO (EBT_BASE_CTL) #define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO + 1) #define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES + 1) #define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO + 1) struct ebt_replace { char name[EBT_TABLE_MAXNAMELEN]; unsigned int valid_hooks; unsigned int nentries; unsigned int entries_size; struct ebt_entries* hook_entry[NF_BR_NUMHOOKS]; unsigned int num_counters; struct ebt_counter* counters; char* entries; }; struct ebt_entries { unsigned int distinguisher; char name[EBT_CHAIN_MAXNAMELEN]; unsigned int counter_offset; int policy; unsigned int nentries; char data[0] __attribute__((aligned(__alignof__(struct ebt_replace)))); }; struct ebt_table_desc { const char* name; struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; }; static struct ebt_table_desc ebt_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "broute"}, }; static void checkpoint_ebtables(void) { socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; strcpy(table->replace.name, table->name); optlen = sizeof(table->replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_INFO, &table->replace, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->replace.entries_size > sizeof(table->entrytable)) exit(1); table->replace.num_counters = 0; table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_ENTRIES, &table->replace, &optlen)) exit(1); } close(fd); } static void reset_ebtables() { struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; socklen_t optlen; unsigned i, j, h; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; if (table->replace.valid_hooks == 0) continue; memset(&replace, 0, sizeof(replace)); strcpy(replace.name, table->name); optlen = sizeof(replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INFO, &replace, &optlen)) exit(1); replace.num_counters = 0; table->replace.entries = 0; for (h = 0; h < NF_BR_NUMHOOKS; h++) table->replace.hook_entry[h] = 0; if (memcmp(&table->replace, &replace, sizeof(table->replace)) == 0) { memset(&entrytable, 0, sizeof(entrytable)); replace.entries = entrytable; optlen = sizeof(replace) + replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_ENTRIES, &replace, &optlen)) exit(1); if (memcmp(table->entrytable, entrytable, replace.entries_size) == 0) continue; } for (j = 0, h = 0; h < NF_BR_NUMHOOKS; h++) { if (table->replace.valid_hooks & (1 << h)) { table->replace.hook_entry[h] = (struct ebt_entries*)table->entrytable + j; j++; } } table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (setsockopt(fd, SOL_IP, EBT_SO_SET_ENTRIES, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_net_namespace(void) { checkpoint_ebtables(); checkpoint_arptables(); checkpoint_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); checkpoint_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void reset_net_namespace(void) { reset_ebtables(); reset_arptables(); reset_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); reset_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void setup_cgroups() { if (mkdir("/syzcgroup", 0777)) { } if (mkdir("/syzcgroup/unified", 0777)) { } if (mount("none", "/syzcgroup/unified", "cgroup2", 0, NULL)) { } if (chmod("/syzcgroup/unified", 0777)) { } write_file("/syzcgroup/unified/cgroup.subtree_control", "+cpu +memory +io +pids +rdma"); if (mkdir("/syzcgroup/cpu", 0777)) { } if (mount("none", "/syzcgroup/cpu", "cgroup", 0, "cpuset,cpuacct,perf_event,hugetlb")) { } write_file("/syzcgroup/cpu/cgroup.clone_children", "1"); if (chmod("/syzcgroup/cpu", 0777)) { } if (mkdir("/syzcgroup/net", 0777)) { } if (mount("none", "/syzcgroup/net", "cgroup", 0, "net_cls,net_prio,devices,freezer")) { } if (chmod("/syzcgroup/net", 0777)) { } } static void setup_binfmt_misc() { if (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0)) { } write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:"); write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC"); } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } setup_cgroups(); setup_binfmt_misc(); } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 200 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); sandbox_common(); initialize_netdevices_init(); if (unshare(CLONE_NEWNET)) { } initialize_tun(); initialize_netdevices(); loop(); exit(1); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { DIR* dp; struct dirent* ep; int iter = 0; retry: while (umount2(dir, MNT_DETACH) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, MNT_DETACH) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, MNT_DETACH)) exit(1); } } closedir(dp); int i; for (i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); int i; for (i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } #define SYZ_HAVE_SETUP_LOOP 1 static void setup_loop() { int pid = getpid(); char cgroupdir[64]; char file[128]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/pids.max", cgroupdir); write_file(file, "32"); snprintf(file, sizeof(file), "%s/memory.low", cgroupdir); write_file(file, "%d", 298 << 20); snprintf(file, sizeof(file), "%s/memory.high", cgroupdir); write_file(file, "%d", 299 << 20); snprintf(file, sizeof(file), "%s/memory.max", cgroupdir); write_file(file, "%d", 300 << 20); snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); checkpoint_net_namespace(); } #define SYZ_HAVE_RESET_LOOP 1 static void reset_loop() { reset_net_namespace(); } #define SYZ_HAVE_SETUP_TEST 1 static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (symlink(cgroupdir, "./cgroup")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.cpu")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.net")) { } write_file("/proc/self/oom_score_adj", "1000"); flush_tun(); } #define SYZ_HAVE_RESET_TEST 1 static void reset_test() { int fd; for (fd = 3; fd < 30; fd++) close(fd); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; int collide = 0; again: for (call = 0; call < 2; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); if (collide && (call % 2) == 0) break; event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); if (!collide) { collide = 1; goto again; } } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { setup_loop(); int iter; for (iter = 0;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); reset_test(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { long res; switch (call) { case 0: res = syscall(__NR_socket, 0x10, 3, 0x10); if (res != -1) r[0] = res; break; case 1: NONFAILING(*(uint64_t*)0x20000080 = 0); NONFAILING(*(uint32_t*)0x20000088 = 0); NONFAILING(*(uint64_t*)0x20000090 = 0x20000440); NONFAILING(*(uint64_t*)0x20000440 = 0x20000000); NONFAILING(memcpy((void*)0x20000000, "\x28\x00\x00\x00\x22\x00\x01\x00\x00\x00\x08\x00\x3f\xea" "\x00\x00\x04\x00\x00\x00\x14\x00\x17\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", 40)); NONFAILING(*(uint64_t*)0x20000448 = 1); NONFAILING(*(uint64_t*)0x20000098 = 1); NONFAILING(*(uint64_t*)0x200000a0 = 0); NONFAILING(*(uint64_t*)0x200000a8 = 0); NONFAILING(*(uint32_t*)0x200000b0 = 0); syscall(__NR_sendmsg, r[0], 0x20000080, 0); break; } } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); install_segv_handler(); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }
the_stack_data/115110.c
#include <stdio.h> int main() { int answer; printf("Hello World\n\n"); printf("Please enter a number:"); scanf("%d",&answer); printf("Entered number is %d",answer); }
the_stack_data/150140545.c
#include <unistd.h> void encrypt(char block[64], int edflag) { } /* XOPEN(4) */
the_stack_data/59512186.c
/* getenv( const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ /* This is an example implementation of getenv() fit for use with POSIX kernels. */ #include <string.h> #include <stdlib.h> #ifndef REGTEST extern char** environ; char* getenv(const char* name) { size_t len = strlen(name); size_t index = 0; while (environ[index] != NULL) { if (strncmp(environ[index], name, len) == 0) { return environ[index] + len + 1; } index++; } return NULL; } #endif #ifdef TEST #include "_PDCLIB_test.h" int main(void) { TESTCASE(strcmp(getenv("SHELL"), "/bin/bash") == 0); /* TESTCASE( strcmp( getenv( "SHELL" ), "/bin/sh" ) == 0 ); */ return TEST_RESULTS; } #endif
the_stack_data/23575936.c
/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* sqerror.c * * error handling for the squid library */ /* a global errno equivalent */ int squid_errno; #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: Die() * * Purpose: Print an error message and die. The arguments * are formatted exactly like arguments to printf(). * * Return: None. Exits the program. */ /* VARARGS0 */ int Die(char *format, ...) { va_list argp; /* format the error mesg */ fprintf(stderr, "FATAL: "); va_start(argp, format); vfprintf(stderr, format, argp); va_end(argp); fprintf(stderr, "\n"); fflush(stderr); /* exit */ exit(1); /*NOTREACHED*/ return 1; /* fool lint */ } /* Function: Warn() * * Purpose: Print an error message and return. The arguments * are formatted exactly like arguments to printf(). * * Return: (void) */ /* VARARGS0 */ int Warn(char *format, ...) { va_list argp; /* format the error mesg */ fprintf(stderr, "WARNING: "); va_start(argp, format); vfprintf(stderr, format, argp); va_end(argp); fprintf(stderr, "\n"); fflush(stderr); return 1; }
the_stack_data/167331469.c
//Error while //Q: why the result(count) is not equal to a * b #include <stdio.h> int main() { int n, a, b, c; int count; scanf("%d", &n); while(n--) { scanf("%d%d", &a, &b); count = 0; while(a--) { while(b--) { count++; } } printf("%d\n", count); } return 0; }
the_stack_data/170453313.c
#include <stdio.h> #include <math.h> int main () { long long int n, i, sum, ans, arr[110]; printf("PERFECTION OUTPUT\n"); while (scanf("%lld", &n)==1) { if (n==0) { printf("END OF OUTPUT\n"); break; } sum=0; if (n<=11) { if (n==4) printf ("%5.0lld ABUNDANT\n", n); else if (n==6) printf ("%5.0lld PERFECT\n", n); else printf ("%5.0lld DEFICIENT\n", n); } else { for (i=1; i<=n/4; i++) { if (i==1) { sum= sum+i; } else { if (n%i==0) sum= sum+i+(n/i); if (sum>n || sum==n) break; } } if (sum==n) printf ("%5.0lld PERFECT\n", n); else if (sum>n) printf ("%5.0lld ABUNDANT\n", n); else printf ("%5.0lld DEFICIENT\n", n); } } return 0; }
the_stack_data/212642811.c
// Test program for CS333 scheduler, project 4. #ifdef CS333_P4 #include "types.h" #include "user.h" #define PrioCount MAXPRIO #define numChildren 2 void countForever(int i) { int j, p, rc; unsigned long count = 0; j = getpid(); if (PrioCount > 0){ p = i%PrioCount; } rc = setpriority(j, p); if (rc == 0) printf(1, "%d: start prio %d\n", j, p); else { printf(1, "setpriority failed. file %s at %d\n", __FILE__, __LINE__); exit(); } while (1) { count++; if ((count & (0x1FFFFFFF)) == 0 && PrioCount > 0){ p = (p+1) % PrioCount; rc = setpriority(j, p); if (rc == 0) printf(1, "%d: new prio %d\n", j, p); else { printf(1, "setpriority failed. file %s at %d\n", __FILE__, __LINE__); exit(); } } } } int main(void) { if (PrioCount == 0) { printf(1, "MAXPRIO is 0. Change MAXPRIO and try again\n"); exit(); } int i, rc; for (i=0; i<numChildren; i++) { rc = fork(); if (!rc) { // child countForever(i); } } // what the heck, let's have the parent waste time as well! wait(); exit(); } #endif
the_stack_data/150142816.c
enum DayZCreatureAIConstants { DEBUG_SHOWDEBUGPLUGIN };
the_stack_data/9679.c
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2018.2 // Copyright (C) 1986-2018 Xilinx, Inc. All Rights Reserved. // // ============================================================== #ifndef __linux__ #include "xstatus.h" #include "xparameters.h" #include "xpointer_basic.h" extern XPointer_basic_Config XPointer_basic_ConfigTable[]; XPointer_basic_Config *XPointer_basic_LookupConfig(u16 DeviceId) { XPointer_basic_Config *ConfigPtr = NULL; int Index; for (Index = 0; Index < XPAR_XPOINTER_BASIC_NUM_INSTANCES; Index++) { if (XPointer_basic_ConfigTable[Index].DeviceId == DeviceId) { ConfigPtr = &XPointer_basic_ConfigTable[Index]; break; } } return ConfigPtr; } int XPointer_basic_Initialize(XPointer_basic *InstancePtr, u16 DeviceId) { XPointer_basic_Config *ConfigPtr; Xil_AssertNonvoid(InstancePtr != NULL); ConfigPtr = XPointer_basic_LookupConfig(DeviceId); if (ConfigPtr == NULL) { InstancePtr->IsReady = 0; return (XST_DEVICE_NOT_FOUND); } return XPointer_basic_CfgInitialize(InstancePtr, ConfigPtr); } #endif
the_stack_data/76038.c
#include <stdio.h> #include <stdlib.h> void insertion_sort(int *a, int n) { for (size_t i = 1; i < n; ++i) { int tmp = a[i]; size_t j = i; while (j > 0 && tmp < a[j-1]) { a[j] = a[j - 1]; --j; } a[j] = tmp; } } int main() { int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1}; int n = sizeof a / sizeof a[0]; int i; for (i = 0; i < n; i++) printf("%d%s", a[i], i == n - 1 ? "\n" : " "); insertion_sort(a, n); for (i = 0; i < n; i++) printf("%d%s", a[i], i == n - 1 ? "\n" : " "); return 0; }
the_stack_data/237643776.c
#include <sys/sem.h> int open_semaphore_set( key_t keyval, int numsems ) { int sid; if (!numsems) // 我們要求不論建立還是獲得訊號量都必須指明集合中訊號量的個數 return(-1); if((sid = semget( keyval, numsems, IPC_CREAT | 0660 )) == -1) return(-1); else return(sid); }
the_stack_data/526261.c
/**************************************************************************** * TinySMB * Nintendo Wii/GameCube SMB implementation * * DES encryption/decryption Algorithm ****************************************************************************/ #include <stdint.h> #include <string.h> typedef struct { uint32_t encrypt_subkeys[32]; uint32_t decrypt_subkeys[32]; } gl_des_ctx; /* * The s-box values are permuted according to the 'primitive function P' * and are rotated one bit to the left. */ static const uint32_t sbox1[64] = { 0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404, 0x00000004, 0x00010000, 0x00000400, 0x01010400, 0x01010404, 0x00000400, 0x01000404, 0x01010004, 0x01000000, 0x00000004, 0x00000404, 0x01000400, 0x01000400, 0x00010400, 0x00010400, 0x01010000, 0x01010000, 0x01000404, 0x00010004, 0x01000004, 0x01000004, 0x00010004, 0x00000000, 0x00000404, 0x00010404, 0x01000000, 0x00010000, 0x01010404, 0x00000004, 0x01010000, 0x01010400, 0x01000000, 0x01000000, 0x00000400, 0x01010004, 0x00010000, 0x00010400, 0x01000004, 0x00000400, 0x00000004, 0x01000404, 0x00010404, 0x01010404, 0x00010004, 0x01010000, 0x01000404, 0x01000004, 0x00000404, 0x00010404, 0x01010400, 0x00000404, 0x01000400, 0x01000400, 0x00000000, 0x00010004, 0x00010400, 0x00000000, 0x01010004 }; static const uint32_t sbox2[64] = { 0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020, 0x80100020, 0x80008020, 0x80000020, 0x80108020, 0x80108000, 0x80000000, 0x80008000, 0x00100000, 0x00000020, 0x80100020, 0x00108000, 0x00100020, 0x80008020, 0x00000000, 0x80000000, 0x00008000, 0x00108020, 0x80100000, 0x00100020, 0x80000020, 0x00000000, 0x00108000, 0x00008020, 0x80108000, 0x80100000, 0x00008020, 0x00000000, 0x00108020, 0x80100020, 0x00100000, 0x80008020, 0x80100000, 0x80108000, 0x00008000, 0x80100000, 0x80008000, 0x00000020, 0x80108020, 0x00108020, 0x00000020, 0x00008000, 0x80000000, 0x00008020, 0x80108000, 0x00100000, 0x80000020, 0x00100020, 0x80008020, 0x80000020, 0x00100020, 0x00108000, 0x00000000, 0x80008000, 0x00008020, 0x80000000, 0x80100020, 0x80108020, 0x00108000 }; static const uint32_t sbox3[64] = { 0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000, 0x00020208, 0x08000200, 0x00020008, 0x08000008, 0x08000008, 0x00020000, 0x08020208, 0x00020008, 0x08020000, 0x00000208, 0x08000000, 0x00000008, 0x08020200, 0x00000200, 0x00020200, 0x08020000, 0x08020008, 0x00020208, 0x08000208, 0x00020200, 0x00020000, 0x08000208, 0x00000008, 0x08020208, 0x00000200, 0x08000000, 0x08020200, 0x08000000, 0x00020008, 0x00000208, 0x00020000, 0x08020200, 0x08000200, 0x00000000, 0x00000200, 0x00020008, 0x08020208, 0x08000200, 0x08000008, 0x00000200, 0x00000000, 0x08020008, 0x08000208, 0x00020000, 0x08000000, 0x08020208, 0x00000008, 0x00020208, 0x00020200, 0x08000008, 0x08020000, 0x08000208, 0x00000208, 0x08020000, 0x00020208, 0x00000008, 0x08020008, 0x00020200 }; static const uint32_t sbox4[64] = { 0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081, 0x00800001, 0x00002001, 0x00000000, 0x00802000, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00800080, 0x00800001, 0x00000001, 0x00002000, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002001, 0x00002080, 0x00800081, 0x00000001, 0x00002080, 0x00800080, 0x00002000, 0x00802080, 0x00802081, 0x00000081, 0x00800080, 0x00800001, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00000000, 0x00802000, 0x00002080, 0x00800080, 0x00800081, 0x00000001, 0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802081, 0x00000081, 0x00000001, 0x00002000, 0x00800001, 0x00002001, 0x00802080, 0x00800081, 0x00002001, 0x00002080, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002000, 0x00802080 }; static const uint32_t sbox5[64] = { 0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100, 0x40000000, 0x02080000, 0x40080100, 0x00080000, 0x02000100, 0x40080100, 0x42000100, 0x42080000, 0x00080100, 0x40000000, 0x02000000, 0x40080000, 0x40080000, 0x00000000, 0x40000100, 0x42080100, 0x42080100, 0x02000100, 0x42080000, 0x40000100, 0x00000000, 0x42000000, 0x02080100, 0x02000000, 0x42000000, 0x00080100, 0x00080000, 0x42000100, 0x00000100, 0x02000000, 0x40000000, 0x02080000, 0x42000100, 0x40080100, 0x02000100, 0x40000000, 0x42080000, 0x02080100, 0x40080100, 0x00000100, 0x02000000, 0x42080000, 0x42080100, 0x00080100, 0x42000000, 0x42080100, 0x02080000, 0x00000000, 0x40080000, 0x42000000, 0x00080100, 0x02000100, 0x40000100, 0x00080000, 0x00000000, 0x40080000, 0x02080100, 0x40000100 }; static const uint32_t sbox6[64] = { 0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010, 0x20404010, 0x00400000, 0x20004000, 0x00404010, 0x00400000, 0x20000010, 0x00400010, 0x20004000, 0x20000000, 0x00004010, 0x00000000, 0x00400010, 0x20004010, 0x00004000, 0x00404000, 0x20004010, 0x00000010, 0x20400010, 0x20400010, 0x00000000, 0x00404010, 0x20404000, 0x00004010, 0x00404000, 0x20404000, 0x20000000, 0x20004000, 0x00000010, 0x20400010, 0x00404000, 0x20404010, 0x00400000, 0x00004010, 0x20000010, 0x00400000, 0x20004000, 0x20000000, 0x00004010, 0x20000010, 0x20404010, 0x00404000, 0x20400000, 0x00404010, 0x20404000, 0x00000000, 0x20400010, 0x00000010, 0x00004000, 0x20400000, 0x00404010, 0x00004000, 0x00400010, 0x20004010, 0x00000000, 0x20404000, 0x20000000, 0x00400010, 0x20004010 }; static const uint32_t sbox7[64] = { 0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802, 0x00200802, 0x04200800, 0x04200802, 0x00200000, 0x00000000, 0x04000002, 0x00000002, 0x04000000, 0x04200002, 0x00000802, 0x04000800, 0x00200802, 0x00200002, 0x04000800, 0x04000002, 0x04200000, 0x04200800, 0x00200002, 0x04200000, 0x00000800, 0x00000802, 0x04200802, 0x00200800, 0x00000002, 0x04000000, 0x00200800, 0x04000000, 0x00200800, 0x00200000, 0x04000802, 0x04000802, 0x04200002, 0x04200002, 0x00000002, 0x00200002, 0x04000000, 0x04000800, 0x00200000, 0x04200800, 0x00000802, 0x00200802, 0x04200800, 0x00000802, 0x04000002, 0x04200802, 0x04200000, 0x00200800, 0x00000000, 0x00000002, 0x04200802, 0x00000000, 0x00200802, 0x04200000, 0x00000800, 0x04000002, 0x04000800, 0x00000800, 0x00200002 }; static const uint32_t sbox8[64] = { 0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040, 0x00000040, 0x10000000, 0x00040040, 0x10040000, 0x10041040, 0x00041000, 0x10041000, 0x00041040, 0x00001000, 0x00000040, 0x10040000, 0x10000040, 0x10001000, 0x00001040, 0x00041000, 0x00040040, 0x10040040, 0x10041000, 0x00001040, 0x00000000, 0x00000000, 0x10040040, 0x10000040, 0x10001000, 0x00041040, 0x00040000, 0x00041040, 0x00040000, 0x10041000, 0x00001000, 0x00000040, 0x10040040, 0x00001000, 0x00041040, 0x10001000, 0x00000040, 0x10000040, 0x10040000, 0x10040040, 0x10000000, 0x00040000, 0x10001040, 0x00000000, 0x10041040, 0x00040040, 0x10000040, 0x10040000, 0x10001000, 0x10001040, 0x00000000, 0x10041040, 0x00041000, 0x00041000, 0x00001040, 0x00001040, 0x00040040, 0x10000000, 0x10041000 }; /* * These two tables are part of the 'permuted choice 1' function. * In this implementation several speed improvements are done. */ static const uint32_t leftkey_swap[16] = { 0x00000000, 0x00000001, 0x00000100, 0x00000101, 0x00010000, 0x00010001, 0x00010100, 0x00010101, 0x01000000, 0x01000001, 0x01000100, 0x01000101, 0x01010000, 0x01010001, 0x01010100, 0x01010101 }; static const uint32_t rightkey_swap[16] = { 0x00000000, 0x01000000, 0x00010000, 0x01010000, 0x00000100, 0x01000100, 0x00010100, 0x01010100, 0x00000001, 0x01000001, 0x00010001, 0x01010001, 0x00000101, 0x01000101, 0x00010101, 0x01010101, }; /* * Numbers of left shifts per round for encryption subkeys. To * calculate the decryption subkeys we just reverse the ordering of * the calculated encryption subkeys, so there is no need for a * decryption rotate tab. */ static const unsigned char encrypt_rotate_tab[16] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 }; /* * Table with weak DES keys sorted in ascending order. In DES there * are 64 known keys which are weak. They are weak because they * produce only one, two or four different subkeys in the subkey * scheduling process. The keys in this table have all their parity * bits cleared. */ static const unsigned char weak_keys[64][8] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*w */ {0x00, 0x00, 0x1e, 0x1e, 0x00, 0x00, 0x0e, 0x0e}, {0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0}, {0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe}, {0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x0e}, /*sw */ {0x00, 0x1e, 0x1e, 0x00, 0x00, 0x0e, 0x0e, 0x00}, {0x00, 0x1e, 0xe0, 0xfe, 0x00, 0x0e, 0xf0, 0xfe}, {0x00, 0x1e, 0xfe, 0xe0, 0x00, 0x0e, 0xfe, 0xf0}, {0x00, 0xe0, 0x00, 0xe0, 0x00, 0xf0, 0x00, 0xf0}, /*sw */ {0x00, 0xe0, 0x1e, 0xfe, 0x00, 0xf0, 0x0e, 0xfe}, {0x00, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0xf0, 0x00}, {0x00, 0xe0, 0xfe, 0x1e, 0x00, 0xf0, 0xfe, 0x0e}, {0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe}, /*sw */ {0x00, 0xfe, 0x1e, 0xe0, 0x00, 0xfe, 0x0e, 0xf0}, {0x00, 0xfe, 0xe0, 0x1e, 0x00, 0xfe, 0xf0, 0x0e}, {0x00, 0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe, 0x00}, {0x1e, 0x00, 0x00, 0x1e, 0x0e, 0x00, 0x00, 0x0e}, {0x1e, 0x00,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0xe0, 0xfe, 0xe0, 0xfe, 0xf0, 0xfe, 0xf0}, /*sw */ {0xfe, 0xfe, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00}, {0xfe, 0xfe, 0x1e, 0x1e, 0xfe, 0xfe, 0x0e, 0x0e}, {0xfe, 0xfe, 0xe0, 0xe0, 0xfe, 0xfe, 0xf0, 0xf0}, {0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe} /*w */ }; /* * Macro to swap bits across two words. */ #define DO_PERMUTATION(a, temp, b, offset, mask) \ temp = ((a>>offset) ^ b) & mask; \ b ^= temp; \ a ^= temp<<offset; /* * This performs the 'initial permutation' of the data to be encrypted * or decrypted. Additionally the resulting two words are rotated one bit * to the left. */ #define INITIAL_PERMUTATION(left, temp, right) \ DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) \ DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \ DO_PERMUTATION(right, temp, left, 2, 0x33333333) \ DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \ right = (right << 1) | (right >> 31); \ temp = (left ^ right) & 0xaaaaaaaa; \ right ^= temp; \ left ^= temp; \ left = (left << 1) | (left >> 31); /* * The 'inverse initial permutation'. */ #define FINAL_PERMUTATION(left, temp, right) \ left = (left << 31) | (left >> 1); \ temp = (left ^ right) & 0xaaaaaaaa; \ left ^= temp; \ right ^= temp; \ right = (right << 31) | (right >> 1); \ DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff) \ DO_PERMUTATION(right, temp, left, 2, 0x33333333) \ DO_PERMUTATION(left, temp, right, 16, 0x0000ffff) \ DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f) /* * A full DES round including 'expansion function', 'sbox substitution' * and 'primitive function P' but without swapping the left and right word. * Please note: The data in 'from' and 'to' is already rotated one bit to * the left, done in the initial permutation. */ #define DES_ROUND(from, to, work, subkey) \ work = from ^ *subkey++; \ to ^= sbox8[ work & 0x3f ]; \ to ^= sbox6[ (work>>8) & 0x3f ]; \ to ^= sbox4[ (work>>16) & 0x3f ]; \ to ^= sbox2[ (work>>24) & 0x3f ]; \ work = ((from << 28) | (from >> 4)) ^ *subkey++; \ to ^= sbox7[ work & 0x3f ]; \ to ^= sbox5[ (work>>8) & 0x3f ]; \ to ^= sbox3[ (work>>16) & 0x3f ]; \ to ^= sbox1[ (work>>24) & 0x3f ]; /* * Macros to convert 8 bytes from/to 32bit words. */ #define READ_64BIT_DATA(data, left, right) \ left = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; \ right = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7]; #define WRITE_64BIT_DATA(data, left, right) \ data[0] = (left >> 24) &0xff; data[1] = (left >> 16) &0xff; \ data[2] = (left >> 8) &0xff; data[3] = left &0xff; \ data[4] = (right >> 24) &0xff; data[5] = (right >> 16) &0xff; \ data[6] = (right >> 8) &0xff; data[7] = right &0xff; /* * des_key_schedule(): Calculate 16 subkeys pairs (even/odd) for * 16 encryption rounds. * To calculate subkeys for decryption the caller * have to reorder the generated subkeys. * * rawkey: 8 Bytes of key data * subkey: Array of at least 32 uint32_ts. Will be filled * with calculated subkeys. * */ static void des_key_schedule (const char * _rawkey, uint32_t * subkey) { const unsigned char *rawkey = (const unsigned char *) _rawkey; uint32_t left, right, work; int round; READ_64BIT_DATA (rawkey, left, right) DO_PERMUTATION (right, work, left, 4, 0x0f0f0f0f) DO_PERMUTATION (right, work, left, 0, 0x10101010) left = ((leftkey_swap[(left >> 0) & 0xf] << 3) | (leftkey_swap[(left >> 8) & 0xf] << 2) | (leftkey_swap[(left >> 16) & 0xf] << 1) | (leftkey_swap[(left >> 24) & 0xf]) | (leftkey_swap[(left >> 5) & 0xf] << 7) | (leftkey_swap[(left >> 13) & 0xf] << 6) | (leftkey_swap[(left >> 21) & 0xf] << 5) | (leftkey_swap[(left >> 29) & 0xf] << 4)); left &= 0x0fffffff; right = ((rightkey_swap[(right >> 1) & 0xf] << 3) | (rightkey_swap[(right >> 9) & 0xf] << 2) | (rightkey_swap[(right >> 17) & 0xf] << 1) | (rightkey_swap[(right >> 25) & 0xf]) | (rightkey_swap[(right >> 4) & 0xf] << 7) | (rightkey_swap[(right >> 12) & 0xf] << 6) | (rightkey_swap[(right >> 20) & 0xf] << 5) | (rightkey_swap[(right >> 28) & 0xf] << 4)); right &= 0x0fffffff; for (round = 0; round < 16; ++round) { left = ((left << encrypt_rotate_tab[round]) | (left >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff; right = ((right << encrypt_rotate_tab[round]) | (right >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff; *subkey++ = (((left << 4) & 0x24000000) | ((left << 28) & 0x10000000) | ((left << 14) & 0x08000000) | ((left << 18) & 0x02080000) | ((left << 6) & 0x01000000) | ((left << 9) & 0x00200000) | ((left >> 1) & 0x00100000) | ((left << 10) & 0x00040000) | ((left << 2) & 0x00020000) | ((left >> 10) & 0x00010000) | ((right >> 13) & 0x00002000) | ((right >> 4) & 0x00001000) | ((right << 6) & 0x00000800) | ((right >> 1) & 0x00000400) | ((right >> 14) & 0x00000200) | (right & 0x00000100) | ((right >> 5) & 0x00000020) | ((right >> 10) & 0x00000010) | ((right >> 3) & 0x00000008) | ((right >> 18) & 0x00000004) | ((right >> 26) & 0x00000002) | ((right >> 24) & 0x00000001)); *subkey++ = (((left << 15) & 0x20000000) | ((left << 17) & 0x10000000) | ((left << 10) & 0x08000000) | ((left << 22) & 0x04000000) | ((left >> 2) & 0x02000000) | ((left << 1) & 0x01000000) | ((left << 16) & 0x00200000) | ((left << 11) & 0x00100000) | ((left << 3) & 0x00080000) | ((left >> 6) & 0x00040000) | ((left << 15) & 0x00020000) | ((left >> 4) & 0x00010000) | ((right >> 2) & 0x00002000) | ((right << 8) & 0x00001000) | ((right >> 14) & 0x00000808) | ((right >> 9) & 0x00000400) | ((right) & 0x00000200) | ((right << 7) & 0x00000100) | ((right >> 7) & 0x00000020) | ((right >> 3) & 0x00000011) | ((right << 2) & 0x00000004) | ((right >> 21) & 0x00000002)); } } void gl_des_setkey (gl_des_ctx *ctx, const char * key) { int i; des_key_schedule (key, ctx->encrypt_subkeys); for (i = 0; i < 32; i += 2) { ctx->decrypt_subkeys[i] = ctx->encrypt_subkeys[30 - i]; ctx->decrypt_subkeys[i + 1] = ctx->encrypt_subkeys[31 - i]; } } void gl_des_ecb_encrypt (gl_des_ctx *ctx, const char * _from, char * _to) { const unsigned char *from = (const unsigned char *) _from; unsigned char *to = (unsigned char *) _to; uint32_t left, right, work; uint32_t *keys; keys = ctx->encrypt_subkeys; READ_64BIT_DATA (from, left, right) INITIAL_PERMUTATION (left, work, right) DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys) FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left) }
the_stack_data/175143771.c
/*++ Copyright (c) 1991 Microsoft Corporation Module Name: ntapmdmp.c Abstract: Dump data about whether machine is ACPI or APM, and if APM whether APM is usable, good, bad, etc. Author: Byan M. Willman (bryanwi) 24-Aug-1998 Revision History: --*/ #if 0 #include <nt.h> #include <ntrtl.h> #include <nturtl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <apmlib.h> void DumpApmError(); void _CRTAPI1 main( int argc, char *argv[] ) { if (IsSystemACPI()) { printf("ACPI system. APM is not relevent.\n"); exit(0); } switch (IsApmPresent()) { case APM_NOT_PRESENT: printf("APM not detected on this system.\n"); exit(1); break; case APM_PRESENT_BUT_NOT_USABLE: printf("APM detected on this system, but not usable.\n"); DumpApmError(); exit(2); break; case APM_ON_GOOD_LIST: printf("APM detected on this system, usable, on the Good bios list.\n"); if (IsApmActive()) { printf("APM is active on this machine.\n"); } else { printf("APM is NOT active on this machine.\n"); } exit(3); break; case APM_NEUTRAL: printf("APM detected on this system, usable, NOT on the Good or Bad lists.\n"); if (IsApmActive()) { printf("APM is active on this machine.\n"); } else { printf("APM is NOT active on this machine.\n"); } exit(4); break; case APM_ON_BAD_LIST: printf("APM detected on this system, usable, BUT on the bad bios list.\n"); if (IsApmActive()) { printf("APM is active on this machine.\n"); } else { printf("APM is NOT active on this machine.\n"); } exit(5); break; default: printf("Something very strange has happened.\n"); exit(99); break; } } VOID DumpApmError() { } #endif
the_stack_data/61074474.c
/* This file is part of GDB, the GNU debugger. Copyright 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GNUC__ #define __attribute__(x) #endif unsigned * __attribute__((noinline)) start_sequence (unsigned * x, unsigned * y) { return (unsigned *)0xdeadbeef; }; unsigned __attribute__((noinline)) gen_movsd (unsigned * operand0, unsigned * operand1) { return *start_sequence(operand0, operand1); } int main(void) { unsigned x, y; x = 13; y = 14; return (int)gen_movsd (&x, &y); }
the_stack_data/89432.c
#include<stdio.h> int main(int argc, char **argv) { printf("I can only come into existance via trickery.\n"); return 0; }
the_stack_data/67326467.c
/*------------------------------------------------------------------------- _rlulonglong.c - routine for left shift of 64 bit unsigned long long Copyright (C) 2012, Philipp Klaus Krause . [email protected] This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, if you link this library with other files, some of which are compiled with SDCC, to produce an executable, this library does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. -------------------------------------------------------------------------*/ #pragma std_c99 #include <stdint.h> #ifdef __SDCC_LONGLONG #if defined(__SDCC_hc08) || defined(__SDCC_s08) || defined(__SDCC_stm8) // Big-endian unsigned long long _rlulonglong(unsigned long long l, char s) { uint32_t *const top = (uint32_t *)((char *)(&l) + 0); uint16_t *const middle = (uint16_t *)((char *)(&l) + 4); uint32_t *const bottom = (uint32_t *)((char *)(&l) + 4); uint16_t *const b = (uint16_t *)(&l); for(;s >= 16; s-= 16) { b[0] = b[1]; b[1] = b[2]; b[2] = b[3]; b[3] = 0; } (*top) <<= s; (*top) |= (((uint32_t)((*middle) & 0xffffu) << s) >> 16); (*bottom) <<= s; return(l); } #else // Little-endian unsigned long long _rlulonglong(unsigned long long l, char s) { uint32_t *const top = (uint32_t *)((char *)(&l) + 4); uint16_t *const middle = (uint16_t *)((char *)(&l) + 2); uint32_t *const bottom = (uint32_t *)(&l); uint16_t *const b = (uint16_t *)(&l); for(;s >= 16; s-= 16) { b[3] = b[2]; b[2] = b[1]; b[1] = b[0]; b[0] = 0; } (*top) <<= s; (*top) |= (((uint32_t)((*middle) & 0xffffu) << s) >> 16); (*bottom) <<= s; return(l); } #endif #endif
the_stack_data/20451386.c
/***************************************************************************** * Name: time_epoch.c * * Summary: Demo of obtaining seconds since The Epoch. * * Created: Tue 04 Dec 2001 12:54:32 (Bob Heckel) ***************************************************************************** */ #include <stdio.h> #include <time.h> int main(int argc, char *argv[]) { time_t currtime; currtime = time(NULL); printf("seconds since Epoch: %d\n", currtime); return 0; }
the_stack_data/248580887.c
#include <stdio.h> int main(){ int num,reminder, temp,sum=0; printf("Enter a Number: "); scanf("%d",&num); temp = num; while(temp!=0){ reminder = temp%10; sum = sum*10+reminder; temp = temp/10; } printf("Reverse number: %d",sum); }
the_stack_data/146383.c
#ifdef STM32F0xx #include "stm32f0xx_hal_rcc.c" #elif STM32F1xx #include "stm32f1xx_hal_rcc.c" #elif STM32F2xx #include "stm32f2xx_hal_rcc.c" #elif STM32F3xx #include "stm32f3xx_hal_rcc.c" #elif STM32F4xx #include "stm32f4xx_hal_rcc.c" #elif STM32F7xx #include "stm32f7xx_hal_rcc.c" #elif STM32G0xx #include "stm32g0xx_hal_rcc.c" #elif STM32G4xx #include "stm32g4xx_hal_rcc.c" #elif STM32H7xx #include "stm32h7xx_hal_rcc.c" #elif STM32L0xx #include "stm32l0xx_hal_rcc.c" #elif STM32L1xx #include "stm32l1xx_hal_rcc.c" #elif STM32L4xx #include "stm32l4xx_hal_rcc.c" #elif STM32L5xx #include "stm32l5xx_hal_rcc.c" #elif STM32MP1xx #include "stm32mp1xx_hal_rcc.c" #elif STM32WBxx #include "stm32wbxx_hal_rcc.c" #endif
the_stack_data/69174.c
/************************************************************************* @File Name: memcpy.c @Author: jesen @Mail:[email protected] @Created Time: 2021年04月29日 星期四 14时27分05秒 ************************************************************************/ #include <stdio.h> #include <string.h> int main(int argc, char* argv[]) { char p[] = "hello\0mike"; char buf[100]; strncpy(buf, p, sizeof(p)); printf("buf = %s\n", buf); printf("buf end = %s\n", buf + strlen("hello") +1); memset(buf, 0, sizeof(buf)); // 先清空数组 memcpy(buf, p, sizeof(p)); printf("buf 2 = %s\n", buf); printf("buf 2 end = %s\n", buf + strlen("hello") +1); int src[] = {1,2,3,4,5,6}; int dst[10]; memcpy(dst, src, sizeof(src)); int i; for(i = 0; i < 6; i++){ printf("dst %d\n", dst[i]); } // 使用memcpy要防止出现内存重叠,如果重叠要用memmove() memcpy(&src[2], src, 4*sizeof(int)); int n = sizeof(src) / sizeof(src[0]); for(i = 0; i < n; i++){ printf("src 重叠 %d\n", src[i]); } memmove(&src[2], src, 4*sizeof(int)); for(i = 0; i < n; i++){ printf("src move %d\n", src[i]); } return 0; }
the_stack_data/168893062.c
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> int main() { printf("uid:%d euid:%d\n", getuid(), geteuid()); setuid(0); printf("uid:%d euid:%d\n", getuid(), geteuid()); int fd; fd = open("./zzz", O_RDWR | O_APPEND); if (fd == -1) { printf("Cannot open ./zzz\n"); exit(0); } write(fd, "Malicious Data\n", 15); close(fd); }
the_stack_data/82950890.c
#include <stdio.h> #include <stdbool.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <time.h> #include <pthread.h> #include <sys/types.h> #include <sys/wait.h> FILE *ipg; // Cuenten con este codigo monolitico en una funcion // main como punto de partida. // Idealmente, el codigo del programa deberia estar // adecuadamente modularizado en distintas funciones, // e incluso en archivos separados, con dependencias // distribuidas en headers. //Variables Globales. int bankId; //Pipes. int outwPipes[50][2];//salida de banco principal. int inwPipes[50][2];//entrada al banco principal. char branches[50][5];//Sucursales. char branchesac[50][7];//cantidad de cuentas en cada sucursal. char brancheter[50][2];//cantidad de terminales en cada sucursal. char transc[100000][40];//transacciones generadas en cada sucursal. char transcfail[100000][70];//transacciones fallidas por falta de plata o cuenta inexistente. int tr = 0; //contador de transacciones. int trfail = 0; //cantidad de errores hasta el momento. int forks = 0; //contador de fork actual. int counter = 0; //contador general de sucursales andando. int terminated = 0; //Indicador para terminar thread. char readbuffer[40]; // buffer para lectura desde pipe de salida. char readbuffer2[40]; // buffer para lectura desde pipe de entrada. int *cash; //Arreglo con la plata de cada cuenta, se hace malloc despues de especificar pthread_mutex_t mutex[10000];//Mutex para cada cuenta. pthread_mutex_t emutex = PTHREAD_MUTEX_INITIALIZER;//Mutex para agregar errores y hacer dump de estos. pthread_mutex_t tmutex = PTHREAD_MUTEX_INITIALIZER;//Mutex para agregar transacciones y hacer dump de estas. pthread_mutex_t rmutex = PTHREAD_MUTEX_INITIALIZER;//Mutex para agregar escribir en los pipes. //Metodos con lock para la plata de las cuentas. Cada cuenta tiene un Mutex propio. void addcash(int cual, int cuanto){ pthread_mutex_lock(&mutex[cual]); cash[cual]+=cuanto; pthread_mutex_unlock(&mutex[cual]); } void subcash(int cual, int cuanto){ pthread_mutex_lock(&mutex[cual]); cash[cual]-=cuanto; pthread_mutex_unlock(&mutex[cual]); } //Metodo para agregar errores. void adderror(char *new){ pthread_mutex_lock(&emutex); strcpy(transcfail[trfail],new); trfail+=1; pthread_mutex_unlock(&emutex); } //Metodo para agregar transacciones. void addtransc(char *new){ pthread_mutex_lock(&tmutex); strcpy(transc[tr],new); tr+=1; pthread_mutex_unlock(&tmutex); } //Thread de banco principal. void *parent(void *arg){ while(terminated == 0){ for(int j = 0; j < forks; j++){ if (atoi(branches[j])>-1){ //Lector de transacciones. for(int l = 0; l < atoi(brancheter[j]) ; l++){ int five = 0; //Hacemos read caracter por caracter del pipe, cada mensaje termina en un '\0'. char buff[2]; buff[1]='\0'; while(read(inwPipes[j][0], buff, 1)>0){ if(strcmp(buff,"\0")==0){ break; } strcat(readbuffer2,buff); } for(int i = 0; i < strlen(readbuffer2); i++){ if(readbuffer2[i]==','){ five+=1; } } //Se revisa que el mensaje venga con el formato correcto. if(five==5 && ( (!strncmp("DP", readbuffer2, strlen("DP"))) || (!strncmp("RT", readbuffer2, strlen("RT")))) ){ char copiaoriginal[40]; strcpy(copiaoriginal,readbuffer2); char* tipo; char* sucursaldestino; char* cuentadestino; char* monto; int existe = 0; tipo = strtok(copiaoriginal, ","); strtok(NULL, ","); strtok(NULL, ","); sucursaldestino=strtok(NULL, ","); cuentadestino=strtok(NULL,","); monto = strtok(NULL,","); //redireccion de operaciones. for (int k = 0; k<forks;k++){ if((strcmp(branches[k],sucursaldestino)==0) && (atoi(branchesac[k])>= atoi(cuentadestino))){ //existe es para verificar que la cuenta a la que se quiera enviar la transaccion aun exista. existe=1; if (strcmp(tipo,"DP")==0){ char asd[40]; sprintf(asd,"%s,%s,%s","DP",cuentadestino,monto); write(outwPipes[k][1], asd, (strlen(asd)+1)); } else{ char cp[40]; strcpy(cp,readbuffer2); write(outwPipes[k][1],cp,(strlen(cp)+1)); } } } //error de cuenta o sucursal cerrada. se le envia un error a la sucursal original. if(existe==0){ char co[40]; strcpy(co,readbuffer2); char mens [40]="FAIL,"; strcat(mens,co); write(outwPipes[j][1], mens, (strlen(mens)+1)); } } //Se reinicia el buffer devolviendo sus valores a 0. memset(&readbuffer2[0], 0, sizeof(readbuffer2)); } } } } return NULL; } //Thread de sucursales. void *child(void *arg){ while(terminated == 0){ //Generacion de transacciones. char msg[80]=""; //Texto a enviar. char guardartransc[30]=""; //Registro de transaccion a guardar. int t = 100000; t+=rand()%400000; usleep(t); //Tipo de transaccion. DP = Deposito, RT = Retiro. int tipo = rand()%2; if (tipo==1){ strcpy(msg,"DP,"); strcpy(guardartransc,"DP,"); }else{ strcpy(msg,"RT,"); strcpy(guardartransc,"RT,"); } //Sucursal origen (donde se genero la transaccion). strcat(msg,branches[forks]); strcat(msg,","); strcat(guardartransc,branches[forks]); strcat(guardartransc,","); char sourcec[7]; //Cuenta de Origen a la que se le quiere agregar o quitar plata. int sourcei = rand()%atoi(branchesac[forks]); sprintf(sourcec,"%d",sourcei); strcat(msg,sourcec); strcat(msg,","); strcat(guardartransc,sourcec); strcat(guardartransc,","); //Sucursal de Destino a la que se le quiere agregar o quitar plata. int destiny = rand()%counter; while(atoi(branches[destiny])<0){ destiny = rand()%counter; } char branch[4]=""; strcat(branch,branches[destiny]); strcat(msg,branch); strcat(msg,","); //Cuenta de Destino a la que se le quiere agregar o quitar plata. La cuenta es random, el banco matriz revisa si existe la cuenta. char account[6]=""; int ac = rand()%10000; sprintf(account,"%d",ac); strcat(msg,account); strcat(msg,","); strcat(guardartransc,account); //Cantidad de dinero a depositar o retirar. char out[10]; int money = rand()%500000000; sprintf(out,"%d",money); strcat(msg,out); msg[strlen(msg)]='\0'; if (tipo ==1){ //Si es un deposito, se asegura de tener los fondos, o anotar el error. if (cash[sourcei]>money){ subcash(sourcei,money); pthread_mutex_lock(&rmutex); write(inwPipes[forks][1], msg, strlen(msg)+1); pthread_mutex_unlock(&rmutex); //Se guarda la transaccion generada. addtransc(guardartransc); }else{ //error char failfinal [80]=""; strcat(failfinal,"1,"); strcat(failfinal,sourcec); strcat(failfinal,","); char montoactual [10]; sprintf(montoactual,"%d",cash[sourcei]); char montoretiro[10]; sprintf(montoretiro,"%d",money); strcat(failfinal,montoactual); strcat(failfinal,","); strcat(failfinal,montoretiro); adderror(failfinal); } } //Si es retiro. else{ pthread_mutex_lock(&rmutex); write(inwPipes[forks][1], msg, strlen(msg)+1); pthread_mutex_unlock(&rmutex); //Se guarda la transaccion generada. addtransc(guardartransc); } } usleep(1500000); char bye[] = " "; write(inwPipes[forks][1], bye, strlen(bye)+1); return NULL; } int main(int argc, char** argv) { size_t bufsize = 512; char* commandBuf = malloc(sizeof(char)*bufsize); // Para guardar descriptores de pipe // el elemento 0 es para lectura // y el elemento 1 es para escritura. for (int i = 0; i<50;i++){ pipe(outwPipes[i]); pipe(inwPipes[i]); } bankId = getpid() % 1000; printf("Bienvenido a Banco '%d'\n", bankId); //Creacion de thread del banco. pthread_t th; pthread_create(&th, NULL,parent,NULL); while (true) { usleep(200000); printf(">>"); getline(&commandBuf, &bufsize, stdin); //Manera de eliminar el \n leido por getline commandBuf[strlen(commandBuf)-1] = '\0'; printf("Comando ingresado: '%s'\n", commandBuf); if (!strncmp("quit", commandBuf, strlen("quit"))) { break; } //Comando para ver sucursales activas. else if (!strncmp("list", commandBuf, strlen("list"))) { printf("| PID | N° cuentas | Terminales | \n"); for (int j = 0; j<forks;j++){ if (atoi(branches[j])>-1){ printf("| %3s |%12s| %11s| \n",branches[j],branchesac[j],brancheter[j]); } } continue; } //Comando para iniciar nueva sucursal. else if (!strncmp("init", commandBuf, strlen("init"))) { // OJO: Llamar a fork dentro de un ciclo // es potencialmente peligroso, dado que accidentalmente // pueden iniciarse procesos sin control. // Buscar en Google "fork bomb" char * numerocuentas; char * numerothreads; //int largo = strlen(commandBuf); numerocuentas = strtok(commandBuf, " "); char n[7] = "1000"; //Cantidad default de cuentas. char thds[2] = "1"; //Cantidad default de threads. numerocuentas=strtok(NULL," "); //Se revisa si se introdujo un numero aceptable de cuentas, 10000 como maximo. if (numerocuentas && atoi(numerocuentas)>0 && atoi(numerocuentas)<=10000){ strcpy(n,numerocuentas); } numerothreads=strtok(NULL," "); //Se revisa si se introdujo un numero aceptable de threads, 8 como maximo. if (numerothreads && atoi(numerothreads)>0 && atoi(numerothreads)<9){ strcpy(thds,numerothreads); } //Fork. pid_t sucid = fork(); if (sucid > 0) { printf("Sucursal creada con ID '%d'\n", sucid); int sucId = sucid % 1000; sprintf(branches[forks],"%d",sucId); strcpy(branchesac[forks], n); strcpy(brancheter[forks], thds); //Aviso a cada sucursal que se ha creado una nueva sucursal. for (int i = 0; i < forks; i++){ if (atoi(branches[i])>-1){ char NS[7]; sprintf(NS,"NS %d",sucId); write(outwPipes[i][1], NS,7); } } forks +=1; counter +=1; continue; } // Proceso de sucursal else if (!sucid) { int sucId = getpid() % 1000; sprintf(branches[forks],"%d",sucId); strcpy(branchesac[forks], n); counter +=1; //Se hace malloc con la cantidad de cuentas especificada en el init. cash= malloc(atoi(n) * sizeof *cash); srand(time(NULL)); for (int i=0; i< atoi(n); i++){ cash[i]=1000; cash[i]+=rand()%499999000; pthread_mutex_init(&mutex[i],NULL); } //Se inicia la cantidad de threads especificados en el init. pthread_t tc[8]; for (int i = 0; i < atoi(thds); i++){ pthread_create(&tc[i], NULL,child,NULL); } printf("Hola, soy la sucursal '%d' y tengo '%s' cuentas \n", sucId, n); while (true) { //Lector de transacciones, desde banco matriz hacia sucursales. Se lee caracter por caracter. char buff[2]; buff[1]='\0'; while(read(outwPipes[forks][0], buff, 1)>0){ if(strcmp(buff,"\0")==0){ break; } strcat(readbuffer,buff); } char *aux; char name[20]=""; //manejo de error en momento de que maten una sucursal a la que se le estaba enviando una transaccion o que la cuenta de destino //no existiera. Este es el error tipo 2. if (!strncmp("FAIL", readbuffer, strlen("FAIL"))){ char * tipo; char * cuentao; char * cuentad; char * monto; strtok(readbuffer, ",");//nada tipo=strtok(NULL,","); strtok(NULL,",");//so cuentao=strtok(NULL,",");//co strtok(NULL,",");//sd cuentad=strtok(NULL,",");//cd monto =strtok(NULL,",");//monto if (strncmp("DP", tipo,2)==0){ addcash(atoi(cuentao),atoi(monto));// le devuelvo la plata } char fail[6]; strcpy(fail,"2,"); strcat(fail,cuentad); //Se agrega el error. adderror(fail); } //Manejo de depositos hacia esta sucursal. Se encarga de agregar la plata a la cuenta de destino. else if (!strncmp("DP", readbuffer, strlen("DP"))){ //depositar char * cuenta; char * monto; strtok(readbuffer, ","); cuenta=strtok(NULL, ","); monto=strtok(NULL,","); addcash(atoi(cuenta),atoi(monto)); } //Manejo de retiros en esta sucursal. Se encarga de generar deposito de vuelta a sucursal de origen. En el caso de no tener la //plata necesaria, se anota como error de tipo 1. else if (!strncmp("RT", readbuffer, strlen("RT"))){ //char copia[34]; char dep[34]; char * cuenta; char * monto; char montop[7]=""; char * so; char * co; char * sd; char error[20]=""; char newtransac[30]=""; strtok(readbuffer, ",");//tipo so=strtok(NULL,",");//so co=strtok(NULL,",");//co sd=strtok(NULL,",");//sd cuenta=strtok(NULL,",");//cd sprintf(montop,"%d",cash[atoi(cuenta)]); monto =strtok(NULL,",");//monto if (cash[atoi(cuenta)]>=atoi(monto)){ subcash(atoi(cuenta),atoi(monto)); strcpy(dep,"DP,"); strcat(dep,sd); strcat(dep,","); strcat(dep,cuenta); strcat(dep,","); strcat(dep,so); strcat(dep,","); strcat(dep,co); strcat(dep,","); strcat(dep,monto); strcpy(newtransac,"DP,"); strcat(newtransac,so); strcat(newtransac,","); strcat(newtransac,co); strcat(newtransac,","); strcat(newtransac,cuenta); addtransc(newtransac); for(int i = 0; i<counter;i++){ if(strcmp(branches[i],so)==0){ write(inwPipes[forks][1], dep, strlen(dep)+1); } } } //error en el caso de no tener el dinero para el retiro pedido. else{ strcpy(error,"1,"); strcat(error,cuenta); strcat(error,","); strcat(error,montop); strcat(error,","); strcat(error,monto); adderror(error); } } //aviso de nueva sucursal abierta. esto es para el momento de generar transacciones. else if (!strncmp("NS", readbuffer, strlen("NS"))){ char id[3]=""; aux=strtok(readbuffer, " "); aux=strtok(NULL," "); strcpy(id,aux); strcpy(branches[counter],id); counter +=1; } //señal para terminar proceso. else if (!strncmp("kill", readbuffer, strlen("kill"))){ aux=strtok(readbuffer, " "); aux=strtok(NULL," "); //Si la sucursal a cerrar es esta misma. if(strcmp(branches[forks],aux)==0){ //Se le señala al thread que deberia dejar de generar transacciones y terminar. terminated = 1; //Se le hace Join a cada thread. Espera que todos los threads terminen antes de terminar el proceso. for (int i = 0; i < atoi(thds); i++){ pthread_join(tc[i],NULL); } //Se libera el malloc de commandBuf y cash. free(cash); free(commandBuf); _exit(EXIT_SUCCESS); } //Si se quiere cerrar otra sucursal, se elimina de sucursales activas. for (int j = 0; j<counter;j++){ if(strcmp(branches[j],aux)==0){ strcpy(branches[j],"-1"); } } } //dump de cuentas. else if (!strncmp("dump_accs", readbuffer, strlen("dump_accs"))){ //Se le hace lock a todos los mutex de las cuentas, para que no se puedan editar mientras se hace el dump. for (int i=0; i< atoi(n); i++){ pthread_mutex_lock(&mutex[i]); } //Se le pone el nombre al archivo con el id de la sucursal. sprintf(name,"dump_accs_%s.csv",branches[forks]); //Se crea el archivo. ipg=fopen(name, "w"); if (ipg == NULL) { fprintf(stderr, "No se puede abrir archivo de entrada\n"); exit(1); } fprintf(ipg,"Numero de cuenta, saldo\n"); //Se escribe transaccion una por una en el archivo. for (int i=0; i<atoi(n); i++){ fprintf(ipg,"%06d, %d \n", i, cash[i]); } //Se cierra el archivo if(ipg!=NULL) fclose(ipg); //Se le hace unlock a todos los mutex de las cuentas. for (int i=0; i< atoi(n); i++){ pthread_mutex_unlock(&mutex[i]); } }//dump de transacciones con error. else if (!strncmp("dump_errs", readbuffer, strlen("dump_errs"))){ //Se le hace lock al mutex de los errores, para que no se puedan agregar errores mientras se hace el dump. pthread_mutex_lock(&emutex); //Se le pone el nombre al archivo con el id de la sucursal. sprintf(name,"dump_errs_%s.csv",branches[forks]); //Se crea el archivo. ipg=fopen(name, "w"); if (ipg == NULL) { fprintf(stderr, "No se puede abrir archivo de entrada\n"); exit(1); } fprintf(ipg,"tipo de error, número de cuenta, saldo previo a la transacción, monto que se quiso retirar\n"); //Se escriben los errores en el archivo, uno por uno. for (int i=0; i<trfail; i++){ fprintf(ipg,"%s\n", transcfail[i]); } //Se cierra el archivo. if(ipg!=NULL) fclose(ipg); //Se le hace unlock al mutex de los errores. pthread_mutex_unlock(&emutex); } //dump de transacciones generadas. else if (!strncmp("dump", readbuffer, strlen("dump"))){ //Se le hace lock al mutex de las transacciones, para que no se puedan agregar transacciones mientras se hace el dump. pthread_mutex_lock(&tmutex); //Se le pone el nombre al archivo con el id de la sucursal. sprintf(name,"dump_%s.csv",branches[forks]); //Se crea el archivo. ipg=fopen(name, "w"); if (ipg == NULL) { fprintf(stderr, "No se puede abrir archivo de entrada\n"); exit(1); } fprintf(ipg,"tipo de transacción, medio de origen, cuenta de origen, cuenta de destino\n"); //Se escriben las transacciones en el archivo, una por una. for (int i=0; i<tr; i++){ fprintf(ipg,"%s \n", transc[i]); } //Se cierra el archivo. if(ipg!=NULL) fclose(ipg); //Se le hace lock al mutex de las transacciones. pthread_mutex_unlock(&tmutex); } else{ } //Se reinicia el buffer devolviendo sus valores a 0. memset(&readbuffer[0], 0, sizeof(readbuffer)); } } // error else { fprintf(stderr, "Error al crear proceso de sucursal!\n"); return (EXIT_FAILURE); } } //comando para eliminar determinada sucursal. else if (!strncmp("kill", commandBuf, strlen("kill"))) { char *id; char aux[15]=""; if (strlen(commandBuf)<5){ printf("ERROR Se debe ingresar un id de sucursal\n"); continue; } strcpy(aux,commandBuf); id=strtok(aux, " "); id=strtok(NULL," "); //Se le envia el mensaje a todas las sucursales. for (int j = 0; j<forks;j++){ write(outwPipes[j][1], commandBuf, (strlen(commandBuf)+1)); if(strcmp(branches[j],id)==0){ strcpy(branches[j],"-1"); } } continue; } //comando para generar determinado dump. else if (!strncmp("dump_accs", commandBuf, strlen("dump_accs"))) { char *id; if (strlen(commandBuf)<10){ printf("ERROR Se debe ingresar un id de sucursal\n"); continue; } id=strtok(commandBuf, " "); id=strtok(NULL," "); //Se le pide el dump a la sucursal determinada. if(id!=NULL){ for (int j = 0; j<forks;j++){ if(strcmp(branches[j],id)==0){ write(outwPipes[j][1], commandBuf, (strlen(commandBuf)+1)); } } } continue; }else if (!strncmp("dump_errs", commandBuf, strlen("dump_errs"))) { char *id; if (strlen(commandBuf)<10){ printf("ERROR Se debe ingresar un id de sucursal\n"); continue; } id=strtok(commandBuf, " "); id=strtok(NULL," "); if(id!=NULL){ for (int j = 0; j<forks;j++){ if(strcmp(branches[j],id)==0){ write(outwPipes[j][1], commandBuf, (strlen(commandBuf)+1)); } } } continue; }else if (!strncmp("dump", commandBuf, strlen("dump"))) { char *id; if (strlen(commandBuf)<5){ printf("ERROR Se debe ingresar un id de sucursal\n"); continue; } id=strtok(commandBuf, " "); id=strtok(NULL," "); //Se le pide el dump a la sucursal determinada. if(id!=NULL){ for (int j = 0; j<forks;j++){ if(strcmp(branches[j],id)==0){ write(outwPipes[j][1], commandBuf, (strlen(commandBuf)+1)); } } } continue; } else { fprintf(stderr, "Comando no reconocido.\n"); } } //cuando se termina el banco principal, se envia mensajes para terminar todas las sucursales aun vivas. for (int i = 0; i < forks; i++){ if (atoi(branches[i])>-1){ char msg[8] = "kill "; strcat(msg,branches[i]); write(outwPipes[i][1], msg,strlen(msg)+1); } } //señal para terminar thread del banco matriz concurrente. terminated = 1; //Se libera el malloc de commandBuf. free(commandBuf); printf("Terminando ejecucion limpiamente...\n"); //Se espera que terminen todas las sucursales. wait(NULL); //Se hace join del thread del banco matriz. Espera que este termine antes de salir del programa. pthread_join(th,NULL); return(EXIT_SUCCESS); }
the_stack_data/187644303.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_6__ TYPE_3__ ; typedef struct TYPE_5__ TYPE_2__ ; typedef struct TYPE_4__ TYPE_1__ ; /* Type definitions */ struct zc0301_device {scalar_t__* transfer_buffer; struct urb** urb; int /*<<< orphan*/ * frame_current; struct usb_device* usbdev; } ; struct usb_host_interface {TYPE_2__* endpoint; } ; struct usb_device {int dummy; } ; struct urb {unsigned int number_of_packets; unsigned int transfer_buffer_length; int interval; TYPE_3__* iso_frame_desc; scalar_t__ transfer_buffer; int /*<<< orphan*/ complete; int /*<<< orphan*/ transfer_flags; int /*<<< orphan*/ pipe; struct zc0301_device* context; struct usb_device* dev; } ; typedef size_t s8 ; struct TYPE_6__ {unsigned int offset; unsigned int length; } ; struct TYPE_4__ {int /*<<< orphan*/ wMaxPacketSize; } ; struct TYPE_5__ {TYPE_1__ desc; } ; /* Variables and functions */ int /*<<< orphan*/ DBG (int,char*,...) ; int ENOMEM ; int /*<<< orphan*/ GFP_KERNEL ; int /*<<< orphan*/ URB_ISO_ASAP ; int /*<<< orphan*/ ZC0301_ALTERNATE_SETTING ; unsigned int const ZC0301_ISO_PACKETS ; size_t ZC0301_URBS ; int /*<<< orphan*/ kfree (scalar_t__) ; scalar_t__ kzalloc (unsigned int const,int /*<<< orphan*/ ) ; unsigned int le16_to_cpu (int /*<<< orphan*/ ) ; struct urb* usb_alloc_urb (unsigned int const,int /*<<< orphan*/ ) ; struct usb_host_interface* usb_altnum_to_altsetting (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; int /*<<< orphan*/ usb_free_urb (struct urb*) ; int /*<<< orphan*/ usb_ifnum_to_if (struct usb_device*,int /*<<< orphan*/ ) ; int /*<<< orphan*/ usb_kill_urb (struct urb*) ; int /*<<< orphan*/ usb_rcvisocpipe (struct usb_device*,int) ; int usb_set_interface (struct usb_device*,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; int usb_submit_urb (struct urb*,int /*<<< orphan*/ ) ; int /*<<< orphan*/ zc0301_urb_complete ; __attribute__((used)) static int zc0301_start_transfer(struct zc0301_device* cam) { struct usb_device *udev = cam->usbdev; struct usb_host_interface* altsetting = usb_altnum_to_altsetting( usb_ifnum_to_if(udev, 0), ZC0301_ALTERNATE_SETTING); const unsigned int psz = le16_to_cpu(altsetting-> endpoint[0].desc.wMaxPacketSize); struct urb* urb; s8 i, j; int err = 0; for (i = 0; i < ZC0301_URBS; i++) { cam->transfer_buffer[i] = kzalloc(ZC0301_ISO_PACKETS * psz, GFP_KERNEL); if (!cam->transfer_buffer[i]) { err = -ENOMEM; DBG(1, "Not enough memory"); goto free_buffers; } } for (i = 0; i < ZC0301_URBS; i++) { urb = usb_alloc_urb(ZC0301_ISO_PACKETS, GFP_KERNEL); cam->urb[i] = urb; if (!urb) { err = -ENOMEM; DBG(1, "usb_alloc_urb() failed"); goto free_urbs; } urb->dev = udev; urb->context = cam; urb->pipe = usb_rcvisocpipe(udev, 1); urb->transfer_flags = URB_ISO_ASAP; urb->number_of_packets = ZC0301_ISO_PACKETS; urb->complete = zc0301_urb_complete; urb->transfer_buffer = cam->transfer_buffer[i]; urb->transfer_buffer_length = psz * ZC0301_ISO_PACKETS; urb->interval = 1; for (j = 0; j < ZC0301_ISO_PACKETS; j++) { urb->iso_frame_desc[j].offset = psz * j; urb->iso_frame_desc[j].length = psz; } } err = usb_set_interface(udev, 0, ZC0301_ALTERNATE_SETTING); if (err) { DBG(1, "usb_set_interface() failed"); goto free_urbs; } cam->frame_current = NULL; for (i = 0; i < ZC0301_URBS; i++) { err = usb_submit_urb(cam->urb[i], GFP_KERNEL); if (err) { for (j = i-1; j >= 0; j--) usb_kill_urb(cam->urb[j]); DBG(1, "usb_submit_urb() failed, error %d", err); goto free_urbs; } } return 0; free_urbs: for (i = 0; (i < ZC0301_URBS) && cam->urb[i]; i++) usb_free_urb(cam->urb[i]); free_buffers: for (i = 0; (i < ZC0301_URBS) && cam->transfer_buffer[i]; i++) kfree(cam->transfer_buffer[i]); return err; }
the_stack_data/41624.c
/*selection sort*/ #include <stdio.h> void selectionSort(int[], int); int main() { int a[100], i, n; printf("Enter size of the array : "); scanf("%d", &n); printf("Enter elements in array : \n"); for (i = 0; i < n; i++) scanf("%d", &a[i]); selectionSort(a, n); printf("The sorted Array : \n"); for (i = 0; i < n; i++) printf("%d\t", a[i]); printf("\n"); return 0; } void selectionSort(int a[], int n) { int i, j, temp, min; for (i = 0; i < n; i++) { min = i; for (j = i + 1; j < n; j++) if (a[j] < a[min]) min = j; if (min != i) { temp = a[min]; a[min] = a[i]; a[i] = temp; } } }
the_stack_data/66162.c
/* { dg-do compile } */ /* { dg-options "-O -ffixed-ebp -mno-accumulate-outgoing-args" } */ /* { dg-warning "fixed ebp register requires" "" { target *-*-* } 0 } */ void foo (void); int main (int argc, char *argv[]) { foo (); return argc - 1; }
the_stack_data/149395.c
/* PR middle-end/36043 target/58744 target/65408 */ /* { dg-do run { target mmap } } */ /* { dg-options "-O2" } */ #include <sys/mman.h> #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON #endif #ifndef MAP_ANON #define MAP_ANON 0 #endif #ifndef MAP_FAILED #define MAP_FAILED ((void *)-1) #endif typedef struct { unsigned char r; unsigned char g; unsigned char b; } __attribute__((packed)) pr58744; typedef struct { unsigned short r; unsigned short g; unsigned short b; } pr36043; typedef struct { int r; int g; int b; } pr65408; __attribute__ ((noinline, noclone)) void f1a (pr58744 x) { if (x.r != 1 || x.g != 2 || x.b != 3) __builtin_abort(); } __attribute__ ((noinline, noclone)) void f1 (pr58744 *x) { f1a (*x); } __attribute__ ((noinline, noclone)) void f2a (pr36043 x) { if (x.r != 1 || x.g != 2 || x.b != 3) __builtin_abort(); } __attribute__ ((noinline, noclone)) void f2 (pr36043 *x) { f2a (*x); } __attribute__ ((noinline, noclone)) void f3a (pr65408 x) { if (x.r != 1 || x.g != 2 || x.b != 3) __builtin_abort(); } __attribute__ ((noinline, noclone)) void f3 (pr65408 *x) { f3a (*x); } int main () { char *p = mmap ((void *) 0, 131072, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) return 0; char *endp = p + 65536; if (munmap (endp, 65536) < 0) return 0; pr58744 *s1 = (pr58744 *) endp - 1; s1->r = 1; s1->g = 2; s1->b = 3; f1 (s1); pr36043 *s2 = (pr36043 *) endp - 1; s2->r = 1; s2->g = 2; s2->b = 3; f2 (s2); pr65408 *s3 = (pr65408 *) endp - 1; s3->r = 1; s3->g = 2; s3->b = 3; f3 (s3); return 0; }
the_stack_data/9512090.c
#include<stdio.h> int main() { printf("Hello World!\n"); return 0; }
the_stack_data/9513318.c
/* We used to mis-compile this testcase as we did not know that &a+offsetof(b,a) was the same as &a.b */ struct A { int t; int i; }; void bar (float *p) { *p = 5.2; } int foo(struct A *locp, int i, int str) { float f, g, *p; int T355; int *T356; /* Currently, the alias analyzer has limited support for handling aliases of structure fields when no other variables are aliased. Introduce additional aliases to confuse it. */ p = i ? &g : &f; bar (p); if (*p > 0.0) str = 1; T355 = locp->i; T356 = &locp->i; *T356 = str; T355 = locp->i; return T355; } int TestNano () { struct A loc; int str; loc.i = 2; str = foo (&loc, 10, 3); if (str!=1) return 1; return 0; }
the_stack_data/86424.c
#include <stdio.h> #include <string.h> enum Langue { LANGUE_EN, LANGUE_FR, LANGUE_INVALIDE }; static char const * chaines_langues[] = { [LANGUE_EN] = "en", [LANGUE_FR] = "fr" }; static char const * prompts[] = { [LANGUE_EN] = "Please enter an integer N:", [LANGUE_FR] = "Veuillez entrer un entier N :" }; char const * chaine_langue(char const * chaines[], char const * chaine_langue) { enum Langue langue; char const * chaine = NULL; for (langue = 0; !chaine && langue <= LANGUE_INVALIDE; langue++) { if (!strcmp(chaines_langues[langue], chaine_langue)) { chaine = chaines[langue]; } } return chaine; } int main(int argc, char * argv[]) { unsigned n; printf("%s\n", chaine_langue(prompts, argv[1])); scanf("%u", &n); printf("2^N = %u\n", 1 << n); return 0; }
the_stack_data/154829372.c
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin %s // This file tests -Wconstant-conversion, a subcategory of -Wconversion // which is on by default. // rdar://problem/6792488 void test_6792488(void) { int x = 0x3ff0000000000000U; // expected-warning {{implicit conversion from 'unsigned long' to 'int' changes value from 4607182418800017408 to 0}} } void test_7809123(void) { struct { int i5 : 5; } a; a.i5 = 36; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 36 to 4}} } void test() { struct { int bit : 1; } a; a.bit = 1; // shouldn't warn } enum Test2 { K_zero, K_one }; enum Test2 test2(enum Test2 *t) { *t = 20; return 10; // shouldn't warn } void test3() { struct A { unsigned int foo : 2; int bar : 2; }; struct A a = { 0, 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}} struct A b[] = { 0, 10, 0, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}} struct A c[] = {{10, 0}}; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}} struct A d = (struct A) { 10, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}} struct A e = { .foo = 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}} } void test4() { struct A { char c : 2; } a; a.c = 0x101; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 257 to 1}} } void test5() { struct A { _Bool b : 1; } a; // Don't warn about this implicit conversion to bool, or at least // don't warn about it just because it's a bitfield. a.b = 100; } void test6() { // Test that unreachable code doesn't trigger the truncation warning. unsigned char x = 0 ? 65535 : 1; // no-warning unsigned char y = 1 ? 65535 : 1; // expected-warning {{changes value}} } void test7() { struct { unsigned int twoBits1:2; unsigned int twoBits2:2; unsigned int reserved:28; } f; f.twoBits1 = ~1; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -2 to 2}} f.twoBits2 = ~2; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -3 to 1}} f.twoBits1 &= ~1; // no-warning f.twoBits2 &= ~2; // no-warning } void test8() { enum E { A, B, C }; struct { enum E x : 1; } f; f.x = C; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 2 to 0}} }
the_stack_data/62639013.c
// // Created by ywh on 2020/7/22. // #include <string.h> #define max(a, b) ( (a)>(b) ? (a):(b) ) #define min(a, b) ( (a)>(b) ? (b):(a) ) /** * 无重复字符的最长子串 * * @param s * @return */ static int lengthOfLongestSubstring(char *s) { int maxLen = 0; int idxHash[256]; for (int i = 0; i < 255; ++i) { idxHash[i] = -1; } for (int l = 0, r = 0; r < strlen(s); r++) { l = max(idxHash[s[r]] + 1, l); maxLen = max(maxLen, r - l + 1); idxHash[s[r]] = r; } return maxLen; }
the_stack_data/99568.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <elf.h> #define N 16 int main(int argc, char *argv[]) { char *pdata, *data; Elf64_Ehdr ehdr; Elf64_Phdr *phdr; unsigned long start, stop, len, n; int fd; int i; int plen; if (argc != 4) { fprintf(stderr, "usage: elf-text2egg filename start stop\n"); exit(1); } start = strtol(argv[2], NULL, 16); stop = strtol(argv[3], NULL, 16); if (stop <= start) { fprintf(stderr, "ERROR: stop <= start\n"); exit(1); } fd = open(argv[1], O_RDONLY); if (fd < 0) { perror("open"); exit(1); } if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) { perror("read"); exit(1); } if (strncmp(ehdr.e_ident, ELFMAG, SELFMAG)) { fprintf(stderr, "Not ELF\n"); exit(1); } pdata = (char *)malloc(plen = sizeof(*phdr)*ehdr.e_phnum); if (pdata == NULL) { perror("malloc"); exit(1); } if (lseek(fd, ehdr.e_phoff, SEEK_SET) < 0) { perror("lseek"); exit(1); } if (read(fd, pdata, plen) != plen) { perror("read"); exit(1); } for (phdr = (Elf64_Phdr *)pdata, i = 0; i < ehdr.e_phnum; i++) { if ( phdr->p_type == PT_LOAD && phdr->p_vaddr <= start && phdr->p_vaddr + phdr->p_filesz >= stop ) { break; } ++phdr; } if (i == ehdr.e_phnum) { fprintf(stderr, "No SEGMENT\n"); exit(1); } if (lseek(fd, phdr->p_offset + start - phdr->p_vaddr, SEEK_SET) < 0) { perror("lseek"); exit(1); } data = (char *)malloc(len = stop - start); //New the space for we want if (data == NULL) { perror("malloc"); exit(1); } if (read(fd, data, len) != len) { perror("read"); exit(1); } n = 0; while (n < len) { // You can change the form of output by change here. for (i = 0; n < len && i < N; i++) { printf(",0x%2.2x", data[n] & 0xff); ++n; } printf("\n"); } exit(0); }
the_stack_data/418408.c
#include<stdio.h> int N(int l,int r,int a[],int n) { int i,ans=0; for(i=l;i<=r;i++) { ans=((ans%n)+(a[i]%n)); } return ans%n; } int M(int l,int r,int a[],int n) { int i,ans=1; for(i=l;i<=r;i++) { ans=((ans%n)*(a[i]%n)); } return ans%n; } int H(int l,int r,int a[],int n) { int i,sum; sum=a[l]; for(i=l+1;i<=r;i++) { sum=sum^a[i]; } return sum; } int max(int a,int b) { if(a>=b) return a; if(a<b) return b; } int min(int a,int b) { if(a>=b) return b; if(a<b) return a; } int main() { int n,k,i; scanf("%d%d",&n,&k); int a[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); } int l[k],r[k]; for(i=0;i<k;i++) { scanf("%d%d",&l[i],&r[i]); } int x,y,c,d,ans; for(i=0;i<k;i++) { x=N(l[i],r[i],a,n); y=M(l[i],r[i],a,n); c=min(x,y); d=max(x,y); ans=H(c,d,a,n); printf("%d\n",ans); } }