blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
721
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
5
91
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
321 values
visit_date
timestamp[ns]date
2016-08-12 09:31:09
2023-09-06 10:45:07
revision_date
timestamp[ns]date
2010-09-28 14:01:40
2023-09-06 06:22:19
committer_date
timestamp[ns]date
2010-09-28 14:01:40
2023-09-06 06:22:19
github_id
int64
426
681M
star_events_count
int64
101
243k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[ns]date
2012-06-28 18:51:49
2023-09-14 21:59:16
gha_created_at
timestamp[ns]date
2008-02-11 22:55:26
2023-08-10 11:14:58
gha_language
stringclasses
147 values
src_encoding
stringclasses
26 values
language
stringclasses
2 values
is_vendor
bool
2 classes
is_generated
bool
2 classes
length_bytes
int64
6
10.2M
extension
stringclasses
115 values
filename
stringlengths
3
113
content
stringlengths
6
10.2M
ac4886408af8f53e7d7f25e743ab1c51b38bcb92
7d2667eb56489d7d36ae377b00ef2cf1569aa3b6
/external/libcrt/include/libcrt.h
09ffa04857f67156019bb66f50fa9f0aa32ca3f1
[ "MIT" ]
permissive
AMDESE/linux-svsm
e0eef44ef407b47a1d029e4cb0e25a4a53522bff
7f286b506bb969a919c01a9d852177493397da27
refs/heads/main
2023-07-06T14:41:42.392149
2023-04-28T16:30:15
2023-04-28T16:30:15
515,643,561
102
36
MIT
2023-06-22T16:03:54
2022-07-19T15:34:24
Rust
UTF-8
C
false
false
10,201
h
libcrt.h
/* SPDX-License-Identifier: MIT */ #ifndef __LIBCRT_H__ #define __LIBCRT_H__ // The SVSM guids are expected to be the last bytes of the svsm.bin file. When // we set the external dependencies symbols to be hidden, we prevent them from // being preempted. Otherwise, the SVSM guids will not be the last bytes of the // svsm.bin. #if defined(__pie__) #pragma GCC visibility push (hidden) #endif // Openssl big number operation (bn_op). Ensure it is defined for all SVSM // external dependency that requires openssl crypto functions. #define SIXTY_FOUR_BIT_LONG // features.h #define _Noreturn __attribute__((__noreturn__)) #define weak __attribute__((__weak__)) #define hidden __attribute__((__visibility__("hidden"))) #define weak_alias(old, new) \ extern __typeof(old) new __attribute__((__weak__, __alias__(#old))) // All types required #define __NEED_va_list #define __NEED_int8_t #define __NEED_int16_t #define __NEED_int32_t #define __NEED_int64_t #define __NEED_uint8_t #define __NEED_uint16_t #define __NEED_uint32_t #define __NEED_uint64_t #define __NEED_intptr_t #define __NEED_uintptr_t #define __NEED_size_t #define __NEED_ssize_t #define __NEED_ptrdiff_t #define __NEED_wchar_t #define __NEED_intmax_t #define __NEED_uintmax_t #define __NEED_time_t #define __NEED_clock_t #define __NEED_clockid_t #define __NEED_struct_timespec #define __NEED_pid_t #define __NEED_FILE #define __NEED_struct__IO_FILE #define __NEED_dev_t #define __NEED_ino_t #define __NEED_mode_t #define __NEED_nlink_t #define __NEED_uid_t #define __NEED_gid_t #define __NEED_off_t #define __NEED_blksize_t #define __NEED_blkcnt_t #include <bits/alltypes.h> // errno.h extern int errno; #define ENOMEM 12 #define EINVAL 22 #define EAFNOSUPPORT 47 #define EOVERFLOW 75 // stddef.h #ifndef NULL #define NULL ((void *) 0) #endif #define offsetof(type, member) __builtin_offsetof(type, member) // stdbool.h #define true 1 #define false 0 #define bool _Bool // stdint.h #define INT8_MIN (-1-0x7f) #define INT16_MIN (-1-0x7fff) #define INT32_MIN (-1-0x7fffffff) #define INT64_MIN (-1-0x7fffffffffffffff) #define INT8_MAX (0x7f) #define INT16_MAX (0x7fff) #define INT32_MAX (0x7fffffff) #define INT64_MAX (0x7fffffffffffffff) #define UINT8_MAX (0xff) #define UINT16_MAX (0xffff) #define UINT32_MAX (0xffffffffu) #define UINT64_MAX (0xffffffffffffffffu) // limits.h #define UCHAR_MAX 255 #define SSIZE_MAX 0xFFFFFFFFFFFFFFFFU #define INT_MIN (-1-0x7fffffff) #define INT_MAX 0x7fffffff #define LONG_MIN (-LONG_MAX-1) #define LONG_MAX __LONG_MAX #define UINT_MAX 0xffffffffU #define ULONG_MAX (2UL*LONG_MAX+1) #define CHAR_BIT 8 // atomic.h // Check the atomic.h file for the atomic definitions. It is a busy file with // lots of inline functions and it also includes architecture dependent code. // stdarg.h #define va_start(v,l) __builtin_va_start(v,l) #define va_end(v) __builtin_va_end(v) #define va_arg(v,l) __builtin_va_arg(v,l) #define va_copy(d,s) __builtin_va_copy(d,s) // unistd.h #define STDERR_FILENO 2 #define SEEK_SET 0 #define SEEK_CUR 1 #define SEEK_END 2 pid_t getpid(void); uid_t getuid(void); uid_t geteuid(void); gid_t getgid(void); gid_t getegid(void); int issetugid(void); // stdio.h #define EOF (-1) #define BUFSIZ 8192 void setbuf(FILE *stream, char *buf); int printf(const char *restrict fmt, ...); int dprintf(int fd, const char *__restrict fmt, ...); int vdprintf(int fd, const char *restrict fmt, va_list ap); int puts(const char *s); int fprintf(FILE *restrict f, const char *restrict fmt, ...); int asprintf(char **s, const char *fmt, ...); int snprintf(char *restrict s, size_t n, const char *restrict fmt, ...); int sprintf(char *restrict s, const char *restrict fmt, ...); int vasprintf(char **s, const char *fmt, va_list ap); int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap); int vsprintf(char *restrict s, const char *restrict fmt, va_list ap); int vprints(const char *format, va_list ap); int vsnprints(char *str, size_t size, const char *format, va_list ap); // Functions exported by the SVSM extern void serial_out(const char *s, int len); // stdlib.h // Functions exported by the SVSM extern void *malloc(size_t size); extern void *realloc(void *ptr, size_t size); extern void *calloc(size_t nmemb, size_t size); extern void free(void *ptr); extern _Noreturn void abort(void); int atoi(const char *s); int atexit(void (*func)(void)); void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); void qsort_r(void *, size_t, size_t, int (*)(const void *, const void *, void *), void *); void __qsort_r(void *, size_t, size_t, int (*)(const void *, const void *, void *), void *); char *getenv(const char *); int rand(void); void srand(unsigned s); // time.h struct tm { int tm_sec; /* seconds after the minute [0-60] */ int tm_min; /* minutes after the hour [0-59] */ int tm_hour; /* hours since midnight [0-23] */ int tm_mday; /* day of the month [1-31] */ int tm_mon; /* months since January [0-11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0-6] */ int tm_yday; /* days since January 1 [0-365] */ int tm_isdst; /* Daylight Savings Time flag */ long tm_gmtoff; /* offset from CUT in seconds */ char *tm_zone; /* timezone abbreviation */ }; struct timeval { long tv_sec; /* time value, in seconds */ long tv_usec; /* time value, in microseconds */ }; time_t time(time_t *); struct tm *gmtime(const time_t *); struct tm *gmtime_r(const time_t *restrict t, struct tm *restrict tm); clock_t clock(void); int clock_gettime(clockid_t clk_id, struct timespec *tp); int gettimeofday(struct timeval *restrict tv, void *restrict tz); int __secs_to_tm(long long t, struct tm *tm); #define DECLARE_ARGS(val, low, high) unsigned long low, high #define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32) #define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high) static inline unsigned long long rdtsc(void) { DECLARE_ARGS(val, low, high); asm volatile("rdtsc" : EAX_EDX_RET(val, low, high)); return EAX_EDX_VAL(val, low, high); } // inttypes.h #if UINTPTR_MAX == UINT64_MAX #define __PRI64 "l" #define __PRIPTR "l" #else #define __PRI64 "ll" #define __PRIPTR "" #endif #define PRIu8 "u" #define PRIu16 "u" #define PRIu32 "u" #define PRIu64 __PRI64 "u" // dirent.h typedef struct __dirstream DIR; struct dirent { ino_t d_ino; off_t d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; }; DIR *opendir(const char *name); int closedir(DIR *name); struct dirent *readdir(DIR *name); typedef unsigned long __jmp_buf[8]; typedef struct __jmp_buf_tag { __jmp_buf __jb; unsigned long __fl; unsigned long __ss[128/sizeof(long)]; } jmp_buf[1]; #define __setjmp_attr __attribute__((__returns_twice__)) // sys/stat.h #define S_IFDIR 0040000 #define S_IFMT 0170000 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) /* copied from kernel definition, but with padding replaced * by the corresponding correctly-sized userspace types. */ struct stat { dev_t st_dev; ino_t st_ino; nlink_t st_nlink; mode_t st_mode; uid_t st_uid; gid_t st_gid; unsigned int __pad0; dev_t st_rdev; off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __unused[3]; }; int stat(const char *__restrict path, struct stat *restrict buf); // string.h void *memset(void *, int, size_t); int memcmp(const void *, const void *, size_t); void *memcpy(void *restrict dest, const void *restrict src, size_t n); void *memchr(const void *src, int c, size_t n); void *memmove(void *dest, const void *src, size_t n); void *memrchr(const void *m, int c, size_t n); void *__memrchr(const void *m, int c, size_t n); int strcmp(const char *, const char *); int strncasecmp(const char *, const char *, size_t); char *strchr(const char *, int); char *strrchr(const char *, int); unsigned long strtoul(const char *, char **, int); long strtol(const char *, char **, int); char *strerror(int); size_t strspn(const char *, const char *); size_t strcspn(const char *, const char *); char *strcpy(char *strDest, const char *strSource); size_t strlen(const char *s); char *__strchrnul(const char *s, int c); char *__stpcpy(char *restrict d, const char *restrict s); char *__stpncpy(char *restrict d, const char *restrict s, size_t n); char *strstr(const char *h, const char *n); char *strdup(const char *s); char *strncpy(char *restrict d, const char *restrict s, size_t n); int strncmp(const char *_l, const char *_r, size_t n); int strcasecmp(const char *_l, const char *_r); char *strcat(char *restrict dest, const char *restrict src); char *strncat (char *__restrict, const char *__restrict, size_t); // ctype.h int isdigit(int c); int isspace(int c); int isupper(int c); int isascii(int c); int islower(int c); int tolower(int c); int toupper(int c); // stdio.h int printf(const char *, ...); int sscanf(const char *, const char *, ...); FILE *fopen(const char *, const char *); int fclose(FILE *); size_t fread(void *, size_t, size_t, FILE *); size_t fwrite(const void *buffer, size_t size, size_t count, FILE *stream); int fprintf(FILE *, const char *, ...); int vasprintf(char **s, const char *fmt, va_list ap); int asprintf(char **s, const char *fmt, ...); int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap); int vsprintf(char *restrict s, const char *restrict fmt, va_list ap); int snprintf(char *restrict s, size_t n, const char *restrict fmt, ...); int sprintf(char *restrict s, const char *restrict fmt, ...); int dprintf(int fd, const char *__restrict fmt, ...); int vdprintf(int fd, const char *restrict fmt, va_list ap); // inet.h int inet_pton(int, const char *, void *); // setjmp.h int setjmp (jmp_buf) __setjmp_attr; _Noreturn void longjmp (jmp_buf, int); // assert.h #define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) _Noreturn void __assert_fail (const char *, const char *, int, const char *); #endif
06627df9599f5269cab602868a033ac974e0f4aa
8a51a96f61699f0318315ccc89cef39f6866f2b5
/src/backend/utils/adt/oid.c
3f7af5b3a066148a7b8bfbae3eaa3a338e527a6e
[ "PostgreSQL" ]
permissive
postgres/postgres
979febf2b41c00090d1256228f768f33e7ef3b6f
b5934bfd6071fed3a38cea0cfaa93afda63d9c0c
refs/heads/master
2023-08-31T00:10:01.373472
2023-08-30T23:07:48
2023-08-30T23:07:48
927,442
13,691
4,807
NOASSERTION
2023-09-09T13:59:15
2010-09-21T11:35:45
C
UTF-8
C
false
false
7,938
c
oid.c
/*------------------------------------------------------------------------- * * oid.c * Functions for the built-in type Oid ... also oidvector. * * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * src/backend/utils/adt/oid.c * *------------------------------------------------------------------------- */ #include "postgres.h" #include <ctype.h> #include <limits.h> #include "catalog/pg_type.h" #include "libpq/pqformat.h" #include "nodes/miscnodes.h" #include "nodes/value.h" #include "utils/array.h" #include "utils/builtins.h" #define OidVectorSize(n) (offsetof(oidvector, values) + (n) * sizeof(Oid)) /***************************************************************************** * USER I/O ROUTINES * *****************************************************************************/ Datum oidin(PG_FUNCTION_ARGS) { char *s = PG_GETARG_CSTRING(0); Oid result; result = uint32in_subr(s, NULL, "oid", fcinfo->context); PG_RETURN_OID(result); } Datum oidout(PG_FUNCTION_ARGS) { Oid o = PG_GETARG_OID(0); char *result = (char *) palloc(12); snprintf(result, 12, "%u", o); PG_RETURN_CSTRING(result); } /* * oidrecv - converts external binary format to oid */ Datum oidrecv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); PG_RETURN_OID((Oid) pq_getmsgint(buf, sizeof(Oid))); } /* * oidsend - converts oid to binary format */ Datum oidsend(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); StringInfoData buf; pq_begintypsend(&buf); pq_sendint32(&buf, arg1); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } /* * construct oidvector given a raw array of Oids * * If oids is NULL then caller must fill values[] afterward */ oidvector * buildoidvector(const Oid *oids, int n) { oidvector *result; result = (oidvector *) palloc0(OidVectorSize(n)); if (n > 0 && oids) memcpy(result->values, oids, n * sizeof(Oid)); /* * Attach standard array header. For historical reasons, we set the index * lower bound to 0 not 1. */ SET_VARSIZE(result, OidVectorSize(n)); result->ndim = 1; result->dataoffset = 0; /* never any nulls */ result->elemtype = OIDOID; result->dim1 = n; result->lbound1 = 0; return result; } /* * oidvectorin - converts "num num ..." to internal form */ Datum oidvectorin(PG_FUNCTION_ARGS) { char *oidString = PG_GETARG_CSTRING(0); Node *escontext = fcinfo->context; oidvector *result; int nalloc; int n; nalloc = 32; /* arbitrary initial size guess */ result = (oidvector *) palloc0(OidVectorSize(nalloc)); for (n = 0;; n++) { while (*oidString && isspace((unsigned char) *oidString)) oidString++; if (*oidString == '\0') break; if (n >= nalloc) { nalloc *= 2; result = (oidvector *) repalloc(result, OidVectorSize(nalloc)); } result->values[n] = uint32in_subr(oidString, &oidString, "oid", escontext); if (SOFT_ERROR_OCCURRED(escontext)) PG_RETURN_NULL(); } SET_VARSIZE(result, OidVectorSize(n)); result->ndim = 1; result->dataoffset = 0; /* never any nulls */ result->elemtype = OIDOID; result->dim1 = n; result->lbound1 = 0; PG_RETURN_POINTER(result); } /* * oidvectorout - converts internal form to "num num ..." */ Datum oidvectorout(PG_FUNCTION_ARGS) { oidvector *oidArray = (oidvector *) PG_GETARG_POINTER(0); int num, nnums = oidArray->dim1; char *rp; char *result; /* assumes sign, 10 digits, ' ' */ rp = result = (char *) palloc(nnums * 12 + 1); for (num = 0; num < nnums; num++) { if (num != 0) *rp++ = ' '; sprintf(rp, "%u", oidArray->values[num]); while (*++rp != '\0') ; } *rp = '\0'; PG_RETURN_CSTRING(result); } /* * oidvectorrecv - converts external binary format to oidvector */ Datum oidvectorrecv(PG_FUNCTION_ARGS) { LOCAL_FCINFO(locfcinfo, 3); StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); oidvector *result; /* * Normally one would call array_recv() using DirectFunctionCall3, but * that does not work since array_recv wants to cache some data using * fcinfo->flinfo->fn_extra. So we need to pass it our own flinfo * parameter. */ InitFunctionCallInfoData(*locfcinfo, fcinfo->flinfo, 3, InvalidOid, NULL, NULL); locfcinfo->args[0].value = PointerGetDatum(buf); locfcinfo->args[0].isnull = false; locfcinfo->args[1].value = ObjectIdGetDatum(OIDOID); locfcinfo->args[1].isnull = false; locfcinfo->args[2].value = Int32GetDatum(-1); locfcinfo->args[2].isnull = false; result = (oidvector *) DatumGetPointer(array_recv(locfcinfo)); Assert(!locfcinfo->isnull); /* sanity checks: oidvector must be 1-D, 0-based, no nulls */ if (ARR_NDIM(result) != 1 || ARR_HASNULL(result) || ARR_ELEMTYPE(result) != OIDOID || ARR_LBOUND(result)[0] != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("invalid oidvector data"))); PG_RETURN_POINTER(result); } /* * oidvectorsend - converts oidvector to binary format */ Datum oidvectorsend(PG_FUNCTION_ARGS) { return array_send(fcinfo); } /* * oidparse - get OID from ICONST/FCONST node */ Oid oidparse(Node *node) { switch (nodeTag(node)) { case T_Integer: return intVal(node); case T_Float: /* * Values too large for int4 will be represented as Float * constants by the lexer. Accept these if they are valid OID * strings. */ return uint32in_subr(castNode(Float, node)->fval, NULL, "oid", NULL); default: elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); } return InvalidOid; /* keep compiler quiet */ } /* qsort comparison function for Oids */ int oid_cmp(const void *p1, const void *p2) { Oid v1 = *((const Oid *) p1); Oid v2 = *((const Oid *) p2); if (v1 < v2) return -1; if (v1 > v2) return 1; return 0; } /***************************************************************************** * PUBLIC ROUTINES * *****************************************************************************/ Datum oideq(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); Oid arg2 = PG_GETARG_OID(1); PG_RETURN_BOOL(arg1 == arg2); } Datum oidne(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); Oid arg2 = PG_GETARG_OID(1); PG_RETURN_BOOL(arg1 != arg2); } Datum oidlt(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); Oid arg2 = PG_GETARG_OID(1); PG_RETURN_BOOL(arg1 < arg2); } Datum oidle(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); Oid arg2 = PG_GETARG_OID(1); PG_RETURN_BOOL(arg1 <= arg2); } Datum oidge(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); Oid arg2 = PG_GETARG_OID(1); PG_RETURN_BOOL(arg1 >= arg2); } Datum oidgt(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); Oid arg2 = PG_GETARG_OID(1); PG_RETURN_BOOL(arg1 > arg2); } Datum oidlarger(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); Oid arg2 = PG_GETARG_OID(1); PG_RETURN_OID((arg1 > arg2) ? arg1 : arg2); } Datum oidsmaller(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); Oid arg2 = PG_GETARG_OID(1); PG_RETURN_OID((arg1 < arg2) ? arg1 : arg2); } Datum oidvectoreq(PG_FUNCTION_ARGS) { int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo)); PG_RETURN_BOOL(cmp == 0); } Datum oidvectorne(PG_FUNCTION_ARGS) { int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo)); PG_RETURN_BOOL(cmp != 0); } Datum oidvectorlt(PG_FUNCTION_ARGS) { int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo)); PG_RETURN_BOOL(cmp < 0); } Datum oidvectorle(PG_FUNCTION_ARGS) { int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo)); PG_RETURN_BOOL(cmp <= 0); } Datum oidvectorge(PG_FUNCTION_ARGS) { int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo)); PG_RETURN_BOOL(cmp >= 0); } Datum oidvectorgt(PG_FUNCTION_ARGS) { int32 cmp = DatumGetInt32(btoidvectorcmp(fcinfo)); PG_RETURN_BOOL(cmp > 0); }
984bc23ab5e4b6ac1cd98230bc05301e0ad7dffe
5ab69c8644a936a3d9dec1669a86c7369c911bf8
/arch/cpu/cc2538/dev/rom-util.h
2ab4bd82c65757b2a585885f1a17cdd40f27a162
[ "BSD-3-Clause" ]
permissive
contiki-ng/contiki-ng
393d36f68b98f5ee3544ea32502cf662ffb2fe9f
31fcaadf7a0dc8ceea07f438cd69db73174879e6
refs/heads/develop
2023-09-01T20:10:30.000765
2023-09-01T14:37:12
2023-09-01T14:37:12
91,191,972
1,242
788
BSD-3-Clause
2023-09-14T19:08:35
2017-05-13T17:37:59
C
UTF-8
C
false
false
4,605
h
rom-util.h
/* * Original file: * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ * All rights reserved. * * Port to Contiki: * Copyright (c) 2013, ADVANSEE - http://www.advansee.com/ * Benoît Thébaudeau <benoit.thebaudeau@advansee.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * \addtogroup cc2538 * @{ * * \defgroup cc2538-rom-util cc2538 ROM utility function library * * Driver for the cc2538 ROM utility function library * @{ * * \file * Header file for the cc2538 ROM utility function library driver */ #ifndef ROM_UTIL_H_ #define ROM_UTIL_H_ #include "contiki.h" #include <stddef.h> #include <stdint.h> /*---------------------------------------------------------------------------*/ /** \name ROM utility function library API access table structure * @{ */ struct rom_util_api { /** Calculate CRC32 over a given address range */ uint32_t (*crc32)(uint8_t *data, uint32_t byte_count); /** Return the flash size */ uint32_t (*get_flash_size)(void); /** Return the chip ID */ uint32_t (*get_chip_id)(void); /** Erase flash pages */ int32_t (*page_erase)(uint32_t flash_addr, uint32_t size); /** Program the flash */ int32_t (*program_flash)(uint32_t *ram_data, uint32_t flash_addr, uint32_t byte_count); /** Perform a system reset of the SoC */ void (*reset_device)(void); /** Set a memory area to a specified value */ void *(*memset)(void *s, int c, size_t n); /** Copy data from one memory area to another */ void *(*memcpy)(void *dest, const void *src, size_t n); /** Compare two memory areas */ int (*memcmp)(const void *s1, const void *s2, size_t n); /** Move a block of data from one memory area to another */ void *(*memmove)(void *dest, const void *src, size_t n); }; /** @} */ /*---------------------------------------------------------------------------*/ /** \name Pointer to the ROM utility function library API table * @{ */ #define ROM_UTIL_API ((struct rom_util_api *)0x00000048) /** @} */ /*---------------------------------------------------------------------------*/ /** \name ROM utility function library API accessor macros * @{ */ #define rom_util_crc32(data, byte_count) \ (ROM_UTIL_API->crc32((data), (byte_count))) #define rom_util_get_flash_size() \ (ROM_UTIL_API->get_flash_size()) #define rom_util_get_chip_id() \ (ROM_UTIL_API->get_chip_id()) #define rom_util_page_erase(flash_addr, size) \ (ROM_UTIL_API->page_erase((flash_addr), (size))) #define rom_util_program_flash(ram_data, flash_addr, byte_count) \ (ROM_UTIL_API->program_flash((ram_data), (flash_addr), (byte_count))) #define rom_util_reset_device() \ (ROM_UTIL_API->reset_device()) #define rom_util_memset(s, c, n) \ (ROM_UTIL_API->memset((s), (c), (n))) #define rom_util_memcpy(dest, src, n) \ (ROM_UTIL_API->memcpy((dest), (src), (n))) #define rom_util_memcmp(s1, s2, n) \ (ROM_UTIL_API->memcmp((s1), (s2), (n))) #define rom_util_memmove(dest, src, n) \ (ROM_UTIL_API->memmove((dest), (src), (n))) /** @} */ #endif /* ROM_UTIL_H_ */ /** * @} * @} */
9c7c67e0d66f97c0a7435b614ddccb36bec9802e
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
/src/mono/mono/metadata/appdomain-icalls.h
f435007eb4216bd7b3985c48c96c3e58bacfdd9a
[ "MIT" ]
permissive
dotnet/runtime
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
47bb554d298e1e34c4e3895d7731e18ad1c47d02
refs/heads/main
2023-09-03T15:35:46.493337
2023-09-03T08:13:23
2023-09-03T08:13:23
210,716,005
13,765
5,179
MIT
2023-09-14T21:58:52
2019-09-24T23:36:39
C#
UTF-8
C
false
false
500
h
appdomain-icalls.h
/** * \file * Appdomain-related icalls. * Copyright 2016 Microsoft * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #ifndef __MONO_METADATA_APPDOMAIN_ICALLS_H__ #define __MONO_METADATA_APPDOMAIN_ICALLS_H__ #include <mono/metadata/appdomain.h> #include <mono/metadata/handle.h> #include <mono/metadata/object-internals.h> #include <mono/metadata/icalls.h> #include "reflection-internals.h" #endif /*__MONO_METADATA_APPDOMAIN_ICALLS_H__*/
907b06c0d91f2094c7fb282aa15ca8743dad0bb1
f34c3cc5ee087643bf6492afea1503b8f8440869
/board/jungle/boards/board_v1.h
8d41b94524365fb917a4716850988f006a0ec741
[ "MIT" ]
permissive
commaai/panda
24334163d7c2ee49b5baa854fe355681fd5ceaba
72f1603a89c7fecb6746d0154232f2d8187ebe70
refs/heads/master
2023-09-04T12:48:22.461254
2023-09-01T23:32:08
2023-09-01T23:32:08
87,490,037
1,493
781
MIT
2023-09-14T21:34:19
2017-04-07T01:11:08
C
UTF-8
C
false
false
4,911
h
board_v1.h
void board_v1_set_led(uint8_t color, bool enabled) { switch (color) { case LED_RED: set_gpio_output(GPIOC, 9, !enabled); break; case LED_GREEN: set_gpio_output(GPIOC, 7, !enabled); break; case LED_BLUE: set_gpio_output(GPIOC, 6, !enabled); break; default: break; } } void board_v1_enable_can_transciever(uint8_t transciever, bool enabled) { switch (transciever) { case 1U: set_gpio_output(GPIOC, 1, !enabled); break; case 2U: set_gpio_output(GPIOC, 13, !enabled); break; case 3U: set_gpio_output(GPIOA, 0, !enabled); break; case 4U: set_gpio_output(GPIOB, 10, !enabled); break; default: print("Invalid CAN transciever ("); puth(transciever); print("): enabling failed\n"); break; } } void board_v1_set_can_mode(uint8_t mode) { board_v1_enable_can_transciever(2U, false); board_v1_enable_can_transciever(4U, false); switch (mode) { case CAN_MODE_NORMAL: print("Setting normal CAN mode\n"); // B12,B13: disable OBD mode set_gpio_mode(GPIOB, 12, MODE_INPUT); set_gpio_mode(GPIOB, 13, MODE_INPUT); // B5,B6: normal CAN2 mode set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); can_mode = CAN_MODE_NORMAL; board_v1_enable_can_transciever(2U, true); break; case CAN_MODE_OBD_CAN2: print("Setting OBD CAN mode\n"); // B5,B6: disable normal CAN2 mode set_gpio_mode(GPIOB, 5, MODE_INPUT); set_gpio_mode(GPIOB, 6, MODE_INPUT); // B12,B13: OBD mode set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); can_mode = CAN_MODE_OBD_CAN2; board_v1_enable_can_transciever(4U, true); break; default: print("Tried to set unsupported CAN mode: "); puth(mode); print("\n"); break; } } void board_v1_set_harness_orientation(uint8_t orientation) { switch (orientation) { case HARNESS_ORIENTATION_NONE: set_gpio_output(GPIOA, 2, false); set_gpio_output(GPIOA, 3, false); set_gpio_output(GPIOA, 4, false); set_gpio_output(GPIOA, 5, false); harness_orientation = orientation; break; case HARNESS_ORIENTATION_1: set_gpio_output(GPIOA, 2, false); set_gpio_output(GPIOA, 3, (ignition != 0U)); set_gpio_output(GPIOA, 4, true); set_gpio_output(GPIOA, 5, false); harness_orientation = orientation; break; case HARNESS_ORIENTATION_2: set_gpio_output(GPIOA, 2, (ignition != 0U)); set_gpio_output(GPIOA, 3, false); set_gpio_output(GPIOA, 4, false); set_gpio_output(GPIOA, 5, true); harness_orientation = orientation; break; default: print("Tried to set an unsupported harness orientation: "); puth(orientation); print("\n"); break; } } bool panda_power = false; void board_v1_set_panda_power(bool enable) { panda_power = enable; set_gpio_output(GPIOB, 14, enable); } bool board_v1_get_button(void) { return get_gpio_input(GPIOC, 8); } void board_v1_set_ignition(bool enabled) { ignition = enabled ? 0xFFU : 0U; board_v1_set_harness_orientation(harness_orientation); } float board_v1_get_channel_power(uint8_t channel) { UNUSED(channel); return 0.0f; } uint16_t board_v1_get_sbu_mV(uint8_t channel, uint8_t sbu) { UNUSED(channel); UNUSED(sbu); return 0U; } void board_v1_init(void) { common_init_gpio(); // A8,A15: normal CAN3 mode set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); board_v1_set_can_mode(CAN_MODE_NORMAL); // Enable CAN transcievers for(uint8_t i = 1; i <= 4; i++) { board_v1_enable_can_transciever(i, true); } // Disable LEDs board_v1_set_led(LED_RED, false); board_v1_set_led(LED_GREEN, false); board_v1_set_led(LED_BLUE, false); // Set normal CAN mode board_v1_set_can_mode(CAN_MODE_NORMAL); // Set to no harness orientation board_v1_set_harness_orientation(HARNESS_ORIENTATION_NONE); // Enable panda power by default board_v1_set_panda_power(true); } void board_v1_tick(void) {} const board board_v1 = { .board_type = "V1", .has_canfd = false, .has_sbu_sense = false, .avdd_mV = 3300U, .init = &board_v1_init, .set_led = &board_v1_set_led, .board_tick = &board_v1_tick, .get_button = &board_v1_get_button, .set_panda_power = &board_v1_set_panda_power, .set_ignition = &board_v1_set_ignition, .set_individual_ignition = &unused_set_individual_ignition, .set_harness_orientation = &board_v1_set_harness_orientation, .set_can_mode = &board_v1_set_can_mode, .enable_can_transciever = &board_v1_enable_can_transciever, .enable_header_pin = &unused_board_enable_header_pin, .get_channel_power = &board_v1_get_channel_power, .get_sbu_mV = &board_v1_get_sbu_mV, };
7f3295b417ef3fad2de7f45de30ce102f27c656f
5741e4e7e3fedc3ae03996843b2bcfec70e17049
/c/meterpreter/source/extensions/stdapi/server/audio/output.c
e2138d1e16780747de683258bfa45607ddb63ed1
[ "BSD-3-Clause", "PSF-2.0", "Python-2.0", "Zlib", "BSD-4-Clause", "BSD-2-Clause" ]
permissive
rapid7/metasploit-payloads
5981b44a1054d307d97b9cffcdbb559bfc690625
dcaad10486e22885d0cbcbce508e3e763ce689e9
refs/heads/master
2023-09-01T01:27:12.834909
2023-07-11T13:27:41
2023-07-11T13:27:41
18,418,533
1,674
743
NOASSERTION
2023-09-14T16:58:38
2014-04-03T21:18:24
C
UTF-8
C
false
false
2,955
c
output.c
#include "precomp.h" #include "common_metapi.h" #include <sys/stat.h> /*************************** * Audio Channel Operations * ***************************/ typedef struct { size_t offset; void* buffer; } AudioContext; /* * Writes the supplied data to the audio buffer */ static DWORD audio_channel_write(Channel* channel, Packet* request, LPVOID context, LPVOID buffer, DWORD bufferSize, LPDWORD bytesWritten) { AudioContext* ctx = (AudioContext*)context; DWORD result = ERROR_SUCCESS; size_t written = 0; // Write to the buffer if (bufferSize) { char* newbuffer = 0; if (ctx->buffer) { newbuffer = realloc(ctx->buffer, ctx->offset + bufferSize); } else { newbuffer = malloc(bufferSize); } if (newbuffer) { memcpy(newbuffer + ctx->offset, buffer, bufferSize); ctx->buffer = newbuffer; ctx->offset += bufferSize; written = bufferSize; } else { result = ERROR_NOT_ENOUGH_MEMORY; } } if (bytesWritten) { *bytesWritten = (DWORD)written; } return result; } /* * Play the audio on channel close */ static DWORD audio_channel_close(Channel *channel, Packet *request, LPVOID context) { AudioContext *ctx = (AudioContext *)context; // Play the audio buffer sndPlaySound(ctx->buffer, SND_MEMORY); if (ctx->buffer) { free(ctx->buffer); ctx->buffer = 0; } free(ctx); return ERROR_SUCCESS; } /* * Handles the open request for a audio channel and returns a valid channel */ DWORD request_audio_output_channel_open(Remote *remote, Packet *packet) { Packet *response = NULL; DWORD res = ERROR_SUCCESS; DWORD flags = 0; PoolChannelOps chops = { 0 }; AudioContext *ctx; Channel *newChannel = NULL; // Allocate a response response = met_api->packet.create_response(packet); // Allocate storage for the audio buffer context if (!(ctx = calloc(1, sizeof(AudioContext)))) { res = ERROR_NOT_ENOUGH_MEMORY; goto out; } // Get the channel flags flags = met_api->packet.get_tlv_value_uint(packet, TLV_TYPE_FLAGS); memset(&chops, 0, sizeof(chops)); // Initialize the pool operation handlers chops.native.context = ctx; chops.native.write = audio_channel_write; chops.native.close = audio_channel_close; // Check the response allocation & allocate a un-connected // channel if ((!response) || (!(newChannel = met_api->channel.create_pool(0, flags, &chops)))) { res = ERROR_NOT_ENOUGH_MEMORY; goto out; } // Add the channel identifier to the response met_api->packet.add_tlv_uint(response, TLV_TYPE_CHANNEL_ID, met_api->channel.get_id(newChannel)); out: // Transmit the packet if it's valid met_api->packet.transmit_response(res, remote, response); // Clean up on failure if (res != ERROR_SUCCESS) { if (newChannel) { met_api->channel.destroy(newChannel, NULL); } } return res; }
51b1d294f91374ecc7afab9f1c686f48df44ce83
e814383d36a10839104efaa4df277996ab220fa3
/3rd-party/romio341/mpl/src/str/mpl_arg_serial.c
b0e70ca51f65ee62f8e80369b56ca18d8144ff05
[ "mpich2", "BSD-3-Clause-Open-MPI" ]
permissive
open-mpi/ompi
a1d7483ae1d83dd8fd8ae3ee95e832e0a0ee04e3
1edfdb025c4450f694600083ad871cf06c8d45cd
refs/heads/main
2023-09-01T01:30:02.040705
2023-08-29T17:32:18
2023-08-29T17:32:18
24,107,001
2,008
973
NOASSERTION
2023-09-14T20:59:26
2014-09-16T16:08:30
C
UTF-8
C
false
false
2,305
c
mpl_arg_serial.c
/* * Copyright (C) by Argonne National Laboratory * See COPYRIGHT in top-level directory */ #include "mpl.h" #include <assert.h> int MPL_args_serialize(int argc, char **argv, int *len, void **serialized_buf) { int buf_size, offset, tmp; char *buf; int i; /* * the serialized format will contain the following: * 1. An integer indicating how many arguments there are * 2. An array of integers indicating the length of each argument * 3. An array of strings with the actual arguments */ buf_size = 0; buf_size += sizeof(int); /* for the number of arguments */ buf_size += argc * sizeof(int); /* for the argument lengths */ for (i = 0; i < argc; i++) buf_size += strlen(argv[i]); /* for the arguments themselves */ buf = MPL_malloc(buf_size, MPL_MEM_STRINGS); assert(buf); offset = 0; memcpy(buf, &argc, sizeof(int)); offset += sizeof(int); for (i = 0; i < argc; i++) { tmp = strlen(argv[i]); memcpy(buf + offset, &tmp, sizeof(int)); offset += sizeof(int); } for (i = 0; i < argc; i++) { memcpy(buf + offset, argv[i], strlen(argv[i])); offset += strlen(argv[i]); } *len = buf_size; *serialized_buf = buf; return 0; } int MPL_args_deserialize(int len, const void *serialized_buf, int *argc, char ***argv) { const char *buf = serialized_buf; int nargs; int *arg_lengths; char **targv; int i; nargs = *((int *) buf); buf += sizeof(int); targv = (char **) MPL_malloc(nargs * sizeof(char *), MPL_MEM_STRINGS); arg_lengths = (int *) MPL_malloc(nargs * sizeof(int), MPL_MEM_STRINGS); assert(targv && arg_lengths); for (i = 0; i < nargs; i++) { arg_lengths[i] = (*((int *) buf)); buf += sizeof(int); /* allocate an extra end-of-string character for each string */ targv[i] = (char *) MPL_malloc(arg_lengths[i] + 1, MPL_MEM_STRINGS); assert(targv[i]); } for (i = 0; i < nargs; i++) { memcpy(targv[i], buf, arg_lengths[i]); targv[i][arg_lengths[i]] = 0; /* append an end of string character */ buf += arg_lengths[i]; } *argc = nargs; *argv = targv; MPL_free(arg_lengths); return 0; }
8c77ded1a3b0510f771a514502b7039427819804
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/components/exo/input_trace.h
d61ede321489191a9dd7538c3c328abcab8a69d3
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
607
h
input_trace.h
// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_EXO_INPUT_TRACE_H_ #define COMPONENTS_EXO_INPUT_TRACE_H_ #include "base/time/time.h" #include "ui/events/event.h" #define TRACE_EXO_INPUT_EVENT(event) \ TRACE_EVENT2("exo", "Input::OnInputEvent", "type", event->type(), \ "timestamp", \ (event->time_stamp() - base::TimeTicks()).InMicroseconds()); #endif // COMPONENTS_EXO_INPUT_TRACE_H_
24ee35c0f36b3f6f5f75539b83e9c15513060db0
aa793c2b787ff591f69147e2cc5e23d6c7b4d77e
/src/minilzlib/xzstream.h
f2278796740130abd45616f662adba8b2025c1fc
[ "MIT", "BSD-3-Clause", "OFL-1.1", "GPL-2.0-only", "CC0-1.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
AsahiLinux/m1n1
8280a8342c407936beabda0f08a700759a636b05
6d0979e71e83f47c5da5fdb8c5e21eb1268d54e8
refs/heads/main
2023-08-22T20:52:30.090704
2023-08-21T14:16:08
2023-08-21T14:16:08
329,707,886
2,966
200
MIT
2023-09-07T10:19:39
2021-01-14T18:59:03
Python
UTF-8
C
false
false
2,932
h
xzstream.h
/*++ Copyright (c) Alex Ionescu. All rights reserved. Module Name: xzstream.h Abstract: This header file contains C-style data structures and enumerations that map back to the XZ stream and file format standard, including for the decoding of Variable Length Integers (VLI). This includes definitions for the stream header, block header, index and stream footer, and associated check types. Author: Alex Ionescu (@aionescu) 15-Apr-2020 - Initial version Environment: Windows & Linux, user mode and kernel mode. --*/ #pragma once // // XZ streams encode certain numbers as "variable length integers", with 7 bits // for the data, and a high bit to encode that another byte must be consumed. // typedef uint32_t vli_type; #define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7) // // These are the possible supported types for integrity checking in an XZ file // typedef enum _XZ_CHECK_TYPES { XzCheckTypeNone = 0, XzCheckTypeCrc32 = 1, XzCheckTypeCrc64 = 4, XzCheckTypeSha2 = 10 } XZ_CHECK_TYPES; // // This describes the first 12 bytes of any XZ container file / stream // typedef struct _XZ_STREAM_HEADER { uint8_t Magic[6]; union { struct { uint8_t ReservedFlags; uint8_t CheckType : 4; uint8_t ReservedType : 4; } s; uint16_t Flags; } u; uint32_t Crc32; } XZ_STREAM_HEADER, * PXZ_STREAM_HEADER; static_assert(sizeof(XZ_STREAM_HEADER) == 12, "Invalid Stream Header Size"); // // This describes the last 12 bytes of any XZ container file / stream // typedef struct _XZ_STREAM_FOOTER { uint32_t Crc32; uint32_t BackwardSize; union { struct { uint8_t ReservedFlags; uint8_t CheckType : 4; uint8_t ReservedType : 4; } s; uint16_t Flags; } u; uint16_t Magic; } XZ_STREAM_FOOTER, * PXZ_STREAM_FOOTER; static_assert(sizeof(XZ_STREAM_FOOTER) == 12, "Invalid Stream Footer Size"); // // This describes the beginning of a compressed payload stored in an XZ stream, // with hardcoded expectations for an LZMA2-compressed payload that has 0 extra // filters (such as BCJ2). // typedef struct _XZ_BLOCK_HEADER { uint8_t Size; union { struct { uint8_t FilterCount : 2; uint8_t Reserved : 4; uint8_t HasCompressedSize : 1; uint8_t HasUncompressedSize : 1; } s; uint8_t Flags; } u; struct { uint8_t Id; uint8_t Size; union { struct { uint8_t DictionarySize : 6; uint8_t Reserved : 2; } s; uint8_t Properties; } u; } LzmaFlags; uint8_t Padding[3]; uint32_t Crc32; } XZ_BLOCK_HEADER, * PXZ_BLOCK_HEADER; static_assert(sizeof(XZ_BLOCK_HEADER) == 12, "Invalid Block Header Size");
39dbb4d567c11895974c1a291101d8abd7c1d064
b33394c69589d95e38530fa80c74cf796ba6a5af
/felix/bpf-apache/sockops.h
07fe0b1319c1b180ea9061b047d411e367574f20
[ "GPL-1.0-or-later", "GPL-2.0-only", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
projectcalico/calico
3212e99d951dd17a50d95ec585676d525eae26ec
b494be8fc7d135034a482322119d6d9f1bbf9c0f
refs/heads/master
2023-08-29T21:50:21.982251
2023-08-29T09:31:32
2023-08-29T09:31:32
63,882,194
5,115
1,407
Apache-2.0
2023-09-14T18:55:43
2016-07-21T15:45:54
Go
UTF-8
C
false
false
972
h
sockops.h
// Copyright (c) 2019 Tigera, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "bpf.h" #define ENVOY_IP 0x100007f #define ENVOY_PORT 0x993a struct sock_key { __u32 ip4; __u32 port; __u32 envoy_side; }; struct bpf_map_def __attribute__((section("maps"))) calico_sock_map = { .type = BPF_MAP_TYPE_SOCKHASH, .key_size = sizeof(struct sock_key), .value_size = sizeof(__u32), .max_entries = 65535, };
4fed606bbb7504c7c0bf2d36a14bbca5767d2cdd
f79dec3c4033ca3cbb55d8a51a748cc7b8b6fbab
/www/nvu/patches/patch-xpcom_ds_nsRefPtrHashtable.h
1f04f5195723ab970d1cf327f398857001dc43a7
[]
no_license
jsonn/pkgsrc
fb34c4a6a2d350e8e415f3c4955d4989fcd86881
c1514b5f4a3726d90e30aa16b0c209adbc276d17
refs/heads/trunk
2021-01-24T09:10:01.038867
2017-07-07T15:49:43
2017-07-07T15:49:43
2,095,004
106
47
null
2016-09-19T09:26:01
2011-07-23T23:49:04
Makefile
UTF-8
C
false
false
444
h
patch-xpcom_ds_nsRefPtrHashtable.h
$NetBSD: patch-xpcom_ds_nsRefPtrHashtable.h,v 1.1 2013/03/24 16:45:56 joerg Exp $ --- xpcom/ds/nsRefPtrHashtable.h.orig 2004-01-31 12:37:36.000000000 +0000 +++ xpcom/ds/nsRefPtrHashtable.h @@ -140,7 +140,7 @@ nsRefPtrHashtable<KeyClass,RefPtr>::GetW (KeyType aKey, PRBool* aFound) const { typename nsBaseHashtable<KeyClass, nsRefPtr<RefPtr>, RefPtr*>::EntryType* ent = - GetEntry(aKey); + this->GetEntry(aKey); if (ent) {
795b7b091c04e82a1cbd7e41e4fa0cc5222051fc
3a4f120f3211a1482b8ba826f4922fa741c5586e
/ip/Pmods/PmodCLS_v1_0/drivers/PmodCLS_v1_0/examples/main.c
ea729fbe7a8fc0355c68b5c9c810ada66622f970
[ "MIT" ]
permissive
Digilent/vivado-library
7135129c7e4fec84d17e1fe037598bd2124085eb
cbfde215a27053004cb41d85535c4a1bd1673e14
refs/heads/master
2023-09-05T22:04:31.189589
2023-08-22T17:23:00
2023-08-22T17:23:46
46,139,497
512
327
MIT
2023-08-22T17:23:47
2015-11-13T18:23:02
C
UTF-8
C
false
false
4,149
c
main.c
/******************************************************************************/ /* */ /* main.c -- PmodCLS Example Projects */ /* */ /******************************************************************************/ /* Author: Mikel Skreen */ /* */ /******************************************************************************/ /* File Description: */ /* */ /* This demo sends data through SPI to the PmodCLS. The demo alters the first */ /* string slightly so you can see that the data is changing between the */ /* different prints to the PmodCLS. Depending on the Rev of the PmodCLS the */ /* jumper configuration will be different. Make sure to refer to the */ /* Reference Manual for the correct jumper configuration. */ /* */ /******************************************************************************/ /* Revision History: */ /* */ /* 06/15/2016(MikelSkreen): Created */ /* 08/17/2017(jPeyron): Updated */ /* 11/03/2017(artvvb): 2016.4 Maintenance */ /* 02/12/2018(atangzwj): Validated for Vivado 2017.4 */ /* */ /******************************************************************************/ /* Baud Rates: */ /* */ /* Microblaze: 9600 or what was specified in UARTlite core */ /* Zynq: 115200 */ /* */ /******************************************************************************/ #include <stdio.h> #include "PmodCLS.h" #include "sleep.h" #include "string.h" #include "xil_cache.h" #include "xil_printf.h" #include "xparameters.h" void DemoInitialize(); void DemoRun(); void DemoCleanup(); void EnableCaches(); void DisableCaches(); PmodCLS myDevice; int main(void) { DemoInitialize(); DemoRun(); DemoCleanup(); return 0; } void DemoInitialize() { EnableCaches(); CLS_begin(&myDevice, XPAR_PMODCLS_0_AXI_LITE_SPI_BASEADDR); } void DemoRun() { char szInfo1[32]; char szInfo2[32]; CLS_DisplayClear(&myDevice); strcpy(szInfo1, " PmodCLS Demo"); strcpy(szInfo2, " Hello World!"); CLS_WriteStringAtPos(&myDevice, 0, 0, szInfo1); CLS_WriteStringAtPos(&myDevice, 1, 0, szInfo2); usleep(500000); while (1) { CLS_DisplayClear(&myDevice); strcpy(szInfo1, "->PmodCLS Demo<- "); CLS_WriteStringAtPos(&myDevice, 0, 0, szInfo1); CLS_WriteStringAtPos(&myDevice, 1, 0, szInfo2); usleep(500000); CLS_DisplayClear(&myDevice); strcpy(szInfo1, " PmodCLS Demo "); CLS_WriteStringAtPos(&myDevice, 0, 0, szInfo1); CLS_WriteStringAtPos(&myDevice, 1, 0, szInfo2); usleep(500000); } } void DemoCleanup() { CLS_end(&myDevice); DisableCaches(); } void EnableCaches() { #ifdef __MICROBLAZE__ #ifdef XPAR_MICROBLAZE_USE_ICACHE Xil_ICacheEnable(); #endif #ifdef XPAR_MICROBLAZE_USE_DCACHE Xil_DCacheEnable(); #endif #endif } void DisableCaches() { #ifdef __MICROBLAZE__ #ifdef XPAR_MICROBLAZE_USE_DCACHE Xil_DCacheDisable(); #endif #ifdef XPAR_MICROBLAZE_USE_ICACHE Xil_ICacheDisable(); #endif #endif }
50acd6ec3d6435b95297b41ffda1e6082ab45d29
d9cb0274eef7367641a5aa4b631c6940626638ec
/_15_Internet_Server/_15_6_setting_mime_types/main/lm75a.h
6698fb7a4fbc72ce1048d64d43b5d69c55fce824
[]
no_license
Mair/esp32-course
b1392c60c827698685f7b853899746bf33be845e
d9b1c92d6c24382a390ce89edfec000990e6832e
refs/heads/master
2023-08-30T18:40:34.341468
2023-08-27T23:40:06
2023-08-27T23:40:06
208,529,208
232
122
null
2023-08-27T23:40:07
2019-09-15T02:06:13
C
UTF-8
C
false
false
101
h
lm75a.h
#ifndef _LM75A_H #define _LM75A_H float readTemperature(); void activateLM75A(void *params); #endif
5dac011be833e3c764bba4f7162035ec63c6d55b
3afd7229cfff2da1b504cf33869f0397e7d72535
/src/wrapped/wrappedlibvadrm.c
f78b88e4671f808054006a2d8430802b49c40ac8
[ "MIT" ]
permissive
ptitSeb/box64
ed62db37d8dd328316fef259be24ff95b9d785e7
7cba83231a0ca05a18bb6a07735ba8d5f0a216b6
refs/heads/main
2023-08-31T06:25:22.053788
2023-08-30T19:53:29
2023-08-30T19:53:29
317,493,442
2,317
197
MIT
2023-09-13T13:51:23
2020-12-01T09:42:50
C
UTF-8
C
false
false
368
c
wrappedlibvadrm.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #define _GNU_SOURCE /* See feature_test_macros(7) */ #include <dlfcn.h> #include "wrappedlibs.h" #include "wrapper.h" #include "bridge.h" #include "librarian/library_private.h" #include "x64emu.h" const char* libvadrmName = "libva-drm.so.2"; #define LIBNAME libvadrm #include "wrappedlib_init.h"
c8afc58125aebcc0be2453fa650ba5513417b6fa
ea49dd7d31d2e0b65ce6aadf1274f3bb70abfaf9
/problems/0521_Longest_Uncommon_Subsequence_I/nicefuture.c
31999c3f730d047a9385362df2a370d3654873f2
[]
no_license
yychuyu/LeetCode
907a3d7d67ada9714e86103ac96422381e75d683
48384483a55e120caf5d8d353e9aa287fce3cf4a
refs/heads/master
2020-03-30T15:02:12.492378
2019-06-19T01:52:45
2019-06-19T01:52:45
151,345,944
134
331
null
2019-08-01T02:56:10
2018-10-03T01:26:28
C++
UTF-8
C
false
false
203
c
nicefuture.c
int findLUSlength(char* a, char* b) { if (strcmp(a, b) == 0) { return -1; } else { int len_a = strlen(a), len_b = strlen(b); return len_a > len_b ? len_a : len_b; } }
6e129344948e4f4be04180404cff69e2b8c4b84d
de0c523399eaf24544f7c0cbd61fe8d3c69c84f8
/test/test-uint_cases.c
bb57f40805f2450ac41328c4945b0ff04526d5f0
[ "Apache-2.0" ]
permissive
AFLplusplus/AFLplusplus
d45b697b8f2f767d29f4d886a2f9c5bd9ad6c032
11a622c63d70c9ca16c9847418b88992139aa892
refs/heads/stable
2023-09-01T16:24:45.928708
2023-08-31T12:51:42
2023-08-31T12:51:42
189,044,704
3,470
872
Apache-2.0
2023-09-13T13:56:14
2019-05-28T14:29:06
C
UTF-8
C
false
false
4,283
c
test-uint_cases.c
/* * compile with -DINT_TYPE="char" * or -DINT_TYPE="short" * or -DINT_TYPE="int" * or -DINT_TYPE="long" * or -DINT_TYPE="long long" */ #include <assert.h> int main() { volatile unsigned INT_TYPE a, b; a = 1; b = 8; assert((a < b)); assert((a <= b)); assert(!(a > b)); assert(!(a >= b)); assert((a != b)); assert(!(a == b)); if ((INT_TYPE)(~0) > 255) { volatile unsigned short a, b; a = 256 + 2; b = 256 + 21; assert((a < b)); assert((a <= b)); assert(!(a > b)); assert(!(a >= b)); assert((a != b)); assert(!(a == b)); a = 21; b = 256 + 1; assert((a < b)); assert((a <= b)); assert(!(a > b)); assert(!(a >= b)); assert((a != b)); assert(!(a == b)); if ((INT_TYPE)(~0) > 65535) { volatile unsigned int a, b; a = 65536 + 2; b = 65536 + 21; assert((a < b)); assert((a <= b)); assert(!(a > b)); assert(!(a >= b)); assert((a != b)); assert(!(a == b)); a = 21; b = 65536 + 1; assert((a < b)); assert((a <= b)); assert(!(a > b)); assert(!(a >= b)); assert((a != b)); assert(!(a == b)); } if ((INT_TYPE)(~0) > 4294967295) { volatile unsigned long a, b; a = 4294967296 + 2; b = 4294967296 + 21; assert((a < b)); assert((a <= b)); assert(!(a > b)); assert(!(a >= b)); assert((a != b)); assert(!(a == b)); a = 21; b = 4294967296 + 1; assert((a < b)); assert((a <= b)); assert(!(a > b)); assert(!(a >= b)); assert((a != b)); assert(!(a == b)); } } a = 8; b = 1; assert((a > b)); assert((a >= b)); assert(!(a < b)); assert(!(a <= b)); assert((a != b)); assert(!(a == b)); if ((INT_TYPE)(~0) > 255) { volatile unsigned short a, b; a = 256 + 2; b = 256 + 1; assert((a > b)); assert((a >= b)); assert(!(a < b)); assert(!(a <= b)); assert((a != b)); assert(!(a == b)); a = 256 + 2; b = 6; assert((a > b)); assert((a >= b)); assert(!(a < b)); assert(!(a <= b)); assert((a != b)); assert(!(a == b)); if ((INT_TYPE)(~0) > 65535) { volatile unsigned int a, b; a = 65536 + 2; b = 65536 + 1; assert((a > b)); assert((a >= b)); assert(!(a < b)); assert(!(a <= b)); assert((a != b)); assert(!(a == b)); a = 65536 + 2; b = 6; assert((a > b)); assert((a >= b)); assert(!(a < b)); assert(!(a <= b)); assert((a != b)); assert(!(a == b)); if ((INT_TYPE)(~0) > 4294967295) { volatile unsigned long a, b; a = 4294967296 + 2; b = 4294967296 + 1; assert((a > b)); assert((a >= b)); assert(!(a < b)); assert(!(a <= b)); assert((a != b)); assert(!(a == b)); a = 4294967296 + 2; b = 6; assert((a > b)); assert((a >= b)); assert(!(a < b)); assert(!(a <= b)); assert((a != b)); assert(!(a == b)); } } } a = 0; b = 0; assert(!(a < b)); assert((a <= b)); assert(!(a > b)); assert((a >= b)); assert(!(a != b)); assert((a == b)); a = 1; b = 1; assert(!(a < b)); assert((a <= b)); assert(!(a > b)); assert((a >= b)); assert(!(a != b)); assert((a == b)); if ((INT_TYPE)(~0) > 255) { volatile unsigned short a, b; a = 256 + 5; b = 256 + 5; assert(!(a < b)); assert((a <= b)); assert(!(a > b)); assert((a >= b)); assert(!(a != b)); assert((a == b)); if ((INT_TYPE)(~0) > 65535) { volatile unsigned int a, b; a = 65536 + 5; b = 65536 + 5; assert(!(a < b)); assert((a <= b)); assert(!(a > b)); assert((a >= b)); assert(!(a != b)); assert((a == b)); if ((INT_TYPE)(~0) > 4294967295) { volatile unsigned long a, b; a = 4294967296 + 5; b = 4294967296 + 5; assert(!(a < b)); assert((a <= b)); assert(!(a > b)); assert((a >= b)); assert(!(a != b)); assert((a == b)); } } } }
caf294e4fda6a241ba32a492fbdb8b1f74b78877
847ebadf2b0e7c01ad33ce92b42528a1a5c4846c
/datapath-windows/ovsext/Flow.c
86e809fc1f845839bdafceb4714cc7031937ac3b
[ "BSD-3-Clause", "ISC", "Apache-2.0", "SISSL", "GPL-2.0-only", "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
openvswitch/ovs
6f782527cf5fde4ccfd25e68d359b91ff41acf8a
bc79a7bf033fa4cda8ccfc5481db3cfccd72650c
refs/heads/master
2023-09-04T06:31:47.899017
2023-08-03T16:19:12
2023-09-01T20:15:05
18,383,364
3,366
2,259
Apache-2.0
2023-08-17T13:17:13
2014-04-02T22:15:28
C
UTF-8
C
false
false
118,134
c
Flow.c
/* * Copyright (c) 2014 VMware, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "precomp.h" #include "NetProto.h" #include "Util.h" #include "Jhash.h" #include "Flow.h" #include "PacketParser.h" #include "Datapath.h" #include "Geneve.h" #include "IpHelper.h" #include <ip2string.h> #ifdef OVS_DBG_MOD #undef OVS_DBG_MOD #endif #define OVS_DBG_MOD OVS_DBG_FLOW #include "Debug.h" #pragma warning( push ) #pragma warning( disable:4127 ) extern POVS_SWITCH_CONTEXT gOvsSwitchContext; extern UINT64 ovsTimeIncrementPerTick; static NTSTATUS ReportFlowInfo(OvsFlow *flow, UINT32 getFlags, OvsFlowInfo *info); static NTSTATUS HandleFlowPut(OvsFlowPut *put, OVS_DATAPATH *datapath, struct OvsFlowStats *stats); static NTSTATUS OvsPrepareFlow(OvsFlow **flow, const OvsFlowPut *put, UINT64 hash); static VOID RemoveFlow(OVS_DATAPATH *datapath, OvsFlow **flow); static VOID DeleteAllFlows(OVS_DATAPATH *datapath); static NTSTATUS AddFlow(OVS_DATAPATH *datapath, OvsFlow *flow); static VOID FreeFlow(OvsFlow *flow); static VOID __inline *GetStartAddrNBL(const NET_BUFFER_LIST *_pNB); static NTSTATUS _MapNlToFlowPut(POVS_MESSAGE msgIn, PNL_ATTR keyAttr, PNL_ATTR actionAttr, PNL_ATTR flowAttrClear, OvsFlowPut *mappedFlow); static VOID _MapKeyAttrToFlowPut(PNL_ATTR *keyAttrs, PNL_ATTR *tunnelAttrs, OvsFlowKey *destKey); static VOID _MapNlToFlowPutFlags(PGENL_MSG_HDR genlMsgHdr, PNL_ATTR flowAttrClear, OvsFlowPut *mappedFlow); static NTSTATUS _FlowNlGetCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, UINT32 *replyLen); static NTSTATUS _FlowNlDumpCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, UINT32 *replyLen); static NTSTATUS _MapFlowInfoToNl(PNL_BUFFER nlBuf, OvsFlowInfo *flowInfo); static NTSTATUS _MapFlowStatsToNlStats(PNL_BUFFER nlBuf, OvsFlowStats *flowStats); static NTSTATUS _MapFlowActionToNlAction(PNL_BUFFER nlBuf, uint32_t actionsLen, PNL_ATTR actions); static NTSTATUS _MapFlowIpv4KeyToNlKey(PNL_BUFFER nlBuf, IpKey *ipv4FlowPutKey); static NTSTATUS _MapFlowIpv6KeyToNlKey(PNL_BUFFER nlBuf, Ipv6Key *ipv6FlowPutKey, Icmp6Key *ipv6FlowPutIcmpKey); static NTSTATUS _MapFlowArpKeyToNlKey(PNL_BUFFER nlBuf, ArpKey *arpFlowPutKey); static NTSTATUS _MapFlowMplsKeyToNlKey(PNL_BUFFER nlBuf, MplsKey *mplsFlowPutKey); static NTSTATUS OvsDoDumpFlows(OvsFlowDumpInput *dumpInput, OvsFlowDumpOutput *dumpOutput, UINT32 *replyLen); static NTSTATUS OvsProbeSupportedFeature(POVS_MESSAGE msgIn, PNL_ATTR keyAttr); UINT16 OvsGetFlowIPL2Offset(const OvsIPTunnelKey *tunKey); #define OVS_FLOW_TABLE_SIZE 2048 #define OVS_FLOW_TABLE_MASK (OVS_FLOW_TABLE_SIZE -1) #define HASH_BUCKET(hash) ((hash) & OVS_FLOW_TABLE_MASK) /* Flow family related netlink policies */ /* For Parsing attributes in FLOW_* commands */ const NL_POLICY nlFlowPolicy[] = { [OVS_FLOW_ATTR_KEY] = {.type = NL_A_NESTED, .optional = FALSE}, [OVS_FLOW_ATTR_MASK] = {.type = NL_A_NESTED, .optional = TRUE}, [OVS_FLOW_ATTR_ACTIONS] = {.type = NL_A_NESTED, .optional = TRUE}, [OVS_FLOW_ATTR_STATS] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_flow_stats), .maxLen = sizeof(struct ovs_flow_stats), .optional = TRUE}, [OVS_FLOW_ATTR_TCP_FLAGS] = {NL_A_U8, .optional = TRUE}, [OVS_FLOW_ATTR_USED] = {NL_A_U64, .optional = TRUE}, [OVS_FLOW_ATTR_PROBE] = {.type = NL_A_FLAG, .optional = TRUE} }; /* For Parsing nested OVS_FLOW_ATTR_KEY attributes. */ const NL_POLICY nlFlowKeyPolicy[] = { [OVS_KEY_ATTR_ENCAP] = {.type = NL_A_VAR_LEN, .optional = TRUE}, [OVS_KEY_ATTR_PRIORITY] = {.type = NL_A_UNSPEC, .minLen = 4, .maxLen = 4, .optional = TRUE}, [OVS_KEY_ATTR_IN_PORT] = {.type = NL_A_UNSPEC, .minLen = 4, .maxLen = 4, .optional = TRUE}, [OVS_KEY_ATTR_ETHERNET] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_ethernet), .maxLen = sizeof(struct ovs_key_ethernet), .optional = TRUE}, [OVS_KEY_ATTR_VLAN] = {.type = NL_A_UNSPEC, .minLen = 2, .maxLen = 2, .optional = TRUE}, [OVS_KEY_ATTR_ETHERTYPE] = {.type = NL_A_UNSPEC, .minLen = 2, .maxLen = 2, .optional = TRUE}, [OVS_KEY_ATTR_IPV4] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_ipv4), .maxLen = sizeof(struct ovs_key_ipv4), .optional = TRUE}, [OVS_KEY_ATTR_IPV6] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_ipv6), .maxLen = sizeof(struct ovs_key_ipv6), .optional = TRUE}, [OVS_KEY_ATTR_TCP] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_tcp), .maxLen = sizeof(struct ovs_key_tcp), .optional = TRUE}, [OVS_KEY_ATTR_UDP] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_udp), .maxLen = sizeof(struct ovs_key_udp), .optional = TRUE}, [OVS_KEY_ATTR_ICMP] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_icmp), .maxLen = sizeof(struct ovs_key_icmp), .optional = TRUE}, [OVS_KEY_ATTR_ICMPV6] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_icmpv6), .maxLen = sizeof(struct ovs_key_icmpv6), .optional = TRUE}, [OVS_KEY_ATTR_ARP] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_arp), .maxLen = sizeof(struct ovs_key_arp), .optional = TRUE}, [OVS_KEY_ATTR_ND] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_nd), .maxLen = sizeof(struct ovs_key_nd), .optional = TRUE}, [OVS_KEY_ATTR_SKB_MARK] = {.type = NL_A_UNSPEC, .minLen = 4, .maxLen = 4, .optional = TRUE}, [OVS_KEY_ATTR_TUNNEL] = {.type = NL_A_VAR_LEN, .optional = TRUE}, [OVS_KEY_ATTR_SCTP] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_sctp), .maxLen = sizeof(struct ovs_key_sctp), .optional = TRUE}, [OVS_KEY_ATTR_TCP_FLAGS] = {.type = NL_A_UNSPEC, .minLen = 2, .maxLen = 2, .optional = TRUE}, [OVS_KEY_ATTR_DP_HASH] = {.type = NL_A_UNSPEC, .minLen = 4, .maxLen = 4, .optional = TRUE}, [OVS_KEY_ATTR_RECIRC_ID] = {.type = NL_A_UNSPEC, .minLen = 4, .maxLen = 4, .optional = TRUE}, [OVS_KEY_ATTR_MPLS] = {.type = NL_A_VAR_LEN, .optional = TRUE}, [OVS_KEY_ATTR_CT_STATE] = {.type = NL_A_UNSPEC, .minLen = 4, .maxLen = 4, .optional = TRUE}, [OVS_KEY_ATTR_CT_ZONE] = {.type = NL_A_UNSPEC, .minLen = 2, .maxLen = 2, .optional = TRUE}, [OVS_KEY_ATTR_CT_MARK] = {.type = NL_A_UNSPEC, .minLen = 4, .maxLen = 4, .optional = TRUE}, [OVS_KEY_ATTR_CT_LABELS] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_ct_labels), .maxLen = sizeof(struct ovs_key_ct_labels), .optional = TRUE}, [OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_key_ct_tuple_ipv4), .maxLen = sizeof(struct ovs_key_ct_tuple_ipv4), .optional = TRUE}, [OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6] = {.type = NL_A_UNSPEC, .minLen = OVS_TUPLE_IPV6, .maxLen = OVS_TUPLE_IPV6, .optional = TRUE} }; const UINT32 nlFlowKeyPolicyLen = ARRAY_SIZE(nlFlowKeyPolicy); /* For Parsing nested OVS_KEY_ATTR_TUNNEL attributes */ const NL_POLICY nlFlowTunnelKeyPolicy[] = { [OVS_TUNNEL_KEY_ATTR_ID] = {.type = NL_A_UNSPEC, .minLen = 8, .maxLen = 8, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_IPV4_SRC] = {.type = NL_A_UNSPEC, .minLen = 4, .maxLen = 4, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_IPV4_DST] = {.type = NL_A_UNSPEC, .minLen = 4 , .maxLen = 4, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_IPV6_DST] = {.type = NL_A_UNSPEC, .minLen = 16, .maxLen = 16, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_IPV6_SRC] = {.type = NL_A_UNSPEC, .minLen = 16, .maxLen = 16, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_TOS] = {.type = NL_A_UNSPEC, .minLen = 1, .maxLen = 1, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_TTL] = {.type = NL_A_UNSPEC, .minLen = 1, .maxLen = 1, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT] = {.type = NL_A_UNSPEC, .minLen = 0, .maxLen = 0, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_CSUM] = {.type = NL_A_UNSPEC, .minLen = 0, .maxLen = 0, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_OAM] = {.type = NL_A_UNSPEC, .minLen = 0, .maxLen = 0, .optional = TRUE}, [OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS] = {.type = NL_A_VAR_LEN, .optional = TRUE} }; const UINT32 nlFlowTunnelKeyPolicyLen = ARRAY_SIZE(nlFlowTunnelKeyPolicy); /* For Parsing nested OVS_FLOW_ATTR_ACTIONS attributes */ const NL_POLICY nlFlowActionPolicy[] = { [OVS_ACTION_ATTR_OUTPUT] = {.type = NL_A_UNSPEC, .minLen = sizeof(UINT32), .maxLen = sizeof(UINT32), .optional = TRUE}, [OVS_ACTION_ATTR_USERSPACE] = {.type = NL_A_VAR_LEN, .optional = TRUE}, [OVS_ACTION_ATTR_PUSH_VLAN] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_action_push_vlan), .maxLen = sizeof(struct ovs_action_push_vlan), .optional = TRUE}, [OVS_ACTION_ATTR_POP_VLAN] = {.type = NL_A_UNSPEC, .optional = TRUE}, [OVS_ACTION_ATTR_PUSH_MPLS] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_action_push_mpls), .maxLen = sizeof(struct ovs_action_push_mpls), .optional = TRUE}, [OVS_ACTION_ATTR_POP_MPLS] = {.type = NL_A_UNSPEC, .minLen = sizeof(UINT16), .maxLen = sizeof(UINT16), .optional = TRUE}, [OVS_ACTION_ATTR_RECIRC] = {.type = NL_A_UNSPEC, .minLen = sizeof(UINT32), .maxLen = sizeof(UINT32), .optional = TRUE}, [OVS_ACTION_ATTR_HASH] = {.type = NL_A_UNSPEC, .minLen = sizeof(struct ovs_action_hash), .maxLen = sizeof(struct ovs_action_hash), .optional = TRUE}, [OVS_ACTION_ATTR_SET] = {.type = NL_A_VAR_LEN, .optional = TRUE}, [OVS_ACTION_ATTR_SAMPLE] = {.type = NL_A_VAR_LEN, .optional = TRUE}, [OVS_ACTION_ATTR_CT] = {.type = NL_A_VAR_LEN, .optional = TRUE} }; /* *---------------------------------------------------------------------------- * Netlink interface for flow commands. *---------------------------------------------------------------------------- */ /* *---------------------------------------------------------------------------- * OvsFlowNewCmdHandler -- * Handler for OVS_FLOW_CMD_NEW/SET/DEL command. * It also handles FLUSH case (DEL w/o any key in input) *---------------------------------------------------------------------------- */ NTSTATUS OvsFlowNlCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, UINT32 *replyLen) { NTSTATUS rc = STATUS_SUCCESS; BOOLEAN ok = FALSE; POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer; POVS_MESSAGE msgOut = (POVS_MESSAGE)usrParamsCtx->outputBuffer; PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg); PGENL_MSG_HDR genlMsgHdr = &(msgIn->genlMsg); POVS_HDR ovsHdr = &(msgIn->ovsHdr); PNL_ATTR flowAttrs[__OVS_FLOW_ATTR_MAX]; UINT32 attrOffset = NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN; OvsFlowPut mappedFlow; OvsFlowStats stats; struct ovs_flow_stats replyStats; NL_ERROR nlError = NL_ERROR_SUCCESS; NL_BUFFER nlBuf; RtlZeroMemory(&mappedFlow, sizeof(OvsFlowPut)); RtlZeroMemory(&stats, sizeof(stats)); RtlZeroMemory(&replyStats, sizeof(replyStats)); if (!(usrParamsCtx->outputBuffer)) { /* No output buffer */ rc = STATUS_INVALID_BUFFER_SIZE; goto done; } /* FLOW_DEL command w/o any key input is a flush case. If we don't have any attr, we treat this as a flush command*/ if ((genlMsgHdr->cmd == OVS_FLOW_CMD_DEL) && (!NlMsgAttrsLen(nlMsgHdr))) { rc = OvsFlushFlowIoctl(ovsHdr->dp_ifindex); if (rc == STATUS_SUCCESS) { /* XXX: refactor this code. */ /* So far so good. Prepare the reply for userspace */ NlBufInit(&nlBuf, usrParamsCtx->outputBuffer, usrParamsCtx->outputLength); /* Prepare nl Msg headers */ ok = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, 0, nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid, genlMsgHdr->cmd, OVS_FLOW_VERSION, ovsHdr->dp_ifindex); if (ok) { *replyLen = msgOut->nlMsg.nlmsgLen; } else { rc = STATUS_INVALID_BUFFER_SIZE; } } goto done; } /* Get all the top level Flow attributes */ if ((NlAttrParse(nlMsgHdr, attrOffset, NlMsgAttrsLen(nlMsgHdr), nlFlowPolicy, ARRAY_SIZE(nlFlowPolicy), flowAttrs, ARRAY_SIZE(flowAttrs))) != TRUE) { OVS_LOG_ERROR("Attr Parsing failed for msg: %p", nlMsgHdr); rc = STATUS_INVALID_PARAMETER; goto done; } if (flowAttrs[OVS_FLOW_ATTR_PROBE]) { rc = OvsProbeSupportedFeature(msgIn, flowAttrs[OVS_FLOW_ATTR_KEY]); if (rc != STATUS_SUCCESS) { nlError = NlMapStatusToNlErr(rc); goto done; } } if ((rc = _MapNlToFlowPut(msgIn, flowAttrs[OVS_FLOW_ATTR_KEY], flowAttrs[OVS_FLOW_ATTR_ACTIONS], flowAttrs[OVS_FLOW_ATTR_CLEAR], &mappedFlow)) != STATUS_SUCCESS) { OVS_LOG_ERROR("Conversion to OvsFlowPut failed"); goto done; } rc = OvsPutFlowIoctl(&mappedFlow, sizeof (struct OvsFlowPut), &stats); if (rc != STATUS_SUCCESS) { OVS_LOG_ERROR("OvsPutFlowIoctl failed."); /* * Report back to the userspace the flow could not be modified, * created or deleted */ nlError = NL_ERROR_NOENT; if (rc == STATUS_DUPLICATE_NAME) { nlError = NL_ERROR_EXIST; } goto done; } replyStats.n_packets = stats.packetCount; replyStats.n_bytes = stats.byteCount; /* So far so good. Prepare the reply for userspace */ NlBufInit(&nlBuf, usrParamsCtx->outputBuffer, usrParamsCtx->outputLength); /* Prepare nl Msg headers */ ok = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, 0, nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid, genlMsgHdr->cmd, OVS_FLOW_VERSION, ovsHdr->dp_ifindex); if (!ok) { rc = STATUS_INVALID_BUFFER_SIZE; goto done; } else { rc = STATUS_SUCCESS; } /* Append OVS_FLOW_ATTR_KEY attribute. This is need i.e. for flow delete*/ if (!NlMsgPutNested(&nlBuf, OVS_FLOW_ATTR_KEY, NlAttrData(flowAttrs[OVS_FLOW_ATTR_KEY]), NlAttrGetSize(flowAttrs[OVS_FLOW_ATTR_KEY]))) { OVS_LOG_ERROR("Adding OVS_FLOW_ATTR_KEY attribute failed."); rc = STATUS_INVALID_BUFFER_SIZE; goto done; } /* Append OVS_FLOW_ATTR_STATS attribute */ if (!NlMsgPutTailUnspec(&nlBuf, OVS_FLOW_ATTR_STATS, (PCHAR)(&replyStats), sizeof(replyStats))) { OVS_LOG_ERROR("Adding OVS_FLOW_ATTR_STATS attribute failed."); rc = STATUS_INVALID_BUFFER_SIZE; goto done; } msgOut->nlMsg.nlmsgLen = NLMSG_ALIGN(NlBufSize(&nlBuf)); *replyLen = msgOut->nlMsg.nlmsgLen; done: if (nlError != NL_ERROR_SUCCESS) { POVS_MESSAGE_ERROR msgError = (POVS_MESSAGE_ERROR) usrParamsCtx->outputBuffer; ASSERT(msgError); NlBuildErrorMsg(msgIn, msgError, nlError, replyLen); ASSERT(*replyLen != 0); rc = STATUS_SUCCESS; } return rc; } /* *---------------------------------------------------------------------------- * OvsFlowNlGetCmdHandler -- * Handler for OVS_FLOW_CMD_GET/DUMP commands. *---------------------------------------------------------------------------- */ NTSTATUS OvsFlowNlGetCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, UINT32 *replyLen) { NTSTATUS status = STATUS_SUCCESS; if (usrParamsCtx->devOp == OVS_TRANSACTION_DEV_OP) { status = _FlowNlGetCmdHandler(usrParamsCtx, replyLen); } else { status = _FlowNlDumpCmdHandler(usrParamsCtx, replyLen); } return status; } /* *---------------------------------------------------------------------------- * _FlowNlGetCmdHandler -- * Handler for OVS_FLOW_CMD_GET command. *---------------------------------------------------------------------------- */ NTSTATUS _FlowNlGetCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, UINT32 *replyLen) { NTSTATUS rc = STATUS_SUCCESS; POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer; PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg); POVS_HDR ovsHdr = &(msgIn->ovsHdr); PNL_MSG_HDR nlMsgOutHdr = NULL; UINT32 attrOffset = NLMSG_HDRLEN + GENL_HDRLEN + OVS_HDRLEN; PNL_ATTR nlAttrs[__OVS_FLOW_ATTR_MAX]; OvsFlowGetInput getInput; OvsFlowGetOutput getOutput; NL_BUFFER nlBuf; PNL_ATTR keyAttrs[__OVS_KEY_ATTR_MAX]; PNL_ATTR tunnelAttrs[__OVS_TUNNEL_KEY_ATTR_MAX]; PNL_ATTR encapAttrs[__OVS_KEY_ATTR_MAX]; NlBufInit(&nlBuf, usrParamsCtx->outputBuffer, usrParamsCtx->outputLength); RtlZeroMemory(&getInput, sizeof(OvsFlowGetInput)); RtlZeroMemory(&getOutput, sizeof(OvsFlowGetOutput)); UINT32 keyAttrOffset = 0; UINT32 tunnelKeyAttrOffset = 0; UINT32 encapOffset = 0; BOOLEAN ok; NL_ERROR nlError = NL_ERROR_SUCCESS; if (usrParamsCtx->inputLength > usrParamsCtx->outputLength) { /* Should not be the case. * We'll be copying the flow keys back from * input buffer to output buffer. */ rc = STATUS_INVALID_PARAMETER; OVS_LOG_ERROR("inputLength: %d GREATER THEN outputLength: %d", usrParamsCtx->inputLength, usrParamsCtx->outputLength); goto done; } /* Get all the top level Flow attributes */ if ((NlAttrParse(nlMsgHdr, attrOffset, NlMsgAttrsLen(nlMsgHdr), nlFlowPolicy, ARRAY_SIZE(nlFlowPolicy), nlAttrs, ARRAY_SIZE(nlAttrs))) != TRUE) { OVS_LOG_ERROR("Attr Parsing failed for msg: %p", nlMsgHdr); rc = STATUS_INVALID_PARAMETER; goto done; } keyAttrOffset = (UINT32)((PCHAR) nlAttrs[OVS_FLOW_ATTR_KEY] - (PCHAR)nlMsgHdr); /* Get flow keys attributes */ if ((NlAttrParseNested(nlMsgHdr, keyAttrOffset, NlAttrLen(nlAttrs[OVS_FLOW_ATTR_KEY]), nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy), keyAttrs, ARRAY_SIZE(keyAttrs))) != TRUE) { OVS_LOG_ERROR("Key Attr Parsing failed for msg: %p", nlMsgHdr); rc = STATUS_INVALID_PARAMETER; goto done; } if (keyAttrs[OVS_KEY_ATTR_ENCAP]) { encapOffset = (UINT32)((PCHAR) (keyAttrs[OVS_KEY_ATTR_ENCAP]) - (PCHAR)nlMsgHdr); if ((NlAttrParseNested(nlMsgHdr, encapOffset, NlAttrLen(keyAttrs[OVS_KEY_ATTR_ENCAP]), nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy), encapAttrs, ARRAY_SIZE(encapAttrs))) != TRUE) { OVS_LOG_ERROR("Encap Key Attr Parsing failed for msg: %p", nlMsgHdr); rc = STATUS_INVALID_PARAMETER; goto done; } } if (keyAttrs[OVS_KEY_ATTR_TUNNEL]) { tunnelKeyAttrOffset = (UINT32)((PCHAR) (keyAttrs[OVS_KEY_ATTR_TUNNEL]) - (PCHAR)nlMsgHdr); /* Get tunnel keys attributes */ if ((NlAttrParseNested(nlMsgHdr, tunnelKeyAttrOffset, NlAttrLen(keyAttrs[OVS_KEY_ATTR_TUNNEL]), nlFlowTunnelKeyPolicy, ARRAY_SIZE(nlFlowTunnelKeyPolicy), tunnelAttrs, ARRAY_SIZE(tunnelAttrs))) != TRUE) { OVS_LOG_ERROR("Tunnel key Attr Parsing failed for msg: %p", nlMsgHdr); rc = STATUS_INVALID_PARAMETER; goto done; } } _MapKeyAttrToFlowPut(keyAttrs, tunnelAttrs, &(getInput.key)); ASSERT(keyAttrs[OVS_KEY_ATTR_IN_PORT]); if (encapOffset) { _MapKeyAttrToFlowPut(encapAttrs, tunnelAttrs, &(getInput.key)); } getInput.dpNo = ovsHdr->dp_ifindex; getInput.getFlags = FLOW_GET_STATS | FLOW_GET_ACTIONS; /* 4th argument is a no op. * We are keeping this argument to be compatible * with our dpif-windows based interface. */ rc = OvsGetFlowIoctl(&getInput, &getOutput); if (rc != STATUS_SUCCESS) { OVS_LOG_ERROR("OvsGetFlowIoctl failed."); /* * Report back to the userspace the flow could not be found */ nlError = NL_ERROR_NOENT; goto done; } /* Lets prepare the reply. */ nlMsgOutHdr = (PNL_MSG_HDR)(NlBufAt(&nlBuf, 0, 0)); /* Input already has all the attributes for the flow key. * Lets copy the values back. */ ok = NlMsgPutTail(&nlBuf, (PCHAR)(usrParamsCtx->inputBuffer), usrParamsCtx->inputLength); if (!ok) { OVS_LOG_ERROR("Could not copy the data to the buffer tail"); goto done; } rc = _MapFlowStatsToNlStats(&nlBuf, &((getOutput.info).stats)); if (rc != STATUS_SUCCESS) { OVS_LOG_ERROR("_OvsFlowMapFlowKeyToNlStats failed."); goto done; } rc = _MapFlowActionToNlAction(&nlBuf, ((getOutput.info).actionsLen), getOutput.info.actions); if (rc != STATUS_SUCCESS) { OVS_LOG_ERROR("_MapFlowActionToNlAction failed."); goto done; } NlMsgSetSize(nlMsgOutHdr, NlBufSize(&nlBuf)); NlMsgAlignSize(nlMsgOutHdr); *replyLen += NlMsgSize(nlMsgOutHdr); done: if (nlError != NL_ERROR_SUCCESS) { POVS_MESSAGE_ERROR msgError = (POVS_MESSAGE_ERROR) usrParamsCtx->outputBuffer; ASSERT(msgError); NlBuildErrorMsg(msgIn, msgError, nlError, replyLen); ASSERT(*replyLen != 0); rc = STATUS_SUCCESS; } return rc; } /* *---------------------------------------------------------------------------- * _FlowNlDumpCmdHandler -- * Handler for OVS_FLOW_CMD_DUMP command. *---------------------------------------------------------------------------- */ NTSTATUS _FlowNlDumpCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, UINT32 *replyLen) { NTSTATUS rc = STATUS_SUCCESS; UINT32 temp = 0; /* To keep compiler happy for calling OvsDoDumpFlows */ NL_ERROR nlError = NL_ERROR_SUCCESS; POVS_OPEN_INSTANCE instance = (POVS_OPEN_INSTANCE) (usrParamsCtx->ovsInstance); POVS_MESSAGE msgIn = instance->dumpState.ovsMsg; if (usrParamsCtx->devOp == OVS_WRITE_DEV_OP) { /* Dump Start */ OvsSetupDumpStart(usrParamsCtx); goto done; } PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg); PGENL_MSG_HDR genlMsgHdr = &(msgIn->genlMsg); POVS_HDR ovsHdr = &(msgIn->ovsHdr); PNL_MSG_HDR nlMsgOutHdr = NULL; UINT32 hdrOffset = 0; /* Get Next */ OvsFlowDumpOutput dumpOutput; OvsFlowDumpInput dumpInput; NL_BUFFER nlBuf; NlBufInit(&nlBuf, usrParamsCtx->outputBuffer, usrParamsCtx->outputLength); ASSERT(usrParamsCtx->devOp == OVS_READ_DEV_OP); ASSERT(usrParamsCtx->outputLength); RtlZeroMemory(&dumpInput, sizeof(OvsFlowDumpInput)); RtlZeroMemory(&dumpOutput, sizeof(OvsFlowDumpOutput)); dumpInput.dpNo = ovsHdr->dp_ifindex; dumpInput.getFlags = FLOW_GET_KEY | FLOW_GET_STATS | FLOW_GET_ACTIONS; /* Lets provide as many flows to userspace as possible. */ do { dumpInput.position[0] = instance->dumpState.index[0]; dumpInput.position[1] = instance->dumpState.index[1]; rc = OvsDoDumpFlows(&dumpInput, &dumpOutput, &temp); if (rc != STATUS_SUCCESS) { OVS_LOG_ERROR("OvsDoDumpFlows failed with rc: %d", rc); /* * Report back to the userspace the flows could not be found */ nlError = NL_ERROR_NOENT; break; } /* Done with Dump, send NLMSG_DONE */ if (!(dumpOutput.n)) { BOOLEAN ok; OVS_LOG_INFO("Dump Done"); nlMsgOutHdr = (PNL_MSG_HDR)(NlBufAt(&nlBuf, NlBufSize(&nlBuf), 0)); ok = NlFillNlHdr(&nlBuf, NLMSG_DONE, NLM_F_MULTI, nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid); if (!ok) { rc = STATUS_INVALID_BUFFER_SIZE; OVS_LOG_ERROR("Unable to prepare DUMP_DONE reply."); break; } else { rc = STATUS_SUCCESS; } NlMsgAlignSize(nlMsgOutHdr); *replyLen += NlMsgSize(nlMsgOutHdr); FreeUserDumpState(instance); break; } else { BOOLEAN ok; hdrOffset = NlBufSize(&nlBuf); nlMsgOutHdr = (PNL_MSG_HDR)(NlBufAt(&nlBuf, hdrOffset, 0)); /* Netlink header */ ok = NlFillOvsMsg(&nlBuf, nlMsgHdr->nlmsgType, NLM_F_MULTI, nlMsgHdr->nlmsgSeq, nlMsgHdr->nlmsgPid, genlMsgHdr->cmd, genlMsgHdr->version, ovsHdr->dp_ifindex); if (!ok) { /* Reset rc to success so that we can * send already added messages to user space. */ rc = STATUS_SUCCESS; break; } /* Time to add attributes */ rc = _MapFlowInfoToNl(&nlBuf, &(dumpOutput.flow)); if (rc != STATUS_SUCCESS) { /* Adding the attribute failed, we are out of space in the buffer, remove the appended OVS header */ NlMsgSetSize(nlMsgOutHdr, NlMsgSize(nlMsgOutHdr) - sizeof(struct _OVS_MESSAGE)); /* Reset rc to success so that we can * send already added messages to user space. */ rc = STATUS_SUCCESS; break; } NlMsgSetSize(nlMsgOutHdr, NlBufSize(&nlBuf) - hdrOffset); NlMsgAlignSize(nlMsgOutHdr); *replyLen += NlMsgSize(nlMsgOutHdr); instance->dumpState.index[0] = dumpOutput.position[0]; instance->dumpState.index[1] = dumpOutput.position[1]; } } while(TRUE); done: if (nlError != NL_ERROR_SUCCESS) { POVS_MESSAGE_ERROR msgError = (POVS_MESSAGE_ERROR) usrParamsCtx->outputBuffer; ASSERT(msgError); NlBuildErrorMsg(msgIn, msgError, nlError, replyLen); ASSERT(*replyLen != 0); rc = STATUS_SUCCESS; } return rc; } /* *---------------------------------------------------------------------------- * _MapFlowInfoToNl -- * Maps OvsFlowInfo to Netlink attributes. *---------------------------------------------------------------------------- */ static NTSTATUS _MapFlowInfoToNl(PNL_BUFFER nlBuf, OvsFlowInfo *flowInfo) { NTSTATUS rc; rc = MapFlowKeyToNlKey(nlBuf, &(flowInfo->key), OVS_FLOW_ATTR_KEY, OVS_KEY_ATTR_TUNNEL); if (rc != STATUS_SUCCESS) { goto done; } rc = _MapFlowStatsToNlStats(nlBuf, &(flowInfo->stats)); if (rc != STATUS_SUCCESS) { goto done; } rc = _MapFlowActionToNlAction(nlBuf, flowInfo->actionsLen, flowInfo->actions); if (rc != STATUS_SUCCESS) { goto done; } done: return rc; } UINT64 OvsFlowUsedTime(UINT64 flowUsed) { UINT64 currentMs, iddleMs; LARGE_INTEGER tickCount; KeQueryTickCount(&tickCount); iddleMs = tickCount.QuadPart - flowUsed; iddleMs *= ovsTimeIncrementPerTick; currentMs = KeQueryPerformanceCounter(&tickCount).QuadPart * 1000 / tickCount.QuadPart; return currentMs - iddleMs; } /* *---------------------------------------------------------------------------- * _MapFlowStatsToNlStats -- * Maps OvsFlowStats to OVS_FLOW_ATTR_STATS attribute. *---------------------------------------------------------------------------- */ static NTSTATUS _MapFlowStatsToNlStats(PNL_BUFFER nlBuf, OvsFlowStats *flowStats) { NTSTATUS rc = STATUS_SUCCESS; struct ovs_flow_stats replyStats; replyStats.n_packets = flowStats->packetCount; replyStats.n_bytes = flowStats->byteCount; if (flowStats->used && !NlMsgPutTailU64(nlBuf, OVS_FLOW_ATTR_USED, OvsFlowUsedTime(flowStats->used)) ) { rc = STATUS_INVALID_BUFFER_SIZE; goto done; } if (!NlMsgPutTailUnspec(nlBuf, OVS_FLOW_ATTR_STATS, (PCHAR)(&replyStats), sizeof(struct ovs_flow_stats))) { rc = STATUS_INVALID_BUFFER_SIZE; goto done; } if (!NlMsgPutTailU8(nlBuf, OVS_FLOW_ATTR_TCP_FLAGS, flowStats->tcpFlags)) { rc = STATUS_INVALID_BUFFER_SIZE; goto done; } done: return rc; } /* *---------------------------------------------------------------------------- * _MapFlowActionToNlAction -- * Maps flow actions to OVS_FLOW_ATTR_ACTION attribute. *---------------------------------------------------------------------------- */ static NTSTATUS _MapFlowActionToNlAction(PNL_BUFFER nlBuf, uint32_t actionsLen, PNL_ATTR actions) { NTSTATUS rc = STATUS_SUCCESS; UINT32 offset = 0; offset = NlMsgStartNested(nlBuf, OVS_FLOW_ATTR_ACTIONS); if (!offset) { /* Starting the nested attribute failed. */ rc = STATUS_INVALID_BUFFER_SIZE; goto error_nested_start; } if (!NlBufCopyAtTail(nlBuf, (PCHAR)actions, actionsLen)) { /* Adding a nested attribute failed. */ rc = STATUS_INVALID_BUFFER_SIZE; goto done; } done: NlMsgEndNested(nlBuf, offset); error_nested_start: return rc; } /* *---------------------------------------------------------------------------- * MapFlowKeyToNlKey -- * Maps OvsFlowKey to OVS_FLOW_ATTR_KEY attribute. *---------------------------------------------------------------------------- */ NTSTATUS MapFlowKeyToNlKey(PNL_BUFFER nlBuf, OvsFlowKey *flowKey, UINT16 keyType, UINT16 tunKeyType) { NTSTATUS rc = STATUS_SUCCESS; struct ovs_key_ethernet ethKey; UINT32 offset = 0, encap_offset = 0; offset = NlMsgStartNested(nlBuf, keyType); if (!offset) { /* Starting the nested attribute failed. */ rc = STATUS_UNSUCCESSFUL; goto error_nested_start; } if (!NlMsgPutTailU32(nlBuf, OVS_KEY_ATTR_RECIRC_ID, flowKey->recircId)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailU32(nlBuf, OVS_KEY_ATTR_CT_STATE, flowKey->ct.state)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailU16(nlBuf, OVS_KEY_ATTR_CT_ZONE, flowKey->ct.zone)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailU32(nlBuf, OVS_KEY_ATTR_CT_MARK, flowKey->ct.mark)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_CT_LABELS, (PCHAR)(&flowKey->ct.labels), sizeof(struct ovs_key_ct_labels))) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4, (PCHAR)(&flowKey->ct.tuple_ipv4), sizeof(struct ovs_key_ct_tuple_ipv4))) { rc = STATUS_UNSUCCESSFUL; goto done; } if (flowKey->dpHash) { if (!NlMsgPutTailU32(nlBuf, OVS_KEY_ATTR_DP_HASH, flowKey->dpHash)) { rc = STATUS_UNSUCCESSFUL; goto done; } } /* Ethernet header */ RtlCopyMemory(&(ethKey.eth_src), flowKey->l2.dlSrc, ETH_ADDR_LEN); RtlCopyMemory(&(ethKey.eth_dst), flowKey->l2.dlDst, ETH_ADDR_LEN); if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_ETHERNET, (PCHAR)(&ethKey), sizeof(struct ovs_key_ethernet))) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailU32(nlBuf, OVS_KEY_ATTR_IN_PORT, flowKey->l2.inPort)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailU16(nlBuf, OVS_KEY_ATTR_ETHERTYPE, flowKey->l2.vlanKey.vlanTci == 0 ? flowKey->l2.dlType : flowKey->l2.vlanKey.vlanTpid)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (flowKey->l2.vlanKey.vlanTci || flowKey->l2.dlType == ETH_TYPE_802_1PQ) { if (!NlMsgPutTailU16(nlBuf, OVS_KEY_ATTR_VLAN, flowKey->l2.vlanKey.vlanTci)) { rc = STATUS_UNSUCCESSFUL; goto done; } /* Add encap attributes. */ encap_offset = NlMsgStartNested(nlBuf, OVS_KEY_ATTR_ENCAP); if (!encap_offset) { /* Starting the nested attribute failed. */ rc = STATUS_UNSUCCESSFUL; goto done; } /* Add packet Ethernet Type*/ if (!NlMsgPutTailU16(nlBuf, OVS_KEY_ATTR_ETHERTYPE, flowKey->l2.dlType)) { rc = STATUS_UNSUCCESSFUL; goto encap; } } /* ==== L3 + L4 ==== */ switch (ntohs(flowKey->l2.dlType)) { case ETH_TYPE_IPV4: { IpKey *ipv4FlowPutKey = &(flowKey->ipKey); rc = _MapFlowIpv4KeyToNlKey(nlBuf, ipv4FlowPutKey); break; } case ETH_TYPE_IPV6: { Ipv6Key *ipv6FlowPutKey = &(flowKey->ipv6Key); Icmp6Key *icmpv6FlowPutKey = &(flowKey->icmp6Key); rc = _MapFlowIpv6KeyToNlKey(nlBuf, ipv6FlowPutKey, icmpv6FlowPutKey); break; } case ETH_TYPE_ARP: case ETH_TYPE_RARP: { ArpKey *arpFlowPutKey = &(flowKey->arpKey); rc = _MapFlowArpKeyToNlKey(nlBuf, arpFlowPutKey); break; } case ETH_TYPE_MPLS: case ETH_TYPE_MPLS_MCAST: { MplsKey *mplsFlowPutKey = &(flowKey->mplsKey); rc = _MapFlowMplsKeyToNlKey(nlBuf, mplsFlowPutKey); break; } default: break; } if (rc != STATUS_SUCCESS) { goto done; } if (!OvsIphIsZero(&(flowKey->tunKey.dst))) { rc = MapFlowTunKeyToNlKey(nlBuf, &(flowKey->tunKey), tunKeyType); if (rc != STATUS_SUCCESS) { goto done; } } encap: if (encap_offset) { NlMsgEndNested(nlBuf, encap_offset); } done: NlMsgEndNested(nlBuf, offset); error_nested_start: return rc; } /* *---------------------------------------------------------------------------- * MapFlowTunKeyToNlKey -- * Maps OvsIPTunnelKey to OVS_TUNNEL_KEY_ATTR_ID attribute. *---------------------------------------------------------------------------- */ NTSTATUS MapFlowTunKeyToNlKey(PNL_BUFFER nlBuf, OvsIPTunnelKey*tunKey, UINT16 tunKeyType) { NTSTATUS rc = STATUS_SUCCESS; UINT32 offset = 0; offset = NlMsgStartNested(nlBuf, tunKeyType); if (!offset) { /* Starting the nested attribute failed. */ rc = STATUS_UNSUCCESSFUL; goto error_nested_start; } if (!NlMsgPutTailU64(nlBuf, OVS_TUNNEL_KEY_ATTR_ID, tunKey->tunnelId)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!OvsIphIsZero(&tunKey->dst)) { if (tunKey->dst.si_family == AF_INET) { if (!NlMsgPutTailU32(nlBuf, OVS_TUNNEL_KEY_ATTR_IPV4_DST, tunKey->dst.Ipv4.sin_addr.s_addr)) { rc = STATUS_UNSUCCESSFUL; goto done; } } else if (tunKey->dst.si_family == AF_INET6) { if (!NlMsgPutTailUnspec(nlBuf, OVS_TUNNEL_KEY_ATTR_IPV6_DST, (PCHAR)&tunKey->dst.Ipv6.sin6_addr, sizeof(tunKey->dst.Ipv6.sin6_addr))) { rc = STATUS_UNSUCCESSFUL; goto done; } } } if (!OvsIphIsZero(&tunKey->src)) { if (tunKey->src.si_family == AF_INET) { if (!NlMsgPutTailU32(nlBuf, OVS_TUNNEL_KEY_ATTR_IPV4_SRC, tunKey->src.Ipv4.sin_addr.s_addr)) { rc = STATUS_UNSUCCESSFUL; goto done; } } else if (tunKey->src.si_family == AF_INET6) { if (!NlMsgPutTailUnspec(nlBuf, OVS_TUNNEL_KEY_ATTR_IPV6_SRC, (PCHAR)&tunKey->src.Ipv6.sin6_addr, sizeof(tunKey->src.Ipv6.sin6_addr))) { rc = STATUS_UNSUCCESSFUL; goto done; } } } if (!NlMsgPutTailU8(nlBuf, OVS_TUNNEL_KEY_ATTR_TOS, tunKey->tos)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailU8(nlBuf, OVS_TUNNEL_KEY_ATTR_TTL, tunKey->ttl)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (tunKey->tunOptLen > 0 && !NlMsgPutTailUnspec(nlBuf, OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS, (PCHAR)IPTunnelKeyGetOptions(tunKey), tunKey->tunOptLen)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailU16(nlBuf, OVS_TUNNEL_KEY_ATTR_TP_SRC, tunKey->flow_hash)) { rc = STATUS_UNSUCCESSFUL; goto done; } if (!NlMsgPutTailU16(nlBuf, OVS_TUNNEL_KEY_ATTR_TP_DST, tunKey->dst_port)) { rc = STATUS_UNSUCCESSFUL; goto done; } done: NlMsgEndNested(nlBuf, offset); error_nested_start: return rc; } /* *---------------------------------------------------------------------------- * _MapFlowTunKeyToNlKey -- * Maps OvsIPv4FlowPutKey to OVS_KEY_ATTR_IPV4 attribute. *---------------------------------------------------------------------------- */ static NTSTATUS _MapFlowIpv4KeyToNlKey(PNL_BUFFER nlBuf, IpKey *ipv4FlowPutKey) { NTSTATUS rc = STATUS_SUCCESS; struct ovs_key_ipv4 ipv4Key; ipv4Key.ipv4_src = ipv4FlowPutKey->nwSrc; ipv4Key.ipv4_dst = ipv4FlowPutKey->nwDst; ipv4Key.ipv4_proto = ipv4FlowPutKey->nwProto; ipv4Key.ipv4_tos = ipv4FlowPutKey->nwTos; ipv4Key.ipv4_ttl = ipv4FlowPutKey->nwTtl; ipv4Key.ipv4_frag = ipv4FlowPutKey->nwFrag; if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_IPV4, (PCHAR)(&ipv4Key), sizeof(struct ovs_key_ipv4))) { rc = STATUS_UNSUCCESSFUL; goto done; } switch (ipv4Key.ipv4_proto) { case IPPROTO_TCP: { struct ovs_key_tcp tcpKey; tcpKey.tcp_src = ipv4FlowPutKey->l4.tpSrc; tcpKey.tcp_dst = ipv4FlowPutKey->l4.tpDst; if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_TCP, (PCHAR)(&tcpKey), sizeof(tcpKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } break; } case IPPROTO_UDP: { struct ovs_key_udp udpKey; udpKey.udp_src = ipv4FlowPutKey->l4.tpSrc; udpKey.udp_dst = ipv4FlowPutKey->l4.tpDst; if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_UDP, (PCHAR)(&udpKey), sizeof(udpKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } break; } case IPPROTO_SCTP: { struct ovs_key_sctp sctpKey; sctpKey.sctp_src = ipv4FlowPutKey->l4.tpSrc; sctpKey.sctp_dst = ipv4FlowPutKey->l4.tpDst; if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_SCTP, (PCHAR)(&sctpKey), sizeof(sctpKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } break; } case IPPROTO_ICMP: { struct ovs_key_icmp icmpKey; icmpKey.icmp_type = (__u8)ntohs(ipv4FlowPutKey->l4.tpSrc); icmpKey.icmp_code = (__u8)ntohs(ipv4FlowPutKey->l4.tpDst); if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_ICMP, (PCHAR)(&icmpKey), sizeof(icmpKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } break; } default: break; } done: return rc; } /* *---------------------------------------------------------------------------- * _MapFlowIpv6KeyToNlKey -- * Maps _MapFlowIpv6KeyToNlKey to OVS_KEY_ATTR_IPV6 attribute. *---------------------------------------------------------------------------- */ static NTSTATUS _MapFlowIpv6KeyToNlKey(PNL_BUFFER nlBuf, Ipv6Key *ipv6FlowPutKey, Icmp6Key *icmpv6FlowPutKey) { NTSTATUS rc = STATUS_SUCCESS; struct ovs_key_ipv6 ipv6Key; RtlCopyMemory(&(ipv6Key.ipv6_src), &ipv6FlowPutKey->ipv6Src, sizeof ipv6Key.ipv6_src); RtlCopyMemory(&(ipv6Key.ipv6_dst), &ipv6FlowPutKey->ipv6Dst, sizeof ipv6Key.ipv6_dst); ipv6Key.ipv6_label = ipv6FlowPutKey->ipv6Label; ipv6Key.ipv6_proto = ipv6FlowPutKey->nwProto; ipv6Key.ipv6_tclass = ipv6FlowPutKey->nwTos; ipv6Key.ipv6_hlimit = ipv6FlowPutKey->nwTtl; ipv6Key.ipv6_frag = ipv6FlowPutKey->nwFrag; if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_IPV6, (PCHAR)(&ipv6Key), sizeof(ipv6Key))) { rc = STATUS_UNSUCCESSFUL; goto done; } switch (ipv6Key.ipv6_proto) { case IPPROTO_TCP: { struct ovs_key_tcp tcpKey; tcpKey.tcp_src = ipv6FlowPutKey->l4.tpSrc; tcpKey.tcp_dst = ipv6FlowPutKey->l4.tpDst; if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_TCP, (PCHAR)(&tcpKey), sizeof(tcpKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } break; } case IPPROTO_UDP: { struct ovs_key_udp udpKey; udpKey.udp_src = ipv6FlowPutKey->l4.tpSrc; udpKey.udp_dst = ipv6FlowPutKey->l4.tpDst; if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_UDP, (PCHAR)(&udpKey), sizeof(udpKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } break; } case IPPROTO_SCTP: { struct ovs_key_sctp sctpKey; sctpKey.sctp_src = ipv6FlowPutKey->l4.tpSrc; sctpKey.sctp_dst = ipv6FlowPutKey->l4.tpDst; if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_SCTP, (PCHAR)(&sctpKey), sizeof(sctpKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } break; } case IPPROTO_ICMPV6: { struct ovs_key_icmpv6 icmpV6Key; struct ovs_key_nd ndKey; icmpV6Key.icmpv6_type = (__u8)ntohs(icmpv6FlowPutKey->l4.tpSrc); icmpV6Key.icmpv6_code = (__u8)ntohs(icmpv6FlowPutKey->l4.tpDst); if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_ICMPV6, (PCHAR)(&icmpV6Key), sizeof(icmpV6Key))) { rc = STATUS_UNSUCCESSFUL; goto done; } RtlCopyMemory(&(ndKey.nd_target), &icmpv6FlowPutKey->ndTarget, sizeof(icmpv6FlowPutKey->ndTarget)); RtlCopyMemory(&(ndKey.nd_sll), &icmpv6FlowPutKey->arpSha, ETH_ADDR_LEN); RtlCopyMemory(&(ndKey.nd_tll), &icmpv6FlowPutKey->arpTha, ETH_ADDR_LEN); if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_ND, (PCHAR)(&ndKey), sizeof(ndKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } break; } default: break; } done: return rc; } /* *---------------------------------------------------------------------------- * _MapFlowArpKeyToNlKey -- * Maps _MapFlowArpKeyToNlKey to OVS_KEY_ATTR_ARP attribute. *---------------------------------------------------------------------------- */ static NTSTATUS _MapFlowArpKeyToNlKey(PNL_BUFFER nlBuf, ArpKey *arpFlowPutKey) { NTSTATUS rc = STATUS_SUCCESS; struct ovs_key_arp arpKey; arpKey.arp_sip = arpFlowPutKey->nwSrc; arpKey.arp_tip = arpFlowPutKey->nwDst; RtlCopyMemory(&(arpKey.arp_sha), arpFlowPutKey->arpSha, ETH_ADDR_LEN); RtlCopyMemory(&(arpKey.arp_tha), arpFlowPutKey->arpTha, ETH_ADDR_LEN); /* * Flow_Extract() stores 'nwProto' in host order for ARP since 'nwProto' is * 1 byte field and the ARP opcode is 2 bytes, and all of the kernel code * understand this while looking at an ARP key. * While we pass up the ARP key to userspace, convert from host order to * network order. Likewise, when processing an ARP key from userspace, * convert from network order to host order. * * It is important to note that the flow table stores the ARP opcode field * in host order. */ arpKey.arp_op = htons(arpFlowPutKey->nwProto); if (!NlMsgPutTailUnspec(nlBuf, OVS_KEY_ATTR_ARP, (PCHAR)(&arpKey), sizeof(arpKey))) { rc = STATUS_UNSUCCESSFUL; goto done; } done: return rc; } /* *---------------------------------------------------------------------------- * _MapFlowMplsKeyToNlKey -- * Maps _MapFlowMplsKeyToNlKey to OVS_KEY_ATTR_MPLS attribute. *---------------------------------------------------------------------------- */ static NTSTATUS _MapFlowMplsKeyToNlKey(PNL_BUFFER nlBuf, MplsKey *mplsFlowPutKey) { NTSTATUS rc = STATUS_SUCCESS; struct ovs_key_mpls *mplsKey; mplsKey = (struct ovs_key_mpls *) NlMsgPutTailUnspecUninit(nlBuf, OVS_KEY_ATTR_MPLS, sizeof(*mplsKey)); if (!mplsKey) { rc = STATUS_UNSUCCESSFUL; goto done; } mplsKey->mpls_lse = mplsFlowPutKey->lse; done: return rc; } /* *---------------------------------------------------------------------------- * _MapNlToFlowPut -- * Maps input netlink message to OvsFlowPut. *---------------------------------------------------------------------------- */ static NTSTATUS _MapNlToFlowPut(POVS_MESSAGE msgIn, PNL_ATTR keyAttr, PNL_ATTR actionAttr, PNL_ATTR flowAttrClear, OvsFlowPut *mappedFlow) { NTSTATUS rc = STATUS_SUCCESS; PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg); PGENL_MSG_HDR genlMsgHdr = &(msgIn->genlMsg); POVS_HDR ovsHdr = &(msgIn->ovsHdr); UINT32 keyAttrOffset = (UINT32)((PCHAR)keyAttr - (PCHAR)nlMsgHdr); UINT32 tunnelKeyAttrOffset; UINT32 encapOffset = 0; PNL_ATTR keyAttrs[__OVS_KEY_ATTR_MAX] = {NULL}; PNL_ATTR tunnelAttrs[__OVS_TUNNEL_KEY_ATTR_MAX] = {NULL}; PNL_ATTR encapAttrs[__OVS_KEY_ATTR_MAX] = { NULL }; /* Get flow keys attributes */ if ((NlAttrParseNested(nlMsgHdr, keyAttrOffset, NlAttrLen(keyAttr), nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy), keyAttrs, ARRAY_SIZE(keyAttrs))) != TRUE) { OVS_LOG_ERROR("Key Attr Parsing failed for msg: %p", nlMsgHdr); rc = STATUS_INVALID_PARAMETER; goto done; } if (keyAttrs[OVS_KEY_ATTR_ENCAP]) { encapOffset = (UINT32)((PCHAR)(keyAttrs[OVS_KEY_ATTR_ENCAP]) - (PCHAR)nlMsgHdr); if ((NlAttrParseNested(nlMsgHdr, encapOffset, NlAttrLen(keyAttrs[OVS_KEY_ATTR_ENCAP]), nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy), encapAttrs, ARRAY_SIZE(encapAttrs))) != TRUE) { OVS_LOG_ERROR("Encap Key Attr Parsing failed for msg: %p", nlMsgHdr); rc = STATUS_INVALID_PARAMETER; goto done; } } if (keyAttrs[OVS_KEY_ATTR_TUNNEL]) { tunnelKeyAttrOffset = (UINT32)((PCHAR) (keyAttrs[OVS_KEY_ATTR_TUNNEL]) - (PCHAR)nlMsgHdr); /* Get tunnel keys attributes */ if ((NlAttrParseNested(nlMsgHdr, tunnelKeyAttrOffset, NlAttrLen(keyAttrs[OVS_KEY_ATTR_TUNNEL]), nlFlowTunnelKeyPolicy, ARRAY_SIZE(nlFlowTunnelKeyPolicy), tunnelAttrs, ARRAY_SIZE(tunnelAttrs))) != TRUE) { OVS_LOG_ERROR("Tunnel key Attr Parsing failed for msg: %p", nlMsgHdr); rc = STATUS_INVALID_PARAMETER; goto done; } } _MapKeyAttrToFlowPut(keyAttrs, tunnelAttrs, &(mappedFlow->key)); ASSERT(keyAttrs[OVS_KEY_ATTR_IN_PORT]); if (encapOffset) { _MapKeyAttrToFlowPut(encapAttrs, tunnelAttrs, &(mappedFlow->key)); } /* Map the action */ if (actionAttr) { mappedFlow->actionsLen = NlAttrGetSize(actionAttr); mappedFlow->actions = NlAttrGet(actionAttr); } mappedFlow->dpNo = ovsHdr->dp_ifindex; _MapNlToFlowPutFlags(genlMsgHdr, flowAttrClear, mappedFlow); done: return rc; } /* *---------------------------------------------------------------------------- * _MapNlToFlowPutFlags -- * Maps netlink message to OvsFlowPut->flags. *---------------------------------------------------------------------------- */ static VOID _MapNlToFlowPutFlags(PGENL_MSG_HDR genlMsgHdr, PNL_ATTR flowAttrClear, OvsFlowPut *mappedFlow) { uint32_t flags = 0; switch (genlMsgHdr->cmd) { case OVS_FLOW_CMD_NEW: flags |= OVSWIN_FLOW_PUT_CREATE; break; case OVS_FLOW_CMD_DEL: flags |= OVSWIN_FLOW_PUT_DELETE; break; case OVS_FLOW_CMD_SET: flags |= OVSWIN_FLOW_PUT_MODIFY; break; default: ASSERT(0); } if (flowAttrClear) { flags |= OVSWIN_FLOW_PUT_CLEAR; } mappedFlow->flags = flags; } /* *---------------------------------------------------------------------------- * _MapKeyAttrToFlowPut -- * Converts FLOW_KEY attribute to OvsFlowPut->key. *---------------------------------------------------------------------------- */ static VOID _MapKeyAttrToFlowPut(PNL_ATTR *keyAttrs, PNL_ATTR *tunnelAttrs, OvsFlowKey *destKey) { MapTunAttrToFlowPut(keyAttrs, tunnelAttrs, destKey); if (keyAttrs[OVS_KEY_ATTR_RECIRC_ID]) { destKey->recircId = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_RECIRC_ID]); } if (keyAttrs[OVS_KEY_ATTR_DP_HASH]) { destKey->dpHash = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_DP_HASH]); } if (keyAttrs[OVS_KEY_ATTR_CT_STATE]) { destKey->ct.state = (NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_CT_STATE])); } if (keyAttrs[OVS_KEY_ATTR_CT_ZONE]) { destKey->ct.zone = (NlAttrGetU16(keyAttrs[OVS_KEY_ATTR_CT_ZONE])); } if (keyAttrs[OVS_KEY_ATTR_CT_MARK]) { destKey->ct.mark = (NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_CT_MARK])); } if (keyAttrs[OVS_KEY_ATTR_CT_LABELS]) { const struct ovs_key_ct_labels *ct_labels; ct_labels = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_LABELS]); NdisMoveMemory(&destKey->ct.labels, ct_labels, sizeof(struct ovs_key_ct_labels)); } if (keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4]) { const struct ovs_key_ct_tuple_ipv4 *tuple_ipv4; tuple_ipv4 = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4]); NdisMoveMemory(&destKey->ct.tuple_ipv4, tuple_ipv4, sizeof(struct ovs_key_ct_tuple_ipv4)); } if (keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6]) { const struct ovs_key_ct_tuple_ipv6 *tuple_ipv6; tuple_ipv6 = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6]); NdisMoveMemory(&destKey->ct.tuple_ipv6, tuple_ipv6, sizeof(struct ovs_key_ct_tuple_ipv6)); } /* ===== L2 headers ===== */ if (keyAttrs[OVS_KEY_ATTR_IN_PORT]) { destKey->l2.inPort = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_IN_PORT]); } if (keyAttrs[OVS_KEY_ATTR_ETHERNET]) { const struct ovs_key_ethernet *eth_key; eth_key = NlAttrGet(keyAttrs[OVS_KEY_ATTR_ETHERNET]); RtlCopyMemory(destKey->l2.dlSrc, eth_key->eth_src, ETH_ADDR_LEN); RtlCopyMemory(destKey->l2.dlDst, eth_key->eth_dst, ETH_ADDR_LEN); } /* TODO: Ideally ETHERTYPE should not be optional. * But during vswitchd bootup we are seeing FLOW_ADD * requests with no ETHERTYPE attributes. * Need to verify this. */ if (keyAttrs[OVS_KEY_ATTR_ETHERTYPE]) { destKey->l2.dlType = (NlAttrGetU16(keyAttrs [OVS_KEY_ATTR_ETHERTYPE])); } if (keyAttrs[OVS_KEY_ATTR_VLAN]) { destKey->l2.vlanKey.vlanTci = NlAttrGetU16(keyAttrs[OVS_KEY_ATTR_VLAN]); if (destKey->l2.vlanKey.vlanTci != 0) { /* set TPID to dlType. */ destKey->l2.vlanKey.vlanTpid = destKey->l2.dlType; } } /* ==== L3 + L4. ==== */ destKey->l2.keyLen = OVS_WIN_IP_TUNNEL_KEY_SIZE + OVS_L2_KEY_SIZE - destKey->l2.offset; switch (ntohs(destKey->l2.dlType)) { case ETH_TYPE_IPV4: { if (keyAttrs[OVS_KEY_ATTR_IPV4]) { const struct ovs_key_ipv4 *ipv4Key; ipv4Key = NlAttrGet(keyAttrs[OVS_KEY_ATTR_IPV4]); IpKey *ipv4FlowPutKey = &(destKey->ipKey); ipv4FlowPutKey->nwSrc = ipv4Key->ipv4_src; ipv4FlowPutKey->nwDst = ipv4Key->ipv4_dst; ipv4FlowPutKey->nwProto = ipv4Key->ipv4_proto; ipv4FlowPutKey->nwTos = ipv4Key->ipv4_tos; ipv4FlowPutKey->nwTtl = ipv4Key->ipv4_ttl; ipv4FlowPutKey->nwFrag = ipv4Key->ipv4_frag; if (keyAttrs[OVS_KEY_ATTR_TCP]) { const struct ovs_key_tcp *tcpKey; tcpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_TCP]); ipv4FlowPutKey->l4.tpSrc = tcpKey->tcp_src; ipv4FlowPutKey->l4.tpDst = tcpKey->tcp_dst; } if (keyAttrs[OVS_KEY_ATTR_UDP]) { const struct ovs_key_udp *udpKey; udpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_UDP]); ipv4FlowPutKey->l4.tpSrc = udpKey->udp_src; ipv4FlowPutKey->l4.tpDst = udpKey->udp_dst; } if (keyAttrs[OVS_KEY_ATTR_SCTP]) { const struct ovs_key_sctp *sctpKey; sctpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_SCTP]); ipv4FlowPutKey->l4.tpSrc = sctpKey->sctp_src; ipv4FlowPutKey->l4.tpDst = sctpKey->sctp_dst; } if (keyAttrs[OVS_KEY_ATTR_ICMP]) { const struct ovs_key_icmp *icmpKey; icmpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_ICMP]); ipv4FlowPutKey->l4.tpSrc = htons(icmpKey->icmp_type); ipv4FlowPutKey->l4.tpDst = htons(icmpKey->icmp_code); } destKey->l2.keyLen += OVS_IP_KEY_SIZE; } break; } case ETH_TYPE_IPV6: { if (keyAttrs[OVS_KEY_ATTR_IPV6]) { const struct ovs_key_ipv6 *ipv6Key; ipv6Key = NlAttrGet(keyAttrs[OVS_KEY_ATTR_IPV6]); Ipv6Key *ipv6FlowPutKey = &(destKey->ipv6Key); RtlCopyMemory(&ipv6FlowPutKey->ipv6Src, ipv6Key->ipv6_src, sizeof ipv6Key->ipv6_src); RtlCopyMemory(&ipv6FlowPutKey->ipv6Dst, ipv6Key->ipv6_dst, sizeof ipv6Key->ipv6_dst); ipv6FlowPutKey->ipv6Label = ipv6Key->ipv6_label; ipv6FlowPutKey->nwProto = ipv6Key->ipv6_proto; ipv6FlowPutKey->nwTos = ipv6Key->ipv6_tclass; ipv6FlowPutKey->nwTtl = ipv6Key->ipv6_hlimit; ipv6FlowPutKey->nwFrag = ipv6Key->ipv6_frag; if (keyAttrs[OVS_KEY_ATTR_TCP]) { const struct ovs_key_tcp *tcpKey; tcpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_TCP]); ipv6FlowPutKey->l4.tpSrc = tcpKey->tcp_src; ipv6FlowPutKey->l4.tpDst = tcpKey->tcp_dst; } if (keyAttrs[OVS_KEY_ATTR_UDP]) { const struct ovs_key_udp *udpKey; udpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_UDP]); ipv6FlowPutKey->l4.tpSrc = udpKey->udp_src; ipv6FlowPutKey->l4.tpDst = udpKey->udp_dst; } if (keyAttrs[OVS_KEY_ATTR_SCTP]) { const struct ovs_key_sctp *sctpKey; sctpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_SCTP]); ipv6FlowPutKey->l4.tpSrc = sctpKey->sctp_src; ipv6FlowPutKey->l4.tpDst = sctpKey->sctp_dst; } if (keyAttrs[OVS_KEY_ATTR_ICMPV6]) { const struct ovs_key_icmpv6 *icmpv6Key; Icmp6Key *icmp6FlowPutKey= &(destKey->icmp6Key); icmpv6Key = NlAttrGet(keyAttrs[OVS_KEY_ATTR_ICMPV6]); icmp6FlowPutKey->l4.tpSrc = htons(icmpv6Key->icmpv6_type); icmp6FlowPutKey->l4.tpDst = htons(icmpv6Key->icmpv6_code); if (keyAttrs[OVS_KEY_ATTR_ND]) { const struct ovs_key_nd *ndKey; ndKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_ND]); RtlCopyMemory(&icmp6FlowPutKey->ndTarget, ndKey->nd_target, sizeof (icmp6FlowPutKey->ndTarget)); RtlCopyMemory(icmp6FlowPutKey->arpSha, ndKey->nd_sll, ETH_ADDR_LEN); RtlCopyMemory(icmp6FlowPutKey->arpTha, ndKey->nd_tll, ETH_ADDR_LEN); } destKey->l2.keyLen += OVS_ICMPV6_KEY_SIZE; } else { destKey->l2.keyLen += OVS_IPV6_KEY_SIZE; } ipv6FlowPutKey->pad = 0; } break; } case ETH_TYPE_ARP: case ETH_TYPE_RARP: { if (keyAttrs[OVS_KEY_ATTR_ARP]) { ArpKey *arpFlowPutKey = &destKey->arpKey; const struct ovs_key_arp *arpKey; arpKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_ARP]); arpFlowPutKey->nwSrc = arpKey->arp_sip; arpFlowPutKey->nwDst = arpKey->arp_tip; RtlCopyMemory(arpFlowPutKey->arpSha, arpKey->arp_sha, ETH_ADDR_LEN); RtlCopyMemory(arpFlowPutKey->arpTha, arpKey->arp_tha, ETH_ADDR_LEN); /* Kernel datapath assumes 'arpFlowPutKey->nwProto' to be in host * order. */ arpFlowPutKey->nwProto = (UINT8)ntohs((arpKey->arp_op)); arpFlowPutKey->pad[0] = 0; arpFlowPutKey->pad[1] = 0; arpFlowPutKey->pad[2] = 0; destKey->l2.keyLen += OVS_ARP_KEY_SIZE; } break; } case ETH_TYPE_MPLS: case ETH_TYPE_MPLS_MCAST: { if (keyAttrs[OVS_KEY_ATTR_MPLS]) { MplsKey *mplsFlowPutKey = &destKey->mplsKey; const struct ovs_key_mpls *mplsKey; mplsKey = NlAttrGet(keyAttrs[OVS_KEY_ATTR_MPLS]); mplsFlowPutKey->lse = mplsKey->mpls_lse; mplsFlowPutKey->pad[0] = 0; mplsFlowPutKey->pad[1] = 0; mplsFlowPutKey->pad[2] = 0; mplsFlowPutKey->pad[3] = 0; destKey->l2.keyLen += OVS_MPLS_KEY_SIZE; } break; } } } /* *---------------------------------------------------------------------------- * OvsTunnelAttrToGeneveOptions -- * Converts OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS attribute to tunKey->tunOpts. *---------------------------------------------------------------------------- */ static __inline NTSTATUS OvsTunnelAttrToGeneveOptions(PNL_ATTR attr, OvsIPTunnelKey *tunKey) { UINT32 optLen = NlAttrGetSize(attr); GeneveOptionHdr *option; BOOLEAN isCritical = FALSE; if (optLen > TUN_OPT_MAX_LEN) { OVS_LOG_ERROR("Geneve option length err (len %d, max %Iu).", optLen, TUN_OPT_MAX_LEN); return STATUS_INFO_LENGTH_MISMATCH; } else if (optLen % 4 != 0) { OVS_LOG_ERROR("Geneve opt len %d is not a multiple of 4.", optLen); return STATUS_INFO_LENGTH_MISMATCH; } tunKey->tunOptLen = (UINT8)optLen; option = (GeneveOptionHdr *)NlAttrData(attr); while (optLen > 0) { UINT32 len; if (optLen < sizeof(*option)) { return STATUS_INFO_LENGTH_MISMATCH; } len = sizeof(*option) + option->length * 4; if (len > optLen) { return STATUS_INFO_LENGTH_MISMATCH; } if (option->type & GENEVE_CRIT_OPT_TYPE) { isCritical = TRUE; } option = (GeneveOptionHdr *)((UINT8 *)option + len); optLen -= len; } memcpy(IPTunnelKeyGetOptions(tunKey), NlAttrData(attr), tunKey->tunOptLen); if (isCritical) { tunKey->flags |= OVS_TNL_F_CRT_OPT; } return STATUS_SUCCESS; } /* *---------------------------------------------------------------------------- * OvsTunnelAttrToIPTunnelKey -- * Converts OVS_KEY_ATTR_TUNNEL attribute to tunKey. *---------------------------------------------------------------------------- */ NTSTATUS OvsTunnelAttrToIPTunnelKey(PNL_ATTR attr, OvsIPTunnelKey *tunKey) { PNL_ATTR a; INT rem; INT hasOpt = 0; NTSTATUS status; memset(tunKey, 0, OVS_WIN_IP_TUNNEL_KEY_SIZE); ASSERT(NlAttrType(attr) == OVS_KEY_ATTR_TUNNEL); NL_ATTR_FOR_EACH_UNSAFE(a, rem, NlAttrData(attr), NlAttrGetSize(attr)) { switch (NlAttrType(a)) { case OVS_TUNNEL_KEY_ATTR_ID: tunKey->tunnelId = NlAttrGetBe64(a); tunKey->flags |= OVS_TNL_F_KEY; break; case OVS_TUNNEL_KEY_ATTR_IPV4_SRC: tunKey->src.si_family = AF_INET; tunKey->src.Ipv4.sin_addr.s_addr = NlAttrGetBe32(a); break; case OVS_TUNNEL_KEY_ATTR_IPV4_DST: tunKey->dst.si_family = AF_INET; tunKey->dst.Ipv4.sin_addr.s_addr = NlAttrGetBe32(a); break; case OVS_TUNNEL_KEY_ATTR_IPV6_SRC: tunKey->src.si_family = AF_INET6; RtlCopyMemory(&tunKey->src.Ipv6.sin6_addr, NlAttrGetUnspec(a, sizeof(tunKey->src.Ipv6.sin6_addr)), sizeof(tunKey->src.Ipv6.sin6_addr)); break; case OVS_TUNNEL_KEY_ATTR_IPV6_DST: tunKey->dst.si_family = AF_INET6; RtlCopyMemory(&tunKey->dst.Ipv6.sin6_addr, NlAttrGetUnspec(a, sizeof(tunKey->dst.Ipv6.sin6_addr)), sizeof(tunKey->dst.Ipv6.sin6_addr)); break; case OVS_TUNNEL_KEY_ATTR_TOS: tunKey->tos = NlAttrGetU8(a); break; case OVS_TUNNEL_KEY_ATTR_TTL: tunKey->ttl = NlAttrGetU8(a); break; case OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT: tunKey->flags |= OVS_TNL_F_DONT_FRAGMENT; break; case OVS_TUNNEL_KEY_ATTR_CSUM: tunKey->flags |= OVS_TNL_F_CSUM; break; case OVS_TUNNEL_KEY_ATTR_OAM: tunKey->flags |= OVS_TNL_F_OAM; break; case OVS_TUNNEL_KEY_ATTR_TP_DST: tunKey->dst_port = NlAttrGetBe16(a); break; case OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS: if (hasOpt) { /* Duplicate options attribute is not allowed. */ return NDIS_STATUS_FAILURE; } status = OvsTunnelAttrToGeneveOptions(a, tunKey); if (!SUCCEEDED(status)) { return status; } tunKey->flags |= OVS_TNL_F_GENEVE_OPT; hasOpt = 1; break; default: // XXX: Support OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS return STATUS_INVALID_PARAMETER; } } return STATUS_SUCCESS; } /* *---------------------------------------------------------------------------- * MapTunAttrToFlowPut -- * Converts FLOW_TUNNEL_KEY attribute to OvsFlowKey->tunKey. *---------------------------------------------------------------------------- */ VOID MapTunAttrToFlowPut(PNL_ATTR *keyAttrs, PNL_ATTR *tunAttrs, OvsFlowKey *destKey) { memset(&destKey->tunKey, 0, OVS_WIN_IP_TUNNEL_KEY_SIZE); if (keyAttrs[OVS_KEY_ATTR_TUNNEL]) { /* XXX: This blocks performs same functionality as OvsTunnelAttrToIPv4TunnelKey. Consider refactoring the code.*/ if (tunAttrs[OVS_TUNNEL_KEY_ATTR_ID]) { destKey->tunKey.tunnelId = NlAttrGetU64(tunAttrs[OVS_TUNNEL_KEY_ATTR_ID]); destKey->tunKey.flags |= OVS_TNL_F_KEY; } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_IPV4_DST]) { destKey->tunKey.dst.si_family = AF_INET; destKey->tunKey.dst.Ipv4.sin_addr.s_addr = NlAttrGetU32(tunAttrs[OVS_TUNNEL_KEY_ATTR_IPV4_DST]); } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_IPV4_SRC]) { destKey->tunKey.src.si_family = AF_INET; destKey->tunKey.src.Ipv4.sin_addr.s_addr = NlAttrGetU32(tunAttrs[OVS_TUNNEL_KEY_ATTR_IPV4_SRC]); } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_IPV6_DST]) { destKey->tunKey.dst.si_family = AF_INET6; RtlCopyMemory(&destKey->tunKey.dst.Ipv6.sin6_addr, NlAttrGetUnspec( tunAttrs[OVS_TUNNEL_KEY_ATTR_IPV6_DST], sizeof(destKey->tunKey.dst.Ipv6.sin6_addr)), sizeof(destKey->tunKey.dst.Ipv6.sin6_addr)); } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_IPV6_SRC]) { destKey->tunKey.src.si_family = AF_INET6; RtlCopyMemory(&destKey->tunKey.src.Ipv6.sin6_addr, NlAttrGetUnspec( tunAttrs[OVS_TUNNEL_KEY_ATTR_IPV6_SRC], sizeof(destKey->tunKey.src.Ipv6.sin6_addr)), sizeof(destKey->tunKey.src.Ipv6.sin6_addr)); } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT]) { destKey->tunKey.flags |= OVS_TNL_F_DONT_FRAGMENT; } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_CSUM]) { destKey->tunKey.flags |= OVS_TNL_F_CSUM; } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_TOS]) { destKey->tunKey.tos = NlAttrGetU8(tunAttrs[OVS_TUNNEL_KEY_ATTR_TOS]); } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_TTL]) { destKey->tunKey.ttl = NlAttrGetU8(tunAttrs[OVS_TUNNEL_KEY_ATTR_TTL]); } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_OAM]) { destKey->tunKey.flags |= OVS_TNL_F_OAM; } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_TP_DST]) { destKey->tunKey.dst_port = NlAttrGetU16(tunAttrs[OVS_TUNNEL_KEY_ATTR_TP_DST]); } if (tunAttrs[OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS]) { NTSTATUS status = OvsTunnelAttrToGeneveOptions( tunAttrs[OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS], &destKey->tunKey); if (SUCCEEDED(status)) { destKey->tunKey.flags |= OVS_TNL_F_GENEVE_OPT; } } destKey->l2.offset = OvsGetFlowIPL2Offset(&(destKey->tunKey)); } else { destKey->l2.offset = OvsGetFlowIPL2Offset(NULL); } } /* *---------------------------------------------------------------------------- * OvsDeleteFlowTable -- * Results: * NDIS_STATUS_SUCCESS always. *---------------------------------------------------------------------------- */ NDIS_STATUS OvsDeleteFlowTable(OVS_DATAPATH *datapath) { if (datapath == NULL || datapath->flowTable == NULL) { return NDIS_STATUS_SUCCESS; } DeleteAllFlows(datapath); OvsFreeMemoryWithTag(datapath->flowTable, OVS_FLOW_POOL_TAG); datapath->flowTable = NULL; if (datapath->lock == NULL) { return NDIS_STATUS_SUCCESS; } NdisFreeRWLock(datapath->lock); return NDIS_STATUS_SUCCESS; } /* *---------------------------------------------------------------------------- * OvsAllocateFlowTable -- * Results: * NDIS_STATUS_SUCCESS on success. * NDIS_STATUS_RESOURCES if memory couldn't be allocated *---------------------------------------------------------------------------- */ NDIS_STATUS OvsAllocateFlowTable(OVS_DATAPATH *datapath, POVS_SWITCH_CONTEXT switchContext) { PLIST_ENTRY bucket; int i; datapath->flowTable = OvsAllocateMemoryWithTag( OVS_FLOW_TABLE_SIZE * sizeof(LIST_ENTRY), OVS_FLOW_POOL_TAG); if (!datapath->flowTable) { return NDIS_STATUS_RESOURCES; } for (i = 0; i < OVS_FLOW_TABLE_SIZE; i++) { bucket = &(datapath->flowTable[i]); InitializeListHead(bucket); } datapath->lock = NdisAllocateRWLock(switchContext->NdisFilterHandle); if (!datapath->lock) { return NDIS_STATUS_RESOURCES; } return NDIS_STATUS_SUCCESS; } /* *---------------------------------------------------------------------------- * GetStartAddrNBL -- * Get the virtual address of the frame. * * Results: * Virtual address of the frame. *---------------------------------------------------------------------------- */ static __inline VOID * GetStartAddrNBL(const NET_BUFFER_LIST *_pNB) { PMDL curMdl; PUINT8 curBuffer; PEthHdr curHeader; ASSERT(_pNB); // Ethernet Header is a guaranteed safe access. curMdl = (NET_BUFFER_LIST_FIRST_NB(_pNB))->CurrentMdl; curBuffer = OvsGetMdlWithLowPriority(curMdl); if (!curBuffer) { return NULL; } curHeader = (PEthHdr) (curBuffer + (NET_BUFFER_LIST_FIRST_NB(_pNB))->CurrentMdlOffset); return (VOID *) curHeader; } VOID OvsFlowUsed(OvsFlow *flow, const NET_BUFFER_LIST *packet, const POVS_PACKET_HDR_INFO layers) { LARGE_INTEGER tickCount; KeQueryTickCount(&tickCount); flow->used = tickCount.QuadPart; flow->packetCount++; flow->byteCount += OvsPacketLenNBL(packet); flow->tcpFlags |= OvsGetTcpFlags(packet, &flow->key, layers); } VOID DeleteAllFlows(OVS_DATAPATH *datapath) { INT i; PLIST_ENTRY bucket; for (i = 0; i < OVS_FLOW_TABLE_SIZE; i++) { PLIST_ENTRY next; bucket = &(datapath->flowTable[i]); while (!IsListEmpty(bucket)) { OvsFlow *flow; next = bucket->Flink; flow = CONTAINING_RECORD(next, OvsFlow, ListEntry); RemoveFlow(datapath, &flow); } } } NDIS_STATUS OvsGetFlowMetadata(OvsFlowKey *key, PNL_ATTR *keyAttrs) { NDIS_STATUS status = NDIS_STATUS_SUCCESS; if (keyAttrs[OVS_KEY_ATTR_RECIRC_ID]) { key->recircId = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_RECIRC_ID]); } if (keyAttrs[OVS_KEY_ATTR_DP_HASH]) { key->dpHash = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_DP_HASH]); } if (keyAttrs[OVS_KEY_ATTR_CT_STATE]) { key->ct.state = (NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_CT_STATE])); } if (keyAttrs[OVS_KEY_ATTR_CT_ZONE]) { key->ct.zone = (NlAttrGetU16(keyAttrs[OVS_KEY_ATTR_CT_ZONE])); } if (keyAttrs[OVS_KEY_ATTR_CT_MARK]) { key->ct.mark = (NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_CT_MARK])); } if (keyAttrs[OVS_KEY_ATTR_CT_LABELS]) { const struct ovs_key_ct_labels *ct_labels; ct_labels = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_LABELS]); NdisMoveMemory(&key->ct.labels, ct_labels, sizeof(struct ovs_key_ct_labels)); } if (keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4]) { const struct ovs_key_ct_tuple_ipv4 *tuple_ipv4; tuple_ipv4 = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4]); NdisMoveMemory(&key->ct.tuple_ipv4, tuple_ipv4, sizeof(struct ovs_key_ct_tuple_ipv4)); } if (keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6]) { const struct ovs_key_ct_tuple_ipv6 *tuple_ipv6; tuple_ipv6 = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6]); NdisMoveMemory(&key->ct.tuple_ipv6, tuple_ipv6, sizeof(struct ovs_key_ct_tuple_ipv6)); } return status; } UINT16 OvsGetFlowIPL2Offset(const OvsIPTunnelKey *tunKey) { if (tunKey != NULL) { // Align with int64 boundary if (tunKey->tunOptLen == 0) { return (TUN_OPT_MAX_LEN + 1) / 8 * 8; } return IPTunnelKeyGetOptionsOffset(tunKey) / 8 * 8; } else { return OVS_WIN_IP_TUNNEL_KEY_SIZE; } } /* *---------------------------------------------------------------------------- * Initializes 'layers' members from 'packet' * * Initializes 'layers' header pointers as follows: * * - layers->l2 to the start of the Ethernet header. * * - layers->l3 to just past the Ethernet header, or just past the * vlan_header if one is present, to the first byte of the payload of the * Ethernet frame. * * - layers->l4 to just past the IPv4 header, if one is present and has a * correct length, and otherwise NULL. * * - layers->l7 to just past the TCP, UDP, SCTP or ICMP header, if one is * present and has a correct length, and otherwise NULL. * * - layers->isIPv4/isIPv6/isTcp/isUdp/isSctp based on the packet type * * Returns NDIS_STATUS_SUCCESS normally. * Fails only if packet data cannot be accessed. * (e.g. if OvsParseIPv6() returns an error). *---------------------------------------------------------------------------- */ NDIS_STATUS OvsExtractLayers(const NET_BUFFER_LIST *packet, POVS_PACKET_HDR_INFO layers) { struct Eth_Header *eth; UINT8 offset = 0; PVOID vlanTagValue; ovs_be16 dlType; layers->value = 0; /* Link layer. */ eth = (Eth_Header *)GetStartAddrNBL((NET_BUFFER_LIST *)packet); /* * vlan_tci. */ vlanTagValue = NET_BUFFER_LIST_INFO(packet, Ieee8021QNetBufferListInfo); if (!vlanTagValue) { if (eth->dix.typeNBO == ETH_TYPE_802_1PQ_NBO) { offset = sizeof(Eth_802_1pq_Tag); } /* * XXX Please note after this point, src mac and dst mac should * not be accessed through eth */ eth = (Eth_Header *)((UINT8 *)eth + offset); } /* * dl_type. * * XXX assume that at least the first * 12 bytes of received packets are mapped. This code has the stronger * assumption that at least the first 22 bytes of 'packet' is mapped (if my * arithmetic is right). */ if (ETH_TYPENOT8023(eth->dix.typeNBO)) { dlType = eth->dix.typeNBO; layers->l3Offset = ETH_HEADER_LEN_DIX + offset; } else if (OvsPacketLenNBL(packet) >= ETH_HEADER_LEN_802_3 && eth->e802_3.llc.dsap == 0xaa && eth->e802_3.llc.ssap == 0xaa && eth->e802_3.llc.control == ETH_LLC_CONTROL_UFRAME && eth->e802_3.snap.snapOrg[0] == 0x00 && eth->e802_3.snap.snapOrg[1] == 0x00 && eth->e802_3.snap.snapOrg[2] == 0x00) { dlType = eth->e802_3.snap.snapType.typeNBO; layers->l3Offset = ETH_HEADER_LEN_802_3 + offset; } else { dlType = htons(OVSWIN_DL_TYPE_NONE); layers->l3Offset = ETH_HEADER_LEN_DIX + offset; } /* Network layer. */ if (dlType == htons(ETH_TYPE_IPV4)) { struct IPHdr ip_storage; const struct IPHdr *nh; layers->isIPv4 = 1; nh = OvsGetIp(packet, layers->l3Offset, &ip_storage); if (nh) { layers->l4Offset = layers->l3Offset + nh->ihl * 4; if (!(nh->frag_off & htons(IP_OFFSET))) { if (nh->protocol == SOCKET_IPPROTO_TCP) { OvsParseTcp(packet, NULL, layers); } else if (nh->protocol == SOCKET_IPPROTO_UDP) { OvsParseUdp(packet, NULL, layers); } else if (nh->protocol == SOCKET_IPPROTO_SCTP) { OvsParseSctp(packet, NULL, layers); } else if (nh->protocol == SOCKET_IPPROTO_ICMP) { ICMPHdr icmpStorage; const ICMPHdr *icmp; icmp = OvsGetIcmp(packet, layers->l4Offset, &icmpStorage); if (icmp) { layers->l7Offset = layers->l4Offset + sizeof *icmp; } layers->isIcmp = 1; } } } else { /* Invalid network header */ return NDIS_STATUS_INVALID_PACKET; } } else if (dlType == htons(ETH_TYPE_IPV6)) { NDIS_STATUS status; Ipv6Key ipv6Key; status = OvsParseIPv6(packet, &ipv6Key, layers); if (status != NDIS_STATUS_SUCCESS) { return status; } layers->isIPv6 = 1; if (ipv6Key.nwProto == SOCKET_IPPROTO_TCP) { OvsParseTcp(packet, &(ipv6Key.l4), layers); } else if (ipv6Key.nwProto == SOCKET_IPPROTO_UDP) { OvsParseUdp(packet, &(ipv6Key.l4), layers); } else if (ipv6Key.nwProto == SOCKET_IPPROTO_SCTP) { OvsParseSctp(packet, &ipv6Key.l4, layers); } else if (ipv6Key.nwProto == SOCKET_IPPROTO_ICMPV6) { Icmp6Key icmp6Key; OvsParseIcmpV6(packet, NULL, &icmp6Key, layers); } } else if (OvsEthertypeIsMpls(dlType)) { MPLSHdr mplsStorage; const MPLSHdr *mpls; /* * In the presence of an MPLS label stack the end of the L2 * header and the beginning of the L3 header differ. * * A network packet may contain multiple MPLS labels, but we * are only interested in the topmost label stack entry. * * Advance network header to the beginning of the L3 header. * layers->l3Offset corresponds to the end of the L2 header. */ for (UINT32 i = 0; i < FLOW_MAX_MPLS_LABELS; i++) { mpls = OvsGetMpls(packet, layers->l3Offset, &mplsStorage); if (!mpls) { break; } layers->l3Offset += MPLS_HLEN; layers->l4Offset += MPLS_HLEN; if (mpls->lse & htonl(MPLS_BOS_MASK)) { /* * Bottom of Stack bit is set, which means there are no * remaining MPLS labels in the packet. */ break; } } } return NDIS_STATUS_SUCCESS; } /* *---------------------------------------------------------------------------- * Initializes 'flow' members from 'packet', 'skb_priority', 'tun_id', and * 'ofp_in_port'. * * Initializes 'packet' header pointers as follows: * * - packet->l2 to the start of the Ethernet header. * * - packet->l3 to just past the Ethernet header, or just past the * vlan_header if one is present, to the first byte of the payload of the * Ethernet frame. * * - packet->l4 to just past the IPv4 header, if one is present and has a * correct length, and otherwise NULL. * * - packet->l7 to just past the TCP, UDP, SCTP or ICMP header, if one is * present and has a correct length, and otherwise NULL. * * Returns NDIS_STATUS_SUCCESS normally. * Fails only if packet data cannot be accessed. * (e.g. if Pkt_CopyBytesOut() returns an error). *---------------------------------------------------------------------------- */ NDIS_STATUS OvsExtractFlow(const NET_BUFFER_LIST *packet, UINT32 inPort, OvsFlowKey *flow, POVS_PACKET_HDR_INFO layers, OvsIPTunnelKey *tunKey) { struct Eth_Header *eth; UINT8 offset = 0; PVOID vlanTagValue; layers->value = 0; if (tunKey) { ASSERT(!OvsIphIsZero(&(tunKey->dst))); UINT8 optOffset = IPTunnelKeyGetOptionsOffset(tunKey); RtlMoveMemory(((UINT8 *)&flow->tunKey) + optOffset, ((UINT8 *)tunKey) + optOffset, IPTunnelKeyGetRealSize(tunKey)); } else { RtlZeroMemory(&flow->tunKey.dst, sizeof(flow->tunKey.dst)); } flow->l2.offset = OvsGetFlowIPL2Offset(tunKey); flow->l2.inPort = inPort; if (OvsPacketLenNBL(packet) < ETH_HEADER_LEN_DIX) { flow->l2.keyLen = OVS_WIN_IP_TUNNEL_KEY_SIZE + 8 - flow->l2.offset; return NDIS_STATUS_SUCCESS; } /* Link layer. */ eth = (Eth_Header *)GetStartAddrNBL((NET_BUFFER_LIST *)packet); RtlCopyMemory(flow->l2.dlSrc, eth->src, ETH_ADDR_LENGTH); RtlCopyMemory(flow->l2.dlDst, eth->dst, ETH_ADDR_LENGTH); /* * vlan_tci. */ vlanTagValue = NET_BUFFER_LIST_INFO(packet, Ieee8021QNetBufferListInfo); if (vlanTagValue) { PNDIS_NET_BUFFER_LIST_8021Q_INFO vlanTag = (PNDIS_NET_BUFFER_LIST_8021Q_INFO)(PVOID *)&vlanTagValue; flow->l2.vlanKey.vlanTci = htons(vlanTag->TagHeader.VlanId | OVSWIN_VLAN_CFI | (vlanTag->TagHeader.UserPriority << 13)); flow->l2.vlanKey.vlanTpid = htons(ETH_TYPE_802_1PQ); } else { if (eth->dix.typeNBO == ETH_TYPE_802_1PQ_NBO) { Eth_802_1pq_Tag *tag= (Eth_802_1pq_Tag *)&eth->dix.typeNBO; flow->l2.vlanKey.vlanTci = htons(((UINT16)tag->priority << 13) | OVSWIN_VLAN_CFI | ((UINT16)tag->vidHi << 8) | tag->vidLo); flow->l2.vlanKey.vlanTpid = htons(ETH_TYPE_802_1PQ); offset = sizeof (Eth_802_1pq_Tag); } else { /* Initialize vlan key to 0 for non vlan packets. */ flow->l2.vlanKey.vlanTci = 0; flow->l2.vlanKey.vlanTpid = 0; } /* * XXX Please note after this point, src mac and dst mac should * not be accessed through eth */ eth = (Eth_Header *)((UINT8 *)eth + offset); } /* * dl_type. * * XXX assume that at least the first * 12 bytes of received packets are mapped. This code has the stronger * assumption that at least the first 22 bytes of 'packet' is mapped (if my * arithmetic is right). */ if (ETH_TYPENOT8023(eth->dix.typeNBO)) { flow->l2.dlType = eth->dix.typeNBO; layers->l3Offset = ETH_HEADER_LEN_DIX + offset; } else if (OvsPacketLenNBL(packet) >= ETH_HEADER_LEN_802_3 && eth->e802_3.llc.dsap == 0xaa && eth->e802_3.llc.ssap == 0xaa && eth->e802_3.llc.control == ETH_LLC_CONTROL_UFRAME && eth->e802_3.snap.snapOrg[0] == 0x00 && eth->e802_3.snap.snapOrg[1] == 0x00 && eth->e802_3.snap.snapOrg[2] == 0x00) { flow->l2.dlType = eth->e802_3.snap.snapType.typeNBO; layers->l3Offset = ETH_HEADER_LEN_802_3 + offset; } else { flow->l2.dlType = htons(OVSWIN_DL_TYPE_NONE); layers->l3Offset = ETH_HEADER_LEN_DIX + offset; } flow->l2.keyLen = OVS_WIN_IP_TUNNEL_KEY_SIZE + OVS_L2_KEY_SIZE - flow->l2.offset; /* Network layer. */ if (flow->l2.dlType == htons(ETH_TYPE_IPV4)) { struct IPHdr ip_storage; const struct IPHdr *nh; IpKey *ipKey = &flow->ipKey; flow->l2.keyLen += OVS_IP_KEY_SIZE; layers->isIPv4 = 1; nh = OvsGetIp(packet, layers->l3Offset, &ip_storage); if (nh) { layers->l4Offset = layers->l3Offset + nh->ihl * 4; ipKey->nwSrc = nh->saddr; ipKey->nwDst = nh->daddr; ipKey->nwProto = nh->protocol; ipKey->nwTos = nh->tos; if (nh->frag_off & htons(IP_MF | IP_OFFSET)) { ipKey->nwFrag = OVS_FRAG_TYPE_FIRST; if (nh->frag_off & htons(IP_OFFSET)) { ipKey->nwFrag = OVS_FRAG_TYPE_LATER; } } else { ipKey->nwFrag = OVS_FRAG_TYPE_NONE; } ipKey->nwTtl = nh->ttl; ipKey->l4.tpSrc = 0; ipKey->l4.tpDst = 0; if (!(nh->frag_off & htons(IP_OFFSET))) { if (ipKey->nwProto == SOCKET_IPPROTO_TCP) { OvsParseTcp(packet, &ipKey->l4, layers); } else if (ipKey->nwProto == SOCKET_IPPROTO_UDP) { OvsParseUdp(packet, &ipKey->l4, layers); } else if (ipKey->nwProto == SOCKET_IPPROTO_SCTP) { OvsParseSctp(packet, &ipKey->l4, layers); } else if (ipKey->nwProto == SOCKET_IPPROTO_ICMP) { ICMPHdr icmpStorage; const ICMPHdr *icmp; icmp = OvsGetIcmp(packet, layers->l4Offset, &icmpStorage); if (icmp) { ipKey->l4.tpSrc = htons(icmp->type); ipKey->l4.tpDst = htons(icmp->code); layers->l7Offset = layers->l4Offset + sizeof *icmp; } } } } else { /* Invalid network header */ ((UINT64 *)ipKey)[0] = 0; ((UINT64 *)ipKey)[1] = 0; return NDIS_STATUS_INVALID_PACKET; } } else if (flow->l2.dlType == htons(ETH_TYPE_IPV6)) { NDIS_STATUS status; flow->l2.keyLen += OVS_IPV6_KEY_SIZE; status = OvsParseIPv6(packet, &flow->ipv6Key, layers); if (status != NDIS_STATUS_SUCCESS) { RtlZeroMemory(&flow->ipv6Key, sizeof (Ipv6Key)); return status; } layers->isIPv6 = 1; flow->ipv6Key.l4.tpSrc = 0; flow->ipv6Key.l4.tpDst = 0; flow->ipv6Key.pad = 0; if (flow->ipv6Key.nwProto == SOCKET_IPPROTO_TCP) { OvsParseTcp(packet, &(flow->ipv6Key.l4), layers); } else if (flow->ipv6Key.nwProto == SOCKET_IPPROTO_UDP) { OvsParseUdp(packet, &(flow->ipv6Key.l4), layers); } else if (flow->ipv6Key.nwProto == SOCKET_IPPROTO_SCTP) { OvsParseSctp(packet, &flow->ipv6Key.l4, layers); } else if (flow->ipv6Key.nwProto == SOCKET_IPPROTO_ICMPV6) { OvsParseIcmpV6(packet, &flow->ipv6Key, &flow->icmp6Key, layers); flow->l2.keyLen += (OVS_ICMPV6_KEY_SIZE - OVS_IPV6_KEY_SIZE); } } else if (flow->l2.dlType == htons(ETH_TYPE_ARP)) { EtherArp arpStorage; const EtherArp *arp; ArpKey *arpKey = &flow->arpKey; ((UINT64 *)arpKey)[0] = 0; ((UINT64 *)arpKey)[1] = 0; ((UINT64 *)arpKey)[2] = 0; flow->l2.keyLen += OVS_ARP_KEY_SIZE; arp = OvsGetArp(packet, layers->l3Offset, &arpStorage); if (arp && arp->ea_hdr.ar_hrd == htons(1) && arp->ea_hdr.ar_pro == htons(ETH_TYPE_IPV4) && arp->ea_hdr.ar_hln == ETH_ADDR_LENGTH && arp->ea_hdr.ar_pln == 4) { /* We only match on the lower 8 bits of the opcode. */ if (ntohs(arp->ea_hdr.ar_op) <= 0xff) { arpKey->nwProto = (UINT8)ntohs(arp->ea_hdr.ar_op); } if (arpKey->nwProto == ARPOP_REQUEST || arpKey->nwProto == ARPOP_REPLY) { RtlCopyMemory(&arpKey->nwSrc, arp->arp_spa, 4); RtlCopyMemory(&arpKey->nwDst, arp->arp_tpa, 4); RtlCopyMemory(arpKey->arpSha, arp->arp_sha, ETH_ADDR_LENGTH); RtlCopyMemory(arpKey->arpTha, arp->arp_tha, ETH_ADDR_LENGTH); } } } else if (OvsEthertypeIsMpls(flow->l2.dlType)) { MPLSHdr mplsStorage; const MPLSHdr *mpls; MplsKey *mplsKey = &flow->mplsKey; ((UINT64 *)mplsKey)[0] = 0; flow->l2.keyLen += OVS_MPLS_KEY_SIZE; /* * In the presence of an MPLS label stack the end of the L2 * header and the beginning of the L3 header differ. * * A network packet may contain multiple MPLS labels, but we * are only interested in the topmost label stack entry. * * Advance network header to the beginning of the L3 header. * layers->l3Offset corresponds to the end of the L2 header. */ for (UINT32 i = 0; i < FLOW_MAX_MPLS_LABELS; i++) { mpls = OvsGetMpls(packet, layers->l3Offset, &mplsStorage); if (!mpls) { break; } /* Keep only the topmost MPLS label stack entry. */ if (i == 0) { mplsKey->lse = mpls->lse; } layers->l3Offset += MPLS_HLEN; layers->l4Offset += MPLS_HLEN; if (mpls->lse & htonl(MPLS_BOS_MASK)) { /* * Bottom of Stack bit is set, which means there are no * remaining MPLS labels in the packet. */ break; } } } return NDIS_STATUS_SUCCESS; } __inline BOOLEAN FlowMemoryEqual(UINT64 *src, UINT64 *dst, UINT32 size) { UINT32 i; ASSERT((size & 0x7) == 0); ASSERT(((UINT64)src & 0x7) == 0); ASSERT(((UINT64)dst & 0x7) == 0); for (i = 0; i < (size >> 3); i++) { if (src[i] != dst[i]) { return FALSE; } } return TRUE; } __inline BOOLEAN FlowEqual(OvsFlow *srcFlow, const OvsFlowKey *dstKey, UINT8 *dstStart, UINT64 hash, UINT32 offset, UINT16 size) { return (srcFlow->hash == hash && srcFlow->key.l2.val == dstKey->l2.val && srcFlow->key.recircId == dstKey->recircId && srcFlow->key.dpHash == dstKey->dpHash && srcFlow->key.ct.state == dstKey->ct.state && srcFlow->key.ct.zone == dstKey->ct.zone && srcFlow->key.ct.mark == dstKey->ct.mark && !memcmp(&srcFlow->key.ct.labels, &dstKey->ct.labels, sizeof(struct ovs_key_ct_labels)) && !memcmp(&srcFlow->key.ct.tuple_ipv4, &dstKey->ct.tuple_ipv4, sizeof(struct ovs_key_ct_tuple_ipv4)) && !memcmp(&srcFlow->key.ct.tuple_ipv6, &dstKey->ct.tuple_ipv6, sizeof(struct ovs_key_ct_tuple_ipv6)) && FlowMemoryEqual((UINT64 *)((UINT8 *)&srcFlow->key + offset), (UINT64 *) dstStart, size)); } /* * ---------------------------------------------------------------------------- * AddFlow -- * Add a flow to flow table. * * Results: * NDIS_STATUS_SUCCESS if no same flow in the flow table. * ---------------------------------------------------------------------------- */ NTSTATUS AddFlow(OVS_DATAPATH *datapath, OvsFlow *flow) { PLIST_ENTRY head; if (OvsLookupFlow(datapath, &flow->key, &flow->hash, TRUE) != NULL) { return STATUS_INVALID_HANDLE; } head = &(datapath->flowTable[HASH_BUCKET(flow->hash)]); /* * We need fence here to make sure flow's nextPtr is updated before * head->nextPtr is updated. */ KeMemoryBarrier(); //KeAcquireSpinLock(&FilterDeviceExtension->NblQueueLock, &oldIrql); InsertTailList(head, &flow->ListEntry); //KeReleaseSpinLock(&FilterDeviceExtension->NblQueueLock, oldIrql); datapath->nFlows++; return STATUS_SUCCESS; } /* ---------------------------------------------------------------------------- * RemoveFlow -- * Remove a flow from flow table, and added to wait list * ---------------------------------------------------------------------------- */ VOID RemoveFlow(OVS_DATAPATH *datapath, OvsFlow **flow) { OvsFlow *f = *flow; *flow = NULL; ASSERT(datapath->nFlows); datapath->nFlows--; // Remove the flow from queue RemoveEntryList(&f->ListEntry); FreeFlow(f); } /* * ---------------------------------------------------------------------------- * OvsLookupFlow -- * * Find flow from flow table based on flow key. * Caller should either hold portset handle or should * have a flowRef in datapath or Acquired datapath. * * Results: * Flow pointer if lookup successful. * NULL if not exists. * ---------------------------------------------------------------------------- */ OvsFlow * OvsLookupFlow(OVS_DATAPATH *datapath, const OvsFlowKey *key, UINT64 *hash, BOOLEAN hashValid) { PLIST_ENTRY link, head; UINT16 offset = key->l2.offset; UINT16 size = key->l2.keyLen; UINT8 *start; ASSERT(!OvsIphIsZero(&(key->tunKey.dst)) || offset == sizeof(OvsIPTunnelKey)); ASSERT(OvsIphIsZero(&(key->tunKey.dst)) || offset == OvsGetFlowIPL2Offset(&key->tunKey)); start = (UINT8 *)key + offset; if (!hashValid) { *hash = OvsJhashBytes(start, size, 0); if (key->recircId) { *hash = OvsJhashWords((UINT32*)hash, 1, key->recircId); } if (key->dpHash) { *hash = OvsJhashWords((UINT32*)hash, 1, key->dpHash); } if (key->ct.state) { *hash = OvsJhashWords((UINT32*)hash, 1, key->ct.state); } if (key->ct.zone) { *hash = OvsJhashWords((UINT32*)hash, 1, key->ct.zone); } if (key->ct.mark) { *hash = OvsJhashWords((UINT32*)hash, 1, key->ct.mark); } if (key->ct.labels.ct_labels) { UINT32 lblHash = OvsJhashBytes(&key->ct.labels, sizeof(struct ovs_key_ct_labels), 0); *hash = OvsJhashWords((UINT32*)hash, 1, lblHash); } if (key->ct.tuple_ipv4.ipv4_proto) { UINT32 tupleHash = OvsJhashBytes( &key->ct.tuple_ipv4, sizeof(struct ovs_key_ct_tuple_ipv4), 0); *hash = OvsJhashWords((UINT32*)hash, 1, tupleHash); } if (key->ct.tuple_ipv6.ipv6_proto) { UINT32 tupleHash = OvsJhashBytes(&key->ct.tuple_ipv6, sizeof(struct ovs_key_ct_tuple_ipv6), 0); *hash = OvsJhashWords((UINT32*)hash, 1, tupleHash); } } head = &datapath->flowTable[HASH_BUCKET(*hash)]; link = head->Flink; while (link != head) { OvsFlow *flow = CONTAINING_RECORD(link, OvsFlow, ListEntry); if (FlowEqual(flow, key, start, *hash, offset, size)) { return flow; } link = link->Flink; } return NULL; } /* * ---------------------------------------------------------------------------- * OvsHashFlow -- * Calculate the hash for the given flow key. * ---------------------------------------------------------------------------- */ UINT64 OvsHashFlow(const OvsFlowKey *key) { UINT16 offset = key->l2.offset; UINT16 size = key->l2.keyLen; UINT8 *start; ASSERT(!OvsIphIsZero(&(key->tunKey.dst)) || offset == sizeof(OvsIPTunnelKey)); ASSERT(OvsIphIsZero(&(key->tunKey.dst)) || offset == OvsGetFlowIPL2Offset(&key->tunKey)); start = (UINT8 *)key + offset; return OvsJhashBytes(start, size, 0); } /* * ---------------------------------------------------------------------------- * FreeFlow -- * Free a flow and its actions. * ---------------------------------------------------------------------------- */ VOID FreeFlow(OvsFlow *flow) { ASSERT(flow); OvsFreeMemoryWithTag(flow, OVS_FLOW_POOL_TAG); } NTSTATUS OvsDoDumpFlows(OvsFlowDumpInput *dumpInput, OvsFlowDumpOutput *dumpOutput, UINT32 *replyLen) { UINT32 dpNo; OVS_DATAPATH *datapath = NULL; OvsFlow *flow; PLIST_ENTRY node, head; UINT32 column = 0; UINT32 rowIndex, columnIndex; LOCK_STATE_EX dpLockState; NTSTATUS status = STATUS_SUCCESS; BOOLEAN findNextNonEmpty = FALSE; dpNo = dumpInput->dpNo; if (gOvsSwitchContext->dpNo != dpNo) { status = STATUS_INVALID_PARAMETER; goto exit; } rowIndex = dumpInput->position[0]; if (rowIndex >= OVS_FLOW_TABLE_SIZE) { dumpOutput->n = 0; *replyLen = sizeof(*dumpOutput); goto exit; } columnIndex = dumpInput->position[1]; datapath = &gOvsSwitchContext->datapath; ASSERT(datapath); OvsAcquireDatapathRead(datapath, &dpLockState, FALSE); head = &datapath->flowTable[rowIndex]; node = head->Flink; while (column < columnIndex) { if (node == head) { break; } node = node->Flink; column++; } if (node == head) { findNextNonEmpty = TRUE; columnIndex = 0; } if (findNextNonEmpty) { while (head == node) { if (++rowIndex >= OVS_FLOW_TABLE_SIZE) { dumpOutput->n = 0; goto dp_unlock; } head = &datapath->flowTable[rowIndex]; node = head->Flink; } } ASSERT(node != head); ASSERT(rowIndex < OVS_FLOW_TABLE_SIZE); flow = CONTAINING_RECORD(node, OvsFlow, ListEntry); status = ReportFlowInfo(flow, dumpInput->getFlags, &dumpOutput->flow); if (status == STATUS_BUFFER_TOO_SMALL) { dumpOutput->n = sizeof(OvsFlowDumpOutput) + flow->actionsLen; *replyLen = sizeof(*dumpOutput); } else { dumpOutput->n = 1; //one flow reported. *replyLen = sizeof(*dumpOutput) + dumpOutput->flow.actionsLen; } dumpOutput->position[0] = rowIndex; dumpOutput->position[1] = ++columnIndex; dp_unlock: OvsReleaseDatapath(datapath, &dpLockState); exit: return status; } static NTSTATUS ReportFlowInfo(OvsFlow *flow, UINT32 getFlags, OvsFlowInfo *info) { NTSTATUS status = STATUS_SUCCESS; if (getFlags & FLOW_GET_KEY) { // always copy the tunnel key part RtlCopyMemory(&info->key, &flow->key, flow->key.l2.keyLen + flow->key.l2.offset); } if (getFlags & FLOW_GET_STATS) { OvsFlowStats *stats = &info->stats; stats->packetCount = flow->packetCount; stats->byteCount = flow->byteCount; stats->used = flow->used; stats->tcpFlags = flow->tcpFlags; } if (getFlags & FLOW_GET_ACTIONS) { if (flow->actionsLen == 0) { info->actionsLen = 0; } else { info->actions = flow->actions; info->actionsLen = flow->actionsLen; } } info->key.recircId = flow->key.recircId; info->key.dpHash = flow->key.dpHash; info->key.ct.state = flow->key.ct.state; info->key.ct.zone = flow->key.ct.zone; info->key.ct.mark = flow->key.ct.mark; NdisMoveMemory(&info->key.ct.labels, &flow->key.ct.labels, sizeof(struct ovs_key_ct_labels)); NdisMoveMemory(&info->key.ct.tuple_ipv4, &flow->key.ct.tuple_ipv4, sizeof(struct ovs_key_ct_tuple_ipv4)); NdisMoveMemory(&info->key.ct.tuple_ipv6, &flow->key.ct.tuple_ipv6, sizeof(struct ovs_key_ct_tuple_ipv6)); return status; } NTSTATUS OvsPutFlowIoctl(PVOID inputBuffer, UINT32 inputLength, struct OvsFlowStats *stats) { NTSTATUS status = STATUS_SUCCESS; OVS_DATAPATH *datapath = NULL; ULONG actionsLen; OvsFlowPut *put; UINT32 dpNo; LOCK_STATE_EX dpLockState; if ((inputLength < sizeof(OvsFlowPut)) || (inputBuffer == NULL)) { return STATUS_INFO_LENGTH_MISMATCH; } put = (OvsFlowPut *)inputBuffer; if (put->actionsLen > 0) { actionsLen = put->actionsLen; } else { actionsLen = 0; } dpNo = put->dpNo; if (gOvsSwitchContext->dpNo != dpNo) { status = STATUS_INVALID_PARAMETER; goto exit; } datapath = &gOvsSwitchContext->datapath; ASSERT(datapath); OvsAcquireDatapathWrite(datapath, &dpLockState, FALSE); status = HandleFlowPut(put, datapath, stats); OvsReleaseDatapath(datapath, &dpLockState); exit: return status; } /* Handles flow add, modify as well as delete */ static NTSTATUS HandleFlowPut(OvsFlowPut *put, OVS_DATAPATH *datapath, struct OvsFlowStats *stats) { BOOLEAN mayCreate, mayModify, mayDelete; OvsFlow *KernelFlow; UINT64 hash; NTSTATUS status = STATUS_SUCCESS; mayCreate = (put->flags & OVSWIN_FLOW_PUT_CREATE) != 0; mayModify = (put->flags & OVSWIN_FLOW_PUT_MODIFY) != 0; mayDelete = (put->flags & OVSWIN_FLOW_PUT_DELETE) != 0; if ((mayCreate || mayModify) == mayDelete) { return STATUS_INVALID_PARAMETER; } KernelFlow = OvsLookupFlow(datapath, &put->key, &hash, FALSE); if (!KernelFlow) { if (!mayCreate) { return STATUS_INVALID_PARAMETER; } status = OvsPrepareFlow(&KernelFlow, put, hash); if (status != STATUS_SUCCESS) { return STATUS_UNSUCCESSFUL; } status = AddFlow(datapath, KernelFlow); if (status != STATUS_SUCCESS) { FreeFlow(KernelFlow); return STATUS_UNSUCCESSFUL; } #if DBG /* Validate the flow addition */ { UINT64 newHash; OvsFlow *flow = OvsLookupFlow(datapath, &put->key, &newHash, FALSE); ASSERT(flow); ASSERT(newHash == hash); if (!flow || newHash != hash) { return STATUS_UNSUCCESSFUL; } } #endif } else { stats->packetCount = KernelFlow->packetCount; stats->byteCount = KernelFlow->byteCount; stats->tcpFlags = KernelFlow->tcpFlags; stats->used = KernelFlow->used; if (mayModify) { OvsFlow *newFlow; status = OvsPrepareFlow(&newFlow, put, hash); if (status != STATUS_SUCCESS) { return STATUS_UNSUCCESSFUL; } if ((put->flags & OVSWIN_FLOW_PUT_CLEAR) == 0) { newFlow->packetCount = KernelFlow->packetCount; newFlow->byteCount = KernelFlow->byteCount; newFlow->tcpFlags = KernelFlow->tcpFlags; newFlow->used = KernelFlow->used; } RemoveFlow(datapath, &KernelFlow); status = AddFlow(datapath, newFlow); ASSERT(status == STATUS_SUCCESS); #if DBG /* Validate the flow addition */ { UINT64 newHash; OvsFlow *testflow = OvsLookupFlow(datapath, &put->key, &newHash, FALSE); ASSERT(testflow); ASSERT(newHash == hash); if (!testflow || newHash != hash) { FreeFlow(newFlow); return STATUS_UNSUCCESSFUL; } } #endif } else { if (mayDelete) { if (KernelFlow) { RemoveFlow(datapath, &KernelFlow); } } else { /* Return duplicate if an identical flow already exists. */ return STATUS_DUPLICATE_NAME; } } } return STATUS_SUCCESS; } static NTSTATUS OvsPrepareFlow(OvsFlow **flow, const OvsFlowPut *put, UINT64 hash) { OvsFlow *localFlow = *flow; NTSTATUS status = STATUS_SUCCESS; do { *flow = localFlow = OvsAllocateMemoryWithTag(sizeof(OvsFlow) + put->actionsLen, OVS_FLOW_POOL_TAG); if (localFlow == NULL) { status = STATUS_NO_MEMORY; break; } localFlow->key = put->key; localFlow->actionsLen = put->actionsLen; if (put->actionsLen) { NdisMoveMemory((PUCHAR)localFlow->actions, put->actions, put->actionsLen); } localFlow->userActionsLen = 0; // 0 indicate no conversion is made localFlow->used = 0; localFlow->packetCount = 0; localFlow->byteCount = 0; localFlow->tcpFlags = 0; localFlow->hash = hash; } while(FALSE); return status; } NTSTATUS OvsGetFlowIoctl(PVOID inputBuffer, PVOID outputBuffer) { NTSTATUS status = STATUS_SUCCESS; OVS_DATAPATH *datapath = NULL; OvsFlow *flow; UINT32 getFlags, getActionsLen; OvsFlowGetInput *getInput; OvsFlowGetOutput *getOutput; UINT64 hash; UINT32 dpNo; LOCK_STATE_EX dpLockState; getInput = (OvsFlowGetInput *) inputBuffer; getFlags = getInput->getFlags; getActionsLen = getInput->actionsLen; if (outputBuffer == NULL) { return STATUS_INFO_LENGTH_MISMATCH; } dpNo = getInput->dpNo; if (gOvsSwitchContext->dpNo != dpNo) { status = STATUS_INVALID_PARAMETER; goto exit; } datapath = &gOvsSwitchContext->datapath; ASSERT(datapath); OvsAcquireDatapathRead(datapath, &dpLockState, FALSE); flow = OvsLookupFlow(datapath, &getInput->key, &hash, FALSE); if (!flow) { status = STATUS_INVALID_PARAMETER; goto dp_unlock; } getOutput = (OvsFlowGetOutput *)outputBuffer; ReportFlowInfo(flow, getFlags, &getOutput->info); dp_unlock: OvsReleaseDatapath(datapath, &dpLockState); exit: return status; } NTSTATUS OvsFlushFlowIoctl(UINT32 dpNo) { NTSTATUS status = STATUS_SUCCESS; OVS_DATAPATH *datapath = NULL; LOCK_STATE_EX dpLockState; if (gOvsSwitchContext->dpNo != dpNo) { status = STATUS_INVALID_PARAMETER; goto exit; } datapath = &gOvsSwitchContext->datapath; ASSERT(datapath); OvsAcquireDatapathWrite(datapath, &dpLockState, FALSE); DeleteAllFlows(datapath); OvsReleaseDatapath(datapath, &dpLockState); exit: return status; } UINT32 OvsFlowKeyAttrSize(void) { return NlAttrTotalSize(4) /* OVS_KEY_ATTR_PRIORITY */ + NlAttrTotalSize(0) /* OVS_KEY_ATTR_TUNNEL */ + OvsTunKeyAttrSize() + NlAttrTotalSize(4) /* OVS_KEY_ATTR_IN_PORT */ + NlAttrTotalSize(4) /* OVS_KEY_ATTR_SKB_MARK */ + NlAttrTotalSize(4) /* OVS_KEY_ATTR_DP_HASH */ + NlAttrTotalSize(4) /* OVS_KEY_ATTR_RECIRC_ID */ + NlAttrTotalSize(4) /* OVS_KEY_ATTR_CT_STATE */ + NlAttrTotalSize(2) /* OVS_KEY_ATTR_CT_ZONE */ + NlAttrTotalSize(4) /* OVS_KEY_ATTR_CT_MARK */ + NlAttrTotalSize(16) /* OVS_KEY_ATTR_CT_LABELS */ + NlAttrTotalSize(13) /* OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4 */ + NlAttrTotalSize(12) /* OVS_KEY_ATTR_ETHERNET */ + NlAttrTotalSize(2) /* OVS_KEY_ATTR_ETHERTYPE */ + NlAttrTotalSize(4) /* OVS_KEY_ATTR_VLAN */ + NlAttrTotalSize(0) /* OVS_KEY_ATTR_ENCAP */ + NlAttrTotalSize(2) /* OVS_KEY_ATTR_ETHERTYPE */ + NlAttrTotalSize(40) /* OVS_KEY_ATTR_IPV6 */ + NlAttrTotalSize(2) /* OVS_KEY_ATTR_ICMPV6 */ + NlAttrTotalSize(28); /* OVS_KEY_ATTR_ND */ } UINT32 OvsTunKeyAttrSize(void) { /* Whenever adding new OVS_TUNNEL_KEY_ FIELDS, we should consider * updating this function. */ return NlAttrTotalSize(8) /* OVS_TUNNEL_KEY_ATTR_ID */ + NlAttrTotalSize(4) /* OVS_TUNNEL_KEY_ATTR_IPV4_SRC */ + NlAttrTotalSize(4) /* OVS_TUNNEL_KEY_ATTR_IPV4_DST */ + NlAttrTotalSize(16) /* OVS_TUNNEL_KEY_ATTR_IPV6_SRC */ + NlAttrTotalSize(16) /* OVS_TUNNEL_KEY_ATTR_IPV6_DST */ + NlAttrTotalSize(1) /* OVS_TUNNEL_KEY_ATTR_TOS */ + NlAttrTotalSize(1) /* OVS_TUNNEL_KEY_ATTR_TTL */ + NlAttrTotalSize(0) /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */ + NlAttrTotalSize(0) /* OVS_TUNNEL_KEY_ATTR_CSUM */ + NlAttrTotalSize(0) /* OVS_TUNNEL_KEY_ATTR_OAM */ + NlAttrTotalSize(256) /* OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS */ + NlAttrTotalSize(2) /* OVS_TUNNEL_KEY_ATTR_TP_SRC */ + NlAttrTotalSize(2); /* OVS_TUNNEL_KEY_ATTR_TP_DST */ } /* *---------------------------------------------------------------------------- * OvsProbeSupportedFeature -- * Verifies if the probed feature is supported. * * Results: * STATUS_SUCCESS if the probed feature is supported. *---------------------------------------------------------------------------- */ static NTSTATUS OvsProbeSupportedFeature(POVS_MESSAGE msgIn, PNL_ATTR keyAttr) { NTSTATUS status = STATUS_SUCCESS; PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg); UINT32 keyAttrOffset = (UINT32)((PCHAR)keyAttr - (PCHAR)nlMsgHdr); UINT32 encapOffset = 0; PNL_ATTR keyAttrs[__OVS_KEY_ATTR_MAX] = { NULL }; PNL_ATTR encapAttrs[__OVS_KEY_ATTR_MAX] = { NULL }; /* Get flow keys attributes */ if ((NlAttrParseNested(nlMsgHdr, keyAttrOffset, NlAttrLen(keyAttr), nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy), keyAttrs, ARRAY_SIZE(keyAttrs))) != TRUE) { OVS_LOG_ERROR("Key Attr Parsing failed for msg: %p", nlMsgHdr); status = STATUS_INVALID_PARAMETER; goto done; } if (keyAttrs[OVS_KEY_ATTR_ENCAP]) { encapOffset = (UINT32)((PCHAR)(keyAttrs[OVS_KEY_ATTR_ENCAP]) - (PCHAR)nlMsgHdr); /* Get tunnel keys attributes */ if ((NlAttrParseNested(nlMsgHdr, encapOffset, NlAttrLen(keyAttrs[OVS_KEY_ATTR_ENCAP]), nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy), encapAttrs, ARRAY_SIZE(encapAttrs))) != TRUE) { OVS_LOG_ERROR("Encap Key Attr Parsing failed for msg: %p", nlMsgHdr); status = STATUS_INVALID_PARAMETER; goto done; } } if (keyAttrs[OVS_KEY_ATTR_MPLS] && keyAttrs[OVS_KEY_ATTR_ETHERTYPE]) { ovs_be16 ethType = NlAttrGetU16(keyAttrs[OVS_KEY_ATTR_ETHERTYPE]); if (OvsEthertypeIsMpls(ethType)) { if (!OvsCountMplsLabels(keyAttrs[OVS_KEY_ATTR_MPLS])) { OVS_LOG_ERROR("Maximum supported MPLS labels exceeded."); status = STATUS_INVALID_MESSAGE; } } else { OVS_LOG_ERROR("Wrong ethertype for MPLS attribute."); status = STATUS_INVALID_PARAMETER; } } else if (keyAttrs[OVS_KEY_ATTR_RECIRC_ID]) { UINT32 recircId = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_RECIRC_ID]); if (!recircId) { OVS_LOG_ERROR("Invalid recirculation ID."); status = STATUS_INVALID_PARAMETER; } } else if (keyAttrs[OVS_KEY_ATTR_CT_STATE]) { UINT32 state = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_CT_STATE]); if (!state) { status = STATUS_INVALID_PARAMETER; OVS_LOG_ERROR("Invalid state specified."); } } else if (keyAttrs[OVS_KEY_ATTR_CT_ZONE]) { UINT16 zone = (NlAttrGetU16(keyAttrs[OVS_KEY_ATTR_CT_ZONE])); if (!zone) { OVS_LOG_ERROR("Invalid zone specified."); status = STATUS_INVALID_PARAMETER; } } else if (keyAttrs[OVS_KEY_ATTR_CT_MARK]) { UINT32 mark = (NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_CT_MARK])); if (!mark) { OVS_LOG_ERROR("Invalid ct mark specified."); status = STATUS_INVALID_PARAMETER; } } else if (keyAttrs[OVS_KEY_ATTR_CT_LABELS]) { const struct ovs_key_ct_labels *ct_labels; ct_labels = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_LABELS]); if (!ct_labels->ct_labels) { OVS_LOG_ERROR("Invalid ct label specified."); status = STATUS_INVALID_PARAMETER; } } else if (keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4]) { const struct ovs_key_ct_tuple_ipv4 *ct_tuple_ipv4; ct_tuple_ipv4 = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4]); if (!ct_tuple_ipv4) { OVS_LOG_ERROR("Invalid ct_tuple_ipv4."); status = STATUS_INVALID_PARAMETER; } } else if (keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6]) { const struct ovs_key_ct_tuple_ipv6 *ct_tuple_ipv6; ct_tuple_ipv6 = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6]); if (!ct_tuple_ipv6) { OVS_LOG_ERROR("Invalid ct_tuple_ipv6."); status = STATUS_INVALID_PARAMETER; } } else { OVS_LOG_ERROR("Feature not supported."); status = STATUS_INVALID_PARAMETER; } done: return status; } #pragma warning( pop )
7498028430350ff01d96f8130782a40f6d826e76
aa3befea459382dc5c01c925653d54f435b3fb0f
/arch/arm/src/cxd56xx/cxd56_gnss.c
ac101812e1340ce5c961a71a722ef2c5066d27d2
[ "MIT-open-group", "BSD-3-Clause", "HPND-sell-variant", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "MIT-0", "LicenseRef-scancode-bsd-atmel", "LicenseRef-scancode-gary-s-brown", "LicenseRef-scancode-proprietary-license", "SunPro", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "LicenseRef-scancode-other-permissive", "HPND", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "GPL-1.0-or-later", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
apache/nuttx
14519a7bff4a87935d94fb8fb2b19edb501c7cec
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
refs/heads/master
2023-08-25T06:55:45.822534
2023-08-23T16:03:31
2023-08-24T21:25:47
228,103,273
407
241
Apache-2.0
2023-09-14T18:26:05
2019-12-14T23:27:55
C
UTF-8
C
false
false
85,540
c
cxd56_gnss.c
/**************************************************************************** * arch/arm/src/cxd56xx/cxd56_gnss.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fixedmath.h> #include <fcntl.h> #include <poll.h> #include <errno.h> #include <debug.h> #include <sys/stat.h> #include <nuttx/kmalloc.h> #include <nuttx/mutex.h> #include <nuttx/board.h> #include <nuttx/signal.h> #include <nuttx/fs/fs.h> #include <nuttx/spi/spi.h> #include <arch/chip/gnss.h> #include <arch/chip/pm.h> #include <arch/board/board.h> #include "cxd56_gnss_api.h" #include "cxd56_cpu1signal.h" #include "cxd56_gnss.h" #include "cxd56_pinconfig.h" #if defined(CONFIG_CXD56_GNSS) /**************************************************************************** * External Defined Functions ****************************************************************************/ extern int fw_pm_loadimage(int cpuid, const char *filename); extern int fw_pm_startcpu(int cpuid, int wait); extern int fw_pm_sleepcpu(int cpuid, int mode); /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #ifndef CONFIG_CXD56_GNSS_NPOLLWAITERS # define CONFIG_CXD56_GNSS_NPOLLWAITERS 4 #endif #ifndef CONFIG_CXD56_GNSS_NSIGNALRECEIVERS # define CONFIG_CXD56_GNSS_NSIGNALRECEIVERS 4 #endif #ifndef CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE # define CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE 1024 #endif #ifndef CONFIG_CXD56_GNSS_BACKUP_FILENAME # define CONFIG_CXD56_GNSS_BACKUP_FILENAME "/mnt/spif/gnss_backup.bin" #endif #ifndef CONFIG_CXD56_GNSS_CEP_FILENAME # define CONFIG_CXD56_GNSS_CEP_FILENAME "/mnt/spif/gnss_cep.bin" #endif #define CXD56_GNSS_GPS_CPUID 1 #ifdef CONFIG_CXD56_GNSS_FW_RTK # define CXD56_GNSS_FWNAME "gnssfwrtk" #else # define CXD56_GNSS_FWNAME "gnssfw" #endif #ifndef PM_SLEEP_MODE_COLD # define PM_SLEEP_MODE_COLD 2 #endif #ifndef PM_SLEEP_MODE_HOT_ENABLE # define PM_SLEEP_MODE_HOT_ENABLE 7 #endif #ifndef PM_SLEEP_MODE_HOT_DISABLE # define PM_SLEEP_MODE_HOT_DISABLE 8 #endif /* Notify data of PUBLISH_TYPE_GNSS */ #define CXD56_GNSS_NOTIFY_TYPE_POSITION 0 #define CXD56_GNSS_NOTIFY_TYPE_BOOTCOMP 1 #define CXD56_GNSS_NOTIFY_TYPE_REQBKUPDAT 2 #define CXD56_GNSS_NOTIFY_TYPE_REQCEPOPEN 3 #define CXD56_GNSS_NOTIFY_TYPE_REQCEPCLOSE 4 #define CXD56_GNSS_NOTIFY_TYPE_REQCEPDAT 5 #define CXD56_GNSS_NOTIFY_TYPE_REQCEPBUFFREE 6 /* GNSS core CPU FIFO interface API */ #define CXD56_GNSS_GD_GNSS_START 0 #define CXD56_GNSS_GD_GNSS_STOP 1 #define CXD56_GNSS_GD_GNSS_CEPINITASSISTDATA 2 /* CPU FIFO API bitfield converter */ #define CXD56_GNSS_CPUFIFOAPI_SET_DATA(API, DATA) (((DATA) << 8) | (API)) /* Common info shared with GNSS core */ #define GNSS_SHARED_INFO_MAX_ARGC 6 /* GDSP File read/write arguments */ #define GNSS_ARGS_FILE_OFFSET 0 #define GNSS_ARGS_FILE_BUF 1 #define GNSS_ARGS_FILE_LENGTH 2 /**************************************************************************** * Private Types ****************************************************************************/ struct cxd56_gnss_sig_s { uint8_t enable; pid_t pid; struct cxd56_gnss_signal_info_s info; }; struct cxd56_gnss_shared_info_s { int retval; uint32_t argc; uint32_t argv[GNSS_SHARED_INFO_MAX_ARGC]; }; struct cxd56_devsig_table_s { uint8_t sigtype; cxd56_cpu1sighandler_t handler; }; struct cxd56_gnss_dev_s { mutex_t devlock; sem_t syncsem; uint8_t num_open; uint8_t notify_data; struct file cepfp; void *cepbuf; struct pollfd *fds[CONFIG_CXD56_GNSS_NPOLLWAITERS]; #if CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0 struct cxd56_gnss_sig_s sigs[CONFIG_CXD56_GNSS_NSIGNALRECEIVERS]; #endif struct cxd56_gnss_shared_info_s shared_info; mutex_t ioctllock; sem_t apiwait; int apiret; bool has_event; }; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ /* ioctl command functions */ static int cxd56_gnss_start(struct file *filep, unsigned long arg); static int cxd56_gnss_stop(struct file *filep, unsigned long arg); static int cxd56_gnss_select_satellite_system(struct file *filep, unsigned long arg); static int cxd56_gnss_get_satellite_system(struct file *filep, unsigned long arg); static int cxd56_gnss_set_receiver_position_ellipsoidal(struct file *filep, unsigned long arg); static int cxd56_gnss_set_receiver_position_orthogonal( struct file *filep, unsigned long arg); static int cxd56_gnss_set_ope_mode(struct file *filep, unsigned long arg); static int cxd56_gnss_get_ope_mode(struct file *filep, unsigned long arg); static int cxd56_gnss_set_tcxo_offset(struct file *filep, unsigned long arg); static int cxd56_gnss_get_tcxo_offset(struct file *filep, unsigned long arg); static int cxd56_gnss_set_time(struct file *filep, unsigned long arg); static int cxd56_gnss_get_almanac(struct file *filep, unsigned long arg); static int cxd56_gnss_set_almanac(struct file *filep, unsigned long arg); static int cxd56_gnss_get_ephemeris(struct file *filep, unsigned long arg); static int cxd56_gnss_set_ephemeris(struct file *filep, unsigned long arg); static int cxd56_gnss_save_backup_data(struct file *filep, unsigned long arg); static int cxd56_gnss_erase_backup_data(struct file *filep, unsigned long arg); static int cxd56_gnss_open_cep_data(struct file *filep, unsigned long arg); static int cxd56_gnss_close_cep_data(struct file *filep, unsigned long arg); static int cxd56_gnss_check_cep_data(struct file *filep, unsigned long arg); static int cxd56_gnss_get_cep_age(struct file *filep, unsigned long arg); static int cxd56_gnss_reset_cep_flag(struct file *filep, unsigned long arg); static int cxd56_gnss_set_acquist_data(struct file *filep, unsigned long arg); static int cxd56_gnss_set_frametime(struct file *filep, unsigned long arg); static int cxd56_gnss_set_tau_gps(struct file *filep, unsigned long arg); static int cxd56_gnss_set_time_gps(struct file *filep, unsigned long arg); static int cxd56_gnss_clear_receiver_info(struct file *filep, unsigned long arg); static int cxd56_gnss_set_tow_assist(struct file *filep, unsigned long arg); static int cxd56_gnss_set_utc_model(struct file *filep, unsigned long arg); static int cxd56_gnss_control_spectrum(struct file *filep, unsigned long arg); static int cxd56_gnss_start_test(struct file *filep, unsigned long arg); static int cxd56_gnss_stop_test(struct file *filep, unsigned long arg); static int cxd56_gnss_get_test_result(struct file *filep, unsigned long arg); static int cxd56_gnss_set_signal(struct file *filep, unsigned long arg); static int cxd56_gnss_start_pvtlog(struct file *filep, unsigned long arg); static int cxd56_gnss_stop_pvtlog(struct file *filep, unsigned long arg); static int cxd56_gnss_delete_pvtlog(struct file *filep, unsigned long arg); static int cxd56_gnss_get_pvtlog_status(struct file *filep, unsigned long arg); static int cxd56_gnss_start_rtk_output(struct file *filep, unsigned long arg); static int cxd56_gnss_stop_rtk_output(struct file *filep, unsigned long arg); static int cxd56_gnss_set_rtk_interval(struct file *filep, unsigned long arg); static int cxd56_gnss_get_rtk_interval(struct file *filep, unsigned long arg); static int cxd56_gnss_select_rtk_satellite(struct file *filep, unsigned long arg); static int cxd56_gnss_get_rtk_satellite(struct file *filep, unsigned long arg); static int cxd56_gnss_set_rtk_ephemeris_enable(struct file *filep, unsigned long arg); static int cxd56_gnss_get_rtk_ephemeris_enable(struct file *filep, unsigned long arg); static int cxd56_gnss_start_navmsg_output(struct file *filep, unsigned long arg); static int cxd56_gnss_get_var_ephemeris(struct file *filep, unsigned long arg); static int cxd56_gnss_set_var_ephemeris(struct file *filep, unsigned long arg); static int cxd56_gnss_set_usecase(struct file *filep, unsigned long arg); static int cxd56_gnss_get_usecase(struct file *filep, unsigned long arg); static int cxd56_gnss_set_1pps_output(struct file *filep, unsigned long arg); static int cxd56_gnss_get_1pps_output(struct file *filep, unsigned long arg); /* file operation functions */ static int cxd56_gnss_open(struct file *filep); static int cxd56_gnss_close(struct file *filep); static ssize_t cxd56_gnss_read(struct file *filep, char *buffer, size_t len); static ssize_t cxd56_gnss_write(struct file *filep, const char *buffer, size_t buflen); static int cxd56_gnss_ioctl(struct file *filep, int cmd, unsigned long arg); static int cxd56_gnss_poll(struct file *filep, struct pollfd *fds, bool setup); static int8_t cxd56_gnss_select_notifytype(off_t fpos, uint32_t *offset); static int cxd56_gnss_cpufifo_api(struct file *filep, unsigned int api, unsigned int data); /**************************************************************************** * Private Data ****************************************************************************/ /* This the vtable that supports the character driver interface */ static const struct file_operations g_gnssfops = { cxd56_gnss_open, /* open */ cxd56_gnss_close, /* close */ cxd56_gnss_read, /* read */ cxd56_gnss_write, /* write */ NULL, /* seek */ cxd56_gnss_ioctl, /* ioctl */ NULL, /* mmap */ NULL, /* truncate */ cxd56_gnss_poll /* poll */ }; /* GNSS ioctl command list */ static int (*g_cmdlist[CXD56_GNSS_IOCTL_MAX])(struct file *filep, unsigned long arg) = { NULL, /* CXD56_GNSS_IOCTL_INVAL = 0 */ cxd56_gnss_start, cxd56_gnss_stop, cxd56_gnss_select_satellite_system, cxd56_gnss_get_satellite_system, cxd56_gnss_set_receiver_position_ellipsoidal, cxd56_gnss_set_receiver_position_orthogonal, cxd56_gnss_set_ope_mode, cxd56_gnss_get_ope_mode, cxd56_gnss_set_tcxo_offset, cxd56_gnss_get_tcxo_offset, cxd56_gnss_set_time, cxd56_gnss_get_almanac, cxd56_gnss_set_almanac, cxd56_gnss_get_ephemeris, cxd56_gnss_set_ephemeris, cxd56_gnss_save_backup_data, cxd56_gnss_erase_backup_data, cxd56_gnss_open_cep_data, cxd56_gnss_close_cep_data, cxd56_gnss_check_cep_data, cxd56_gnss_get_cep_age, cxd56_gnss_reset_cep_flag, cxd56_gnss_start_rtk_output, cxd56_gnss_stop_rtk_output, cxd56_gnss_set_rtk_interval, cxd56_gnss_get_rtk_interval, cxd56_gnss_select_rtk_satellite, cxd56_gnss_get_rtk_satellite, cxd56_gnss_set_rtk_ephemeris_enable, cxd56_gnss_get_rtk_ephemeris_enable, cxd56_gnss_set_acquist_data, cxd56_gnss_set_frametime, cxd56_gnss_set_tau_gps, cxd56_gnss_set_time_gps, cxd56_gnss_clear_receiver_info, cxd56_gnss_set_tow_assist, cxd56_gnss_set_utc_model, cxd56_gnss_control_spectrum, cxd56_gnss_start_test, cxd56_gnss_stop_test, cxd56_gnss_get_test_result, cxd56_gnss_set_signal, cxd56_gnss_start_pvtlog, cxd56_gnss_stop_pvtlog, cxd56_gnss_delete_pvtlog, cxd56_gnss_get_pvtlog_status, cxd56_gnss_start_navmsg_output, cxd56_gnss_set_var_ephemeris, cxd56_gnss_get_var_ephemeris, cxd56_gnss_set_usecase, cxd56_gnss_get_usecase, cxd56_gnss_set_1pps_output, cxd56_gnss_get_1pps_output, /* max CXD56_GNSS_IOCTL_MAX */ }; static struct pm_cpu_freqlock_s g_lv_lock = PM_CPUFREQLOCK_INIT(PM_CPUFREQLOCK_TAG('G', 'T', 0), PM_CPUFREQLOCK_FLAG_LV); /* Lock to prohibit clock change in gnss open */ static struct pm_cpu_freqlock_s g_hold_lock = PM_CPUFREQLOCK_INIT(0, PM_CPUFREQLOCK_FLAG_HOLD); #ifdef CONFIG_CXD56_GNSS_CEP_ON_SPIFLASH /* Buffer and length for CEP data on SPI-Flash */ static int g_check_cep_flag = 0; static char *g_cepdata = NULL; static size_t g_ceplen = 0; #endif /**************************************************************************** * Private Functions ****************************************************************************/ /* IOCTL private functions */ /**************************************************************************** * Name: cxd56_gnss_start * * Description: * Process CXD56_GNSS_IOCTL_START command. * Start a positioning * beginning to search the satellites and measure the receiver position * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_start(struct file *filep, unsigned long arg) { int ret; int retry = 50; uint8_t start_mode = (uint8_t)arg; ret = board_lna_power_control(true); if (ret < 0) { return ret; } while (!g_rtc_enabled && 0 < retry--) { /* GNSS requires stable RTC */ nxsig_usleep(100 * 1000); } ret = cxd56_gnss_cpufifo_api(filep, CXD56_GNSS_GD_GNSS_START, start_mode); if (ret < 0) { board_lna_power_control(false); } return ret; } /**************************************************************************** * Name: cxd56_gnss_stop * * Description: * Process CXD56_GNSS_IOCTL_STOP command. * Stop a positioning. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_stop(struct file *filep, unsigned long arg) { int ret; ret = cxd56_gnss_cpufifo_api(filep, CXD56_GNSS_GD_GNSS_STOP, 0); board_lna_power_control(false); return ret; } /**************************************************************************** * Name: cxd56_gnss_get_satellite_system * * Description: * Process CXD56_GNSS_IOCTL_SELECT_SATELLITE_SYSTEM command. * Select GNSSs to positioning * These are able to specified by CXD56_GNSS_B_SAT_XXX defines. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_select_satellite_system(struct file *filep, unsigned long arg) { uint32_t system = (uint32_t)arg; return fw_gd_selectsatellitesystem(system); } /**************************************************************************** * Name: cxd56_gnss_get_satellite_system * * Description: * Process CXD56_GNSS_IOCTL_GET_SATELLITE_SYSTEM command. * Get current using GNSSs to positioning * A argument 'satellite' indicates current GNSSs by bit fields defined by * CXD56_GNSS_B_SAT_XXX. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_satellite_system(struct file *filep, unsigned long arg) { int ret; uint32_t system = 0; if (!arg) { return -EINVAL; } ret = fw_gd_getsatellitesystem(&system); *(uint32_t *)arg = system; return ret; } /**************************************************************************** * Name: cxd56_gnss_set_receiver_position_ellipsoidal * * Description: * Process CXD56_GNSS_IOCTL_SET_RECEIVER_POSITION_ELLIPSOIDAL command. * Set the rough receiver position * arg = { double lat, double lon, double height } * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_receiver_position_ellipsoidal(struct file *filep, unsigned long arg) { struct cxd56_gnss_ellipsoidal_position_s *pos; if (!arg) { return -EINVAL; } pos = (struct cxd56_gnss_ellipsoidal_position_s *)arg; return fw_gd_setreceiverpositionellipsoidal(&pos->latitude, &pos->longitude, &pos->altitude); } /**************************************************************************** * Name: cxd56_gnss_set_receiver_position_orthogonal * * Description: * Process CXD56_GNSS_IOCTL_SET_RECEIVER_POSITION_ORTHOGONAL command. * Set the rough receiver position as orgothonal * arg = { int32_t x, int32_t y, int32_t z } * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_receiver_position_orthogonal( struct file *filep, unsigned long arg) { struct cxd56_gnss_orthogonal_position_s *pos; if (!arg) { return -EINVAL; } pos = (struct cxd56_gnss_orthogonal_position_s *)arg; return fw_gd_setreceiverpositionorthogonal(pos->x, pos->y, pos->z); } /**************************************************************************** * Name: cxd56_gnss_set_ope_mode * * Description: * Process CXD56_GNSS_IOCTL_SET_OPE_MODE command. * Set GNSS operation mode. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_ope_mode(struct file *filep, unsigned long arg) { struct cxd56_gnss_ope_mode_param_s *ope_mode; if (!arg) { return -EINVAL; } ope_mode = (struct cxd56_gnss_ope_mode_param_s *)arg; return fw_gd_setoperationmode(ope_mode->mode, ope_mode->cycle); } /**************************************************************************** * Name: cxd56_gnss_get_ope_mode * * Description: * Process CXD56_GNSS_IOCTL_GET_OPE_MODE command. * Set the TCXO offset * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_ope_mode(struct file *filep, unsigned long arg) { struct cxd56_gnss_ope_mode_param_s *ope_mode; if (!arg) { return -EINVAL; } ope_mode = (struct cxd56_gnss_ope_mode_param_s *)arg; return fw_gd_getoperationmode(&ope_mode->mode, &ope_mode->cycle); } /**************************************************************************** * Name: cxd56_gnss_set_tcxo_offset * * Description: * Process CXD56_GNSS_IOCTL_SET_TCXO_OFFSET command. * Set the TCXO offset * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_tcxo_offset(struct file *filep, unsigned long arg) { int32_t offset = (int32_t)arg; return fw_gd_settcxooffset(offset); } /**************************************************************************** * Name: cxd56_gnss_get_tcxo_offset * * Description: * Process CXD56_GNSS_IOCTL_GET_TCXO_OFFSET command. * Get the TCXO offset * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_tcxo_offset(struct file *filep, unsigned long arg) { int ret; int32_t offset = 0; if (!arg) { return -EINVAL; } ret = fw_gd_gettcxooffset(&offset); *(uint32_t *)arg = offset; return ret; } /**************************************************************************** * Name: cxd56_gnss_set_time * * Description: * Process CXD56_GNSS_IOCTL_SET_TIME command. * Set the estimated current time of the receiver. * 1st argument date & time are in UTC. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_time(struct file *filep, unsigned long arg) { struct cxd56_gnss_datetime_s *date_time; int ret; if (!arg) { return -EINVAL; } date_time = (struct cxd56_gnss_datetime_s *)arg; up_pm_acquire_freqlock(&g_lv_lock); ret = fw_gd_settime(&date_time->date, &date_time->time); up_pm_release_freqlock(&g_lv_lock); return ret; } /**************************************************************************** * Name: cxd56_gnss_get_almanac * * Description: * Process CXD56_GNSS_IOCTL_GET_ALMANAC command. * Get the almanac data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_almanac(struct file *filep, unsigned long arg) { struct cxd56_gnss_orbital_param_s *param; uint32_t almanac_size; if (!arg) { return -EINVAL; } param = (struct cxd56_gnss_orbital_param_s *)arg; return fw_gd_getalmanac(param->type, param->data, &almanac_size); } /**************************************************************************** * Name: cxd56_gnss_set_almanac * * Description: * Process CXD56_GNSS_IOCTL_SET_ALMANAC command. * Set the almanac data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_almanac(struct file *filep, unsigned long arg) { struct cxd56_gnss_orbital_param_s *param; if (!arg) { return -EINVAL; } param = (struct cxd56_gnss_orbital_param_s *)arg; return fw_gd_setalmanac(param->type, param->data); } /**************************************************************************** * Name: cxd56_gnss_get_ephemeris * * Description: * Process CXD56_GNSS_IOCTL_GET_EPHEMERIS command. * Get the Ephemeris data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_ephemeris(struct file *filep, unsigned long arg) { struct cxd56_gnss_orbital_param_s *param; uint32_t ephemeris_size; if (!arg) { return -EINVAL; } param = (struct cxd56_gnss_orbital_param_s *)arg; return fw_gd_getephemeris(param->type, param->data, &ephemeris_size); } /**************************************************************************** * Name: cxd56_gnss_set_ephemeris * * Description: * Process CXD56_GNSS_IOCTL_SET_EPHEMERIS command. * Set the Ephemeris data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_ephemeris(struct file *filep, unsigned long arg) { struct cxd56_gnss_orbital_param_s *param; if (!arg) { return -EINVAL; } param = (struct cxd56_gnss_orbital_param_s *)arg; return fw_gd_setephemeris(param->type, param->data); } /**************************************************************************** * Name: cxd56_gnss_save_backup_data * * Description: * Process CXD56_GNSS_IOCTL_SAVE_BACKUP_DATA command. * Save the backup data to a Flash memory. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_save_backup_data(struct file *filep, unsigned long arg) { char *buf; struct file file; int n = 0; int32_t offset = 0; buf = (char *)kmm_malloc(CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE); if (buf == NULL) { return -ENOMEM; } n = file_open(&file, CONFIG_CXD56_GNSS_BACKUP_FILENAME, O_WRONLY | O_CREAT | O_TRUNC); if (n < 0) { kmm_free(buf); return n; } do { n = fw_gd_readbuffer(CXD56_CPU1_DATA_TYPE_BACKUP, offset, buf, CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE); if (n <= 0) { break; } n = file_write(&file, buf, n); offset += n; } while (n == CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE); kmm_free(buf); file_close(&file); return n < 0 ? n : 0; } /**************************************************************************** * Name: cxd56_gnss_erase_backup_data * * Description: * Process CXD56_GNSS_IOCTL_ERASE_BACKUP_DATA command. * Erase the backup data on a Flash memory. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_erase_backup_data(struct file *filep, unsigned long arg) { return nx_unlink(CONFIG_CXD56_GNSS_BACKUP_FILENAME); } /**************************************************************************** * Name: cxd56_gnss_open_cep_data * * Description: * Process CXD56_GNSS_IOCTL_OPEN_CEP_DATA command. * Open CEP data file * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_open_cep_data(struct file *filep, unsigned long arg) { return cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CEPFILE, TRUE); } /**************************************************************************** * Name: cxd56_gnss_close_cep_data * * Description: * Process CXD56_GNSS_IOCTL_CLOSE_CEP_DATA command. * Close CEP data file * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_close_cep_data(struct file *filep, unsigned long arg) { return cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CEPFILE, FALSE); } /**************************************************************************** * Name: cxd56_gnss_check_cep_data * * Description: * Process CXD56_GNSS_IOCTL_CHECK_CEP_DATA command. * Check CEP data valid * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ #ifdef CONFIG_CXD56_GNSS_CEP_ON_SPIFLASH static int cxd56_gnss_check_cep_data(struct file *filep, unsigned long arg) { int ret; struct stat statbuf; struct inode *inode; struct cxd56_gnss_dev_s *priv; inode = filep->f_inode; priv = (struct cxd56_gnss_dev_s *)inode->i_private; /* Set a flag for checking CEP data */ g_check_cep_flag = 1; /* Allocate a buffer and read all of CEP data to it */ g_cepdata = NULL; g_ceplen = 0; ret = file_fstat(&priv->cepfp, &statbuf); if (ret == 0) { g_ceplen = (size_t)statbuf.st_size; } else { return ret; } if (g_ceplen > 0) { g_cepdata = (char *)kmm_malloc(g_ceplen); } if (!g_cepdata) { gnsserr("Failed to allocate cep data\n"); return -ENOMEM; } /* Set the file position to the beginning before reading */ ret = file_seek(&priv->cepfp, 0, SEEK_SET); if (ret < 0) { goto errout; } ret = file_read(&priv->cepfp, g_cepdata, g_ceplen); if (ret < 0) { goto errout; } ret = fw_gd_cepcheckassistdata(); errout: /* Free an allocated buffer */ if (g_cepdata) { kmm_free(g_cepdata); g_cepdata = NULL; g_ceplen = 0; } /* Clear a flag for checking CEP data */ g_check_cep_flag = 0; return ret; } #else /* !CONFIG_CXD56_GNSS_CEP_ON_SPIFLASH */ static int cxd56_gnss_check_cep_data(struct file *filep, unsigned long arg) { return fw_gd_cepcheckassistdata(); } #endif /**************************************************************************** * Name: cxd56_gnss_get_cep_age * * Description: * Process CXD56_GNSS_IOCTL_GET_CEP_AGE command. * Get CEP valid term * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_cep_age(struct file *filep, unsigned long arg) { struct cxd56_gnss_cep_age_s *age; if (!arg) { return -EINVAL; } age = (struct cxd56_gnss_cep_age_s *)arg; return fw_gd_cepgetagedata(&age->age, &age->cepi); } /**************************************************************************** * Name: cxd56_gnss_reset_cep_flag * * Description: * Process CXD56_GNSS_IOCTL_RESET_CEP_FLAG command. * Reset CEP data init flag & valid flag * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_reset_cep_flag(struct file *filep, unsigned long arg) { return cxd56_gnss_cpufifo_api(filep, CXD56_GNSS_GD_GNSS_CEPINITASSISTDATA, 0); } /**************************************************************************** * Name: cxd56_gnss_set_acquist_data * * Description: * Process CXD56_GNSS_IOCTL_AGPS_SET_ACQUIST command. * AGPS set acquist data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_acquist_data(struct file *filep, unsigned long arg) { struct cxd56_gnss_agps_acquist_s *acquist; if (!arg) { return -EINVAL; } acquist = (struct cxd56_gnss_agps_acquist_s *)arg; return fw_gd_setacquist(acquist->data, acquist->size); } /**************************************************************************** * Name: cxd56_gnss_set_frametime * * Description: * Process CXD56_GNSS_IOCTL_AGPS_SET_FRAMETIME command. * AGPS set frame time * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_frametime(struct file *filep, unsigned long arg) { struct cxd56_gnss_agps_frametime_s *frametime; if (!arg) { return -EINVAL; } frametime = (struct cxd56_gnss_agps_frametime_s *)arg; return fw_gd_setframetime(frametime->sec, frametime->frac); } /**************************************************************************** * Name: cxd56_gnss_set_tau_gps * * Description: * Process CXD56_GNSS_IOCTL_AGPS_SET_TAU_GPS command. * AGPS set TAU GPS * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_tau_gps(struct file *filep, unsigned long arg) { struct cxd56_gnss_agps_tau_gps_s *taugpstime; if (!arg) { return -EINVAL; } taugpstime = (struct cxd56_gnss_agps_tau_gps_s *)arg; return fw_gd_settaugps(&taugpstime->taugps); } /**************************************************************************** * Name: cxd56_gnss_set_time_gps * * Description: * Process CXD56_GNSS_IOCTL_AGPS_SET_TIME_GPS command. * Set high precision receiver time * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_time_gps(struct file *filep, unsigned long arg) { struct cxd56_gnss_agps_time_gps_s *time_gps; if (!arg) { return -EINVAL; } time_gps = (struct cxd56_gnss_agps_time_gps_s *)arg; return fw_gd_settimegps(&time_gps->date, &time_gps->time); } /**************************************************************************** * Name: cxd56_gnss_clear_receiver_info * * Description: * Process CXD56_GNSS_IOCTL_AGPS_CLEAR_RECEIVER_INFO command. * Clear info(s) for hot start such as ephemeris. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_clear_receiver_info(struct file *filep, unsigned long arg) { uint32_t clear_type = arg; return fw_gd_clearreceiverinfo(clear_type); } /**************************************************************************** * Name: cxd56_gnss_set_tow_assist * * Description: * Process CXD56_GNSS_IOCTL_AGPS_SET_TOW_ASSIST command. * AGPS set acquist data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_tow_assist(struct file *filep, unsigned long arg) { struct cxd56_gnss_agps_tow_assist_s *assist; if (!arg) { return -EINVAL; } assist = (struct cxd56_gnss_agps_tow_assist_s *)arg; return fw_gd_settowassist(assist->data, assist->size); } /**************************************************************************** * Name: cxd56_gnss_set_utc_model * * Description: * Process CXD56_GNSS_IOCTL_AGPS_SET_UTC_MODEL command. * AGPS set UTC model * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_utc_model(struct file *filep, unsigned long arg) { struct cxd56_gnss_agps_utc_model_s *model; if (!arg) { return -EINVAL; } model = (struct cxd56_gnss_agps_utc_model_s *)arg; return fw_gd_setutcmodel(model->data, model->size); } /**************************************************************************** * Name: cxd56_gnss_control_spectrum * * Description: * Process CXD56_GNSS_IOCTL_SPECTRUM_CONTROL command. * Enable or not to output spectrum data of GNSS signal * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_control_spectrum(struct file *filep, unsigned long arg) { struct cxd56_gnss_spectrum_control_s *control; if (!arg) { return -EINVAL; } control = (struct cxd56_gnss_spectrum_control_s *)arg; return fw_gd_spectrumcontrol(control->time, control->enable, control->point1, control->step1, control->point2, control->step2); } /**************************************************************************** * Name: cxd56_gnss_start_test * * Description: * Process CXD56_GNSS_IOCTL_FACTORY_START_TEST command. * Start GPS factory test * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_start_test(struct file *filep, unsigned long arg) { int ret; int retry = 50; struct cxd56_gnss_test_info_s *info; /* check argument */ if (!arg) { ret = -EINVAL; } else { /* Power on the LNA device */ ret = board_lna_power_control(true); if (ret < 0) { return ret; } while (!g_rtc_enabled && 0 < retry--) { /* GNSS requires stable RTC */ nxsig_usleep(100 * 1000); } /* set parameter */ info = (struct cxd56_gnss_test_info_s *)arg; fw_gd_startgpstest(info->satellite, info->reserve1, info->reserve2, info->reserve3); /* start test */ ret = fw_gd_start(CXD56_GNSS_STMOD_COLD); } return ret; } /**************************************************************************** * Name: cxd56_gnss_stop_test * * Description: * Process CXD56_GNSS_IOCTL_FACTORY_STOP_TEST command. * Stop GPS factory test * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_stop_test(struct file *filep, unsigned long arg) { int ret; /* term test */ ret = fw_gd_stopgpstest(); if (ret == OK) { /* stop test */ ret = fw_gd_stop(); } /* Power off the LNA device */ board_lna_power_control(false); return ret; } /**************************************************************************** * Name: cxd56_gnss_get_test_result * * Description: * Process CXD56_GNSS_IOCTL_FACTORY_GET_TEST_RESULT command. * Get GPS factory test result * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_test_result(struct file *filep, unsigned long arg) { struct cxd56_gnss_test_result_s *result; if (!arg) { return -EINVAL; } result = (struct cxd56_gnss_test_result_s *)arg; return fw_gd_getgpstestresult(&result->cn, &result->doppler); } /**************************************************************************** * Name: cxd56_gnss_set_signal * * Description: * Process CXD56_GNSS_IOCTL_SIGNAL_SET command. * Set signal information for synchronous reading data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_signal(struct file *filep, unsigned long arg) { int ret = 0; #if CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0 struct inode *inode; struct cxd56_gnss_dev_s *priv; struct cxd56_gnss_signal_setting_s *setting; struct cxd56_gnss_sig_s *sig; struct cxd56_gnss_sig_s *checksig; pid_t pid; int i; if (!arg) { return -EINVAL; } setting = (struct cxd56_gnss_signal_setting_s *)arg; if (setting->gnsssig >= CXD56_CPU1_DATA_TYPE_MAX) { return -EPROTOTYPE; } inode = filep->f_inode; priv = (struct cxd56_gnss_dev_s *)inode->i_private; ret = nxmutex_lock(&priv->devlock); if (ret < 0) { return ret; } sig = NULL; pid = nxsched_getpid(); for (i = 0; i < CONFIG_CXD56_GNSS_NSIGNALRECEIVERS; i++) { checksig = &priv->sigs[i]; if (setting->enable) { if (sig == NULL && !checksig->enable) { sig = checksig; } else if (checksig->info.gnsssig == setting->gnsssig && checksig->pid == pid) { sig = checksig; break; } } else if (checksig->info.gnsssig == setting->gnsssig && checksig->pid == pid) { checksig->enable = 0; goto success; } } if (sig == NULL) { ret = -ENOENT; goto err; } fw_gd_setnotifymask(setting->gnsssig, FALSE); sig->enable = 1; sig->pid = pid; sig->info.fd = setting->fd; sig->info.gnsssig = setting->gnsssig; sig->info.signo = setting->signo; sig->info.data = setting->data; success: err: nxmutex_unlock(&priv->devlock); #endif /* CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0 */ return ret; } /**************************************************************************** * Name: cxd56_gnss_start_pvtlog * * Description: * Process CXD56_GNSS_IOCTL_PVTLOG_START command. * Start saving PVT logs. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_start_pvtlog(struct file *filep, unsigned long arg) { struct cxd56_pvtlog_setting_s *setting; if (!arg) { return -EINVAL; } setting = (struct cxd56_pvtlog_setting_s *)arg; return fw_gd_registerpvtlog(setting->cycle, setting->threshold); } /**************************************************************************** * Name: cxd56_gnss_stop_pvtlog * * Description: * Process CXD56_GNSS_IOCTL_PVTLOG_STOP command. * Stop saving PVT logs. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_stop_pvtlog(struct file *filep, unsigned long arg) { return fw_gd_releasepvtlog(); } /**************************************************************************** * Name: cxd56_gnss_delete_pvtlog * * Description: * Process CXD56_GNSS_IOCTL_PVTLOG_STOP command. * Delete stored PVT logs. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_delete_pvtlog(struct file *filep, unsigned long arg) { return fw_gd_pvtlogdeletelog(); } /**************************************************************************** * Name: cxd56_gnss_get_pvtlog_status * * Description: * Process CXD56_GNSS_IOCTL_PVTLOG_GET_STATUS command. * Get stored log status of PVTLOG. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_pvtlog_status(struct file *filep, unsigned long arg) { struct cxd56_pvtlog_status_s *status; if (!arg) { return -EINVAL; } status = (struct cxd56_pvtlog_status_s *)arg; return fw_gd_pvtloggetlogstatus(&status->status); } /**************************************************************************** * Name: cxd56_gnss_start_rtk_output * * Description: * Process CXD56_GNSS_IOCTL_RTK_START command. * Start RTK data output * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_start_rtk_output(struct file *filep, unsigned long arg) { struct cxd56_rtk_setting_s *setting; if (!arg) { return -EINVAL; } setting = (struct cxd56_rtk_setting_s *)arg; setting->sbasout = 0; return fw_gd_rtkstart(setting); } /**************************************************************************** * Name: cxd56_gnss_stop_rtk_output * * Description: * Process CXD56_GNSS_IOCTL_RTK_STOP command. * Stop RTK data output * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_stop_rtk_output(struct file *filep, unsigned long arg) { return fw_gd_rtkstop(); } /**************************************************************************** * Name: cxd56_gnss_set_rtk_interval * * Description: * Process CXD56_GNSS_IOCTL_RTK_SET_INTERVAL command. * Set RTK data output interval * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_rtk_interval(struct file *filep, unsigned long arg) { int interval = (int)arg; return fw_gd_rtksetoutputinterval(interval); } /**************************************************************************** * Name: cxd56_gnss_get_rtk_interval * * Description: * Process CXD56_GNSS_IOCTL_RTK_GET_INTERVAL command. * Get RTK data output interval setting * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_rtk_interval(struct file *filep, unsigned long arg) { int ret; int interval = 0; if (!arg) { return -EINVAL; } ret = fw_gd_rtkgetoutputinterval(&interval); *(uint32_t *)arg = interval; return ret; } /**************************************************************************** * Name: cxd56_gnss_select_rtk_satellite * * Description: * Process CXD56_GNSS_IOCTL_RTK_SELECT_SATELLITE_SYSTEM command. * Select RTK satellite type * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_select_rtk_satellite(struct file *filep, unsigned long arg) { uint32_t gnss = (uint32_t)arg; return fw_gd_rtksetgnss(gnss); } /**************************************************************************** * Name: cxd56_gnss_get_rtk_ephemeris_enable * * Description: * Process CXD56_GNSS_IOCTL_RTK_GET_SATELLITE_SYSTEM command. * Get RTK satellite type setting * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_rtk_satellite(struct file *filep, unsigned long arg) { int ret; uint32_t gnss = 0; if (!arg) { return -EINVAL; } ret = fw_gd_rtkgetgnss(&gnss); *(uint32_t *)arg = gnss; return ret; } /**************************************************************************** * Name: cxd56_gnss_get_rtk_ephemeris_enable * * Description: * Process CXD56_GNSS_IOCTL_RTK_SET_EPHEMERIS_ENABLER command. * Set RTK ephemeris notify enable setting * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_rtk_ephemeris_enable(struct file *filep, unsigned long arg) { int enable = (int)arg; return fw_gd_rtksetephnotify(enable); } /**************************************************************************** * Name: cxd56_gnss_get_rtk_ephemeris_enable * * Description: * Process CXD56_GNSS_IOCTL_RTK_GET_EPHEMERIS_ENABLER command. * Get RTK ephemeris notify enable setting. * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_rtk_ephemeris_enable(struct file *filep, unsigned long arg) { int ret; int enable = 0; if (!arg) { return -EINVAL; } ret = fw_gd_rtkgetephnotify(&enable); *(uint32_t *)arg = enable; return ret; } /**************************************************************************** * Name: cxd56_gnss_start_navmsg_output * * Description: * Process CXD56_GNSS_IOCTL_NAVMSG_START command. * Start NAVMSG data output * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_start_navmsg_output(struct file *filep, unsigned long arg) { struct cxd56_rtk_setting_s *setting; if (!arg) { return -EINVAL; } setting = (struct cxd56_rtk_setting_s *)arg; return fw_gd_rtkstart(setting); } /**************************************************************************** * Name: cxd56_gnss_set_var_ephemeris * * Description: * Process CXD56_GNSS_IOCTL_SET_VAR_EPHEMERIS command. * Set the Ephemeris data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_var_ephemeris(struct file *filep, unsigned long arg) { struct cxd56_gnss_set_var_ephemeris_s *param; if (!arg) { return -EINVAL; } param = (struct cxd56_gnss_set_var_ephemeris_s *)arg; return fw_gd_setvarephemeris(param->data, param->size); } /**************************************************************************** * Name: cxd56_gnss_get_var_ephemeris * * Description: * Process CXD56_GNSS_IOCTL_GET_VAR_EPHEMERIS command. * Get the Ephemeris data * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_var_ephemeris(struct file *filep, unsigned long arg) { struct cxd56_gnss_get_var_ephemeris_s *param; if (!arg) { return -EINVAL; } param = (struct cxd56_gnss_get_var_ephemeris_s *)arg; return fw_gd_getvarephemeris(param->type, param->data, param->size); } /**************************************************************************** * Name: cxd56_gnss_set_usecase * * Description: * Set usecase mode * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_usecase(struct file *filep, unsigned long arg) { return fw_gd_setusecase(arg); } /**************************************************************************** * Name: cxd56_gnss_get_usecase * * Description: * Get usecase mode * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_usecase(struct file *filep, unsigned long arg) { int ret; uint32_t usecase = 0; if (!arg) { return -EINVAL; } ret = fw_gd_getusecase(&usecase); *(uint32_t *)arg = usecase; return ret; } /**************************************************************************** * Name: cxd56_gnss_set_1pps_output * * Description: * Set enable or disable of 1PPS output * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_set_1pps_output(struct file *filep, unsigned long arg) { if (arg) { /* Enable 1PPS output pin */ #ifdef CONFIG_CXD56_GNSS_1PPS_PIN_GNSS_1PPS_OUT CXD56_PIN_CONFIGS(PINCONFS_GNSS_1PPS_OUT); #else CXD56_PIN_CONFIGS(PINCONFS_HIF_IRQ_OUT_GNSS_1PPS_OUT); #endif } else { /* Disable 1PPS output pin */ #ifdef CONFIG_CXD56_GNSS_1PPS_PIN_GNSS_1PPS_OUT CXD56_PIN_CONFIGS(PINCONFS_GNSS_1PPS_OUT_GPIO); #else CXD56_PIN_CONFIGS(PINCONFS_HIF_IRQ_OUT_GPIO); #endif } return fw_gd_set1ppsoutput(arg); } /**************************************************************************** * Name: cxd56_gnss_get_1pps_output * * Description: * Get the current 1PPS output setting * * Input Parameters: * filep - File structure pointer * arg - Data for command * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_get_1pps_output(struct file *filep, unsigned long arg) { int ret; uint32_t enable = 0; if (!arg) { return -EINVAL; } ret = fw_gd_get1ppsoutput(&enable); *(uint32_t *)arg = enable; return ret; } /* Synchronized with processes and CPUs * CXD56_GNSS signal handler and utils */ /**************************************************************************** * Name: cxd56_gnss_pollnotify * * Description: * Notify POLLIN event for poll * * Input Parameters: * dev - Gnss device structure pointer * ****************************************************************************/ static void cxd56_gnss_pollnotify(struct cxd56_gnss_dev_s *dev) { poll_notify(dev->fds, CONFIG_CXD56_GNSS_NPOLLWAITERS, POLLIN); dev->has_event = true; } /**************************************************************************** * Name: cxd56_gnss_wait_notify * * Description: * Wait notify from GNSS CPU with timeout. * * Input Parameters: * sem - Semaphore for waiting * waitset - Wait time in seconds * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_wait_notify(sem_t *sem, time_t waitsec) { return nxsem_tickwait(sem, SEC2TICK(waitsec)); } /**************************************************************************** * Name: cxd56_gnss_read_cep_file * * Description: * Read a CEP data packet from file and notify to GNSS CPU. * * Input Parameters: * fp - File pointer * offset - File offset of last read * len - packet size to read * retval - Status to read file * * Returned Value: * Buffer address allocated in this function for reading data. * ****************************************************************************/ static char * cxd56_gnss_read_cep_file(struct file *fp, int32_t offset, size_t len, int *retval) { char *buf; int ret; #ifdef CONFIG_CXD56_GNSS_CEP_ON_SPIFLASH if (g_check_cep_flag) { /* If checking CEP data, use a pre-read buffer in advance */ if (offset + len > g_ceplen) { ret = -ENOENT; goto _err0; } buf = &g_cepdata[offset]; *retval = len; cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CEP, (uint32_t)buf); return NULL; } #endif if (fp == NULL) { ret = -ENOENT; goto err0; } buf = (char *)kmm_malloc(len); if (buf == NULL) { ret = -ENOMEM; goto err0; } ret = file_seek(fp, offset, SEEK_SET); if (ret < 0) { goto err1; } ret = file_read(fp, buf, len); if (ret <= 0) { goto err1; } *retval = ret; cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CEP, (uint32_t)buf); return buf; /* Send signal to CPU1 in error for just notify completion of read * sequence. */ err1: kmm_free(buf); err0: *retval = ret; cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CEP, 0); return NULL; } /**************************************************************************** * Name: cxd56_gnss_read_backup_file * * Description: * Read a backup data packet from file and notify to GNSS CPU. * * Input Parameters: * retval - Status to read file * * Returned Value: * None * ****************************************************************************/ static void cxd56_gnss_read_backup_file(int *retval) { char *buf; struct file file; int32_t offset = 0; size_t n; int ret = 0; buf = (char *)kmm_malloc(CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE); if (buf == NULL) { ret = -ENOMEM; goto err; } ret = file_open(&file, CONFIG_CXD56_GNSS_BACKUP_FILENAME, O_RDONLY); if (ret < 0) { kmm_free(buf); goto err; } do { n = file_read(&file, buf, CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE); if (n <= 0) { ret = n; break; } ret = fw_gd_writebuffer(CXD56_CPU1_DATA_TYPE_BACKUP, offset, buf, n); if (ret < 0) { break; } offset += n; } while (n > 0); file_close(&file); kmm_free(buf); /* Notify the termination of backup sequence by write zero length data */ err: *retval = ret; cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_BKUPFILE, 0); } /**************************************************************************** * Name: cxd56_gnss_common_signalhandler * * Description: * Common signal handler from GNSS CPU. * * Input Parameters: * data - Received data from GNSS CPU * userdata - User data, this is the device information specified by the * second argument of the function cxd56_cpu1siginit. * * Returned Value: * None * ****************************************************************************/ #if CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0 static void cxd56_gnss_common_signalhandler(uint32_t data, void *userdata) { struct cxd56_gnss_dev_s *priv = (struct cxd56_gnss_dev_s *)userdata; uint8_t sigtype = CXD56_CPU1_GET_DEV(data); int issetmask = 0; int i; int ret; ret = nxmutex_lock(&priv->devlock); if (ret < 0) { return; } for (i = 0; i < CONFIG_CXD56_GNSS_NSIGNALRECEIVERS; i++) { struct cxd56_gnss_sig_s *sig = &priv->sigs[i]; if (sig->enable && sig->info.gnsssig == sigtype) { union sigval value; value.sival_ptr = &sig->info; nxsig_queue(sig->pid, sig->info.signo, value); issetmask = 1; } } if (issetmask) { fw_gd_setnotifymask(sigtype, FALSE); } nxmutex_unlock(&priv->devlock); } #endif /* CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0 */ /**************************************************************************** * Name: cxd56_gnss_default_sighandler * * Description: * Handler for GNSS type notification from GNSS CPU for signal and poll. * * Input Parameters: * data - Received data from GNSS CPU * userdata - User data, this is the device information specified by the * second argument of the function cxd56_cpu1siginit. * * Returned Value: * None * ****************************************************************************/ static void cxd56_gnss_default_sighandler(uint32_t data, void *userdata) { struct cxd56_gnss_dev_s *priv = (struct cxd56_gnss_dev_s *)userdata; int ret; int dtype = CXD56_CPU1_GET_DATA(data); switch (dtype) { case CXD56_GNSS_NOTIFY_TYPE_REQCEPDAT: { priv->cepbuf = cxd56_gnss_read_cep_file( &priv->cepfp, priv->shared_info.argv[GNSS_ARGS_FILE_OFFSET], priv->shared_info.argv[GNSS_ARGS_FILE_LENGTH], &priv->shared_info.retval); return; } case CXD56_GNSS_NOTIFY_TYPE_REQCEPBUFFREE: if (priv->cepbuf) { kmm_free(priv->cepbuf); } return; case CXD56_GNSS_NOTIFY_TYPE_BOOTCOMP: if (priv->num_open == 0) { /* Post to wait-semaphore in cxd56_gnss_open to notify completion * of GNSS core initialization in first device open. */ priv->notify_data = dtype; nxsem_post(&priv->syncsem); } return; case CXD56_GNSS_NOTIFY_TYPE_REQBKUPDAT: cxd56_gnss_read_backup_file(&priv->shared_info.retval); return; case CXD56_GNSS_NOTIFY_TYPE_REQCEPOPEN: if (priv->cepfp.f_inode != NULL) { file_close(&priv->cepfp); } file_open(&priv->cepfp, CONFIG_CXD56_GNSS_CEP_FILENAME, O_RDONLY); return; case CXD56_GNSS_NOTIFY_TYPE_REQCEPCLOSE: if (priv->cepfp.f_inode != NULL) { file_close(&priv->cepfp); } return; default: break; } ret = nxmutex_lock(&priv->devlock); if (ret < 0) { return; } cxd56_gnss_pollnotify(priv); nxmutex_unlock(&priv->devlock); #if CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0 cxd56_gnss_common_signalhandler(data, userdata); #endif } /**************************************************************************** * Name: cxd56_gnss_cpufifoapi_signalhandler * * Description: * Handler for API type notification from GNSS CPU. * * Input Parameters: * data - Received data from GNSS CPU * userdata - User data, this is the device information specified by the * second argument of the function cxd56_cpu1siginit. * * Returned Value: * None * ****************************************************************************/ static void cxd56_gnss_cpufifoapi_signalhandler(uint32_t data, void *userdata) { struct cxd56_gnss_dev_s *priv = (struct cxd56_gnss_dev_s *)userdata; priv->apiret = CXD56_CPU1_GET_DATA((int)data); nxsem_post(&priv->apiwait); } /**************************************************************************** * Name: cxd56_gnss_cpufifo_api * * Description: * Send API type event to GNSS CPU. * * Input Parameters: * filep - File structure pointer * api - Signal type * data - Any data * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_cpufifo_api(struct file *filep, unsigned int api, unsigned int data) { struct inode *inode; struct cxd56_gnss_dev_s *priv; unsigned int type; int ret = OK; inode = filep->f_inode; priv = (struct cxd56_gnss_dev_s *)inode->i_private; type = CXD56_GNSS_CPUFIFOAPI_SET_DATA(api, data); cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CPUFIFOAPI, type); ret = nxsem_wait(&priv->apiwait); if (ret < 0) { /* If nxsem_wait returns -EINTR, there is a possibility that the signal * for GNSS set with CXD56_GNSS_IOCTL_SIGNAL_SET is unmasked * by SIG_UNMASK in the signal mask. */ _warn("Cannot wait GNSS semaphore %d\n", ret); return ret; } return priv->apiret; } /**************************************************************************** * Name: cxd56_gnss_select_notifytype * * Description: * Decide notify type about data from GNSS device * * Input Parameters: * fpos - file offset indicated about data type * offset - Actual offset value * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int8_t cxd56_gnss_select_notifytype(off_t fpos, uint32_t *offset) { int8_t type; if ((fpos >= CXD56_GNSS_READ_OFFSET_LAST_GNSS) && (fpos < CXD56_GNSS_READ_OFFSET_AGPS)) { type = CXD56_CPU1_DATA_TYPE_GNSS; *offset = fpos; } else if (fpos == CXD56_GNSS_READ_OFFSET_AGPS) { type = CXD56_CPU1_DATA_TYPE_AGPS; *offset = 0; } else if (fpos == CXD56_GNSS_READ_OFFSET_RTK) { type = CXD56_CPU1_DATA_TYPE_RTK; *offset = 0; } else if (fpos == CXD56_GNSS_READ_OFFSET_GPSEPHEMERIS) { type = CXD56_CPU1_DATA_TYPE_GPSEPHEMERIS; *offset = 0; } else if (fpos == CXD56_GNSS_READ_OFFSET_GLNEPHEMERIS) { type = CXD56_CPU1_DATA_TYPE_GLNEPHEMERIS; *offset = 0; } else if ((fpos == CXD56_GNSS_READ_OFFSET_SPECTRUM) || (fpos == CXD56_GNSS_READ_OFFSET_INFO)) { type = CXD56_CPU1_DATA_TYPE_SPECTRUM; *offset = 0; } else if (fpos == CXD56_GNSS_READ_OFFSET_PVTLOG) { type = CXD56_CPU1_DATA_TYPE_PVTLOG; *offset = 0; } else if (fpos == CXD56_GNSS_READ_OFFSET_SBAS) { type = CXD56_CPU1_DATA_TYPE_SBAS; *offset = 0; } else if (fpos == CXD56_GNSS_READ_OFFSET_DCREPORT) { type = CXD56_CPU1_DATA_TYPE_DCREPORT; *offset = 0; } else if (fpos == CXD56_GNSS_READ_OFFSET_SARRLM) { type = CXD56_CPU1_DATA_TYPE_SARRLM; *offset = 0; } else { type = -1; } return type; } /**************************************************************************** * Name: cxd56_gnss_initialize * * Description: * initialize gnss device * * Input Parameters: * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_initialize(struct cxd56_gnss_dev_s *dev) { int32_t ret = 0; return ret; } /**************************************************************************** * Name: cxd56_gnss_open * * Description: * Standard character driver open method. * * Input Parameters: * filep - File structure pointer * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_open(struct file *filep) { struct inode *inode; struct cxd56_gnss_dev_s *priv; int ret = OK; int retry = 50; inode = filep->f_inode; priv = (struct cxd56_gnss_dev_s *)inode->i_private; while (!g_rtc_enabled && 0 < retry--) { /* GNSS requires stable RTC */ usleep(100 * 1000); } ret = nxmutex_lock(&priv->devlock); if (ret < 0) { return ret; } if (priv->num_open == 0) { nxsem_init(&priv->syncsem, 0, 0); /* Prohibit the clock change during loading image */ up_pm_acquire_freqlock(&g_hold_lock); ret = fw_pm_loadimage(CXD56_GNSS_GPS_CPUID, CXD56_GNSS_FWNAME); /* Allow the clock change after loading image */ up_pm_release_freqlock(&g_hold_lock); if (ret < 0) { goto err0; } ret = fw_pm_startcpu(CXD56_GNSS_GPS_CPUID, 1); if (ret < 0) { goto err1; } #ifndef CONFIG_CXD56_GNSS_HOT_SLEEP fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_DISABLE); #endif /* Wait the request from GNSS core to restore backup data, * or for completion of initialization of GNSS core here. * It is post the semaphore syncsem from cxd56_gnss_default_sighandler. */ ret = cxd56_gnss_wait_notify(&priv->syncsem, 5); if (ret < 0) { goto err1; } ret = fw_gd_writebuffer(CXD56_CPU1_DATA_TYPE_INFO, 0, &priv->shared_info, sizeof(priv->shared_info)); if (ret < 0) { goto err1; } nxsem_destroy(&priv->syncsem); } priv->num_open++; goto success; err1: #ifndef CONFIG_CXD56_GNSS_HOT_SLEEP fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_ENABLE); #endif fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_COLD); err0: nxsem_destroy(&priv->syncsem); success: nxmutex_unlock(&priv->devlock); return ret; } /**************************************************************************** * Name: cxd56_gnss_close * * Description: * Standard character driver close method. * * Input Parameters: * filep - File structure pointer * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_close(struct file *filep) { struct inode *inode; struct cxd56_gnss_dev_s *priv; int ret = OK; inode = filep->f_inode; priv = (struct cxd56_gnss_dev_s *)inode->i_private; ret = nxmutex_lock(&priv->devlock); if (ret < 0) { return ret; } priv->num_open--; if (priv->num_open == 0) { #ifndef CONFIG_CXD56_GNSS_HOT_SLEEP fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_ENABLE); #endif ret = fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_COLD); if (ret < 0) { goto errout; } } errout: nxmutex_unlock(&priv->devlock); return ret; } /**************************************************************************** * Name: cxd56_gnss_read * * Description: * Standard character driver read method. * * Input Parameters: * filep - File structure pointer * buffer - Buffer to read from GNSS device * buflen - The read length of the buffer * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static ssize_t cxd56_gnss_read(struct file *filep, char *buffer, size_t len) { int32_t ret = 0; uint32_t offset = 0; int8_t type; if (!buffer) { ret = -EINVAL; goto out; } if (len == 0) { goto out; } /* setect data type */ type = cxd56_gnss_select_notifytype(filep->f_pos, &offset); if (type < 0) { ret = -ESPIPE; goto out; } if (type == CXD56_CPU1_DATA_TYPE_GNSS) { /* Trim len if read would go beyond end of device */ if ((offset + len) > sizeof(struct cxd56_gnss_positiondata_s)) { len = sizeof(struct cxd56_gnss_positiondata_s) - offset; } } else if (type == CXD56_CPU1_DATA_TYPE_AGPS) { if ((offset + len) > sizeof(struct cxd56_supl_mesurementdata_s)) { len = sizeof(struct cxd56_supl_mesurementdata_s) - offset; } } /* fw_gd_readbuffer returns copied data size or negative error code */ ret = fw_gd_readbuffer(type, offset, buffer, len); out: filep->f_pos = 0; return ret; } /**************************************************************************** * Name: cxd56_gnss_write * * Description: * Standard character driver write method. * * Input Parameters: * filep - File structure pointer * buffer - Buffer to write * buflen - The write length of the buffer * * Returned Value: * Always returns -ENOENT error. * ****************************************************************************/ static ssize_t cxd56_gnss_write(struct file *filep, const char *buffer, size_t buflen) { return -ENOENT; } /**************************************************************************** * Name: cxd56_gnss_ioctl * * Description: * Standard character driver ioctl method. * * Input Parameters: * filep - File structure pointer * fds - Array of file descriptor * setup - 1 if start poll, 0 if stop poll * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_ioctl(struct file *filep, int cmd, unsigned long arg) { struct inode *inode; struct cxd56_gnss_dev_s *priv; int ret; inode = filep->f_inode; priv = (struct cxd56_gnss_dev_s *)inode->i_private; if (cmd <= CXD56_GNSS_IOCTL_INVAL || cmd >= CXD56_GNSS_IOCTL_MAX) { return -EINVAL; } ret = nxmutex_lock(&priv->ioctllock); if (ret < 0) { return ret; } ret = g_cmdlist[cmd](filep, arg); nxmutex_unlock(&priv->ioctllock); return ret; } /**************************************************************************** * Name: cxd56_gnss_poll * * Description: * Standard character driver poll method. * * Input Parameters: * filep - File structure pointer * fds - array of file descriptor * setup - 1 if start poll, 0 if stop poll * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_poll(struct file *filep, struct pollfd *fds, bool setup) { struct inode *inode; struct cxd56_gnss_dev_s *priv; int ret = OK; int i; inode = filep->f_inode; priv = (struct cxd56_gnss_dev_s *)inode->i_private; ret = nxmutex_lock(&priv->devlock); if (ret < 0) { return ret; } if (setup) { if ((fds->events & POLLIN) == 0) { ret = -EDEADLK; goto errout; } for (i = 0; i < CONFIG_CXD56_GNSS_NPOLLWAITERS; i++) { /* Find an unused slot */ if (priv->fds[i] == NULL) { /* Bind the poll structure and this slot */ priv->fds[i] = fds; fds->priv = &priv->fds[i]; fw_gd_setnotifymask(CXD56_CPU1_DEV_GNSS, FALSE); break; } } /* No space in priv fds array for poll handling */ if (i >= CONFIG_CXD56_GNSS_NPOLLWAITERS) { fds->priv = NULL; ret = -EBUSY; goto errout; } /* Should we immediately notify on any of the requested events? */ if (priv->has_event) { cxd56_gnss_pollnotify(priv); } } else if (fds->priv) { /* This is a request to tear down the poll. */ struct pollfd **slot = (struct pollfd **)fds->priv; /* Remove all memory of the poll setup */ *slot = NULL; fds->priv = NULL; priv->has_event = false; } errout: nxmutex_unlock(&priv->devlock); return ret; } /**************************************************************************** * Name: cxd56_gnss_register * * Description: * Register the GNSS character device as 'devpath' * * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/gps" * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ static int cxd56_gnss_register(const char *devpath) { struct cxd56_gnss_dev_s *priv; int i; int ret; static struct cxd56_devsig_table_s devsig_table[] = { { CXD56_CPU1_DATA_TYPE_GNSS, cxd56_gnss_default_sighandler }, { CXD56_CPU1_DATA_TYPE_AGPS, cxd56_gnss_common_signalhandler }, { CXD56_CPU1_DATA_TYPE_RTK, cxd56_gnss_common_signalhandler }, { CXD56_CPU1_DATA_TYPE_GPSEPHEMERIS, cxd56_gnss_common_signalhandler }, { CXD56_CPU1_DATA_TYPE_GLNEPHEMERIS, cxd56_gnss_common_signalhandler }, { CXD56_CPU1_DATA_TYPE_SPECTRUM, cxd56_gnss_common_signalhandler }, { CXD56_CPU1_DATA_TYPE_PVTLOG, cxd56_gnss_common_signalhandler }, { CXD56_CPU1_DATA_TYPE_CPUFIFOAPI, cxd56_gnss_cpufifoapi_signalhandler }, { CXD56_CPU1_DATA_TYPE_SBAS, cxd56_gnss_common_signalhandler }, { CXD56_CPU1_DATA_TYPE_DCREPORT, cxd56_gnss_common_signalhandler }, { CXD56_CPU1_DATA_TYPE_SARRLM, cxd56_gnss_common_signalhandler } }; priv = (struct cxd56_gnss_dev_s *)kmm_zalloc( sizeof(struct cxd56_gnss_dev_s)); if (!priv) { gnsserr("Failed to allocate instance\n"); return -ENOMEM; } nxmutex_init(&priv->devlock); nxsem_init(&priv->apiwait, 0, 0); nxmutex_init(&priv->ioctllock); ret = cxd56_gnss_initialize(priv); if (ret < 0) { gnsserr("Failed to initialize gnss device!\n"); goto err0; } ret = register_driver(devpath, &g_gnssfops, 0666, priv); if (ret < 0) { gnsserr("Failed to register driver: %d\n", ret); goto err0; } for (i = 0; i < sizeof(devsig_table) / sizeof(devsig_table[0]); i++) { ret = cxd56_cpu1siginit(devsig_table[i].sigtype, priv); if (ret < 0) { gnsserr("Failed to initialize ICC for GPS CPU: %d,%d\n", ret, devsig_table[i].sigtype); goto err1; } cxd56_cpu1sigregisterhandler(devsig_table[i].sigtype, devsig_table[i].handler); } gnssinfo("GNSS driver loaded successfully!\n"); return ret; err1: unregister_driver(devpath); err0: nxmutex_destroy(&priv->ioctllock); nxsem_destroy(&priv->apiwait); nxmutex_destroy(&priv->devlock); kmm_free(priv); return ret; } /**************************************************************************** * Name: cxd56_gnssinitialize * * Description: * Initialize GNSS device * * Input Parameters: * devpath - The full path to the driver to register. E.g., "/dev/gps" * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ int cxd56_gnssinitialize(const char *devpath) { int ret; gnssinfo("Initializing GNSS..\n"); ret = cxd56_gnss_register(devpath); if (ret < 0) { gnsserr("Error registering GNSS\n"); } return ret; } #endif
4a6c54cabaab620cbf29b43fee785a51e1fc4078
91b0590e4fe507612d6e4dc17b940b531008048b
/test/oblivc/linreg/linreg.h
9bb9fcbb44c2de9b637f5c67f1af1a87dd21f403
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
samee/obliv-c
bec564bb1a8cdfea27c31ae4121a464edd8a9cdf
e02e5c590523ef4dae06e167a7fa00037bb3fdaf
refs/heads/obliv-c
2021-06-23T10:58:01.394350
2021-06-21T03:33:48
2021-06-21T03:33:48
10,367,312
172
74
NOASSERTION
2022-08-22T12:42:25
2013-05-29T19:14:15
C
UTF-8
C
false
false
494
h
linreg.h
// initial amount for input data: #define ALLOC 128 // doubled when needed in load_data() double lap; int cp; typedef struct { char *src; // filename for data read int n; // number of data points float m; // slope float b; // y-intercept int rsqr; // correlation numerator, cov^2 / variances int r; // correlation } protocolIO; void linReg(void* args); void load_data(protocolIO *io, float** x, float** y, int party); void check_mem(float* x, float* y, int party);
b2fb97b2516472b8a1f49af2b1d7fd3b88d65278
b732361d6b3405c3e79ac0a7d8361cf5b329b015
/ext/phalcon/filter/validation/validatorcompositeinterface.zep.c
b5722d1b50f2db461cee6a53a9167632975ac243
[ "BSD-3-Clause" ]
permissive
phalcon/cphalcon
4a5b26f47b5c2a4107541d7fd73c595c0d90ed73
fc183e11e8b96c43daf7d893244846206dc2aa73
refs/heads/master
2023-03-07T22:09:48.814291
2023-02-28T16:45:15
2023-02-28T16:45:15
2,854,337
8,135
2,343
BSD-3-Clause
2023-09-12T12:41:13
2011-11-26T05:52:50
PHP
UTF-8
C
false
true
1,041
c
validatorcompositeinterface.zep.c
#ifdef HAVE_CONFIG_H #include "../../../ext_config.h" #endif #include <php.h> #include "../../../php_ext.h" #include "../../../ext.h" #include <Zend/zend_exceptions.h> #include "kernel/main.h" /** * This file is part of the Phalcon Framework. * * (c) Phalcon Team <team@phalcon.io> * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ /** * This is a base class for combined fields validators */ ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_ValidatorCompositeInterface) { ZEPHIR_REGISTER_INTERFACE(Phalcon\\Filter\\Validation, ValidatorCompositeInterface, phalcon, filter_validation_validatorcompositeinterface, phalcon_filter_validation_validatorcompositeinterface_method_entry); return SUCCESS; } /** * Executes the validation */ ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorCompositeInterface, getValidators); /** * Executes the validation */ ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorCompositeInterface, validate);
f5d41eb14b2922a766d5a2b9ae1c073f3bc96865
aa3befea459382dc5c01c925653d54f435b3fb0f
/drivers/note/note_driver.c
229a2a9d1235793b7a6d9199fb5efcf38ec419ef
[ "MIT-open-group", "BSD-3-Clause", "HPND-sell-variant", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "MIT-0", "LicenseRef-scancode-bsd-atmel", "LicenseRef-scancode-gary-s-brown", "LicenseRef-scancode-proprietary-license", "SunPro", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "LicenseRef-scancode-other-permissive", "HPND", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "GPL-1.0-or-later", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
apache/nuttx
14519a7bff4a87935d94fb8fb2b19edb501c7cec
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
refs/heads/master
2023-08-25T06:55:45.822534
2023-08-23T16:03:31
2023-08-24T21:25:47
228,103,273
407
241
Apache-2.0
2023-09-14T18:26:05
2019-12-14T23:27:55
C
UTF-8
C
false
false
51,167
c
note_driver.c
/**************************************************************************** * drivers/note/note_driver.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <stdio.h> #include <stdint.h> #include <stdarg.h> #include <string.h> #include <assert.h> #include <errno.h> #include <time.h> #include <nuttx/irq.h> #include <nuttx/sched.h> #include <nuttx/clock.h> #include <nuttx/note/note_driver.h> #include <nuttx/note/noteram_driver.h> #include <nuttx/note/notelog_driver.h> #include <nuttx/spinlock.h> #include <nuttx/sched_note.h> #include "sched/sched.h" #if defined(CONFIG_DRIVERS_NOTERAM) + defined(CONFIG_DRIVERS_NOTELOG) + \ defined(CONFIG_DRIVERS_NOTESNAP) + defined(CONFIG_DRIVERS_NOTERTT) + \ defined(CONFIG_SEGGER_SYSVIEW) > CONFIG_DRIVERS_NOTE_MAX # error "Maximum channel number exceeds. " #endif #define note_add(drv, note, notelen) \ ((drv)->ops->add(drv, note, notelen)) #define note_start(drv, tcb) \ ((drv)->ops->start && ((drv)->ops->start(drv, tcb), true)) #define note_stop(drv, tcb) \ ((drv)->ops->stop && ((drv)->ops->stop(drv, tcb), true)) #define note_suspend(drv, tcb) \ ((drv)->ops->suspend && ((drv)->ops->suspend(drv, tcb), true)) #define note_resume(drv, tcb) \ ((drv)->ops->resume && ((drv)->ops->resume(drv, tcb), true)) #define note_cpu_start(drv, tcb, cpu) \ ((drv)->ops->cpu_start && ((drv)->ops->cpu_start(drv, tcb, cpu), true)) #define note_cpu_started(drv, tcb) \ ((drv)->ops->cpu_started && ((drv)->ops->cpu_started(drv, tcb), true)) #define note_cpu_pause(drv, tcb, cpu) \ ((drv)->ops->cpu_pause && ((drv)->ops->cpu_pause(drv, tcb, cpu), true)) #define note_cpu_paused(drv, tcb) \ ((drv)->ops->cpu_paused && ((drv)->ops->cpu_paused(drv, tcb), true)) #define note_cpu_resume(drv, tcb, cpu) \ ((drv)->ops->cpu_resume && ((drv)->ops->cpu_resume(drv, tcb, cpu), true)) #define note_cpu_resumed(drv, tcb) \ ((drv)->ops->cpu_resumed && ((drv)->ops->cpu_resumed(drv, tcb), true)) #define note_premption(drv, tcb, locked) \ ((drv)->ops->premption && ((drv)->ops->premption(drv, tcb, locked), true)) #define note_csection(drv, tcb, enter) \ ((drv)->ops->csection && ((drv)->ops->csection(drv, tcb, enter), true)) #define note_spinlock(drv, tcb, spinlock, type) \ ((drv)->ops->spinlock && \ ((drv)->ops->spinlock(drv, tcb, spinlock, type), true)) #define note_syscall_enter(drv, nr, argc, ap) \ ((drv)->ops->syscall_enter && \ ((drv)->ops->syscall_enter(drv, nr, argc, ap), true)) #define note_syscall_leave(drv, nr, result) \ ((drv)->ops->syscall_leave && \ ((drv)->ops->syscall_leave(drv, nr, result), true)) #define note_irqhandler(drv, irq, handler, enter) \ ((drv)->ops->irqhandler && \ ((drv)->ops->irqhandler(drv, irq, handler, enter), true)) #define note_string(drv, ip, buf) \ ((drv)->ops->string && ((drv)->ops->string(drv, ip, buf), true)) #define note_dump(drv, ip, buf, len) \ ((drv)->ops->dump && ((drv)->ops->dump(drv, ip, event, buf, len), true)) #define note_vprintf(drv, ip, fmt, va) \ ((drv)->ops->vprintf && ((drv)->ops->vprintf(drv, ip, fmt, va), true)) #define note_vbprintf(drv, ip, event, fmt, va) \ ((drv)->ops->vbprintf && \ ((drv)->ops->vbprintf(drv, ip, event, fmt, va), true)) /**************************************************************************** * Private Types ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER struct note_filter_s { struct note_filter_mode_s mode; # ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP struct note_filter_tag_s tag_mask; # endif # ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER struct note_filter_irq_s irq_mask; # endif # ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL struct note_filter_syscall_s syscall_mask; # endif }; #endif struct note_startalloc_s { struct note_common_s nsa_cmn; /* Common note parameters */ #if CONFIG_TASK_NAME_SIZE > 0 char nsa_name[CONFIG_TASK_NAME_SIZE + 1]; #endif }; #if CONFIG_TASK_NAME_SIZE > 0 # define SIZEOF_NOTE_START(n) (sizeof(struct note_start_s) + (n) - 1) #else # define SIZEOF_NOTE_START(n) (sizeof(struct note_start_s)) #endif #if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0 struct note_taskname_info_s { uint8_t size; uint8_t pid[2]; char name[1]; }; struct note_taskname_s { size_t head; size_t tail; char buffer[CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE]; }; #endif /**************************************************************************** * Private Data ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER static struct note_filter_s g_note_filter = { { CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE #ifdef CONFIG_SMP , (cpu_set_t)CONFIG_SCHED_INSTRUMENTATION_CPUSET #endif } }; #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS]; #endif #endif FAR static struct note_driver_s * g_note_drivers[CONFIG_DRIVERS_NOTE_MAX + 1] = { #ifdef CONFIG_DRIVERS_NOTERAM (FAR struct note_driver_s *)&g_noteram_driver, #endif #ifdef CONFIG_DRIVERS_NOTELOG &g_notelog_driver, #endif NULL }; #if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0 static struct note_taskname_s g_note_taskname; #endif #if defined(CONFIG_SCHED_INSTRUMENTATION_FILTER) static spinlock_t g_note_lock; #endif /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** * Name: sched_note_flatten * * Description: * Copy the data in the little endian layout * ****************************************************************************/ static inline void sched_note_flatten(FAR uint8_t *dst, FAR void *src, size_t len) { #ifdef CONFIG_ENDIAN_BIG FAR uint8_t *end = (FAR uint8_t *)src + len - 1; while (len-- > 0) { *dst++ = *end--; } #else memcpy(dst, src, len); #endif } /**************************************************************************** * Name: note_common * * Description: * Fill in some of the common fields in the note structure. * * Input Parameters: * tcb - The TCB containing the information * note - The common note structure to use * length - The total lengthof the note structure * type - The type of the note * * Returned Value: * None * ****************************************************************************/ static void note_common(FAR struct tcb_s *tcb, FAR struct note_common_s *note, uint8_t length, uint8_t type) { #ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT struct timespec perftime; #endif struct timespec ts; clock_systime_timespec(&ts); #ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT up_perf_convert(up_perf_gettime(), &perftime); ts.tv_nsec = perftime.tv_nsec; #endif /* Save all of the common fields */ note->nc_length = length; note->nc_type = type; if (tcb == NULL) { note->nc_priority = CONFIG_INIT_PRIORITY; #ifdef CONFIG_SMP note->nc_cpu = 0; #endif memset(note->nc_pid, 0, sizeof(tcb->pid)); } else { note->nc_priority = tcb->sched_priority; #ifdef CONFIG_SMP note->nc_cpu = tcb->cpu; #endif sched_note_flatten(note->nc_pid, &tcb->pid, sizeof(tcb->pid)); } sched_note_flatten(note->nc_systime_nsec, &ts.tv_nsec, sizeof(ts.tv_nsec)); sched_note_flatten(note->nc_systime_sec, &ts.tv_sec, sizeof(ts.tv_sec)); } /**************************************************************************** * Name: note_isenabled * * Description: * Check whether the instrumentation is enabled. * * Input Parameters: * None * * Returned Value: * True is returned if the instrumentation is enabled. * ****************************************************************************/ static inline int note_isenabled(void) { #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER if (!(g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)) { return false; } #ifdef CONFIG_SMP /* Ignore notes that are not in the set of monitored CPUs */ if (CPU_ISSET(this_cpu(), &g_note_filter.mode.cpuset) == 0) { /* Not in the set of monitored CPUs. Do not log the note. */ return false; } #endif #endif return true; } /**************************************************************************** * Name: note_isenabled_switch * * Description: * Check whether the switch instrumentation is enabled. * * Input Parameters: * None * * Returned Value: * True is returned if the instrumentation is enabled. * ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH static inline int note_isenabled_switch(void) { #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER if (!note_isenabled()) { return false; } /* If the switch trace is disabled, do nothing. */ if ((g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_SWITCH) == 0) { return false; } #endif return true; } #endif /**************************************************************************** * Name: note_isenabled_syscall * * Description: * Check whether the syscall instrumentation is enabled. * * Input Parameters: * nr - syscall number * * Returned Value: * True is returned if the instrumentation is enabled. * ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL static inline int note_isenabled_syscall(int nr) { #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER if (!note_isenabled()) { return false; } /* Exclude the case of syscall called by the interrupt handler which is * not traced. */ if (up_interrupt_context()) { #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER int cpu = this_cpu(); if (g_note_disabled_irq_nest[cpu] > 0) { return false; } #else return false; #endif } /* If the syscall trace is disabled or the syscall number is masked, * do nothing. */ if (!(g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_SYSCALL) || NOTE_FILTER_SYSCALLMASK_ISSET(nr - CONFIG_SYS_RESERVED, &g_note_filter.syscall_mask)) { return false; } #endif return true; } #endif /**************************************************************************** * Name: note_isenabled_irqhandler * * Description: * Check whether the interrupt handler instrumentation is enabled. * * Input Parameters: * irq - IRQ number * enter - interrupt enter/leave flag * * Returned Value: * True is returned if the instrumentation is enabled. * ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER static inline int note_isenabled_irq(int irq, bool enter) { #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER if (!note_isenabled()) { return false; } /* If the IRQ trace is disabled or the IRQ number is masked, disable * subsequent syscall traces until leaving the interrupt handler */ if (!(g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_IRQ) || NOTE_FILTER_IRQMASK_ISSET(irq, &g_note_filter.irq_mask)) { int cpu = this_cpu(); if (enter) { g_note_disabled_irq_nest[cpu]++; } else { g_note_disabled_irq_nest[cpu]--; } return false; } #endif return true; } #endif /**************************************************************************** * Name: note_isenabled_dump * * Description: * Check whether the dump instrumentation is enabled. * * Input Parameters: * tag: The dump instrumentation tag * * Returned Value: * True is returned if the instrumentation is enabled. * ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP static inline int note_isenabled_dump(uint32_t tag) { # ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER if (!note_isenabled()) { return false; } /* If the dump trace is disabled, do nothing. */ if (!(g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_DUMP) || NOTE_FILTER_TAGMASK_ISSET(tag, &g_note_filter.tag_mask)) { return false; } # endif return true; } #endif #if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0 /**************************************************************************** * Name: note_find_taskname * * Description: * Find task name info corresponding to the specified PID * * Input Parameters: * PID - Task ID * * Returned Value: * Pointer to the task name info * If the corresponding info doesn't exist in the buffer, NULL is returned. * ****************************************************************************/ static FAR struct note_taskname_info_s *note_find_taskname(pid_t pid) { FAR struct note_taskname_info_s *ti; int n = g_note_taskname.tail; while (n != g_note_taskname.head) { ti = (FAR struct note_taskname_info_s *) &g_note_taskname.buffer[n]; if (ti->pid[0] + (ti->pid[1] << 8) == pid) { return ti; } n += ti->size; if (n >= CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE) { n -= CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE; } } return NULL; } /**************************************************************************** * Name: note_record_taskname * * Description: * Record the task name info of the specified task * * Input Parameters: * PID - Task ID * name - task name * * Returned Value: * None * ****************************************************************************/ static void note_record_taskname(pid_t pid, FAR const char *name) { FAR struct note_taskname_info_s *ti; size_t tilen; size_t namelen; size_t skiplen; size_t remain; namelen = strlen(name); DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE); tilen = sizeof(struct note_taskname_info_s) + namelen; DEBUGASSERT(tilen <= UCHAR_MAX); skiplen = CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE - g_note_taskname.head; if (skiplen >= tilen + sizeof(struct note_taskname_info_s)) { skiplen = 0; /* Have enough space at the tail - needn't skip */ } if (g_note_taskname.head >= g_note_taskname.tail) { remain = CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE - (g_note_taskname.head - g_note_taskname.tail); } else { remain = g_note_taskname.tail - g_note_taskname.head; } while (skiplen + tilen >= remain) { /* No enough space, drop the old info */ ti = (FAR struct note_taskname_info_s *) &g_note_taskname.buffer[g_note_taskname.tail]; g_note_taskname.tail = (g_note_taskname.tail + ti->size) % CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE; remain += ti->size; } if (skiplen) { /* Fill the skipped region with an invalid info */ ti = (FAR struct note_taskname_info_s *) &g_note_taskname.buffer[g_note_taskname.head]; ti->size = skiplen; ti->pid[0] = 0xff; ti->pid[1] = 0xff; ti->name[0] = '\0'; /* Move to the begin of circle buffer */ g_note_taskname.head = 0; } ti = (FAR struct note_taskname_info_s *) &g_note_taskname.buffer[g_note_taskname.head]; ti->size = tilen; ti->pid[0] = pid & 0xff; ti->pid[1] = (pid >> 8) & 0xff; strlcpy(ti->name, name, namelen + 1); g_note_taskname.head += tilen; } #endif /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: sched_note_* * * Description: * These are the hooks into the scheduling instrumentation logic. Each * simply formats the note associated with the schedule event and adds * that note to the circular buffer. * * Input Parameters: * tcb - The TCB of the thread. * * Returned Value: * None * * Assumptions: * We are within a critical section. * ****************************************************************************/ void sched_note_start(FAR struct tcb_s *tcb) { struct note_startalloc_s note; unsigned int length; FAR struct note_driver_s **driver; bool formatted = false; #if CONFIG_TASK_NAME_SIZE > 0 int namelen; #endif if (!note_isenabled()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_start(*driver, tcb)) { continue; } if ((*driver)->ops->add == NULL) { continue; } if (!formatted) { formatted = true; /* Copy the task name (if possible) and * get the length of the note */ #if CONFIG_TASK_NAME_SIZE > 0 namelen = strlen(tcb->name); DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE); strlcpy(note.nsa_name, tcb->name, sizeof(note.nsa_name)); length = SIZEOF_NOTE_START(namelen + 1); #else length = SIZEOF_NOTE_START(0); #endif /* Finish formatting the note */ note_common(tcb, &note.nsa_cmn, length, NOTE_START); } /* Add the note to circular buffer */ note_add(*driver, &note, length); } } void sched_note_stop(FAR struct tcb_s *tcb) { struct note_stop_s note; FAR struct note_driver_s **driver; bool formatted = false; #if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0 note_record_taskname(tcb->pid, tcb->name); #endif if (!note_isenabled()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_stop(*driver, tcb)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.nsp_cmn, sizeof(struct note_stop_s), NOTE_STOP); } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_stop_s)); } } #ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH void sched_note_suspend(FAR struct tcb_s *tcb) { struct note_suspend_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled_switch()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_suspend(*driver, tcb)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.nsu_cmn, sizeof(struct note_suspend_s), NOTE_SUSPEND); note.nsu_state = tcb->task_state; } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_suspend_s)); } } void sched_note_resume(FAR struct tcb_s *tcb) { struct note_resume_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled_switch()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_resume(*driver, tcb)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.nre_cmn, sizeof(struct note_resume_s), NOTE_RESUME); } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_resume_s)); } } #endif #ifdef CONFIG_SMP void sched_note_cpu_start(FAR struct tcb_s *tcb, int cpu) { struct note_cpu_start_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_cpu_start(*driver, tcb, cpu)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.ncs_cmn, sizeof(struct note_cpu_start_s), NOTE_CPU_START); note.ncs_target = (uint8_t)cpu; } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_cpu_start_s)); } } void sched_note_cpu_started(FAR struct tcb_s *tcb) { struct note_cpu_started_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_cpu_started(*driver, tcb)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.ncs_cmn, sizeof(struct note_cpu_started_s), NOTE_CPU_STARTED); } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_cpu_started_s)); } } #ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH void sched_note_cpu_pause(FAR struct tcb_s *tcb, int cpu) { struct note_cpu_pause_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled_switch()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_cpu_pause(*driver, tcb, cpu)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.ncp_cmn, sizeof(struct note_cpu_pause_s), NOTE_CPU_PAUSE); note.ncp_target = (uint8_t)cpu; } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_cpu_pause_s)); } } void sched_note_cpu_paused(FAR struct tcb_s *tcb) { struct note_cpu_paused_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled_switch()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_cpu_paused(*driver, tcb)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.ncp_cmn, sizeof(struct note_cpu_paused_s), NOTE_CPU_PAUSED); } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_cpu_paused_s)); } } void sched_note_cpu_resume(FAR struct tcb_s *tcb, int cpu) { struct note_cpu_resume_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled_switch()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_cpu_resume(*driver, tcb, cpu)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.ncr_cmn, sizeof(struct note_cpu_resume_s), NOTE_CPU_RESUME); note.ncr_target = (uint8_t)cpu; } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_cpu_resume_s)); } } void sched_note_cpu_resumed(FAR struct tcb_s *tcb) { struct note_cpu_resumed_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled_switch()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_cpu_resumed(*driver, tcb)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.ncr_cmn, sizeof(struct note_cpu_resumed_s), NOTE_CPU_RESUMED); } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_cpu_resumed_s)); } } #endif #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION void sched_note_premption(FAR struct tcb_s *tcb, bool locked) { struct note_preempt_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_premption(*driver, tcb, locked)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.npr_cmn, sizeof(struct note_preempt_s), locked ? NOTE_PREEMPT_LOCK : NOTE_PREEMPT_UNLOCK); sched_note_flatten(note.npr_count, &tcb->lockcount, sizeof(tcb->lockcount)); } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_preempt_s)); } } #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION void sched_note_csection(FAR struct tcb_s *tcb, bool enter) { struct note_csection_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_csection(*driver, tcb, enter)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.ncs_cmn, sizeof(struct note_csection_s), enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE); #ifdef CONFIG_SMP sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount)); #endif } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_csection_s)); } } #endif /**************************************************************************** * Name: sched_note_spinlock * * Description: * Common logic for NOTE_SPINLOCK, NOTE_SPINLOCKED, and NOTE_SPINUNLOCK * * Input Parameters: * tcb - The TCB containing the information * note - The common note structure to use * * Returned Value: * None * ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS void sched_note_spinlock(FAR struct tcb_s *tcb, FAR volatile spinlock_t *spinlock, int type) { struct note_spinlock_s note; FAR struct note_driver_s **driver; bool formatted = false; if (!note_isenabled()) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_spinlock(*driver, tcb, spinlock, type)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.nsp_cmn, sizeof(struct note_spinlock_s), type); sched_note_flatten(note.nsp_spinlock, &spinlock, sizeof(spinlock)); note.nsp_value = *(FAR uint8_t *)spinlock; } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_spinlock_s)); } } #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL void sched_note_syscall_enter(int nr, int argc, ...) { struct note_syscall_enter_s note; FAR struct note_driver_s **driver; bool formatted = false; FAR struct tcb_s *tcb = this_task(); unsigned int length; FAR uint8_t *args; uintptr_t arg; va_list ap; int i; if (!note_isenabled_syscall(nr)) { return; } #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER if (!(g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_SYSCALL_ARGS)) { argc = 0; } #endif va_start(ap, argc); for (driver = g_note_drivers; *driver; driver++) { va_list copy; va_copy(copy, ap); if (note_syscall_enter(*driver, nr, argc, &copy)) { va_end(copy); continue; } if ((*driver)->ops->add == NULL) { va_end(copy); continue; } /* Format the note */ if (!formatted) { formatted = true; length = SIZEOF_NOTE_SYSCALL_ENTER(argc); note_common(tcb, &note.nsc_cmn, length, NOTE_SYSCALL_ENTER); DEBUGASSERT(nr <= UCHAR_MAX); note.nsc_nr = nr; DEBUGASSERT(argc <= MAX_SYSCALL_ARGS); note.nsc_argc = argc; /* If needed, retrieve the given syscall arguments */ args = note.nsc_args; for (i = 0; i < argc; i++) { arg = (uintptr_t)va_arg(copy, uintptr_t); sched_note_flatten(args, &arg, sizeof(arg)); args += sizeof(uintptr_t); } } va_end(copy); /* Add the note to circular buffer */ note_add(*driver, &note, length); } va_end(ap); } void sched_note_syscall_leave(int nr, uintptr_t result) { struct note_syscall_leave_s note; FAR struct note_driver_s **driver; bool formatted = false; FAR struct tcb_s *tcb = this_task(); if (!note_isenabled_syscall(nr)) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_syscall_leave(*driver, nr, result)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note_common(tcb, &note.nsc_cmn, sizeof(struct note_syscall_leave_s), NOTE_SYSCALL_LEAVE); DEBUGASSERT(nr <= UCHAR_MAX); note.nsc_nr = nr; sched_note_flatten(note.nsc_result, &result, sizeof(result)); } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_syscall_leave_s)); } } #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER void sched_note_irqhandler(int irq, FAR void *handler, bool enter) { struct note_irqhandler_s note; FAR struct note_driver_s **driver; bool formatted = false; FAR struct tcb_s *tcb = this_task(); if (!note_isenabled_irq(irq, enter)) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_irqhandler(*driver, irq, handler, enter)) { continue; } if ((*driver)->ops->add == NULL) { continue; } if (!formatted) { formatted = true; note_common(tcb, &note.nih_cmn, sizeof(struct note_irqhandler_s), enter ? NOTE_IRQ_ENTER : NOTE_IRQ_LEAVE); DEBUGASSERT(irq <= UCHAR_MAX); note.nih_irq = irq; note.nih_handler = (uintptr_t)handler; } /* Add the note to circular buffer */ note_add(*driver, &note, sizeof(struct note_irqhandler_s)); } } #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP void sched_note_string_ip(uint32_t tag, uintptr_t ip, FAR const char *buf) { FAR struct note_string_s *note; uint8_t data[255]; unsigned int length; FAR struct note_driver_s **driver; bool formatted = false; FAR struct tcb_s *tcb = this_task(); if (!note_isenabled_dump(tag)) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_string(*driver, ip, buf)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note = (FAR struct note_string_s *)data; length = SIZEOF_NOTE_STRING(strlen(buf)); if (length > sizeof(data)) { length = sizeof(data); } note_common(tcb, &note->nst_cmn, length, NOTE_DUMP_STRING); sched_note_flatten(note->nst_ip, &ip, sizeof(uintptr_t)); memcpy(note->nst_data, buf, length - sizeof(struct note_string_s)); data[length - 1] = '\0'; } /* Add the note to circular buffer */ note_add(*driver, note, length); } } void sched_note_dump_ip(uint32_t tag, uintptr_t ip, uint8_t event, FAR const void *buf, size_t len) { FAR struct note_binary_s *note; FAR struct note_driver_s **driver; bool formatted = false; char data[255]; unsigned int length; FAR struct tcb_s *tcb = this_task(); if (!note_isenabled_dump(tag)) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_dump(*driver, ip, buf, len)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note = (FAR struct note_binary_s *)data; length = SIZEOF_NOTE_BINARY(len); if (length > sizeof(data)) { length = sizeof(data); } note_common(tcb, &note->nbi_cmn, length, NOTE_DUMP_BINARY); sched_note_flatten(note->nbi_ip, &ip, sizeof(uintptr_t)); note->nbi_event = event; memcpy(note->nbi_data, buf, length - sizeof(struct note_binary_s) + 1); } /* Add the note to circular buffer */ note_add(*driver, note, length); } } void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt, va_list va) { FAR struct note_string_s *note; uint8_t data[255]; unsigned int length; FAR struct note_driver_s **driver; bool formatted = false; FAR struct tcb_s *tcb = this_task(); if (!note_isenabled_dump(tag)) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_vprintf(*driver, ip, fmt, va)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note = (FAR struct note_string_s *)data; length = vsnprintf(note->nst_data, sizeof(data) - sizeof(struct note_string_s), fmt, va); length = SIZEOF_NOTE_STRING(length); if (length > sizeof(data)) { length = sizeof(data); } note_common(tcb, &note->nst_cmn, length, NOTE_DUMP_STRING); sched_note_flatten(note->nst_ip, &ip, sizeof(uintptr_t)); } /* Add the note to circular buffer */ note_add(*driver, note, length); } } void sched_note_vbprintf_ip(uint32_t tag, uintptr_t ip, uint8_t event, FAR const char *fmt, va_list va) { FAR struct note_binary_s *note; FAR struct note_driver_s **driver; bool formatted = false; uint8_t data[255]; begin_packed_struct union { char c; short s; int i; long l; #ifdef CONFIG_HAVE_LONG_LONG long long ll; #endif intmax_t im; size_t sz; ptrdiff_t ptr; #ifdef CONFIG_HAVE_FLOAT float f; #endif #ifdef CONFIG_HAVE_DOUBLE double d; #endif #ifdef CONFIG_HAVE_LONG_DOUBLE long double ld; #endif } end_packed_struct *var; char c; int length; bool search_fmt = 0; int next = 0; FAR struct tcb_s *tcb = this_task(); if (!note_isenabled_dump(tag)) { return; } for (driver = g_note_drivers; *driver; driver++) { if (note_vbprintf(*driver, ip, event, fmt, va)) { continue; } if ((*driver)->ops->add == NULL) { continue; } /* Format the note */ if (!formatted) { formatted = true; note = (FAR struct note_binary_s *)data; length = sizeof(data) - sizeof(struct note_binary_s) + 1; while ((c = *fmt++) != '\0') { if (c != '%' && search_fmt == 0) { continue; } search_fmt = 1; var = (FAR void *)&note->nbi_data[next]; if (c == 'd' || c == 'i' || c == 'u' || c == 'o' || c == 'x' || c == 'X') { if (*(fmt - 2) == 'h' && *(fmt - 3) == 'h') { if (next + sizeof(var->c) > length) { break; } var->c = va_arg(va, int); next += sizeof(var->c); } else if (*(fmt - 2) == 'h') { if (next + sizeof(var->s) > length) { break; } var->s = va_arg(va, int); next += sizeof(var->s); } else if (*(fmt - 2) == 'j') { if (next + sizeof(var->im) > length) { break; } var->im = va_arg(va, intmax_t); next += sizeof(var->im); } #ifdef CONFIG_HAVE_LONG_LONG else if (*(fmt - 2) == 'l' && *(fmt - 3) == 'l') { if (next + sizeof(var->ll) > length) { break; } var->ll = va_arg(va, long long); next += sizeof(var->ll); } #endif else if (*(fmt - 2) == 'l') { if (next + sizeof(var->l) > length) { break; } var->l = va_arg(va, long); next += sizeof(var->l); } else if (*(fmt - 2) == 'z') { if (next + sizeof(var->sz) > length) { break; } var->sz = va_arg(va, size_t); next += sizeof(var->sz); } else if (*(fmt - 2) == 't') { if (next + sizeof(var->ptr) > length) { break; } var->ptr = va_arg(va, ptrdiff_t); next += sizeof(var->ptr); } else { if (next + sizeof(var->i) > length) { break; } var->i = va_arg(va, int); next += sizeof(var->i); } search_fmt = 0; } if (c == 'e' || c == 'f' || c == 'g' || c == 'E' || c == 'F' || c == 'G') { if (*(fmt - 2) == 'L') { #ifdef CONFIG_HAVE_LONG_DOUBLE if (next + sizeof(var->ld) > length) { break; } var->ld = va_arg(va, long double); next += sizeof(var->ld); #endif } else if (*(fmt - 2) == 'l') { #ifdef CONFIG_HAVE_DOUBLE if (next + sizeof(var->d) > length) { break; } var->d = va_arg(va, double); next += sizeof(var->d); #endif } else #ifdef CONFIG_HAVE_FLOAT { if (next + sizeof(var->l) > length) { break; } var->l = va_arg(va, double); next += sizeof(var->l); #endif } search_fmt = 0; } } length = SIZEOF_NOTE_BINARY(next); note_common(tcb, &note->nbi_cmn, length, NOTE_DUMP_BINARY); sched_note_flatten(note->nbi_ip, &ip, sizeof(uintptr_t)); note->nbi_event = event; } /* Add the note to circular buffer */ note_add(*driver, note, length); } } void sched_note_printf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt, ...) { va_list va; va_start(va, fmt); sched_note_vprintf_ip(tag, ip, fmt, va); va_end(va); } void sched_note_bprintf_ip(uint32_t tag, uintptr_t ip, uint8_t event, FAR const char *fmt, ...) { va_list va; va_start(va, fmt); sched_note_vbprintf_ip(tag, ip, event, fmt, va); va_end(va); } #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */ #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER /**************************************************************************** * Name: sched_note_filter_mode * * Description: * Set and get note filter mode. * (Same as NOTECTL_GETMODE / NOTECTL_SETMODE ioctls) * * Input Parameters: * oldm - A writable pointer to struct note_filter_mode_s to get current * filter mode * If 0, no data is written. * newm - A read-only pointer to struct note_filter_mode_s which holds the * new filter mode * If 0, the filter mode is not updated. * * Returned Value: * None * ****************************************************************************/ void sched_note_filter_mode(FAR struct note_filter_mode_s *oldm, FAR struct note_filter_mode_s *newm) { irqstate_t irq_mask; irq_mask = spin_lock_irqsave_wo_note(&g_note_lock); if (oldm != NULL) { *oldm = g_note_filter.mode; } if (newm != NULL) { g_note_filter.mode = *newm; } spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask); } /**************************************************************************** * Name: sched_note_filter_syscall * * Description: * Set and get syscall filter setting * (Same as NOTECTL_GETSYSCALLFILTER / NOTECTL_SETSYSCALLFILTER ioctls) * * Input Parameters: * oldf - A writable pointer to struct note_filter_syscall_s to get * current syscall filter setting * If 0, no data is written. * newf - A read-only pointer to struct note_filter_syscall_s of the * new syscall filter setting * If 0, the setting is not updated. * * Returned Value: * None * ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL void sched_note_filter_syscall(FAR struct note_filter_syscall_s *oldf, FAR struct note_filter_syscall_s *newf) { irqstate_t irq_mask; irq_mask = spin_lock_irqsave_wo_note(&g_note_lock); if (oldf != NULL) { /* Return the current filter setting */ *oldf = g_note_filter.syscall_mask; } if (newf != NULL) { /* Replace the syscall filter mask by the provided setting */ g_note_filter.syscall_mask = *newf; } spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask); } #endif /**************************************************************************** * Name: sched_note_filter_irq * * Description: * Set and get IRQ filter setting * (Same as NOTECTL_GETIRQFILTER / NOTECTL_SETIRQFILTER ioctls) * * Input Parameters: * oldf - A writable pointer to struct note_filter_irq_s to get * current IRQ filter setting * If 0, no data is written. * newf - A read-only pointer to struct note_filter_irq_s of the new * IRQ filter setting * If 0, the setting is not updated. * * Returned Value: * None * ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER void sched_note_filter_irq(FAR struct note_filter_irq_s *oldf, FAR struct note_filter_irq_s *newf) { irqstate_t irq_mask; irq_mask = spin_lock_irqsave_wo_note(&g_note_lock); if (oldf != NULL) { /* Return the current filter setting */ *oldf = g_note_filter.irq_mask; } if (newf != NULL) { /* Replace the syscall filter mask by the provided setting */ g_note_filter.irq_mask = *newf; } spin_unlock_irqrestore_wo_note(&g_note_lock, irq_mask); } #endif /**************************************************************************** * Name: sched_note_filter_tag * * Description: * Set and get tag filter setting * (Same as NOTECTL_GETDUMPFILTER / NOTECTL_SETDUMPFILTER ioctls) * * Input Parameters: * oldf - A writable pointer to struct note_filter_tag_s to get * current dump filter setting * If 0, no data is written. * newf - A read-only pointer to struct note_filter_tag_s of the * new dump filter setting * If 0, the setting is not updated. * * Returned Value: * None * ****************************************************************************/ #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP void sched_note_filter_tag(FAR struct note_filter_tag_s *oldf, FAR struct note_filter_tag_s *newf) { irqstate_t falgs; falgs = spin_lock_irqsave_wo_note(&g_note_lock); if (oldf != NULL) { /* Return the current filter setting */ *oldf = g_note_filter.tag_mask; } if (newf != NULL) { /* Replace the dump filter mask by the provided setting */ g_note_filter.tag_mask = *newf; } spin_unlock_irqrestore_wo_note(&g_note_lock, falgs); } #endif #endif /* CONFIG_SCHED_INSTRUMENTATION_FILTER */ #if CONFIG_DRIVERS_NOTE_TASKNAME_BUFSIZE > 0 /**************************************************************************** * Name: note_get_taskname * * Description: * Get the task name string of the specified PID * * Input Parameters: * PID - Task ID * * Returned Value: * Retrun name if task name can be retrieved, otherwise NULL ****************************************************************************/ FAR const char *note_get_taskname(pid_t pid) { FAR struct note_taskname_info_s *ti; FAR struct tcb_s *tcb; tcb = nxsched_get_tcb(pid); if (tcb != NULL) { return tcb->name; } ti = note_find_taskname(pid); if (ti != NULL) { return ti->name; } return NULL; } #endif /**************************************************************************** * Name: note_driver_register ****************************************************************************/ int note_driver_register(FAR struct note_driver_s *driver) { int i; DEBUGASSERT(driver); for (i = 0; i < CONFIG_DRIVERS_NOTE_MAX; i++) { if (g_note_drivers[i] == NULL) { g_note_drivers[i] = driver; return OK; } } return -ENOMEM; } #ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION /**************************************************************************** * Name: __cyg_profile_func_enter ****************************************************************************/ void noinstrument_function __cyg_profile_func_enter(void *this_fn, void *call_site) { sched_note_string_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn, "B"); } /**************************************************************************** * Name: __cyg_profile_func_exit ****************************************************************************/ void noinstrument_function __cyg_profile_func_exit(void *this_fn, void *call_site) { sched_note_string_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn, "E"); } #endif
e820333f100e99e62a49c089db3601a8fb2d01ec
b0f08154e3eebc7d8465efc57597e52d08d69c18
/src/connection/connection_cl.c
489d730b45219138b61fc51aa1b8da542b7e6629
[ "BSD-3-Clause", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
CUBRID/cubrid
8f71a0010243b72e43ba887d229210650f4e901e
3b952af33230839a1b561a78ecd4b773374b66f8
refs/heads/develop
2023-08-18T19:16:30.987583
2023-08-18T08:18:05
2023-08-18T08:18:05
52,080,367
287
294
NOASSERTION
2023-09-14T21:29:09
2016-02-19T10:25:32
C
UTF-8
C
false
false
35,719
c
connection_cl.c
/* * Copyright 2008 Search Solution Corporation * Copyright 2016 CUBRID Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /* * connection_cl.c - general interface routines needed to support * the client and server interaction */ #ident "$Id$" #include "config.h" #if defined (WINDOWS) #include <io.h> #endif #include <filesystem> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <assert.h> #include <math.h> #if defined(WINDOWS) #include <winsock2.h> #else /* WINDOWS */ #include <sys/time.h> #include <sys/ioctl.h> #include <sys/uio.h> #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> #endif /* WINDOWS */ #if defined(_AIX) #include <sys/select.h> #endif /* _AIX */ #if defined(SOLARIS) #include <sys/filio.h> #include <netdb.h> /* for MAXHOSTNAMELEN */ #endif /* SOLARIS */ #include "porting.h" #include "error_manager.h" #include "connection_globals.h" #include "filesys.hpp" #include "filesys_temp.hpp" #include "memory_alloc.h" #include "system_parameter.h" #include "environment_variable.h" #if defined(WINDOWS) #include "wintcp.h" #else /* WINDOWS */ #include "tcp.h" #endif /* WINDOWS */ #include "connection_list_cl.h" #include "connection_cl.h" #include "master_util.h" #if defined(HPUX) /* * HP uses a monster fd set size (2K) and recommends in sys/types.h * that users reduce the size. */ #undef FD_SETSIZE #define FD_SETSIZE 256 #endif /* HPUX */ #ifdef PACKET_TRACE #define TRACE(string, arg1) \ do { \ er_log_debug(ARG_FILE_LINE, string, arg1); \ } \ while (0) #else /* PACKET_TRACE */ #define TRACE(string, arg1) #endif /* PACKET_TRACE */ /* the queue anchor for all the connection structures */ static CSS_CONN_ENTRY *css_Conn_anchor = NULL; static int css_Client_id = 0; static void css_initialize_conn (CSS_CONN_ENTRY * conn, SOCKET fd); static void css_dealloc_conn (CSS_CONN_ENTRY * conn); static int css_read_header (CSS_CONN_ENTRY * conn, NET_HEADER * local_header); static CSS_CONN_ENTRY *css_server_connect (char *host_name, CSS_CONN_ENTRY * conn, char *server_name, unsigned short *rid); static int css_return_queued_data (CSS_CONN_ENTRY * conn, unsigned short request_id, char **buffer, int *buffer_size, int *rc); static int css_return_queued_request (CSS_CONN_ENTRY * conn, unsigned short *rid, int *request, int *buffer_size); /* * css_shutdown_conn () - * return: void * conn(in/out): * * To close down a connection and make sure that the fd gets * set to -1 so we don't try to shutdown the socket more than once. * */ void css_shutdown_conn (CSS_CONN_ENTRY * conn) { if (!IS_INVALID_SOCKET (conn->fd)) { css_shutdown_socket (conn->fd); conn->fd = INVALID_SOCKET; } conn->status = CONN_CLOSED; } /* * css_initialize_conn () - * return: void * conn(in/out): * fd(in): */ static void css_initialize_conn (CSS_CONN_ENTRY * conn, SOCKET fd) { conn->request_id = 0; conn->fd = fd; conn->status = CONN_OPEN; conn->client_id = ++css_Client_id; conn->data_queue = NULL; conn->request_queue = NULL; conn->abort_queue = NULL; conn->buffer_queue = NULL; conn->error_queue = NULL; conn->set_tran_index (NULL_TRAN_INDEX); conn->invalidate_snapshot = 1; conn->in_method = false; conn->db_error = 0; conn->cnxn = NULL; } /* * css_make_conn () - * return: * fd(in): */ CSS_CONN_ENTRY * css_make_conn (SOCKET fd) { CSS_CONN_ENTRY *conn; conn = (CSS_CONN_ENTRY *) malloc (sizeof (CSS_CONN_ENTRY)); if (conn != NULL) { css_initialize_conn (conn, fd); conn->next = css_Conn_anchor; css_Conn_anchor = conn; } return conn; } /* * css_close_conn () - * return: void * conn(in): */ void css_close_conn (CSS_CONN_ENTRY * conn) { if (conn && !IS_INVALID_SOCKET (conn->fd)) { css_shutdown_conn (conn); css_initialize_conn (conn, -1); } } /* * css_dealloc_conn () - * return: void * conn(in/out): */ static void css_dealloc_conn (CSS_CONN_ENTRY * conn) { CSS_CONN_ENTRY *p, *previous; for (p = previous = css_Conn_anchor; p; previous = p, p = p->next) { if (p == conn) { if (p == css_Conn_anchor) { css_Conn_anchor = p->next; } else { previous->next = p->next; } break; } } if (p) { free_and_init (conn); } } /* * css_free_conn () - * return: void * conn(in/out): */ void css_free_conn (CSS_CONN_ENTRY * conn) { css_close_conn (conn); css_dealloc_conn (conn); } /* * css_find_exception_conn () - * return: */ CSS_CONN_ENTRY * css_find_exception_conn (void) { return NULL; } /* * css_find_conn_from_fd () - find the connection associated with the current socket descriptor * return: conn or NULL * fd(in): Socket fd */ CSS_CONN_ENTRY * css_find_conn_from_fd (SOCKET fd) { CSS_CONN_ENTRY *p; for (p = css_Conn_anchor; p; p = p->next) { if (p->fd == fd) { return p; } } return NULL; } /* * css_get_request_id () - return the next valid request id * return: * conn(in): */ unsigned short css_get_request_id (CSS_CONN_ENTRY * conn) { unsigned short old_rid; old_rid = conn->request_id++; if (conn->request_id == 0) { conn->request_id++; } while (conn->request_id != old_rid) { if (css_is_valid_request_id (conn, conn->request_id)) { return (conn->request_id); } else { conn->request_id++; if (conn->request_id == 0) { conn->request_id++; } } } er_set (ER_WARNING_SEVERITY, ARG_FILE_LINE, ERR_CSS_REQUEST_ID_FAILURE, 0); return 0; } /* * css_test_for_open_conn () - test to see if the connection is still open * return: * conn(in): */ int css_test_for_open_conn (CSS_CONN_ENTRY * conn) { return (conn && conn->status == CONN_OPEN); } /* * css_send_close_request () - close an open connection * return: * conn(in): */ int css_send_close_request (CSS_CONN_ENTRY * conn) { NET_HEADER header = DEFAULT_HEADER_DATA; unsigned short flags; if (!conn || conn->status == CONN_CLOSED) { return CONNECTION_CLOSED; } if (conn->status == CONN_OPEN) { header.type = htonl (CLOSE_TYPE); header.transaction_id = htonl (conn->get_tran_index ()); flags = 0; /** * FIXME!! * make NET_HEADER_FLAG_INVALIDATE_SNAPSHOT be enabled always due to CBRD-24157 * * flags was mis-readed at css_read_header() and fixed at CBRD-24118. * But The side effects described in CBRD-24157 occurred. */ if (true) // if (conn->invalidate_snapshot) { flags |= NET_HEADER_FLAG_INVALIDATE_SNAPSHOT; } if (conn->in_method) { flags |= NET_HEADER_FLAG_METHOD_MODE; } header.flags = htons (flags); header.db_error = htonl (conn->db_error); /* timeout in milli-second in css_net_send() */ css_net_send (conn, (char *) &header, sizeof (NET_HEADER), -1); } css_remove_all_unexpected_packets (conn); css_shutdown_conn (conn); return NO_ERRORS; } /* * css_read_header () - read a header from the socket * return: * conn(in): * local_header(in): * * Note: It is a blocking read. */ static int css_read_header (CSS_CONN_ENTRY * conn, NET_HEADER * local_header) { int buffer_size; int rc = 0; unsigned short flags = 0; buffer_size = sizeof (NET_HEADER); rc = css_net_read_header (conn->fd, (char *) local_header, &buffer_size, -1); if (rc == NO_ERRORS && ntohl (local_header->type) == CLOSE_TYPE) { css_shutdown_conn (conn); return CONNECTION_CLOSED; } if (rc != NO_ERRORS && rc != RECORD_TRUNCATED) { css_shutdown_conn (conn); return CONNECTION_CLOSED; } conn->set_tran_index (ntohl (local_header->transaction_id)); flags = ntohs (local_header->flags); conn->invalidate_snapshot = flags & NET_HEADER_FLAG_INVALIDATE_SNAPSHOT ? 1 : 0; conn->in_method = flags & NET_HEADER_FLAG_METHOD_MODE ? true : false; conn->db_error = (int) ntohl (local_header->db_error); return rc; } /* * css_read_one_request () - return a request if one is queued up or on the socket * return: * conn(in): * rid(out): * request(out): * buffer_size(out): * * Note: If no input is available on the socket, it will block until something is available. */ int css_read_one_request (CSS_CONN_ENTRY * conn, unsigned short *rid, int *request, int *buffer_size) { int rc; int type; NET_HEADER local_header = DEFAULT_HEADER_DATA; if (conn == NULL || conn->status != CONN_OPEN) { return CONNECTION_CLOSED; } if (css_return_queued_request (conn, rid, request, buffer_size)) { return NO_ERRORS; } rc = css_read_header (conn, &local_header); if (rc == NO_ERRORS) { *rid = (unsigned short) ntohl (local_header.request_id); type = ntohl (local_header.type); if (type == COMMAND_TYPE) { *request = (int) (unsigned short) ntohs (local_header.function_code); *buffer_size = (int) ntohl (local_header.buffer_size); return rc; } else { css_queue_unexpected_packet (type, conn, *rid, &local_header, sizeof (NET_HEADER)); rc = WRONG_PACKET_TYPE; } } *buffer_size = 0; *rid = 0; *request = 0; return rc; } /* * css_receive_request () - "blocking" read for a new request * return: * conn(in): * rid(out): * request(out): * buffer_size(out): */ int css_receive_request (CSS_CONN_ENTRY * conn, unsigned short *rid, int *request, int *buffer_size) { int rc; do { rc = css_read_one_request (conn, rid, request, buffer_size); } while (rc == WRONG_PACKET_TYPE); TRACE ("in css_receive_request, received request: %d\n", *request); return rc; } /* * css_receive_data () - return a data buffer for an associated request * return: * conn(in): * req_id(in): * buffer(out): * buffer_size(out): * timeout(in): * * Note: this is a blocking read. */ int css_receive_data (CSS_CONN_ENTRY * conn, unsigned short req_id, char **buffer, int *buffer_size, int timeout) { NET_HEADER header = DEFAULT_HEADER_DATA; int header_size; int rc; unsigned int rid; int type; char *buf = NULL; int buf_size = 0; if (conn == NULL || conn->status != CONN_OPEN) { TRACE ("conn->status = %d in css_receive_data\n", conn ? conn->status : 0); return CONNECTION_CLOSED; } assert (buffer && buffer_size); if (css_return_queued_data (conn, req_id, buffer, buffer_size, &rc)) { TRACE ("returning queued data of size %d\n", *buffer_size); return rc; } begin: header_size = sizeof (NET_HEADER); rc = css_net_read_header (conn->fd, (char *) &header, &header_size, timeout); if (rc != NO_ERRORS) { return rc; } assert (header_size == sizeof (NET_HEADER)); // to make it sure. rid = ntohl (header.request_id); conn->db_error = (int) ntohl (header.db_error); type = ntohl (header.type); if (type == DATA_TYPE) { conn->set_tran_index (ntohl (header.transaction_id)); buf_size = ntohl (header.buffer_size); if (rid == req_id) { buf = (char *) css_return_data_buffer (conn, rid, &buf_size); } else { buf = (char *) css_return_data_buffer (conn, 0, &buf_size); } if (buf != NULL) { rc = css_net_recv (conn->fd, buf, &buf_size, timeout); if (rc == NO_ERRORS || rc == RECORD_TRUNCATED) { if (req_id != rid) { /* We have some data for a different request id */ css_queue_unexpected_data_packet (conn, rid, buf, buf_size, rc); goto begin; } } } else if (0 <= buf_size) { // Two cases here: // 1. allocation failure: (buf == NULL && buf_size > 0) // 2. receives size 0 buffer: (buf == NULL && buf_size == 0) // - sender sent size 0 for nil buffer and receiver should consume its size. css_read_remaining_bytes (conn->fd, sizeof (int) + buf_size); if (0 < buf_size) { rc = CANT_ALLOC_BUFFER; } if (req_id != rid) { css_queue_unexpected_data_packet (conn, rid, NULL, 0, rc); goto begin; } } *buffer = buf; *buffer_size = buf_size; return rc; } #if defined(CS_MODE) else if (type == ABORT_TYPE) { /* * if the user registered a buffer, we should return the buffer */ *buffer_size = ntohl (header.buffer_size); *buffer = css_return_data_buffer (conn, req_id, buffer_size); assert (*buffer_size == 0); return SERVER_ABORTED; } #endif /* CS_MODE */ else { css_queue_unexpected_packet (type, conn, rid, &header, ntohl (header.buffer_size)); goto begin; } // unreachable assert (0); } /* * css_receive_error () - return an error buffer for an associated request * return: * conn(in): * req_id(in): * buffer(out): * buffer_size(out): * * Note: this is a blocking read. */ int css_receive_error (CSS_CONN_ENTRY * conn, unsigned short req_id, char **buffer, int *buffer_size) { NET_HEADER header = DEFAULT_HEADER_DATA; int header_size; int rc; int rid; int type; char *buf = NULL; int buf_size = 0; if (conn == NULL || conn->status != CONN_OPEN) { return CONNECTION_CLOSED; } assert (buffer && buffer_size); if (css_return_queued_error (conn, req_id, buffer, buffer_size, &rc)) { return rc; } begin: header_size = sizeof (NET_HEADER); rc = css_net_read_header (conn->fd, (char *) &header, &header_size, -1); if (rc != NO_ERRORS) { return rc; } assert (header_size == sizeof (NET_HEADER)); rid = ntohl (header.request_id); conn->db_error = (int) ntohl (header.db_error); type = ntohl (header.type); if (type == ERROR_TYPE) { conn->set_tran_index (ntohl (header.transaction_id)); buf_size = ntohl (header.buffer_size); if (buf_size != 0) { buf = (char *) css_return_data_buffer (conn, rid, &buf_size); if (buf != NULL) { rc = css_net_recv (conn->fd, buf, &buf_size, -1); if (rc == NO_ERRORS || rc == RECORD_TRUNCATED) { if (req_id != rid) { /* We have some data for a different request id */ css_queue_unexpected_error_packet (conn, rid, buf, buf_size, rc); goto begin; } } } else { /* * allocation error, buffer == NULL * cleanup received message and set error */ css_read_remaining_bytes (conn->fd, sizeof (int) + buf_size); rc = CANT_ALLOC_BUFFER; if (req_id != rid) { css_queue_unexpected_error_packet (conn, rid, NULL, 0, rc); goto begin; } } *buffer = buf; *buffer_size = buf_size; return rc; } else { /* * This is the case where data length is zero, but if the * user registered a buffer, we should return the buffer */ *buffer_size = ntohl (header.buffer_size); *buffer = css_return_data_buffer (conn, req_id, buffer_size); assert (*buffer_size == 0); return rc; } } else { css_queue_unexpected_packet (type, conn, rid, &header, ntohl (header.buffer_size)); goto begin; } // unreachable assert (0); } /* * css_common_connect () - actually try to make a connection to a server * return: * host_name(in): * conn(in/out): * connect_type(in): * server_name(in): * server_name_length(in): * port(in): * timeout(in): timeout in seconds * rid(out): */ CSS_CONN_ENTRY * css_common_connect (const char *host_name, CSS_CONN_ENTRY * conn, int connect_type, const char *server_name, int server_name_length, int port, int timeout, unsigned short *rid, bool send_magic) { SOCKET fd; #if !defined (WINDOWS) if (timeout > 0) { /* timeout in milli-seconds in css_tcp_client_open_with_timeout() */ fd = css_tcp_client_open_with_timeout (host_name, port, timeout * 1000); } else { fd = css_tcp_client_open_with_retry (host_name, port, true); } #else /* !WINDOWS */ fd = css_tcp_client_open_with_retry (host_name, port, true); #endif /* WINDOWS */ if (!IS_INVALID_SOCKET (fd)) { conn->fd = fd; if (send_magic == true && css_send_magic (conn) != NO_ERRORS) { return NULL; } if (css_send_request (conn, connect_type, rid, server_name, server_name_length) == NO_ERRORS) { return conn; } } #if !defined (WINDOWS) else if (errno == ETIMEDOUT) { er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_TCP_CONNECT_TIMEDOUT, 2, host_name, timeout); } #endif /* !WINDOWS */ else { er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_TCP_CANNOT_CONNECT_TO_MASTER, 1, host_name); } return NULL; } /* * css_server_connect () - actually try to make a connection to a server * return: * host_name(in): * conn(in): * server_name(in): * rid(out): */ static CSS_CONN_ENTRY * css_server_connect (char *host_name, CSS_CONN_ENTRY * conn, char *server_name, unsigned short *rid) { int length; if (server_name) { length = (int) strlen (server_name) + 1; } else { length = 0; } /* timeout in second in css_common_connect() */ return (css_common_connect (host_name, conn, DATA_REQUEST, server_name, length, css_Service_id, prm_get_integer_value (PRM_ID_TCP_CONNECTION_TIMEOUT), rid, true)); } /* New style server connection function that uses an explicit port id */ /* * css_server_connect_part_two () - * return: * host_name(in): * conn(in): * port_id(in): * rid(in): */ CSS_CONN_ENTRY * css_server_connect_part_two (char *host_name, CSS_CONN_ENTRY * conn, int port_id, unsigned short *rid) { int reason = -1, buffer_size; char *buffer = NULL; CSS_CONN_ENTRY *return_status; int timeout = -1; return_status = NULL; timeout = prm_get_integer_value (PRM_ID_TCP_CONNECTION_TIMEOUT); /* Use css_common_connect with the server's port id, since we already know we'll be connecting to the right server, * don't bother sending the server name. */ /* timeout in second in css_common_connect() */ if (css_common_connect (host_name, conn, DATA_REQUEST, NULL, 0, port_id, timeout, rid, false) == NULL) { return NULL; } /* now ask for a reply from the server */ css_queue_user_data_buffer (conn, *rid, sizeof (int), (char *) &reason); if (css_receive_data (conn, *rid, &buffer, &buffer_size, timeout * 1000) == NO_ERRORS) { if (buffer_size == sizeof (int) && buffer == (char *) &reason) { reason = ntohl (reason); if (reason == SERVER_CONNECTED) { return_status = conn; } /* we shouldn't have to deal with SERVER_STARTED responses here ? */ } } if (buffer != NULL && buffer != (char *) &reason) { free_and_init (buffer); } return return_status; } /* * css_connect_to_master_server () - connect to the master from the server * return: * master_port_id(in): * server_name(in): * name_length(in): * * Note: The server name argument is actually a combination of two strings, * the server name and the server version */ CSS_CONN_ENTRY * css_connect_to_master_server (int master_port_id, const char *server_name, int name_length) { char hname[CUB_MAXHOSTNAMELEN]; CSS_CONN_ENTRY *conn; unsigned short rid; int response, response_buff; int server_port_id; int connection_protocol; #if !defined(WINDOWS) std::string pname; int datagram_fd, socket_fd; #endif css_Service_id = master_port_id; if (GETHOSTNAME (hname, CUB_MAXHOSTNAMELEN) != 0) { return NULL; } conn = css_make_conn (0); if (conn == NULL) { er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_ERROR_DURING_SERVER_CONNECT, 1, server_name); return NULL; } /* select the connection protocol, for PC's this will always be new */ connection_protocol = ((css_Server_use_new_connection_protocol) ? SERVER_REQUEST_NEW : SERVER_REQUEST); if (css_common_connect (hname, conn, connection_protocol, server_name, name_length, master_port_id, 0, &rid, true) == NULL) { goto fail_end; } if (css_readn (conn->fd, (char *) &response_buff, sizeof (int), -1) != sizeof (int)) { goto fail_end; } response = ntohl (response_buff); TRACE ("connect_to_master received %d as response from master\n", response); switch (response) { case SERVER_ALREADY_EXISTS: #if defined(CS_MODE) if (IS_MASTER_CONN_NAME_HA_COPYLOG (server_name)) { er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_COPYLOG_ALREADY_EXISTS, 1, GET_REAL_MASTER_CONN_NAME (server_name)); } else if (IS_MASTER_CONN_NAME_HA_APPLYLOG (server_name)) { er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_APPLYLOG_ALREADY_EXISTS, 1, GET_REAL_MASTER_CONN_NAME (server_name)); } else if (IS_MASTER_CONN_NAME_HA_SERVER (server_name)) { er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_SERVER_ALREADY_EXISTS, 1, GET_REAL_MASTER_CONN_NAME (server_name)); } else #endif /* CS_MODE */ { er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_SERVER_ALREADY_EXISTS, 1, server_name); } goto fail_end; case SERVER_REQUEST_ACCEPTED_NEW: /* * Master requests a new-style connect, must go get our port id and set up our connection socket. * For drivers, we don't need a connection socket and we don't want to allocate a bunch of them. * Let a flag variable control whether or not we actually create one of these. */ if (css_Server_inhibit_connection_socket) { server_port_id = -1; } else { server_port_id = css_open_server_connection_socket (); } response = htonl (server_port_id); css_net_send (conn, (char *) &response, sizeof (int), -1); /* this connection remains our only contact with the master */ return conn; case SERVER_REQUEST_ACCEPTED: #if defined(WINDOWS) /* Windows can't handle this style of connection at all */ er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_ERROR_DURING_SERVER_CONNECT, 1, server_name); goto fail_end; #else /* WINDOWS */ /* send the "pathname" for the datagram */ /* be sure to open the datagram first. */ pname = std::filesystem::temp_directory_path (); pname += "/csql_tcp_setup_server" + std::to_string (getpid ()); (void) unlink (pname.c_str ()); // make sure file is deleted if (!css_tcp_setup_server_datagram (pname.c_str (), &socket_fd)) { (void) unlink (pname.c_str ()); er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_ERROR_DURING_SERVER_CONNECT, 1, server_name); goto fail_end; } if (css_send_data (conn, rid, pname.c_str (), pname.length () + 1) != NO_ERRORS) { (void) unlink (pname.c_str ()); close (socket_fd); er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_ERROR_DURING_SERVER_CONNECT, 1, server_name); goto fail_end; } if (!css_tcp_listen_server_datagram (socket_fd, &datagram_fd)) { (void) unlink (pname.c_str ()); close (socket_fd); er_set_with_oserror (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_ERROR_DURING_SERVER_CONNECT, 1, server_name); goto fail_end; } // success (void) unlink (pname.c_str ()); css_free_conn (conn); close (socket_fd); return (css_make_conn (datagram_fd)); #endif /* WINDOWS */ } fail_end: css_free_conn (conn); return NULL; } /* * css_connect_to_cubrid_server () - make a new connection to a server * return: * host_name(in): * server_name(in): */ CSS_CONN_ENTRY * css_connect_to_cubrid_server (char *host_name, char *server_name) { CSS_CONN_ENTRY *conn; CSS_QUEUE_ENTRY *buffer_q_entry_p; int css_err_code; int reason, port_id; int size; int retry_count; unsigned short rid; char *buffer = NULL; char reason_buffer[sizeof (int)]; char *error_area; int error_length; int timeout = -1; conn = css_make_conn (-1); if (conn == NULL) { return NULL; } timeout = prm_get_integer_value (PRM_ID_TCP_CONNECTION_TIMEOUT) * 1000; retry_count = 0; if (css_server_connect (host_name, conn, server_name, &rid) == NULL) { goto exit; } css_queue_user_data_buffer (conn, rid, sizeof (int), reason_buffer); css_err_code = css_receive_data (conn, rid, &buffer, &size, timeout); if (css_err_code != NO_ERRORS) { goto error_receive_data; } if (buffer != NULL && size == sizeof (int)) { reason = ntohl (*((int *) buffer)); } else { reason = SERVER_NOT_FOUND; } if (buffer != NULL && buffer != reason_buffer) { free_and_init (buffer); } switch (reason) { case SERVER_CONNECTED: return conn; case SERVER_STARTED: if (++retry_count > 20) { break; } else { css_close_conn (conn); } break; case SERVER_CONNECTED_NEW: /* new style of connection protocol, get the server port id */ css_queue_user_data_buffer (conn, rid, sizeof (int), reason_buffer); css_err_code = css_receive_data (conn, rid, &buffer, &size, timeout); if (css_err_code != NO_ERRORS) { goto error_receive_data; } if (buffer != NULL && size == sizeof (int)) { port_id = ntohl (*((int *) buffer)); css_close_conn (conn); if (buffer != reason_buffer) { free_and_init (buffer); } if (css_server_connect_part_two (host_name, conn, port_id, &rid)) { return conn; } } break; case SERVER_IS_RECOVERING: case SERVER_CLIENTS_EXCEEDED: case SERVER_INACCESSIBLE_IP: error_area = NULL; /* TODO: We may need to change protocol to properly receive server error for the cases. * Receiving error from server might not be completed because server disconnects the temporary connection. */ css_err_code = css_receive_error (conn, rid, &error_area, &error_length); if (css_err_code == NO_ERRORS && error_area != NULL) { // properly received the server error er_set_area_error (error_area); } if (error_area != NULL) { free_and_init (error_area); } break; case SERVER_NOT_FOUND: case SERVER_HANG: default: break; } if (buffer != NULL && buffer != reason_buffer) { free_and_init (buffer); } exit: css_free_conn (conn); return NULL; error_receive_data: /* buffer queue should be freed */ buffer_q_entry_p = css_find_queue_entry (conn->buffer_queue, rid); if (buffer_q_entry_p != NULL) { /* buffer_q_entry_p->buffer is the pointer of reason_buffer */ buffer_q_entry_p->buffer = NULL; css_queue_remove_header_entry_ptr (&conn->buffer_queue, buffer_q_entry_p); } goto exit; } /* * css_connect_to_master_for_info () - connect to the master server * return: * host_name(in): * port_id(in): * rid(out): * * Note: This will allow the client to extract information from the master, * as well as modify runtime parameters. */ CSS_CONN_ENTRY * css_connect_to_master_for_info (const char *host_name, int port_id, unsigned short *rid) { return (css_connect_to_master_timeout (host_name, port_id, 0, rid)); } /* * css_connect_to_master_timeout () - connect to the master server * return: * host_name(in): * port_id(in): * timeout(in): timeout in milli-seconds * rid(out): * * Note: This will allow the client to extract information from the master, * as well as modify runtime parameters. */ CSS_CONN_ENTRY * css_connect_to_master_timeout (const char *host_name, int port_id, int timeout, unsigned short *rid) { CSS_CONN_ENTRY *conn; double time = timeout; conn = css_make_conn (0); if (conn == NULL) { return NULL; } time = ceil (time / 1000); return (css_common_connect (host_name, conn, INFO_REQUEST, NULL, 0, port_id, (int) time, rid, true)); } /* * css_does_master_exist () - * return: * port_id(in): */ bool css_does_master_exist (int port_id) { SOCKET fd; /* Don't waste time retrying between master to master connections */ fd = css_tcp_client_open_with_retry ("localhost", port_id, false); if (!IS_INVALID_SOCKET (fd)) { css_shutdown_socket (fd); return true; } else { return false; } } /* * css_is_valid_request_id () - verify that there are no currently outstanding * requests with the same id * return: * conn(in): * request_id(in): */ bool css_is_valid_request_id (CSS_CONN_ENTRY * conn, unsigned short request_id) { #if defined(CS_MODE) extern unsigned short method_request_id; if (method_request_id == request_id) { return false; } #endif /* CS_MODE */ if (css_find_queue_entry (conn->data_queue, request_id) != NULL) { return false; } if (css_find_queue_entry (conn->request_queue, request_id) != NULL) { return false; } if (css_find_queue_entry (conn->abort_queue, request_id) != NULL) { return false; } if (css_find_queue_entry (conn->error_queue, request_id) != NULL) { return false; } return true; } /* * css_return_data_buffer() - return a buffer that has been queued by the * client (at request time), or will allocate a * new buffer * return: * conn(in/out): * request_id(in): * buffer_size(in/out): */ char * css_return_data_buffer (CSS_CONN_ENTRY * conn, unsigned short request_id, int *buffer_size) { CSS_QUEUE_ENTRY *buffer_q_entry_p; char *buffer; buffer_q_entry_p = css_find_queue_entry (conn->buffer_queue, request_id); if (buffer_q_entry_p != NULL) { if (*buffer_size > buffer_q_entry_p->size) { *buffer_size = buffer_q_entry_p->size; } buffer = buffer_q_entry_p->buffer; buffer_q_entry_p->buffer = NULL; css_queue_remove_header_entry_ptr (&conn->buffer_queue, buffer_q_entry_p); return buffer; } else if (*buffer_size == 0) { return NULL; } else { return (char *) malloc (*buffer_size); } } /* * css_return_queued_data () - return any data that has been queued * return: * conn(in/out): * request_id(in): * buffer(out): * buffer_size(out): * rc(out): */ static int css_return_queued_data (CSS_CONN_ENTRY * conn, unsigned short request_id, char **buffer, int *buffer_size, int *rc) { CSS_QUEUE_ENTRY *data_q_entry_p, *buffer_q_entry_p; data_q_entry_p = css_find_queue_entry (conn->data_queue, request_id); if (data_q_entry_p == NULL) { /* empty queue */ return 0; } /* * We may have somehow already queued a receive buffer for this * packet. If so, it's important that we use *that* buffer, because * upper level code will check to see that the buffer address that we * return from this level is the same as the one that the upper level * queued earlier. If it isn't, it will raise an error and stop * (error code -187, "Communications buffer not used"). */ buffer_q_entry_p = css_find_queue_entry (conn->buffer_queue, request_id); if (buffer_q_entry_p != NULL) { *buffer = buffer_q_entry_p->buffer; *buffer_size = data_q_entry_p->size; buffer_q_entry_p->buffer = NULL; memcpy (*buffer, data_q_entry_p->buffer, *buffer_size); css_queue_remove_header_entry_ptr (&conn->buffer_queue, buffer_q_entry_p); } else { *buffer = data_q_entry_p->buffer; *buffer_size = data_q_entry_p->size; /* * Null this out so that the call to css_queue_remove_header_entry_ptr() * below doesn't free the buffer out from underneath our caller. */ data_q_entry_p->buffer = NULL; } *rc = data_q_entry_p->rc; conn->set_tran_index (data_q_entry_p->transaction_id); conn->invalidate_snapshot = data_q_entry_p->invalidate_snapshot; conn->in_method = data_q_entry_p->in_method; conn->db_error = data_q_entry_p->db_error; css_queue_remove_header_entry_ptr (&conn->data_queue, data_q_entry_p); return 1; } /* * css_return_queued_error () - return any error data that has been queued * return: * conn(in/out): * request_id(in): * buffer(out): * buffer_size(out): * rc(out): */ int css_return_queued_error (CSS_CONN_ENTRY * conn, unsigned short request_id, char **buffer, int *buffer_size, int *rc) { CSS_QUEUE_ENTRY *error_q_entry_p, *p; CSS_QUEUE_ENTRY entry; error_q_entry_p = css_find_queue_entry (conn->error_queue, request_id); if (error_q_entry_p == NULL) { /* empty queue */ return 0; } *buffer = error_q_entry_p->buffer; *buffer_size = error_q_entry_p->size; *rc = error_q_entry_p->db_error; error_q_entry_p->buffer = NULL; css_queue_remove_header_entry_ptr (&conn->error_queue, error_q_entry_p); /* * Propagate ER_LK_UNILATERALLY_ABORTED error * when it is set during method call. */ if (*rc == ER_LK_UNILATERALLY_ABORTED) { for (p = conn->error_queue; p; p = p->next) { entry = *p; if (p->size < *buffer_size) { p->buffer = (char *) malloc (*buffer_size); if (p->buffer) { free_and_init (entry.buffer); } else { p->buffer = entry.buffer; p->db_error = *rc; continue; } } p->size = *buffer_size; memcpy (p->buffer, *buffer, p->size); p->db_error = *rc; } } return 1; } /* * css_return_queued_request () - return a pointer to a request, if one is * queued * return: * conn(in/out): * rid(out): * request(out): * buffer_size(out): */ static int css_return_queued_request (CSS_CONN_ENTRY * conn, unsigned short *rid, int *request, int *buffer_size) { CSS_QUEUE_ENTRY *request_q_entry_p; NET_HEADER *buffer; TPRINTF ("Entered return queued request %d\n", 0); request_q_entry_p = conn->request_queue; if (request_q_entry_p == NULL) { /* empty queue */ return 0; } TPRINTF ("Found a queued request %d\n", 0); *rid = request_q_entry_p->key; buffer = (NET_HEADER *) request_q_entry_p->buffer; *request = ntohs (buffer->function_code); *buffer_size = ntohl (buffer->buffer_size); conn->set_tran_index (request_q_entry_p->transaction_id); conn->invalidate_snapshot = request_q_entry_p->invalidate_snapshot; conn->in_method = request_q_entry_p->in_method; conn->db_error = request_q_entry_p->db_error; /* This will remove both the entry and the buffer */ css_queue_remove_header_entry (&conn->request_queue, *rid); return 1; } /* * css_remove_all_unexpected_packets () - remove all entries in all the queues associated with fd * return: void * conn(in/out): * * Note: DO NOT REMOVE THE DATA BUFFERS QUEUED BY THE USER */ void css_remove_all_unexpected_packets (CSS_CONN_ENTRY * conn) { css_queue_remove_header (&conn->request_queue); css_queue_remove_header (&conn->data_queue); css_queue_remove_header (&conn->abort_queue); css_queue_remove_header (&conn->error_queue); }
dfcffc03752aaf17d7292269838cae128581b80a
e73547787354afd9b717ea57fe8dd0695d161821
/include/mapfs/pra_16_shape.h
3900a928feb6fac9513e52a62f21e3c7a5a5c735
[]
no_license
pmret/papermario
8b514b19653cef8d6145e47499b3636b8c474a37
9774b26d93f1045dd2a67e502b6efc9599fb6c31
refs/heads/main
2023-08-31T07:09:48.951514
2023-08-21T18:07:08
2023-08-21T18:07:08
287,151,133
904
139
null
2023-09-14T02:44:23
2020-08-13T01:22:57
C
UTF-8
C
false
false
2,494
h
pra_16_shape.h
#define MODEL_Root 0x41 #define MODEL_g199 0x40 #define MODEL_o686 0x3F #define MODEL_o965 0x3E #define MODEL_g257 0x3D #define MODEL_o947 0x3C #define MODEL_o945 0x3B #define MODEL_g252 0x3A #define MODEL_o893 0x39 #define MODEL_o690 0x38 #define MODEL_g242 0x37 #define MODEL_g246 0x36 #define MODEL_o881 0x35 #define MODEL_o880 0x34 #define MODEL_g245 0x33 #define MODEL_o879 0x32 #define MODEL_o878 0x31 #define MODEL_g244 0x30 #define MODEL_o877 0x2F #define MODEL_o876 0x2E #define MODEL_g243 0x2D #define MODEL_o875 0x2C #define MODEL_o874 0x2B #define MODEL_g238 0x2A #define MODEL_g237 0x29 #define MODEL_o862 0x28 #define MODEL_o861 0x27 #define MODEL_g236 0x26 #define MODEL_o860 0x25 #define MODEL_o859 0x24 #define MODEL_g220 0x23 #define MODEL_o844 0x22 #define MODEL_o772 0x21 #define MODEL_g219 0x20 #define MODEL_o846 0x1F #define MODEL_o768 0x1E #define MODEL_g240 0x1D #define MODEL_o922 0x1C #define MODEL_o885 0x1B #define MODEL_o872 0x1A #define MODEL_o870 0x19 #define MODEL_o868 0x18 #define MODEL_g185 0x17 #define MODEL_o982 0x16 #define MODEL_o646 0x15 #define MODEL_o856 0x14 #define MODEL_o638 0x13 #define MODEL_o636 0x12 #define MODEL_o914 0x11 #define MODEL_g197 0x10 #define MODEL_o680 0xF #define MODEL_g228 0xE #define MODEL_o955 0xD #define MODEL_o950 0xC #define MODEL_o949 0xB #define MODEL_g230 0xA #define MODEL_o951 0x9 #define MODEL_o676 0x8 #define MODEL_o981 0x7 #define MODEL_g229 0x6 #define MODEL_g265 0x5 #define MODEL_o980 0x4 #define MODEL_o979 0x3 #define MODEL_o978 0x2 #define MODEL_o953 0x1 #define MODEL_o658 0x0
5bdbebb30da3f412153b9be9214a380ead9ff170
f367e4b66a1ee42e85830b31df88f63723c36a47
/lib/luajit-3065c9/src/lj_strfmt_num.c
3c60695cccbdcf6f3a5e0f9373af4a8972f5a0f9
[ "Apache-2.0", "MIT", "LicenseRef-scancode-public-domain" ]
permissive
fluent/fluent-bit
06873e441162b92941024e9a7e9e8fc934150bf7
1a41f49dc2f3ae31a780caa9ffd6137b1d703065
refs/heads/master
2023-09-05T13:44:55.347372
2023-09-05T10:14:33
2023-09-05T10:14:33
29,933,948
4,907
1,565
Apache-2.0
2023-09-14T10:17:02
2015-01-27T20:41:52
C
UTF-8
C
false
false
20,410
c
lj_strfmt_num.c
/* ** String formatting for floating-point numbers. ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h ** Contributed by Peter Cawley. */ #include <stdio.h> #define lj_strfmt_num_c #define LUA_CORE #include "lj_obj.h" #include "lj_buf.h" #include "lj_str.h" #include "lj_strfmt.h" /* -- Precomputed tables -------------------------------------------------- */ /* Rescale factors to push the exponent of a number towards zero. */ #define RESCALE_EXPONENTS(P, N) \ P(308), P(289), P(270), P(250), P(231), P(212), P(193), P(173), P(154), \ P(135), P(115), P(96), P(77), P(58), P(38), P(0), P(0), P(0), N(39), N(58), \ N(77), N(96), N(116), N(135), N(154), N(174), N(193), N(212), N(231), \ N(251), N(270), N(289) #define ONE_E_P(X) 1e+0 ## X #define ONE_E_N(X) 1e-0 ## X static const int16_t rescale_e[] = { RESCALE_EXPONENTS(-, +) }; static const double rescale_n[] = { RESCALE_EXPONENTS(ONE_E_P, ONE_E_N) }; #undef ONE_E_N #undef ONE_E_P /* ** For p in range -70 through 57, this table encodes pairs (m, e) such that ** 4*2^p <= (uint8_t)m*10^e, and is the smallest value for which this holds. */ static const int8_t four_ulp_m_e[] = { 34, -21, 68, -21, 14, -20, 28, -20, 55, -20, 2, -19, 3, -19, 5, -19, 9, -19, -82, -18, 35, -18, 7, -17, -117, -17, 28, -17, 56, -17, 112, -16, -33, -16, 45, -16, 89, -16, -78, -15, 36, -15, 72, -15, -113, -14, 29, -14, 57, -14, 114, -13, -28, -13, 46, -13, 91, -12, -74, -12, 37, -12, 73, -12, 15, -11, 3, -11, 59, -11, 2, -10, 3, -10, 5, -10, 1, -9, -69, -9, 38, -9, 75, -9, 15, -7, 3, -7, 6, -7, 12, -6, -17, -7, 48, -7, 96, -7, -65, -6, 39, -6, 77, -6, -103, -5, 31, -5, 62, -5, 123, -4, -11, -4, 49, -4, 98, -4, -60, -3, 4, -2, 79, -3, 16, -2, 32, -2, 63, -2, 2, -1, 25, 0, 5, 1, 1, 2, 2, 2, 4, 2, 8, 2, 16, 2, 32, 2, 64, 2, -128, 2, 26, 2, 52, 2, 103, 3, -51, 3, 41, 4, 82, 4, -92, 4, 33, 4, 66, 4, -124, 5, 27, 5, 53, 5, 105, 6, 21, 6, 42, 6, 84, 6, 17, 7, 34, 7, 68, 7, 2, 8, 3, 8, 6, 8, 108, 9, -41, 9, 43, 10, 86, 9, -84, 10, 35, 10, 69, 10, -118, 11, 28, 11, 55, 12, 11, 13, 22, 13, 44, 13, 88, 13, -80, 13, 36, 13, 71, 13, -115, 14, 29, 14, 57, 14, 113, 15, -30, 15, 46, 15, 91, 15, 19, 16, 37, 16, 73, 16, 2, 17, 3, 17, 6, 17 }; /* min(2^32-1, 10^e-1) for e in range 0 through 10 */ static uint32_t ndigits_dec_threshold[] = { 0, 9U, 99U, 999U, 9999U, 99999U, 999999U, 9999999U, 99999999U, 999999999U, 0xffffffffU }; /* -- Helper functions ---------------------------------------------------- */ /* Compute the number of digits in the decimal representation of x. */ static MSize ndigits_dec(uint32_t x) { MSize t = ((lj_fls(x | 1) * 77) >> 8) + 1; /* 2^8/77 is roughly log2(10) */ return t + (x > ndigits_dec_threshold[t]); } #define WINT_R(x, sh, sc) \ { uint32_t d = (x*(((1<<sh)+sc-1)/sc))>>sh; x -= d*sc; *p++ = (char)('0'+d); } /* Write 9-digit unsigned integer to buffer. */ static char *lj_strfmt_wuint9(char *p, uint32_t u) { uint32_t v = u / 10000, w; u -= v * 10000; w = v / 10000; v -= w * 10000; *p++ = (char)('0'+w); WINT_R(v, 23, 1000) WINT_R(v, 12, 100) WINT_R(v, 10, 10) *p++ = (char)('0'+v); WINT_R(u, 23, 1000) WINT_R(u, 12, 100) WINT_R(u, 10, 10) *p++ = (char)('0'+u); return p; } #undef WINT_R /* -- Extended precision arithmetic --------------------------------------- */ /* ** The "nd" format is a fixed-precision decimal representation for numbers. It ** consists of up to 64 uint32_t values, with each uint32_t storing a value ** in the range [0, 1e9). A number in "nd" format consists of three variables: ** ** uint32_t nd[64]; ** uint32_t ndlo; ** uint32_t ndhi; ** ** The integral part of the number is stored in nd[0 ... ndhi], the value of ** which is sum{i in [0, ndhi] | nd[i] * 10^(9*i)}. If the fractional part of ** the number is zero, ndlo is zero. Otherwise, the fractional part is stored ** in nd[ndlo ... 63], the value of which is taken to be ** sum{i in [ndlo, 63] | nd[i] * 10^(9*(i-64))}. ** ** If the array part had 128 elements rather than 64, then every double would ** have an exact representation in "nd" format. With 64 elements, all integral ** doubles have an exact representation, and all non-integral doubles have ** enough digits to make both %.99e and %.99f do the right thing. */ #if LJ_64 #define ND_MUL2K_MAX_SHIFT 29 #define ND_MUL2K_DIV1E9(val) ((uint32_t)((val) / 1000000000)) #else #define ND_MUL2K_MAX_SHIFT 11 #define ND_MUL2K_DIV1E9(val) ((uint32_t)((val) >> 9) / 1953125) #endif /* Multiply nd by 2^k and add carry_in (ndlo is assumed to be zero). */ static uint32_t nd_mul2k(uint32_t* nd, uint32_t ndhi, uint32_t k, uint32_t carry_in, SFormat sf) { uint32_t i, ndlo = 0, start = 1; /* Performance hacks. */ if (k > ND_MUL2K_MAX_SHIFT*2 && STRFMT_FP(sf) != STRFMT_FP(STRFMT_T_FP_F)) { start = ndhi - (STRFMT_PREC(sf) + 17) / 8; } /* Real logic. */ while (k >= ND_MUL2K_MAX_SHIFT) { for (i = ndlo; i <= ndhi; i++) { uint64_t val = ((uint64_t)nd[i] << ND_MUL2K_MAX_SHIFT) | carry_in; carry_in = ND_MUL2K_DIV1E9(val); nd[i] = (uint32_t)val - carry_in * 1000000000; } if (carry_in) { nd[++ndhi] = carry_in; carry_in = 0; if (start++ == ndlo) ++ndlo; } k -= ND_MUL2K_MAX_SHIFT; } if (k) { for (i = ndlo; i <= ndhi; i++) { uint64_t val = ((uint64_t)nd[i] << k) | carry_in; carry_in = ND_MUL2K_DIV1E9(val); nd[i] = (uint32_t)val - carry_in * 1000000000; } if (carry_in) nd[++ndhi] = carry_in; } return ndhi; } /* Divide nd by 2^k (ndlo is assumed to be zero). */ static uint32_t nd_div2k(uint32_t* nd, uint32_t ndhi, uint32_t k, SFormat sf) { uint32_t ndlo = 0, stop1 = ~0, stop2 = ~0; /* Performance hacks. */ if (!ndhi) { if (!nd[0]) { return 0; } else { uint32_t s = lj_ffs(nd[0]); if (s >= k) { nd[0] >>= k; return 0; } nd[0] >>= s; k -= s; } } if (k > 18) { if (STRFMT_FP(sf) == STRFMT_FP(STRFMT_T_FP_F)) { stop1 = 63 - (int32_t)STRFMT_PREC(sf) / 9; } else { int32_t floorlog2 = ndhi * 29 + lj_fls(nd[ndhi]) - k; int32_t floorlog10 = (int32_t)(floorlog2 * 0.30102999566398114); stop1 = 62 + (floorlog10 - (int32_t)STRFMT_PREC(sf)) / 9; stop2 = 61 + ndhi - (int32_t)STRFMT_PREC(sf) / 8; } } /* Real logic. */ while (k >= 9) { uint32_t i = ndhi, carry = 0; for (;;) { uint32_t val = nd[i]; nd[i] = (val >> 9) + carry; carry = (val & 0x1ff) * 1953125; if (i == ndlo) break; i = (i - 1) & 0x3f; } if (ndlo != stop1 && ndlo != stop2) { if (carry) { ndlo = (ndlo - 1) & 0x3f; nd[ndlo] = carry; } if (!nd[ndhi]) { ndhi = (ndhi - 1) & 0x3f; stop2--; } } else if (!nd[ndhi]) { if (ndhi != ndlo) { ndhi = (ndhi - 1) & 0x3f; stop2--; } else return ndlo; } k -= 9; } if (k) { uint32_t mask = (1U << k) - 1, mul = 1000000000 >> k, i = ndhi, carry = 0; for (;;) { uint32_t val = nd[i]; nd[i] = (val >> k) + carry; carry = (val & mask) * mul; if (i == ndlo) break; i = (i - 1) & 0x3f; } if (carry) { ndlo = (ndlo - 1) & 0x3f; nd[ndlo] = carry; } } return ndlo; } /* Add m*10^e to nd (assumes ndlo <= e/9 <= ndhi and 0 <= m <= 9). */ static uint32_t nd_add_m10e(uint32_t* nd, uint32_t ndhi, uint8_t m, int32_t e) { uint32_t i, carry; if (e >= 0) { i = (uint32_t)e/9; carry = m * (ndigits_dec_threshold[e - (int32_t)i*9] + 1); } else { int32_t f = (e-8)/9; i = (uint32_t)(64 + f); carry = m * (ndigits_dec_threshold[e - f*9] + 1); } for (;;) { uint32_t val = nd[i] + carry; if (LJ_UNLIKELY(val >= 1000000000)) { val -= 1000000000; nd[i] = val; if (LJ_UNLIKELY(i == ndhi)) { ndhi = (ndhi + 1) & 0x3f; nd[ndhi] = 1; break; } carry = 1; i = (i + 1) & 0x3f; } else { nd[i] = val; break; } } return ndhi; } /* Test whether two "nd" values are equal in their most significant digits. */ static int nd_similar(uint32_t* nd, uint32_t ndhi, uint32_t* ref, MSize hilen, MSize prec) { char nd9[9], ref9[9]; if (hilen <= prec) { if (LJ_UNLIKELY(nd[ndhi] != *ref)) return 0; prec -= hilen; ref--; ndhi = (ndhi - 1) & 0x3f; if (prec >= 9) { if (LJ_UNLIKELY(nd[ndhi] != *ref)) return 0; prec -= 9; ref--; ndhi = (ndhi - 1) & 0x3f; } } else { prec -= hilen - 9; } lj_assertX(prec < 9, "bad precision %d", prec); lj_strfmt_wuint9(nd9, nd[ndhi]); lj_strfmt_wuint9(ref9, *ref); return !memcmp(nd9, ref9, prec) && (nd9[prec] < '5') == (ref9[prec] < '5'); } /* -- Formatted conversions to buffer ------------------------------------- */ /* Write formatted floating-point number to either sb or p. */ static char *lj_strfmt_wfnum(SBuf *sb, SFormat sf, lua_Number n, char *p) { MSize width = STRFMT_WIDTH(sf), prec = STRFMT_PREC(sf), len; TValue t; t.n = n; if (LJ_UNLIKELY((t.u32.hi << 1) >= 0xffe00000)) { /* Handle non-finite values uniformly for %a, %e, %f, %g. */ int prefix = 0, ch = (sf & STRFMT_F_UPPER) ? 0x202020 : 0; if (((t.u32.hi & 0x000fffff) | t.u32.lo) != 0) { ch ^= ('n' << 16) | ('a' << 8) | 'n'; if ((sf & STRFMT_F_SPACE)) prefix = ' '; } else { ch ^= ('i' << 16) | ('n' << 8) | 'f'; if ((t.u32.hi & 0x80000000)) prefix = '-'; else if ((sf & STRFMT_F_PLUS)) prefix = '+'; else if ((sf & STRFMT_F_SPACE)) prefix = ' '; } len = 3 + (prefix != 0); if (!p) p = lj_buf_more(sb, width > len ? width : len); if (!(sf & STRFMT_F_LEFT)) while (width-- > len) *p++ = ' '; if (prefix) *p++ = prefix; *p++ = (char)(ch >> 16); *p++ = (char)(ch >> 8); *p++ = (char)ch; } else if (STRFMT_FP(sf) == STRFMT_FP(STRFMT_T_FP_A)) { /* %a */ const char *hexdig = (sf & STRFMT_F_UPPER) ? "0123456789ABCDEFPX" : "0123456789abcdefpx"; int32_t e = (t.u32.hi >> 20) & 0x7ff; char prefix = 0, eprefix = '+'; if (t.u32.hi & 0x80000000) prefix = '-'; else if ((sf & STRFMT_F_PLUS)) prefix = '+'; else if ((sf & STRFMT_F_SPACE)) prefix = ' '; t.u32.hi &= 0xfffff; if (e) { t.u32.hi |= 0x100000; e -= 1023; } else if (t.u32.lo | t.u32.hi) { /* Non-zero denormal - normalise it. */ uint32_t shift = t.u32.hi ? 20-lj_fls(t.u32.hi) : 52-lj_fls(t.u32.lo); e = -1022 - shift; t.u64 <<= shift; } /* abs(n) == t.u64 * 2^(e - 52) */ /* If n != 0, bit 52 of t.u64 is set, and is the highest set bit. */ if ((int32_t)prec < 0) { /* Default precision: use smallest precision giving exact result. */ prec = t.u32.lo ? 13-lj_ffs(t.u32.lo)/4 : 5-lj_ffs(t.u32.hi|0x100000)/4; } else if (prec < 13) { /* Precision is sufficiently low as to maybe require rounding. */ t.u64 += (((uint64_t)1) << (51 - prec*4)); } if (e < 0) { eprefix = '-'; e = -e; } len = 5 + ndigits_dec((uint32_t)e) + prec + (prefix != 0) + ((prec | (sf & STRFMT_F_ALT)) != 0); if (!p) p = lj_buf_more(sb, width > len ? width : len); if (!(sf & (STRFMT_F_LEFT | STRFMT_F_ZERO))) { while (width-- > len) *p++ = ' '; } if (prefix) *p++ = prefix; *p++ = '0'; *p++ = hexdig[17]; /* x or X */ if ((sf & (STRFMT_F_LEFT | STRFMT_F_ZERO)) == STRFMT_F_ZERO) { while (width-- > len) *p++ = '0'; } *p++ = '0' + (t.u32.hi >> 20); /* Usually '1', sometimes '0' or '2'. */ if ((prec | (sf & STRFMT_F_ALT))) { /* Emit fractional part. */ char *q = p + 1 + prec; *p = '.'; if (prec < 13) t.u64 >>= (52 - prec*4); else while (prec > 13) p[prec--] = '0'; while (prec) { p[prec--] = hexdig[t.u64 & 15]; t.u64 >>= 4; } p = q; } *p++ = hexdig[16]; /* p or P */ *p++ = eprefix; /* + or - */ p = lj_strfmt_wint(p, e); } else { /* %e or %f or %g - begin by converting n to "nd" format. */ uint32_t nd[64]; uint32_t ndhi = 0, ndlo, i; int32_t e = (t.u32.hi >> 20) & 0x7ff, ndebias = 0; char prefix = 0, *q; if (t.u32.hi & 0x80000000) prefix = '-'; else if ((sf & STRFMT_F_PLUS)) prefix = '+'; else if ((sf & STRFMT_F_SPACE)) prefix = ' '; prec += ((int32_t)prec >> 31) & 7; /* Default precision is 6. */ if (STRFMT_FP(sf) == STRFMT_FP(STRFMT_T_FP_G)) { /* %g - decrement precision if non-zero (to make it like %e). */ prec--; prec ^= (uint32_t)((int32_t)prec >> 31); } if ((sf & STRFMT_T_FP_E) && prec < 14 && n != 0) { /* Precision is sufficiently low that rescaling will probably work. */ if ((ndebias = rescale_e[e >> 6])) { t.n = n * rescale_n[e >> 6]; if (LJ_UNLIKELY(!e)) t.n *= 1e10, ndebias -= 10; t.u64 -= 2; /* Convert 2ulp below (later we convert 2ulp above). */ nd[0] = 0x100000 | (t.u32.hi & 0xfffff); e = ((t.u32.hi >> 20) & 0x7ff) - 1075 - (ND_MUL2K_MAX_SHIFT < 29); goto load_t_lo; rescale_failed: t.n = n; e = (t.u32.hi >> 20) & 0x7ff; ndebias = ndhi = 0; } } nd[0] = t.u32.hi & 0xfffff; if (e == 0) e++; else nd[0] |= 0x100000; e -= 1043; if (t.u32.lo) { e -= 32 + (ND_MUL2K_MAX_SHIFT < 29); load_t_lo: #if ND_MUL2K_MAX_SHIFT >= 29 nd[0] = (nd[0] << 3) | (t.u32.lo >> 29); ndhi = nd_mul2k(nd, ndhi, 29, t.u32.lo & 0x1fffffff, sf); #elif ND_MUL2K_MAX_SHIFT >= 11 ndhi = nd_mul2k(nd, ndhi, 11, t.u32.lo >> 21, sf); ndhi = nd_mul2k(nd, ndhi, 11, (t.u32.lo >> 10) & 0x7ff, sf); ndhi = nd_mul2k(nd, ndhi, 11, (t.u32.lo << 1) & 0x7ff, sf); #else #error "ND_MUL2K_MAX_SHIFT too small" #endif } if (e >= 0) { ndhi = nd_mul2k(nd, ndhi, (uint32_t)e, 0, sf); ndlo = 0; } else { ndlo = nd_div2k(nd, ndhi, (uint32_t)-e, sf); if (ndhi && !nd[ndhi]) ndhi--; } /* abs(n) == nd * 10^ndebias (for slightly loose interpretation of ==) */ if ((sf & STRFMT_T_FP_E)) { /* %e or %g - assume %e and start by calculating nd's exponent (nde). */ char eprefix = '+'; int32_t nde = -1; MSize hilen; if (ndlo && !nd[ndhi]) { ndhi = 64; do {} while (!nd[--ndhi]); nde -= 64 * 9; } hilen = ndigits_dec(nd[ndhi]); nde += ndhi * 9 + hilen; if (ndebias) { /* ** Rescaling was performed, but this introduced some error, and might ** have pushed us across a rounding boundary. We check whether this ** error affected the result by introducing even more error (2ulp in ** either direction), and seeing whether a rounding boundary was ** crossed. Having already converted the -2ulp case, we save off its ** most significant digits, convert the +2ulp case, and compare them. */ int32_t eidx = e + 70 + (ND_MUL2K_MAX_SHIFT < 29) + (t.u32.lo >= 0xfffffffe && !(~t.u32.hi << 12)); const int8_t *m_e = four_ulp_m_e + eidx * 2; lj_assertG_(G(sbufL(sb)), 0 <= eidx && eidx < 128, "bad eidx %d", eidx); nd[33] = nd[ndhi]; nd[32] = nd[(ndhi - 1) & 0x3f]; nd[31] = nd[(ndhi - 2) & 0x3f]; nd_add_m10e(nd, ndhi, (uint8_t)*m_e, m_e[1]); if (LJ_UNLIKELY(!nd_similar(nd, ndhi, nd + 33, hilen, prec + 1))) { goto rescale_failed; } } if ((int32_t)(prec - nde) < (0x3f & -(int32_t)ndlo) * 9) { /* Precision is sufficiently low as to maybe require rounding. */ ndhi = nd_add_m10e(nd, ndhi, 5, nde - prec - 1); nde += (hilen != ndigits_dec(nd[ndhi])); } nde += ndebias; if ((sf & STRFMT_T_FP_F)) { /* %g */ if ((int32_t)prec >= nde && nde >= -4) { if (nde < 0) ndhi = 0; prec -= nde; goto g_format_like_f; } else if (!(sf & STRFMT_F_ALT) && prec && width > 5) { /* Decrease precision in order to strip trailing zeroes. */ char tail[9]; uint32_t maxprec = hilen - 1 + ((ndhi - ndlo) & 0x3f) * 9; if (prec >= maxprec) prec = maxprec; else ndlo = (ndhi - (((int32_t)(prec - hilen) + 9) / 9)) & 0x3f; i = prec - hilen - (((ndhi - ndlo) & 0x3f) * 9) + 10; lj_strfmt_wuint9(tail, nd[ndlo]); while (prec && tail[--i] == '0') { prec--; if (!i) { if (ndlo == ndhi) { prec = 0; break; } lj_strfmt_wuint9(tail, nd[++ndlo]); i = 9; } } } } if (nde < 0) { /* Make nde non-negative. */ eprefix = '-'; nde = -nde; } len = 3 + prec + (prefix != 0) + ndigits_dec((uint32_t)nde) + (nde < 10) + ((prec | (sf & STRFMT_F_ALT)) != 0); if (!p) p = lj_buf_more(sb, (width > len ? width : len) + 5); if (!(sf & (STRFMT_F_LEFT | STRFMT_F_ZERO))) { while (width-- > len) *p++ = ' '; } if (prefix) *p++ = prefix; if ((sf & (STRFMT_F_LEFT | STRFMT_F_ZERO)) == STRFMT_F_ZERO) { while (width-- > len) *p++ = '0'; } q = lj_strfmt_wint(p + 1, nd[ndhi]); p[0] = p[1]; /* Put leading digit in the correct place. */ if ((prec | (sf & STRFMT_F_ALT))) { /* Emit fractional part. */ p[1] = '.'; p += 2; prec -= (MSize)(q - p); p = q; /* Account for digits already emitted. */ /* Then emit chunks of 9 digits (this may emit 8 digits too many). */ for (i = ndhi; (int32_t)prec > 0 && i != ndlo; prec -= 9) { i = (i - 1) & 0x3f; p = lj_strfmt_wuint9(p, nd[i]); } if ((sf & STRFMT_T_FP_F) && !(sf & STRFMT_F_ALT)) { /* %g (and not %#g) - strip trailing zeroes. */ p += (int32_t)prec & ((int32_t)prec >> 31); while (p[-1] == '0') p--; if (p[-1] == '.') p--; } else { /* %e (or %#g) - emit trailing zeroes. */ while ((int32_t)prec > 0) { *p++ = '0'; prec--; } p += (int32_t)prec; } } else { p++; } *p++ = (sf & STRFMT_F_UPPER) ? 'E' : 'e'; *p++ = eprefix; /* + or - */ if (nde < 10) *p++ = '0'; /* Always at least two digits of exponent. */ p = lj_strfmt_wint(p, nde); } else { /* %f (or, shortly, %g in %f style) */ if (prec < (MSize)(0x3f & -(int32_t)ndlo) * 9) { /* Precision is sufficiently low as to maybe require rounding. */ ndhi = nd_add_m10e(nd, ndhi, 5, 0 - prec - 1); } g_format_like_f: if ((sf & STRFMT_T_FP_E) && !(sf & STRFMT_F_ALT) && prec && width) { /* Decrease precision in order to strip trailing zeroes. */ if (ndlo) { /* nd has a fractional part; we need to look at its digits. */ char tail[9]; uint32_t maxprec = (64 - ndlo) * 9; if (prec >= maxprec) prec = maxprec; else ndlo = 64 - (prec + 8) / 9; i = prec - ((63 - ndlo) * 9); lj_strfmt_wuint9(tail, nd[ndlo]); while (prec && tail[--i] == '0') { prec--; if (!i) { if (ndlo == 63) { prec = 0; break; } lj_strfmt_wuint9(tail, nd[++ndlo]); i = 9; } } } else { /* nd has no fractional part, so precision goes straight to zero. */ prec = 0; } } len = ndhi * 9 + ndigits_dec(nd[ndhi]) + prec + (prefix != 0) + ((prec | (sf & STRFMT_F_ALT)) != 0); if (!p) p = lj_buf_more(sb, (width > len ? width : len) + 8); if (!(sf & (STRFMT_F_LEFT | STRFMT_F_ZERO))) { while (width-- > len) *p++ = ' '; } if (prefix) *p++ = prefix; if ((sf & (STRFMT_F_LEFT | STRFMT_F_ZERO)) == STRFMT_F_ZERO) { while (width-- > len) *p++ = '0'; } /* Emit integer part. */ p = lj_strfmt_wint(p, nd[ndhi]); i = ndhi; while (i) p = lj_strfmt_wuint9(p, nd[--i]); if ((prec | (sf & STRFMT_F_ALT))) { /* Emit fractional part. */ *p++ = '.'; /* Emit chunks of 9 digits (this may emit 8 digits too many). */ while ((int32_t)prec > 0 && i != ndlo) { i = (i - 1) & 0x3f; p = lj_strfmt_wuint9(p, nd[i]); prec -= 9; } if ((sf & STRFMT_T_FP_E) && !(sf & STRFMT_F_ALT)) { /* %g (and not %#g) - strip trailing zeroes. */ p += (int32_t)prec & ((int32_t)prec >> 31); while (p[-1] == '0') p--; if (p[-1] == '.') p--; } else { /* %f (or %#g) - emit trailing zeroes. */ while ((int32_t)prec > 0) { *p++ = '0'; prec--; } p += (int32_t)prec; } } } } if ((sf & STRFMT_F_LEFT)) while (width-- > len) *p++ = ' '; return p; } /* Add formatted floating-point number to buffer. */ SBuf *lj_strfmt_putfnum(SBuf *sb, SFormat sf, lua_Number n) { sb->w = lj_strfmt_wfnum(sb, sf, n, NULL); return sb; } /* -- Conversions to strings ---------------------------------------------- */ /* Convert number to string. */ GCstr * LJ_FASTCALL lj_strfmt_num(lua_State *L, cTValue *o) { char buf[STRFMT_MAXBUF_NUM]; MSize len = (MSize)(lj_strfmt_wfnum(NULL, STRFMT_G14, o->n, buf) - buf); return lj_str_new(L, buf, len); }
2eff19dd356861ecfeb5d65c2dac638700408afc
ed98b77f3f09b392e68a0d59c48eec299e883bb9
/tests/src/cons/nonlinear/nlhdlr_perspective.c
118fd886b8ae11a57c0e693a9561dddf5ea8afe8
[ "Apache-2.0" ]
permissive
scipopt/scip
c8ddbe7cdec0a3af5a230c04b74b76ffacbdcc33
dc856a4c966ea50bd5f52c58d7be4fea33706f4c
refs/heads/master
2023-08-19T11:39:12.578790
2023-08-15T20:05:58
2023-08-15T20:05:58
342,522,859
262
46
NOASSERTION
2023-08-03T07:37:45
2021-02-26T09:16:17
C
UTF-8
C
false
false
25,356
c
nlhdlr_perspective.c
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the program and library */ /* SCIP --- Solving Constraint Integer Programs */ /* */ /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */ /* */ /* 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. */ /* */ /* You should have received a copy of the Apache-2.0 license */ /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /**@file nlhdlr_perspective.c * @brief tests perspective nonlinear handler methods * @author Ksenia Bestuzheva */ /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ #include <string.h> #include "include/scip_test.h" #include "scip/scipdefplugins.h" #include "scip/nlhdlr.c" #include "scip/cons_nonlinear.c" #include "scip/nlhdlr_perspective.c" /* * TEST */ static SCIP* scip; static SCIP_VAR* x_1; static SCIP_VAR* x_2; static SCIP_VAR* x_3; static SCIP_VAR* y_1; static SCIP_VAR* y_2; static SCIP_VAR* y_3; static SCIP_VAR* z_1; static SCIP_VAR* z_2; static SCIP_VAR* z_3; static SCIP_CONSHDLR* conshdlr; static SCIP_NLHDLR* nlhdlr = NULL; static SCIP_NLHDLR* nlhdlr_conv = NULL; /* creates scip, problem, includes nonlinear constraint handler, creates and adds variables */ static void setup(void) { SCIP_CONSHDLRDATA* conshdlrdata; SCIP_CALL( SCIPcreate(&scip) ); SCIP_CALL( SCIPincludeDefaultPlugins(scip) ); conshdlr = SCIPfindConshdlr(scip, "nonlinear"); cr_assert_not_null(conshdlr); conshdlrdata = SCIPconshdlrGetData(conshdlr); cr_assert_not_null(conshdlrdata); /* get perspective and convex nlhdlrs */ nlhdlr = SCIPfindNlhdlrNonlinear(conshdlr, NLHDLR_NAME); nlhdlr_conv = SCIPfindNlhdlrNonlinear(conshdlr, "convex"); cr_assert_not_null(nlhdlr); cr_assert_not_null(nlhdlr_conv); /* create problem */ SCIP_CALL( SCIPcreateProbBasic(scip, "test_problem") ); SCIP_CALL( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_OFF, TRUE) ); SCIP_CALL( SCIPsetPresolving(scip, SCIP_PARAMSETTING_OFF, TRUE) ); /* TODO test also with adjrefpoint enabled (needs adjustment in expected cuts in sepa test) */ SCIP_CALL( SCIPsetBoolParam(scip, "nlhdlr/" NLHDLR_NAME "/adjrefpoint", FALSE) ); /* go to SOLVING stage */ SCIP_CALL( TESTscipSetStage(scip, SCIP_STAGE_SOLVING, TRUE) ); SCIP_CALL( SCIPcreateVarBasic(scip, &x_1, "x1", 0.0, 4.0, 0.0, SCIP_VARTYPE_CONTINUOUS) ); SCIP_CALL( SCIPcreateVarBasic(scip, &x_2, "x2", -1.0, 5.0, 0.0, SCIP_VARTYPE_CONTINUOUS) ); SCIP_CALL( SCIPcreateVarBasic(scip, &x_3, "x3", -1.0, 5.0, 0.0, SCIP_VARTYPE_CONTINUOUS) ); SCIP_CALL( SCIPcreateVarBasic(scip, &y_1, "y1", 0.0, 4.0, 0.0, SCIP_VARTYPE_CONTINUOUS) ); SCIP_CALL( SCIPcreateVarBasic(scip, &y_2, "y2", 0.0, 4.0, 0.0, SCIP_VARTYPE_CONTINUOUS) ); SCIP_CALL( SCIPcreateVarBasic(scip, &y_3, "y3", 0.0, 4.0, 0.0, SCIP_VARTYPE_CONTINUOUS) ); SCIP_CALL( SCIPcreateVarBasic(scip, &z_1, "z1", 0, 1, 0, SCIP_VARTYPE_BINARY) ); SCIP_CALL( SCIPcreateVarBasic(scip, &z_2, "z2", 0, 1, 0, SCIP_VARTYPE_BINARY) ); SCIP_CALL( SCIPcreateVarBasic(scip, &z_3, "z3", 0, 1, 0, SCIP_VARTYPE_BINARY) ); SCIP_CALL( SCIPaddVar(scip, x_1) ); SCIP_CALL( SCIPaddVar(scip, x_2) ); SCIP_CALL( SCIPaddVar(scip, x_3) ); SCIP_CALL( SCIPaddVar(scip, y_1) ); SCIP_CALL( SCIPaddVar(scip, y_2) ); SCIP_CALL( SCIPaddVar(scip, y_3) ); SCIP_CALL( SCIPaddVar(scip, z_1) ); SCIP_CALL( SCIPaddVar(scip, z_2) ); SCIP_CALL( SCIPaddVar(scip, z_3) ); } /* releases variables, frees scip */ static void teardown(void) { SCIP_CALL( SCIPreleaseVar(scip, &x_1) ); SCIP_CALL( SCIPreleaseVar(scip, &x_2) ); SCIP_CALL( SCIPreleaseVar(scip, &x_3) ); SCIP_CALL( SCIPreleaseVar(scip, &y_1) ); SCIP_CALL( SCIPreleaseVar(scip, &y_2) ); SCIP_CALL( SCIPreleaseVar(scip, &y_3) ); SCIP_CALL( SCIPreleaseVar(scip, &z_1) ); SCIP_CALL( SCIPreleaseVar(scip, &z_2) ); SCIP_CALL( SCIPreleaseVar(scip, &z_3) ); SCIP_CALL( SCIPfree(&scip) ); BMSdisplayMemory(); cr_assert_eq(BMSgetMemoryUsed(), 0, "Memory is leaking!!"); } static void checkCut(SCIP_ROW* cut, SCIP_VAR** vars, SCIP_Real* vals, int nvars, SCIP_Real lhs, SCIP_Real rhs) { SCIP_VAR* var; SCIP_Real coef; SCIP_Bool found; int i; int j; cr_assert(cut != NULL); cr_expect_eq(SCIProwGetNNonz(cut), nvars, "\nExpected %d vars, got %d", nvars, SCIProwGetNNonz(cut)); cr_expect(SCIPisEQ(scip, SCIProwGetLhs(cut), lhs)); cr_expect(SCIPisEQ(scip, SCIProwGetRhs(cut), rhs)); for( i = 0; i < SCIProwGetNNonz(cut); ++i ) { var = SCIPcolGetVar(SCIProwGetCols(cut)[i]); coef = SCIProwGetVals(cut)[i]; found = FALSE; for( j = 0; j < nvars; ++j ) { if( var == vars[j] ) { cr_expect(SCIPisEQ(scip, coef, vals[j])); found = TRUE; } } cr_expect(found, "variable %s must be in the cut", SCIPvarGetName(var)); } } /* tests the detection of semicontinuous variables */ Test(nlhdlrperspective, varissc, .init = setup, .fini = teardown) { SCIP_HASHMAP* scvars; SCIP_HASHMAPENTRY* entry; SCVARDATA* scvdata; SCIP_Bool result; SCIP_Bool infeas; int nbndchgs; int c; /* allocate memory */ SCIP_CALL( SCIPhashmapCreate(&scvars, SCIPblkmem(scip), 1) ); /* add bound information to the vars */ /* z1 <= x1 <= 3*z1 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_1, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_1, 3.0, 0.0, &infeas, &nbndchgs) ); /* x1 <= 2*z2 */ SCIP_CALL( SCIPaddVarVub(scip, x_1, z_2, 2.0, 0.0, &infeas, &nbndchgs) ); /* -z3 + 1 <= x1 <= 4*z3 + 1 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_3, -1.0, 1.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_3, 4.0, 1.0, &infeas, &nbndchgs) ); /* check if the var is semicontinuous */ SCIP_CALL( varIsSemicontinuous(scip, x_1, scvars, &result) ); /* check result */ cr_expect_eq(SCIPhashmapGetNElements(scvars), 1, "Expected 1 semicontinuous variable, got %d", SCIPhashmapGetNElements(scvars)); scvdata = (SCVARDATA*) SCIPhashmapGetImage(scvars, (void*)x_1); cr_expect_eq(scvdata->nbnds, 3, "Expected 3 on/off bounds for variable x1, got %d", scvdata->nbnds); cr_expect_eq(scvdata->bvars[0], (void*)z_1, "bvars[0] expected to be z1, got %s", SCIPvarGetName(scvdata->bvars[0])); cr_expect_eq(scvdata->vals0[0], 0.0, "vals0[0] expected to be 0.0, got %f", scvdata->vals0[0]); cr_expect_eq(scvdata->bvars[1], (void*)z_2, "bvars[1] expected to be z2, got %s", SCIPvarGetName(scvdata->bvars[1])); cr_expect_eq(scvdata->vals0[1], 0.0, "vals0[1] expected to be 0.0, got %f", scvdata->vals0[1]); cr_expect_eq(scvdata->bvars[2], (void*)z_3, "bvars[2] expected to be z3, got %s", SCIPvarGetName(scvdata->bvars[2])); cr_expect_eq(scvdata->vals0[2], 1.0, "vals0[2] expected to be 1.0, got %f", scvdata->vals0[2]); /* free memory */ for( c = 0; c < SCIPhashmapGetNEntries(scvars); ++c ) { entry = SCIPhashmapGetEntry(scvars, c); if( entry != NULL ) { scvdata = (SCVARDATA*) SCIPhashmapEntryGetImage(entry); SCIPfreeBlockMemoryArray(scip, &scvdata->ubs1, scvdata->bndssize); SCIPfreeBlockMemoryArray(scip, &scvdata->lbs1, scvdata->bndssize); SCIPfreeBlockMemoryArray(scip, &scvdata->vals0, scvdata->bndssize); SCIPfreeBlockMemoryArray(scip, &scvdata->bvars, scvdata->bndssize); SCIPfreeBlockMemory(scip, &scvdata); } } SCIPhashmapFree(&scvars); } /* detects x1^2 + x1y1 + x2^2 as an on/off expression with 2 indicator variables */ Test(nlhdlrperspective, detectandfree1, .init = setup, .fini = teardown) { SCIP_NLHDLREXPRDATA* nlhdlrexprdata = NULL; SCIP_EXPR* expr; SCIP_NLHDLR_METHOD enforcing; SCIP_NLHDLR_METHOD participating; SCIP_Bool infeas; SCIP_CONS* cons; int nbndchgs; SCIP_EXPR_OWNERDATA* ownerdata; /* create expression and constraint */ SCIP_CALL( SCIPparseExpr(scip, &expr, (char*)"<x1>^2 + <x1>*<y1> + <x2>^2", NULL, NULL, NULL) ); SCIP_CALL( SCIPcreateConsBasicNonlinear(scip, &cons, (char*)"nlin", expr, -SCIPinfinity(scip), 0) ); SCIP_CALL( SCIPreleaseExpr(scip, &expr) ); expr = SCIPgetExprNonlinear(cons); SCIP_CALL( SCIPcomputeExprCurvature(scip, expr) ); SCIP_CALL( SCIPregisterExprUsageNonlinear(scip, expr, TRUE, FALSE, FALSE, FALSE) ); /* add implied variable bounds */ /* -3z1 + 3 <= x1 <= 3*z1 + 3 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_1, -3.0, 3.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_1, 3.0, 3.0, &infeas, &nbndchgs) ); /* z1 <= y1 <= 3*z1 */ SCIP_CALL( SCIPaddVarVlb(scip, y_1, z_1, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, y_1, z_1, 3.0, 0.0, &infeas, &nbndchgs) ); /* -z1 <= x2 <= 5*z1 */ SCIP_CALL( SCIPaddVarVlb(scip, x_2, z_1, -1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_2, z_1, 5.0, 0.0, &infeas, &nbndchgs) ); /* add bounds with z_2 */ /* z2 <= x1 <= 3*z2 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_2, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_2, 3.0, 0.0, &infeas, &nbndchgs) ); /* -z2 <= y1 <= 3*z2 */ SCIP_CALL( SCIPaddVarVlb(scip, y_1, z_2, -1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, y_1, z_2, 3.0, 0.0, &infeas, &nbndchgs) ); /* -z2 <= x2 <= 5*z2 */ SCIP_CALL( SCIPaddVarVlb(scip, x_2, z_2, -1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_2, z_2, 5.0, 0.0, &infeas, &nbndchgs) ); /* for a sum, detect wants another (non default) nlhdlr to have detected; pretend that convex has detected */ ownerdata = SCIPexprGetOwnerData(expr); SCIP_CALL( SCIPallocBlockMemoryArray(scip, &ownerdata->enfos, 2) ); SCIP_CALL( SCIPallocBlockMemory(scip, &ownerdata->enfos[0]) ); SCIP_CALL( SCIPallocBlockMemory(scip, &ownerdata->enfos[1]) ); ownerdata->nenfos = 2; ownerdata->enfos[0]->nlhdlr = nlhdlr_conv; ownerdata->enfos[0]->nlhdlrparticipation = SCIP_NLHDLR_METHOD_SEPABELOW; ownerdata->enfos[1]->nlhdlr = nlhdlr; /* detect */ enforcing = SCIP_NLHDLR_METHOD_NONE; participating = SCIP_NLHDLR_METHOD_NONE; SCIP_CALL( nlhdlrDetectPerspective(scip, conshdlr, nlhdlr, expr, cons, &enforcing, &participating, &nlhdlrexprdata) ); cr_expect_eq(participating, SCIP_NLHDLR_METHOD_SEPABELOW, "expecting sepabelow, got %d\n", participating); cr_assert_eq(enforcing, SCIP_NLHDLR_METHOD_NONE); cr_assert_not_null(nlhdlrexprdata); cr_expect_eq(nlhdlrexprdata->nindicators, 2, "Expecting 2 indicator variables, got %d\n", nlhdlrexprdata->nindicators); /* compute and check the 'off' values */ SCIP_CALL( nlhdlrInitSepaPerspective(scip, conshdlr, cons, nlhdlr, expr, nlhdlrexprdata, TRUE, TRUE, &infeas) ); cr_assert_eq(nlhdlrexprdata->indicators[0], z_1, "Expecting the first indicator to be z_1, got %s\n", SCIPvarGetName(nlhdlrexprdata->indicators[0])); cr_assert_eq(nlhdlrexprdata->exprvals0[0], 9.0, "Expecting off value = 9.0, got %f\n", nlhdlrexprdata->exprvals0[0]); cr_assert_eq(nlhdlrexprdata->indicators[1], z_2, "Expecting the second indicator to be z_2, got %s\n", SCIPvarGetName(nlhdlrexprdata->indicators[1])); cr_assert_eq(nlhdlrexprdata->exprvals0[1], 0.0, "Expecting off value = 0.0, got %f\n", nlhdlrexprdata->exprvals0[1]); SCIP_CALL( freeNlhdlrExprData(scip, nlhdlrexprdata) ); SCIPfreeBlockMemory(scip, &nlhdlrexprdata); SCIPfreeBlockMemory(scip, &ownerdata->enfos[1]); SCIPfreeBlockMemory(scip, &ownerdata->enfos[0]); SCIPfreeBlockMemoryArray(scip, &ownerdata->enfos, 2); ownerdata->nenfos = 0; SCIP_CALL( SCIPreleaseCons(scip, &cons) ); } /* detects x1^2 as an on/off expression */ Test(nlhdlrperspective, detectandfree2, .init = setup, .fini = teardown) { SCIP_NLHDLREXPRDATA* nlhdlrexprdata = NULL; SCIP_EXPR* expr; SCIP_NLHDLR_METHOD enforcing; SCIP_NLHDLR_METHOD participating; SCIP_Bool infeas; SCIP_CONS* cons; int nbndchgs; SCIP_EXPR_OWNERDATA* ownerdata; /* create expression and constraint */ SCIP_CALL( SCIPparseExpr(scip, &expr, (char*)"<x1>^2", NULL, NULL, NULL) ); SCIP_CALL( SCIPcreateConsBasicNonlinear(scip, &cons, (char*)"nlin", expr, -SCIPinfinity(scip), 0) ); SCIP_CALL( SCIPreleaseExpr(scip, &expr) ); expr = SCIPgetExprNonlinear(cons); SCIP_CALL( SCIPcomputeExprCurvature(scip, expr) ); SCIP_CALL( SCIPregisterExprUsageNonlinear(scip, expr, TRUE, FALSE, FALSE, FALSE) ); /* z1 <= x1 <= 3*z1 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_1, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_1, 3.0, 0.0, &infeas, &nbndchgs) ); /* z2 <= x1 <= 3*z2 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_2, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_2, 3.0, 0.0, &infeas, &nbndchgs) ); /* detect wants another nlhdlr to have detected; pretend that convex has detected */ ownerdata = SCIPexprGetOwnerData(expr); SCIP_CALL( SCIPallocBlockMemoryArray(scip, &ownerdata->enfos, 2) ); SCIP_CALL( SCIPallocBlockMemory(scip, &ownerdata->enfos[0]) ); SCIP_CALL( SCIPallocBlockMemory(scip, &ownerdata->enfos[1]) ); ownerdata->nenfos = 2; ownerdata->enfos[0]->nlhdlr = nlhdlr_conv; ownerdata->enfos[0]->nlhdlrparticipation = SCIP_NLHDLR_METHOD_SEPABELOW; ownerdata->enfos[1]->nlhdlr = nlhdlr; /* detect */ enforcing = SCIP_NLHDLR_METHOD_NONE; participating = SCIP_NLHDLR_METHOD_NONE; SCIP_CALL( nlhdlrDetectPerspective(scip, conshdlr, nlhdlr, expr, cons, &enforcing, &participating, &nlhdlrexprdata) ); cr_expect_eq(participating, SCIP_NLHDLR_METHOD_SEPABELOW, "expecting participating = sepabelow, got %d\n", participating); cr_assert_eq(enforcing, SCIP_NLHDLR_METHOD_NONE); cr_assert_not_null(nlhdlrexprdata); cr_expect_eq(nlhdlrexprdata->nindicators, 2, "Expecting 2 indicator variables, got %d\n", nlhdlrexprdata->nindicators); SCIP_CALL( freeNlhdlrExprData(scip, nlhdlrexprdata) ); SCIPfreeBlockMemory(scip, &nlhdlrexprdata); SCIPfreeBlockMemory(scip, &ownerdata->enfos[1]); SCIPfreeBlockMemory(scip, &ownerdata->enfos[0]); SCIPfreeBlockMemoryArray(scip, &ownerdata->enfos, 2); ownerdata->nenfos = 0; SCIP_CALL( SCIPreleaseCons(scip, &cons) ); } /* detects log(x1+x2+1) as an on/off expression */ Test(nlhdlrperspective, detectandfree3, .init = setup, .fini = teardown) { SCIP_NLHDLREXPRDATA* nlhdlrexprdata = NULL; SCIP_EXPR* expr; SCIP_NLHDLR_METHOD enforcing; SCIP_NLHDLR_METHOD participating; SCIP_Bool infeas; SCIP_CONS* cons; int nbndchgs; SCIP_EXPR_OWNERDATA* ownerdata; /* create expression and constraint */ SCIP_CALL( SCIPparseExpr(scip, &expr, (char*)"log(<x1>+<x2>+1.0)", NULL, NULL, NULL) ); SCIP_CALL( SCIPcreateConsBasicNonlinear(scip, &cons, (char*)"nlin", expr, -SCIPinfinity(scip), 0) ); SCIP_CALL( SCIPreleaseExpr(scip, &expr) ); expr = SCIPgetExprNonlinear(cons); SCIP_CALL( SCIPcomputeExprCurvature(scip, expr) ); SCIP_CALL( SCIPregisterExprUsageNonlinear(scip, expr, TRUE, FALSE, FALSE, FALSE) ); /* z1 <= x1 <= 3*z1 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_1, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_1, 3.0, 0.0, &infeas, &nbndchgs) ); /* z2 <= x1 <= 3*z2 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_2, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_2, 3.0, 0.0, &infeas, &nbndchgs) ); /* z1 <= x2 <= 3*z1 */ SCIP_CALL( SCIPaddVarVlb(scip, x_2, z_1, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_2, z_1, 3.0, 0.0, &infeas, &nbndchgs) ); /* z2 <= x2 <= 3*z2 */ SCIP_CALL( SCIPaddVarVlb(scip, x_2, z_2, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_2, z_2, 3.0, 0.0, &infeas, &nbndchgs) ); /* z3 <= x2 <= 3*z3 */ SCIP_CALL( SCIPaddVarVlb(scip, x_2, z_3, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_2, z_3, 3.0, 0.0, &infeas, &nbndchgs) ); /* detect wants another nlhdlr to have detected; pretend that convex has detected */ ownerdata = SCIPexprGetOwnerData(expr); SCIP_CALL( SCIPallocBlockMemoryArray(scip, &ownerdata->enfos, 2) ); SCIP_CALL( SCIPallocBlockMemory(scip, &ownerdata->enfos[0]) ); SCIP_CALL( SCIPallocBlockMemory(scip, &ownerdata->enfos[1]) ); ownerdata->nenfos = 2; ownerdata->enfos[0]->nlhdlr = nlhdlr_conv; ownerdata->enfos[0]->nlhdlrparticipation = SCIP_NLHDLR_METHOD_SEPAABOVE; ownerdata->enfos[1]->nlhdlr = nlhdlr; /* detect */ enforcing = SCIP_NLHDLR_METHOD_NONE; participating = SCIP_NLHDLR_METHOD_NONE; SCIP_CALL( nlhdlrDetectPerspective(scip, conshdlr, nlhdlr, expr, cons, &enforcing, &participating, &nlhdlrexprdata) ); cr_expect_eq(participating, SCIP_NLHDLR_METHOD_SEPAABOVE, "expecting sepaabove, got %d\n", participating); cr_assert_eq(enforcing, SCIP_NLHDLR_METHOD_NONE); cr_assert_not_null(nlhdlrexprdata); cr_expect_eq(nlhdlrexprdata->nindicators, 2, "Expecting 2 indicator vars, got %d\n", nlhdlrexprdata->nindicators); SCIP_CALL( freeNlhdlrExprData(scip, nlhdlrexprdata) ); SCIPfreeBlockMemory(scip, &nlhdlrexprdata); SCIPfreeBlockMemory(scip, &ownerdata->enfos[1]); SCIPfreeBlockMemory(scip, &ownerdata->enfos[0]); SCIPfreeBlockMemoryArray(scip, &ownerdata->enfos, 2); ownerdata->nenfos = 0; SCIP_CALL( SCIPreleaseCons(scip, &cons) ); } /* separates x1^2 + x1y1 + x2^2 for 2 indicator variables */ Test(nlhdlrperspective, sepa, .init = setup, .fini = teardown) { SCIP_NLHDLREXPRDATA* nlhdlrexprdata = NULL; SCIP_NLHDLREXPRDATA* nlhdlrexprdata_conv = NULL; SCIP_EXPR* expr; SCIP_NLHDLR_METHOD enforcing; SCIP_NLHDLR_METHOD participating; SCIP_NLHDLR_METHOD enforcing_conv; SCIP_NLHDLR_METHOD participating_conv; SCIP_Bool infeas; SCIP_CONS* cons; int nbndchgs; SCIP_SOL* sol; SCIP_VAR** cutvars; SCIP_Real* cutvals; SCIP_VAR* auxvar; SCIP_PTRARRAY* rowpreps; SCIP_RESULT result; SCIP_EXPR_OWNERDATA* ownerdata; /* skip when no ipopt */ if( ! SCIPisIpoptAvailableIpopt() ) return; /* create expression and constraint */ SCIP_CALL( SCIPparseExpr(scip, &expr, (char*)"<x1>^2 + <x1>*<x2> + <x2>^2", NULL, NULL, NULL) ); SCIP_CALL( SCIPcreateConsBasicNonlinear(scip, &cons, (char*)"nlin", expr, -SCIPinfinity(scip), 0) ); SCIP_CALL( SCIPreleaseExpr(scip, &expr) ); expr = SCIPgetExprNonlinear(cons); SCIP_CALL( SCIPaddConsLocks(scip, cons, 1, 0) ); SCIP_CALL( SCIPcomputeExprCurvature(scip, expr) ); SCIP_CALL( SCIPregisterExprUsageNonlinear(scip, expr, TRUE, FALSE, FALSE, FALSE) ); /* add implied variable bounds */ /* -3z1 + 3 <= x1 <= 3*z1 + 3 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_1, -3.0, 3.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_1, 3.0, 3.0, &infeas, &nbndchgs) ); /* -z1 <= x2 <= 5*z1 */ SCIP_CALL( SCIPaddVarVlb(scip, x_2, z_1, -1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_2, z_1, 5.0, 0.0, &infeas, &nbndchgs) ); /* add bounds with z_2 */ /* z2 <= x1 <= 3*z2 */ SCIP_CALL( SCIPaddVarVlb(scip, x_1, z_2, 1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_1, z_2, 3.0, 0.0, &infeas, &nbndchgs) ); /* -z2 <= x2 <= 5*z2 */ SCIP_CALL( SCIPaddVarVlb(scip, x_2, z_2, -1.0, 0.0, &infeas, &nbndchgs) ); SCIP_CALL( SCIPaddVarVub(scip, x_2, z_2, 5.0, 0.0, &infeas, &nbndchgs) ); /* detect by convex handler */ enforcing_conv = SCIP_NLHDLR_METHOD_NONE; participating_conv = SCIP_NLHDLR_METHOD_NONE; SCIP_CALL( SCIPnlhdlrDetect(scip, conshdlr, nlhdlr_conv, expr, cons, &enforcing_conv, &participating_conv, &nlhdlrexprdata_conv) ); cr_expect_eq(participating_conv, SCIP_NLHDLR_METHOD_SEPABELOW, "expecting participating_conv = sepabelow, got %d\n", participating); cr_assert_eq(enforcing_conv, SCIP_NLHDLR_METHOD_SEPABELOW); cr_assert_not_null(nlhdlrexprdata_conv); /* although convex has already detected, it doesn't fill the ownerdata, so we do it here */ ownerdata = SCIPexprGetOwnerData(expr); SCIP_CALL( SCIPallocBlockMemoryArray(scip, &ownerdata->enfos, 2) ); SCIP_CALL( SCIPallocBlockMemory(scip, &ownerdata->enfos[0]) ); SCIP_CALL( SCIPallocBlockMemory(scip, &ownerdata->enfos[1]) ); ownerdata->nenfos = 2; ownerdata->enfos[0]->nlhdlr = nlhdlr_conv; ownerdata->enfos[0]->nlhdlrexprdata = nlhdlrexprdata_conv; ownerdata->enfos[0]->nlhdlrparticipation = participating_conv; ownerdata->enfos[1]->nlhdlr = nlhdlr; /* detect by perspective handler */ participating = SCIP_NLHDLR_METHOD_NONE; SCIP_CALL( nlhdlrDetectPerspective(scip, conshdlr, nlhdlr, expr, cons, &enforcing, &participating, &nlhdlrexprdata) ); cr_expect_eq(participating, SCIP_NLHDLR_METHOD_SEPABELOW, "expecting sepabelow, got %d\n", participating); cr_assert_not_null(nlhdlrexprdata); ownerdata->enfos[1]->nlhdlrexprdata = nlhdlrexprdata; cr_expect_eq(nlhdlrexprdata->nindicators, 2, "Expecting 2 indicator variables, got %d\n", nlhdlrexprdata->nindicators); /* compute and check the 'off' values */ SCIP_CALL( nlhdlrInitSepaPerspective(scip, conshdlr, cons, nlhdlr, expr, nlhdlrexprdata, TRUE, TRUE, &infeas) ); cr_assert_eq(nlhdlrexprdata->indicators[0], z_1, "Expecting the first indicator to be z_1, got %s\n", SCIPvarGetName(nlhdlrexprdata->indicators[0])); cr_assert_eq(nlhdlrexprdata->exprvals0[0], 9.0, "Expecting off value = 9.0, got %f\n", nlhdlrexprdata->exprvals0[0]); cr_assert_eq(nlhdlrexprdata->indicators[1], z_2, "Expecting the second indicator to be z_2, got %s\n", SCIPvarGetName(nlhdlrexprdata->indicators[1])); cr_assert_eq(nlhdlrexprdata->exprvals0[1], 0.0, "Expecting off value = 0.0, got %f\n", nlhdlrexprdata->exprvals0[1]); /* make sure there is an auxvar; since expr is not part of a constraint, we cannot lean on cons_nonlinear to do that for us TODO but it is part of a constraint? */ SCIP_CALL( createAuxVar(scip, expr) ); auxvar = SCIPgetExprAuxVarNonlinear(expr); /* initsepa of nlhdlr convex, so its estimate can be called later */ SCIP_CALL( SCIPnlhdlrInitsepa(scip, conshdlr, cons, nlhdlr_conv, expr, nlhdlrexprdata_conv, FALSE, TRUE, &infeas) ); /* clear cuts from initsepa, so we can do a cutcount later */ SCIP_CALL( SCIPclearCuts(scip) ); /* separate */ SCIP_CALL( SCIPcreateSol(scip, &sol, NULL) ); SCIP_CALL( SCIPsetSolVal(scip, sol, x_1, 0.0) ); SCIP_CALL( SCIPsetSolVal(scip, sol, x_2, 4.0) ); SCIP_CALL( SCIPsetSolVal(scip, sol, z_1, 0.5) ); SCIP_CALL( SCIPsetSolVal(scip, sol, z_2, 0.5) ); SCIP_CALL( SCIPsetSolVal(scip, sol, auxvar, 10) ); SCIP_CALL( SCIPnlhdlrEvalaux(scip, nlhdlr, expr, nlhdlrexprdata, &(ownerdata->enfos[1]->auxvalue), sol) ); cr_expect_eq(ownerdata->enfos[1]->auxvalue, 16.0); SCIP_CALL( SCIPcreatePtrarray(scip, &rowpreps) ); SCIP_CALL( nlhdlrEnfoPerspective(scip, conshdlr, cons, nlhdlr, expr, nlhdlrexprdata, sol, ownerdata->enfos[1]->auxvalue, FALSE, FALSE, FALSE, FALSE, &result) ); cr_expect_eq(result, SCIP_SEPARATED, "Expected enfo result = %d, got %d", SCIP_SEPARATED, result); cr_assert(SCIPgetNCuts(scip) == 2); /* check the cuts */ cutvars = (SCIP_VAR*[4]) {z_1, x_2, x_1, auxvar}; cutvals = (SCIP_Real[4]) {-13.0, 8.0, 4.0, -1.0}; checkCut(SCIPgetCuts(scip)[0], cutvars, cutvals, 4, -SCIPinfinity(scip), 3.0); cutvars = (SCIP_VAR*[4]) {x_2, x_1, auxvar, z_2}; cutvals = (SCIP_Real[4]) {8.0, 4.0, -1.0, -16.0}; checkCut(SCIPgetCuts(scip)[1], cutvars, cutvals, 4, -SCIPinfinity(scip), 0.0); /* free memory */ SCIP_CALL( SCIPclearCuts(scip) ); SCIP_CALL( SCIPfreePtrarray(scip, &rowpreps) ); SCIP_CALL( SCIPfreeSol(scip, &sol) ); SCIP_CALL( SCIPaddConsLocks(scip, cons, -1, 0) ); SCIP_CALL( SCIPreleaseCons(scip, &cons) ); }
45de35b844b385a8bace28154861076c0186e604
e8b04bef9aa1ac8e2c109dd315f133c8f4d28ae6
/tests/api/controllers/distance_sensor_enable_disable/distance_sensor_enable_disable.c
b5ef946ac991cf675c588c0a5ad0cf320ac2f4f8
[ "Apache-2.0" ]
permissive
cyberbotics/webots
f075dacf4067e8dcebbfd89e8690df8525f6d745
8aba6eaae76989facf3442305c8089d3cc366bcf
refs/heads/master
2023-08-31T09:41:13.205940
2023-08-18T10:48:30
2023-08-18T10:48:30
156,228,018
2,495
1,525
Apache-2.0
2023-08-28T16:30:33
2018-11-05T14:09:10
C++
UTF-8
C
false
false
5,245
c
distance_sensor_enable_disable.c
#include <webots/distance_sensor.h> #include <webots/robot.h> #include <webots/supervisor.h> #include "../../../lib/ts_assertion.h" #include "../../../lib/ts_utils.h" #define TIME_STEP 32 int main(int argc, char **argv) { ts_setup(argv[0]); double value; double newPosition[3] = {-0.03, 0.0, 0.0}; WbNodeRef robotNode = wb_supervisor_node_get_self(); WbFieldRef translationField = wb_supervisor_node_get_field(robotNode, "translation"); WbDeviceTag ds_generic = wb_robot_get_device("ds generic"); WbDeviceTag ds_sonar = wb_robot_get_device("ds sonar"); WbDeviceTag ds_infra_red = wb_robot_get_device("ds infra-red"); WbDeviceTag ds_laser = wb_robot_get_device("ds laser"); // test: get the value of a sensor which has not been enabled yet value = wb_distance_sensor_get_value(ds_generic); ts_assert_double_equal(value, NAN, "The distance sensor in generic mode doesn't return NAN when it has not been enabled yet. %lf != %lf", NAN, value); value = wb_distance_sensor_get_value(ds_sonar); ts_assert_double_equal(value, NAN, "The distance sensor in sonar mode doesn't return NAN when it has not been enabled yet."); value = wb_distance_sensor_get_value(ds_infra_red); ts_assert_double_equal(value, NAN, "The distance sensor in infra-red mode doesn't return NAN when it has not been enabled yet."); value = wb_distance_sensor_get_value(ds_laser); ts_assert_double_equal(value, NAN, "The distance sensor in laser mode doesn't return NAN when it has not been enabled yet."); wb_distance_sensor_enable(ds_generic, 3 * TIME_STEP); wb_distance_sensor_enable(ds_sonar, TIME_STEP); wb_distance_sensor_enable(ds_infra_red, TIME_STEP); wb_distance_sensor_enable(ds_laser, TIME_STEP); wb_robot_step(TIME_STEP); value = wb_distance_sensor_get_value(ds_sonar); ts_assert_double_in_delta( value, 500.0, 0.001, "The distance sensor in sonar mode doesn't return the right distance in the regular case. (%f but %f was expected)", value, 500.0); value = wb_distance_sensor_get_value(ds_infra_red); ts_assert_double_in_delta( value, 500.0, 0.001, "The distance sensor in infra-red mode doesn't return the right distance in the regular case. (%f but %f was expected)", value, 500.0); value = wb_distance_sensor_get_value(ds_laser); ts_assert_double_in_delta( value, 500.0, 0.001, "The distance sensor in laser mode doesn't return the right distance in the regular case. (%f but %f was expected)", value, 500.0); // test sensor value not available before first sampling period elapsed value = wb_distance_sensor_get_value(ds_generic); ts_assert_double_equal(value, NAN, "The distance sensor in generic mode should not yet be active during the first step."); wb_robot_step(TIME_STEP); value = wb_distance_sensor_get_value(ds_generic); ts_assert_double_equal(value, NAN, "The distance sensor in generic mode should not yet be active during the second step."); wb_robot_step(TIME_STEP); value = wb_distance_sensor_get_value(ds_generic); ts_assert_double_in_delta( value, 500.0, 0.001, "The distance sensor in generic mode doesn't return the right distance in the regular case. (%f but %f was expected)", value, 500.0); wb_supervisor_field_set_sf_vec3f(translationField, newPosition); // test: laser and sonar disabled -> last value returned // infra-red enabled -> return value changes next step // generic enabled -> return value changes in two steps wb_distance_sensor_disable(ds_sonar); wb_distance_sensor_disable(ds_laser); wb_robot_step(TIME_STEP); // test: get the value of an disabled sonar value = wb_distance_sensor_get_value(ds_sonar); ts_assert_double_in_delta(value, 500.0, 0.001, "The distance sensor in sonar mode doesn't return the last measured distance when being disabled."); value = wb_distance_sensor_get_value(ds_laser); ts_assert_double_in_delta(value, 500.0, 0.001, "The distance sensor in laser mode doesn't return the last measured distance when being disabled."); // test value updated value = wb_distance_sensor_get_value(ds_infra_red); ts_assert_double_in_delta( value, 800.0, 0.001, "The distance sensor in infra-red mode doesn't return the updated measured distance after translation."); // test value not updated yet value = wb_distance_sensor_get_value(ds_generic); ts_assert_double_in_delta( value, 500.0, 0.001, "The distance sensor in generic mode shouldn't update the measured distance the next step after translation."); wb_robot_step(TIME_STEP); value = wb_distance_sensor_get_value(ds_generic); ts_assert_double_in_delta( value, 500.0, 0.001, "The distance sensor in generic mode shouldn't update the measured distance two steps after translation."); wb_robot_step(TIME_STEP); value = wb_distance_sensor_get_value(ds_generic); ts_assert_double_in_delta( value, 800.0, 0.001, "The distance sensor in generic mode doesn't return the updates measured distance three steps after translation."); ts_send_success(); return EXIT_SUCCESS; }
6ac6853c4ff5987aac9e29e150f309b70c8d248c
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/mips/cavium/mainbus.c
747c0e4e7d8281a294e34bc943993cc064b85420
[]
no_license
NetBSD/src
1a9cbc22ed778be638b37869ed4fb5c8dd616166
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
refs/heads/trunk
2023-08-31T13:24:58.105962
2023-08-27T15:50:47
2023-08-27T15:50:47
88,439,547
656
348
null
2023-07-20T20:07:24
2017-04-16T20:03:43
null
UTF-8
C
false
false
5,275
c
mainbus.c
/* $NetBSD: mainbus.c,v 1.10 2021/09/06 14:03:18 jmcneill Exp $ */ /* * Copyright (c) 2007 * Internet Initiative Japan, Inc. 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. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/cdefs.h> __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.10 2021/09/06 14:03:18 jmcneill Exp $"); #define _MIPS_BUS_DMA_PRIVATE #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> #include <sys/bus.h> #include <mips/cavium/include/mainbusvar.h> #include <mips/cavium/octeonvar.h> #include <dev/fdt/fdtvar.h> static int mainbus_match(device_t, struct cfdata *, void *); static void mainbus_attach(device_t, device_t, void *); static void mainbus_attach_static(device_t); static void mainbus_attach_devicetree(device_t); static int mainbus_submatch(device_t, cfdata_t, const int *, void *); static int mainbus_print(void *, const char *); static void simplebus_bus_io_init(bus_space_tag_t, void *); CFATTACH_DECL_NEW(mainbus, sizeof(device_t), mainbus_match, mainbus_attach, NULL, NULL); static struct mips_bus_space simplebus_bus_tag; static struct mips_bus_dma_tag simplebus_dma_tag = { ._cookie = NULL, ._wbase = 0, ._bounce_alloc_lo = 0, ._bounce_alloc_hi = 0, ._dmamap_ops = _BUS_DMAMAP_OPS_INITIALIZER, ._dmamem_ops = _BUS_DMAMEM_OPS_INITIALIZER, ._dmatag_ops = _BUS_DMATAG_OPS_INITIALIZER, }; static int mainbus_match(device_t parent, struct cfdata *match, void *aux) { static int once = 0; if (once != 0) return 0; once = 1; return 1; } static void mainbus_attach(device_t parent, device_t self, void *aux) { aprint_normal("\n"); if (fdtbus_get_data() != NULL) { mainbus_attach_devicetree(self); } else { mainbus_attach_static(self); } } static void mainbus_attach_static(device_t self) { struct mainbus_attach_args aa; int i; for (i = 0; i < (int)mainbus_ndevs; i++) { aa.aa_name = mainbus_devs[i]; config_found(self, &aa, mainbus_print, CFARGS(.submatch = mainbus_submatch, .iattr = "mainbus")); } } extern struct octeon_config octeon_configuration; extern void octpow_bootstrap(struct octeon_config *); extern void octfpa_bootstrap(struct octeon_config *); static void mainbus_attach_devicetree(device_t self) { const struct fdt_console *cons = fdtbus_get_console(); struct mainbus_attach_args aa; struct fdt_attach_args faa; u_int uart_freq; aa.aa_name = "cpunode"; config_found(self, &aa, mainbus_print, CFARGS(.submatch = mainbus_submatch, .iattr = "mainbus")); aa.aa_name = "iobus"; config_found(self, &aa, mainbus_print, CFARGS(.submatch = mainbus_submatch, .iattr = "mainbus")); simplebus_bus_io_init(&simplebus_bus_tag, NULL); faa.faa_bst = &simplebus_bus_tag; faa.faa_dmat = &simplebus_dma_tag; faa.faa_name = ""; if (cons != NULL) { faa.faa_phandle = fdtbus_get_stdout_phandle(); if (of_getprop_uint32(faa.faa_phandle, "clock-frequency", &uart_freq) != 0) { uart_freq = octeon_ioclock_speed(); } if (uart_freq > 0) delay(640000000 / uart_freq); cons->consinit(&faa, uart_freq); } faa.faa_phandle = OF_peer(0); config_found(self, &faa, NULL, CFARGS(.iattr = "fdt")); } static int mainbus_submatch(device_t parent, cfdata_t cf, const int *locs, void *aux) { struct mainbus_attach_args *aa = aux; if (strcmp(cf->cf_name, aa->aa_name) != 0) return 0; return config_match(parent, cf, aux); } static int mainbus_print(void *aux, const char *pnp) { struct mainbus_attach_args *aa = aux; if (pnp != 0) return QUIET; if (pnp) aprint_normal("%s at %s", aa->aa_name, pnp); return UNCONF; } /* ---- bus_space(9) */ #define CHIP simplebus #define CHIP_IO #define CHIP_ACCESS_SIZE 8 #define CHIP_W1_BUS_START(v) 0x0000000000000000ULL #define CHIP_W1_BUS_END(v) 0x7fffffffffffffffULL #define CHIP_W1_SYS_START(v) 0x8000000000000000ULL #define CHIP_W1_SYS_END(v) 0xffffffffffffffffULL #include <mips/mips/bus_space_alignstride_chipdep.c> bus_space_tag_t fdtbus_bus_tag_create(int phandle, uint32_t flags) { return &simplebus_bus_tag; }
d08db3afcdded60314322316ac73bd3db854d749
a2440dbe95b034784aa940ddc0ee0faae7869e76
/modules/lwjgl/opengl/src/generated/c/org_lwjgl_opengl_EXTTransformFeedback.c
01aab5f2c0d992a3ce7aeff624f77324761c285c
[ "LicenseRef-scancode-khronos", "LGPL-2.0-or-later", "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
LWJGL/lwjgl3
8972338303520c5880d4a705ddeef60472a3d8e5
67b64ad33bdeece7c09b0f533effffb278c3ecf7
refs/heads/master
2023-08-26T16:21:38.090410
2023-08-26T16:05:52
2023-08-26T16:05:52
7,296,244
4,835
1,004
BSD-3-Clause
2023-09-10T12:03:24
2012-12-23T15:40:04
Java
UTF-8
C
false
false
3,704
c
org_lwjgl_opengl_EXTTransformFeedback.c
/* * Copyright LWJGL. All rights reserved. * License terms: https://www.lwjgl.org/license * MACHINE GENERATED FILE, DO NOT EDIT */ #include "common_tools.h" #include "opengl.h" typedef void (APIENTRY *glBindBufferRangeEXTPROC) (jint, jint, jint, uintptr_t, uintptr_t); typedef void (APIENTRY *glBindBufferOffsetEXTPROC) (jint, jint, jint, uintptr_t); typedef void (APIENTRY *glBindBufferBaseEXTPROC) (jint, jint, jint); typedef void (APIENTRY *glBeginTransformFeedbackEXTPROC) (jint); typedef void (APIENTRY *glEndTransformFeedbackEXTPROC) (void); typedef void (APIENTRY *glTransformFeedbackVaryingsEXTPROC) (jint, jint, uintptr_t, jint); typedef void (APIENTRY *glGetTransformFeedbackVaryingEXTPROC) (jint, jint, jint, uintptr_t, uintptr_t, uintptr_t, uintptr_t); EXTERN_C_ENTER JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_glBindBufferRangeEXT(JNIEnv *__env, jclass clazz, jint target, jint index, jint buffer, jlong offset, jlong size) { glBindBufferRangeEXTPROC glBindBufferRangeEXT = (glBindBufferRangeEXTPROC)tlsGetFunction(1867); UNUSED_PARAM(clazz) glBindBufferRangeEXT(target, index, buffer, (uintptr_t)offset, (uintptr_t)size); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_glBindBufferOffsetEXT(JNIEnv *__env, jclass clazz, jint target, jint index, jint buffer, jlong offset) { glBindBufferOffsetEXTPROC glBindBufferOffsetEXT = (glBindBufferOffsetEXTPROC)tlsGetFunction(1868); UNUSED_PARAM(clazz) glBindBufferOffsetEXT(target, index, buffer, (uintptr_t)offset); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_glBindBufferBaseEXT(JNIEnv *__env, jclass clazz, jint target, jint index, jint buffer) { glBindBufferBaseEXTPROC glBindBufferBaseEXT = (glBindBufferBaseEXTPROC)tlsGetFunction(1869); UNUSED_PARAM(clazz) glBindBufferBaseEXT(target, index, buffer); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_glBeginTransformFeedbackEXT(JNIEnv *__env, jclass clazz, jint primitiveMode) { glBeginTransformFeedbackEXTPROC glBeginTransformFeedbackEXT = (glBeginTransformFeedbackEXTPROC)tlsGetFunction(1870); UNUSED_PARAM(clazz) glBeginTransformFeedbackEXT(primitiveMode); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_glEndTransformFeedbackEXT(JNIEnv *__env, jclass clazz) { glEndTransformFeedbackEXTPROC glEndTransformFeedbackEXT = (glEndTransformFeedbackEXTPROC)tlsGetFunction(1871); UNUSED_PARAM(clazz) glEndTransformFeedbackEXT(); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_nglTransformFeedbackVaryingsEXT(JNIEnv *__env, jclass clazz, jint program, jint count, jlong varyingsAddress, jint bufferMode) { glTransformFeedbackVaryingsEXTPROC glTransformFeedbackVaryingsEXT = (glTransformFeedbackVaryingsEXTPROC)tlsGetFunction(1872); uintptr_t varyings = (uintptr_t)varyingsAddress; UNUSED_PARAM(clazz) glTransformFeedbackVaryingsEXT(program, count, varyings, bufferMode); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTTransformFeedback_nglGetTransformFeedbackVaryingEXT__IIIJJJJ(JNIEnv *__env, jclass clazz, jint program, jint index, jint bufSize, jlong lengthAddress, jlong sizeAddress, jlong typeAddress, jlong nameAddress) { glGetTransformFeedbackVaryingEXTPROC glGetTransformFeedbackVaryingEXT = (glGetTransformFeedbackVaryingEXTPROC)tlsGetFunction(1873); uintptr_t length = (uintptr_t)lengthAddress; uintptr_t size = (uintptr_t)sizeAddress; uintptr_t type = (uintptr_t)typeAddress; uintptr_t name = (uintptr_t)nameAddress; UNUSED_PARAM(clazz) glGetTransformFeedbackVaryingEXT(program, index, bufSize, length, size, type, name); } EXTERN_C_EXIT
abd9a91f43933c8862a99e95968f02428fc5527d
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/include/linux/module.h
761dc2848ffafb003f9c62245ad1c7908e1f2d7f
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
18,426
h
module.h
#ifndef _LINUX_MODULE_H #define _LINUX_MODULE_H /* * Dynamic loading of modules into the kernel. * * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996 * Rewritten again by Rusty Russell, 2002 */ #include <linux/list.h> #include <linux/stat.h> #include <linux/compiler.h> #include <linux/cache.h> #include <linux/kmod.h> #include <linux/elf.h> #include <linux/stringify.h> #include <linux/kobject.h> #include <linux/moduleparam.h> #include <linux/tracepoint.h> #include <linux/export.h> #include <linux/percpu.h> #include <asm/module.h> /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */ #define MODULE_SIG_STRING "~Module signature appended~\n" /* Not Yet Implemented */ #define MODULE_SUPPORTED_DEVICE(name) #define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN struct modversion_info { unsigned long crc; char name[MODULE_NAME_LEN]; }; struct module; struct module_kobject { struct kobject kobj; struct module *mod; struct kobject *drivers_dir; struct module_param_attrs *mp; }; struct module_attribute { struct attribute attr; ssize_t (*show)(struct module_attribute *, struct module_kobject *, char *); ssize_t (*store)(struct module_attribute *, struct module_kobject *, const char *, size_t count); void (*setup)(struct module *, const char *); int (*test)(struct module *); void (*free)(struct module *); }; struct module_version_attribute { struct module_attribute mattr; const char *module_name; const char *version; } __attribute__ ((__aligned__(sizeof(void *)))); extern ssize_t __modver_version_show(struct module_attribute *, struct module_kobject *, char *); extern struct module_attribute module_uevent; /* These are either module local, or the kernel's dummy ones. */ extern int init_module(void); extern void cleanup_module(void); /* Archs provide a method of finding the correct exception table. */ struct exception_table_entry; const struct exception_table_entry * search_extable(const struct exception_table_entry *first, const struct exception_table_entry *last, unsigned long value); void sort_extable(struct exception_table_entry *start, struct exception_table_entry *finish); void sort_main_extable(void); void trim_init_extable(struct module *m); #ifdef MODULE #define MODULE_GENERIC_TABLE(gtype,name) \ extern const struct gtype##_id __mod_##gtype##_table \ __attribute__ ((unused, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_GENERIC_TABLE(gtype,name) #endif /* Generic info of form tag = "info" */ #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info) /* For userspace: you can also call me... */ #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias) /* * The following license idents are currently accepted as indicating free * software modules * * "GPL" [GNU Public License v2 or later] * "GPL v2" [GNU Public License v2] * "GPL and additional rights" [GNU Public License v2 rights and more] * "Dual BSD/GPL" [GNU Public License v2 * or BSD license choice] * "Dual MIT/GPL" [GNU Public License v2 * or MIT license choice] * "Dual MPL/GPL" [GNU Public License v2 * or Mozilla license choice] * * The following other idents are available * * "Proprietary" [Non free products] * * There are dual licensed components, but when running with Linux it is the * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL * is a GPL combined work. * * This exists for several reasons * 1. So modinfo can show license info for users wanting to vet their setup * is free * 2. So the community can ignore bug reports including proprietary modules * 3. So vendors can do likewise based on their own policies */ #define MODULE_LICENSE(_license) MODULE_INFO(license, _license) /* * Author(s), use "Name <email>" or just "Name", for multiple * authors use multiple MODULE_AUTHOR() statements/lines. */ #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) /* What your module does. */ #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) #define MODULE_DEVICE_TABLE(type,name) \ MODULE_GENERIC_TABLE(type##_device,name) /* Version of form [<epoch>:]<version>[-<extra-version>]. Or for CVS/RCS ID version, everything but the number is stripped. <epoch>: A (small) unsigned integer which allows you to start versions anew. If not mentioned, it's zero. eg. "2:1.0" is after "1:2.0". <version>: The <version> may contain only alphanumerics and the character `.'. Ordered by numeric sort for numeric parts, ascii sort for ascii parts (as per RPM or DEB algorithm). <extraversion>: Like <version>, but inserted for local customizations, eg "rh3" or "rusty1". Using this automatically adds a checksum of the .c files and the local headers in "srcversion". */ #if defined(MODULE) || !defined(CONFIG_SYSFS) #define MODULE_VERSION(_version) MODULE_INFO(version, _version) #else #define MODULE_VERSION(_version) \ static struct module_version_attribute ___modver_attr = { \ .mattr = { \ .attr = { \ .name = "version", \ .mode = S_IRUGO, \ }, \ .show = __modver_version_show, \ }, \ .module_name = KBUILD_MODNAME, \ .version = _version, \ }; \ static const struct module_version_attribute \ __used __attribute__ ((__section__ ("__modver"))) \ * __moduleparam_const __modver_attr = &___modver_attr #endif /* Optional firmware file (or files) needed by the module * format is simply firmware file name. Multiple firmware * files require multiple MODULE_FIRMWARE() specifiers */ #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware) /* Given an address, look for it in the exception tables */ const struct exception_table_entry *search_exception_tables(unsigned long add); struct notifier_block; #ifdef CONFIG_MODULES extern int modules_disabled; /* for sysctl */ /* Get/put a kernel symbol (calls must be symmetric) */ void *__symbol_get(const char *symbol); void *__symbol_get_gpl(const char *symbol); #define symbol_get(x) ((typeof(&x))(__symbol_get(VMLINUX_SYMBOL_STR(x)))) /* modules using other modules: kdb wants to see this. */ struct module_use { struct list_head source_list; struct list_head target_list; struct module *source, *target; }; enum module_state { MODULE_STATE_LIVE, /* Normal state. */ MODULE_STATE_COMING, /* Full formed, running module_init. */ MODULE_STATE_GOING, /* Going away. */ MODULE_STATE_UNFORMED, /* Still setting it up. */ }; /** * struct module_ref - per cpu module reference counts * @incs: number of module get on this cpu * @decs: number of module put on this cpu * * We force an alignment on 8 or 16 bytes, so that alloc_percpu() * put @incs/@decs in same cache line, with no extra memory cost, * since alloc_percpu() is fine grained. */ struct module_ref { unsigned long incs; unsigned long decs; } __attribute((aligned(2 * sizeof(unsigned long)))); struct mod_kallsyms { Elf_Sym *symtab; unsigned int num_symtab; char *strtab; }; struct module { enum module_state state; /* Member of list of modules */ struct list_head list; /* Unique handle for this module */ char name[MODULE_NAME_LEN]; /* Sysfs stuff. */ struct module_kobject mkobj; struct module_attribute *modinfo_attrs; const char *version; const char *srcversion; struct kobject *holders_dir; /* Exported symbols */ const struct kernel_symbol *syms; const unsigned long *crcs; unsigned int num_syms; /* Kernel parameters. */ struct kernel_param *kp; unsigned int num_kp; /* GPL-only exported symbols. */ unsigned int num_gpl_syms; const struct kernel_symbol *gpl_syms; const unsigned long *gpl_crcs; #ifdef CONFIG_UNUSED_SYMBOLS /* unused exported symbols. */ const struct kernel_symbol *unused_syms; const unsigned long *unused_crcs; unsigned int num_unused_syms; /* GPL-only, unused exported symbols. */ unsigned int num_unused_gpl_syms; const struct kernel_symbol *unused_gpl_syms; const unsigned long *unused_gpl_crcs; #endif #ifdef CONFIG_MODULE_SIG /* Signature was verified. */ bool sig_ok; #endif /* symbols that will be GPL-only in the near future. */ const struct kernel_symbol *gpl_future_syms; const unsigned long *gpl_future_crcs; unsigned int num_gpl_future_syms; /* Exception table */ unsigned int num_exentries; struct exception_table_entry *extable; /* Startup function. */ int (*init)(void); /* If this is non-NULL, vfree after init() returns */ void *module_init; /* Here is the actual code + data, vfree'd on unload. */ void *module_core; /* Here are the sizes of the init and core sections */ unsigned int init_size, core_size; /* The size of the executable code in each section. */ unsigned int init_text_size, core_text_size; /* Size of RO sections of the module (text+rodata) */ unsigned int init_ro_size, core_ro_size; /* Arch-specific module values */ struct mod_arch_specific arch; unsigned int taints; /* same bits as kernel:tainted */ #ifdef CONFIG_GENERIC_BUG /* Support for BUG */ unsigned num_bugs; struct list_head bug_list; struct bug_entry *bug_table; #endif #ifdef CONFIG_KALLSYMS /* Protected by RCU and/or module_mutex: use rcu_dereference() */ struct mod_kallsyms *kallsyms; struct mod_kallsyms core_kallsyms; /* Section attributes */ struct module_sect_attrs *sect_attrs; /* Notes attributes */ struct module_notes_attrs *notes_attrs; #endif /* The command line arguments (may be mangled). People like keeping pointers to this stuff */ char *args; #ifdef CONFIG_SMP /* Per-cpu data. */ void __percpu *percpu; unsigned int percpu_size; #endif #ifdef CONFIG_TRACEPOINTS unsigned int num_tracepoints; struct tracepoint * const *tracepoints_ptrs; #endif #ifdef HAVE_JUMP_LABEL struct jump_entry *jump_entries; unsigned int num_jump_entries; #endif #ifdef CONFIG_TRACING unsigned int num_trace_bprintk_fmt; const char **trace_bprintk_fmt_start; #endif #ifdef CONFIG_EVENT_TRACING struct ftrace_event_call **trace_events; unsigned int num_trace_events; #endif #ifdef CONFIG_FTRACE_MCOUNT_RECORD unsigned int num_ftrace_callsites; unsigned long *ftrace_callsites; #endif #ifdef CONFIG_MODULE_UNLOAD /* What modules depend on me? */ struct list_head source_list; /* What modules do I depend on? */ struct list_head target_list; /* Who is waiting for us to be unloaded */ struct task_struct *waiter; /* Destruction function. */ void (*exit)(void); struct module_ref __percpu *refptr; #endif #ifdef CONFIG_CONSTRUCTORS /* Constructor functions. */ ctor_fn_t *ctors; unsigned int num_ctors; #endif }; #ifndef MODULE_ARCH_INIT #define MODULE_ARCH_INIT {} #endif extern struct mutex module_mutex; /* FIXME: It'd be nice to isolate modules during init, too, so they aren't used before they (may) fail. But presently too much code (IDE & SCSI) require entry into the module during init.*/ static inline int module_is_live(struct module *mod) { return mod->state != MODULE_STATE_GOING; } struct module *__module_text_address(unsigned long addr); struct module *__module_address(unsigned long addr); bool is_module_address(unsigned long addr); bool is_module_percpu_address(unsigned long addr); bool is_module_text_address(unsigned long addr); static inline int within_module_core(unsigned long addr, const struct module *mod) { return (unsigned long)mod->module_core <= addr && addr < (unsigned long)mod->module_core + mod->core_size; } static inline int within_module_init(unsigned long addr, const struct module *mod) { return (unsigned long)mod->module_init <= addr && addr < (unsigned long)mod->module_init + mod->init_size; } /* Search for module by name: must hold module_mutex. */ struct module *find_module(const char *name); struct symsearch { const struct kernel_symbol *start, *stop; const unsigned long *crcs; enum { NOT_GPL_ONLY, GPL_ONLY, WILL_BE_GPL_ONLY, } licence; bool unused; }; /* Search for an exported symbol by name. */ const struct kernel_symbol *find_symbol(const char *name, struct module **owner, const unsigned long **crc, bool gplok, bool warn); /* Walk the exported symbol table */ bool each_symbol_section(bool (*fn)(const struct symsearch *arr, struct module *owner, void *data), void *data); /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if symnum out of range. */ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *name, char *module_name, int *exported); /* Look for this name: can be of form module:name. */ unsigned long module_kallsyms_lookup_name(const char *name); int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, unsigned long), void *data); extern void __module_put_and_exit(struct module *mod, long code) __attribute__((noreturn)); #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); #ifdef CONFIG_MODULE_UNLOAD unsigned long module_refcount(struct module *mod); void __symbol_put(const char *symbol); #define symbol_put(x) __symbol_put(VMLINUX_SYMBOL_STR(x)) void symbol_put_addr(void *addr); /* Sometimes we know we already have a refcount, and it's easier not to handle the error case (which only happens with rmmod --wait). */ extern void __module_get(struct module *module); /* This is the Right Way to get a module: if it fails, it's being removed, * so pretend it's not there. */ extern bool try_module_get(struct module *module); extern void module_put(struct module *module); #else /*!CONFIG_MODULE_UNLOAD*/ static inline int try_module_get(struct module *module) { return !module || module_is_live(module); } static inline void module_put(struct module *module) { } static inline void __module_get(struct module *module) { } #define symbol_put(x) do { } while(0) #define symbol_put_addr(p) do { } while(0) #endif /* CONFIG_MODULE_UNLOAD */ int ref_module(struct module *a, struct module *b); /* This is a #define so the string doesn't get put in every .o file */ #define module_name(mod) \ ({ \ struct module *__mod = (mod); \ __mod ? __mod->name : "kernel"; \ }) /* For kallsyms to ask for address resolution. namebuf should be at * least KSYM_NAME_LEN long: a pointer to namebuf is returned if * found, otherwise NULL. */ const char *module_address_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf); int lookup_module_symbol_name(unsigned long addr, char *symname); int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); /* For extable.c to search modules' exception tables. */ const struct exception_table_entry *search_module_extables(unsigned long addr); int register_module_notifier(struct notifier_block * nb); int unregister_module_notifier(struct notifier_block * nb); extern void print_modules(void); #else /* !CONFIG_MODULES... */ /* Given an address, look for it in the exception tables. */ static inline const struct exception_table_entry * search_module_extables(unsigned long addr) { return NULL; } static inline struct module *__module_address(unsigned long addr) { return NULL; } static inline struct module *__module_text_address(unsigned long addr) { return NULL; } static inline bool is_module_address(unsigned long addr) { return false; } static inline bool is_module_percpu_address(unsigned long addr) { return false; } static inline bool is_module_text_address(unsigned long addr) { return false; } /* Get/put a kernel symbol (calls should be symmetric) */ #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); }) #define symbol_put(x) do { } while(0) #define symbol_put_addr(x) do { } while(0) static inline void __module_get(struct module *module) { } static inline int try_module_get(struct module *module) { return 1; } static inline void module_put(struct module *module) { } #define module_name(mod) "kernel" /* For kallsyms to ask for address resolution. NULL means not found. */ static inline const char *module_address_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf) { return NULL; } static inline int lookup_module_symbol_name(unsigned long addr, char *symname) { return -ERANGE; } static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name) { return -ERANGE; } static inline int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *name, char *module_name, int *exported) { return -ERANGE; } static inline unsigned long module_kallsyms_lookup_name(const char *name) { return 0; } static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, unsigned long), void *data) { return 0; } static inline int register_module_notifier(struct notifier_block * nb) { /* no events will happen anyway, so this can always succeed */ return 0; } static inline int unregister_module_notifier(struct notifier_block * nb) { return 0; } #define module_put_and_exit(code) do_exit(code) static inline void print_modules(void) { } #endif /* CONFIG_MODULES */ #ifdef CONFIG_SYSFS extern struct kset *module_kset; extern struct kobj_type module_ktype; extern int module_sysfs_initialized; #endif /* CONFIG_SYSFS */ #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ #define __MODULE_STRING(x) __stringify(x) #ifdef CONFIG_DEBUG_SET_MODULE_RONX extern void set_all_modules_text_rw(void); extern void set_all_modules_text_ro(void); #else static inline void set_all_modules_text_rw(void) { } static inline void set_all_modules_text_ro(void) { } #endif #ifdef CONFIG_GENERIC_BUG void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *, struct module *); void module_bug_cleanup(struct module *); #else /* !CONFIG_GENERIC_BUG */ static inline void module_bug_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *mod) { } static inline void module_bug_cleanup(struct module *mod) {} #endif /* CONFIG_GENERIC_BUG */ #endif /* _LINUX_MODULE_H */
35230b20ae96738e52c95e709dea1d3662cbf802
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
/hackathon/zhi/NeuronStudio_zhi/std/nsprofiler.h
200f18d99e6af17900221673ca25fa78013b5896
[ "MIT" ]
permissive
Vaa3D/vaa3d_tools
edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9
e6974d5223ae70474efaa85e1253f5df1814fae8
refs/heads/master
2023-08-03T06:12:01.013752
2023-08-02T07:26:01
2023-08-02T07:26:01
50,527,925
107
86
MIT
2023-05-22T23:43:48
2016-01-27T18:19:17
C++
UTF-8
C
false
false
3,818
h
nsprofiler.h
#ifndef __NS_STD_PROFILER_H__ #define __NS_STD_PROFILER_H__ #include <nsconfigure.h> #include <std/nsmacros.h> #include <std/nstypes.h> #include <std/nsdebug.h> #include <std/nserror.h> #include <std/nsfunc.h> #include <std/nsmemory.h> #include <std/nsascii.h> #include <std/nsmutex.h> #include <std/nshier.h> #include <std/nstime.h> #include <std/nsprint.h> #include <std/nsutil.h> NS_DECLS_BEGIN typedef struct _NsProfiler { NsHier profiles; nshieriter curr_profile; nsdouble elapsed_seconds; nshieriter shell_profile; nsboolean exit_shell; nstimer timer; nssize begin_count; NsMutex mutex; } NsProfiler; NS_IMPEXP void ns_profiler_construct( NsProfiler *profiler ); NS_IMPEXP void ns_profiler_destruct( NsProfiler *profiler ); NS_IMPEXP void ns_profiler_clear( NsProfiler *profiler ); /* NOTE: If either of E_DEBUG or E_ENABLE_PROFILING is not defined, the following functions will do nothing. */ /* Profiles a block of code with the given 'name' between the calls to begin/end. */ NS_IMPEXP NS_SYNCHRONIZED void ns_profiler_begin( NsProfiler *profiler, const nschar* name ); NS_IMPEXP NS_SYNCHRONIZED void ns_profiler_end( NsProfiler *profiler ); /* These functions just call ns_profiler_end() and then return the passed 'value'. */ NS_IMPEXP NsError ns_profiler_end_error( NsProfiler *profiler, NsError value ); NS_IMPEXP nspointer ns_profiler_end_pointer( NsProfiler *profiler, nspointer value ); NS_IMPEXP nslong ns_profiler_end_long( NsProfiler *profiler, nslong value ); NS_IMPEXP nsulong ns_profiler_end_ulong( NsProfiler *profiler, nsulong value ); #ifdef NS_HAVE_LONGLONG NS_IMPEXP nslonglong ns_profiler_end_longlong( NsProfiler *profiler, nslonglong value ); NS_IMPEXP nsulonglong ns_profiler_end_ulonglong( NsProfiler *profiler, nsulonglong value ); #endif NS_IMPEXP nsfloat ns_profiler_end_float( NsProfiler *profiler, nsfloat value ); NS_IMPEXP nsdouble ns_profiler_end_double( NsProfiler *profiler, nsdouble value ); NS_IMPEXP void ns_profiler_shell( NsProfiler *profiler ); /* Global profiler. Only active if both NS_DEBUG and NS_ENABLE_PROFILING are defined. */ NS_IMPEXP NsProfiler* ns_profiler( void ); /* Internal. DO NOT USE! */ NS_IMPEXP NS_INTERNAL void _ns_profiler_init( void ); NS_IMPEXP NS_INTERNAL void _ns_profiler_finalize( void ); #if defined( NS_DEBUG ) && defined( NS_ENABLE_PROFILING ) #define NS_PROFILER_CLEAR()\ ns_profiler_clear( ns_profiler() ) #define NS_PROFILER_BEGIN( name )\ ns_profiler_begin( ns_profiler(), (name) ) #define NS_PROFILER_END()\ ns_profiler_end( ns_profiler() ) #define NS_PROFILER_END_ERROR( value )\ ns_profiler_end_error( ns_profiler(), (value) ) #define NS_PROFILER_END_POINTER( value )\ ns_profiler_end_pointer( ns_profiler(), (value) ) #define NS_PROFILER_END_LONG( value )\ ns_profiler_end_long( ns_profiler(), (value) ) #define NS_PROFILER_END_ULONG( value )\ ns_profiler_end_ulong( ns_profiler(), (value) ) #define NS_PROFILER_END_FLOAT( value )\ ns_profiler_end_float( ns_profiler(), (value) ) #define NS_PROFILER_END_DOUBLE( value )\ ns_profiler_end_double( ns_profiler(), (value) ) #define NS_PROFILER_SHELL()\ ns_profiler_shell( ns_profiler() ) #else #define NS_PROFILER_CLEAR() #define NS_PROFILER_BEGIN( name ) #define NS_PROFILER_END() #define NS_PROFILER_END_ERROR( value ) (value) #define NS_PROFILER_END_POINTER( value ) (value) #define NS_PROFILER_END_LONG( value ) (value) #define NS_PROFILER_END_ULONG( value ) (value) #define NS_PROFILER_END_FLOAT( value ) (value) #define NS_PROFILER_END_DOUBLE( value ) (value) #define NS_PROFILER_SHELL() #endif NS_DECLS_END #endif/* __NS_STD_PROFILER_H__ */
75ef87900ace735b90bd2c2a6ba9da92d2e91475
0744dcc5394cebf57ebcba343747af6871b67017
/external/iotivity/iotivity_1.2-rel/plugins/zigbee_wrapper/telegesis_wrapper/include/twtypes.h
8dc20e9700f3764d7d4975e8e3310737994f39e2
[ "Apache-2.0", "GPL-2.0-only", "MIT", "BSD-3-Clause" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
5,213
h
twtypes.h
//****************************************************************** // // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved. // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= /** * @file * * This API only works with: * Telegesis ETRX357 * CICIE R310 B110615 * */ #ifndef TWTYPES_H_ #define TWTYPES_H_ #ifdef __cplusplus extern "C" { #endif // __cplusplus #include <stdint.h> #include <stdbool.h> #define DEVICE_BAUDRATE (B19200) #define MAX_ZIGBEE_BYTES (512) #define MAX_ZIGBEE_ENROLLED_DEVICES (255) #define TIME_OUT_00_SECOND (0) #define TIME_OUT_01_SECOND (1) #define TIME_OUT_05_SECONDS (5) #define TIME_OUT_07_SECONDS (7) #define TIME_OUT_10_SECONDS (10) #define TIME_OUT_15_SECONDS (15) #define SIMPLEDESC_RESPONSE_EXPECTED_LINES (6) #define ZB_PROFILE_ID_HOME_AUTOMATION "0104" #define ZB_CLUSTER_IDENTIFY "0003" #define ZB_CLUSTER_ON_OFF "0006" #define ZB_CLUSTER_TEMPERATURE_MEASUREMENT "0402" #define ZB_CLUSTER_IAS_ZONE "0500" #define ZB_CLUSTER_COLOR_CONTROL "0300" #define AT_STR_ERROR_OK "00" #define AT_STR_ERROR_INVALID_OP "70" #define AT_STR_ERROR_EVERYTHING_OK "00" #define AT_STR_ERROR_NODE_IS_PART_OF_PAN "28" #define AT_STR_ERROR_MESSAGE_NOT_SENT_TO_TARGET_SUCCESSFULLY "66" #define AT_STR_ERROR_INVALID_OPERATION "70" #define SENDMODE "0" #define SEPARATOR "," #define SEPARATOR_LENGTH strlen(SEPARATOR) #define AT_CMD_RESET "AT&F" #define AT_CMD_GET_NETWORK_INFO "AT+N" #define AT_CMD_ESTABLISH_NETWORK "AT+EN" #define AT_CMD_PERMIT_JOIN "AT+PJOIN:" #define AT_CMD_MATCH_REQUEST "AT+MATCHREQ:" #define AT_CMD_SIMPLE_DESC "AT+SIMPLEDESC:" #define AT_CMD_WRITE_ATR "AT+WRITEATR:" #define AT_CMD_READ_ATR "AT+READATR:" #define AT_CMD_RUN_ON_OFF "AT+RONOFF:" #define AT_CMD_MOVE_TO_LEVEL "AT+LCMVTOLEV:" #define AT_CMD_DOOR_LOCK "AT+DRLOCK:" #define AT_CMD_COLOR_CTRL_MOVE_TO_COLOR_TEMPERATURE "AT+CCMVTOCT:" #define AT_CMD_GET_LOCAL_EUI "ATS04?" #define AT_CMD_REMOTE_EUI_REQUEST "AT+EUIREQ:" #define TW_ENDCONTROL_ERROR_STRING "ERROR:" #define SIZE_EUI (17) #define SIZE_NODEID (5) #define SIZE_CLUSTERID (5) #define SIZE_ENDPOINTID (3) #define SIZE_ZONESTATUS (5) #define SIZE_ZONESTATUS_EXTENDED (3) #define SIZE_ZONEID (3) #define SIZE_ZONETYPE (5) #define SIZE_UPDATE_DELAY_TIME (5) //----------------------------------------------------------------------------- // Typedefs //----------------------------------------------------------------------------- typedef enum { ZB_STATE_UNKNOWN, ZB_STATE_INIT } TWState; typedef struct { TWState state; uint64_t panId; uint64_t extPanId; char* remoteAttributeValueRead; uint8_t remoteAtrributeValueReadLength; } TWStatus; typedef enum { TW_RESULT_OK = 0, TW_RESULT_ERROR_LINE_COUNT, TW_RESULT_NO_LOCAL_PAN, TW_RESULT_HAS_LOCAL_PAN, TW_RESULT_NEW_LOCAL_PAN_ESTABLISHED, TW_RESULT_DEVICE_JOINED, TW_RESULT_FOUND_NO_MATCHED_DEVICE, TW_RESULT_FOUND_MATCHED_DEVICES, TW_RESULT_HAS_CLUSTERS, TW_RESULT_HAS_NO_CLUSTER, TW_RESULT_REMOTE_ATTR_HAS_VALUE, TW_RESULT_UNKNOWN, TW_RESULT_ERROR_INVALID_PARAMS, TW_RESULT_ERROR_INVALID_PORT, TW_RESULT_ERROR_NO_MEMORY, TW_RESULT_ERROR_INVALID_OP, TW_RESULT_ERROR_NOTIMPL, TW_RESULT_ERROR = 255 } TWResultCode; typedef enum { AT_ERROR_EVERYTHING_OK = 0, AT_ERROR_NODE_IS_PART_OF_PAN = 28, AT_ERROR_MESSAGE_NOT_SENT_TO_TARGET_SUCCESSFULLY = 66, AT_ERROR_INVALID_OPERATION = 70, } TWATErrorCode; typedef enum { TW_ENDCONTROL_OK = 0, TW_ENDCONTROL_ERROR, TW_ENDCONTROL_ACK, TW_ENDCONTROL_SEQ, TW_ENDCONTROL_MAX_VALUE } TWEndControl; typedef struct { const char * endStr; TWEndControl endControl; } TWEndControlMap; #ifdef __cplusplus } #endif // __cplusplus #endif /* TWTYPES_H_ */
3bdded3897bd3174ee75c7afff2ac86f82bd82b4
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/HDF5/src/itkhdf5/hl/src/H5LT.c
fb507e7d79214d2e78f7d53f852dc43d107cc33e
[ "LicenseRef-scancode-hdf5", "LicenseRef-scancode-llnl", "IJG", "Zlib", "LicenseRef-scancode-proprietary-license", "SMLNJ", "BSD-3-Clause", "BSD-4.3TAHOE", "LicenseRef-scancode-free-unknown", "Spencer-86", "FSFUL", "Libpng", "libtiff", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive", "MIT", "NTP", "LicenseRef-scancode-mit-old-style", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "MPL-2.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
InsightSoftwareConsortium/ITK
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
refs/heads/master
2023-08-31T17:21:47.754304
2023-08-31T00:58:51
2023-08-31T14:12:21
800,928
1,229
656
Apache-2.0
2023-09-14T17:54:00
2010-07-27T15:48:04
C++
UTF-8
C
false
false
104,537
c
H5LT.c
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5LTprivate.h" /* For Lex and Yacc */ #define COL 3 #define LIMIT 512 #define INCREMENT 1024 #define TMP_LEN 256 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) size_t input_len; char * myinput; size_t indent = 0; /* File Image operations A file image is a representation of an HDF5 file in a memory buffer. In order to perform operations on an image in a similar way to a file, the application buffer is copied to a FAPL buffer, which in turn is copied to a VFD buffer. Buffer copying can decrease performance, especially when using large file images. A solution to this issue is to simulate the copying of the application buffer, when actually the same buffer is used for the FAPL and the VFD. This is implemented by using callbacks that simulate the standard functions for memory management (additional callbacks are used for the management of associated data structures). From the application standpoint, a file handle can be obtained from a file image by using the API routine H5LTopen_file_image(). This function takes a flag argument that indicates the HDF5 library how to handle the given image; several flag values can be combined by using the bitwise OR operator. Valid flag values include: H5LT_FILE_IMAGE_OPEN_RW indicates the HDF5 library to open the file image in read/write mode. Default is read-only mode. H5LT_FILE_IMAGE_DONT_COPY indicates the HDF5 library to not copy the supplied user buffer; the same buffer will be handled by the FAPL and the VFD driver. Default operation copies the user buffer to the FAPL and VFD driver. H5LT_FILE_IMAGE_DONT_RELEASE indicates the HDF5 library to not release the buffer handled by the FAPL and the VFD upon closing. This flag value is only applicable when the flag value H5LT_FILE_IMAGE_DONT_COPY is set as well. The application is responsible to release the image buffer. */ /* Data structure to pass application data to callbacks. */ typedef struct { void * app_image_ptr; /* Pointer to application buffer */ size_t app_image_size; /* Size of application buffer */ void * fapl_image_ptr; /* Pointer to FAPL buffer */ size_t fapl_image_size; /* Size of FAPL buffer */ int fapl_ref_count; /* Reference counter for FAPL buffer */ void * vfd_image_ptr; /* Pointer to VFD buffer */ size_t vfd_image_size; /* Size of VFD buffer */ int vfd_ref_count; /* Reference counter for VFD buffer */ unsigned flags; /* Flags indicate how the file image will */ /* be open */ int ref_count; /* Reference counter on udata struct */ } H5LT_file_image_ud_t; /* callbacks prototypes for file image ops */ static void * image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata); static void * image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *udata); static void * image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); static herr_t image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *udata); static void * udata_copy(void *udata); static herr_t udata_free(void *udata); /* Definition of callbacks for file image operations. */ /*------------------------------------------------------------------------- * Function: image_malloc * * Purpose: Simulates malloc() function to avoid copying file images. * The application buffer is set to the buffer on only one FAPL. * Then the FAPL buffer can be copied to other FAPL buffers or * to only one VFD buffer. * * Return: Address of "allocated" buffer, if successful. Otherwise, it returns * NULL. * * Programmer: Christian Chilan * * Date: October 3, 2011 * *------------------------------------------------------------------------- */ static void * image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; void * return_value = NULL; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch (file_image_op) { /* the app buffer is "copied" to only one FAPL. Afterwards, FAPLs can be "copied" */ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: if (udata->app_image_ptr == NULL) goto out; if (udata->app_image_size != size) goto out; if (udata->fapl_image_ptr != NULL) goto out; if (udata->fapl_image_size != 0) goto out; if (udata->fapl_ref_count != 0) goto out; udata->fapl_image_ptr = udata->app_image_ptr; udata->fapl_image_size = udata->app_image_size; return_value = udata->fapl_image_ptr; udata->fapl_ref_count++; break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: if (udata->fapl_image_ptr == NULL) goto out; if (udata->fapl_image_size != size) goto out; if (udata->fapl_ref_count == 0) goto out; return_value = udata->fapl_image_ptr; udata->fapl_ref_count++; break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: goto out; case H5FD_FILE_IMAGE_OP_FILE_OPEN: /* FAPL buffer is "copied" to only one VFD buffer */ if (udata->vfd_image_ptr != NULL) goto out; if (udata->vfd_image_size != 0) goto out; if (udata->vfd_ref_count != 0) goto out; if (udata->fapl_image_ptr == NULL) goto out; if (udata->fapl_image_size != size) goto out; if (udata->fapl_ref_count == 0) goto out; udata->vfd_image_ptr = udata->fapl_image_ptr; udata->vfd_image_size = size; udata->vfd_ref_count++; return_value = udata->vfd_image_ptr; break; /* added unused labels to shut the compiler up */ case H5FD_FILE_IMAGE_OP_NO_OP: case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: case H5FD_FILE_IMAGE_OP_FILE_RESIZE: case H5FD_FILE_IMAGE_OP_FILE_CLOSE: default: goto out; } /* end switch */ return (return_value); out: return NULL; } /* end image_malloc() */ /*------------------------------------------------------------------------- * Function: image_memcpy * * Purpose: Simulates memcpy() function to avoid copying file images. * The image buffer can be set to only one FAPL buffer, and * "copied" to only one VFD buffer. The FAPL buffer can be * "copied" to other FAPLs buffers. * * Return: The address of the destination buffer, if successful. Otherwise, it * returns NULL. * * Programmer: Christian Chilan * * Date: October 3, 2011 * *------------------------------------------------------------------------- */ static void * image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch (file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: if (dest != udata->fapl_image_ptr) goto out; if (src != udata->app_image_ptr) goto out; if (size != udata->fapl_image_size) goto out; if (size != udata->app_image_size) goto out; if (udata->fapl_ref_count == 0) goto out; break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: if (dest != udata->fapl_image_ptr) goto out; if (src != udata->fapl_image_ptr) goto out; if (size != udata->fapl_image_size) goto out; if (udata->fapl_ref_count < 2) goto out; break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: goto out; case H5FD_FILE_IMAGE_OP_FILE_OPEN: if (dest != udata->vfd_image_ptr) goto out; if (src != udata->fapl_image_ptr) goto out; if (size != udata->vfd_image_size) goto out; if (size != udata->fapl_image_size) goto out; if (udata->fapl_ref_count == 0) goto out; if (udata->vfd_ref_count != 1) goto out; break; /* added unused labels to shut the compiler up */ case H5FD_FILE_IMAGE_OP_NO_OP: case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: case H5FD_FILE_IMAGE_OP_FILE_RESIZE: case H5FD_FILE_IMAGE_OP_FILE_CLOSE: default: goto out; } /* end switch */ return (dest); out: return NULL; } /* end image_memcpy() */ /*------------------------------------------------------------------------- * Function: image_realloc * * Purpose: Reallocates the shared application image buffer and updates data * structures that manage buffer "copying". * * Return: Address of reallocated buffer, if successful. Otherwise, it returns * NULL. * * Programmer: Christian Chilan * * Date: October 3, 2011 * *------------------------------------------------------------------------- */ static void * image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; void * return_value = NULL; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; /* realloc() is not allowed when the HDF5 library won't release the image buffer because reallocation may change the address of the buffer. The new address cannot be communicated to the application to release it. */ if (udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE) goto out; /* realloc() is not allowed if the image is open in read-only mode */ if (!(udata->flags & H5LT_FILE_IMAGE_OPEN_RW)) goto out; if (file_image_op == H5FD_FILE_IMAGE_OP_FILE_RESIZE) { if (udata->vfd_image_ptr != ptr) goto out; if (udata->vfd_ref_count != 1) goto out; if (NULL == (udata->vfd_image_ptr = HDrealloc(ptr, size))) goto out; udata->vfd_image_size = size; return_value = udata->vfd_image_ptr; } /* end if */ else goto out; return (return_value); out: return NULL; } /* end image_realloc() */ /*------------------------------------------------------------------------- * Function: image_free * * Purpose: Simulates deallocation of FAPL and VFD buffers by decreasing * reference counters. Shared application buffer is actually * deallocated if there are no outstanding references. * * Return: SUCCEED or FAIL * * Programmer: Christian Chilan * * Date: October 3, 2011 * *------------------------------------------------------------------------- */ static herr_t image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch (file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: if (udata->fapl_image_ptr != ptr) goto out; if (udata->fapl_ref_count == 0) goto out; udata->fapl_ref_count--; /* release the shared buffer only if indicated by the respective flag and there are no outstanding * references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->fapl_image_ptr); udata->app_image_ptr = NULL; udata->fapl_image_ptr = NULL; udata->vfd_image_ptr = NULL; } /* end if */ break; case H5FD_FILE_IMAGE_OP_FILE_CLOSE: if (udata->vfd_image_ptr != ptr) goto out; if (udata->vfd_ref_count != 1) goto out; udata->vfd_ref_count--; /* release the shared buffer only if indicated by the respective flag and there are no outstanding * references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->vfd_image_ptr); udata->app_image_ptr = NULL; udata->fapl_image_ptr = NULL; udata->vfd_image_ptr = NULL; } /* end if */ break; /* added unused labels to keep the compiler quite */ case H5FD_FILE_IMAGE_OP_NO_OP: case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: case H5FD_FILE_IMAGE_OP_FILE_OPEN: case H5FD_FILE_IMAGE_OP_FILE_RESIZE: default: goto out; } /* end switch */ return (SUCCEED); out: return (FAIL); } /* end image_free() */ /*------------------------------------------------------------------------- * Function: udata_copy * * Purpose: Simulates the copying of the user data structure utilized in the * management of the "copying" of file images. * * Return: Address of "newly allocated" structure, if successful. Otherwise, it * returns NULL. * * Programmer: Christian Chilan * * Date: October 3, 2011 * *------------------------------------------------------------------------- */ static void * udata_copy(void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; if (udata->ref_count == 0) goto out; udata->ref_count++; return (udata); out: return NULL; } /* end udata_copy */ /*------------------------------------------------------------------------- * Function: udata_free * * Purpose: Simulates deallocation of the user data structure utilized in the * management of the "copying" of file images. The data structure is * actually deallocated when there are no outstanding references. * * Return: SUCCEED or FAIL * * Programmer: Christian Chilan * * Date: October 3, 2011 * *------------------------------------------------------------------------- */ static herr_t udata_free(void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; if (udata->ref_count == 0) goto out; udata->ref_count--; /* checks that there are no references outstanding before deallocating udata */ if (udata->ref_count == 0 && udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0) HDfree(udata); return (SUCCEED); out: return (FAIL); } /* end udata_free */ /* End of callbacks definitions for file image operations */ /*------------------------------------------------------------------------- * * internal functions * *------------------------------------------------------------------------- */ static herr_t H5LT_get_attribute_mem(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *data); /*------------------------------------------------------------------------- * Function: H5LT_make_dataset * * Purpose: Creates and writes a dataset of a type tid * * Return: Success: 0, Failure: -1 * * Programmer: Quincey Koziol * * Date: October 10, 2007 * *------------------------------------------------------------------------- */ static herr_t H5LT_make_dataset_numerical(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid, const void *data) { hid_t did = -1, sid = -1; /* check the arguments */ if (dset_name == NULL) return -1; /* Create the data space for the dataset. */ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; /* Create the dataset. */ if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the dataset only if there is data to write */ if (data) if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto out; /* End access to the dataset and release resources used by it. */ if (H5Dclose(did) < 0) return -1; /* Terminate access to the data space. */ if (H5Sclose(sid) < 0) return -1; return 0; out: H5E_BEGIN_TRY { H5Dclose(did); H5Sclose(sid); } H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- * * Public functions * *------------------------------------------------------------------------- */ /*------------------------------------------------------------------------- * Function: H5LTmake_dataset * * Purpose: Creates and writes a dataset of a type tid * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 19, 2001 * * Comments: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5LTmake_dataset(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid, const void *data) { return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data)); } /*------------------------------------------------------------------------- * Function: H5LTmake_dataset_char * * Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 14, 2001 * * Comments: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5LTmake_dataset_char(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const char *data) { return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data)); } /*------------------------------------------------------------------------- * Function: H5LTmake_dataset_short * * Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 14, 2001 * * Comments: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5LTmake_dataset_short(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const short *data) { return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- * Function: H5LTmake_dataset_int * * Purpose: Creates and writes a dataset of H5T_NATIVE_INT type * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 14, 2001 * * Comments: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5LTmake_dataset_int(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const int *data) { return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data)); } /*------------------------------------------------------------------------- * Function: H5LTmake_dataset_long * * Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 14, 2001 * * Comments: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5LTmake_dataset_long(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const long *data) { return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- * Function: H5LTmake_dataset_float * * Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 14, 2001 * * Comments: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5LTmake_dataset_float(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const float *data) { return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data)); } /*------------------------------------------------------------------------- * Function: H5LTmake_dataset_double * * Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 14, 2001 * * Comments: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5LTmake_dataset_double(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const double *data) { return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data)); } /*------------------------------------------------------------------------- * Function: H5LTmake_dataset_string * * Purpose: Creates and writes a dataset of H5T_C_S1 type * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: October 05, 2004 * * Comments: * * Modifications: * * *------------------------------------------------------------------------- */ herr_t H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf) { hid_t did = -1; hid_t sid = -1; hid_t tid = -1; size_t size; /* check the arguments */ if (dset_name == NULL) return -1; /* create a string data type */ if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; size = HDstrlen(buf) + 1; /* extra null term */ if (H5Tset_size(tid, size) < 0) goto out; if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) goto out; /* Create the data space for the dataset. */ if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; /* Create the dataset. */ if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the dataset only if there is data to write */ if (buf) if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close*/ if (H5Dclose(did) < 0) return -1; if (H5Sclose(sid) < 0) return -1; if (H5Tclose(tid) < 0) goto out; return 0; out: H5E_BEGIN_TRY { H5Dclose(did); H5Tclose(tid); H5Sclose(sid); } H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- * Function: H5LTopen_file_image * * Purpose: Open a user supplied file image using the core file driver. * * Return: File identifier, Failure: -1 * * Programmer: Christian Chilan * * Date: October 3, 2011 * *------------------------------------------------------------------------- */ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) { hid_t fapl = -1, file_id = -1; /* HDF5 identifiers */ unsigned file_open_flags; /* Flags for image open */ char file_name[64]; /* Filename buffer */ size_t alloc_incr; /* Buffer allocation increment */ size_t min_incr = 65536; /* Minimum buffer increment */ double buf_prcnt = 0.1; /* Percentage of buffer size to set as increment */ static long file_name_counter; H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, &image_realloc, &image_free, &udata_copy, &udata_free, (void *)NULL}; /* check arguments */ if (buf_ptr == NULL) goto out; if (buf_size == 0) goto out; if (flags & (unsigned)~(H5LT_FILE_IMAGE_ALL)) goto out; /* Create FAPL to transmit file image */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto out; /* set allocation increment to a percentage of the supplied buffer size, or * a pre-defined minimum increment value, whichever is larger */ if ((size_t)(buf_prcnt * (double)buf_size) > min_incr) alloc_incr = (size_t)(buf_prcnt * (double)buf_size); else alloc_incr = min_incr; /* Configure FAPL to use the core file driver */ if (H5Pset_fapl_core(fapl, alloc_incr, FALSE) < 0) goto out; /* Set callbacks for file image ops ONLY if the file image is NOT copied */ if (flags & H5LT_FILE_IMAGE_DONT_COPY) { H5LT_file_image_ud_t *udata; /* Pointer to udata structure */ /* Allocate buffer to communicate user data to callbacks */ if (NULL == (udata = (H5LT_file_image_ud_t *)HDmalloc(sizeof(H5LT_file_image_ud_t)))) goto out; /* Initialize udata with info about app buffer containing file image and flags */ udata->app_image_ptr = buf_ptr; udata->app_image_size = buf_size; udata->fapl_image_ptr = NULL; udata->fapl_image_size = 0; udata->fapl_ref_count = 0; udata->vfd_image_ptr = NULL; udata->vfd_image_size = 0; udata->vfd_ref_count = 0; udata->flags = flags; udata->ref_count = 1; /* corresponding to the first FAPL */ /* copy address of udata into callbacks */ callbacks.udata = (void *)udata; /* Set file image callbacks */ if (H5Pset_file_image_callbacks(fapl, &callbacks) < 0) { HDfree(udata); goto out; } /* end if */ } /* end if */ /* Assign file image in user buffer to FAPL */ if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0) goto out; /* set file open flags */ if (flags & H5LT_FILE_IMAGE_OPEN_RW) file_open_flags = H5F_ACC_RDWR; else file_open_flags = H5F_ACC_RDONLY; /* define a unique file name */ HDsnprintf(file_name, (sizeof(file_name) - 1), "file_image_%ld", file_name_counter++); /* Assign file image in FAPL to the core file driver */ if ((file_id = H5Fopen(file_name, file_open_flags, fapl)) < 0) goto out; /* Close FAPL */ if (H5Pclose(fapl) < 0) goto out; /* Return file identifier */ return file_id; out: H5E_BEGIN_TRY { H5Pclose(fapl); } H5E_END_TRY; return -1; } /* end H5LTopen_file_image() */ /*------------------------------------------------------------------------- * Function: H5LT_read_dataset * * Purpose: Reads a dataset from disk. * * Return: Success: 0, Failure: -1 * * Programmer: Quincey Koziol * * Date: October 8, 2007 * *------------------------------------------------------------------------- */ static herr_t H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void *data) { hid_t did; /* check the arguments */ if (dset_name == NULL) return -1; /* Open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Read */ if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto out; /* End access to the dataset and release resources used by it. */ if (H5Dclose(did)) return -1; return 0; out: H5Dclose(did); return -1; } /*------------------------------------------------------------------------- * Function: H5LTread_dataset * * Purpose: Reads a dataset from disk. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: June 13, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t tid, void *data) { return (H5LT_read_dataset_numerical(loc_id, dset_name, tid, data)); } /*------------------------------------------------------------------------- * Function: H5LTread_dataset_char * * Purpose: Reads a dataset from disk. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 5, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *data) { return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data)); } /*------------------------------------------------------------------------- * Function: H5LTread_dataset_short * * Purpose: Reads a dataset from disk. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 5, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *data) { return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- * Function: H5LTread_dataset_int * * Purpose: Reads a dataset from disk. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 5, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *data) { return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data)); } /*------------------------------------------------------------------------- * Function: H5LTread_dataset_long * * Purpose: Reads a dataset from disk. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 5, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *data) { return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- * Function: H5LTread_dataset_float * * Purpose: Reads a dataset from disk. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 5, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *data) { return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); } /*------------------------------------------------------------------------- * Function: H5LTread_dataset_double * * Purpose: Reads a dataset from disk. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 5, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *data) { return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); } /*------------------------------------------------------------------------- * Function: H5LTread_dataset_string * * Purpose: Reads a dataset * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: October 05, 2004 * *------------------------------------------------------------------------- */ herr_t H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf) { hid_t did = -1; hid_t tid = -1; /* check the arguments */ if (dset_name == NULL) return -1; /* Open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; if ((tid = H5Dget_type(did)) < 0) goto out; /* Read */ if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ if (H5Dclose(did)) goto out; if (H5Tclose(tid)) return -1; return 0; out: H5E_BEGIN_TRY { H5Dclose(did); H5Tclose(tid); } H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- * Function: H5LTget_dataset_ndims * * Purpose: Gets the dimensionality of a dataset. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 4, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank) { hid_t did = -1; hid_t sid = -1; /* check the arguments */ if (dset_name == NULL) return -1; /* Open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Get the dataspace handle */ if ((sid = H5Dget_space(did)) < 0) goto out; /* Get rank */ if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* Terminate access to the dataspace */ if (H5Sclose(sid) < 0) goto out; /* End access to the dataset */ if (H5Dclose(did)) return -1; return 0; out: H5E_BEGIN_TRY { H5Dclose(did); H5Sclose(sid); } H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- * Function: H5LTget_dataset_info * * Purpose: Gets information about a dataset. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 4, 2001 * Modified: February 28, 2006: checked for NULL parameters * *------------------------------------------------------------------------- */ herr_t H5LTget_dataset_info(hid_t loc_id, const char *dset_name, hsize_t *dims, H5T_class_t *type_class, size_t *type_size) { hid_t did = -1; hid_t tid = -1; hid_t sid = -1; /* check the arguments */ if (dset_name == NULL) return -1; /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* get an identifier for the datatype. */ tid = H5Dget_type(did); /* get the class. */ if (type_class != NULL) *type_class = H5Tget_class(tid); /* get the size. */ if (type_size != NULL) *type_size = H5Tget_size(tid); if (dims != NULL) { /* get the dataspace handle */ if ((sid = H5Dget_space(did)) < 0) goto out; /* get dimensions */ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* terminate access to the dataspace */ if (H5Sclose(sid) < 0) goto out; } /* end if */ /* release the datatype. */ if (H5Tclose(tid)) return -1; /* end access to the dataset */ if (H5Dclose(did)) return -1; return 0; out: H5E_BEGIN_TRY { H5Tclose(tid); H5Sclose(sid); H5Dclose(did); } H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- * Function: find_dataset * * Purpose: operator function used by H5LTfind_dataset * * Programmer: Pedro Vicente * * Date: June 21, 2001 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ static herr_t find_dataset(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5L_info2_t *linfo, void *op_data) { /* Define a default zero value for return. This will cause the iterator to continue if * the dataset is not found yet. */ int ret = 0; /* check the arguments */ if (name == NULL) return ret; /* Shut the compiler up */ (void)loc_id; (void)linfo; /* Define a positive value for return value if the dataset was found. This will * cause the iterator to immediately return that positive value, * indicating short-circuit success */ if (HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0) ret = 1; return ret; } /*------------------------------------------------------------------------- * Function: H5LTfind_dataset * * Purpose: Inquires if a dataset named dset_name exists attached * to the object loc_id. * * Programmer: Pedro Vicente * * Date: July 15, 2001 * * Return: * Success: The return value of the first operator that * returns non-zero, or zero if all members were * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the * library, or the negative value returned by one * of the operators. * *------------------------------------------------------------------------- */ /* H5Literate wants a non-const pointer but we have a const pointer in the API * call. It's safe to ignore this because we control the callback, don't * modify the op_data buffer (i.e.: dset_name) during the traversal, and the * library never modifies that buffer. */ H5_GCC_DIAG_OFF("cast-qual") herr_t H5LTfind_dataset(hid_t loc_id, const char *dset_name) { return H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name); } H5_GCC_DIAG_ON("cast-qual") /*------------------------------------------------------------------------- * * Set attribute functions * *------------------------------------------------------------------------- */ /*------------------------------------------------------------------------- * Function: H5LTset_attribute_string * * Purpose: Creates and writes a string attribute named attr_name and attaches * it to the object specified by the name obj_name. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: July 23, 2001 * * Comments: If the attribute already exists, it is overwritten * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, const char *attr_data) { hid_t attr_type; hid_t attr_space_id; hid_t attr_id; hid_t obj_id; int has_attr; size_t attr_size; /* check the arguments */ if (obj_name == NULL) return -1; if (attr_name == NULL) return -1; if (attr_data == NULL) return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Create the attribute */ if ((attr_type = H5Tcopy(H5T_C_S1)) < 0) goto out; attr_size = HDstrlen(attr_data) + 1; /* extra null term */ if (H5Tset_size(attr_type, (size_t)attr_size) < 0) goto out; if (H5Tset_strpad(attr_type, H5T_STR_NULLTERM) < 0) goto out; if ((attr_space_id = H5Screate(H5S_SCALAR)) < 0) goto out; /* Verify if the attribute already exists */ has_attr = H5LT_find_attribute(obj_id, attr_name); /* The attribute already exists, delete it */ if (has_attr == 1) if (H5Adelete(obj_id, attr_name) < 0) goto out; /* Create and write the attribute */ if ((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; if (H5Awrite(attr_id, attr_type, attr_data) < 0) goto out; if (H5Aclose(attr_id) < 0) goto out; if (H5Sclose(attr_space_id) < 0) goto out; if (H5Tclose(attr_type) < 0) goto out; /* Close the object */ if (H5Oclose(obj_id) < 0) return -1; return 0; out: H5Oclose(obj_id); return -1; } /*------------------------------------------------------------------------- * Function: H5LT_set_attribute_numerical * * Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: July 25, 2001 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LT_set_attribute_numerical(hid_t loc_id, const char *obj_name, const char *attr_name, size_t size, hid_t tid, const void *data) { hid_t obj_id, sid, attr_id; hsize_t dim_size = size; int has_attr; /* check the arguments */ if (obj_name == NULL) return -1; if (attr_name == NULL) return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Create the data space for the attribute. */ if ((sid = H5Screate_simple(1, &dim_size, NULL)) < 0) goto out; /* Verify if the attribute already exists */ has_attr = H5LT_find_attribute(obj_id, attr_name); /* The attribute already exists, delete it */ if (has_attr == 1) if (H5Adelete(obj_id, attr_name) < 0) goto out; /* Create the attribute. */ if ((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the attribute data. */ if (H5Awrite(attr_id, tid, data) < 0) goto out; /* Close the attribute. */ if (H5Aclose(attr_id) < 0) goto out; /* Close the dataspace. */ if (H5Sclose(sid) < 0) goto out; /* Close the object */ if (H5Oclose(obj_id) < 0) return -1; return 0; out: H5Oclose(obj_id); return -1; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_char * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 7, 2001 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, const char *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_CHAR, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_uchar * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 8, 2004 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned char *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UCHAR, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_short * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 7, 2001 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, const short *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_SHORT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_ushort * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 8, 2004 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned short *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_USHORT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_int * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 7, 2001 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, const int *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_INT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_uint * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 8, 2004 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned int *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UINT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_long * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 7, 2001 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_long_long * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Elena Pourmal * * Date: June 17, 2005 * * Comments: This function was added to support attributes of type long long * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long long *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LLONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_ulong * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 8, 2004 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_float * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: July 25, 2001 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTset_attribute_double * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: November 7, 2001 * * Comments: * *------------------------------------------------------------------------- */ herr_t H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *data, size_t size) { if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: find_attr * * Purpose: operator function used by H5LT_find_attribute * * Programmer: Pedro Vicente * * Date: June 21, 2001 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ static herr_t find_attr(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5A_info_t *ainfo, void *op_data) { int ret = H5_ITER_CONT; /* check the arguments */ if (name == NULL) return H5_ITER_CONT; /* Shut compiler up */ (void)loc_id; (void)ainfo; /* Define a positive value for return value if the attribute was found. This will * cause the iterator to immediately return that positive value, * indicating short-circuit success */ if (HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data), HDstrlen(name))) == 0) ret = H5_ITER_STOP; return ret; } /*------------------------------------------------------------------------- * Function: H5LTfind_attribute * * Purpose: Inquires if an attribute named attr_name exists attached to * the object loc_id. * * Programmer: Pedro Vicente * * Date: May 17, 2006 * * Comments: * Calls the private version of the function * *------------------------------------------------------------------------- */ herr_t H5LTfind_attribute(hid_t loc_id, const char *attr_name) { return H5LT_find_attribute(loc_id, attr_name); } /*------------------------------------------------------------------------- * Function: H5LT_find_attribute * * Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id. * * Programmer: Pedro Vicente * * Date: June 21, 2001 * * Comments: * The function uses H5Aiterate2 with the operator function find_attr * * Return: * Success: The return value of the first operator that * returns non-zero, or zero if all members were * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the * library, or the negative value returned by one * of the operators. * *------------------------------------------------------------------------- */ /* H5Aiterate wants a non-const pointer but we have a const pointer in the API * call. It's safe to ignore this because we control the callback, don't * modify the op_data buffer (i.e.: attr_name) during the traversal, and the * library never modifies that buffer. */ H5_GCC_DIAG_OFF("cast-qual") herr_t H5LT_find_attribute(hid_t loc_id, const char *attr_name) { return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name); } H5_GCC_DIAG_ON("cast-qual") /*------------------------------------------------------------------------- * Function: H5LTget_attribute_ndims * * Purpose: Gets the dimensionality of an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 4, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_ndims(hid_t loc_id, const char *obj_name, const char *attr_name, int *rank) { hid_t attr_id; hid_t sid; hid_t obj_id; /* check the arguments */ if (obj_name == NULL) return -1; if (attr_name == NULL) return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Open the attribute. */ if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) { H5Oclose(obj_id); return -1; } /* Get the dataspace handle */ if ((sid = H5Aget_space(attr_id)) < 0) goto out; /* Get rank */ if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* Terminate access to the attribute */ if (H5Sclose(sid) < 0) goto out; /* End access to the attribute */ if (H5Aclose(attr_id)) goto out; ; /* Close the object */ if (H5Oclose(obj_id) < 0) return -1; return 0; out: H5Aclose(attr_id); H5Oclose(obj_id); return -1; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_info * * Purpose: Gets information about an attribute. * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 4, 2001 * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_info(hid_t loc_id, const char *obj_name, const char *attr_name, hsize_t *dims, H5T_class_t *type_class, size_t *type_size) { hid_t attr_id; hid_t tid; hid_t sid; hid_t obj_id; /* check the arguments */ if (obj_name == NULL) return -1; if (attr_name == NULL) return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Open the attribute. */ if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) { H5Oclose(obj_id); return -1; } /* Get an identifier for the datatype. */ tid = H5Aget_type(attr_id); /* Get the class. */ *type_class = H5Tget_class(tid); /* Get the size. */ *type_size = H5Tget_size(tid); /* Get the dataspace handle */ if ((sid = H5Aget_space(attr_id)) < 0) goto out; /* Get dimensions */ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* Terminate access to the dataspace */ if (H5Sclose(sid) < 0) goto out; /* Release the datatype. */ if (H5Tclose(tid)) goto out; /* End access to the attribute */ if (H5Aclose(attr_id)) goto out; /* Close the object */ if (H5Oclose(obj_id) < 0) return -1; return 0; out: H5Tclose(tid); H5Aclose(attr_id); H5Oclose(obj_id); return -1; } /*------------------------------------------------------------------------- * Function: H5LTtext_to_dtype * * Purpose: Convert DDL description to HDF5 data type. * * Return: Success: 0, Failure: -1 * * Programmer: Raymond Lu * * Date: October 6, 2004 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) { hid_t type_id; /* check the arguments */ if (text == NULL) return -1; if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; if (lang_type != H5LT_DDL) { HDfprintf(stderr, "only DDL is supported for now.\n"); goto out; } input_len = HDstrlen(text); myinput = HDstrdup(text); if ((type_id = H5LTyyparse()) < 0) { HDfree(myinput); goto out; } HDfree(myinput); input_len = 0; return type_id; out: return -1; } /*------------------------------------------------------------------------- * Function: realloc_and_append * * Purpose: Expand the buffer and append a string to it. * * Return: void * * Programmer: Raymond Lu * * Date: 29 September 2011 * * Modifications: * *------------------------------------------------------------------------- */ static char * realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str_to_add) { size_t size_str_to_add, size_str; if (_no_user_buf) { /* If the buffer isn't big enough, reallocate it. Otherwise, go to do strcat. */ if (str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) { *len += ((HDstrlen(buf) + HDstrlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT; buf = (char *)HDrealloc(buf, *len); } else if (!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) { *len += INCREMENT; buf = (char *)HDrealloc(buf, *len); } } if (!buf) goto out; if (str_to_add) { /* find the size of the buffer to add */ size_str_to_add = HDstrlen(str_to_add); /* find the size of the current buffer */ size_str = HDstrlen(buf); /* Check to make sure the appended string does not * extend past the allocated buffer; if it does then truncate the string */ if (size_str < *len - 1) { if (size_str + size_str_to_add < *len - 1) { HDstrncat(buf, str_to_add, size_str_to_add); } else { HDstrncat(buf, str_to_add, (*len - 1) - size_str); } } else { buf[*len - 1] = '\0'; /* buffer is full, null terminate */ } } return buf; out: return NULL; } /*------------------------------------------------------------------------- * Function: indentation * * Purpose: Print spaces for indentation * * Return: void * * Programmer: Raymond Lu * * Date: December 6, 2005 * * Modifications: * *------------------------------------------------------------------------- */ static char * indentation(size_t x, char *str, hbool_t no_u_buf, size_t *s_len) { char tmp_str[TMP_LEN]; if (x < 80) { HDmemset(tmp_str, ' ', x); tmp_str[x] = '\0'; } else HDsnprintf(tmp_str, TMP_LEN, "error: the indentation exceeds the number of cols."); if (!(str = realloc_and_append(no_u_buf, s_len, str, tmp_str))) goto out; return str; out: return NULL; } /*------------------------------------------------------------------------- * Function: print_enum * * Purpose: prints the enum data * * Return: Success: 0, Failure: -1 * * Programmer: Raymond Lu * * Modifications: * *-----------------------------------------------------------------------*/ static char * print_enum(hid_t type, char *str, size_t *str_len, hbool_t no_ubuf, size_t indt) { char ** name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ int nmembs; /*number of members */ char tmp_str[TMP_LEN]; int nchars; /*number of output characters */ hid_t super = -1; /*enum base integer type */ hid_t native = -1; /*native integer data type */ size_t super_size; /*enum base type size */ size_t dst_size; /*destination value type size */ int i; if ((nmembs = H5Tget_nmembers(type)) <= 0) goto out; if ((super = H5Tget_super(type)) < 0) goto out; /* Use buffer of INT or UNSIGNED INT to print enum values because * we don't expect these values to be so big that INT or UNSIGNED * INT can't hold. */ if (H5T_SGN_NONE == H5Tget_sign(super)) { native = H5T_NATIVE_UINT; } else { native = H5T_NATIVE_INT; } super_size = H5Tget_size(super); dst_size = H5Tget_size(native); /* Get the names and raw values of all members */ name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)); value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(dst_size, super_size)); for (i = 0; i < nmembs; i++) { if ((name[i] = H5Tget_member_name(type, (unsigned)i)) == NULL) goto out; if (H5Tget_member_value(type, (unsigned)i, value + (size_t)i * super_size) < 0) goto out; } /* Convert values to native data type */ if (native > 0) { if (H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) goto out; } /* * Sort members by increasing value * ***not implemented yet*** */ /* Print members */ for (i = 0; i < nmembs; i++) { if (!(str = indentation(indt + COL, str, no_ubuf, str_len))) goto out; nchars = HDsnprintf(tmp_str, TMP_LEN, "\"%s\"", name[i]); if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; HDmemset(tmp_str, ' ', (size_t)MAX(3, 19 - nchars) + 1); tmp_str[MAX(3, 19 - nchars)] = '\0'; if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; if (H5T_SGN_NONE == H5Tget_sign(native)) HDsnprintf(tmp_str, TMP_LEN, "%u", *((unsigned int *)((void *)(value + (size_t)i * dst_size)))); else HDsnprintf(tmp_str, TMP_LEN, "%d", *((int *)((void *)(value + (size_t)i * dst_size)))); if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; HDsnprintf(tmp_str, TMP_LEN, ";\n"); if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; } /* Release resources */ for (i = 0; i < nmembs; i++) H5free_memory(name[i]); HDfree(name); HDfree(value); H5Tclose(super); return str; out: if (0 == nmembs) { str = realloc_and_append(no_ubuf, str_len, str, "\n"); HDassert((indt + 4) < TMP_LEN); HDmemset(tmp_str, ' ', (indt + 4) + 1); tmp_str[(indt + 4)] = '\0'; str = realloc_and_append(no_ubuf, str_len, str, tmp_str); str = realloc_and_append(no_ubuf, str_len, str, " <empty>"); } /* end if */ /* Release resources */ if (name) { for (i = 0; i < nmembs; i++) if (name[i]) HDfree(name[i]); HDfree(name); } /* end if */ if (value) HDfree(value); if (super >= 0) H5Tclose(super); return NULL; } /*------------------------------------------------------------------------- * Function: H5LTdtype_to_text * * Purpose: Convert HDF5 data type to DDL description. * * Return: Success: 0, Failure: -1 * * Programmer: Raymond Lu * * Date: December 6, 2005 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) { size_t str_len = INCREMENT; char * text_str; herr_t ret = SUCCEED; if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; if (len && !str) { text_str = (char *)HDcalloc(str_len, sizeof(char)); text_str[0] = '\0'; if (!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1))) goto out; *len = HDstrlen(text_str) + 1; if (text_str) HDfree(text_str); text_str = NULL; } else if (len && str) { if (!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0))) goto out; str[*len - 1] = '\0'; } return ret; out: return FAIL; } /*------------------------------------------------------------------------- * Function: H5LT_dtype_to_text * * Purpose: Private function to convert HDF5 data type to DDL description. * * Return: Success: 0, Failure: -1 * * Programmer: Raymond Lu * * Date: December 20, 2005 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ char * H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hbool_t no_user_buf) { H5T_class_t tcls; char tmp_str[TMP_LEN]; int i; if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL))) goto out; if (lang != H5LT_DDL) { HDsnprintf(dt_str, *slen, "only DDL is supported for now"); goto out; } if ((tcls = H5Tget_class(dtype)) < 0) goto out; switch (tcls) { case H5T_INTEGER: case H5T_BITFIELD: if (H5Tequal(dtype, H5T_STD_I8BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I8BE"); } else if (H5Tequal(dtype, H5T_STD_I8LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I8LE"); } else if (H5Tequal(dtype, H5T_STD_I16BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I16BE"); } else if (H5Tequal(dtype, H5T_STD_I16LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I16LE"); } else if (H5Tequal(dtype, H5T_STD_I32BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I32BE"); } else if (H5Tequal(dtype, H5T_STD_I32LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I32LE"); } else if (H5Tequal(dtype, H5T_STD_I64BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I64BE"); } else if (H5Tequal(dtype, H5T_STD_I64LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I64LE"); } else if (H5Tequal(dtype, H5T_STD_U8BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U8BE"); } else if (H5Tequal(dtype, H5T_STD_U8LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U8LE"); } else if (H5Tequal(dtype, H5T_STD_U16BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U16BE"); } else if (H5Tequal(dtype, H5T_STD_U16LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U16LE"); } else if (H5Tequal(dtype, H5T_STD_U32BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U32BE"); } else if (H5Tequal(dtype, H5T_STD_U32LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U32LE"); } else if (H5Tequal(dtype, H5T_STD_U64BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U64BE"); } else if (H5Tequal(dtype, H5T_STD_U64LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U64LE"); } else if (H5Tequal(dtype, H5T_NATIVE_SCHAR)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_SCHAR"); } else if (H5Tequal(dtype, H5T_NATIVE_UCHAR)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_UCHAR"); } else if (H5Tequal(dtype, H5T_NATIVE_SHORT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_SHORT"); } else if (H5Tequal(dtype, H5T_NATIVE_USHORT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_USHORT"); } else if (H5Tequal(dtype, H5T_NATIVE_INT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_INT"); } else if (H5Tequal(dtype, H5T_NATIVE_UINT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_UINT"); } else if (H5Tequal(dtype, H5T_NATIVE_LONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LONG"); } else if (H5Tequal(dtype, H5T_NATIVE_ULONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_ULONG"); } else if (H5Tequal(dtype, H5T_NATIVE_LLONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LLONG"); } else if (H5Tequal(dtype, H5T_NATIVE_ULLONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_ULLONG"); } else { HDsnprintf(dt_str, *slen, "undefined integer"); } break; case H5T_FLOAT: if (H5Tequal(dtype, H5T_IEEE_F32BE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F32BE"); } else if (H5Tequal(dtype, H5T_IEEE_F32LE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F32LE"); } else if (H5Tequal(dtype, H5T_IEEE_F64BE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F64BE"); } else if (H5Tequal(dtype, H5T_IEEE_F64LE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F64LE"); } else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_FLOAT"); } else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_DOUBLE"); #if H5_SIZEOF_LONG_DOUBLE != 0 } else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LDOUBLE"); #endif } else { HDsnprintf(dt_str, *slen, "undefined float"); } break; case H5T_STRING: { /* Make a copy of type in memory in case when DTYPE is on disk, the size * will be bigger than in memory. This makes it easier to compare * types in memory. */ hid_t str_type; H5T_order_t order; hid_t tmp_type; size_t size; H5T_str_t str_pad; H5T_cset_t cset; htri_t is_vlstr; if ((tmp_type = H5Tcopy(dtype)) < 0) goto out; if ((size = H5Tget_size(tmp_type)) == 0) goto out; if ((str_pad = H5Tget_strpad(tmp_type)) < 0) goto out; if ((cset = H5Tget_cset(tmp_type)) < 0) goto out; if ((is_vlstr = H5Tis_variable_str(tmp_type)) < 0) goto out; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_STRING {\n"); indent += COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; if (is_vlstr) HDsnprintf(tmp_str, TMP_LEN, "STRSIZE H5T_VARIABLE;\n"); else HDsnprintf(tmp_str, TMP_LEN, "STRSIZE %d;\n", (int)size); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; if (str_pad == H5T_STR_NULLTERM) HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLTERM;\n"); else if (str_pad == H5T_STR_NULLPAD) HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLPAD;\n"); else if (str_pad == H5T_STR_SPACEPAD) HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_SPACEPAD;\n"); else HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_ERROR;\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; if (cset == H5T_CSET_ASCII) HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_ASCII;\n"); else if (cset == H5T_CSET_UTF8) HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_UTF8;\n"); else HDsnprintf(tmp_str, TMP_LEN, "CSET unknown;\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; /* Reproduce a C type string */ if ((str_type = H5Tcopy(H5T_C_S1)) < 0) goto out; if (is_vlstr) { if (H5Tset_size(str_type, H5T_VARIABLE) < 0) goto out; } else { if (H5Tset_size(str_type, size) < 0) goto out; } if (H5Tset_cset(str_type, cset) < 0) goto out; if (H5Tset_strpad(str_type, str_pad) < 0) goto out; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; /* Check C variable-length string first. Are the two types equal? */ if (H5Tequal(tmp_type, str_type)) { HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; goto next; } /* Change the endianness and see if they're equal. */ if ((order = H5Tget_order(tmp_type)) < 0) goto out; if (order == H5T_ORDER_LE) { if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) goto out; } else if (order == H5T_ORDER_BE) { if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) goto out; } if (H5Tequal(tmp_type, str_type)) { HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; goto next; } /* If not equal to C variable-length string, check Fortran type. * Actually H5Tequal can't tell difference between H5T_C_S1 and * H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ if (H5Tclose(str_type) < 0) goto out; if ((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0) goto out; if (H5Tset_cset(str_type, cset) < 0) goto out; if (H5Tset_size(str_type, size) < 0) goto out; if (H5Tset_strpad(str_type, str_pad) < 0) goto out; /* Are the two types equal? */ if (H5Tequal(tmp_type, str_type)) { HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; goto next; } /* Change the endianness and see if they're equal. */ if ((order = H5Tget_order(tmp_type)) < 0) goto out; if (order == H5T_ORDER_LE) { if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) goto out; } else if (order == H5T_ORDER_BE) { if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) goto out; } /* Are the two types equal? */ if (H5Tequal(tmp_type, str_type)) { HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; goto next; } /* Type doesn't match any of above. */ HDsnprintf(tmp_str, TMP_LEN, "CTYPE unknown_one_character_type;\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; next: H5Tclose(str_type); H5Tclose(tmp_type); /* Print closing */ indent -= COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "}"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; break; } case H5T_OPAQUE: { char *tag = NULL; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_OPAQUE {\n"); indent += COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "OPQ_SIZE %lu;\n", (unsigned long)H5Tget_size(dtype)); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; tag = H5Tget_tag(dtype); if (tag) { HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"%s\";\n", tag); if (tag) H5free_memory(tag); tag = NULL; } else HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"\";\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; /* Print closing */ indent -= COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "}"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; break; } case H5T_ENUM: { hid_t super; size_t super_len; char * stmp = NULL; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_ENUM {\n"); indent += COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; if ((super = H5Tget_super(dtype)) < 0) goto out; if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) goto out; if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) goto out; if (stmp) HDfree(stmp); stmp = NULL; HDsnprintf(tmp_str, TMP_LEN, ";\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; H5Tclose(super); if (!(dt_str = print_enum(dtype, dt_str, slen, no_user_buf, indent))) goto out; /* Print closing */ indent -= COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "}"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; break; } case H5T_VLEN: { hid_t super; size_t super_len; char * stmp = NULL; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_VLEN {\n"); indent += COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; if ((super = H5Tget_super(dtype)) < 0) goto out; if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) goto out; if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) goto out; if (stmp) HDfree(stmp); stmp = NULL; HDsnprintf(tmp_str, TMP_LEN, "\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; H5Tclose(super); /* Print closing */ indent -= COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "}"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; break; } case H5T_ARRAY: { hid_t super; size_t super_len; char * stmp = NULL; hsize_t dims[H5S_MAX_RANK]; int ndims; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_ARRAY {\n"); indent += COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; /* Get array information */ if ((ndims = H5Tget_array_ndims(dtype)) < 0) goto out; if (H5Tget_array_dims2(dtype, dims) < 0) goto out; /* Print array dimensions */ for (i = 0; i < ndims; i++) { HDsnprintf(tmp_str, TMP_LEN, "[%d]", (int)dims[i]); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; } HDsnprintf(tmp_str, TMP_LEN, " "); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; if ((super = H5Tget_super(dtype)) < 0) goto out; if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) goto out; if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) goto out; if (stmp) HDfree(stmp); stmp = NULL; HDsnprintf(tmp_str, TMP_LEN, "\n"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; H5Tclose(super); /* Print closing */ indent -= COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "}"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; break; } case H5T_COMPOUND: { char * mname = NULL; hid_t mtype; size_t moffset; H5T_class_t mclass; size_t mlen; char * mtmp = NULL; int nmembs; if ((nmembs = H5Tget_nmembers(dtype)) < 0) goto out; HDsnprintf(dt_str, *slen, "H5T_COMPOUND {\n"); indent += COL; for (i = 0; i < nmembs; i++) { if ((mname = H5Tget_member_name(dtype, (unsigned)i)) == NULL) goto out; if ((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0) goto out; moffset = H5Tget_member_offset(dtype, (unsigned)i); if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; if ((mclass = H5Tget_class(mtype)) < 0) goto out; if (H5T_COMPOUND == mclass) indent += COL; if (H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) goto out; mtmp = (char *)HDcalloc(mlen, sizeof(char)); if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) goto out; if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) goto out; if (mtmp) HDfree(mtmp); mtmp = NULL; if (H5T_COMPOUND == mclass) indent -= COL; HDsnprintf(tmp_str, TMP_LEN, " \"%s\"", mname); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; if (mname) H5free_memory(mname); mname = NULL; HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; } /* Print closing */ indent -= COL; if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "}"); if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; break; } case H5T_TIME: HDsnprintf(dt_str, *slen, "H5T_TIME: not yet implemented"); break; case H5T_NO_CLASS: HDsnprintf(dt_str, *slen, "H5T_NO_CLASS"); break; case H5T_REFERENCE: if (H5Tequal(dtype, H5T_STD_REF_DSETREG) == TRUE) { HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_DSETREG }"); } else { HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_OBJECT }"); } break; case H5T_NCLASSES: break; default: HDsnprintf(dt_str, *slen, "unknown data type"); } return dt_str; out: return NULL; } /*------------------------------------------------------------------------- * * Get attribute functions * *------------------------------------------------------------------------- */ /*------------------------------------------------------------------------- * Function: H5LTget_attribute_string * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, char *data) { /* identifiers */ hid_t obj_id; /* check the arguments */ if (obj_name == NULL) return -1; if (attr_name == NULL) return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Get the attribute */ if (H5LT_get_attribute_disk(obj_id, attr_name, data) < 0) { H5Oclose(obj_id); return -1; } /* Close the object */ if (H5Oclose(obj_id) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_char * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, char *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_uchar * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 8, 2004 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned char *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_short * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, short *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_ushort * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 8, 2004 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned short *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_int * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, int *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_uint * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 8, 2004 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned int *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_long * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_long_long * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Elena Pourmal * * Date: June 17, 2005 * * Comments: This function was added to support INTEGER*8 Fortran types * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, long long *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_ulong * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: March 8, 2004 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_float * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, float *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute_double * * Purpose: Reads an attribute named attr_name * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, double *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * Function: H5LTget_attribute * * Purpose: Reads an attribute named attr_name with the memory type mem_type_id * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: Private function * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LTget_attribute(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *data) { /* Get the attribute */ if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- * private functions *------------------------------------------------------------------------- */ /*------------------------------------------------------------------------- * Function: H5LT_get_attribute_mem * * Purpose: Reads an attribute named attr_name with the memory type mem_type_id * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: Private function * * Modifications: * *------------------------------------------------------------------------- */ static herr_t H5LT_get_attribute_mem(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *data) { /* identifiers */ hid_t obj_id = -1; hid_t attr_id = -1; /* check the arguments */ if (obj_name == NULL) return -1; if (attr_name == NULL) return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) goto out; if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) goto out; if (H5Aread(attr_id, mem_type_id, data) < 0) goto out; if (H5Aclose(attr_id) < 0) goto out; attr_id = -1; /* Close the object */ if (H5Oclose(obj_id) < 0) goto out; obj_id = -1; return 0; out: if (obj_id > 0) H5Oclose(obj_id); if (attr_id > 0) H5Aclose(attr_id); return -1; } /*------------------------------------------------------------------------- * Function: H5LT_get_attribute_disk * * Purpose: Reads an attribute named attr_name with the datatype stored on disk * * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * * Date: September 19, 2002 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LT_get_attribute_disk(hid_t loc_id, const char *attr_name, void *attr_out) { /* identifiers */ hid_t attr_id; hid_t attr_type; if ((attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0) return -1; if ((attr_type = H5Aget_type(attr_id)) < 0) goto out; if (H5Aread(attr_id, attr_type, attr_out) < 0) goto out; if (H5Tclose(attr_type) < 0) goto out; if (H5Aclose(attr_id) < 0) return -1; ; return 0; out: H5Tclose(attr_type); H5Aclose(attr_id); return -1; } /*------------------------------------------------------------------------- * Function: H5LT_set_attribute_string * * Purpose: creates and writes an attribute named NAME to the dataset DSET_ID * * Return: FAIL on error, SUCCESS on success * * Programmer: Pedro Vicente * * Date: January 04, 2005 * * Comments: * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf) { hid_t tid; hid_t sid = -1; hid_t aid = -1; int has_attr; size_t size; /* verify if the attribute already exists */ has_attr = H5LT_find_attribute(dset_id, name); /* the attribute already exists, delete it */ if (has_attr == 1) if (H5Adelete(dset_id, name) < 0) return FAIL; /*------------------------------------------------------------------------- * create the attribute type *------------------------------------------------------------------------- */ if ((tid = H5Tcopy(H5T_C_S1)) < 0) return FAIL; size = HDstrlen(buf) + 1; /* extra null term */ if (H5Tset_size(tid, (size_t)size) < 0) goto out; if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) goto out; if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; /*------------------------------------------------------------------------- * create and write the attribute *------------------------------------------------------------------------- */ if ((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; if (H5Awrite(aid, tid, buf) < 0) goto out; if (H5Aclose(aid) < 0) goto out; if (H5Sclose(sid) < 0) goto out; if (H5Tclose(tid) < 0) goto out; return SUCCEED; /* error zone */ out: H5E_BEGIN_TRY { H5Aclose(aid); H5Tclose(tid); H5Sclose(sid); } H5E_END_TRY; return FAIL; } htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid) { char * tmp_path = NULL; /* Temporary copy of the path */ char * curr_name; /* Pointer to current component of path name */ char * delimit; /* Pointer to path delimiter during traversal */ H5I_type_t obj_type; htri_t link_exists, obj_exists; size_t path_length; htri_t ret_value; /* Initialize */ ret_value = FALSE; /* check the arguments */ if (path == NULL) { ret_value = FAIL; goto done; } /* Find the type of loc_id */ if ((obj_type = H5Iget_type(loc_id)) == H5I_BADID) { ret_value = FAIL; goto done; } /* Find the length of the path */ path_length = HDstrlen(path); /* Check if the identifier is the object itself, i.e. path is '.' */ if (HDstrncmp(path, ".", path_length) == 0) { if (check_object_valid) { obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT); ret_value = obj_exists; goto done; } else { ret_value = TRUE; /* Since the object is the identifier itself, * we can only check if loc_id is a valid type */ goto done; } } /* Duplicate the path to use */ if (NULL == (tmp_path = HDstrdup(path))) { ret_value = FAIL; goto done; } curr_name = tmp_path; /* check if absolute pathname */ if (HDstrncmp(path, "/", 1) == 0) curr_name++; /* check if relative path name starts with "./" */ if (HDstrncmp(path, "./", 2) == 0) curr_name += 2; while ((delimit = HDstrchr(curr_name, '/')) != NULL) { /* Change the delimiter to terminate the string */ *delimit = '\0'; obj_exists = FALSE; if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { ret_value = FAIL; goto done; } /* If target link does not exist then no reason to * continue checking the path */ if (link_exists != TRUE) { ret_value = FALSE; goto done; } /* Determine if link resolves to an actual object */ if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { ret_value = FAIL; goto done; } if (obj_exists != TRUE) break; /* Change the delimiter back to '/' */ *delimit = '/'; /* Advance the pointer in the path to the start of the next component */ curr_name = delimit + 1; } /* end while */ /* Should be pointing to the last component in the path name now... */ /* Check if link does not exist */ if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { ret_value = FAIL; } else { ret_value = link_exists; /* Determine if link resolves to an actual object for check_object_valid TRUE */ if (check_object_valid == TRUE && link_exists == TRUE) { if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { ret_value = FAIL; } else { ret_value = obj_exists; } } } done: if (tmp_path != NULL) HDfree(tmp_path); return ret_value; }
923db9fa764cf14956d27065a933b1b3f59ac789
ec6a71b57ebe88538269197fd16bede6bc2062ae
/system/doc/tutorial/complex.c
206d8abf4ee2841c7c3cbd8529bf8ccdc89b946c
[ "LGPL-2.1-or-later", "GPL-1.0-or-later", "LGPL-2.0-or-later", "WxWindows-exception-3.1", "Zlib", "BSD-3-Clause", "BSD-4.3TAHOE", "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-pcre", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
erlang/otp
7c6e88ca955bd6a3ede1530154c80e8ce449a370
334589af62a8db25a81afba2ecc50f33ff69ddb8
refs/heads/master
2023-08-30T23:37:28.061328
2023-08-30T04:20:48
2023-08-30T04:20:48
374,927
9,920
3,018
Apache-2.0
2023-09-14T10:37:26
2009-11-16T17:17:57
Erlang
UTF-8
C
false
false
84
c
complex.c
/* complex.c */ int foo(int x) { return x+1; } int bar(int y) { return y*2; }
5d39f922a369a7fe52881b3663ca9100b53fc5cc
540c04254075b9fb22685a73487531f4c0b3e3ac
/lib-rdm/include/rdm_e120.h
9c116d4e92b4dc5609dfb3980d470317f00daff1
[ "MIT" ]
permissive
vanvught/rpidmx512
197573217fc2c0c3673d6727d199c10e528a9fac
f27ae141d14c1d1cb9e0b62a291356ae0780c99f
refs/heads/master
2023-08-08T02:06:52.200184
2023-05-19T12:44:48
2023-05-19T12:44:48
15,496,962
380
125
MIT
2023-05-19T12:47:24
2013-12-28T18:27:20
C++
UTF-8
C
false
false
56,559
h
rdm_e120.h
/*****************************************************************/ /* Entertainment Services Technology Association (ESTA) */ /* ANSI E1.20 Remote Device Management (RDM) over DMX512 Networks*/ /*****************************************************************/ /* */ /* RDM.h */ /* */ /*****************************************************************/ /* Appendix A Defines for the RDM Protocol. */ /* Publish date: 3/31/2006 */ /*****************************************************************/ /* Compiled by: Scott M. Blair 8/18/2006 */ /* Updated 10/11/2011: Adding E1.20-2010 and E1.37-1 defines. */ /* Updated 10/24/2014: Adding E1.37-2 defines */ /*****************************************************************/ /* For updates see: http://www.rdmprotocol.org */ /*****************************************************************/ /* Copyright 2006,2011, 2014 Litespeed Design */ /*****************************************************************/ /* Permission to use, copy, modify, and distribute this software */ /* is freely granted, provided that this notice is preserved. */ /*****************************************************************/ /* Protocol version. */ #define E120_PROTOCOL_VERSION 0x0100 /* RDM START CODE (Slot 0) */ #define E120_SC_RDM 0xCC /* RDM Protocol Data Structure ID's (Slot 1) */ #define E120_SC_SUB_MESSAGE 0x01 /* Broadcast Device UID's */ #define E120_BROADCAST_ALL_DEVICES_ID 0xFFFFFFFFFFFF /* (Broadcast all Manufacturers) */ //#define ALL_DEVICES_ID 0xmmmmFFFFFFFF /* (Specific Manufacturer ID 0xmmmm) */ #define E120_SUB_DEVICE_ALL_CALL 0xFFFF /********************************************************/ /* Table A-1: RDM Command Classes (Slot 20) */ /********************************************************/ #define E120_DISCOVERY_COMMAND 0x10 #define E120_DISCOVERY_COMMAND_RESPONSE 0x11 #define E120_GET_COMMAND 0x20 #define E120_GET_COMMAND_RESPONSE 0x21 #define E120_SET_COMMAND 0x30 #define E120_SET_COMMAND_RESPONSE 0x31 /********************************************************/ /* Table A-2: RDM Response Type (Slot 16) */ /********************************************************/ #define E120_RESPONSE_TYPE_ACK 0x00 #define E120_RESPONSE_TYPE_ACK_TIMER 0x01 #define E120_RESPONSE_TYPE_NACK_REASON 0x02 /* See Table A-17 */ #define E120_RESPONSE_TYPE_ACK_OVERFLOW 0x03 /* Additional Response Data available beyond single response length.*/ /********************************************************/ /* Table A-3: RDM Parameter ID's (Slots 21-22) */ /********************************************************/ /* Category - Network Management */ #define E120_DISC_UNIQUE_BRANCH 0x0001 #define E120_DISC_MUTE 0x0002 #define E120_DISC_UN_MUTE 0x0003 #define E120_PROXIED_DEVICES 0x0010 #define E120_PROXIED_DEVICE_COUNT 0x0011 #define E120_COMMS_STATUS 0x0015 /* Category - Status Collection */ #define E120_QUEUED_MESSAGE 0x0020 /* See Table A-4 */ #define E120_STATUS_MESSAGES 0x0030 /* See Table A-4 */ #define E120_STATUS_ID_DESCRIPTION 0x0031 #define E120_CLEAR_STATUS_ID 0x0032 #define E120_SUB_DEVICE_STATUS_REPORT_THRESHOLD 0x0033 /* See Table A-4 */ /* Category - RDM Information */ #define E120_SUPPORTED_PARAMETERS 0x0050 /* Support required only if supporting Parameters beyond the minimum required set.*/ #define E120_PARAMETER_DESCRIPTION 0x0051 /* Support required for Manufacturer-Specific PIDs exposed in SUPPORTED_PARAMETERS message */ /* Category - Product Information */ #define E120_DEVICE_INFO 0x0060 #define E120_PRODUCT_DETAIL_ID_LIST 0x0070 #define E120_DEVICE_MODEL_DESCRIPTION 0x0080 #define E120_MANUFACTURER_LABEL 0x0081 #define E120_DEVICE_LABEL 0x0082 #define E120_FACTORY_DEFAULTS 0x0090 #define E120_LANGUAGE_CAPABILITIES 0x00A0 #define E120_LANGUAGE 0x00B0 #define E120_SOFTWARE_VERSION_LABEL 0x00C0 #define E120_BOOT_SOFTWARE_VERSION_ID 0x00C1 #define E120_BOOT_SOFTWARE_VERSION_LABEL 0x00C2 /* Category - DMX512 Setup */ #define E120_DMX_PERSONALITY 0x00E0 #define E120_DMX_PERSONALITY_DESCRIPTION 0x00E1 #define E120_DMX_START_ADDRESS 0x00F0 /* Support required if device uses a DMX512 Slot. */ #define E120_SLOT_INFO 0x0120 #define E120_SLOT_DESCRIPTION 0x0121 #define E120_DEFAULT_SLOT_VALUE 0x0122 #define E137_1_DMX_BLOCK_ADDRESS 0x0140 /* Defined in ANSI E1.37-1 document */ #define E137_1_DMX_FAIL_MODE 0x0141 /* Defined in ANSI E1.37-1 document */ #define E137_1_DMX_STARTUP_MODE 0x0142 /* Defined in ANSI E1.37-1 document */ /* Category - Sensors */ #define E120_SENSOR_DEFINITION 0x0200 #define E120_SENSOR_VALUE 0x0201 #define E120_RECORD_SENSORS 0x0202 /* Category - Dimmer Settings */ #define E137_1_DIMMER_INFO 0x0340 #define E137_1_MINIMUM_LEVEL 0x0341 #define E137_1_MAXIMUM_LEVEL 0x0342 #define E137_1_CURVE 0x0343 #define E137_1_CURVE_DESCRIPTION 0x0344 /* Support required if CURVE is supported */ #define E137_1_OUTPUT_RESPONSE_TIME 0x0345 #define E137_1_OUTPUT_RESPONSE_TIME_DESCRIPTION 0x0346 /* Support required if OUTPUT_RESPONSE_TIME is supported */ #define E137_1_MODULATION_FREQUENCY 0x0347 #define E137_1_MODULATION_FREQUENCY_DESCRIPTION 0x0348 /* Support required if MODULATION_FREQUENCY is supported */ /* Category - Power/Lamp Settings */ #define E120_DEVICE_HOURS 0x0400 #define E120_LAMP_HOURS 0x0401 #define E120_LAMP_STRIKES 0x0402 #define E120_LAMP_STATE 0x0403 /* See Table A-8 */ #define E120_LAMP_ON_MODE 0x0404 /* See Table A-9 */ #define E120_DEVICE_POWER_CYCLES 0x0405 #define E137_1_BURN_IN 0x0440 /* Defined in ANSI E1.37-1 */ /* Category - Display Settings */ #define E120_DISPLAY_INVERT 0x0500 #define E120_DISPLAY_LEVEL 0x0501 /* Category - Configuration */ #define E120_PAN_INVERT 0x0600 #define E120_TILT_INVERT 0x0601 #define E120_PAN_TILT_SWAP 0x0602 #define E120_REAL_TIME_CLOCK 0x0603 #define E137_1_LOCK_PIN 0x0640 /* Defined in ANSI E1.37-1 */ #define E137_1_LOCK_STATE 0x0641 /* Defined in ANSI E1.37-1 */ #define E137_1_LOCK_STATE_DESCRIPTION 0x0642 /* Support required if MODULATION_FREQUENCY is supported */ /* Category - Network Configuration*/ #define E137_2_LIST_INTERFACES 0x0700 /* Defined in ANSI E1.37-2 */ #define E137_2_INTERFACE_LABEL 0x0701 /* Defined in ANSI E1.37-2 */ #define E137_2_INTERFACE_HARDWARE_ADDRESS_TYPE1 0x0702 /* Defined in ANSI E1.37-2 */ #define E137_2_IPV4_DHCP_MODE 0x0703 /* Defined in ANSI E1.37-2 */ #define E137_2_IPV4_ZEROCONF_MODE 0x0704 /* Defined in ANSI E1.37-2 */ #define E137_2_IPV4_CURRENT_ADDRESS 0x0705 /* Defined in ANSI E1.37-2 */ #define E137_2_IPV4_STATIC_ADDRESS 0x0706 /* Defined in ANSI E1.37-2 */ #define E137_2_INTERFACE_RENEW_DHCP 0x0707 /* Defined in ANSI E1.37-2 */ #define E137_2_INTERFACE_RELEASE_DHCP 0x0708 /* Defined in ANSI E1.37-2 */ #define E137_2_INTERFACE_APPLY_CONFIGURATION 0x0709 /* Defined in ANSI E1.37-2 (Support required if _ADDRESS PIDs supported) */ #define E137_2_IPV4_DEFAULT_ROUTE 0x070A /* Defined in ANSI E1.37-2 */ #define E137_2_DNS_IPV4_NAME_SERVER 0x070B /* Defined in ANSI E1.37-2 */ #define E137_2_DNS_HOSTNAME 0x070C /* Defined in ANSI E1.37-2 */ #define E137_2_DNS_DOMAIN_NAME 0x070D /* Defined in ANSI E1.37-2 */ /* Category - Control */ #define E120_IDENTIFY_DEVICE 0x1000 #define E120_RESET_DEVICE 0x1001 #define E120_POWER_STATE 0x1010 /* See Table A-11 */ #define E120_PERFORM_SELFTEST 0x1020 /* See Table A-10 */ #define E120_SELF_TEST_DESCRIPTION 0x1021 #define E120_CAPTURE_PRESET 0x1030 #define E120_PRESET_PLAYBACK 0x1031 /* See Table A-7 */ #define E137_1_IDENTIFY_MODE 0x1040 /* Defined in ANSI E1.37-1 */ #define E137_1_PRESET_INFO 0x1041 /* Defined in ANSI E1.37-1 */ #define E137_1_PRESET_STATUS 0x1042 /* Defined in ANSI E1.37-1 */ #define E137_1_PRESET_MERGEMODE 0x1043 /* See E1.37-1 Table A-3 */ #define E137_1_POWER_ON_SELF_TEST 0x1044 /* Defined in ANSI E1.37-1 */ /* ESTA Reserved Future RDM Development 0x7FE0- 0x7FFF Manufacturer-Specific PIDs 0x8000- 0xFFDF ESTA Reserved Future RDM Development 0xFFE0- 0xFFFF */ /*****************************************************************/ /* Discovery Mute/Un-Mute Messages Control Field. See Table 7-3. */ /*****************************************************************/ #define E120_CONTROL_PROXIED_DEVICE 0x0008 #define E120_CONTROL_BOOT_LOADER 0x0004 #define E120_CONTROL_SUB_DEVICE 0x0002 #define E120_CONTROL_MANAGED_PROXY 0x0001 /********************************************************/ /* Table A-4: Status Type Defines */ /********************************************************/ #define E120_STATUS_NONE 0x00 /* Not allowed for use with GET: QUEUED_MESSAGE */ #define E120_STATUS_GET_LAST_MESSAGE 0x01 #define E120_STATUS_ADVISORY 0x02 #define E120_STATUS_WARNING 0x03 #define E120_STATUS_ERROR 0x04 #define E120_STATUS_ADVISORY_CLEARED 0x12 /* Added in E1.20-2010 version */ #define E120_STATUS_WARNING_CLEARED 0x13 /* Added in E1.20-2010 version */ #define E120_STATUS_ERROR_CLEARED 0x14 /* Added in E1.20-2010 version */ /********************************************************/ /* Table A-5: Product Category Defines */ /********************************************************/ #define E120_PRODUCT_CATEGORY_NOT_DECLARED 0x0000 /* Fixtures - intended as source of illumination See Note 1 */ #define E120_PRODUCT_CATEGORY_FIXTURE 0x0100 /* No Fine Category declared */ #define E120_PRODUCT_CATEGORY_FIXTURE_FIXED 0x0101 /* No pan / tilt / focus style functions */ #define E120_PRODUCT_CATEGORY_FIXTURE_MOVING_YOKE 0x0102 #define E120_PRODUCT_CATEGORY_FIXTURE_MOVING_MIRROR 0x0103 #define E120_PRODUCT_CATEGORY_FIXTURE_OTHER 0x01FF /* For example, focus but no pan/tilt. */ /* Fixture Accessories - add-ons to fixtures or projectors */ #define E120_PRODUCT_CATEGORY_FIXTURE_ACCESSORY 0x0200 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_FIXTURE_ACCESSORY_COLOR 0x0201 /* Scrollers / Color Changers */ #define E120_PRODUCT_CATEGORY_FIXTURE_ACCESSORY_YOKE 0x0202 /* Yoke add-on */ #define E120_PRODUCT_CATEGORY_FIXTURE_ACCESSORY_MIRROR 0x0203 /* Moving mirror add-on */ #define E120_PRODUCT_CATEGORY_FIXTURE_ACCESSORY_EFFECT 0x0204 /* Effects Discs */ #define E120_PRODUCT_CATEGORY_FIXTURE_ACCESSORY_BEAM 0x0205 /* Gobo Rotators /Iris / Shutters / Dousers/ Beam modifiers. */ #define E120_PRODUCT_CATEGORY_FIXTURE_ACCESSORY_OTHER 0x02FF /* Projectors - light source capable of producing realistic images from another media i.e Video / Slide / Oil Wheel / Film */ #define E120_PRODUCT_CATEGORY_PROJECTOR 0x0300 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_PROJECTOR_FIXED 0x0301 /* No pan / tilt functions. */ #define E120_PRODUCT_CATEGORY_PROJECTOR_MOVING_YOKE 0x0302 #define E120_PRODUCT_CATEGORY_PROJECTOR_MOVING_MIRROR 0x0303 #define E120_PRODUCT_CATEGORY_PROJECTOR_OTHER 0x03FF /* Atmospheric Effect - earth/wind/fire */ #define E120_PRODUCT_CATEGORY_ATMOSPHERIC 0x0400 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_ATMOSPHERIC_EFFECT 0x0401 /* Fogger / Hazer / Flame, etc. */ #define E120_PRODUCT_CATEGORY_ATMOSPHERIC_PYRO 0x0402 /* See Note 2. */ #define E120_PRODUCT_CATEGORY_ATMOSPHERIC_OTHER 0x04FF /* Intensity Control (specifically Dimming equipment) */ #define E120_PRODUCT_CATEGORY_DIMMER 0x0500 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_DIMMER_AC_INCANDESCENT 0x0501 /* AC > 50VAC */ #define E120_PRODUCT_CATEGORY_DIMMER_AC_FLUORESCENT 0x0502 #define E120_PRODUCT_CATEGORY_DIMMER_AC_COLDCATHODE 0x0503 /* High Voltage outputs such as Neon or other cold cathode. */ #define E120_PRODUCT_CATEGORY_DIMMER_AC_NONDIM 0x0504 /* Non-Dim module in dimmer rack. */ #define E120_PRODUCT_CATEGORY_DIMMER_AC_ELV 0x0505 /* AC <= 50V such as 12/24V AC Low voltage lamps. */ #define E120_PRODUCT_CATEGORY_DIMMER_AC_OTHER 0x0506 #define E120_PRODUCT_CATEGORY_DIMMER_DC_LEVEL 0x0507 /* Variable DC level output. */ #define E120_PRODUCT_CATEGORY_DIMMER_DC_PWM 0x0508 /* Chopped (PWM) output. */ #define E120_PRODUCT_CATEGORY_DIMMER_CS_LED 0x0509 /* Specialized LED dimmer. */ #define E120_PRODUCT_CATEGORY_DIMMER_OTHER 0x05FF /* Power Control (other than Dimming equipment) */ #define E120_PRODUCT_CATEGORY_POWER 0x0600 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_POWER_CONTROL 0x0601 /* Contactor racks, other forms of Power Controllers. */ #define E120_PRODUCT_CATEGORY_POWER_SOURCE 0x0602 /* Generators */ #define E120_PRODUCT_CATEGORY_POWER_OTHER 0x06FF /* Scenic Drive - including motorized effects unrelated to light source. */ #define E120_PRODUCT_CATEGORY_SCENIC 0x0700 /* No Fine Category declared */ #define E120_PRODUCT_CATEGORY_SCENIC_DRIVE 0x0701 /* Rotators / Kabuki drops, etc. See Note 2. */ #define E120_PRODUCT_CATEGORY_SCENIC_OTHER 0x07FF /* DMX Infrastructure, conversion and interfaces */ #define E120_PRODUCT_CATEGORY_DATA 0x0800 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_DATA_DISTRIBUTION 0x0801 /* Splitters/repeaters/Ethernet products used to distribute DMX*/ #define E120_PRODUCT_CATEGORY_DATA_CONVERSION 0x0802 /* Protocol Conversion analog decoders. */ #define E120_PRODUCT_CATEGORY_DATA_OTHER 0x08FF /* Audio-Visual Equipment */ #define E120_PRODUCT_CATEGORY_AV 0x0900 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_AV_AUDIO 0x0901 /* Audio controller or device. */ #define E120_PRODUCT_CATEGORY_AV_VIDEO 0x0902 /* Video controller or display device. */ #define E120_PRODUCT_CATEGORY_AV_OTHER 0x09FF /* Parameter Monitoring Equipment See Note 3. */ #define E120_PRODUCT_CATEGORY_MONITOR 0x0A00 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_MONITOR_ACLINEPOWER 0x0A01 /* Product that monitors AC line voltage, current or power. */ #define E120_PRODUCT_CATEGORY_MONITOR_DCPOWER 0x0A02 /* Product that monitors DC line voltage, current or power. */ #define E120_PRODUCT_CATEGORY_MONITOR_ENVIRONMENTAL 0x0A03 /* Temperature or other environmental parameter. */ #define E120_PRODUCT_CATEGORY_MONITOR_OTHER 0x0AFF /* Controllers, Backup devices */ #define E120_PRODUCT_CATEGORY_CONTROL 0x7000 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_CONTROL_CONTROLLER 0x7001 #define E120_PRODUCT_CATEGORY_CONTROL_BACKUPDEVICE 0x7002 #define E120_PRODUCT_CATEGORY_CONTROL_OTHER 0x70FF /* Test Equipment */ #define E120_PRODUCT_CATEGORY_TEST 0x7100 /* No Fine Category declared. */ #define E120_PRODUCT_CATEGORY_TEST_EQUIPMENT 0x7101 #define E120_PRODUCT_CATEGORY_TEST_EQUIPMENT_OTHER 0x71FF /* Miscellaneous */ #define E120_PRODUCT_CATEGORY_OTHER 0x7FFF /* For devices that aren't described within this table. */ /* Manufacturer Specific Categories 0x8000 - 0xDFFF */ /********************************************************/ /* Table A-6: Product Detail Defines */ /********************************************************/ #define E120_PRODUCT_DETAIL_NOT DECLARED 0x0000 /* Generally applied to fixtures */ #define E120_PRODUCT_DETAIL_ARC 0x0001 #define E120_PRODUCT_DETAIL_METAL_HALIDE 0x0002 #define E120_PRODUCT_DETAIL_INCANDESCENT 0x0003 #define E120_PRODUCT_DETAIL_LED 0x0004 #define E120_PRODUCT_DETAIL_FLUROESCENT 0x0005 #define E120_PRODUCT_DETAIL_COLDCATHODE 0x0006 /*includes Neon/Argon */ #define E120_PRODUCT_DETAIL_ELECTROLUMINESCENT 0x0007 #define E120_PRODUCT_DETAIL_LASER 0x0008 #define E120_PRODUCT_DETAIL_FLASHTUBE 0x0009 /* Strobes or other flashtubes */ /* Generally applied to fixture accessories */ #define E120_PRODUCT_DETAIL_COLORSCROLLER 0x0100 #define E120_PRODUCT_DETAIL_COLORWHEEL 0x0101 #define E120_PRODUCT_DETAIL_COLORCHANGE 0x0102 /* Semaphore or other type */ #define E120_PRODUCT_DETAIL_IRIS_DOUSER 0x0103 #define E120_PRODUCT_DETAIL_DIMMING_SHUTTER 0x0104 #define E120_PRODUCT_DETAIL_PROFILE_SHUTTER 0x0105 /* hard-edge beam masking */ #define E120_PRODUCT_DETAIL_BARNDOOR_SHUTTER 0x0106 /* soft-edge beam masking */ #define E120_PRODUCT_DETAIL_EFFECTS_DISC 0x0107 #define E120_PRODUCT_DETAIL_GOBO_ROTATOR 0x0108 /* Generally applied to Projectors */ #define E120_PRODUCT_DETAIL_VIDEO 0x0200 #define E120_PRODUCT_DETAIL_SLIDE 0x0201 #define E120_PRODUCT_DETAIL_FILM 0x0202 #define E120_PRODUCT_DETAIL_OILWHEEL 0x0203 #define E120_PRODUCT_DETAIL_LCDGATE 0x0204 /* Generally applied to Atmospheric Effects */ #define E120_PRODUCT_DETAIL_FOGGER_GLYCOL 0x0300 /* Glycol/Glycerin hazer */ #define E120_PRODUCT_DETAIL_FOGGER_MINERALOIL 0x0301 /* White Mineral oil hazer */ #define E120_PRODUCT_DETAIL_FOGGER_WATER 0x0302 /* Water hazer */ #define E120_PRODUCT_DETAIL_C02 0x0303 /* Dry Ice/Carbon Dioxide based */ #define E120_PRODUCT_DETAIL_LN2 0x0304 /* Nitrogen based */ #define E120_PRODUCT_DETAIL_BUBBLE 0x0305 /* including foam */ #define E120_PRODUCT_DETAIL_FLAME_PROPANE 0x0306 #define E120_PRODUCT_DETAIL_FLAME_OTHER 0x0307 #define E120_PRODUCT_DETAIL_OLEFACTORY_STIMULATOR 0x0308 /* Scents */ #define E120_PRODUCT_DETAIL_SNOW 0x0309 #define E120_PRODUCT_DETAIL_WATER_JET 0x030A /* Fountain controls etc */ #define E120_PRODUCT_DETAIL_WIND 0x030B /* Air Mover */ #define E120_PRODUCT_DETAIL_CONFETTI 0x030C #define E120_PRODUCT_DETAIL_HAZARD 0x030D /* Any form of pyrotechnic control or device. */ /* Generally applied to Dimmers/Power controllers See Note 1 */ #define E120_PRODUCT_DETAIL_PHASE_CONTROL 0x0400 #define E120_PRODUCT_DETAIL_REVERSE_PHASE_CONTROL 0x0401 /* includes FET/IGBT */ #define E120_PRODUCT_DETAIL_SINE 0x0402 #define E120_PRODUCT_DETAIL_PWM 0x0403 #define E120_PRODUCT_DETAIL_DC 0x0404 /* Variable voltage */ #define E120_PRODUCT_DETAIL_HFBALLAST 0x0405 /* for Fluroescent */ #define E120_PRODUCT_DETAIL_HFHV_NEONBALLAST 0x0406 /* for Neon/Argon and other coldcathode. */ #define E120_PRODUCT_DETAIL_HFHV_EL 0x0407 /* for Electroluminscent */ #define E120_PRODUCT_DETAIL_MHR_BALLAST 0x0408 /* for Metal Halide */ #define E120_PRODUCT_DETAIL_BITANGLE_MODULATION 0x0409 #define E120_PRODUCT_DETAIL_FREQUENCY_MODULATION 0x040A #define E120_PRODUCT_DETAIL_HIGHFREQUENCY_12V 0x040B /* as commonly used with MR16 lamps */ #define E120_PRODUCT_DETAIL_RELAY_MECHANICAL 0x040C /* See Note 1 */ #define E120_PRODUCT_DETAIL_RELAY_ELECTRONIC 0x040D /* See Note 1, Note 2 */ #define E120_PRODUCT_DETAIL_SWITCH_ELECTRONIC 0x040E /* See Note 1, Note 2 */ #define E120_PRODUCT_DETAIL_CONTACTOR 0x040F /* See Note 1 */ /* Generally applied to Scenic drive */ #define E120_PRODUCT_DETAIL_MIRRORBALL_ROTATOR 0x0500 #define E120_PRODUCT_DETAIL_OTHER_ROTATOR 0x0501 /* includes turntables */ #define E120_PRODUCT_DETAIL_KABUKI_DROP 0x0502 #define E120_PRODUCT_DETAIL_CURTAIN 0x0503 /* flown or traveller */ #define E120_PRODUCT_DETAIL_LINESET 0x0504 #define E120_PRODUCT_DETAIL_MOTOR_CONTROL 0x0505 #define E120_PRODUCT_DETAIL_DAMPER_CONTROL 0x0506 /* HVAC Damper */ /* Generally applied to Data Distribution */ #define E120_PRODUCT_DETAIL_SPLITTER 0x0600 /* Includes buffers/repeaters */ #define E120_PRODUCT_DETAIL_ETHERNET_NODE 0x0601 /* DMX512 to/from Ethernet */ #define E120_PRODUCT_DETAIL_MERGE 0x0602 /* DMX512 combiner */ #define E120_PRODUCT_DETAIL_DATAPATCH 0x0603 /* Electronic Datalink Patch */ #define E120_PRODUCT_DETAIL_WIRELESS_LINK 0x0604 /* radio/infrared */ /* Generally applied to Data Conversion and Interfaces */ #define E120_PRODUCT_DETAIL_PROTOCOL_CONVERTOR 0x0701 /* D54/AMX192/Non DMX serial links, etc to/from DMX512 */ #define E120_PRODUCT_DETAIL_ANALOG_DEMULTIPLEX 0x0702 /* DMX to DC voltage */ #define E120_PRODUCT_DETAIL_ANALOG_MULTIPLEX 0x0703 /* DC Voltage to DMX */ #define E120_PRODUCT_DETAIL_SWITCH_PANEL 0x0704 /* Pushbuttons to DMX or polled using RDM */ /* Generally applied to Audio or Video (AV) devices */ #define E120_PRODUCT_DETAIL_ROUTER 0x0800 /* Switching device */ #define E120_PRODUCT_DETAIL_FADER 0x0801 /* Single channel */ #define E120_PRODUCT_DETAIL_MIXER 0x0802 /* Multi-channel */ /* Generally applied to Controllers, Backup devices and Test Equipment */ #define E120_PRODUCT_DETAIL_CHANGEOVER_MANUAL 0x0900 /* requires manual intervention to assume control of DMX line */ #define E120_PRODUCT_DETAIL_CHANGEOVER_AUTO 0x0901 /* may automatically assume control of DMX line */ #define E120_PRODUCT_DETAIL_TEST 0x0902 /* test equipment */ /* Could be applied to any category */ #define E120_PRODUCT_DETAIL_GFI_RCD 0x0A00 /* device includes GFI/RCD trip */ #define E120_PRODUCT_DETAIL_BATTERY 0x0A01 /* device is battery operated */ #define E120_PRODUCT_DETAIL_CONTROLLABLE_BREAKER 0x0A02 #define E120_PRODUCT_DETAIL_OTHER 0x7FFF /* for use where the Manufacturer believes that none of the defined details apply. */ /* Manufacturer Specific Types 0x8000- 0xDFFF */ /* Note 1: Products intended for switching 50V AC / 120V DC or greater should be declared with a Product Category of PRODUCT_CATEGORY_POWER_CONTROL. Products only suitable for extra low voltage switching (typically up to 50VAC / 30VDC) at currents less than 1 ampere should be declared with a Product Category of PRODUCT_CATEGORY_DATA_CONVERSION. Please refer to GET: DEVICE_INFO and Table A-5 for an explanation of Product Category declaration. Note 2: Products with TTL, MOSFET or Open Collector Transistor Outputs or similar non-isolated electronic outputs should be declared as PRODUCT_DETAIL_SWITCH_ELECTRONIC. Use of PRODUCT_DETAIL_RELAY_ELECTRONIC shall be restricted to devices whereby the switched circuits are electrically isolated from the control signals. */ /********************************************************/ /* Table A-7: Preset Playback Defines */ /********************************************************/ #define E120_PRESET_PLAYBACK_OFF 0x0000 /* Returns to Normal DMX512 Input */ #define E120_PRESET_PLAYBACK_ALL 0xFFFF /* Plays Scenes in Sequence if supported. */ /* E120_PRESET_PLAYBACK_SCENE 0x0001- 0xFFFE Plays individual Scene # */ /********************************************************/ /* Table A-8: Lamp State Defines */ /********************************************************/ #define E120_LAMP_OFF 0x00 /* No demonstrable light output */ #define E120_LAMP_ON 0x01 #define E120_LAMP_STRIKE 0x02 /* Arc-Lamp ignite */ #define E120_LAMP_STANDBY 0x03 /* Arc-Lamp Reduced Power Mode */ #define E120_LAMP_NOT_PRESENT 0x04 /* Lamp not installed */ #define E120_LAMP_ERROR 0x7F /* Manufacturer-Specific States 0x80- 0xDF */ /********************************************************/ /* Table A-9: Lamp On Mode Defines */ /********************************************************/ #define E120_LAMP_ON_MODE_OFF 0x00 /* Lamp Stays off until directly instructed to Strike. */ #define E120_LAMP_ON_MODE_DMX 0x01 /* Lamp Strikes upon receiving a DMX512 signal. */ #define E120_LAMP_ON_MODE_ON 0x02 /* Lamp Strikes automatically at Power-up. */ #define E120_LAMP_ON_MODE_AFTER_CAL 0x03 /* Lamp Strikes after Calibration or Homing procedure. */ /* Manufacturer-Specific Modes 0x80- 0xDF */ /********************************************************/ /* Table A-10: Self Test Defines */ /********************************************************/ #define E120_SELF_TEST_OFF 0x00 /* Turns Self Tests Off */ /* Manufacturer Tests 0x01- 0xFE Various Manufacturer Self Tests */ #define E120_SELF_TEST_ALL 0xFF /* Self Test All, if applicable */ /********************************************************/ /* Table A-11: Power State Defines */ /********************************************************/ #define E120_POWER_STATE_FULL_OFF 0x00 /* Completely disengages power to device. Device can no longer respond. */ #define E120_POWER_STATE_SHUTDOWN 0x01 /* Reduced power mode, may require device reset to return to normal operation. Device still responds to messages. */ #define E120_POWER_STATE_STANDBY 0x02 /* Reduced power mode. Device can return to NORMAL without a reset. Device still responds to messages. */ #define E120_POWER_STATE_NORMAL 0xFF /* Normal Operating Mode. */ /********************************************************/ /* Table A-12: Sensor Type Defines */ /********************************************************/ #define E120_SENS_TEMPERATURE 0x00 #define E120_SENS_VOLTAGE 0x01 #define E120_SENS_CURRENT 0x02 #define E120_SENS_FREQUENCY 0x03 #define E120_SENS_RESISTANCE 0x04 /* Eg: Cable resistance */ #define E120_SENS_POWER 0x05 #define E120_SENS_MASS 0x06 /* Eg: Truss load Cell */ #define E120_SENS_LENGTH 0x07 #define E120_SENS_AREA 0x08 #define E120_SENS_VOLUME 0x09 /* Eg: Smoke Fluid */ #define E120_SENS_DENSITY 0x0A #define E120_SENS_VELOCITY 0x0B #define E120_SENS_ACCELERATION 0x0C #define E120_SENS_FORCE 0x0D #define E120_SENS_ENERGY 0x0E #define E120_SENS_PRESSURE 0x0F #define E120_SENS_TIME 0x10 #define E120_SENS_ANGLE 0x11 #define E120_SENS_POSITION_X 0x12 /* E.g.: Lamp position on Truss */ #define E120_SENS_POSITION_Y 0x13 #define E120_SENS_POSITION_Z 0x14 #define E120_SENS_ANGULAR_VELOCITY 0x15 /* E.g.: Wind speed */ #define E120_SENS_LUMINOUS_INTENSITY 0x16 #define E120_SENS_LUMINOUS_FLUX 0x17 #define E120_SENS_ILLUMINANCE 0x18 #define E120_SENS_CHROMINANCE_RED 0x19 #define E120_SENS_CHROMINANCE_GREEN 0x1A #define E120_SENS_CHROMINANCE_BLUE 0x1B #define E120_SENS_CONTACTS 0x1C /* E.g.: Switch inputs. */ #define E120_SENS_MEMORY 0x1D /* E.g.: ROM Size */ #define E120_SENS_ITEMS 0x1E /* E.g.: Scroller gel frames. */ #define E120_SENS_HUMIDITY 0x1F #define E120_SENS_COUNTER_16BIT 0x20 #define E120_SENS_OTHER 0x7F /* Manufacturer-Specific Sensors 0x80- 0xFF */ /********************************************************/ /* Table A-13: Sensor Unit Defines */ /********************************************************/ #define E120_UNITS_NONE 0x00 /* CONTACTS */ #define E120_UNITS_CENTIGRADE 0x01 /* TEMPERATURE */ #define E120_UNITS_VOLTS_DC 0x02 /* VOLTAGE */ #define E120_UNITS_VOLTS_AC_PEAK 0x03 /* VOLTAGE */ #define E120_UNITS_VOLTS_AC_RMS 0x04 /* VOLTAGE */ #define E120_UNITS_AMPERE_DC 0x05 /* CURRENT */ #define E120_UNITS_AMPERE_AC_PEAK 0x06 /* CURRENT */ #define E120_UNITS_AMPERE_AC_RMS 0x07 /* CURRENT */ #define E120_UNITS_HERTZ 0x08 /* FREQUENCY / ANG_VEL */ #define E120_UNITS_OHM 0x09 /* RESISTANCE */ #define E120_UNITS_WATT 0x0A /* POWER */ #define E120_UNITS_KILOGRAM 0x0B /* MASS */ #define E120_UNITS_METERS 0x0C /* LENGTH / POSITION */ #define E120_UNITS_METERS_SQUARED 0x0D /* AREA */ #define E120_UNITS_METERS_CUBED 0x0E /* VOLUME */ #define E120_UNITS_KILOGRAMMES_PER_METER_CUBED 0x0F /* DENSITY */ #define E120_UNITS_METERS_PER_SECOND 0x10 /* VELOCITY */ #define E120_UNITS_METERS_PER_SECOND_SQUARED 0x11 /* ACCELERATION */ #define E120_UNITS_NEWTON 0x12 /* FORCE */ #define E120_UNITS_JOULE 0x13 /* ENERGY */ #define E120_UNITS_PASCAL 0x14 /* PRESSURE */ #define E120_UNITS_SECOND 0x15 /* TIME */ #define E120_UNITS_DEGREE 0x16 /* ANGLE */ #define E120_UNITS_STERADIAN 0x17 /* ANGLE */ #define E120_UNITS_CANDELA 0x18 /* LUMINOUS_INTENSITY */ #define E120_UNITS_LUMEN 0x19 /* LUMINOUS_FLUX */ #define E120_UNITS_LUX 0x1A /* ILLUMINANCE */ #define E120_UNITS_IRE 0x1B /* CHROMINANCE */ #define E120_UNITS_BYTE 0x1C /* MEMORY */ /* Manufacturer-Specific Units 0x80- 0xFF */ /********************************************************/ /* Table A-14: Sensor Unit Prefix Defines */ /********************************************************/ #define E120_PREFIX_NONE 0x00 /* Multiply by 1 */ #define E120_PREFIX_DECI 0x01 /* Multiply by 10-1 */ #define E120_PREFIX_CENTI 0x02 /* Multiply by 10-2 */ #define E120_PREFIX_MILLI 0x03 /* Multiply by 10-3 */ #define E120_PREFIX_MICRO 0x04 /* Multiply by 10-6 */ #define E120_PREFIX_NANO 0x05 /* Multiply by 10-9 */ #define E120_PREFIX_PICO 0x06 /* Multiply by 10-12 */ #define E120_PREFIX_FEMPTO 0x07 /* Multiply by 10-15 */ #define E120_PREFIX_ATTO 0x08 /* Multiply by 10-18 */ #define E120_PREFIX_ZEPTO 0x09 /* Multiply by 10-21 */ #define E120_PREFIX_YOCTO 0x0A /* Multiply by 10-24 */ #define E120_PREFIX_DECA 0x11 /* Multiply by 10+1 */ #define E120_PREFIX_HECTO 0x12 /* Multiply by 10+2 */ #define E120_PREFIX_KILO 0x13 /* Multiply by 10+3 */ #define E120_PREFIX_MEGA 0x14 /* Multiply by 10+6 */ #define E120_PREFIX_GIGA 0x15 /* Multiply by 10+9 */ #define E120_PREFIX_TERRA 0x16 /* Multiply by 10+12 */ #define E120_PREFIX_PETA 0x17 /* Multiply by 10+15 */ #define E120_PREFIX_EXA 0x18 /* Multiply by 10+18 */ #define E120_PREFIX_ZETTA 0x19 /* Multiply by 10+21 */ #define E120_PREFIX_YOTTA 0x1A /* Multiply by 10+24 */ /********************************************************/ /* Table A-15: Data Type Defines */ /********************************************************/ #define E120_DS_NOT_DEFINED 0x00 /* Data type is not defined */ #define E120_DS_BIT_FIELD 0x01 /* Data is bit packed */ #define E120_DS_ASCII 0x02 /* Data is a string */ #define E120_DS_UNSIGNED_BYTE 0x03 /* Data is an array of unsigned bytes */ #define E120_DS_SIGNED_BYTE 0x04 /* Data is an array of signed bytes */ #define E120_DS_UNSIGNED_WORD 0x05 /* Data is an array of unsigned 16-bit words */ #define E120_DS_SIGNED_WORD 0x06 /* Data is an array of signed 16-bit words */ #define E120_DS_UNSIGNED_DWORD 0x07 /* Data is an array of unsigned 32-bit words */ #define E120_DS_SIGNED_DWORD 0x08 /* Data is an array of signed 32-bit words */ /* Manufacturer-Specific Data Types 0x80- */ /* 0xDF */ /********************************************************/ /* Table A-16: Parameter Desc. Command Class Defines */ /********************************************************/ #define E120_CC_GET 0x01 /* PID supports GET only */ #define E120_CC_SET 0x02 /* PID supports SET only */ #define E120_CC_GET_SET 0x03 /* PID supports GET & SET */ /********************************************************/ /* Table A-17: Response NACK Reason Code Defines */ /********************************************************/ #define E120_NR_UNKNOWN_PID 0x0000 /* The responder cannot comply with request because the message is not implemented in responder. */ #define E120_NR_FORMAT_ERROR 0x0001 /* The responder cannot interpret request as controller data was not formatted correctly. */ #define E120_NR_HARDWARE_FAULT 0x0002 /* The responder cannot comply due to an internal hardware fault*/ #define E120_NR_PROXY_REJECT 0x0003 /* Proxy is not the RDM line master and cannot comply with message.*/ #define E120_NR_WRITE_PROTECT 0x0004 /* SET Command normally allowed but being blocked currently. */ #define E120_NR_UNSUPPORTED_COMMAND_CLASS 0x0005 /* Not valid for Command Class attempted. May be used where GET allowed but SET is not supported. */ #define E120_NR_DATA_OUT_OF_RANGE 0x0006 /* Value for given Parameter out of allowable range or not supported. */ #define E120_NR_BUFFER_FULL 0x0007 /* Buffer or Queue space currently has no free space to store data. */ #define E120_NR_PACKET_SIZE_UNSUPPORTED 0x0008 /* Incoming message exceeds buffer capacity. */ #define E120_NR_SUB_DEVICE_OUT_OF_RANGE 0x0009 /* Sub-Device is out of range or unknown. */ #define E120_NR_PROXY_BUFFER_FULL 0x000A /* Proxy buffer is full and can not store any more Queued */ /* Message or Status Message responses. */ #define E137_2_NR_ACTION_NOT_SUPPORTED 0x000B /* The parameter data is valid but the SET operation cannot be */ /* performed with the current configuration. */ /********************************************************************************************************************************/ /********************************************************************************************************************************/ /* ANSI E1.37-1 DEFINES */ /********************************************************************************************************************************/ /********************************************************************************************************************************/ /********************************************************/ /* E1.37-1 Table A-2: Preset Programmed Defines */ /********************************************************/ #define E137_1_PRESET_NOT_PROGRAMMED 0x00 /* Preset Scene not programmed. */ #define E137_1_PRESET_PROGRAMMED 0x01 /* Preset Scene programmed. */ #define E137_1_PRESET_PROGRAMMED_READ_ONLY 0x02 /* Preset Scene read-only, factory programmed. */ /********************************************************/ /* E1.37-1 Table A-3: Merge Mode Defines */ /********************************************************/ #define E137_1_MERGEMODE_DEFAULT 0x00 /* Preset overrides DMX512 default behavior as defined in */ /* E1.20 PRESET_PLAYBACK */ #define E137_1_MERGEMODE_HTP 0x01 /* Highest Takes Precedence on slot by slot basis */ #define E137_1_MERGEMODE_LTP 0x02 /* Latest Takes Precedence from Preset or DMX512 on slot by slot */ #define E137_1_MERGEMODE_DMX_ONLY 0x03 /* DMX512 only, Preset ignored */ #define E137_1_MERGEMODE_OTHER 0xFF /* Other (undefined) merge mode */ /********************************************************************************************************************************/ /********************************************************************************************************************************/ /* ANSI E1.37-2 DEFINES */ /********************************************************************************************************************************/ /********************************************************************************************************************************/ /********************************************************/ /* E1.37-2 Table A-3: DHCP Mode Defines */ /********************************************************/ #define E137_2_DHCP_MODE_INACTIVE 0x00 /* IP Address was not obtained via DHCP */ #define E137_2_DHCP_MODE_ACTIVE 0x01 /* IP Address was obtained via DHCP */ #define E137_2_DHCP_MODE_UNKNOWN 0x02 /* The system cannot determine if address was obtained via DHCP. */
6c96ebeaf2fc940bb9847b1ec596b15bc0e21d35
7621ded45d87cbf0f1528fbf5340ab0c23e3414c
/targets/__deprecated__/glfw/template/glfw/lib/win32/win32_time.c
3c76b6f0408de71b6d864d5354386606e207c3db
[ "Zlib" ]
permissive
blitz-research/monkey
11ec8005321c51e0be7ae06b9695950824091009
1ad8c237d1bae94ab6f12bd3c2db2073ecf38e58
refs/heads/develop
2020-03-27T08:50:31.720954
2017-06-11T21:25:17
2017-06-11T21:25:17
8,043,513
156
65
null
2021-10-03T01:19:35
2013-02-06T03:06:35
C
UTF-8
C
false
false
4,652
c
win32_time.c
//======================================================================== // GLFW - An OpenGL framework // Platform: Win32/WGL // API version: 2.7 // WWW: http://www.glfw.org/ //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org> // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would // be appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, and must not // be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source // distribution. // //======================================================================== #include "internal.h" //************************************************************************ //**** GLFW internal functions **** //************************************************************************ //======================================================================== // Initialise timer //======================================================================== void _glfwInitTimer( void ) { __int64 freq; // Check if we have a performance counter if( QueryPerformanceFrequency( (LARGE_INTEGER *)&freq ) ) { // Performance counter is available => use it! _glfwLibrary.Timer.HasPerformanceCounter = GL_TRUE; // Counter resolution is 1 / counter frequency _glfwLibrary.Timer.Resolution = 1.0 / (double)freq; // Set start time for timer QueryPerformanceCounter( (LARGE_INTEGER *)&_glfwLibrary.Timer.t0_64 ); } else { // No performace counter available => use the tick counter _glfwLibrary.Timer.HasPerformanceCounter = GL_FALSE; // Counter resolution is 1 ms _glfwLibrary.Timer.Resolution = 0.001; // Set start time for timer _glfwLibrary.Timer.t0_32 = _glfw_timeGetTime(); } } //************************************************************************ //**** Platform implementation functions **** //************************************************************************ //======================================================================== // Return timer value in seconds //======================================================================== double _glfwPlatformGetTime( void ) { double t; __int64 t_64; if( _glfwLibrary.Timer.HasPerformanceCounter ) { QueryPerformanceCounter( (LARGE_INTEGER *)&t_64 ); t = (double)(t_64 - _glfwLibrary.Timer.t0_64); } else { t = (double)(_glfw_timeGetTime() - _glfwLibrary.Timer.t0_32); } // Calculate the current time in seconds return t * _glfwLibrary.Timer.Resolution; } //======================================================================== // Set timer value in seconds //======================================================================== void _glfwPlatformSetTime( double t ) { __int64 t_64; if( _glfwLibrary.Timer.HasPerformanceCounter ) { QueryPerformanceCounter( (LARGE_INTEGER *)&t_64 ); _glfwLibrary.Timer.t0_64 = t_64 - (__int64)(t/_glfwLibrary.Timer.Resolution); } else { _glfwLibrary.Timer.t0_32 = _glfw_timeGetTime() - (int)(t*1000.0); } } //======================================================================== // Put a thread to sleep for a specified amount of time //======================================================================== void _glfwPlatformSleep( double time ) { DWORD t; if( time == 0.0 ) { t = 0; } else if( time < 0.001 ) { t = 1; } else if( time > 2147483647.0 ) { t = 2147483647; } else { t = (DWORD)(time*1000.0 + 0.5); } Sleep( t ); }
97ae1f48bbe2dcbf4ee879251efbe3f1ec11792a
fbdc48c28e54fb33ae4842ef95ff63893902c99a
/src/omv/sensors/paj6100.c
72ecaed28f99b0614ccb0361cd73025c8cacba13
[ "MIT" ]
permissive
openmv/openmv
44d4b79fc8693950a2e330e5e0fd95b5c36e230f
8a90e070a88b7fc14c87a00351b9c4a213278419
refs/heads/master
2023-08-30T20:59:57.227603
2023-08-23T16:50:55
2023-08-23T16:50:55
14,360,940
2,150
1,226
MIT
2023-09-14T07:18:15
2013-11-13T10:23:44
C
UTF-8
C
false
false
21,928
c
paj6100.c
/* * File: paj6100.c * Created Date: Tuesday, May 25th 2021, 10:45:35 am * Author: Lake Fu * ----- * Last Modified: Tuesday June 15th 2021 2:54:43 pm * Modified By: Lake Fu at <lake_fu@pixart.com> * ----- * MIT License * * Copyright (c) 2021 Pixart 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 * 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. * ----- * HISTORY: * Date By Comments * ---------- --- ---------------------------------------------------------- */ #include "omv_boardconfig.h" #if (OMV_ENABLE_PAJ6100 == 1) #include <stdio.h> #include <stdbool.h> #include "py/mphal.h" #include "sensor.h" #include "framebuffer.h" #include "omv_gpio.h" #include "paj6100.h" #include "paj6100_reg.h" #include "pixspi.h" #define CACHE_BANK #ifdef DEBUG // For dump initial result before connect to IDE, // we use a global variable to store it. static int8_t init_res; #endif static int16_t bank_cache = -1; // Exposure time related paramaters + #define QVGA_MAX_EXPO_PA 85161 #define QQVGA_MAX_EXPO_PA 25497 #define R_AE_MinGain 1 #define R_AE_MaxGain 8 static float R_FrameTime = 6000000 / 30; static long R_AE_MaxExpoTime; static long R_AE_MinExpoTime = 120 / 6 + 0.5f; #define CAL_MAX_EXPO_TIME(PA) (fast_roundf(((float) (R_FrameTime - PA)) / 6)) #define L_TARGET 127 #define AE_LOCK_RANGE_IN 8 #define AE_LOCK_RANGE_OUT 16 static uint32_t l_total = 0; static uint32_t l_target_total = 0; static uint32_t lt_lockrange_in_ubound, lt_lockrange_in_lbound; static uint32_t lt_lockrange_out_ubound, lt_lockrange_out_lbound; static bool ae_converged_flag = false; static uint8_t skip_frame = 0; static bool is_ae_enabled = true; static int exp_us_cache = -1; // Exposure time related paramaters - static int set_auto_gain(sensor_t *sensor, int enable, float gain_db, float gain_db_ceiling); static int get_gain_db(sensor_t *sensor, float *gain_db); static int bank_switch(uint8_t bank) { #ifdef CACHE_BANK if (bank_cache == bank) { return 0; } #endif if (pixspi_regs_write(REG_BANK_SWITCH, &bank, 1)) { printf("Bank switch failed.\n"); return -1; } bank_cache = bank; return 0; } static int read_regs_w_bank(uint8_t bank, uint8_t addr, uint8_t *buff, uint16_t len) { if (bank_switch(bank)) { return -1; } return pixspi_regs_read(addr, buff, len); } static int write_regs_w_bank(uint8_t bank, uint8_t addr, uint8_t *buff, uint16_t len) { if (bank_switch(bank)) { return -1; } return pixspi_regs_write(addr, buff, len); } static int init_sensor(sensor_t *sensor) { #define ta_seq low_active_R_ABC_Avg_UBx50_T_BLACINV_EnHx1_T_SIG_REFx1 int arr_size = sizeof(ta_seq) / sizeof(ta_seq[0]); for (int i = 0; i < arr_size; i += 2) { #ifndef DEBUG int #endif init_res = pixspi_regs_write(ta_seq[i], &ta_seq[i + 1], 1); if (init_res) { return init_res; } } // Clear bank cache. bank_cache = -1; return 0; } //----------------------------------------------------------------- static int set_exposure(sensor_t *sensor, int exp_us, bool protected) { // 3642T static const uint32_t EXPOSURE_BASE = 3642 / (PAJ6100_XCLK_FREQ / 1000000.0f) + 0.5f; int ret; uint32_t cmd_expo /* 24-bit available */; uint16_t exp_offset; #ifdef DEBUG_AE printf("set_exposure() = %d\n", exp_us); #endif if (exp_us == 0) { return 0; } if (exp_us >= EXPOSURE_BASE) { int param; if (sensor->framesize == FRAMESIZE_QVGA) { param = 88803; } else if (sensor->framesize == FRAMESIZE_QQVGA) { param = 29139; // QQVGA } else { param = 88803; } int max_cmd_expo = R_FrameTime - param; cmd_expo = (exp_us - EXPOSURE_BASE) * ((float) PAJ6100_XCLK_FREQ / 1000000) + 0.5f; if (protected) { if (cmd_expo > max_cmd_expo) { cmd_expo = max_cmd_expo; exp_us = (cmd_expo + 3642) / ((float) PAJ6100_XCLK_FREQ / 1000000) + 0.5f; printf("Exposure time overflow, reset to %dus.\n", exp_us); } } exp_offset = 0; } else { cmd_expo = 0; exp_offset = (EXPOSURE_BASE - exp_us) * ((float) PAJ6100_XCLK_FREQ / 1000000) + 0.5; } #ifdef DEBUG_AE printf("target - cmd_exp: %ld, exp_offset: %d\n", cmd_expo, exp_offset); #endif uint8_t buff[3] = { (uint8_t) (cmd_expo & 0xff), (uint8_t) ((cmd_expo >> 8) & 0xff), (uint8_t) ((cmd_expo >> 16) & 0xff), }; ret = write_regs_w_bank(BANK_0, REG_CMD_EXPO_L, buff, 3); buff[0] = (uint8_t) (exp_offset & 0xff); buff[1] = (uint8_t) ((exp_offset >> 8) & 0xff); ret |= write_regs_w_bank(BANK_0, REG_EXP_OFFSET_L, buff, 2); buff[0] = 1; ret |= write_regs_w_bank(BANK_1, REG_ISP_UPDATE, buff, 1); if (ret) { printf("Failed to write cmd_expo or exp_offset.\n"); return -1; } exp_us_cache = exp_us; return ret; } static int get_exposure(sensor_t *sensor) { int ret; uint8_t buff[3] = {}; uint32_t cmd_expo /* 24-bit available */; uint16_t exp_offset; if (exp_us_cache >= 0) { return exp_us_cache; } ret = read_regs_w_bank(BANK_0, REG_CMD_EXPO_L, buff, 3); if (ret) { printf("Read cmd_expo failed.\n"); return -1; } cmd_expo = buff[0] + (((uint32_t) buff[1]) << 8) + (((uint32_t) buff[2]) << 16); ret = read_regs_w_bank(BANK_0, REG_EXP_OFFSET_L, buff, 2); if (ret) { printf("Read exp_offset failed.\n"); return -1; } exp_offset = buff[0] + (((uint16_t) buff[1]) << 8); #ifdef DEBUG_AE printf("cmd_exp: %ld, exp_offset: %d\n", cmd_expo, exp_offset); #endif if (exp_offset == 0) { exp_us_cache = (cmd_expo + 3642) / (PAJ6100_XCLK_FREQ / 1000000); } else { exp_us_cache = (3642 - exp_offset) / (PAJ6100_XCLK_FREQ / 1000000); } return exp_us_cache; } static void blc_freeze(bool enable) { uint8_t tmp; tmp = enable?2:0; write_regs_w_bank(0, 0x0E, &tmp, 1); tmp = 1; write_regs_w_bank(1, 0x00, &tmp, 1); // Update flag } static void auto_exposure(sensor_t *sensor) { if (!is_ae_enabled) { return; } if (skip_frame) { --skip_frame; return; } if ((lt_lockrange_in_lbound <= l_total) && (l_total <= lt_lockrange_in_ubound)) { ae_converged_flag = true; } else if ((l_total > lt_lockrange_out_ubound) || (l_total < lt_lockrange_out_lbound)) { ae_converged_flag = false; } blc_freeze(ae_converged_flag); if (ae_converged_flag == false) { float gain_db = 0; if (get_gain_db(sensor, &gain_db)) { printf("Get Gain DB failed.\n"); return; } uint32_t gain; if (gain_db < 6) { // 1x gain gain = 1; } else if (gain_db < 12) { // 2x gain gain = 2; } else if (gain_db < 18) { // 4x gain gain = 4; } else { // 8x gain gain = 8; } int expo = get_exposure(sensor); if (expo < 0) { printf("Get exposure failed.\n"); return; } #ifdef DEBUG_AE printf("Current Gain: %ldx, Expo: %d\n", gain, expo); #endif uint32_t GEP = gain * expo; float l_ratio = ((float) l_target_total) / l_total; float GEP_target = GEP * l_ratio; uint32_t expo_target = IM_MIN(IM_MAX(fast_roundf(GEP_target / R_AE_MinGain), R_AE_MinExpoTime), R_AE_MaxExpoTime); #ifdef DEBUG_AE printf("GEP: %ld ", GEP); printf("GEP_target: %d (x1000), L_Ratio: %d (x1000)\n", (int) (GEP_target * 1000), (int) (l_ratio * 1000)); printf("1st Expo Target: %ld (max: %ld) ", expo_target, R_AE_MaxExpoTime); #endif uint32_t gain_target; float tmp_gain = GEP_target / expo_target; if (tmp_gain <= 1) { gain_target = 1; } else if (tmp_gain <= 2) { gain_target = 2; } else if (tmp_gain <= 4) { gain_target = 4; } else { gain_target = 8; } //gain_target = IM_MIN(IM_MAX(fast_ceilf(GEP_target/expo_target), R_AE_MinGain), R_AE_MaxGain); gain_db = 20 * (fast_log((float) gain_target) / fast_log(10.0)); expo_target = IM_MIN(IM_MAX(fast_roundf(GEP_target / gain_target), R_AE_MinExpoTime), R_AE_MaxExpoTime); #ifdef DEBUG_AE printf("Gain Target: %ld (%d DB (x1000))\n", gain_target, (int) (gain_db * 1000)); printf("Final Expo Target: %ld (max: %ld) \n", expo_target, R_AE_MaxExpoTime); #endif set_exposure(sensor, expo_target, false); set_auto_gain(sensor, false, gain_db, 0); skip_frame = 0; } } //----------------------------------------------------------------- static int sleep(sensor_t *sensor, int enable) { int ret; uint8_t val; if (enable) { ret = read_regs_w_bank(BANK_1, REG_CMD_SENSOR_MODE, &val, 1); if (ret) { printf("Failed to read REG_CMD_SENSOR_MODE.\n"); return -1; } val |= (1 << 7); ret = write_regs_w_bank(BANK_1, REG_CMD_SENSOR_MODE, &val, 1); if (ret) { printf("Failed to write REG_CMD_SENSOR_MODE.\n"); return -1; } // Sleep 30ms mp_hal_delay_ms(30); ret = read_regs_w_bank(BANK_1, REG_CMD_LPM_ENH, &val, 1); if (ret) { printf("Failed to read REG_CMD_SENSOR_MODE.\n"); return -1; } val |= (1 << 6); ret = write_regs_w_bank(BANK_1, REG_CMD_LPM_ENH, &val, 1); if (ret) { printf("Failed to write REG_CMD_LPM_ENH.\n"); return -1; } } else { ret = read_regs_w_bank(BANK_1, REG_CMD_SENSOR_MODE, &val, 1); if (ret) { #ifdef DEBUG printf("Failed to read REG_CMD_SENSOR_MODE.\n"); #endif return -1; } val &= ~(1 << 7); val &= ~(1 << 6); ret = write_regs_w_bank(BANK_1, REG_CMD_SENSOR_MODE, &val, 1); if (ret) { #ifdef DEBUG printf("Failed to write REG_CMD_SENSOR_MODE.\n"); #endif return -1; } } return 0; } static int read_reg(sensor_t *sensor, uint16_t reg_addr) { uint8_t data; if (pixspi_regs_read((uint8_t) reg_addr, &data, 1)) { return -1; } return data; } static int write_reg(sensor_t *sensor, uint16_t reg_addr, uint16_t reg_data) { uint8_t data = reg_data; // Clear bank cache. bank_cache = -1; return pixspi_regs_write((uint8_t) reg_addr, &data, 1); } static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) { if (pixformat != PIXFORMAT_GRAYSCALE) { return -1; } return 0; } static int set_framesize(sensor_t *sensor, framesize_t framesize) { int ret = 0; uint16_t w = resolution[framesize][0]; uint16_t h = resolution[framesize][1]; uint8_t aavg_VnH, abc_start_line, voffset, abc_sample_size; ret |= read_regs_w_bank(BANK_0, REG_CMD_AAVG_V /* REG_CMD_AAVG_H */, &aavg_VnH, 1); ret |= read_regs_w_bank(BANK_0, REG_ABC_START_LINE, &abc_start_line, 1); ret |= read_regs_w_bank(BANK_1, REG_ABC_SAMPLE_SIZE, &abc_sample_size, 1); if (ret) { printf("Failed to read Average mode registers.\n"); return -1; } switch (framesize) { case FRAMESIZE_QVGA: aavg_VnH &= ~((1 << 3) | (1 << 2)); abc_start_line = (abc_start_line & ~(0x07 << 1)) | (2 << 1); voffset = 2; abc_sample_size = (abc_sample_size & ~(0x07)) | 6; R_AE_MaxExpoTime = CAL_MAX_EXPO_TIME(QVGA_MAX_EXPO_PA); break; case FRAMESIZE_QQVGA: aavg_VnH |= (1 << 3) | (1 << 2); abc_start_line = (abc_start_line & ~(0x07 << 1)) | (1 << 1); voffset = 1; abc_sample_size = (abc_sample_size & ~(0x07)) | 5; R_AE_MaxExpoTime = CAL_MAX_EXPO_TIME(QQVGA_MAX_EXPO_PA); break; default: printf("PAJ6100 only support QVGA & QQVGA now.\n"); return -1; } ret |= write_regs_w_bank(BANK_0, REG_CMD_AAVG_V /* REG_CMD_AAVG_H */, &aavg_VnH, 1); ret |= write_regs_w_bank(BANK_0, REG_ABC_START_LINE, &abc_start_line, 1); ret |= write_regs_w_bank(BANK_1, REG_CP_WOI_VOFFSET, &voffset, 1); ret |= write_regs_w_bank(BANK_1, REG_ABC_SAMPLE_SIZE, &abc_sample_size, 1); if (ret) { printf("Failed to write Average mode registers.\n"); return -1; } l_target_total = L_TARGET * w * h; lt_lockrange_in_ubound = (L_TARGET + AE_LOCK_RANGE_IN) * w * h; lt_lockrange_in_lbound = (L_TARGET - AE_LOCK_RANGE_IN) * w * h; lt_lockrange_out_ubound = (L_TARGET + AE_LOCK_RANGE_OUT) * w * h; lt_lockrange_out_lbound = (L_TARGET - AE_LOCK_RANGE_OUT) * w * h; return 0; } static int set_contrast(sensor_t *sensor, int level) { return 0; } static int set_brightness(sensor_t *sensor, int level) { return 0; } static int set_saturation(sensor_t *sensor, int level) { return 0; } static int set_gainceiling(sensor_t *sensor, gainceiling_t gainceiling) { return 0; } static int set_special_effect(sensor_t *sensor, sde_t sde) { return 0; } static int set_auto_gain(sensor_t *sensor, int enable, float gain_db, float gain_db_ceiling) { if (enable) { return 0; } int ret = 0; uint8_t val, fgh, ggh; if (gain_db < 6) { // 1x gain fgh = 0; ggh = 0; } else if (gain_db < 12) { // 2x gain fgh = 0; ggh = 1; } else if (gain_db < 18) { // 4x gain fgh = 2; ggh = 1; } else { // 8x gain fgh = 3; ggh = 1; } ret = read_regs_w_bank(BANK_0, REG_FGH, &val, 1); fgh = (val & ~(3 << 4)) | (fgh << 4); // fgh[5:4] = 0 ret |= read_regs_w_bank(BANK_0, REG_GGH, &val, 1); ggh = (val & ~(1 << 7)) | (ggh << 7); // ggh[7] = 1 if (ret) { printf("Failed to read FGH or GGH.\n"); } else { write_regs_w_bank(BANK_0, REG_FGH, &fgh, 1); write_regs_w_bank(BANK_0, REG_GGH, &ggh, 1); val = 1; write_regs_w_bank(BANK_1, REG_ISP_UPDATE, &val, 1); } return 0; } static int get_gain_db(sensor_t *sensor, float *gain_db) { int ret = 0; uint8_t val; uint8_t fgh, ggh; ret |= read_regs_w_bank(BANK_0, REG_FGH, &val, 1); fgh = (val >> 4) & 0x03; ret |= read_regs_w_bank(BANK_0, REG_GGH, &val, 1); ggh = (val >> 7) & 0x01; if (ret) { printf("Failed to read FGH or GGH.\n"); return -1; } if (ggh == 0 && fgh == 0) { *gain_db = 0; } else if (ggh == 1) { switch (fgh) { case 0: *gain_db = 6; break; case 2: *gain_db = 12; break; case 3: *gain_db = 18; break; default: { printf("Read a undefined FGH value (%d).\n", fgh); return -1; } } } return 0; } static int set_auto_exposure(sensor_t *sensor, int enable, int exposure_us) { if (enable) { is_ae_enabled = true; return 0; } else { is_ae_enabled = false; return set_exposure(sensor, exposure_us, false); } } static int get_exposure_us(sensor_t *sensor, int *exposure_us) { int ret = get_exposure(sensor); if (ret >= 0) { *exposure_us = ret; return 0; } return ret; } static int set_auto_whitebal(sensor_t *sensor, int enable, float r_gain_db, float g_gain_db, float b_gain_db) { return 0; } static int get_rgb_gain_db(sensor_t *sensor, float *r_gain_db, float *g_gain_db, float *b_gain_db) { return 0; } static int set_hmirror(sensor_t *sensor, int enable) { int ret; uint8_t val; ret = read_regs_w_bank(BANK_0, REG_CMD_HSYNC_INV, &val, 1); if (ret) { printf("Failed to read REG_CMD_HSYNC_INV.\n"); return -1; } val = enable == 1?val | (0x01):val & ~(0x01); ret = write_regs_w_bank(BANK_0, REG_CMD_HSYNC_INV, &val, 1); ret = write_regs_w_bank(BANK_1, REG_ISP_UPDATE, &val, 1); if (ret) { printf("Failed to write REG_CMD_HSYNC_INV.\n"); } return ret; } static int set_vflip(sensor_t *sensor, int enable) { int ret; uint8_t val; ret = read_regs_w_bank(BANK_0, REG_CMD_VSYNC_INV, &val, 1); if (ret) { printf("Failed to read REG_CMD_VSYNC_INV.\n"); return -1; } val = enable == 1?val | (0x01 << 1):val & ~(0x01 << 1); ret = write_regs_w_bank(BANK_0, REG_CMD_VSYNC_INV, &val, 1); ret = write_regs_w_bank(BANK_1, REG_ISP_UPDATE, &val, 1); if (ret) { printf("Failed to write REG_CMD_VSYNC_INV.\n"); } return ret; } static int set_lens_correction(sensor_t *sensor, int enable, int radi, int coef) { return 0; } static int reset(sensor_t *sensor) { int ret; bank_cache = -1; exp_us_cache = -1; #ifdef DEBUG uint8_t part_id_l = 0, part_id_h = 0; read_regs_w_bank(0, 0x00, &part_id_l, 1); read_regs_w_bank(0, 0x01, &part_id_h, 1); printf("Part ID 0x%x 0x%x\n", part_id_l, part_id_h); printf("init_res: %d\n", init_res); #endif // Re-init sensor every time. init_sensor(sensor); // Fetch default R_Frame_Time uint8_t buff[3] = {}; ret = read_regs_w_bank(BANK_0, REG_FRAME_TIME_L, buff, 3); if (ret) { printf("Read cmd_expo failed.\n"); } else { R_FrameTime = buff[0] + (((uint32_t) buff[1]) << 8) + (((uint32_t) buff[2]) << 16); } // Default Gain 2x uint8_t val, fgh, ggh; ret = read_regs_w_bank(BANK_0, REG_FGH, &val, 1); fgh = (val & ~(3 << 4)); // fgh[5:4] = 0 ret |= read_regs_w_bank(BANK_0, REG_GGH, &val, 1); ggh = (val & ~(1 << 7)) | (0x01 << 7); // ggh[7] = 1 if (ret) { printf("Failed to read FGH or GGH.\n"); } else { write_regs_w_bank(BANK_0, REG_FGH, &fgh, 1); write_regs_w_bank(BANK_0, REG_GGH, &ggh, 1); val = 1; write_regs_w_bank(BANK_1, REG_ISP_UPDATE, &val, 1); } return 0; } static int paj6100_snapshot(sensor_t *sensor, image_t *image, uint32_t flags) { int res = sensor_snapshot(sensor, image, flags); if (res == 0) { l_total = 0; int iml = image->h * image->w; for (int i = 0; i < iml; ++i) { l_total += image->data[i]; } // PAJ6100 doesn't support HW auto-exposure, // we provide a software implementation. auto_exposure(sensor); } return res; } int paj6100_init(sensor_t *sensor) { // Initialize sensor structure. sensor->reset = reset; sensor->sleep = sleep; sensor->read_reg = read_reg; sensor->write_reg = write_reg; sensor->set_pixformat = set_pixformat; sensor->set_framesize = set_framesize; sensor->set_contrast = set_contrast; sensor->set_brightness = set_brightness; sensor->set_saturation = set_saturation; sensor->set_gainceiling = set_gainceiling; sensor->set_auto_gain = set_auto_gain; sensor->get_gain_db = get_gain_db; sensor->set_auto_exposure = set_auto_exposure; sensor->get_exposure_us = get_exposure_us; sensor->set_auto_whitebal = set_auto_whitebal; sensor->get_rgb_gain_db = get_rgb_gain_db; sensor->set_hmirror = set_hmirror; sensor->set_vflip = set_vflip; sensor->set_special_effect = set_special_effect; sensor->set_lens_correction = set_lens_correction; sensor->snapshot = paj6100_snapshot; // Set sensor flags sensor->hw_flags.vsync = 1; sensor->hw_flags.hsync = 1; sensor->hw_flags.pixck = 1; sensor->hw_flags.fsync = 0; sensor->hw_flags.jpege = 0; sensor->hw_flags.gs_bpp = 1; init_sensor(sensor); return 0; } bool paj6100_detect(sensor_t *sensor) { int ret = 0; uint8_t part_id_l, part_id_h; omv_gpio_write(DCMI_RESET_PIN, 1); mp_hal_delay_ms(10); if (!pixspi_init()) { printf("Initial pixspi failed.\n"); return false; } ret |= pixspi_regs_read(0x00, &part_id_l, 1); ret |= pixspi_regs_read(0x01, &part_id_h, 1); #ifdef DEBUG printf("Part ID 0x%x 0x%x\n", part_id_l, part_id_h); #endif if (ret == 0 && (part_id_l == 0x00 && part_id_h == 0x61)) { return true; // Got you. } pixspi_release(); return false; } #endif //(OMV_ENABLE_PAJ6100 == 1)
bd7dae597e5574179104a1a1b863d7c6550deaf7
8551168c7b71c31eebad0f9b0c71eebbcc743000
/src/lib/profile.c
27dfd3fc04c3185d0866571b7c7768c8a5bf7543
[ "MIT" ]
permissive
n64decomp/perfect_dark
0db80e8ecba74741b959962e55c835a91c920f44
0235a971d6fb1a0d4421856d5a65aa8067bd4658
refs/heads/master
2023-08-31T04:27:53.864767
2023-08-29T11:36:58
2023-08-29T11:36:58
241,214,589
452
47
MIT
2023-08-21T08:53:40
2020-02-17T21:46:45
C
UTF-8
C
false
false
350
c
profile.c
#include <ultra64.h> #include "constants.h" #include "bss.h" #include "data.h" #include "types.h" void profileInit(void) { // empty } void profileTick(void) { // empty } void profileReset(void) { // empty } void profile00009a98(void) { // empty } void profileSetMarker(u32 value) { // empty } Gfx *profileRender(Gfx *gdl) { return gdl; }
640abb0079ad8eba04f6cabdeb231fa8b3bc53d6
cff4428975e403e4ef02d75498b78cd1a610a01a
/src/lib/core/fiber_pool.c
cdf067a7f70ca77f16798de089f41a9d6ba81335
[ "BSD-2-Clause" ]
permissive
tarantool/tarantool
c1f252b642d223af62485dc21165c7f7c3354e7e
f58cc96f2798ddc5f492223897d0b77e4f902128
refs/heads/master
2023-09-03T15:16:29.144171
2023-08-31T11:39:28
2023-09-01T12:39:29
911,980
3,205
490
NOASSERTION
2023-09-14T17:58:17
2010-09-15T07:59:26
Lua
UTF-8
C
false
false
6,205
c
fiber_pool.c
/* * Copyright 2010-2017, Tarantool AUTHORS, please see AUTHORS file. * * 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. * * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "fiber_pool.h" /** * Main function of the fiber invoked to handle all outstanding * tasks in a queue. */ static int fiber_pool_f(va_list ap) { struct fiber_pool *pool = va_arg(ap, struct fiber_pool *); struct cord *cord = cord(); struct fiber *f = fiber(); struct ev_loop *loop = pool->consumer; struct stailq *output = &pool->output; struct cmsg *msg; ev_tstamp last_active_at = ev_monotonic_now(loop); pool->size++; restart: msg = NULL; while (!stailq_empty(output) && !fiber_is_cancelled()) { msg = stailq_shift_entry(output, struct cmsg, fifo); if (f->caller == &cord->sched && ! stailq_empty(output) && ! rlist_empty(&pool->idle)) { /* * Activate a "backup" fiber for the next * message in the queue. */ f->caller = rlist_shift_entry(&pool->idle, struct fiber, state); f->caller->flags |= FIBER_IS_READY; assert(f->caller->caller == &cord->sched); } cmsg_deliver(msg); fiber_check_gc(); /* * Normally fibers die after their function * returns, and they call on_stop() triggers. The * pool optimization interferes into that logic * and a fiber doesn't die after its function * returns. But on_stop triggers still should be * called so that the pool wouldn't affect fiber's * visible lifecycle. */ fiber_on_stop(f); } /** Put the current fiber into a fiber cache. */ if (!fiber_is_cancelled() && (msg != NULL || ev_monotonic_now(loop) - last_active_at < pool->idle_timeout)) { if (msg != NULL) last_active_at = ev_monotonic_now(loop); /* * Add the fiber to the front of the list, so that * it is most likely to get scheduled again. */ f->flags |= FIBER_IS_IDLE; rlist_add_entry(&pool->idle, fiber(), state); fiber_yield(); f->flags &= ~FIBER_IS_IDLE; goto restart; } pool->size--; fiber_cond_signal(&pool->worker_cond); return 0; } static void fiber_pool_idle_cb(ev_loop *loop, struct ev_timer *watcher, int events) { (void) events; struct fiber_pool *pool = (struct fiber_pool *) watcher->data; if (! rlist_empty(&pool->idle)) { struct fiber *f; /* * Schedule the fiber at the tail of the list, * it's the one most likely to have not been * scheduled lately. */ f = rlist_shift_tail_entry(&pool->idle, struct fiber, state); fiber_call(f); } ev_timer_again(loop, watcher); } /** Create fibers to handle all outstanding tasks. */ static void fiber_pool_cb(ev_loop *loop, struct ev_watcher *watcher, int events) { (void) loop; (void) events; struct fiber_pool *pool = (struct fiber_pool *) watcher->data; /** Fetch messages */ cbus_endpoint_fetch(&pool->endpoint, &pool->output); struct stailq *output = &pool->output; while (! stailq_empty(output)) { struct fiber *f; if (! rlist_empty(&pool->idle)) { f = rlist_shift_entry(&pool->idle, struct fiber, state); fiber_call(f); } else if (pool->size < pool->max_size) { f = fiber_new(cord_name(cord()), fiber_pool_f); if (f == NULL) { diag_log(); break; } fiber_start(f, pool); } else { /** * No worries that this watcher may not * get scheduled again - there are enough * worker fibers already, so just leave. */ say_warn("fiber pool size %d reached on endpoint %s", pool->max_size, pool->endpoint.name); break; } } } void fiber_pool_set_max_size(struct fiber_pool *pool, int new_max_size) { pool->max_size = new_max_size; } void fiber_pool_create(struct fiber_pool *pool, const char *name, int max_pool_size, float idle_timeout) { pool->consumer = loop(); pool->idle_timeout = idle_timeout; rlist_create(&pool->idle); ev_timer_init(&pool->idle_timer, fiber_pool_idle_cb, 0, pool->idle_timeout); pool->idle_timer.data = pool; ev_timer_again(loop(), &pool->idle_timer); pool->size = 0; pool->max_size = max_pool_size; stailq_create(&pool->output); fiber_cond_create(&pool->worker_cond); /* Join fiber pool to cbus */ cbus_endpoint_create(&pool->endpoint, name, fiber_pool_cb, pool); } void fiber_pool_destroy(struct fiber_pool *pool) { /** Endpoint has connected pipes or unfetched messages */ cbus_endpoint_destroy(&pool->endpoint, NULL); /** * At this point all messages are started to execution because last * cbus poison message was fired (endpoint_destroy condition). * We won't to have new messages from cbus and can send wakeup * to each idle fiber. In this case idle fiber can not fetch any * new message and will exit. We adjust idle_timeout to. */ pool->idle_timeout = 0; struct fiber *idle_fiber; rlist_foreach_entry(idle_fiber, &pool->idle, state) fiber_wakeup(idle_fiber); /** * Just wait on fiber exit condition until all fibers are done */ while (pool->size > 0) fiber_cond_wait(&pool->worker_cond); fiber_cond_destroy(&pool->worker_cond); }
232810050bd5e51a53cee88ff8d48fee5a6d4aed
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_0016/AKWF_1516.h
d06d94d9341434a9d3451991728aa0b27b0fd9f5
[ "CC0-1.0" ]
permissive
KristofferKarlAxelEkstrand/AKWF-FREE
b2defa1a2d389d309be6dd2e9f968923daf80d1b
cf8171df36e9fec25416b5f568b72a6e2cb69194
refs/heads/master
2023-07-23T18:22:36.939705
2023-07-10T17:14:40
2023-07-10T17:14:40
145,817,187
359
59
CC0-1.0
2023-07-10T17:14:41
2018-08-23T07:26:56
null
UTF-8
C
false
false
4,672
h
AKWF_1516.h
/* Adventure Kid Waveforms (AKWF) converted for use with Teensy Audio Library * * Adventure Kid Waveforms(AKWF) Open waveforms library * https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/ * * This code is in the public domain, CC0 1.0 Universal (CC0 1.0) * https://creativecommons.org/publicdomain/zero/1.0/ * * Converted by Brad Roy, https://github.com/prosper00 */ /* AKWF_1516 256 samples +-----------------------------------------------------------------------------------------------------------------+ | ** ** | | * * | | ****************** *** | | * * | | * * | |******* * | |* ** | | ***** | | ** *| | * *******| | * * | | * * | | *** ****************** | | * * | | ** ** | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_1516 [] = { 36478, 38784, 40007, 40518, 40239, 40418, 40305, 40367, 40345, 40334, 40370, 40317, 40378, 40322, 40352, 40388, 40176, 42377, 44284, 50768, 52474, 52210, 52731, 52284, 52675, 52330, 52635, 52367, 52600, 52402, 52567, 52432, 52540, 52454, 52521, 52468, 52522, 52388, 51851, 51906, 51863, 51896, 51876, 51878, 51898, 51851, 51932, 51810, 51982, 51750, 52055, 51655, 52188, 51441, 52731, 53726, 58174, 64019, 64493, 65535, 65303, 65535, 65441, 65535, 65507, 65535, 65535, 65512, 65535, 65495, 65535, 65486, 65535, 65484, 65535, 65483, 65535, 65487, 65535, 65490, 65535, 65493, 65535, 65495, 65535, 65497, 65535, 65498, 65535, 65499, 65535, 65503, 65535, 65508, 65535, 65516, 65535, 65530, 65532, 65535, 65510, 65535, 65482, 65535, 65447, 65535, 65403, 65535, 65346, 65535, 65260, 65535, 65067, 65535, 63001, 59505, 54847, 50868, 52693, 50958, 53389, 44052, 36398, 34408, 31990, 33306, 32362, 33076, 32542, 32911, 32721, 32679, 33129, 29905, 27433, 15998, 12794, 14235, 13152, 14231, 7879, 5107, 319, 0, 118, 0, 115, 0, 119, 0, 118, 1, 113, 0, 104, 1, 90, 0, 76, 0, 61, 1, 47, 0, 35, 0, 24, 0, 16, 0, 9, 0, 4, 3, 0, 8, 0, 15, 0, 26, 0, 38, 0, 54, 0, 71, 0, 92, 0, 115, 0, 137, 0, 158, 0, 176, 0, 164, 1152, 3228, 10158, 12067, 13670, 13724, 13556, 13762, 13545, 13762, 13551, 13750, 13567, 13732, 13586, 13712, 13605, 13696, 13616, 13702, 13499, 12992, 13085, 13008, 13080, 13011, 13071, 13023, 13055, 13046, 13025, 13085, 12976, 13148, 12894, 13262, 12721, 13618, 12834, 17721, 22466, 24016, 25661, 24892, 25396, 25039, 25300, 25106, 25253, 25136, 25237, 25139, 25253, 25100, 25332, 24921, 26217, 27184, };
2e573b07f1fae814aa1edb69dca1ec66fe3a028a
f367e4b66a1ee42e85830b31df88f63723c36a47
/lib/librdkafka-2.1.0/src/rdkafka_topic.h
cbed9308a7a517b4da987781e36afc21847864fb
[ "Apache-2.0", "BSD-2-Clause", "MIT", "BSD-3-Clause", "Zlib", "LicenseRef-scancode-public-domain", "ISC", "LicenseRef-scancode-public-domain-disclaimer" ]
permissive
fluent/fluent-bit
06873e441162b92941024e9a7e9e8fc934150bf7
1a41f49dc2f3ae31a780caa9ffd6137b1d703065
refs/heads/master
2023-09-05T13:44:55.347372
2023-09-05T10:14:33
2023-09-05T10:14:33
29,933,948
4,907
1,565
Apache-2.0
2023-09-14T10:17:02
2015-01-27T20:41:52
C
UTF-8
C
false
false
12,168
h
rdkafka_topic.h
/* * librdkafka - Apache Kafka C library * * Copyright (c) 2012,2013 Magnus Edenhill * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _RDKAFKA_TOPIC_H_ #define _RDKAFKA_TOPIC_H_ #include "rdlist.h" extern const char *rd_kafka_topic_state_names[]; /** * @struct Light-weight topic object which only contains the topic name. * * For use in outgoing APIs (like rd_kafka_message_t) when there is * no proper topic object available. * * @remark lrkt_magic[4] MUST be the first field and be set to "LRKT". */ struct rd_kafka_lwtopic_s { char lrkt_magic[4]; /**< "LRKT" */ rd_kafka_t *lrkt_rk; /**< Pointer to the client instance. */ rd_refcnt_t lrkt_refcnt; /**< Refcount */ char *lrkt_topic; /**< Points past this struct, allocated * along with the struct. */ }; /** Casts a topic_t to a light-weight lwtopic_t */ #define rd_kafka_rkt_lw(rkt) ((rd_kafka_lwtopic_t *)rkt) #define rd_kafka_rkt_lw_const(rkt) ((const rd_kafka_lwtopic_t *)rkt) /** * @returns true if the topic object is a light-weight topic, else false. */ static RD_UNUSED RD_INLINE rd_bool_t rd_kafka_rkt_is_lw(const rd_kafka_topic_t *app_rkt) { const rd_kafka_lwtopic_t *lrkt = rd_kafka_rkt_lw_const(app_rkt); return !memcmp(lrkt->lrkt_magic, "LRKT", 4); } /** @returns the lwtopic_t if \p rkt is a light-weight topic, else NULL. */ static RD_UNUSED RD_INLINE rd_kafka_lwtopic_t * rd_kafka_rkt_get_lw(rd_kafka_topic_t *rkt) { if (rd_kafka_rkt_is_lw(rkt)) return rd_kafka_rkt_lw(rkt); return NULL; } void rd_kafka_lwtopic_destroy(rd_kafka_lwtopic_t *lrkt); rd_kafka_lwtopic_t *rd_kafka_lwtopic_new(rd_kafka_t *rk, const char *topic); static RD_UNUSED RD_INLINE void rd_kafka_lwtopic_keep(rd_kafka_lwtopic_t *lrkt) { rd_refcnt_add(&lrkt->lrkt_refcnt); } /** * @struct Holds partition + transactional PID + base sequence msgid. * * Used in rkt_saved_partmsgids to restore transactional/idempotency state * for a partition that is lost from metadata for some time and then returns. */ typedef struct rd_kafka_partition_msgid_s { TAILQ_ENTRY(rd_kafka_partition_msgid_s) link; int32_t partition; rd_kafka_pid_t pid; uint64_t msgid; uint64_t epoch_base_msgid; rd_ts_t ts; } rd_kafka_partition_msgid_t; /** * @struct Aux struct that holds a partition id and a leader epoch. * Used as temporary holding space for per-partition leader epochs * while parsing MetadataResponse. */ typedef struct rd_kafka_partition_leader_epoch_s { int32_t partition_id; int32_t leader_epoch; } rd_kafka_partition_leader_epoch_t; /* * @struct Internal representation of a topic. * * @remark rkt_magic[4] MUST be the first field and be set to "IRKT". */ struct rd_kafka_topic_s { char rkt_magic[4]; /**< "IRKT" */ TAILQ_ENTRY(rd_kafka_topic_s) rkt_link; rd_refcnt_t rkt_refcnt; rwlock_t rkt_lock; rd_kafkap_str_t *rkt_topic; rd_kafka_toppar_t *rkt_ua; /**< Unassigned partition (-1) */ rd_kafka_toppar_t **rkt_p; /**< Partition array */ int32_t rkt_partition_cnt; int32_t rkt_sticky_partition; /**< Current sticky partition. * @locks rkt_lock */ rd_interval_t rkt_sticky_intvl; /**< Interval to assign new * sticky partition. */ rd_list_t rkt_desp; /* Desired partitions * that are not yet seen * in the cluster. */ rd_interval_t rkt_desp_refresh_intvl; /**< Rate-limiter for * desired partition * metadata refresh. */ rd_ts_t rkt_ts_create; /**< Topic object creation time. */ rd_ts_t rkt_ts_metadata; /* Timestamp of last metadata * update for this topic. */ rd_refcnt_t rkt_app_refcnt; /**< Number of active rkt's new()ed * by application. */ enum { RD_KAFKA_TOPIC_S_UNKNOWN, /* No cluster information yet */ RD_KAFKA_TOPIC_S_EXISTS, /* Topic exists in cluster */ RD_KAFKA_TOPIC_S_NOTEXISTS, /* Topic is not known in cluster */ RD_KAFKA_TOPIC_S_ERROR, /* Topic exists but is in an errored * state, such as auth failure. */ } rkt_state; int rkt_flags; #define RD_KAFKA_TOPIC_F_LEADER_UNAVAIL \ 0x1 /* Leader lost/unavailable \ * for at least one partition. */ rd_kafka_resp_err_t rkt_err; /**< Permanent error. */ rd_kafka_t *rkt_rk; rd_avg_t rkt_avg_batchsize; /**< Average batch size */ rd_avg_t rkt_avg_batchcnt; /**< Average batch message count */ rd_kafka_topic_conf_t rkt_conf; /** Idempotent/Txn producer: * The PID,Epoch,base Msgid state for removed partitions. */ TAILQ_HEAD(, rd_kafka_partition_msgid_s) rkt_saved_partmsgids; }; #define rd_kafka_topic_rdlock(rkt) rwlock_rdlock(&(rkt)->rkt_lock) #define rd_kafka_topic_wrlock(rkt) rwlock_wrlock(&(rkt)->rkt_lock) #define rd_kafka_topic_rdunlock(rkt) rwlock_rdunlock(&(rkt)->rkt_lock) #define rd_kafka_topic_wrunlock(rkt) rwlock_wrunlock(&(rkt)->rkt_lock) /** * @brief Increase refcount and return topic object. */ static RD_INLINE RD_UNUSED rd_kafka_topic_t * rd_kafka_topic_keep(rd_kafka_topic_t *rkt) { rd_kafka_lwtopic_t *lrkt; if (unlikely((lrkt = rd_kafka_rkt_get_lw(rkt)) != NULL)) rd_kafka_lwtopic_keep(lrkt); else rd_refcnt_add(&rkt->rkt_refcnt); return rkt; } void rd_kafka_topic_destroy_final(rd_kafka_topic_t *rkt); rd_kafka_topic_t *rd_kafka_topic_proper(rd_kafka_topic_t *app_rkt); /** * @brief Loose reference to topic object as increased by ..topic_keep(). */ static RD_INLINE RD_UNUSED void rd_kafka_topic_destroy0(rd_kafka_topic_t *rkt) { rd_kafka_lwtopic_t *lrkt; if (unlikely((lrkt = rd_kafka_rkt_get_lw(rkt)) != NULL)) rd_kafka_lwtopic_destroy(lrkt); else if (unlikely(rd_refcnt_sub(&rkt->rkt_refcnt) == 0)) rd_kafka_topic_destroy_final(rkt); } rd_kafka_topic_t *rd_kafka_topic_new0(rd_kafka_t *rk, const char *topic, rd_kafka_topic_conf_t *conf, int *existing, int do_lock); rd_kafka_topic_t *rd_kafka_topic_find_fl(const char *func, int line, rd_kafka_t *rk, const char *topic, int do_lock); rd_kafka_topic_t *rd_kafka_topic_find0_fl(const char *func, int line, rd_kafka_t *rk, const rd_kafkap_str_t *topic); #define rd_kafka_topic_find(rk, topic, do_lock) \ rd_kafka_topic_find_fl(__FUNCTION__, __LINE__, rk, topic, do_lock) #define rd_kafka_topic_find0(rk, topic) \ rd_kafka_topic_find0_fl(__FUNCTION__, __LINE__, rk, topic) int rd_kafka_topic_cmp_rkt(const void *_a, const void *_b); void rd_kafka_topic_partitions_remove(rd_kafka_topic_t *rkt); rd_bool_t rd_kafka_topic_set_notexists(rd_kafka_topic_t *rkt, rd_kafka_resp_err_t err); rd_bool_t rd_kafka_topic_set_error(rd_kafka_topic_t *rkt, rd_kafka_resp_err_t err); /** * @returns the topic's permanent error, if any. * * @locality any * @locks_acquired rd_kafka_topic_rdlock(rkt) */ static RD_INLINE RD_UNUSED rd_kafka_resp_err_t rd_kafka_topic_get_error(rd_kafka_topic_t *rkt) { rd_kafka_resp_err_t err = RD_KAFKA_RESP_ERR_NO_ERROR; rd_kafka_topic_rdlock(rkt); if (rkt->rkt_state == RD_KAFKA_TOPIC_S_ERROR) err = rkt->rkt_err; rd_kafka_topic_rdunlock(rkt); return err; } int rd_kafka_topic_metadata_update2( rd_kafka_broker_t *rkb, const struct rd_kafka_metadata_topic *mdt, const rd_kafka_partition_leader_epoch_t *leader_epochs); void rd_kafka_topic_scan_all(rd_kafka_t *rk, rd_ts_t now); typedef struct rd_kafka_topic_info_s { const char *topic; /**< Allocated along with struct */ int partition_cnt; } rd_kafka_topic_info_t; int rd_kafka_topic_info_topic_cmp(const void *_a, const void *_b); int rd_kafka_topic_info_cmp(const void *_a, const void *_b); rd_kafka_topic_info_t *rd_kafka_topic_info_new(const char *topic, int partition_cnt); void rd_kafka_topic_info_destroy(rd_kafka_topic_info_t *ti); int rd_kafka_topic_match(rd_kafka_t *rk, const char *pattern, const char *topic); int rd_kafka_toppar_broker_update(rd_kafka_toppar_t *rktp, int32_t broker_id, rd_kafka_broker_t *rkb, const char *reason); int rd_kafka_toppar_delegate_to_leader(rd_kafka_toppar_t *rktp); rd_kafka_resp_err_t rd_kafka_topics_leader_query_sync(rd_kafka_t *rk, int all_topics, const rd_list_t *topics, int timeout_ms); void rd_kafka_topic_leader_query0(rd_kafka_t *rk, rd_kafka_topic_t *rkt, int do_rk_lock, rd_bool_t force); #define rd_kafka_topic_leader_query(rk, rkt) \ rd_kafka_topic_leader_query0(rk, rkt, 1 /*lock*/, \ rd_false /*dont force*/) #define rd_kafka_topic_fast_leader_query(rk) \ rd_kafka_metadata_fast_leader_query(rk) void rd_kafka_local_topics_to_list(rd_kafka_t *rk, rd_list_t *topics, int *cache_cntp); void rd_ut_kafka_topic_set_topic_exists(rd_kafka_topic_t *rkt, int partition_cnt, int32_t leader_id); #endif /* _RDKAFKA_TOPIC_H_ */
899de068bcc0b17ad54bd7e2f268ed38525a5535
61da6274995cf914291af51bd02e60f408fdfedd
/src/nlops/zhyperbolic.c
06567f62b6b3c205b4938a9234a28f35e260e30c
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
mrirecon/bart
360d518b4c79836d506803aa4a77e8e252ab820b
a3c9dc313f79c4c52f1ba3e617d5831ef088ddf7
refs/heads/master
2023-08-31T11:01:08.932824
2023-08-30T12:15:35
2023-08-30T13:51:18
23,212,230
264
185
BSD-3-Clause
2023-08-03T18:43:36
2014-08-22T03:57:09
C
UTF-8
C
false
false
1,637
c
zhyperbolic.c
/* Copyright 2021. Uecker Lab. University Medical Center Göttingen. * All rights reserved. Use of this source code is governed by * a BSD-style license which can be found in the LICENSE file. * * Authors: Moritz Blumenthal */ #include <complex.h> #include "misc/types.h" #include "misc/misc.h" #include "num/multind.h" #include "num/flpmath.h" #include "nlops/nlop.h" #include "nlops/nlop_jacobian.h" #include "zhyperbolic.h" struct zsinh_s { INTERFACE(nlop_data_t); }; DEF_TYPEID(zsinh_s); static void zsinh_free(const nlop_data_t* _data) { xfree(_data); } static void zsinh_apply(const nlop_data_t* _data, int N, const long dims[N], complex float* dst, const complex float* src, complex float* der) { UNUSED(_data); if (NULL != der) md_zcosh(N, dims, der, src); md_zsinh(N, dims, dst, src); } struct nlop_s* nlop_zsinh_create(int N, const long dims[N]) { PTR_ALLOC(struct zsinh_s, data); SET_TYPEID(zsinh_s, data); return nlop_zdiag_create(N, dims, CAST_UP(PTR_PASS(data)), zsinh_apply, zsinh_free); } struct zcosh_s { INTERFACE(nlop_data_t); }; DEF_TYPEID(zcosh_s); static void zcosh_free(const nlop_data_t* _data) { xfree(_data); } static void zcosh_apply(const nlop_data_t* _data, int N, const long dims[N], complex float* dst, const complex float* src, complex float* der) { UNUSED(_data); if (NULL != der) md_zsinh(N, dims, der, src); md_zcosh(N, dims, dst, src); } struct nlop_s* nlop_zcosh_create(int N, const long dims[N]) { PTR_ALLOC(struct zcosh_s, data); SET_TYPEID(zcosh_s, data); return nlop_zdiag_create(N, dims, CAST_UP(PTR_PASS(data)), zcosh_apply, zcosh_free); }
3d7716050f63d03142ed4a00c14a5622223e5d7f
8380b5eb12e24692e97480bfa8939a199d067bce
/Carberp Botnet/source - absource/pro/all source/bootkit/KipLib/raslink.h
73a001b0a065e54cf711b4cbdfc598d8f21a7439
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
RamadhanAmizudin/malware
788ee745b5bb23b980005c2af08f6cb8763981c2
62d0035db6bc9aa279b7c60250d439825ae65e41
refs/heads/master
2023-02-05T13:37:18.909646
2023-01-26T08:43:18
2023-01-26T08:43:18
53,407,812
873
291
null
2023-01-26T08:43:19
2016-03-08T11:44:21
C++
UTF-8
C
false
false
691
h
raslink.h
#ifndef _RAS_LINK_H_ #define _RAS_LINK_H_ BOOL WAN_CheckForContext ( IN PKIP_NDIS_ADAPTER pAdapter, IN PCHAR pProtoContext ); NDIS_STATUS WAN_AddRasLink ( IN PKIP_NDIS_ADAPTER pAdapter, IN PNDIS_WAN_LINE_UP pWanLineUp ); VOID WAN_RemoveRasLink ( IN PKIP_NDIS_ADAPTER pAdapter, IN PNDIS_WAN_LINE_DOWN pWanLineDown ); VOID WAN_RemoveAllLinks ( IN PKIP_NDIS_ADAPTER pAdapter ); VOID WAN_WwanActivated ( IN PKIP_NDIS_ADAPTER pAdapter, IN PNDIS_WWAN_CONTEXT_STATE ContextState ); VOID WAN_WwanDeactivated ( IN PKIP_NDIS_ADAPTER pAdapter, IN PNDIS_WWAN_CONTEXT_STATE ContextState ); #endif //_RAS_LINK_H_
6bb5e1f957f4f8132b21607ff0da0cd46616754a
7f6c235b0598353549959c18f69eefd20b766907
/libsrc/_DEVELOPMENT/EXAMPLES/sms/AstroForce/src/introsideplayer.h
d1fb602bc6246fcbc3d32165a0e0fd12e5b6c09f
[ "ClArtistic" ]
permissive
z88dk/z88dk
46dfd4905f36d99333173cadd0a660839befc9f0
8b07f37cc43c5d9ffe69b563c80763491d8faff7
refs/heads/master
2023-09-04T19:29:49.254958
2023-09-03T20:51:24
2023-09-03T20:51:24
54,035,569
820
263
NOASSERTION
2023-09-05T11:09:04
2016-03-16T13:48:16
Assembly
UTF-8
C
false
false
574
h
introsideplayer.h
void InitIntroSidePlayer(enemy *en) { en->enemyparama=en->enemyposx; } unsigned char UpdateIntroSidePlayer(enemy *en) { unsigned int a; // Player DrawQuadSprite(en->enemyposx,en->enemyposy,INTROSIDEPLAYERBASE); // Propulsion SMS_addSprite(en->enemyposx-8,en->enemyposy+4,INTROSIDEPLAYERBASE+4+((stageframe>>2)%2)); // Updating a=en->enemyparama==0?752:910; if(stageframe<a) { a-=stageframe; if(en->enemyposx<128)en->enemyposx++; en->enemyposy=72+((sinus(a)*3)>>4); } else { en->enemyposx+=4; if(en->enemyposx>240)return 0; } return 1; }
de1bc8dbb825527baf389e4dee7965abd6468b44
7664f318ed04bd0680f3d82321c18896e3ef6ad5
/src/overlays/actors/ovl_En_Skb/z_en_skb.h
216b5848ccd1f67ecfa67152a1d2e7125c6bbd3a
[]
no_license
zeldaret/oot
9c80ce17f2d8fd61514b375f92ee4739b5ce9d4e
2875ab4fcf5c5f81d76353d1ee0024c9ea8d0b23
refs/heads/master
2023-08-29T05:29:31.356427
2023-08-28T22:48:52
2023-08-28T22:48:52
247,875,738
4,401
802
null
2023-09-14T13:34:38
2020-03-17T04:02:19
C
UTF-8
C
false
false
719
h
z_en_skb.h
#ifndef Z_EN_SKB_H #define Z_EN_SKB_H #include "ultra64.h" #include "global.h" struct EnSkb; typedef void (*EnSkbActionFunc)(struct EnSkb*, PlayState*); typedef struct EnSkb { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; /* 0x0190 */ Vec3s jointTable[20]; /* 0x0208 */ Vec3s morphTable[20]; /* 0x0280 */ u8 actionState; /* 0x0281 */ u8 setColliderAT; /* 0x0282 */ u8 lastDamageEffect; /* 0x0283 */ u8 breakFlags; /* 0x0284 */ EnSkbActionFunc actionFunc; /* 0x0288 */ s16 headlessYawOffset; /* 0x028C */ BodyBreak bodyBreak; /* 0x02A4 */ ColliderJntSph collider; /* 0x02C4 */ ColliderJntSphElement colliderItem[2]; } EnSkb; // size = 0x0344 #endif
3e48f1eb16b501052e2f6d61c1e651c5868beeb3
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/powerpc/boot/stdlib.h
1bf01ac73aba15119cf654e0a21092bea5f482b1
[ "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
137
h
stdlib.h
#ifndef _PPC_BOOT_STDLIB_H_ #define _PPC_BOOT_STDLIB_H_ unsigned long long int strtoull(const char *ptr, char **end, int base); #endif
aae0ac5579b895cfc75194a810e98f72bf68b62e
01bcef56ade123623725ca78d233ac8653a91ece
/engine/cl_demosmoothing.h
5b0a0725412882032077b3211cc488a7c09c4fbe
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
SwagSoftware/Kisak-Strike
1085ba3c6003e622dac5ebc0c9424cb16ef58467
4c2fdc31432b4f5b911546c8c0d499a9cff68a85
refs/heads/master
2023-09-01T02:06:59.187775
2022-09-05T00:51:46
2022-09-05T00:51:46
266,676,410
921
123
null
2022-10-01T16:26:41
2020-05-25T03:41:35
C++
WINDOWS-1252
C
false
false
441
h
cl_demosmoothing.h
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: // // $NoKeywords: $ //=============================================================================// #ifndef CL_DEMOSMOOTHING_H #define CL_DEMOSMOOTHING_H #ifdef _WIN32 #pragma once #endif #include "mathlib/vector.h" #include "quakedef.h" #include "tier0/platform.h" #include "demofile/demoformat.h" #endif // CL_DEMOSMOOTHING_H
fb2eb4ce34dd608b58215fe9232e5f6fe3185679
bb38c44037a99d0a12a12d92059678f2faebbc80
/src/include/gtm/utils/register.h
e41635d367d417fad9f4015d76278feee0b5e0b8
[ "LicenseRef-scancode-mulanpsl-2.0-en", "LicenseRef-scancode-unknown-license-reference", "PostgreSQL", "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-unicode", "LicenseRef-scancode-warranty-disclaimer", "curl", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LGPL-2.1-only", "CC-BY-4.0", "LicenseRef-scancode-protobuf", "OpenSSL", "LicenseRef-scancode-generic-export-compliance", "X11-distribute-modifications-variant", "LicenseRef-scancode-other-permissive", "MIT", "NCSA", "Python-2.0", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "CC-BY-3.0", "LicenseRef-scancode-other-copyleft", "GPL-2.0-only", "BSL-1.0", "Apache-2.0", "LGPL-2.0-only", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Zlib" ]
permissive
opengauss-mirror/openGauss-server
a9c5a62908643492347830826c56da49f0942796
310e84631c68c8bf37b004148b66f94064f701e4
refs/heads/master
2023-07-26T19:29:12.495484
2023-07-17T12:23:32
2023-07-17T12:23:32
276,117,477
591
208
MulanPSL-2.0
2023-04-28T12:30:18
2020-06-30T14:08:59
C++
UTF-8
C
false
false
3,190
h
register.h
/* ------------------------------------------------------------------------- * * register.h * * * Portions Copyright (c) 2020 Huawei Technologies Co.,Ltd. * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 2010-2012 Postgres-XC Development Group * * $PostgreSQL$ * * ------------------------------------------------------------------------- */ #ifndef GTM_REGISTER_H #define GTM_REGISTER_H #include "gtm/utils/libpq-be.h" #include "gtm/gtm_c.h" #include "gtm/gtm_lock.h" #include "gtm/gtm_list.h" #include "gtm/utils/stringinfo.h" /* * This structure represents the data that is saved each time a openGauss node * registered on GTM. * It contains: * - Type of the Node: Proxy, Coordinator, Datanode * - Node number * - Proxy number: This ID number is set at 0 if node does not go through a Proxy * or if Node Type is Proxy * - openGauss port the node uses to communicate * - IP visible to GTM * - Data folder of the node */ typedef enum GTM_PGXCNodeStatus { NODE_CONNECTED, NODE_DISCONNECTED } GTM_PGXCNodeStatus; typedef struct GTM_PGXCNodeInfo { GTM_PGXCNodeType type; /* Type of node */ char* nodename; /* Node Name */ char* proxyname; /* Proxy name the node goes through */ GTM_PGXCNodePort port; /* Port number of the node */ char* ipaddress; /* IP address of the nodes */ char* datafolder; /* Data folder of the node */ GTM_PGXCNodeStatus status; /* Node status */ GTM_RWLock node_lock; /* Lock on this structure */ int socket; /* socket number used for registration */ uint32 timeline; /* Timeline for node (restart times) */ } GTM_PGXCNodeInfo; /* Maximum number of nodes that can be registered */ #define MAX_NODES 1024 size_t pgxcnode_find_by_type(GTM_PGXCNodeType type, GTM_PGXCNodeInfo** data, size_t maxlen); int Recovery_PGXCNodeRegister(GTM_PGXCNodeType type, char* nodename, GTM_PGXCNodePort port, char* proxyname, GTM_PGXCNodeStatus status, char* ipaddress, char* datafolder, bool in_recovery, int socket, uint32 timeline); int Recovery_PGXCNodeUnregister(GTM_PGXCNodeType type, const char* node_name, bool in_recovery, int socket); int Recovery_PGXCNodeBackendDisconnect(GTM_PGXCNodeType type, const char* nodename, int socket); void Recovery_RecordRegisterInfo(GTM_PGXCNodeInfo* nodeinfo, bool is_register); void Recovery_SaveRegisterInfo(void); void Recovery_PGXCNodeDisconnect(Port* myport); void Recovery_SaveRegisterFileName(const char* dir); void ProcessPGXCNodeRegister(Port* myport, StringInfo message, bool is_backup); void ProcessPGXCNodeUnregister(Port* myport, StringInfo message, bool is_backup); void ProcessPGXCNodeBackendDisconnect(Port* myport, StringInfo message); void ProcessPGXCNodeList(Port* myport, StringInfo message); void ProcessGTMBeginBackup(Port* myport, StringInfo message); void ProcessGTMEndBackup(Port* myport, StringInfo message); void RemoveGTMNodes(void); char* Recovery_GetRegisterFileName(void); void Recovery_RegisterFileLock(void); #endif /* GTM_NODE_H */
b741bd710da0656b797f1282cabf39853ac3cf14
b970e053302588f44ee1c6b7187c4769934c857f
/ajax/libs/openlayers/5.0.0-beta.14/reproj.js
f4665360149c90de5fc24aa187e49a8556173ed1
[ "MIT" ]
permissive
cdnjs/cdnjs
2fe0f21477c08618fe609da844f5d133224c3eda
6843ffa5339e4595b3a6893ae3e9ede1117cc5f9
refs/heads/master
2023-07-23T14:52:44.587645
2023-07-23T07:12:24
2023-07-23T07:12:24
1,409,811
8,894
5,633
MIT
2023-06-27T12:32:50
2011-02-25T05:53:47
null
UTF-8
C
false
false
9,067
js
reproj.js
/** * @module ol/reproj */ import {createCanvasContext2D} from './dom.js'; import {containsCoordinate, createEmpty, extend, getHeight, getTopLeft, getWidth} from './extent.js'; import {solveLinearSystem} from './math.js'; import {getPointResolution, transform} from './proj.js'; /** * Calculates ideal resolution to use from the source in order to achieve * pixel mapping as close as possible to 1:1 during reprojection. * The resolution is calculated regardless of what resolutions * are actually available in the dataset (TileGrid, Image, ...). * * @param {module:ol/proj/Projection} sourceProj Source projection. * @param {module:ol/proj/Projection} targetProj Target projection. * @param {module:ol/coordinate~Coordinate} targetCenter Target center. * @param {number} targetResolution Target resolution. * @return {number} The best resolution to use. Can be +-Infinity, NaN or 0. */ export function calculateSourceResolution(sourceProj, targetProj, targetCenter, targetResolution) { const sourceCenter = transform(targetCenter, targetProj, sourceProj); // calculate the ideal resolution of the source data let sourceResolution = getPointResolution(targetProj, targetResolution, targetCenter); const targetMetersPerUnit = targetProj.getMetersPerUnit(); if (targetMetersPerUnit !== undefined) { sourceResolution *= targetMetersPerUnit; } const sourceMetersPerUnit = sourceProj.getMetersPerUnit(); if (sourceMetersPerUnit !== undefined) { sourceResolution /= sourceMetersPerUnit; } // Based on the projection properties, the point resolution at the specified // coordinates may be slightly different. We need to reverse-compensate this // in order to achieve optimal results. const sourceExtent = sourceProj.getExtent(); if (!sourceExtent || containsCoordinate(sourceExtent, sourceCenter)) { const compensationFactor = getPointResolution(sourceProj, sourceResolution, sourceCenter) / sourceResolution; if (isFinite(compensationFactor) && compensationFactor > 0) { sourceResolution /= compensationFactor; } } return sourceResolution; } /** * Enlarge the clipping triangle point by 1 pixel to ensure the edges overlap * in order to mask gaps caused by antialiasing. * * @param {number} centroidX Centroid of the triangle (x coordinate in pixels). * @param {number} centroidY Centroid of the triangle (y coordinate in pixels). * @param {number} x X coordinate of the point (in pixels). * @param {number} y Y coordinate of the point (in pixels). * @return {module:ol/coordinate~Coordinate} New point 1 px farther from the centroid. */ function enlargeClipPoint(centroidX, centroidY, x, y) { const dX = x - centroidX; const dY = y - centroidY; const distance = Math.sqrt(dX * dX + dY * dY); return [Math.round(x + dX / distance), Math.round(y + dY / distance)]; } /** * Renders the source data into new canvas based on the triangulation. * * @param {number} width Width of the canvas. * @param {number} height Height of the canvas. * @param {number} pixelRatio Pixel ratio. * @param {number} sourceResolution Source resolution. * @param {module:ol/extent~Extent} sourceExtent Extent of the data source. * @param {number} targetResolution Target resolution. * @param {module:ol/extent~Extent} targetExtent Target extent. * @param {module:ol/reproj/Triangulation} triangulation * Calculated triangulation. * @param {Array.<{extent: module:ol/extent~Extent, * image: (HTMLCanvasElement|Image|HTMLVideoElement)}>} sources * Array of sources. * @param {number} gutter Gutter of the sources. * @param {boolean=} opt_renderEdges Render reprojection edges. * @return {HTMLCanvasElement} Canvas with reprojected data. */ export function render(width, height, pixelRatio, sourceResolution, sourceExtent, targetResolution, targetExtent, triangulation, sources, gutter, opt_renderEdges) { const context = createCanvasContext2D(Math.round(pixelRatio * width), Math.round(pixelRatio * height)); if (sources.length === 0) { return context.canvas; } context.scale(pixelRatio, pixelRatio); const sourceDataExtent = createEmpty(); sources.forEach(function(src, i, arr) { extend(sourceDataExtent, src.extent); }); const canvasWidthInUnits = getWidth(sourceDataExtent); const canvasHeightInUnits = getHeight(sourceDataExtent); const stitchContext = createCanvasContext2D( Math.round(pixelRatio * canvasWidthInUnits / sourceResolution), Math.round(pixelRatio * canvasHeightInUnits / sourceResolution)); const stitchScale = pixelRatio / sourceResolution; sources.forEach(function(src, i, arr) { const xPos = src.extent[0] - sourceDataExtent[0]; const yPos = -(src.extent[3] - sourceDataExtent[3]); const srcWidth = getWidth(src.extent); const srcHeight = getHeight(src.extent); stitchContext.drawImage( src.image, gutter, gutter, src.image.width - 2 * gutter, src.image.height - 2 * gutter, xPos * stitchScale, yPos * stitchScale, srcWidth * stitchScale, srcHeight * stitchScale); }); const targetTopLeft = getTopLeft(targetExtent); triangulation.getTriangles().forEach(function(triangle, i, arr) { /* Calculate affine transform (src -> dst) * Resulting matrix can be used to transform coordinate * from `sourceProjection` to destination pixels. * * To optimize number of context calls and increase numerical stability, * we also do the following operations: * trans(-topLeftExtentCorner), scale(1 / targetResolution), scale(1, -1) * here before solving the linear system so [ui, vi] are pixel coordinates. * * Src points: xi, yi * Dst points: ui, vi * Affine coefficients: aij * * | x0 y0 1 0 0 0 | |a00| |u0| * | x1 y1 1 0 0 0 | |a01| |u1| * | x2 y2 1 0 0 0 | x |a02| = |u2| * | 0 0 0 x0 y0 1 | |a10| |v0| * | 0 0 0 x1 y1 1 | |a11| |v1| * | 0 0 0 x2 y2 1 | |a12| |v2| */ const source = triangle.source; const target = triangle.target; let x0 = source[0][0], y0 = source[0][1]; let x1 = source[1][0], y1 = source[1][1]; let x2 = source[2][0], y2 = source[2][1]; const u0 = (target[0][0] - targetTopLeft[0]) / targetResolution; const v0 = -(target[0][1] - targetTopLeft[1]) / targetResolution; const u1 = (target[1][0] - targetTopLeft[0]) / targetResolution; const v1 = -(target[1][1] - targetTopLeft[1]) / targetResolution; const u2 = (target[2][0] - targetTopLeft[0]) / targetResolution; const v2 = -(target[2][1] - targetTopLeft[1]) / targetResolution; // Shift all the source points to improve numerical stability // of all the subsequent calculations. The [x0, y0] is used here. // This is also used to simplify the linear system. const sourceNumericalShiftX = x0; const sourceNumericalShiftY = y0; x0 = 0; y0 = 0; x1 -= sourceNumericalShiftX; y1 -= sourceNumericalShiftY; x2 -= sourceNumericalShiftX; y2 -= sourceNumericalShiftY; const augmentedMatrix = [ [x1, y1, 0, 0, u1 - u0], [x2, y2, 0, 0, u2 - u0], [0, 0, x1, y1, v1 - v0], [0, 0, x2, y2, v2 - v0] ]; const affineCoefs = solveLinearSystem(augmentedMatrix); if (!affineCoefs) { return; } context.save(); context.beginPath(); const centroidX = (u0 + u1 + u2) / 3; const centroidY = (v0 + v1 + v2) / 3; const p0 = enlargeClipPoint(centroidX, centroidY, u0, v0); const p1 = enlargeClipPoint(centroidX, centroidY, u1, v1); const p2 = enlargeClipPoint(centroidX, centroidY, u2, v2); context.moveTo(p1[0], p1[1]); context.lineTo(p0[0], p0[1]); context.lineTo(p2[0], p2[1]); context.clip(); context.transform( affineCoefs[0], affineCoefs[2], affineCoefs[1], affineCoefs[3], u0, v0); context.translate(sourceDataExtent[0] - sourceNumericalShiftX, sourceDataExtent[3] - sourceNumericalShiftY); context.scale(sourceResolution / pixelRatio, -sourceResolution / pixelRatio); context.drawImage(stitchContext.canvas, 0, 0); context.restore(); }); if (opt_renderEdges) { context.save(); context.strokeStyle = 'black'; context.lineWidth = 1; triangulation.getTriangles().forEach(function(triangle, i, arr) { const target = triangle.target; const u0 = (target[0][0] - targetTopLeft[0]) / targetResolution; const v0 = -(target[0][1] - targetTopLeft[1]) / targetResolution; const u1 = (target[1][0] - targetTopLeft[0]) / targetResolution; const v1 = -(target[1][1] - targetTopLeft[1]) / targetResolution; const u2 = (target[2][0] - targetTopLeft[0]) / targetResolution; const v2 = -(target[2][1] - targetTopLeft[1]) / targetResolution; context.beginPath(); context.moveTo(u1, v1); context.lineTo(u0, v0); context.lineTo(u2, v2); context.closePath(); context.stroke(); }); context.restore(); } return context.canvas; }
74943b4fb471f5a7db4c489edadf7b37e9d02d50
c1096f2729fcc2e76dfcc9d4d277cebb669ef50f
/samples/x86/test_java.c
fc868c4534edef1c5b92150010a7020d28f014e1
[]
no_license
mikeakohn/java_grinder
8d67f183aebfc412bff8537b23ff8be99f86dea6
273d6e97f46d3fa442b33ae19a2b2cde16dc5c4b
refs/heads/master
2023-08-15T13:17:50.551116
2023-06-20T21:44:37
2023-06-20T21:44:37
15,153,331
481
41
null
2020-01-28T02:30:24
2013-12-13T02:48:12
C++
UTF-8
C
false
false
2,974
c
test_java.c
#include <stdio.h> #include <stdlib.h> void init(); int add_nums_II(int a, int b); int sub_nums_II(int a, int b); int mul_nums_II(int a, int b); int div_nums_II(int a, int b); int mod_nums_II(int a, int b); int shift_nums_II(int a, int b); int loop_test_II(int a, int b); void put_static_I(int a); int get_static(); int method_call_test_II(int a, int b); int method_call_long_test_I(int a); int add_array_aB(int8_t *a); void fill_array_aB(int8_t *a); int add_array_aS(int16_t *a); void fill_array_aS(int16_t *a); int add_array_aI(int32_t *a); void fill_array_aI(int32_t *a); struct _byte_array { int len; int8_t data[]; }; struct _short_array { int len; int16_t data[]; }; struct _int_array { int len; int32_t data[]; }; int main(int argc, char *argv[]) { int a,b,i; struct _byte_array *byte_array = alloca(4 + sizeof(int)); struct _short_array *short_array = alloca(4 * sizeof(int16_t) + sizeof(int)); struct _int_array *int_array = alloca(4 * sizeof(int32_t) + sizeof(int)); if (argc != 3) { printf("Usage: %s <num> <num>\n", argv[0]); exit(0); } byte_array->len = 4; byte_array->data[0] = 1; byte_array->data[1] = 2; byte_array->data[2] = 3; byte_array->data[3] = 4; short_array->len = 4; short_array->data[0] = 10; short_array->data[1] = 20; short_array->data[2] = 30; short_array->data[3] = 40; int_array->len = 4; int_array->data[0] = 100; int_array->data[1] = 200; int_array->data[2] = 300; int_array->data[3] = 400; a = atoi(argv[1]); b = atoi(argv[2]); init(); printf("%d + %d = %d\n", a, b, add_nums_II(a,b)); printf("%d - %d = %d\n", a, b, sub_nums_II(a,b)); printf("%d * %d = %d\n", a, b, mul_nums_II(a,b)); printf("%d / %d = %d\n", a, b, div_nums_II(a,b)); printf("%d %% %d = %d\n", a, b, mod_nums_II(a,b)); printf("%d << %d = %d\n", a, b, shift_nums_II(a,b)); printf("loop test (%d,%d) %d\n", a, b, loop_test_II(a,b)); printf("get_static()=%d\n", get_static()); printf("put_static(%d)\n", a); put_static_I(a); printf("get_static()=%d\n", get_static()); printf("method_call_test_II(%d,%d)=%d\n", a, b, method_call_test_II(a,b)); printf("method_call_long_test_I(%d)=%d\n", a, method_call_long_test_I(a)); printf("add_array_aB(%p)=%d\n", byte_array, add_array_aB(byte_array->data)); printf("fill_array_aB(%p)={", byte_array); fill_array_aB(byte_array->data); for (i = 0; i < 4; i++) { printf(" %d", byte_array->data[i]); } printf(" }\n"); printf("add_array_aS(%p)=%d\n", short_array, add_array_aS(short_array->data)); printf("fill_array_aS(%p)={", short_array); fill_array_aS(short_array->data); for (i = 0; i < 4; i++) { printf(" %d", short_array->data[i]); } printf(" }\n"); printf("add_array_aI(%p)=%d\n", int_array, add_array_aI(int_array->data)); printf("fill_array_aI(%p)={", int_array); fill_array_aI(int_array->data); for (i = 0; i < 4; i++) { printf(" %d", int_array->data[i]); } printf(" }\n"); return 0; }
49b77ea7ced937d458319e1998e7ee5ffba5580e
33bbf5ec9c25a08cdc2ea9b404fef066f48b91e6
/i18n/ht/dictionary.h
620b60ac6f6a7887a91f62236a7b5431252cb918
[ "BSD-2-Clause" ]
permissive
gabordemooij/citrine
2cf1102851461b273158e6731a68e35fe7123c88
135beb4c417e006028b3affb264c1bd554ae28f1
refs/heads/master
2023-08-28T01:10:20.952764
2023-07-08T10:02:04
2023-07-08T10:02:04
23,259,816
110
23
BSD-2-Clause
2023-07-08T10:02:08
2014-08-23T15:55:48
C
UTF-8
C
false
false
9,016
h
dictionary.h
#define CTR_DICT_CODEGEN_MAP_NEW "(Kat nouvo) " #define CTR_DICT_CODEGEN_MAP_PUT "mete:" #define CTR_DICT_CODEGEN_MAP_PUT_AT " nan:" #define CTR_DICT_CODEGEN_ARRAY_NEW "Lis nouvo " #define CTR_DICT_CODEGEN_ARRAY_NEW_PUSH "Lis ← " #define CTR_DICT_END_OF_LINE "." #define CTR_DICT_NIL "Nil" #define CTR_DICT_BOOLEAN "Boolean" #define CTR_DICT_TRUE "Vrè" #define CTR_DICT_FALSE "Fo" #define CTR_DICT_NUMBER "Nimewo" #define CTR_DICT_STRING "Fisèl" #define CTR_DICT_TASK "Kòd" #define CTR_DICT_OBJECT "Objè" #define CTR_DICT_ARRAY_OBJECT "Lis" #define CTR_DICT_MAP_OBJECT "Kat" #define CTR_DICT_PROGRAM "Pwogram" #define CTR_DICT_FILE "File" #define CTR_DICT_MOMENT "Moman" #define CTR_DICT_VAR_ICON "☞" #define CTR_DICT_ME_ICON "⛏" #define CTR_DICT_MY_ICON "⚿" #define CTR_DICT_BULLET "•" #define CTR_DICT_SYMBOL_EQUALS "=" #define CTR_DICT_PLUS "+" #define CTR_DICT_MINUS "-" #define CTR_DICT_MULTIPLIER "×" #define CTR_DICT_DIVISION "÷" #define CTR_DICT_GREATER ">" #define CTR_DICT_LESS "<" #define CTR_DICT_AT_SYMBOL "?" #define CTR_DICT_PEN_ICON "✎" #define CTR_DICT_NEW_ARRAY_AND_PUSH_SYMBOL "←" #define CTR_DICT_GREATER_OR_EQUAL_SYMBOL "≥" #define CTR_DICT_LESS_OR_EQUAL_SYMBOL "≤" #define CTR_DICT_UNEQUALS_SYMBOL "≠" #define CTR_DICT_NEW "nouvo" #define CTR_DICT_EQUALS "egal:" #define CTR_DICT_AND "e:" #define CTR_DICT_OR "oswa:" #define CTR_DICT_MODULO "modulo:" #define CTR_DICT_NOR "ni:" #define CTR_DICT_ONDO "sou:fè:" #define CTR_DICT_TYPE "di ki kalite" #define CTR_DICT_ISNIL "nil?" #define CTR_DICT_MYSELF "mwen menm" #define CTR_DICT_DO "fè" #define CTR_DICT_DONE "fini" #define CTR_DICT_IFFALSE "fo:" #define CTR_DICT_IFTRUE "vre:" #define CTR_DICT_WHILE "pandan ke:" #define CTR_DICT_MESSAGEARGS "mesaj:agiman:" #define CTR_DICT_MESSAGE "mesaj:" #define CTR_DICT_LEARN "aprann:vle di:" #define CTR_DICT_BREAK "kraze" #define CTR_DICT_CONTINUE "kontinye" #define CTR_DICT_ELSE "lòt bagay:" #define CTR_DICT_NOT "pa" #define CTR_DICT_TONUMBER "nimewo" #define CTR_DICT_ITONUMBER "nimewo entènasyonal" #define CTR_DICT_TOSTRING "fil" #define CTR_DICT_CHAR_AT_SET "karaktè:" #define CTR_DICT_EITHEROR "oswa:oswa:" #define CTR_DICT_BY_SET "pa:" #define CTR_DICT_FLOOR "etaj" #define CTR_DICT_CEIL "plafon" #define CTR_DICT_ROUND "wonn" #define CTR_DICT_ABS "absoli" #define CTR_DICT_SQRT "rasin kare" #define CTR_DICT_POWER "pouvwa:" #define CTR_DICT_MIN "minimòm" #define CTR_DICT_MAX "maksimòm" #define CTR_DICT_ODD "enpè?" #define CTR_DICT_EVEN "menm?" #define CTR_DICT_POS "pozitif?" #define CTR_DICT_NEG "negatif?" #define CTR_DICT_TOBOOL "boolean" #define CTR_DICT_RANDOM_NUM_BETWEEN "ant:ak:" #define CTR_DICT_LENGTH "longè" #define CTR_DICT_FROM_LENGTH "soti nan:longè:" #define CTR_DICT_TRIM "retire espas ki antoure yo" #define CTR_DICT_AT "nan:" #define CTR_DICT_POSITION_SET "pozisyon:" #define CTR_DICT_INDEX_OF "jwenn:" #define CTR_DICT_LAST_INDEX_OF "dènye:" #define CTR_DICT_REPLACE_WITH "ranplase:ak:" #define CTR_DICT_SPLIT "divize:" #define CTR_DICT_SKIP "konpanse:" #define CTR_DICT_RUN "kouri" #define CTR_DICT_APPLY_TO "aplike:" #define CTR_DICT_APPLY_TO_AND "aplike:ak:" #define CTR_DICT_VALUE_SET "mete:valè:" #define CTR_DICT_ERROR "erè:" #define CTR_DICT_CATCH "trape:" #define CTR_DICT_PUSH_SYMBOL ";" #define CTR_DICT_SHIFT "kale" #define CTR_DICT_COUNT "konte" #define CTR_DICT_JOIN "rantre nan:" #define CTR_DICT_POP "koupe" #define CTR_DICT_SORT "sòt:" #define CTR_DICT_PUT_AT "mete:nan:" #define CTR_DICT_MAP "kat:" #define CTR_DICT_EACH "chak:" #define CTR_DICT_WRITE "ekri:" #define CTR_DICT_PATH "chemen" #define CTR_DICT_READ "li" #define CTR_DICT_APPEND "sifiks:" #define CTR_DICT_PREPEND "prefiks:" #define CTR_DICT_EXISTS "egziste" #define CTR_DICT_SIZE "gwosè" #define CTR_DICT_DELETE "efase" #define CTR_DICT_USE_SET "itilize:" #define CTR_DICT_ARRAY "lis:" #define CTR_DICT_END "fen" #define CTR_DICT_ARGUMENT "agiman:" #define CTR_DICT_ARGUMENT_COUNT "agiman" #define CTR_DICT_WAIT_FOR_PASSW "mande modpas" #define CTR_DICT_WAIT_FOR_INPUT "mande" #define CTR_DICT_INPUT "opinyon" #define CTR_DICT_FLUSH "kole" #define CTR_DICT_WAIT "tann:" #define CTR_DICT_TIME "tan" #define CTR_DICT_RESPOND_TO "reponn:" #define CTR_DICT_RESPOND_TO_AND "reponn:epi:" #define CTR_DICT_SHELL "machin:" #define CTR_DICT_SWEEP "memwa pwòp" #define CTR_DICT_MEMORY_LIMIT "memwa:" #define CTR_DICT_MEMORY "memwa" #define CTR_DICT_GC_MODE "tidty:" #define CTR_DICT_HASH_WITH_KEY "hash:" #define CTR_DICT_CHARACTERS "karaktè" #define CTR_DICT_QUALIFIER_SET "kalifye:" #define CTR_DICT_QUALIFIER "kalifikasyon" #define CTR_DICT_NEW_SET "nouvo:" #define CTR_DICT_HOUR "èdtan" #define CTR_DICT_HOUR_SET "èdtan:" #define CTR_DICT_MINUTE_SET "minit:" #define CTR_DICT_MINUTE "minit" #define CTR_DICT_SECOND_SET "dezyèm fwa:" #define CTR_DICT_SECOND "dezyèm fwa" #define CTR_DICT_DAY "jou" #define CTR_DICT_DAY_SET "jou:" #define CTR_DICT_WEEK "semèn" #define CTR_DICT_WEEK_SET "semèn:" #define CTR_DICT_MONTH "mwa" #define CTR_DICT_MONTH_SET "mwa:" #define CTR_DICT_YEAR "ane" #define CTR_DICT_RAW "kri" #define CTR_DICT_YEAR_SET "ane:" #define CTR_DICT_WEEK_DAY "jou lasemèn" #define CTR_DICT_YEAR_DAY "jou nan ane an" #define CTR_DICT_ZONE "zòn" #define CTR_DICT_ZONE_SET "zòn:" #define CTR_DICT_ADD_SET "ajoute:" #define CTR_DICT_SUBTRACT_SET "fè soustraksyon:" #define CTR_DICT_MULTIPLIER_SET "miltipliye pa:" #define CTR_DICT_DIVIDER_SET "divize pa:" #define CTR_DICT_LAST "dènye" #define CTR_DICT_FIRST "premye" #define CTR_DICT_SECOND_LAST "dezyèm dènye" #define CTR_DICT_FILL_WITH "ranpli:ak:" #define CTR_DICT_SPLICE "ranplase:longè:ak:" #define CTR_DICT_VALUES "valè yo" #define CTR_DICT_ENTRIES "antre" #define CTR_DICT_COMPARE_SET "konpare:" #define CTR_DICT_HAS "gen:" #define CTR_DICT_COPY "kopi" #define CTR_DICT_CASE_DO "ka:fè:" #define CTR_DICT_STOP "kanpe" #define CTR_DICT_ASCII_UPPER_CASE "majiskil" #define CTR_DICT_ASCII_LOWER_CASE "miniskil" #define CTR_DICT_CONTAINS "gen ladan:" #define CTR_DICT_APPLY_TO_AND_AND "aplike:ak:ak:" #define CTR_DICT_ENVIRONMENT_VARIABLE "anviwònman:" #define CTR_DICT_SET_ENVIRONMENT_VARIABLE "anviwònman:valè:" #define CTR_DICT_RESPOND_TO_AND_AND "reponn:ak:ak:" #define CTR_DICT_RESPOND_TO_AND_AND_AND "reponn:ak:ak:ak:" #define CTR_DICT_CURRENT_TASK "blòk kòd sa a" #define CTR_DICT_NUM_DEC_SEP "," #define CTR_DICT_NUM_THO_SEP "." #define CTR_DICT_QUOT_OPEN "‘" #define CTR_DICT_QUOT_CLOSE "’" #define CTR_DICT_MESSAGE_CHAIN "," #define CTR_DICT_ASSIGN "≔" #define CTR_DICT_PAREN_OPEN "(" #define CTR_DICT_PAREN_CLOSE ")" #define CTR_DICT_BLOCK_START "{" #define CTR_DICT_BLOCK_END "}" #define CTR_DICT_PARAMETER_PREFIX ":" #define CTR_DICT_RETURN "↲" #define CTR_DICT_CODE "ekri" #define CTR_DICT_PROCEDURE "pwosedi" #define CTR_DICT_TOOBJECT "objè" #define CTR_DICT_PATH_OBJECT "Kote dosye" #define CTR_DICT_CMD_OBJECT "Enstriksyon" #define CTR_DICT_RECURSIVE "repetitif"
fbf8f7098a8f2f495d858ccd4e74e7c3dcf9eae5
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/third_party/win_build_output/midl/ui/accessibility/platform/arm64/ichromeaccessible_p.c
803a08df8a31667106d49b49da84fda2ce9d5d3c
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
19,780
c
ichromeaccessible_p.c
/* this ALWAYS GENERATED file contains the proxy stub code */ /* File created by MIDL compiler version 8.xx.xxxx */ /* at a redacted point in time */ /* Compiler settings for ../../ui/accessibility/platform/ichromeaccessible.idl: Oicf, W1, Zp8, env=Win64 (32b run), target_arch=ARM64 8.01.0628 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ /* @@MIDL_FILE_HEADING( ) */ #if defined(_M_ARM64) #pragma warning( disable: 4049 ) /* more than 64k source lines */ #if _MSC_VER >= 1200 #pragma warning(push) #endif #pragma warning( disable: 4211 ) /* redefine extern to static */ #pragma warning( disable: 4232 ) /* dllimport identity*/ #pragma warning( disable: 4024 ) /* array to pointer mapping*/ #pragma warning( disable: 4152 ) /* function/data pointer conversion in expression */ #define USE_STUBLESS_PROXY /* verify that the <rpcproxy.h> version is high enough to compile this file*/ #ifndef __REDQ_RPCPROXY_H_VERSION__ #define __REQUIRED_RPCPROXY_H_VERSION__ 475 #endif #include "rpcproxy.h" #ifndef __RPCPROXY_H_VERSION__ #error this stub requires an updated version of <rpcproxy.h> #endif /* __RPCPROXY_H_VERSION__ */ #include "ichromeaccessible.h" #define TYPE_FORMAT_STRING_SIZE 75 #define PROC_FORMAT_STRING_SIZE 215 #define EXPR_FORMAT_STRING_SIZE 1 #define TRANSMIT_AS_TABLE_SIZE 0 #define WIRE_MARSHAL_TABLE_SIZE 1 typedef struct _ichromeaccessible_MIDL_TYPE_FORMAT_STRING { short Pad; unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; } ichromeaccessible_MIDL_TYPE_FORMAT_STRING; typedef struct _ichromeaccessible_MIDL_PROC_FORMAT_STRING { short Pad; unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; } ichromeaccessible_MIDL_PROC_FORMAT_STRING; typedef struct _ichromeaccessible_MIDL_EXPR_FORMAT_STRING { long Pad; unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; } ichromeaccessible_MIDL_EXPR_FORMAT_STRING; static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax_2_0 = {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; #if defined(_CONTROL_FLOW_GUARD_XFG) #define XFG_TRAMPOLINES(ObjectType)\ NDR_SHAREABLE unsigned long ObjectType ## _UserSize_XFG(unsigned long * pFlags, unsigned long Offset, void * pObject)\ {\ return ObjectType ## _UserSize(pFlags, Offset, (ObjectType *)pObject);\ }\ NDR_SHAREABLE unsigned char * ObjectType ## _UserMarshal_XFG(unsigned long * pFlags, unsigned char * pBuffer, void * pObject)\ {\ return ObjectType ## _UserMarshal(pFlags, pBuffer, (ObjectType *)pObject);\ }\ NDR_SHAREABLE unsigned char * ObjectType ## _UserUnmarshal_XFG(unsigned long * pFlags, unsigned char * pBuffer, void * pObject)\ {\ return ObjectType ## _UserUnmarshal(pFlags, pBuffer, (ObjectType *)pObject);\ }\ NDR_SHAREABLE void ObjectType ## _UserFree_XFG(unsigned long * pFlags, void * pObject)\ {\ ObjectType ## _UserFree(pFlags, (ObjectType *)pObject);\ } #define XFG_TRAMPOLINES64(ObjectType)\ NDR_SHAREABLE unsigned long ObjectType ## _UserSize64_XFG(unsigned long * pFlags, unsigned long Offset, void * pObject)\ {\ return ObjectType ## _UserSize64(pFlags, Offset, (ObjectType *)pObject);\ }\ NDR_SHAREABLE unsigned char * ObjectType ## _UserMarshal64_XFG(unsigned long * pFlags, unsigned char * pBuffer, void * pObject)\ {\ return ObjectType ## _UserMarshal64(pFlags, pBuffer, (ObjectType *)pObject);\ }\ NDR_SHAREABLE unsigned char * ObjectType ## _UserUnmarshal64_XFG(unsigned long * pFlags, unsigned char * pBuffer, void * pObject)\ {\ return ObjectType ## _UserUnmarshal64(pFlags, pBuffer, (ObjectType *)pObject);\ }\ NDR_SHAREABLE void ObjectType ## _UserFree64_XFG(unsigned long * pFlags, void * pObject)\ {\ ObjectType ## _UserFree64(pFlags, (ObjectType *)pObject);\ } #define XFG_BIND_TRAMPOLINES(HandleType, ObjectType)\ static void* ObjectType ## _bind_XFG(HandleType pObject)\ {\ return ObjectType ## _bind((ObjectType) pObject);\ }\ static void ObjectType ## _unbind_XFG(HandleType pObject, handle_t ServerHandle)\ {\ ObjectType ## _unbind((ObjectType) pObject, ServerHandle);\ } #define XFG_TRAMPOLINE_FPTR(Function) Function ## _XFG #define XFG_TRAMPOLINE_FPTR_DEPENDENT_SYMBOL(Symbol) Symbol ## _XFG #else #define XFG_TRAMPOLINES(ObjectType) #define XFG_TRAMPOLINES64(ObjectType) #define XFG_BIND_TRAMPOLINES(HandleType, ObjectType) #define XFG_TRAMPOLINE_FPTR(Function) Function #define XFG_TRAMPOLINE_FPTR_DEPENDENT_SYMBOL(Symbol) Symbol #endif extern const ichromeaccessible_MIDL_TYPE_FORMAT_STRING ichromeaccessible__MIDL_TypeFormatString; extern const ichromeaccessible_MIDL_PROC_FORMAT_STRING ichromeaccessible__MIDL_ProcFormatString; extern const ichromeaccessible_MIDL_EXPR_FORMAT_STRING ichromeaccessible__MIDL_ExprFormatString; #ifdef __cplusplus namespace { #endif extern const MIDL_STUB_DESC Object_StubDesc; #ifdef __cplusplus } #endif extern const MIDL_SERVER_INFO IChromeAccessibleDelegate_ServerInfo; extern const MIDL_STUBLESS_PROXY_INFO IChromeAccessibleDelegate_ProxyInfo; #ifdef __cplusplus namespace { #endif extern const MIDL_STUB_DESC Object_StubDesc; #ifdef __cplusplus } #endif extern const MIDL_SERVER_INFO IChromeAccessible_ServerInfo; extern const MIDL_STUBLESS_PROXY_INFO IChromeAccessible_ProxyInfo; extern const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ]; #if !defined(__RPC_ARM64__) #error Invalid build platform for this stub. #endif static const ichromeaccessible_MIDL_PROC_FORMAT_STRING ichromeaccessible__MIDL_ProcFormatString = { 0, { /* Procedure put_bulkFetchResult */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 2 */ NdrFcLong( 0x0 ), /* 0 */ /* 6 */ NdrFcShort( 0x3 ), /* 3 */ /* 8 */ NdrFcShort( 0x20 ), /* ARM64 Stack size/offset = 32 */ /* 10 */ NdrFcShort( 0x8 ), /* 8 */ /* 12 */ NdrFcShort( 0x8 ), /* 8 */ /* 14 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ 0x3, /* 3 */ /* 16 */ 0xe, /* 14 */ 0x5, /* Ext Flags: new corr desc, srv corr check, */ /* 18 */ NdrFcShort( 0x0 ), /* 0 */ /* 20 */ NdrFcShort( 0x1 ), /* 1 */ /* 22 */ NdrFcShort( 0x0 ), /* 0 */ /* 24 */ NdrFcShort( 0x3 ), /* 3 */ /* 26 */ 0x3, /* 3 */ 0x80, /* 128 */ /* 28 */ 0x81, /* 129 */ 0x82, /* 130 */ /* Parameter requestID */ /* 30 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ /* 32 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ /* 34 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Parameter resultJson */ /* 36 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ /* 38 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ /* 40 */ NdrFcShort( 0x1c ), /* Type Offset=28 */ /* Return value */ /* 42 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ /* 44 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ /* 46 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Procedure put_hitTestResult */ /* 48 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 50 */ NdrFcLong( 0x0 ), /* 0 */ /* 54 */ NdrFcShort( 0x4 ), /* 4 */ /* 56 */ NdrFcShort( 0x20 ), /* ARM64 Stack size/offset = 32 */ /* 58 */ NdrFcShort( 0x8 ), /* 8 */ /* 60 */ NdrFcShort( 0x8 ), /* 8 */ /* 62 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ 0x3, /* 3 */ /* 64 */ 0xe, /* 14 */ 0x1, /* Ext Flags: new corr desc, */ /* 66 */ NdrFcShort( 0x0 ), /* 0 */ /* 68 */ NdrFcShort( 0x0 ), /* 0 */ /* 70 */ NdrFcShort( 0x0 ), /* 0 */ /* 72 */ NdrFcShort( 0x3 ), /* 3 */ /* 74 */ 0x3, /* 3 */ 0x80, /* 128 */ /* 76 */ 0x81, /* 129 */ 0x82, /* 130 */ /* Parameter requestID */ /* 78 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ /* 80 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ /* 82 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Parameter result */ /* 84 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ /* 86 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ /* 88 */ NdrFcShort( 0x26 ), /* Type Offset=38 */ /* Return value */ /* 90 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ /* 92 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ /* 94 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Procedure get_bulkFetch */ /* 96 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 98 */ NdrFcLong( 0x0 ), /* 0 */ /* 102 */ NdrFcShort( 0x3 ), /* 3 */ /* 104 */ NdrFcShort( 0x28 ), /* ARM64 Stack size/offset = 40 */ /* 106 */ NdrFcShort( 0x8 ), /* 8 */ /* 108 */ NdrFcShort( 0x8 ), /* 8 */ /* 110 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ 0x4, /* 4 */ /* 112 */ 0x10, /* 16 */ 0x5, /* Ext Flags: new corr desc, srv corr check, */ /* 114 */ NdrFcShort( 0x0 ), /* 0 */ /* 116 */ NdrFcShort( 0x1 ), /* 1 */ /* 118 */ NdrFcShort( 0x0 ), /* 0 */ /* 120 */ NdrFcShort( 0x4 ), /* 4 */ /* 122 */ 0x4, /* 4 */ 0x80, /* 128 */ /* 124 */ 0x81, /* 129 */ 0x82, /* 130 */ /* 126 */ 0x83, /* 131 */ 0x0, /* 0 */ /* Parameter inputJson */ /* 128 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ /* 130 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ /* 132 */ NdrFcShort( 0x1c ), /* Type Offset=28 */ /* Parameter requestID */ /* 134 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ /* 136 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ /* 138 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Parameter delegate */ /* 140 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ /* 142 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ /* 144 */ NdrFcShort( 0x38 ), /* Type Offset=56 */ /* Return value */ /* 146 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ /* 148 */ NdrFcShort( 0x20 ), /* ARM64 Stack size/offset = 32 */ /* 150 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Procedure get_hitTest */ /* 152 */ 0x33, /* FC_AUTO_HANDLE */ 0x6c, /* Old Flags: object, Oi2 */ /* 154 */ NdrFcLong( 0x0 ), /* 0 */ /* 158 */ NdrFcShort( 0x4 ), /* 4 */ /* 160 */ NdrFcShort( 0x30 ), /* ARM64 Stack size/offset = 48 */ /* 162 */ NdrFcShort( 0x18 ), /* 24 */ /* 164 */ NdrFcShort( 0x8 ), /* 8 */ /* 166 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ 0x5, /* 5 */ /* 168 */ 0x10, /* 16 */ 0x1, /* Ext Flags: new corr desc, */ /* 170 */ NdrFcShort( 0x0 ), /* 0 */ /* 172 */ NdrFcShort( 0x0 ), /* 0 */ /* 174 */ NdrFcShort( 0x0 ), /* 0 */ /* 176 */ NdrFcShort( 0x5 ), /* 5 */ /* 178 */ 0x5, /* 5 */ 0x80, /* 128 */ /* 180 */ 0x81, /* 129 */ 0x82, /* 130 */ /* 182 */ 0x83, /* 131 */ 0x84, /* 132 */ /* Parameter screenPhysicalPixelX */ /* 184 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ /* 186 */ NdrFcShort( 0x8 ), /* ARM64 Stack size/offset = 8 */ /* 188 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Parameter screenPhysicalPixelY */ /* 190 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ /* 192 */ NdrFcShort( 0x10 ), /* ARM64 Stack size/offset = 16 */ /* 194 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Parameter requestID */ /* 196 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ /* 198 */ NdrFcShort( 0x18 ), /* ARM64 Stack size/offset = 24 */ /* 200 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ /* Parameter delegate */ /* 202 */ NdrFcShort( 0xb ), /* Flags: must size, must free, in, */ /* 204 */ NdrFcShort( 0x20 ), /* ARM64 Stack size/offset = 32 */ /* 206 */ NdrFcShort( 0x38 ), /* Type Offset=56 */ /* Return value */ /* 208 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ /* 210 */ NdrFcShort( 0x28 ), /* ARM64 Stack size/offset = 40 */ /* 212 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ 0x0 } }; static const ichromeaccessible_MIDL_TYPE_FORMAT_STRING ichromeaccessible__MIDL_TypeFormatString = { 0, { NdrFcShort( 0x0 ), /* 0 */ /* 2 */ 0x12, 0x0, /* FC_UP */ /* 4 */ NdrFcShort( 0xe ), /* Offset= 14 (18) */ /* 6 */ 0x1b, /* FC_CARRAY */ 0x1, /* 1 */ /* 8 */ NdrFcShort( 0x2 ), /* 2 */ /* 10 */ 0x9, /* Corr desc: FC_ULONG */ 0x0, /* */ /* 12 */ NdrFcShort( 0xfffc ), /* -4 */ /* 14 */ NdrFcShort( 0x1 ), /* Corr flags: early, */ /* 16 */ 0x6, /* FC_SHORT */ 0x5b, /* FC_END */ /* 18 */ 0x17, /* FC_CSTRUCT */ 0x3, /* 3 */ /* 20 */ NdrFcShort( 0x8 ), /* 8 */ /* 22 */ NdrFcShort( 0xfff0 ), /* Offset= -16 (6) */ /* 24 */ 0x8, /* FC_LONG */ 0x8, /* FC_LONG */ /* 26 */ 0x5c, /* FC_PAD */ 0x5b, /* FC_END */ /* 28 */ 0xb4, /* FC_USER_MARSHAL */ 0x83, /* 131 */ /* 30 */ NdrFcShort( 0x0 ), /* 0 */ /* 32 */ NdrFcShort( 0x8 ), /* 8 */ /* 34 */ NdrFcShort( 0x0 ), /* 0 */ /* 36 */ NdrFcShort( 0xffde ), /* Offset= -34 (2) */ /* 38 */ 0x2f, /* FC_IP */ 0x5a, /* FC_CONSTANT_IID */ /* 40 */ NdrFcLong( 0x0 ), /* 0 */ /* 44 */ NdrFcShort( 0x0 ), /* 0 */ /* 46 */ NdrFcShort( 0x0 ), /* 0 */ /* 48 */ 0xc0, /* 192 */ 0x0, /* 0 */ /* 50 */ 0x0, /* 0 */ 0x0, /* 0 */ /* 52 */ 0x0, /* 0 */ 0x0, /* 0 */ /* 54 */ 0x0, /* 0 */ 0x46, /* 70 */ /* 56 */ 0x2f, /* FC_IP */ 0x5a, /* FC_CONSTANT_IID */ /* 58 */ NdrFcLong( 0xe3edc14 ), /* 239000596 */ /* 62 */ NdrFcShort( 0x79f4 ), /* 31220 */ /* 64 */ NdrFcShort( 0x413f ), /* 16703 */ /* 66 */ 0xb8, /* 184 */ 0x54, /* 84 */ /* 68 */ 0xd3, /* 211 */ 0xb6, /* 182 */ /* 70 */ 0x86, /* 134 */ 0xd, /* 13 */ /* 72 */ 0x74, /* 116 */ 0xa2, /* 162 */ 0x0 } }; XFG_TRAMPOLINES(BSTR) static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[ WIRE_MARSHAL_TABLE_SIZE ] = { { (USER_MARSHAL_SIZING_ROUTINE)XFG_TRAMPOLINE_FPTR(BSTR_UserSize) ,(USER_MARSHAL_MARSHALLING_ROUTINE)XFG_TRAMPOLINE_FPTR(BSTR_UserMarshal) ,(USER_MARSHAL_UNMARSHALLING_ROUTINE)XFG_TRAMPOLINE_FPTR(BSTR_UserUnmarshal) ,(USER_MARSHAL_FREEING_ROUTINE)XFG_TRAMPOLINE_FPTR(BSTR_UserFree) } }; /* Standard interface: __MIDL_itf_ichromeaccessible_0000_0000, ver. 0.0, GUID={0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} */ /* Object interface: IUnknown, ver. 0.0, GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */ /* Object interface: IChromeAccessibleDelegate, ver. 0.0, GUID={0x0e3edc14,0x79f4,0x413f,{0xb8,0x54,0xd3,0xb6,0x86,0x0d,0x74,0xa2}} */ #pragma code_seg(".orpc") static const unsigned short IChromeAccessibleDelegate_FormatStringOffsetTable[] = { 0, 48 }; static const MIDL_STUBLESS_PROXY_INFO IChromeAccessibleDelegate_ProxyInfo = { &Object_StubDesc, ichromeaccessible__MIDL_ProcFormatString.Format, &IChromeAccessibleDelegate_FormatStringOffsetTable[-3], 0, 0, 0 }; static const MIDL_SERVER_INFO IChromeAccessibleDelegate_ServerInfo = { &Object_StubDesc, 0, ichromeaccessible__MIDL_ProcFormatString.Format, &IChromeAccessibleDelegate_FormatStringOffsetTable[-3], 0, 0, 0, 0}; CINTERFACE_PROXY_VTABLE(5) _IChromeAccessibleDelegateProxyVtbl = { &IChromeAccessibleDelegate_ProxyInfo, &IID_IChromeAccessibleDelegate, IUnknown_QueryInterface_Proxy, IUnknown_AddRef_Proxy, IUnknown_Release_Proxy , (void *) (INT_PTR) -1 /* IChromeAccessibleDelegate::put_bulkFetchResult */ , (void *) (INT_PTR) -1 /* IChromeAccessibleDelegate::put_hitTestResult */ }; const CInterfaceStubVtbl _IChromeAccessibleDelegateStubVtbl = { &IID_IChromeAccessibleDelegate, &IChromeAccessibleDelegate_ServerInfo, 5, 0, /* pure interpreted */ CStdStubBuffer_METHODS }; /* Object interface: IChromeAccessible, ver. 0.0, GUID={0x6175bd95,0x3b2e,0x4ebc,{0xbc,0x51,0x9c,0xab,0x78,0x2b,0xec,0x92}} */ #pragma code_seg(".orpc") static const unsigned short IChromeAccessible_FormatStringOffsetTable[] = { 96, 152 }; static const MIDL_STUBLESS_PROXY_INFO IChromeAccessible_ProxyInfo = { &Object_StubDesc, ichromeaccessible__MIDL_ProcFormatString.Format, &IChromeAccessible_FormatStringOffsetTable[-3], 0, 0, 0 }; static const MIDL_SERVER_INFO IChromeAccessible_ServerInfo = { &Object_StubDesc, 0, ichromeaccessible__MIDL_ProcFormatString.Format, &IChromeAccessible_FormatStringOffsetTable[-3], 0, 0, 0, 0}; CINTERFACE_PROXY_VTABLE(5) _IChromeAccessibleProxyVtbl = { &IChromeAccessible_ProxyInfo, &IID_IChromeAccessible, IUnknown_QueryInterface_Proxy, IUnknown_AddRef_Proxy, IUnknown_Release_Proxy , (void *) (INT_PTR) -1 /* IChromeAccessible::get_bulkFetch */ , (void *) (INT_PTR) -1 /* IChromeAccessible::get_hitTest */ }; const CInterfaceStubVtbl _IChromeAccessibleStubVtbl = { &IID_IChromeAccessible, &IChromeAccessible_ServerInfo, 5, 0, /* pure interpreted */ CStdStubBuffer_METHODS }; #ifdef __cplusplus namespace { #endif static const MIDL_STUB_DESC Object_StubDesc = { 0, NdrOleAllocate, NdrOleFree, 0, 0, 0, 0, 0, ichromeaccessible__MIDL_TypeFormatString.Format, 1, /* -error bounds_check flag */ 0x50002, /* Ndr library version */ 0, 0x8010274, /* MIDL Version 8.1.628 */ 0, UserMarshalRoutines, 0, /* notify & notify_flag routine table */ 0x1, /* MIDL flag */ 0, /* cs routines */ 0, /* proxy/server info */ 0 }; #ifdef __cplusplus } #endif const CInterfaceProxyVtbl * const _ichromeaccessible_ProxyVtblList[] = { ( CInterfaceProxyVtbl *) &_IChromeAccessibleDelegateProxyVtbl, ( CInterfaceProxyVtbl *) &_IChromeAccessibleProxyVtbl, 0 }; const CInterfaceStubVtbl * const _ichromeaccessible_StubVtblList[] = { ( CInterfaceStubVtbl *) &_IChromeAccessibleDelegateStubVtbl, ( CInterfaceStubVtbl *) &_IChromeAccessibleStubVtbl, 0 }; PCInterfaceName const _ichromeaccessible_InterfaceNamesList[] = { "IChromeAccessibleDelegate", "IChromeAccessible", 0 }; #define _ichromeaccessible_CHECK_IID(n) IID_GENERIC_CHECK_IID( _ichromeaccessible, pIID, n) int __stdcall _ichromeaccessible_IID_Lookup( const IID * pIID, int * pIndex ) { IID_BS_LOOKUP_SETUP IID_BS_LOOKUP_INITIAL_TEST( _ichromeaccessible, 2, 1 ) IID_BS_LOOKUP_RETURN_RESULT( _ichromeaccessible, 2, *pIndex ) } EXTERN_C const ExtendedProxyFileInfo ichromeaccessible_ProxyFileInfo = { (PCInterfaceProxyVtblList *) & _ichromeaccessible_ProxyVtblList, (PCInterfaceStubVtblList *) & _ichromeaccessible_StubVtblList, (const PCInterfaceName * ) & _ichromeaccessible_InterfaceNamesList, 0, /* no delegation */ & _ichromeaccessible_IID_Lookup, 2, 2, 0, /* table of [async_uuid] interfaces */ 0, /* Filler1 */ 0, /* Filler2 */ 0 /* Filler3 */ }; #if _MSC_VER >= 1200 #pragma warning(pop) #endif #endif /* defined(_M_ARM64) */
064f81a5782aadff9c2fc22b7b3ef30111e4234a
e1055e6a4117c7e0785ad0dee9f7911492d2298c
/src/atari800/libatari800.h
7ab7c55719ae5362227030302e1c535a2c13727b
[]
no_license
rossumur/esp_8_bit
f45fba3ca791ecf37a6a311c7fcfd523a63532cd
55eb7b86eda290d96b02c38c3e787efb8ae6a8c0
refs/heads/master
2023-08-22T19:07:41.899291
2022-03-19T19:21:25
2022-03-19T19:21:25
262,904,229
906
130
null
2023-02-17T17:15:22
2020-05-11T00:50:54
C
UTF-8
C
false
false
3,997
h
libatari800.h
#ifndef LIBATARI800_H_ #define LIBATARI800_H_ #ifdef __cplusplus extern "C" { #endif #ifndef UBYTE #define UBYTE unsigned char #endif #ifndef UWORD #define UWORD unsigned short #endif #ifndef ULONG #include <stdint.h> #define ULONG uint32_t #endif #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif typedef struct { UBYTE keychar; UBYTE keycode; UBYTE special; UBYTE shift; UBYTE control; UBYTE start; UBYTE select; UBYTE option; UBYTE joy0; UBYTE trig0; UBYTE joy1; UBYTE trig1; UBYTE joy2; UBYTE trig2; UBYTE joy3; UBYTE trig3; UBYTE mousex; UBYTE mousey; UBYTE mouse_buttons; UBYTE mouse_mode; } input_template_t; #define STATESAV_MAX_SIZE 210000 /* byte offsets into output_template.state array of groups of data to prevent the need for a full parsing of the save state data to be able to find parts needed for the visualizer display */ typedef struct { ULONG size; ULONG cpu; ULONG pc; ULONG base_ram; ULONG base_ram_attrib; ULONG antic; ULONG gtia; ULONG pia; ULONG pokey; } statesav_tags_t; typedef struct { UBYTE selftest_enabled; } statesav_flags_t; typedef struct { union { statesav_tags_t tags; UBYTE tags_storage[128]; }; union { statesav_flags_t flags; UBYTE flags_storage[128]; }; UBYTE state[STATESAV_MAX_SIZE]; } emulator_state_t; typedef struct { UBYTE A; UBYTE P; UBYTE S; UBYTE X; UBYTE Y; UBYTE IRQ; } cpu_state_t; typedef struct { UBYTE DMACTL; UBYTE CHACTL; UBYTE HSCROL; UBYTE VSCROL; UBYTE PMBASE; UBYTE CHBASE; UBYTE NMIEN; UBYTE NMIST; UBYTE IR; UBYTE anticmode; UBYTE dctr; UBYTE lastline; UBYTE need_dl; UBYTE vscrol_off; UWORD dlist; UWORD screenaddr; int xpos; int xpos_limit; int ypos; } antic_state_t; typedef struct { UBYTE HPOSP0; UBYTE HPOSP1; UBYTE HPOSP2; UBYTE HPOSP3; UBYTE HPOSM0; UBYTE HPOSM1; UBYTE HPOSM2; UBYTE HPOSM3; UBYTE PF0PM; UBYTE PF1PM; UBYTE PF2PM; UBYTE PF3PM; UBYTE M0PL; UBYTE M1PL; UBYTE M2PL; UBYTE M3PL; UBYTE P0PL; UBYTE P1PL; UBYTE P2PL; UBYTE P3PL; UBYTE SIZEP0; UBYTE SIZEP1; UBYTE SIZEP2; UBYTE SIZEP3; UBYTE SIZEM; UBYTE GRAFP0; UBYTE GRAFP1; UBYTE GRAFP2; UBYTE GRAFP3; UBYTE GRAFM; UBYTE COLPM0; UBYTE COLPM1; UBYTE COLPM2; UBYTE COLPM3; UBYTE COLPF0; UBYTE COLPF1; UBYTE COLPF2; UBYTE COLPF3; UBYTE COLBK; UBYTE PRIOR; UBYTE VDELAY; UBYTE GRACTL; } gtia_state_t; typedef struct { UBYTE KBCODE; UBYTE IRQST; UBYTE IRQEN; UBYTE SKCTL; int shift_key; int keypressed; int DELAYED_SERIN_IRQ; int DELAYED_SEROUT_IRQ; int DELAYED_XMTDONE_IRQ; UBYTE AUDF[4]; UBYTE AUDC[4]; UBYTE AUDCTL[4]; int DivNIRQ[4]; int DivNMax[4]; int Base_mult[4]; } pokey_state_t; extern int libatari800_error_code; #define LIBATARI800_UNIDENTIFIED_CART_TYPE 1 #define LIBATARI800_CPU_CRASH 2 #define LIBATARI800_BRK_INSTRUCTION 3 #define LIBATARI800_DLIST_ERROR 4 #define LIBATARI800_SELF_TEST 5 #define LIBATARI800_MEMO_PAD 6 #define LIBATARI800_INVALID_ESCAPE_OPCODE 7 int libatari800_init(int argc, char **argv); char *libatari800_error_message(); void libatari800_clear_input_array(input_template_t *input); int libatari800_next_frame(input_template_t *input); int libatari800_mount_disk_image(int diskno, const char *filename, int readonly); int libatari800_reboot_with_file(const char *filename); UBYTE *libatari800_get_main_memory_ptr(); UBYTE *libatari800_get_screen_ptr(); cpu_state_t *libatari800_get_cpu_ptr(); void libatari800_get_current_state(emulator_state_t *state); void libatari800_restore_state(emulator_state_t *state); #ifdef __cplusplus } #endif #endif /* LIBATARI800_H_ */
a1d4b98eb4733bc59da11a08a1eb96d934107c9b
2308899071a849a199e3b70806b4dd1c396efc8a
/md5/md5assert.h
cd3cd63cde482f962471832ff030703a2cdb3bcf
[ "MIT" ]
permissive
cyd01/KiTTY
b0b06d771508668ccbd6316474382b538a65bac0
0e5d8582aad192db96ba240444a6840fa82ccf05
refs/heads/master
2023-08-10T21:25:06.926589
2023-05-23T17:23:03
2023-05-23T17:56:00
154,540,955
1,451
147
NOASSERTION
2023-05-30T17:16:10
2018-10-24T17:26:24
C
UTF-8
C
false
false
350
h
md5assert.h
#ifndef __ASSERT_H__ #define __ASSERT_H__ #define _str(x) #x #define str(x) _str(x) #ifndef NDEBUG extern VOID NORETURN _assert(LPCTSTR, UINT, LPCTSTR); #define assert(x) ((x) ? SetLastErrorEx(0, SLE_WARNING) : _assert(TEXT(__FILE__), __LINE__, TEXT(#x))) #else #define assert(x) ((void) (x)) #endif #endif
416430b594c1f9c99f22f20953575b0dc3c8ef3e
f9e7d65cb784c01a0200145ba8d289afe41d4a56
/board/berknip/led.c
20421866230668e829dbc11230a7f23a5961fadd
[ "BSD-3-Clause" ]
permissive
FrameworkComputer/EmbeddedController
ad7086769e87d0a4179eae96a7c9ff5e383ff54e
f6d6b927eed71550d3475411cfc3e59abe5cef2a
refs/heads/hx20-hx30
2023-08-08T20:45:10.621169
2023-05-26T07:03:59
2023-05-26T07:03:59
447,021,040
846
48
BSD-3-Clause
2023-05-26T07:04:59
2022-01-12T00:11:14
C
UTF-8
C
false
false
5,018
c
led.c
/* Copyright 2020 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. */ #include "battery.h" #include "charge_manager.h" #include "charge_state.h" #include "chipset.h" #include "ec_commands.h" #include "gpio.h" #include "host_command.h" #include "led_common.h" #include "hooks.h" #define BAT_LED_ON 0 #define BAT_LED_OFF 1 #define POWER_LED_ON 0 #define POWER_LED_OFF 1 #define LED_TICKS_PER_CYCLE 10 #define LED_ON_TICKS 5 const enum ec_led_id supported_led_ids[] = { EC_LED_ID_LEFT_LED, EC_LED_ID_RIGHT_LED, }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); enum led_color { LED_OFF = 0, LED_AMBER, LED_WHITE, LED_COLOR_COUNT /* Number of colors, not a color itself */ }; enum led_port { RIGHT_PORT = 0, LEFT_PORT }; static void led_set_color_battery(int port, enum led_color color) { enum gpio_signal amber_led, white_led; amber_led = (port == RIGHT_PORT ? GPIO_LED_CHRG_L : GPIO_C1_CHARGE_LED_AMBER_DB_L); white_led = (port == RIGHT_PORT ? GPIO_LED_FULL_L : GPIO_C1_CHARGE_LED_WHITE_DB_L); switch (color) { case LED_WHITE: gpio_set_level(white_led, BAT_LED_ON); gpio_set_level(amber_led, BAT_LED_OFF); break; case LED_AMBER: gpio_set_level(white_led, BAT_LED_OFF); gpio_set_level(amber_led, BAT_LED_ON); break; case LED_OFF: gpio_set_level(white_led, BAT_LED_OFF); gpio_set_level(amber_led, BAT_LED_OFF); break; default: break; } } void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { switch (led_id) { case EC_LED_ID_LEFT_LED: brightness_range[EC_LED_COLOR_WHITE] = 1; brightness_range[EC_LED_COLOR_AMBER] = 1; break; case EC_LED_ID_RIGHT_LED: brightness_range[EC_LED_COLOR_WHITE] = 1; brightness_range[EC_LED_COLOR_AMBER] = 1; break; default: break; } } int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { switch (led_id) { case EC_LED_ID_LEFT_LED: if (brightness[EC_LED_COLOR_WHITE] != 0) led_set_color_battery(LEFT_PORT, LED_WHITE); else if (brightness[EC_LED_COLOR_AMBER] != 0) led_set_color_battery(LEFT_PORT, LED_AMBER); else led_set_color_battery(LEFT_PORT, LED_OFF); break; case EC_LED_ID_RIGHT_LED: if (brightness[EC_LED_COLOR_WHITE] != 0) led_set_color_battery(RIGHT_PORT, LED_WHITE); else if (brightness[EC_LED_COLOR_AMBER] != 0) led_set_color_battery(RIGHT_PORT, LED_AMBER); else led_set_color_battery(RIGHT_PORT, LED_OFF); break; default: return EC_ERROR_PARAM1; } return EC_SUCCESS; } /* * Set active charge port color to the parameter, turn off all others. * If no port is active (-1), turn off all LEDs. */ static void set_active_port_color(enum led_color color) { int port = charge_manager_get_active_charge_port(); if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) led_set_color_battery(RIGHT_PORT, (port == RIGHT_PORT) ? color : LED_OFF); if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) led_set_color_battery(LEFT_PORT, (port == LEFT_PORT) ? color : LED_OFF); } static void led_set_battery(void) { static int battery_ticks; static int power_ticks; uint32_t chflags = charge_get_flags(); battery_ticks++; /* * Override battery LEDs for Berknip, Berknip is non-power LED * design, blinking both two side battery white LEDs to indicate * system suspend with non-charging state. */ if (chipset_in_state(CHIPSET_STATE_SUSPEND | CHIPSET_STATE_STANDBY) && charge_get_state() != PWR_STATE_CHARGE) { power_ticks++; led_set_color_battery(RIGHT_PORT, power_ticks & 0x4 ? LED_WHITE : LED_OFF); led_set_color_battery(LEFT_PORT, power_ticks & 0x4 ? LED_WHITE : LED_OFF); return; } power_ticks = 0; switch (charge_get_state()) { case PWR_STATE_CHARGE: /* Always indicate when charging, even in suspend. */ set_active_port_color(LED_AMBER); break; case PWR_STATE_DISCHARGE: if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) { if (charge_get_percent() < 10) led_set_color_battery(RIGHT_PORT, (battery_ticks % LED_TICKS_PER_CYCLE < LED_ON_TICKS) ? LED_WHITE : LED_OFF); else led_set_color_battery(RIGHT_PORT, LED_OFF); } if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) led_set_color_battery(LEFT_PORT, LED_OFF); break; case PWR_STATE_ERROR: set_active_port_color((battery_ticks & 0x2) ? LED_WHITE : LED_OFF); break; case PWR_STATE_CHARGE_NEAR_FULL: set_active_port_color(LED_WHITE); break; case PWR_STATE_IDLE: /* External power connected in IDLE */ if (chflags & CHARGE_FLAG_FORCE_IDLE) set_active_port_color((battery_ticks % LED_TICKS_PER_CYCLE < LED_ON_TICKS) ? LED_AMBER : LED_OFF); else set_active_port_color(LED_WHITE); break; default: /* Other states don't alter LED behavior */ break; } } /* Called by hook task every TICK */ static void led_tick(void) { led_set_battery(); } DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);
d2969b0c57b3c19a9731968ab1729bf738cb0b02
b732361d6b3405c3e79ac0a7d8361cf5b329b015
/ext/phalcon/mvc/model/metadata/strategy/annotations.zep.c
d5a21d567a55c38a79e6e71a9781626eae38075d
[ "BSD-3-Clause" ]
permissive
phalcon/cphalcon
4a5b26f47b5c2a4107541d7fd73c595c0d90ed73
fc183e11e8b96c43daf7d893244846206dc2aa73
refs/heads/master
2023-03-07T22:09:48.814291
2023-02-28T16:45:15
2023-02-28T16:45:15
2,854,337
8,135
2,343
BSD-3-Clause
2023-09-12T12:41:13
2011-11-26T05:52:50
PHP
UTF-8
C
false
true
48,960
c
annotations.zep.c
#ifdef HAVE_CONFIG_H #include "../../../../../ext_config.h" #endif #include <php.h> #include "../../../../../php_ext.h" #include "../../../../../ext.h" #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> #include "kernel/main.h" #include "kernel/exception.h" #include "kernel/fcall.h" #include "kernel/memory.h" #include "kernel/object.h" #include "kernel/concat.h" #include "kernel/operators.h" #include "kernel/array.h" /** * This file is part of the Phalcon Framework. * * (c) Phalcon Team <team@phalcon.io> * * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Strategy_Annotations) { ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\MetaData\\Strategy, Annotations, phalcon, mvc_model_metadata_strategy_annotations, phalcon_mvc_model_metadata_strategy_annotations_method_entry, 0); zend_class_implements(phalcon_mvc_model_metadata_strategy_annotations_ce, 1, phalcon_mvc_model_metadata_strategy_strategyinterface_ce); return SUCCESS; } /** * Read the model's column map, this can't be inferred */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Annotations, getColumnMaps) { zend_string *_8; zend_ulong _7; zend_bool hasReversedColumn = 0, _11$$6, _14$$10; zval orderedColumnMap, reversedColumnMap; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *model, model_sub, *container, container_sub, __$null, annotations, className, reflection, propertiesAnnotations, property, propAnnotations, columnAnnotation, columnName, _0, *_5, _6, _1$$4, _2$$4, _3$$5, _4$$5, _9$$6, _10$$6, _12$$10, _13$$10; zval *this_ptr = getThis(); ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&container_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&annotations); ZVAL_UNDEF(&className); ZVAL_UNDEF(&reflection); ZVAL_UNDEF(&propertiesAnnotations); ZVAL_UNDEF(&property); ZVAL_UNDEF(&propAnnotations); ZVAL_UNDEF(&columnAnnotation); ZVAL_UNDEF(&columnName); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$5); ZVAL_UNDEF(&_4$$5); ZVAL_UNDEF(&_9$$6); ZVAL_UNDEF(&_10$$6); ZVAL_UNDEF(&_12$$10); ZVAL_UNDEF(&_13$$10); ZVAL_UNDEF(&orderedColumnMap); ZVAL_UNDEF(&reversedColumnMap); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &container); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector is invalid", "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 32); return; } ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "annotations"); ZEPHIR_CALL_METHOD(&annotations, container, "get", NULL, 0, &_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(&className); zephir_get_class(&className, model, 0); ZEPHIR_CALL_METHOD(&reflection, &annotations, "get", NULL, 0, &className); zephir_check_call_status(); if (UNEXPECTED(Z_TYPE_P(&reflection) != IS_OBJECT)) { ZEPHIR_INIT_VAR(&_1$$4); object_init_ex(&_1$$4, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(&_2$$4); ZEPHIR_CONCAT_SV(&_2$$4, "No annotations were found in class ", &className); ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 29, &_2$$4); zephir_check_call_status(); zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 43); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&propertiesAnnotations, &reflection, "getpropertiesannotations", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!(zephir_fast_count_int(&propertiesAnnotations)))) { ZEPHIR_INIT_VAR(&_3$$5); object_init_ex(&_3$$5, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(&_4$$5); ZEPHIR_CONCAT_SV(&_4$$5, "No properties with annotations were found in class ", &className); ZEPHIR_CALL_METHOD(NULL, &_3$$5, "__construct", NULL, 29, &_4$$5); zephir_check_call_status(); zephir_throw_exception_debug(&_3$$5, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 54); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&orderedColumnMap); array_init(&orderedColumnMap); ZEPHIR_INIT_VAR(&reversedColumnMap); array_init(&reversedColumnMap); hasReversedColumn = 0; zephir_is_iterable(&propertiesAnnotations, 0, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 91); if (Z_TYPE_P(&propertiesAnnotations) == IS_ARRAY) { ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&propertiesAnnotations), _7, _8, _5) { ZEPHIR_INIT_NVAR(&property); if (_8 != NULL) { ZVAL_STR_COPY(&property, _8); } else { ZVAL_LONG(&property, _7); } ZEPHIR_INIT_NVAR(&propAnnotations); ZVAL_COPY(&propAnnotations, _5); ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "Column"); ZEPHIR_CALL_METHOD(&_9$$6, &propAnnotations, "has", NULL, 0, &_10$$6); zephir_check_call_status(); if (!(zephir_is_true(&_9$$6))) { continue; } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "Column"); ZEPHIR_CALL_METHOD(&columnAnnotation, &propAnnotations, "get", NULL, 0, &_10$$6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "column"); ZEPHIR_CALL_METHOD(&columnName, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(&columnName)) { ZEPHIR_CPY_WRT(&columnName, &property); } zephir_array_update_zval(&orderedColumnMap, &columnName, &property, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&reversedColumnMap, &property, &columnName, PH_COPY | PH_SEPARATE); _11$$6 = !hasReversedColumn; if (_11$$6) { _11$$6 = !ZEPHIR_IS_EQUAL(&columnName, &property); } if (_11$$6) { hasReversedColumn = 1; } } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &propertiesAnnotations, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_6, &propertiesAnnotations, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_6)) { break; } ZEPHIR_CALL_METHOD(&property, &propertiesAnnotations, "key", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&propAnnotations, &propertiesAnnotations, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$10); ZVAL_STRING(&_13$$10, "Column"); ZEPHIR_CALL_METHOD(&_12$$10, &propAnnotations, "has", NULL, 0, &_13$$10); zephir_check_call_status(); if (!(zephir_is_true(&_12$$10))) { continue; } ZEPHIR_INIT_NVAR(&_13$$10); ZVAL_STRING(&_13$$10, "Column"); ZEPHIR_CALL_METHOD(&columnAnnotation, &propAnnotations, "get", NULL, 0, &_13$$10); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$10); ZVAL_STRING(&_13$$10, "column"); ZEPHIR_CALL_METHOD(&columnName, &columnAnnotation, "getnamedparameter", NULL, 0, &_13$$10); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(&columnName)) { ZEPHIR_CPY_WRT(&columnName, &property); } zephir_array_update_zval(&orderedColumnMap, &columnName, &property, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&reversedColumnMap, &property, &columnName, PH_COPY | PH_SEPARATE); _14$$10 = !hasReversedColumn; if (_14$$10) { _14$$10 = !ZEPHIR_IS_EQUAL(&columnName, &property); } if (_14$$10) { hasReversedColumn = 1; } ZEPHIR_CALL_METHOD(NULL, &propertiesAnnotations, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&propAnnotations); ZEPHIR_INIT_NVAR(&property); if (!(hasReversedColumn)) { zephir_create_array(return_value, 2, 0); zephir_array_fast_append(return_value, &__$null); zephir_array_fast_append(return_value, &__$null); RETURN_MM(); } zephir_create_array(return_value, 2, 0); zephir_array_fast_append(return_value, &orderedColumnMap); zephir_array_fast_append(return_value, &reversedColumnMap); RETURN_MM(); } /** * The meta-data is obtained by reading the column descriptions from the database information schema */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Annotations, getMetaData) { zend_bool _71$$6, _135$$44; zend_string *_8; zend_ulong _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *model, model_sub, *container, container_sub, __$true, annotations, className, reflection, propertiesAnnotations, property, propAnnotations, columnAnnotation, columnName, feature, fieldTypes, fieldBindTypes, numericTyped, primaryKeys, nonPrimaryKeys, identityField, notNull, attributes, defaultValues, defaultValue, emptyStringValues, skipOnInsert, skipOnUpdate, _0, *_5, _6, _1$$4, _2$$4, _3$$5, _4$$5, _9$$6, _10$$6, _65$$6, _66$$6, _67$$6, _68$$6, _69$$6, _70$$6, _72$$6, _11$$9, _12$$9, _13$$10, _14$$10, _15$$11, _16$$11, _17$$12, _18$$12, _19$$13, _20$$13, _21$$14, _22$$14, _23$$15, _24$$15, _25$$16, _26$$16, _27$$17, _28$$17, _29$$18, _30$$18, _31$$19, _32$$19, _33$$20, _34$$20, _35$$21, _36$$21, _37$$22, _38$$22, _39$$23, _40$$23, _41$$24, _42$$24, _43$$25, _44$$25, _45$$26, _46$$26, _47$$27, _48$$27, _49$$28, _50$$28, _51$$29, _52$$29, _53$$30, _54$$30, _55$$31, _56$$31, _57$$32, _58$$32, _59$$33, _60$$33, _61$$34, _62$$34, _63$$35, _64$$35, _73$$44, _74$$44, _129$$44, _130$$44, _131$$44, _132$$44, _133$$44, _134$$44, _136$$44, _75$$47, _76$$47, _77$$48, _78$$48, _79$$49, _80$$49, _81$$50, _82$$50, _83$$51, _84$$51, _85$$52, _86$$52, _87$$53, _88$$53, _89$$54, _90$$54, _91$$55, _92$$55, _93$$56, _94$$56, _95$$57, _96$$57, _97$$58, _98$$58, _99$$59, _100$$59, _101$$60, _102$$60, _103$$61, _104$$61, _105$$62, _106$$62, _107$$63, _108$$63, _109$$64, _110$$64, _111$$65, _112$$65, _113$$66, _114$$66, _115$$67, _116$$67, _117$$68, _118$$68, _119$$69, _120$$69, _121$$70, _122$$70, _123$$71, _124$$71, _125$$72, _126$$72, _127$$73, _128$$73; zval *this_ptr = getThis(); ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&container_sub); ZVAL_BOOL(&__$true, 1); ZVAL_UNDEF(&annotations); ZVAL_UNDEF(&className); ZVAL_UNDEF(&reflection); ZVAL_UNDEF(&propertiesAnnotations); ZVAL_UNDEF(&property); ZVAL_UNDEF(&propAnnotations); ZVAL_UNDEF(&columnAnnotation); ZVAL_UNDEF(&columnName); ZVAL_UNDEF(&feature); ZVAL_UNDEF(&fieldTypes); ZVAL_UNDEF(&fieldBindTypes); ZVAL_UNDEF(&numericTyped); ZVAL_UNDEF(&primaryKeys); ZVAL_UNDEF(&nonPrimaryKeys); ZVAL_UNDEF(&identityField); ZVAL_UNDEF(&notNull); ZVAL_UNDEF(&attributes); ZVAL_UNDEF(&defaultValues); ZVAL_UNDEF(&defaultValue); ZVAL_UNDEF(&emptyStringValues); ZVAL_UNDEF(&skipOnInsert); ZVAL_UNDEF(&skipOnUpdate); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$5); ZVAL_UNDEF(&_4$$5); ZVAL_UNDEF(&_9$$6); ZVAL_UNDEF(&_10$$6); ZVAL_UNDEF(&_65$$6); ZVAL_UNDEF(&_66$$6); ZVAL_UNDEF(&_67$$6); ZVAL_UNDEF(&_68$$6); ZVAL_UNDEF(&_69$$6); ZVAL_UNDEF(&_70$$6); ZVAL_UNDEF(&_72$$6); ZVAL_UNDEF(&_11$$9); ZVAL_UNDEF(&_12$$9); ZVAL_UNDEF(&_13$$10); ZVAL_UNDEF(&_14$$10); ZVAL_UNDEF(&_15$$11); ZVAL_UNDEF(&_16$$11); ZVAL_UNDEF(&_17$$12); ZVAL_UNDEF(&_18$$12); ZVAL_UNDEF(&_19$$13); ZVAL_UNDEF(&_20$$13); ZVAL_UNDEF(&_21$$14); ZVAL_UNDEF(&_22$$14); ZVAL_UNDEF(&_23$$15); ZVAL_UNDEF(&_24$$15); ZVAL_UNDEF(&_25$$16); ZVAL_UNDEF(&_26$$16); ZVAL_UNDEF(&_27$$17); ZVAL_UNDEF(&_28$$17); ZVAL_UNDEF(&_29$$18); ZVAL_UNDEF(&_30$$18); ZVAL_UNDEF(&_31$$19); ZVAL_UNDEF(&_32$$19); ZVAL_UNDEF(&_33$$20); ZVAL_UNDEF(&_34$$20); ZVAL_UNDEF(&_35$$21); ZVAL_UNDEF(&_36$$21); ZVAL_UNDEF(&_37$$22); ZVAL_UNDEF(&_38$$22); ZVAL_UNDEF(&_39$$23); ZVAL_UNDEF(&_40$$23); ZVAL_UNDEF(&_41$$24); ZVAL_UNDEF(&_42$$24); ZVAL_UNDEF(&_43$$25); ZVAL_UNDEF(&_44$$25); ZVAL_UNDEF(&_45$$26); ZVAL_UNDEF(&_46$$26); ZVAL_UNDEF(&_47$$27); ZVAL_UNDEF(&_48$$27); ZVAL_UNDEF(&_49$$28); ZVAL_UNDEF(&_50$$28); ZVAL_UNDEF(&_51$$29); ZVAL_UNDEF(&_52$$29); ZVAL_UNDEF(&_53$$30); ZVAL_UNDEF(&_54$$30); ZVAL_UNDEF(&_55$$31); ZVAL_UNDEF(&_56$$31); ZVAL_UNDEF(&_57$$32); ZVAL_UNDEF(&_58$$32); ZVAL_UNDEF(&_59$$33); ZVAL_UNDEF(&_60$$33); ZVAL_UNDEF(&_61$$34); ZVAL_UNDEF(&_62$$34); ZVAL_UNDEF(&_63$$35); ZVAL_UNDEF(&_64$$35); ZVAL_UNDEF(&_73$$44); ZVAL_UNDEF(&_74$$44); ZVAL_UNDEF(&_129$$44); ZVAL_UNDEF(&_130$$44); ZVAL_UNDEF(&_131$$44); ZVAL_UNDEF(&_132$$44); ZVAL_UNDEF(&_133$$44); ZVAL_UNDEF(&_134$$44); ZVAL_UNDEF(&_136$$44); ZVAL_UNDEF(&_75$$47); ZVAL_UNDEF(&_76$$47); ZVAL_UNDEF(&_77$$48); ZVAL_UNDEF(&_78$$48); ZVAL_UNDEF(&_79$$49); ZVAL_UNDEF(&_80$$49); ZVAL_UNDEF(&_81$$50); ZVAL_UNDEF(&_82$$50); ZVAL_UNDEF(&_83$$51); ZVAL_UNDEF(&_84$$51); ZVAL_UNDEF(&_85$$52); ZVAL_UNDEF(&_86$$52); ZVAL_UNDEF(&_87$$53); ZVAL_UNDEF(&_88$$53); ZVAL_UNDEF(&_89$$54); ZVAL_UNDEF(&_90$$54); ZVAL_UNDEF(&_91$$55); ZVAL_UNDEF(&_92$$55); ZVAL_UNDEF(&_93$$56); ZVAL_UNDEF(&_94$$56); ZVAL_UNDEF(&_95$$57); ZVAL_UNDEF(&_96$$57); ZVAL_UNDEF(&_97$$58); ZVAL_UNDEF(&_98$$58); ZVAL_UNDEF(&_99$$59); ZVAL_UNDEF(&_100$$59); ZVAL_UNDEF(&_101$$60); ZVAL_UNDEF(&_102$$60); ZVAL_UNDEF(&_103$$61); ZVAL_UNDEF(&_104$$61); ZVAL_UNDEF(&_105$$62); ZVAL_UNDEF(&_106$$62); ZVAL_UNDEF(&_107$$63); ZVAL_UNDEF(&_108$$63); ZVAL_UNDEF(&_109$$64); ZVAL_UNDEF(&_110$$64); ZVAL_UNDEF(&_111$$65); ZVAL_UNDEF(&_112$$65); ZVAL_UNDEF(&_113$$66); ZVAL_UNDEF(&_114$$66); ZVAL_UNDEF(&_115$$67); ZVAL_UNDEF(&_116$$67); ZVAL_UNDEF(&_117$$68); ZVAL_UNDEF(&_118$$68); ZVAL_UNDEF(&_119$$69); ZVAL_UNDEF(&_120$$69); ZVAL_UNDEF(&_121$$70); ZVAL_UNDEF(&_122$$70); ZVAL_UNDEF(&_123$$71); ZVAL_UNDEF(&_124$$71); ZVAL_UNDEF(&_125$$72); ZVAL_UNDEF(&_126$$72); ZVAL_UNDEF(&_127$$73); ZVAL_UNDEF(&_128$$73); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &model, &container); if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector is invalid", "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 113); return; } ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "annotations"); ZEPHIR_CALL_METHOD(&annotations, container, "get", NULL, 0, &_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(&className); zephir_get_class(&className, model, 0); ZEPHIR_CALL_METHOD(&reflection, &annotations, "get", NULL, 0, &className); zephir_check_call_status(); if (UNEXPECTED(Z_TYPE_P(&reflection) != IS_OBJECT)) { ZEPHIR_INIT_VAR(&_1$$4); object_init_ex(&_1$$4, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(&_2$$4); ZEPHIR_CONCAT_SV(&_2$$4, "No annotations were found in class ", &className); ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 29, &_2$$4); zephir_check_call_status(); zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 124); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&propertiesAnnotations, &reflection, "getpropertiesannotations", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!(zephir_fast_count_int(&propertiesAnnotations)))) { ZEPHIR_INIT_VAR(&_3$$5); object_init_ex(&_3$$5, phalcon_mvc_model_exception_ce); ZEPHIR_INIT_VAR(&_4$$5); ZEPHIR_CONCAT_SV(&_4$$5, "No properties with annotations were found in class ", &className); ZEPHIR_CALL_METHOD(NULL, &_3$$5, "__construct", NULL, 29, &_4$$5); zephir_check_call_status(); zephir_throw_exception_debug(&_3$$5, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 135); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&attributes); array_init(&attributes); ZEPHIR_INIT_VAR(&primaryKeys); array_init(&primaryKeys); ZEPHIR_INIT_VAR(&nonPrimaryKeys); array_init(&nonPrimaryKeys); ZEPHIR_INIT_VAR(&numericTyped); array_init(&numericTyped); ZEPHIR_INIT_VAR(&notNull); array_init(&notNull); ZEPHIR_INIT_VAR(&fieldTypes); array_init(&fieldTypes); ZEPHIR_INIT_VAR(&fieldBindTypes); array_init(&fieldBindTypes); ZEPHIR_INIT_VAR(&identityField); ZVAL_BOOL(&identityField, 0); ZEPHIR_INIT_VAR(&skipOnInsert); array_init(&skipOnInsert); ZEPHIR_INIT_VAR(&skipOnUpdate); array_init(&skipOnUpdate); ZEPHIR_INIT_VAR(&defaultValues); array_init(&defaultValues); ZEPHIR_INIT_VAR(&emptyStringValues); array_init(&emptyStringValues); zephir_is_iterable(&propertiesAnnotations, 0, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 392); if (Z_TYPE_P(&propertiesAnnotations) == IS_ARRAY) { ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&propertiesAnnotations), _7, _8, _5) { ZEPHIR_INIT_NVAR(&property); if (_8 != NULL) { ZVAL_STR_COPY(&property, _8); } else { ZVAL_LONG(&property, _7); } ZEPHIR_INIT_NVAR(&propAnnotations); ZVAL_COPY(&propAnnotations, _5); ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "Column"); ZEPHIR_CALL_METHOD(&_9$$6, &propAnnotations, "has", NULL, 0, &_10$$6); zephir_check_call_status(); if (!(zephir_is_true(&_9$$6))) { continue; } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "Column"); ZEPHIR_CALL_METHOD(&columnAnnotation, &propAnnotations, "get", NULL, 0, &_10$$6); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "column"); ZEPHIR_CALL_METHOD(&columnName, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(&columnName)) { ZEPHIR_CPY_WRT(&columnName, &property); } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "type"); ZEPHIR_CALL_METHOD(&feature, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); do { if (ZEPHIR_IS_STRING(&feature, "biginteger")) { ZEPHIR_INIT_NVAR(&_11$$9); ZVAL_LONG(&_11$$9, 14); zephir_array_update_zval(&fieldTypes, &columnName, &_11$$9, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_12$$9); ZVAL_LONG(&_12$$9, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_12$$9, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "bit")) { ZEPHIR_INIT_NVAR(&_13$$10); ZVAL_LONG(&_13$$10, 19); zephir_array_update_zval(&fieldTypes, &columnName, &_13$$10, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_14$$10); ZVAL_LONG(&_14$$10, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_14$$10, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "blob")) { ZEPHIR_INIT_NVAR(&_15$$11); ZVAL_LONG(&_15$$11, 11); zephir_array_update_zval(&fieldTypes, &columnName, &_15$$11, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_16$$11); ZVAL_LONG(&_16$$11, 3); zephir_array_update_zval(&fieldBindTypes, &columnName, &_16$$11, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "boolean")) { ZEPHIR_INIT_NVAR(&_17$$12); ZVAL_LONG(&_17$$12, 8); zephir_array_update_zval(&fieldTypes, &columnName, &_17$$12, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_18$$12); ZVAL_LONG(&_18$$12, 5); zephir_array_update_zval(&fieldBindTypes, &columnName, &_18$$12, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "char")) { ZEPHIR_INIT_NVAR(&_19$$13); ZVAL_LONG(&_19$$13, 5); zephir_array_update_zval(&fieldTypes, &columnName, &_19$$13, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_20$$13); ZVAL_LONG(&_20$$13, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_20$$13, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "date")) { ZEPHIR_INIT_NVAR(&_21$$14); ZVAL_LONG(&_21$$14, 1); zephir_array_update_zval(&fieldTypes, &columnName, &_21$$14, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_22$$14); ZVAL_LONG(&_22$$14, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_22$$14, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "datetime")) { ZEPHIR_INIT_NVAR(&_23$$15); ZVAL_LONG(&_23$$15, 4); zephir_array_update_zval(&fieldTypes, &columnName, &_23$$15, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_24$$15); ZVAL_LONG(&_24$$15, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_24$$15, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "decimal")) { ZEPHIR_INIT_NVAR(&_25$$16); ZVAL_LONG(&_25$$16, 3); zephir_array_update_zval(&fieldTypes, &columnName, &_25$$16, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_26$$16); ZVAL_LONG(&_26$$16, 32); zephir_array_update_zval(&fieldBindTypes, &columnName, &_26$$16, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "double")) { ZEPHIR_INIT_NVAR(&_27$$17); ZVAL_LONG(&_27$$17, 9); zephir_array_update_zval(&fieldTypes, &columnName, &_27$$17, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_28$$17); ZVAL_LONG(&_28$$17, 32); zephir_array_update_zval(&fieldBindTypes, &columnName, &_28$$17, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "enum")) { ZEPHIR_INIT_NVAR(&_29$$18); ZVAL_LONG(&_29$$18, 18); zephir_array_update_zval(&fieldTypes, &columnName, &_29$$18, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_30$$18); ZVAL_LONG(&_30$$18, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_30$$18, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "float")) { ZEPHIR_INIT_NVAR(&_31$$19); ZVAL_LONG(&_31$$19, 7); zephir_array_update_zval(&fieldTypes, &columnName, &_31$$19, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_32$$19); ZVAL_LONG(&_32$$19, 32); zephir_array_update_zval(&fieldBindTypes, &columnName, &_32$$19, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "integer")) { ZEPHIR_INIT_NVAR(&_33$$20); ZVAL_LONG(&_33$$20, 0); zephir_array_update_zval(&fieldTypes, &columnName, &_33$$20, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_34$$20); ZVAL_LONG(&_34$$20, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_34$$20, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "json")) { ZEPHIR_INIT_NVAR(&_35$$21); ZVAL_LONG(&_35$$21, 15); zephir_array_update_zval(&fieldTypes, &columnName, &_35$$21, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_36$$21); ZVAL_LONG(&_36$$21, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_36$$21, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "jsonb")) { ZEPHIR_INIT_NVAR(&_37$$22); ZVAL_LONG(&_37$$22, 16); zephir_array_update_zval(&fieldTypes, &columnName, &_37$$22, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_38$$22); ZVAL_LONG(&_38$$22, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_38$$22, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "longblob")) { ZEPHIR_INIT_NVAR(&_39$$23); ZVAL_LONG(&_39$$23, 13); zephir_array_update_zval(&fieldTypes, &columnName, &_39$$23, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_40$$23); ZVAL_LONG(&_40$$23, 3); zephir_array_update_zval(&fieldBindTypes, &columnName, &_40$$23, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "longtext")) { ZEPHIR_INIT_NVAR(&_41$$24); ZVAL_LONG(&_41$$24, 24); zephir_array_update_zval(&fieldTypes, &columnName, &_41$$24, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_42$$24); ZVAL_LONG(&_42$$24, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_42$$24, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "mediumblob")) { ZEPHIR_INIT_NVAR(&_43$$25); ZVAL_LONG(&_43$$25, 12); zephir_array_update_zval(&fieldTypes, &columnName, &_43$$25, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_44$$25); ZVAL_LONG(&_44$$25, 3); zephir_array_update_zval(&fieldBindTypes, &columnName, &_44$$25, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "mediumint")) { ZEPHIR_INIT_NVAR(&_45$$26); ZVAL_LONG(&_45$$26, 21); zephir_array_update_zval(&fieldTypes, &columnName, &_45$$26, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_46$$26); ZVAL_LONG(&_46$$26, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_46$$26, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "mediumtext")) { ZEPHIR_INIT_NVAR(&_47$$27); ZVAL_LONG(&_47$$27, 23); zephir_array_update_zval(&fieldTypes, &columnName, &_47$$27, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_48$$27); ZVAL_LONG(&_48$$27, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_48$$27, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "smallint")) { ZEPHIR_INIT_NVAR(&_49$$28); ZVAL_LONG(&_49$$28, 22); zephir_array_update_zval(&fieldTypes, &columnName, &_49$$28, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_50$$28); ZVAL_LONG(&_50$$28, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_50$$28, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "text")) { ZEPHIR_INIT_NVAR(&_51$$29); ZVAL_LONG(&_51$$29, 6); zephir_array_update_zval(&fieldTypes, &columnName, &_51$$29, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_52$$29); ZVAL_LONG(&_52$$29, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_52$$29, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "time")) { ZEPHIR_INIT_NVAR(&_53$$30); ZVAL_LONG(&_53$$30, 20); zephir_array_update_zval(&fieldTypes, &columnName, &_53$$30, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_54$$30); ZVAL_LONG(&_54$$30, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_54$$30, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "timestamp")) { ZEPHIR_INIT_NVAR(&_55$$31); ZVAL_LONG(&_55$$31, 17); zephir_array_update_zval(&fieldTypes, &columnName, &_55$$31, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_56$$31); ZVAL_LONG(&_56$$31, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_56$$31, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "tinyblob")) { ZEPHIR_INIT_NVAR(&_57$$32); ZVAL_LONG(&_57$$32, 10); zephir_array_update_zval(&fieldTypes, &columnName, &_57$$32, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_58$$32); ZVAL_LONG(&_58$$32, 3); zephir_array_update_zval(&fieldBindTypes, &columnName, &_58$$32, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "tinyint")) { ZEPHIR_INIT_NVAR(&_59$$33); ZVAL_LONG(&_59$$33, 26); zephir_array_update_zval(&fieldTypes, &columnName, &_59$$33, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_60$$33); ZVAL_LONG(&_60$$33, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_60$$33, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "tinytext")) { ZEPHIR_INIT_NVAR(&_61$$34); ZVAL_LONG(&_61$$34, 25); zephir_array_update_zval(&fieldTypes, &columnName, &_61$$34, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_62$$34); ZVAL_LONG(&_62$$34, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_62$$34, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(&_63$$35); ZVAL_LONG(&_63$$35, 2); zephir_array_update_zval(&fieldTypes, &columnName, &_63$$35, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_64$$35); ZVAL_LONG(&_64$$35, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_64$$35, PH_COPY | PH_SEPARATE); } while(0); ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "Primary"); ZEPHIR_CALL_METHOD(&_65$$6, &propAnnotations, "has", NULL, 0, &_10$$6); zephir_check_call_status(); if (zephir_is_true(&_65$$6)) { zephir_array_append(&primaryKeys, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 336); } else { zephir_array_append(&nonPrimaryKeys, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 338); } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "Identity"); ZEPHIR_CALL_METHOD(&_66$$6, &propAnnotations, "has", NULL, 0, &_10$$6); zephir_check_call_status(); if (zephir_is_true(&_66$$6)) { ZEPHIR_CPY_WRT(&identityField, &columnName); } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "skip_on_insert"); ZEPHIR_CALL_METHOD(&_67$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); if (zephir_is_true(&_67$$6)) { zephir_array_append(&skipOnInsert, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 353); } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "skip_on_update"); ZEPHIR_CALL_METHOD(&_68$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); if (zephir_is_true(&_68$$6)) { zephir_array_append(&skipOnUpdate, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 360); } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "allow_empty_string"); ZEPHIR_CALL_METHOD(&_69$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); if (zephir_is_true(&_69$$6)) { zephir_array_append(&emptyStringValues, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 367); } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "nullable"); ZEPHIR_CALL_METHOD(&_70$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); if (!(zephir_is_true(&_70$$6))) { zephir_array_append(&notNull, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 374); } ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "default"); ZEPHIR_CALL_METHOD(&defaultValue, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); _71$$6 = Z_TYPE_P(&defaultValue) != IS_NULL; if (!(_71$$6)) { ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_STRING(&_10$$6, "nullable"); ZEPHIR_CALL_METHOD(&_72$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); zephir_check_call_status(); _71$$6 = zephir_is_true(&_72$$6); } if (_71$$6) { zephir_array_update_zval(&defaultValues, &columnName, &defaultValue, PH_COPY | PH_SEPARATE); } zephir_array_append(&attributes, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 386); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &propertiesAnnotations, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_6, &propertiesAnnotations, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_6)) { break; } ZEPHIR_CALL_METHOD(&property, &propertiesAnnotations, "key", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&propAnnotations, &propertiesAnnotations, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "Column"); ZEPHIR_CALL_METHOD(&_73$$44, &propAnnotations, "has", NULL, 0, &_74$$44); zephir_check_call_status(); if (!(zephir_is_true(&_73$$44))) { continue; } ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "Column"); ZEPHIR_CALL_METHOD(&columnAnnotation, &propAnnotations, "get", NULL, 0, &_74$$44); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "column"); ZEPHIR_CALL_METHOD(&columnName, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); zephir_check_call_status(); if (ZEPHIR_IS_EMPTY(&columnName)) { ZEPHIR_CPY_WRT(&columnName, &property); } ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "type"); ZEPHIR_CALL_METHOD(&feature, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); zephir_check_call_status(); do { if (ZEPHIR_IS_STRING(&feature, "biginteger")) { ZEPHIR_INIT_NVAR(&_75$$47); ZVAL_LONG(&_75$$47, 14); zephir_array_update_zval(&fieldTypes, &columnName, &_75$$47, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_76$$47); ZVAL_LONG(&_76$$47, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_76$$47, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "bit")) { ZEPHIR_INIT_NVAR(&_77$$48); ZVAL_LONG(&_77$$48, 19); zephir_array_update_zval(&fieldTypes, &columnName, &_77$$48, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_78$$48); ZVAL_LONG(&_78$$48, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_78$$48, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "blob")) { ZEPHIR_INIT_NVAR(&_79$$49); ZVAL_LONG(&_79$$49, 11); zephir_array_update_zval(&fieldTypes, &columnName, &_79$$49, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_80$$49); ZVAL_LONG(&_80$$49, 3); zephir_array_update_zval(&fieldBindTypes, &columnName, &_80$$49, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "boolean")) { ZEPHIR_INIT_NVAR(&_81$$50); ZVAL_LONG(&_81$$50, 8); zephir_array_update_zval(&fieldTypes, &columnName, &_81$$50, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_82$$50); ZVAL_LONG(&_82$$50, 5); zephir_array_update_zval(&fieldBindTypes, &columnName, &_82$$50, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "char")) { ZEPHIR_INIT_NVAR(&_83$$51); ZVAL_LONG(&_83$$51, 5); zephir_array_update_zval(&fieldTypes, &columnName, &_83$$51, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_84$$51); ZVAL_LONG(&_84$$51, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_84$$51, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "date")) { ZEPHIR_INIT_NVAR(&_85$$52); ZVAL_LONG(&_85$$52, 1); zephir_array_update_zval(&fieldTypes, &columnName, &_85$$52, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_86$$52); ZVAL_LONG(&_86$$52, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_86$$52, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "datetime")) { ZEPHIR_INIT_NVAR(&_87$$53); ZVAL_LONG(&_87$$53, 4); zephir_array_update_zval(&fieldTypes, &columnName, &_87$$53, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_88$$53); ZVAL_LONG(&_88$$53, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_88$$53, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "decimal")) { ZEPHIR_INIT_NVAR(&_89$$54); ZVAL_LONG(&_89$$54, 3); zephir_array_update_zval(&fieldTypes, &columnName, &_89$$54, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_90$$54); ZVAL_LONG(&_90$$54, 32); zephir_array_update_zval(&fieldBindTypes, &columnName, &_90$$54, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "double")) { ZEPHIR_INIT_NVAR(&_91$$55); ZVAL_LONG(&_91$$55, 9); zephir_array_update_zval(&fieldTypes, &columnName, &_91$$55, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_92$$55); ZVAL_LONG(&_92$$55, 32); zephir_array_update_zval(&fieldBindTypes, &columnName, &_92$$55, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "enum")) { ZEPHIR_INIT_NVAR(&_93$$56); ZVAL_LONG(&_93$$56, 18); zephir_array_update_zval(&fieldTypes, &columnName, &_93$$56, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_94$$56); ZVAL_LONG(&_94$$56, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_94$$56, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "float")) { ZEPHIR_INIT_NVAR(&_95$$57); ZVAL_LONG(&_95$$57, 7); zephir_array_update_zval(&fieldTypes, &columnName, &_95$$57, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_96$$57); ZVAL_LONG(&_96$$57, 32); zephir_array_update_zval(&fieldBindTypes, &columnName, &_96$$57, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "integer")) { ZEPHIR_INIT_NVAR(&_97$$58); ZVAL_LONG(&_97$$58, 0); zephir_array_update_zval(&fieldTypes, &columnName, &_97$$58, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_98$$58); ZVAL_LONG(&_98$$58, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_98$$58, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "json")) { ZEPHIR_INIT_NVAR(&_99$$59); ZVAL_LONG(&_99$$59, 15); zephir_array_update_zval(&fieldTypes, &columnName, &_99$$59, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_100$$59); ZVAL_LONG(&_100$$59, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_100$$59, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "jsonb")) { ZEPHIR_INIT_NVAR(&_101$$60); ZVAL_LONG(&_101$$60, 16); zephir_array_update_zval(&fieldTypes, &columnName, &_101$$60, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_102$$60); ZVAL_LONG(&_102$$60, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_102$$60, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "longblob")) { ZEPHIR_INIT_NVAR(&_103$$61); ZVAL_LONG(&_103$$61, 13); zephir_array_update_zval(&fieldTypes, &columnName, &_103$$61, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_104$$61); ZVAL_LONG(&_104$$61, 3); zephir_array_update_zval(&fieldBindTypes, &columnName, &_104$$61, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "longtext")) { ZEPHIR_INIT_NVAR(&_105$$62); ZVAL_LONG(&_105$$62, 24); zephir_array_update_zval(&fieldTypes, &columnName, &_105$$62, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_106$$62); ZVAL_LONG(&_106$$62, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_106$$62, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "mediumblob")) { ZEPHIR_INIT_NVAR(&_107$$63); ZVAL_LONG(&_107$$63, 12); zephir_array_update_zval(&fieldTypes, &columnName, &_107$$63, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_108$$63); ZVAL_LONG(&_108$$63, 3); zephir_array_update_zval(&fieldBindTypes, &columnName, &_108$$63, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "mediumint")) { ZEPHIR_INIT_NVAR(&_109$$64); ZVAL_LONG(&_109$$64, 21); zephir_array_update_zval(&fieldTypes, &columnName, &_109$$64, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_110$$64); ZVAL_LONG(&_110$$64, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_110$$64, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "mediumtext")) { ZEPHIR_INIT_NVAR(&_111$$65); ZVAL_LONG(&_111$$65, 23); zephir_array_update_zval(&fieldTypes, &columnName, &_111$$65, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_112$$65); ZVAL_LONG(&_112$$65, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_112$$65, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "smallint")) { ZEPHIR_INIT_NVAR(&_113$$66); ZVAL_LONG(&_113$$66, 22); zephir_array_update_zval(&fieldTypes, &columnName, &_113$$66, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_114$$66); ZVAL_LONG(&_114$$66, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_114$$66, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "text")) { ZEPHIR_INIT_NVAR(&_115$$67); ZVAL_LONG(&_115$$67, 6); zephir_array_update_zval(&fieldTypes, &columnName, &_115$$67, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_116$$67); ZVAL_LONG(&_116$$67, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_116$$67, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "time")) { ZEPHIR_INIT_NVAR(&_117$$68); ZVAL_LONG(&_117$$68, 20); zephir_array_update_zval(&fieldTypes, &columnName, &_117$$68, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_118$$68); ZVAL_LONG(&_118$$68, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_118$$68, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "timestamp")) { ZEPHIR_INIT_NVAR(&_119$$69); ZVAL_LONG(&_119$$69, 17); zephir_array_update_zval(&fieldTypes, &columnName, &_119$$69, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_120$$69); ZVAL_LONG(&_120$$69, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_120$$69, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "tinyblob")) { ZEPHIR_INIT_NVAR(&_121$$70); ZVAL_LONG(&_121$$70, 10); zephir_array_update_zval(&fieldTypes, &columnName, &_121$$70, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_122$$70); ZVAL_LONG(&_122$$70, 3); zephir_array_update_zval(&fieldBindTypes, &columnName, &_122$$70, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "tinyint")) { ZEPHIR_INIT_NVAR(&_123$$71); ZVAL_LONG(&_123$$71, 26); zephir_array_update_zval(&fieldTypes, &columnName, &_123$$71, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_124$$71); ZVAL_LONG(&_124$$71, 1); zephir_array_update_zval(&fieldBindTypes, &columnName, &_124$$71, PH_COPY | PH_SEPARATE); zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); break; } if (ZEPHIR_IS_STRING(&feature, "tinytext")) { ZEPHIR_INIT_NVAR(&_125$$72); ZVAL_LONG(&_125$$72, 25); zephir_array_update_zval(&fieldTypes, &columnName, &_125$$72, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_126$$72); ZVAL_LONG(&_126$$72, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_126$$72, PH_COPY | PH_SEPARATE); break; } ZEPHIR_INIT_NVAR(&_127$$73); ZVAL_LONG(&_127$$73, 2); zephir_array_update_zval(&fieldTypes, &columnName, &_127$$73, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(&_128$$73); ZVAL_LONG(&_128$$73, 2); zephir_array_update_zval(&fieldBindTypes, &columnName, &_128$$73, PH_COPY | PH_SEPARATE); } while(0); ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "Primary"); ZEPHIR_CALL_METHOD(&_129$$44, &propAnnotations, "has", NULL, 0, &_74$$44); zephir_check_call_status(); if (zephir_is_true(&_129$$44)) { zephir_array_append(&primaryKeys, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 336); } else { zephir_array_append(&nonPrimaryKeys, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 338); } ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "Identity"); ZEPHIR_CALL_METHOD(&_130$$44, &propAnnotations, "has", NULL, 0, &_74$$44); zephir_check_call_status(); if (zephir_is_true(&_130$$44)) { ZEPHIR_CPY_WRT(&identityField, &columnName); } ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "skip_on_insert"); ZEPHIR_CALL_METHOD(&_131$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); zephir_check_call_status(); if (zephir_is_true(&_131$$44)) { zephir_array_append(&skipOnInsert, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 353); } ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "skip_on_update"); ZEPHIR_CALL_METHOD(&_132$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); zephir_check_call_status(); if (zephir_is_true(&_132$$44)) { zephir_array_append(&skipOnUpdate, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 360); } ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "allow_empty_string"); ZEPHIR_CALL_METHOD(&_133$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); zephir_check_call_status(); if (zephir_is_true(&_133$$44)) { zephir_array_append(&emptyStringValues, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 367); } ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "nullable"); ZEPHIR_CALL_METHOD(&_134$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); zephir_check_call_status(); if (!(zephir_is_true(&_134$$44))) { zephir_array_append(&notNull, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 374); } ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "default"); ZEPHIR_CALL_METHOD(&defaultValue, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); zephir_check_call_status(); _135$$44 = Z_TYPE_P(&defaultValue) != IS_NULL; if (!(_135$$44)) { ZEPHIR_INIT_NVAR(&_74$$44); ZVAL_STRING(&_74$$44, "nullable"); ZEPHIR_CALL_METHOD(&_136$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); zephir_check_call_status(); _135$$44 = zephir_is_true(&_136$$44); } if (_135$$44) { zephir_array_update_zval(&defaultValues, &columnName, &defaultValue, PH_COPY | PH_SEPARATE); } zephir_array_append(&attributes, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 386); ZEPHIR_CALL_METHOD(NULL, &propertiesAnnotations, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&propAnnotations); ZEPHIR_INIT_NVAR(&property); zephir_create_array(return_value, 12, 0); zephir_array_update_long(return_value, 0, &attributes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 1, &primaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 2, &nonPrimaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 3, &notNull, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 4, &fieldTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 5, &numericTyped, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 8, &identityField, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 9, &fieldBindTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 10, &skipOnInsert, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 11, &skipOnUpdate, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 12, &defaultValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); zephir_array_update_long(return_value, 13, &emptyStringValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); RETURN_MM(); }
553e8bfe9d85b3126c6de94d11fe7023519bc1ee
20e1c2f5cfac01f6b007124fa7792dd69751a6bb
/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h
6c3a818df69ef291ea37272f759f15f5465c6a7c
[ "Apache-2.0" ]
permissive
nasa/osal
71f159b767ba4a8c39df48f238b4f296cc571ac8
99e3b4007da51031b521d90390526e123ff740b4
refs/heads/main
2023-09-01T06:33:53.932829
2023-08-18T14:27:02
2023-08-18T14:27:02
4,814,601
493
229
Apache-2.0
2023-09-13T13:57:40
2012-06-27T23:10:37
C
UTF-8
C
false
false
1,740
h
ut-adaptor-binsem.h
/************************************************************************ * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” * * Copyright (c) 2020 United States Government as represented by the * Administrator of the National Aeronautics and Space Administration. * All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ************************************************************************/ /** * \file * \ingroup adaptors * * Declarations and prototypes for ut-adaptor-binsem */ #ifndef UT_ADAPTOR_BINSEM_H #define UT_ADAPTOR_BINSEM_H #include "common_types.h" #include "utstubs.h" #include "OCS_taskLib.h" #include "OCS_semLib.h" extern void *const UT_Ref_OS_impl_bin_sem_table; extern size_t const UT_Ref_OS_impl_bin_sem_table_SIZE; /* * This also needs to expose the keys for the stubs to * helper functions that the test case needs to configure. * * This is because the test case cannot directly include * the internal header file which provides this API. */ extern const UT_EntryKey_t UT_StubKey_GenericSemTake; extern const UT_EntryKey_t UT_StubKey_GenericSemGive; extern int32 UT_Call_OS_VxWorks_BinSemAPI_Impl_Init(void); #endif /* UT_ADAPTOR_BINSEM_H */
55e3c408cba0ef2d0264467f059c9223e4be8d77
aa3befea459382dc5c01c925653d54f435b3fb0f
/wireless/bluetooth/bt_keys.h
2eb8c9633b1a021688c5e517eda9dd259e96b010
[ "MIT-open-group", "BSD-3-Clause", "HPND-sell-variant", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "MIT-0", "LicenseRef-scancode-bsd-atmel", "LicenseRef-scancode-gary-s-brown", "LicenseRef-scancode-proprietary-license", "SunPro", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "LicenseRef-scancode-other-permissive", "HPND", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "GPL-1.0-or-later", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
apache/nuttx
14519a7bff4a87935d94fb8fb2b19edb501c7cec
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
refs/heads/master
2023-08-25T06:55:45.822534
2023-08-23T16:03:31
2023-08-24T21:25:47
228,103,273
407
241
Apache-2.0
2023-09-14T18:26:05
2019-12-14T23:27:55
C
UTF-8
C
false
false
3,603
h
bt_keys.h
/**************************************************************************** * wireless/bluetooth/bt_keys.h * * Copyright (c) 2016, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS * ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> /**************************************************************************** * Public Types ****************************************************************************/ enum { BT_KEYS_SLAVE_LTK = (1 << 0), BT_KEYS_IRK = (1 << 1), BT_KEYS_LTK = (1 << 2), BT_KEYS_LOCAL_CSRK = (1 << 3), BT_KEYS_REMOTE_CSRK = (1 << 4), BT_KEYS_ALL = (BT_KEYS_SLAVE_LTK | BT_KEYS_IRK | BT_KEYS_LTK | BT_KEYS_LOCAL_CSRK | BT_KEYS_REMOTE_CSRK), }; struct bt_ltk_s { uint64_t rand; uint16_t ediv; uint8_t val[16]; FAR struct bt_keys_s *next; }; struct bt_irk_s { uint8_t val[16]; bt_addr_t rpa; FAR struct bt_keys_s *next; }; struct bt_csrk_s { uint8_t val[16]; uint32_t cnt; FAR struct bt_keys_s *next; }; struct bt_keys_s { bt_addr_le_t addr; int keys; struct bt_ltk_s slave_ltk; struct bt_ltk_s ltk; struct bt_irk_s irk; struct bt_csrk_s local_csrk; struct bt_csrk_s remote_csrk; }; /**************************************************************************** * Public Function Prototypes ****************************************************************************/ FAR struct bt_keys_s *bt_keys_get_addr(FAR const bt_addr_le_t *addr); FAR struct bt_keys_s *bt_keys_get_type(int type, FAR const bt_addr_le_t *addr); void bt_keys_add_type(FAR struct bt_keys_s *keys, int type); void bt_keys_clear(FAR struct bt_keys_s *keys, int type); FAR struct bt_keys_s *bt_keys_find(int type, FAR const bt_addr_le_t *addr); FAR struct bt_keys_s *bt_keys_find_irk(FAR const bt_addr_le_t *addr);
31ad2f1d1e7cf483e213990621edfb28f847748c
76a81265e2d29de91fb65b03ce7dff00894802a0
/tools/applegcr.h
5c8d612a1bb4b3ae79ec56f8c2a87d31374644c2
[ "MIT" ]
permissive
picosonic/bbc-fdc
6c4f8d3fb33842d34f4aab29fff607afb82264c5
b3d0b82ec4dac05753d47955da3bf300382ac51b
refs/heads/master
2022-08-09T18:19:03.668696
2022-07-25T11:48:01
2022-07-25T11:48:01
83,670,462
240
23
MIT
2021-03-03T11:10:03
2017-03-02T11:29:05
C
UTF-8
C
false
false
592
h
applegcr.h
#ifndef _APPLEGCR_H_ #define _APPLEGCR_H_ // State machine #define APPLEGCR_IDLE 0 #define APPLEGCR_ID 1 #define APPLEGCR_DATA 2 // GCR encoding types #define APPLEGCR_DATA_53 410 #define APPLEGCR_DATA_62 342 #define APPLEGCR_SECTORLEN 256 // Ideal bitcell width at 300 RPM #define APPLEGCR_BITCELL 4 extern int applegcr_idamtrack, applegcr_idamsector; extern int applegcr_lasttrack, applegcr_lastsector; extern void applegcr_addsample(const unsigned long samples, const unsigned long datapos, const int usepll); extern void applegcr_init(const int debug, const char density); #endif
ccdda4ac5231466bbdca0f09c7a5a3f42ec90c53
24017cc0b56b68e19e76a5ee36f16ea5db04e69b
/lib/facil/http/http1.h
d9ee93b143cca20d453b6f6946ceb7446cc46c53
[ "MIT", "LicenseRef-scancode-public-domain" ]
permissive
boazsegev/facil.io
45376dafd161618551091d1b300f2ca3d6cd9a31
7b8e5fcf5e945d07df92aca7728909c5887a80fc
refs/heads/master
2023-08-09T08:43:42.285506
2021-12-11T16:09:59
2021-12-11T16:13:13
49,816,276
1,822
153
MIT
2023-02-12T12:59:14
2016-01-17T12:28:48
C
UTF-8
C
false
false
693
h
http1.h
/* Copyright: Boaz Segev, 2017-2019 License: MIT */ #ifndef H_HTTP1_H #define H_HTTP1_H #include <http.h> #ifndef HTTP1_READ_BUFFER /** * The size of a single `read` command, it sets the limit for an HTTP/1.1 * header line. */ #define HTTP1_READ_BUFFER (8 * 1024) /* ~8kb */ #endif /** Creates an HTTP1 protocol object and handles any unread data in the buffer * (if any). */ fio_protocol_s *http1_new(uintptr_t uuid, http_settings_s *settings, void *unread_data, size_t unread_length); /** Manually destroys the HTTP1 protocol object. */ void http1_destroy(fio_protocol_s *); /** returns the HTTP/1.1 protocol's VTable. */ void *http1_vtable(void); #endif
6ab917c3bee0a95539c03b097565ee03176f1a2b
b8969d48bbb69227db21f8446a3be4955363b694
/ntvdmpatch/src/ldntvdm/ldntvdm/consbmpxpbug.h
24c3b34064049a5375086c2de6067d1972b5b8c1
[]
no_license
leecher1337/ntvdmx64
dc0e6428e531b661836dd9543016016d98bf7b24
0f7f33e295024b81681d506cc86b8606960ef713
refs/heads/master
2023-07-26T13:52:27.549799
2023-07-09T14:33:29
2023-07-09T14:33:29
60,649,860
696
91
null
2020-08-23T19:41:36
2016-06-07T22:09:12
C
UTF-8
C
false
false
34
h
consbmpxpbug.h
BOOL ConsBmpXpBug_Install(void);
6e7a4ab56f079f67466c80254a22bb79bc5b8888
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/infiniband/hw/qib/qib_srq.c
d6235931a1ba867afdd87806317891122ff38f51
[ "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
9,447
c
qib_srq.c
/* * Copyright (c) 2006, 2007, 2008, 2009 QLogic Corporation. All rights reserved. * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <linux/err.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include "qib_verbs.h" /** * qib_post_srq_receive - post a receive on a shared receive queue * @ibsrq: the SRQ to post the receive on * @wr: the list of work requests to post * @bad_wr: A pointer to the first WR to cause a problem is put here * * This may be called from interrupt context. */ int qib_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr, struct ib_recv_wr **bad_wr) { struct qib_srq *srq = to_isrq(ibsrq); struct qib_rwq *wq; unsigned long flags; int ret; for (; wr; wr = wr->next) { struct qib_rwqe *wqe; u32 next; int i; if ((unsigned) wr->num_sge > srq->rq.max_sge) { *bad_wr = wr; ret = -EINVAL; goto bail; } spin_lock_irqsave(&srq->rq.lock, flags); wq = srq->rq.wq; next = wq->head + 1; if (next >= srq->rq.size) next = 0; if (next == wq->tail) { spin_unlock_irqrestore(&srq->rq.lock, flags); *bad_wr = wr; ret = -ENOMEM; goto bail; } wqe = get_rwqe_ptr(&srq->rq, wq->head); wqe->wr_id = wr->wr_id; wqe->num_sge = wr->num_sge; for (i = 0; i < wr->num_sge; i++) wqe->sg_list[i] = wr->sg_list[i]; /* Make sure queue entry is written before the head index. */ smp_wmb(); wq->head = next; spin_unlock_irqrestore(&srq->rq.lock, flags); } ret = 0; bail: return ret; } /** * qib_create_srq - create a shared receive queue * @ibpd: the protection domain of the SRQ to create * @srq_init_attr: the attributes of the SRQ * @udata: data from libibverbs when creating a user SRQ */ struct ib_srq *qib_create_srq(struct ib_pd *ibpd, struct ib_srq_init_attr *srq_init_attr, struct ib_udata *udata) { struct qib_ibdev *dev = to_idev(ibpd->device); struct qib_srq *srq; u32 sz; struct ib_srq *ret; if (srq_init_attr->srq_type != IB_SRQT_BASIC) { ret = ERR_PTR(-ENOSYS); goto done; } if (srq_init_attr->attr.max_sge == 0 || srq_init_attr->attr.max_sge > ib_qib_max_srq_sges || srq_init_attr->attr.max_wr == 0 || srq_init_attr->attr.max_wr > ib_qib_max_srq_wrs) { ret = ERR_PTR(-EINVAL); goto done; } srq = kmalloc(sizeof(*srq), GFP_KERNEL); if (!srq) { ret = ERR_PTR(-ENOMEM); goto done; } /* * Need to use vmalloc() if we want to support large #s of entries. */ srq->rq.size = srq_init_attr->attr.max_wr + 1; srq->rq.max_sge = srq_init_attr->attr.max_sge; sz = sizeof(struct ib_sge) * srq->rq.max_sge + sizeof(struct qib_rwqe); srq->rq.wq = vmalloc_user(sizeof(struct qib_rwq) + srq->rq.size * sz); if (!srq->rq.wq) { ret = ERR_PTR(-ENOMEM); goto bail_srq; } /* * Return the address of the RWQ as the offset to mmap. * See qib_mmap() for details. */ if (udata && udata->outlen >= sizeof(__u64)) { int err; u32 s = sizeof(struct qib_rwq) + srq->rq.size * sz; srq->ip = qib_create_mmap_info(dev, s, ibpd->uobject->context, srq->rq.wq); if (!srq->ip) { ret = ERR_PTR(-ENOMEM); goto bail_wq; } err = ib_copy_to_udata(udata, &srq->ip->offset, sizeof(srq->ip->offset)); if (err) { ret = ERR_PTR(err); goto bail_ip; } } else srq->ip = NULL; /* * ib_create_srq() will initialize srq->ibsrq. */ spin_lock_init(&srq->rq.lock); srq->rq.wq->head = 0; srq->rq.wq->tail = 0; srq->limit = srq_init_attr->attr.srq_limit; spin_lock(&dev->n_srqs_lock); if (dev->n_srqs_allocated == ib_qib_max_srqs) { spin_unlock(&dev->n_srqs_lock); ret = ERR_PTR(-ENOMEM); goto bail_ip; } dev->n_srqs_allocated++; spin_unlock(&dev->n_srqs_lock); if (srq->ip) { spin_lock_irq(&dev->pending_lock); list_add(&srq->ip->pending_mmaps, &dev->pending_mmaps); spin_unlock_irq(&dev->pending_lock); } ret = &srq->ibsrq; goto done; bail_ip: kfree(srq->ip); bail_wq: vfree(srq->rq.wq); bail_srq: kfree(srq); done: return ret; } /** * qib_modify_srq - modify a shared receive queue * @ibsrq: the SRQ to modify * @attr: the new attributes of the SRQ * @attr_mask: indicates which attributes to modify * @udata: user data for libibverbs.so */ int qib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, enum ib_srq_attr_mask attr_mask, struct ib_udata *udata) { struct qib_srq *srq = to_isrq(ibsrq); struct qib_rwq *wq; int ret = 0; if (attr_mask & IB_SRQ_MAX_WR) { struct qib_rwq *owq; struct qib_rwqe *p; u32 sz, size, n, head, tail; /* Check that the requested sizes are below the limits. */ if ((attr->max_wr > ib_qib_max_srq_wrs) || ((attr_mask & IB_SRQ_LIMIT) ? attr->srq_limit : srq->limit) > attr->max_wr) { ret = -EINVAL; goto bail; } sz = sizeof(struct qib_rwqe) + srq->rq.max_sge * sizeof(struct ib_sge); size = attr->max_wr + 1; wq = vmalloc_user(sizeof(struct qib_rwq) + size * sz); if (!wq) { ret = -ENOMEM; goto bail; } /* Check that we can write the offset to mmap. */ if (udata && udata->inlen >= sizeof(__u64)) { __u64 offset_addr; __u64 offset = 0; ret = ib_copy_from_udata(&offset_addr, udata, sizeof(offset_addr)); if (ret) goto bail_free; udata->outbuf = (void __user *) (unsigned long) offset_addr; ret = ib_copy_to_udata(udata, &offset, sizeof(offset)); if (ret) goto bail_free; } spin_lock_irq(&srq->rq.lock); /* * validate head and tail pointer values and compute * the number of remaining WQEs. */ owq = srq->rq.wq; head = owq->head; tail = owq->tail; if (head >= srq->rq.size || tail >= srq->rq.size) { ret = -EINVAL; goto bail_unlock; } n = head; if (n < tail) n += srq->rq.size - tail; else n -= tail; if (size <= n) { ret = -EINVAL; goto bail_unlock; } n = 0; p = wq->wq; while (tail != head) { struct qib_rwqe *wqe; int i; wqe = get_rwqe_ptr(&srq->rq, tail); p->wr_id = wqe->wr_id; p->num_sge = wqe->num_sge; for (i = 0; i < wqe->num_sge; i++) p->sg_list[i] = wqe->sg_list[i]; n++; p = (struct qib_rwqe *)((char *) p + sz); if (++tail >= srq->rq.size) tail = 0; } srq->rq.wq = wq; srq->rq.size = size; wq->head = n; wq->tail = 0; if (attr_mask & IB_SRQ_LIMIT) srq->limit = attr->srq_limit; spin_unlock_irq(&srq->rq.lock); vfree(owq); if (srq->ip) { struct qib_mmap_info *ip = srq->ip; struct qib_ibdev *dev = to_idev(srq->ibsrq.device); u32 s = sizeof(struct qib_rwq) + size * sz; qib_update_mmap_info(dev, ip, s, wq); /* * Return the offset to mmap. * See qib_mmap() for details. */ if (udata && udata->inlen >= sizeof(__u64)) { ret = ib_copy_to_udata(udata, &ip->offset, sizeof(ip->offset)); if (ret) goto bail; } /* * Put user mapping info onto the pending list * unless it already is on the list. */ spin_lock_irq(&dev->pending_lock); if (list_empty(&ip->pending_mmaps)) list_add(&ip->pending_mmaps, &dev->pending_mmaps); spin_unlock_irq(&dev->pending_lock); } } else if (attr_mask & IB_SRQ_LIMIT) { spin_lock_irq(&srq->rq.lock); if (attr->srq_limit >= srq->rq.size) ret = -EINVAL; else srq->limit = attr->srq_limit; spin_unlock_irq(&srq->rq.lock); } goto bail; bail_unlock: spin_unlock_irq(&srq->rq.lock); bail_free: vfree(wq); bail: return ret; } int qib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr) { struct qib_srq *srq = to_isrq(ibsrq); attr->max_wr = srq->rq.size - 1; attr->max_sge = srq->rq.max_sge; attr->srq_limit = srq->limit; return 0; } /** * qib_destroy_srq - destroy a shared receive queue * @ibsrq: the SRQ to destroy */ int qib_destroy_srq(struct ib_srq *ibsrq) { struct qib_srq *srq = to_isrq(ibsrq); struct qib_ibdev *dev = to_idev(ibsrq->device); spin_lock(&dev->n_srqs_lock); dev->n_srqs_allocated--; spin_unlock(&dev->n_srqs_lock); if (srq->ip) kref_put(&srq->ip->ref, qib_release_mmap_info); else vfree(srq->rq.wq); kfree(srq); return 0; }
6c4aab107a851bb348c95bff6ffd99a57460772c
2d11442aa09b51e10c245ee2b64231aeb051744f
/platforms/unix/plugins/FileAttributesPlugin/faSupport.h
d23feab342ff6b01c84b5ec5e7aa1ea979b5755f
[ "MIT" ]
permissive
OpenSmalltalk/opensmalltalk-vm
622b01c10017a93fdff4f1ef2188c45342384c78
330d6779ad2ecbce1f07131f53d75cd168165f0b
refs/heads/Cog
2023-09-04T05:36:54.320281
2023-08-17T11:32:52
2023-08-31T12:26:44
59,481,716
556
153
NOASSERTION
2023-06-19T19:58:13
2016-05-23T12:40:27
C
UTF-8
C
false
false
2,836
h
faSupport.h
/* * faSupport.h - Unix macro and type definitions for FileAttributesPlugin */ #include <dirent.h> #include <sys/stat.h> /* Maximum path length allowed on this platform */ #define FA_PATH_MAX PATH_MAX #define PATH_SEPARATOR '/' #include "sqUnixCharConv.h" /* * Set the structure used by stat(). */ typedef struct stat faStatStruct; /* * fapath * * fapath is used to pass path names between smalltalk and the primitives. * The structure holds the path name in Smalltalk format (precomposed UTF8) * and the platform format (Wide Strings for Windows). * Set and Get functions are used to ensure that the two formats are always * kept in sync. * * State information for iterating over directories is also held by fapath. * The directory (path) being enumerated and the current file name are stored * in a single string (path) to simplify stat()ing the file. * * path - The path name in precomposed UTF8 encoding (Smalltalk encoding). * path_len - length of path. * path_file - When iterating over a directory, this points to the * character after the trailing path separator. * The current file will be stored here and is used to * stat() each file. * max_file_len - The space remaining after the path for the file name. * * uxpath, uxpath_len, uxpath_file and uxmax_file_len are the Unix * encoded equivalents: * - UTF8 for Linux * - HFS specific decomposed UTF8 for OSX */ typedef struct fapathstruct { char path[FA_PATH_MAX]; sqInt path_len; char *path_file; sqInt max_file_len; char uxpath[FA_PATH_MAX]; sqInt uxpath_len; char *uxpath_file; sqInt uxmax_file_len; DIR *platformDir; } fapath; sqInt faSetStDir(fapath *aFaPath, char *pathName, int len); sqInt faSetStPath(fapath *aFaPath, char *pathName, int len); sqInt faSetStFile(fapath *aFaPath, char *pathName); sqInt faSetPlatPath(fapath *aFaPath, char *pathName); sqInt faSetPlatPathOop(fapath *aFaPath, sqInt pathNameOop); sqInt faSetPlatFile(fapath *aFaPath, char *pathName); #define faGetStPath(aFaPath) (aFaPath)->path #define faGetStPathLen(aFaPath) (aFaPath)->path_len #define faGetStFile(aFaPath) (aFaPath)->path_file #define faGetPlatPath(aFaPath) (aFaPath)->uxpath #define faGetPlatFile(aFaPath) (aFaPath)->uxpath_file #define faGetPlatPathByteCount(aFaPath) ((aFaPath)->uxpath_len * sizeof(char)) #define faExists(aFaPath) (!access(faGetPlatPath(aFaPath), F_OK)) sqLong faConvertUnixToLongSqueakTime(time_t unixTime); sqInt faOpenDirectory(fapath *aFaPath); sqInt faReadDirectory(fapath *aFaPath); sqInt faCloseDirectory(fapath *aFaPath); sqInt faRewindDirectory(fapath *aFaPath); sqInt faFileAttribute(fapath *aFaPath, sqInt attributeNumber); sqInt faFileStatAttributes(fapath *aFaPath, int lStat, sqInt attributeArray); sqInt faAccessAttributes(fapath *aFaPath, sqInt attributeArray, sqInt offset);
e5bc4e267937ccdd2a8275ca27ece76ea532db52
52c8ed39b32ccc7c0673278c1adea3638797c9ff
/src/include/input/rc/rc-core.h
fa0c0050aa139f34c743c3170cdcbe55fa90e87e
[ "MIT" ]
permissive
xboot/xboot
0cab7b440b612aa0a4c366025598a53a7ec3adf1
6d6b93947b7fcb8c3924fedb0715c23877eedd5e
refs/heads/master
2023-08-20T05:56:25.149388
2023-07-12T07:38:29
2023-07-12T07:38:29
471,539
765
296
MIT
2023-05-25T09:39:01
2010-01-14T08:25:12
C
UTF-8
C
false
false
518
h
rc-core.h
#ifndef __RC_CORE_H__ #define __RC_CORE_H__ #ifdef __cplusplus extern "C" { #endif #include <xboot.h> #include <input/input.h> #include <input/keyboard.h> #include <input/rc/rc-decoder-nec.h> struct rc_map_t { uint32_t scancode; uint32_t keycode; }; struct rc_decoder_t { struct rc_decoder_nec_t nec; struct rc_map_t * map; int size; }; uint32_t rc_decoder_handle(struct rc_decoder_t * decoder, int pulse, int duration); #ifdef __cplusplus } #endif #endif /* __RC_CORE_H__ */
d54a4daa96a85bbdfe268467105a41fb395099a9
dbc5fd6f0b741d07aca08cff31fe88d2f62e8483
/tools/clang/test/zapcc/single/duplicate/duplicate-macrotype-function.h
89074da8099c59be3cbcb86d8c3b13685b2c4311
[ "LicenseRef-scancode-unknown-license-reference", "NCSA" ]
permissive
yrnkrn/zapcc
647246a2ed860f73adb49fa1bd21333d972ff76b
c6a8aa30006d997eff0d60fd37b0e62b8aa0ea50
refs/heads/master
2023-03-08T22:55:12.842122
2020-07-21T10:21:59
2020-07-21T10:21:59
137,340,494
1,255
88
NOASSERTION
2020-07-21T10:22:01
2018-06-14T10:00:31
C++
UTF-8
C
false
false
106
h
duplicate-macrotype-function.h
#define VOID void VOID DuplicateMacrotypeFunction(const char *); VOID DuplicateMacrotypeFunction(double);
b4574c25bfeedb45bf5ab76d54695c128ce385ee
54f59bfc9d657e35f52762fd7ac5a5034c301dfb
/src/secp256k1/src/modules/musig/session.h
dfaa5e0d00f7ed85b0e3bf92dfea736cbaec8998
[ "MIT" ]
permissive
ElementsProject/elements
a8db662b18b27f7f0162bc76e98d23b2ca80727d
93cc036edfc855ea7e8a357897958cb55bbce369
refs/heads/master
2023-08-31T13:24:12.360307
2023-08-24T20:51:08
2023-08-24T20:51:08
37,064,937
1,064
436
MIT
2023-08-29T17:49:35
2015-06-08T12:17:33
C++
UTF-8
C
false
false
934
h
session.h
/*********************************************************************** * Copyright (c) 2021 Jonas Nick * * Distributed under the MIT software license, see the accompanying * * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ #ifndef SECP256K1_MODULE_MUSIG_SESSION_H #define SECP256K1_MODULE_MUSIG_SESSION_H #include "../../../include/secp256k1.h" #include "../../../include/secp256k1_musig.h" #include "../../scalar.h" typedef struct { int fin_nonce_parity; unsigned char fin_nonce[32]; secp256k1_scalar noncecoef; secp256k1_scalar challenge; secp256k1_scalar s_part; } secp256k1_musig_session_internal; static int secp256k1_musig_session_load(const secp256k1_context* ctx, secp256k1_musig_session_internal *session_i, const secp256k1_musig_session *session); #endif
b651855608835538481fd96d7aa708c082fd2098
76f9898ff7a555f4a729d725056a317af818375d
/assets/objects/object_wallmaster/object_wallmaster.h
83b6d7045014462744d3d6f1d821f6e08c5f3b2a
[]
no_license
z64proto/sw97
0b65837ab2f2a4073faca5670761d7fe0e74d29d
f571505ade2cefd4a5b5d19da06d33e7c6b02c60
refs/heads/master
2023-08-01T02:47:42.895871
2022-05-15T20:29:08
2022-05-15T20:29:08
430,216,978
208
29
null
2021-11-22T12:23:50
2021-11-20T21:52:59
C
UTF-8
C
false
false
4,448
h
object_wallmaster.h
extern AnimationHeader gWallmasterBJumpAnim; extern AnimationHeader gWallmasterDamageAnim; extern AnimationHeader gWallmasterRecoverFromDamageAnim; extern AnimationHeader gWallmasterFJumpAnim; extern AnimationHeader gFloormasterTurnAnim; extern AnimationHeader gWallmasterLungeAnim; extern AnimationHeader gWallmasterMissAnim; extern AnimationHeader gFloormasterTapFingerAnim; extern AnimationHeader gWallmasterWalkAnim; extern AnimationHeader gWallmasterStopWalkAnim; extern AnimationHeader gWallmasterHoverAnim; extern AnimationHeader gWallmasterWaitAnim; extern Gfx object_wallmasterDlist0x005750[]; extern Gfx object_wallmasterDlist0x005940[]; extern Gfx wm_body_model[]; extern Gfx object_wallmasterDlist0x005C88[]; extern Gfx object_wallmasterDlist0x005E10[]; extern Gfx wm_hito1_model[]; extern Gfx object_wallmasterDlist0x005F98[]; extern Gfx object_wallmasterDlist0x0060B8[]; extern Gfx wm_hito2_model[]; extern Gfx object_wallmasterDlist0x0061F0[]; extern Gfx object_wallmasterDlist0x006360[]; extern Gfx wm_hito3_model[]; extern Gfx object_wallmasterDlist0x006498[]; extern Gfx object_wallmasterDlist0x006620[]; extern Gfx wm_ko1_model[]; extern Gfx object_wallmasterDlist0x0067A8[]; extern Gfx object_wallmasterDlist0x0068C8[]; extern Gfx wm_ko2_model[]; extern Gfx object_wallmasterDlist0x006A10[]; extern Gfx object_wallmasterDlist0x006B80[]; extern Gfx wm_ko3_model[]; extern Gfx object_wallmasterDlist0x006C88[]; extern Gfx object_wallmasterDlist0x006E10[]; extern Gfx wm_naka1_model[]; extern Gfx object_wallmasterDlist0x006F88[]; extern Gfx object_wallmasterDlist0x0070A8[]; extern Gfx wm_naka2_model[]; extern Gfx object_wallmasterDlist0x0071D0[]; extern Gfx object_wallmasterDlist0x007340[]; extern Gfx wm_naka3_model[]; extern Gfx object_wallmasterDlist0x007448[]; extern Gfx object_wallmasterDlist0x007588[]; extern Gfx wm_neck_model[]; extern Gfx object_wallmasterDlist0x0076B0[]; extern Gfx object_wallmasterDlist0x007840[]; extern Gfx wm_oya1_model[]; extern Gfx object_wallmasterDlist0x007A18[]; extern Gfx object_wallmasterDlist0x007BA0[]; extern Gfx wm_oya2_model[]; extern Gfx object_wallmasterDlist0x007D38[]; extern Gfx object_wallmasterDlist0x007EA8[]; extern Gfx wm_oya3_model[]; extern u64 object_wallmasterTex_007FB0[]; extern u64 object_wallmasterTex_0081B0[]; extern u64 object_wallmasterTex_0083B0[]; extern u64 object_wallmasterTex_0084B0[]; extern u64 object_wallmasterTex_008CB0[]; extern StandardLimb sallmaster_wait_mdl_infoLimb_008EB0; extern StandardLimb sallmaster_wait_mdl_infoLimb_008EBC; extern StandardLimb sallmaster_wait_mdl_infoLimb_008EC8; extern StandardLimb sallmaster_wait_mdl_infoLimb_008ED4; extern StandardLimb sallmaster_wait_mdl_infoLimb_008EE0; extern StandardLimb sallmaster_wait_mdl_infoLimb_008EEC; extern StandardLimb sallmaster_wait_mdl_infoLimb_008EF8; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F04; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F10; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F1C; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F28; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F34; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F40; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F4C; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F58; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F64; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F70; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F7C; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F88; extern StandardLimb sallmaster_wait_mdl_infoLimb_008F94; extern StandardLimb sallmaster_wait_mdl_infoLimb_008FA0; extern StandardLimb sallmaster_wait_mdl_infoLimb_008FAC; extern StandardLimb sallmaster_wait_mdl_infoLimb_008FB8; extern StandardLimb sallmaster_wait_mdl_infoLimb_008FC4; extern StandardLimb sallmaster_wait_mdl_infoLimb_008FD0; extern StandardLimb sallmaster_wait_mdl_infoLimb_008FDC; extern StandardLimb sallmaster_wait_mdl_infoLimb_008FE8; extern StandardLimb sallmaster_wait_mdl_infoLimb_008FF4; extern StandardLimb sallmaster_wait_mdl_infoLimb_009000; extern StandardLimb sallmaster_wait_mdl_infoLimb_00900C; extern StandardLimb sallmaster_wait_mdl_infoLimb_009018; extern StandardLimb sallmaster_wait_mdl_infoLimb_009024; extern StandardLimb sallmaster_wait_mdl_infoLimb_009030; extern StandardLimb sallmaster_wait_mdl_infoLimb_00903C; extern SkeletonHeader gWallmasterSkel; extern AnimationHeader gWallmasterStandUpAnim;
a10c7d78b361794ff83ac79cd7ef4a19b375e4e2
cfb156de35a7f3987f88d6b025c762921f5e9931
/tests/headers/posix/termios_h.c
1255c162f24ad9d55cb1c96be8b57900a68a3c31
[ "Apache-2.0", "BSD-2-Clause" ]
permissive
aosp-mirror/platform_bionic
6faa82304cb67f3347a9b04f2f0eb712444d764a
143f3cea320becbfc836309fade5dfa1074731d0
refs/heads/master
2023-07-08T07:44:02.618070
2023-06-26T23:35:08
2023-06-26T23:35:08
65,830
300
131
null
2018-11-05T20:53:52
2008-10-21T18:19:55
Objective-C
UTF-8
C
false
false
3,981
c
termios_h.c
/* * Copyright (C) 2017 The Android Open Source 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: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <termios.h> #include "header_checks.h" static void termios_h() { TYPE(cc_t); TYPE(speed_t); TYPE(tcflag_t); TYPE(struct termios); STRUCT_MEMBER(struct termios, tcflag_t, c_iflag); STRUCT_MEMBER(struct termios, tcflag_t, c_oflag); STRUCT_MEMBER(struct termios, tcflag_t, c_cflag); STRUCT_MEMBER(struct termios, tcflag_t, c_lflag); STRUCT_MEMBER_ARRAY(struct termios, cc_t/*[]*/, c_cc); MACRO(NCCS); MACRO(VEOF); MACRO(VEOL); MACRO(VERASE); MACRO(VINTR); MACRO(VKILL); MACRO(VMIN); MACRO(VQUIT); MACRO(VSTART); MACRO(VSTOP); MACRO(VSUSP); MACRO(VTIME); MACRO(BRKINT); MACRO(ICRNL); MACRO(IGNBRK); MACRO(IGNCR); MACRO(IGNPAR); MACRO(INLCR); MACRO(INPCK); MACRO(ISTRIP); MACRO(IXANY); MACRO(IXOFF); MACRO(IXON); MACRO(PARMRK); MACRO(OPOST); MACRO(ONLCR); MACRO(OCRNL); MACRO(ONOCR); MACRO(ONLRET); MACRO(OFDEL); MACRO(OFILL); MACRO(NLDLY); MACRO(NL0); MACRO(NL1); MACRO(CRDLY); MACRO(CR0); MACRO(CR1); MACRO(CR2); MACRO(CR3); MACRO(TABDLY); MACRO(TAB0); MACRO(TAB1); MACRO(TAB2); MACRO(TAB3); MACRO(BSDLY); MACRO(BS0); MACRO(BS1); MACRO(VTDLY); MACRO(VT0); MACRO(VT1); MACRO(FFDLY); MACRO(FF0); MACRO(FF1); MACRO(B0); MACRO(B50); MACRO(B75); MACRO(B110); MACRO(B134); MACRO(B150); MACRO(B200); MACRO(B300); MACRO(B600); MACRO(B1200); MACRO(B1800); MACRO(B2400); MACRO(B4800); MACRO(B9600); MACRO(B19200); MACRO(B38400); MACRO(CSIZE); MACRO(CS5); MACRO(CS6); MACRO(CS7); MACRO(CS8); MACRO(CSTOPB); MACRO(CREAD); MACRO(PARENB); MACRO(PARODD); MACRO(HUPCL); MACRO(CLOCAL); MACRO(ECHO); MACRO(ECHOE); MACRO(ECHOK); MACRO(ECHONL); MACRO(ICANON); MACRO(IEXTEN); MACRO(ISIG); MACRO(NOFLSH); MACRO(TOSTOP); MACRO(TCSANOW); MACRO(TCSADRAIN); MACRO(TCSAFLUSH); MACRO(TCIFLUSH); MACRO(TCIOFLUSH); MACRO(TCOFLUSH); MACRO(TCIOFF); MACRO(TCION); MACRO(TCOOFF); MACRO(TCOON); TYPE(pid_t); FUNCTION(cfgetispeed, speed_t (*f)(const struct termios*)); FUNCTION(cfgetospeed, speed_t (*f)(const struct termios*)); FUNCTION(cfsetispeed, int (*f)(struct termios*, speed_t)); FUNCTION(cfsetospeed, int (*f)(struct termios*, speed_t)); FUNCTION(tcdrain, int (*f)(int)); FUNCTION(tcflow, int (*f)(int, int)); FUNCTION(tcflush, int (*f)(int, int)); FUNCTION(tcgetattr, int (*f)(int, struct termios*)); FUNCTION(tcgetsid, pid_t (*f)(int)); FUNCTION(tcsendbreak, int (*f)(int, int)); FUNCTION(tcsetattr, int (*f)(int, int, const struct termios*)); }
948c92de48b49f19977aba2b06033b0fb927d5ac
198bb3ac9175436978f47b45900eab24dc76cdac
/src/Core/OOVoxel.h
4c4e07f019a0ca1cba31b4da552fbdb20ca9f7d1
[]
no_license
OoliteProject/oolite
fd1c96c6a9eab40d0d4901866a47d7d8fa5d511d
377ecde334a0ff4a0df24153c0de272d2311377a
refs/heads/master
2023-08-25T01:19:35.702819
2023-08-21T16:28:59
2023-08-21T16:28:59
10,004,412
457
107
null
2023-09-13T09:26:53
2013-05-11T19:50:30
Objective-C
UTF-8
C
false
false
1,305
h
OOVoxel.h
/* OOVoxel.h Mathematical framework for Oolite. Primitive functions used for octree intersection tests. Oolite Copyright (C) 2004-2013 Giles C Williams and contributors This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_OOMATHS_h #error Do not include OOVoxel.h directly; include OOMaths.h. #else #define CUBE_FACE_RIGHT 0x01 #define CUBE_FACE_LEFT 0x02 #define CUBE_FACE_TOP 0x04 #define CUBE_FACE_BOTTOM 0x08 #define CUBE_FACE_FRONT 0x10 #define CUBE_FACE_BACK 0x20 Vector lineIntersectionWithFace(Vector p1, Vector p2, long mask, GLfloat rd) CONST_FUNC; int lineCubeIntersection(Vector v0, Vector v1, GLfloat rd) CONST_FUNC; #endif
ef09e4e60520a337acb5f549ffdad80be57701be
baf824f8819f90928e11480d0eae89efb60341a1
/lib/berkeley-db-1.xx/PORT/ptx.2.0/include/mpool.h
03f870c8fd33fdfc9c7be00c09afc99578e4f978
[ "MIT" ]
permissive
RockySong/micropython-rocky
549770723ba92cb311c468880ead0ffdd4fa8fe5
2d728f414bf8d041ca609e00448850759aade3cd
refs/heads/omv_initial_integrate
2021-05-12T12:20:18.404341
2021-01-15T01:15:48
2021-01-15T01:15:48
117,408,452
198
90
MIT
2020-08-25T03:31:32
2018-01-14T06:40:36
C
UTF-8
C
false
false
21
h
mpool.h
../../include/mpool.h
75e543d4f2786de4265ad06f7a97678f9c2c2085
fbef550c1f0206aac0582a58f7e3db945f442a9a
/Pods/Sentry/Sources/SentryCrash/Recording/Tools/SentryCrashCPU_arm64.c
4cd9939b2483edf45063b8e34a669fc25f9392b7
[ "MIT" ]
permissive
Hammerspoon/hammerspoon
0f03b4dd2ef3b44ea4c0a1cd0b94fcb513b5f2b7
0ccc9d07641a660140d1d2f05b76f682b501a0e8
refs/heads/master
2023-08-19T01:26:41.898873
2023-06-20T22:52:50
2023-06-20T22:52:50
24,956,772
11,379
676
MIT
2023-06-09T02:51:33
2014-10-08T19:24:44
Objective-C
UTF-8
C
false
false
6,261
c
SentryCrashCPU_arm64.c
// // SentryCrashCPU_arm64_Apple.c // // Created by Karl Stenerud on 2013-09-29. // // Copyright (c) 2012 Karl Stenerud. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall remain in place // in this source code. // // 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. // #if defined(__arm64__) # include "SentryCrashCPU.h" # include "SentryCrashCPU_Apple.h" # include "SentryCrashMachineContext.h" # include "SentryCrashMachineContext_Apple.h" # include <stdlib.h> // #define SentryCrashLogger_LocalLevel TRACE # include "SentryCrashLogger.h" # define KSPACStrippingMask_ARM64e 0x0000000fffffffff static const char *g_registerNames[] = { "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28", "fp", "lr", "sp", "pc", "cpsr" }; static const int g_registerNamesCount = sizeof(g_registerNames) / sizeof(*g_registerNames); static const char *g_exceptionRegisterNames[] = { "exception", "esr", "far" }; static const int g_exceptionRegisterNamesCount = sizeof(g_exceptionRegisterNames) / sizeof(*g_exceptionRegisterNames); uintptr_t sentrycrashcpu_framePointer(const SentryCrashMachineContext *const context) { // We don't want this from stopping us to enable warnings as errors. This needs to be fixed. # pragma clang diagnostic push # pragma GCC diagnostic ignored "-Wshorten-64-to-32" return context->machineContext.__ss.__fp; # pragma clang diagnostic pop } uintptr_t sentrycrashcpu_stackPointer(const SentryCrashMachineContext *const context) { // We don't want this from stopping us to enable warnings as errors. This needs to be fixed. # pragma clang diagnostic push # pragma GCC diagnostic ignored "-Wshorten-64-to-32" return context->machineContext.__ss.__sp; # pragma clang diagnostic pop } uintptr_t sentrycrashcpu_instructionAddress(const SentryCrashMachineContext *const context) { // We don't want this from stopping us to enable warnings as errors. This needs to be fixed. # pragma clang diagnostic push # pragma GCC diagnostic ignored "-Wshorten-64-to-32" return context->machineContext.__ss.__pc; # pragma clang diagnostic pop } uintptr_t sentrycrashcpu_linkRegister(const SentryCrashMachineContext *const context) { // We don't want this from stopping us to enable warnings as errors. This needs to be fixed. # pragma clang diagnostic push # pragma GCC diagnostic ignored "-Wshorten-64-to-32" return context->machineContext.__ss.__lr; # pragma clang diagnostic pop } void sentrycrashcpu_getState(SentryCrashMachineContext *context) { thread_t thread = context->thisThread; STRUCT_MCONTEXT_L *const machineContext = &context->machineContext; sentrycrashcpu_i_fillState(thread, (thread_state_t)&machineContext->__ss, ARM_THREAD_STATE64, ARM_THREAD_STATE64_COUNT); sentrycrashcpu_i_fillState(thread, (thread_state_t)&machineContext->__es, ARM_EXCEPTION_STATE64, ARM_EXCEPTION_STATE64_COUNT); } int sentrycrashcpu_numRegisters(void) { return g_registerNamesCount; } const char * sentrycrashcpu_registerName(const int regNumber) { if (regNumber < sentrycrashcpu_numRegisters()) { return g_registerNames[regNumber]; } return NULL; } uint64_t sentrycrashcpu_registerValue(const SentryCrashMachineContext *const context, const int regNumber) { if (regNumber < 29) { return context->machineContext.__ss.__x[regNumber]; } switch (regNumber) { case 29: return context->machineContext.__ss.__fp; case 30: return context->machineContext.__ss.__lr; case 31: return context->machineContext.__ss.__sp; case 32: return context->machineContext.__ss.__pc; case 33: return context->machineContext.__ss.__cpsr; } SentryCrashLOG_ERROR("Invalid register number: %d", regNumber); return 0; } int sentrycrashcpu_numExceptionRegisters(void) { return g_exceptionRegisterNamesCount; } const char * sentrycrashcpu_exceptionRegisterName(const int regNumber) { if (regNumber < sentrycrashcpu_numExceptionRegisters()) { return g_exceptionRegisterNames[regNumber]; } SentryCrashLOG_ERROR("Invalid register number: %d", regNumber); return NULL; } uint64_t sentrycrashcpu_exceptionRegisterValue( const SentryCrashMachineContext *const context, const int regNumber) { switch (regNumber) { case 0: return context->machineContext.__es.__exception; case 1: return context->machineContext.__es.__esr; case 2: return context->machineContext.__es.__far; } SentryCrashLOG_ERROR("Invalid register number: %d", regNumber); return 0; } uintptr_t sentrycrashcpu_faultAddress(const SentryCrashMachineContext *const context) { // We don't want this from stopping us to enable warnings as errors. This needs to be fixed. # pragma clang diagnostic push # pragma GCC diagnostic ignored "-Wshorten-64-to-32" return context->machineContext.__es.__far; # pragma clang diagnostic pop } int sentrycrashcpu_stackGrowDirection(void) { return -1; } uintptr_t sentrycrashcpu_normaliseInstructionPointer(uintptr_t ip) { return ip & KSPACStrippingMask_ARM64e; } #endif
3d99b25568b509819730d93d63c7cb0cc6040b5d
95a14668d0e9289decb373e7222c3e9bb5778ccf
/src/request.c
594f026772edeb10120b322cd60dbd387b1b2c4f
[ "MIT" ]
permissive
TimeToogo/ff-proxy
9cc124a15d504d982da4892e1863a4dc4318512d
8a71365fa8f5748c5c42b2c5e44e0a35829ec772
refs/heads/master
2023-08-22T01:42:44.680667
2023-02-05T12:31:46
2023-02-05T12:31:46
239,283,589
763
58
MIT
2023-07-25T21:15:29
2020-02-09T10:16:17
C
UTF-8
C
false
false
2,993
c
request.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include "request.h" #include "alloc.h" #include "constants.h" #include "logging.h" struct ff_request_option_node *ff_request_option_node_alloc() { struct ff_request_option_node *option = malloc(sizeof(struct ff_request_option_node)); option->type = 0; option->length = 0; option->value = NULL; return option; } void ff_request_option_load_buff(struct ff_request_option_node *node, uint32_t buff_size, void *buff) { void *buff_copy = malloc(buff_size * sizeof(buff)); memcpy(buff_copy, buff, buff_size); node->value = buff_copy; } void ff_request_option_node_free(struct ff_request_option_node *option) { if (option == NULL) return; FREE(option->value); FREE(option); } struct ff_request_payload_node *ff_request_payload_node_alloc() { struct ff_request_payload_node *node = malloc(sizeof(struct ff_request_payload_node)); node->length = 0; node->offset = 0; node->value = NULL; node->next = NULL; return node; } void ff_request_payload_load_buff(struct ff_request_payload_node *node, uint32_t buff_size, void *buff) { void *buff_copy = malloc(buff_size * sizeof(buff)); memcpy(buff_copy, buff, buff_size); node->value = buff_copy; } void ff_request_payload_node_free(struct ff_request_payload_node *node) { if (node == NULL) return; FREE(node->value); FREE(node); } struct ff_request *ff_request_alloc() { struct ff_request *request = calloc(1, sizeof(struct ff_request)); request->state = FF_REQUEST_STATE_RECEIVING; return request; } void ff_request_free(struct ff_request *request) { if (request == NULL) return; for (int i = 0; i < request->options_length; i++) { ff_request_option_node_free(request->options[i]); } FREE(request->options); struct ff_request_payload_node *payload_node = request->payload; struct ff_request_payload_node *payload_prev; while (payload_node != NULL) { payload_prev = payload_node; payload_node = payload_node->next; ff_request_payload_node_free(payload_prev); } FREE(request); } void ff_request_vectorise_payload(struct ff_request *request) { if (request->payload->next == NULL) { return; } struct ff_request_payload_node *payload = ff_request_payload_node_alloc(); payload->length = request->payload_length; payload->offset = 0; payload->next = NULL; payload->value = malloc(request->payload_length * sizeof(uint8_t)); struct ff_request_payload_node *node = request->payload; struct ff_request_payload_node *tmp_node = NULL; do { memcpy(payload->value + node->offset, node->value, node->length * sizeof(uint8_t)); tmp_node = node->next; ff_request_payload_node_free(node); node = tmp_node; } while (node != NULL); request->payload = payload; }
0cda8cc91068991465945344442c5080430153e5
a8cc8d42a3b3a8ac16ae68dd49ef39fea92fa764
/src/server/wsgi_apache.h
e6e7356fbf9c7f37f619ccd82c0ab227cc5ec694
[ "Apache-2.0" ]
permissive
GrahamDumpleton/mod_wsgi
e2b2584b4e364aafdd32aa29cba4f35744444120
2f40a11feecceaed4c38fdd4d9a3943348125722
refs/heads/develop
2023-08-29T11:51:15.962749
2023-06-26T06:31:39
2023-06-26T06:31:39
15,648,929
1,026
346
Apache-2.0
2023-05-22T01:17:03
2014-01-05T09:58:44
C
UTF-8
C
false
false
4,334
h
wsgi_apache.h
#ifndef WSGI_APACHE_H #define WSGI_APACHE_H /* ------------------------------------------------------------------------- */ /* * Copyright 2007-2022 GRAHAM DUMPLETON * * 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. */ /* ------------------------------------------------------------------------- */ /* * Enabled access to Apache private API and data structures. Need to do * this to access the following: * * In Apache 2.X need access to ap_create_request_config(). * * In Apache 2.X need access to core_module and core_request_config. * */ /* ------------------------------------------------------------------------- */ #define CORE_PRIVATE 1 #if defined(_WIN32) #include <ws2tcpip.h> #endif #include "httpd.h" #if !defined(HTTPD_ROOT) #error Sorry, Apache developer package does not appear to be installed. #endif #if !defined(AP_SERVER_MAJORVERSION_NUMBER) #if AP_MODULE_MAGIC_AT_LEAST(20010224,0) #define AP_SERVER_MAJORVERSION_NUMBER 2 #define AP_SERVER_MINORVERSION_NUMBER 0 #define AP_SERVER_PATCHLEVEL_NUMBER 0 #else #define AP_SERVER_MAJORVERSION_NUMBER 1 #define AP_SERVER_MINORVERSION_NUMBER 3 #define AP_SERVER_PATCHLEVEL_NUMBER 0 #endif #endif #if !defined(AP_SERVER_BASEVERSION) #define AP_SERVER_BASEVERSION SERVER_BASEVERSION #endif #if AP_SERVER_MAJORVERSION_NUMBER < 2 #error Sorry, mod_wsgi 4.0+ requires Apache 2.0+. #endif #include "apr_lib.h" #include "ap_mpm.h" #include "ap_compat.h" #include "apr_tables.h" #include "apr_strings.h" #include "http_config.h" #include "ap_listen.h" #include "apr_version.h" #include "apr_buckets.h" #include "apr_date.h" #include "mpm_common.h" #include "apr_optional.h" APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *)); APR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup, (apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *)); #include "ap_config.h" #include "http_core.h" #include "http_log.h" #include "http_main.h" #include "http_protocol.h" #include "http_request.h" #include "util_script.h" #include "util_md5.h" #include "mpm_common.h" #include "scoreboard.h" #ifdef APLOG_USE_MODULE APLOG_USE_MODULE(wsgi); #endif #ifndef APR_FPROT_GWRITE #define APR_FPROT_GWRITE APR_GWRITE #endif #ifndef APR_FPROT_WWRITE #define APR_FPROT_WWRITE APR_WWRITE #endif #ifndef MPM_NAME #define MPM_NAME ap_show_mpm() #endif #if !AP_MODULE_MAGIC_AT_LEAST(20050127,0) /* Debian backported ap_regex_t to Apache 2.0 and * thus made official version checking break. */ #ifndef AP_REG_EXTENDED typedef regex_t ap_regex_t; typedef regmatch_t ap_regmatch_t; #define AP_REG_EXTENDED REG_EXTENDED #endif #endif #if !AP_MODULE_MAGIC_AT_LEAST(20081201,0) #define ap_unixd_config unixd_config #endif #if !AP_MODULE_MAGIC_AT_LEAST(20051115,0) extern void wsgi_ap_close_listeners(void); #define ap_close_listeners wsgi_ap_close_listeners #endif #if !AP_MODULE_MAGIC_AT_LEAST(20101106,1) extern apr_status_t wsgi_ap_pool_cleanup_set_null(void *); #define ap_pool_cleanup_set_null wsgi_ap_pool_cleanup_set_null #endif #if (APR_MAJOR_VERSION == 0) && \ (APR_MINOR_VERSION == 9) && \ (APR_PATCH_VERSION < 5) extern apr_status_t wsgi_apr_unix_file_cleanup(void *); extern apr_status_t wsgi_apr_os_pipe_put_ex(apr_file_t **, apr_os_file_t *, int, apr_pool_t *); #define apr_unix_file_cleanup wsgi_apr_unix_file_cleanup #define apr_os_pipe_put_ex wsgi_apr_os_pipe_put_ex #endif #if defined(WIN32) && defined(APR_HAS_UNICODE_FS) typedef apr_uint16_t apr_wchar_t; extern apr_status_t wsgi_utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen, const char* srcstr); #endif /* ------------------------------------------------------------------------- */ #endif /* vi: set sw=4 expandtab : */
4bc72e660dad99f25e506dbd78268af100437f95
67eac20379df329d55d74f4e36ac206f7d50ec75
/code_examples/Blinky_LED_1_KIT_TC237_TFT/Libraries/iLLD/TC23A/Tricore/Gtm/Trig/IfxGtm_Trig.h
7408e83ce23dc8001060bca282feab9700a3f068
[]
no_license
Infineon/AURIX_code_examples
d0adb2daa86df1eae52aac6451fd5a9d4ba1b5eb
a1623634511d4463537aac33bf791c37fbb17f1c
refs/heads/master
2023-04-13T01:31:03.043401
2023-04-03T11:53:03
2023-04-03T11:53:03
192,314,276
365
278
null
null
null
null
UTF-8
C
false
false
7,038
h
IfxGtm_Trig.h
/** * \file IfxGtm_Trig.h * \brief GTM TRIG details * \ingroup IfxLld_Gtm * * \version iLLD_1_0_1_12_0 * \copyright Copyright (c) 2018 Infineon Technologies AG. All rights reserved. * * * IMPORTANT NOTICE * * Use of this file is subject to the terms of use agreed between (i) you or * the company in which ordinary course of business you are acting and (ii) * Infineon Technologies AG or its licensees. If and as long as no such terms * of use are agreed, use of this file is subject to following: * * Boost Software License - Version 1.0 - August 17th, 2003 * * Permission is hereby granted, free of charge, to any person or organization * obtaining a copy of the software and accompanying documentation covered by * this license (the "Software") to use, reproduce, display, distribute, * execute, and transmit the Software, and to prepare derivative works of the * Software, and to permit third-parties to whom the Software is furnished to * do so, all subject to the following: * * The copyright notices in the Software and this entire statement, including * the above license grant, this restriction and the following disclaimer, must * be included in all copies of the Software, in whole or in part, and all * derivative works of the Software, unless such copies or derivative works are * solely in the form of machine-executable object code generated by a source * language processor. * * 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * \defgroup IfxLld_Gtm_Trig GTM Trigger Configuration * \ingroup IfxLld_Gtm * \defgroup IfxLld_Gtm_Trig_Enumerations Enumerations * \ingroup IfxLld_Gtm_Trig * \defgroup IfxLld_Gtm_Trig_Data_Structures Data Structures * \ingroup IfxLld_Gtm_Trig * \defgroup IfxLld_Gtm_Trig_Trigger_Functions Trigger Functions * \ingroup IfxLld_Gtm_Trig */ #ifndef IFXGTM_TRIG_H #define IFXGTM_TRIG_H 1 /******************************************************************************/ /*----------------------------------Includes----------------------------------*/ /******************************************************************************/ #include "Cpu/Std/Ifx_Types.h" #include "_Impl/IfxGtm_cfg.h" #include "Gtm/Std/IfxGtm_Tim.h" /******************************************************************************/ /*--------------------------------Enumerations--------------------------------*/ /******************************************************************************/ /** \addtogroup IfxLld_Gtm_Trig_Enumerations * \{ */ /** \brief Enum for ADC group */ typedef enum { IfxGtm_Trig_AdcGroup_0, /**< \brief For ADC group 0 */ IfxGtm_Trig_AdcGroup_1, /**< \brief For ADC group 1 */ IfxGtm_Trig_AdcGroup_2, /**< \brief For ADC group 2 */ IfxGtm_Trig_AdcGroup_3 /**< \brief For ADC group 3 */ } IfxGtm_Trig_AdcGroup; /** \brief Enum for ADC trigger */ typedef enum { IfxGtm_Trig_AdcTrig_0, IfxGtm_Trig_AdcTrig_1, IfxGtm_Trig_AdcTrig_count /**< \brief count of the enum definition */ } IfxGtm_Trig_AdcTrig; /** \brief Enum for ADC trigger channel */ typedef enum { IfxGtm_Trig_AdcTrigChannel_1, IfxGtm_Trig_AdcTrigChannel_2, IfxGtm_Trig_AdcTrigChannel_3, IfxGtm_Trig_AdcTrigChannel_4, IfxGtm_Trig_AdcTrigChannel_5, IfxGtm_Trig_AdcTrigChannel_6, IfxGtm_Trig_AdcTrigChannel_7, IfxGtm_Trig_AdcTrigChannel_8, IfxGtm_Trig_AdcTrigChannel_9, IfxGtm_Trig_AdcTrigChannel_10, IfxGtm_Trig_AdcTrigChannel_11, IfxGtm_Trig_AdcTrigChannel_12, IfxGtm_Trig_AdcTrigChannel_13, IfxGtm_Trig_AdcTrigChannel_14, IfxGtm_Trig_AdcTrigChannel_15, IfxGtm_Trig_AdcTrigChannel_count /**< \brief count of the enum definition */ } IfxGtm_Trig_AdcTrigChannel; /** \brief Enum for ADC trigger source */ typedef enum { IfxGtm_Trig_AdcTrigSource_tom0, IfxGtm_Trig_AdcTrigSource_tom1, IfxGtm_Trig_AdcTrigSource_count /**< \brief count of the enum definition */ } IfxGtm_Trig_AdcTrigSource; /** \brief Enum for SENT group */ typedef enum { IfxGtm_Trig_SentGroup_0, /**< \brief For SENT group 0 */ IfxGtm_Trig_SentGroup_1, /**< \brief For SENT group 1 */ IfxGtm_Trig_SentGroup_2, /**< \brief For SENT group 2 */ IfxGtm_Trig_SentGroup_3 /**< \brief For SENT group 3 */ } IfxGtm_Trig_SentGroup; /** \brief Enum for SENT trigger */ typedef enum { IfxGtm_Trig_SentTrig_0 /**< \brief sent trigger 0 */ } IfxGtm_Trig_SentTrig; /** \brief Enum for SENT trigger channel */ typedef enum { IfxGtm_Trig_SentTrigChannel_1, IfxGtm_Trig_SentTrigChannel_2, IfxGtm_Trig_SentTrigChannel_3, IfxGtm_Trig_SentTrigChannel_4, IfxGtm_Trig_SentTrigChannel_5, IfxGtm_Trig_SentTrigChannel_6, IfxGtm_Trig_SentTrigChannel_7, IfxGtm_Trig_SentTrigChannel_8, IfxGtm_Trig_SentTrigChannel_9, IfxGtm_Trig_SentTrigChannel_10, IfxGtm_Trig_SentTrigChannel_11, IfxGtm_Trig_SentTrigChannel_12, IfxGtm_Trig_SentTrigChannel_13, IfxGtm_Trig_SentTrigChannel_14, IfxGtm_Trig_SentTrigChannel_15, IfxGtm_Trig_SentTrigChannel_count /**< \brief count of the enum definition */ } IfxGtm_Trig_SentTrigChannel; /** \brief Enum for SENT trigger source */ typedef enum { IfxGtm_Trig_SentTrigSource_tom0, IfxGtm_Trig_SentTrigSource_tom1, IfxGtm_Trig_SentTrigSource_count /**< \brief count of the enum definition */ } IfxGtm_Trig_SentTrigSource; /** \} */ /** \addtogroup IfxLld_Gtm_Trig_Trigger_Functions * \{ */ /******************************************************************************/ /*-------------------------Global Function Prototypes-------------------------*/ /******************************************************************************/ /** * \param gtm Pointer to GTM module * \param adcGroup ADC group * \param adcTrig ADC trigger * \param source ADC trigger source * \param channel ADC trigger channel * \return TRUE on success else FALSE */ IFX_EXTERN boolean IfxGtm_Trig_toVadc(Ifx_GTM *gtm, IfxGtm_Trig_AdcGroup adcGroup, IfxGtm_Trig_AdcTrig adcTrig, IfxGtm_Trig_AdcTrigSource source, IfxGtm_Trig_AdcTrigChannel channel); /** * \param gtm Pointer to GTM module * \param sentGroup SENT group * \param sentTrig SENT trigger * \param source SENT trigger source * \param channel SENT trigger channel * \return TRUE on success else FALSE */ IFX_EXTERN boolean IfxGtm_Trig_toSent(Ifx_GTM *gtm, IfxGtm_Trig_SentGroup sentGroup, IfxGtm_Trig_SentTrig sentTrig, IfxGtm_Trig_SentTrigSource source, IfxGtm_Trig_SentTrigChannel channel); /** \} */ #endif /* IFXGTM_TRIG_H */
36c3e6ed79c80fa58434412573454b337ab56dcd
468cd559cb5374e737bb1b5f42f5fe73dd98dd8b
/source/parser/rmt_assert.h
9bf914c042417cc2ecd8a5624213e09f1174219b
[ "MIT" ]
permissive
GPUOpen-Tools/radeon_memory_visualizer
31b84ceeb44573e654876df7af9cbf0063015898
87d9ca84492432f384e1cc8e93e59c3700ef0e3f
refs/heads/master
2023-09-01T00:41:37.480829
2023-07-12T15:02:57
2023-08-16T18:44:26
245,466,905
117
17
null
null
null
null
UTF-8
C
false
false
4,250
h
rmt_assert.h
//============================================================================= // Copyright (c) 2017-2023 Advanced Micro Devices, Inc. All rights reserved. /// @author AMD Developer Tools Team /// @file /// @brief Definition of assert. //============================================================================= #ifndef RMV_PARSER_RMT_ASSERT_H_ #define RMV_PARSER_RMT_ASSERT_H_ #include <stdio.h> #include <stdint.h> #include <stdbool.h> #include "rmt_util.h" #ifdef __cplusplus extern "C" { #endif // #ifdef __cplusplus #ifdef _DEBUG #ifdef _WIN32 #ifdef DISABLE_RMT_DEBUG_BREAK #define RMT_DEBUG_BREAK \ { \ } #else /// Macro to force the debugger to break at this point in the code. #define RMT_DEBUG_BREAK __debugbreak(); #endif #else #define RMT_DEBUG_BREAK \ { \ } #endif #else // don't allow debug break in release builds. #define RMT_DEBUG_BREAK #endif /// A typedef for the callback function for assert printing. /// /// This can be used to re-route printing of assert messages from the RMT backend /// to another destination. For example instead of the default behaviour of printing /// the assert messages to the debugger's TTY the message can be re-routed to a /// MessageBox in a GUI application. /// /// @param [in] message The message generated by the assert. /// typedef void (*RmtAssertCallback)(const char* message); /// Function to report an assert. /// /// @param [in] file The name of the file as a string. /// @param [in] line The index of the line in the file. /// @param [in] condition The boolean condition that was tested. /// @param [in] message The optional message to print. /// /// @returns /// Always returns true. /// bool RmtAssertReport(const char* file, int32_t line, const char* condition, const char* msg); /// Provides the ability to set a callback for assert messages. /// /// @param [in] callback The callback function that will receive assert messages. /// void RmtAssertSetPrintingCallback(RmtAssertCallback callback); #if _DEBUG /// Standard assert macro. #define RMT_ASSERT(condition) \ do \ { \ if (!(condition) && RmtAssertReport(__FILE__, __LINE__, #condition, NULL)) \ RMT_DEBUG_BREAK \ } while (0) /// Assert macro with message. #define RMT_ASSERT_MESSAGE(condition, msg) \ do \ { \ if (!(condition) && RmtAssertReport(__FILE__, __LINE__, #condition, msg)) \ RMT_DEBUG_BREAK \ } while (0) /// Assert macro that always fails. #define RMT_ASSERT_FAIL(message) \ do \ { \ RmtAssertReport(__FILE__, __LINE__, NULL, message); \ RMT_DEBUG_BREAK \ } while (0) #else // asserts disabled #define RMT_ASSERT(condition) \ do \ { \ RMT_UNUSED(condition); \ } while (0) #define RMT_ASSERT_MESSAGE(condition, message) \ do \ { \ RMT_UNUSED(condition); \ RMT_UNUSED(message); \ } while (0) #define RMT_ASSERT_FAIL(message) \ do \ { \ RMT_UNUSED(message); \ } while (0) #endif // #if _DEBUG /// Simple static assert. #define RMT_STATIC_ASSERT(condition) static_assert(condition, #condition) #ifdef __cplusplus } #endif // #ifdef __cplusplus #endif // #ifndef RMV_PARSER_RMT_ASSERT_H_
ebf51d9e15521dee0fde3f4da151f1a48b7a9ad1
b801d688e01ca0ea993c1a84e1bc164967258aff
/LTP/LTP_01/abs.c
081ba533e158fd50eab2f81b8f50e72986553c89
[ "Apache-2.0" ]
permissive
jitwxs/blog-sample
1a1e4152b48939baa5b09a2704dd089dfbe520ed
5123346e01a1ec94cc56b5afbd45732487d7ecb8
refs/heads/master
2022-02-24T06:04:26.341746
2022-02-16T14:11:26
2022-02-16T14:11:26
131,931,262
339
243
Apache-2.0
2021-09-20T15:25:44
2018-05-03T02:32:58
Java
UTF-8
C
false
false
585
c
abs.c
#include <errno.h> #include <string.h> #include <sys/mount.h> #include "tst_test.h" static struct tcase { const int input; const int output; } tcases[] = { {-1,1}, {3,3} }; static void testAbs(unsigned int n) { struct tcase *tc = &tcases[n]; TEST(abs(tc->input)); if (TEST_RETURN != tc->output) { tst_res(TFAIL, "abs() failed"); return; } tst_res(TPASS, "abs() succeeds"); } static struct tst_test test = { .tid = "testAbs", .tcnt = ARRAY_SIZE(tcases), .test = testAbs, };
2dc990de358886f4d63db1c0951617d30c3b1c17
7be8e3636bf08ebdc6662879dc5afec548705537
/ios/Pods/Headers/Public/Flipper-Folly/folly/experimental/Instructions.h
982a09b6f9ef3b335b2d54753217799ea6a7d085
[ "MIT" ]
permissive
rdhox/react-native-smooth-picker
3c7384f1fed0e37f076361cce96071d01b70e209
ae9316c49512f7ed9824c5a3ad50cdf5e80fffa9
refs/heads/master
2023-01-08T16:59:40.709147
2021-07-03T14:13:21
2021-07-03T14:13:21
160,224,312
230
31
MIT
2023-01-06T01:46:04
2018-12-03T16:54:10
TypeScript
UTF-8
C
false
false
62
h
Instructions.h
../../../../../Flipper-Folly/folly/experimental/Instructions.h
e5b358d4079bb6cdbe2414bd778f076b928199a1
ae31542273a142210a1ff30fb76ed9d45d38eba9
/src/backend/access/appendonly/appendonly_blkdir_udf.c
ccf838f8a0355f8e5f3240c188d0f508e3faacbd
[ "Apache-2.0", "LicenseRef-scancode-generic-cla", "PostgreSQL", "OpenSSL", "LicenseRef-scancode-stream-benchmark", "ISC", "LicenseRef-scancode-openssl", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-ssleay-windows", "BSD-2-Clause", "Python-2.0" ]
permissive
greenplum-db/gpdb
8334837bceb2d5d51a684500793d11b190117c6a
2c0f8f0fb24a2d7a7da114dc80f5f5a2712fca50
refs/heads/main
2023-08-22T02:03:03.806269
2023-08-21T22:59:53
2023-08-22T01:17:10
44,781,140
6,417
2,082
Apache-2.0
2023-09-14T20:33:42
2015-10-23T00:25:17
C
UTF-8
C
false
false
6,298
c
appendonly_blkdir_udf.c
/*------------------------------------------------------------------------------ * * AppendOnly_Blkdir UDFs * User-defined functions (UDF) for support of append-only block directory * * Copyright (c) 2013-Present VMware, Inc. or its affiliates. * * * IDENTIFICATION * src/backend/access/appendonly/appendonly_blkdir_udf.c * *------------------------------------------------------------------------------ */ #include "postgres.h" #include "access/appendonly_visimap.h" #include "access/table.h" #include "catalog/aoblkdir.h" #include "cdb/cdbappendonlyblockdirectory.h" #include "cdb/cdbvars.h" #include "funcapi.h" #include "utils/snapmgr.h" Datum gp_aoblkdir(PG_FUNCTION_ARGS); /* * This UDF emits block directory entries for an AO/AOCO relation. It does so * by flattening the minipage column of ao_blkdir relations, yielding 1 minipage * entry / output row. * * Format: * tupleid | segno | columngroup_no | entry_no | first_row_no | file_offset | row_count * * This UDF also respects gp_select_invisible to report block directory entries * that are invisible. To determine invisible entries we can use the tupleid * projected here and tie it to the corresponding pg_aoblkdir tuple's xmax. */ Datum gp_aoblkdir(PG_FUNCTION_ARGS) { Oid aoRelOid = PG_GETARG_OID(0); HeapTuple tuple; typedef struct Context { Relation aorel; SysScanDesc scan; MinipagePerColumnGroup currMinipage; bool currMinipageValid; int currMinipageEntryIdx; Relation blkdirrel; } Context; FuncCallContext *funcctx; Context *context; if (SRF_IS_FIRSTCALL()) { TupleDesc tupdesc; MemoryContext oldcontext; Snapshot sst; Oid blkdirrelid; /* create a function context for cross-call persistence */ funcctx = SRF_FIRSTCALL_INIT(); /* * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); /* build tupdesc for result tuples */ tupdesc = CreateTemplateTupleDesc(7); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "tupleid", TIDOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 2, "segno", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 3, "columngroup_no", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 4, "entry_no", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 5, "first_row_no", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 6, "file_offset", INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 7, "row_count", INT8OID, -1, 0); funcctx->tuple_desc = BlessTupleDesc(tupdesc); /* initialize Context for SRF */ context = (Context *) palloc0(sizeof(Context)); context->aorel = table_open(aoRelOid, AccessShareLock); if (!RelationStorageIsAO(context->aorel)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("function not supported on non append-optimized relation"))); sst = GetLatestSnapshot(); GetAppendOnlyEntryAuxOids(context->aorel, NULL, &blkdirrelid, NULL); sst = gp_select_invisible ? SnapshotAny : GetLatestSnapshot(); if (blkdirrelid == InvalidOid) ereport(ERROR, (errmsg("appendoptimized relation doesn't have a block directory"), errhint("relation must have or must have had an index"))); context->blkdirrel = table_open(blkdirrelid, AccessShareLock); context->scan = systable_beginscan(context->blkdirrel, InvalidOid, false, sst, 0, NULL); context->currMinipage.minipage = palloc0(minipage_size(NUM_MINIPAGE_ENTRIES)); context->currMinipageValid = false; context->currMinipageEntryIdx = -1; funcctx->user_fctx = (void *) context; MemoryContextSwitchTo(oldcontext); } funcctx = SRF_PERCALL_SETUP(); context = (Context *) funcctx->user_fctx; if (!context->currMinipageValid) { Datum minipage; bool minipageNull; /* We need to fetch the next tuple from the blkdir relation */ if (!systable_getnext(context->scan)) goto srf_done; /* deform the tuple and populate slot->values/nulls */ slot_getallattrs(context->scan->slot); minipage = slot_getattr(context->scan->slot, Anum_pg_aoblkdir_minipage, &minipageNull); /* * There should not really be any NULL values. We opt to report it * instead of ERRORing out. */ context->currMinipageValid = !minipageNull; if (context->currMinipageValid) { /* * Cache the latest scanned minipage and use it to emit the next * (context->currMinipage->numMinipageEntries) rows */ copy_out_minipage(&context->currMinipage, minipage, false); context->currMinipageEntryIdx = 0; } } { Datum values[7]; bool nulls[7]; TupleTableSlot *slot = context->scan->slot; Datum result; values[0] = ItemPointerGetDatum(&slot->tts_tid); nulls[0] = false; values[1] = slot_getattr(slot, Anum_pg_aoblkdir_segno, &nulls[1]); values[2] = slot_getattr(slot, Anum_pg_aoblkdir_columngroupno, &nulls[2]); /* emit minipage entry */ if (context->currMinipageValid) { MinipagePerColumnGroup *currMinipage = &context->currMinipage; MinipageEntry *minipageEntry; Assert(context->currMinipageEntryIdx < currMinipage->numMinipageEntries); minipageEntry = &currMinipage->minipage->entry[context->currMinipageEntryIdx]; values[3] = context->currMinipageEntryIdx++; values[4] = Int64GetDatum(minipageEntry->firstRowNum); values[5] = Int64GetDatum(minipageEntry->fileOffset); values[6] = Int64GetDatum(minipageEntry->rowCount); nulls[3] = false; nulls[4] = false; nulls[5] = false; nulls[6] = false; context->currMinipageValid = (context->currMinipageEntryIdx != currMinipage->numMinipageEntries); } else { nulls[3] = true; nulls[4] = true; nulls[5] = true; nulls[6] = true; } tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls); result = HeapTupleGetDatum(tuple); SRF_RETURN_NEXT(funcctx, result); } srf_done: table_close(context->aorel, AccessShareLock); systable_endscan(context->scan); table_close(context->blkdirrel, AccessShareLock); pfree(context); funcctx->user_fctx = NULL; SRF_RETURN_DONE(funcctx); }
ff7a3c014ef8b019d4503777fbcd6dbb2277e6de
78dc9f153549b281be709227bc9897931b06260d
/generation/WinSDK/RecompiledIdlHeaders/um/swdevicedef.h
0d79795eabd011d9576d5334bd16390d90df6f6a
[ "MIT" ]
permissive
microsoft/win32metadata
dff35b4fe904d556162cee5133294c4498f1a79a
5bf233f04d45f7a697e112e9639722551103eb07
refs/heads/main
2023-09-01T19:51:22.972899
2023-08-30T21:39:44
2023-08-30T21:39:44
270,838,404
1,240
107
NOASSERTION
2023-09-14T18:49:44
2020-06-08T21:52:10
C++
UTF-8
C
false
false
1,354
h
swdevicedef.h
/*++ Copyright (c) Microsoft Corporation Abstract: This module contains the public Software Device shared definitions. */ #pragma once #if (NTDDI_VERSION >= NTDDI_WIN8) #if defined(__cplusplus) extern "C" { #endif // defined(__cplusplus) typedef #ifdef MIDL_PASS [v1_enum] #endif enum _SW_DEVICE_CAPABILITIES { SWDeviceCapabilitiesNone = 0x00000000, SWDeviceCapabilitiesRemovable = 0x00000001, SWDeviceCapabilitiesSilentInstall = 0x00000002, SWDeviceCapabilitiesNoDisplayInUI = 0x00000004, SWDeviceCapabilitiesDriverRequired = 0x00000008 } SW_DEVICE_CAPABILITIES, *PSW_DEVICE_CAPABILITIES; typedef struct _SW_DEVICE_CREATE_INFO { ULONG cbSize; __in PCWSTR pszInstanceId; __in_opt PCZZWSTR pszzHardwareIds; __in_opt PCZZWSTR pszzCompatibleIds; __in_opt const GUID *pContainerId; ULONG CapabilityFlags; __in_opt PCWSTR pszDeviceDescription; __in_opt PCWSTR pszDeviceLocation; __in_opt const SECURITY_DESCRIPTOR *pSecurityDescriptor; } SW_DEVICE_CREATE_INFO, *PSW_DEVICE_CREATE_INFO; typedef #ifdef MIDL_PASS [v1_enum] #endif enum _SW_DEVICE_LIFETIME { SWDeviceLifetimeHandle, SWDeviceLifetimeParentPresent, SWDeviceLifetimeMax } SW_DEVICE_LIFETIME, *PSW_DEVICE_LIFETIME; #if defined(__cplusplus) } #endif // defined(__cplusplus) #endif // NTDDI_VERSION
619f223c46f46d5badb8f627557eaea8ec6a4401
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/wasi/libc-bottom-half/sources/environ.c
50d60deff407fcf929303933ac95daef3783bb00
[ "MIT", "LLVM-exception", "Apache-2.0", "NCSA", "BSD-2-Clause" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C
false
false
1,222
c
environ.c
#include <unistd.h> #include <stdlib.h> #include <sysexits.h> #include <wasi/api.h> #include <wasi/libc.h> #include <wasi/libc-environ.h> // If the program does use `environ`, it'll get this version of // `__wasilibc_environ`, which is initialized with a constructor function, so // that it's initialized whenever user code might want to access it. char **__wasilibc_environ; weak_alias(__wasilibc_environ, _environ); weak_alias(__wasilibc_environ, environ); // We define this function here in the same source file as // `__wasilibc_environ`, so that this function is called in iff environment // variable support is used. // Concerning the 50 -- levels up to 100 are reserved for the implementation, // so we an arbitrary number in the middle of the range to allow other // reserved things to go before or after. __attribute__((constructor(50))) static void __wasilibc_initialize_environ_eagerly(void) { __wasilibc_initialize_environ(); } // See the comments in libc-environ.h. void __wasilibc_maybe_reinitialize_environ_eagerly(void) { // This translation unit is linked in if `environ` is used, meaning we need // to eagerly reinitialize the environment variables. __wasilibc_initialize_environ(); }
53dd9044c696a82bc53aa52f06eb8552de69303d
0c4a079b5ac2fc627b91b48f4bcf6faa804d5a28
/third_party/FLAC/src/win_utf8_io.c
ceb53533026232d91f7e1085da124afe9f876b2b
[ "LGPL-2.0-or-later", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-synthesis-toolkit", "LicenseRef-scancode-public-domain" ]
permissive
ddiakopoulos/libnyquist
37eb768bcf31cb310c710ee43c76d33baa823282
767efd97cdd7a281d193296586e708490eb6e54f
refs/heads/master
2023-08-18T04:43:21.137134
2023-02-13T07:54:10
2023-02-13T07:54:10
32,698,321
515
77
BSD-2-Clause
2022-09-25T20:29:39
2015-03-22T22:15:11
C++
UTF-8
C
false
false
9,421
c
win_utf8_io.c
/* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2013-2014 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Xiph.org Foundation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <stdio.h> #include <sys/stat.h> #include <sys/utime.h> #include <io.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> /* for WideCharToMultiByte and MultiByteToWideChar */ #include "share/win_utf8_io.h" #define UTF8_BUFFER_SIZE 32768 static int local_vsnprintf(char *str, size_t size, const char *fmt, va_list va) { int rc; #if defined _MSC_VER if (size == 0) return 1024; rc = vsnprintf_s (str, size, _TRUNCATE, fmt, va); if (rc < 0) rc = size - 1; #elif defined __MINGW32__ rc = __mingw_vsnprintf (str, size, fmt, va); #else rc = vsnprintf (str, size, fmt, va); #endif return rc; } static UINT win_utf8_io_codepage = CP_ACP; /* convert WCHAR stored Unicode string to UTF-8. Caller is responsible for freeing memory */ static char *utf8_from_wchar(const wchar_t *wstr) { char *utf8str; int len; if (!wstr) return NULL; if ((len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL)) == 0) return NULL; if ((utf8str = (char *)malloc(++len)) == NULL) return NULL; if (WideCharToMultiByte(CP_UTF8, 0, wstr, -1, utf8str, len, NULL, NULL) == 0) { free(utf8str); utf8str = NULL; } return utf8str; } /* convert UTF-8 back to WCHAR. Caller is responsible for freeing memory */ static wchar_t *wchar_from_utf8(const char *str) { wchar_t *widestr; int len; if (!str) return NULL; len=(int)strlen(str)+1; if ((widestr = (wchar_t *)malloc(len*sizeof(wchar_t))) != NULL) { if (MultiByteToWideChar(win_utf8_io_codepage, 0, str, len, widestr, len) == 0) { if (MultiByteToWideChar(CP_ACP, 0, str, len, widestr, len) == 0) { /* try conversion from Ansi in case the initial UTF-8 conversion had failed */ free(widestr); widestr = NULL; } } } return widestr; } /* retrieve WCHAR commandline, expand wildcards and convert everything to UTF-8 */ int get_utf8_argv(int *argc, char ***argv) { typedef int (__cdecl *wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*); wgetmainargs_t wgetmainargs; HMODULE handle; int wargc; wchar_t **wargv; wchar_t **wenv; char **utf8argv; int ret, i; if ((handle = LoadLibrary("msvcrt.dll")) == NULL) return 1; if ((wgetmainargs = (wgetmainargs_t)GetProcAddress(handle, "__wgetmainargs")) == NULL) return 1; i = 0; /* if __wgetmainargs expands wildcards then it also erroneously converts \\?\c:\path\to\file.flac to \\file.flac */ if (wgetmainargs(&wargc, &wargv, &wenv, 1, &i) != 0) return 1; if ((utf8argv = (char **)calloc(wargc, sizeof(char*))) == NULL) return 1; ret = 0; for (i=0; i<wargc; i++) { if ((utf8argv[i] = utf8_from_wchar(wargv[i])) == NULL) { ret = 1; break; } } FreeLibrary(handle); if (ret == 0) { win_utf8_io_codepage = CP_UTF8; *argc = wargc; *argv = utf8argv; } else { for (i=0; i<wargc; i++) free(utf8argv[i]); free(utf8argv); } return ret; } /* return number of characters in the UTF-8 string */ size_t strlen_utf8(const char *str) { size_t len; if ((len = MultiByteToWideChar(win_utf8_io_codepage, 0, str, -1, NULL, 0)) == 0) len = strlen(str); return len; } /* get the console width in characters */ int win_get_console_width(void) { int width = 80; CONSOLE_SCREEN_BUFFER_INFO csbi; HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0) width = csbi.dwSize.X; return width; } /* print functions */ int print_console(FILE *stream, const wchar_t *text, size_t len) { static HANDLE hOut; static HANDLE hErr; DWORD out; hOut = GetStdHandle(STD_OUTPUT_HANDLE); hErr = GetStdHandle(STD_ERROR_HANDLE); if (stream == stdout && hOut != INVALID_HANDLE_VALUE && GetFileType(hOut) == FILE_TYPE_CHAR) { if (WriteConsoleW(hOut, text, len, &out, NULL) == 0) return -1; return out; } else if (stream == stderr && hErr != INVALID_HANDLE_VALUE && GetFileType(hErr) == FILE_TYPE_CHAR) { if (WriteConsoleW(hErr, text, len, &out, NULL) == 0) return -1; return out; } else { int ret = fputws(text, stream); if (ret < 0) return ret; return len; } } int printf_utf8(const char *format, ...) { char *utmp = NULL; wchar_t *wout = NULL; int ret = -1; while (1) { va_list argptr; if (!(utmp = (char *)malloc(UTF8_BUFFER_SIZE*sizeof(char)))) break; va_start(argptr, format); ret = local_vsnprintf(utmp, UTF8_BUFFER_SIZE, format, argptr); va_end(argptr); if (ret < 0) break; if (!(wout = wchar_from_utf8(utmp))) { ret = -1; break; } ret = print_console(stdout, wout, wcslen(wout)); break; } if (utmp) free(utmp); if (wout) free(wout); return ret; } int fprintf_utf8(FILE *stream, const char *format, ...) { char *utmp = NULL; wchar_t *wout = NULL; int ret = -1; while (1) { va_list argptr; if (!(utmp = (char *)malloc(UTF8_BUFFER_SIZE*sizeof(char)))) break; va_start(argptr, format); ret = local_vsnprintf(utmp, UTF8_BUFFER_SIZE, format, argptr); va_end(argptr); if (ret < 0) break; if (!(wout = wchar_from_utf8(utmp))) { ret = -1; break; } ret = print_console(stream, wout, wcslen(wout)); break; } if (utmp) free(utmp); if (wout) free(wout); return ret; } int vfprintf_utf8(FILE *stream, const char *format, va_list argptr) { char *utmp = NULL; wchar_t *wout = NULL; int ret = -1; while (1) { if (!(utmp = (char *)malloc(UTF8_BUFFER_SIZE*sizeof(char)))) break; if ((ret = local_vsnprintf(utmp, UTF8_BUFFER_SIZE, format, argptr)) < 0) break; if (!(wout = wchar_from_utf8(utmp))) { ret = -1; break; } ret = print_console(stream, wout, wcslen(wout)); break; } if (utmp) free(utmp); if (wout) free(wout); return ret; } /* file functions */ FILE *fopen_utf8(const char *filename, const char *mode) { wchar_t *wname = NULL; wchar_t *wmode = NULL; FILE *f = NULL; while (1) { if (!(wname = wchar_from_utf8(filename))) break; if (!(wmode = wchar_from_utf8(mode))) break; f = _wfopen(wname, wmode); break; } if (wname) free(wname); if (wmode) free(wmode); return f; } int _stat64_utf8(const char *path, struct __stat64 *buffer) { wchar_t *wpath; int ret; if (!(wpath = wchar_from_utf8(path))) return -1; ret = _wstat64(wpath, buffer); free(wpath); return ret; } int chmod_utf8(const char *filename, int pmode) { wchar_t *wname; int ret; if (!(wname = wchar_from_utf8(filename))) return -1; ret = _wchmod(wname, pmode); free(wname); return ret; } int utime_utf8(const char *filename, struct utimbuf *times) { wchar_t *wname; struct __utimbuf64 ut; int ret; if (sizeof(*times) == sizeof(ut)) { memcpy(&ut, times, sizeof(ut)); } else { ut.actime = times->actime; ut.modtime = times->modtime; } if (!(wname = wchar_from_utf8(filename))) return -1; ret = _wutime64(wname, &ut); free(wname); return ret; } int unlink_utf8(const char *filename) { wchar_t *wname; int ret; if (!(wname = wchar_from_utf8(filename))) return -1; ret = _wunlink(wname); free(wname); return ret; } int rename_utf8(const char *oldname, const char *newname) { wchar_t *wold = NULL; wchar_t *wnew = NULL; int ret = -1; while (1) { if (!(wold = wchar_from_utf8(oldname))) break; if (!(wnew = wchar_from_utf8(newname))) break; ret = _wrename(wold, wnew); break; } if (wold) free(wold); if (wnew) free(wnew); return ret; } HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { wchar_t *wname; HANDLE handle = INVALID_HANDLE_VALUE; if ((wname = wchar_from_utf8(lpFileName)) != NULL) { handle = CreateFileW(wname, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); free(wname); } return handle; }
aa88bf32d44e4315271643e08b5285472b8d5b01
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
/PWGLF/totEt/macros/hadEt/GetCorrections.C
0d578c5309a03fced1a9b11c8d61fa3088060201
[]
permissive
alisw/AliPhysics
91bf1bd01ab2af656a25ff10b25e618a63667d3e
5df28b2b415e78e81273b0d9bf5c1b99feda3348
refs/heads/master
2023-08-31T20:41:44.927176
2023-08-31T14:51:12
2023-08-31T14:51:12
61,661,378
129
1,150
BSD-3-Clause
2023-09-14T18:48:45
2016-06-21T19:31:29
C++
UTF-8
C
false
false
147,855
c
GetCorrections.C
//Create by Christine Nattrass, Rebecca Scott, Irakli Martashvili //University of Tennessee at Knoxville //This macro takes an input file created by AliAnalysisHadEtMonteCarlo and creates an AliAnalysisHadEtCorrections for the determination of the corrected Et // #include "TFile.h" // #include <iostream> // #include "AliAnalysisHadEtCorrections.h" // #include <iostream> // #include <TROOT.h> // #include <TSystem.h> // #include "TStopwatch.h" //Corrections added in by hand to deal with the inadequacies of PYTHIA and HIJING TH1D *pp276TPCBkgd(); TH1D *pp276ITSBkgd(); TH1D *PbPb276TPCBkgd(); TH1D *PbPb276ITSBkgd(); Double_t xAxis1[112] = {0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38, 0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58, 0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78, 0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98, 1, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4, 3.6, 3.8, 4, 4.2, 4.4, 4.6, 4.8, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 12, 14, 16, 18, 20, 25}; Float_t CorrNeutral(float ptcut, char *prodname, char *shortprodname, bool ispp = true, bool forSim = true, bool TPC, bool hadronic = false, float etacut = 0.7, int dataset); TH1D *GetHistoCorrNeutral(float cut, char *name, bool ispp, bool forSim, int mycase, bool eta, int color, int marker, bool hadronic = false); Float_t CorrPtCut(float ptcut, char *prodname = "Enter Production Name", char *shortprodname = "EnterProductionName", bool ispp = true, bool forSim = true, int mycase = 0); TH1D *GetHistoCorrPtCut(float ptcut = 0.15, char *name, bool ispp = true, bool forSim = true, int mycase); TH1D *GetHistoCorrNotID(float etacut,char *name, bool TPC, bool eta, bool ispp = true, bool forSim = true); TH1D *CorrNotID(float etacut,char *name, char *prodname, char *shortprodname, bool TPC, bool ispp = true, bool forSim = true); Float_t CorrNotIDConst(float ptcut, float etacut,char *name, char *prodname, char *shortprodname, bool TPC, bool ispp, bool forSim, Int_t dataset); TH1D *GetHistoNoID(float etacut, char *name, bool eta, bool TPC, bool ispp, bool forSim); TH1D *CorrNoID(float etacut,char *name, char *prodname, char *shortprodname, bool ispp, bool forSim); Float_t CorrNoIDConst(float etacut, float ptcut,char *name, char *prodname, char *shortprodname, bool ispp, bool forSim, Int_t dataset); TH1D* bayneseffdiv(TH1D* numerator, TH1D* denominator,Char_t* name); TH1D *GetHistoEfficiency(float cut, char *name, int mycase, int color, int marker,bool TPC, bool ITS, int cb = -1, int cblast = -1); void CorrEfficiencyPlots(bool TPC, char *prodname, char *shortprodname); TH1D *GetHistoCorrBkgd(float etacut,char *name, bool TPC,bool ispp,bool forSim); void CorrBkgdPlots(char *prodname, char *shortprodname, bool TPC,bool ispp,bool forSim); //Some variables that we'll use multiple times. We'll declare them here since they don't seem to delete right in the functions char prefix[100]; char histoname[100]; char epsname[100]; char pngname[100]; TFile *file = NULL;//initiated in main function const char *mynameTPC = "TPC"; const char *mynameITS = "ITS"; const char *mynameTPCITS = "TPCITS"; const char *detectorEMCAL = "EMCAL"; const char *detectorPHOS = "PHOS"; const char *reweightedNo = ""; const char *reweightedYes = "Reweighted"; //=========================================================================================== void GetCorrections(char *prodname = "Enter Production Name", char *shortprodname = "EnterProductionName", bool ispp = true, bool forSim = true, bool TPC = true, char *infilename="Et.ESD.new.sim.merged.root", int dataset = 2009, Int_t nCentBins = 21){ TStopwatch timer; timer.Start(); gSystem->Load("libTree.so"); gSystem->Load("libGeom.so"); gSystem->Load("libVMC.so"); gSystem->Load("libXMLIO.so"); gSystem->Load("libSTEERBase.so"); gSystem->Load("libESD.so"); gSystem->Load("libAOD.so"); gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); gSystem->AddIncludePath("-I$ALICE_ROOT/include"); gROOT->ProcessLine(".L AliAnalysisEtCuts.cxx+g"); gROOT->ProcessLine(".L AliAnalysisHadEtCorrections.cxx+g"); file = new TFile(infilename); char outfilename[200]; char *sim = "ForData"; if(forSim) sim = "ForSimulations"; char *system = "PbPb"; if(ispp){ system = "pp"; if(dataset==2013) system = "pPb"; } sprintf(outfilename,"rootFiles/corrections/corrections.%s.%s.%s.root",shortprodname,system,sim); TFile *outfile = new TFile(outfilename,"RECREATE"); AliAnalysisHadEtCorrections *hadCorrectionEMCAL = new AliAnalysisHadEtCorrections(); hadCorrectionEMCAL->SetName("hadCorrectionEMCAL"); float etacut = 0.7; hadCorrectionEMCAL->SetEtaCut(etacut); hadCorrectionEMCAL->IsData(!forSim); hadCorrectionEMCAL->IsEMCal(kTRUE); hadCorrectionEMCAL->SetProduction(shortprodname); hadCorrectionEMCAL->SetProductionDescription(prodname); hadCorrectionEMCAL->SetDataSet(dataset); //float etacut = hadCorrectionEMCAL->GetEtaCut(); //cout<<"eta cut is "<<etacut<<endl; hadCorrectionEMCAL->SetAcceptanceCorrectionFull(1.0); cout<<"Warning: Acceptance corrections will have to be updated to include real acceptance maps of the EMCAL"<<endl; hadCorrectionEMCAL->SetAcceptanceCorrectionPHOS(360.0/60.0); hadCorrectionEMCAL->SetAcceptanceCorrectionEMCAL(360.0/60.0); float ptcut = 0.1; float neutralCorr = CorrNeutral(ptcut,prodname,shortprodname,ispp,forSim,TPC,false,etacut,dataset); hadCorrectionEMCAL->SetNeutralCorrection(neutralCorr); //Using error from data, see analysis note for details if(ispp){ hadCorrectionEMCAL->SetNeutralCorrectionLowBound(neutralCorr*0.7571/(0.7571+0.0165)); hadCorrectionEMCAL->SetNeutralCorrectionHighBound(neutralCorr*0.7571/(0.7571-0.0165)); } else{ hadCorrectionEMCAL->SetNeutralCorrectionLowBound(neutralCorr*0.7275/(0.7275+0.0165)); hadCorrectionEMCAL->SetNeutralCorrectionHighBound(neutralCorr*0.7275/(0.7275-0.0165)); } float hadronicCorr = CorrNeutral(ptcut,prodname,shortprodname,ispp,forSim,TPC,true,etacut,dataset); hadCorrectionEMCAL->SetNotHadronicCorrection(hadronicCorr); if(ispp){ hadCorrectionEMCAL->SetNotHadronicCorrectionLowBound(hadronicCorr*(0.559243/(0.559243+0.016564))); hadCorrectionEMCAL->SetNotHadronicCorrectionHighBound(hadronicCorr*(0.559243/(0.559243-0.016564))); } else{ if(dataset==2015){ cout<<"Hello! I am here!! "<<hadronicCorr<<endl; hadCorrectionEMCAL->SetNotHadronicCorrectionLowBound(hadronicCorr*0.547882/(0.547882-0.02792498));//3.33149690798611731e-02)); hadCorrectionEMCAL->SetNotHadronicCorrectionHighBound(hadronicCorr*0.547882/(0.547882+0.02792498));//3.33149690798611731e-02)); } else{ hadCorrectionEMCAL->SetNotHadronicCorrectionLowBound(hadronicCorr*(0.559243/(0.559243+0.016564))); hadCorrectionEMCAL->SetNotHadronicCorrectionHighBound(hadronicCorr*(0.559243/(0.559243-0.016564))); } } float ptcutITS = CorrPtCut(0.1,prodname,shortprodname,ispp,forSim); hadCorrectionEMCAL->SetpTCutCorrectionITS(ptcutITS); float ptcutTPC = CorrPtCut(0.15,prodname,shortprodname,ispp,forSim); hadCorrectionEMCAL->SetpTCutCorrectionTPC(ptcutTPC); float ptcutITSLow = CorrPtCut(0.1,prodname,shortprodname,ispp,forSim,-1); float ptcutTPCLow = CorrPtCut(0.15,prodname,shortprodname,ispp,forSim,-1); hadCorrectionEMCAL->SetpTCutCorrectionITSLowBound(ptcutITSLow); hadCorrectionEMCAL->SetpTCutCorrectionTPCLowBound(ptcutTPCLow); float ptcutITSHigh = CorrPtCut(0.1,prodname,shortprodname,ispp,forSim,1); float ptcutTPCHigh = CorrPtCut(0.15,prodname,shortprodname,ispp,forSim,1); hadCorrectionEMCAL->SetpTCutCorrectionITSHighBound(ptcutITSHigh); hadCorrectionEMCAL->SetpTCutCorrectionTPCHighBound(ptcutTPCHigh); TH1D *NotIDTPC = CorrNotID(etacut,"CorrNotIDEMCALTPC",prodname,shortprodname,true,ispp,forSim); TH1D *NotIDITS = CorrNotID(etacut,"CorrNotIDEMCALITS",prodname,shortprodname,false,ispp,forSim); hadCorrectionEMCAL->SetNotIDCorrectionTPC(NotIDTPC); hadCorrectionEMCAL->SetNotIDCorrectionITS(NotIDITS); Float_t NotIDConstTPC = CorrNotIDConst(0.15,etacut,"CorrNotIDEMCALTPC2",prodname,shortprodname,true,ispp,forSim, dataset); Float_t NotIDConstITS = CorrNotIDConst(0.10,etacut,"CorrNotIDEMCALTPC2",prodname,shortprodname,true,ispp,forSim, dataset); hadCorrectionEMCAL->SetNotIDConstCorrectionTPC(1.0/NotIDConstTPC); hadCorrectionEMCAL->SetNotIDConstCorrectionITS(1.0/NotIDConstITS); if(ispp){ hadCorrectionEMCAL->SetNotIDConstCorrectionTPCLowBound(1./NotIDConstTPC*(1.0-0.010)); hadCorrectionEMCAL->SetNotIDConstCorrectionITSLowBound(1./NotIDConstITS*(1.0-0.010)); hadCorrectionEMCAL->SetNotIDConstCorrectionTPCHighBound(1./NotIDConstTPC*(1.0+0.010)); hadCorrectionEMCAL->SetNotIDConstCorrectionITSHighBound(1./NotIDConstITS*(1.0+0.010)); } else{ if(dataset==2015){ hadCorrectionEMCAL->SetNotIDConstCorrectionTPCLowBound(1./NotIDConstTPC*(1.0-0.01)); hadCorrectionEMCAL->SetNotIDConstCorrectionITSLowBound(1./NotIDConstITS*(1.0-0.01)); hadCorrectionEMCAL->SetNotIDConstCorrectionTPCHighBound(1./NotIDConstTPC*(1.0+0.01)); hadCorrectionEMCAL->SetNotIDConstCorrectionITSHighBound(1./NotIDConstITS*(1.0+0.01)); } else{ hadCorrectionEMCAL->SetNotIDConstCorrectionTPCLowBound(1./NotIDConstTPC*(1.0-0.0022)); hadCorrectionEMCAL->SetNotIDConstCorrectionITSLowBound(1./NotIDConstITS*(1.0-0.0022)); hadCorrectionEMCAL->SetNotIDConstCorrectionTPCHighBound(1./NotIDConstTPC*(1.0+0.0022)); hadCorrectionEMCAL->SetNotIDConstCorrectionITSHighBound(1./NotIDConstITS*(1.0+0.0022)); } } TH1D *NoID = CorrNoID(etacut,"CorrNoIDEMCAL",prodname,shortprodname,ispp,forSim); hadCorrectionEMCAL->SetNotIDCorrectionNoPID(NoID); Float_t NoIDTPC =0.989;// CorrNoIDConst(etacut,0.15,"CorrNoIDEMCAL2",prodname,shortprodname,ispp,forSim); Float_t NoIDITS = 0.989;//CorrNoIDConst(etacut,0.1,"CorrNoIDEMCAL2",prodname,shortprodname,ispp,forSim); Float_t NoIDErr = 0.005; if(dataset==2015){ NoIDTPC =0.985;// CorrNoIDConst(etacut,0.15,"CorrNoIDEMCAL2",prodname,shortprodname,ispp,forSim); NoIDITS = 0.985;//CorrNoIDConst(etacut,0.1,"CorrNoIDEMCAL2",prodname,shortprodname,ispp,forSim); NoIDErr = 0.010; } hadCorrectionEMCAL->SetNotIDConstCorrectionTPCNoID(1./NoIDTPC); hadCorrectionEMCAL->SetNotIDConstCorrectionITSNoID(1./NoIDITS); hadCorrectionEMCAL->SetNotIDConstCorrectionTPCNoIDLowBound(1./(NoIDTPC*(1-NoIDErr))); hadCorrectionEMCAL->SetNotIDConstCorrectionITSNoIDLowBound(1./(NoIDITS*(1-NoIDErr))); hadCorrectionEMCAL->SetNotIDConstCorrectionTPCNoIDHighBound(1./(NoIDTPC*(1-NoIDErr))); hadCorrectionEMCAL->SetNotIDConstCorrectionITSNoIDHighBound(1./(NoIDITS*(1-NoIDErr))); //Here we're going to do a bit of a cheat. We want the efficiency for ITS standalone tracks + TPC+ITS tracks. This is returned by the function for the efficiency function if I ask for ITS only efficiency. Had I known how this worked I probably would have written the code differently... but... //anyhow I left a switch for changing it back. bool useITSStandalone = false; TH1D *efficiencyPionTPC = GetHistoEfficiency(etacut,"hEfficiencyPionTPC",1,1,20,useITSStandalone,true); hadCorrectionEMCAL->SetEfficiencyPionTPC(efficiencyPionTPC); TH1D *efficiencyKaonTPC = GetHistoEfficiency(etacut,"hEfficiencyKaonTPC",2,1,20,useITSStandalone,true); hadCorrectionEMCAL->SetEfficiencyKaonTPC(efficiencyKaonTPC); TH1D *efficiencyProtonTPC = GetHistoEfficiency(etacut,"hEfficiencyProtonTPC",3,1,20,useITSStandalone,true); hadCorrectionEMCAL->SetEfficiencyProtonTPC(efficiencyProtonTPC); TH1D *efficiencyHadronTPC = GetHistoEfficiency(etacut,"hEfficiencyHadronTPC",0,1,20,useITSStandalone,true); hadCorrectionEMCAL->SetEfficiencyHadronTPC(efficiencyHadronTPC); TH1D *efficiencyPionITS = GetHistoEfficiency(etacut,"hEfficiencyPionITS",1,1,20,false,true); hadCorrectionEMCAL->SetEfficiencyPionITS(efficiencyPionITS); TH1D *efficiencyKaonITS = GetHistoEfficiency(etacut,"hEfficiencyKaonITS",2,1,20,false,true); hadCorrectionEMCAL->SetEfficiencyKaonITS(efficiencyKaonITS); TH1D *efficiencyProtonITS = GetHistoEfficiency(etacut,"hEfficiencyProtonITS",3,1,20,false,true); hadCorrectionEMCAL->SetEfficiencyProtonITS(efficiencyProtonITS); TH1D *efficiencyHadronITS = GetHistoEfficiency(etacut,"hEfficiencyHadronITS",0,1,20,false,true); hadCorrectionEMCAL->SetEfficiencyHadronITS(efficiencyHadronITS); Int_t binwidth = 5; if(nCentBins>21){ binwidth = 10;//for 41 centrality bins cout<<"Using fine centrality bins"<<endl; } if(!ispp){ TH1D *efficiencyPionTPCCB0 = GetHistoEfficiency(etacut,"hEfficiencyPionTPCCB0",1,1,20,useITSStandalone,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyPionTPC((TH1D*)efficiencyPionTPCCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyPionTPCCB5 = GetHistoEfficiency(etacut,"hEfficiencyPionTPCCB5",1,1,20,useITSStandalone,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyPionTPC((TH1D*)efficiencyPionTPCCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyPionTPCCB10 = GetHistoEfficiency(etacut,"hEfficiencyPionTPCCB10",1,1,20,useITSStandalone,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionEMCAL->SetEfficiencyPionTPC((TH1D*)efficiencyPionTPCCB10->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonTPCCB0 = GetHistoEfficiency(etacut,"hEfficiencyKaonTPCCB0",2,1,20,useITSStandalone,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyKaonTPC((TH1D*)efficiencyKaonTPCCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonTPCCB5 = GetHistoEfficiency(etacut,"hEfficiencyKaonTPCCB5",2,1,20,useITSStandalone,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyKaonTPC((TH1D*)efficiencyKaonTPCCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonTPCCB10 = GetHistoEfficiency(etacut,"hEfficiencyKaonTPCCB10",2,1,20,useITSStandalone,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionEMCAL->SetEfficiencyKaonTPC((TH1D*)efficiencyKaonTPCCB10->Clone(Form("Test%i",i)),i);//Kaon TH1D *efficiencyProtonTPCCB0 = GetHistoEfficiency(etacut,"hEfficiencyProtonTPCCB0",3,1,20,useITSStandalone,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyProtonTPC((TH1D*)efficiencyProtonTPCCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyProtonTPCCB5 = GetHistoEfficiency(etacut,"hEfficiencyProtonTPCCB5",3,1,20,useITSStandalone,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyProtonTPC((TH1D*)efficiencyProtonTPCCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyProtonTPCCB10 = GetHistoEfficiency(etacut,"hEfficiencyProtonTPCCB10",3,1,20,useITSStandalone,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionEMCAL->SetEfficiencyProtonTPC((TH1D*)efficiencyProtonTPCCB10->Clone(Form("Test%i",i)),i);//Proton TH1D *efficiencyHadronTPCCB0 = GetHistoEfficiency(etacut,"hEfficiencyHadronTPCCB0",0,1,20,useITSStandalone,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyHadronTPC((TH1D*)efficiencyHadronTPCCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyHadronTPCCB5 = GetHistoEfficiency(etacut,"hEfficiencyHadronTPCCB5",0,1,20,useITSStandalone,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyHadronTPC((TH1D*)efficiencyHadronTPCCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyHadronTPCCB10 = GetHistoEfficiency(etacut,"hEfficiencyHadronTPCCB10",0,1,20,useITSStandalone,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionEMCAL->SetEfficiencyHadronTPC((TH1D*)efficiencyHadronTPCCB10->Clone(Form("Test%i",i)),i);//Hadron TH1D *efficiencyPionITSCB0 = GetHistoEfficiency(etacut,"hEfficiencyPionITSCB0",1,1,20,false,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyPionITS((TH1D*)efficiencyPionITSCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyPionITSCB5 = GetHistoEfficiency(etacut,"hEfficiencyPionITSCB5",1,1,20,false,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyPionITS((TH1D*)efficiencyPionITSCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyPionITSCB10 = GetHistoEfficiency(etacut,"hEfficiencyPionITSCB10",1,1,20,false,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionEMCAL->SetEfficiencyPionITS((TH1D*)efficiencyPionITSCB10->Clone(Form("Test%i",i)),i);//Pion TH1D *efficiencyKaonITSCB0 = GetHistoEfficiency(etacut,"hEfficiencyKaonITSCB0",2,1,20,false,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyKaonITS((TH1D*)efficiencyKaonITSCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonITSCB5 = GetHistoEfficiency(etacut,"hEfficiencyKaonITSCB5",2,1,20,false,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyKaonITS((TH1D*)efficiencyKaonITSCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonITSCB10 = GetHistoEfficiency(etacut,"hEfficiencyKaonITSCB10",2,1,20,false,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionEMCAL->SetEfficiencyKaonITS((TH1D*)efficiencyKaonITSCB10->Clone(Form("Test%i",i)),i);//Kaon TH1D *efficiencyProtonITSCB0 = GetHistoEfficiency(etacut,"hEfficiencyProtonITSCB0",3,1,20,false,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyProtonITS((TH1D*)efficiencyProtonITSCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyProtonITSCB5 = GetHistoEfficiency(etacut,"hEfficiencyProtonITSCB5",3,1,20,false,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyProtonITS((TH1D*)efficiencyProtonITSCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyProtonITSCB10 = GetHistoEfficiency(etacut,"hEfficiencyProtonITSCB10",3,1,20,false,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionEMCAL->SetEfficiencyProtonITS((TH1D*)efficiencyProtonITSCB10->Clone(Form("Test%i",i)),i);//Proton TH1D *efficiencyHadronITSCB0 = GetHistoEfficiency(etacut,"hEfficiencyHadronITSCB0",0,1,20,false,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyHadronITS((TH1D*)efficiencyHadronITSCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyHadronITSCB5 = GetHistoEfficiency(etacut,"hEfficiencyHadronITSCB5",0,1,20,false,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionEMCAL->SetEfficiencyHadronITS((TH1D*)efficiencyHadronITSCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyHadronITSCB10 = GetHistoEfficiency(etacut,"hEfficiencyHadronITSCB10",0,1,20,false,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionEMCAL->SetEfficiencyHadronITS((TH1D*)efficiencyHadronITSCB10->Clone(Form("Test%i",i)),i);//Hadron }//EMCAL hadCorrectionEMCAL->SetEfficiencyErrorLowBound(0.95); hadCorrectionEMCAL->SetEfficiencyErrorHighBound(1.05); //CorrEfficiencyPlots(true,prodname,shortprodname); //CorrEfficiencyPlots(false,prodname,shortprodname,infilename); //hadCorrectionEMCAL->GetEfficiencyHadronTPC()->Draw(); TH1D *backgroundTPC; TH1D *backgroundITS; if((dataset==20111 || dataset==20100|| dataset==2011|| dataset==2015) && !forSim){//2.76 TeV p+p or Pb+Pb if(dataset==20111){ cout<<"Fixing 2.76 TeV p+p background to be average of 900 GeV and 7 TeV scaling"<<endl; backgroundTPC = pp276TPCBkgd(); backgroundTPC->SetName("hBackgroundTPC"); backgroundITS = pp276ITSBkgd(); backgroundITS->SetName("hBackgroundITS"); } else{//PbPb cout<<"Fixing 2.76 TeV Pb+Pb background to be average of 900 GeV and 7 TeV scaling with baryon enhancement"<<endl; backgroundTPC = pp276TPCBkgd(); backgroundTPC->SetName("hBackgroundTPC"); //ITS background is currently a placeholder backgroundITS = GetHistoCorrBkgd(etacut,"hBackgroundITS",false,ispp,forSim); } } else{ backgroundTPC = GetHistoCorrBkgd(etacut,"hBackgroundTPC",true,ispp,forSim); backgroundITS = GetHistoCorrBkgd(etacut,"hBackgroundITS",false,ispp,forSim); } float bkgdpcterror = 0.0; switch(dataset){ case 2009: bkgdpcterror = 0.37; break; case 20111: bkgdpcterror = 0.38; break; case 2010: case 2012: case 2013: bkgdpcterror = 0.13; break; case 20100: case 2011: bkgdpcterror = 0.76; break; } hadCorrectionEMCAL->SetBackgroundCorrectionTPC(backgroundTPC); hadCorrectionEMCAL->SetBackgroundCorrectionITS(backgroundITS); hadCorrectionEMCAL->SetBackgroundErrorLowBound(1.0-bkgdpcterror/100.0); hadCorrectionEMCAL->SetBackgroundErrorHighBound(1.0+bkgdpcterror/100.0); hadCorrectionEMCAL->SetConstBackgroundCorrectionTPC(1.0-0.018); hadCorrectionEMCAL->SetConstBackgroundCorrectionITS(1.0-0.018); hadCorrectionEMCAL->SetConstBackgroundErrorLowBound(1-0.008); hadCorrectionEMCAL->SetConstBackgroundErrorHighBound(1+0.008); hadCorrectionEMCAL->SetConstBackgroundTrue(); //CorrBkgdPlots(prodname,shortprodname,true,ispp,forSim); //CorrBkgdPlots(prodname,shortprodname,false,ispp,forSim); hadCorrectionEMCAL->Report(); outfile->cd(); hadCorrectionEMCAL->Write(); outfile->Write(); delete hadCorrectionEMCAL; AliAnalysisHadEtCorrections *hadCorrectionPHOS = new AliAnalysisHadEtCorrections(); hadCorrectionPHOS->SetName("hadCorrectionPHOS"); float etacut = 0.12; hadCorrectionPHOS->SetEtaCut(etacut); hadCorrectionPHOS->IsData(!forSim); hadCorrectionPHOS->IsEMCal(kTRUE); hadCorrectionPHOS->SetProduction(shortprodname); hadCorrectionPHOS->SetProductionDescription(prodname); hadCorrectionPHOS->SetDataSet(dataset); //float etacut = hadCorrectionPHOS->GetEtaCut(); //cout<<"eta cut is "<<etacut<<endl; hadCorrectionPHOS->SetAcceptanceCorrectionFull(1.0); cout<<"Warning: Acceptance corrections will have to be updated to include real acceptance maps of the PHOS"<<endl; hadCorrectionPHOS->SetAcceptanceCorrectionPHOS(360.0/60.0); hadCorrectionPHOS->SetAcceptanceCorrectionEMCAL(360.0/60.0); float ptcut = 0.1; float neutralCorr = CorrNeutral(ptcut,prodname,shortprodname,ispp,forSim,TPC,false,etacut,dataset); hadCorrectionPHOS->SetNeutralCorrection(neutralCorr); //Using error from data, see analysis note for details if(ispp){ hadCorrectionPHOS->SetNeutralCorrectionLowBound(neutralCorr*(1.0-.017)); hadCorrectionPHOS->SetNeutralCorrectionHighBound(neutralCorr*(1.0+.017)); } else{ if(dataset==2015){ hadCorrectionPHOS->SetNeutralCorrectionLowBound(neutralCorr*(1.0-3.33149690798611731e-02)); hadCorrectionPHOS->SetNeutralCorrectionHighBound(neutralCorr*(1.0+3.33149690798611731e-02)); } else{ hadCorrectionPHOS->SetNeutralCorrectionLowBound(neutralCorr*(1.0-0.017)); hadCorrectionPHOS->SetNeutralCorrectionHighBound(neutralCorr*(1.0+0.017)); } } float hadronicCorr = CorrNeutral(ptcut,prodname,shortprodname,ispp,forSim,TPC,true,etacut,dataset); hadCorrectionPHOS->SetNotHadronicCorrection(hadronicCorr); if(ispp){ hadCorrectionPHOS->SetNotHadronicCorrectionLowBound(hadronicCorr*(1.0-0.009)); hadCorrectionPHOS->SetNotHadronicCorrectionHighBound(hadronicCorr*(1.0+0.009)); } else{ if(dataset==2015){ hadCorrectionPHOS->SetNotHadronicCorrectionLowBound(hadronicCorr*0.547882/(0.547882-0.02792498));//3.33149690798611731e-02)); hadCorrectionPHOS->SetNotHadronicCorrectionHighBound(hadronicCorr*0.547882/(0.547882+0.02792498));//3.33149690798611731e-02)); } else{ hadCorrectionPHOS->SetNotHadronicCorrectionLowBound(hadronicCorr*(1.0-0.009)); hadCorrectionPHOS->SetNotHadronicCorrectionHighBound(hadronicCorr*(1.0+0.009)); } } float ptcutITS = CorrPtCut(0.1,prodname,shortprodname,ispp,forSim); hadCorrectionPHOS->SetpTCutCorrectionITS(ptcutITS); float ptcutTPC = CorrPtCut(0.15,prodname,shortprodname,ispp,forSim); hadCorrectionPHOS->SetpTCutCorrectionTPC(ptcutTPC); float ptcutITSLow = CorrPtCut(0.1,prodname,shortprodname,ispp,forSim,-1); float ptcutTPCLow = CorrPtCut(0.15,prodname,shortprodname,ispp,forSim,-1); hadCorrectionPHOS->SetpTCutCorrectionITSLowBound(ptcutITSLow); hadCorrectionPHOS->SetpTCutCorrectionTPCLowBound(ptcutTPCLow); float ptcutITSHigh = CorrPtCut(0.1,prodname,shortprodname,ispp,forSim,1); float ptcutTPCHigh = CorrPtCut(0.15,prodname,shortprodname,ispp,forSim,1); hadCorrectionPHOS->SetpTCutCorrectionITSHighBound(ptcutITSHigh); hadCorrectionPHOS->SetpTCutCorrectionTPCHighBound(ptcutTPCHigh); TH1D *NotIDTPC = CorrNotID(etacut,"CorrNotIDPHOSTPC",prodname,shortprodname,true,ispp,forSim); TH1D *NotIDITS = CorrNotID(etacut,"CorrNotIDPHOSITS",prodname,shortprodname,false,ispp,forSim); hadCorrectionPHOS->SetNotIDCorrectionTPC(NotIDTPC); hadCorrectionPHOS->SetNotIDCorrectionITS(NotIDITS); Float_t NotIDConstTPC = CorrNotIDConst(0.15,etacut,"CorrNotIDPHOSTPC2",prodname,shortprodname,true,ispp,forSim,dataset); Float_t NotIDConstITS = CorrNotIDConst(0.10,etacut,"CorrNotIDPHOSTPC2",prodname,shortprodname,true,ispp,forSim,dataset); hadCorrectionPHOS->SetNotIDConstCorrectionTPC(1./NotIDConstTPC); hadCorrectionPHOS->SetNotIDConstCorrectionITS(1./NotIDConstITS); if(ispp){ hadCorrectionPHOS->SetNotIDConstCorrectionTPCLowBound(1./NotIDConstTPC*(1.0-0.010)); hadCorrectionPHOS->SetNotIDConstCorrectionITSLowBound(1./NotIDConstITS*(1.0-0.010)); hadCorrectionPHOS->SetNotIDConstCorrectionTPCHighBound(1./NotIDConstTPC*(1.0+0.010)); hadCorrectionPHOS->SetNotIDConstCorrectionITSHighBound(1./NotIDConstITS*(1.0+0.010)); } else{ if(dataset==2015){ hadCorrectionPHOS->SetNotIDConstCorrectionTPCLowBound(1./(NotIDConstTPC*(1.0-0.01))); hadCorrectionPHOS->SetNotIDConstCorrectionITSLowBound(1./(NotIDConstITS*(1.0-0.1))); hadCorrectionPHOS->SetNotIDConstCorrectionTPCHighBound(1./(NotIDConstTPC*(1.0+0.01))); hadCorrectionPHOS->SetNotIDConstCorrectionITSHighBound(1./(NotIDConstITS*(1.0+0.01))); } else{ hadCorrectionPHOS->SetNotIDConstCorrectionTPCLowBound(1./NotIDConstTPC*(1.0-0.022)); hadCorrectionPHOS->SetNotIDConstCorrectionITSLowBound(1./NotIDConstITS*(1.0-0.022)); hadCorrectionPHOS->SetNotIDConstCorrectionTPCHighBound(1./NotIDConstTPC*(1.0+0.022)); hadCorrectionPHOS->SetNotIDConstCorrectionITSHighBound(1./NotIDConstITS*(1.0+0.022)); } } TH1D *NoID = CorrNoID(etacut,"CorrNoIDPHOS",prodname,shortprodname,ispp,forSim); hadCorrectionPHOS->SetNotIDCorrectionNoPID(NoID); Float_t NoIDTPC = CorrNoIDConst(etacut,0.15,"CorrNoIDPHOS2",prodname,shortprodname,ispp,forSim, dataset); Float_t NoIDITS = CorrNoIDConst(etacut,0.1,"CorrNoIDPHOS2",prodname,shortprodname,ispp,forSim, dataset); hadCorrectionPHOS->SetNotIDConstCorrectionTPCNoID(1./NoIDTPC); hadCorrectionPHOS->SetNotIDConstCorrectionITSNoID(1./NoIDITS); hadCorrectionPHOS->SetNotIDConstCorrectionTPCNoIDLowBound(1./NoIDTPC*.98); hadCorrectionPHOS->SetNotIDConstCorrectionITSNoIDLowBound(1./NoIDITS*.98); hadCorrectionPHOS->SetNotIDConstCorrectionTPCNoIDHighBound(1./NoIDTPC*1.02); hadCorrectionPHOS->SetNotIDConstCorrectionITSNoIDHighBound(1./NoIDITS*1.02); TH1D *efficiencyPionTPC = GetHistoEfficiency(etacut,"hEfficiencyPionTPC",1,1,20,useITSStandalone,true); TH1D *efficiencyKaonTPC = GetHistoEfficiency(etacut,"hEfficiencyKaonTPC",2,1,20,useITSStandalone,true); TH1D *efficiencyProtonTPC = GetHistoEfficiency(etacut,"hEfficiencyProtonTPC",3,1,20,useITSStandalone,true); TH1D *efficiencyHadronTPC = GetHistoEfficiency(etacut,"hEfficiencyHadronTPC",0,1,20,useITSStandalone,true); TH1D *efficiencyPionITS = GetHistoEfficiency(etacut,"hEfficiencyPionITS",1,1,20,false,true); TH1D *efficiencyKaonITS = GetHistoEfficiency(etacut,"hEfficiencyKaonITS",2,1,20,false,true); TH1D *efficiencyProtonITS = GetHistoEfficiency(etacut,"hEfficiencyProtonITS",3,1,20,false,true); TH1D *efficiencyHadronITS = GetHistoEfficiency(etacut,"hEfficiencyHadronITS",0,1,20,false,true); //CorrEfficiencyPlots(true,prodname,shortprodname); //CorrEfficiencyPlots(false,prodname,shortprodname); hadCorrectionPHOS->SetEfficiencyPionTPC(efficiencyPionTPC); hadCorrectionPHOS->SetEfficiencyKaonTPC(efficiencyKaonTPC); hadCorrectionPHOS->SetEfficiencyProtonTPC(efficiencyProtonTPC); hadCorrectionPHOS->SetEfficiencyHadronTPC(efficiencyHadronTPC); hadCorrectionPHOS->SetEfficiencyPionITS(efficiencyPionITS); hadCorrectionPHOS->SetEfficiencyKaonITS(efficiencyKaonITS); hadCorrectionPHOS->SetEfficiencyProtonITS(efficiencyProtonITS); hadCorrectionPHOS->SetEfficiencyHadronITS(efficiencyHadronITS); if(!ispp){ TH1D *efficiencyPionTPCCB0 = GetHistoEfficiency(etacut,"hEfficiencyPionTPCCB0",1,1,20,useITSStandalone,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyPionTPC((TH1D*)efficiencyPionTPCCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyPionTPCCB5 = GetHistoEfficiency(etacut,"hEfficiencyPionTPCCB5",1,1,20,useITSStandalone,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyPionTPC((TH1D*)efficiencyPionTPCCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyPionTPCCB10 = GetHistoEfficiency(etacut,"hEfficiencyPionTPCCB10",1,1,20,useITSStandalone,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionPHOS->SetEfficiencyPionTPC((TH1D*)efficiencyPionTPCCB10->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonTPCCB0 = GetHistoEfficiency(etacut,"hEfficiencyKaonTPCCB0",2,1,20,useITSStandalone,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyKaonTPC((TH1D*)efficiencyKaonTPCCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonTPCCB5 = GetHistoEfficiency(etacut,"hEfficiencyKaonTPCCB5",2,1,20,useITSStandalone,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyKaonTPC((TH1D*)efficiencyKaonTPCCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonTPCCB10 = GetHistoEfficiency(etacut,"hEfficiencyKaonTPCCB10",2,1,20,useITSStandalone,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionPHOS->SetEfficiencyKaonTPC((TH1D*)efficiencyKaonTPCCB10->Clone(Form("Test%i",i)),i);//Kaon TH1D *efficiencyProtonTPCCB0 = GetHistoEfficiency(etacut,"hEfficiencyProtonTPCCB0",3,1,20,useITSStandalone,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyProtonTPC((TH1D*)efficiencyProtonTPCCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyProtonTPCCB5 = GetHistoEfficiency(etacut,"hEfficiencyProtonTPCCB5",3,1,20,useITSStandalone,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyProtonTPC((TH1D*)efficiencyProtonTPCCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyProtonTPCCB10 = GetHistoEfficiency(etacut,"hEfficiencyProtonTPCCB10",3,1,20,useITSStandalone,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionPHOS->SetEfficiencyProtonTPC((TH1D*)efficiencyProtonTPCCB10->Clone(Form("Test%i",i)),i);//Proton TH1D *efficiencyHadronTPCCB0 = GetHistoEfficiency(etacut,"hEfficiencyHadronTPCCB0",0,1,20,useITSStandalone,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyHadronTPC((TH1D*)efficiencyHadronTPCCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyHadronTPCCB5 = GetHistoEfficiency(etacut,"hEfficiencyHadronTPCCB5",0,1,20,useITSStandalone,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyHadronTPC((TH1D*)efficiencyHadronTPCCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyHadronTPCCB10 = GetHistoEfficiency(etacut,"hEfficiencyHadronTPCCB10",0,1,20,useITSStandalone,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionPHOS->SetEfficiencyHadronTPC((TH1D*)efficiencyHadronTPCCB10->Clone(Form("Test%i",i)),i);//Hadron TH1D *efficiencyPionITSCB0 = GetHistoEfficiency(etacut,"hEfficiencyPionITSCB0",1,1,20,false,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyPionITS((TH1D*)efficiencyPionITSCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyPionITSCB5 = GetHistoEfficiency(etacut,"hEfficiencyPionITSCB5",1,1,20,false,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyPionITS((TH1D*)efficiencyPionITSCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyPionITSCB10 = GetHistoEfficiency(etacut,"hEfficiencyPionITSCB10",1,1,20,false,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionPHOS->SetEfficiencyPionITS((TH1D*)efficiencyPionITSCB10->Clone(Form("Test%i",i)),i);//Pion TH1D *efficiencyKaonITSCB0 = GetHistoEfficiency(etacut,"hEfficiencyKaonITSCB0",2,1,20,false,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyKaonITS((TH1D*)efficiencyKaonITSCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonITSCB5 = GetHistoEfficiency(etacut,"hEfficiencyKaonITSCB5",2,1,20,false,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyKaonITS((TH1D*)efficiencyKaonITSCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyKaonITSCB10 = GetHistoEfficiency(etacut,"hEfficiencyKaonITSCB10",2,1,20,false,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionPHOS->SetEfficiencyKaonITS((TH1D*)efficiencyKaonITSCB10->Clone(Form("Test%i",i)),i);//Kaon TH1D *efficiencyProtonITSCB0 = GetHistoEfficiency(etacut,"hEfficiencyProtonITSCB0",3,1,20,false,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyProtonITS((TH1D*)efficiencyProtonITSCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyProtonITSCB5 = GetHistoEfficiency(etacut,"hEfficiencyProtonITSCB5",3,1,20,false,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyProtonITS((TH1D*)efficiencyProtonITSCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyProtonITSCB10 = GetHistoEfficiency(etacut,"hEfficiencyProtonITSCB10",3,1,20,false,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionPHOS->SetEfficiencyProtonITS((TH1D*)efficiencyProtonITSCB10->Clone(Form("Test%i",i)),i);//Proton TH1D *efficiencyHadronITSCB0 = GetHistoEfficiency(etacut,"hEfficiencyHadronITSCB0",0,1,20,false,true,0,binwidth-1); for(int i=0;i<=binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyHadronITS((TH1D*)efficiencyHadronITSCB0->Clone(Form("Test%i",i)),i); TH1D *efficiencyHadronITSCB5 = GetHistoEfficiency(etacut,"hEfficiencyHadronITSCB5",0,1,20,false,true,binwidth,2*binwidth-1); for(int i=binwidth;i<=2*binwidth-1;i++) hadCorrectionPHOS->SetEfficiencyHadronITS((TH1D*)efficiencyHadronITSCB5->Clone(Form("Test%i",i)),i); TH1D *efficiencyHadronITSCB10 = GetHistoEfficiency(etacut,"hEfficiencyHadronITSCB10",0,1,20,false,true,2*binwidth,3*binwidth); for(int i=2*binwidth;i<=nCentBins-1;i++) hadCorrectionPHOS->SetEfficiencyHadronITS((TH1D*)efficiencyHadronITSCB10->Clone(Form("Test%i",i)),i);//Hadron }//EMCAL hadCorrectionPHOS->SetEfficiencyErrorLowBound(0.97); hadCorrectionPHOS->SetEfficiencyErrorHighBound(1.03); TH1D *backgroundTPC; TH1D *backgroundITS; if((dataset==20111 || dataset==20100|| dataset==2011|| dataset==2015) && !forSim){//2.76 TeV p+p or Pb+Pb if(dataset==20111){ cout<<"Fixing 2.76 TeV p+p background to be average of 900 GeV and 7 TeV scaling"<<endl; backgroundTPC = pp276TPCBkgd(); backgroundTPC->SetName("hBackgroundTPCPHOS"); backgroundITS = pp276ITSBkgd(); backgroundITS->SetName("hBackgroundITSPHOS"); } else{//PbPb cout<<"Fixing 2.76 TeV Pb+Pb background to be average of 900 GeV and 7 TeV scaling with baryon enhancement"<<endl; backgroundTPC = pp276TPCBkgd(); backgroundTPC->SetName("hBackgroundTPCPHOS"); //ITS background is currently a placeholder backgroundITS = GetHistoCorrBkgd(etacut,"hBackgroundITS",false,ispp,forSim); } } else{ backgroundTPC = GetHistoCorrBkgd(etacut,"hBackgroundTPC",true,ispp,forSim); backgroundITS = GetHistoCorrBkgd(etacut,"hBackgroundITS",false,ispp,forSim); } hadCorrectionPHOS->SetBackgroundCorrectionTPC(backgroundTPC); hadCorrectionPHOS->SetBackgroundCorrectionITS(backgroundITS); hadCorrectionPHOS->SetBackgroundErrorLowBound(1.0-0.001); hadCorrectionPHOS->SetBackgroundErrorHighBound(1.0+0.001); hadCorrectionPHOS->SetConstBackgroundCorrectionTPC(1.0-0.018); hadCorrectionPHOS->SetConstBackgroundCorrectionITS(1.0-0.018); hadCorrectionPHOS->SetConstBackgroundErrorLowBound(1-0.008); hadCorrectionPHOS->SetConstBackgroundErrorHighBound(1+0.008); hadCorrectionPHOS->SetConstBackgroundTrue(); //CorrBkgdPlots(prodname,shortprodname,true,ispp,forSim); //CorrBkgdPlots(prodname,shortprodname,false,ispp,forSim); hadCorrectionPHOS->Report(); //Write the output outfile->cd(); hadCorrectionPHOS->Write(); outfile->Write(); outfile->Close(); timer.Stop(); timer.Print(); } //==================================CorrNeutral============================================== Float_t CorrNeutral(float ptcut, char *prodname, char *shortprodname, bool ispp, bool forSim, bool TPC, bool hadronic, float etacut, int dataset){ if(!forSim){//for data we have evaluated the neutral correction from ALICE data if(hadronic){//for tot et from had et if(2015) return 1.0/0.547882; return 1/0.5665;//0.5665 0.0145 <-- Correct - what should be applied } else{//for had et only if(dataset==2009){ return 1.0/0.7571; } else{ return 1.0/0.751; } } } gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",400,400); c->SetTopMargin(0.0); c->SetRightMargin(0.0); c->SetBorderSize(0); c->SetFillColor(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); TPad *ptpad = c->cd(1); ptpad->SetTopMargin(0.04); ptpad->SetRightMargin(0.04); ptpad->SetLeftMargin(0.149288); ptpad->SetBorderSize(0); ptpad->SetFillColor(0); ptpad->SetFillColor(0); ptpad->SetBorderMode(0); ptpad->SetFrameFillColor(0); ptpad->SetFrameBorderMode(0); int phosmarker = 20; sprintf(prefix,"%s%2.1f",shortprodname,ptcut); sprintf(histoname,"%stotal",histoname); int colortotal = 1; int casetotal = 4; if(hadronic) casetotal = 8; TH1D *total = GetHistoCorrNeutral(ptcut,histoname,ispp,forSim,casetotal,false,colortotal,phosmarker,hadronic); int colorallneutral = 2; TH1D *allneutral = GetHistoCorrNeutral(ptcut,"allneutral",ispp,forSim,3,false,colorallneutral,phosmarker,hadronic); int colorchargedsecondary = TColor::kViolet-3; TH1D *chargedsecondary = GetHistoCorrNeutral(ptcut,"chargedsecondary",ispp,forSim,2,false,colorchargedsecondary,phosmarker,hadronic); int colorneutralUndet = 4; TH1D *neutralUndet = GetHistoCorrNeutral(ptcut,"neutralUndet",ispp,forSim,1,false,colorneutralUndet,phosmarker,hadronic); int colorv0 = TColor::kGreen+2; TH1D *v0 = GetHistoCorrNeutral(ptcut,"v0",ispp,forSim,0,false,colorv0,phosmarker,hadronic); int colorem = TColor::kCyan; TH1D *em = GetHistoCorrNeutral(ptcut,"em",ispp,forSim,9,false,colorem,phosmarker,hadronic); TF1 *func = new TF1("func","[0]",-.7,.7); func->SetParameter(0,0.2); total->Fit(func,"","",-etacut,etacut); //total->SetAxisRange(0.0,4); total->GetXaxis()->SetLabelSize(0.05); total->GetYaxis()->SetLabelSize(0.045); total->GetXaxis()->SetTitleSize(0.05); total->GetYaxis()->SetTitleSize(0.06); if(hadronic){ total->SetMaximum(0.6); total->SetMinimum(0.0); } else{ total->SetMaximum(0.3); total->SetMinimum(0.0); } total->Draw(); allneutral->Draw("same"); chargedsecondary->Draw("same"); neutralUndet->Draw("same"); v0->Draw("same"); if(hadronic) em->Draw("same"); TLatex *tex = new TLatex(0.161478,1.0835,prodname); tex->SetTextSize(0.0537634); tex->Draw(); TLegend *leg2 = new TLegend(0.518321,0.746873,0.774812,0.955343); leg2->AddEntry(total,"Total"); leg2->AddEntry(allneutral,"#Lambda,#bar{#Lambda},K^{0}_{S},K^{0}_{L},n,#bar{n}"); leg2->AddEntry(neutralUndet,"K^{0}_{L},n,#bar{n}"); if(hadronic) leg2->AddEntry(em,"e^{#pm},#gamma,#eta,#pi^{0},#omega"); leg2->SetFillStyle(0); leg2->SetFillColor(0); leg2->SetBorderSize(0); leg2->SetTextSize(0.0548607); leg2->Draw(); if(hadronic){ sprintf(epsname,"pics/%s/fhadronic.eps",shortprodname); sprintf(pngname,"pics/%s/fhadronic.png",shortprodname); } else{ sprintf(epsname,"pics/%s/fneutral.eps",shortprodname); sprintf(pngname,"pics/%s/fneutral.png",shortprodname); } c->SaveAs(epsname); c->SaveAs(pngname); delete total; delete allneutral; delete chargedsecondary; delete neutralUndet; delete v0; delete em; delete c; float corr = func->GetParameter(0); delete func; delete tex; delete leg2; return 1.0/(1.0-corr); } TH1D *GetHistoCorrNeutral(float cut, char *name, bool ispp, bool forSim, int mycase, bool eta, int color, int marker, bool hadronic){ file->cd(); char *reweightname = ""; if(!forSim) reweightname = "Reweighted"; TH2F *numeratorParent; switch(mycase){ case 0: numeratorParent= (TH2F*)((TH2F*) out2->FindObject(Form("EtSimulatedLambda%s",reweightname)))->Clone("v0"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedAntiLambda%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0S%s",reweightname))); break; case 1: numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtSimulatedK0L%s",reweightname)))->Clone("Knnbar"); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedNeutron")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiNeutron")); break; case 2: numeratorParent = (TH2F*)((TH2F*) out2->FindObject("EtSimulatedOmega"))->Clone("ch2ndary"); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiOmega")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedXi")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedXi0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi0")); break; case 3: numeratorParent= (TH2F*)((TH2F*) out2->FindObject(Form("EtSimulatedLambda%s",reweightname)))->Clone("allneutral"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedAntiLambda%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0S%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0L%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedNeutron")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiNeutron")); break; case 4: numeratorParent= (TH2F*)((TH2F*) out2->FindObject(Form("EtSimulatedLambda%s",reweightname)))->Clone("allneutral"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedAntiLambda%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0S%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0L%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedNeutron")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiNeutron")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedOmega")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiOmega")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedXi")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedXi0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi0")); break; case 5: numeratorParent= (TH2F*)((TH2F*) out2->FindObject("EtSimulatedXi"))->Clone("allxi"); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedXi0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi0")); break; case 6: numeratorParent = (TH2F*)((TH2F*) out2->FindObject("EtSimulatedOmega"))->Clone("allomega"); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiOmega")); break; case 7: numeratorParent = (TH2F*)((TH2F*) out2->FindObject("EtSimulatedSigma"))->Clone("allsigma"); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiSigma")); break; case 8: numeratorParent= (TH2F*)((TH2F*) out2->FindObject(Form("EtSimulatedLambda%s",reweightname)))->Clone("allneutral"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedAntiLambda%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0S%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0L%s",reweightname))); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedNeutron")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiNeutron")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedOmega")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiOmega")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedXi")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedXi0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedGamma")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedEta")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedPi0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedOmega0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedEPlus")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedEMinus")); break; case 9: numeratorParent= (TH2F*)((TH2F*) out2->FindObject("EtSimulatedGamma"))->Clone("allem"); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedEta")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedPi0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedOmega0")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedEPlus")); numeratorParent->Add((TH2F*) out2->FindObject("EtSimulatedEMinus")); break; } TH2F *allhad; //allhad=(TH2F*) ((TH2F*) out2->FindObject("EtSimulatedAllHadron"))->Clone("id"); allhad=(TH2F*) ((TH2F*) out2->FindObject("EtSimulatedPiPlus"))->Clone("id"); allhad->Add((TH2F*) out2->FindObject("EtSimulatedPiMinus")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedKMinus")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedKPlus")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedProton")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedAntiProton")); allhad->Add((TH2F*) out2->FindObject(Form("EtSimulatedLambda%s",reweightname))); allhad->Add((TH2F*) out2->FindObject(Form("EtSimulatedAntiLambda%s",reweightname))); allhad->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0S%s",reweightname))); allhad->Add((TH2F*) out2->FindObject(Form("EtSimulatedK0L%s",reweightname))); allhad->Add((TH2F*) out2->FindObject("EtSimulatedNeutron")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedAntiNeutron")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedEPlus")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedEMinus")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedOmega")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedAntiOmega")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedXi")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedSigma")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedAntiSigma")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedXi0")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedAntiXi0")); if(hadronic){//if we are getting the correction for the hadronic only case... allhad->Add((TH2F*) out2->FindObject("EtSimulatedGamma")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedEta")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedPi0")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedOmega0")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedEPlus")); allhad->Add((TH2F*) out2->FindObject("EtSimulatedEMinus")); } TH1D *denominator; TH1D *numerator; if(eta){ int lowbin = numeratorParent->GetYaxis()->FindBin(-cut+.001);//make sure we don't accv0entally get the wrong bin int highbin = numeratorParent->GetYaxis()->FindBin(cut-.001); //cout<<"Projecting from "<<numeratorParent->GetYaxis()->GetBinLowEdge(lowbin)<<" to "<<numeratorParent->GetYaxis()->GetBinLowEdge(highbin+1)<<endl; denominator = allhad->ProjectionX("name",lowbin,highbin); numerator = numeratorParent->ProjectionX("numerator",lowbin,highbin); } else{ int lowbin = allhad->GetXaxis()->FindBin(cut);//make sure we don't accidentally get the wrong bin int highbin = allhad->GetXaxis()->GetNbins(); //cout<<"Projecting from "<<allhad->GetXaxis()->GetBinLowEdge(lowbin)<<" to "<<allhad->GetXaxis()->GetBinLowEdge(highbin+1)<<endl; numerator = numeratorParent->ProjectionY("name",lowbin,highbin); denominator = allhad->ProjectionY("denominator",lowbin,highbin); } numerator->Divide(denominator); //numerator->Rebin(2); //numerator->Scale(0.5); numerator->SetYTitle("E_{T}^{had,sample}/E_{T}^{had,total}"); numerator->GetYaxis()->SetTitleOffset(1.2); numerator->SetMarkerColor(color); numerator->SetLineColor(color); numerator->SetMarkerStyle(marker); delete denominator; delete numeratorParent; delete allhad; //file->Close(); numerator->SetName(name); return numerator; } //===============================CorrPtCut========================================= TH1D *GetHistoCorrPtCut(float ptcut, char *name, bool ispp, bool forSim, int mycase){ file->cd(); TH2F *allhad = ((TH2F*) out2->FindObject("EtSimulatedAllHadron"))->Clone("allhad"); TH2F *ptlow = ((TH2F*) out2->FindObject("EtSimulatedChargedHadronAssumingNoPt"))->Clone("ptlow"); TH2F *pthigh; if(ptcut>0.14){//TPC cut off (TH2F*)pthigh =(TH2F*) ((TH2F*) out2->FindObject("EtSimulatedChargedHadronAssumingPtTPCCut"))->Clone("pthigh"); } else{ (TH2F*)pthigh =(TH2F*) ((TH2F*) out2->FindObject("EtSimulatedChargedHadronAssumingPtITSCut"))->Clone("pthigh"); } int lowbin = allhad->GetXaxis()->FindBin(0.0);//make sure we don't accidentally get the wrong bin int highbin = allhad->GetXaxis()->FindBin(ptcut); int nbins = allhad->GetXaxis()->GetNbins(); //cout<<"Projecting from "<<allhad->GetXaxis()->GetBinLowEdge(lowbin)<<" to "<<allhad->GetXaxis()->GetBinLowEdge(highbin+1)<<endl; //cout<<"Projecting from "<<allhad->GetXaxis()->GetBinLowEdge(lowbin)<<" to "<<allhad->GetXaxis()->GetBinLowEdge(nbins)<<endl; //allhad->Sumw2(); TH1D *numerator; TH1D *denominator; switch(mycase){ case -1: numerator = ptlow->ProjectionY("nameLow",lowbin,highbin); denominator = allhad->ProjectionY("denominatorLow",highbin,nbins); denominator->Add(numerator); break; case 1: numerator = pthigh->ProjectionY("nameHigh",lowbin,highbin); denominator = allhad->ProjectionY("denominatorHigh",highbin,nbins); denominator->Add(numerator); break; default: numerator = allhad->ProjectionY("name",lowbin,highbin); denominator = allhad->ProjectionY("denominator",lowbin,nbins); } numerator->Divide(denominator); numerator->SetYTitle("E_{T}^{had, p_{T}<cut-off}/E_{T}^{had, all p_{T}}"); numerator->GetYaxis()->SetTitleOffset(1.); numerator->GetYaxis()->SetTitleSize(0.08); numerator->GetYaxis()->SetLabelSize(0.05); numerator->GetXaxis()->SetTitleSize(0.08); numerator->GetXaxis()->SetLabelSize(0.05); numerator->GetXaxis()->SetTitleOffset(.6); //numerator->Rebin(2); //numerator->Scale(0.5); //numerator->Draw("e"); delete allhad; delete denominator; delete ptlow; delete pthigh; numerator->SetName(name); return numerator; } Float_t CorrPtCut(float ptcut, char *prodname, char *shortprodname, bool ispp, bool forSim, int mycase){ gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",500,400); c->SetTopMargin(0.04); c->SetRightMargin(0.04); c->SetLeftMargin(0.181452); c->SetBottomMargin(0.134409); c->SetBorderSize(0); c->SetFillColor(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); TH1D *High = GetHistoCorrPtCut(0.15-.001,"High",ispp,forSim,mycase); TH1D *Low = GetHistoCorrPtCut(0.1-.001,"Low",ispp,forSim,mycase); TH1D *Lowest = GetHistoCorrPtCut(0.05-.001,"Lowest",ispp,forSim,mycase); TF1 *func = new TF1("func","[0]",-.7,.7); func->SetParameter(0,0.2); if(ptcut<.125){//its cuts Low->Fit(func); } else{//tpc cuts High->Fit(func); } High->SetMaximum(0.04); High->SetMinimum(0.0); High->SetMarkerColor(2); Low->SetMarkerColor(4); High->SetLineColor(2); Low->SetLineColor(4); High->SetMinimum(0.0); High->SetMarkerStyle(20); Low->SetMarkerStyle(21); Lowest->SetMarkerStyle(22); High->Draw(); Low->Draw("same"); Lowest->Draw("same"); TLatex *tex = new TLatex(-0.723444,0.0373593,prodname); tex->SetTextSize(0.0537634); tex->Draw(); TLegend *leg = new TLegend(0.217742,0.66129,0.477823,0.873656); leg->AddEntry(High,"p_{T} cut-off = 0.15 GeV/c"); leg->AddEntry(Low,"p_{T} cut-off = 0.1 GeV/c"); leg->AddEntry(Lowest,"p_{T} cut-off = 0.05 GeV/c"); leg->SetFillStyle(0); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetTextSize(0.0537634); leg->Draw(); if(ptcut<.125){//its cuts c->SaveAs(Form("pics/%s/fptcutITS.eps",shortprodname)); c->SaveAs(Form("pics/%s/fptcutITS.png",shortprodname)); } else{//tpc cuts c->SaveAs(Form("pics/%s/fptcutTPC.eps",shortprodname)); c->SaveAs(Form("pics/%s/fptcutTPC.png",shortprodname)); } float corr = func->GetParameter(0); //cout<<"Pt cut correction: "<<1.0/(1.0-corr)<<endl; delete High; delete Low; delete Lowest; delete func; delete c; delete tex; delete leg; return 1.0/(1.0-corr); } //==================================CorrNotID================================================= TH1D *GetHistoCorrNotID(float etacut,char *name, bool TPC, bool eta, bool ispp, bool forSim){ file->cd(); char *myname = mynameITS; if(TPC) myname = mynameTPCITS; TH2F *notid = ((TH2F*) out2->FindObject(Form("EtReconstructed%sUnidentifiedAssumingPion",myname)))->Clone("notid"); TH2F *nNotid = ((TH2F*) out2->FindObject(Form("EtNReconstructed%sUnidentified",myname)))->Clone("nNotid"); if(!eta){ //cout<<"Correction determined for all charged hadrons"<<endl; notid->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedPiPlus",myname))); notid->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedPiMinus",myname))); notid->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedKPlus",myname))); notid->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedKMinus",myname))); notid->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedProton",myname))); notid->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedAntiProton",myname))); nNotid->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%sPiPlus",myname))); nNotid->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%sPiMinus",myname))); nNotid->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%sKPlus",myname))); nNotid->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%sKMinus",myname))); nNotid->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%sProton",myname))); nNotid->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%sAntiProton",myname))); } TH2F *id = ((TH2F*) out2->FindObject(Form("EtReconstructed%sUnidentified",myname)))->Clone("id"); if(!eta){ id->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedPiPlus",myname))); id->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedPiMinus",myname))); id->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedKPlus",myname))); id->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedKMinus",myname))); id->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedProton",myname))); id->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedAntiProton",myname))); } TH1D *nNotidProj; TH1D *denominator; TH1D *numerator; if(eta){ int lowbin = notid->GetYaxis()->FindBin(-etacut+.001);//make sure we don't accv0entally get the wrong bin int highbin = notid->GetYaxis()->FindBin(etacut-.001); //cout<<"Projecting from "<<notid->GetYaxis()->GetBinLowEdge(lowbin)<<" to "<<notid->GetYaxis()->GetBinLowEdge(highbin+1)<<endl; denominator = id->ProjectionX("name",lowbin,highbin); numerator = notid->ProjectionX("numerator",lowbin,highbin); nNotidProj = nNotid->ProjectionX("nNotidProj",lowbin,highbin); } else{ //cout<<"Getting eta dependence"<<endl; int lowbin = id->GetXaxis()->FindBin(etacut);//make sure we don't accidentally get the wrong bin int highbin; if(etacut<0.15){//then we actually have ITS standalone tracks and we only want this to run from 0.1 to 0.15 because this will be used only for ITS standalone tracks highbin = id->GetXaxis()->FindBin(0.15); } else{ highbin = id->GetXaxis()->GetNbins(); } //cout<<"Projecting from "<<id->GetXaxis()->GetBinLowEdge(lowbin)<<" to "<<id->GetXaxis()->GetBinLowEdge(highbin+1)<<endl; numerator = notid->ProjectionY("name",lowbin,highbin); denominator = id->ProjectionY("denominator",lowbin,highbin); nNotidProj = nNotid->ProjectionY("nNotidProj",lowbin,highbin); } TH1D *result = numerator; if(!denominator){ cerr<<"Uh-oh! Can't find denominator!!"; return numerator; } else{result->Divide(denominator);} if(result->GetNbinsX() != nNotidProj->GetNbinsX()){ cerr<<"Uh-oh! Can't rescale errors! "<<result->GetNbinsX()<<"!="<<nNotidProj->GetNbinsX()<<endl; return result; } if(!nNotidProj){ cerr<<"Uh-oh! Can't find histogram!!"; return numerator; } //fixing the errors for(int i=1;i<=result->GetNbinsX();i++){ Float_t value = result->GetBinContent(i); Float_t valueerr = result->GetBinError(i); Float_t n = nNotidProj->GetBinContent(i); Float_t err; if(n<=0) err = 0.0; else{err= value/TMath::Power(n,0.5);} result->SetBinError(i,err); //cout<<"Was "<<valueerr<<", setting to "<<err<<endl; } result->SetYTitle("Ratio of E_{T}^{assuming pion}/E_{T}^{real}"); result->GetYaxis()->SetTitleOffset(1.2); delete denominator; delete nNotidProj; delete notid; delete nNotid; delete id; result->SetName(name); return result; } TH1D *CorrNotID(float etacut,char *name, char *prodname, char *shortprodname, bool TPC, bool ispp, bool forSim){ gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",500,400); c->SetTopMargin(0.04); c->SetRightMargin(0.04); c->SetBorderSize(0); c->SetFillColor(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); TH1D *PHOS = GetHistoCorrNotID(etacut,name,TPC,true,ispp,forSim); PHOS->SetMarkerColor(2); PHOS->SetLineColor(2); PHOS->SetAxisRange(0.0,4); if(TPC){ PHOS->SetMaximum(1.1); PHOS->SetMinimum(0.85); } else{ PHOS->SetAxisRange(0.0,0.5); } PHOS->SetMarkerStyle(20); PHOS->Draw(); TLatex *tex = new TLatex(0.161478,1.0835,prodname); tex->SetTextSize(0.0537634); tex->Draw(); char *detector = detectorEMCAL; if(etacut<0.2) detector = detectorPHOS; if(TPC){ sprintf(epsname,"pics/%s/fnotidTPC%s.eps",shortprodname,detector); sprintf(pngname,"pics/%s/fnotidTPC%s.png",shortprodname,detector); } else{ sprintf(epsname,"pics/%s/fnotidITS%s.eps",shortprodname,detector); sprintf(pngname,"pics/%s/fnotidITS%s.png",shortprodname,detector); } c->SaveAs(epsname); c->SaveAs(pngname); delete c; delete tex; PHOS->SetName(name); return PHOS; } Float_t CorrNotIDConst(float ptcut, float etacut,char *name, char *prodname, char *shortprodname, bool TPC, bool ispp, bool forSim, Int_t dataset){ if(!forSim){ if(ispp){ return 0.996; } else{ if(dataset==2015){ return 0.99; } else{ return 0.992; } } } gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",500,400); c->SetTopMargin(0.04); c->SetRightMargin(0.04); c->SetBorderSize(0); c->SetFillColor(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); TH1D *PHOS = GetHistoCorrNotID(ptcut,name,TPC,false,ispp,forSim); PHOS->SetMarkerColor(2); PHOS->SetLineColor(2); PHOS->SetMaximum(1.01); PHOS->SetMinimum(0.98); TF1 *func = new TF1("func","[0]",-etacut,etacut); PHOS->Fit(func,"","",-etacut,etacut); PHOS->SetMarkerStyle(20); PHOS->Draw(); TLatex *tex = new TLatex(0.161478,1.0835,prodname); tex->SetTextSize(0.0537634); tex->Draw(); char *detector = detectorEMCAL; if(etacut<0.2) detector = detectorPHOS; if(TPC){ sprintf(epsname,"pics/%s/fnotidConstTPC%s.eps",shortprodname,detector); sprintf(pngname,"pics/%s/fnotidConstTPC%s.png",shortprodname,detector); } else{ sprintf(epsname,"pics/%s/fnotidConstITS%s.eps",shortprodname,detector); sprintf(pngname,"pics/%s/fnotidConstITS%s.png",shortprodname,detector); } c->SaveAs(epsname); c->SaveAs(pngname); delete c; delete PHOS; float value = func->GetParameter(0); delete func; delete tex; return value; } //==================================CorrNoID================================================= TH1D *GetHistoNoID(float etacut, char *name, bool eta, bool TPC, bool ispp, bool forSim){ file->cd(); char *myname = mynameITS; if(TPC) myname = mynameTPCITS; TH2F *notid = ((TH2F*) out2->FindObject(Form("EtReconstructed%sChargedHadronAssumingPion",myname)))->Clone("notid"); TH2F *nNotid = ((TH2F*) out2->FindObject(Form("EtNReconstructed%sChargedHadron",myname)))->Clone("nNotid"); TH2F *id = ((TH2F*) out2->FindObject(Form("EtReconstructed%sChargedHadron",myname)))->Clone("id"); int lowbin = id->GetYaxis()->FindBin(-etacut+.001);//make sure we don't accidentally get the wrong bin int highbin = id->GetYaxis()->FindBin(etacut-.001); TH1D *nNotidProj; TH1D *denominator; TH1D *numerator; if(eta){ int lowbin = notid->GetYaxis()->FindBin(-etacut+.001);//make sure we don't accv0entally get the wrong bin int highbin = notid->GetYaxis()->FindBin(etacut-.001); //cout<<"Projecting from "<<notid->GetYaxis()->GetBinLowEdge(lowbin)<<" to "<<notid->GetYaxis()->GetBinLowEdge(highbin+1)<<endl; denominator = id->ProjectionX("name",lowbin,highbin); numerator = notid->ProjectionX("numerator",lowbin,highbin); nNotidProj = nNotid->ProjectionX("nNotidProj",lowbin,highbin); } else{ //cout<<"Getting eta dependence"<<endl; int lowbin = id->GetXaxis()->FindBin(etacut);//make sure we don't accidentally get the wrong bin int highbin; if(etacut<0.15){//then we actually have ITS standalone tracks and we only want this to run from 0.1 to 0.15 because this will be used only for ITS standalone tracks highbin = id->GetXaxis()->FindBin(0.15); } else{ highbin = id->GetXaxis()->GetNbins(); } //cout<<"Projecting from "<<id->GetXaxis()->GetBinLowEdge(lowbin)<<" to "<<id->GetXaxis()->GetBinLowEdge(highbin+1)<<endl; numerator = notid->ProjectionY("name",lowbin,highbin); denominator = id->ProjectionY("denominator",lowbin,highbin); nNotidProj = nNotid->ProjectionY("nNotidProj",lowbin,highbin); } if(denominator) numerator->Divide(denominator); if(numerator->GetNbinsX() != nNotidProj->GetNbinsX()){ cerr<<"Uh-oh! Can't rescale errors! "<<numerator->GetNbinsX()<<"!="<<nNotidProj->GetNbinsX()<<endl; return numerator; } //fixing the errors for(int i=1;i<=numerator->GetNbinsX();i++){ Float_t value = numerator->GetBinContent(i); Float_t valueerr = numerator->GetBinError(i); Float_t n = nNotidProj->GetBinContent(i); Float_t err=0.; if(n>0.0){ err = value/TMath::Power(n,0.5); } numerator->SetBinError(i,err);; } numerator->SetYTitle("Ratio of E_{T}^{assuming pion}/E_{T}^{real}"); numerator->GetYaxis()->SetTitleOffset(1.2); delete denominator; delete nNotidProj; delete notid; delete nNotid; delete id; numerator->SetName(name); return numerator; } TH1D *CorrNoID(float etacut,char *name, char *prodname, char *shortprodname, bool ispp, bool forSim){ gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",500,400); c->SetTopMargin(0.04); c->SetRightMargin(0.04); c->SetBorderSize(0); c->SetFillColor(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); TH1D *PHOS = GetHistoNoID(etacut,name,true,true,ispp,forSim); PHOS->SetMarkerColor(2); PHOS->SetLineColor(2); PHOS->SetAxisRange(0.0,4); PHOS->SetMaximum(1.1); PHOS->SetMinimum(0.85); PHOS->SetMarkerStyle(20);; PHOS->Draw(); TLatex *tex = new TLatex(0.161478,1.0835,prodname); tex->SetTextSize(0.0537634); tex->Draw(); char *detector = detectorEMCAL; if(etacut<0.2) detector = detectorPHOS; sprintf(epsname,"pics/%s/fnoid%s.eps",shortprodname,detector); sprintf(pngname,"pics/%s/fnoid%s.png",shortprodname,detector); c->SaveAs(epsname); c->SaveAs(pngname); delete c; delete tex; PHOS->SetName(name); return PHOS; } Float_t CorrNoIDConst(float etacut, float ptcut,char *name, char *prodname, char *shortprodname, bool ispp, bool forSim, Int_t dataset){ if(dataset==2015){ return 0.985; } gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",500,400); c->SetTopMargin(0.04); c->SetRightMargin(0.04); c->SetBorderSize(0); c->SetFillColor(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); bool TPC = true; if(ptcut<.15) TPC = false; TH1D *PHOS = GetHistoNoID(ptcut,name,false,TPC,ispp,forSim); TF1 *func = new TF1("func","[0]",-etacut,etacut); PHOS->Fit(func,"","",-etacut,etacut); PHOS->SetMarkerColor(2); PHOS->SetLineColor(2); PHOS->SetMaximum(1.1); PHOS->SetMinimum(0.85); PHOS->SetMarkerStyle(20);; PHOS->Draw(); TLatex *tex = new TLatex(0.161478,1.0835,prodname); tex->SetTextSize(0.0537634); tex->Draw(); char *detector = detectorEMCAL; if(etacut<0.2) detector = detectorPHOS; if(TPC){ sprintf(epsname,"pics/%s/fnoid%sTPC.eps",shortprodname,detector); sprintf(pngname,"pics/%s/fnoid%sTPC.png",shortprodname,detector); } else{ sprintf(epsname,"pics/%s/fnoid%sITS.eps",shortprodname,detector); sprintf(pngname,"pics/%s/fnoid%sITS.png",shortprodname,detector); } c->SaveAs(epsname); c->SaveAs(pngname); delete c; delete PHOS; float value = func->GetParameter(0); delete func; delete tex; return value; } //==================================Efficiency================================================= TH1D* bayneseffdiv(TH1D* numerator, TH1D* denominator,Char_t* name) { if(!numerator){ cerr<<"Error: numerator does not exist!"<<endl; return NULL; } if(!denominator){ cerr<<"Error: denominator does not exist!"<<endl; return NULL; } TH1D* result = (TH1D*)numerator->Clone(name); Int_t nbins = numerator->GetNbinsX(); for (Int_t ibin=0; ibin<= nbins+1; ++ibin) { Double_t numeratorVal = numerator->GetBinContent(ibin); Double_t denominatorVal = denominator->GetBinContent(ibin); // Check if the errors are right or the thing is scaled Double_t numeratorValErr = numerator->GetBinError(ibin); if (!(numeratorValErr==0. || numeratorVal ==0.) ) { Double_t rescale = numeratorValErr*numeratorValErr/numeratorVal; numeratorVal /= rescale; } Double_t denominatorValErr = denominator->GetBinError(ibin); if (!(denominatorValErr==0. || denominatorVal==0. )) { Double_t rescale = denominatorValErr*denominatorValErr/denominatorVal; denominatorVal /= rescale; } Double_t quotient = 0.; if (denominatorVal!=0.) { quotient = numeratorVal/denominatorVal; } Double_t quotientErr=0; if(numeratorVal>0.0 && denominatorVal>0.0 && (denominatorVal+2.0)>0.0 && (denominatorVal+3.0) >0.0){ double argument = (numeratorVal+1.0)/(denominatorVal+2.0)* ((numeratorVal+2.0)/(denominatorVal+3.0)-(numeratorVal+1.0)/(denominatorVal+2.0)); double test = TMath::Power(TMath::Abs(argument),0.5); quotientErr = TMath::Sqrt( TMath::Abs( (numeratorVal+1.0)/(denominatorVal+2.0)* ((numeratorVal+2.0)/(denominatorVal+3.0)-(numeratorVal+1.0)/(denominatorVal+2.0)))); } result->SetBinContent(ibin,quotient); result->SetBinError(ibin,quotientErr); //cout<<"Setting bin "<<ibin<<" to "<<quotient<<" "<<numeratorVal<<"/"<<denominatorVal<<endl; } return result; } TH1D *GetHistoEfficiency(float cut, char *name, int mycase, int color, int marker,bool TPC,bool ITS, int cb, int cblast){ bool eta = true; file->cd(); char *myname = mynameITS; if(TPC && !ITS){ myname = mynameTPCITS;cout<<"I was here I should not be called"<<endl;} if(TPC&&ITS) myname = mynameTPCITS; char *mynamealt = mynameTPCITS; TH2F *numeratorParent; switch(mycase){ case 0: if(cblast != -1){//add more centrality bins for(int i=cb;i<=cblast;i++){ if(i==cb) numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"PiPlus",i)))->Clone("RecoHadron"); else{numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"PiPlus",i)));} numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"PiMinus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"KMinus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"KPlus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"Proton",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"AntiProton",i))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"PiPlus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"PiMinus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"KMinus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"KPlus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"Proton",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"AntiProton",i))); } } } else{ numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"PiPlus")))->Clone("RecoHadron"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"PiMinus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"KMinus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"KPlus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"Proton"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"AntiProton"))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"PiPlus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"PiMinus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"KMinus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"KPlus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"Proton"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"AntiProton"))); } } break; case 1://pion if(cblast != -1){//add more centrality bins for(int i=cb;i<=cblast;i++){ if(i==cb) numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"PiPlus",i)))->Clone("RecoPion"); else{numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"PiPlus",i)));} numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"PiMinus",i))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"PiMinus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"PiPlus",i))); } } } else{ numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"PiPlus")))->Clone("RecoPion"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"PiMinus"))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"PiPlus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"PiMinus"))); } } break; case 2://kaon if(cblast != -1){//add more centrality bins for(int i=cb;i<=cblast;i++){ if(i==cb) numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"KPlus",i)))->Clone("RecoKaon"); else{numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"KPlus",i)));} numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"KMinus",i))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"KPlus",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"KMinus",i))); } } } else{ // cout<<"I am kaoning here !"<<endl; numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"KPlus")))->Clone("RecoKaon"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"KMinus"))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"KPlus"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"KMinus"))); } //cout<<"Numerator "<<numeratorParent->GetEntries()<<endl; } break; case 3://proton if(cblast != -1){//add more centrality bins for(int i=cb;i<=cblast;i++){ if(i==cb) numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"Proton",i)))->Clone("RecoProton"); else{numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"Proton",i)));} numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",myname,"AntiProton",i))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"Proton",i))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%sCB%i",mynamealt,"AntiProton",i))); } } } else{ //cout<<"I am protoning here !"<<endl; numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"Proton")))->Clone("RecoProton"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",myname,"AntiProton"))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"Proton"))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s",mynamealt,"AntiProton"))); } //cout<<"Numerator "<<numeratorParent->GetEntries()<<endl; } break; case 4://electron numeratorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s%s",myname,"EPlus",cbname)))->Clone("RecoElectron"); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s%s",myname,"EMinus",cbname))); if(!TPC&&ITS){//ITS Standalone tracks - from leftover hits, don't want to double count numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s%s",mynamealt,"EPlus",cbname))); numeratorParent->Add((TH2F*) out2->FindObject(Form("EtNReconstructed%s%s%s",mynamealt,"EMinus",cbname))); } break; } TH2F *denominatorParent; switch(mycase){ case 0: if(cblast != -1){//add more centrality bins denominatorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNSimulatedChargedHadronCB%i",cb)))->Clone("RecoHadron"); for(int i=cb+1;i<=cblast;i++){ denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedChargedHadronCB%i",i))); } } else{ denominatorParent = (TH2F*)((TH2F*) out2->FindObject("EtNSimulatedChargedHadron"))->Clone("RecoHadron"); } break; case 1://pion if(cblast != -1){//add more centrality bins denominatorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNSimulatedPiPlusCB%i",cb)))->Clone("RecoPion"); denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedPiMinusCB%i",cb))); for(int i=cb+1;i<=cblast;i++){ denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedPiPlusCB%i",i))); denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedPiMinusCB%i",i))); } } else{ denominatorParent = (TH2F*)((TH2F*) out2->FindObject("EtNSimulatedPiPlus"))->Clone("RecoPion"); denominatorParent->Add((TH2F*) out2->FindObject("EtNSimulatedPiMinus")); } break; case 2://kaon if(cblast != -1){//add more centrality bins denominatorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNSimulatedKPlusCB%i",cb)))->Clone("RecoKaon"); denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedKMinusCB%i",cb))); for(int i=cb+1;i<=cblast;i++){ denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedKPlusCB%i",i))); denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedKMinusCB%i",i))); } } else{ denominatorParent = (TH2F*)((TH2F*) out2->FindObject("EtNSimulatedKPlus"))->Clone("RecoKaon"); denominatorParent->Add((TH2F*) out2->FindObject("EtNSimulatedKMinus")); } break; case 3://proton if(cblast != -1){//add more centrality bins for(int i=cb;i<=cblast;i++){ if(cb==i)denominatorParent = (TH2F*)((TH2F*) out2->FindObject(Form("EtNSimulatedProtonCB%i",i)))->Clone("RecoProton"); else{denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedProtonCB%i",i)));} denominatorParent->Add((TH2F*) out2->FindObject(Form("EtNSimulatedAntiProtonCB%i",i))); } } else{ denominatorParent = (TH2F*)((TH2F*) out2->FindObject("EtNSimulatedProton"))->Clone("RecoProton"); denominatorParent->Add((TH2F*) out2->FindObject("EtNSimulatedAntiProton")); } break; case 4://electron denominatorParent = (TH2F*)((TH2F*) out2->FindObject("EtNSimulatedEPlus"))->Clone("RecoElectron"); denominatorParent->Add((TH2F*) out2->FindObject("EtNSimulatedEMinus")); break; } TH1D *denominator; TH1D *numerator; if(eta){ int lowbin = numeratorParent->GetYaxis()->FindBin(-cut+.001);//make sure we don't accv0entally get the wrong bin int highbin = numeratorParent->GetYaxis()->FindBin(cut-.001); //cout<<"Projecting from "<<numeratorParent->GetYaxis()->GetBinLowEdge(lowbin)<<" to "<<numeratorParent->GetYaxis()->GetBinLowEdge(highbin+1)<<endl; denominator = denominatorParent->ProjectionX(Form("garbage%s",name),lowbin,highbin); numerator = numeratorParent->ProjectionX(name,lowbin,highbin); } else{ int lowbin = denominatorParent->GetXaxis()->FindBin(cut);//make sure we don't accidentally get the wrong bin int highbin = denominatorParent->GetXaxis()->GetNbins(); //cout<<"Projecting from "<<denominatorParent->GetXaxis()->GetBinLowEdge(lowbin)<<" to "<<denominatorParent->GetXaxis()->GetBinLowEdge(highbin+1)<<endl; numerator = numeratorParent->ProjectionY(name,lowbin,highbin); denominator = denominatorParent->ProjectionY(Form("denominator%s",name),lowbin,highbin); } delete numeratorParent; delete denominatorParent; //numerator->Divide(denominator); TH1D *result = bayneseffdiv((TH1D*) numerator,(TH1D*)denominator,name); //result->Rebin(2); //result->Scale(0.5); result->SetYTitle("Efficiency"); result->GetYaxis()->SetTitleOffset(0.8); result->GetXaxis()->SetTitleOffset(0.8); result->GetYaxis()->SetLabelSize(0.05); result->GetXaxis()->SetLabelSize(0.05); result->GetYaxis()->SetTitleSize(0.05); result->GetXaxis()->SetTitleSize(0.05); result->SetMarkerColor(color); result->SetLineColor(color); result->SetMarkerStyle(marker); //result->SetName(name); //result->Draw("e"); delete denominator; delete numerator; delete numeratorParent; delete denominatorParent; result->SetName(name); return result; } void CorrEfficiencyPlots(bool TPC, char *prodname, char *shortprodname){ bool ITS = true; gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",600,400); c->SetTopMargin(0.02); c->SetRightMargin(0.02); c->SetBorderSize(0); c->SetFillColor(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); //c->SetLogx(); int colortotal = 1; int colorpi = 2; int colork = 3; int colorp = 4; int phosmarker = 20; int emcalmarker = 24; float ptcut1 = 0.05; float ptcut2 = 0.1; TH1D *PHOStotal = GetHistoEfficiency(0.12,"PHOStotal",0,colortotal,phosmarker,TPC,ITS); TH1D *PHOSpi = GetHistoEfficiency(0.12,"PHOSpi",1,colorpi,phosmarker,TPC,ITS); TH1D *PHOSp = GetHistoEfficiency(0.12,"PHOSp",2,colork,phosmarker,TPC,ITS); TH1D *PHOSk = GetHistoEfficiency(0.12,"PHOSk",3,colorp,phosmarker,TPC,ITS); if(!TPC){PHOStotal->GetXaxis()->SetRange(PHOStotal->GetXaxis()->FindBin(0.05),PHOStotal->GetXaxis()->FindBin(1.0));} else{PHOStotal->GetXaxis()->SetRange(PHOStotal->GetXaxis()->FindBin(0.15),PHOStotal->GetXaxis()->FindBin(3.0));} PHOStotal->SetMinimum(0.0); PHOStotal->SetMaximum(1.0); PHOStotal->Draw(); PHOSpi->Draw("same"); PHOSp->Draw("same"); PHOSk->Draw("same"); TH1D *EMCALtotal = GetHistoEfficiency(0.7,"EMCALtotal",0,colortotal,emcalmarker,TPC,ITS); TH1D *EMCALpi = GetHistoEfficiency(0.7,"EMCALpi",1,colorpi,emcalmarker,TPC,ITS); TH1D *EMCALp = GetHistoEfficiency(0.7,"EMCALp",2,colork,emcalmarker,TPC,ITS); TH1D *EMCALk = GetHistoEfficiency(0.7,"EMCALk",3,colorp,emcalmarker,TPC,ITS); EMCALtotal->Draw("same"); EMCALpi->Draw("same"); EMCALp->Draw("same"); EMCALk->Draw("same"); TLegend *leg = new TLegend(0.22651,0.247312,0.370805,0.438172); leg->AddEntry(PHOStotal,"#pi,K,p"); leg->AddEntry(PHOSpi,"#pi^{#pm}"); leg->AddEntry(PHOSk,"K^{#pm}"); leg->AddEntry(PHOSp,"p,#bar{p}"); leg->SetFillStyle(0); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetTextSize(0.06); leg->Draw(); TLine *line = new TLine(0.2,0.0,0.2,1.0); line->Draw(); line->SetLineWidth(3.0); //line->SetLineColor(TColor::kYellow); line->SetLineStyle(2); TLatex *tex = new TLatex(0.497269,0.0513196,prodname); tex->SetTextSize(0.0537634); tex->Draw(); TLatex *tex3 = new TLatex(1.16186,0.28348,"Closed symbols |#eta|<0.12 (PHOS)"); tex3->SetTextSize(0.0537634); tex3->Draw(); TLatex *tex4 = new TLatex(1.16186,0.213221,"Open symbols |#eta|<0.70 (EMCal)"); tex4->SetTextSize(0.0537634); tex4->Draw(); TLatex *tex2 = new TLatex(0.241937,0.448436,"Likely TPC cut-off 200 MeV/c"); tex2->SetTextSize(0.0537634); tex2->Draw(); if(TPC){ if(ITS){ sprintf(epsname,"pics/%s/CorrEfficiencyITSTPC.eps",shortprodname); sprintf(pngname,"pics/%s/CorrEfficiencyITSTPC.png",shortprodname); } else{ sprintf(epsname,"pics/%s/CorrEfficiencyTPC.eps",shortprodname); sprintf(pngname,"pics/%s/CorrEfficiencyTPC.png",shortprodname); } } else{ sprintf(epsname,"pics/%s/CorrEfficiencyITS.eps",shortprodname); sprintf(pngname,"pics/%s/CorrEfficiencyITS.png",shortprodname); } delete PHOStotal; delete PHOSpi; delete PHOSp; delete PHOSk; delete EMCALtotal; delete EMCALpi; delete EMCALp; delete EMCALk; delete leg; c->SaveAs(epsname); c->SaveAs(pngname); delete c; delete line; delete tex; delete tex3; } //==================================CorrBkgd================================================= TH1D *GetHistoCorrBkgd(float etacut,char *name, bool TPC,bool ispp,bool forSim){ file->cd(); char *reweightname = reweightedNo; if(!forSim) reweightname = reweightedYes; char *myname = mynameITS; if(TPC) myname = mynameTPCITS; TH2F *signal = ((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedPiPlus",myname)))->Clone("signal"); signal->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedPiMinus",myname))); signal->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedKMinus",myname))); signal->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedKPlus",myname))); signal->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedProton",myname))); signal->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sIdentifiedAntiProton",myname))); signal->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sUnidentifiedAssumingPion",myname))); //Et of all unidentified hadrons (plus hadrons identified as pions) calculated assuming their true mass TH2F *bkgd = ((TH2F*) out2->FindObject(Form("EtReconstructed%sMisidentifiedElectrons",myname)))->Clone("bkgd"); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sLambdaDaughters%s",myname,reweightname))); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sAntiLambdaDaughters%s",myname,reweightname))); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sK0SDaughters%s",myname,reweightname))); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sXiDaughters",myname))); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sAntiXiDaughters",myname))); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sOmegaDaughters",myname))); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sAntiOmegaDaughters",myname))); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sConversionElectrons",myname)) ); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sSecondaryMuons",myname)) ); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sSecondaryPions",myname)) ); bkgd->Add((TH2F*) out2->FindObject(Form("EtReconstructed%sSecondaryProtons",myname)) ); int lowbin = bkgd->GetYaxis()->FindBin(-etacut+.001);//make sure we don't accidentally get the wrong bin int highbin = bkgd->GetYaxis()->FindBin(etacut-.001); //cout<<"Projecting from "<<bkgd->GetYaxis()->GetBinLowEdge(lowbin)<<" to "<<bkgd->GetYaxis()->GetBinLowEdge(highbin+1)<<endl; TH1D *denominator = signal->ProjectionX(name,lowbin,highbin); TH1D *numerator = bkgd->ProjectionX("numerator",lowbin,highbin); denominator->Add(numerator); numerator->Divide(denominator); numerator->SetYTitle("Ratio of E_{T}^{background}/E_{T}^{real}"); numerator->GetYaxis()->SetTitleOffset(1.2); delete signal; delete bkgd; delete denominator; numerator->SetName(name); return numerator; } void CorrBkgdPlots(char *prodname, char *shortprodname, bool TPC,bool ispp,bool forSim){ gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *c = new TCanvas("c","c",500,400); c->SetTopMargin(0.04); c->SetRightMargin(0.04); c->SetBorderSize(0); c->SetFillColor(0); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillColor(0); c->SetFrameBorderMode(0); TH1D *PHOS = GetHistoCorrBkgd(0.12,"PHOS2",TPC,ispp,forSim); TH1D *EMCAL = GetHistoCorrBkgd(0.7,"EMCAL2",TPC,ispp,forSim); PHOS->SetMarkerColor(2); EMCAL->SetMarkerColor(4); PHOS->SetLineColor(2); EMCAL->SetLineColor(4); //EMCAL->SetLineWidth(2); //PHOS->SetAxisRange(0.0,4); PHOS->SetMaximum(0.2); PHOS->SetMinimum(0.0); PHOS->SetMarkerStyle(20);; EMCAL->SetMarkerStyle(21); // TF1 *funcEMCAL = new TF1("funcEMCAL","[0]+0.0*x",0.05,4); // funcEMCAL->SetParameter(0,0.95); // funcEMCAL->SetParLimits(0,0.9,1.1); //EMCAL->Fit(funcEMCAL);//,"","",0.05,3.0); // TF1 *funcPHOS = new TF1("funcPHOS","[0]+0.0*x",0.05,4); // funcPHOS->SetParameter(0,1.0); //PHOS->Fit(funcPHOS); if(TPC) PHOS->GetXaxis()->SetRange(PHOS->GetXaxis()->FindBin(0.0),PHOS->GetXaxis()->FindBin(4.)); else{ PHOS->GetXaxis()->SetRange(PHOS->GetXaxis()->FindBin(0.0),PHOS->GetXaxis()->FindBin(1.));} PHOS->Draw(); EMCAL->Draw("same"); TLatex *tex = new TLatex(0.161478,1.0835,prodname); tex->SetTextSize(0.0537634); tex->Draw(); TLegend *leg = new TLegend(0.145161,0.604839,0.40121,0.860215); leg->AddEntry(PHOS,"|#eta|<0.12"); leg->AddEntry(EMCAL,"|#eta|<0.70"); leg->SetFillStyle(0); leg->SetFillColor(0); leg->SetBorderSize(0); leg->Draw(); if(TPC){ c->SaveAs(Form("pics/%s/bkgdTPC.eps",shortprodname)); c->SaveAs(Form("pics/%s/bkgdTPC.png",shortprodname)); } else{ c->SaveAs(Form("pics/%s/bkgdITS.eps",shortprodname)); c->SaveAs(Form("pics/%s/bkgdITS.png",shortprodname)); } delete c; delete PHOS; delete EMCAL; delete tex; delete leg; } //TH1D *ppBkgd() TH1D *pp276TPCBkgd(){ //=========Macro generated from canvas: c4/c4 //========= (Thu May 5 23:07:14 2011) by ROOT version5.28/00c TH1D *Allpt7TeVScaling = new TH1D("Allpt7TeVScaling","Reconstructed E_{T} from misidentified electrons",111, xAxis1); Allpt7TeVScaling->SetBinContent(13,0.1673787); Allpt7TeVScaling->SetBinContent(14,0.1548408); Allpt7TeVScaling->SetBinContent(15,0.1328529); Allpt7TeVScaling->SetBinContent(16,0.1220669); Allpt7TeVScaling->SetBinContent(17,0.1109226); Allpt7TeVScaling->SetBinContent(18,0.0981996); Allpt7TeVScaling->SetBinContent(19,0.09152354); Allpt7TeVScaling->SetBinContent(20,0.07937801); Allpt7TeVScaling->SetBinContent(21,0.07163593); Allpt7TeVScaling->SetBinContent(22,0.0562236); Allpt7TeVScaling->SetBinContent(23,0.04398756); Allpt7TeVScaling->SetBinContent(24,0.039459); Allpt7TeVScaling->SetBinContent(25,0.03618901); Allpt7TeVScaling->SetBinContent(26,0.0322147); Allpt7TeVScaling->SetBinContent(27,0.03294796); Allpt7TeVScaling->SetBinContent(28,0.03114461); Allpt7TeVScaling->SetBinContent(29,0.03039579); Allpt7TeVScaling->SetBinContent(30,0.03261539); Allpt7TeVScaling->SetBinContent(31,0.03239832); Allpt7TeVScaling->SetBinContent(32,0.03055859); Allpt7TeVScaling->SetBinContent(33,0.03181271); Allpt7TeVScaling->SetBinContent(34,0.02882665); Allpt7TeVScaling->SetBinContent(35,0.03102149); Allpt7TeVScaling->SetBinContent(36,0.0272696); Allpt7TeVScaling->SetBinContent(37,0.02783727); Allpt7TeVScaling->SetBinContent(38,0.02334413); Allpt7TeVScaling->SetBinContent(39,0.02357657); Allpt7TeVScaling->SetBinContent(40,0.02630686); Allpt7TeVScaling->SetBinContent(41,0.02372341); Allpt7TeVScaling->SetBinContent(42,0.02279457); Allpt7TeVScaling->SetBinContent(43,0.01999143); Allpt7TeVScaling->SetBinContent(44,0.02019579); Allpt7TeVScaling->SetBinContent(45,0.02029719); Allpt7TeVScaling->SetBinContent(46,0.0166231); Allpt7TeVScaling->SetBinContent(47,0.01824842); Allpt7TeVScaling->SetBinContent(48,0.0188995); Allpt7TeVScaling->SetBinContent(49,0.01836067); Allpt7TeVScaling->SetBinContent(50,0.02113978); Allpt7TeVScaling->SetBinContent(51,0.02236854); Allpt7TeVScaling->SetBinContent(52,0.0204874); Allpt7TeVScaling->SetBinContent(53,0.02236788); Allpt7TeVScaling->SetBinContent(54,0.01862457); Allpt7TeVScaling->SetBinContent(55,0.0215448); Allpt7TeVScaling->SetBinContent(56,0.01757402); Allpt7TeVScaling->SetBinContent(57,0.01899477); Allpt7TeVScaling->SetBinContent(58,0.01766989); Allpt7TeVScaling->SetBinContent(59,0.01984435); Allpt7TeVScaling->SetBinContent(60,0.01842092); Allpt7TeVScaling->SetBinContent(61,0.01668053); Allpt7TeVScaling->SetBinContent(62,0.01708603); Allpt7TeVScaling->SetBinContent(63,0.01557306); Allpt7TeVScaling->SetBinContent(64,0.01878942); Allpt7TeVScaling->SetBinContent(65,0.01458043); Allpt7TeVScaling->SetBinContent(66,0.0151346); Allpt7TeVScaling->SetBinContent(67,0.01565407); Allpt7TeVScaling->SetBinContent(68,0.01327014); Allpt7TeVScaling->SetBinContent(69,0.01284378); Allpt7TeVScaling->SetBinContent(70,0.01046102); Allpt7TeVScaling->SetBinContent(71,0.009963117); Allpt7TeVScaling->SetBinContent(72,0.01359609); Allpt7TeVScaling->SetBinContent(73,0.01088263); Allpt7TeVScaling->SetBinContent(74,0.01317689); Allpt7TeVScaling->SetBinContent(75,0.01433201); Allpt7TeVScaling->SetBinContent(76,0.01215939); Allpt7TeVScaling->SetBinContent(77,0.01380766); Allpt7TeVScaling->SetBinContent(78,0.01499505); Allpt7TeVScaling->SetBinContent(79,0.015013); Allpt7TeVScaling->SetBinContent(80,0.01140629); Allpt7TeVScaling->SetBinContent(81,0.009461979); Allpt7TeVScaling->SetBinContent(82,0.007775343); Allpt7TeVScaling->SetBinContent(83,0.01092198); Allpt7TeVScaling->SetBinContent(84,0.009924767); Allpt7TeVScaling->SetBinContent(85,0.006399066); Allpt7TeVScaling->SetBinContent(86,0.008370865); Allpt7TeVScaling->SetBinContent(87,0.01115192); Allpt7TeVScaling->SetBinContent(88,0.003781796); Allpt7TeVScaling->SetBinContent(89,0.01596916); Allpt7TeVScaling->SetBinContent(90,0.005959723); Allpt7TeVScaling->SetBinContent(91,0.006885685); Allpt7TeVScaling->SetBinContent(93,0.006011974); Allpt7TeVScaling->SetBinContent(94,0.008862645); Allpt7TeVScaling->SetBinContent(95,0.009963223); Allpt7TeVScaling->SetBinContent(96,0.01457121); Allpt7TeVScaling->SetBinContent(97,0.007500135); Allpt7TeVScaling->SetBinContent(98,0.02636933); Allpt7TeVScaling->SetBinContent(103,0.06353767); Allpt7TeVScaling->SetBinError(13,0.02859277); Allpt7TeVScaling->SetBinError(14,0.006796474); Allpt7TeVScaling->SetBinError(15,0.004234415); Allpt7TeVScaling->SetBinError(16,0.0036414); Allpt7TeVScaling->SetBinError(17,0.003333835); Allpt7TeVScaling->SetBinError(18,0.003009034); Allpt7TeVScaling->SetBinError(19,0.002839933); Allpt7TeVScaling->SetBinError(20,0.002588262); Allpt7TeVScaling->SetBinError(21,0.001703954); Allpt7TeVScaling->SetBinError(22,0.001495734); Allpt7TeVScaling->SetBinError(23,0.001297475); Allpt7TeVScaling->SetBinError(24,0.001213434); Allpt7TeVScaling->SetBinError(25,0.001162398); Allpt7TeVScaling->SetBinError(26,0.001137158); Allpt7TeVScaling->SetBinError(27,0.001208358); Allpt7TeVScaling->SetBinError(28,0.001183675); Allpt7TeVScaling->SetBinError(29,0.001263691); Allpt7TeVScaling->SetBinError(30,0.001320041); Allpt7TeVScaling->SetBinError(31,0.001362399); Allpt7TeVScaling->SetBinError(32,0.001338259); Allpt7TeVScaling->SetBinError(33,0.001369813); Allpt7TeVScaling->SetBinError(34,0.001358652); Allpt7TeVScaling->SetBinError(35,0.00142864); Allpt7TeVScaling->SetBinError(36,0.001378454); Allpt7TeVScaling->SetBinError(37,0.001384729); Allpt7TeVScaling->SetBinError(38,0.001257903); Allpt7TeVScaling->SetBinError(39,0.001295459); Allpt7TeVScaling->SetBinError(40,0.001546992); Allpt7TeVScaling->SetBinError(41,0.001496938); Allpt7TeVScaling->SetBinError(42,0.001486813); Allpt7TeVScaling->SetBinError(43,0.00140119); Allpt7TeVScaling->SetBinError(44,0.001478331); Allpt7TeVScaling->SetBinError(45,0.001566594); Allpt7TeVScaling->SetBinError(46,0.001407568); Allpt7TeVScaling->SetBinError(47,0.001509742); Allpt7TeVScaling->SetBinError(48,0.001583129); Allpt7TeVScaling->SetBinError(49,0.001668789); Allpt7TeVScaling->SetBinError(50,0.001915902); Allpt7TeVScaling->SetBinError(51,0.001968585); Allpt7TeVScaling->SetBinError(52,0.00195473); Allpt7TeVScaling->SetBinError(53,0.00207896); Allpt7TeVScaling->SetBinError(54,0.001937327); Allpt7TeVScaling->SetBinError(55,0.002108783); Allpt7TeVScaling->SetBinError(56,0.001816997); Allpt7TeVScaling->SetBinError(57,0.001892795); Allpt7TeVScaling->SetBinError(58,0.001803616); Allpt7TeVScaling->SetBinError(59,0.001994761); Allpt7TeVScaling->SetBinError(60,0.001964909); Allpt7TeVScaling->SetBinError(61,0.001255034); Allpt7TeVScaling->SetBinError(62,0.001312232); Allpt7TeVScaling->SetBinError(63,0.001358296); Allpt7TeVScaling->SetBinError(64,0.001569736); Allpt7TeVScaling->SetBinError(65,0.001469072); Allpt7TeVScaling->SetBinError(66,0.001588803); Allpt7TeVScaling->SetBinError(67,0.001683862); Allpt7TeVScaling->SetBinError(68,0.00164699); Allpt7TeVScaling->SetBinError(69,0.001760645); Allpt7TeVScaling->SetBinError(70,0.00160423); Allpt7TeVScaling->SetBinError(71,0.001693146); Allpt7TeVScaling->SetBinError(72,0.002042705); Allpt7TeVScaling->SetBinError(73,0.001965856); Allpt7TeVScaling->SetBinError(74,0.002245841); Allpt7TeVScaling->SetBinError(75,0.002520926); Allpt7TeVScaling->SetBinError(76,0.002402524); Allpt7TeVScaling->SetBinError(77,0.002627656); Allpt7TeVScaling->SetBinError(78,0.002963027); Allpt7TeVScaling->SetBinError(79,0.003088673); Allpt7TeVScaling->SetBinError(80,0.002958055); Allpt7TeVScaling->SetBinError(81,0.001434729); Allpt7TeVScaling->SetBinError(82,0.001531537); Allpt7TeVScaling->SetBinError(83,0.002200666); Allpt7TeVScaling->SetBinError(84,0.00242244); Allpt7TeVScaling->SetBinError(85,0.002270338); Allpt7TeVScaling->SetBinError(86,0.002972849); Allpt7TeVScaling->SetBinError(87,0.003966084); Allpt7TeVScaling->SetBinError(88,0.002679263); Allpt7TeVScaling->SetBinError(89,0.006083804); Allpt7TeVScaling->SetBinError(90,0.004227019); Allpt7TeVScaling->SetBinError(91,0.004886052); Allpt7TeVScaling->SetBinError(93,0.006030514); Allpt7TeVScaling->SetBinError(94,0.008892003); Allpt7TeVScaling->SetBinError(95,0.01001297); Allpt7TeVScaling->SetBinError(96,0.008480241); Allpt7TeVScaling->SetBinError(97,0.007527505); Allpt7TeVScaling->SetBinError(98,0.01889477); Allpt7TeVScaling->SetBinError(103,0.065502); Allpt7TeVScaling->SetMinimum(0); Allpt7TeVScaling->SetMaximum(0.04); Allpt7TeVScaling->SetEntries(1049.145); Allpt7TeVScaling->SetStats(0); Allpt7TeVScaling->SetMarkerStyle(20); Allpt7TeVScaling->GetXaxis()->SetTitle("p_{T}"); Allpt7TeVScaling->GetXaxis()->SetRange(1,91); Allpt7TeVScaling->GetYaxis()->SetTitle("Ratio of E_{T}^{background}/E_{T}^{had, meas.}"); Allpt7TeVScaling->GetYaxis()->SetTitleOffset(1.2); TH1D *Allpt900GeVScaling = new TH1D("Allpt900GeVScaling","Reconstructed E_{T} from misidentified electrons",111, xAxis1); Allpt900GeVScaling->SetBinContent(13,0.1950247); Allpt900GeVScaling->SetBinContent(14,0.147561); Allpt900GeVScaling->SetBinContent(15,0.136378); Allpt900GeVScaling->SetBinContent(16,0.1233744); Allpt900GeVScaling->SetBinContent(17,0.1126807); Allpt900GeVScaling->SetBinContent(18,0.09909555); Allpt900GeVScaling->SetBinContent(19,0.09191239); Allpt900GeVScaling->SetBinContent(20,0.08438053); Allpt900GeVScaling->SetBinContent(21,0.07119319); Allpt900GeVScaling->SetBinContent(22,0.05773434); Allpt900GeVScaling->SetBinContent(23,0.04292845); Allpt900GeVScaling->SetBinContent(24,0.0396127); Allpt900GeVScaling->SetBinContent(25,0.03395077); Allpt900GeVScaling->SetBinContent(26,0.03305251); Allpt900GeVScaling->SetBinContent(27,0.03297093); Allpt900GeVScaling->SetBinContent(28,0.031215); Allpt900GeVScaling->SetBinContent(29,0.03178372); Allpt900GeVScaling->SetBinContent(30,0.03236985); Allpt900GeVScaling->SetBinContent(31,0.03271276); Allpt900GeVScaling->SetBinContent(32,0.02993124); Allpt900GeVScaling->SetBinContent(33,0.03004746); Allpt900GeVScaling->SetBinContent(34,0.03077143); Allpt900GeVScaling->SetBinContent(35,0.03211214); Allpt900GeVScaling->SetBinContent(36,0.02807512); Allpt900GeVScaling->SetBinContent(37,0.02651954); Allpt900GeVScaling->SetBinContent(38,0.02503885); Allpt900GeVScaling->SetBinContent(39,0.02325777); Allpt900GeVScaling->SetBinContent(40,0.02773712); Allpt900GeVScaling->SetBinContent(41,0.02491155); Allpt900GeVScaling->SetBinContent(42,0.02389028); Allpt900GeVScaling->SetBinContent(43,0.02085532); Allpt900GeVScaling->SetBinContent(44,0.01959721); Allpt900GeVScaling->SetBinContent(45,0.01937255); Allpt900GeVScaling->SetBinContent(46,0.01745646); Allpt900GeVScaling->SetBinContent(47,0.01890853); Allpt900GeVScaling->SetBinContent(48,0.02053692); Allpt900GeVScaling->SetBinContent(49,0.01813791); Allpt900GeVScaling->SetBinContent(50,0.02187495); Allpt900GeVScaling->SetBinContent(51,0.02409687); Allpt900GeVScaling->SetBinContent(52,0.0206565); Allpt900GeVScaling->SetBinContent(53,0.02269165); Allpt900GeVScaling->SetBinContent(54,0.01850795); Allpt900GeVScaling->SetBinContent(55,0.02115427); Allpt900GeVScaling->SetBinContent(56,0.01543302); Allpt900GeVScaling->SetBinContent(57,0.01642095); Allpt900GeVScaling->SetBinContent(58,0.01542331); Allpt900GeVScaling->SetBinContent(59,0.01931254); Allpt900GeVScaling->SetBinContent(60,0.01650654); Allpt900GeVScaling->SetBinContent(61,0.01827512); Allpt900GeVScaling->SetBinContent(62,0.01700125); Allpt900GeVScaling->SetBinContent(63,0.01544321); Allpt900GeVScaling->SetBinContent(64,0.01830588); Allpt900GeVScaling->SetBinContent(65,0.01584369); Allpt900GeVScaling->SetBinContent(66,0.0145421); Allpt900GeVScaling->SetBinContent(67,0.01382206); Allpt900GeVScaling->SetBinContent(68,0.01358825); Allpt900GeVScaling->SetBinContent(69,0.01294888); Allpt900GeVScaling->SetBinContent(70,0.009346655); Allpt900GeVScaling->SetBinContent(71,0.01235781); Allpt900GeVScaling->SetBinContent(72,0.0127376); Allpt900GeVScaling->SetBinContent(73,0.008968166); Allpt900GeVScaling->SetBinContent(74,0.01467765); Allpt900GeVScaling->SetBinContent(75,0.01432309); Allpt900GeVScaling->SetBinContent(76,0.01204856); Allpt900GeVScaling->SetBinContent(77,0.01436071); Allpt900GeVScaling->SetBinContent(78,0.01451222); Allpt900GeVScaling->SetBinContent(79,0.01378967); Allpt900GeVScaling->SetBinContent(80,0.01040148); Allpt900GeVScaling->SetBinContent(81,0.01041213); Allpt900GeVScaling->SetBinContent(82,0.009971816); Allpt900GeVScaling->SetBinContent(83,0.01417668); Allpt900GeVScaling->SetBinContent(84,0.008713292); Allpt900GeVScaling->SetBinContent(85,0.005425386); Allpt900GeVScaling->SetBinContent(86,0.005303683); Allpt900GeVScaling->SetBinContent(87,0.006759432); Allpt900GeVScaling->SetBinContent(88,0.004445477); Allpt900GeVScaling->SetBinContent(89,0.01810702); Allpt900GeVScaling->SetBinContent(90,0.0108909); Allpt900GeVScaling->SetBinContent(91,0.01186746); Allpt900GeVScaling->SetBinContent(92,0.006128581); Allpt900GeVScaling->SetBinContent(93,0.007452721); Allpt900GeVScaling->SetBinContent(94,0.0259471); Allpt900GeVScaling->SetBinContent(95,0.0114321); Allpt900GeVScaling->SetBinContent(98,0.03264295); Allpt900GeVScaling->SetBinContent(103,0.07829265); Allpt900GeVScaling->SetBinError(13,0.03504783); Allpt900GeVScaling->SetBinError(14,0.007336667); Allpt900GeVScaling->SetBinError(15,0.004765958); Allpt900GeVScaling->SetBinError(16,0.004028143); Allpt900GeVScaling->SetBinError(17,0.003760166); Allpt900GeVScaling->SetBinError(18,0.003357858); Allpt900GeVScaling->SetBinError(19,0.003156502); Allpt900GeVScaling->SetBinError(20,0.002970822); Allpt900GeVScaling->SetBinError(21,0.001886555); Allpt900GeVScaling->SetBinError(22,0.001676045); Allpt900GeVScaling->SetBinError(23,0.001411794); Allpt900GeVScaling->SetBinError(24,0.001346425); Allpt900GeVScaling->SetBinError(25,0.001254258); Allpt900GeVScaling->SetBinError(26,0.001299384); Allpt900GeVScaling->SetBinError(27,0.001328066); Allpt900GeVScaling->SetBinError(28,0.001330088); Allpt900GeVScaling->SetBinError(29,0.001446767); Allpt900GeVScaling->SetBinError(30,0.00145402); Allpt900GeVScaling->SetBinError(31,0.001463994); Allpt900GeVScaling->SetBinError(32,0.001449209); Allpt900GeVScaling->SetBinError(33,0.001414847); Allpt900GeVScaling->SetBinError(34,0.001598429); Allpt900GeVScaling->SetBinError(35,0.001590854); Allpt900GeVScaling->SetBinError(36,0.001526798); Allpt900GeVScaling->SetBinError(37,0.001486126); Allpt900GeVScaling->SetBinError(38,0.001457142); Allpt900GeVScaling->SetBinError(39,0.001474238); Allpt900GeVScaling->SetBinError(40,0.001757902); Allpt900GeVScaling->SetBinError(41,0.001712601); Allpt900GeVScaling->SetBinError(42,0.001671385); Allpt900GeVScaling->SetBinError(43,0.001570556); Allpt900GeVScaling->SetBinError(44,0.001627725); Allpt900GeVScaling->SetBinError(45,0.001637262); Allpt900GeVScaling->SetBinError(46,0.001641227); Allpt900GeVScaling->SetBinError(47,0.001716345); Allpt900GeVScaling->SetBinError(48,0.001907778); Allpt900GeVScaling->SetBinError(49,0.001842589); Allpt900GeVScaling->SetBinError(50,0.00215445); Allpt900GeVScaling->SetBinError(51,0.002310602); Allpt900GeVScaling->SetBinError(52,0.002171046); Allpt900GeVScaling->SetBinError(53,0.002386521); Allpt900GeVScaling->SetBinError(54,0.002149237); Allpt900GeVScaling->SetBinError(55,0.002233898); Allpt900GeVScaling->SetBinError(56,0.001856697); Allpt900GeVScaling->SetBinError(57,0.001891742); Allpt900GeVScaling->SetBinError(58,0.001840334); Allpt900GeVScaling->SetBinError(59,0.002168741); Allpt900GeVScaling->SetBinError(60,0.002044863); Allpt900GeVScaling->SetBinError(61,0.001431972); Allpt900GeVScaling->SetBinError(62,0.001452706); Allpt900GeVScaling->SetBinError(63,0.001477499); Allpt900GeVScaling->SetBinError(64,0.001722091); Allpt900GeVScaling->SetBinError(65,0.001674803); Allpt900GeVScaling->SetBinError(66,0.001737491); Allpt900GeVScaling->SetBinError(67,0.001783912); Allpt900GeVScaling->SetBinError(68,0.00186443); Allpt900GeVScaling->SetBinError(69,0.001965873); Allpt900GeVScaling->SetBinError(70,0.001687347); Allpt900GeVScaling->SetBinError(71,0.002072538); Allpt900GeVScaling->SetBinError(72,0.002233273); Allpt900GeVScaling->SetBinError(73,0.001965905); Allpt900GeVScaling->SetBinError(74,0.002669571); Allpt900GeVScaling->SetBinError(75,0.00278613); Allpt900GeVScaling->SetBinError(76,0.002661412); Allpt900GeVScaling->SetBinError(77,0.002952605); Allpt900GeVScaling->SetBinError(78,0.003268721); Allpt900GeVScaling->SetBinError(79,0.003273694); Allpt900GeVScaling->SetBinError(80,0.002900898); Allpt900GeVScaling->SetBinError(81,0.001677933); Allpt900GeVScaling->SetBinError(82,0.001933408); Allpt900GeVScaling->SetBinError(83,0.002759328); Allpt900GeVScaling->SetBinError(84,0.002526604); Allpt900GeVScaling->SetBinError(85,0.002297818); Allpt900GeVScaling->SetBinError(86,0.002659213); Allpt900GeVScaling->SetBinError(87,0.003392141); Allpt900GeVScaling->SetBinError(88,0.003150511); Allpt900GeVScaling->SetBinError(89,0.007499872); Allpt900GeVScaling->SetBinError(90,0.006322856); Allpt900GeVScaling->SetBinError(91,0.00689283); Allpt900GeVScaling->SetBinError(92,0.006146806); Allpt900GeVScaling->SetBinError(93,0.007481131); Allpt900GeVScaling->SetBinError(94,0.01853139); Allpt900GeVScaling->SetBinError(95,0.01149767); Allpt900GeVScaling->SetBinError(98,0.02345991); Allpt900GeVScaling->SetBinError(103,0.08126059); Allpt900GeVScaling->SetMinimum(0); Allpt900GeVScaling->SetMaximum(0.04); Allpt900GeVScaling->SetEntries(724.3671); Allpt900GeVScaling->SetStats(0); Allpt900GeVScaling->SetMarkerStyle(20); Allpt900GeVScaling->GetXaxis()->SetTitle("p_{T}"); Allpt900GeVScaling->GetXaxis()->SetRange(1,91); Allpt900GeVScaling->GetYaxis()->SetTitle("Ratio of E_{T}^{background}/E_{T}^{had, meas.}"); Allpt900GeVScaling->GetYaxis()->SetTitleOffset(1.2); Allpt7TeVScaling->Add(Allpt900GeVScaling); Allpt7TeVScaling->Scale(0.5); delete Allpt900GeVScaling; return Allpt7TeVScaling; } TH1D *PbPb276TPCBkgd(){ TH1D *Allpt7TeVScaling = new TH1D("Allpt7TeVScaling","Reconstructed E_{T} from misidentified electrons",111, xAxis1); Allpt7TeVScaling->SetBinContent(13,0.1745755); Allpt7TeVScaling->SetBinContent(14,0.1624186); Allpt7TeVScaling->SetBinContent(15,0.1431048); Allpt7TeVScaling->SetBinContent(16,0.1331614); Allpt7TeVScaling->SetBinContent(17,0.121262); Allpt7TeVScaling->SetBinContent(18,0.1082923); Allpt7TeVScaling->SetBinContent(19,0.1011451); Allpt7TeVScaling->SetBinContent(20,0.08875923); Allpt7TeVScaling->SetBinContent(21,0.08100933); Allpt7TeVScaling->SetBinContent(22,0.06527292); Allpt7TeVScaling->SetBinContent(23,0.05220065); Allpt7TeVScaling->SetBinContent(24,0.04752904); Allpt7TeVScaling->SetBinContent(25,0.04421568); Allpt7TeVScaling->SetBinContent(26,0.03879551); Allpt7TeVScaling->SetBinContent(27,0.03944679); Allpt7TeVScaling->SetBinContent(28,0.03707215); Allpt7TeVScaling->SetBinContent(29,0.03663599); Allpt7TeVScaling->SetBinContent(30,0.03937437); Allpt7TeVScaling->SetBinContent(31,0.03888919); Allpt7TeVScaling->SetBinContent(32,0.03646502); Allpt7TeVScaling->SetBinContent(33,0.03784992); Allpt7TeVScaling->SetBinContent(34,0.03360079); Allpt7TeVScaling->SetBinContent(35,0.03761566); Allpt7TeVScaling->SetBinContent(36,0.03276653); Allpt7TeVScaling->SetBinContent(37,0.03401566); Allpt7TeVScaling->SetBinContent(38,0.02803893); Allpt7TeVScaling->SetBinContent(39,0.0290018); Allpt7TeVScaling->SetBinContent(40,0.03323201); Allpt7TeVScaling->SetBinContent(41,0.03006077); Allpt7TeVScaling->SetBinContent(42,0.02867674); Allpt7TeVScaling->SetBinContent(43,0.02471421); Allpt7TeVScaling->SetBinContent(44,0.02610375); Allpt7TeVScaling->SetBinContent(45,0.02601621); Allpt7TeVScaling->SetBinContent(46,0.02184781); Allpt7TeVScaling->SetBinContent(47,0.02479646); Allpt7TeVScaling->SetBinContent(48,0.02519956); Allpt7TeVScaling->SetBinContent(49,0.02376095); Allpt7TeVScaling->SetBinContent(50,0.02836189); Allpt7TeVScaling->SetBinContent(51,0.0339595); Allpt7TeVScaling->SetBinContent(52,0.03057126); Allpt7TeVScaling->SetBinContent(53,0.03238621); Allpt7TeVScaling->SetBinContent(54,0.0264272); Allpt7TeVScaling->SetBinContent(55,0.03203146); Allpt7TeVScaling->SetBinContent(56,0.02554187); Allpt7TeVScaling->SetBinContent(57,0.02901947); Allpt7TeVScaling->SetBinContent(58,0.02584016); Allpt7TeVScaling->SetBinContent(59,0.03055042); Allpt7TeVScaling->SetBinContent(60,0.02658193); Allpt7TeVScaling->SetBinContent(61,0.02553988); Allpt7TeVScaling->SetBinContent(62,0.02787508); Allpt7TeVScaling->SetBinContent(63,0.02836785); Allpt7TeVScaling->SetBinContent(64,0.03449766); Allpt7TeVScaling->SetBinContent(65,0.02710397); Allpt7TeVScaling->SetBinContent(66,0.02741966); Allpt7TeVScaling->SetBinContent(67,0.03184318); Allpt7TeVScaling->SetBinContent(68,0.02993716); Allpt7TeVScaling->SetBinContent(69,0.03113033); Allpt7TeVScaling->SetBinContent(70,0.01946293); Allpt7TeVScaling->SetBinContent(71,0.02890383); Allpt7TeVScaling->SetBinContent(72,0.02602078); Allpt7TeVScaling->SetBinContent(73,0.02063028); Allpt7TeVScaling->SetBinContent(74,0.03186679); Allpt7TeVScaling->SetBinContent(75,0.0399062); Allpt7TeVScaling->SetBinContent(76,0.02051914); Allpt7TeVScaling->SetBinContent(77,0.04454688); Allpt7TeVScaling->SetBinContent(78,0.04798449); Allpt7TeVScaling->SetBinContent(79,0.0311417); Allpt7TeVScaling->SetBinContent(80,0.03774521); Allpt7TeVScaling->SetBinContent(81,0.0219128); Allpt7TeVScaling->SetBinContent(82,0.02323492); Allpt7TeVScaling->SetBinContent(83,0.02412182); Allpt7TeVScaling->SetBinContent(84,0.03636555); Allpt7TeVScaling->SetBinContent(85,0.007488934); Allpt7TeVScaling->SetBinContent(86,0.01676086); Allpt7TeVScaling->SetBinContent(87,0.02427021); Allpt7TeVScaling->SetBinContent(88,0.02482882); Allpt7TeVScaling->SetBinContent(89,0.03680926); Allpt7TeVScaling->SetBinContent(90,0.01600685); Allpt7TeVScaling->SetBinContent(91,0.006885685); Allpt7TeVScaling->SetBinContent(93,0.0195411); Allpt7TeVScaling->SetBinContent(94,0.008862645); Allpt7TeVScaling->SetBinContent(95,0.009963223); Allpt7TeVScaling->SetBinContent(96,0.01399091); Allpt7TeVScaling->SetBinContent(97,0.007500135); Allpt7TeVScaling->SetBinContent(98,0.01922651); Allpt7TeVScaling->SetBinContent(103,0.03511665); Allpt7TeVScaling->SetBinError(13,0.03042345); Allpt7TeVScaling->SetBinError(14,0.007201474); Allpt7TeVScaling->SetBinError(15,0.004623859); Allpt7TeVScaling->SetBinError(16,0.004039713); Allpt7TeVScaling->SetBinError(17,0.003694238); Allpt7TeVScaling->SetBinError(18,0.003377785); Allpt7TeVScaling->SetBinError(19,0.00319956); Allpt7TeVScaling->SetBinError(20,0.00294949); Allpt7TeVScaling->SetBinError(21,0.001965652); Allpt7TeVScaling->SetBinError(22,0.001771706); Allpt7TeVScaling->SetBinError(23,0.0015726); Allpt7TeVScaling->SetBinError(24,0.001495611); Allpt7TeVScaling->SetBinError(25,0.00145454); Allpt7TeVScaling->SetBinError(26,0.001398941); Allpt7TeVScaling->SetBinError(27,0.001495129); Allpt7TeVScaling->SetBinError(28,0.001474393); Allpt7TeVScaling->SetBinError(29,0.001608602); Allpt7TeVScaling->SetBinError(30,0.001684714); Allpt7TeVScaling->SetBinError(31,0.001755251); Allpt7TeVScaling->SetBinError(32,0.001658064); Allpt7TeVScaling->SetBinError(33,0.001734642); Allpt7TeVScaling->SetBinError(34,0.001624169); Allpt7TeVScaling->SetBinError(35,0.001893747); Allpt7TeVScaling->SetBinError(36,0.001748243); Allpt7TeVScaling->SetBinError(37,0.001824646); Allpt7TeVScaling->SetBinError(38,0.001587514); Allpt7TeVScaling->SetBinError(39,0.001697203); Allpt7TeVScaling->SetBinError(40,0.002112545); Allpt7TeVScaling->SetBinError(41,0.002060819); Allpt7TeVScaling->SetBinError(42,0.002026571); Allpt7TeVScaling->SetBinError(43,0.001821759); Allpt7TeVScaling->SetBinError(44,0.002051793); Allpt7TeVScaling->SetBinError(45,0.002193957); Allpt7TeVScaling->SetBinError(46,0.001991362); Allpt7TeVScaling->SetBinError(47,0.002242771); Allpt7TeVScaling->SetBinError(48,0.002305595); Allpt7TeVScaling->SetBinError(49,0.002335076); Allpt7TeVScaling->SetBinError(50,0.002798601); Allpt7TeVScaling->SetBinError(51,0.003536788); Allpt7TeVScaling->SetBinError(52,0.003440952); Allpt7TeVScaling->SetBinError(53,0.003495971); Allpt7TeVScaling->SetBinError(54,0.003067046); Allpt7TeVScaling->SetBinError(55,0.003553133); Allpt7TeVScaling->SetBinError(56,0.003084681); Allpt7TeVScaling->SetBinError(57,0.003207651); Allpt7TeVScaling->SetBinError(58,0.002958898); Allpt7TeVScaling->SetBinError(59,0.003486212); Allpt7TeVScaling->SetBinError(60,0.003160784); Allpt7TeVScaling->SetBinError(61,0.00221753); Allpt7TeVScaling->SetBinError(62,0.002573063); Allpt7TeVScaling->SetBinError(63,0.003014171); Allpt7TeVScaling->SetBinError(64,0.003535776); Allpt7TeVScaling->SetBinError(65,0.003472028); Allpt7TeVScaling->SetBinError(66,0.003649103); Allpt7TeVScaling->SetBinError(67,0.004547596); Allpt7TeVScaling->SetBinError(68,0.004987629); Allpt7TeVScaling->SetBinError(69,0.005726305); Allpt7TeVScaling->SetBinError(70,0.003978767); Allpt7TeVScaling->SetBinError(71,0.00668463); Allpt7TeVScaling->SetBinError(72,0.005573138); Allpt7TeVScaling->SetBinError(73,0.005310436); Allpt7TeVScaling->SetBinError(74,0.007698246); Allpt7TeVScaling->SetBinError(75,0.01002912); Allpt7TeVScaling->SetBinError(76,0.006029285); Allpt7TeVScaling->SetBinError(77,0.0117225); Allpt7TeVScaling->SetBinError(78,0.01333887); Allpt7TeVScaling->SetBinError(79,0.009949805); Allpt7TeVScaling->SetBinError(80,0.01335105); Allpt7TeVScaling->SetBinError(81,0.004966615); Allpt7TeVScaling->SetBinError(82,0.006669427); Allpt7TeVScaling->SetBinError(83,0.007591192); Allpt7TeVScaling->SetBinError(84,0.01217267); Allpt7TeVScaling->SetBinError(85,0.002708538); Allpt7TeVScaling->SetBinError(86,0.008143581); Allpt7TeVScaling->SetBinError(87,0.01149673); Allpt7TeVScaling->SetBinError(88,0.01759547); Allpt7TeVScaling->SetBinError(89,0.01766708); Allpt7TeVScaling->SetBinError(90,0.01339557); Allpt7TeVScaling->SetBinError(91,0.004886052); Allpt7TeVScaling->SetBinError(93,0.01960311); Allpt7TeVScaling->SetBinError(94,0.008892003); Allpt7TeVScaling->SetBinError(95,0.01001297); Allpt7TeVScaling->SetBinError(96,0.008178781); Allpt7TeVScaling->SetBinError(97,0.007527505); Allpt7TeVScaling->SetBinError(98,0.01463862); Allpt7TeVScaling->SetBinError(103,0.03621621); Allpt7TeVScaling->SetMinimum(0); Allpt7TeVScaling->SetMaximum(0.04); Allpt7TeVScaling->SetEntries(1949.423); Allpt7TeVScaling->SetStats(0); Allpt7TeVScaling->SetMarkerStyle(20); Allpt7TeVScaling->GetXaxis()->SetTitle("p_{T}"); Allpt7TeVScaling->GetXaxis()->SetRange(1,91); Allpt7TeVScaling->GetYaxis()->SetTitle("Ratio of E_{T}^{background}/E_{T}^{had, meas.}"); Allpt7TeVScaling->GetYaxis()->SetTitleOffset(1.2); TH1D *Allpt900GeVScaling = new TH1D("Allpt900GeVScaling","Reconstructed E_{T} from misidentified electrons",111, xAxis1); Allpt900GeVScaling->SetBinContent(13,0.2098361); Allpt900GeVScaling->SetBinContent(14,0.1557776); Allpt900GeVScaling->SetBinContent(15,0.1480364); Allpt900GeVScaling->SetBinContent(16,0.1368096); Allpt900GeVScaling->SetBinContent(17,0.1244875); Allpt900GeVScaling->SetBinContent(18,0.1119436); Allpt900GeVScaling->SetBinContent(19,0.104192); Allpt900GeVScaling->SetBinContent(20,0.0938359); Allpt900GeVScaling->SetBinContent(21,0.08228509); Allpt900GeVScaling->SetBinContent(22,0.06783117); Allpt900GeVScaling->SetBinContent(23,0.05079209); Allpt900GeVScaling->SetBinContent(24,0.04795673); Allpt900GeVScaling->SetBinContent(25,0.04181242); Allpt900GeVScaling->SetBinContent(26,0.03994469); Allpt900GeVScaling->SetBinContent(27,0.03981588); Allpt900GeVScaling->SetBinContent(28,0.0377358); Allpt900GeVScaling->SetBinContent(29,0.0399667); Allpt900GeVScaling->SetBinContent(30,0.04095473); Allpt900GeVScaling->SetBinContent(31,0.04058456); Allpt900GeVScaling->SetBinContent(32,0.03641218); Allpt900GeVScaling->SetBinContent(33,0.03599966); Allpt900GeVScaling->SetBinContent(34,0.03853838); Allpt900GeVScaling->SetBinContent(35,0.04105409); Allpt900GeVScaling->SetBinContent(36,0.03461075); Allpt900GeVScaling->SetBinContent(37,0.03478729); Allpt900GeVScaling->SetBinContent(38,0.03150168); Allpt900GeVScaling->SetBinContent(39,0.03121329); Allpt900GeVScaling->SetBinContent(40,0.0370806); Allpt900GeVScaling->SetBinContent(41,0.03322445); Allpt900GeVScaling->SetBinContent(42,0.03200198); Allpt900GeVScaling->SetBinContent(43,0.02753292); Allpt900GeVScaling->SetBinContent(44,0.02776155); Allpt900GeVScaling->SetBinContent(45,0.02671865); Allpt900GeVScaling->SetBinContent(46,0.02612601); Allpt900GeVScaling->SetBinContent(47,0.02779079); Allpt900GeVScaling->SetBinContent(48,0.02762603); Allpt900GeVScaling->SetBinContent(49,0.0288977); Allpt900GeVScaling->SetBinContent(50,0.03181282); Allpt900GeVScaling->SetBinContent(51,0.04194707); Allpt900GeVScaling->SetBinContent(52,0.03287613); Allpt900GeVScaling->SetBinContent(53,0.04363778); Allpt900GeVScaling->SetBinContent(54,0.03003709); Allpt900GeVScaling->SetBinContent(55,0.03286254); Allpt900GeVScaling->SetBinContent(56,0.02585759); Allpt900GeVScaling->SetBinContent(57,0.03390592); Allpt900GeVScaling->SetBinContent(58,0.03212414); Allpt900GeVScaling->SetBinContent(59,0.03559123); Allpt900GeVScaling->SetBinContent(60,0.02464371); Allpt900GeVScaling->SetBinContent(61,0.03680997); Allpt900GeVScaling->SetBinContent(62,0.03569024); Allpt900GeVScaling->SetBinContent(63,0.03662885); Allpt900GeVScaling->SetBinContent(64,0.04690057); Allpt900GeVScaling->SetBinContent(65,0.04036927); Allpt900GeVScaling->SetBinContent(66,0.03237555); Allpt900GeVScaling->SetBinContent(67,0.04285642); Allpt900GeVScaling->SetBinContent(68,0.04778185); Allpt900GeVScaling->SetBinContent(69,0.0411135); Allpt900GeVScaling->SetBinContent(70,0.02465524); Allpt900GeVScaling->SetBinContent(71,0.03686565); Allpt900GeVScaling->SetBinContent(72,0.03694553); Allpt900GeVScaling->SetBinContent(73,0.02206743); Allpt900GeVScaling->SetBinContent(74,0.04854334); Allpt900GeVScaling->SetBinContent(75,0.04190287); Allpt900GeVScaling->SetBinContent(76,0.03255752); Allpt900GeVScaling->SetBinContent(77,0.0715847); Allpt900GeVScaling->SetBinContent(78,0.07329647); Allpt900GeVScaling->SetBinContent(79,0.02727783); Allpt900GeVScaling->SetBinContent(80,0.041527); Allpt900GeVScaling->SetBinContent(81,0.0400001); Allpt900GeVScaling->SetBinContent(82,0.0246785); Allpt900GeVScaling->SetBinContent(83,0.03546198); Allpt900GeVScaling->SetBinContent(84,0.0244789); Allpt900GeVScaling->SetBinContent(85,0.01692187); Allpt900GeVScaling->SetBinContent(86,0.01669025); Allpt900GeVScaling->SetBinContent(87,0.01506698); Allpt900GeVScaling->SetBinContent(88,0.02896953); Allpt900GeVScaling->SetBinContent(89,0.04019321); Allpt900GeVScaling->SetBinContent(90,0.0108909); Allpt900GeVScaling->SetBinContent(91,0.02059646); Allpt900GeVScaling->SetBinContent(92,0.01781294); Allpt900GeVScaling->SetBinContent(93,0.01930956); Allpt900GeVScaling->SetBinContent(94,0.0259471); Allpt900GeVScaling->SetBinContent(95,0.0114321); Allpt900GeVScaling->SetBinContent(98,0.04961994); Allpt900GeVScaling->SetBinContent(103,0.1436233); Allpt900GeVScaling->SetBinError(13,0.04135227); Allpt900GeVScaling->SetBinError(14,0.007955716); Allpt900GeVScaling->SetBinError(15,0.005353158); Allpt900GeVScaling->SetBinError(16,0.00465994); Allpt900GeVScaling->SetBinError(17,0.004317818); Allpt900GeVScaling->SetBinError(18,0.003992759); Allpt900GeVScaling->SetBinError(19,0.003794229); Allpt900GeVScaling->SetBinError(20,0.003428406); Allpt900GeVScaling->SetBinError(21,0.002309662); Allpt900GeVScaling->SetBinError(22,0.002082593); Allpt900GeVScaling->SetBinError(23,0.001768867); Allpt900GeVScaling->SetBinError(24,0.001734781); Allpt900GeVScaling->SetBinError(25,0.001668325); Allpt900GeVScaling->SetBinError(26,0.001736728); Allpt900GeVScaling->SetBinError(27,0.001793642); Allpt900GeVScaling->SetBinError(28,0.001824914); Allpt900GeVScaling->SetBinError(29,0.002216558); Allpt900GeVScaling->SetBinError(30,0.00224095); Allpt900GeVScaling->SetBinError(31,0.002244602); Allpt900GeVScaling->SetBinError(32,0.002073202); Allpt900GeVScaling->SetBinError(33,0.001913981); Allpt900GeVScaling->SetBinError(34,0.002456659); Allpt900GeVScaling->SetBinError(35,0.002596584); Allpt900GeVScaling->SetBinError(36,0.002232065); Allpt900GeVScaling->SetBinError(37,0.00251725); Allpt900GeVScaling->SetBinError(38,0.002196274); Allpt900GeVScaling->SetBinError(39,0.002513529); Allpt900GeVScaling->SetBinError(40,0.002973807); Allpt900GeVScaling->SetBinError(41,0.002807704); Allpt900GeVScaling->SetBinError(42,0.002773487); Allpt900GeVScaling->SetBinError(43,0.002527062); Allpt900GeVScaling->SetBinError(44,0.002921618); Allpt900GeVScaling->SetBinError(45,0.002907984); Allpt900GeVScaling->SetBinError(46,0.003115439); Allpt900GeVScaling->SetBinError(47,0.003224686); Allpt900GeVScaling->SetBinError(48,0.00312276); Allpt900GeVScaling->SetBinError(49,0.00393121); Allpt900GeVScaling->SetBinError(50,0.003948797); Allpt900GeVScaling->SetBinError(51,0.005565144); Allpt900GeVScaling->SetBinError(52,0.004615559); Allpt900GeVScaling->SetBinError(53,0.006431509); Allpt900GeVScaling->SetBinError(54,0.004787345); Allpt900GeVScaling->SetBinError(55,0.004506561); Allpt900GeVScaling->SetBinError(56,0.004277351); Allpt900GeVScaling->SetBinError(57,0.005084143); Allpt900GeVScaling->SetBinError(58,0.005085463); Allpt900GeVScaling->SetBinError(59,0.005312616); Allpt900GeVScaling->SetBinError(60,0.003899113); Allpt900GeVScaling->SetBinError(61,0.003977416); Allpt900GeVScaling->SetBinError(62,0.004292332); Allpt900GeVScaling->SetBinError(63,0.005072534); Allpt900GeVScaling->SetBinError(64,0.006271891); Allpt900GeVScaling->SetBinError(65,0.006463988); Allpt900GeVScaling->SetBinError(66,0.005869634); Allpt900GeVScaling->SetBinError(67,0.008405251); Allpt900GeVScaling->SetBinError(68,0.009847454); Allpt900GeVScaling->SetBinError(69,0.009749354); Allpt900GeVScaling->SetBinError(70,0.007179523); Allpt900GeVScaling->SetBinError(71,0.01004867); Allpt900GeVScaling->SetBinError(72,0.01065873); Allpt900GeVScaling->SetBinError(73,0.007849093); Allpt900GeVScaling->SetBinError(74,0.01402708); Allpt900GeVScaling->SetBinError(75,0.01330162); Allpt900GeVScaling->SetBinError(76,0.01245402); Allpt900GeVScaling->SetBinError(77,0.02130282); Allpt900GeVScaling->SetBinError(78,0.02296044); Allpt900GeVScaling->SetBinError(79,0.01175655); Allpt900GeVScaling->SetBinError(80,0.0187519); Allpt900GeVScaling->SetBinError(81,0.009932965); Allpt900GeVScaling->SetBinError(82,0.007798875); Allpt900GeVScaling->SetBinError(83,0.01126926); Allpt900GeVScaling->SetBinError(84,0.01123177); Allpt900GeVScaling->SetBinError(85,0.01013651); Allpt900GeVScaling->SetBinError(86,0.01187595); Allpt900GeVScaling->SetBinError(87,0.009213867); Allpt900GeVScaling->SetBinError(88,0.02054123); Allpt900GeVScaling->SetBinError(89,0.01976358); Allpt900GeVScaling->SetBinError(90,0.006322856); Allpt900GeVScaling->SetBinError(91,0.01400211); Allpt900GeVScaling->SetBinError(92,0.01786717); Allpt900GeVScaling->SetBinError(93,0.01938449); Allpt900GeVScaling->SetBinError(94,0.01853139); Allpt900GeVScaling->SetBinError(95,0.01149767); Allpt900GeVScaling->SetBinError(98,0.03786105); Allpt900GeVScaling->SetBinError(103,0.1493976); Allpt900GeVScaling->SetMinimum(0); Allpt900GeVScaling->SetMaximum(0.04); Allpt900GeVScaling->SetEntries(482.6447); Allpt900GeVScaling->SetStats(0); Allpt900GeVScaling->SetMarkerStyle(20); Allpt900GeVScaling->GetXaxis()->SetTitle("p_{T}"); Allpt900GeVScaling->GetXaxis()->SetRange(1,91); Allpt900GeVScaling->GetYaxis()->SetTitle("Ratio of E_{T}^{background}/E_{T}^{had, meas.}"); Allpt900GeVScaling->GetYaxis()->SetTitleOffset(1.2); Allpt7TeVScaling->Add(Allpt900GeVScaling); Allpt7TeVScaling->Scale(0.5); delete Allpt900GeVScaling; return Allpt7TeVScaling; } TH1D *pp276ITSBkgd(){ TH1D *Allpt7TeVScaling = new TH1D("Allpt7TeVScaling","Reconstructed E_{T} from misidentified electrons",111, xAxis1); Allpt7TeVScaling->SetBinContent(11,0.2557976); Allpt7TeVScaling->SetBinContent(12,0.1130502); Allpt7TeVScaling->SetBinContent(13,0.07504393); Allpt7TeVScaling->SetBinContent(14,0.05774832); Allpt7TeVScaling->SetBinContent(15,0.06389806); Allpt7TeVScaling->SetBinContent(16,0.0468956); Allpt7TeVScaling->SetBinContent(17,0.04355167); Allpt7TeVScaling->SetBinContent(18,0.04035013); Allpt7TeVScaling->SetBinContent(19,0.04359472); Allpt7TeVScaling->SetBinContent(20,0.03392261); Allpt7TeVScaling->SetBinContent(21,0.0327676); Allpt7TeVScaling->SetBinContent(22,0.02916985); Allpt7TeVScaling->SetBinContent(23,0.02603138); Allpt7TeVScaling->SetBinContent(24,0.02298032); Allpt7TeVScaling->SetBinContent(25,0.02366939); Allpt7TeVScaling->SetBinContent(26,0.01941947); Allpt7TeVScaling->SetBinContent(27,0.02077003); Allpt7TeVScaling->SetBinContent(28,0.01985847); Allpt7TeVScaling->SetBinContent(29,0.0177459); Allpt7TeVScaling->SetBinContent(30,0.01889314); Allpt7TeVScaling->SetBinContent(31,0.01783637); Allpt7TeVScaling->SetBinContent(32,0.01742894); Allpt7TeVScaling->SetBinContent(33,0.01400672); Allpt7TeVScaling->SetBinContent(34,0.01509014); Allpt7TeVScaling->SetBinContent(35,0.01473409); Allpt7TeVScaling->SetBinContent(36,0.01337399); Allpt7TeVScaling->SetBinContent(37,0.01458302); Allpt7TeVScaling->SetBinContent(38,0.01103552); Allpt7TeVScaling->SetBinContent(39,0.01440217); Allpt7TeVScaling->SetBinContent(40,0.0147644); Allpt7TeVScaling->SetBinContent(41,0.01459072); Allpt7TeVScaling->SetBinContent(42,0.01318416); Allpt7TeVScaling->SetBinContent(43,0.01364365); Allpt7TeVScaling->SetBinContent(44,0.01186023); Allpt7TeVScaling->SetBinContent(45,0.01218222); Allpt7TeVScaling->SetBinContent(46,0.01015807); Allpt7TeVScaling->SetBinContent(47,0.01158454); Allpt7TeVScaling->SetBinContent(48,0.009338749); Allpt7TeVScaling->SetBinContent(49,0.01320016); Allpt7TeVScaling->SetBinContent(50,0.01029357); Allpt7TeVScaling->SetBinContent(51,0.01238829); Allpt7TeVScaling->SetBinContent(52,0.008714745); Allpt7TeVScaling->SetBinContent(53,0.01300408); Allpt7TeVScaling->SetBinContent(54,0.009445714); Allpt7TeVScaling->SetBinContent(55,0.01301231); Allpt7TeVScaling->SetBinContent(56,0.01010809); Allpt7TeVScaling->SetBinContent(57,0.01181843); Allpt7TeVScaling->SetBinContent(58,0.01037317); Allpt7TeVScaling->SetBinContent(59,0.01172911); Allpt7TeVScaling->SetBinContent(60,0.007576451); Allpt7TeVScaling->SetBinContent(61,0.011185); Allpt7TeVScaling->SetBinContent(62,0.01009882); Allpt7TeVScaling->SetBinContent(63,0.01042078); Allpt7TeVScaling->SetBinContent(64,0.01079128); Allpt7TeVScaling->SetBinContent(65,0.008657009); Allpt7TeVScaling->SetBinContent(66,0.009641373); Allpt7TeVScaling->SetBinContent(67,0.01201938); Allpt7TeVScaling->SetBinContent(68,0.01031088); Allpt7TeVScaling->SetBinContent(69,0.009905995); Allpt7TeVScaling->SetBinContent(70,0.009569216); Allpt7TeVScaling->SetBinContent(71,0.009473246); Allpt7TeVScaling->SetBinContent(72,0.00825013); Allpt7TeVScaling->SetBinContent(73,0.008405926); Allpt7TeVScaling->SetBinContent(74,0.006479467); Allpt7TeVScaling->SetBinContent(75,0.01135131); Allpt7TeVScaling->SetBinContent(76,0.007318432); Allpt7TeVScaling->SetBinContent(77,0.01145386); Allpt7TeVScaling->SetBinContent(78,0.01425465); Allpt7TeVScaling->SetBinContent(79,0.01205772); Allpt7TeVScaling->SetBinContent(80,0.009454997); Allpt7TeVScaling->SetBinContent(81,0.006863416); Allpt7TeVScaling->SetBinContent(82,0.006285407); Allpt7TeVScaling->SetBinContent(83,0.004974776); Allpt7TeVScaling->SetBinContent(84,0.00748478); Allpt7TeVScaling->SetBinContent(85,0.002485323); Allpt7TeVScaling->SetBinContent(86,0.009973802); Allpt7TeVScaling->SetBinContent(87,0.00543998); Allpt7TeVScaling->SetBinContent(89,0.01703395); Allpt7TeVScaling->SetBinContent(90,0.004394557); Allpt7TeVScaling->SetBinContent(96,0.01833441); Allpt7TeVScaling->SetBinContent(98,0.02964621); Allpt7TeVScaling->SetBinContent(101,0.0574538); Allpt7TeVScaling->SetBinError(11,0.07407797); Allpt7TeVScaling->SetBinError(12,0.01275005); Allpt7TeVScaling->SetBinError(13,0.00608927); Allpt7TeVScaling->SetBinError(14,0.00428747); Allpt7TeVScaling->SetBinError(15,0.004071853); Allpt7TeVScaling->SetBinError(16,0.003225169); Allpt7TeVScaling->SetBinError(17,0.002968269); Allpt7TeVScaling->SetBinError(18,0.002761875); Allpt7TeVScaling->SetBinError(19,0.002800096); Allpt7TeVScaling->SetBinError(20,0.002386005); Allpt7TeVScaling->SetBinError(21,0.001589813); Allpt7TeVScaling->SetBinError(22,0.001475329); Allpt7TeVScaling->SetBinError(23,0.001364666); Allpt7TeVScaling->SetBinError(24,0.00126007); Allpt7TeVScaling->SetBinError(25,0.001265789); Allpt7TeVScaling->SetBinError(26,0.001156208); Allpt7TeVScaling->SetBinError(27,0.001182566); Allpt7TeVScaling->SetBinError(28,0.001171098); Allpt7TeVScaling->SetBinError(29,0.001122203); Allpt7TeVScaling->SetBinError(30,0.001173633); Allpt7TeVScaling->SetBinError(31,0.001154546); Allpt7TeVScaling->SetBinError(32,0.001162445); Allpt7TeVScaling->SetBinError(33,0.001067574); Allpt7TeVScaling->SetBinError(34,0.001116243); Allpt7TeVScaling->SetBinError(35,0.001144851); Allpt7TeVScaling->SetBinError(36,0.001110251); Allpt7TeVScaling->SetBinError(37,0.001192711); Allpt7TeVScaling->SetBinError(38,0.001062774); Allpt7TeVScaling->SetBinError(39,0.001255752); Allpt7TeVScaling->SetBinError(40,0.001319021); Allpt7TeVScaling->SetBinError(41,0.001323284); Allpt7TeVScaling->SetBinError(42,0.001303463); Allpt7TeVScaling->SetBinError(43,0.001388458); Allpt7TeVScaling->SetBinError(44,0.001312344); Allpt7TeVScaling->SetBinError(45,0.001383885); Allpt7TeVScaling->SetBinError(46,0.001289152); Allpt7TeVScaling->SetBinError(47,0.001430287); Allpt7TeVScaling->SetBinError(48,0.001302716); Allpt7TeVScaling->SetBinError(49,0.001578988); Allpt7TeVScaling->SetBinError(50,0.0014581); Allpt7TeVScaling->SetBinError(51,0.00165325); Allpt7TeVScaling->SetBinError(52,0.001404793); Allpt7TeVScaling->SetBinError(53,0.001757303); Allpt7TeVScaling->SetBinError(54,0.001562987); Allpt7TeVScaling->SetBinError(55,0.001911932); Allpt7TeVScaling->SetBinError(56,0.001695077); Allpt7TeVScaling->SetBinError(57,0.001932989); Allpt7TeVScaling->SetBinError(58,0.001844963); Allpt7TeVScaling->SetBinError(59,0.002000117); Allpt7TeVScaling->SetBinError(60,0.001689391); Allpt7TeVScaling->SetBinError(61,0.001386339); Allpt7TeVScaling->SetBinError(62,0.001349763); Allpt7TeVScaling->SetBinError(63,0.001454327); Allpt7TeVScaling->SetBinError(64,0.001584791); Allpt7TeVScaling->SetBinError(65,0.00151686); Allpt7TeVScaling->SetBinError(66,0.001668507); Allpt7TeVScaling->SetBinError(67,0.001963962); Allpt7TeVScaling->SetBinError(68,0.001970941); Allpt7TeVScaling->SetBinError(69,0.001992913); Allpt7TeVScaling->SetBinError(70,0.002006771); Allpt7TeVScaling->SetBinError(71,0.002187254); Allpt7TeVScaling->SetBinError(72,0.002140473); Allpt7TeVScaling->SetBinError(73,0.002256925); Allpt7TeVScaling->SetBinError(74,0.002056219); Allpt7TeVScaling->SetBinError(75,0.002854892); Allpt7TeVScaling->SetBinError(76,0.002450159); Allpt7TeVScaling->SetBinError(77,0.003197387); Allpt7TeVScaling->SetBinError(78,0.003840947); Allpt7TeVScaling->SetBinError(79,0.003660464); Allpt7TeVScaling->SetBinError(80,0.003363956); Allpt7TeVScaling->SetBinError(81,0.001624793); Allpt7TeVScaling->SetBinError(82,0.00181065); Allpt7TeVScaling->SetBinError(83,0.001888966); Allpt7TeVScaling->SetBinError(84,0.002671173); Allpt7TeVScaling->SetBinError(85,0.001759843); Allpt7TeVScaling->SetBinError(86,0.004094911); Allpt7TeVScaling->SetBinError(87,0.003871198); Allpt7TeVScaling->SetBinError(89,0.008630108); Allpt7TeVScaling->SetBinError(90,0.004405367); Allpt7TeVScaling->SetBinError(96,0.01308755); Allpt7TeVScaling->SetBinError(98,0.02127892); Allpt7TeVScaling->SetBinError(101,0.05904744); Allpt7TeVScaling->SetMinimum(0); Allpt7TeVScaling->SetMaximum(0.04); Allpt7TeVScaling->SetEntries(300.6659); Allpt7TeVScaling->SetStats(0); Allpt7TeVScaling->SetMarkerStyle(20); Allpt7TeVScaling->GetXaxis()->SetTitle("p_{T}"); Allpt7TeVScaling->GetXaxis()->SetRange(1,61); Allpt7TeVScaling->GetYaxis()->SetTitle("Ratio of E_{T}^{background}/E_{T}^{had, meas.}"); Allpt7TeVScaling->GetYaxis()->SetTitleOffset(1.2); TH1D *Allpt900GeVScaling = new TH1D("Allpt900GeVScaling","Reconstructed E_{T} from misidentified electrons",111, xAxis1); Allpt900GeVScaling->SetBinContent(9,1); Allpt900GeVScaling->SetBinContent(11,0.2834258); Allpt900GeVScaling->SetBinContent(12,0.1188776); Allpt900GeVScaling->SetBinContent(13,0.08085647); Allpt900GeVScaling->SetBinContent(14,0.05677858); Allpt900GeVScaling->SetBinContent(15,0.0616757); Allpt900GeVScaling->SetBinContent(16,0.04844882); Allpt900GeVScaling->SetBinContent(17,0.03999142); Allpt900GeVScaling->SetBinContent(18,0.03890007); Allpt900GeVScaling->SetBinContent(19,0.0406008); Allpt900GeVScaling->SetBinContent(20,0.02900627); Allpt900GeVScaling->SetBinContent(21,0.03088961); Allpt900GeVScaling->SetBinContent(22,0.03033992); Allpt900GeVScaling->SetBinContent(23,0.02521969); Allpt900GeVScaling->SetBinContent(24,0.02143008); Allpt900GeVScaling->SetBinContent(25,0.02266187); Allpt900GeVScaling->SetBinContent(26,0.01981764); Allpt900GeVScaling->SetBinContent(27,0.02127366); Allpt900GeVScaling->SetBinContent(28,0.0192753); Allpt900GeVScaling->SetBinContent(29,0.01854744); Allpt900GeVScaling->SetBinContent(30,0.01903471); Allpt900GeVScaling->SetBinContent(31,0.01819287); Allpt900GeVScaling->SetBinContent(32,0.01715784); Allpt900GeVScaling->SetBinContent(33,0.01488607); Allpt900GeVScaling->SetBinContent(34,0.0156348); Allpt900GeVScaling->SetBinContent(35,0.01699235); Allpt900GeVScaling->SetBinContent(36,0.01398954); Allpt900GeVScaling->SetBinContent(37,0.01435865); Allpt900GeVScaling->SetBinContent(38,0.01236315); Allpt900GeVScaling->SetBinContent(39,0.01282288); Allpt900GeVScaling->SetBinContent(40,0.01668125); Allpt900GeVScaling->SetBinContent(41,0.01372736); Allpt900GeVScaling->SetBinContent(42,0.01433745); Allpt900GeVScaling->SetBinContent(43,0.01477496); Allpt900GeVScaling->SetBinContent(44,0.0116776); Allpt900GeVScaling->SetBinContent(45,0.01245205); Allpt900GeVScaling->SetBinContent(46,0.009475905); Allpt900GeVScaling->SetBinContent(47,0.01117031); Allpt900GeVScaling->SetBinContent(48,0.009558273); Allpt900GeVScaling->SetBinContent(49,0.01404047); Allpt900GeVScaling->SetBinContent(50,0.01037464); Allpt900GeVScaling->SetBinContent(51,0.01195013); Allpt900GeVScaling->SetBinContent(52,0.01155682); Allpt900GeVScaling->SetBinContent(53,0.0137127); Allpt900GeVScaling->SetBinContent(54,0.009255665); Allpt900GeVScaling->SetBinContent(55,0.01133598); Allpt900GeVScaling->SetBinContent(56,0.009080946); Allpt900GeVScaling->SetBinContent(57,0.01124535); Allpt900GeVScaling->SetBinContent(58,0.008398657); Allpt900GeVScaling->SetBinContent(59,0.008324869); Allpt900GeVScaling->SetBinContent(60,0.007103489); Allpt900GeVScaling->SetBinContent(61,0.01142644); Allpt900GeVScaling->SetBinContent(62,0.0110906); Allpt900GeVScaling->SetBinContent(63,0.01076479); Allpt900GeVScaling->SetBinContent(64,0.01168746); Allpt900GeVScaling->SetBinContent(65,0.008513672); Allpt900GeVScaling->SetBinContent(66,0.00828279); Allpt900GeVScaling->SetBinContent(67,0.01140648); Allpt900GeVScaling->SetBinContent(68,0.01111323); Allpt900GeVScaling->SetBinContent(69,0.007425678); Allpt900GeVScaling->SetBinContent(70,0.009847098); Allpt900GeVScaling->SetBinContent(71,0.009834419); Allpt900GeVScaling->SetBinContent(72,0.008930991); Allpt900GeVScaling->SetBinContent(73,0.00669819); Allpt900GeVScaling->SetBinContent(74,0.00662618); Allpt900GeVScaling->SetBinContent(75,0.01370167); Allpt900GeVScaling->SetBinContent(76,0.006451024); Allpt900GeVScaling->SetBinContent(77,0.01307605); Allpt900GeVScaling->SetBinContent(78,0.01579264); Allpt900GeVScaling->SetBinContent(79,0.01255205); Allpt900GeVScaling->SetBinContent(80,0.01010045); Allpt900GeVScaling->SetBinContent(81,0.01082155); Allpt900GeVScaling->SetBinContent(82,0.006495255); Allpt900GeVScaling->SetBinContent(83,0.005512525); Allpt900GeVScaling->SetBinContent(84,0.003527945); Allpt900GeVScaling->SetBinContent(85,0.001806946); Allpt900GeVScaling->SetBinContent(86,0.004225982); Allpt900GeVScaling->SetBinContent(89,0.01106803); Allpt900GeVScaling->SetBinContent(90,0.005044269); Allpt900GeVScaling->SetBinContent(98,0.04456838); Allpt900GeVScaling->SetBinContent(101,0.07960857); Allpt900GeVScaling->SetBinError(9,1.414214); Allpt900GeVScaling->SetBinError(11,0.08936516); Allpt900GeVScaling->SetBinError(12,0.01474769); Allpt900GeVScaling->SetBinError(13,0.006947232); Allpt900GeVScaling->SetBinError(14,0.00470276); Allpt900GeVScaling->SetBinError(15,0.004394222); Allpt900GeVScaling->SetBinError(16,0.003598075); Allpt900GeVScaling->SetBinError(17,0.00312581); Allpt900GeVScaling->SetBinError(18,0.003002622); Allpt900GeVScaling->SetBinError(19,0.002976063); Allpt900GeVScaling->SetBinError(20,0.002438669); Allpt900GeVScaling->SetBinError(21,0.00172144); Allpt900GeVScaling->SetBinError(22,0.001661658); Allpt900GeVScaling->SetBinError(23,0.001477901); Allpt900GeVScaling->SetBinError(24,0.001329128); Allpt900GeVScaling->SetBinError(25,0.00137131); Allpt900GeVScaling->SetBinError(26,0.001299862); Allpt900GeVScaling->SetBinError(27,0.001332285); Allpt900GeVScaling->SetBinError(28,0.001274491); Allpt900GeVScaling->SetBinError(29,0.001266741); Allpt900GeVScaling->SetBinError(30,0.001305369); Allpt900GeVScaling->SetBinError(31,0.001295113); Allpt900GeVScaling->SetBinError(32,0.001278961); Allpt900GeVScaling->SetBinError(33,0.00122243); Allpt900GeVScaling->SetBinError(34,0.001256858); Allpt900GeVScaling->SetBinError(35,0.001357681); Allpt900GeVScaling->SetBinError(36,0.001267233); Allpt900GeVScaling->SetBinError(37,0.00131839); Allpt900GeVScaling->SetBinError(38,0.001256835); Allpt900GeVScaling->SetBinError(39,0.001306764); Allpt900GeVScaling->SetBinError(40,0.001544152); Allpt900GeVScaling->SetBinError(41,0.001438378); Allpt900GeVScaling->SetBinError(42,0.001507702); Allpt900GeVScaling->SetBinError(43,0.001615741); Allpt900GeVScaling->SetBinError(44,0.00143817); Allpt900GeVScaling->SetBinError(45,0.001536765); Allpt900GeVScaling->SetBinError(46,0.001377493); Allpt900GeVScaling->SetBinError(47,0.001536932); Allpt900GeVScaling->SetBinError(48,0.001466076); Allpt900GeVScaling->SetBinError(49,0.001814185); Allpt900GeVScaling->SetBinError(50,0.001620601); Allpt900GeVScaling->SetBinError(51,0.001814658); Allpt900GeVScaling->SetBinError(52,0.001822325); Allpt900GeVScaling->SetBinError(53,0.001976947); Allpt900GeVScaling->SetBinError(54,0.001729338); Allpt900GeVScaling->SetBinError(55,0.001988634); Allpt900GeVScaling->SetBinError(56,0.001792157); Allpt900GeVScaling->SetBinError(57,0.00206644); Allpt900GeVScaling->SetBinError(58,0.001842037); Allpt900GeVScaling->SetBinError(59,0.001826512); Allpt900GeVScaling->SetBinError(60,0.001732292); Allpt900GeVScaling->SetBinError(61,0.001512696); Allpt900GeVScaling->SetBinError(62,0.001543542); Allpt900GeVScaling->SetBinError(63,0.001633358); Allpt900GeVScaling->SetBinError(64,0.001816012); Allpt900GeVScaling->SetBinError(65,0.001680175); Allpt900GeVScaling->SetBinError(66,0.001692314); Allpt900GeVScaling->SetBinError(67,0.00213108); Allpt900GeVScaling->SetBinError(68,0.002295308); Allpt900GeVScaling->SetBinError(69,0.001926907); Allpt900GeVScaling->SetBinError(70,0.002272706); Allpt900GeVScaling->SetBinError(71,0.002475109); Allpt900GeVScaling->SetBinError(72,0.002399123); Allpt900GeVScaling->SetBinError(73,0.002241209); Allpt900GeVScaling->SetBinError(74,0.002365641); Allpt900GeVScaling->SetBinError(75,0.003450507); Allpt900GeVScaling->SetBinError(76,0.002503392); Allpt900GeVScaling->SetBinError(77,0.003801781); Allpt900GeVScaling->SetBinError(78,0.004417338); Allpt900GeVScaling->SetBinError(79,0.00421245); Allpt900GeVScaling->SetBinError(80,0.003844397); Allpt900GeVScaling->SetBinError(81,0.002274688); Allpt900GeVScaling->SetBinError(82,0.002043975); Allpt900GeVScaling->SetBinError(83,0.002262563); Allpt900GeVScaling->SetBinError(84,0.00204239); Allpt900GeVScaling->SetBinError(85,0.00180851); Allpt900GeVScaling->SetBinError(86,0.002994568); Allpt900GeVScaling->SetBinError(89,0.007939965); Allpt900GeVScaling->SetBinError(90,0.005058548); Allpt900GeVScaling->SetBinError(98,0.03222111); Allpt900GeVScaling->SetBinError(101,0.08264771); Allpt900GeVScaling->SetMinimum(0); Allpt900GeVScaling->SetMaximum(0.04); Allpt900GeVScaling->SetEntries(3.837105); Allpt900GeVScaling->SetStats(0); Allpt900GeVScaling->SetMarkerStyle(20); Allpt900GeVScaling->GetXaxis()->SetTitle("p_{T}"); Allpt900GeVScaling->GetXaxis()->SetRange(1,61); Allpt900GeVScaling->GetYaxis()->SetTitle("Ratio of E_{T}^{background}/E_{T}^{had, meas.}"); Allpt900GeVScaling->GetYaxis()->SetTitleOffset(1.2); Allpt7TeVScaling->Add(Allpt900GeVScaling); Allpt7TeVScaling->Scale(0.5); delete Allpt900GeVScaling; return Allpt7TeVScaling; }
251712a05728af8fb7762b76a1bb22f80483f4e1
3fb927c4e75708324ca65835d7f108cc809936c0
/archive/2000-eecs280/examples/examples.c++/programs/pythag.C
f8698301d8e04ff45f4f0feb1371063d302e3d6e
[ "CC-BY-4.0", "Apache-2.0" ]
permissive
csev/cc4e
f5d355ab37e495d7807916a031bcbec9e2d77b23
8ea00f27dfcb9c080263b9a87cbb2a833ce758ae
refs/heads/master
2023-08-09T21:55:53.990191
2023-08-01T08:11:24
2023-08-01T08:11:24
226,528,307
170
60
NOASSERTION
2023-08-02T15:55:02
2019-12-07T14:37:23
C++
UTF-8
C
false
false
554
c
pythag.C
/* pythag - Calaculates the hypotenuse given two sides of a triangle */ /* Written by: C. Severance - Tue Dec 7 22:31:01 EST 1993 */ #include<math.h> #include <iostream.h> main() { float a,b,hyp; double tmp,sqrt(double); /* Prompt the user two sides of the triangle */ cout << "enter the first side of the triangle -"; cin >> a; cout << "enter the second side of the triangle -"; cin >> b; /* Calculate the hypotenuse */ tmp = a * a + b * b; hyp = sqrt ( tmp ); cout << "third side of the triangle is - " << hyp << "\n"; }
f8ff79380267dcb15ef7b4b2e975a4c9a1f848eb
af777935080dd963960f44561f25b0ae59f373a3
/Example/Pods/Headers/Public/JXCategoryView/JXCategoryListContainerView.h
9398e27e6b890851cbb00af9beb73b7c5105e71d
[ "MIT" ]
permissive
pujiaxin33/JXCategoryView
2a3684461988cc1de8cf1e6190225d16af7816e3
8865907e0d5e7fd5af8ae847c309056a8a478315
refs/heads/master
2023-07-07T08:36:44.520235
2022-07-17T10:30:35
2022-07-17T10:30:35
126,299,577
6,223
1,179
MIT
2023-06-30T08:49:22
2018-03-22T07:54:35
Objective-C
UTF-8
C
false
false
59
h
JXCategoryListContainerView.h
../../../../../Sources/Common/JXCategoryListContainerView.h
2474e652bf26170fb9c5b2c3b7782cb22346955d
a474d7e6c0dd5f8f3a0919db050ebf773780865f
/lib/drivers/spi.c
7dce21d1c3e4a36fec9c32371531f2f00d7fe9a6
[ "Apache-2.0" ]
permissive
kendryte/kendryte-standalone-sdk
7b8b1887eab040da76b4ad9063d11b8ca5e5e5b9
02576ba67e8797444f3ee3f34c625b5ed048e707
refs/heads/develop
2023-09-03T11:18:18.009662
2021-09-24T02:56:10
2021-09-24T02:56:10
147,705,154
416
158
Apache-2.0
2021-07-18T10:25:52
2018-09-06T16:53:21
C
UTF-8
C
false
false
54,159
c
spi.c
/* Copyright 2018 Canaan Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <bsp.h> #include <stddef.h> #include <stdlib.h> #include <string.h> #include "fpioa.h" #include "gpiohs.h" #include "platform.h" #include "spi.h" #include "sysctl.h" #include "utils.h" #include "iomem.h" volatile spi_t *const spi[4] = { (volatile spi_t *)SPI0_BASE_ADDR, (volatile spi_t *)SPI1_BASE_ADDR, (volatile spi_t *)SPI_SLAVE_BASE_ADDR, (volatile spi_t *)SPI3_BASE_ADDR}; typedef struct _spi_dma_context { uint8_t *buffer; size_t buf_len; uint32_t *malloc_buffer; spi_transfer_mode_t int_mode; dmac_channel_number_t dmac_channel; spi_device_num_t spi_num; plic_instance_t spi_int_instance; } spi_dma_context_t; spi_dma_context_t spi_dma_context[4]; typedef struct _spi_instance_t { spi_device_num_t spi_num; spi_transfer_mode_t transfer_mode; dmac_channel_number_t dmac_channel; plic_instance_t spi_int_instance; spinlock_t lock; } spi_instance_t; static spi_instance_t g_spi_instance[4]; static spi_slave_instance_t g_instance; static spi_frame_format_t spi_get_frame_format(spi_device_num_t spi_num) { uint8_t frf_offset; switch(spi_num) { case 0: case 1: frf_offset = 21; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: frf_offset = 22; break; } volatile spi_t *spi_adapter = spi[spi_num]; return ((spi_adapter->ctrlr0 >> frf_offset) & 0x3); } static spi_transfer_width_t spi_get_frame_size(size_t data_bit_length) { if(data_bit_length < 8) return SPI_TRANS_CHAR; else if(data_bit_length < 16) return SPI_TRANS_SHORT; return SPI_TRANS_INT; } static int spi_dma_irq(void *ctx) { spi_instance_t *v_instance = (spi_instance_t *)ctx; volatile spi_t *spi_handle = spi[v_instance->spi_num]; dmac_irq_unregister(v_instance->dmac_channel); while((spi_handle->sr & 0x05) != 0x04) ; spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; spinlock_unlock(&v_instance->lock); if(v_instance->spi_int_instance.callback) { v_instance->spi_int_instance.callback(v_instance->spi_int_instance.ctx); } return 0; } static int spi_clk_init(uint8_t spi_num) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); if(spi_num == 3) sysctl_clock_set_clock_select(SYSCTL_CLOCK_SELECT_SPI3, 1); sysctl_clock_enable(SYSCTL_CLOCK_SPI0 + spi_num); sysctl_clock_set_threshold(SYSCTL_THRESHOLD_SPI0 + spi_num, 0); return 0; } static void spi_set_tmod(uint8_t spi_num, uint32_t tmod) { configASSERT(spi_num < SPI_DEVICE_MAX); volatile spi_t *spi_handle = spi[spi_num]; uint8_t tmod_offset = 0; switch(spi_num) { case 0: case 1: case 2: tmod_offset = 8; break; case 3: default: tmod_offset = 10; break; } set_bit(&spi_handle->ctrlr0, 3 << tmod_offset, tmod << tmod_offset); } void spi_init(spi_device_num_t spi_num, spi_work_mode_t work_mode, spi_frame_format_t frame_format, size_t data_bit_length, uint32_t endian) { configASSERT(data_bit_length >= 4 && data_bit_length <= 32); configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); spi_clk_init(spi_num); uint8_t dfs_offset, frf_offset, work_mode_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; frf_offset = 21; work_mode_offset = 6; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; frf_offset = 22; work_mode_offset = 8; break; } switch(frame_format) { case SPI_FF_DUAL: configASSERT(data_bit_length % 2 == 0); break; case SPI_FF_QUAD: configASSERT(data_bit_length % 4 == 0); break; case SPI_FF_OCTAL: configASSERT(data_bit_length % 8 == 0); break; default: break; } volatile spi_t *spi_adapter = spi[spi_num]; if(spi_adapter->baudr == 0) spi_adapter->baudr = 0x14; spi_adapter->imr = 0x00; spi_adapter->dmacr = 0x00; spi_adapter->dmatdlr = 0x10; spi_adapter->dmardlr = 0x00; spi_adapter->ser = 0x00; spi_adapter->ssienr = 0x00; spi_adapter->ctrlr0 = (work_mode << work_mode_offset) | (frame_format << frf_offset) | ((data_bit_length - 1) << dfs_offset); spi_adapter->spi_ctrlr0 = 0; spi_adapter->endian = endian; } void spi_init_non_standard(spi_device_num_t spi_num, uint32_t instruction_length, uint32_t address_length, uint32_t wait_cycles, spi_instruction_address_trans_mode_t instruction_address_trans_mode) { configASSERT(wait_cycles < (1 << 5)); configASSERT(instruction_address_trans_mode < 3); configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); volatile spi_t *spi_handle = spi[spi_num]; uint32_t inst_l = 0; switch(instruction_length) { case 0: inst_l = 0; break; case 4: inst_l = 1; break; case 8: inst_l = 2; break; case 16: inst_l = 3; break; default: configASSERT(!"Invalid instruction length"); break; } configASSERT(address_length % 4 == 0 && address_length <= 60); uint32_t addr_l = address_length / 4; spi_handle->spi_ctrlr0 = (wait_cycles << 11) | (inst_l << 8) | (addr_l << 2) | instruction_address_trans_mode; } uint32_t spi_set_clk_rate(spi_device_num_t spi_num, uint32_t spi_clk) { uint32_t spi_baudr = sysctl_clock_get_freq(SYSCTL_CLOCK_SPI0 + spi_num) / spi_clk; if(spi_baudr < 2) { spi_baudr = 2; } else if(spi_baudr > 65534) { spi_baudr = 65534; } volatile spi_t *spi_adapter = spi[spi_num]; spi_adapter->baudr = spi_baudr; return sysctl_clock_get_freq(SYSCTL_CLOCK_SPI0 + spi_num) / spi_baudr; } void spi_send_data_normal(spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint8_t *tx_buff, size_t tx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); size_t index, fifo_len; spi_set_tmod(spi_num, SPI_TMOD_TRANS); volatile spi_t *spi_handle = spi[spi_num]; uint8_t dfs_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; break; } uint32_t data_bit_length = (spi_handle->ctrlr0 >> dfs_offset) & 0x1F; spi_transfer_width_t frame_width = spi_get_frame_size(data_bit_length); uint8_t v_misalign_flag = 0; uint32_t v_send_data; if((uintptr_t)tx_buff % frame_width) v_misalign_flag = 1; spi_handle->ssienr = 0x01; spi_handle->ser = 1U << chip_select; uint32_t i = 0; while(tx_len) { fifo_len = 32 - spi_handle->txflr; fifo_len = fifo_len < tx_len ? fifo_len : tx_len; switch(frame_width) { case SPI_TRANS_INT: fifo_len = fifo_len / 4 * 4; if(v_misalign_flag) { for(index = 0; index < fifo_len; index += 4) { memcpy(&v_send_data, tx_buff + i, 4); spi_handle->dr[0] = v_send_data; i += 4; } } else { for(index = 0; index < fifo_len / 4; index++) spi_handle->dr[0] = ((uint32_t *)tx_buff)[i++]; } break; case SPI_TRANS_SHORT: fifo_len = fifo_len / 2 * 2; if(v_misalign_flag) { for(index = 0; index < fifo_len; index += 2) { memcpy(&v_send_data, tx_buff + i, 2); spi_handle->dr[0] = v_send_data; i += 2; } } else { for(index = 0; index < fifo_len / 2; index++) spi_handle->dr[0] = ((uint16_t *)tx_buff)[i++]; } break; default: for(index = 0; index < fifo_len; index++) spi_handle->dr[0] = tx_buff[i++]; break; } tx_len -= fifo_len; } while((spi_handle->sr & 0x05) != 0x04) ; spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; } void spi_send_data_standard(spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint8_t *cmd_buff, size_t cmd_len, const uint8_t *tx_buff, size_t tx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); uint8_t *v_buf = malloc(cmd_len + tx_len); size_t i; for(i = 0; i < cmd_len; i++) v_buf[i] = cmd_buff[i]; for(i = 0; i < tx_len; i++) v_buf[cmd_len + i] = tx_buff[i]; spi_send_data_normal(spi_num, chip_select, v_buf, cmd_len + tx_len); free((void *)v_buf); } void spi_send_data_standard_dma(dmac_channel_number_t channel_num, spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint8_t *cmd_buff, size_t cmd_len, const uint8_t *tx_buff, size_t tx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); volatile spi_t *spi_handle = spi[spi_num]; uint8_t dfs_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; break; } uint32_t data_bit_length = (spi_handle->ctrlr0 >> dfs_offset) & 0x1F; spi_transfer_width_t frame_width = spi_get_frame_size(data_bit_length); uint32_t *buf; size_t v_send_len; int i; switch(frame_width) { case SPI_TRANS_INT: buf = malloc(cmd_len + tx_len); for(i = 0; i < cmd_len / 4; i++) buf[i] = ((uint32_t *)cmd_buff)[i]; for(i = 0; i < tx_len / 4; i++) buf[cmd_len / 4 + i] = ((uint32_t *)tx_buff)[i]; v_send_len = (cmd_len + tx_len) / 4; break; case SPI_TRANS_SHORT: buf = malloc((cmd_len + tx_len) / 2 * sizeof(uint32_t)); for(i = 0; i < cmd_len / 2; i++) buf[i] = ((uint16_t *)cmd_buff)[i]; for(i = 0; i < tx_len / 2; i++) buf[cmd_len / 2 + i] = ((uint16_t *)tx_buff)[i]; v_send_len = (cmd_len + tx_len) / 2; break; default: buf = malloc((cmd_len + tx_len) * sizeof(uint32_t)); for(i = 0; i < cmd_len; i++) buf[i] = cmd_buff[i]; for(i = 0; i < tx_len; i++) buf[cmd_len + i] = tx_buff[i]; v_send_len = cmd_len + tx_len; break; } spi_send_data_normal_dma(channel_num, spi_num, chip_select, buf, v_send_len, SPI_TRANS_INT); free((void *)buf); } void spi_send_data_normal_dma(dmac_channel_number_t channel_num, spi_device_num_t spi_num, spi_chip_select_t chip_select, const void *tx_buff, size_t tx_len, spi_transfer_width_t spi_transfer_width) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); spi_set_tmod(spi_num, SPI_TMOD_TRANS); volatile spi_t *spi_handle = spi[spi_num]; uint32_t *buf; int i; switch(spi_transfer_width) { case SPI_TRANS_SHORT: #if FIX_CACHE buf = (uint32_t *)iomem_malloc((tx_len) * sizeof(uint32_t)); #else buf = (uint32_t *)malloc((tx_len) * sizeof(uint32_t)); #endif for(i = 0; i < tx_len; i++) buf[i] = ((uint16_t *)tx_buff)[i]; break; case SPI_TRANS_INT: buf = (uint32_t *)tx_buff; break; case SPI_TRANS_CHAR: default: #if FIX_CACHE buf = (uint32_t *)iomem_malloc((tx_len) * sizeof(uint32_t)); #else buf = (uint32_t *)malloc((tx_len) * sizeof(uint32_t)); #endif for(i = 0; i < tx_len; i++) buf[i] = ((uint8_t *)tx_buff)[i]; break; } spi_handle->dmacr = 0x2; /*enable dma transmit*/ spi_handle->ssienr = 0x01; sysctl_dma_select((sysctl_dma_channel_t)channel_num, SYSCTL_DMA_SELECT_SSI0_TX_REQ + spi_num * 2); dmac_set_single_mode(channel_num, buf, (void *)(&spi_handle->dr[0]), DMAC_ADDR_INCREMENT, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, tx_len); spi_handle->ser = 1U << chip_select; dmac_wait_done(channel_num); if(spi_transfer_width != SPI_TRANS_INT) { #if FIX_CACHE iomem_free((void *)buf); #else free((void *)buf); #endif } while((spi_handle->sr & 0x05) != 0x04) ; spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; } void spi_dup_send_receive_data_dma(dmac_channel_number_t dma_send_channel_num, dmac_channel_number_t dma_receive_channel_num, spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint8_t *tx_buf, size_t tx_len, uint8_t *rx_buf, size_t rx_len) { spi_set_tmod(spi_num, SPI_TMOD_TRANS_RECV); volatile spi_t *spi_handle = spi[spi_num]; uint8_t dfs_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; break; } uint32_t data_bit_length = (spi_handle->ctrlr0 >> dfs_offset) & 0x1F; spi_transfer_width_t frame_width = spi_get_frame_size(data_bit_length); size_t v_tx_len = tx_len / frame_width; size_t v_rx_len = rx_len / frame_width; size_t v_max_len = v_tx_len > v_rx_len ? v_tx_len : v_rx_len; #if FIX_CACHE uint32_t *v_tx_buf = iomem_malloc(v_max_len * 4); uint32_t *v_rx_buf = iomem_malloc(v_max_len * 4); #else uint32_t *v_tx_buf = malloc(v_max_len * 4); uint32_t *v_rx_buf = malloc(v_max_len * 4); #endif uint32_t i = 0; switch(frame_width) { case SPI_TRANS_INT: for(i = 0; i < v_tx_len; i++) { v_tx_buf[i] = ((uint32_t *)tx_buf)[i]; } if(v_max_len > v_tx_len) { while(i < v_max_len) { v_tx_buf[i++] = 0xFFFFFFFF; } } break; case SPI_TRANS_SHORT: for(i = 0; i < v_tx_len; i++) { v_tx_buf[i] = ((uint16_t *)tx_buf)[i]; } if(v_max_len > v_tx_len) { while(i < v_max_len) { v_tx_buf[i++] = 0xFFFFFFFF; } } break; default: for(i = 0; i < v_tx_len; i++) { v_tx_buf[i] = tx_buf[i]; } if(v_max_len > v_tx_len) { while(i < v_max_len) { v_tx_buf[i++] = 0xFFFFFFFF; } } break; } spi_handle->dmacr = 0x3; spi_handle->ssienr = 0x01; sysctl_dma_select((sysctl_dma_channel_t)dma_send_channel_num, SYSCTL_DMA_SELECT_SSI0_TX_REQ + spi_num * 2); sysctl_dma_select((sysctl_dma_channel_t)dma_receive_channel_num, SYSCTL_DMA_SELECT_SSI0_RX_REQ + spi_num * 2); dmac_set_single_mode(dma_receive_channel_num, (void *)(&spi_handle->dr[0]), v_rx_buf, DMAC_ADDR_NOCHANGE, DMAC_ADDR_INCREMENT, DMAC_MSIZE_1, DMAC_TRANS_WIDTH_32, v_max_len); dmac_set_single_mode(dma_send_channel_num, v_tx_buf, (void *)(&spi_handle->dr[0]), DMAC_ADDR_INCREMENT, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, v_max_len); spi_handle->ser = 1U << chip_select; dmac_wait_done(dma_send_channel_num); dmac_wait_done(dma_receive_channel_num); spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; switch(frame_width) { case SPI_TRANS_INT: for(i = 0; i < v_rx_len; i++) ((uint32_t *)rx_buf)[i] = v_rx_buf[i]; break; case SPI_TRANS_SHORT: for(i = 0; i < v_rx_len; i++) ((uint16_t *)rx_buf)[i] = v_rx_buf[i]; break; default: for(i = 0; i < v_rx_len; i++) rx_buf[i] = v_rx_buf[i]; break; } #if FIX_CACHE iomem_free(v_tx_buf); iomem_free(v_rx_buf); #else free(v_tx_buf); free(v_rx_buf); #endif } void spi_receive_data_standard(spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint8_t *cmd_buff, size_t cmd_len, uint8_t *rx_buff, size_t rx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); size_t index, fifo_len; if(cmd_len == 0) spi_set_tmod(spi_num, SPI_TMOD_RECV); else spi_set_tmod(spi_num, SPI_TMOD_EEROM); volatile spi_t *spi_handle = spi[spi_num]; uint8_t dfs_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; break; } uint32_t data_bit_length = (spi_handle->ctrlr0 >> dfs_offset) & 0x1F; spi_transfer_width_t frame_width = spi_get_frame_size(data_bit_length); uint32_t i = 0; size_t v_cmd_len = cmd_len / frame_width; uint32_t v_rx_len = rx_len / frame_width; spi_handle->ctrlr1 = (uint32_t)(v_rx_len - 1); spi_handle->ssienr = 0x01; while(v_cmd_len) { fifo_len = 32 - spi_handle->txflr; fifo_len = fifo_len < v_cmd_len ? fifo_len : v_cmd_len; switch(frame_width) { case SPI_TRANS_INT: for(index = 0; index < fifo_len; index++) spi_handle->dr[0] = ((uint32_t *)cmd_buff)[i++]; break; case SPI_TRANS_SHORT: for(index = 0; index < fifo_len; index++) spi_handle->dr[0] = ((uint16_t *)cmd_buff)[i++]; break; default: for(index = 0; index < fifo_len; index++) spi_handle->dr[0] = cmd_buff[i++]; break; } spi_handle->ser = 1U << chip_select; v_cmd_len -= fifo_len; } if(cmd_len == 0) { spi_handle->dr[0] = 0xffffffff; spi_handle->ser = 1U << chip_select; } i = 0; while(v_rx_len) { fifo_len = spi_handle->rxflr; fifo_len = fifo_len < v_rx_len ? fifo_len : v_rx_len; switch(frame_width) { case SPI_TRANS_INT: for(index = 0; index < fifo_len; index++) ((uint32_t *)rx_buff)[i++] = spi_handle->dr[0]; break; case SPI_TRANS_SHORT: for(index = 0; index < fifo_len; index++) ((uint16_t *)rx_buff)[i++] = (uint16_t)spi_handle->dr[0]; break; default: for(index = 0; index < fifo_len; index++) rx_buff[i++] = (uint8_t)spi_handle->dr[0]; break; } v_rx_len -= fifo_len; } spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; } void spi_receive_data_normal_dma(dmac_channel_number_t dma_send_channel_num, dmac_channel_number_t dma_receive_channel_num, spi_device_num_t spi_num, spi_chip_select_t chip_select, const void *cmd_buff, size_t cmd_len, void *rx_buff, size_t rx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); if(cmd_len == 0) spi_set_tmod(spi_num, SPI_TMOD_RECV); else spi_set_tmod(spi_num, SPI_TMOD_EEROM); volatile spi_t *spi_handle = spi[spi_num]; spi_handle->ctrlr1 = (uint32_t)(rx_len - 1); spi_handle->dmacr = 0x3; spi_handle->ssienr = 0x01; if(cmd_len) sysctl_dma_select((sysctl_dma_channel_t)dma_send_channel_num, SYSCTL_DMA_SELECT_SSI0_TX_REQ + spi_num * 2); sysctl_dma_select((sysctl_dma_channel_t)dma_receive_channel_num, SYSCTL_DMA_SELECT_SSI0_RX_REQ + spi_num * 2); dmac_set_single_mode(dma_receive_channel_num, (void *)(&spi_handle->dr[0]), rx_buff, DMAC_ADDR_NOCHANGE, DMAC_ADDR_INCREMENT, DMAC_MSIZE_1, DMAC_TRANS_WIDTH_32, rx_len); if(cmd_len) dmac_set_single_mode(dma_send_channel_num, cmd_buff, (void *)(&spi_handle->dr[0]), DMAC_ADDR_INCREMENT, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, cmd_len); if(cmd_len == 0 && spi_get_frame_format(spi_num) == SPI_FF_STANDARD) spi[spi_num]->dr[0] = 0xffffffff; spi_handle->ser = 1U << chip_select; if(cmd_len) dmac_wait_done(dma_send_channel_num); dmac_wait_done(dma_receive_channel_num); spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; } void spi_receive_data_standard_dma(dmac_channel_number_t dma_send_channel_num, dmac_channel_number_t dma_receive_channel_num, spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint8_t *cmd_buff, size_t cmd_len, uint8_t *rx_buff, size_t rx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); volatile spi_t *spi_handle = spi[spi_num]; uint8_t dfs_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; break; } uint32_t data_bit_length = (spi_handle->ctrlr0 >> dfs_offset) & 0x1F; spi_transfer_width_t frame_width = spi_get_frame_size(data_bit_length); size_t i; uint32_t *write_cmd; uint32_t *read_buf; size_t v_recv_len; size_t v_cmd_len; switch(frame_width) { case SPI_TRANS_INT: #if FIX_CACHE write_cmd = iomem_malloc(cmd_len + rx_len); #else write_cmd = malloc(cmd_len + rx_len); #endif for(i = 0; i < cmd_len / 4; i++) write_cmd[i] = ((uint32_t *)cmd_buff)[i]; read_buf = &write_cmd[i]; v_recv_len = rx_len / 4; v_cmd_len = cmd_len / 4; break; case SPI_TRANS_SHORT: #if FIX_CACHE write_cmd = iomem_malloc((cmd_len + rx_len) / 2 * sizeof(uint32_t)); #else write_cmd = malloc((cmd_len + rx_len) / 2 * sizeof(uint32_t)); #endif for(i = 0; i < cmd_len / 2; i++) write_cmd[i] = ((uint16_t *)cmd_buff)[i]; read_buf = &write_cmd[i]; v_recv_len = rx_len / 2; v_cmd_len = cmd_len / 2; break; default: #if FIX_CACHE write_cmd = iomem_malloc((cmd_len + rx_len) * sizeof(uint32_t)); #else write_cmd = malloc((cmd_len + rx_len) * sizeof(uint32_t)); #endif for(i = 0; i < cmd_len; i++) write_cmd[i] = cmd_buff[i]; read_buf = &write_cmd[i]; v_recv_len = rx_len; v_cmd_len = cmd_len; break; } spi_receive_data_normal_dma(dma_send_channel_num, dma_receive_channel_num, spi_num, chip_select, write_cmd, v_cmd_len, read_buf, v_recv_len); switch(frame_width) { case SPI_TRANS_INT: for(i = 0; i < v_recv_len; i++) ((uint32_t *)rx_buff)[i] = read_buf[i]; break; case SPI_TRANS_SHORT: for(i = 0; i < v_recv_len; i++) ((uint16_t *)rx_buff)[i] = read_buf[i]; break; default: for(i = 0; i < v_recv_len; i++) rx_buff[i] = read_buf[i]; break; } #if FIX_CACHE iomem_free(write_cmd); #else free(write_cmd); #endif } void spi_receive_data_multiple(spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint32_t *cmd_buff, size_t cmd_len, uint8_t *rx_buff, size_t rx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); size_t index, fifo_len; if(cmd_len == 0) spi_set_tmod(spi_num, SPI_TMOD_RECV); else spi_set_tmod(spi_num, SPI_TMOD_EEROM); volatile spi_t *spi_handle = spi[spi_num]; uint8_t dfs_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; break; } uint32_t data_bit_length = (spi_handle->ctrlr0 >> dfs_offset) & 0x1F; spi_transfer_width_t frame_width = spi_get_frame_size(data_bit_length); uint32_t v_cmd_len = cmd_len; uint32_t i = 0; uint32_t v_rx_len = rx_len / frame_width; spi_handle->ctrlr1 = (uint32_t)(v_rx_len - 1); spi_handle->ssienr = 0x01; while(v_cmd_len) { fifo_len = 32 - spi_handle->txflr; fifo_len = fifo_len < v_cmd_len ? fifo_len : v_cmd_len; for(index = 0; index < fifo_len; index++) spi_handle->dr[0] = *cmd_buff++; spi_handle->ser = 1U << chip_select; v_cmd_len -= fifo_len; } if(cmd_len == 0) { spi_handle->ser = 1U << chip_select; } while(v_rx_len) { fifo_len = spi_handle->rxflr; fifo_len = fifo_len < v_rx_len ? fifo_len : v_rx_len; switch(frame_width) { case SPI_TRANS_INT: for(index = 0; index < fifo_len; index++) ((uint32_t *)rx_buff)[i++] = spi_handle->dr[0]; break; case SPI_TRANS_SHORT: for(index = 0; index < fifo_len; index++) ((uint16_t *)rx_buff)[i++] = (uint16_t)spi_handle->dr[0]; break; default: for(index = 0; index < fifo_len; index++) rx_buff[i++] = (uint8_t)spi_handle->dr[0]; break; } v_rx_len -= fifo_len; } spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; } void spi_receive_data_multiple_dma(dmac_channel_number_t dma_send_channel_num, dmac_channel_number_t dma_receive_channel_num, spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint32_t *cmd_buff, size_t cmd_len, uint8_t *rx_buff, size_t rx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); volatile spi_t *spi_handle = spi[spi_num]; uint8_t dfs_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; break; } uint32_t data_bit_length = (spi_handle->ctrlr0 >> dfs_offset) & 0x1F; spi_transfer_width_t frame_width = spi_get_frame_size(data_bit_length); size_t i; uint32_t *write_cmd = NULL; uint32_t *read_buf; size_t v_recv_len; switch(frame_width) { case SPI_TRANS_INT: v_recv_len = rx_len / 4; break; case SPI_TRANS_SHORT: #if FIX_CACHE write_cmd = iomem_malloc(cmd_len + rx_len / 2 * sizeof(uint32_t)); #else write_cmd = malloc(cmd_len + rx_len / 2 * sizeof(uint32_t)); #endif for(i = 0; i < cmd_len; i++) write_cmd[i] = cmd_buff[i]; read_buf = &write_cmd[i]; v_recv_len = rx_len / 2; break; default: #if FIX_CACHE write_cmd = iomem_malloc(cmd_len + rx_len * sizeof(uint32_t)); #else write_cmd = malloc(cmd_len + rx_len * sizeof(uint32_t)); #endif for(i = 0; i < cmd_len; i++) write_cmd[i] = cmd_buff[i]; read_buf = &write_cmd[i]; v_recv_len = rx_len; break; } if(frame_width == SPI_TRANS_INT) spi_receive_data_normal_dma(dma_send_channel_num, dma_receive_channel_num, spi_num, chip_select, cmd_buff, cmd_len, rx_buff, v_recv_len); else spi_receive_data_normal_dma(dma_send_channel_num, dma_receive_channel_num, spi_num, chip_select, write_cmd, cmd_len, read_buf, v_recv_len); switch(frame_width) { case SPI_TRANS_INT: break; case SPI_TRANS_SHORT: for(i = 0; i < v_recv_len; i++) ((uint16_t *)rx_buff)[i] = read_buf[i]; break; default: for(i = 0; i < v_recv_len; i++) rx_buff[i] = read_buf[i]; break; } if(frame_width != SPI_TRANS_INT) { #if FIX_CACHE iomem_free(write_cmd); #else free(write_cmd); #endif } } void spi_send_data_multiple(spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint32_t *cmd_buff, size_t cmd_len, const uint8_t *tx_buff, size_t tx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); size_t index, fifo_len; spi_set_tmod(spi_num, SPI_TMOD_TRANS); volatile spi_t *spi_handle = spi[spi_num]; spi_handle->ssienr = 0x01; spi_handle->ser = 1U << chip_select; size_t v_cmd_len = cmd_len * 4; while(v_cmd_len) { fifo_len = 32 - spi_handle->txflr; fifo_len = fifo_len < v_cmd_len ? fifo_len : v_cmd_len; fifo_len = fifo_len / 4 * 4; for(index = 0; index < fifo_len / 4; index++) spi_handle->dr[0] = *cmd_buff++; v_cmd_len -= fifo_len; } spi_send_data_normal(spi_num, chip_select, tx_buff, tx_len); } void spi_send_data_multiple_dma(dmac_channel_number_t channel_num, spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint32_t *cmd_buff, size_t cmd_len, const uint8_t *tx_buff, size_t tx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); volatile spi_t *spi_handle = spi[spi_num]; uint8_t dfs_offset; switch(spi_num) { case 0: case 1: dfs_offset = 16; break; case 2: configASSERT(!"Spi Bus 2 Not Support!"); break; case 3: default: dfs_offset = 0; break; } uint32_t data_bit_length = (spi_handle->ctrlr0 >> dfs_offset) & 0x1F; spi_transfer_width_t frame_width = spi_get_frame_size(data_bit_length); uint32_t *buf; size_t v_send_len; int i; switch(frame_width) { case SPI_TRANS_INT: #if FIX_CACHE buf = iomem_malloc(cmd_len * sizeof(uint32_t) + tx_len); #else buf = malloc(cmd_len * sizeof(uint32_t) + tx_len); #endif for(i = 0; i < cmd_len; i++) buf[i] = cmd_buff[i]; for(i = 0; i < tx_len / 4; i++) buf[cmd_len + i] = ((uint32_t *)tx_buff)[i]; v_send_len = cmd_len + tx_len / 4; break; case SPI_TRANS_SHORT: #if FIX_CACHE buf = iomem_malloc(cmd_len * sizeof(uint32_t) + tx_len / 2 * sizeof(uint32_t)); #else buf = malloc(cmd_len * sizeof(uint32_t) + tx_len / 2 * sizeof(uint32_t)); #endif for(i = 0; i < cmd_len; i++) buf[i] = cmd_buff[i]; for(i = 0; i < tx_len / 2; i++) buf[cmd_len + i] = ((uint16_t *)tx_buff)[i]; v_send_len = cmd_len + tx_len / 2; break; default: #if FIX_CACHE buf = iomem_malloc((cmd_len + tx_len) * sizeof(uint32_t)); #else buf = malloc((cmd_len + tx_len) * sizeof(uint32_t)); #endif for(i = 0; i < cmd_len; i++) buf[i] = cmd_buff[i]; for(i = 0; i < tx_len; i++) buf[cmd_len + i] = tx_buff[i]; v_send_len = cmd_len + tx_len; break; } spi_send_data_normal_dma(channel_num, spi_num, chip_select, buf, v_send_len, SPI_TRANS_INT); #if FIX_CACHE iomem_free((void *)buf); #else free((void *)buf); #endif } void spi_fill_data_dma(dmac_channel_number_t channel_num, spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint32_t *tx_buff, size_t tx_len) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); spi_set_tmod(spi_num, SPI_TMOD_TRANS); volatile spi_t *spi_handle = spi[spi_num]; spi_handle->dmacr = 0x2; /*enable dma transmit*/ spi_handle->ssienr = 0x01; sysctl_dma_select((sysctl_dma_channel_t)channel_num, SYSCTL_DMA_SELECT_SSI0_TX_REQ + spi_num * 2); dmac_set_single_mode(channel_num, tx_buff, (void *)(&spi_handle->dr[0]), DMAC_ADDR_NOCHANGE, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_1, DMAC_TRANS_WIDTH_32, tx_len); spi_handle->ser = 1U << chip_select; dmac_wait_done(channel_num); while((spi_handle->sr & 0x05) != 0x04) ; spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; } static void spi_slave_idle_mode(void) { if(g_instance.is_dual) { fpioa_set_function(g_instance.mosi_pin, FUNC_SPI_SLAVE_D0); } volatile spi_t *spi_handle = spi[2]; g_instance.status = IDLE; spi_handle->ssienr = 0x00; spi_handle->ctrlr0 = (0x0 << g_instance.work_mode) | (0x1 << g_instance.slv_oe) | ((g_instance.data_bit_length - 1) << g_instance.dfs); spi_handle->dmacr = 0x00; spi_handle->ssienr = 0x01; gpiohs_set_pin(g_instance.ready_pin, GPIO_PV_HIGH); } static void spi_slave_command_mode(void) { volatile spi_t *spi_handle = spi[2]; uint8_t cmd_data[8], sum = 0; spi_transfer_width_t frame_width = spi_get_frame_size(g_instance.data_bit_length - 1); spi_device_num_t spi_num = SPI_DEVICE_2; switch(frame_width) { case SPI_TRANS_INT: for(uint32_t i = 0; i < 8 / 4; i++) ((uint32_t *)cmd_data)[i] = spi_handle->dr[0]; break; case SPI_TRANS_SHORT: for(uint32_t i = 0; i < 8 / 2; i++) ((uint16_t *)cmd_data)[i] = spi_handle->dr[0]; break; default: for(uint32_t i = 0; i < 8; i++) cmd_data[i] = spi_handle->dr[0]; break; } for(uint32_t i = 0; i < 7; i++) { sum += cmd_data[i]; } if(cmd_data[7] != sum) { spi_slave_idle_mode(); return; } g_instance.command.cmd = cmd_data[0]; g_instance.command.addr = cmd_data[1] | (cmd_data[2] << 8) | (cmd_data[3] << 16) | (cmd_data[4] << 24); g_instance.command.len = cmd_data[5] | (cmd_data[6] << 8); if(g_instance.command.len == 0) g_instance.command.len = 65536; if((g_instance.command.cmd < WRITE_DATA_BLOCK) && (g_instance.command.len > 8)) { spi_slave_idle_mode(); return; } g_instance.status = TRANSFER; spi_handle->ssienr = 0x00; if(g_instance.command.cmd == WRITE_CONFIG) { spi_handle->ctrlr0 = (0x0 << g_instance.work_mode) | (0x1 << g_instance.slv_oe) | ((g_instance.data_bit_length - 1) << g_instance.dfs); spi_handle->ssienr = 0x01; } else if(g_instance.command.cmd == READ_CONFIG) { if(g_instance.is_dual) { fpioa_set_function(g_instance.miso_pin, FUNC_SPI_SLAVE_D0); } spi_handle->ctrlr0 = (0x0 << g_instance.work_mode) | (0x0 << g_instance.slv_oe) | ((g_instance.data_bit_length - 1) << g_instance.dfs); spi_set_tmod(2, SPI_TMOD_TRANS); spi_handle->ssienr = 0x01; switch(frame_width) { case SPI_TRANS_INT: for(uint32_t i = 0; i < g_instance.command.len / 4; i++) { spi_handle->dr[0] = ((uint32_t *)&g_instance.config_ptr[g_instance.command.addr])[i]; } break; case SPI_TRANS_SHORT: for(uint32_t i = 0; i < g_instance.command.len / 2; i++) { spi_handle->dr[0] = ((uint16_t *)&g_instance.config_ptr[g_instance.command.addr])[i]; } break; default: for(uint32_t i = 0; i < g_instance.command.len; i++) { spi_handle->dr[0] = ((uint8_t *)&g_instance.config_ptr[g_instance.command.addr])[i]; } break; } } else if(g_instance.command.cmd == WRITE_DATA_BYTE) { spi_handle->ctrlr0 = (0x0 << g_instance.work_mode) | (0x1 << g_instance.slv_oe) | ((g_instance.data_bit_length - 1) << g_instance.dfs); spi_handle->ssienr = 0x01; } else if(g_instance.command.cmd == READ_DATA_BYTE) { if(g_instance.is_dual) { fpioa_set_function(g_instance.miso_pin, FUNC_SPI_SLAVE_D0); } spi_handle->ctrlr0 = (0x0 << g_instance.work_mode) | (0x0 << g_instance.slv_oe) | ((g_instance.data_bit_length - 1) << g_instance.dfs); spi_set_tmod(2, SPI_TMOD_TRANS); spi_handle->ssienr = 0x01; switch(frame_width) { case SPI_TRANS_INT: for(uint32_t i = 0; i < g_instance.command.len / 4; i++) { spi_handle->dr[0] = ((uint32_t *)(uintptr_t)g_instance.command.addr)[i]; } break; case SPI_TRANS_SHORT: for(uint32_t i = 0; i < g_instance.command.len / 2; i++) { spi_handle->dr[0] = ((uint16_t *)(uintptr_t)g_instance.command.addr)[i]; } break; default: for(uint32_t i = 0; i < g_instance.command.len; i++) { spi_handle->dr[0] = ((uint8_t *)(uintptr_t)g_instance.command.addr)[i]; } break; } } else if(g_instance.command.cmd == WRITE_DATA_BLOCK) { spi_handle->ctrlr0 = (0x0 << g_instance.work_mode) | (0x1 << g_instance.slv_oe) | ((32 - 1) << g_instance.dfs); spi_handle->dmacr = 0x01; spi_handle->ssienr = 0x01; sysctl_dma_select(g_instance.dmac_channel, SYSCTL_DMA_SELECT_SSI0_RX_REQ + spi_num * 2); dmac_set_single_mode(g_instance.dmac_channel, (void *)(&spi_handle->dr[0]), (void *)((uintptr_t)g_instance.command.addr & 0xFFFFFFF0), DMAC_ADDR_NOCHANGE, DMAC_ADDR_INCREMENT, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, g_instance.command.len * 4); } else if(g_instance.command.cmd == READ_DATA_BLOCK) { if(g_instance.is_dual) { fpioa_set_function(g_instance.miso_pin, FUNC_SPI_SLAVE_D0); } spi_handle->ctrlr0 = (0x0 << g_instance.work_mode) | (0x0 << g_instance.slv_oe) | ((32 - 1) << g_instance.dfs); spi_set_tmod(2, SPI_TMOD_TRANS); spi_handle->dmacr = 0x02; spi_handle->ssienr = 0x01; sysctl_dma_select(g_instance.dmac_channel, SYSCTL_DMA_SELECT_SSI0_TX_REQ + spi_num * 2); dmac_set_single_mode(g_instance.dmac_channel, (void *)((uintptr_t)g_instance.command.addr & 0xFFFFFFF0), (void *)(&spi_handle->dr[0]), DMAC_ADDR_INCREMENT, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, g_instance.command.len * 4); } else { spi_slave_idle_mode(); return; } gpiohs_set_pin(g_instance.ready_pin, GPIO_PV_LOW); } static void spi_slave_transfer_mode(void) { spi_transfer_width_t frame_width = spi_get_frame_size(g_instance.data_bit_length - 1); uint32_t command_len = 0; switch(frame_width) { case SPI_TRANS_INT: command_len = g_instance.command.len / 4; break; case SPI_TRANS_SHORT: command_len = g_instance.command.len / 2; break; default: command_len = g_instance.command.len; break; } volatile spi_t *spi_handle = spi[2]; g_instance.command.err = 0; if(g_instance.command.cmd == WRITE_CONFIG || g_instance.command.cmd == WRITE_DATA_BYTE) { if(spi_handle->rxflr < command_len - 1) g_instance.command.err = 1; } else if(g_instance.command.cmd == READ_CONFIG || g_instance.command.cmd == READ_DATA_BYTE) { if(spi_handle->txflr != 0) g_instance.command.err = 2; } else if(g_instance.command.cmd == WRITE_DATA_BLOCK || g_instance.command.cmd == READ_DATA_BLOCK) { if(dmac_is_done(g_instance.dmac_channel) == 0) { dmac_channel_disable(g_instance.dmac_channel); g_instance.command.err = 3; } dmac_wait_done(g_instance.dmac_channel); } else { spi_slave_idle_mode(); return; } if(g_instance.command.err == 0) { if(g_instance.command.cmd == WRITE_CONFIG) { switch(frame_width) { case SPI_TRANS_INT: for(uint32_t i = 0; i < command_len; i++) { ((uint32_t *)&g_instance.config_ptr[g_instance.command.addr])[i] = spi_handle->dr[0]; } break; case SPI_TRANS_SHORT: for(uint32_t i = 0; i < command_len; i++) { ((uint16_t *)&g_instance.config_ptr[g_instance.command.addr])[i] = spi_handle->dr[0]; } break; default: for(uint32_t i = 0; i < command_len; i++) { ((uint8_t *)&g_instance.config_ptr[g_instance.command.addr])[i] = spi_handle->dr[0]; } break; } } else if(g_instance.command.cmd == WRITE_DATA_BYTE) { switch(frame_width) { case SPI_TRANS_INT: for(uint32_t i = 0; i < command_len; i++) { ((uint32_t *)(uintptr_t)g_instance.command.addr)[i] = spi_handle->dr[0]; } break; case SPI_TRANS_SHORT: for(uint32_t i = 0; i < command_len; i++) { ((uint16_t *)(uintptr_t)g_instance.command.addr)[i] = spi_handle->dr[0]; } break; default: for(uint32_t i = 0; i < command_len; i++) { ((uint8_t *)(uintptr_t)g_instance.command.addr)[i] = spi_handle->dr[0]; } break; } } } if(g_instance.callback != NULL) { g_instance.callback((void *)&g_instance.command); } spi_slave_idle_mode(); } static void spi_slave_cs_irq(void) { volatile spi_t *spi_handle = spi[2]; if (g_instance.status == IDLE && spi_handle->rxflr == 8) g_instance.status = COMMAND; if(g_instance.status == IDLE) spi_slave_idle_mode(); else if(g_instance.status == COMMAND) spi_slave_command_mode(); else if(g_instance.status == TRANSFER) spi_slave_transfer_mode(); } void spi_slave_config(uint8_t int_pin, uint8_t ready_pin, dmac_channel_number_t dmac_channel, size_t data_bit_length, uint8_t *data, uint32_t len, spi_slave_receive_callback_t callback) { g_instance.status = IDLE; g_instance.config_ptr = data; g_instance.config_len = len; g_instance.work_mode = 6; g_instance.slv_oe = 10; g_instance.dfs = 16; g_instance.data_bit_length = data_bit_length; g_instance.ready_pin = ready_pin; g_instance.int_pin = int_pin; g_instance.callback = callback; g_instance.dmac_channel = dmac_channel; g_instance.is_dual = 0; sysctl_reset(SYSCTL_RESET_SPI2); sysctl_clock_enable(SYSCTL_CLOCK_SPI2); sysctl_clock_set_threshold(SYSCTL_THRESHOLD_SPI2, 0); uint32_t data_width = data_bit_length / 8; volatile spi_t *spi_handle = spi[2]; spi_handle->ssienr = 0x00; spi_handle->ctrlr0 = (0x0 << g_instance.work_mode) | (0x1 << g_instance.slv_oe) | ((data_bit_length - 1) << g_instance.dfs); spi_handle->dmatdlr = 0x04; spi_handle->dmardlr = 0x03; spi_handle->dmacr = 0x00; spi_handle->txftlr = 0x00; spi_handle->rxftlr = 0x08 / data_width - 1; spi_handle->imr = 0x00; spi_handle->ssienr = 0x01; gpiohs_set_drive_mode(g_instance.ready_pin, GPIO_DM_OUTPUT); gpiohs_set_pin(g_instance.ready_pin, GPIO_PV_HIGH); gpiohs_set_drive_mode(g_instance.int_pin, GPIO_DM_INPUT_PULL_UP); gpiohs_set_pin_edge(g_instance.int_pin, GPIO_PE_RISING); gpiohs_set_irq(g_instance.int_pin, 3, spi_slave_cs_irq); } void spi_slave_dual_config(uint8_t int_pin, uint8_t ready_pin, uint8_t mosi_pin, uint8_t miso_pin, dmac_channel_number_t dmac_channel, size_t data_bit_length, uint8_t *data, uint32_t len, spi_slave_receive_callback_t callback) { spi_slave_config(int_pin, ready_pin, dmac_channel, data_bit_length, data, len, callback); g_instance.is_dual = 1; g_instance.mosi_pin = mosi_pin; g_instance.miso_pin = miso_pin; } void spi_handle_data_dma(spi_device_num_t spi_num, spi_chip_select_t chip_select, spi_data_t data, plic_interrupt_t *cb) { configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2); configASSERT(chip_select < SPI_CHIP_SELECT_MAX); switch(data.transfer_mode) { case SPI_TMOD_TRANS_RECV: case SPI_TMOD_EEROM: configASSERT(data.tx_buf && data.tx_len && data.rx_buf && data.rx_len); break; case SPI_TMOD_TRANS: configASSERT(data.tx_buf && data.tx_len); break; case SPI_TMOD_RECV: configASSERT(data.rx_buf && data.rx_len); break; default: configASSERT(!"Transfer Mode ERR"); break; } configASSERT(data.tx_channel < DMAC_CHANNEL_MAX && data.rx_channel < DMAC_CHANNEL_MAX); volatile spi_t *spi_handle = spi[spi_num]; spinlock_lock(&g_spi_instance[spi_num].lock); if(cb) { g_spi_instance[spi_num].spi_int_instance.callback = cb->callback; g_spi_instance[spi_num].spi_int_instance.ctx = cb->ctx; } switch(data.transfer_mode) { case SPI_TMOD_RECV: spi_set_tmod(spi_num, SPI_TMOD_RECV); if(data.rx_len > 65536) data.rx_len = 65536; spi_handle->ctrlr1 = (uint32_t)(data.rx_len - 1); spi_handle->dmacr = 0x03; spi_handle->ssienr = 0x01; if(spi_get_frame_format(spi_num) == SPI_FF_STANDARD) spi_handle->dr[0] = 0xffffffff; if(cb) { dmac_irq_register(data.rx_channel, spi_dma_irq, &g_spi_instance[spi_num], cb->priority); g_spi_instance[spi_num].dmac_channel = data.rx_channel; } sysctl_dma_select((sysctl_dma_channel_t)data.rx_channel, SYSCTL_DMA_SELECT_SSI0_RX_REQ + spi_num * 2); dmac_set_single_mode(data.rx_channel, (void *)(&spi_handle->dr[0]), (void *)data.rx_buf, DMAC_ADDR_NOCHANGE, DMAC_ADDR_INCREMENT, DMAC_MSIZE_1, DMAC_TRANS_WIDTH_32, data.rx_len); spi_handle->ser = 1U << chip_select; if(!cb) dmac_wait_done(data.rx_channel); break; case SPI_TMOD_TRANS: spi_set_tmod(spi_num, SPI_TMOD_TRANS); spi_handle->dmacr = 0x2; /*enable dma transmit*/ spi_handle->ssienr = 0x01; if(cb) { dmac_irq_register(data.tx_channel, spi_dma_irq, &g_spi_instance[spi_num], cb->priority); g_spi_instance[spi_num].dmac_channel = data.tx_channel; } sysctl_dma_select(data.tx_channel, SYSCTL_DMA_SELECT_SSI0_TX_REQ + spi_num * 2); if(data.fill_mode) dmac_set_single_mode(data.tx_channel, data.tx_buf, (void *)(&spi_handle->dr[0]), DMAC_ADDR_NOCHANGE, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, data.tx_len); else dmac_set_single_mode(data.tx_channel, data.tx_buf, (void *)(&spi_handle->dr[0]), DMAC_ADDR_INCREMENT, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, data.tx_len); spi_handle->ser = 1U << chip_select; if(!cb) { dmac_wait_done(data.tx_channel); while((spi_handle->sr & 0x05) != 0x04) ; } break; case SPI_TMOD_EEROM: spi_set_tmod(spi_num, SPI_TMOD_EEROM); if(data.rx_len > 65536) data.rx_len = 65536; spi_handle->ctrlr1 = (uint32_t)(data.rx_len - 1); spi_handle->dmacr = 0x3; spi_handle->ssienr = 0x01; sysctl_dma_select(data.tx_channel, SYSCTL_DMA_SELECT_SSI0_TX_REQ + spi_num * 2); if(data.fill_mode) dmac_set_single_mode(data.tx_channel, data.tx_buf, (void *)(&spi_handle->dr[0]), DMAC_ADDR_NOCHANGE, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, data.tx_len); else dmac_set_single_mode(data.tx_channel, data.tx_buf, (void *)(&spi_handle->dr[0]), DMAC_ADDR_INCREMENT, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, data.tx_len); if(cb) { dmac_irq_register(data.rx_channel, spi_dma_irq, &g_spi_instance[spi_num], cb->priority); g_spi_instance[spi_num].dmac_channel = data.rx_channel; } sysctl_dma_select(data.rx_channel, SYSCTL_DMA_SELECT_SSI0_RX_REQ + spi_num * 2); dmac_set_single_mode(data.rx_channel, (void *)(&spi_handle->dr[0]), (void *)data.rx_buf, DMAC_ADDR_NOCHANGE, DMAC_ADDR_INCREMENT, DMAC_MSIZE_1, DMAC_TRANS_WIDTH_32, data.rx_len); spi_handle->ser = 1U << chip_select; if(!cb) { dmac_wait_done(data.tx_channel); dmac_wait_done(data.rx_channel); } break; case SPI_TMOD_TRANS_RECV: spi_set_tmod(spi_num, SPI_TMOD_TRANS_RECV); if(data.rx_len > 65536) data.rx_len = 65536; if(cb) { if(data.tx_len > data.rx_len) { dmac_irq_register(data.tx_channel, spi_dma_irq, &g_spi_instance[spi_num], cb->priority); g_spi_instance[spi_num].dmac_channel = data.tx_channel; } else { dmac_irq_register(data.rx_channel, spi_dma_irq, &g_spi_instance[spi_num], cb->priority); g_spi_instance[spi_num].dmac_channel = data.rx_channel; } } spi_handle->ctrlr1 = (uint32_t)(data.rx_len - 1); spi_handle->dmacr = 0x3; spi_handle->ssienr = 0x01; sysctl_dma_select(data.tx_channel, SYSCTL_DMA_SELECT_SSI0_TX_REQ + spi_num * 2); if(data.fill_mode) dmac_set_single_mode(data.tx_channel, data.tx_buf, (void *)(&spi_handle->dr[0]), DMAC_ADDR_NOCHANGE, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, data.tx_len); else dmac_set_single_mode(data.tx_channel, data.tx_buf, (void *)(&spi_handle->dr[0]), DMAC_ADDR_INCREMENT, DMAC_ADDR_NOCHANGE, DMAC_MSIZE_4, DMAC_TRANS_WIDTH_32, data.tx_len); sysctl_dma_select(data.rx_channel, SYSCTL_DMA_SELECT_SSI0_RX_REQ + spi_num * 2); dmac_set_single_mode(data.rx_channel, (void *)(&spi_handle->dr[0]), (void *)data.rx_buf, DMAC_ADDR_NOCHANGE, DMAC_ADDR_INCREMENT, DMAC_MSIZE_1, DMAC_TRANS_WIDTH_32, data.rx_len); spi_handle->ser = 1U << chip_select; if(!cb) { dmac_wait_done(data.tx_channel); dmac_wait_done(data.rx_channel); } break; } if(!cb) { spinlock_unlock(&g_spi_instance[spi_num].lock); spi_handle->ser = 0x00; spi_handle->ssienr = 0x00; } }
cff00b24cbf8545396b219797d65319c61f3ea9a
3059b388ef9bf2b7d81265f2a418bf3e360fb235
/SNESticle/Source/common/snspcbrr.c
387178257622e033ce23423ea669c0418324f5d4
[ "MIT" ]
permissive
iaddis/SNESticle
4486e560e3c8ee0d1d8993955f1394e0edc4b38f
9590ebf3bf768424ebd6cb018f322e724a7aade3
refs/heads/main
2023-09-03T13:19:59.494801
2022-01-13T07:59:38
2022-01-13T07:59:38
447,509,804
341
51
null
null
null
null
UTF-8
C
false
false
7,445
c
snspcbrr.c
#include "types.h" #include "snspcbrr.h" #include "prof.h" #define SNSPCBRR_CLAMP FALSE /* ldl t0 // load 16 nibbles ldr t0 // T0 = OPMN KLIJ GHEF CDAB pextlb t1,t0,r0 // t1 = OP00 MN00 KL00 IJ00 GH00 EF00 CD00 AB00 psllh t2,t1,4 // t2 = P000 N000 L000 J000 H000 F000 D000 B000 psrah t1,t1,12 // t1 = OOOO MMMM KKKK IIII GGGG EEEE CCCC AAAA psrah t2,t2,12 // t2 = PPPP NNNN LLLL JJJJ HHHH FFFF DDDD BBBB pcpyld t3,t2,t2 // t3 = HHHH FFFF DDDD BBBB HHHH FFFF DDDD BBBB pcpyud t4,t1,t1 // t4 = OOOO MMMM KKKK IIII OOOO MMMM KKKK IIII pinth t0,t3,t0 // t0 = HHHH GGGG FFFF EEEE DDDD CCCC BBBB AAAA pinth t2,t4,t2 // t2 = PPPP OOOO NNNN MMMM LLLL KKKK JJJJ IIII */ static Int32 _SNSpcDsp_FilterParm[4][2]= { {0x100 * 0 / 16, 0x100 * 0 / 16}, {0x100 * 15 / 16, 0x100 * 0 / 16}, {0x100 * 61 / 32, 0x100 * -15 / 16}, {0x100 * 115/ 64, 0x100 * -13 / 16} }; #if 0 typedef void (*SNSpcBRRDecodeFuncT)(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 iPrev0, Int32 iPrev1); static void _SNSpcBRRFilter(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 iPrev0, Int32 iPrev1); static void _SNSpcBRRFilter3(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 iPrev0, Int32 iPrev1); static void _SNSpcBRRFilter4(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 iPrev0, Int32 iPrev1); static void _SNSpcBRRFilter_9x(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 prev0, Int32 prev1); static SNSpcBRRDecodeFuncT _SNSpcBRR_pDecodeFunc = _SNSpcBRRFilter4 //_SNSpcBRRFilter4 //_SNSpcBRRFilter_9x ; #endif // // BRR decode // #include "console.h" #if 0 static void _SNSpcBRRFilter(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 iPrev0, Int32 iPrev1) { Int32 iFilter0, iFilter1; #if 1 //SNSPCBRR_CLAMP Int32 iMin = -0x8000; Int32 iMax = 0x7FFF; #endif iFilter0 = _SNSpcDsp_FilterParm[eFilterType][0]; iFilter1 = _SNSpcDsp_FilterParm[eFilterType][1]; while (nSamples > 0) { Int32 iSample; iSample = *pIn; iSample += ((iPrev0 * iFilter0 + iPrev1 * iFilter1) >> 8); // rotate sample queue iPrev1 = iPrev0; iPrev0 = iSample; iPrev0<<=16; iPrev0>>=16; // clamp sample to 16-bit range if (iSample > iMax) { iSample = iMax; } if (iSample < iMin) { iSample = iMin; } // ConDebug("%d %d\n", eFilterType, iSample); // write sample *pOut = iSample; pOut++; pIn++; nSamples--; } } #endif #if 0 static void _SNSpcBRRFilter_9x(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 prev0, Int32 prev1) { int i; Int32 sample1,sample2,out; eFilterType<<=2; for (i = 8; i != 0; i--) { int nybblesmp; sample1 = *pIn++; sample2 = *pIn++; for (nybblesmp = 0; nybblesmp<2; nybblesmp++) { out=(((nybblesmp) ? sample2 : sample1)); out >>= 1; switch(eFilterType) { case 0x00: // Method0 - [Smp] break; case 0x04: // Method1 - [Delta]+[Smp-1](15/16) out+=(prev0>>1)+((-prev0)>>5); break; case 0x08: // Method2 - [Delta]+[Smp-1](61/32)-[Smp-2](15/16) out+=(prev0)+((-(prev0 +(prev0>>1)))>>5)-(prev1>>1)+(prev1>>5); break; default: // Method3 - [Delta]+[Smp-1](115/64)-[Smp-2](13/16) out+=(prev0)+((-(prev0 + (prev0<<2) + (prev0<<3)))>>7)-(prev1>>1)+((prev1+(prev1>>1))>>4); break; // 115/128 * prev0 + -13/32 * prev1 } if (out > 32767) out = 32767; else if (out < -32768) out = -32768; *pOut++ = (signed short)(out<<1); prev1=(signed short)prev0; prev0=(signed short)(out<<1); } } } #endif #if 0 static void _SNSpcBRRFilter2(Int32 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 iPrev0, Int32 iPrev1) { Int32 iFilter0, iFilter1; Int32 iMin = -0x8000; Int32 iMax = 0x7FFF; iFilter0 = _SNSpcDsp_FilterParm[eFilterType][0]; iFilter1 = _SNSpcDsp_FilterParm[eFilterType][1]; while (nSamples > 0) { Int32 iSample; iSample = *pIn; iSample>>=1; iSample += ((iPrev0 * iFilter0)>>9) + ((iPrev1 * iFilter1) >> 9); // clamp sample to 16-bit range if (iSample > iMax) iSample = iMax; if (iSample < iMin) iSample = iMin; iSample<<=1; iSample<<=16; iSample>>=16; // write sample *pOut = iSample; // rotate sample queue iPrev1 = iPrev0; iPrev0 = iSample; pOut++; pIn++; nSamples--; } } #endif #if 4 static void _SNSpcBRRFilter3(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 iPrev0, Int32 iPrev1) { Int32 iFilter0, iFilter1; Int32 iMin = -0x8000; Int32 iMax = 0x7FFF; iFilter0 = _SNSpcDsp_FilterParm[eFilterType][0]; iFilter1 = _SNSpcDsp_FilterParm[eFilterType][1]; while (nSamples > 0) { Int32 iSample; iSample = *pIn; iSample>>=1; iSample += ((iPrev0 * iFilter0)>>9) + ((iPrev1 * iFilter1) >> 9); // clamp sample to 16-bit range if (iSample > iMax) iSample = iMax; if (iSample < iMin) iSample = iMin; iSample<<=1; // write sample *pOut = iSample; // rotate sample queue iPrev1 = iPrev0; iPrev0 = *pOut; pOut++; pIn++; nSamples--; } } #endif #if 0 static void _SNSpcBRRFilter4(Int16 *pOut, Int16 *pIn, Int32 nSamples, Int32 eFilterType, Int32 iPrev0, Int32 iPrev1) { Int32 iFilter0, iFilter1; Int32 iMin = -0x8000; Int32 iMax = 0x7FFF; iFilter0 = _SNSpcDsp_FilterParm[eFilterType][0]; iFilter1 = _SNSpcDsp_FilterParm[eFilterType][1]; while (nSamples > 0) { Int32 iSample; iSample = *pIn; iSample>>=1; iSample += ((iPrev0 * iFilter0)>>9) + ((iPrev1 * iFilter1) >> 9); // rotate sample queue iPrev1 = iPrev0; iPrev0 = iSample << 1; // clamp sample to 16-bit range if (iSample > iMax) iSample = iMax; if (iSample < iMin) iSample = iMin; iSample<<=1; // write sample *pOut = iSample; pOut++; pIn++; nSamples--; } } #endif Uint8 SNSpcBRRDecode(Uint8 *pBRRBlock, Int16 *pOut, Int32 iPrev0, Int32 iPrev1) { Uint8 uHeader; Uint32 uRange; Int16 Decode[16]; Int16 *pDecode; Int32 iByte; uHeader = *pBRRBlock++; uRange = uHeader >> 4; // adjust range if invalid if (uRange > 12) { uRange-=4; } // decode 16 samples to temp buffer pDecode = Decode; for (iByte=0; iByte< 8; iByte++) { Int32 iData = *pBRRBlock++; pDecode[0] = ((iData << 24) >> 28) << uRange; // upper nibble pDecode[1] = ((iData << 28) >> 28) << uRange; // lower nibble pDecode+=2; } // apply filter // _SNSpcBRR_pDecodeFunc(pOut, Decode, 16, (uHeader >> 2) & 3, iPrev0, iPrev1); // _SNSpcBRRFilter(pOut, Decode, 16, (uHeader >> 2) & 3, iPrev0, iPrev1); // _SNSpcBRRFilter_9x(pOut, Decode, 16, (uHeader >> 2) & 3, iPrev0, iPrev1); // _SNSpcBRRFilter2(pOut, Decode, 16, (uHeader >> 2) & 3, iPrev0, iPrev1); _SNSpcBRRFilter3(pOut, Decode, 16, (uHeader >> 2) & 3, iPrev0, iPrev1); // _SNSpcBRRFilter4(pOut, Decode, 16, (uHeader >> 2) & 3, iPrev0, iPrev1); // return end and loop bits return uHeader & 3; } void SNSpcBRRClear(Int16 *pOut, Int16 iPrev) { Int32 nSamples = 16; while (nSamples > 0) { pOut[0]=iPrev; pOut[1]=iPrev; pOut[2]=iPrev; pOut[3]=iPrev; pOut+=4; nSamples-=4; } }
bc3da911bd55c7d1d491e95bc7d5b0d977c42f79
1efb2283837c9b70bc6449cec877799e4efa3268
/test/mpi/ft/agree.c
a5800b65d1062b3d3d918441ea808c8c00d6f94e
[ "mpich2" ]
permissive
pmodels/mpich
d2392e8e30536cad3e500c16aa1e71211101d83f
2d265f9f5f93ebdd07ad547423bc6212868262a4
refs/heads/main
2023-09-04T05:50:15.041823
2023-09-01T23:07:33
2023-09-01T23:07:33
70,918,679
506
313
NOASSERTION
2023-09-14T14:38:36
2016-10-14T14:39:42
C
UTF-8
C
false
false
1,720
c
agree.c
/* * Copyright (C) by Argonne National Laboratory * See COPYRIGHT in top-level directory */ #include "mpi.h" #include <stdio.h> #include <stdlib.h> #include "mpitest.h" int main(int argc, char **argv) { int rank, size, rc, errclass, errs = 0; int flag = 1; MTest_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN); if (size < 4) { fprintf(stderr, "Must run with at least 4 processes\n"); MPI_Abort(MPI_COMM_WORLD, 1); } if (2 == rank) exit(EXIT_FAILURE); if (0 == rank) flag = 0; rc = MPIX_Comm_agree(MPI_COMM_WORLD, &flag); MPI_Error_class(rc, &errclass); if (errclass != MPIX_ERR_PROC_FAILED) { fprintf(stderr, "[%d] Expected MPIX_ERR_PROC_FAILED after agree. Received: %d\n", rank, errclass); MPI_Abort(MPI_COMM_WORLD, 1); errs++; } else if (0 != flag) { fprintf(stderr, "[%d] Expected flag to be 0. Received: %d\n", rank, flag); errs++; } MPIX_Comm_failure_ack(MPI_COMM_WORLD); if (0 == rank) flag = 0; else flag = 1; rc = MPIX_Comm_agree(MPI_COMM_WORLD, &flag); MPI_Error_class(rc, &errclass); if (MPI_SUCCESS != rc) { fprintf(stderr, "[%d] Expected MPI_SUCCESS after agree. Received: %d\n", rank, errclass); MPI_Abort(MPI_COMM_WORLD, 1); errs++; } else if (0 != flag) { fprintf(stderr, "[%d] Expected flag to be 0. Received: %d\n", rank, flag); MPI_Abort(MPI_COMM_WORLD, 1); errs++; } MTest_Finalize(errs); return MTestReturnValue(errs); }
150e85ea44e002d533d63019a7088f8fee9065d0
f1ee65fbe1ffc43c2aac45e41515f1987eb534a4
/src/third_party/nasm/misc/crcgen.c
f11e252fb592134ba93f8386b73ee82a49b0f2f6
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
klzgrad/naiveproxy
6e0d206b6f065b9311d1e12b363109f2d35cc058
8ef1cecadfd4e2b5d57e7ea2fa42d05717e51c2e
refs/heads/master
2023-08-20T22:42:12.511091
2023-06-04T03:54:34
2023-08-16T23:30:19
119,178,893
5,710
976
BSD-3-Clause
2023-08-05T10:59:59
2018-01-27T16:02:33
C++
UTF-8
C
false
false
1,077
c
crcgen.c
#include <inttypes.h> #include <stdio.h> int main(int argc, char *argv[]) { /* Polynomial in bit-reversed notation */ uint64_t poly; uint64_t crctab[256], v; int i, j; poly = strtoumax(argv[1], NULL, 0); printf("/* C */\n"); printf("static const uint64_t crc64_tab[256] = {\n"); for (i = 0; i < 256; i++) { v = i; for (j = 0; j < 8; j++) v = (v >> 1) ^ ((v & 1) ? poly : 0); crctab[i] = v; } for (i = 0; i < 256; i += 2) { printf(" /* %02x */ UINT64_C(0x%016"PRIx64"), " "UINT64_C(0x%016"PRIx64")%s\n", i, crctab[i], crctab[i+1], (i == 254) ? "" : ","); } printf("};\n\n"); printf("# perl\n"); printf("@crc64_tab = (\n"); for (i = 0; i < 256; i += 2) { printf(" [0x%08"PRIx32", 0x%08"PRIx32"], " "[0x%08"PRIx32", 0x%08"PRIx32"]%-1s # %02x\n", (uint32_t)(crctab[i] >> 32), (uint32_t)(crctab[i]), (uint32_t)(crctab[i+1] >> 32), (uint32_t)(crctab[i+1]), (i == 254) ? "" : ",", i); } printf(");\n"); return 0; }
2bb0191e614a954d1a86fa5ef2f0c3d34f76cbb4
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/x86/pci/pci_ranges.c
a11efb108f7f601ad6a91615fac276d1c9f32108
[]
no_license
NetBSD/src
1a9cbc22ed778be638b37869ed4fb5c8dd616166
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
refs/heads/trunk
2023-08-31T13:24:58.105962
2023-08-27T15:50:47
2023-08-27T15:50:47
88,439,547
656
348
null
2023-07-20T20:07:24
2017-04-16T20:03:43
null
UTF-8
C
false
false
27,647
c
pci_ranges.c
/* $NetBSD: pci_ranges.c,v 1.9 2021/06/21 03:01:23 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by David Young <dyoung@NetBSD.org>. * * 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. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> __KERNEL_RCSID(0, "$NetBSD: pci_ranges.c,v 1.9 2021/06/21 03:01:23 christos Exp $"); #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> #include <sys/errno.h> #include <sys/bus.h> #include <sys/kmem.h> #include <prop/proplib.h> #include <ppath/ppath.h> #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> #include <dev/pci/pccbbreg.h> #include <machine/autoconf.h> typedef enum pci_alloc_regtype { PCI_ALLOC_REGTYPE_NONE = 0 , PCI_ALLOC_REGTYPE_BAR = 1 , PCI_ALLOC_REGTYPE_WIN = 2 , PCI_ALLOC_REGTYPE_CBWIN = 3 , PCI_ALLOC_REGTYPE_VGA_EN = 4 } pci_alloc_regtype_t; typedef enum pci_alloc_space { PCI_ALLOC_SPACE_IO = 0 , PCI_ALLOC_SPACE_MEM = 1 } pci_alloc_space_t; typedef enum pci_alloc_flags { PCI_ALLOC_F_PREFETCHABLE = 0x1 } pci_alloc_flags_t; typedef struct pci_alloc { TAILQ_ENTRY(pci_alloc) pal_link; pcitag_t pal_tag; uint64_t pal_addr; uint64_t pal_size; pci_alloc_regtype_t pal_type; struct pci_alloc_reg { int r_ofs; pcireg_t r_val; pcireg_t r_mask; } pal_reg[3]; pci_alloc_space_t pal_space; pci_alloc_flags_t pal_flags; } pci_alloc_t; typedef struct pci_alloc_reg pci_alloc_reg_t; TAILQ_HEAD(pci_alloc_list, pci_alloc); typedef struct pci_alloc_list pci_alloc_list_t; static pci_alloc_t * pci_alloc_dup(const pci_alloc_t *pal) { pci_alloc_t *npal; npal = kmem_alloc(sizeof(*npal), KM_SLEEP); *npal = *pal; return npal; } static bool pci_alloc_linkdup(pci_alloc_list_t *pals, const pci_alloc_t *pal) { pci_alloc_t *npal; if ((npal = pci_alloc_dup(pal)) == NULL) return false; TAILQ_INSERT_TAIL(pals, npal, pal_link); return true; } struct range_infer_ctx { pci_chipset_tag_t ric_pc; pci_alloc_list_t ric_pals; bus_addr_t ric_mmio_bottom; bus_addr_t ric_mmio_top; bus_addr_t ric_io_bottom; bus_addr_t ric_io_top; }; static bool io_range_extend(struct range_infer_ctx *ric, const pci_alloc_t *pal) { if (ric->ric_io_bottom > pal->pal_addr) ric->ric_io_bottom = pal->pal_addr; if (ric->ric_io_top < pal->pal_addr + pal->pal_size) ric->ric_io_top = pal->pal_addr + pal->pal_size; return pci_alloc_linkdup(&ric->ric_pals, pal); } static bool io_range_extend_by_bar(struct range_infer_ctx *ric, int bus, int dev, int fun, int ofs, pcireg_t curbar, pcireg_t sizebar) { pci_alloc_reg_t *r; pci_alloc_t pal = { .pal_flags = 0 , .pal_space = PCI_ALLOC_SPACE_IO , .pal_type = PCI_ALLOC_REGTYPE_BAR , .pal_reg = {{ .r_mask = ~(pcireg_t)0 }} }; r = &pal.pal_reg[0]; pal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r->r_ofs = ofs; r->r_val = curbar; pal.pal_addr = PCI_MAPREG_IO_ADDR(curbar); pal.pal_size = PCI_MAPREG_IO_SIZE(sizebar); aprint_debug("%s: %d.%d.%d base at %" PRIx64 " size %" PRIx64 "\n", __func__, bus, dev, fun, pal.pal_addr, pal.pal_size); return (pal.pal_size == 0) || io_range_extend(ric, &pal); } static bool io_range_extend_by_vga_enable(struct range_infer_ctx *ric, int bus, int dev, int fun, pcireg_t csr, pcireg_t bcr) { pci_alloc_reg_t *r; pci_alloc_t tpal = { .pal_flags = 0 , .pal_space = PCI_ALLOC_SPACE_IO , .pal_type = PCI_ALLOC_REGTYPE_VGA_EN , .pal_reg = {{ .r_ofs = PCI_COMMAND_STATUS_REG , .r_mask = PCI_COMMAND_IO_ENABLE }, { .r_ofs = PCI_BRIDGE_CONTROL_REG , .r_mask = PCI_BRIDGE_CONTROL_VGA; }} }, pal[2]; aprint_debug("%s: %d.%d.%d enter\n", __func__, bus, dev, fun); if ((csr & PCI_COMMAND_IO_ENABLE) == 0 || (bcr & PCI_BRIDGE_CONTROL_VGA) == 0) { aprint_debug("%s: %d.%d.%d I/O or VGA disabled\n", __func__, bus, dev, fun); return true; } r = &tpal.pal_reg[0]; tpal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r[0].r_val = csr; r[1].r_val = bcr; pal[0] = pal[1] = tpal; pal[0].pal_addr = 0x3b0; pal[0].pal_size = 0x3bb - 0x3b0 + 1; pal[1].pal_addr = 0x3c0; pal[1].pal_size = 0x3df - 0x3c0 + 1; /* XXX add aliases for pal[0..1] */ return io_range_extend(ric, &pal[0]) && io_range_extend(ric, &pal[1]); } static bool io_range_extend_by_win(struct range_infer_ctx *ric, int bus, int dev, int fun, int ofs, int ofshigh, pcireg_t io, pcireg_t iohigh) { const int fourkb = 4 * 1024; pcireg_t baser, limitr; pci_alloc_reg_t *r; pci_alloc_t pal = { .pal_flags = 0 , .pal_space = PCI_ALLOC_SPACE_IO , .pal_type = PCI_ALLOC_REGTYPE_WIN , .pal_reg = {{ .r_mask = ~(pcireg_t)0 }} }; r = &pal.pal_reg[0]; pal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r[0].r_ofs = ofs; r[0].r_val = io; baser = __SHIFTOUT(io, PCI_BRIDGE_STATIO_IOBASE) >> 4; limitr = __SHIFTOUT(io, PCI_BRIDGE_STATIO_IOLIMIT) >> 4; if (PCI_BRIDGE_IO_32BITS(io)) { pcireg_t baseh, limith; r[1].r_mask = ~(pcireg_t)0; r[1].r_ofs = ofshigh; r[1].r_val = iohigh; baseh = __SHIFTOUT(iohigh, PCI_BRIDGE_IOHIGH_BASE); limith = __SHIFTOUT(iohigh, PCI_BRIDGE_IOHIGH_LIMIT); baser |= baseh << 4; limitr |= limith << 4; } /* XXX check with the PCI standard */ if (baser > limitr) return true; pal.pal_addr = baser * fourkb; pal.pal_size = (limitr - baser + 1) * fourkb; aprint_debug("%s: %d.%d.%d window at %" PRIx64 " size %" PRIx64 "\n", __func__, bus, dev, fun, pal.pal_addr, pal.pal_size); return io_range_extend(ric, &pal); } static bool io_range_extend_by_cbwin(struct range_infer_ctx *ric, int bus, int dev, int fun, int ofs, pcireg_t base0, pcireg_t limit0) { pcireg_t base, limit; pci_alloc_reg_t *r; pci_alloc_t pal = { .pal_flags = 0 , .pal_space = PCI_ALLOC_SPACE_IO , .pal_type = PCI_ALLOC_REGTYPE_CBWIN , .pal_reg = {{ .r_mask = ~(pcireg_t)0 }, { .r_mask = ~(pcireg_t)0 }} }; r = &pal.pal_reg[0]; pal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r[0].r_ofs = ofs; r[0].r_val = base0; r[1].r_ofs = ofs + 4; r[1].r_val = limit0; base = base0 & __BITS(31, 2); limit = limit0 & __BITS(31, 2); if (base > limit) return true; pal.pal_addr = base; pal.pal_size = limit - base + 4; /* XXX */ aprint_debug("%s: %d.%d.%d window at %" PRIx64 " size %" PRIx64 "\n", __func__, bus, dev, fun, pal.pal_addr, pal.pal_size); return io_range_extend(ric, &pal); } static void io_range_infer(pci_chipset_tag_t pc, pcitag_t tag, void *ctx) { struct range_infer_ctx *ric = ctx; pcireg_t bhlcr, limit, io; int bar, bus, dev, fun, hdrtype, nbar; bool ok = true; bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG); hdrtype = PCI_HDRTYPE_TYPE(bhlcr); pci_decompose_tag(pc, tag, &bus, &dev, &fun); switch (hdrtype) { case PCI_HDRTYPE_PPB: nbar = 2; /* Extract I/O windows */ ok = ok && io_range_extend_by_win(ric, bus, dev, fun, PCI_BRIDGE_STATIO_REG, PCI_BRIDGE_IOHIGH_REG, pci_conf_read(pc, tag, PCI_BRIDGE_STATIO_REG), pci_conf_read(pc, tag, PCI_BRIDGE_IOHIGH_REG)); ok = ok && io_range_extend_by_vga_enable(ric, bus, dev, fun, pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG), pci_conf_read(pc, tag, PCI_BRIDGE_CONTROL_REG)); break; case PCI_HDRTYPE_PCB: /* Extract I/O windows */ io = pci_conf_read(pc, tag, PCI_CB_IOBASE0); limit = pci_conf_read(pc, tag, PCI_CB_IOLIMIT0); ok = ok && io_range_extend_by_cbwin(ric, bus, dev, fun, PCI_CB_IOBASE0, io, limit); io = pci_conf_read(pc, tag, PCI_CB_IOBASE1); limit = pci_conf_read(pc, tag, PCI_CB_IOLIMIT1); ok = ok && io_range_extend_by_cbwin(ric, bus, dev, fun, PCI_CB_IOBASE1, io, limit); nbar = 1; break; case PCI_HDRTYPE_DEVICE: nbar = 6; break; default: aprint_debug("%s: unknown header type %d at %d.%d.%d\n", __func__, hdrtype, bus, dev, fun); return; } for (bar = 0; bar < nbar; bar++) { pcireg_t basebar, sizebar; basebar = pci_conf_read(pc, tag, PCI_BAR(bar)); pci_conf_write(pc, tag, PCI_BAR(bar), 0xffffffff); sizebar = pci_conf_read(pc, tag, PCI_BAR(bar)); pci_conf_write(pc, tag, PCI_BAR(bar), basebar); if (sizebar == 0) continue; if (PCI_MAPREG_TYPE(sizebar) != PCI_MAPREG_TYPE_IO) continue; ok = ok && io_range_extend_by_bar(ric, bus, dev, fun, PCI_BAR(bar), basebar, sizebar); } if (!ok) { aprint_verbose("I/O range inference failed at PCI %d.%d.%d\n", bus, dev, fun); } } static bool mmio_range_extend(struct range_infer_ctx *ric, const pci_alloc_t *pal) { if (ric->ric_mmio_bottom > pal->pal_addr) ric->ric_mmio_bottom = pal->pal_addr; if (ric->ric_mmio_top < pal->pal_addr + pal->pal_size) ric->ric_mmio_top = pal->pal_addr + pal->pal_size; return pci_alloc_linkdup(&ric->ric_pals, pal); } static bool mmio_range_extend_by_bar(struct range_infer_ctx *ric, int bus, int dev, int fun, int ofs, pcireg_t curbar, pcireg_t sizebar) { int type; bool prefetchable; pci_alloc_reg_t *r; pci_alloc_t pal = { .pal_flags = 0 , .pal_space = PCI_ALLOC_SPACE_MEM , .pal_type = PCI_ALLOC_REGTYPE_BAR , .pal_reg = {{ .r_mask = ~(pcireg_t)0 }} }; r = &pal.pal_reg[0]; pal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r->r_ofs = ofs; r->r_val = curbar; pal.pal_addr = PCI_MAPREG_MEM_ADDR(curbar); type = PCI_MAPREG_MEM_TYPE(curbar); prefetchable = PCI_MAPREG_MEM_PREFETCHABLE(curbar); if (prefetchable) pal.pal_flags |= PCI_ALLOC_F_PREFETCHABLE; switch (type) { case PCI_MAPREG_MEM_TYPE_32BIT: pal.pal_size = PCI_MAPREG_MEM_SIZE(sizebar); break; case PCI_MAPREG_MEM_TYPE_64BIT: pal.pal_size = PCI_MAPREG_MEM64_SIZE(sizebar); break; case PCI_MAPREG_MEM_TYPE_32BIT_1M: default: aprint_debug("%s: ignored memory type %d at %d.%d.%d\n", __func__, type, bus, dev, fun); return false; } aprint_debug("%s: %d.%d.%d base at %" PRIx64 " size %" PRIx64 "\n", __func__, bus, dev, fun, pal.pal_addr, pal.pal_size); return (pal.pal_size == 0) || mmio_range_extend(ric, &pal); } static bool mmio_range_extend_by_vga_enable(struct range_infer_ctx *ric, int bus, int dev, int fun, pcireg_t csr, pcireg_t bcr) { pci_alloc_reg_t *r; pci_alloc_t tpal = { .pal_flags = PCI_ALLOC_F_PREFETCHABLE /* XXX a guess */ , .pal_space = PCI_ALLOC_SPACE_MEM , .pal_type = PCI_ALLOC_REGTYPE_VGA_EN , .pal_reg = {{ .r_ofs = PCI_COMMAND_STATUS_REG , .r_mask = PCI_COMMAND_MEM_ENABLE }, { .r_ofs = PCI_BRIDGE_CONTROL_REG , .r_mask = PCI_BRIDGE_CONTROL_VGA }} }, pal; aprint_debug("%s: %d.%d.%d enter\n", __func__, bus, dev, fun); if ((csr & PCI_COMMAND_MEM_ENABLE) == 0 || (bcr & PCI_BRIDGE_CONTROL_VGA) == 0) { aprint_debug("%s: %d.%d.%d memory or VGA disabled\n", __func__, bus, dev, fun); return true; } r = &tpal.pal_reg[0]; tpal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r[0].r_val = csr; r[1].r_val = bcr; pal = tpal; pal.pal_addr = 0xa0000; pal.pal_size = 0xbffff - 0xa0000 + 1; return mmio_range_extend(ric, &pal); } static bool mmio_range_extend_by_win(struct range_infer_ctx *ric, int bus, int dev, int fun, int ofs, pcireg_t mem) { const int onemeg = 1024 * 1024; pcireg_t baser, limitr; pci_alloc_reg_t *r; pci_alloc_t pal = { .pal_flags = 0 , .pal_space = PCI_ALLOC_SPACE_MEM , .pal_type = PCI_ALLOC_REGTYPE_WIN , .pal_reg = {{ .r_mask = ~(pcireg_t)0 }} }; r = &pal.pal_reg[0]; pal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r->r_ofs = ofs; r->r_val = mem; baser = (mem >> PCI_BRIDGE_MEMORY_BASE_SHIFT) & PCI_BRIDGE_MEMORY_BASE_MASK; limitr = (mem >> PCI_BRIDGE_MEMORY_LIMIT_SHIFT) & PCI_BRIDGE_MEMORY_LIMIT_MASK; /* XXX check with the PCI standard */ if (baser > limitr || limitr == 0) return true; pal.pal_addr = baser * onemeg; pal.pal_size = (limitr - baser + 1) * onemeg; aprint_debug("%s: %d.%d.%d window at %" PRIx64 " size %" PRIx64 "\n", __func__, bus, dev, fun, pal.pal_addr, pal.pal_size); return mmio_range_extend(ric, &pal); } static bool mmio_range_extend_by_prememwin(struct range_infer_ctx *ric, int bus, int dev, int fun, int ofs, pcireg_t mem, int hibaseofs, pcireg_t hibase, int hilimitofs, pcireg_t hilimit) { const int onemeg = 1024 * 1024; uint64_t baser, limitr; pci_alloc_reg_t *r; pci_alloc_t pal = { .pal_flags = PCI_ALLOC_F_PREFETCHABLE , .pal_space = PCI_ALLOC_SPACE_MEM , .pal_type = PCI_ALLOC_REGTYPE_WIN , .pal_reg = {{ .r_mask = ~(pcireg_t)0 }} }; r = &pal.pal_reg[0]; pal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r[0].r_ofs = ofs; r[0].r_val = mem; baser = (mem >> PCI_BRIDGE_PREFETCHMEM_BASE_SHIFT) & PCI_BRIDGE_PREFETCHMEM_BASE_MASK; limitr = (mem >> PCI_BRIDGE_PREFETCHMEM_LIMIT_SHIFT) & PCI_BRIDGE_PREFETCHMEM_LIMIT_MASK; if (PCI_BRIDGE_PREFETCHMEM_64BITS(mem)) { r[1].r_mask = r[2].r_mask = ~(pcireg_t)0; r[1].r_ofs = hibaseofs; r[1].r_val = hibase; r[2].r_ofs = hilimitofs; r[2].r_val = hilimit; baser |= hibase << 12; limitr |= hibase << 12; } /* XXX check with the PCI standard */ if (baser > limitr || limitr == 0) return true; pal.pal_addr = baser * onemeg; pal.pal_size = (limitr - baser + 1) * onemeg; aprint_debug("%s: %d.%d.%d window at %" PRIx64 " size %" PRIx64 "\n", __func__, bus, dev, fun, pal.pal_addr, pal.pal_size); return mmio_range_extend(ric, &pal); } static bool mmio_range_extend_by_cbwin(struct range_infer_ctx *ric, int bus, int dev, int fun, int ofs, pcireg_t base, pcireg_t limit, bool prefetchable) { pci_alloc_reg_t *r; pci_alloc_t pal = { .pal_flags = 0 , .pal_space = PCI_ALLOC_SPACE_MEM , .pal_type = PCI_ALLOC_REGTYPE_CBWIN , .pal_reg = {{ .r_mask = ~(pcireg_t)0 }, { .r_mask = ~(pcireg_t)0 }} }; r = &pal.pal_reg[0]; if (prefetchable) pal.pal_flags |= PCI_ALLOC_F_PREFETCHABLE; pal.pal_tag = pci_make_tag(ric->ric_pc, bus, dev, fun); r[0].r_ofs = ofs; r[0].r_val = base; r[1].r_ofs = ofs + 4; r[1].r_val = limit; if (base > limit) return true; if (limit == 0) return true; pal.pal_addr = base; pal.pal_size = limit - base + 4096; aprint_debug("%s: %d.%d.%d window at %" PRIx64 " size %" PRIx64 "\n", __func__, bus, dev, fun, pal.pal_addr, pal.pal_size); return mmio_range_extend(ric, &pal); } static void mmio_range_infer(pci_chipset_tag_t pc, pcitag_t tag, void *ctx) { struct range_infer_ctx *ric = ctx; pcireg_t bcr, bhlcr, limit, mem, premem, hiprebase, hiprelimit; int bar, bus, dev, fun, hdrtype, nbar; bool ok = true; bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG); hdrtype = PCI_HDRTYPE_TYPE(bhlcr); pci_decompose_tag(pc, tag, &bus, &dev, &fun); switch (hdrtype) { case PCI_HDRTYPE_PPB: nbar = 2; /* Extract memory windows */ ok = ok && mmio_range_extend_by_win(ric, bus, dev, fun, PCI_BRIDGE_MEMORY_REG, pci_conf_read(pc, tag, PCI_BRIDGE_MEMORY_REG)); premem = pci_conf_read(pc, tag, PCI_BRIDGE_PREFETCHMEM_REG); if (PCI_BRIDGE_PREFETCHMEM_64BITS(premem)) { aprint_debug("%s: 64-bit prefetchable memory window " "at %d.%d.%d\n", __func__, bus, dev, fun); hiprebase = pci_conf_read(pc, tag, PCI_BRIDGE_PREFETCHBASE32_REG); hiprelimit = pci_conf_read(pc, tag, PCI_BRIDGE_PREFETCHLIMIT32_REG); } else hiprebase = hiprelimit = 0; ok = ok && mmio_range_extend_by_prememwin(ric, bus, dev, fun, PCI_BRIDGE_PREFETCHMEM_REG, premem, PCI_BRIDGE_PREFETCHBASE32_REG, hiprebase, PCI_BRIDGE_PREFETCHLIMIT32_REG, hiprelimit) && mmio_range_extend_by_vga_enable(ric, bus, dev, fun, pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG), pci_conf_read(pc, tag, PCI_BRIDGE_CONTROL_REG)); break; case PCI_HDRTYPE_PCB: /* Extract memory windows */ bcr = pci_conf_read(pc, tag, PCI_BRIDGE_CONTROL_REG); mem = pci_conf_read(pc, tag, PCI_CB_MEMBASE0); limit = pci_conf_read(pc, tag, PCI_CB_MEMLIMIT0); ok = ok && mmio_range_extend_by_cbwin(ric, bus, dev, fun, PCI_CB_MEMBASE0, mem, limit, (bcr & CB_BCR_PREFETCH_MEMWIN0) != 0); mem = pci_conf_read(pc, tag, PCI_CB_MEMBASE1); limit = pci_conf_read(pc, tag, PCI_CB_MEMLIMIT1); ok = ok && mmio_range_extend_by_cbwin(ric, bus, dev, fun, PCI_CB_MEMBASE1, mem, limit, (bcr & CB_BCR_PREFETCH_MEMWIN1) != 0); nbar = 1; break; case PCI_HDRTYPE_DEVICE: nbar = 6; break; default: aprint_debug("%s: unknown header type %d at %d.%d.%d\n", __func__, hdrtype, bus, dev, fun); return; } for (bar = 0; bar < nbar; bar++) { pcireg_t basebar, sizebar; basebar = pci_conf_read(pc, tag, PCI_BAR(bar)); pci_conf_write(pc, tag, PCI_BAR(bar), 0xffffffff); sizebar = pci_conf_read(pc, tag, PCI_BAR(bar)); pci_conf_write(pc, tag, PCI_BAR(bar), basebar); if (sizebar == 0) continue; if (PCI_MAPREG_TYPE(sizebar) != PCI_MAPREG_TYPE_MEM) continue; ok = ok && mmio_range_extend_by_bar(ric, bus, dev, fun, PCI_BAR(bar), basebar, sizebar); } if (!ok) { aprint_verbose("MMIO range inference failed at PCI %d.%d.%d\n", bus, dev, fun); } } static const char * pci_alloc_regtype_string(const pci_alloc_regtype_t t) { switch (t) { case PCI_ALLOC_REGTYPE_BAR: return "bar"; case PCI_ALLOC_REGTYPE_WIN: case PCI_ALLOC_REGTYPE_CBWIN: return "window"; case PCI_ALLOC_REGTYPE_VGA_EN: return "vga-enable"; default: return "<unknown>"; } } static void pci_alloc_print(pci_chipset_tag_t pc, const pci_alloc_t *pal) { int bus, dev, fun; const pci_alloc_reg_t *r; pci_decompose_tag(pc, pal->pal_tag, &bus, &dev, &fun); r = &pal->pal_reg[0]; aprint_normal("%s range [0x%08" PRIx64 ", 0x%08" PRIx64 ")" " at %d.%d.%d %s%s 0x%02x\n", (pal->pal_space == PCI_ALLOC_SPACE_IO) ? "IO" : "MMIO", pal->pal_addr, pal->pal_addr + pal->pal_size, bus, dev, fun, (pal->pal_flags & PCI_ALLOC_F_PREFETCHABLE) ? "prefetchable " : "", pci_alloc_regtype_string(pal->pal_type), r->r_ofs); } prop_dictionary_t pci_rsrc_dict = NULL; static bool pci_range_record(pci_chipset_tag_t pc, prop_array_t rsvns, pci_alloc_list_t *pals, pci_alloc_space_t space) { int bus, dev, fun, i; prop_array_t regs; prop_dictionary_t reg; const pci_alloc_t *pal; const pci_alloc_reg_t *r; prop_dictionary_t rsvn; TAILQ_FOREACH(pal, pals, pal_link) { bool ok = true; r = &pal->pal_reg[0]; if (pal->pal_space != space) continue; if ((rsvn = prop_dictionary_create()) == NULL) return false; if ((regs = prop_array_create()) == NULL) { prop_object_release(rsvn); return false; } if (!prop_dictionary_set(rsvn, "regs", regs)) { prop_object_release(rsvn); prop_object_release(regs); return false; } for (i = 0; i < __arraycount(pal->pal_reg); i++) { r = &pal->pal_reg[i]; if (r->r_mask == 0) break; ok = (reg = prop_dictionary_create()) != NULL; if (!ok) break; ok = prop_dictionary_set_uint16(reg, "offset", r->r_ofs) && prop_dictionary_set_uint32(reg, "val", r->r_val) && prop_dictionary_set_uint32(reg, "mask", r->r_mask) && prop_array_add(regs, reg); if (!ok) { prop_object_release(reg); break; } } pci_decompose_tag(pc, pal->pal_tag, &bus, &dev, &fun); ok = ok && prop_dictionary_set_string_nocopy(rsvn, "type", pci_alloc_regtype_string(pal->pal_type)) && prop_dictionary_set_uint64(rsvn, "address", pal->pal_addr) && prop_dictionary_set_uint64(rsvn, "size", pal->pal_size) && prop_dictionary_set_uint8(rsvn, "bus", bus) && prop_dictionary_set_uint8(rsvn, "device", dev) && prop_dictionary_set_uint8(rsvn, "function", fun) && prop_array_add(rsvns, rsvn); prop_object_release(rsvn); if (!ok) return false; } return true; } prop_dictionary_t pci_rsrc_filter(prop_dictionary_t rsrcs0, bool (*predicate)(void *, prop_dictionary_t), void *arg) { int i, space; prop_dictionary_t rsrcs; prop_array_t rsvns; ppath_t *op, *p; if ((rsrcs = prop_dictionary_copy(rsrcs0)) == NULL) return NULL; for (space = 0; space < 2; space++) { op = p = ppath_create(); p = ppath_push_key(p, (space == 0) ? "memory" : "io"); p = ppath_push_key(p, "bios-reservations"); if (p == NULL) { ppath_release(op); return NULL; } if ((rsvns = ppath_lookup(rsrcs0, p)) == NULL) { printf("%s: reservations not found\n", __func__); ppath_release(p); return NULL; } for (i = prop_array_count(rsvns); --i >= 0; ) { prop_dictionary_t rsvn; if ((p = ppath_push_idx(p, i)) == NULL) { printf("%s: ppath_push_idx\n", __func__); ppath_release(op); prop_object_release(rsrcs); return NULL; } rsvn = ppath_lookup(rsrcs0, p); KASSERT(rsvn != NULL); if (!(*predicate)(arg, rsvn)) { ppath_copydel_object((prop_object_t)rsrcs0, (prop_object_t *)&rsrcs, p); } if ((p = ppath_pop(p, NULL)) == NULL) { printf("%s: ppath_pop\n", __func__); ppath_release(p); prop_object_release(rsrcs); return NULL; } } ppath_release(op); } return rsrcs; } void pci_ranges_infer(pci_chipset_tag_t pc, int minbus, int maxbus, bus_addr_t *iobasep, bus_size_t *iosizep, bus_addr_t *membasep, bus_size_t *memsizep) { prop_dictionary_t iodict = NULL, memdict = NULL; prop_array_t iorsvns, memrsvns; struct range_infer_ctx ric = { .ric_io_bottom = ~((bus_addr_t)0) , .ric_io_top = 0 , .ric_mmio_bottom = ~((bus_addr_t)0) , .ric_mmio_top = 0 , .ric_pals = TAILQ_HEAD_INITIALIZER(ric.ric_pals) }; const pci_alloc_t *pal; ric.ric_pc = pc; pci_device_foreach_min(pc, minbus, maxbus, mmio_range_infer, &ric); pci_device_foreach_min(pc, minbus, maxbus, io_range_infer, &ric); if (membasep != NULL) *membasep = ric.ric_mmio_bottom; if (memsizep != NULL) *memsizep = ric.ric_mmio_top - ric.ric_mmio_bottom; if (iobasep != NULL) *iobasep = ric.ric_io_bottom; if (iosizep != NULL) *iosizep = ric.ric_io_top - ric.ric_io_bottom; aprint_verbose("%s: inferred %" PRIuMAX " bytes of memory-mapped PCI space at 0x%" PRIxMAX "\n", __func__, (uintmax_t)(ric.ric_mmio_top - ric.ric_mmio_bottom), (uintmax_t)ric.ric_mmio_bottom); aprint_verbose("%s: inferred %" PRIuMAX " bytes of PCI I/O space at 0x%" PRIxMAX "\n", __func__, (uintmax_t)(ric.ric_io_top - ric.ric_io_bottom), (uintmax_t)ric.ric_io_bottom); TAILQ_FOREACH(pal, &ric.ric_pals, pal_link) pci_alloc_print(pc, pal); if ((memdict = prop_dictionary_create()) == NULL) { aprint_error("%s: could not create PCI MMIO " "resources dictionary\n", __func__); } else if ((memrsvns = prop_array_create()) == NULL) { aprint_error("%s: could not create PCI BIOS memory " "reservations array\n", __func__); } else if (!prop_dictionary_set(memdict, "bios-reservations", memrsvns)) { aprint_error("%s: could not record PCI BIOS memory " "reservations array\n", __func__); } else if (!pci_range_record(pc, memrsvns, &ric.ric_pals, PCI_ALLOC_SPACE_MEM)) { aprint_error("%s: could not record PCI BIOS memory " "reservations\n", __func__); } else if (!prop_dictionary_set_uint64(memdict, "start", ric.ric_mmio_bottom) || !prop_dictionary_set_uint64(memdict, "size", ric.ric_mmio_top - ric.ric_mmio_bottom)) { aprint_error("%s: could not record PCI memory min & max\n", __func__); } else if ((iodict = prop_dictionary_create()) == NULL) { aprint_error("%s: could not create PCI I/O " "resources dictionary\n", __func__); } else if ((iorsvns = prop_array_create()) == NULL) { aprint_error("%s: could not create PCI BIOS I/O " "reservations array\n", __func__); } else if (!prop_dictionary_set(iodict, "bios-reservations", iorsvns)) { aprint_error("%s: could not record PCI BIOS I/O " "reservations array\n", __func__); } else if (!pci_range_record(pc, iorsvns, &ric.ric_pals, PCI_ALLOC_SPACE_IO)) { aprint_error("%s: could not record PCI BIOS I/O " "reservations\n", __func__); } else if (!prop_dictionary_set_uint64(iodict, "start", ric.ric_io_bottom) || !prop_dictionary_set_uint64(iodict, "size", ric.ric_io_top - ric.ric_io_bottom)) { aprint_error("%s: could not record PCI I/O min & max\n", __func__); } else if ((pci_rsrc_dict = prop_dictionary_create()) == NULL) { aprint_error("%s: could not create PCI resources dictionary\n", __func__); } else if (!prop_dictionary_set(pci_rsrc_dict, "memory", memdict) || !prop_dictionary_set(pci_rsrc_dict, "io", iodict)) { aprint_error("%s: could not record PCI memory- or I/O-" "resources dictionary\n", __func__); prop_object_release(pci_rsrc_dict); pci_rsrc_dict = NULL; } if (iodict != NULL) prop_object_release(iodict); if (memdict != NULL) prop_object_release(memdict); /* XXX release iorsvns, memrsvns */ } static bool pcibus_rsvn_predicate(void *arg, prop_dictionary_t rsvn) { struct pcibus_attach_args *pba = arg; uint8_t bus; if (!prop_dictionary_get_uint8(rsvn, "bus", &bus)) return false; return pba->pba_bus <= bus && bus <= pba->pba_sub; } static bool pci_rsvn_predicate(void *arg, prop_dictionary_t rsvn) { struct pci_attach_args *pa = arg; uint8_t bus, device, function; bool rc; rc = prop_dictionary_get_uint8(rsvn, "bus", &bus) && prop_dictionary_get_uint8(rsvn, "device", &device) && prop_dictionary_get_uint8(rsvn, "function", &function); if (!rc) return false; return pa->pa_bus == bus && pa->pa_device == device && pa->pa_function == function; } void device_pci_props_register(device_t dev, void *aux) { cfdata_t cf; prop_dictionary_t dict; cf = (device_parent(dev) != NULL) ? device_cfdata(dev) : NULL; #if 0 aprint_normal_dev(dev, "is%s a pci, parent %p, cf %p, ifattr %s\n", device_is_a(dev, "pci") ? "" : " not", device_parent(dev), cf, cf != NULL ? cfdata_ifattr(cf) : ""); #endif if (pci_rsrc_dict == NULL) return; if (!device_is_a(dev, "pci") && (cf == NULL || strcmp(cfdata_ifattr(cf), "pci") != 0)) return; dict = pci_rsrc_filter(pci_rsrc_dict, device_is_a(dev, "pci") ? &pcibus_rsvn_predicate : &pci_rsvn_predicate, aux); if (dict == NULL) return; (void)prop_dictionary_set(device_properties(dev), "pci-resources", dict); }
113f2053aaf8d05e45b6b720253344d46ba7ffde
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/include/configs/balloon3.h
2f5a6609b8e84ae73a3d0aa9568d73121815f5bb
[ "GPL-2.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
6,314
h
balloon3.h
/* * Balloon3 configuration file * * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com> * * SPDX-License-Identifier: GPL-2.0+ */ #ifndef __CONFIG_H #define __CONFIG_H /* * High Level Board Configuration Options */ #define CONFIG_CPU_PXA27X 1 /* Marvell PXA270 CPU */ #define CONFIG_BALLOON3 1 /* Balloon3 board */ /* * Environment settings */ #define CONFIG_ENV_OVERWRITE #define CONFIG_SYS_MALLOC_LEN (128*1024) #define CONFIG_ARCH_CPU_INIT #define CONFIG_BOOTCOMMAND \ "fpga load 0x0 0x50000 0x62638; " \ "if usb reset && fatload usb 0 0xa4000000 uImage; then " \ "bootm 0xa4000000; " \ "fi; " \ "bootm 0xd0000;" #define CONFIG_BOOTARGS "console=tty0 console=ttyS2,115200" #define CONFIG_TIMESTAMP #define CONFIG_BOOTDELAY 2 /* Autoboot delay */ #define CONFIG_CMDLINE_TAG #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_SYS_TEXT_BASE 0x0 #define CONFIG_LZMA /* LZMA compression support */ /* * Serial Console Configuration */ #define CONFIG_PXA_SERIAL #define CONFIG_STUART 1 #define CONFIG_CONS_INDEX 2 #define CONFIG_BAUDRATE 115200 /* * Bootloader Components Configuration */ #include <config_cmd_default.h> #undef CONFIG_CMD_NET #undef CONFIG_CMD_NFS #undef CONFIG_CMD_ENV #undef CONFIG_CMD_IMLS #define CONFIG_CMD_USB #define CONFIG_CMD_FPGA #define CONFIG_CMD_FPGA_LOADMK #undef CONFIG_LCD /* * KGDB */ #ifdef CONFIG_CMD_KGDB #define CONFIG_KGDB_BAUDRATE 230400 /* kgdb serial port speed */ #endif /* * HUSH Shell Configuration */ #define CONFIG_SYS_HUSH_PARSER 1 #define CONFIG_SYS_LONGHELP #ifdef CONFIG_SYS_HUSH_PARSER #define CONFIG_SYS_PROMPT "$ " #else #endif #define CONFIG_SYS_CBSIZE 256 #define CONFIG_SYS_PBSIZE \ (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) #define CONFIG_SYS_MAXARGS 16 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE #define CONFIG_SYS_DEVICE_NULLDEV 1 /* * Clock Configuration */ #undef CONFIG_SYS_CLKS_IN_HZ #define CONFIG_SYS_CPUSPEED 0x290 /* 520MHz */ /* * DRAM Map */ #define CONFIG_NR_DRAM_BANKS 3 /* 2 banks of DRAM */ #define PHYS_SDRAM_1 0xa0000000 /* SDRAM Bank #1 */ #define PHYS_SDRAM_1_SIZE 0x08000000 /* 128 MB */ #define PHYS_SDRAM_2 0xb0000000 /* SDRAM Bank #2 */ #define PHYS_SDRAM_2_SIZE 0x08000000 /* 128 MB */ #define PHYS_SDRAM_3 0x80000000 /* SDRAM Bank #2 */ #define PHYS_SDRAM_3_SIZE 0x08000000 /* 128 MB */ #define CONFIG_SYS_DRAM_BASE 0xa0000000 /* CS0 */ #define CONFIG_SYS_DRAM_SIZE 0x18000000 /* 384 MB DRAM */ #define CONFIG_SYS_MEMTEST_START 0xa0400000 /* memtest works on */ #define CONFIG_SYS_MEMTEST_END 0xa0800000 /* 4 ... 8 MB in DRAM */ #define CONFIG_SYS_LOAD_ADDR 0xa1000000 #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 #define CONFIG_SYS_INIT_SP_ADDR \ (PHYS_SDRAM_1 + GENERATED_GBL_DATA_SIZE + 2048) /* * NOR FLASH */ #ifdef CONFIG_CMD_FLASH #define PHYS_FLASH_1 0x00000000 /* Flash Bank #1 */ #define PHYS_FLASH_SIZE 0x00800000 /* 8 MB */ #define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1 #define CONFIG_SYS_FLASH_CFI #define CONFIG_FLASH_CFI_DRIVER 1 #define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT #define CONFIG_SYS_MAX_FLASH_BANKS 1 #define CONFIG_SYS_MAX_FLASH_SECT 256 #define CONFIG_SYS_FLASH_USE_BUFFER_WRITE 1 #define CONFIG_SYS_FLASH_ERASE_TOUT 240000 #define CONFIG_SYS_FLASH_WRITE_TOUT 240000 #define CONFIG_SYS_FLASH_LOCK_TOUT 240000 #define CONFIG_SYS_FLASH_UNLOCK_TOUT 240000 #define CONFIG_SYS_FLASH_PROTECTION #define CONFIG_ENV_IS_IN_FLASH #else #define CONFIG_SYS_NO_FLASH #define CONFIG_SYS_ENV_IS_NOWHERE #endif #define CONFIG_SYS_MONITOR_BASE 0x000000 #define CONFIG_SYS_MONITOR_LEN 0x40000 #define CONFIG_ENV_SIZE 0x2000 #define CONFIG_ENV_ADDR 0x40000 #define CONFIG_ENV_SECT_SIZE 0x10000 /* * GPIO settings */ #define CONFIG_SYS_GPSR0_VAL 0x307dc7fd #define CONFIG_SYS_GPSR1_VAL 0x03cffa4e #define CONFIG_SYS_GPSR2_VAL 0x7131c000 #define CONFIG_SYS_GPSR3_VAL 0x01e1f3ff #define CONFIG_SYS_GPCR0_VAL 0x0 #define CONFIG_SYS_GPCR1_VAL 0x0 #define CONFIG_SYS_GPCR2_VAL 0x0 #define CONFIG_SYS_GPCR3_VAL 0x0 #define CONFIG_SYS_GPDR0_VAL 0xc0f98e02 #define CONFIG_SYS_GPDR1_VAL 0xfcffa8b7 #define CONFIG_SYS_GPDR2_VAL 0x22e3ffff #define CONFIG_SYS_GPDR3_VAL 0x000201fe #define CONFIG_SYS_GAFR0_L_VAL 0x96c00000 #define CONFIG_SYS_GAFR0_U_VAL 0xa5e5459b #define CONFIG_SYS_GAFR1_L_VAL 0x699b759a #define CONFIG_SYS_GAFR1_U_VAL 0xaaa5a5aa #define CONFIG_SYS_GAFR2_L_VAL 0xaaaaaaaa #define CONFIG_SYS_GAFR2_U_VAL 0x01f9a6aa #define CONFIG_SYS_GAFR3_L_VAL 0x54510003 #define CONFIG_SYS_GAFR3_U_VAL 0x00001599 #define CONFIG_SYS_PSSR_VAL 0x30 /* * Clock settings */ #define CONFIG_SYS_CKEN 0xffffffff #define CONFIG_SYS_CCCR 0x00000290 /* * Memory settings */ #define CONFIG_SYS_MSC0_VAL 0x7ff07ff8 #define CONFIG_SYS_MSC1_VAL 0x7ff07ff0 #define CONFIG_SYS_MSC2_VAL 0x74a42491 #define CONFIG_SYS_MDCNFG_VAL 0x89d309d3 #define CONFIG_SYS_MDREFR_VAL 0x001d8018 #define CONFIG_SYS_MDMRS_VAL 0x00220022 #define CONFIG_SYS_FLYCNFG_VAL 0x00000000 #define CONFIG_SYS_SXCNFG_VAL 0x00000000 #define CONFIG_SYS_MEM_BUF_IMP 0x0f /* * PCMCIA and CF Interfaces */ #define CONFIG_SYS_MECR_VAL 0x00000000 #define CONFIG_SYS_MCMEM0_VAL 0x00014307 #define CONFIG_SYS_MCMEM1_VAL 0x00014307 #define CONFIG_SYS_MCATT0_VAL 0x0001c787 #define CONFIG_SYS_MCATT1_VAL 0x0001c787 #define CONFIG_SYS_MCIO0_VAL 0x0001430f #define CONFIG_SYS_MCIO1_VAL 0x0001430f /* * LCD */ #ifdef CONFIG_LCD #define CONFIG_BALLOON3LCD #define CONFIG_VIDEO_LOGO #define CONFIG_CMD_BMP #define CONFIG_SPLASH_SCREEN #define CONFIG_SPLASH_SCREEN_ALIGN #define CONFIG_VIDEO_BMP_GZIP #define CONFIG_VIDEO_BMP_RLE8 #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE (2 << 20) #endif /* * USB */ #ifdef CONFIG_CMD_USB #define CONFIG_USB_OHCI_NEW #define CONFIG_SYS_USB_OHCI_CPU_INIT #define CONFIG_SYS_USB_OHCI_BOARD_INIT #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 2 #define CONFIG_SYS_USB_OHCI_REGS_BASE 0x4C000000 #define CONFIG_SYS_USB_OHCI_SLOT_NAME "balloon3" #define CONFIG_USB_STORAGE #define CONFIG_DOS_PARTITION #define CONFIG_CMD_FAT #define CONFIG_CMD_EXT2 #endif /* * FPGA */ #ifdef CONFIG_CMD_FPGA #define CONFIG_FPGA #define CONFIG_FPGA_XILINX #define CONFIG_FPGA_SPARTAN3 #define CONFIG_SYS_FPGA_PROG_FEEDBACK #define CONFIG_SYS_FPGA_WAIT 1000 #define CONFIG_MAX_FPGA_DEVICES 1 #endif #endif /* __CONFIG_H */
58f760716fae2a9eb4666749c03ad7e41c7b0b6c
e20e26fcbbb172503a3abda73995c5b05ccda549
/kernel/common.c
d2e1878b498e1ddf4a3711b2417890d63ed5be49
[ "BSD-3-Clause", "BSD-2-Clause-Views" ]
permissive
viest/php-ext-xlswriter
13a76729c3f4d63a84cd6e7e2becb281e6a2efe9
cf7e1933a6566c6426d994c8a56880ce1c53793f
refs/heads/master
2023-08-20T05:56:13.134635
2023-05-15T06:18:42
2023-05-15T06:18:42
111,766,797
1,485
162
BSD-2-Clause
2023-05-14T22:07:37
2017-11-23T05:23:49
C
UTF-8
C
false
false
3,275
c
common.c
/* +----------------------------------------------------------------------+ | XlsWriter Extension | +----------------------------------------------------------------------+ | Copyright (c) 2017-2018 The Viest | +----------------------------------------------------------------------+ | http://www.viest.me | +----------------------------------------------------------------------+ | Author: viest <dev@service.viest.me> | +----------------------------------------------------------------------+ */ #include "xlswriter.h" /* {{{ */ void xls_file_path(zend_string *file_name, zval *dir_path, zval *file_path) { zend_string *full_path, *zstr_path; zstr_path = zval_get_string(dir_path); if (Z_STRVAL_P(dir_path)[Z_STRLEN_P(dir_path)-1] == '/') { full_path = zend_string_extend(zstr_path, ZSTR_LEN(zstr_path) + ZSTR_LEN(file_name), 0); memcpy(ZSTR_VAL(full_path)+ZSTR_LEN(zstr_path), ZSTR_VAL(file_name), ZSTR_LEN(file_name)+1); } else { full_path = zend_string_extend(zstr_path, ZSTR_LEN(zstr_path) + ZSTR_LEN(file_name) + 1, 0); ZSTR_VAL(full_path)[ZSTR_LEN(zstr_path)] ='/'; memcpy(ZSTR_VAL(full_path)+ZSTR_LEN(zstr_path)+1, ZSTR_VAL(file_name), ZSTR_LEN(file_name)+1); } ZVAL_STR(file_path, full_path); } /* }}} */ /* {{{ */ zend_string* str_pick_up(zend_string *left, const char *right, size_t len) { zend_string *full = NULL; size_t _left_length = ZSTR_LEN(left); size_t _extend_length = _left_length + len; full = zend_string_extend(left, _extend_length, 0); memcpy(ZSTR_VAL(full) + _left_length, right, len); ZSTR_VAL(full)[_extend_length] = '\0'; return full; } /* }}} */ /* {{{ */ zend_string* char_join_to_zend_str(const char *left, const char *right) { size_t _new_len = strlen(left) + strlen(right); zend_string *str = zend_string_alloc(_new_len, 0); memcpy(ZSTR_VAL(str), left, strlen(left)); memcpy(ZSTR_VAL(str) + strlen(left), right, strlen(right) + 1); ZSTR_VAL(str)[_new_len] = '\0'; return str; } /* }}} */ /* {{{ */ void call_object_method(zval *object, const char *function_name, uint32_t param_count, zval *params, zval *ret_val) { uint32_t index; zval z_f_name; ZVAL_STRINGL(&z_f_name, function_name, strlen(function_name)); call_user_function(NULL, object, &z_f_name, ret_val, param_count, params); if (Z_ISUNDEF_P(ret_val)) { ZVAL_NULL(ret_val); } for (index = 0; index < param_count; index++) { zval_ptr_dtor(&params[index]); } zval_ptr_dtor(&z_f_name); } /* }}} */ lxw_datetime timestamp_to_datetime(zend_long timestamp) { int yearLocal = php_idate('Y', timestamp, 0); int monthLocal = php_idate('m', timestamp, 0); int dayLocal = php_idate('d', timestamp, 0); int hourLocal = php_idate('H', timestamp, 0); int minuteLocal = php_idate('i', timestamp, 0); int secondLocal = php_idate('s', timestamp, 0); lxw_datetime datetime = { yearLocal, monthLocal, dayLocal, hourLocal, minuteLocal, secondLocal }; return datetime; }
4a599b7c3e7979f4ab4c85293768ffee9398ddd9
57bd259dfd03b06c452bc5ab7d17f0eb4b3fcc19
/rest-api-asr/c/common.c
daa879ca4e48b6a018158baf04a80aae23ce08a8
[]
no_license
Baidu-AIP/speech-demo
c701f70c3ad96702f7c14928afc6de008619dcde
3f45e1718c770faa9d1fb1575f2fe68450ae9782
refs/heads/master
2023-07-06T21:52:20.034358
2023-06-28T09:23:02
2023-06-28T09:23:02
122,720,114
712
876
null
2020-11-23T04:05:53
2018-02-24T08:28:09
Java
UTF-8
C
false
false
967
c
common.c
// // Created by fu on 3/2/18. // 定义常量 // #include <stdio.h> #include <memory.h> #include <stdlib.h> const int BUFFER_ERROR_SIZE = 1024; char g_demo_error_msg[1024] = {0}; // libcurl 返回回调 size_t writefunc(void *ptr, size_t size, size_t nmemb, char **result) { size_t result_len = size * nmemb; int is_new = (*result == NULL); if (is_new) { *result = (char *) malloc(result_len + 1); if (*result == NULL) { printf("realloc failure!\n"); return 1; } memcpy(*result, ptr, result_len); (*result)[result_len] = '\0'; } else { size_t old_size = strlen(*result); *result = (char *) realloc(*result, result_len + old_size); if (*result == NULL) { printf("realloc failure!\n"); return 1; } memcpy(*result + old_size, ptr, result_len); (*result)[result_len + old_size] = '\0'; } return result_len; }
44adece7a2d19c05db47edfe9ed7162272940971
89db60818afeb3dc7c3b7abe9ceae155f074f7f2
/src/libhttpd/fail.c
c65ddaaeb935ebb9385d63913beeb9792ba6fd97
[ "bzip2-1.0.6", "LPL-1.02", "MIT" ]
permissive
9fans/plan9port
63c3d01928c6f8a8617d3ea6ecc05bac72391132
65c090346a38a8c30cb242d345aa71060116340c
refs/heads/master
2023-08-25T17:14:26.233105
2023-08-23T13:21:37
2023-08-23T18:47:08
26,095,474
1,645
468
NOASSERTION
2023-09-05T16:55:41
2014-11-02T22:40:13
C
UTF-8
C
false
false
2,850
c
fail.c
#include <u.h> #include <libc.h> #include <bin.h> #include <httpd.h> typedef struct Error Error; struct Error { char *num; char *concise; char *verbose; }; Error errormsg[] = { /* HInternal */ {"500 Internal Error", "Internal Error", "This server could not process your request due to an internal error."}, /* HTempFail */ {"500 Internal Error", "Temporary Failure", "The object %s is currently inaccessible.<p>Please try again later."}, /* HUnimp */ {"501 Not implemented", "Command not implemented", "This server does not implement the %s command."}, /* HBadReq */ {"400 Bad Request", "Strange Request", "Your client sent a query that this server could not understand."}, /* HBadSearch */ {"400 Bad Request", "Inapplicable Search", "Your client sent a search that cannot be applied to %s."}, /* HNotFound */ {"404 Not Found", "Object not found", "The object %s does not exist on this server."}, /* HUnauth */ {"403 Forbidden", "Forbidden", "You are not allowed to see the object %s."}, /* HSyntax */ {"400 Bad Request", "Garbled Syntax", "Your client sent a query with incoherent syntax."}, /* HNoSearch */ {"403 Forbidden", "Search not supported", "The object %s does not support the search command."}, /* HNoData */ {"403 Forbidden", "No data supplied", "Search or forms data must be supplied to %s."}, /* HExpectFail */ {"403 Expectation Failed", "Expectation Failed", "This server does not support some of your request's expectations."}, /* HUnkVers */ {"501 Not Implemented", "Unknown http version", "This server does not know how to respond to http version %s."}, /* HBadCont */ {"501 Not Implemented", "Impossible format", "This server cannot produce %s in any of the formats your client accepts."}, /* HOK */ {"200 OK", "everything is fine"}, }; /* * write a failure message to the net and exit */ int hfail(HConnect *c, int reason, ...) { Hio *hout; char makeup[HBufSize]; va_list arg; int n; hout = &c->hout; va_start(arg, reason); vseprint(makeup, makeup+HBufSize, errormsg[reason].verbose, arg); va_end(arg); n = snprint(c->xferbuf, HBufSize, "<head><title>%s</title></head>\n<body><h1>%s</h1>\n%s</body>\n", errormsg[reason].concise, errormsg[reason].concise, makeup); hprint(hout, "%s %s\r\n", hversion, errormsg[reason].num); hprint(hout, "Date: %D\r\n", time(nil)); hprint(hout, "Server: Plan9\r\n"); hprint(hout, "Content-Type: text/html\r\n"); hprint(hout, "Content-Length: %d\r\n", n); if(c->head.closeit) hprint(hout, "Connection: close\r\n"); else if(!http11(c)) hprint(hout, "Connection: Keep-Alive\r\n"); hprint(hout, "\r\n"); if(c->req.meth == nil || strcmp(c->req.meth, "HEAD") != 0) hwrite(hout, c->xferbuf, n); if(c->replog) c->replog(c, "Reply: %s\nReason: %s\n", errormsg[reason].num, errormsg[reason].concise); return hflush(hout); }
323aef24c668c852c2de9d7389c51f003d60ba33
5eff7a36d9a9917dce9111f0c3074375fe6f7656
/app/xlockmore/modes/glx/b_lockglue.c
8c7459b10357d31fb1c298a7d12241542890ee81
[]
no_license
openbsd/xenocara
cb392d02ebba06f6ff7d826fd8a89aa3b8401779
a012b5de33ea0b977095d77316a521195b26cc6b
refs/heads/master
2023-08-25T12:16:58.862008
2023-08-12T16:16:25
2023-08-12T16:16:25
66,967,384
177
66
null
2023-07-22T18:12:37
2016-08-30T18:36:01
C
UTF-8
C
false
false
3,975
c
b_lockglue.c
#if !defined( lint ) && !defined( SABER ) static const char sccsid[] = "@(#)b_lockglue.c 5.01 2001/03/01 xlockmore"; #endif /*- * BUBBLE3D (C) 1998 Richard W.M. Jones. * b_lockglue.c: Glue to make this all work with xlockmore. * * Revision History: * 01-Mar-2001: Added FPS stuff - Eric Lassauge <lassauge AT users.sourceforge.net> * */ #include "bubble3d.h" /* XXX This lot should eventually be made configurable using the * options stuff below. */ struct glb_config glb_config = { #if GLB_SLOW_GL 2, /* subdivision_depth */ #else 3, /* subdivision_depth */ #endif 5, /* nr_nudge_axes */ 0.3, /* nudge_angle_factor */ 0.15, /* nudge_factor */ 0.1, /* rotation_factor */ 8, /* create_bubbles_every */ 8, /* max_bubbles */ {0.7, 0.8, 0.9, 1.0}, /* p_bubble_group */ 0.5, /* max_size */ 0.1, /* min_size */ 0.1, /* max_speed */ 0.03, /* min_speed */ 1.5, /* scale_factor */ -4, /* screen_bottom */ 4, /* screen_top */ #if 1 {0.1, 0.0, 0.4, 0.0}, /* bg_colour */ #else {0.0, 0.0, 0.0, 0.0}, /* bg_colour */ #endif #if 0 {0.7, 0.7, 0.0, 0.3} /* bubble_colour */ #else {0.0, 0.0, 0.7, 0.3} /* bubble_colour */ #endif }; #ifdef STANDALONE #define MODE_bubble3d #define PROGCLASS "Bubble3D" #define HACK_INIT init_bubble3d #define HACK_DRAW draw_bubble3d #define bubble3d_opts xlockmore_opts #define DEFAULTS "*delay: 20000 \n" #include "xlockmore.h" #else #include "xlock.h" #include "vis.h" #endif #ifdef MODE_bubble3d ModeSpecOpt bubble3d_opts = {0, (XrmOptionDescRec *) NULL, 0, (argtype *) NULL, (OptionStruct *) NULL}; #ifdef USE_MODULES ModStruct bubble3d_description = {(char *) "bubble3d", (char *) "init_bubble3d", (char *) "draw_bubble3d", (char *) "release_bubble3d", (char *) "draw_bubble3d", (char *) "change_bubble3d", (char *) NULL, &bubble3d_opts, 20000, 1, 1, 1, 64, 1.0, (char *) "", (char *) "Richard Jones's GL bubbles", 0, NULL}; #endif /* USE_MODULES */ struct context { GLXContext *glx_context; void *draw_context; }; static struct context *contexts = 0; static void init(struct context *c) { glb_sphere_init(); c->draw_context = glb_draw_init(); } static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (GLdouble) w / (GLdouble) h, 3, 8); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -5); } static void do_display(struct context *c) { glb_draw_step(c->draw_context); } void init_bubble3d(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); struct context *c; if (contexts == NULL) { if ((contexts = (struct context *) malloc(sizeof (struct context) * MI_NUM_SCREENS(mi))) == NULL) return; } c = &contexts[MI_SCREEN(mi)]; if ((c->glx_context = init_GL(mi)) != NULL) { init(c); reshape(MI_WIDTH(mi), MI_HEIGHT(mi)); do_display(c); glFinish(); glXSwapBuffers(display, window); } else MI_CLEARWINDOW(mi); } void draw_bubble3d(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); struct context *c; if (contexts == NULL) return; c = &contexts[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if (!c->glx_context) return; glDrawBuffer(GL_BACK); glXMakeCurrent(display, window, *(c->glx_context)); do_display(c); if (MI_IS_FPS(mi)) do_fps (mi); glFinish(); glXSwapBuffers(display, window); } void change_bubble3d(ModeInfo * mi) { /* nothing */ } void release_bubble3d(ModeInfo * mi) { if (contexts != NULL) { int screen; for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { struct context *c = &contexts[screen]; if (c->glx_context) { glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(c->glx_context)); if (c->draw_context) { glb_draw_end(c->draw_context); } } } free(contexts); contexts = (struct context *) NULL; } FreeAllGL(mi); } #endif /* MODE_bubble3d */
bf3e46dc9bdb1a64f144da3c379d3177a8e27538
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/shells/ksh93/files/patch-src_lib_libast_sfio_sfseek.c
41e5cd15271a6f6159a61f8f8af066d05a13d8f2
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
661
c
patch-src_lib_libast_sfio_sfseek.c
--- src/lib/libast/sfio/sfseek.c.orig 2020-02-08 10:39:38.000000000 -0800 +++ src/lib/libast/sfio/sfseek.c 2020-02-09 20:01:11.420655000 -0800 @@ -204,18 +204,9 @@ #ifdef MAP_TYPE if(f->bits&SF_MMAP) { /* if mmap is not great, stop mmaping if moving around too much */ -#if _mmap_worthy < 2 - if((f->next - f->data) < ((f->endb - f->data)/4) ) - { SFSETBUF(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND); - hardseek = 1; /* this forces a hard seek below */ - } - else -#endif - { /* for mmap, f->here can be virtual except for hardseek */ - newpos(f,p); - if(!hardseek) - goto done; - } + newpos(f,p); + if(!hardseek) + goto done; } #endif
a987c9a2c873529d11384242a17107eb76843af1
aefc47d59ab1ee8886e2ac4bbc9d4f5c36bde9c4
/seccomp_filter.h
f8208a7a16e32139d3203cd08b621ba47e862fed
[ "Apache-2.0" ]
permissive
NVIDIA/pyxis
4a401ddb1313b4c3a669dd121c4780775147bdd6
3b408d3d044a7cce4fc6bd7339afefe9010134e4
refs/heads/master
2023-09-01T05:50:30.219783
2023-08-21T16:39:00
2023-08-21T16:39:00
203,874,678
183
23
Apache-2.0
2023-01-28T00:58:35
2019-08-22T21:16:09
C
UTF-8
C
false
false
3,289
h
seccomp_filter.h
#ifdef __aarch64__ #define __ARCH_WANT_SYSCALL_NO_AT #endif #include <linux/audit.h> #include <linux/filter.h> #include <linux/seccomp.h> #include <sys/syscall.h> #include <elf.h> #include "common.h" #ifndef SECCOMP_FILTER_FLAG_SPEC_ALLOW # define SECCOMP_FILTER_FLAG_SPEC_ALLOW 4 #endif #ifndef AUDIT_ARCH_AARCH64 # define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) #endif /* * This seccomp filter is necessary to allow users to install packages inside the * container. Another common option is to assign each user a range of subordinate uids * and gids, but this can prove challenging to setup in a cluster environment with a * large number of users: * - it requires careful setup to avoid overlap between users on different machines * - it requires using setuid binaries newuidmap(1) and newgidmap(1) * - writing to a shared filesystem with a subordinate uid/gid can create surprising * results for the user. * This code was taken from enroot: https://github.com/NVIDIA/enroot/blob/77bb892ff1738fd65c2dfc437f82fb7d57888c0b/bin/enroot-nsenter.c#L93-L129 */ static struct sock_filter filter[] = { /* Check for the syscall architecture (x86_64 and aarch64 ABIs). */ BPF_STMT(BPF_LD|BPF_W|BPF_ABS, offsetof(struct seccomp_data, arch)), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, AUDIT_ARCH_X86_64, 3, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, AUDIT_ARCH_AARCH64, 2, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, AUDIT_ARCH_PPC64LE, 1, 0), /* FIXME We do not support x86, x32 and aarch32, allow all syscalls for now. */ BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), /* Load the syscall number. */ BPF_STMT(BPF_LD|BPF_W|BPF_ABS, offsetof(struct seccomp_data, nr)), /* Return success on all the following syscalls. */ #if defined(SYS_chown) && defined(SYS_lchown) BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_chown, 15, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_lchown, 14, 0), #endif BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setuid, 13, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setgid, 12, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setreuid, 11, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setregid, 10, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setresuid, 9, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setresgid, 8, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setgroups, 7, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_fchownat, 6, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_fchown, 5, 0), /* For setfsuid/setfsgid we only return success if the uid/gid argument is not -1. */ BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setfsuid, 1, 0), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, SYS_setfsgid, 0, 2), BPF_STMT(BPF_LD|BPF_W|BPF_ABS, offsetof(struct seccomp_data, args[0])), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, (uint32_t)-1, 0, 1), /* Execute the syscall as usual. */ BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), /* Return success. */ BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ERRNO|(SECCOMP_RET_DATA & 0x0)), }; static inline int seccomp_set_filter(void) { if ((int)syscall(SYS_seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_SPEC_ALLOW, &(const struct sock_fprog){ARRAY_SIZE(filter), filter}) == 0) return (0); else if (errno != EINVAL) return (-1); return syscall(SYS_seccomp, SECCOMP_SET_MODE_FILTER, 0, &(const struct sock_fprog){ARRAY_SIZE(filter), filter}); }
0c68a42fd55ba4411ec85713d0c3e5964bc9a302
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/VNL/src/vxl/v3p/netlib/lapack/complex16/zgecon.c
340f841e916675c7f0c531c2b241c14dc3a97191
[ "IJG", "Zlib", "LicenseRef-scancode-proprietary-license", "SMLNJ", "BSD-3-Clause", "BSD-4.3TAHOE", "LicenseRef-scancode-free-unknown", "Spencer-86", "LicenseRef-scancode-llnl", "FSFUL", "Libpng", "libtiff", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-hdf5", "MIT", "NTP", "LicenseRef-scancode-mit-old-style", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "MPL-2.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
InsightSoftwareConsortium/ITK
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
refs/heads/master
2023-08-31T17:21:47.754304
2023-08-31T00:58:51
2023-08-31T14:12:21
800,928
1,229
656
Apache-2.0
2023-09-14T17:54:00
2010-07-27T15:48:04
C++
UTF-8
C
false
false
10,157
c
zgecon.c
/* lapack/complex16/zgecon.f -- translated by f2c (version 20090411). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib; on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */ #ifdef __cplusplus extern "C" { #endif #include "v3p_netlib.h" /* Table of constant values */ static integer c__1 = 1; /*< >*/ /* Subroutine */ int zgecon_(char *norm, integer *n, doublecomplex *a, integer *lda, doublereal *anorm, doublereal *rcond, doublecomplex * work, doublereal *rwork, integer *info, ftnlen norm_len) { /* System generated locals */ integer a_dim1, a_offset, i__1; doublereal d__1, d__2; /* Builtin functions */ double d_imag(doublecomplex *); /* Local variables */ doublereal sl; integer ix; doublereal su; integer kase, kase1; doublereal scale; extern logical lsame_(const char *, const char *, ftnlen, ftnlen); integer isave[3]; extern /* Subroutine */ int zlacn2_(integer *, doublecomplex *, doublecomplex *, doublereal *, integer *, integer *); extern doublereal dlamch_(char *, ftnlen); extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); doublereal ainvnm; extern integer izamax_(integer *, doublecomplex *, integer *); logical onenrm; extern /* Subroutine */ int zdrscl_(integer *, doublereal *, doublecomplex *, integer *); char normin[1]; doublereal smlnum; extern /* Subroutine */ int zlatrs_(char *, char *, char *, char *, integer *, doublecomplex *, integer *, doublecomplex *, doublereal *, doublereal *, integer *, ftnlen, ftnlen, ftnlen, ftnlen); (void)norm_len; /* -- LAPACK routine (version 3.2) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* November 2006 */ /* Modified to call ZLACN2 in place of ZLACON, 10 Feb 03, SJH. */ /* .. Scalar Arguments .. */ /*< CHARACTER NORM >*/ /*< INTEGER INFO, LDA, N >*/ /*< DOUBLE PRECISION ANORM, RCOND >*/ /* .. */ /* .. Array Arguments .. */ /*< DOUBLE PRECISION RWORK( * ) >*/ /*< COMPLEX*16 A( LDA, * ), WORK( * ) >*/ /* .. */ /* Purpose */ /* ======= */ /* ZGECON estimates the reciprocal of the condition number of a general */ /* complex matrix A, in either the 1-norm or the infinity-norm, using */ /* the LU factorization computed by ZGETRF. */ /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */ /* condition number is computed as */ /* RCOND = 1 / ( norm(A) * norm(inv(A)) ). */ /* Arguments */ /* ========= */ /* NORM (input) CHARACTER*1 */ /* Specifies whether the 1-norm condition number or the */ /* infinity-norm condition number is required: */ /* = '1' or 'O': 1-norm; */ /* = 'I': Infinity-norm. */ /* N (input) INTEGER */ /* The order of the matrix A. N >= 0. */ /* A (input) COMPLEX*16 array, dimension (LDA,N) */ /* The factors L and U from the factorization A = P*L*U */ /* as computed by ZGETRF. */ /* LDA (input) INTEGER */ /* The leading dimension of the array A. LDA >= max(1,N). */ /* ANORM (input) DOUBLE PRECISION */ /* If NORM = '1' or 'O', the 1-norm of the original matrix A. */ /* If NORM = 'I', the infinity-norm of the original matrix A. */ /* RCOND (output) DOUBLE PRECISION */ /* The reciprocal of the condition number of the matrix A, */ /* computed as RCOND = 1/(norm(A) * norm(inv(A))). */ /* WORK (workspace) COMPLEX*16 array, dimension (2*N) */ /* RWORK (workspace) DOUBLE PRECISION array, dimension (2*N) */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* < 0: if INFO = -i, the i-th argument had an illegal value */ /* ===================================================================== */ /* .. Parameters .. */ /*< DOUBLE PRECISION ONE, ZERO >*/ /*< PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) >*/ /* .. */ /* .. Local Scalars .. */ /*< LOGICAL ONENRM >*/ /*< CHARACTER NORMIN >*/ /*< INTEGER IX, KASE, KASE1 >*/ /*< DOUBLE PRECISION AINVNM, SCALE, SL, SMLNUM, SU >*/ /*< COMPLEX*16 ZDUM >*/ /* .. */ /* .. Local Arrays .. */ /*< INTEGER ISAVE( 3 ) >*/ /* .. */ /* .. External Functions .. */ /*< LOGICAL LSAME >*/ /*< INTEGER IZAMAX >*/ /*< DOUBLE PRECISION DLAMCH >*/ /*< EXTERNAL LSAME, IZAMAX, DLAMCH >*/ /* .. */ /* .. External Subroutines .. */ /*< EXTERNAL XERBLA, ZDRSCL, ZLACN2, ZLATRS >*/ /* .. */ /* .. Intrinsic Functions .. */ /*< INTRINSIC ABS, DBLE, DIMAG, MAX >*/ /* .. */ /* .. Statement Functions .. */ /*< DOUBLE PRECISION CABS1 >*/ /* .. */ /* .. Statement Function definitions .. */ /*< CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) ) >*/ /* .. */ /* .. Executable Statements .. */ /* Test the input parameters. */ /*< INFO = 0 >*/ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --work; --rwork; /* Function Body */ *info = 0; /*< ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' ) >*/ onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O", (ftnlen)1, ( ftnlen)1); /*< IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN >*/ if (! onenrm && ! lsame_(norm, "I", (ftnlen)1, (ftnlen)1)) { /*< INFO = -1 >*/ *info = -1; /*< ELSE IF( N.LT.0 ) THEN >*/ } else if (*n < 0) { /*< INFO = -2 >*/ *info = -2; /*< ELSE IF( LDA.LT.MAX( 1, N ) ) THEN >*/ } else if (*lda < max(1,*n)) { /*< INFO = -4 >*/ *info = -4; /*< ELSE IF( ANORM.LT.ZERO ) THEN >*/ } else if (*anorm < 0.) { /*< INFO = -5 >*/ *info = -5; /*< END IF >*/ } /*< IF( INFO.NE.0 ) THEN >*/ if (*info != 0) { /*< CALL XERBLA( 'ZGECON', -INFO ) >*/ i__1 = -(*info); xerbla_("ZGECON", &i__1, (ftnlen)6); /*< RETURN >*/ return 0; /*< END IF >*/ } /* Quick return if possible */ /*< RCOND = ZERO >*/ *rcond = 0.; /*< IF( N.EQ.0 ) THEN >*/ if (*n == 0) { /*< RCOND = ONE >*/ *rcond = 1.; /*< RETURN >*/ return 0; /*< ELSE IF( ANORM.EQ.ZERO ) THEN >*/ } else if (*anorm == 0.) { /*< RETURN >*/ return 0; /*< END IF >*/ } /*< SMLNUM = DLAMCH( 'Safe minimum' ) >*/ smlnum = dlamch_("Safe minimum", (ftnlen)12); /* Estimate the norm of inv(A). */ /*< AINVNM = ZERO >*/ ainvnm = 0.; /*< NORMIN = 'N' >*/ *(unsigned char *)normin = 'N'; /*< IF( ONENRM ) THEN >*/ if (onenrm) { /*< KASE1 = 1 >*/ kase1 = 1; /*< ELSE >*/ } else { /*< KASE1 = 2 >*/ kase1 = 2; /*< END IF >*/ } /*< KASE = 0 >*/ kase = 0; /*< 10 CONTINUE >*/ L10: /*< CALL ZLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE ) >*/ zlacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave); /*< IF( KASE.NE.0 ) THEN >*/ if (kase != 0) { /*< IF( KASE.EQ.KASE1 ) THEN >*/ if (kase == kase1) { /* Multiply by inv(L). */ /*< >*/ zlatrs_("Lower", "No transpose", "Unit", normin, n, &a[a_offset], lda, &work[1], &sl, &rwork[1], info, (ftnlen)5, (ftnlen) 12, (ftnlen)4, (ftnlen)1); /* Multiply by inv(U). */ /*< >*/ zlatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[ a_offset], lda, &work[1], &su, &rwork[*n + 1], info, ( ftnlen)5, (ftnlen)12, (ftnlen)8, (ftnlen)1); /*< ELSE >*/ } else { /* Multiply by inv(U'). */ /*< >*/ zlatrs_("Upper", "Conjugate transpose", "Non-unit", normin, n, &a[ a_offset], lda, &work[1], &su, &rwork[*n + 1], info, ( ftnlen)5, (ftnlen)19, (ftnlen)8, (ftnlen)1); /* Multiply by inv(L'). */ /*< >*/ zlatrs_("Lower", "Conjugate transpose", "Unit", normin, n, &a[ a_offset], lda, &work[1], &sl, &rwork[1], info, (ftnlen)5, (ftnlen)19, (ftnlen)4, (ftnlen)1); /*< END IF >*/ } /* Divide X by 1/(SL*SU) if doing so will not cause overflow. */ /*< SCALE = SL*SU >*/ scale = sl * su; /*< NORMIN = 'Y' >*/ *(unsigned char *)normin = 'Y'; /*< IF( SCALE.NE.ONE ) THEN >*/ if (scale != 1.) { /*< IX = IZAMAX( N, WORK, 1 ) >*/ ix = izamax_(n, &work[1], &c__1); /*< >*/ i__1 = ix; if (scale < ((d__1 = work[i__1].r, abs(d__1)) + (d__2 = d_imag(& work[ix]), abs(d__2))) * smlnum || scale == 0.) { goto L20; } /*< CALL ZDRSCL( N, SCALE, WORK, 1 ) >*/ zdrscl_(n, &scale, &work[1], &c__1); /*< END IF >*/ } /*< GO TO 10 >*/ goto L10; /*< END IF >*/ } /* Compute the estimate of the reciprocal condition number. */ /*< >*/ if (ainvnm != 0.) { *rcond = 1. / ainvnm / *anorm; } /*< 20 CONTINUE >*/ L20: /*< RETURN >*/ return 0; /* End of ZGECON */ /*< END >*/ } /* zgecon_ */ #ifdef __cplusplus } #endif
7541e756cbb630719579d86f0458ea6a4169d6dd
7c08121239dd6143e33b07a566a4300e45584a80
/Processor/Project/Vivado/TargetBoards/Zedboard/project_src/run_simple.c
8f2efb156426df38e71e8124937d24955bd6d944
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
rsd-devel/rsd
15f1a0f3a37af25f0fe4125144efb77aa097b625
bc874fc450c04ccf85ab6a3a93469582f01e5ce4
refs/heads/master
2023-08-03T11:31:30.378769
2023-04-05T16:05:28
2023-04-05T16:05:28
227,267,635
838
83
Apache-2.0
2023-07-27T08:16:57
2019-12-11T03:22:54
SystemVerilog
UTF-8
C
false
false
149,644
c
run_simple.c
#include <stdio.h> #include <stdlib.h> #include "platform.h" #include "xil_printf.h" #include "xil_cache_l.h" // PSからRSDに送るプログラムのワード数(メモリの1エントリ単位) #define PROGRAM_WORDSIZE (65536/16) // RSDのメモリ1エントリあたりのバイト数 #define MEMORY_WORD_BYTE_SIZE 16 // AXIバスのバイト幅 #define AXI_WORD_BYTE_SIZE 4 // 注意: このプログラムはMEMORY_WORD_BYTE_SIZEがAXI_WORD_BYTE_SIZEで割り切れないと正しく動作しない // RSDの1ワード(AXIバスの1ワード単位)を16進数で表現する場合の文字数 #define AXI_WORD_CHAR_SIZE AXI_WORD_BYTE_SIZE*2 // PSからRSDに送るプログラムの文字数(programinit関数内に記述したプログラムの文字数) #define PROGRAM_CHARSIZE PROGRAM_WORDSIZE*MEMORY_WORD_BYTE_SIZE*2 // ------------------------------------------------ // PS -> PL のメモリマップドレジスタの各データに対応するオフセット // PLから対応するデータを受け取る際に使用する // PL内のデータ受け取り用FIFOのFULL信号 #define S2L_FULL_OFFSET 0 // 現在PLが受け取ったワード数(メモリの1エントリ単位) #define S2L_MEMORY_WORDCOUNT_OFFSET 3 // PL内のデータ受け取り用FIFOのEMPTY信号 (普段は使わない) #define S2L_EMPTY_OFFSET 4 // デバッグ用.普段は使わない. #define S2L_POPED_DATACOUNT_OFFSET 5 // ------------------------------------------------ // PS -> PL のメモリマップドレジスタの各データに対応するオフセット // PSからPLに対応するデータを送る際に使用する // このオフセットに書き込むとPL内のデータ受け取り用FIFOにプッシュされる #define S2L_PUSHED_DATA_OFFSET 0 // プッシュされたデータを書き込むRSDのメインメモリ上のアドレスをこのオフセットに書き込む // Byteアドレスであることに注意 #define S2L_MEMORY_ADDR_OFFSET 1 // このオフセットにPSからPLに送信するプログラムのデータサイズをメモリの1エントリ単位のワード数で書き込む #define S2L_PROGRAM_WORDSIZE_OFFSET 2 // 0 を書きこむと RSD にリセットがかかり続けるので,その間にプログラムをロード // ロードし終わったら 1 を書き込んで実行を開始 #define S2L_DONE_OFFSET 6 // ------------------------------------------------ // PL -> PS のメモリマップドレジスタの各データに対応するオフセット // PSがPL(RSD)から対応するデータを受け取る際に使用する // PLからのデータを一時的に保存するFIFOのEMPTY信号 #define L2S_EMPTY_OFFSET 0 // PLからのデータを一時的に保存するFIFOの先頭にあるデータ // このオフセットからデータを読むと,自動的にPOPもされたことになる #define L2S_DATA_OFFSET 1 // 最後にコミットした命令の PC #define L2S_LAST_COMMITTED_PC 4 // 最後にコミットした命令の PC #define L2S_COMMITTED_INSN_COUNT 5 // ------------------------------------------------ char *prog; void programinit(); int main() { init_platform(); printf("-- Initialization started\n"); // S2L registerとL2S registerを配列に定義 // TODO: 本当はxparameters.hの中でdefineされた値を指定すべき // だが現状バグってて使えないので直接数値で指定 // L2S volatile int *rsd_pl2ps = 0x43C00000; // S2L volatile int *rsd_ps2pl = 0x43C10000; // volatile int *mem = 0x10000000; // volatile char *memchar = 0x10000000; // volatile int *memout = 0x10030000; rsd_ps2pl[S2L_DONE_OFFSET] = 0; // 送信したいプログラムを初期化 programinit(); // プログラムの1文字 char rc; // プログラムの1ワード(AXIバスの1ワード単位) char val[AXI_WORD_CHAR_SIZE+2]; // valは必ず"0x????????"となる val[0] = '0'; val[1] = 'x'; char *endptr; unsigned long x; int i = 2; int j = 0; int k = 3; int sendword = 0; int offset = 0; int t = 0; for (t = 0; t < PROGRAM_WORDSIZE*MEMORY_WORD_BYTE_SIZE; t++) { mem[t] = 0; } for (;;) { // プログラムの全データの送信が終わったらbreak if (j == PROGRAM_CHARSIZE) { break; } rc = prog[j]; j++; val[i] = rc; // valに1ワード(AXIバスの1ワード単位)が格納されたら送信する if(i==(AXI_WORD_CHAR_SIZE+1)) { i = 2; x = strtoul(val, &endptr, 16); mem[offset+k] = x; if (k == 0) { k = 3; offset += 4; } else { k--; } } else { i++; } } // printf("offset:%0x\n", offset); // for (t=0;t<100;t++) { // printf("%x\n", memchar[t]); // } Xil_L1DCacheFlush(); Xil_L2CacheFlush(); rsd_ps2pl[S2L_DONE_OFFSET] = 1; t = 0; int u = 0; printf("-- Initialization completed\n"); // プログラムの転送が終わったら,PL(RSD)からの出力をポーリングして表示する // TODO: 無限ループになっているので,ある特定の出力を受け取ったら終了するとかをしてもいいかもしれない while(1) { // PLからのデータが入っているFIFOが空でなかったらPOPして表示 if (rsd_pl2ps[L2S_EMPTY_OFFSET] != 1) { //printf ("%08x\n", rsd_pl2ps[L2S_DATA_OFFSET]); printf("%c", rsd_pl2ps[L2S_DATA_OFFSET]); } // 定期的に PC を表示 if (t == 10000000) { t = 0; printf("PC: %08x, ", rsd_pl2ps[L2S_LAST_COMMITTED_PC]); printf("Committed instructions: %d\n", rsd_pl2ps[L2S_COMMITTED_INSN_COUNT]); u++; if (u == 10) { break; } } else { t++; } } //for (u=0;u<100;u++) { // printf("%08x\n", memout[u]); //} cleanup_platform(); return 0; } void programinit() { // code.hexの中身をここに配置する // 以下のコードは Hello World prog = "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "ff9ff06f535000ef0000006f0100006f" "80020137305510730985051300000517" "00000193000001130000009319d000ef" "00000393000003130000029300000213" "00000593000005130000049300000413" "00000793000007130000069300000613" "00000993000009130000089300000813" "00000b9300000b1300000a9300000a13" "00000d9300000d1300000c9300000c13" "00000f9300000f1300000e9300000e13" "00012023f8010113f65ff06f80020137" "00412823003126230021242300112223" "0281202300712e2300612c2300512a23" "02c1282302b1262302a1242302912223" "0501202302f12e2302e12c2302d12a23" "05412823053126230521242305112223" "0781202305712e2305612c2305512a23" "07c1282307b1262307a1242307912223" "7ffff51707f12e2307e12c2307d12a23" "0002c5034000233700050293ed450513" "ff1ff06f00a320230005066300128293" "4000233700050293ed0505137ffff517" "00a3202300050663001282930002c503" "eb8282937ffff29734202573ff1ff06f" "0005051300b2a42300a2a2230012a023" "00050313000505130185551300050593" "e98282937ffff29700f5751300435513" "00a2a023400022b70005450300550533" "00550533e7c282937ffff29700f37513" "0005851300a2a023400022b700054503" "00435513000503130005051301055513" "00550533e6c282937ffff29700f57513" "00f3751300a2a023400022b700054503" "0005450300550533e50282937ffff297" "008555130005851300a2a023400022b7" "00f57513004355130005031300050513" "0005450300550533e40282937ffff297" "7ffff29700f3751300a2a023400022b7" "400022b70005450300550533e2428293" "00050313000505130005851300a2a023" "e18282937ffff29700f5751300435513" "00a2a023400022b70005450300550533" "00550533dfc282937ffff29700f37513" "7ffff29700a2a023400022b700054503" "0082a5830042a5030002a083de428293" "4000233700050293df0505137ffff517" "00a3202300050663001282930002c503" "dd8282937ffff29734102573ff1ff06f" "0005051300b2a42300a2a2230012a023" "00050313000505130185551300050593" "db8282937ffff29700f5751300435513" "00a2a023400022b70005450300550533" "00550533d9c282937ffff29700f37513" "0005851300a2a023400022b700054503" "00435513000503130005051301055513" "00550533d8c282937ffff29700f57513" "00f3751300a2a023400022b700054503" "0005450300550533d70282937ffff297" "008555130005851300a2a023400022b7" "00f57513004355130005031300050513" "0005450300550533d60282937ffff297" "7ffff29700f3751300a2a023400022b7" "400022b70005450300550533d4428293" "00050313000505130005851300a2a023" "d38282937ffff29700f5751300435513" "00a2a023400022b70005450300550533" "00550533d1c282937ffff29700f37513" "7ffff29700a2a023400022b700054503" "0082a5830042a5030002a083d0428293" "4000233700050293d10505137ffff517" "00a3202300050663001282930002c503" "cf8282937ffff29734302573ff1ff06f" "0005051300b2a42300a2a2230012a023" "00050313000505130185551300050593" "cd8282937ffff29700f5751300435513" "00a2a023400022b70005450300550533" "00550533cbc282937ffff29700f37513" "0005851300a2a023400022b700054503" "00435513000503130005051301055513" "00550533cac282937ffff29700f57513" "00f3751300a2a023400022b700054503" "0005450300550533c90282937ffff297" "008555130005851300a2a023400022b7" "00f57513004355130005031300050513" "0005450300550533c80282937ffff297" "7ffff29700f3751300a2a023400022b7" "400022b70005450300550533c6428293" "00050313000505130005851300a2a023" "c58282937ffff29700f5751300435513" "00a2a023400022b70005450300550533" "00550533c3c282937ffff29700f37513" "7ffff29700a2a023400022b700054503" "0082a5830042a5030002a083c2428293" "4000233700050293c30505137ffff517" "00a3202300050663001282930002c503" "0023d51308000e1300000393ff1ff06f" "00a2a2230012a023c10282937ffff297" "01855513000505930005051300b2a423" "00f57513004355130005031300050513" "0005450300550533bf0282937ffff297" "7ffff29700f3751300a2a023400022b7" "400022b70005450300550533bd428293" "00050513010555130005851300a2a023" "7ffff29700f575130043551300050313" "400022b70005450300550533bc428293" "ba8282937ffff29700f3751300a2a023" "00a2a023400022b70005450300550533" "00050313000505130085551300058513" "b98282937ffff29700f5751300435513" "00a2a023400022b70005450300550533" "00550533b7c282937ffff29700f37513" "0005851300a2a023400022b700054503" "00f57513004355130005031300050513" "0005450300550533b70282937ffff297" "7ffff29700f3751300a2a023400022b7" "400022b70005450300550533b5428293" "0002a083b3c282937ffff29700a2a023" "b48505137ffff5170082a5830042a503" "001282930002c5034000233700050293" "00238533ff1ff06f00a3202300050663" "0012a023b2c282937ffff29700052503" "000505930005051300b2a42300a2a223" "00435513000503130005051301855513" "00550533b0c282937ffff29700f57513" "00f3751300a2a023400022b700054503" "0005450300550533af0282937ffff297" "010555130005851300a2a023400022b7" "00f57513004355130005031300050513" "0005450300550533ae0282937ffff297" "7ffff29700f3751300a2a023400022b7" "400022b70005450300550533ac428293" "00050513008555130005851300a2a023" "7ffff29700f575130043551300050313" "400022b70005450300550533ab428293" "a98282937ffff29700f3751300a2a023" "00a2a023400022b70005450300550533" "00435513000503130005051300058513" "00550533a8c282937ffff29700f57513" "00f3751300a2a023400022b700054503" "0005450300550533a70282937ffff297" "a58282937ffff29700a2a023400022b7" "7ffff5170082a5830042a5030002a083" "0002c5034000233700050293a6450513" "ff1ff06f00a320230005066300128293" "a48505137ffff517cfc39ce300438393" "001282930002c5034000233700050293" "ed8ff06fff1ff06f00a3202300050663" "00c12183008121030041208300012003" "01c12383018123030141228301012203" "02c12583028125030241248302012403" "03c12783038127030341268303012603" "04c12983048129030441288304012803" "05c12b8305812b0305412a8305012a03" "06c12d8306812d0306412c8306012c03" "07c12f8307812f0307412e8307012e03" "800005b7000000003020007308010113" "000787933745859380000737800007b7" "40f585b3374505133747071380000537" "f8478693000027b70205886340e50533" "40f8083300d585b3f847879380000837" "00c680230017879300f806b30007c603" "00e787b3ffc5779300050c63feb798e3" "00008067fef71ce30047071300072023" "00e5b73300458693004507130c060663" "0016c69300174713fff6079300d536b3" "00e7f7b30017c79300d767330097b793" "06079a630037f79300b567b308078063" "00b808330005071300058793ffc67813" "fed72e2300478793004707130007a683" "00f5873306f60263ffc67793ff0798e3" "010680230017871300f506b300074803" "00e507330006c68300e586b304c77663" "00f585b302c7fa6300d7002300278793" "0000806700e7802300f507b30005c703" "001787930005c70300c5863300050793" "00008067fec598e3fee78fa300158593" "064006930000079300012623ff010113" "0017879300e1262300f7073300c12703" "bf0101130000806701010113fed798e3" "0010089340a005330005566300000893" "00a00593000007930008069301010813" "0046869302b56733000607930080006f" "fee6ae230307071302b5453300178613" "002617934101071300088e63fe0512e3" "00060793c0e7a02302d0071300f707b3" "400025b70640069300f8063300279793" "00f7073300c127030000079300012623" "00062783fed798e30017879300e12623" "0007061300c8066300f5a023ffc60713" "fc0101130000806741010113fd1ff06f" "03212a2302912c2302812e2301010613" "00200893001008130006071303010593" "00600393005004130040049300300313" "00a00e9300900f1300800f9300700293" "080780630300069300f5779300b00e13" "071788630320069307078c6303100693" "06978063034006930667846303300693" "047788630360069304878c6303500693" "05f78063038006930457846303700693" "03d788630610069303e78c6303900693" "0630069300c0091303c7846306200693" "012788630640069300d0091301278e63" "00d720230657869300f037b3ff278793" "fe060513f6b716e34045551300470713" "0000079300012623400025b706400693" "0017879300e1262300f7073300c12703" "00f5a023ffc6061301c62783fed798e3" "034129030381248303c12403fcc51ce3" "00012623ff0101130000806704010113" "00f7073300c127030640069300000793" "400027b7fed798e30017879300e12623" "fc010113000080670101011300a78023" "03c12703064006930000079302012e23" "fed798e30017879302e12e2300f70733" "02012c2300e7802304800713400027b7" "00f70733038127030640069300000793" "400027b7fed798e30017879302e12c23" "0000079302012a2300e7802306500713" "02e12a2300f707330341270306400693" "06c00713400027b7fed798e300178793" "06400693000007930201282300e78023" "0017879302e1282300f7073303012703" "00e7802306c00713400027b7fed798e3" "02c12703064006930000079302012623" "fed798e30017879302e1262300f70733" "0201242300e7802306f00713400027b7" "00f70733028127030640069300000793" "400027b7fed798e30017879302e12423" "000007930201222300e7802302c00713" "02e1222300f707330241270306400693" "05700713400027b7fed798e300178793" "06400693000007930201202300e78023" "0017879302e1202300f7073302012703" "00e7802306f00713400027b7fed798e3" "01c12703064006930000079300012e23" "fed798e30017879300e12e2300f70733" "00012c2300e7802307200713400027b7" "00f70733018127030640069300000793" "400027b7fed798e30017879300e12c23" "0000079300012a2300e7802306c00713" "00e12a2300f707330141270306400693" "00f7002340002737fed798e300178793" "01012703064006930000079300012823" "fed798e30017879300e1282300f70733" "0001262300e7802302100713400027b7" "00f7073300c127030640069300000793" "400027b7fed798e30017879300e12623" "040101130000051300e7802300a00713" "7470656378450a6d34335b1b00008067" "000000000a2e646573756163206e6f69" "00000000003a65737561636d00000000" "00000000000000000000000000000000" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "0000000000003a6370656d2000000000" "00000000000000000000000000000000" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "00003a726464616461626d2000000000" "00000000000000000000000000000000" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "00000000000000000000000a00000000" "00000000000000000000000000000000" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "00000000000000000000203a00000000" "00000000000000000000000000000000" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "62613938373635343332313000000000" "00000000000000000000000066656463" "00000000000000000000000a00000000" "0a2e2e2e676e6974726f626100000000" "0000000000000000000000006d305b1b" "00000000000000000044535200000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000" "00000000000000000000000000000000"; }
bcd78b7cf5be8eb14fb4b12814e909f164030ad3
bed3ac926beac0f4e0293303d7b2a6031ee476c9
/Modules/ThirdParty/VNL/src/vxl/v3p/netlib/blas/srotg.c
b10e70a2e0aa69073bbd084f6041c2b338ba36f1
[ "IJG", "Zlib", "LicenseRef-scancode-proprietary-license", "SMLNJ", "BSD-3-Clause", "BSD-4.3TAHOE", "LicenseRef-scancode-free-unknown", "Spencer-86", "LicenseRef-scancode-llnl", "FSFUL", "Libpng", "libtiff", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-hdf5", "MIT", "NTP", "LicenseRef-scancode-mit-old-style", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "MPL-2.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
InsightSoftwareConsortium/ITK
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
refs/heads/master
2023-08-31T17:21:47.754304
2023-08-31T00:58:51
2023-08-31T14:12:21
800,928
1,229
656
Apache-2.0
2023-09-14T17:54:00
2010-07-27T15:48:04
C++
UTF-8
C
false
false
2,505
c
srotg.c
/* blas/srotg.f -- translated by f2c (version 20050501). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib; on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */ #ifdef __cplusplus extern "C" { #endif #include "v3p_netlib.h" /* Table of constant values */ static real c_b4 = (float)1.; /*< subroutine srotg(sa,sb,c,s) >*/ /* Subroutine */ int srotg_(real *sa, real *sb, real *c__, real *s) { /* System generated locals */ real r__1, r__2; /* Builtin functions */ double sqrt(doublereal), r_sign(real *, real *); /* Local variables */ real r__, z__, roe, scale; /* construct givens plane rotation. */ /* jack dongarra, linpack, 3/11/78. */ /*< real sa,sb,c,s,roe,scale,r,z >*/ /*< roe = sb >*/ roe = *sb; /*< if( abs(sa) .gt. abs(sb) ) roe = sa >*/ if (dabs(*sa) > dabs(*sb)) { roe = *sa; } /*< scale = abs(sa) + abs(sb) >*/ scale = dabs(*sa) + dabs(*sb); /*< if( scale .ne. 0.0 ) go to 10 >*/ if (scale != (float)0.) { goto L10; } /*< c = 1.0 >*/ *c__ = (float)1.; /*< s = 0.0 >*/ *s = (float)0.; /*< r = 0.0 >*/ r__ = (float)0.; /*< z = 0.0 >*/ z__ = (float)0.; /*< go to 20 >*/ goto L20; /*< 10 r = scale*sqrt((sa/scale)**2 + (sb/scale)**2) >*/ L10: /* Computing 2nd power */ r__1 = *sa / scale; /* Computing 2nd power */ r__2 = *sb / scale; r__ = scale * sqrt(r__1 * r__1 + r__2 * r__2); /*< r = sign(1.0,roe)*r >*/ r__ = r_sign(&c_b4, &roe) * r__; /*< c = sa/r >*/ *c__ = *sa / r__; /*< s = sb/r >*/ *s = *sb / r__; /*< z = 1.0 >*/ z__ = (float)1.; /*< if( abs(sa) .gt. abs(sb) ) z = s >*/ if (dabs(*sa) > dabs(*sb)) { z__ = *s; } /*< if( abs(sb) .ge. abs(sa) .and. c .ne. 0.0 ) z = 1.0/c >*/ if (dabs(*sb) >= dabs(*sa) && *c__ != (float)0.) { z__ = (float)1. / *c__; } /*< 20 sa = r >*/ L20: *sa = r__; /*< sb = z >*/ *sb = z__; /*< return >*/ return 0; /*< end >*/ } /* srotg_ */ #ifdef __cplusplus } #endif
7149762c45839a44c868cb23aca371d0daebf671
1efb2283837c9b70bc6449cec877799e4efa3268
/src/mpid/ch4/netmod/ucx/ucx_am.h
68fa6aa2d064b02dde07daaad0089b8d79f11f5e
[ "mpich2" ]
permissive
pmodels/mpich
d2392e8e30536cad3e500c16aa1e71211101d83f
2d265f9f5f93ebdd07ad547423bc6212868262a4
refs/heads/main
2023-09-04T05:50:15.041823
2023-09-01T23:07:33
2023-09-01T23:07:33
70,918,679
506
313
NOASSERTION
2023-09-14T14:38:36
2016-10-14T14:39:42
C
UTF-8
C
false
false
10,246
h
ucx_am.h
/* * Copyright (C) by Argonne National Laboratory * See COPYRIGHT in top-level directory */ #ifndef UCX_AM_H_INCLUDED #define UCX_AM_H_INCLUDED #include "ucx_impl.h" MPL_STATIC_INLINE_PREFIX int MPIDI_NM_am_isend(int rank, MPIR_Comm * comm, int handler_id, const void *am_hdr, MPI_Aint am_hdr_sz, const void *data, MPI_Aint count, MPI_Datatype datatype, int src_vci, int dst_vci, MPIR_Request * sreq) { int mpi_errno = MPI_SUCCESS; MPIDI_UCX_ucp_request_t *ucp_request; ucp_ep_h ep; MPIDI_UCX_am_header_t ucx_hdr; MPIR_FUNC_ENTER; MPIR_Assert(src_vci < MPIDI_UCX_global.num_vcis); MPIR_Assert(dst_vci < MPIDI_UCX_global.num_vcis); ep = MPIDI_UCX_COMM_TO_EP(comm, rank, src_vci, dst_vci); int dt_contig; size_t data_sz; MPI_Aint dt_true_lb; MPIR_Datatype *dt_ptr; MPIDI_Datatype_get_info(count, datatype, dt_contig, data_sz, dt_ptr, dt_true_lb); /* initialize our portion of the hdr */ ucx_hdr.handler_id = handler_id; ucx_hdr.src_vci = src_vci; ucx_hdr.dst_vci = dst_vci; ucx_hdr.data_sz = data_sz; #ifdef HAVE_UCP_AM_NBX size_t header_size = sizeof(ucx_hdr) + am_hdr_sz; void *send_buf, *header, *data_ptr; /* note: since we are not copying large contig gpu data, it is less useful * to use MPIR_gpu_malloc_host */ if (dt_contig) { /* only need copy headers */ send_buf = MPL_malloc(header_size, MPL_MEM_OTHER); MPIR_Assert(send_buf); header = send_buf; MPIR_Memcpy(header, &ucx_hdr, sizeof(ucx_hdr)); MPIR_Memcpy((char *) header + sizeof(ucx_hdr), am_hdr, am_hdr_sz); data_ptr = (char *) data + dt_true_lb; } else { /* need copy headers and pack data */ send_buf = MPL_malloc(header_size + data_sz, MPL_MEM_OTHER); MPIR_Assert(send_buf); header = send_buf; data_ptr = (char *) send_buf + header_size; MPIR_Memcpy(header, &ucx_hdr, sizeof(ucx_hdr)); MPIR_Memcpy((char *) header + sizeof(ucx_hdr), am_hdr, am_hdr_sz); MPI_Aint actual_pack_bytes; mpi_errno = MPIR_Typerep_pack(data, count, datatype, 0, data_ptr, data_sz, &actual_pack_bytes, MPIR_TYPEREP_FLAG_NONE); MPIR_ERR_CHECK(mpi_errno); MPIR_Assert(actual_pack_bytes == data_sz); } ucp_request_param_t param = { .op_attr_mask = UCP_OP_ATTR_FIELD_CALLBACK, .cb.send = &MPIDI_UCX_am_isend_callback_nbx, }; ucp_request = (MPIDI_UCX_ucp_request_t *) ucp_am_send_nbx(ep, MPIDI_UCX_AM_NBX_HANDLER_ID, header, header_size, data_ptr, data_sz, &param); MPIDI_UCX_CHK_REQUEST(ucp_request); /* if send is done, free all resources and complete the request */ if (ucp_request == NULL) { MPL_free(send_buf); MPIDIG_global.origin_cbs[handler_id] (sreq); goto fn_exit; } MPIDI_UCX_AM_SEND_REQUEST(sreq, pack_buffer) = send_buf; MPIDI_UCX_AM_SEND_REQUEST(sreq, handler_id) = handler_id; ucp_request->req = sreq; ucp_request_release(ucp_request); #else /* !HAVE_UCP_AM_NBX */ MPL_pointer_attr_t attr; MPIR_GPU_query_pointer_attr(data, &attr); if (attr.type == MPL_GPU_POINTER_DEV) { /* Force packing of GPU buffer in host memory */ dt_contig = 0; } char *send_buf; void *send_buf_p; size_t total_sz; ucp_datatype_t dt; if (dt_contig) { send_buf = MPL_malloc(sizeof(ucx_hdr) + am_hdr_sz, MPL_MEM_OTHER); MPIR_Memcpy(send_buf, &ucx_hdr, sizeof(ucx_hdr)); MPIR_Memcpy(send_buf + sizeof(ucx_hdr), am_hdr, am_hdr_sz); ucp_dt_iov_t *iov = MPIDI_UCX_AM_SEND_REQUEST(sreq, iov); iov[0].buffer = send_buf; iov[0].length = sizeof(ucx_hdr) + am_hdr_sz; iov[1].buffer = MPIR_get_contig_ptr(data, dt_true_lb); iov[1].length = data_sz; send_buf_p = iov; dt = ucp_dt_make_iov(); total_sz = 2; } else { send_buf = MPL_malloc(data_sz + am_hdr_sz + sizeof(ucx_hdr), MPL_MEM_OTHER); MPIR_Memcpy(send_buf, &ucx_hdr, sizeof(ucx_hdr)); MPIR_Memcpy(send_buf + sizeof(ucx_hdr), am_hdr, am_hdr_sz); MPI_Aint actual_pack_bytes; mpi_errno = MPIR_Typerep_pack(data, count, datatype, 0, send_buf + am_hdr_sz + sizeof(ucx_hdr), data_sz, &actual_pack_bytes, MPIR_TYPEREP_FLAG_NONE); MPIR_ERR_CHECK(mpi_errno); MPIR_Assert(actual_pack_bytes == data_sz); send_buf_p = send_buf; dt = ucp_dt_make_contig(1); total_sz = data_sz + am_hdr_sz + sizeof(ucx_hdr); } ucp_request = (MPIDI_UCX_ucp_request_t *) ucp_am_send_nb(ep, MPIDI_UCX_AM_HANDLER_ID, send_buf_p, total_sz, dt, &MPIDI_UCX_am_isend_callback, 0); MPIDI_UCX_CHK_REQUEST(ucp_request); /* send is done. free all resources and complete the request */ if (ucp_request == NULL) { MPL_free(send_buf); MPIDIG_global.origin_cbs[handler_id] (sreq); goto fn_exit; } /* set the ch4r request inside the UCP request */ MPIDI_UCX_AM_SEND_REQUEST(sreq, pack_buffer) = send_buf; MPIDI_UCX_AM_SEND_REQUEST(sreq, handler_id) = handler_id; ucp_request->req = sreq; ucp_request_release(ucp_request); #endif /* HAVE_UCP_AM_NBX */ fn_exit: MPIR_FUNC_EXIT; return mpi_errno; fn_fail: goto fn_exit; } MPL_STATIC_INLINE_PREFIX int MPIDI_NM_am_isend_reply(MPIR_Comm * comm, int src_rank, int handler_id, const void *am_hdr, MPI_Aint am_hdr_sz, const void *data, MPI_Aint count, MPI_Datatype datatype, int src_vci, int dst_vci, MPIR_Request * sreq) { int mpi_errno = MPI_SUCCESS; MPIR_FUNC_ENTER; mpi_errno = MPIDI_NM_am_isend(src_rank, comm, handler_id, am_hdr, am_hdr_sz, data, count, datatype, src_vci, dst_vci, sreq); MPIR_FUNC_EXIT; return mpi_errno; } MPL_STATIC_INLINE_PREFIX MPI_Aint MPIDI_NM_am_hdr_max_sz(void) { return (MPIDI_UCX_MAX_AM_EAGER_SZ - sizeof(MPIDI_UCX_am_header_t)); } MPL_STATIC_INLINE_PREFIX MPI_Aint MPIDI_NM_am_eager_limit(void) { return (MPIDI_UCX_MAX_AM_EAGER_SZ - sizeof(MPIDI_UCX_am_header_t)); } MPL_STATIC_INLINE_PREFIX MPI_Aint MPIDI_NM_am_eager_buf_limit(void) { return MPIDI_UCX_MAX_AM_EAGER_SZ; } MPL_STATIC_INLINE_PREFIX int MPIDI_NM_am_send_hdr(int rank, MPIR_Comm * comm, int handler_id, const void *am_hdr, MPI_Aint am_hdr_sz, int src_vci, int dst_vci) { int mpi_errno = MPI_SUCCESS; MPIDI_UCX_ucp_request_t *ucp_request; ucp_ep_h ep; char *send_buf; MPIDI_UCX_am_header_t ucx_hdr; MPIR_FUNC_ENTER; MPIR_Assert(src_vci < MPIDI_UCX_global.num_vcis); MPIR_Assert(dst_vci < MPIDI_UCX_global.num_vcis); ep = MPIDI_UCX_COMM_TO_EP(comm, rank, src_vci, dst_vci); /* initialize our portion of the hdr */ ucx_hdr.handler_id = handler_id; ucx_hdr.src_vci = src_vci; ucx_hdr.dst_vci = dst_vci; ucx_hdr.data_sz = 0; /* just pack and send for now */ send_buf = MPL_malloc(am_hdr_sz + sizeof(ucx_hdr), MPL_MEM_BUFFER); MPIR_Memcpy(send_buf, &ucx_hdr, sizeof(ucx_hdr)); MPIR_Memcpy(send_buf + sizeof(ucx_hdr), am_hdr, am_hdr_sz); ucp_request = (MPIDI_UCX_ucp_request_t *) ucp_am_send_nb(ep, MPIDI_UCX_AM_HANDLER_ID, send_buf, am_hdr_sz + sizeof(ucx_hdr), ucp_dt_make_contig(1), &MPIDI_UCX_am_send_callback, 0); MPIDI_UCX_CHK_REQUEST(ucp_request); if (ucp_request == NULL) { /* inject is done */ MPL_free(send_buf); } else { ucp_request->buf = send_buf; } fn_exit: MPIR_FUNC_EXIT; return mpi_errno; fn_fail: goto fn_exit; } MPL_STATIC_INLINE_PREFIX int MPIDI_NM_am_send_hdr_reply(MPIR_Comm * comm, int rank, int handler_id, const void *am_hdr, MPI_Aint am_hdr_sz, int src_vci, int dst_vci) { int mpi_errno = MPI_SUCCESS; MPIR_FUNC_ENTER; mpi_errno = MPIDI_NM_am_send_hdr(rank, comm, handler_id, am_hdr, am_hdr_sz, src_vci, dst_vci); MPIR_FUNC_EXIT; return mpi_errno; } MPL_STATIC_INLINE_PREFIX bool MPIDI_NM_am_check_eager(MPI_Aint am_hdr_sz, MPI_Aint data_sz, const void *data, MPI_Aint count, MPI_Datatype datatype, MPIR_Request * sreq) { #ifdef HAVE_UCP_AM_NBX /* ucx will handle rndv */ return true; #else return (am_hdr_sz + data_sz) <= (MPIDI_UCX_MAX_AM_EAGER_SZ - sizeof(MPIDI_UCX_am_header_t)); #endif } int MPIDI_UCX_do_am_recv(MPIR_Request * rreq); MPL_STATIC_INLINE_PREFIX MPIDIG_recv_data_copy_cb MPIDI_NM_am_get_data_copy_cb(uint32_t attr) { #ifdef HAVE_UCP_AM_NBX return MPIDI_UCX_do_am_recv; #else return NULL; #endif } #endif /* UCX_AM_H_INCLUDED */
2be0400e3b97eba2538a9961d88ced9e104f5270
4d317369bd7de599e0364e9097e50f381845e22c
/C Programs/C Programs - 7/3_Palindrome.c
6d22092d7aac488f1705fa657d2592d6f8ad5c7e
[]
no_license
MathProgrammer/CodeForces
4865f0bad799c674ff9e6fde9a008b988af2aed0
e3483c1ac4a7c81662f6a0bc8af20be69e0c0a98
refs/heads/master
2023-04-07T11:27:31.766011
2023-04-01T06:29:19
2023-04-01T06:29:19
84,833,335
256
114
null
2021-10-02T21:14:47
2017-03-13T14:02:57
C++
UTF-8
C
false
false
584
c
3_Palindrome.c
#include <stdio.h> int main() { int number_of_letters, i; scanf("%d", &number_of_letters); //No letter must have the same neighbour on both the left and the right. aabbaabbaabb.... satisfies this condition for(i = 1; i <= number_of_letters; i = i+2) { //If n is odd, then only one letter should be printed at the end. if(i%4 == 1) { printf(i == number_of_letters ? "a\n" : "aa"); } else { printf(i == number_of_letters ? "b\n" : "bb"); } } return 0; }