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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e7fded64eae217243084da5351f8f40e806f25da
|
a2440dbe95b034784aa940ddc0ee0faae7869e76
|
/modules/lwjgl/nanovg/src/main/c/nanosvg.h
|
e917a3470c435b0231e23374263d8f9a058a1ec5
|
[
"Zlib",
"MIT",
"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
| 85,954
|
h
|
nanosvg.h
|
/*
* Copyright (c) 2013-14 Mikko Mononen memon@inside.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.
*
* The SVG parser is based on Anti-Grain Geometry 2.4 SVG example
* Copyright (C) 2002-2004 Maxim Shemanarev (McSeem) (http://www.antigrain.com/)
*
* Arc calculation code based on canvg (https://code.google.com/p/canvg/)
*
* Bounding box calculation based on http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
*
*/
#ifndef NANOSVG_H
#define NANOSVG_H
#ifndef NANOSVG_CPLUSPLUS
#ifdef __cplusplus
extern "C" {
#endif
#endif
// NanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes.
//
// The library suits well for anything from rendering scalable icons in your editor application to prototyping a game.
//
// NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request!
//
// The shapes in the SVG images are transformed by the viewBox and converted to specified units.
// That is, you should get the same looking data as your designed in your favorite app.
//
// NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose
// to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.
//
// The units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
// DPI (dots-per-inch) controls how the unit conversion is done.
//
// If you don't know or care about the units stuff, "px" and 96 should get you going.
/* Example Usage:
// Load SVG
NSVGimage* image;
image = nsvgParseFromFile("test.svg", "px", 96);
printf("size: %f x %f\n", image->width, image->height);
// Use...
for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) {
for (NSVGpath *path = shape->paths; path != NULL; path = path->next) {
for (int i = 0; i < path->npts-1; i += 3) {
float* p = &path->pts[i*2];
drawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]);
}
}
}
// Delete
nsvgDelete(image);
*/
enum NSVGpaintType {
NSVG_PAINT_UNDEF = -1,
NSVG_PAINT_NONE = 0,
NSVG_PAINT_COLOR = 1,
NSVG_PAINT_LINEAR_GRADIENT = 2,
NSVG_PAINT_RADIAL_GRADIENT = 3
};
enum NSVGspreadType {
NSVG_SPREAD_PAD = 0,
NSVG_SPREAD_REFLECT = 1,
NSVG_SPREAD_REPEAT = 2
};
enum NSVGlineJoin {
NSVG_JOIN_MITER = 0,
NSVG_JOIN_ROUND = 1,
NSVG_JOIN_BEVEL = 2
};
enum NSVGlineCap {
NSVG_CAP_BUTT = 0,
NSVG_CAP_ROUND = 1,
NSVG_CAP_SQUARE = 2
};
enum NSVGfillRule {
NSVG_FILLRULE_NONZERO = 0,
NSVG_FILLRULE_EVENODD = 1
};
enum NSVGflags {
NSVG_FLAGS_VISIBLE = 0x01
};
typedef struct NSVGgradientStop {
unsigned int color;
float offset;
} NSVGgradientStop;
typedef struct NSVGgradient {
float xform[6];
char spread;
float fx, fy;
int nstops;
NSVGgradientStop stops[1];
} NSVGgradient;
typedef struct NSVGpaint {
signed char type;
union {
unsigned int color;
NSVGgradient* gradient;
};
} NSVGpaint;
typedef struct NSVGpath
{
float* pts; // Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ...
int npts; // Total number of bezier points.
char closed; // Flag indicating if shapes should be treated as closed.
float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy].
struct NSVGpath* next; // Pointer to next path, or NULL if last element.
} NSVGpath;
typedef struct NSVGshape
{
char id[64]; // Optional 'id' attr of the shape or its group
NSVGpaint fill; // Fill paint
NSVGpaint stroke; // Stroke paint
float opacity; // Opacity of the shape.
float strokeWidth; // Stroke width (scaled).
float strokeDashOffset; // Stroke dash offset (scaled).
float strokeDashArray[8]; // Stroke dash array (scaled).
char strokeDashCount; // Number of dash values in dash array.
char strokeLineJoin; // Stroke join type.
char strokeLineCap; // Stroke cap type.
float miterLimit; // Miter limit
char fillRule; // Fill rule, see NSVGfillRule.
unsigned char flags; // Logical or of NSVG_FLAGS_* flags
float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy].
char fillGradient[64]; // Optional 'id' of fill gradient
char strokeGradient[64]; // Optional 'id' of stroke gradient
float xform[6]; // Root transformation for fill/stroke gradient
NSVGpath* paths; // Linked list of paths in the image.
struct NSVGshape* next; // Pointer to next shape, or NULL if last element.
} NSVGshape;
typedef struct NSVGimage
{
float width; // Width of the image.
float height; // Height of the image.
NSVGshape* shapes; // Linked list of shapes in the image.
} NSVGimage;
// Parses SVG file from a file, returns SVG image as paths.
NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi);
// Parses SVG file from a null terminated string, returns SVG image as paths.
// Important note: changes the string.
NSVGimage* nsvgParse(char* input, const char* units, float dpi);
// Duplicates a path.
NSVGpath* nsvgDuplicatePath(NSVGpath* p);
// Deletes an image.
void nsvgDelete(NSVGimage* image);
#ifndef NANOSVG_CPLUSPLUS
#ifdef __cplusplus
}
#endif
#endif
#ifdef NANOSVG_IMPLEMENTATION
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define NSVG_PI (3.14159265358979323846264338327f)
#define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs.
#define NSVG_ALIGN_MIN 0
#define NSVG_ALIGN_MID 1
#define NSVG_ALIGN_MAX 2
#define NSVG_ALIGN_NONE 0
#define NSVG_ALIGN_MEET 1
#define NSVG_ALIGN_SLICE 2
#define NSVG_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0)
#define NSVG_RGB(r, g, b) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16))
#define NSVG_RGBA(r, g, b, a) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16) | ((unsigned int)a << 24))
#ifdef _MSC_VER
#pragma warning (disable: 4996) // Switch off security warnings
#pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings
#ifdef __cplusplus
#define NSVG_INLINE inline
#else
#define NSVG_INLINE
#endif
#else
#define NSVG_INLINE inline
#endif
static int nsvg__isspace(char c)
{
return strchr(" \t\n\v\f\r", c) != 0;
}
static int nsvg__isdigit(char c)
{
return c >= '0' && c <= '9';
}
static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; }
static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; }
// Simple XML parser
#define NSVG_XML_TAG 1
#define NSVG_XML_CONTENT 2
#define NSVG_XML_MAX_ATTRIBS 256
static void nsvg__parseContent(char* s,
void (*contentCb)(void* ud, const char* s),
void* ud)
{
// Trim start white spaces
while (*s && nsvg__isspace(*s)) s++;
if (!*s) return;
if (contentCb)
(*contentCb)(ud, s);
}
static void nsvg__parseElement(char* s,
void (*startelCb)(void* ud, const char* el, const char** attr),
void (*endelCb)(void* ud, const char* el),
void* ud)
{
const char* attr[NSVG_XML_MAX_ATTRIBS];
int nattr = 0;
char* name;
int start = 0;
int end = 0;
char quote;
// Skip white space after the '<'
while (*s && nsvg__isspace(*s)) s++;
// Check if the tag is end tag
if (*s == '/') {
s++;
end = 1;
} else {
start = 1;
}
// Skip comments, data and preprocessor stuff.
if (!*s || *s == '?' || *s == '!')
return;
// Get tag name
name = s;
while (*s && !nsvg__isspace(*s)) s++;
if (*s) { *s++ = '\0'; }
// Get attribs
while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) {
char* name = NULL;
char* value = NULL;
// Skip white space before the attrib name
while (*s && nsvg__isspace(*s)) s++;
if (!*s) break;
if (*s == '/') {
end = 1;
break;
}
name = s;
// Find end of the attrib name.
while (*s && !nsvg__isspace(*s) && *s != '=') s++;
if (*s) { *s++ = '\0'; }
// Skip until the beginning of the value.
while (*s && *s != '\"' && *s != '\'') s++;
if (!*s) break;
quote = *s;
s++;
// Store value and find the end of it.
value = s;
while (*s && *s != quote) s++;
if (*s) { *s++ = '\0'; }
// Store only well formed attributes
if (name && value) {
attr[nattr++] = name;
attr[nattr++] = value;
}
}
// List terminator
attr[nattr++] = 0;
attr[nattr++] = 0;
// Call callbacks.
if (start && startelCb)
(*startelCb)(ud, name, attr);
if (end && endelCb)
(*endelCb)(ud, name);
}
int nsvg__parseXML(char* input,
void (*startelCb)(void* ud, const char* el, const char** attr),
void (*endelCb)(void* ud, const char* el),
void (*contentCb)(void* ud, const char* s),
void* ud)
{
char* s = input;
char* mark = s;
int state = NSVG_XML_CONTENT;
while (*s) {
if (*s == '<' && state == NSVG_XML_CONTENT) {
// Start of a tag
*s++ = '\0';
nsvg__parseContent(mark, contentCb, ud);
mark = s;
state = NSVG_XML_TAG;
} else if (*s == '>' && state == NSVG_XML_TAG) {
// Start of a content or new tag.
*s++ = '\0';
nsvg__parseElement(mark, startelCb, endelCb, ud);
mark = s;
state = NSVG_XML_CONTENT;
} else {
s++;
}
}
return 1;
}
/* Simple SVG parser. */
#define NSVG_MAX_ATTR 128
enum NSVGgradientUnits {
NSVG_USER_SPACE = 0,
NSVG_OBJECT_SPACE = 1
};
#define NSVG_MAX_DASHES 8
enum NSVGunits {
NSVG_UNITS_USER,
NSVG_UNITS_PX,
NSVG_UNITS_PT,
NSVG_UNITS_PC,
NSVG_UNITS_MM,
NSVG_UNITS_CM,
NSVG_UNITS_IN,
NSVG_UNITS_PERCENT,
NSVG_UNITS_EM,
NSVG_UNITS_EX
};
typedef struct NSVGcoordinate {
float value;
int units;
} NSVGcoordinate;
typedef struct NSVGlinearData {
NSVGcoordinate x1, y1, x2, y2;
} NSVGlinearData;
typedef struct NSVGradialData {
NSVGcoordinate cx, cy, r, fx, fy;
} NSVGradialData;
typedef struct NSVGgradientData
{
char id[64];
char ref[64];
signed char type;
union {
NSVGlinearData linear;
NSVGradialData radial;
};
char spread;
char units;
float xform[6];
int nstops;
NSVGgradientStop* stops;
struct NSVGgradientData* next;
} NSVGgradientData;
typedef struct NSVGattrib
{
char id[64];
float xform[6];
unsigned int fillColor;
unsigned int strokeColor;
float opacity;
float fillOpacity;
float strokeOpacity;
char fillGradient[64];
char strokeGradient[64];
float strokeWidth;
float strokeDashOffset;
float strokeDashArray[NSVG_MAX_DASHES];
int strokeDashCount;
char strokeLineJoin;
char strokeLineCap;
float miterLimit;
char fillRule;
float fontSize;
unsigned int stopColor;
float stopOpacity;
float stopOffset;
char hasFill;
char hasStroke;
char visible;
} NSVGattrib;
typedef struct NSVGparser
{
NSVGattrib attr[NSVG_MAX_ATTR];
int attrHead;
float* pts;
int npts;
int cpts;
NSVGpath* plist;
NSVGimage* image;
NSVGgradientData* gradients;
NSVGshape* shapesTail;
float viewMinx, viewMiny, viewWidth, viewHeight;
int alignX, alignY, alignType;
float dpi;
char pathFlag;
char defsFlag;
} NSVGparser;
static void nsvg__xformIdentity(float* t)
{
t[0] = 1.0f; t[1] = 0.0f;
t[2] = 0.0f; t[3] = 1.0f;
t[4] = 0.0f; t[5] = 0.0f;
}
static void nsvg__xformSetTranslation(float* t, float tx, float ty)
{
t[0] = 1.0f; t[1] = 0.0f;
t[2] = 0.0f; t[3] = 1.0f;
t[4] = tx; t[5] = ty;
}
static void nsvg__xformSetScale(float* t, float sx, float sy)
{
t[0] = sx; t[1] = 0.0f;
t[2] = 0.0f; t[3] = sy;
t[4] = 0.0f; t[5] = 0.0f;
}
static void nsvg__xformSetSkewX(float* t, float a)
{
t[0] = 1.0f; t[1] = 0.0f;
t[2] = tanf(a); t[3] = 1.0f;
t[4] = 0.0f; t[5] = 0.0f;
}
static void nsvg__xformSetSkewY(float* t, float a)
{
t[0] = 1.0f; t[1] = tanf(a);
t[2] = 0.0f; t[3] = 1.0f;
t[4] = 0.0f; t[5] = 0.0f;
}
static void nsvg__xformSetRotation(float* t, float a)
{
float cs = cosf(a), sn = sinf(a);
t[0] = cs; t[1] = sn;
t[2] = -sn; t[3] = cs;
t[4] = 0.0f; t[5] = 0.0f;
}
static void nsvg__xformMultiply(float* t, float* s)
{
float t0 = t[0] * s[0] + t[1] * s[2];
float t2 = t[2] * s[0] + t[3] * s[2];
float t4 = t[4] * s[0] + t[5] * s[2] + s[4];
t[1] = t[0] * s[1] + t[1] * s[3];
t[3] = t[2] * s[1] + t[3] * s[3];
t[5] = t[4] * s[1] + t[5] * s[3] + s[5];
t[0] = t0;
t[2] = t2;
t[4] = t4;
}
static void nsvg__xformInverse(float* inv, float* t)
{
double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1];
if (det > -1e-6 && det < 1e-6) {
nsvg__xformIdentity(t);
return;
}
invdet = 1.0 / det;
inv[0] = (float)(t[3] * invdet);
inv[2] = (float)(-t[2] * invdet);
inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet);
inv[1] = (float)(-t[1] * invdet);
inv[3] = (float)(t[0] * invdet);
inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet);
}
static void nsvg__xformPremultiply(float* t, float* s)
{
float s2[6];
memcpy(s2, s, sizeof(float)*6);
nsvg__xformMultiply(s2, t);
memcpy(t, s2, sizeof(float)*6);
}
static void nsvg__xformPoint(float* dx, float* dy, float x, float y, float* t)
{
*dx = x*t[0] + y*t[2] + t[4];
*dy = x*t[1] + y*t[3] + t[5];
}
static void nsvg__xformVec(float* dx, float* dy, float x, float y, float* t)
{
*dx = x*t[0] + y*t[2];
*dy = x*t[1] + y*t[3];
}
#define NSVG_EPSILON (1e-12)
static int nsvg__ptInBounds(float* pt, float* bounds)
{
return pt[0] >= bounds[0] && pt[0] <= bounds[2] && pt[1] >= bounds[1] && pt[1] <= bounds[3];
}
static double nsvg__evalBezier(double t, double p0, double p1, double p2, double p3)
{
double it = 1.0-t;
return it*it*it*p0 + 3.0*it*it*t*p1 + 3.0*it*t*t*p2 + t*t*t*p3;
}
static void nsvg__curveBounds(float* bounds, float* curve)
{
int i, j, count;
double roots[2], a, b, c, b2ac, t, v;
float* v0 = &curve[0];
float* v1 = &curve[2];
float* v2 = &curve[4];
float* v3 = &curve[6];
// Start the bounding box by end points
bounds[0] = nsvg__minf(v0[0], v3[0]);
bounds[1] = nsvg__minf(v0[1], v3[1]);
bounds[2] = nsvg__maxf(v0[0], v3[0]);
bounds[3] = nsvg__maxf(v0[1], v3[1]);
// Bezier curve fits inside the convex hull of it's control points.
// If control points are inside the bounds, we're done.
if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds))
return;
// Add bezier curve inflection points in X and Y.
for (i = 0; i < 2; i++) {
a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i];
b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i];
c = 3.0 * v1[i] - 3.0 * v0[i];
count = 0;
if (fabs(a) < NSVG_EPSILON) {
if (fabs(b) > NSVG_EPSILON) {
t = -c / b;
if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
roots[count++] = t;
}
} else {
b2ac = b*b - 4.0*c*a;
if (b2ac > NSVG_EPSILON) {
t = (-b + sqrt(b2ac)) / (2.0 * a);
if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
roots[count++] = t;
t = (-b - sqrt(b2ac)) / (2.0 * a);
if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
roots[count++] = t;
}
}
for (j = 0; j < count; j++) {
v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]);
bounds[0+i] = nsvg__minf(bounds[0+i], (float)v);
bounds[2+i] = nsvg__maxf(bounds[2+i], (float)v);
}
}
}
static NSVGparser* nsvg__createParser(void)
{
NSVGparser* p;
p = (NSVGparser*)NVG_MALLOC(sizeof(NSVGparser));
if (p == NULL) goto error;
memset(p, 0, sizeof(NSVGparser));
p->image = (NSVGimage*)NVG_MALLOC(sizeof(NSVGimage));
if (p->image == NULL) goto error;
memset(p->image, 0, sizeof(NSVGimage));
// Init style
nsvg__xformIdentity(p->attr[0].xform);
memset(p->attr[0].id, 0, sizeof p->attr[0].id);
p->attr[0].fillColor = NSVG_RGB(0,0,0);
p->attr[0].strokeColor = NSVG_RGB(0,0,0);
p->attr[0].opacity = 1;
p->attr[0].fillOpacity = 1;
p->attr[0].strokeOpacity = 1;
p->attr[0].stopOpacity = 1;
p->attr[0].strokeWidth = 1;
p->attr[0].strokeLineJoin = NSVG_JOIN_MITER;
p->attr[0].strokeLineCap = NSVG_CAP_BUTT;
p->attr[0].miterLimit = 4;
p->attr[0].fillRule = NSVG_FILLRULE_NONZERO;
p->attr[0].hasFill = 1;
p->attr[0].visible = 1;
return p;
error:
if (p) {
if (p->image) NVG_FREE(p->image);
NVG_FREE(p);
}
return NULL;
}
static void nsvg__deletePaths(NSVGpath* path)
{
while (path) {
NSVGpath *next = path->next;
if (path->pts != NULL)
NVG_FREE(path->pts);
NVG_FREE(path);
path = next;
}
}
static void nsvg__deletePaint(NSVGpaint* paint)
{
if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT)
NVG_FREE(paint->gradient);
}
static void nsvg__deleteGradientData(NSVGgradientData* grad)
{
NSVGgradientData* next;
while (grad != NULL) {
next = grad->next;
NVG_FREE(grad->stops);
NVG_FREE(grad);
grad = next;
}
}
static void nsvg__deleteParser(NSVGparser* p)
{
if (p != NULL) {
nsvg__deletePaths(p->plist);
nsvg__deleteGradientData(p->gradients);
nsvgDelete(p->image);
NVG_FREE(p->pts);
NVG_FREE(p);
}
}
static void nsvg__resetPath(NSVGparser* p)
{
p->npts = 0;
}
static void nsvg__addPoint(NSVGparser* p, float x, float y)
{
if (p->npts+1 > p->cpts) {
p->cpts = p->cpts ? p->cpts*2 : 8;
p->pts = (float*)NVG_REALLOC(p->pts, p->cpts*2*sizeof(float));
if (!p->pts) return;
}
p->pts[p->npts*2+0] = x;
p->pts[p->npts*2+1] = y;
p->npts++;
}
static void nsvg__moveTo(NSVGparser* p, float x, float y)
{
if (p->npts > 0) {
p->pts[(p->npts-1)*2+0] = x;
p->pts[(p->npts-1)*2+1] = y;
} else {
nsvg__addPoint(p, x, y);
}
}
static void nsvg__lineTo(NSVGparser* p, float x, float y)
{
float px,py, dx,dy;
if (p->npts > 0) {
px = p->pts[(p->npts-1)*2+0];
py = p->pts[(p->npts-1)*2+1];
dx = x - px;
dy = y - py;
nsvg__addPoint(p, px + dx/3.0f, py + dy/3.0f);
nsvg__addPoint(p, x - dx/3.0f, y - dy/3.0f);
nsvg__addPoint(p, x, y);
}
}
static void nsvg__cubicBezTo(NSVGparser* p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y)
{
if (p->npts > 0) {
nsvg__addPoint(p, cpx1, cpy1);
nsvg__addPoint(p, cpx2, cpy2);
nsvg__addPoint(p, x, y);
}
}
static NSVGattrib* nsvg__getAttr(NSVGparser* p)
{
return &p->attr[p->attrHead];
}
static void nsvg__pushAttr(NSVGparser* p)
{
if (p->attrHead < NSVG_MAX_ATTR-1) {
p->attrHead++;
memcpy(&p->attr[p->attrHead], &p->attr[p->attrHead-1], sizeof(NSVGattrib));
}
}
static void nsvg__popAttr(NSVGparser* p)
{
if (p->attrHead > 0)
p->attrHead--;
}
static float nsvg__actualOrigX(NSVGparser* p)
{
return p->viewMinx;
}
static float nsvg__actualOrigY(NSVGparser* p)
{
return p->viewMiny;
}
static float nsvg__actualWidth(NSVGparser* p)
{
return p->viewWidth;
}
static float nsvg__actualHeight(NSVGparser* p)
{
return p->viewHeight;
}
static float nsvg__actualLength(NSVGparser* p)
{
float w = nsvg__actualWidth(p), h = nsvg__actualHeight(p);
return sqrtf(w*w + h*h) / sqrtf(2.0f);
}
static float nsvg__convertToPixels(NSVGparser* p, NSVGcoordinate c, float orig, float length)
{
NSVGattrib* attr = nsvg__getAttr(p);
switch (c.units) {
case NSVG_UNITS_USER: return c.value;
case NSVG_UNITS_PX: return c.value;
case NSVG_UNITS_PT: return c.value / 72.0f * p->dpi;
case NSVG_UNITS_PC: return c.value / 6.0f * p->dpi;
case NSVG_UNITS_MM: return c.value / 25.4f * p->dpi;
case NSVG_UNITS_CM: return c.value / 2.54f * p->dpi;
case NSVG_UNITS_IN: return c.value * p->dpi;
case NSVG_UNITS_EM: return c.value * attr->fontSize;
case NSVG_UNITS_EX: return c.value * attr->fontSize * 0.52f; // x-height of Helvetica.
case NSVG_UNITS_PERCENT: return orig + c.value / 100.0f * length;
default: return c.value;
}
return c.value;
}
static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id)
{
NSVGgradientData* grad = p->gradients;
if (id == NULL || *id == '\0')
return NULL;
while (grad != NULL) {
if (strcmp(grad->id, id) == 0)
return grad;
grad = grad->next;
}
return NULL;
}
static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const float* localBounds, float *xform, signed char* paintType)
{
NSVGgradientData* data = NULL;
NSVGgradientData* ref = NULL;
NSVGgradientStop* stops = NULL;
NSVGgradient* grad;
float ox, oy, sw, sh, sl;
int nstops = 0;
int refIter;
data = nsvg__findGradientData(p, id);
if (data == NULL) return NULL;
// TODO: use ref to fill in all unset values too.
ref = data;
refIter = 0;
while (ref != NULL) {
NSVGgradientData* nextRef = NULL;
if (stops == NULL && ref->stops != NULL) {
stops = ref->stops;
nstops = ref->nstops;
break;
}
nextRef = nsvg__findGradientData(p, ref->ref);
if (nextRef == ref) break; // prevent infite loops on malformed data
ref = nextRef;
refIter++;
if (refIter > 32) break; // prevent infite loops on malformed data
}
if (stops == NULL) return NULL;
grad = (NSVGgradient*)NVG_MALLOC(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1));
if (grad == NULL) return NULL;
// The shape width and height.
if (data->units == NSVG_OBJECT_SPACE) {
ox = localBounds[0];
oy = localBounds[1];
sw = localBounds[2] - localBounds[0];
sh = localBounds[3] - localBounds[1];
} else {
ox = nsvg__actualOrigX(p);
oy = nsvg__actualOrigY(p);
sw = nsvg__actualWidth(p);
sh = nsvg__actualHeight(p);
}
sl = sqrtf(sw*sw + sh*sh) / sqrtf(2.0f);
if (data->type == NSVG_PAINT_LINEAR_GRADIENT) {
float x1, y1, x2, y2, dx, dy;
x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw);
y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh);
x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw);
y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh);
// Calculate transform aligned to the line
dx = x2 - x1;
dy = y2 - y1;
grad->xform[0] = dy; grad->xform[1] = -dx;
grad->xform[2] = dx; grad->xform[3] = dy;
grad->xform[4] = x1; grad->xform[5] = y1;
} else {
float cx, cy, fx, fy, r;
cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw);
cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh);
fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw);
fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh);
r = nsvg__convertToPixels(p, data->radial.r, 0, sl);
// Calculate transform aligned to the circle
grad->xform[0] = r; grad->xform[1] = 0;
grad->xform[2] = 0; grad->xform[3] = r;
grad->xform[4] = cx; grad->xform[5] = cy;
grad->fx = (fx - cx) / r;
grad->fy = (fy - cy) / r;
}
nsvg__xformMultiply(grad->xform, data->xform);
nsvg__xformMultiply(grad->xform, xform);
grad->spread = data->spread;
memcpy(grad->stops, stops, nstops*sizeof(NSVGgradientStop));
grad->nstops = nstops;
*paintType = data->type;
return grad;
}
static float nsvg__getAverageScale(float* t)
{
float sx = sqrtf(t[0]*t[0] + t[2]*t[2]);
float sy = sqrtf(t[1]*t[1] + t[3]*t[3]);
return (sx + sy) * 0.5f;
}
static void nsvg__getLocalBounds(float* bounds, NSVGshape *shape, float* xform)
{
NSVGpath* path;
float curve[4*2], curveBounds[4];
int i, first = 1;
for (path = shape->paths; path != NULL; path = path->next) {
nsvg__xformPoint(&curve[0], &curve[1], path->pts[0], path->pts[1], xform);
for (i = 0; i < path->npts-1; i += 3) {
nsvg__xformPoint(&curve[2], &curve[3], path->pts[(i+1)*2], path->pts[(i+1)*2+1], xform);
nsvg__xformPoint(&curve[4], &curve[5], path->pts[(i+2)*2], path->pts[(i+2)*2+1], xform);
nsvg__xformPoint(&curve[6], &curve[7], path->pts[(i+3)*2], path->pts[(i+3)*2+1], xform);
nsvg__curveBounds(curveBounds, curve);
if (first) {
bounds[0] = curveBounds[0];
bounds[1] = curveBounds[1];
bounds[2] = curveBounds[2];
bounds[3] = curveBounds[3];
first = 0;
} else {
bounds[0] = nsvg__minf(bounds[0], curveBounds[0]);
bounds[1] = nsvg__minf(bounds[1], curveBounds[1]);
bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]);
bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]);
}
curve[0] = curve[6];
curve[1] = curve[7];
}
}
}
static void nsvg__addShape(NSVGparser* p)
{
NSVGattrib* attr = nsvg__getAttr(p);
float scale = 1.0f;
NSVGshape* shape;
NSVGpath* path;
int i;
if (p->plist == NULL)
return;
shape = (NSVGshape*)NVG_MALLOC(sizeof(NSVGshape));
if (shape == NULL) goto error;
memset(shape, 0, sizeof(NSVGshape));
memcpy(shape->id, attr->id, sizeof shape->id);
memcpy(shape->fillGradient, attr->fillGradient, sizeof shape->fillGradient);
memcpy(shape->strokeGradient, attr->strokeGradient, sizeof shape->strokeGradient);
memcpy(shape->xform, attr->xform, sizeof shape->xform);
scale = nsvg__getAverageScale(attr->xform);
shape->strokeWidth = attr->strokeWidth * scale;
shape->strokeDashOffset = attr->strokeDashOffset * scale;
shape->strokeDashCount = (char)attr->strokeDashCount;
for (i = 0; i < attr->strokeDashCount; i++)
shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
shape->strokeLineJoin = attr->strokeLineJoin;
shape->strokeLineCap = attr->strokeLineCap;
shape->miterLimit = attr->miterLimit;
shape->fillRule = attr->fillRule;
shape->opacity = attr->opacity;
shape->paths = p->plist;
p->plist = NULL;
// Calculate shape bounds
shape->bounds[0] = shape->paths->bounds[0];
shape->bounds[1] = shape->paths->bounds[1];
shape->bounds[2] = shape->paths->bounds[2];
shape->bounds[3] = shape->paths->bounds[3];
for (path = shape->paths->next; path != NULL; path = path->next) {
shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]);
shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]);
shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]);
shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]);
}
// Set fill
if (attr->hasFill == 0) {
shape->fill.type = NSVG_PAINT_NONE;
} else if (attr->hasFill == 1) {
shape->fill.type = NSVG_PAINT_COLOR;
shape->fill.color = attr->fillColor;
shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24;
} else if (attr->hasFill == 2) {
shape->fill.type = NSVG_PAINT_UNDEF;
}
// Set stroke
if (attr->hasStroke == 0) {
shape->stroke.type = NSVG_PAINT_NONE;
} else if (attr->hasStroke == 1) {
shape->stroke.type = NSVG_PAINT_COLOR;
shape->stroke.color = attr->strokeColor;
shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24;
} else if (attr->hasStroke == 2) {
shape->stroke.type = NSVG_PAINT_UNDEF;
}
// Set flags
shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00);
// Add to tail
if (p->image->shapes == NULL)
p->image->shapes = shape;
else
p->shapesTail->next = shape;
p->shapesTail = shape;
return;
error:
if (shape) NVG_FREE(shape);
}
static void nsvg__addPath(NSVGparser* p, char closed)
{
NSVGattrib* attr = nsvg__getAttr(p);
NSVGpath* path = NULL;
float bounds[4];
float* curve;
int i;
if (p->npts < 4)
return;
if (closed)
nsvg__lineTo(p, p->pts[0], p->pts[1]);
// Expect 1 + N*3 points (N = number of cubic bezier segments).
if ((p->npts % 3) != 1)
return;
path = (NSVGpath*)NVG_MALLOC(sizeof(NSVGpath));
if (path == NULL) goto error;
memset(path, 0, sizeof(NSVGpath));
path->pts = (float*)NVG_MALLOC(p->npts*2*sizeof(float));
if (path->pts == NULL) goto error;
path->closed = closed;
path->npts = p->npts;
// Transform path.
for (i = 0; i < p->npts; ++i)
nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform);
// Find bounds
for (i = 0; i < path->npts-1; i += 3) {
curve = &path->pts[i*2];
nsvg__curveBounds(bounds, curve);
if (i == 0) {
path->bounds[0] = bounds[0];
path->bounds[1] = bounds[1];
path->bounds[2] = bounds[2];
path->bounds[3] = bounds[3];
} else {
path->bounds[0] = nsvg__minf(path->bounds[0], bounds[0]);
path->bounds[1] = nsvg__minf(path->bounds[1], bounds[1]);
path->bounds[2] = nsvg__maxf(path->bounds[2], bounds[2]);
path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]);
}
}
path->next = p->plist;
p->plist = path;
return;
error:
if (path != NULL) {
if (path->pts != NULL) NVG_FREE(path->pts);
NVG_FREE(path);
}
}
// We roll our own string to float because the std library one uses locale and messes things up.
static double nsvg__atof(const char* s)
{
char* cur = (char*)s;
char* end = NULL;
double res = 0.0, sign = 1.0;
long long intPart = 0, fracPart = 0;
char hasIntPart = 0, hasFracPart = 0;
// Parse optional sign
if (*cur == '+') {
cur++;
} else if (*cur == '-') {
sign = -1;
cur++;
}
// Parse integer part
if (nsvg__isdigit(*cur)) {
// Parse digit sequence
intPart = strtoll(cur, &end, 10);
if (cur != end) {
res = (double)intPart;
hasIntPart = 1;
cur = end;
}
}
// Parse fractional part.
if (*cur == '.') {
cur++; // Skip '.'
if (nsvg__isdigit(*cur)) {
// Parse digit sequence
fracPart = strtoll(cur, &end, 10);
if (cur != end) {
res += (double)fracPart / pow(10.0, (double)(end - cur));
hasFracPart = 1;
cur = end;
}
}
}
// A valid number should have integer or fractional part.
if (!hasIntPart && !hasFracPart)
return 0.0;
// Parse optional exponent
if (*cur == 'e' || *cur == 'E') {
long expPart = 0;
cur++; // skip 'E'
expPart = strtol(cur, &end, 10); // Parse digit sequence with sign
if (cur != end) {
res *= pow(10.0, (double)expPart);
}
}
return res * sign;
}
static const char* nsvg__parseNumber(const char* s, char* it, const int size)
{
const int last = size-1;
int i = 0;
// sign
if (*s == '-' || *s == '+') {
if (i < last) it[i++] = *s;
s++;
}
// integer part
while (*s && nsvg__isdigit(*s)) {
if (i < last) it[i++] = *s;
s++;
}
if (*s == '.') {
// decimal point
if (i < last) it[i++] = *s;
s++;
// fraction part
while (*s && nsvg__isdigit(*s)) {
if (i < last) it[i++] = *s;
s++;
}
}
// exponent
if ((*s == 'e' || *s == 'E') && (s[1] != 'm' && s[1] != 'x')) {
if (i < last) it[i++] = *s;
s++;
if (*s == '-' || *s == '+') {
if (i < last) it[i++] = *s;
s++;
}
while (*s && nsvg__isdigit(*s)) {
if (i < last) it[i++] = *s;
s++;
}
}
it[i] = '\0';
return s;
}
static const char* nsvg__getNextPathItemWhenArcFlag(const char* s, char* it)
{
it[0] = '\0';
while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
if (!*s) return s;
if (*s == '0' || *s == '1') {
it[0] = *s++;
it[1] = '\0';
return s;
}
return s;
}
static const char* nsvg__getNextPathItem(const char* s, char* it)
{
it[0] = '\0';
// Skip white spaces and commas
while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
if (!*s) return s;
if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) {
s = nsvg__parseNumber(s, it, 64);
} else {
// Parse command
it[0] = *s++;
it[1] = '\0';
return s;
}
return s;
}
static unsigned int nsvg__parseColorHex(const char* str)
{
unsigned int r=0, g=0, b=0;
if (sscanf(str, "#%2x%2x%2x", &r, &g, &b) == 3 ) // 2 digit hex
return NSVG_RGB(r, g, b);
if (sscanf(str, "#%1x%1x%1x", &r, &g, &b) == 3 ) // 1 digit hex, e.g. #abc -> 0xccbbaa
return NSVG_RGB(r*17, g*17, b*17); // same effect as (r<<4|r), (g<<4|g), ..
return NSVG_RGB(128, 128, 128);
}
// Parse rgb color. The pointer 'str' must point at "rgb(" (4+ characters).
// This function returns gray (rgb(128, 128, 128) == '#808080') on parse errors
// for backwards compatibility. Note: other image viewers return black instead.
static unsigned int nsvg__parseColorRGB(const char* str)
{
int i;
unsigned int rgbi[3];
float rgbf[3];
// try decimal integers first
if (sscanf(str, "rgb(%u, %u, %u)", &rgbi[0], &rgbi[1], &rgbi[2]) != 3) {
// integers failed, try percent values (float, locale independent)
const char delimiter[3] = {',', ',', ')'};
str += 4; // skip "rgb("
for (i = 0; i < 3; i++) {
while (*str && (nsvg__isspace(*str))) str++; // skip leading spaces
if (*str == '+') str++; // skip '+' (don't allow '-')
if (!*str) break;
rgbf[i] = nsvg__atof(str);
// Note 1: it would be great if nsvg__atof() returned how many
// bytes it consumed but it doesn't. We need to skip the number,
// the '%' character, spaces, and the delimiter ',' or ')'.
// Note 2: The following code does not allow values like "33.%",
// i.e. a decimal point w/o fractional part, but this is consistent
// with other image viewers, e.g. firefox, chrome, eog, gimp.
while (*str && nsvg__isdigit(*str)) str++; // skip integer part
if (*str == '.') {
str++;
if (!nsvg__isdigit(*str)) break; // error: no digit after '.'
while (*str && nsvg__isdigit(*str)) str++; // skip fractional part
}
if (*str == '%') str++; else break;
while (nsvg__isspace(*str)) str++;
if (*str == delimiter[i]) str++;
else break;
}
if (i == 3) {
rgbi[0] = roundf(rgbf[0] * 2.55f);
rgbi[1] = roundf(rgbf[1] * 2.55f);
rgbi[2] = roundf(rgbf[2] * 2.55f);
} else {
rgbi[0] = rgbi[1] = rgbi[2] = 128;
}
}
// clip values as the CSS spec requires
for (i = 0; i < 3; i++) {
if (rgbi[i] > 255) rgbi[i] = 255;
}
return NSVG_RGB(rgbi[0], rgbi[1], rgbi[2]);
}
static unsigned int nsvg__parseColorRGBA(const char* str)
{
int i;
unsigned int rgbai[4];
float rgbaf[4];
// try decimal integers first
if (sscanf(str, "rgba(%u, %u, %u, %u)", &rgbai[0], &rgbai[1], &rgbai[2], &rgbai[3]) != 4) {
// integers failed, try percent values (float, locale independent)
const char delimiter[4] = {',', ',', ',', ')'};
str += 5; // skip "rgba("
for (i = 0; i < 4; i++) {
while (*str && (nsvg__isspace(*str))) str++; // skip leading spaces
if (*str == '+') str++; // skip '+' (don't allow '-')
if (!*str) break;
rgbaf[i] = nsvg__atof(str);
// Note 1: it would be great if nsvg__atof() returned how many
// bytes it consumed but it doesn't. We need to skip the number,
// the '%' character, spaces, and the delimiter ',' or ')'.
// Note 2: The following code does not allow values like "33.%",
// i.e. a decimal point w/o fractional part, but this is consistent
// with other image viewers, e.g. firefox, chrome, eog, gimp.
while (*str && nsvg__isdigit(*str)) str++; // skip integer part
if (*str == '.') {
str++;
if (!nsvg__isdigit(*str)) break; // error: no digit after '.'
while (*str && nsvg__isdigit(*str)) str++; // skip fractional part
}
if (*str == '%') str++; else break;
while (nsvg__isspace(*str)) str++;
if (*str == delimiter[i]) str++;
else break;
}
if (i == 4) {
rgbai[0] = roundf(rgbaf[0] * 2.55f);
rgbai[1] = roundf(rgbaf[1] * 2.55f);
rgbai[2] = roundf(rgbaf[2] * 2.55f);
rgbai[3] = roundf(rgbaf[3] * 2.55f);
} else {
rgbai[0] = rgbai[1] = rgbai[2] = 128;
rgbai[3] = 255;
}
}
// clip values as the CSS spec requires
for (i = 0; i < 4; i++) {
if (rgbai[i] > 255) rgbai[i] = 255;
}
return NSVG_RGBA(rgbai[0], rgbai[1], rgbai[2], rgbai[3]);
}
typedef struct NSVGNamedColor {
const char* name;
unsigned int color;
} NSVGNamedColor;
NSVGNamedColor nsvg__colors[] = {
{ "red", NSVG_RGB(255, 0, 0) },
{ "green", NSVG_RGB( 0, 128, 0) },
{ "blue", NSVG_RGB( 0, 0, 255) },
{ "yellow", NSVG_RGB(255, 255, 0) },
{ "cyan", NSVG_RGB( 0, 255, 255) },
{ "magenta", NSVG_RGB(255, 0, 255) },
{ "black", NSVG_RGB( 0, 0, 0) },
{ "grey", NSVG_RGB(128, 128, 128) },
{ "gray", NSVG_RGB(128, 128, 128) },
{ "white", NSVG_RGB(255, 255, 255) },
#ifdef NANOSVG_ALL_COLOR_KEYWORDS
{ "aliceblue", NSVG_RGB(240, 248, 255) },
{ "antiquewhite", NSVG_RGB(250, 235, 215) },
{ "aqua", NSVG_RGB( 0, 255, 255) },
{ "aquamarine", NSVG_RGB(127, 255, 212) },
{ "azure", NSVG_RGB(240, 255, 255) },
{ "beige", NSVG_RGB(245, 245, 220) },
{ "bisque", NSVG_RGB(255, 228, 196) },
{ "blanchedalmond", NSVG_RGB(255, 235, 205) },
{ "blueviolet", NSVG_RGB(138, 43, 226) },
{ "brown", NSVG_RGB(165, 42, 42) },
{ "burlywood", NSVG_RGB(222, 184, 135) },
{ "cadetblue", NSVG_RGB( 95, 158, 160) },
{ "chartreuse", NSVG_RGB(127, 255, 0) },
{ "chocolate", NSVG_RGB(210, 105, 30) },
{ "coral", NSVG_RGB(255, 127, 80) },
{ "cornflowerblue", NSVG_RGB(100, 149, 237) },
{ "cornsilk", NSVG_RGB(255, 248, 220) },
{ "crimson", NSVG_RGB(220, 20, 60) },
{ "darkblue", NSVG_RGB( 0, 0, 139) },
{ "darkcyan", NSVG_RGB( 0, 139, 139) },
{ "darkgoldenrod", NSVG_RGB(184, 134, 11) },
{ "darkgray", NSVG_RGB(169, 169, 169) },
{ "darkgreen", NSVG_RGB( 0, 100, 0) },
{ "darkgrey", NSVG_RGB(169, 169, 169) },
{ "darkkhaki", NSVG_RGB(189, 183, 107) },
{ "darkmagenta", NSVG_RGB(139, 0, 139) },
{ "darkolivegreen", NSVG_RGB( 85, 107, 47) },
{ "darkorange", NSVG_RGB(255, 140, 0) },
{ "darkorchid", NSVG_RGB(153, 50, 204) },
{ "darkred", NSVG_RGB(139, 0, 0) },
{ "darksalmon", NSVG_RGB(233, 150, 122) },
{ "darkseagreen", NSVG_RGB(143, 188, 143) },
{ "darkslateblue", NSVG_RGB( 72, 61, 139) },
{ "darkslategray", NSVG_RGB( 47, 79, 79) },
{ "darkslategrey", NSVG_RGB( 47, 79, 79) },
{ "darkturquoise", NSVG_RGB( 0, 206, 209) },
{ "darkviolet", NSVG_RGB(148, 0, 211) },
{ "deeppink", NSVG_RGB(255, 20, 147) },
{ "deepskyblue", NSVG_RGB( 0, 191, 255) },
{ "dimgray", NSVG_RGB(105, 105, 105) },
{ "dimgrey", NSVG_RGB(105, 105, 105) },
{ "dodgerblue", NSVG_RGB( 30, 144, 255) },
{ "firebrick", NSVG_RGB(178, 34, 34) },
{ "floralwhite", NSVG_RGB(255, 250, 240) },
{ "forestgreen", NSVG_RGB( 34, 139, 34) },
{ "fuchsia", NSVG_RGB(255, 0, 255) },
{ "gainsboro", NSVG_RGB(220, 220, 220) },
{ "ghostwhite", NSVG_RGB(248, 248, 255) },
{ "gold", NSVG_RGB(255, 215, 0) },
{ "goldenrod", NSVG_RGB(218, 165, 32) },
{ "greenyellow", NSVG_RGB(173, 255, 47) },
{ "honeydew", NSVG_RGB(240, 255, 240) },
{ "hotpink", NSVG_RGB(255, 105, 180) },
{ "indianred", NSVG_RGB(205, 92, 92) },
{ "indigo", NSVG_RGB( 75, 0, 130) },
{ "ivory", NSVG_RGB(255, 255, 240) },
{ "khaki", NSVG_RGB(240, 230, 140) },
{ "lavender", NSVG_RGB(230, 230, 250) },
{ "lavenderblush", NSVG_RGB(255, 240, 245) },
{ "lawngreen", NSVG_RGB(124, 252, 0) },
{ "lemonchiffon", NSVG_RGB(255, 250, 205) },
{ "lightblue", NSVG_RGB(173, 216, 230) },
{ "lightcoral", NSVG_RGB(240, 128, 128) },
{ "lightcyan", NSVG_RGB(224, 255, 255) },
{ "lightgoldenrodyellow", NSVG_RGB(250, 250, 210) },
{ "lightgray", NSVG_RGB(211, 211, 211) },
{ "lightgreen", NSVG_RGB(144, 238, 144) },
{ "lightgrey", NSVG_RGB(211, 211, 211) },
{ "lightpink", NSVG_RGB(255, 182, 193) },
{ "lightsalmon", NSVG_RGB(255, 160, 122) },
{ "lightseagreen", NSVG_RGB( 32, 178, 170) },
{ "lightskyblue", NSVG_RGB(135, 206, 250) },
{ "lightslategray", NSVG_RGB(119, 136, 153) },
{ "lightslategrey", NSVG_RGB(119, 136, 153) },
{ "lightsteelblue", NSVG_RGB(176, 196, 222) },
{ "lightyellow", NSVG_RGB(255, 255, 224) },
{ "lime", NSVG_RGB( 0, 255, 0) },
{ "limegreen", NSVG_RGB( 50, 205, 50) },
{ "linen", NSVG_RGB(250, 240, 230) },
{ "maroon", NSVG_RGB(128, 0, 0) },
{ "mediumaquamarine", NSVG_RGB(102, 205, 170) },
{ "mediumblue", NSVG_RGB( 0, 0, 205) },
{ "mediumorchid", NSVG_RGB(186, 85, 211) },
{ "mediumpurple", NSVG_RGB(147, 112, 219) },
{ "mediumseagreen", NSVG_RGB( 60, 179, 113) },
{ "mediumslateblue", NSVG_RGB(123, 104, 238) },
{ "mediumspringgreen", NSVG_RGB( 0, 250, 154) },
{ "mediumturquoise", NSVG_RGB( 72, 209, 204) },
{ "mediumvioletred", NSVG_RGB(199, 21, 133) },
{ "midnightblue", NSVG_RGB( 25, 25, 112) },
{ "mintcream", NSVG_RGB(245, 255, 250) },
{ "mistyrose", NSVG_RGB(255, 228, 225) },
{ "moccasin", NSVG_RGB(255, 228, 181) },
{ "navajowhite", NSVG_RGB(255, 222, 173) },
{ "navy", NSVG_RGB( 0, 0, 128) },
{ "oldlace", NSVG_RGB(253, 245, 230) },
{ "olive", NSVG_RGB(128, 128, 0) },
{ "olivedrab", NSVG_RGB(107, 142, 35) },
{ "orange", NSVG_RGB(255, 165, 0) },
{ "orangered", NSVG_RGB(255, 69, 0) },
{ "orchid", NSVG_RGB(218, 112, 214) },
{ "palegoldenrod", NSVG_RGB(238, 232, 170) },
{ "palegreen", NSVG_RGB(152, 251, 152) },
{ "paleturquoise", NSVG_RGB(175, 238, 238) },
{ "palevioletred", NSVG_RGB(219, 112, 147) },
{ "papayawhip", NSVG_RGB(255, 239, 213) },
{ "peachpuff", NSVG_RGB(255, 218, 185) },
{ "peru", NSVG_RGB(205, 133, 63) },
{ "pink", NSVG_RGB(255, 192, 203) },
{ "plum", NSVG_RGB(221, 160, 221) },
{ "powderblue", NSVG_RGB(176, 224, 230) },
{ "purple", NSVG_RGB(128, 0, 128) },
{ "rosybrown", NSVG_RGB(188, 143, 143) },
{ "royalblue", NSVG_RGB( 65, 105, 225) },
{ "saddlebrown", NSVG_RGB(139, 69, 19) },
{ "salmon", NSVG_RGB(250, 128, 114) },
{ "sandybrown", NSVG_RGB(244, 164, 96) },
{ "seagreen", NSVG_RGB( 46, 139, 87) },
{ "seashell", NSVG_RGB(255, 245, 238) },
{ "sienna", NSVG_RGB(160, 82, 45) },
{ "silver", NSVG_RGB(192, 192, 192) },
{ "skyblue", NSVG_RGB(135, 206, 235) },
{ "slateblue", NSVG_RGB(106, 90, 205) },
{ "slategray", NSVG_RGB(112, 128, 144) },
{ "slategrey", NSVG_RGB(112, 128, 144) },
{ "snow", NSVG_RGB(255, 250, 250) },
{ "springgreen", NSVG_RGB( 0, 255, 127) },
{ "steelblue", NSVG_RGB( 70, 130, 180) },
{ "tan", NSVG_RGB(210, 180, 140) },
{ "teal", NSVG_RGB( 0, 128, 128) },
{ "thistle", NSVG_RGB(216, 191, 216) },
{ "tomato", NSVG_RGB(255, 99, 71) },
{ "turquoise", NSVG_RGB( 64, 224, 208) },
{ "violet", NSVG_RGB(238, 130, 238) },
{ "wheat", NSVG_RGB(245, 222, 179) },
{ "whitesmoke", NSVG_RGB(245, 245, 245) },
{ "yellowgreen", NSVG_RGB(154, 205, 50) },
#endif
};
static unsigned int nsvg__parseColorName(const char* str)
{
int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor);
for (i = 0; i < ncolors; i++) {
if (strcmp(nsvg__colors[i].name, str) == 0) {
return nsvg__colors[i].color;
}
}
return NSVG_RGB(128, 128, 128);
}
static unsigned int nsvg__parseColor(const char* str)
{
size_t len = 0;
while(*str == ' ') ++str;
len = strlen(str);
if (len >= 1 && *str == '#')
return nsvg__parseColorHex(str);
else if (len >= 4 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == '(')
return nsvg__parseColorRGB(str);
else if (len >= 5 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == 'a' && str[4] == '(')
return nsvg__parseColorRGBA(str);
return nsvg__parseColorName(str);
}
static float nsvg__parseOpacity(const char* str)
{
float val = nsvg__atof(str);
if (val < 0.0f) val = 0.0f;
if (val > 1.0f) val = 1.0f;
return val;
}
static float nsvg__parseMiterLimit(const char* str)
{
float val = nsvg__atof(str);
if (val < 0.0f) val = 0.0f;
return val;
}
static int nsvg__parseUnits(const char* units)
{
if (units[0] == 'p' && units[1] == 'x')
return NSVG_UNITS_PX;
else if (units[0] == 'p' && units[1] == 't')
return NSVG_UNITS_PT;
else if (units[0] == 'p' && units[1] == 'c')
return NSVG_UNITS_PC;
else if (units[0] == 'm' && units[1] == 'm')
return NSVG_UNITS_MM;
else if (units[0] == 'c' && units[1] == 'm')
return NSVG_UNITS_CM;
else if (units[0] == 'i' && units[1] == 'n')
return NSVG_UNITS_IN;
else if (units[0] == '%')
return NSVG_UNITS_PERCENT;
else if (units[0] == 'e' && units[1] == 'm')
return NSVG_UNITS_EM;
else if (units[0] == 'e' && units[1] == 'x')
return NSVG_UNITS_EX;
return NSVG_UNITS_USER;
}
static int nsvg__isCoordinate(const char* s)
{
// optional sign
if (*s == '-' || *s == '+')
s++;
// must have at least one digit, or start by a dot
return (nsvg__isdigit(*s) || *s == '.');
}
static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str)
{
NSVGcoordinate coord = {0, NSVG_UNITS_USER};
char buf[64];
coord.units = nsvg__parseUnits(nsvg__parseNumber(str, buf, 64));
coord.value = nsvg__atof(buf);
return coord;
}
static NSVGcoordinate nsvg__coord(float v, int units)
{
NSVGcoordinate coord = {v, units};
return coord;
}
static float nsvg__parseCoordinate(NSVGparser* p, const char* str, float orig, float length)
{
NSVGcoordinate coord = nsvg__parseCoordinateRaw(str);
return nsvg__convertToPixels(p, coord, orig, length);
}
static int nsvg__parseTransformArgs(const char* str, float* args, int maxNa, int* na)
{
const char* end;
const char* ptr;
char it[64];
*na = 0;
ptr = str;
while (*ptr && *ptr != '(') ++ptr;
if (*ptr == 0)
return 1;
end = ptr;
while (*end && *end != ')') ++end;
if (*end == 0)
return 1;
while (ptr < end) {
if (*ptr == '-' || *ptr == '+' || *ptr == '.' || nsvg__isdigit(*ptr)) {
if (*na >= maxNa) return 0;
ptr = nsvg__parseNumber(ptr, it, 64);
args[(*na)++] = (float)nsvg__atof(it);
} else {
++ptr;
}
}
return (int)(end - str);
}
static int nsvg__parseMatrix(float* xform, const char* str)
{
float t[6];
int na = 0;
int len = nsvg__parseTransformArgs(str, t, 6, &na);
if (na != 6) return len;
memcpy(xform, t, sizeof(float)*6);
return len;
}
static int nsvg__parseTranslate(float* xform, const char* str)
{
float args[2];
float t[6];
int na = 0;
int len = nsvg__parseTransformArgs(str, args, 2, &na);
if (na == 1) args[1] = 0.0;
nsvg__xformSetTranslation(t, args[0], args[1]);
memcpy(xform, t, sizeof(float)*6);
return len;
}
static int nsvg__parseScale(float* xform, const char* str)
{
float args[2];
int na = 0;
float t[6];
int len = nsvg__parseTransformArgs(str, args, 2, &na);
if (na == 1) args[1] = args[0];
nsvg__xformSetScale(t, args[0], args[1]);
memcpy(xform, t, sizeof(float)*6);
return len;
}
static int nsvg__parseSkewX(float* xform, const char* str)
{
float args[1];
int na = 0;
float t[6];
int len = nsvg__parseTransformArgs(str, args, 1, &na);
nsvg__xformSetSkewX(t, args[0]/180.0f*NSVG_PI);
memcpy(xform, t, sizeof(float)*6);
return len;
}
static int nsvg__parseSkewY(float* xform, const char* str)
{
float args[1];
int na = 0;
float t[6];
int len = nsvg__parseTransformArgs(str, args, 1, &na);
nsvg__xformSetSkewY(t, args[0]/180.0f*NSVG_PI);
memcpy(xform, t, sizeof(float)*6);
return len;
}
static int nsvg__parseRotate(float* xform, const char* str)
{
float args[3];
int na = 0;
float m[6];
float t[6];
int len = nsvg__parseTransformArgs(str, args, 3, &na);
if (na == 1)
args[1] = args[2] = 0.0f;
nsvg__xformIdentity(m);
if (na > 1) {
nsvg__xformSetTranslation(t, -args[1], -args[2]);
nsvg__xformMultiply(m, t);
}
nsvg__xformSetRotation(t, args[0]/180.0f*NSVG_PI);
nsvg__xformMultiply(m, t);
if (na > 1) {
nsvg__xformSetTranslation(t, args[1], args[2]);
nsvg__xformMultiply(m, t);
}
memcpy(xform, m, sizeof(float)*6);
return len;
}
static void nsvg__parseTransform(float* xform, const char* str)
{
float t[6];
int len;
nsvg__xformIdentity(xform);
while (*str)
{
if (strncmp(str, "matrix", 6) == 0)
len = nsvg__parseMatrix(t, str);
else if (strncmp(str, "translate", 9) == 0)
len = nsvg__parseTranslate(t, str);
else if (strncmp(str, "scale", 5) == 0)
len = nsvg__parseScale(t, str);
else if (strncmp(str, "rotate", 6) == 0)
len = nsvg__parseRotate(t, str);
else if (strncmp(str, "skewX", 5) == 0)
len = nsvg__parseSkewX(t, str);
else if (strncmp(str, "skewY", 5) == 0)
len = nsvg__parseSkewY(t, str);
else{
++str;
continue;
}
if (len != 0) {
str += len;
} else {
++str;
continue;
}
nsvg__xformPremultiply(xform, t);
}
}
static void nsvg__parseUrl(char* id, const char* str)
{
int i = 0;
str += 4; // "url(";
if (*str && *str == '#')
str++;
while (i < 63 && *str && *str != ')') {
id[i] = *str++;
i++;
}
id[i] = '\0';
}
static char nsvg__parseLineCap(const char* str)
{
if (strcmp(str, "butt") == 0)
return NSVG_CAP_BUTT;
else if (strcmp(str, "round") == 0)
return NSVG_CAP_ROUND;
else if (strcmp(str, "square") == 0)
return NSVG_CAP_SQUARE;
// TODO: handle inherit.
return NSVG_CAP_BUTT;
}
static char nsvg__parseLineJoin(const char* str)
{
if (strcmp(str, "miter") == 0)
return NSVG_JOIN_MITER;
else if (strcmp(str, "round") == 0)
return NSVG_JOIN_ROUND;
else if (strcmp(str, "bevel") == 0)
return NSVG_JOIN_BEVEL;
// TODO: handle inherit.
return NSVG_JOIN_MITER;
}
static char nsvg__parseFillRule(const char* str)
{
if (strcmp(str, "nonzero") == 0)
return NSVG_FILLRULE_NONZERO;
else if (strcmp(str, "evenodd") == 0)
return NSVG_FILLRULE_EVENODD;
// TODO: handle inherit.
return NSVG_FILLRULE_NONZERO;
}
static const char* nsvg__getNextDashItem(const char* s, char* it)
{
int n = 0;
it[0] = '\0';
// Skip white spaces and commas
while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
// Advance until whitespace, comma or end.
while (*s && (!nsvg__isspace(*s) && *s != ',')) {
if (n < 63)
it[n++] = *s;
s++;
}
it[n++] = '\0';
return s;
}
static int nsvg__parseStrokeDashArray(NSVGparser* p, const char* str, float* strokeDashArray)
{
char item[64];
int count = 0, i;
float sum = 0.0f;
// Handle "none"
if (str[0] == 'n')
return 0;
// Parse dashes
while (*str) {
str = nsvg__getNextDashItem(str, item);
if (!*item) break;
if (count < NSVG_MAX_DASHES)
strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p)));
}
for (i = 0; i < count; i++)
sum += strokeDashArray[i];
if (sum <= 1e-6f)
count = 0;
return count;
}
static void nsvg__parseStyle(NSVGparser* p, const char* str);
static int nsvg__parseAttr(NSVGparser* p, const char* name, const char* value)
{
float xform[6];
NSVGattrib* attr = nsvg__getAttr(p);
if (!attr) return 0;
if (strcmp(name, "style") == 0) {
nsvg__parseStyle(p, value);
} else if (strcmp(name, "display") == 0) {
if (strcmp(value, "none") == 0)
attr->visible = 0;
// Don't reset ->visible on display:inline, one display:none hides the whole subtree
} else if (strcmp(name, "fill") == 0) {
if (strcmp(value, "none") == 0) {
attr->hasFill = 0;
} else if (strncmp(value, "url(", 4) == 0) {
attr->hasFill = 2;
nsvg__parseUrl(attr->fillGradient, value);
} else {
attr->hasFill = 1;
attr->fillColor = nsvg__parseColor(value);
// if the fillColor has an alpha value then use it to
// set the fillOpacity
if (attr->fillColor & 0xFF000000) {
attr->fillOpacity = ((attr->fillColor >> 24) & 0xFF) / 255.0;
// remove the alpha value from the color
attr->fillColor &= 0x00FFFFFF;
}
}
} else if (strcmp(name, "opacity") == 0) {
attr->opacity = nsvg__parseOpacity(value);
} else if (strcmp(name, "fill-opacity") == 0) {
attr->fillOpacity = nsvg__parseOpacity(value);
} else if (strcmp(name, "stroke") == 0) {
if (strcmp(value, "none") == 0) {
attr->hasStroke = 0;
} else if (strncmp(value, "url(", 4) == 0) {
attr->hasStroke = 2;
nsvg__parseUrl(attr->strokeGradient, value);
} else {
attr->hasStroke = 1;
attr->strokeColor = nsvg__parseColor(value);
// if the strokeColor has an alpha value then use it to
// set the strokeOpacity
if (attr->strokeColor & 0xFF000000) {
attr->strokeOpacity = ((attr->strokeColor >> 24) & 0xFF) / 255.0;
// remove the alpha value from the color
attr->strokeColor &= 0x00FFFFFF;
}
}
} else if (strcmp(name, "stroke-width") == 0) {
attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
} else if (strcmp(name, "stroke-dasharray") == 0) {
attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray);
} else if (strcmp(name, "stroke-dashoffset") == 0) {
attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
} else if (strcmp(name, "stroke-opacity") == 0) {
attr->strokeOpacity = nsvg__parseOpacity(value);
} else if (strcmp(name, "stroke-linecap") == 0) {
attr->strokeLineCap = nsvg__parseLineCap(value);
} else if (strcmp(name, "stroke-linejoin") == 0) {
attr->strokeLineJoin = nsvg__parseLineJoin(value);
} else if (strcmp(name, "stroke-miterlimit") == 0) {
attr->miterLimit = nsvg__parseMiterLimit(value);
} else if (strcmp(name, "fill-rule") == 0) {
attr->fillRule = nsvg__parseFillRule(value);
} else if (strcmp(name, "font-size") == 0) {
attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
} else if (strcmp(name, "transform") == 0) {
nsvg__parseTransform(xform, value);
nsvg__xformPremultiply(attr->xform, xform);
} else if (strcmp(name, "stop-color") == 0) {
attr->stopColor = nsvg__parseColor(value);
} else if (strcmp(name, "stop-opacity") == 0) {
attr->stopOpacity = nsvg__parseOpacity(value);
} else if (strcmp(name, "offset") == 0) {
attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f);
} else if (strcmp(name, "id") == 0) {
strncpy(attr->id, value, 63);
attr->id[63] = '\0';
} else {
return 0;
}
return 1;
}
static int nsvg__parseNameValue(NSVGparser* p, const char* start, const char* end)
{
const char* str;
const char* val;
char name[512];
char value[512];
int n;
str = start;
while (str < end && *str != ':') ++str;
val = str;
// Right Trim
while (str > start && (*str == ':' || nsvg__isspace(*str))) --str;
++str;
n = (int)(str - start);
if (n > 511) n = 511;
if (n) memcpy(name, start, n);
name[n] = 0;
while (val < end && (*val == ':' || nsvg__isspace(*val))) ++val;
n = (int)(end - val);
if (n > 511) n = 511;
if (n) memcpy(value, val, n);
value[n] = 0;
return nsvg__parseAttr(p, name, value);
}
static void nsvg__parseStyle(NSVGparser* p, const char* str)
{
const char* start;
const char* end;
while (*str) {
// Left Trim
while(*str && nsvg__isspace(*str)) ++str;
start = str;
while(*str && *str != ';') ++str;
end = str;
// Right Trim
while (end > start && (*end == ';' || nsvg__isspace(*end))) --end;
++end;
nsvg__parseNameValue(p, start, end);
if (*str) ++str;
}
}
static void nsvg__parseAttribs(NSVGparser* p, const char** attr)
{
int i;
for (i = 0; attr[i]; i += 2)
{
if (strcmp(attr[i], "style") == 0)
nsvg__parseStyle(p, attr[i + 1]);
else
nsvg__parseAttr(p, attr[i], attr[i + 1]);
}
}
static int nsvg__getArgsPerElement(char cmd)
{
switch (cmd) {
case 'v':
case 'V':
case 'h':
case 'H':
return 1;
case 'm':
case 'M':
case 'l':
case 'L':
case 't':
case 'T':
return 2;
case 'q':
case 'Q':
case 's':
case 'S':
return 4;
case 'c':
case 'C':
return 6;
case 'a':
case 'A':
return 7;
case 'z':
case 'Z':
return 0;
}
return -1;
}
static void nsvg__pathMoveTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
{
if (rel) {
*cpx += args[0];
*cpy += args[1];
} else {
*cpx = args[0];
*cpy = args[1];
}
nsvg__moveTo(p, *cpx, *cpy);
}
static void nsvg__pathLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
{
if (rel) {
*cpx += args[0];
*cpy += args[1];
} else {
*cpx = args[0];
*cpy = args[1];
}
nsvg__lineTo(p, *cpx, *cpy);
}
static void nsvg__pathHLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
{
if (rel)
*cpx += args[0];
else
*cpx = args[0];
nsvg__lineTo(p, *cpx, *cpy);
}
static void nsvg__pathVLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
{
if (rel)
*cpy += args[0];
else
*cpy = args[0];
nsvg__lineTo(p, *cpx, *cpy);
}
static void nsvg__pathCubicBezTo(NSVGparser* p, float* cpx, float* cpy,
float* cpx2, float* cpy2, float* args, int rel)
{
float x2, y2, cx1, cy1, cx2, cy2;
if (rel) {
cx1 = *cpx + args[0];
cy1 = *cpy + args[1];
cx2 = *cpx + args[2];
cy2 = *cpy + args[3];
x2 = *cpx + args[4];
y2 = *cpy + args[5];
} else {
cx1 = args[0];
cy1 = args[1];
cx2 = args[2];
cy2 = args[3];
x2 = args[4];
y2 = args[5];
}
nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
*cpx2 = cx2;
*cpy2 = cy2;
*cpx = x2;
*cpy = y2;
}
static void nsvg__pathCubicBezShortTo(NSVGparser* p, float* cpx, float* cpy,
float* cpx2, float* cpy2, float* args, int rel)
{
float x1, y1, x2, y2, cx1, cy1, cx2, cy2;
x1 = *cpx;
y1 = *cpy;
if (rel) {
cx2 = *cpx + args[0];
cy2 = *cpy + args[1];
x2 = *cpx + args[2];
y2 = *cpy + args[3];
} else {
cx2 = args[0];
cy2 = args[1];
x2 = args[2];
y2 = args[3];
}
cx1 = 2*x1 - *cpx2;
cy1 = 2*y1 - *cpy2;
nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
*cpx2 = cx2;
*cpy2 = cy2;
*cpx = x2;
*cpy = y2;
}
static void nsvg__pathQuadBezTo(NSVGparser* p, float* cpx, float* cpy,
float* cpx2, float* cpy2, float* args, int rel)
{
float x1, y1, x2, y2, cx, cy;
float cx1, cy1, cx2, cy2;
x1 = *cpx;
y1 = *cpy;
if (rel) {
cx = *cpx + args[0];
cy = *cpy + args[1];
x2 = *cpx + args[2];
y2 = *cpy + args[3];
} else {
cx = args[0];
cy = args[1];
x2 = args[2];
y2 = args[3];
}
// Convert to cubic bezier
cx1 = x1 + 2.0f/3.0f*(cx - x1);
cy1 = y1 + 2.0f/3.0f*(cy - y1);
cx2 = x2 + 2.0f/3.0f*(cx - x2);
cy2 = y2 + 2.0f/3.0f*(cy - y2);
nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
*cpx2 = cx;
*cpy2 = cy;
*cpx = x2;
*cpy = y2;
}
static void nsvg__pathQuadBezShortTo(NSVGparser* p, float* cpx, float* cpy,
float* cpx2, float* cpy2, float* args, int rel)
{
float x1, y1, x2, y2, cx, cy;
float cx1, cy1, cx2, cy2;
x1 = *cpx;
y1 = *cpy;
if (rel) {
x2 = *cpx + args[0];
y2 = *cpy + args[1];
} else {
x2 = args[0];
y2 = args[1];
}
cx = 2*x1 - *cpx2;
cy = 2*y1 - *cpy2;
// Convert to cubix bezier
cx1 = x1 + 2.0f/3.0f*(cx - x1);
cy1 = y1 + 2.0f/3.0f*(cy - y1);
cx2 = x2 + 2.0f/3.0f*(cx - x2);
cy2 = y2 + 2.0f/3.0f*(cy - y2);
nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
*cpx2 = cx;
*cpy2 = cy;
*cpx = x2;
*cpy = y2;
}
static float nsvg__sqr(float x) { return x*x; }
static float nsvg__vmag(float x, float y) { return sqrtf(x*x + y*y); }
static float nsvg__vecrat(float ux, float uy, float vx, float vy)
{
return (ux*vx + uy*vy) / (nsvg__vmag(ux,uy) * nsvg__vmag(vx,vy));
}
static float nsvg__vecang(float ux, float uy, float vx, float vy)
{
float r = nsvg__vecrat(ux,uy, vx,vy);
if (r < -1.0f) r = -1.0f;
if (r > 1.0f) r = 1.0f;
return ((ux*vy < uy*vx) ? -1.0f : 1.0f) * acosf(r);
}
static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
{
// Ported from canvg (https://code.google.com/p/canvg/)
float rx, ry, rotx;
float x1, y1, x2, y2, cx, cy, dx, dy, d;
float x1p, y1p, cxp, cyp, s, sa, sb;
float ux, uy, vx, vy, a1, da;
float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6];
float sinrx, cosrx;
int fa, fs;
int i, ndivs;
float hda, kappa;
rx = fabsf(args[0]); // y radius
ry = fabsf(args[1]); // x radius
rotx = args[2] / 180.0f * NSVG_PI; // x rotation angle
fa = fabsf(args[3]) > 1e-6 ? 1 : 0; // Large arc
fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction
x1 = *cpx; // start point
y1 = *cpy;
if (rel) { // end point
x2 = *cpx + args[5];
y2 = *cpy + args[6];
} else {
x2 = args[5];
y2 = args[6];
}
dx = x1 - x2;
dy = y1 - y2;
d = sqrtf(dx*dx + dy*dy);
if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) {
// The arc degenerates to a line
nsvg__lineTo(p, x2, y2);
*cpx = x2;
*cpy = y2;
return;
}
sinrx = sinf(rotx);
cosrx = cosf(rotx);
// Convert to center point parameterization.
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
// 1) Compute x1', y1'
x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f;
y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f;
d = nsvg__sqr(x1p)/nsvg__sqr(rx) + nsvg__sqr(y1p)/nsvg__sqr(ry);
if (d > 1) {
d = sqrtf(d);
rx *= d;
ry *= d;
}
// 2) Compute cx', cy'
s = 0.0f;
sa = nsvg__sqr(rx)*nsvg__sqr(ry) - nsvg__sqr(rx)*nsvg__sqr(y1p) - nsvg__sqr(ry)*nsvg__sqr(x1p);
sb = nsvg__sqr(rx)*nsvg__sqr(y1p) + nsvg__sqr(ry)*nsvg__sqr(x1p);
if (sa < 0.0f) sa = 0.0f;
if (sb > 0.0f)
s = sqrtf(sa / sb);
if (fa == fs)
s = -s;
cxp = s * rx * y1p / ry;
cyp = s * -ry * x1p / rx;
// 3) Compute cx,cy from cx',cy'
cx = (x1 + x2)/2.0f + cosrx*cxp - sinrx*cyp;
cy = (y1 + y2)/2.0f + sinrx*cxp + cosrx*cyp;
// 4) Calculate theta1, and delta theta.
ux = (x1p - cxp) / rx;
uy = (y1p - cyp) / ry;
vx = (-x1p - cxp) / rx;
vy = (-y1p - cyp) / ry;
a1 = nsvg__vecang(1.0f,0.0f, ux,uy); // Initial angle
da = nsvg__vecang(ux,uy, vx,vy); // Delta angle
// if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI;
// if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0;
if (fs == 0 && da > 0)
da -= 2 * NSVG_PI;
else if (fs == 1 && da < 0)
da += 2 * NSVG_PI;
// Approximate the arc using cubic spline segments.
t[0] = cosrx; t[1] = sinrx;
t[2] = -sinrx; t[3] = cosrx;
t[4] = cx; t[5] = cy;
// Split arc into max 90 degree segments.
// The loop assumes an iteration per end point (including start and end), this +1.
ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f);
hda = (da / (float)ndivs) / 2.0f;
// Fix for ticket #179: division by 0: avoid cotangens around 0 (infinite)
if ((hda < 1e-3f) && (hda > -1e-3f))
hda *= 0.5f;
else
hda = (1.0f - cosf(hda)) / sinf(hda);
kappa = fabsf(4.0f / 3.0f * hda);
if (da < 0.0f)
kappa = -kappa;
for (i = 0; i <= ndivs; i++) {
a = a1 + da * ((float)i/(float)ndivs);
dx = cosf(a);
dy = sinf(a);
nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position
nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); // tangent
if (i > 0)
nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y);
px = x;
py = y;
ptanx = tanx;
ptany = tany;
}
*cpx = x2;
*cpy = y2;
}
static void nsvg__parsePath(NSVGparser* p, const char** attr)
{
const char* s = NULL;
char cmd = '\0';
float args[10];
int nargs;
int rargs = 0;
char initPoint;
float cpx, cpy, cpx2, cpy2;
const char* tmp[4];
char closedFlag;
int i;
char item[64];
for (i = 0; attr[i]; i += 2) {
if (strcmp(attr[i], "d") == 0) {
s = attr[i + 1];
} else {
tmp[0] = attr[i];
tmp[1] = attr[i + 1];
tmp[2] = 0;
tmp[3] = 0;
nsvg__parseAttribs(p, tmp);
}
}
if (s) {
nsvg__resetPath(p);
cpx = 0; cpy = 0;
cpx2 = 0; cpy2 = 0;
initPoint = 0;
closedFlag = 0;
nargs = 0;
while (*s) {
item[0] = '\0';
if ((cmd == 'A' || cmd == 'a') && (nargs == 3 || nargs == 4))
s = nsvg__getNextPathItemWhenArcFlag(s, item);
if (!*item)
s = nsvg__getNextPathItem(s, item);
if (!*item) break;
if (cmd != '\0' && nsvg__isCoordinate(item)) {
if (nargs < 10)
args[nargs++] = (float)nsvg__atof(item);
if (nargs >= rargs) {
switch (cmd) {
case 'm':
case 'M':
nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0);
// Moveto can be followed by multiple coordinate pairs,
// which should be treated as linetos.
cmd = (cmd == 'm') ? 'l' : 'L';
rargs = nsvg__getArgsPerElement(cmd);
cpx2 = cpx; cpy2 = cpy;
initPoint = 1;
break;
case 'l':
case 'L':
nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0);
cpx2 = cpx; cpy2 = cpy;
break;
case 'H':
case 'h':
nsvg__pathHLineTo(p, &cpx, &cpy, args, cmd == 'h' ? 1 : 0);
cpx2 = cpx; cpy2 = cpy;
break;
case 'V':
case 'v':
nsvg__pathVLineTo(p, &cpx, &cpy, args, cmd == 'v' ? 1 : 0);
cpx2 = cpx; cpy2 = cpy;
break;
case 'C':
case 'c':
nsvg__pathCubicBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'c' ? 1 : 0);
break;
case 'S':
case 's':
nsvg__pathCubicBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 's' ? 1 : 0);
break;
case 'Q':
case 'q':
nsvg__pathQuadBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'q' ? 1 : 0);
break;
case 'T':
case 't':
nsvg__pathQuadBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 't' ? 1 : 0);
break;
case 'A':
case 'a':
nsvg__pathArcTo(p, &cpx, &cpy, args, cmd == 'a' ? 1 : 0);
cpx2 = cpx; cpy2 = cpy;
break;
default:
if (nargs >= 2) {
cpx = args[nargs-2];
cpy = args[nargs-1];
cpx2 = cpx; cpy2 = cpy;
}
break;
}
nargs = 0;
}
} else {
cmd = item[0];
if (cmd == 'M' || cmd == 'm') {
// Commit path.
if (p->npts > 0)
nsvg__addPath(p, closedFlag);
// Start new subpath.
nsvg__resetPath(p);
closedFlag = 0;
nargs = 0;
} else if (initPoint == 0) {
// Do not allow other commands until initial point has been set (moveTo called once).
cmd = '\0';
}
if (cmd == 'Z' || cmd == 'z') {
closedFlag = 1;
// Commit path.
if (p->npts > 0) {
// Move current point to first point
cpx = p->pts[0];
cpy = p->pts[1];
cpx2 = cpx; cpy2 = cpy;
nsvg__addPath(p, closedFlag);
}
// Start new subpath.
nsvg__resetPath(p);
nsvg__moveTo(p, cpx, cpy);
closedFlag = 0;
nargs = 0;
}
rargs = nsvg__getArgsPerElement(cmd);
if (rargs == -1) {
// Command not recognized
cmd = '\0';
rargs = 0;
}
}
}
// Commit path.
if (p->npts)
nsvg__addPath(p, closedFlag);
}
nsvg__addShape(p);
}
static void nsvg__parseRect(NSVGparser* p, const char** attr)
{
float x = 0.0f;
float y = 0.0f;
float w = 0.0f;
float h = 0.0f;
float rx = -1.0f; // marks not set
float ry = -1.0f;
int i;
for (i = 0; attr[i]; i += 2) {
if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
if (strcmp(attr[i], "width") == 0) w = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p));
if (strcmp(attr[i], "height") == 0) h = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p));
if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
}
}
if (rx < 0.0f && ry > 0.0f) rx = ry;
if (ry < 0.0f && rx > 0.0f) ry = rx;
if (rx < 0.0f) rx = 0.0f;
if (ry < 0.0f) ry = 0.0f;
if (rx > w/2.0f) rx = w/2.0f;
if (ry > h/2.0f) ry = h/2.0f;
if (w != 0.0f && h != 0.0f) {
nsvg__resetPath(p);
if (rx < 0.00001f || ry < 0.0001f) {
nsvg__moveTo(p, x, y);
nsvg__lineTo(p, x+w, y);
nsvg__lineTo(p, x+w, y+h);
nsvg__lineTo(p, x, y+h);
} else {
// Rounded rectangle
nsvg__moveTo(p, x+rx, y);
nsvg__lineTo(p, x+w-rx, y);
nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry);
nsvg__lineTo(p, x+w, y+h-ry);
nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h);
nsvg__lineTo(p, x+rx, y+h);
nsvg__cubicBezTo(p, x+rx*(1-NSVG_KAPPA90), y+h, x, y+h-ry*(1-NSVG_KAPPA90), x, y+h-ry);
nsvg__lineTo(p, x, y+ry);
nsvg__cubicBezTo(p, x, y+ry*(1-NSVG_KAPPA90), x+rx*(1-NSVG_KAPPA90), y, x+rx, y);
}
nsvg__addPath(p, 1);
nsvg__addShape(p);
}
}
static void nsvg__parseCircle(NSVGparser* p, const char** attr)
{
float cx = 0.0f;
float cy = 0.0f;
float r = 0.0f;
int i;
for (i = 0; attr[i]; i += 2) {
if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
if (strcmp(attr[i], "r") == 0) r = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualLength(p)));
}
}
if (r > 0.0f) {
nsvg__resetPath(p);
nsvg__moveTo(p, cx+r, cy);
nsvg__cubicBezTo(p, cx+r, cy+r*NSVG_KAPPA90, cx+r*NSVG_KAPPA90, cy+r, cx, cy+r);
nsvg__cubicBezTo(p, cx-r*NSVG_KAPPA90, cy+r, cx-r, cy+r*NSVG_KAPPA90, cx-r, cy);
nsvg__cubicBezTo(p, cx-r, cy-r*NSVG_KAPPA90, cx-r*NSVG_KAPPA90, cy-r, cx, cy-r);
nsvg__cubicBezTo(p, cx+r*NSVG_KAPPA90, cy-r, cx+r, cy-r*NSVG_KAPPA90, cx+r, cy);
nsvg__addPath(p, 1);
nsvg__addShape(p);
}
}
static void nsvg__parseEllipse(NSVGparser* p, const char** attr)
{
float cx = 0.0f;
float cy = 0.0f;
float rx = 0.0f;
float ry = 0.0f;
int i;
for (i = 0; attr[i]; i += 2) {
if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
}
}
if (rx > 0.0f && ry > 0.0f) {
nsvg__resetPath(p);
nsvg__moveTo(p, cx+rx, cy);
nsvg__cubicBezTo(p, cx+rx, cy+ry*NSVG_KAPPA90, cx+rx*NSVG_KAPPA90, cy+ry, cx, cy+ry);
nsvg__cubicBezTo(p, cx-rx*NSVG_KAPPA90, cy+ry, cx-rx, cy+ry*NSVG_KAPPA90, cx-rx, cy);
nsvg__cubicBezTo(p, cx-rx, cy-ry*NSVG_KAPPA90, cx-rx*NSVG_KAPPA90, cy-ry, cx, cy-ry);
nsvg__cubicBezTo(p, cx+rx*NSVG_KAPPA90, cy-ry, cx+rx, cy-ry*NSVG_KAPPA90, cx+rx, cy);
nsvg__addPath(p, 1);
nsvg__addShape(p);
}
}
static void nsvg__parseLine(NSVGparser* p, const char** attr)
{
float x1 = 0.0;
float y1 = 0.0;
float x2 = 0.0;
float y2 = 0.0;
int i;
for (i = 0; attr[i]; i += 2) {
if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "x1") == 0) x1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
if (strcmp(attr[i], "y1") == 0) y1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
if (strcmp(attr[i], "x2") == 0) x2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
if (strcmp(attr[i], "y2") == 0) y2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
}
}
nsvg__resetPath(p);
nsvg__moveTo(p, x1, y1);
nsvg__lineTo(p, x2, y2);
nsvg__addPath(p, 0);
nsvg__addShape(p);
}
static void nsvg__parsePoly(NSVGparser* p, const char** attr, int closeFlag)
{
int i;
const char* s;
float args[2];
int nargs, npts = 0;
char item[64];
nsvg__resetPath(p);
for (i = 0; attr[i]; i += 2) {
if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "points") == 0) {
s = attr[i + 1];
nargs = 0;
while (*s) {
s = nsvg__getNextPathItem(s, item);
args[nargs++] = (float)nsvg__atof(item);
if (nargs >= 2) {
if (npts == 0)
nsvg__moveTo(p, args[0], args[1]);
else
nsvg__lineTo(p, args[0], args[1]);
nargs = 0;
npts++;
}
}
}
}
}
nsvg__addPath(p, (char)closeFlag);
nsvg__addShape(p);
}
static void nsvg__parseSVG(NSVGparser* p, const char** attr)
{
int i;
for (i = 0; attr[i]; i += 2) {
if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "width") == 0) {
p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
} else if (strcmp(attr[i], "height") == 0) {
p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
} else if (strcmp(attr[i], "viewBox") == 0) {
const char *s = attr[i + 1];
char buf[64];
s = nsvg__parseNumber(s, buf, 64);
p->viewMinx = nsvg__atof(buf);
while (*s && (nsvg__isspace(*s) || *s == '%' || *s == ',')) s++;
if (!*s) return;
s = nsvg__parseNumber(s, buf, 64);
p->viewMiny = nsvg__atof(buf);
while (*s && (nsvg__isspace(*s) || *s == '%' || *s == ',')) s++;
if (!*s) return;
s = nsvg__parseNumber(s, buf, 64);
p->viewWidth = nsvg__atof(buf);
while (*s && (nsvg__isspace(*s) || *s == '%' || *s == ',')) s++;
if (!*s) return;
s = nsvg__parseNumber(s, buf, 64);
p->viewHeight = nsvg__atof(buf);
} else if (strcmp(attr[i], "preserveAspectRatio") == 0) {
if (strstr(attr[i + 1], "none") != 0) {
// No uniform scaling
p->alignType = NSVG_ALIGN_NONE;
} else {
// Parse X align
if (strstr(attr[i + 1], "xMin") != 0)
p->alignX = NSVG_ALIGN_MIN;
else if (strstr(attr[i + 1], "xMid") != 0)
p->alignX = NSVG_ALIGN_MID;
else if (strstr(attr[i + 1], "xMax") != 0)
p->alignX = NSVG_ALIGN_MAX;
// Parse X align
if (strstr(attr[i + 1], "yMin") != 0)
p->alignY = NSVG_ALIGN_MIN;
else if (strstr(attr[i + 1], "yMid") != 0)
p->alignY = NSVG_ALIGN_MID;
else if (strstr(attr[i + 1], "yMax") != 0)
p->alignY = NSVG_ALIGN_MAX;
// Parse meet/slice
p->alignType = NSVG_ALIGN_MEET;
if (strstr(attr[i + 1], "slice") != 0)
p->alignType = NSVG_ALIGN_SLICE;
}
}
}
}
}
static void nsvg__parseGradient(NSVGparser* p, const char** attr, signed char type)
{
int i;
NSVGgradientData* grad = (NSVGgradientData*)NVG_MALLOC(sizeof(NSVGgradientData));
if (grad == NULL) return;
memset(grad, 0, sizeof(NSVGgradientData));
grad->units = NSVG_OBJECT_SPACE;
grad->type = type;
if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) {
grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT);
grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
} else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) {
grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
}
nsvg__xformIdentity(grad->xform);
for (i = 0; attr[i]; i += 2) {
if (strcmp(attr[i], "id") == 0) {
strncpy(grad->id, attr[i+1], 63);
grad->id[63] = '\0';
} else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "gradientUnits") == 0) {
if (strcmp(attr[i+1], "objectBoundingBox") == 0)
grad->units = NSVG_OBJECT_SPACE;
else
grad->units = NSVG_USER_SPACE;
} else if (strcmp(attr[i], "gradientTransform") == 0) {
nsvg__parseTransform(grad->xform, attr[i + 1]);
} else if (strcmp(attr[i], "cx") == 0) {
grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "cy") == 0) {
grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "r") == 0) {
grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "fx") == 0) {
grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "fy") == 0) {
grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "x1") == 0) {
grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "y1") == 0) {
grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "x2") == 0) {
grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "y2") == 0) {
grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]);
} else if (strcmp(attr[i], "spreadMethod") == 0) {
if (strcmp(attr[i+1], "pad") == 0)
grad->spread = NSVG_SPREAD_PAD;
else if (strcmp(attr[i+1], "reflect") == 0)
grad->spread = NSVG_SPREAD_REFLECT;
else if (strcmp(attr[i+1], "repeat") == 0)
grad->spread = NSVG_SPREAD_REPEAT;
} else if (strcmp(attr[i], "xlink:href") == 0) {
const char *href = attr[i+1];
strncpy(grad->ref, href+1, 62);
grad->ref[62] = '\0';
}
}
}
grad->next = p->gradients;
p->gradients = grad;
}
static void nsvg__parseGradientStop(NSVGparser* p, const char** attr)
{
NSVGattrib* curAttr = nsvg__getAttr(p);
NSVGgradientData* grad;
NSVGgradientStop* stop;
int i, idx;
curAttr->stopOffset = 0;
curAttr->stopColor = 0;
curAttr->stopOpacity = 1.0f;
for (i = 0; attr[i]; i += 2) {
nsvg__parseAttr(p, attr[i], attr[i + 1]);
}
// Add stop to the last gradient.
grad = p->gradients;
if (grad == NULL) return;
grad->nstops++;
grad->stops = (NSVGgradientStop*)NVG_REALLOC(grad->stops, sizeof(NSVGgradientStop)*grad->nstops);
if (grad->stops == NULL) return;
// Insert
idx = grad->nstops-1;
for (i = 0; i < grad->nstops-1; i++) {
if (curAttr->stopOffset < grad->stops[i].offset) {
idx = i;
break;
}
}
if (idx != grad->nstops-1) {
for (i = grad->nstops-1; i > idx; i--)
grad->stops[i] = grad->stops[i-1];
}
stop = &grad->stops[idx];
stop->color = curAttr->stopColor;
stop->color |= (unsigned int)(curAttr->stopOpacity*255) << 24;
stop->offset = curAttr->stopOffset;
}
static void nsvg__startElement(void* ud, const char* el, const char** attr)
{
NSVGparser* p = (NSVGparser*)ud;
if (p->defsFlag) {
// Skip everything but gradients in defs
if (strcmp(el, "linearGradient") == 0) {
nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
} else if (strcmp(el, "radialGradient") == 0) {
nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
} else if (strcmp(el, "stop") == 0) {
nsvg__parseGradientStop(p, attr);
}
return;
}
if (strcmp(el, "g") == 0) {
nsvg__pushAttr(p);
nsvg__parseAttribs(p, attr);
} else if (strcmp(el, "path") == 0) {
if (p->pathFlag) // Do not allow nested paths.
return;
nsvg__pushAttr(p);
nsvg__parsePath(p, attr);
nsvg__popAttr(p);
} else if (strcmp(el, "rect") == 0) {
nsvg__pushAttr(p);
nsvg__parseRect(p, attr);
nsvg__popAttr(p);
} else if (strcmp(el, "circle") == 0) {
nsvg__pushAttr(p);
nsvg__parseCircle(p, attr);
nsvg__popAttr(p);
} else if (strcmp(el, "ellipse") == 0) {
nsvg__pushAttr(p);
nsvg__parseEllipse(p, attr);
nsvg__popAttr(p);
} else if (strcmp(el, "line") == 0) {
nsvg__pushAttr(p);
nsvg__parseLine(p, attr);
nsvg__popAttr(p);
} else if (strcmp(el, "polyline") == 0) {
nsvg__pushAttr(p);
nsvg__parsePoly(p, attr, 0);
nsvg__popAttr(p);
} else if (strcmp(el, "polygon") == 0) {
nsvg__pushAttr(p);
nsvg__parsePoly(p, attr, 1);
nsvg__popAttr(p);
} else if (strcmp(el, "linearGradient") == 0) {
nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
} else if (strcmp(el, "radialGradient") == 0) {
nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
} else if (strcmp(el, "stop") == 0) {
nsvg__parseGradientStop(p, attr);
} else if (strcmp(el, "defs") == 0) {
p->defsFlag = 1;
} else if (strcmp(el, "svg") == 0) {
nsvg__parseSVG(p, attr);
}
}
static void nsvg__endElement(void* ud, const char* el)
{
NSVGparser* p = (NSVGparser*)ud;
if (strcmp(el, "g") == 0) {
nsvg__popAttr(p);
} else if (strcmp(el, "path") == 0) {
p->pathFlag = 0;
} else if (strcmp(el, "defs") == 0) {
p->defsFlag = 0;
}
}
static void nsvg__content(void* ud, const char* s)
{
NSVG_NOTUSED(ud);
NSVG_NOTUSED(s);
// empty
}
static void nsvg__imageBounds(NSVGparser* p, float* bounds)
{
NSVGshape* shape;
shape = p->image->shapes;
if (shape == NULL) {
bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0;
return;
}
bounds[0] = shape->bounds[0];
bounds[1] = shape->bounds[1];
bounds[2] = shape->bounds[2];
bounds[3] = shape->bounds[3];
for (shape = shape->next; shape != NULL; shape = shape->next) {
bounds[0] = nsvg__minf(bounds[0], shape->bounds[0]);
bounds[1] = nsvg__minf(bounds[1], shape->bounds[1]);
bounds[2] = nsvg__maxf(bounds[2], shape->bounds[2]);
bounds[3] = nsvg__maxf(bounds[3], shape->bounds[3]);
}
}
static float nsvg__viewAlign(float content, float container, int type)
{
if (type == NSVG_ALIGN_MIN)
return 0;
else if (type == NSVG_ALIGN_MAX)
return container - content;
// mid
return (container - content) * 0.5f;
}
static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy)
{
float t[6];
nsvg__xformSetTranslation(t, tx, ty);
nsvg__xformMultiply (grad->xform, t);
nsvg__xformSetScale(t, sx, sy);
nsvg__xformMultiply (grad->xform, t);
}
static void nsvg__scaleToViewbox(NSVGparser* p, const char* units)
{
NSVGshape* shape;
NSVGpath* path;
float tx, ty, sx, sy, us, bounds[4], t[6], avgs;
int i;
float* pt;
// Guess image size if not set completely.
nsvg__imageBounds(p, bounds);
if (p->viewWidth == 0) {
if (p->image->width > 0) {
p->viewWidth = p->image->width;
} else {
p->viewMinx = bounds[0];
p->viewWidth = bounds[2] - bounds[0];
}
}
if (p->viewHeight == 0) {
if (p->image->height > 0) {
p->viewHeight = p->image->height;
} else {
p->viewMiny = bounds[1];
p->viewHeight = bounds[3] - bounds[1];
}
}
if (p->image->width == 0)
p->image->width = p->viewWidth;
if (p->image->height == 0)
p->image->height = p->viewHeight;
tx = -p->viewMinx;
ty = -p->viewMiny;
sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0;
sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0;
// Unit scaling
us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f);
// Fix aspect ratio
if (p->alignType == NSVG_ALIGN_MEET) {
// fit whole image into viewbox
sx = sy = nsvg__minf(sx, sy);
tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
} else if (p->alignType == NSVG_ALIGN_SLICE) {
// fill whole viewbox with image
sx = sy = nsvg__maxf(sx, sy);
tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
}
// Transform
sx *= us;
sy *= us;
avgs = (sx+sy) / 2.0f;
for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
shape->bounds[0] = (shape->bounds[0] + tx) * sx;
shape->bounds[1] = (shape->bounds[1] + ty) * sy;
shape->bounds[2] = (shape->bounds[2] + tx) * sx;
shape->bounds[3] = (shape->bounds[3] + ty) * sy;
for (path = shape->paths; path != NULL; path = path->next) {
path->bounds[0] = (path->bounds[0] + tx) * sx;
path->bounds[1] = (path->bounds[1] + ty) * sy;
path->bounds[2] = (path->bounds[2] + tx) * sx;
path->bounds[3] = (path->bounds[3] + ty) * sy;
for (i =0; i < path->npts; i++) {
pt = &path->pts[i*2];
pt[0] = (pt[0] + tx) * sx;
pt[1] = (pt[1] + ty) * sy;
}
}
if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) {
nsvg__scaleGradient(shape->fill.gradient, tx,ty, sx,sy);
memcpy(t, shape->fill.gradient->xform, sizeof(float)*6);
nsvg__xformInverse(shape->fill.gradient->xform, t);
}
if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) {
nsvg__scaleGradient(shape->stroke.gradient, tx,ty, sx,sy);
memcpy(t, shape->stroke.gradient->xform, sizeof(float)*6);
nsvg__xformInverse(shape->stroke.gradient->xform, t);
}
shape->strokeWidth *= avgs;
shape->strokeDashOffset *= avgs;
for (i = 0; i < shape->strokeDashCount; i++)
shape->strokeDashArray[i] *= avgs;
}
}
static void nsvg__createGradients(NSVGparser* p)
{
NSVGshape* shape;
for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
if (shape->fill.type == NSVG_PAINT_UNDEF) {
if (shape->fillGradient[0] != '\0') {
float inv[6], localBounds[4];
nsvg__xformInverse(inv, shape->xform);
nsvg__getLocalBounds(localBounds, shape, inv);
shape->fill.gradient = nsvg__createGradient(p, shape->fillGradient, localBounds, shape->xform, &shape->fill.type);
}
if (shape->fill.type == NSVG_PAINT_UNDEF) {
shape->fill.type = NSVG_PAINT_NONE;
}
}
if (shape->stroke.type == NSVG_PAINT_UNDEF) {
if (shape->strokeGradient[0] != '\0') {
float inv[6], localBounds[4];
nsvg__xformInverse(inv, shape->xform);
nsvg__getLocalBounds(localBounds, shape, inv);
shape->stroke.gradient = nsvg__createGradient(p, shape->strokeGradient, localBounds, shape->xform, &shape->stroke.type);
}
if (shape->stroke.type == NSVG_PAINT_UNDEF) {
shape->stroke.type = NSVG_PAINT_NONE;
}
}
}
}
NSVGimage* nsvgParse(char* input, const char* units, float dpi)
{
NSVGparser* p;
NSVGimage* ret = 0;
p = nsvg__createParser();
if (p == NULL) {
return NULL;
}
p->dpi = dpi;
nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
// Create gradients after all definitions have been parsed
nsvg__createGradients(p);
// Scale to viewBox
nsvg__scaleToViewbox(p, units);
ret = p->image;
p->image = NULL;
nsvg__deleteParser(p);
return ret;
}
NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi)
{
FILE* fp = NULL;
size_t size;
char* data = NULL;
NSVGimage* image = NULL;
fp = fopen(filename, "rb");
if (!fp) goto error;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
data = (char*)NVG_MALLOC(size+1);
if (data == NULL) goto error;
if (fread(data, 1, size, fp) != size) goto error;
data[size] = '\0'; // Must be null terminated.
fclose(fp);
image = nsvgParse(data, units, dpi);
NVG_FREE(data);
return image;
error:
if (fp) fclose(fp);
if (data) NVG_FREE(data);
if (image) nsvgDelete(image);
return NULL;
}
NSVGpath* nsvgDuplicatePath(NSVGpath* p)
{
NSVGpath* res = NULL;
if (p == NULL)
return NULL;
res = (NSVGpath*)NVG_MALLOC(sizeof(NSVGpath));
if (res == NULL) goto error;
memset(res, 0, sizeof(NSVGpath));
res->pts = (float*)NVG_MALLOC(p->npts*2*sizeof(float));
if (res->pts == NULL) goto error;
memcpy(res->pts, p->pts, p->npts * sizeof(float) * 2);
res->npts = p->npts;
memcpy(res->bounds, p->bounds, sizeof(p->bounds));
res->closed = p->closed;
return res;
error:
if (res != NULL) {
NVG_FREE(res->pts);
NVG_FREE(res);
}
return NULL;
}
void nsvgDelete(NSVGimage* image)
{
NSVGshape *snext, *shape;
if (image == NULL) return;
shape = image->shapes;
while (shape != NULL) {
snext = shape->next;
nsvg__deletePaths(shape->paths);
nsvg__deletePaint(&shape->fill);
nsvg__deletePaint(&shape->stroke);
NVG_FREE(shape);
shape = snext;
}
NVG_FREE(image);
}
#endif // NANOSVG_IMPLEMENTATION
#endif // NANOSVG_H
|
d5a70c20a9b97bc747a3f52098618ffaaf12c44f
|
c475cd8531a94ffae69cc92371d41531dbbddb6c
|
/Projects/bullet3-2.89/examples/SharedMemory/plugins/b3PluginAPI.h
|
ef983abdbaf5199d8f103b2774ce43ff5a90d222
|
[
"Apache-2.0",
"LicenseRef-scancode-free-unknown",
"Zlib"
] |
permissive
|
WolfireGames/overgrowth
|
72d3dd29cbd7254337265c29f8de3e5c32400114
|
594a2a4f9da0855304ee8cd5335d042f8e954ce1
|
refs/heads/main
| 2023-08-15T19:36:56.156578
| 2023-05-17T08:17:53
| 2023-05-17T08:20:36
| 467,448,492
| 2,264
| 245
|
Apache-2.0
| 2023-05-09T07:29:58
| 2022-03-08T09:38:54
|
C++
|
UTF-8
|
C
| false
| false
| 1,276
|
h
|
b3PluginAPI.h
|
#ifndef B3_PLUGIN_API_H
#define B3_PLUGIN_API_H
#ifdef _WIN32
#define B3_SHARED_API __declspec(dllexport)
#elif defined(__GNUC__)
#define B3_SHARED_API __attribute__((visibility("default")))
#else
#define B3_SHARED_API
#endif
#if defined(_WIN32)
#define B3_API_ENTRY
#define B3_API_CALL __cdecl
#define B3_CALLBACK __cdecl
#else
#define B3_API_ENTRY
#define B3_API_CALL
#define B3_CALLBACK
#endif
#ifdef __cplusplus
extern "C"
{
#endif
/* Plugin API */
typedef B3_API_ENTRY int(B3_API_CALL* PFN_INIT)(struct b3PluginContext* context);
typedef B3_API_ENTRY void(B3_API_CALL* PFN_EXIT)(struct b3PluginContext* context);
typedef B3_API_ENTRY int(B3_API_CALL* PFN_EXECUTE)(struct b3PluginContext* context, const struct b3PluginArguments* arguments);
typedef B3_API_ENTRY int(B3_API_CALL* PFN_TICK)(struct b3PluginContext* context);
typedef B3_API_ENTRY struct UrdfRenderingInterface*(B3_API_CALL* PFN_GET_RENDER_INTERFACE)(struct b3PluginContext* context);
typedef B3_API_ENTRY struct b3PluginCollisionInterface*(B3_API_CALL* PFN_GET_COLLISION_INTERFACE)(struct b3PluginContext* context);
typedef B3_API_ENTRY struct CommonFileIOInterface*(B3_API_CALL* PFN_GET_FILEIO_INTERFACE)(struct b3PluginContext* context);
#ifdef __cplusplus
}
#endif
#endif //B3_PLUGIN_API_H
|
fbee1e4f822e49130ccd7201da075a3883f81670
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/gpu/drm/nouveau/core/subdev/therm/fanpwm.c
|
5f71db8e8992e0c38ec2c46f945450d8e9778c51
|
[
"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
| 3,257
|
c
|
fanpwm.c
|
/*
* Copyright 2012 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: Ben Skeggs
* Martin Peres
*/
#include <core/option.h>
#include <subdev/gpio.h>
#include "priv.h"
struct nouveau_fanpwm_priv {
struct nouveau_fan base;
struct dcb_gpio_func func;
};
static int
nouveau_fanpwm_get(struct nouveau_therm *therm)
{
struct nouveau_therm_priv *tpriv = (void *)therm;
struct nouveau_fanpwm_priv *priv = (void *)tpriv->fan;
struct nouveau_gpio *gpio = nouveau_gpio(therm);
int card_type = nv_device(therm)->card_type;
u32 divs, duty;
int ret;
ret = therm->pwm_get(therm, priv->func.line, &divs, &duty);
if (ret == 0 && divs) {
divs = max(divs, duty);
if (card_type <= NV_40 || (priv->func.log[0] & 1))
duty = divs - duty;
return (duty * 100) / divs;
}
return gpio->get(gpio, 0, priv->func.func, priv->func.line) * 100;
}
static int
nouveau_fanpwm_set(struct nouveau_therm *therm, int percent)
{
struct nouveau_therm_priv *tpriv = (void *)therm;
struct nouveau_fanpwm_priv *priv = (void *)tpriv->fan;
int card_type = nv_device(therm)->card_type;
u32 divs, duty;
int ret;
divs = priv->base.perf.pwm_divisor;
if (priv->base.bios.pwm_freq) {
divs = 1;
if (therm->pwm_clock)
divs = therm->pwm_clock(therm);
divs /= priv->base.bios.pwm_freq;
}
duty = ((divs * percent) + 99) / 100;
if (card_type <= NV_40 || (priv->func.log[0] & 1))
duty = divs - duty;
ret = therm->pwm_set(therm, priv->func.line, divs, duty);
if (ret == 0)
ret = therm->pwm_ctrl(therm, priv->func.line, true);
return ret;
}
int
nouveau_fanpwm_create(struct nouveau_therm *therm, struct dcb_gpio_func *func)
{
struct nouveau_device *device = nv_device(therm);
struct nouveau_therm_priv *tpriv = (void *)therm;
struct nouveau_fanpwm_priv *priv;
u32 divs, duty;
if (!nouveau_boolopt(device->cfgopt, "NvFanPWM", func->param) ||
!therm->pwm_ctrl ||
therm->pwm_get(therm, func->line, &divs, &duty) == -ENODEV)
return -ENODEV;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
tpriv->fan = &priv->base;
if (!priv)
return -ENOMEM;
priv->base.type = "PWM";
priv->base.get = nouveau_fanpwm_get;
priv->base.set = nouveau_fanpwm_set;
priv->func = *func;
return 0;
}
|
fe5ef25fc2b061b1b1fb9d1fe55c0ea3186483e1
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/lib/mesa/src/gallium/frontends/va/picture_h264_enc.c
|
8c8256eff509572bc0cc4381ed60a54be61ea2cd
|
[] |
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
| 16,694
|
c
|
picture_h264_enc.c
|
/**************************************************************************
*
* Copyright 2018 Advanced Micro Devices, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "util/u_handle_table.h"
#include "util/u_video.h"
#include "va_private.h"
VAStatus
vlVaHandleVAEncPictureParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
{
VAEncPictureParameterBufferH264 *h264;
vlVaBuffer *coded_buf;
h264 = buf->data;
if (h264->pic_fields.bits.idr_pic_flag == 1)
context->desc.h264enc.frame_num = 0;
context->desc.h264enc.not_referenced = !h264->pic_fields.bits.reference_pic_flag;
context->desc.h264enc.pic_order_cnt = h264->CurrPic.TopFieldOrderCnt;
context->desc.h264enc.is_ltr = h264->CurrPic.flags & VA_PICTURE_H264_LONG_TERM_REFERENCE;
if (context->desc.h264enc.is_ltr)
context->desc.h264enc.ltr_index = h264->CurrPic.frame_idx;
if (context->desc.h264enc.gop_cnt == 0)
context->desc.h264enc.i_remain = context->gop_coeff;
else if (context->desc.h264enc.frame_num == 1)
context->desc.h264enc.i_remain--;
context->desc.h264enc.p_remain = context->desc.h264enc.gop_size - context->desc.h264enc.gop_cnt - context->desc.h264enc.i_remain;
coded_buf = handle_table_get(drv->htab, h264->coded_buf);
if (!coded_buf->derived_surface.resource)
coded_buf->derived_surface.resource = pipe_buffer_create(drv->pipe->screen, PIPE_BIND_VERTEX_BUFFER,
PIPE_USAGE_STREAM, coded_buf->size);
context->coded_buf = coded_buf;
if (context->desc.h264enc.is_ltr)
_mesa_hash_table_insert(context->desc.h264enc.frame_idx,
UINT_TO_PTR(h264->CurrPic.picture_id + 1),
UINT_TO_PTR(context->desc.h264enc.ltr_index));
else
_mesa_hash_table_insert(context->desc.h264enc.frame_idx,
UINT_TO_PTR(h264->CurrPic.picture_id + 1),
UINT_TO_PTR(context->desc.h264enc.frame_num));
if (h264->pic_fields.bits.idr_pic_flag == 1)
context->desc.h264enc.picture_type = PIPE_H2645_ENC_PICTURE_TYPE_IDR;
else
context->desc.h264enc.picture_type = PIPE_H2645_ENC_PICTURE_TYPE_P;
/* Initialize slice descriptors for this picture */
context->desc.h264enc.num_slice_descriptors = 0;
memset(&context->desc.h264enc.slices_descriptors, 0, sizeof(context->desc.h264enc.slices_descriptors));
context->desc.h264enc.quant_i_frames = h264->pic_init_qp;
context->desc.h264enc.quant_b_frames = h264->pic_init_qp;
context->desc.h264enc.quant_p_frames = h264->pic_init_qp;
context->desc.h264enc.gop_cnt++;
if (context->desc.h264enc.gop_cnt == context->desc.h264enc.gop_size)
context->desc.h264enc.gop_cnt = 0;
context->desc.h264enc.pic_ctrl.enc_cabac_enable = h264->pic_fields.bits.entropy_coding_mode_flag;
context->desc.h264enc.num_ref_idx_l0_active_minus1 = h264->num_ref_idx_l0_active_minus1;
context->desc.h264enc.num_ref_idx_l1_active_minus1 = h264->num_ref_idx_l1_active_minus1;
context->desc.h264enc.pic_ctrl.deblocking_filter_control_present_flag
= h264->pic_fields.bits.deblocking_filter_control_present_flag;
context->desc.h264enc.pic_ctrl.redundant_pic_cnt_present_flag
= h264->pic_fields.bits.redundant_pic_cnt_present_flag;
context->desc.h264enc.pic_ctrl.chroma_qp_index_offset = h264->chroma_qp_index_offset;
context->desc.h264enc.pic_ctrl.second_chroma_qp_index_offset
= h264->second_chroma_qp_index_offset;
return VA_STATUS_SUCCESS;
}
VAStatus
vlVaHandleVAEncSliceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
{
VAEncSliceParameterBufferH264 *h264;
h264 = buf->data;
memset(&context->desc.h264enc.ref_idx_l0_list, VA_INVALID_ID, sizeof(context->desc.h264enc.ref_idx_l0_list));
memset(&context->desc.h264enc.ref_idx_l1_list, VA_INVALID_ID, sizeof(context->desc.h264enc.ref_idx_l1_list));
if(h264->num_ref_idx_active_override_flag) {
context->desc.h264enc.num_ref_idx_l0_active_minus1 = h264->num_ref_idx_l0_active_minus1;
context->desc.h264enc.num_ref_idx_l1_active_minus1 = h264->num_ref_idx_l1_active_minus1;
}
for (int i = 0; i < 32; i++) {
if (h264->RefPicList0[i].picture_id != VA_INVALID_ID) {
context->desc.h264enc.ref_idx_l0_list[i] = PTR_TO_UINT(util_hash_table_get(context->desc.h264enc.frame_idx,
UINT_TO_PTR(h264->RefPicList0[i].picture_id + 1)));
context->desc.h264enc.l0_is_long_term[i] = h264->RefPicList0[i].flags &
VA_PICTURE_H264_LONG_TERM_REFERENCE;
}
if (h264->RefPicList1[i].picture_id != VA_INVALID_ID && h264->slice_type == 1) {
context->desc.h264enc.ref_idx_l1_list[i] = PTR_TO_UINT(util_hash_table_get(context->desc.h264enc.frame_idx,
UINT_TO_PTR(h264->RefPicList1[i].picture_id + 1)));
context->desc.h264enc.l1_is_long_term[i] = h264->RefPicList1[i].flags &
VA_PICTURE_H264_LONG_TERM_REFERENCE;
}
}
/**
* VAEncSliceParameterBufferH264.slice_type
* Slice type.
* Range: 0..2, 5..7, i.e. no switching slices.
*/
struct h264_slice_descriptor slice_descriptor;
memset(&slice_descriptor, 0, sizeof(slice_descriptor));
slice_descriptor.macroblock_address = h264->macroblock_address;
slice_descriptor.num_macroblocks = h264->num_macroblocks;
if ((h264->slice_type == 1) || (h264->slice_type == 6)) {
context->desc.h264enc.picture_type = PIPE_H2645_ENC_PICTURE_TYPE_B;
slice_descriptor.slice_type = PIPE_H264_SLICE_TYPE_B;
} else if ((h264->slice_type == 0) || (h264->slice_type == 5)) {
context->desc.h264enc.picture_type = PIPE_H2645_ENC_PICTURE_TYPE_P;
slice_descriptor.slice_type = PIPE_H264_SLICE_TYPE_P;
} else if ((h264->slice_type == 2) || (h264->slice_type == 7)) {
if (context->desc.h264enc.picture_type == PIPE_H2645_ENC_PICTURE_TYPE_IDR) {
if (slice_descriptor.macroblock_address == 0) {
/* Increment it only for the first slice of the IDR frame */
context->desc.h264enc.idr_pic_id++;
}
slice_descriptor.slice_type = PIPE_H264_SLICE_TYPE_I;
} else {
context->desc.h264enc.picture_type = PIPE_H2645_ENC_PICTURE_TYPE_I;
slice_descriptor.slice_type = PIPE_H264_SLICE_TYPE_I;
}
} else {
context->desc.h264enc.picture_type = PIPE_H2645_ENC_PICTURE_TYPE_SKIP;
}
context->desc.h264enc.pic_ctrl.enc_cabac_init_idc = h264->cabac_init_idc;
context->desc.h264enc.dbk.disable_deblocking_filter_idc = h264->disable_deblocking_filter_idc;
context->desc.h264enc.dbk.alpha_c0_offset_div2 = h264->slice_alpha_c0_offset_div2;
context->desc.h264enc.dbk.beta_offset_div2 = h264->slice_beta_offset_div2;
/* Handle the slice control parameters */
if (context->desc.h264enc.num_slice_descriptors < ARRAY_SIZE(context->desc.h264enc.slices_descriptors)) {
context->desc.h264enc.slices_descriptors[context->desc.h264enc.num_slice_descriptors++] = slice_descriptor;
} else {
return VA_STATUS_ERROR_NOT_ENOUGH_BUFFER;
}
return VA_STATUS_SUCCESS;
}
VAStatus
vlVaHandleVAEncSequenceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
{
uint32_t num_units_in_tick = 0, time_scale = 0;
VAEncSequenceParameterBufferH264 *h264 = (VAEncSequenceParameterBufferH264 *)buf->data;
if (!context->decoder) {
context->templat.max_references = h264->max_num_ref_frames;
context->templat.level = h264->level_idc;
context->decoder = drv->pipe->create_video_codec(drv->pipe, &context->templat);
if (!context->decoder)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
getEncParamPresetH264(context);
}
context->gop_coeff = ((1024 + h264->intra_idr_period - 1) / h264->intra_idr_period + 1) / 2 * 2;
if (context->gop_coeff > VL_VA_ENC_GOP_COEFF)
context->gop_coeff = VL_VA_ENC_GOP_COEFF;
context->desc.h264enc.gop_size = h264->intra_idr_period * context->gop_coeff;
context->desc.h264enc.seq.pic_order_cnt_type = h264->seq_fields.bits.pic_order_cnt_type;
context->desc.h264enc.seq.vui_parameters_present_flag = h264->vui_parameters_present_flag;
if (h264->vui_parameters_present_flag) {
context->desc.h264enc.seq.vui_flags.aspect_ratio_info_present_flag =
h264->vui_fields.bits.aspect_ratio_info_present_flag;
context->desc.h264enc.seq.aspect_ratio_idc = h264->aspect_ratio_idc;
context->desc.h264enc.seq.sar_width = h264->sar_width;
context->desc.h264enc.seq.sar_height = h264->sar_height;
context->desc.h264enc.seq.vui_flags.timing_info_present_flag =
h264->vui_fields.bits.timing_info_present_flag;
num_units_in_tick = h264->num_units_in_tick;
time_scale = h264->time_scale;
} else
context->desc.h264enc.seq.vui_flags.timing_info_present_flag = 0;
if (!context->desc.h264enc.seq.vui_flags.timing_info_present_flag) {
/* if not present, set default value */
num_units_in_tick = PIPE_DEFAULT_FRAME_RATE_DEN;
time_scale = PIPE_DEFAULT_FRAME_RATE_NUM * 2;
}
context->desc.h264enc.seq.num_units_in_tick = num_units_in_tick;
context->desc.h264enc.seq.time_scale = time_scale;
context->desc.h264enc.rate_ctrl[0].frame_rate_num = time_scale / 2;
context->desc.h264enc.rate_ctrl[0].frame_rate_den = num_units_in_tick;
if (h264->frame_cropping_flag) {
context->desc.h264enc.seq.enc_frame_cropping_flag = h264->frame_cropping_flag;
context->desc.h264enc.seq.enc_frame_crop_left_offset = h264->frame_crop_left_offset;
context->desc.h264enc.seq.enc_frame_crop_right_offset = h264->frame_crop_right_offset;
context->desc.h264enc.seq.enc_frame_crop_top_offset = h264->frame_crop_top_offset;
context->desc.h264enc.seq.enc_frame_crop_bottom_offset = h264->frame_crop_bottom_offset;
}
return VA_STATUS_SUCCESS;
}
VAStatus
vlVaHandleVAEncMiscParameterTypeRateControlH264(vlVaContext *context, VAEncMiscParameterBuffer *misc)
{
unsigned temporal_id;
VAEncMiscParameterRateControl *rc = (VAEncMiscParameterRateControl *)misc->data;
temporal_id = context->desc.h264enc.rate_ctrl[0].rate_ctrl_method !=
PIPE_H2645_ENC_RATE_CONTROL_METHOD_DISABLE ?
rc->rc_flags.bits.temporal_id :
0;
if (context->desc.h264enc.rate_ctrl[0].rate_ctrl_method ==
PIPE_H2645_ENC_RATE_CONTROL_METHOD_CONSTANT)
context->desc.h264enc.rate_ctrl[temporal_id].target_bitrate =
rc->bits_per_second;
else
context->desc.h264enc.rate_ctrl[temporal_id].target_bitrate =
rc->bits_per_second * (rc->target_percentage / 100.0);
if (context->desc.h264enc.seq.num_temporal_layers > 0 &&
temporal_id >= context->desc.h264enc.seq.num_temporal_layers)
return VA_STATUS_ERROR_INVALID_PARAMETER;
context->desc.h264enc.rate_ctrl[temporal_id].fill_data_enable = !(rc->rc_flags.bits.disable_bit_stuffing);
context->desc.h264enc.rate_ctrl[temporal_id].skip_frame_enable = !(rc->rc_flags.bits.disable_frame_skip);
context->desc.h264enc.rate_ctrl[temporal_id].peak_bitrate = rc->bits_per_second;
if (context->desc.h264enc.rate_ctrl[temporal_id].target_bitrate < 2000000)
context->desc.h264enc.rate_ctrl[temporal_id].vbv_buffer_size =
MIN2((context->desc.h264enc.rate_ctrl[0].target_bitrate * 2.75), 2000000);
else
context->desc.h264enc.rate_ctrl[temporal_id].vbv_buffer_size =
context->desc.h264enc.rate_ctrl[0].target_bitrate;
context->desc.h264enc.rate_ctrl[temporal_id].max_qp = rc->max_qp;
context->desc.h264enc.rate_ctrl[temporal_id].min_qp = rc->min_qp;
return VA_STATUS_SUCCESS;
}
VAStatus
vlVaHandleVAEncMiscParameterTypeFrameRateH264(vlVaContext *context, VAEncMiscParameterBuffer *misc)
{
unsigned temporal_id;
VAEncMiscParameterFrameRate *fr = (VAEncMiscParameterFrameRate *)misc->data;
temporal_id = context->desc.h264enc.rate_ctrl[0].rate_ctrl_method !=
PIPE_H2645_ENC_RATE_CONTROL_METHOD_DISABLE ?
fr->framerate_flags.bits.temporal_id :
0;
if (context->desc.h264enc.seq.num_temporal_layers > 0 &&
temporal_id >= context->desc.h264enc.seq.num_temporal_layers)
return VA_STATUS_ERROR_INVALID_PARAMETER;
if (fr->framerate & 0xffff0000) {
context->desc.h264enc.rate_ctrl[temporal_id].frame_rate_num = fr->framerate & 0xffff;
context->desc.h264enc.rate_ctrl[temporal_id].frame_rate_den = fr->framerate >> 16 & 0xffff;
} else {
context->desc.h264enc.rate_ctrl[temporal_id].frame_rate_num = fr->framerate;
context->desc.h264enc.rate_ctrl[temporal_id].frame_rate_den = 1;
}
return VA_STATUS_SUCCESS;
}
VAStatus
vlVaHandleVAEncMiscParameterTypeTemporalLayerH264(vlVaContext *context, VAEncMiscParameterBuffer *misc)
{
VAEncMiscParameterTemporalLayerStructure *tl = (VAEncMiscParameterTemporalLayerStructure *)misc->data;
context->desc.h264enc.seq.num_temporal_layers = tl->number_of_layers;
return VA_STATUS_SUCCESS;
}
VAStatus
vlVaHandleVAEncMiscParameterTypeQualityLevelH264(vlVaContext *context, VAEncMiscParameterBuffer *misc)
{
VAEncMiscParameterBufferQualityLevel *ql = (VAEncMiscParameterBufferQualityLevel *)misc->data;
vlVaHandleVAEncMiscParameterTypeQualityLevel(&context->desc.h264enc.quality_modes,
(vlVaQualityBits *)&ql->quality_level);
return VA_STATUS_SUCCESS;
}
VAStatus
vlVaHandleVAEncMiscParameterTypeMaxFrameSizeH264(vlVaContext *context, VAEncMiscParameterBuffer *misc)
{
VAEncMiscParameterBufferMaxFrameSize *ms = (VAEncMiscParameterBufferMaxFrameSize *)misc->data;
context->desc.h264enc.rate_ctrl[0].max_au_size = ms->max_frame_size;
return VA_STATUS_SUCCESS;
}
VAStatus
vlVaHandleVAEncMiscParameterTypeHRDH264(vlVaContext *context, VAEncMiscParameterBuffer *misc)
{
VAEncMiscParameterHRD *ms = (VAEncMiscParameterHRD *)misc->data;
if (ms->buffer_size) {
context->desc.h264enc.rate_ctrl[0].vbv_buffer_size = ms->buffer_size;
context->desc.h264enc.rate_ctrl[0].vbv_buf_lv = (ms->initial_buffer_fullness << 6 ) / ms->buffer_size;
}
return VA_STATUS_SUCCESS;
}
void getEncParamPresetH264(vlVaContext *context)
{
//rate control
context->desc.h264enc.rate_ctrl[0].vbv_buffer_size = 20000000;
context->desc.h264enc.rate_ctrl[0].vbv_buf_lv = 48;
context->desc.h264enc.rate_ctrl[0].fill_data_enable = 1;
context->desc.h264enc.rate_ctrl[0].enforce_hrd = 1;
context->desc.h264enc.rate_ctrl[0].max_qp = 51;
context->desc.h264enc.rate_ctrl[0].min_qp = 0;
context->desc.h264enc.enable_vui = false;
if (context->desc.h264enc.rate_ctrl[0].frame_rate_num == 0 ||
context->desc.h264enc.rate_ctrl[0].frame_rate_den == 0) {
context->desc.h264enc.rate_ctrl[0].frame_rate_num = 30;
context->desc.h264enc.rate_ctrl[0].frame_rate_den = 1;
}
context->desc.h264enc.rate_ctrl[0].target_bits_picture =
context->desc.h264enc.rate_ctrl[0].target_bitrate *
((float)context->desc.h264enc.rate_ctrl[0].frame_rate_den /
context->desc.h264enc.rate_ctrl[0].frame_rate_num);
context->desc.h264enc.rate_ctrl[0].peak_bits_picture_integer =
context->desc.h264enc.rate_ctrl[0].peak_bitrate *
((float)context->desc.h264enc.rate_ctrl[0].frame_rate_den /
context->desc.h264enc.rate_ctrl[0].frame_rate_num);
context->desc.h264enc.rate_ctrl[0].peak_bits_picture_fraction = 0;
}
|
44d8f95f765d9d45e5cfbaaf1e65ab111c7181c7
|
c2634ebec1d4448e372d174f459c3cbc03fd1edc
|
/lib/node_modules/@stdlib/ndarray/base/nullary/src/internal/range.c
|
355e1c22a2c5d1864cf6c18f0fba0769f3dc7e33
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"SunPro",
"BSD-3-Clause",
"BSL-1.0",
"LicenseRef-scancode-public-domain"
] |
permissive
|
stdlib-js/stdlib
|
ede11aee78f08e4f78a0bb939cb0bc244850b55b
|
f10c6e7db1a2b15cdd2b6237dd0927466ebd7278
|
refs/heads/develop
| 2023-09-05T03:29:36.368208
| 2023-09-03T22:42:11
| 2023-09-03T22:42:11
| 54,614,238
| 4,163
| 230
|
Apache-2.0
| 2023-09-13T21:26:07
| 2016-03-24T04:19:52
|
JavaScript
|
UTF-8
|
C
| false
| false
| 999
|
c
|
range.c
|
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
*
* 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 "stdlib/ndarray/base/nullary/internal/range.h"
#include <stdint.h>
/**
* Writes `n` evenly spaced values from `0` to `n-1` to an output array.
*
* @private
* @param n number of values to write
* @param out output array
*/
void stdlib_ndarray_base_nullary_internal_range( const int64_t n, int64_t *out ) {
int64_t i;
for ( i = 0; i < n; i++ ) {
out[ i ] = i;
}
}
|
be9c06fbcfb7ad4e10373f5ce797209b253e361f
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/games/adventure/hdr.h
|
3d954964a229afefa311079e1db5725f94309f04
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 6,142
|
h
|
hdr.h
|
/* $OpenBSD: hdr.h,v 1.18 2021/01/27 01:59:39 deraadt Exp $ */
/* $NetBSD: hdr.h,v 1.2 1995/03/21 12:05:02 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* The game adventure was originally written in Fortran by Will Crowther
* and Don Woods. It was later translated to C and enhanced by Jim
* Gillogly. This code is derived from software contributed to Berkeley
* by Jim Gillogly at The Rand Corporation.
*
* 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 University 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 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.
*
* @(#)hdr.h 8.1 (Berkeley) 5/31/93
*/
/* ADVENTURE -- Jim Gillogly, Jul 1977
* This program is a re-write of ADVENT, written in FORTRAN mostly by
* Don Woods of SAIL. In most places it is as nearly identical to the
* original as possible given the language and word-size differences.
* A few places, such as the message arrays and travel arrays were changed
* to reflect the smaller core size and word size. The labels of the
* original are reflected in this version, so that the comments of the
* fortran are still applicable here.
*
* The data file distributed with the fortran source is assumed to be called
* "glorkz" in the directory where the program is first run.
*/
/* hdr.h: included by c advent files */
#include <sys/types.h>
#include <signal.h>
extern int datfd; /* message file descriptor */
extern volatile sig_atomic_t delhit;
extern int yea;
extern char data_file[]; /* Virtual data file */
#define TAB 011
#define LF 012
#define FLUSHLINE do { int c; while ((c = getchar()) != EOF && c != '\n'); } while (0)
#define FLUSHLF while (next()!=LF)
extern int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2;
extern int verb, obj, spk;
extern int blklin;
extern time_t savet;
extern int mxscor, latncy;
#define SHORT 50 /* How short is a demo game? */
#define MAXSTR 20 /* max length of user's words */
extern char wd1[MAXSTR]; /* the complete words */
extern char wd2[MAXSTR];
#define HTSIZE 512 /* max number of vocab words */
struct hashtab { /* hash table for vocabulary */
int val; /* word type &index (ktab) */
char *atab; /* pointer to actual string */
};
extern struct hashtab voc[HTSIZE];
struct text {
char *seekadr; /* Msg start in virtual disk */
int txtlen; /* length of msg starting here */
};
#define RTXSIZ 205
extern struct text rtext[RTXSIZ]; /* random text messages */
#define MAGSIZ 35
extern struct text mtext[MAGSIZ]; /* magic messages */
extern int clsses;
#define CLSMAX 12
extern struct text ctext[CLSMAX]; /* classes of adventurer */
extern int cval[CLSMAX];
extern struct text ptext[101]; /* object descriptions */
#define LOCSIZ 141 /* number of locations */
extern struct text ltext[LOCSIZ]; /* long loc description */
extern struct text stext[LOCSIZ]; /* short loc descriptions */
struct travlist { /* direcs & conditions of travel*/
struct travlist *next; /* ptr to next list entry */
int conditions; /* m in writeup (newloc / 1000) */
int tloc; /* n in writeup (newloc % 1000) */
int tverb; /* the verb that takes you there*/
};
extern struct travlist *travel[LOCSIZ],*tkk; /* travel is closer to keys(...)*/
extern int atloc[LOCSIZ];
extern int plac[101]; /* initial object placement */
extern int fixd[101], fixed[101]; /* location fixed? */
extern int actspk[35]; /* rtext msg for verb <n> */
extern int cond[LOCSIZ]; /* various condition bits */
extern int setbit[16]; /* bit defn masks 1,2,4,... */
extern int hntmax;
extern int hints[20][5]; /* info on hints */
extern int hinted[20], hintlc[20];
extern int place[101], prop[101], linkx[201];
extern int abb[LOCSIZ];
extern int maxtrs, tally, tally2; /* treasure values */
#define FALSE 0
#define TRUE 1
extern int
keys, lamp, grate, cage, rod, rod2, steps, /* mnemonics */
bird, door, pillow, snake, fissur, tablet, clam, oyster,
magzin, dwarf, knife, food, bottle, water, oil, plant, plant2,
axe, mirror, dragon, chasm, troll, troll2, bear, messag,
vend, batter, nugget, coins, chest, eggs, tridnt, vase,
emrald, pyram, pearl, rug, chain, spices, back, look, cave,
null, entrnc, dprssn, enter, stream, pour, say, lock, throw,
find, invent;
extern int
chloc, chloc2, dseen[7], dloc[7], /* dwarf stuff */
odloc[7], dflag, daltlc;
extern int
tk[21], stick, dtotal, attack;
extern int
turns, lmwarn, iwest, knfloc, detail, /* various flags & counters */
abbnum, maxdie, numdie, holdng, dkill, foobar, bonus, clock1,
clock2, saved, closng, panic, closed, scorng;
extern int
demo, limit;
/* We need to get a little tricky to avoid strings */
#define DECR(a,b,c,d,e) decr(*#a-'+',*#b-'-',*#c-'#',*#d-'&',*#e-'%')
|
d2e41b60bf6e966e8664d7bd2ed0c1c5b49ebcdf
|
2dfc2beac0ad497f8fc59201921097a412f0df7f
|
/trunk/3rdparty/ffmpeg-4-fit/libavcodec/mpegaudiodsp_template.c
|
e531f8a904b14ad2f5cc6e59ad608bfe64b50065
|
[
"Apache-2.0",
"LicenseRef-scancode-mulanpsl-2.0-en",
"MIT",
"MulanPSL-2.0",
"LicenseRef-scancode-unknown-license-reference",
"OpenSSL",
"JSON",
"LGPL-3.0-only",
"LGPL-2.0-or-later",
"LGPL-3.0-or-later",
"IJG",
"LicenseRef-scancode-proprietary-license",
"GPL-2.0-or-later",
"LGPL-2.1-or-later",
"GPL-3.0-only",
"GPL-2.0-only",
"LicenseRef-scancode-other-permissive",
"GPL-1.0-or-later"
] |
permissive
|
ossrs/srs
|
cf9442478fedcd32ef2817f8d53f405a6fa2c7d1
|
7138edd318d30b545e73e80500adda771817f8d1
|
refs/heads/develop
| 2023-09-01T03:38:35.057515
| 2023-08-31T01:45:25
| 2023-08-31T01:49:36
| 34,777,562
| 23,557
| 5,046
|
MIT
| 2023-09-09T00:57:42
| 2015-04-29T06:59:32
|
C++
|
UTF-8
|
C
| false
| false
| 12,304
|
c
|
mpegaudiodsp_template.c
|
/*
* Copyright (c) 2001, 2002 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#include "dct32.h"
#include "mathops.h"
#include "mpegaudiodsp.h"
#include "mpegaudio.h"
#if USE_FLOATS
#define RENAME(n) n##_float
static inline float round_sample(float *sum)
{
float sum1=*sum;
*sum = 0;
return sum1;
}
#define MACS(rt, ra, rb) rt+=(ra)*(rb)
#define MULS(ra, rb) ((ra)*(rb))
#define MULH3(x, y, s) ((s)*(y)*(x))
#define MLSS(rt, ra, rb) rt-=(ra)*(rb)
#define MULLx(x, y, s) ((y)*(x))
#define FIXHR(x) ((float)(x))
#define FIXR(x) ((float)(x))
#define SHR(a,b) ((a)*(1.0f/(1<<(b))))
#else
#define RENAME(n) n##_fixed
#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
static inline int round_sample(int64_t *sum)
{
int sum1;
sum1 = (int)((*sum) >> OUT_SHIFT);
*sum &= (1<<OUT_SHIFT)-1;
return av_clip_int16(sum1);
}
# define MULS(ra, rb) MUL64(ra, rb)
# define MACS(rt, ra, rb) MAC64(rt, ra, rb)
# define MLSS(rt, ra, rb) MLS64(rt, ra, rb)
# define MULH3(x, y, s) MULH((s)*(x), y)
# define MULLx(x, y, s) MULL((int)(x),(y),s)
# define SHR(a,b) (((int)(a))>>(b))
# define FIXR(a) ((int)((a) * FRAC_ONE + 0.5))
# define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))
#endif
/** Window for MDCT. Actually only the elements in [0,17] and
[MDCT_BUF_SIZE/2, MDCT_BUF_SIZE/2 + 17] are actually used. The rest
is just to preserve alignment for SIMD implementations.
*/
DECLARE_ALIGNED(16, INTFLOAT, RENAME(ff_mdct_win))[8][MDCT_BUF_SIZE];
DECLARE_ALIGNED(16, MPA_INT, RENAME(ff_mpa_synth_window))[512+256];
#define SUM8(op, sum, w, p) \
{ \
op(sum, (w)[0 * 64], (p)[0 * 64]); \
op(sum, (w)[1 * 64], (p)[1 * 64]); \
op(sum, (w)[2 * 64], (p)[2 * 64]); \
op(sum, (w)[3 * 64], (p)[3 * 64]); \
op(sum, (w)[4 * 64], (p)[4 * 64]); \
op(sum, (w)[5 * 64], (p)[5 * 64]); \
op(sum, (w)[6 * 64], (p)[6 * 64]); \
op(sum, (w)[7 * 64], (p)[7 * 64]); \
}
#define SUM8P2(sum1, op1, sum2, op2, w1, w2, p) \
{ \
INTFLOAT tmp;\
tmp = p[0 * 64];\
op1(sum1, (w1)[0 * 64], tmp);\
op2(sum2, (w2)[0 * 64], tmp);\
tmp = p[1 * 64];\
op1(sum1, (w1)[1 * 64], tmp);\
op2(sum2, (w2)[1 * 64], tmp);\
tmp = p[2 * 64];\
op1(sum1, (w1)[2 * 64], tmp);\
op2(sum2, (w2)[2 * 64], tmp);\
tmp = p[3 * 64];\
op1(sum1, (w1)[3 * 64], tmp);\
op2(sum2, (w2)[3 * 64], tmp);\
tmp = p[4 * 64];\
op1(sum1, (w1)[4 * 64], tmp);\
op2(sum2, (w2)[4 * 64], tmp);\
tmp = p[5 * 64];\
op1(sum1, (w1)[5 * 64], tmp);\
op2(sum2, (w2)[5 * 64], tmp);\
tmp = p[6 * 64];\
op1(sum1, (w1)[6 * 64], tmp);\
op2(sum2, (w2)[6 * 64], tmp);\
tmp = p[7 * 64];\
op1(sum1, (w1)[7 * 64], tmp);\
op2(sum2, (w2)[7 * 64], tmp);\
}
void RENAME(ff_mpadsp_apply_window)(MPA_INT *synth_buf, MPA_INT *window,
int *dither_state, OUT_INT *samples,
ptrdiff_t incr)
{
register const MPA_INT *w, *w2, *p;
int j;
OUT_INT *samples2;
#if USE_FLOATS
float sum, sum2;
#else
int64_t sum, sum2;
#endif
/* copy to avoid wrap */
memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));
samples2 = samples + 31 * incr;
w = window;
w2 = window + 31;
sum = *dither_state;
p = synth_buf + 16;
SUM8(MACS, sum, w, p);
p = synth_buf + 48;
SUM8(MLSS, sum, w + 32, p);
*samples = round_sample(&sum);
samples += incr;
w++;
/* we calculate two samples at the same time to avoid one memory
access per two sample */
for(j=1;j<16;j++) {
sum2 = 0;
p = synth_buf + 16 + j;
SUM8P2(sum, MACS, sum2, MLSS, w, w2, p);
p = synth_buf + 48 - j;
SUM8P2(sum, MLSS, sum2, MLSS, w + 32, w2 + 32, p);
*samples = round_sample(&sum);
samples += incr;
sum += sum2;
*samples2 = round_sample(&sum);
samples2 -= incr;
w++;
w2--;
}
p = synth_buf + 32;
SUM8(MLSS, sum, w + 32, p);
*samples = round_sample(&sum);
*dither_state= sum;
}
/* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
32 samples. */
void RENAME(ff_mpa_synth_filter)(MPADSPContext *s, MPA_INT *synth_buf_ptr,
int *synth_buf_offset,
MPA_INT *window, int *dither_state,
OUT_INT *samples, ptrdiff_t incr,
MPA_INT *sb_samples)
{
MPA_INT *synth_buf;
int offset;
offset = *synth_buf_offset;
synth_buf = synth_buf_ptr + offset;
s->RENAME(dct32)(synth_buf, sb_samples);
s->RENAME(apply_window)(synth_buf, window, dither_state, samples, incr);
offset = (offset - 32) & 511;
*synth_buf_offset = offset;
}
av_cold void RENAME(ff_mpa_synth_init)(MPA_INT *window)
{
int i, j;
/* max = 18760, max sum over all 16 coefs : 44736 */
for(i=0;i<257;i++) {
INTFLOAT v;
v = ff_mpa_enwindow[i];
#if USE_FLOATS
v *= 1.0 / (1LL<<(16 + FRAC_BITS));
#endif
window[i] = v;
if ((i & 63) != 0)
v = -v;
if (i != 0)
window[512 - i] = v;
}
// Needed for avoiding shuffles in ASM implementations
for(i=0; i < 8; i++)
for(j=0; j < 16; j++)
window[512+16*i+j] = window[64*i+32-j];
for(i=0; i < 8; i++)
for(j=0; j < 16; j++)
window[512+128+16*i+j] = window[64*i+48-j];
}
av_cold void RENAME(ff_init_mpadsp_tabs)(void)
{
int i, j;
/* compute mdct windows */
for (i = 0; i < 36; i++) {
for (j = 0; j < 4; j++) {
double d;
if (j == 2 && i % 3 != 1)
continue;
d = sin(M_PI * (i + 0.5) / 36.0);
if (j == 1) {
if (i >= 30) d = 0;
else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0);
else if (i >= 18) d = 1;
} else if (j == 3) {
if (i < 6) d = 0;
else if (i < 12) d = sin(M_PI * (i - 6 + 0.5) / 12.0);
else if (i < 18) d = 1;
}
//merge last stage of imdct into the window coefficients
d *= 0.5 * IMDCT_SCALAR / cos(M_PI * (2 * i + 19) / 72);
if (j == 2)
RENAME(ff_mdct_win)[j][i/3] = FIXHR((d / (1<<5)));
else {
int idx = i < 18 ? i : i + (MDCT_BUF_SIZE/2 - 18);
RENAME(ff_mdct_win)[j][idx] = FIXHR((d / (1<<5)));
}
}
}
/* NOTE: we do frequency inversion adter the MDCT by changing
the sign of the right window coefs */
for (j = 0; j < 4; j++) {
for (i = 0; i < MDCT_BUF_SIZE; i += 2) {
RENAME(ff_mdct_win)[j + 4][i ] = RENAME(ff_mdct_win)[j][i ];
RENAME(ff_mdct_win)[j + 4][i + 1] = -RENAME(ff_mdct_win)[j][i + 1];
}
}
}
/* cos(pi*i/18) */
#define C1 FIXHR(0.98480775301220805936/2)
#define C2 FIXHR(0.93969262078590838405/2)
#define C3 FIXHR(0.86602540378443864676/2)
#define C4 FIXHR(0.76604444311897803520/2)
#define C5 FIXHR(0.64278760968653932632/2)
#define C6 FIXHR(0.5/2)
#define C7 FIXHR(0.34202014332566873304/2)
#define C8 FIXHR(0.17364817766693034885/2)
/* 0.5 / cos(pi*(2*i+1)/36) */
static const INTFLOAT icos36[9] = {
FIXR(0.50190991877167369479),
FIXR(0.51763809020504152469), //0
FIXR(0.55168895948124587824),
FIXR(0.61038729438072803416),
FIXR(0.70710678118654752439), //1
FIXR(0.87172339781054900991),
FIXR(1.18310079157624925896),
FIXR(1.93185165257813657349), //2
FIXR(5.73685662283492756461),
};
/* 0.5 / cos(pi*(2*i+1)/36) */
static const INTFLOAT icos36h[9] = {
FIXHR(0.50190991877167369479/2),
FIXHR(0.51763809020504152469/2), //0
FIXHR(0.55168895948124587824/2),
FIXHR(0.61038729438072803416/2),
FIXHR(0.70710678118654752439/2), //1
FIXHR(0.87172339781054900991/2),
FIXHR(1.18310079157624925896/4),
FIXHR(1.93185165257813657349/4), //2
// FIXHR(5.73685662283492756461),
};
/* using Lee like decomposition followed by hand coded 9 points DCT */
static void imdct36(INTFLOAT *out, INTFLOAT *buf, SUINTFLOAT *in, INTFLOAT *win)
{
int i, j;
SUINTFLOAT t0, t1, t2, t3, s0, s1, s2, s3;
SUINTFLOAT tmp[18], *tmp1, *in1;
for (i = 17; i >= 1; i--)
in[i] += in[i-1];
for (i = 17; i >= 3; i -= 2)
in[i] += in[i-2];
for (j = 0; j < 2; j++) {
tmp1 = tmp + j;
in1 = in + j;
t2 = in1[2*4] + in1[2*8] - in1[2*2];
t3 = in1[2*0] + SHR(in1[2*6],1);
t1 = in1[2*0] - in1[2*6];
tmp1[ 6] = t1 - SHR(t2,1);
tmp1[16] = t1 + t2;
t0 = MULH3(in1[2*2] + in1[2*4] , C2, 2);
t1 = MULH3(in1[2*4] - in1[2*8] , -2*C8, 1);
t2 = MULH3(in1[2*2] + in1[2*8] , -C4, 2);
tmp1[10] = t3 - t0 - t2;
tmp1[ 2] = t3 + t0 + t1;
tmp1[14] = t3 + t2 - t1;
tmp1[ 4] = MULH3(in1[2*5] + in1[2*7] - in1[2*1], -C3, 2);
t2 = MULH3(in1[2*1] + in1[2*5], C1, 2);
t3 = MULH3(in1[2*5] - in1[2*7], -2*C7, 1);
t0 = MULH3(in1[2*3], C3, 2);
t1 = MULH3(in1[2*1] + in1[2*7], -C5, 2);
tmp1[ 0] = t2 + t3 + t0;
tmp1[12] = t2 + t1 - t0;
tmp1[ 8] = t3 - t1 - t0;
}
i = 0;
for (j = 0; j < 4; j++) {
t0 = tmp[i];
t1 = tmp[i + 2];
s0 = t1 + t0;
s2 = t1 - t0;
t2 = tmp[i + 1];
t3 = tmp[i + 3];
s1 = MULH3(t3 + t2, icos36h[ j], 2);
s3 = MULLx(t3 - t2, icos36 [8 - j], FRAC_BITS);
t0 = s0 + s1;
t1 = s0 - s1;
out[(9 + j) * SBLIMIT] = MULH3(t1, win[ 9 + j], 1) + buf[4*(9 + j)];
out[(8 - j) * SBLIMIT] = MULH3(t1, win[ 8 - j], 1) + buf[4*(8 - j)];
buf[4 * ( 9 + j )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 9 + j], 1);
buf[4 * ( 8 - j )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 8 - j], 1);
t0 = s2 + s3;
t1 = s2 - s3;
out[(9 + 8 - j) * SBLIMIT] = MULH3(t1, win[ 9 + 8 - j], 1) + buf[4*(9 + 8 - j)];
out[ j * SBLIMIT] = MULH3(t1, win[ j], 1) + buf[4*( j)];
buf[4 * ( 9 + 8 - j )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 9 + 8 - j], 1);
buf[4 * ( j )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + j], 1);
i += 4;
}
s0 = tmp[16];
s1 = MULH3(tmp[17], icos36h[4], 2);
t0 = s0 + s1;
t1 = s0 - s1;
out[(9 + 4) * SBLIMIT] = MULH3(t1, win[ 9 + 4], 1) + buf[4*(9 + 4)];
out[(8 - 4) * SBLIMIT] = MULH3(t1, win[ 8 - 4], 1) + buf[4*(8 - 4)];
buf[4 * ( 9 + 4 )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 9 + 4], 1);
buf[4 * ( 8 - 4 )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 8 - 4], 1);
}
void RENAME(ff_imdct36_blocks)(INTFLOAT *out, INTFLOAT *buf, INTFLOAT *in,
int count, int switch_point, int block_type)
{
int j;
for (j=0 ; j < count; j++) {
/* apply window & overlap with previous buffer */
/* select window */
int win_idx = (switch_point && j < 2) ? 0 : block_type;
INTFLOAT *win = RENAME(ff_mdct_win)[win_idx + (4 & -(j & 1))];
imdct36(out, buf, in, win);
in += 18;
buf += ((j&3) != 3 ? 1 : (72-3));
out++;
}
}
|
a8e15c20a2e66a964b7ef4ea41c9e69ca4a820b1
|
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
|
/released_plugins/v3d_plugins/cellseg_gvf/src/FL_cellSegmentation3D.h
|
938f9fcd338f305399913d04d6c2282908ec0eff
|
[
"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
| 1,777
|
h
|
FL_cellSegmentation3D.h
|
//FL_cellSegmentation3D.h
//by Fuhui Long
//20080310
//20080825: add a FL_SEG_LABEL_TYPE
#ifndef __CELL_SEGMENTATION3D__
#define __CELL_SEGMENTATION3D__
#include "../basic_c_fun/v3d_basicdatatype.h"
//typedef unsigned short int CellSegLabelType;
//class Vol3DSimple <unsigned char>;
//class segParameter // for watershed segmentation
//{
//public:
// char *infilename, *outfilename; // name of input and output files
// int channelNo; // channel to be segmented
//// int backgndLevel; // background level
// int medianFiltWid;
// int gaussinFiltWid;
// float gaussinFiltSigma;
// int adaptThreWid;
// int adaptThreStp;
// int segMethod; // segmentation method
// int adpatThreMethod; // thresholding method
//
// segParameter() //initialize parameters using default values
// {
// infilename = NULL;
// outfilename = NULL;
// channelNo = 2;
//// backgndLevel = 15;
// medianFiltWid = 2;
// gaussinFiltWid = 1;
// gaussinFiltSigma = 1;
// adaptThreWid = 10;
// adaptThreStp = 5;
// segMethod = 0;
// adpatThreMethod = 0;
// }
//
// segParameter(const segParameter & segPara) //initialize parameters using input values
// {
//
// infilename = segPara.infilename;
// outfilename = segPara.outfilename;
// channelNo = segPara.channelNo;
//// backgndLevel = segPara.backgndLevel;
// medianFiltWid = segPara.medianFiltWid;
// gaussinFiltWid = segPara.gaussinFiltWid;
// gaussinFiltSigma= segPara.gaussinFiltSigma;
// adaptThreWid = segPara.adaptThreWid;
// adaptThreStp = segPara.adaptThreStp;
// segMethod = segPara.segMethod;
// adpatThreMethod = segPara.adpatThreMethod;
// }
//
//};
#include "seg_parameter.h"
bool FL_cellseg(Vol3DSimple <unsigned char> *img3d, Vol3DSimple <unsigned short int> *outimg3d, const segParameter & mypara);
#endif
|
1cfbdb2fcf6060ff3b620160d450824fee50d283
|
badb70a0b235c98ac034cfe5b4bfafda36647831
|
/Include/Intel/Guid/BlockIoVendor.h
|
f7318104f454fde2bc9236490192e5a76df84509
|
[
"BSD-3-Clause"
] |
permissive
|
acidanthera/OpenCorePkg
|
f34a7d67b22c74fb5ab559e48519e5f5855b6751
|
1d5b1736fe5a5ef7662b5c076c6d11aac96fd5d6
|
refs/heads/master
| 2023-08-30T21:03:02.993659
| 2023-08-28T23:30:43
| 2023-08-28T23:30:43
| 179,354,282
| 13,212
| 2,999
|
BSD-3-Clause
| 2023-09-10T18:29:53
| 2019-04-03T19:14:29
|
C
|
UTF-8
|
C
| false
| false
| 582
|
h
|
BlockIoVendor.h
|
/** @file
Guid for unrecognized EDD 3.0 device.
Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __BLOCKIO_VENDOR_H__
#define __BLOCKIO_VENDOR_H__
//
// Guid is to specifiy the unrecognized EDD 3.0 device.
//
#define BLOCKIO_VENDOR_GUID \
{ 0xCF31FAC5, 0xC24E, 0x11D2, \
{0x85, 0xF3, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B }}
typedef struct {
VENDOR_DEVICE_PATH DevicePath;
UINT8 LegacyDriveLetter;
} BLOCKIO_VENDOR_DEVICE_PATH;
extern GUID gBlockIoVendorGuid;
#endif
|
0329aeef9ed869f5282ed197557dc42bdbed63aa
|
3b1223e5259c580cbf107d1f45960d9f08aff27f
|
/SOM/Frameworks/some/emitpas/pas.c
|
0110d5aa6c2ede32c129343c9116d10c0e0f4c24
|
[] |
no_license
|
osfree-project/osfree
|
6be0fe3e2fb5ef577650b7a3a9eee1f38fb2eb8b
|
04ba405e346948ef0ae1a1b483aeb76f044c50a0
|
refs/heads/master
| 2023-09-02T21:38:29.849765
| 2023-08-30T05:21:33
| 2023-08-30T05:21:33
| 122,781,887
| 105
| 11
| null | 2023-01-24T08:36:57
| 2018-02-24T21:36:31
|
C
|
IBM866
|
C
| false
| false
| 48,787
|
c
|
pas.c
|
/*
* This file was generated by the SOM Compiler.
* Generated using:
* SOM incremental update: 2.24
*/
/*
* This file was generated by the SOM Compiler and Emitter Framework.
* Generated using template emitter:
* SOM Emitter emitctm: 2.23.1.9
*/
#ifndef SOM_Module_pas_Source
#define SOM_Module_pas_Source
#endif
#define PascalEmitter_Class_Source
#include "pas.ih"
#include <scparm.h>
#include <sctdef.h>
#include <scseqnce.h>
#include <scmodule.h>
#include <scstruct.h>
#include <scconst.h>
#include <scenum.h>
#include <scenumnm.h>
#include <scunion.h>
#include <scattrib.h>
#include <scclass.h>
#include "sequences.h"
#include "strpas.h"
#include <string.h>
#define DEBUG
#ifdef DEBUG
#define debug(s,...) somPrintf(__func__"(): "##s"\n" ,##__VA_ARGS__)
#else
#define debug(x, ...)
#endif
#define GEN_SOM_CLASSES 1
#define GEN_PASCAL_CLASSES 0
#define PARAM_CLASS 1
#define PARAM_CLASS_PTR 2
static PLINKITEM MakeTypeLinkItem(PIDLSEQUENCE TypeItems,
PIDLSEQUENCE LinkItems, SOMTEntryC *et,
SOMTCommonEntryC *decl);
// Cоздание описателя элемента в общем списке элементов TypeItems
static PTYPEITEM MakeTypeItem(PIDLSEQUENCE TypeItems, long DefType,
boolean NeedAddPtr,
char *Name,
SOMTEntryC *entry)
{
PTYPEITEM TypeItem;
TypeItem = calloc( 1, sizeof(TYPEITEM) );
TypeItem->Obj = entry;
TypeItem->DefType = DefType;
TypeItem->PtrFlag = NeedAddPtr;
TypeItem->Name = strdup( Name );
if ( entry )
TypeItem->Comment = __get_somtEntryComment(entry);
seqInit( (PIDLSEQUENCE)&TypeItem->LinkItems, 0, sizeof(PLINKITEM) );
seqInsert( TypeItems, sizeof(PTYPEITEM), &TypeItem );
return TypeItem;
}
// Поиск описателя элемента по объекту Emitter Framework
static PTYPEITEM GetTypeItemByObj(PIDLSEQUENCE TypeItems, SOMTEntryC *en)
{
PTYPEITEM TypeItem;
unsigned long i;
for (i=0; i<TypeItems->length; i++)
{
TypeItem = *(PTYPEITEM *)seqAt( TypeItems, sizeof(PTYPEITEM), i );
if ( TypeItem->Obj &&
__get_somtEntryName(en) == __get_somtEntryName(TypeItem->Obj) )
return TypeItem;
}
return NULL;
}
// Cоздание поля описателя элемента (в его списке LinkItems)
static PLINKITEM MakeSimpleLinkItem(PIDLSEQUENCE TypeItems, PIDLSEQUENCE LinkItems,
SOMTEntryC *en)
{
PLINKITEM LinkItem;
LinkItem = calloc( 1, sizeof(LINKITEM) );
LinkItem->Obj = en;
//// LinkItem->PtrDeep = 0;
//// LinkItem->FieldName = NULL;
// LinkItem->Name = strdup( __get_somtEntryName(en) );
//// LinkItem->TypeItem = NULL;
//// LinkItem->ArrayDim = 0;
seqInsert( LinkItems, sizeof(PLINKITEM), &LinkItem );
return LinkItem;
}
// Cоздание описателя последовательности
static PTYPEITEM CollectSequence(PIDLSEQUENCE TypeItems, SOMTSequenceEntryC *seq,
SOMTCommonEntryC *decl)
{
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
char cBuf[128], cSeqType[128], *pcSeqType;
unsigned long pos;
unsigned long SeqLen = __get_somtSeqLength(seq);
SOMTEntryC *st = __get_somtSeqType(seq);
// обработка вложенных последовательностей
if ( __get_somtElementType(st) == SOMTSequenceE ) // тип послед-ти - посл-ть?
{
TypeItem = CollectSequence(TypeItems, st, decl);
sprintf(cSeqType, "sequence_%s",
__get_somtEntryName( __get_somtSeqType(TypeItem->Obj) ));
pcSeqType = cSeqType;
}
else
pcSeqType = __get_somtEntryName(st);
pos = sprintf( cBuf, "%s_IDL_SEQUENCE_%s", __get_somtEntryName(decl),
pcSeqType/*__get_somtEntryName(st)*/ );
if ( SeqLen ) // для обеспечения уникальности дополняем имя длинной очереди
sprintf( &cBuf[pos], "_%u", SeqLen );
TypeItem = MakeTypeItem(TypeItems, dtSequence, TRUE, cBuf, seq);
debug("collect sequence: %s", TypeItem->Name);
LinkItem = MakeSimpleLinkItem( TypeItems, (PIDLSEQUENCE)&TypeItem->LinkItems,
__get_somtSeqType(seq) );
// используем это поле под хранение длины очереди (оно свободно т.к.
// типом последовательности не может быть массив)
LinkItem->ArrayLen[0] = !SeqLen ? 1 : SeqLen;
return TypeItem;
}
// Cоздание описателя структуры
static void CollectStruct(PIDLSEQUENCE TypeItems, SOMTStructEntryC* struc)
{
SOMTTypedefEntryC *member;
SOMTCommonEntryC *decl;
PTYPEITEM TypeItem;
TypeItem = MakeTypeItem(TypeItems, dtStruct, TRUE,
__get_somtEntryName(struc), struc);
debug("collect struct: %s", TypeItem->Name);
for (member=_somtGetFirstMember(struc); member; member=_somtGetNextMember(struc))
{
for (decl=_somtGetFirstDeclarator(member);decl;decl=_somtGetNextDeclarator(member))
MakeTypeLinkItem( TypeItems, (PIDLSEQUENCE)&TypeItem->LinkItems,
__get_somtTypeObj(member), decl );
}
}
// Cоздание описателя объединения
static void CollectUnion(PIDLSEQUENCE TypeItems, SOMTUnionEntryC* un)
{
PTYPEITEM TypeItem;
SOMTUnionEntryC_somtCaseEntry *ce;
TypeItem = MakeTypeItem(TypeItems, dtUnion,
TRUE, __get_somtEntryName(un), un);
debug("collect union: %s", TypeItem->Name);
// 0й LinkItem - описание типа переключателя объединения
MakeSimpleLinkItem( TypeItems, (PIDLSEQUENCE)&TypeItem->LinkItems,
__get_somtSwitchType(un) );
// поля объединения
for (ce=_somtGetFirstCaseEntry(un); ce; ce=_somtGetNextCaseEntry(un))
MakeTypeLinkItem( TypeItems, (PIDLSEQUENCE)&TypeItem->LinkItems,
ce->memberType, ce->memberDeclarator );
}
// Cоздание описателя объявления типа
// здесь также создаются описатели промежуточных объявлений типов для раскладки
// конструкций вроде: typedef struct St {} MySt; typedef **MyPntToArrOfPnts[10];
static PLINKITEM MakeTypeLinkItem(PIDLSEQUENCE TypeItems,
PIDLSEQUENCE LinkItems, SOMTEntryC *et,
SOMTCommonEntryC *decl)
{
PLINKITEM LinkItem, ScanLinkItem, res;
PTYPEITEM TypeItem;
long dim;
char cBuf[128];
unsigned long i;
long ArrayDim, ArrayLen[32];
if ( !__get_somtIsReference(et) )
switch ( __get_somtElementType(et) )
{
case SOMTSequenceE:
if ( !GetTypeItemByObj(TypeItems, et) )
CollectSequence(TypeItems, et, decl);
break;
case SOMTStructE:
CollectStruct(TypeItems, et);
break;
case SOMTUnionE:
CollectUnion(TypeItems, et);
break;
}
LinkItem = MakeSimpleLinkItem( TypeItems, LinkItems, et );
LinkItem->PtrDeep = strlen(__get_somtPtrs(decl));
LinkItem->FieldName = strdup( __get_somtEntryName(decl) );
res = LinkItem;
debug("\tfield: %s, DeepPtr=%d", LinkItem->FieldName, LinkItem->PtrDeep);
if ( _somtIsArray(decl,&dim) )
{
// читаем размерности массива
ArrayDim = 0;
if ( dim = _somtGetFirstArrayDimension(decl) )
for (; dim; dim = _somtGetNextArrayDimension(decl) )
{
ArrayLen[ArrayDim] = dim;
ArrayDim++;
}
else {
ArrayLen[0] = 1;
ArrayDim = 1;
}
if ( LinkItem->PtrDeep > 1 ) // указатель на массив указателей ==>
{ // необходимо дополнительное объявление
// типа-массива, и объявление указателя на его
LinkItem->PtrDeep--;
// смотрим, нет ли уже найденного объявления идентичного массива
for (i=0; i<TypeItems->length; i++)
{
TypeItem = *(PTYPEITEM *)seqAt( TypeItems, sizeof(PTYPEITEM), i );
if ( TypeItem->DefType != dtTypedef || TypeItem->PtrFlag ||
TypeItem->Obj || TypeItem->LinkItems._length != 1 )
continue;
ScanLinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), 0 );
if ( !ScanLinkItem || LinkItem->PtrDeep != 1 ||
ScanLinkItem->ArrayDim != ArrayDim || ScanLinkItem->Obj != et ||
memcmp(&ScanLinkItem->ArrayLen, &ArrayLen, ArrayDim * sizeof(long)) )
continue;
LinkItem->TypeItem = TypeItem; // есть такой - биндим к нему
return res;
}
// теоретически, тут с именами могут быть накладки при одинаковом типе
// элементов и разных размерах... может, стОит в имени дописывать
// размерность массива... ?
sprintf( cBuf, "%s_IDL_ARRAY_%s", __get_somtEntryName(decl), __get_somtEntryName(et) );
TypeItem = MakeTypeItem(TypeItems, dtTypedef, FALSE, cBuf, NULL);
LinkItem->TypeItem = TypeItem; // биндим к созданному объявлению массива
LinkItem = MakeSimpleLinkItem( TypeItems,
(PIDLSEQUENCE)&TypeItem->LinkItems, et );
LinkItem->PtrDeep = 1;
}
LinkItem->ArrayDim = ArrayDim;
memcpy(&LinkItem->ArrayLen, &ArrayLen, ArrayDim * sizeof(long));
}
return res;
}
// Уничтожение LinkItem
static long destroyLinkItem(unsigned long idx, void *item)
{
PLINKITEM LinkItem = *(PLINKITEM *)item;
free(LinkItem->FieldName);
return 1;
}
// Уничтожение TypeItem
static long destroyTypeItem(unsigned long idx, void *item)
{
PTYPEITEM TypeItem = *(PTYPEITEM *)item;
seqDone((PIDLSEQUENCE)&TypeItem->LinkItems, sizeof(PLINKITEM),
destroyLinkItem);
free(TypeItem->Name);
return 1;
}
#ifdef DEBUG
// debugTypeItems()
// Дебаговый вывод списка описателей TypeItems
static long debugLinkItem(unsigned long idx, void *item)
{
PTYPEITEM UplinkTypeItem;
PLINKITEM LinkItem = *(PLINKITEM *)item;
if ( !LinkItem )
debug(" %u: NULL");
UplinkTypeItem = LinkItem->TypeItem;
debug(" %u: %s->%s", idx,
LinkItem->FieldName ? LinkItem->FieldName : "",
UplinkTypeItem ? UplinkTypeItem->Name : "");
return 1;
}
static long debugTypeItem(unsigned long idx, void *item)
{
PTYPEITEM TypeItem = *(PTYPEITEM *)item;
debug("%u: %s", idx, TypeItem->Name);
seqForEach((PIDLSEQUENCE)&TypeItem->LinkItems, sizeof(PLINKITEM),
debugLinkItem);
return 1;
}
static void debugTypeItems(PIDLSEQUENCE TypeItems)
{
debug("-- "__func__"() --");
seqForEach(TypeItems, sizeof(PTYPEITEM), debugTypeItem);
debug("----------------------");
}
#else
#define debugTypeItems(x)
#endif
// Построение графа, описывающего связи между полями описателей и описателями
// т.е. установка значений LinkItem->TypeItem у полей описателей на основе
// ссылок на объекты Emitter Framework
static void BindTypes(PIDLSEQUENCE TypeItems)
{
unsigned long i, j, k;
PTYPEITEM TypeItem, UplinkTypeItem;
PLINKITEM LinkItem;
for (i=0; i<TypeItems->length; i++)
{
TypeItem = *(PTYPEITEM *)seqAt( TypeItems, sizeof(PTYPEITEM), i );
for (j=0; j < TypeItem->LinkItems._length; j++)
{
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), j );
if ( !LinkItem->TypeItem && LinkItem->Obj )
for (k=0; k<TypeItems->length; k++)
{
UplinkTypeItem = *(PTYPEITEM *)seqAt( TypeItems, sizeof(PTYPEITEM), k );
if ( UplinkTypeItem->Obj && __get_somtEntryName(UplinkTypeItem->Obj)
== __get_somtEntryName(LinkItem->Obj) )
{
LinkItem->TypeItem = UplinkTypeItem;
UplinkTypeItem->BindCount++;
debug("bind: %s.%s -> %s", TypeItem->Name, LinkItem->FieldName,
UplinkTypeItem->Name);
break;
}
}
}
}
debugTypeItems(TypeItems);
}
// Сортировка описателей: все поля описателей должны ссылаться на описатели
// с меньшим индексом в списке TypeItems
static void SortTypes(PIDLSEQUENCE TypeItems)
{
long i, j, k, l;
PTYPEITEM UplinkTypeItem, TypeItem;
PLINKITEM LinkItem;
boolean found;
PTYPEITEM SwapBuf;
for (i=0; i < (long)TypeItems->length-1; i++)
{
l = -1;
TestItem:
TypeItem = *(PTYPEITEM *)seqAt( TypeItems, sizeof(PTYPEITEM), i );
for (j=0; j < TypeItem->LinkItems._length; j++)
{
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&(TypeItem->LinkItems),
sizeof(PLINKITEM), j );
if ( UplinkTypeItem = LinkItem->TypeItem )
{
found = FALSE;
for (k=i+1; k < TypeItems->length; k++)
{
if ( UplinkTypeItem == *(PTYPEITEM *)seqAt(TypeItems, sizeof(PTYPEITEM), k) )
{
found = l != k;
if ( !found ) // надо попробовать добиться такой ситуации (конструкции в idl)
somPrintf("Warning! Cycled links.");
break;
}
}
if ( found )
{
l = k;
seqSwap(TypeItems, sizeof(PTYPEITEM), i, k, &SwapBuf);
goto TestItem;
}
}
}
}
}
// LinkItemStr()
// Строковое представление типа LinkItem в нотации паскаля
static char *PasTypeStr(char *pcBuf, SOMTEntryC *Obj,
unsigned long GenerateRealSOMClassesDef)
{
char *pcTypeName;
pcTypeName = __get_somtEntryName(Obj);
if ( __get_somtElementType(Obj) == SOMTClassE && GenerateRealSOMClassesDef )
sprintf(pcBuf, "Real%s", pcTypeName);
else {
if ( strncmp(pcTypeName,"unsigned ",9) )
return pcTypeName;
*pcBuf = 'u';
strcpy(&pcBuf[1],&pcTypeName[9]);
}
return pcBuf;
}
static char *LinkItemStr(char *pcBuf, PLINKITEM LinkItem,
unsigned long GenerateRealSOMClassesDef)
{
unsigned long i;
char *pcPrefix = NULL;
char cTypeName[92];
PTYPEITEM UplinkTypeItem;
if ( LinkItem->ArrayDim )
{
strcpy(pcBuf,"array [");
pcBuf = strchr(pcBuf,'\0');
for (i=0; i<LinkItem->ArrayDim; i++)
{
if ( i ) *(pcBuf++) = ',';
sprintf(pcBuf, "0..%u", LinkItem->ArrayLen[i]-1);
pcBuf = strchr(pcBuf,'\0');
}
strcpy(pcBuf,"] of ");
pcBuf = strchr(pcBuf,'\0');
}
if ( !LinkItem->Obj ||
strncmp(__get_somtEntryName(LinkItem->Obj), "void*", 5) )
{
UplinkTypeItem = (PTYPEITEM)(LinkItem->TypeItem);
if ( UplinkTypeItem && ( UplinkTypeItem->DefType == dtTypedef ||
UplinkTypeItem->DefType == dtPTypedef ) )
{
if ( LinkItem->PtrDeep <= 1 )
{
pcPrefix = UplinkTypeItem->DefType == dtTypedef ? "^T" : "^P";
if ( !LinkItem->PtrDeep )
pcPrefix++;
}
}
else {
if ( !LinkItem->PtrDeep )
pcPrefix = "T";
else if ( LinkItem->PtrDeep == 1 )
pcPrefix = "P";
else if ( LinkItem->PtrDeep == 2 )
pcPrefix = "^P";
}
}
if ( pcPrefix )
{
sprintf( pcBuf, "%s%s", pcPrefix,
UplinkTypeItem ? UplinkTypeItem->Name :
PasTypeStr(cTypeName,LinkItem->Obj,
GenerateRealSOMClassesDef) );
} else
strcpy( pcBuf, "pointer" );
return pcBuf;
}
// Вывод объявлений типов.
static void PutupTypedefs(PIDLSEQUENCE TypeItems,
unsigned long *pCurrentPasSection,
SOMTTemplateOutputC *template)
{
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
unsigned long i, j;
char cBuf[128];
for (i=0; i<TypeItems->length; i++)
{
TypeItem = *(PTYPEITEM *)seqAt( TypeItems, sizeof(PTYPEITEM), i );
// описываем только объявления типов, dtClass - предварительное объявление
// класса, выводим только если на него были ссылки (BindCount != 0)
if ( !(TypeItem->DefType & dtTypeMask) ||
(TypeItem->DefType == dtClass && !TypeItem->BindCount) )
continue;
if ( !(*pCurrentPasSection & dtTypeMask) )
{
_somtOutputSection(template, "pasTypedefsPrologS");
*pCurrentPasSection = TypeItem->DefType;
}
_somtSetSymbolCopyBoth(template, "pasComment", TypeItem->Comment);
_somtSetSymbolCopyBoth(template, "defDeclName", TypeItem->Name);
// дополнительное рисование указателя на то что дальше будем выводить.
if ( TypeItem->PtrFlag && ( TypeItem->DefType != dtTypedef ) )
_somtOutputSection(template, "pasPtrToRecTypedefS");
switch ( TypeItem->DefType )
{
case dtClass:
_somtOutputSection(template, "pasForwardClassS");
break;
case dtTypedef:
case dtPTypedef:
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), 0 );
LinkItemStr(cBuf, LinkItem, GEN_SOM_CLASSES);
_somtSetSymbolCopyBoth(template, "typedefPasBaseType", cBuf);
_somtOutputSection(template,
TypeItem->DefType == dtTypedef ? "pasTypedefS" : "pasPTypedefS");
_somtOutputSection(template, "pasTypedefEpilogS");
break;
case dtStruct:
_somtOutputSection(template, "pasStructS");
for (j=0; j<TypeItem->LinkItems._length; j++)
{
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), j );
_somtSetSymbolCopyBoth(template, "structFieldName", LinkItem->FieldName);
LinkItemStr(cBuf, LinkItem, GEN_SOM_CLASSES);
_somtSetSymbolCopyBoth(template, "typedefPasBaseType", cBuf);
_somtOutputSection(template, "pasStructMemberS");
}
_somtOutputSection(template, "pasStructEpilogS");
break;
case dtUnion:
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), 0 );
LinkItemStr(cBuf, LinkItem, GEN_SOM_CLASSES);
_somtSetSymbolCopyBoth(template, "switchType", cBuf);
_somtOutputSection(template, "pasUnionS");
for (j=1; j<TypeItem->LinkItems._length; j++)
{
sprintf(cBuf, "%u", (j-1));
_somtSetSymbolCopyBoth(template, "unionMemberLabel", cBuf);
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), j );
_somtSetSymbolCopyBoth(template, "unionMemberName", LinkItem->FieldName);
LinkItemStr(cBuf, LinkItem, GEN_SOM_CLASSES);
_somtSetSymbolCopyBoth(template, "unionMemberType", cBuf);
_somtOutputSection(template, "pasUnionMemberS");
}
_somtOutputSection(template, "pasUnionEpilogS");
break;
case dtSequence:
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), 0 );
sprintf(cBuf, "%u", LinkItem->ArrayLen[0]);
_somtSetSymbolCopyBoth(template, "sequenceMax", cBuf);
LinkItemStr(cBuf, LinkItem, GEN_SOM_CLASSES);
_somtSetSymbolCopyBoth(template, "sequenceType", cBuf);
_somtOutputSection(template, "pasSequenceS");
break;
case dtEnum:
_somtSetSymbolCopyBoth(template, "typedefPasBaseType", "Tlong");
_somtOutputSection(template, "pasTypedefS");
break;
default:
debug("Aukhtung!");
}
}
}
// Вывод структуры ClassData
static void PutupClassData(SOMTClassEntryC *cls, PIDLSEQUENCE TypeItems,
SOMTTemplateOutputC *template)
{
SOMTMethodEntryC *me;
SOMTDataEntryC *de;
string rn, mn;
_somtOutputSection(template, "classDataPrologS");
for (rn=_somtGetFirstReleaseName(cls); rn; rn=_somtGetNextReleaseName(cls))
{
for (de=_somtGetFirstData(cls); de; de=_somtGetNextData(cls))
if ( !strcmp(rn, __get_somtEntryName(de)) ) break;
if ( !de )
{
_somtSetSymbolCopyBoth(template, "dataName", rn);
_somtOutputSection(template, "classDataS");
}
}
for (me=_somtGetFirstMethod(cls); me; me=_somtGetNextMethod(cls))
{
mn = __get_somtEntryName(me);
for (rn=_somtGetFirstReleaseName(cls); rn; rn=_somtGetNextReleaseName(cls))
if ( !strcmp(mn,rn) ) break;
if ( !rn )
{
_somtSetSymbolCopyBoth(template, "dataName", mn);
_somtOutputSection(template, "classDataS");
}
}
_somtOutputSection(template, "classDataEpilogS");
}
static int IsPointerType(SOMTEntryC *td)
{
long P, Dim;
if ( __get_somtElementType(td) != SOMTTypedefBE )
return 0;
P = strlen(__get_somtPtrs(td)) + IsPointerType(__get_somtTypedefType(td));
if ( _somtIsArray(td,&Dim) ) P--;
return P>0 ? 1 : 0;
}
static int IsStructType(SOMTEntryC *td)
{
long Dim;
SOMTTypes somt = __get_somtElementType(td);
if ( somt==SOMTTypedefBE && ( _somtIsArray(td,&Dim) || _somtIsPointer(td) ) )
return 0;
return somt==SOMTSequenceE || somt==SOMTStructE || somt==SOMTUnionE ||
( somt==SOMTTypedefBE && IsStructType(__get_somtTypeObj(td)) );
}
// GetParamClassItem() возвращает флаги для параметра метода:
// PARAM_CLASS - параметр является классом
// PARAM_CLASS_PTR - параметр является указателем на класс
static unsigned long GetParamClassItem(char **pcClassName, SOMTEntryC *et, SOMTCommonEntryC *decl)
{
long Dim;
SOMTTypes somt = __get_somtElementType(et);
unsigned long ptr, flags = 0, upflags;
if ( !decl )
{
decl = et;
if ( somt==SOMTTypedefBE )
et = __get_somtTypedefType(et);
else goto l00;
}
ptr = strlen(__get_somtPtrs(decl));
if ( _somtIsArray(decl,&Dim) || ptr > 1 )
return 0;
if ( ptr )
flags |= PARAM_CLASS_PTR;
l00:
if ( somt==SOMTTypedefBE )
{
upflags = GetParamClassItem(pcClassName, et, NULL);
if ( (upflags & PARAM_CLASS_PTR) && ptr )
return 0;
return flags | upflags;
}
if ( somt == SOMTClassE )
{
*pcClassName = __get_somtEntryName(et);
flags |= PARAM_CLASS;
}
return flags;
}
// Cоздание поля описателя метода
// здесь создаются промежуточные типы для описания параметров методов:
// массивов, указателей.
static PLINKITEM MakeFuncLinkItem(PIDLSEQUENCE TypeItems,
PIDLSEQUENCE LinkItems, SOMTEntryC *et,
SOMTCommonEntryC *decl, char *pcName,
boolean IsResult)
{
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
char cBuf[128];
long CritPD;
LinkItem = MakeTypeLinkItem( TypeItems, LinkItems, et, decl );
// если тип - структура/последовательность/объединение или прямой потомок от
// неё, но не массив или указатель на неё, то аргумент - обязательно указатель,
// но только для "somtInE", т.к. в др. случае аргумент будет объявлен как var.
if ( !IsResult && !LinkItem->PtrDeep &&
__get_somtParameterDirection(decl)==somtInE && IsStructType(et) )
LinkItem->PtrDeep = 1;
CritPD = __get_somtElementType(et) == SOMTTypedefBE ? 0 : 1;
if ( LinkItem->PtrDeep>CritPD || LinkItem->ArrayDim || LinkItem->TypeItem )
{
CritPD = LinkItem->PtrDeep;
if ( LinkItem->ArrayDim ) CritPD--;
sprintf( cBuf, IsResult ? "_IDL_TYPE_RES_%s" : "_IDL_TYPE_%s_%s",
pcName, LinkItem->FieldName );
TypeItem = MakeTypeItem(TypeItems, (CritPD>0 ? dtPTypedef : dtTypedef),
FALSE, cBuf, NULL);
// перетаскиваем LinkItem в создаваемое промежуточное объявление типа
seqDelete(LinkItems, sizeof(PLINKITEM), &LinkItem);
seqInsert((PIDLSEQUENCE)&TypeItem->LinkItems, sizeof(PLINKITEM), &LinkItem);
LinkItem = MakeSimpleLinkItem( TypeItems, LinkItems, NULL );
LinkItem->TypeItem = TypeItem;
LinkItem->PtrDeep = 0;
LinkItem->ArrayDim = 0;
LinkItem->FieldName = strdup( __get_somtEntryName(decl) );
}
return LinkItem;
}
// Установка символов шаблона для описания метода.
static void SetMethodHeaderTemplate(SOMTTemplateOutputC *template,
PIDLSEQUENCE TypeItems, SOMTMethodEntryC *entry)
{
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
boolean IsFunction;
char cBuf[256];
char cHdrParamList[256], *pcHdrParamList;
char cParamList[256], *pcParamList;
char cFullList[256], *pcFullList;
unsigned long ParamId, i;
TypeItem = GetTypeItemByObj(TypeItems, entry);
if ( !TypeItem )
{
debug("Warning! %s() was not found in 'TypeItems' list.",
__get_somtEntryName(entry));
return;
}
IsFunction = TypeItem->DefType == dtFunction;
_somtSetSymbolCopyBoth(template, "pasMethodFunc",
IsFunction ? "function" : "procedure");
if ( IsFunction )
{
*(unsigned short *)&cBuf = ' :';
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), 0 );
LinkItemStr(&cBuf[2], LinkItem, GEN_SOM_CLASSES);
_somtSetSymbolCopyBoth(template, "pasMethodResult", "Result := ");
ParamId = 1;
}
else {
cBuf[0] = '\0';
_somtSetSymbolCopyBoth(template, "pasMethodResult", "");
ParamId = 0;
}
_somtSetSymbolCopyBoth(template, "pasMethodType", cBuf);
strcpy(cFullList,"somSelf\nev");
if ( TypeItem->LinkItems._length == ParamId )
{
cHdrParamList[0] = '\0';
cParamList[0] = '\0';
}
else {
pcHdrParamList = cHdrParamList;
pcParamList = cParamList;
pcFullList = strchr(cFullList, '\0');
for (i=ParamId; i<TypeItem->LinkItems._length; i++)
{
*(pcHdrParamList++) = i == ParamId ? '(' : '\n';
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), i );
pcHdrParamList += sprintf(pcHdrParamList, "%s %s: ",
LinkItem->ArrayLen[0] ? "var" : "const", LinkItem->FieldName);
if ( LinkItem->MethodParamClassFl & PARAM_CLASS )
pcHdrParamList += sprintf(pcHdrParamList, "%c%s",
LinkItem->MethodParamClassFl & PARAM_CLASS_PTR ? 'P' : 'T',
LinkItem->MethodParamClassName);
else {
LinkItemStr(pcHdrParamList, LinkItem, GEN_PASCAL_CLASSES); // здесь 3й параметр ниначто уже не влияет...
pcHdrParamList = strchr( pcHdrParamList, '\0' );
}
if ( i != ParamId ) *(pcParamList++) = '\n';
pcParamList += sprintf(pcParamList, "%s %s: ",
LinkItem->ArrayLen[0] ? "var" : "const", LinkItem->FieldName);
LinkItemStr(pcParamList, LinkItem, GEN_SOM_CLASSES);
pcParamList = strchr( pcParamList, '\0' );
*(pcFullList++) = '\n';
if ( LinkItem->MethodParamClassFl & PARAM_CLASS )
{
if ( LinkItem->MethodParamClassFl & PARAM_CLASS_PTR )
pcFullList += sprintf(pcFullList, "@%s^", LinkItem->FieldName);
else
pcFullList = strchr( strcpy(pcFullList, LinkItem->FieldName), '\0' );
pcFullList = strchr( strcpy(pcFullList, ".classObject"), '\0' );
}
else
pcFullList = strchr( strcpy(pcFullList, LinkItem->FieldName), '\0' );
}
*(unsigned short *)pcHdrParamList = '\0)';
}
_somtSetSymbolCopyBoth(template, "pasMethodHdrParamList", cHdrParamList);
_somtSetSymbolCopyBoth(template, "pasMethodParamList", cParamList);
_somtSetSymbolCopyBoth(template, "pasMethodFullParamNameList", cFullList);
}
/*
* Сбор объявлений типов.
*/
SOM_Scope void SOMLINK somtGetTypedef(PascalEmitter *somSelf,
SOMTTypedefEntryC* td)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
SOMTCommonEntryC *decl;
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
SOMTEntryC *tobj = __get_somtTypeObj(td);
PascalEmitterMethodDebug("PascalEmitter","somtGetTypedef");
for (decl=_somtGetFirstDeclarator(td);decl;decl=_somtGetNextDeclarator(td))
{
TypeItem = MakeTypeItem((PIDLSEQUENCE)&EmitterData->TypeItems,
( !strncmp(__get_somtEntryName(tobj),"void*",5) || IsPointerType(decl) )
? dtPTypedef : dtTypedef,
FALSE, __get_somtEntryName(decl), decl);
debug("collect typedef: %s", TypeItem->Name);
LinkItem = MakeTypeLinkItem( (PIDLSEQUENCE)&EmitterData->TypeItems,
(PIDLSEQUENCE)&TypeItem->LinkItems,
tobj, decl );
}
}
/*
* Сбор объявлений структур.
*/
SOM_Scope void SOMLINK somtGetStruct(PascalEmitter *somSelf,
SOMTStructEntryC* struc)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
PascalEmitterMethodDebug("PascalEmitter","somtGetStruct");
CollectStruct( (PIDLSEQUENCE)&EmitterData->TypeItems, struc );
}
/*
* Сбор объявлений объединений.
*/
SOM_Scope void SOMLINK somtGetUnion(PascalEmitter *somSelf,
SOMTUnionEntryC* un)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
PascalEmitterMethodDebug("PascalEmitter","somtGetUnion");
CollectUnion( (PIDLSEQUENCE)&EmitterData->TypeItems, un );
}
/*
* Сбор параметров функций.
*/
SOM_Scope void SOMLINK somtGetMethodParamTypes(PascalEmitter *somSelf,
SOMTMethodEntryC* me)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
SOMTEntryC *et = __get_somtTypeObj(me);
SOMTParameterEntryC *Param = _somtGetFirstParameter(me);
char *pcMethodName = __get_somtEntryName(me);
PTYPEITEM TypeItem, ScanTypeItem;
PLINKITEM LinkItem, CopyLinkItem;
unsigned long i;
char *pcName = __get_somtEntryName(me);
boolean IsFunc = __get_somtElementType(et) != SOMTVoidBE;
PascalEmitterMethodDebug("PascalEmitter","somtGetMethodParamTypes");
TypeItem = MakeTypeItem((PIDLSEQUENCE)&EmitterData->TypeItems,
IsFunc ? dtFunction : dtProcedure,
FALSE, pcName, me);
// Поиск LinkItem описателя атрибута если обрабатываем метод чтения/записи
// этого атрибута, если находим - делаем дубликат LinkItem и отдаём его.
// Необходимо для исключения генерации большого числа промежуточных типов
// (для ф-ии чтения, процедуры записи и для описателя самого атрибута).
if ( !strncmp(pcName, IsFunc ? "_get_" : "_set_", 5) )
for (i=0; i<((PIDLSEQUENCE)&EmitterData->TypeItems)->length; i++)
{
ScanTypeItem = *(PTYPEITEM *)seqAt( (PIDLSEQUENCE)&EmitterData->TypeItems,
sizeof(PTYPEITEM), i );
if ( ScanTypeItem->DefType == dtAttrib &&
!strcmp(ScanTypeItem->Name,&pcName[5]) )
{
CopyLinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&ScanTypeItem->LinkItems,
sizeof(PLINKITEM), 0 );
LinkItem = MakeSimpleLinkItem( (PIDLSEQUENCE)&EmitterData->TypeItems,
(PIDLSEQUENCE)&TypeItem->LinkItems,
CopyLinkItem->Obj );
LinkItem->FieldName = strdup( CopyLinkItem->FieldName );
LinkItem->PtrDeep = CopyLinkItem->PtrDeep;
LinkItem->ArrayDim = CopyLinkItem->ArrayDim;
memcpy(&LinkItem->ArrayLen, &CopyLinkItem->ArrayLen, 32*sizeof(long));
LinkItem->TypeItem = CopyLinkItem->TypeItem;
return;
}
}
if ( TypeItem->DefType == dtFunction )
MakeFuncLinkItem( (PIDLSEQUENCE)&EmitterData->TypeItems,
(PIDLSEQUENCE)&TypeItem->LinkItems,
__get_somtTypeObj(me), me, pcMethodName, TRUE );
for (; Param; Param=_somtGetNextParameter(me) )
{
//debug("==> %u", GetParamClassItem( &pcName, __get_somtTypeObj(Param), Param ) );
//debug("--> %s", pcName );
LinkItem = MakeFuncLinkItem( (PIDLSEQUENCE)&EmitterData->TypeItems,
(PIDLSEQUENCE)&TypeItem->LinkItems,
__get_somtTypeObj(Param), Param,
pcMethodName, FALSE );
LinkItem->ArrayLen[0] = __get_somtParameterDirection(Param) == somtInE ?
0 : 1;
LinkItem->MethodParamClassFl =
GetParamClassItem( &LinkItem->MethodParamClassName,
__get_somtTypeObj(Param), Param );
}
}
/*
* Сбор атрибутов класса.
*/
SOM_Scope void SOMLINK somtGetAttribute(PascalEmitter *somSelf,
SOMTAttributeEntryC* att)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
SOMTDataEntryC *decl;
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
PascalEmitterMethodDebug("PascalEmitter","somtGetAttribute");
for (decl=_somtGetFirstAttributeDeclarator(att); decl;
decl=_somtGetNextAttributeDeclarator(att))
{
TypeItem = MakeTypeItem((PIDLSEQUENCE)&EmitterData->TypeItems, dtAttrib,
FALSE, __get_somtEntryName(decl), decl);
LinkItem = MakeFuncLinkItem( (PIDLSEQUENCE)&EmitterData->TypeItems,
(PIDLSEQUENCE)&TypeItem->LinkItems,
__get_somtAttribType(att), decl,
TypeItem->Name, TRUE );
LinkItem->ArrayLen[0] = __get_somtIsReadonly(att) ? 1 : 0;
}
}
/*
* Сбор типов констант.
*/
SOM_Scope void SOMLINK somtGetConstant(PascalEmitter *somSelf,
SOMTConstEntryC* con)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
PTYPEITEM TypeItem;
PascalEmitterMethodDebug("PascalEmitter","somtGetConstant");
TypeItem = MakeTypeItem((PIDLSEQUENCE)&EmitterData->TypeItems, dtConst,
FALSE, __get_somtEntryName(con), con);
MakeSimpleLinkItem( (PIDLSEQUENCE)&EmitterData->TypeItems,
(PIDLSEQUENCE)&TypeItem->LinkItems,
__get_somtConstTypeObj(con) );
}
/*
* Сбор перечислений.
*/
SOM_Scope void SOMLINK somtGetEnum(PascalEmitter *somSelf, SOMTEnumEntryC* en)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
SOMTEnumNameEntryC *member;
char cBuf[128];
PascalEmitterMethodDebug("PascalEmitter","somtGetEnum");
TypeItem = MakeTypeItem((PIDLSEQUENCE)&EmitterData->TypeItems, dtEnum,
TRUE, __get_somtEntryName(en), en);
for ( member = _somtGetFirstEnumName(en); member;
member = _somtGetNextEnumName(en) )
{
LinkItem = MakeSimpleLinkItem( (PIDLSEQUENCE)&EmitterData->TypeItems,
(PIDLSEQUENCE)&TypeItem->LinkItems,
NULL );
sprintf(cBuf, "%s_%s", __get_somtEntryName(en), __get_somtEntryName(member));
LinkItem->FieldName = strdup( cBuf );
LinkItem->ArrayLen[0] = __get_somtEnumVal(member);
}
}
/*
* "заглушка".
*/
SOM_Scope void SOMLINK somtEmitNULLFn(PascalEmitter *somSelf,
SOMTEntryC* td)
{
}
/*
* Реализация методов класса (секция паскаля 'implementation')
*/
SOM_Scope void SOMLINK somtEmitMethodImplementationProlog(PascalEmitter *somSelf)
{
_somtOutputSection( __get_somtTemplate(somSelf),
"pasImplementationPrologS" );
}
/*
* Реализация метода класса
*/
SOM_Scope void SOMLINK somtEmitMethodImplementation(PascalEmitter *somSelf,
SOMTMethodEntryC* entry)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
SOMTTemplateOutputC *template = __get_somtTemplate(somSelf);
PascalEmitterMethodDebug("PascalEmitter","somtEmitMethodImplementation");
SetMethodHeaderTemplate(template,
(PIDLSEQUENCE)&EmitterData->TypeItems, entry);
_somtOutputSection(template, "pasMethodImplementationS");
}
/*
* Управление последовательностью секций
*/
SOM_Scope boolean SOMLINK somtGenerateSections(PascalEmitter *somSelf)
{
SOMTClassEntryC *cls = __get_somtTargetClass(somSelf);
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
PascalEmitterMethodDebug("PascalEmitter","somtGenerateSections");
seqInit( (PIDLSEQUENCE)&EmitterData->TypeItems, 0,
sizeof(PTYPEITEM) );
EmitterData->buf = malloc(65535);
EmitterData->CurrentPasSection = 0;
_somtFileSymbols(somSelf);
_somtEmitProlog(somSelf);
if ( cls )
{
_somtScanBases(somSelf, "somtEmitBaseIncludesProlog",
"somtEmitBaseIncludes", "somtEmitBaseIncludesEpilog");
}
// формируем список "носителей типов" (typedef/struct/union/sequence/etc...)
_somtScanTypedefs(somSelf, "somtEmitNULLFn", "somtGetTypedef", "somtEmitNULLFn");
_somtScanStructs(somSelf, "somtEmitNULLFn", "somtGetStruct", "somtEmitNULLFn");
_somtScanUnions(somSelf, "somtEmitNULLFn", "somtGetUnion", "somtEmitNULLFn");
// сбор атрибутов
if ( cls ) {
debug("-- сбор атрибутов");
_somtScanAttributes(somSelf, "somtEmitNULLFn",
"somtGetAttribute", "somtEmitNULLFn");
}
if ( cls ) {
// добавляем класс как "носитель типа", понадобится если на него есть ссылки
// MakeTypeItem((PIDLSEQUENCE)&EmitterData->TypeItems, dtClass, FALSE,
// __get_somtEntryName(cls), cls);
// сбор методов
debug("-- сбор методов");
_somtScanMethods(somSelf,
"somtImplemented", "somtEmitNULLFn",
"somtGetMethodParamTypes", "somtEmitNULLFn", 0);
}
// сбор констант
debug("-- сбор констант");
_somtScanConstants(somSelf, "somtEmitNULLFn", "somtGetConstant",
"somtEmitNULLFn");
// сбор перечислений
debug("-- сбор перечислений");
_somtScanEnums(somSelf, "somtEmitNULLFn",
"somtGetEnum", "somtEmitNULLFn");
// настройка связей "носителей типов" (формирование графа)
debug("-- настройка связей \"носителей типов\" (формирование графа)");
BindTypes( (PIDLSEQUENCE)&EmitterData->TypeItems );
// сортировка "носителей типов"
debug("-- сортировка \"носителей типов\"");
SortTypes( (PIDLSEQUENCE)&EmitterData->TypeItems );
// вывод результата ( секция паскаля "type" )
debug("-- вывод результата ( секция паскаля \"type\" )");
PutupTypedefs( (PIDLSEQUENCE)&EmitterData->TypeItems,
&EmitterData->CurrentPasSection,
__get_somtTemplate(somSelf) );
if ( cls )
{
// вывод структуры ClassData
debug("-- вывод структуры ClassData");
PutupClassData( cls, (PIDLSEQUENCE)&EmitterData->TypeItems,
__get_somtTemplate(somSelf) );
// вывод класса
debug("-- вывод класса");
_somtEmitClass(somSelf);
_somtScanMethods(somSelf,
"somtImplemented", "somtEmitMethodsProlog",
"somtEmitMethod", "somtEmitMethodsEpilog", 0);
_somtScanAttributes(somSelf, "somtEmitAttributeProlog",
"somtEmitAttribute", "somtEmitAttributeEpilog");
EmitterData->CurrentPasSection = dtConst;
}
// вывод констант
debug("-- вывод констант");
_somtScanConstants(somSelf, "somtEmitNULLFn", "somtEmitConstant",
"somtEmitNULLFn");
// вывод значений перечислений
debug("-- вывод значений перечислений");
_somtScanEnums(somSelf, "somtEmitNULLFn", "somtEmitEnum", "somtEmitNULLFn");
if ( cls )
{
// реализация методов класса
debug("-- реализация методов класса");
_somtScanMethods(somSelf,
"somtImplemented", "somtEmitMethodImplementationProlog",
"somtEmitMethodImplementation", "somtEmitMethodsEpilog",
0);
debug("-- somtScanBases()");
_somtScanBases(somSelf, "somtEmitBaseProlog", "somtEmitBase",
"somtEmitBaseEpilog");
}
debug("-- somtEmitEpilog()");
_somtEmitEpilog(somSelf);
debug("done...");
free(EmitterData->buf);
seqDone((PIDLSEQUENCE)&EmitterData->TypeItems, sizeof(PTYPEITEM),
destroyTypeItem);
return TRUE;
}
/*
* Эмитер метода.
*/
SOM_Scope void SOMLINK somtEmitMethod(PascalEmitter *somSelf,
SOMTMethodEntryC* entry)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
PascalEmitterMethodDebug("PascalEmitter","somtEmitMethod");
SetMethodHeaderTemplate( __get_somtTemplate(somSelf),
(PIDLSEQUENCE)&EmitterData->TypeItems, entry );
PascalEmitter_parent_SOMTEmitC_somtEmitMethod(somSelf, entry);
}
/*
* Эмитер атрибута.
*/
SOM_Scope void SOMLINK somtEmitAttribute(PascalEmitter *somSelf,
SOMTAttributeEntryC* att)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
SOMTTemplateOutputC *template = __get_somtTemplate(somSelf);
SOMTDataEntryC *decl;
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
char cBuf[128];
PascalEmitterMethodDebug("PascalEmitter","somtEmitAttribute");
for (decl=_somtGetFirstAttributeDeclarator(att); decl;
decl=_somtGetNextAttributeDeclarator(att))
{
TypeItem = GetTypeItemByObj((PIDLSEQUENCE)&EmitterData->TypeItems, decl);
if ( !TypeItem )
{
debug("Warning! attribute '%s' was not found in 'TypeItems' list.",
__get_somtEntryName(decl));
continue;
}
_somtSetSymbolCopyBoth(template, "attributeComment", TypeItem->Comment);
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), 0 );
_somtSetSymbolCopyBoth(template, "pasAttributeName", LinkItem->FieldName);
LinkItemStr(cBuf, LinkItem, GEN_PASCAL_CLASSES);
_somtSetSymbolCopyBoth(template, "pasAttributeType", cBuf);
_somtOutputSection(template, LinkItem->ArrayLen[0] ?
"pasAttributeROS" : "pasAttributeRWS");
}
}
/*
* Эмитер интерфейса
*/
SOM_Scope void SOMLINK somtEmitInterface(PascalEmitter *somSelf,
SOMTClassEntryC* intfc)
{
/* PascalEmitterData *somThis = PascalEmitterGetData(somSelf); */
PascalEmitterMethodDebug("PascalEmitter","somtEmitInterface");
PascalEmitter_parent_SOMTEmitC_somtEmitInterface(somSelf,
intfc);
}
/*
* Эмитер определения констант.
*/
SOM_Scope void SOMLINK somtEmitConstant(PascalEmitter *somSelf,
SOMTConstEntryC* con)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
SOMTTemplateOutputC *template = __get_somtTemplate(somSelf);
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
char cBuf[128];
PascalEmitterMethodDebug("PascalEmitter","somtEmitConstant");
if ( EmitterData->CurrentPasSection != dtConst )
{
_somtOutputSection(template, "pasConstantsPrologS");
EmitterData->CurrentPasSection = dtConst;
}
TypeItem = GetTypeItemByObj((PIDLSEQUENCE)&EmitterData->TypeItems, con);
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), 0 );
passtrIDLConst( EmitterData->buf, __get_somtConstVal(con) );
_somtSetSymbolCopyBoth(template, "pasConstantValueEvaluated",
EmitterData->buf);
_somtSetSymbolCopyBoth(template, "pasConstType",
LinkItemStr(cBuf, LinkItem, GEN_SOM_CLASSES));
PascalEmitter_parent_SOMTEmitC_somtEmitConstant(somSelf,
con);
}
/*
* Эмитер определения перечислений.
*/
/*
* Эмитер определения значений перечислений.
*/
SOM_Scope void SOMLINK somtEmitEnum(PascalEmitter *somSelf,
SOMTEnumEntryC* en)
{
PascalEmitterData *EmitterData = PascalEmitterGetData(somSelf);
SOMTTemplateOutputC *template = __get_somtTemplate(somSelf);
PTYPEITEM TypeItem;
PLINKITEM LinkItem;
unsigned long i;
char cBuf[128];
PascalEmitterMethodDebug("PascalEmitter","somtEmitEnum");
if ( EmitterData->CurrentPasSection != dtConst )
{
_somtOutputSection(template, "pasConstantsPrologS");
EmitterData->CurrentPasSection = dtConst;
}
TypeItem = GetTypeItemByObj((PIDLSEQUENCE)&EmitterData->TypeItems, en);
for (i=0; i<TypeItem->LinkItems._length; i++)
{
_somtSetSymbolCopyBoth(template, "constantComment",
i ? NULL : TypeItem->Comment );
LinkItem = *(PLINKITEM *)seqAt( (PIDLSEQUENCE)&TypeItem->LinkItems,
sizeof(PLINKITEM), i );
_somtSetSymbolCopyBoth(template, "constantName", LinkItem->FieldName);
sprintf(cBuf, "%u", LinkItem->ArrayLen[0]);
_somtSetSymbolCopyBoth(template, "pasConstantValueEvaluated", cBuf);
_somtSetSymbolCopyBoth(template, "pasConstType", cBuf);
_somtOutputSection(template, "constantS");
}
}
/*
* Эмитер класса
*/
SOM_Scope void SOMLINK somtEmitClass(PascalEmitter *somSelf)
{
SOMTTemplateOutputC *template;
char cBuf[9];
SOMTClassEntryC *cls = __get_somtTargetClass(somSelf);
SOMTClassEntryC *bc;
PascalEmitterMethodDebug("PascalEmitter","somtEmitClass");
template = __get_somtTemplate(somSelf);
sprintf(cBuf, "%d", __get_somtBaseCount(cls));
_somtSetSymbolCopyBoth(template, "baseCount", cBuf);
bc = _somtGetFirstBaseClass(cls);
_somtSetSymbolCopyBoth(template, "directBase",
bc ? __get_somtEntryName(bc) : "SOMMI");
PascalEmitter_parent_SOMTEmitC_somtEmitClass(somSelf);
}
|
1bff1a962431fd5caeae5e6ff47bb33c09a41738
|
2b3a800fa524e0feee9098c5e29b8142545497bb
|
/parse/export.c
|
fb7b05fcc9ca672647d5224e9df857a9b6368878
|
[
"MIT"
] |
permissive
|
oridb/mc
|
775ce818dc74701752a6c9f5ae6afb5d84cf27d2
|
74d91a0021de012908cfdb35fb61a1473a376130
|
refs/heads/master
| 2023-08-27T05:43:30.279203
| 2022-05-23T01:02:07
| 2022-05-23T01:02:07
| 16,144,976
| 409
| 46
|
MIT
| 2020-05-06T03:33:42
| 2014-01-22T16:33:30
|
C
|
UTF-8
|
C
| false
| false
| 7,556
|
c
|
export.c
|
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>
#include <inttypes.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include "util.h"
#include "parse.h"
static void tagnode(Stab *st, Node *n, int ingeneric, int hidelocal);
static void tagtype(Stab *st, Type *t, int ingeneric, int hidelocal);
void
tagreflect(Type *t)
{
size_t i;
if (hasparams(t) || t->isreflect)
return;
t->isreflect = 1;
for (i = 0; i < t->nsub; i++)
tagreflect(t->sub[i]);
switch (t->type) {
case Tystruct:
for (i = 0; i < t->nmemb; i++)
tagreflect(decltype(t->sdecls[i]));
break;
case Tyunion:
for (i = 0; i < t->nmemb; i++)
if (t->udecls[i]->etype)
tagreflect(t->udecls[i]->etype);
break;
case Tyname:
for (i = 0; i < t->narg; i++)
tagreflect(t->arg[i]);
default:
break;
}
}
static void
tagtrait(Stab *st, Trait *tr, int ingeneric, int hidelocal)
{
size_t i;
if (!tr)
return;
if (tr->vis != Visintern)
return;
tr->vis = Vishidden;
if (tr->param)
tagtype(st, tr->param, ingeneric, hidelocal);
for (i = 0; i < tr->naux; i++)
tagtype(st, tr->aux[i], ingeneric, hidelocal);
for (i = 0; i < tr->nproto; i++)
tagnode(st, tr->proto[i], ingeneric, hidelocal);
}
static void
tagtype(Stab *st, Type *t, int ingeneric, int hidelocal)
{
size_t i;
if (!t || t->tagged)
return;
t->tagged = 1;
t->vis = (t->vis == Visintern) ? Vishidden : t->vis;
tagtype(st, t->seqaux, ingeneric, hidelocal);
for (i = 0; i < t->nsub; i++)
tagtype(st, t->sub[i], ingeneric, hidelocal);
for (i = 0; i < t->nspec; i++) {
tagtype(st, t->spec[i]->param, ingeneric, hidelocal);
tagtype(st, t->spec[i]->aux, ingeneric, hidelocal);
}
switch (t->type) {
case Tystruct:
for (i = 0; i < t->nmemb; i++)
tagtype(st, decltype(t->sdecls[i]), ingeneric, hidelocal);
break;
case Tyunion:
for (i = 0; i < t->nmemb; i++)
if (t->udecls[i]->etype)
tagtype(st, t->udecls[i]->etype, ingeneric, hidelocal);
break;
case Tyname:
case Tygeneric:
tagreflect(t);
for (i = 0; i < t->narg; i++)
tagtype(st, t->arg[i], ingeneric, hidelocal);
for (i = 0; i < t->ngparam; i++)
tagtype(st, t->gparam[i], ingeneric, hidelocal);
for (i = 0; i < t->narg; i++)
tagtype(st, t->arg[i], ingeneric, hidelocal);
break;
case Typaram:
if (t->trneed)
for (i = 0; bsiter(t->trneed, &i); i++)
tagtrait(st, traittab[i], ingeneric, hidelocal);
break;
default:
break;
}
}
int
isexportval(Node *n)
{
if (n->decl.isgeneric && !n->decl.trait)
return 1;
/* we want to inline small values, which means we need to export them */
if (istyprimitive(n->decl.type))
return 1;
return 0;
}
static void
tagnode(Stab *st, Node *n, int ingeneric, int hidelocal)
{
size_t i;
Node *d;
if (!n)
return;
switch (n->type) {
case Nblock:
for (i = 0; i < n->block.nstmts; i++)
tagnode(st, n->block.stmts[i], ingeneric, hidelocal);
break;
case Nifstmt:
tagnode(st, n->ifstmt.cond, ingeneric, hidelocal);
tagnode(st, n->ifstmt.iftrue, ingeneric, hidelocal);
tagnode(st, n->ifstmt.iffalse, ingeneric, hidelocal);
break;
case Nloopstmt:
tagnode(st, n->loopstmt.init, ingeneric, hidelocal);
tagnode(st, n->loopstmt.cond, ingeneric, hidelocal);
tagnode(st, n->loopstmt.step, ingeneric, hidelocal);
tagnode(st, n->loopstmt.body, ingeneric, hidelocal);
break;
case Niterstmt:
tagnode(st, n->iterstmt.elt, ingeneric, hidelocal);
tagnode(st, n->iterstmt.seq, ingeneric, hidelocal);
tagnode(st, n->iterstmt.body, ingeneric, hidelocal);
break;
case Nmatchstmt:
tagnode(st, n->matchstmt.val, ingeneric, hidelocal);
for (i = 0; i < n->matchstmt.nmatches; i++)
tagnode(st, n->matchstmt.matches[i], ingeneric, hidelocal);
break;
case Nmatch:
tagnode(st, n->match.pat, ingeneric, hidelocal);
tagnode(st, n->match.block, ingeneric, hidelocal);
break;
case Nexpr:
tagnode(st, n->expr.idx, ingeneric, hidelocal);
tagtype(st, n->expr.type, ingeneric, hidelocal);
if (n->expr.param)
tagtype(st, n->expr.param, ingeneric, hidelocal);
for (i = 0; i < n->expr.nargs; i++)
tagnode(st, n->expr.args[i], ingeneric, hidelocal);
/* generics need to have the decls they refer to exported. */
if (ingeneric && exprop(n) == Ovar) {
d = decls[n->expr.did];
if (d->decl.isglobl && d->decl.vis == Visintern) {
d->decl.vis = Vishidden;
tagnode(st, d, ingeneric, hidelocal);
}
}
break;
case Nlit:
tagtype(st, n->lit.type, ingeneric, hidelocal);
if (n->lit.littype == Lfunc)
tagnode(st, n->lit.fnval, ingeneric, hidelocal);
break;
case Ndecl:
tagtype(st, n->decl.type, ingeneric, hidelocal);
if (hidelocal && n->decl.ispkglocal)
n->decl.vis = Vishidden;
n->decl.isexportval = isexportval(n);
if (n->decl.isexportval || ingeneric)
tagnode(st, n->decl.init, n->decl.isgeneric, hidelocal);
break;
case Nfunc:
tagtype(st, n->func.type, ingeneric, hidelocal);
for (i = 0; i < n->func.nargs; i++)
tagnode(st, n->func.args[i], ingeneric, hidelocal);
tagnode(st, n->func.body, ingeneric, hidelocal);
break;
case Nimpl:
tagtype(st, n->impl.type, ingeneric, hidelocal);
for (i = 0; i < n->impl.naux; i++)
tagtype(st, n->impl.aux[i], ingeneric, hidelocal);
for (i = 0; i < n->impl.ndecls; i++) {
n->impl.decls[i]->decl.vis = Vishidden;
tagnode(st, n->impl.decls[i], 0, hidelocal);
}
break;
case Nuse:
case Nname:
break;
case Nnone:
die("Invalid node for type export\n");
break;
}
}
void
tagexports(int hidelocal)
{
size_t i, j, n;
Trait *tr;
Stab *st;
void **k;
Node *s;
Type *t;
st = file.globls;
/* tag the initializers */
for (i = 0; i < file.ninit; i++)
tagnode(st, file.init[i], 0, hidelocal);
for (i = 0; i < file.nfini; i++)
tagnode(st, file.fini[i], 0, hidelocal);
if (file.localinit)
tagnode(st, file.localinit, 0, hidelocal);
if (file.localfini)
tagnode(st, file.localfini, 0, hidelocal);
/* tag the exported nodes */
k = htkeys(st->dcl, &n);
for (i = 0; i < n; i++) {
s = getdcl(st, k[i]);
if (s->decl.vis == Visexport)
tagnode(st, s, 0, hidelocal);
}
free(k);
/* get the explicitly exported types */
k = htkeys(st->ty, &n);
for (i = 0; i < n; i++) {
t = gettype(st, k[i]);
if (!t->isreflect && t->vis != Visexport)
continue;
if (hidelocal && t->ispkglocal)
t->vis = Vishidden;
tagtype(st, t, 0, hidelocal);
for (j = 0; j < t->nsub; j++)
tagtype(st, t->sub[j], 0, hidelocal);
if (t->type == Tyname) {
tagreflect(t);
for (j = 0; j < t->narg; j++)
tagtype(st, t->arg[j], 0, hidelocal);
} else if (t->type == Tygeneric) {
for (j = 0; j < t->ngparam; j++)
tagtype(st, t->gparam[j], 0, hidelocal);
}
}
free(k);
/* tag the traits */
for (i = 0; i < ntraittab; i++) {
tr = traittab[i];
if (tr->vis != Visexport)
continue;
if (hidelocal && tr->ishidden)
tr->vis = Vishidden;
tagtype(st, tr->param, 0, hidelocal);
tr->param->vis = tr->vis;
for (j = 0; j < tr->naux; j++) {
tagtype(st, tr->aux[j], 0, hidelocal);
tr->aux[j]->vis = tr->vis;
}
for (j = 0; j < tr->nproto; j++) {
tr->proto[j]->decl.vis = tr->vis;
tagnode(st, tr->proto[j], 0, hidelocal);
}
}
/* tag the impls */
for (i = 0; i < nimpltab; i++) {
s = impltab[i];
if (s->impl.vis != Visexport)
continue;
tagnode(st, s, 0, hidelocal);
tr = s->impl.trait;
tagtrait(st, tr, 0, hidelocal);
for (j = 0; j < tr->naux; j++)
tr->aux[j]->vis = tr->vis;
}
}
|
b0588e3a2280b950c69b7cbb9c54adfa2a590d94
|
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
|
/PWGGA/PHOSTasks/PHOS_PbPb/macros/Flow/Method2.C
|
20ba0c41d2c37f4be2f944e1d65045e5bddc4590
|
[] |
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
| 26,701
|
c
|
Method2.C
|
//AA analysis - V2 calculation with Kentaro Miki method
//27 march 2011. First attempt
//28 march 2011. DP's fixes
#include "Methods.h"
Int_t effcor = 1;
Int_t drawopt=0;
Bool_t reject=kTRUE;
Double_t mean=0.137;
Double_t width=2*0.007;
//======================================================
Double_t fbg2(Double_t *x, Double_t *par)
{ //pol 4 - to fit v2 bg
if (reject && x[0] > mean-width && x[0] < mean+width) {
TF1::RejectPoint();
}
return par[0] + par[1]*(x[0] - mean) + par[2]*(x[0] - mean)*(x[0] - mean) + par[3]*(x[0] - mean)*(x[0] - mean)*(x[0] - mean) + par[4]*(x[0] - mean)*(x[0] - mean)*(x[0] - mean)*(x[0] - mean);
}
//======================================================
Double_t fbg(Double_t *x, Double_t *par)
{ //pol 3 - to fit v2 bg
if (reject && x[0] > mean-width && x[0] < mean+width) {
TF1::RejectPoint();
}
return par[0] + par[1]*(x[0] - mean) + par[2]*(x[0] - mean)*(x[0] - mean) + par[3]*(x[0] - mean)*(x[0] - mean)*(x[0] - mean);
}
//======================================================
Double_t fitMgg1(Double_t *x, Double_t *par){
// gauss + pol 1
Double_t fitval = par[0]*TMath::Exp(-(x[0]-par[1])*(x[0]-par[1])/2./par[2]/par[2])+par[3]+par[4]*(x[0]-mean);
return fitval;
}
//======================================================
Double_t fitBg1(Double_t *x, Double_t *par)
{ // pol 1
Double_t fitval = par[0]+par[1]*(x[0]-mean);
return fitval;
}
//======================================================
Double_t fitMgg2(Double_t *x, Double_t *par)
{ //gauss + pol 2
Double_t fitval = par[0]*TMath::Exp(-(x[0]-par[1])*(x[0]-par[1])/2./par[2]/par[2])+par[3]+par[4]*(x[0]-mean)+par[5]*(x[0]-mean)*(x[0]-mean);
return fitval;
}
//======================================================
Double_t fitBg2(Double_t *x, Double_t *par)
{
Double_t fitval = par[0]+par[1]*(x[0]-mean)+par[2]*(x[0]-mean)*(x[0]-mean);
return fitval;
}
//======================================================
Double_t fitV2p1(Double_t *x, Double_t *par){
// gauss + pol 2
// Double_t fitval = par[0]*TMath::Exp(-(x[0]-par[1])*(x[0]-par[1])/2./par[2]/par[2])+
// par[3]+par[4]*(x[0]-mean)+par[5]*(x[0]-mean)*(x[0]-mean);
Double_t fitval = par[0]*TMath::Exp(-(x[0]-mean)*(x[0]-mean)/2./width/width)+
par[3]+par[4]*(x[0]-mean)+par[5]*(x[0]-mean)*(x[0]-mean);
return fitval;
}
//======================================================
Double_t fitV2p2(Double_t *x, Double_t *par){
// gauss + pol 3
// Double_t fitval = par[0]*TMath::Exp(-(x[0]-par[1])*(x[0]-par[1])/2./par[2]/par[2])+
// par[3]+par[4]*(x[0]-mean)+par[5]*(x[0]-mean)*(x[0]-mean)+par[6]*(x[0]-mean)*(x[0]-mean)*(x[0]-mean);
Double_t fitval = par[0]*TMath::Exp(-(x[0]-mean)*(x[0]-mean)/2./width/width)+
par[3]+par[4]*(x[0]-mean)+par[5]*(x[0]-mean)*(x[0]-mean)+par[6]*(x[0]-mean)*(x[0]-mean)*(x[0]-mean);
return fitval;
}
//======================================================
Double_t fitV2mix(Double_t *x, Double_t *par){
// gauss + pol1*mixed
TH1D * hm = (TH1D*)gROOT->FindObjectAny("v2m") ;
Double_t mix = hm->GetBinContent(hm->GetXaxis()->FindBin(x[0])) ;
Double_t fitval = par[0]*TMath::Exp(-(x[0]-par[1])*(x[0]-par[1])/2./par[2]/par[2])+
(par[3]+par[4]*(x[0]-par[1]))*mix;
return fitval;
}
//======================================================
Double_t fitGauss(Double_t *x, Double_t *par)
{
Double_t fitval = par[0]*TMath::Exp(-(x[0]-par[1])*(x[0]-par[1])/2./par[2]/par[2]);
return fitval;
}
//======================================================
void CalcV2(TH1D * h, Double_t &v2, Double_t &v2err){
v2=0.;
v2err=0;
Double_t N=0 ;
Double_t C=0 ;
TAxis * x=h->GetXaxis() ;
for(Int_t i=1;i<=h->GetNbinsX();i++){
Double_t phi=x->GetBinCenter(i) ;
Double_t cj=TMath::Cos(2.*phi) ;
N+=h->GetBinContent(i) ;
C+=cj*h->GetBinContent(i) ;
}
if(N>0.)
v2=C/N ;
else
return ;
for(Int_t i=1;i<=h->GetNbinsX();i++){
Double_t phi=x->GetBinCenter(i) ;
Double_t cj=TMath::Cos(2.*phi) ;
v2err+=(N*cj-C)*(N*cj-C)*h->GetBinContent(i)/N/N/N/N ;
}
if(v2err<0)v2err=0 ;
v2err=TMath::Sqrt(v2err) ;
}
//======================================================
void ScaleMixed(TH1D * v2,TH1D * v2m,TH1D * v2mScaled){
//Scale v2m to reproduce v2 around the pi0 peak
//left side
Double_t leftMin=0.04 ;
Double_t leftMax=0.1 ;
Int_t iMinLeft=v2->GetXaxis()->FindBin(leftMin+0.00001) ;
Int_t iMaxLeft=v2->GetXaxis()->FindBin(leftMax-0.00001) ;
//right side
Double_t rightMin=0.16;
Double_t rightMax=0.4 ;
Int_t iMinRight=v2->GetXaxis()->FindBin(rightMin+0.00001) ;
Int_t iMaxRight=v2->GetXaxis()->FindBin(rightMax-0.00001) ;
Double_t a=0.,b=0.,c=0.,d=0.,e=0. ;
for(Int_t i=iMinLeft; i<=iMaxLeft;i++){
Double_t rY=v2->GetBinContent(i) ;
Double_t eY=v2->GetBinError(i) ;
Double_t mY=v2m->GetBinContent(i) ;
if(eY==0.)continue ;
a+=rY/eY/eY ;
b+=1./eY/eY ;
c+=mY/eY/eY ;
d+=mY*rY/eY/eY ;
e+=mY*mY/eY/eY ;
}
for(Int_t i=iMinRight; i<=iMaxRight;i++){
Double_t rY=v2->GetBinContent(i) ;
Double_t eY=v2->GetBinError(i) ;
Double_t mY=v2m->GetBinContent(i) ;
if(eY==0.)continue ;
a+=rY/eY/eY ;
b+=1./eY/eY ;
c+=mY/eY/eY ;
d+=mY*rY/eY/eY ;
e+=mY*mY/eY/eY ;
}
Double_t aSlope = 1.;//(a*c-d*b)/(c*c-e*b) ;
// Double_t aSlope = (a*c-d*b)/(c*c-e*b) ;
Double_t aConst = (a - aSlope*c)/b ;
for(Int_t i=1; i<=v2mScaled->GetNbinsX();i++){
// v2mScaled->SetBinContent(i+1,aConst+aSlope*v2m->GetBinContent(i)) ;
// v2mScaled->SetBinError(i+1,aSlope*v2m->GetBinError(i)) ;
v2mScaled->SetBinContent(i,aConst+aSlope*v2m->GetBinContent(i)) ;
v2mScaled->SetBinError(i,aSlope*v2m->GetBinError(i)) ;
}
}
//================================================//MAIN
void Method2(Int_t cen=1,Int_t side=1){
//side = 1 - VOC, side = 0 - V0A
//side = 2 - TPC 3 sub method, 3 - TPC 2 sub method
gStyle->SetFillStyle(1) ;
gStyle->SetOptFit(0);
gStyle->SetOptStat(0);
// gStyle->SetOptTitle(0);
// TH2F* hCenTrack = (TH2F*)f->Get("hCenPHOS") ;
char PID[25] ;
sprintf(PID,"Both2core") ;
char key[55];
char kind[15],kind2[15] ; //Reaction plain
char d[15] ; //detector
sprintf(kind,"") ; //"" for real
sprintf(kind2,"") ; //"" for mixed
char w[15]; //weight
sprintf(w,""); //NW
if(side==1)sprintf(d,"V0C");
else if(side==0)sprintf(d,"V0A");
else sprintf(d,"TPC");
TH3F *h3DR, *h3DM;
h3DR = GetRealMixed(cen,w,d,kind,kind2,PID,1);
h3DM = GetRealMixed(cen,w,d,kind,kind2,PID,0);
TH1F * hCen = GetCen() ;
TH2F * hCenPHOS = GetCenPHOS() ;
if(cen==21)
sprintf(inname,"../flow11h_Apr14.root");
TFile * f = new TFile(inname) ;
//Read resolution
TH2F * hcos2AC = (TH2F*)f->Get("cos2V0AC");
TH2F * hcos2FAC= (TH2F*)f->Get("cos2FAC");
Double_t resAC = GetCos(hcos2AC,cen);
resAC=resAC ;
hcos2AC = (TH2F*)f->Get("cos2V0ATPC");
Double_t resAT = GetCos(hcos2AC,cen);
resAT=resAT ;
hcos2AC = (TH2F*)f->Get("cos2V0CTPC");
Double_t resCT = GetCos(hcos2AC,cen);
resCT=resCT ;
hcos2AC = (TH2F*)f->Get("cos2AC");
Double_t resT = GetRes(hcos2AC,cen);
resT=resT ;
Double_t res=1;
if(side==1) res = TMath::Sqrt(resAC*resCT/resAT);
else if(side==0)res = TMath::Sqrt(resAC*resAT/resCT);
else if(side==2)res = TMath::Sqrt(resAT*resCT/resAC);
else res = resT;
cout<<"res = "<<res <<endl;
//--------------------------------------------------------------------
//invariant mass rebin
Int_t nRebin=2 ;
sprintf(key,"v2Pi_mixed%d",cen) ;
TH1D * v2Pi_mix = new TH1D(key,"V2 pi0 using mixed",nbin,xa) ;
sprintf(key,"v2Pi_pol1%d",cen) ;
TH1D * v2Pi_pol1 = new TH1D(key,"V2 pi0 using pol1",nbin,xa) ;
sprintf(key,"v2Pi_pol2%d",cen) ;
TH1D * v2Pi_pol2 = new TH1D(key,"V2 pi0 using pol2",nbin,xa) ;
sprintf(key,"nSig%d",cen) ;
TH1D * nSig = new TH1D(key,"n Pi0",nbin,xa) ;
sprintf(key,"nSig2%d",cen) ;
TH1D * nSig2 = new TH1D(key,"n Pi0",nbin,xa) ;
sprintf(key,"v2sys_m2_%s_%s_%d_%d",w,PID,cen,side) ;
TH1D * v2Asys = new TH1D(key,"V2 sys method2",nbin,xa) ;
sprintf(key,"v2stat_m2_%s_%s_%d_%d",w,PID,cen,side) ;
TH1D * v2Astat = new TH1D(key,"V2 stat method2",nbin,xa) ;
TCanvas * cf = new TCanvas("cf","yield vs phi",10,10,400,400) ;
cf->SetFillColor(0) ;
cf->SetFillStyle(0) ;
cf->Range(0,0,1,1);
cf->SetBorderSize(0);
TCanvas * cinv = new TCanvas("cinv","inv mass",10,10,400,400) ;
TCanvas * c4= new TCanvas("c4","v2 vs minv",10,10,800,800);
c4->SetFillColor(0) ;
c4->SetFillStyle(0) ;
c4->Range(0,0,1,1);
c4->SetBorderSize(0);
c4->Divide(3,2) ;
TCanvas * c3= new TCanvas("c3","v2 vs minv",10,10,800,800);
c3->SetFillColor(0) ;
c3->SetFillStyle(0) ;
c3->Range(0,0,1,1);
c3->SetBorderSize(0);
c3->Divide(3,2) ;
//========================================================== minv
TF1 *fitMgg1 = new TF1("fitMgg1",fitMgg1,0.,0.4,5);
fitMgg1->SetLineWidth(2) ;
fitMgg1->SetLineColor(2) ;
TF1 *fitMgg2 = new TF1("fitMgg2",fitMgg2,0.,0.4,6);
fitMgg2->SetLineWidth(2) ;
fitMgg2->SetLineColor(4) ;
fitMgg2->SetLineStyle(7) ;
TF1 *fitGauss = new TF1("fitGauss",fitGauss,0.,0.4,3);
fitGauss->SetLineWidth(2) ;
fitGauss->SetLineColor(2) ;
TF1 *fitV2p1 = new TF1("fitV2p1",fitV2p1,0.,0.4,6);
fitV2p1->SetLineWidth(2) ;
fitV2p1->SetLineColor(3) ;
TF1 *fitV2p2 = new TF1("fitV2p2",fitV2p2,0.,0.4,7);
fitV2p2->SetLineWidth(2) ;
fitV2p2->SetLineColor(6) ;
fitV2p2->SetLineStyle(7) ;
TF1 *fitV2mix = new TF1("fitV2mix",fitV2mix,0.,0.4,5);
fitV2mix->SetLineWidth(2) ;
fitV2mix->SetLineColor(kRed) ;
fitV2mix->SetLineStyle(1) ;
TF1 *fitBg1 = new TF1("fitBg1",fitBg1,0.,0.4,2);
TF1 *fitBg2 = new TF1("fitBg2",fitBg2,0.,0.4,3);
TF1 * fit= new TF1("fit","[0]*(1+2*[1]*cos(2.*(x)))",0.,10.) ;
TF1 * fitv4= new TF1("fitv4","[0]*(1+2*[1]*cos(2.*(x))+2*[2]*cos(4.*(x)))",0.,10.) ;
TF1 *f1=new TF1("f1",fbg,0.0,0.4,4);
f1->SetLineColor(2) ;
TF1 *f2=new TF1("f2",fbg2,0.0,0.4,5);
f2->SetLineColor(4) ;
f2->SetLineStyle(4) ;
TF1 * unit = new TF1("unit","1.",0.,10.) ;
TF1 * fconst = new TF1("fconst","[0]",0.,1.) ;
//============================
char name[255] ;
TAxis * axis = v2Pi_mix->GetXaxis() ;
for(Int_t ii=1;ii<=nbin;ii++){ //over pT bins
if(ii<7)
c3->cd(ii) ;
else
c4->cd(ii-6) ;
if(ii>4)
nRebin=2 ;
cinv->cd() ;
Double_t ptmin=axis->GetBinLowEdge(ii);
Double_t ptmax=axis->GetBinUpEdge(ii);
h3DR->GetYaxis()->SetRangeUser(ptmin+0.0001,ptmax-0.0001) ;
h3DR->GetXaxis()->SetRangeUser(0.0,0.5) ;
h3DM->GetYaxis()->SetRangeUser(ptmin+0.0001,ptmax-0.0001) ;
h3DM->GetXaxis()->SetRangeUser(0.0,0.5) ;
// h3DR->Rebin(nRebin,"");
// h3DM->Rebin(nRebin,"");
//V2 vs minv for real
TH1D* v2 = (TH1D*)h3DR->Project3D("x") ;
sprintf(name,"v2_%d",ii) ;
v2->SetName(name) ;
sprintf(name,"%3.1f<p_{t}<%3.1f GeV/c",ptmin,ptmax) ;
v2->SetTitle(name) ;
//V2 vs minv for mixed
TH1D* v2m = (TH1D*)h3DM->Project3D("x");
// sprintf(name,"v2m_%d",ii) ;
sprintf(name,"v2m") ;
v2m->SetName(name) ;
TH1D* hRatio =(TH1D*) h3DR->Project3D("x");
sprintf(name,"Ratio_%d",ii) ;
hRatio->SetName(name) ;
TH1D* hInvmassM1d = (TH1D*)h3DM->Project3D("x");
sprintf(name,"Mixed_%d",ii) ;
hInvmassM1d->SetName(name) ;
v2->Rebin(nRebin) ;
v2m->Rebin(nRebin) ;
sprintf(name,"v2v4_%d",ii) ;
TH1D * v2v4=(TH1D*)v2->Clone(name);
sprintf(name,"v2mv4_%d",ii) ;
TH1D * v2mv4=(TH1D*)v2m->Clone(name);
hRatio->Rebin(nRebin) ;
hInvmassM1d->Rebin(nRebin) ;
hRatio->Sumw2();
hRatio->Divide(hInvmassM1d);
hRatio->Fit(fconst,"q0","",0.18,0.2) ;
hRatio->Scale(1./fconst->GetParameter(0)) ;
if(cen>0)
fitMgg1->SetParameters(TMath::Min(0.3,0.0003*ii),0.137,0.0107,0.008,-0.0002,0) ;
else
fitMgg1->SetParameters(TMath::Min(0.3,0.0003*ii),0.137,0.0077,0.01,-0.0002,0) ;
fitMgg1->SetParLimits(2,0.005,0.015) ;
fitMgg1->SetParLimits(1,0.125,0.145);
// fitMgg1->SetParLimits(0,0.,1.) ;
cinv->cd() ;
hRatio->Fit(fitMgg1,"qr0","",0.07,0.25); //fit and draw InvMass real/mixed
hRatio->Fit(fitMgg1,"qrM0","",0.07,0.25); //fit and draw InvMass real/mixed
fitMgg2->SetParameters(fitMgg1->GetParameters());
fitMgg2->SetParameter(5,0.) ;
hRatio->Fit(fitMgg2,"qr0+","",0.07,0.25); //fit and draw InvMass real/mixed
cinv->Update();
Double_t mean1 = fitMgg1->GetParameter(1) ;
Double_t mean1_e = fitMgg1->GetParError(1);
Double_t sigma1 =TMath::Abs(fitMgg1->GetParameter(2)) ;
mean=mean1;
width=2.*sigma1;
cout<< "Bin " << ii <<": sigma: "<<sigma1<<endl;
fitBg1->SetParameters(fitMgg1->GetParameter(3),fitMgg1->GetParameter(4)) ;
fitBg2->SetParameters(fitMgg2->GetParameter(3),fitMgg2->GetParameter(4),fitMgg2->GetParameter(5)) ;
//=========================================================== get v2 real vs minv (200 bins)
v2->Reset() ;
v2->Sumw2();
v2m->Reset() ;
v2m->Sumw2();
v2v4->Reset() ;
v2v4->Sumw2();
v2mv4->Reset() ;
v2mv4->Sumw2();
Int_t mMean = v2->FindBin(mean1) ;
Int_t mMin2 = v2->FindBin(mean1-sigma1) ;
Int_t mMax2 = v2->FindBin(mean1+sigma1) ;
//======================================== get v2 Real vs minv (200 bins)
for(Int_t i=1;i<=v2->GetNbinsX();i++){
// h3DR->GetXaxis()->SetRange(1+(i-1)*nRebin,(i)*nRebin) ;
// TH1D * tmp =(TH1D*) h3DR->Project3D("z") ;
// sprintf(name,"real_%d_%d",ii,i);
// tmp->SetName(name);
Int_t iptMin=h3DM->GetYaxis()->FindBin(ptmin+0.0001) ;
Int_t iptMax=h3DM->GetYaxis()->FindBin(ptmax-0.0001) ;
TH1D * tmp =(TH1D*) h3DR->ProjectionZ(Form("real_%d_%d",ii,i),1+(i-1)*nRebin,(i)*nRebin,iptMin,iptMax) ;
Double_t v2mean=0,v2err=0 ;
CalcV2(tmp,v2mean,v2err) ;
v2->SetBinContent(i,v2mean);
v2->SetBinError(i,v2err);
fit->SetParameters(tmp->GetBinContent(1),0.1);
tmp->Fit(fit,"qr0");
v2->SetBinContent(i,fit->GetParameter(1));
v2->SetBinError(i,fit->GetParError(1));
tmp->Draw();
cout<<"v2{CalcV2}: "<<v2mean<<"+-"<<v2err<<", v2{Fit}: "<<fit->GetParameter(1)<<"+-"<<fit->GetParError(1)<<endl;
delete tmp ;
}
//======================================== get v2 mixed vs minv (200 bins)
for(Int_t i=1;i<=v2m->GetNbinsX();i++){
h3DM->GetXaxis()->SetRange(1+(i-1)*nRebin,(i)*nRebin) ;
TH1D * tmp2 = (TH1D*)h3DM->Project3D("z") ;
sprintf(name,"mixed_%d_%d",ii,i);
tmp2->SetName(name);
/* Double_t v2mean=0,v2err=0 ;
CalcV2(tmp2,v2mean,v2err) ;
v2m->SetBinContent(i,v2mean);
v2m->SetBinError(i,v2err);
*/
tmp2->Fit(fit,"qr0");
v2m->SetBinContent(i,fit->GetParameter(1));
v2m->SetBinError(i,fit->GetParError(1));
delete tmp2 ;
}
///////////////////////////////////////////////with single harmonic v2
//====================================== fit v2 real to find background
//This is to find v2Bg with v2Real fit with polynomial functions with gap
/*
reject=kTRUE;
Double_t mMin_BgFit=0.05 ;
Double_t mMax_BgFit=0.30 ;
Double_t mMax_BgFit2=0.40 ;
f1->SetParameters(0.1,0.,0.,0.);
v2->Fit(f1,"qM","",mMin_BgFit,mMax_BgFit);
f2->SetParameters(0.1,0.,0.,0.,0.);
v2->Fit(f2,"qM+","",mMin_BgFit,mMax_BgFit2);
*/
//Scale Mixed V2 to reproduce real V2
TH1D * v2mScaled = (TH1D*)v2m->Clone(name) ;
ScaleMixed(v2,v2m,v2mScaled) ;
sprintf(name,"%_bg",v2->GetName()) ;
TH1D * v2bg = (TH1D*)v2->Clone(name) ;
fitV2p1->SetParameters(0.1,0.135,0.05,0.1,0.) ;
fitV2p1->FixParameter(1,fitMgg1->GetParameter(1)) ;
fitV2p1->FixParameter(2,fitMgg1->GetParameter(2)) ;
v2->Fit(fitV2p1,"q","",0.07,0.25) ;
fitV2p2->SetParameters(0.1,0.135,0.05,0.1,0.) ;
fitV2p2->FixParameter(1,fitMgg2->GetParameter(1)) ;
fitV2p2->FixParameter(2,fitMgg2->GetParameter(2)) ;
v2->Fit(fitV2p2,"q+","",0.07,0.25) ;
fitV2mix->FixParameter(1,fitMgg1->GetParameter(1)) ;
fitV2mix->FixParameter(2,fitMgg1->GetParameter(2)) ;
v2->Fit(fitV2mix,"q+","",0.07,0.25) ;
//==========Draw===================
if(ii<7)
c3->cd(ii) ;
else
c4->cd(ii-6) ;
spectrum_1 = new TPad("1", "1",0.001,0.32,0.99,0.99);
spectrum_1->Draw();
spectrum_1->cd();
spectrum_1->Range(0,0,1,1);
spectrum_1->SetFillColor(0);
spectrum_1->SetFillStyle(1);
spectrum_1->SetBorderSize(1);
spectrum_1->SetBottomMargin(0.0);
spectrum_1->SetTopMargin(0.03);
spectrum_1->SetLeftMargin(0.1);
spectrum_1->SetRightMargin(0.05);
// spectrum_1->SetLogx();
// spectrum_1->SetLogy();
v2->GetXaxis()->SetRangeUser(0.05,0.3) ;
v2->SetMarkerStyle(20) ;
v2->SetMarkerSize(0.8) ;
v2->SetYTitle("v_{2}^{raw}") ;
v2->GetYaxis()->SetTitleSize(0.08) ;
v2->GetYaxis()->SetTitleOffset(0.40) ;
// v2->SetMinimum(0.) ;
// v2->SetMaximum(0.3);
v2->Draw();
v2m->SetMarkerStyle(24) ;
v2m->SetMarkerSize(0.8) ;
v2m->SetMarkerColor(6) ;
v2m->SetLineColor(6) ;
// v2m->Draw("same");
v2mScaled->SetLineColor(kOrange) ;
v2mScaled->SetLineWidth(3) ;
v2mScaled->SetFillColor(kOrange) ;
v2mScaled->SetFillStyle(1001) ;
// v2mScaled->Draw("sameL");
if(ii==1){
TLegend * lv2 = new TLegend(0.54,0.59,0.94,0.9) ;
lv2->AddEntry(v2,"Data","p") ;
lv2->AddEntry(fitV2mix,"Fit, mixed + G","l") ;
lv2->AddEntry(fitV2p1,"Fit, pol2 + G","l") ;
lv2->AddEntry(fitV2p2,"Fit, pol3 + G","l") ;
lv2->Draw();
}
TLine * linea = new TLine(mean-width,0,mean-width,1.) ;
linea->Draw() ;
TLine * linea2 = new TLine(mean+width,0,mean+width,1.) ;
linea2->Draw() ;
//Evalulate V2
//
// v2^S = v2^Total - Bg/Signal (v2^Total - v2^Bg)
//
//Bg/signal
Double_t bgS = 0 ;
TH1D * hm = (TH1D*)gROOT->FindObjectAny("v2m") ;
Double_t mix = hm->GetBinContent(hm->GetXaxis()->FindBin(fitMgg1->GetParameter(1))) ;
if(fitMgg1->GetParameter(0)>0.) bgS = fitMgg1->Eval(fitMgg1->GetParameter(1))/fitMgg1->GetParameter(0)-1. ;
Double_t v2M = fitV2mix->Eval(fitMgg1->GetParameter(1)) + bgS*fitV2mix->GetParameter(0) ;
Double_t errA = fitV2mix->GetParError(0) + fitV2mix->GetParError(3)*mix ;
Double_t sA = fitMgg1->GetParError(0)/fitMgg1->GetParameter(0) ;
Double_t sB = fitMgg1->GetParError(3)/fitMgg1->GetParameter(3) ;
Double_t errB = bgS*fitV2mix->GetParError(0) ; ;
Double_t errC = bgS*TMath::Sqrt(sA*sA+sB*sB)*fitV2mix->GetParameter(0) ;
Double_t v2Merr = TMath::Sqrt(errA*errA+errB*errB+errC*errC) ;
v2Pi_mix->SetBinContent(ii,v2M) ;
v2Pi_mix->SetBinError(ii,v2Merr) ;
v2M = fitV2p1->Eval(fitMgg1->GetParameter(1)) + bgS*fitV2p1->GetParameter(0) ;
// v2Merr = bgS*fitV2p1->GetParError(0) ;
v2Pi_pol1->SetBinContent(ii,v2M) ;
v2Pi_pol1->SetBinError(ii,v2Merr) ;
if(fitMgg2->GetParameter(0)>0.) bgS = fitMgg2->Eval(fitMgg2->GetParameter(1))/fitMgg2->GetParameter(0)-1. ;
Double_t v2M = fitV2p2->Eval(fitMgg1->GetParameter(1)) + bgS*fitV2p2->GetParameter(0) ;
// Double_t v2Merr = bgS*fitV2p2->GetParError(0) ;
v2Pi_pol2->SetBinContent(ii,v2M) ;
v2Pi_pol2->SetBinError(ii,v2Merr) ;
if(ii<7)
c3->cd(ii) ;
else
c4->cd(ii-6) ;
TPad *spectrum_2 = new TPad("2", "2",0.001,0.01,0.99,0.32);
spectrum_2->SetFillColor(0) ;
spectrum_2->SetFillStyle(0) ;
spectrum_2->SetLogy(0) ;
// spectrum_2->SetGridy() ;
spectrum_2->Draw();
spectrum_2->Range(0,0,1,1);
spectrum_2->SetFillColor(0);
spectrum_2->SetBorderSize(1);
spectrum_2->SetTopMargin(0.0);
spectrum_2->SetBottomMargin(0.25);
spectrum_2->SetLeftMargin(0.1);
spectrum_2->SetRightMargin(0.05);
// spectrum_2->SetLogx();
spectrum_2->cd() ;
//================================================= S/Bg
hRatio->SetMarkerStyle(20) ;
hRatio->SetMarkerSize(0.8) ;
hRatio->GetXaxis()->SetRangeUser(0.05,0.3) ;
// hRatio->SetMaximum(hRatio->GetMaximum()*1.6) ;
// hRatio->GetMinimum(0.0014) ;
// hRatio->GetMinimum(0.002) ;
hRatio->GetXaxis()->SetLabelSize(0.1) ;
hRatio->SetLabelOffset(0.05) ;
hRatio->SetLabelSize(0.1) ;
hRatio->GetXaxis()->SetTitleOffset(0.8);
hRatio->SetXTitle("m_{#gamma#gamma} (GeV/c^{2})");
hRatio->GetXaxis()->SetTitleSize(0.14) ;
hRatio->SetYTitle("Real/Mixed");
hRatio->GetYaxis()->SetTitleSize(0.12) ;
hRatio->GetYaxis()->SetTitleOffset(0.40) ;
hRatio->GetYaxis()->SetLabelOffset(0.01) ;
hRatio->GetYaxis()->SetNdivisions(503) ;
hRatio->GetYaxis()->SetLabelSize(0.1) ;
hRatio->Draw();
TLine * line = new TLine(mean-width,0,mean-width,0.1) ;
line->Draw() ;
TLine * line2 = new TLine(mean+width,0,mean+width,0.1) ;
line2->Draw() ;
// Get Signal and Background if pi0 yield
hRatio->Fit(fconst,"+0rq","",mean-width,mean+width) ; // fit Real2mixed ratio with const
Double_t nRe_const=fconst->GetParameter(0) ;
Double_t nReErr_const=fconst->GetParError(0) ;
Double_t nBg_lin=fitBg1->Integral(mean-width,mean+width)/2./width ; // N in bg = fitbg1 integral under pi0 peak
Double_t nBgErr_lin=fitMgg1->GetParError(3); //fitBg1->GetParError(0);
Double_t nBg_quad=fitBg2->Integral(mean-width,mean+width)/2./width ; // N in bg = fitbg1 integral under pi0 peak
Double_t nBgErr_quad=fitMgg2->GetParError(3); //fitBg2->GetParError(0);
nSig->SetBinContent(ii,(nRe_const - nBg_lin)/nBg_lin) ;
nSig->SetBinError(ii,TMath::Sqrt(nReErr_const*nReErr_const + nBgErr_lin*nBgErr_lin)) ;
nSig2->SetBinContent(ii,(nRe_const - nBg_quad)/nBg_quad) ;
nSig2->SetBinError(ii,TMath::Sqrt(nReErr_const*nReErr_const + nBgErr_quad*nBgErr_quad)) ;
c3->Update() ;
}
TCanvas * csig = new TCanvas("signal","signal") ;
TLegend *leg_n = new TLegend(0.1,0.9,0.5,0.7);
leg_n->AddEntry(nSig,"N real with bg linear fit","p");
leg_n->AddEntry(nSig2,"N real with bg quad fit","p");
nSig->Draw("p");
nSig->SetLineWidth(6);
nSig2->SetMarkerStyle(21);
nSig2->SetMarkerColor(2);
nSig2->SetLineColor(2);
nSig2->SetLineWidth(5);
nSig2->Draw("psame");
leg_n->Draw();
//============================================= Draw every v2
v2Pi_mix->SetMarkerStyle(21) ;
v2Pi_mix->SetLineColor(kOrange) ;
v2Pi_mix->SetMarkerColor(kOrange) ;
v2Pi_mix->Draw() ;
v2Pi_pol1->SetMarkerStyle(25) ;
v2Pi_pol1->SetLineColor(kOrange) ;
v2Pi_pol1->SetMarkerColor(kOrange) ;
v2Pi_pol1->Draw("same") ;
v2Pi_pol2->SetMarkerStyle(23) ;
v2Pi_pol2->SetLineColor(6) ;
v2Pi_pol2->SetMarkerColor(6) ;
v2Pi_pol2->Draw("same");
TLegend *leg_v2 = new TLegend(0.1,0.9,0.5,0.7);
leg_v2->AddEntry(v2Pi_mix,"Corrected Mixed","p");
leg_v2->AddEntry(v2Pi_pol1,"Bg fitted with pol1","p");
leg_v2->AddEntry(v2Pi_pol2,"Bg fitted with pol2","p");
leg_v2->Draw();
//calculate sys errors
TCanvas * csys = new TCanvas("V2sys","V2sys") ;
for(Int_t i=1; i<=v2Pi_mix->GetNbinsX() ;i++){
// Double_t mean=v2Pi_mix->GetBinContent(i);
Double_t mean = v2Pi_pol1->GetBinContent(i)/v2Pi_pol1->GetBinError(i)/v2Pi_pol1->GetBinError(i) + v2Pi_pol2->GetBinContent(i)/v2Pi_pol2->GetBinError(i)/v2Pi_pol2->GetBinError(i);
Double_t weight=
1./v2Pi_pol1->GetBinError(i)/v2Pi_pol1->GetBinError(i)
+1./v2Pi_pol2->GetBinError(i)/v2Pi_pol2->GetBinError(i) ;
mean/=weight;
Double_t rms =
(v2Pi_pol1->GetBinContent(i)-mean)*(v2Pi_pol1->GetBinContent(i)-mean)/v2Pi_pol1->GetBinError(i)/v2Pi_pol1->GetBinError(i)
+(v2Pi_pol2->GetBinContent(i)-mean)*(v2Pi_pol2->GetBinContent(i)-mean)/v2Pi_pol2->GetBinError(i)/v2Pi_pol2->GetBinError(i)
+(v2Pi_mix->GetBinContent(i)-mean)*(v2Pi_mix->GetBinContent(i)-mean)/v2Pi_mix->GetBinError(i)/v2Pi_mix->GetBinError(i) ;
Double_t weight=
1./v2Pi_pol1->GetBinError(i)/v2Pi_pol1->GetBinError(i)
+1./v2Pi_pol2->GetBinError(i)/v2Pi_pol2->GetBinError(i)
+1./v2Pi_mix->GetBinError(i)/v2Pi_mix->GetBinError(i) ;
rms/=weight ;
v2Astat->SetBinContent(i,mean) ;
v2Astat->SetBinError(i,v2Pi_mix->GetBinError(i)) ;
v2Asys->SetBinContent(i,mean) ;
v2Asys->SetBinError(i,TMath::Sqrt(rms)) ;
}
v2Asys->SetFillStyle(1001) ;
v2Asys->SetFillColor(kYellow) ;
v2Astat->SetMarkerColor(kOrange+7) ;
v2Astat->SetMarkerStyle(20) ;
v2Astat->SetLineColor(kOrange+7) ;
switch(cen){
case 0:
sprintf(key,"Centrality 0-5%%") ; break ;
case 1:
sprintf(key,"Centrality 5-10%%") ; break ;
case 2:
sprintf(key,"Centrality 10-20%%") ; break ;
case 3:
sprintf(key,"Centrality 20-30%%") ; break ;
case 4:
sprintf(key,"Centrality 30-40%%") ; break ;
case 5:
sprintf(key,"Centrality 40-50%%") ; break ;
case 10:
sprintf(key,"Centrality 0-10%%") ; break ;
case 11:
sprintf(key,"Centrality 20-40%%") ; break ;
}
v2Asys->SetTitle(key) ;
v2Asys->SetXTitle("p_{t} (GeV/c)") ;
v2Asys->SetYTitle("v_{2}") ;
v2Asys->SetMinimum(-0.05) ;
v2Asys->SetMaximum(0.6) ;
TH1D *effcorrect = v2Asys->Clone("effcorrect");
TH1D *effcorrect2 = v2Asys->Clone("effcorrect2");
Double_t eff=0, err=0;
if(strcmp(PID,"Both2core")==0){
if(cen==0) {eff=.03; err=.04;}
if(cen==1) {eff=.08; err=.04;}
if(cen==2) {eff=.03; err=.03;}
if(cen==3) {eff=.02; err=.02;}
if(cen==4) {eff=.02; err=.02;}
if(cen==5) {eff=.01; err=.02;}
if(cen==10) {eff=.05; err=.02;}
if(cen==11) {eff=.02; err=.02;}
if(cen==20) {eff=.02; err=.02;}
if(cen==21) {eff=.05; err=.02;}
eff=eff*2.*TMath::Pi()/5./sin(2.*TMath::Pi()/5.)/4.;
err=err*2.*TMath::Pi()/5./sin(2.*TMath::Pi()/5.)/4.;
eff=eff*res/resT;
err=err*res/resT;
cout<<"Pi0 efficiency correction: "<<eff<<"+-"<<err<<endl;
}
Double_t x[100],y[100],ex[100],ey[100] ;
for(Int_t i=0;i<effcorrect->GetNbinsX();i++){
effcorrect->SetBinContent(i,eff);
effcorrect->SetBinError(i,err);
effcorrect2->SetBinContent(i,eff);
effcorrect2->SetBinError(i,0);
}
if(effcor){
v2Astat->Add(effcorrect2);
v2Asys->Add(effcorrect);
}
v2Asys->Scale(1/res) ;
v2Astat->Scale(1/res) ;
//Error due to reaction plane into sys
v2Asys->Draw("E2") ;
v2Astat->Draw("same") ;
//=================================================== save to file
TFile fout("v2_method2_QA.root","update") ;
v2Asys->Write(0,TObject::kOverwrite) ;
v2Astat->Write(0,TObject::kOverwrite) ;
}
|
7f337f592e9118ecfa488e28e171d6439050b2ae
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/nv32f100x/lib/src/spi.c
|
a48293f3af751e6b21a75136b0f629b73ebfa348
|
[
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 8,558
|
c
|
spi.c
|
/******************************************************************************
* @brief providing APIs for configuring SPI module (SPI).
*
*******************************************************************************
*
* provide APIs for configuring SPI module (SPI).
******************************************************************************/
#include "common.h"
#include "spi.h"
/******************************************************************************
* Local variables
******************************************************************************/
SPI_CallbackType SPI_Callback[MAX_SPI_NO] = {(SPI_CallbackType)NULL};
/******************************************************************************
* Local function prototypes
******************************************************************************/
/******************************************************************************
* Local functions
*****************************************************************************/
/******************************************************************************
* Global functions
******************************************************************************/
/******************************************************************************
* define SPI APIs
*
*//*! @addtogroup spi_api_list
* @{
*******************************************************************************/
/*****************************************************************************//*!
*
* @brief initialize SPI as per params.
*
* @param[in] pSPI point to SPI module type.
* @param[in] pConfig point to configuration parameters.
*
* @return none.
*
* @ Pass/ Fail criteria: none.
*****************************************************************************/
void SPI_Init(SPI_Type *pSPI, SPI_ConfigType *pConfig)
{
#if defined(CPU_NV32M3)
/* sanity check */
ASSERT((pSPI == SPI0));
SIM->SCGC |= SIM_SCGC_SPI0_MASK;
#else
/* sanity check */
ASSERT((pSPI == SPI0) || (pSPI == SPI1));
/* enable SPI clock gating on */
if( pSPI == SPI0)
{
SIM->SCGC |= SIM_SCGC_SPI0_MASK;
}
else
{
SIM->SCGC |= SIM_SCGC_SPI1_MASK;
}
#endif
/* configure other control bits */
if( pConfig->sSettings.bIntEn)
{
SPI_IntEnable(pSPI);
#if defined(CPU_NV32M3)
NVIC_EnableIRQ(SPI0_IRQn);
#else
if( pSPI == SPI0 )
{
NVIC_EnableIRQ(SPI0_IRQn);
}
else
{
NVIC_EnableIRQ(SPI1_IRQn);
}
#endif
}
if( pConfig->sSettings.bTxIntEn)
{
SPI_TxIntEnable(pSPI);
#if defined(CPU_NV32M3)
NVIC_EnableIRQ(SPI0_IRQn);
#else
if( pSPI == SPI0 )
{
NVIC_EnableIRQ(SPI0_IRQn);
}
else
{
NVIC_EnableIRQ(SPI1_IRQn);
}
#endif
}
if( pConfig->sSettings.bMasterMode)
{
SPI_SetMasterMode(pSPI);
}
else
{
SPI_SetSlaveMode(pSPI);
}
if( pConfig->sSettings.bClkPolarityLow)
{
SPI_SetClockPol(pSPI,1);
}
if( pConfig->sSettings.bClkPhase1)
{
SPI_SetClockPhase(pSPI,1);
}else
{
SPI_SetClockPhase(pSPI,0);
}
if( pConfig->sSettings.bShiftLSBFirst)
{
SPI_SetLSBFirst(pSPI);
}
if( pConfig->sSettings.bMatchIntEn)
{
SPI_MatchIntEnable(pSPI);
}
if( pConfig->sSettings.bModeFaultEn)
{
SPI_ModfEnable(pSPI);
}
if( pConfig->sSettings.bMasterAutoDriveSS)
{
/* set both SSOE and MODFEN bits when auto drive slave SS is enabled */
SPI_SSOutputEnable(pSPI);
SPI_ModfEnable(pSPI);
}
if( pConfig->sSettings.bPinAsOuput)
{
SPI_BidirPinEnable(pSPI);
}
if( pConfig->sSettings.bBidirectionModeEn)
{
SPI_BidirOutEnable(pSPI);
}
if( pConfig->sSettings.bStopInWaitMode)
{
SPI_ClockStopEnable(pSPI);
}
if(pConfig->sSettings.bMasterMode)
{
SPI_SetBaudRate(pSPI,pConfig->u32BusClkHz,pConfig->u32BitRate);
}
/* enable SPI module */
if( pConfig->sSettings.bModuleEn)
{
SPI_Enable(pSPI);
}
}
/*****************************************************************************//*!
*
* @brief SPI set band rate.
*
* @param[in] pSPI point to SPI module type.
* @param[in] u32BusClock Bus clock.
* @param[in] u32Bps set spi's baudrate.
*
* @return none.
*
* @ Pass/ Fail criteria: none.
*****************************************************************************/
void SPI_SetBaudRate(SPI_Type *pSPI,uint32_t u32BusClock,uint32_t u32Bps)
{
uint32_t u32BitRateDivisor;
uint8_t u8Sppr;
uint8_t u8Spr;
uint8_t u8ReadFlag;
u32BitRateDivisor = u32BusClock/u32Bps; /* calculate bit rate divisor */
u8ReadFlag = 0;
/* find best fit SPPR and SPR */
for (u8Spr = 0; u8Spr <= 8; u8Spr++)
{
for(u8Sppr = 0; u8Sppr <= 7; u8Sppr++)
{
if((u32BitRateDivisor>>(u8Spr+1))<=(u8Sppr+1))
{
u8ReadFlag = 1;
break;
}
}
if(u8ReadFlag)
{
break;
}
}
if(u8Sppr >=8)
{
u8Sppr = 7;
}
if(u8Spr >8)
{
u8Spr = 8;
}
/* set bit rate */
pSPI->BR = SPI_BR_SPPR(u8Sppr) | SPI_BR_SPR(u8Spr);
}
/*****************************************************************************//*!
*
* @brief implement write data to SPI.
*
* @param[in] pSPI pointer to SPI module type.
* @param[in] pWrBuff -- write data buffer pointer.
* @param[in] uiLength -- read/write data length.
* @param[out] pRdBuff -- read data buffer pointer.
*
* @return if <0, means error, 0: success.
*
* @ Pass/ Fail criteria: none.
*****************************************************************************/
ResultType SPI_TransferWait(SPI_Type *pSPI, SPI_WidthType* pRdBuff, SPI_WidthType *pWrBuff,uint32 uiLength)
{
ResultType err = SPI_ERR_SUCCESS;
uint32_t i;
if(!uiLength)
{
return (err);
}
for(i = 0; i < uiLength; i++)
{
while(!SPI_IsSPTEF(pSPI));
SPI_WriteDataReg(pSPI,pWrBuff[i]);
while(!SPI_IsSPRF(pSPI));
pRdBuff[i] = SPI_ReadDataReg(pSPI);
}
return (err);
}
/*****************************************************************************//*!
*
* @brief Deinitialize SPI to the default state (reset value).
*
* @param[in] pSPI pointer to SPI module type.
*
* @return none.
*
* @ Pass/ Fail criteria: none.
*****************************************************************************/
void SPI_DeInit(SPI_Type *pSPI)
{
int16 i;
pSPI->C1 = SPI_C1_DEFAULT;
pSPI->C2 = SPI_C2_DEFAULT;
pSPI->BR = SPI_BR_DEFAULT;
pSPI->M = SPI_M_DEFAULT;
for(i = 0; i<100; i++); /* wait for some cycles for the ISR exit */
}
/*****************************************************************************//*!
*
* @brief set up SPI callback routines to be called by interrupt service routine.
*
* @param[in] pSPI pointer to SPI module type.
* @param[in] pfnCallback callback routine.
*
* @return none.
*
* @ Pass/ Fail criteria: none.
*****************************************************************************/
void SPI_SetCallback(SPI_Type *pSPI,SPI_CallbackType pfnCallback)
{
uint32_t u32Port = ((uint32_t)pSPI-(uint32_t)SPI0)>>12;
ASSERT(u32Port <2);
SPI_Callback[u32Port] = pfnCallback;
}
/*! @} End of spi_api_list */
/*****************************************************************************//*!
*
* @brief SPI0 interrupt service routine.
*
* @param none.
* @return none.
*
* @ Pass/ Fail criteria: none.
*****************************************************************************/
void SPI0_Isr(void)
{
if( SPI_Callback[0] )
{
SPI_Callback[0]();
}
}
#ifndef CPU_NV32M3
/*****************************************************************************//*!
*
* @brief SPI1 interrupt service routine.
*
* @param none.
* @return none.
*
* @ Pass/ Fail criteria: none
*****************************************************************************/
void SPI1_Isr(void)
{
if( SPI_Callback[1] )
{
SPI_Callback[1]();
}
}
#endif
|
2c934d61362c1058cde0f35147c9fdb158cd8606
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/acm32/acm32f0x0-nucleo/libraries/HAL_Driver/Inc/HAL_TIMER_EX.h
|
299988491ecfa6f0994c4502b7eb84bcbc732004
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 8,018
|
h
|
HAL_TIMER_EX.h
|
/***********************************************************************
* Filename : hal_timer_ex.h
* Description : timer driver header file
* Author(s) : xwl
* version : V1.0
* Modify date : 2021-03-24
***********************************************************************/
#ifndef __HAL_TIMER_EX_H__
#define __HAL_TIMER_EX_H__
#include "ACM32Fxx_HAL.h"
#define TIM_BDTR_DTG_Pos (0U)
#define TIM_BDTR_DTG_Msk (0xFFUL << TIM_BDTR_DTG_Pos) /*!< 0x000000FF */
#define TIM_BDTR_DTG TIM_BDTR_DTG_Msk /*!<DTG[0:7] bits (Dead-Time Generator set-up) */
#define TIM_BDTR_DTG_0 (0x01UL << TIM_BDTR_DTG_Pos) /*!< 0x00000001 */
#define TIM_BDTR_DTG_1 (0x02UL << TIM_BDTR_DTG_Pos) /*!< 0x00000002 */
#define TIM_BDTR_DTG_2 (0x04UL << TIM_BDTR_DTG_Pos) /*!< 0x00000004 */
#define TIM_BDTR_DTG_3 (0x08UL << TIM_BDTR_DTG_Pos) /*!< 0x00000008 */
#define TIM_BDTR_DTG_4 (0x10UL << TIM_BDTR_DTG_Pos) /*!< 0x00000010 */
#define TIM_BDTR_DTG_5 (0x20UL << TIM_BDTR_DTG_Pos) /*!< 0x00000020 */
#define TIM_BDTR_DTG_6 (0x40UL << TIM_BDTR_DTG_Pos) /*!< 0x00000040 */
#define TIM_BDTR_DTG_7 (0x80UL << TIM_BDTR_DTG_Pos)
#define TIM_BDTR_LOCK_Pos (8U)
#define TIM_BDTR_LOCK_Msk (0x3UL << TIM_BDTR_LOCK_Pos) /*!< 0x00000300 */
#define TIM_BDTR_LOCK TIM_BDTR_LOCK_Msk /*!<LOCK[1:0] bits (Lock Configuration) */
#define TIM_BDTR_LOCK_0 (0x1UL << TIM_BDTR_LOCK_Pos) /*!< 0x00000100 */
#define TIM_BDTR_LOCK_1 (0x2UL << TIM_BDTR_LOCK_Pos)
#define TIM_BDTR_OSSI_Pos (10U)
#define TIM_BDTR_OSSI_Msk (0x1UL << TIM_BDTR_OSSI_Pos) /*!< 0x00000400 */
#define TIM_BDTR_OSSI TIM_BDTR_OSSI_Msk /*!<Off-State Selection for Idle mode */
#define TIM_BDTR_OSSR_Pos (11U)
#define TIM_BDTR_OSSR_Msk (0x1UL << TIM_BDTR_OSSR_Pos) /*!< 0x00000800 */
#define TIM_BDTR_OSSR TIM_BDTR_OSSR_Msk /*!<Off-State Selection for Run mode */
#define TIM_BDTR_BKE_Pos (12U)
#define TIM_BDTR_BKE_Msk (0x1UL << TIM_BDTR_BKE_Pos) /*!< 0x00001000 */
#define TIM_BDTR_BKE TIM_BDTR_BKE_Msk /*!<Break enable for Break 1 */
#define TIM_BDTR_BKP_Pos (13U)
#define TIM_BDTR_BKP_Msk (0x1UL << TIM_BDTR_BKP_Pos) /*!< 0x00002000 */
#define TIM_BDTR_BKP TIM_BDTR_BKP_Msk /*!<Break Polarity for Break 1 */
#define TIM_BDTR_AOE_Pos (14U)
#define TIM_BDTR_AOE_Msk (0x1UL << TIM_BDTR_AOE_Pos) /*!< 0x00004000 */
#define TIM_BDTR_AOE TIM_BDTR_AOE_Msk /*!<Automatic Output enable */
#define TIM_BDTR_MOE_Pos (15U)
#define TIM_BDTR_MOE_Msk (0x1UL << TIM_BDTR_MOE_Pos) /*!< 0x00008000 */
#define TIM_BDTR_MOE TIM_BDTR_MOE_Msk /*!<Main Output enable */
#define TIM_BDTR_BKF_Pos (16U)
#define TIM_BDTR_BKF_Msk (0xFUL << TIM_BDTR_BKF_Pos) /*!< 0x000F0000 */
#define TIM_BDTR_BKF TIM_BDTR_BKF_Msk
#define TIM_BREAKINPUTSOURCE_BKIN 0x00000001U /* !< An external source (GPIO) is connected to the BKIN pin */
#ifdef HAL_COMP_MODULE_ENABLED
#define TIM_BREAKINPUTSOURCE_COMP1 0x00000002U /* !< The COMP1 output is connected to the break input */
#define TIM_BREAKINPUTSOURCE_COMP2 0x00000004U /* !< The COMP2 output is connected to the break input */
#endif /* COMP1 && COMP2 */
#define TIM_BREAKINPUT_BRK 0x00000001U
#define TIM1_AF1_BKINE_Pos (0U)
#define TIM1_AF1_BKINE_Msk (0x1UL << TIM1_AF1_BKINE_Pos) /*!< 0x00000001 */
#define TIM1_AF1_BKINE TIM1_AF1_BKINE_Msk /*!<BRK BKIN input enable */
#define TIM1_AF1_BKCMP1E_Pos (1U)
#define TIM1_AF1_BKCMP1E_Msk (0x1UL << TIM1_AF1_BKCMP1E_Pos) /*!< 0x00000002 */
#define TIM1_AF1_BKCMP1E TIM1_AF1_BKCMP1E_Msk /*!<BRK COMP1 enable */
#define TIM1_AF1_BKCMP2E_Pos (2U)
#define TIM1_AF1_BKCMP2E_Msk (0x1UL << TIM1_AF1_BKCMP2E_Pos) /*!< 0x00000004 */
#define TIM1_AF1_BKCMP2E TIM1_AF1_BKCMP2E_Msk /*!<BRK COMP2 enable */
#define TIM1_AF1_BKINP_Pos (9U)
#define TIM1_AF1_BKINP_Msk (0x1UL << TIM1_AF1_BKINP_Pos) /*!< 0x00000200 */
#define TIM1_AF1_BKINP TIM1_AF1_BKINP_Msk /*!<BRK BKIN input polarity */
#define TIM1_AF1_BKCMP1P_Pos (10U)
#define TIM1_AF1_BKCMP1P_Msk (0x1UL << TIM1_AF1_BKCMP1P_Pos) /*!< 0x00000400 */
#define TIM1_AF1_BKCMP1P TIM1_AF1_BKCMP1P_Msk /*!<BRK COMP1 input polarity */
#define TIM1_AF1_BKCMP2P_Pos (11U)
#define TIM1_AF1_BKCMP2P_Msk (0x1UL << TIM1_AF1_BKCMP2P_Pos) /*!< 0x00000800 */
#define TIM1_AF1_BKCMP2P TIM1_AF1_BKCMP2P_Msk
typedef struct
{
uint32_t OffStateRunMode; // TIM off state in run mode
uint32_t OffStateIDLEMode; // TIM off state in IDLE mode
uint32_t LockLevel; // TIM Lock level
uint32_t DeadTime; // TIM dead Time
uint32_t BreakState; // TIM Break State
uint32_t BreakPolarity; // TIM Break input polarity
uint32_t BreakFilter; // Specifies the break input filter.
uint32_t AutomaticOutput; // TIM Automatic Output Enable state
} TIM_BreakDeadTimeConfigTypeDef;
typedef struct
{
uint32_t Source; /*!< Specifies the source of the timer break input.
This parameter can be a value of @ref TIMEx_Break_Input_Source */
uint32_t Enable; /*!< Specifies whether or not the break input source is enabled.
This parameter can be a value of @ref TIMEx_Break_Input_Source_Enable */
uint32_t Polarity; /*!< Specifies the break input source polarity.
This parameter can be a value of @ref TIMEx_Break_Input_Source_Polarity */
}
TIMEx_BreakInputConfigTypeDef;
/******************* Bit definition for TIM_TISEL register *********************/
#define TIM_TISEL_TI1SEL_Pos (0U)
#define TIM_TISEL_TI1SEL_Msk (0xFUL << TIM_TISEL_TI1SEL_Pos) /*!< 0x0000000F */
#define TIM_TISEL_TI1SEL TIM_TISEL_TI1SEL_Msk /*!<TI1SEL[3:0] bits (TIM1 TI1 SEL)*/
#define TIM_TISEL_TI1SEL_0 (0x1UL << TIM_TISEL_TI1SEL_Pos) /*!< 0x00000001 */
#define TIM_TISEL_TI1SEL_1 (0x2UL << TIM_TISEL_TI1SEL_Pos) /*!< 0x00000002 */
#define TIM_TISEL_TI1SEL_2 (0x4UL << TIM_TISEL_TI1SEL_Pos) /*!< 0x00000004 */
#define TIM_TISEL_TI1SEL_3 (0x8UL << TIM_TISEL_TI1SEL_Pos) /*!< 0x00000008 */
#define TIM_TISEL_TI2SEL_Pos (8U)
#define TIM_TISEL_TI2SEL_Msk (0xFUL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000F00 */
#define TIM_TISEL_TI2SEL TIM_TISEL_TI2SEL_Msk /*!<TI2SEL[3:0] bits (TIM1 TI2 SEL)*/
#define TIM_TISEL_TI2SEL_0 (0x1UL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000100 */
#define TIM_TISEL_TI2SEL_1 (0x2UL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000200 */
#define TIM_TISEL_TI2SEL_2 (0x4UL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000400 */
#define TIM_TISEL_TI2SEL_3 (0x8UL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000800 */
#endif
|
55b044323afb965ee8227f46fba2e6680b20c346
|
fa1ad2e2ac7e376fc7cb3b3a6e1bb88eed3e80be
|
/govern/data-security/krb-1.2.1/src/lib/crypto/krb/default_state.c
|
9e0241675e2651fee72bf42d69c871a4119296fb
|
[
"BSD-4-Clause",
"LicenseRef-scancode-generic-export-compliance",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-mit-old-style",
"BSD-4-Clause-UC",
"LicenseRef-scancode-rsa-1990",
"BSD-3-Clause",
"MIT-CMU",
"LicenseRef-scancode-mit-no-advert-export-control",
"CC-BY-SA-3.0",
"LicenseRef-scancode-mit-modification-obligations",
"LicenseRef-scancode-proprietary-license",
"GPL-2.0-or-later",
"LicenseRef-scancode-michigan-disclaimer",
"ISC",
"LicenseRef-scancode-nrl-permission",
"FreeBSD-DOC",
"LicenseRef-scancode-rsa-md4",
"RSA-MD",
"OLDAP-2.8",
"FSFULLRWD",
"BSD-2-Clause",
"LicenseRef-scancode-brian-gladman",
"MIT",
"Apache-2.0"
] |
permissive
|
alldatacenter/alldata
|
7bc7713c9f1d56ad6b8e59ea03206d1073b7e047
|
8d5f9a2d49ab8f9e85ccf058cb02c2fda287afc6
|
refs/heads/master
| 2023-08-05T07:32:25.442740
| 2023-08-03T13:17:24
| 2023-08-03T13:17:24
| 213,321,771
| 774
| 250
|
Apache-2.0
| 2023-09-06T17:35:32
| 2019-10-07T07:36:18
| null |
UTF-8
|
C
| false
| false
| 2,048
|
c
|
default_state.c
|
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 2001, 2014 by the Massachusetts Institute of Technology.
* All rights reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
* Section 6 (Encryption) of the Kerberos revisions document defines
* cipher states to be used to chain encryptions and decryptions
* together. Examples of cipher states include initialization vectors
* for CBC encription. Most Kerberos encryption systems can share
* code for initializing and freeing cipher states. This file
* contains that default code.
*/
#include "crypto_int.h"
krb5_error_code
krb5int_des_init_state(const krb5_keyblock *key, krb5_keyusage usage,
krb5_data *state_out)
{
if (alloc_data(state_out, 8))
return ENOMEM;
return 0;
}
void
krb5int_default_free_state(krb5_data *state)
{
free(state->data);
*state = empty_data();
}
|
f4e31721e6c588a49bf1c2930a0a875f2d034bee
|
50dd46b8ece33f3cdd174284b15d1d51f89669d4
|
/third_party/edk2/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemSlotDesignationFunction.c
|
30be4adac4b906ee616ef6c8b3a2e9a4eb0e06fd
|
[
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause",
"OpenSSL"
] |
permissive
|
google/google-ctf
|
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
|
df02323eaf945d15e124801c74abaadca2749dc7
|
refs/heads/master
| 2023-08-31T14:30:27.548081
| 2023-08-29T13:04:20
| 2023-08-29T13:04:20
| 131,317,137
| 4,136
| 607
|
Apache-2.0
| 2023-08-30T22:17:02
| 2018-04-27T15:56:03
|
Go
|
UTF-8
|
C
| false
| false
| 4,955
|
c
|
MiscSystemSlotDesignationFunction.c
|
/*++
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
MiscSystemSlotDesignatorFunction.c
Abstract:
BIOS system slot designator information boot time changes.
SMBIOS type 9.
--*/
#include "MiscSubclassDriver.h"
/**
This function makes boot time changes to the contents of the
MiscSystemSlotDesignator structure (Type 9).
@param RecordData Pointer to copy of RecordData from the Data Table.
@retval EFI_SUCCESS All parameters were valid.
@retval EFI_UNSUPPORTED Unexpected RecordType value.
@retval EFI_INVALID_PARAMETER Invalid parameter was found.
**/
MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation)
{
CHAR8 *OptionalStrStart;
UINTN SlotDesignationStrLen;
EFI_STATUS Status;
EFI_STRING SlotDesignation;
STRING_REF TokenToGet;
SMBIOS_TABLE_TYPE9 *SmbiosRecord;
EFI_SMBIOS_HANDLE SmbiosHandle;
EFI_MISC_SYSTEM_SLOT_DESIGNATION* ForType9InputData;
ForType9InputData = (EFI_MISC_SYSTEM_SLOT_DESIGNATION *)RecordData;
//
// First check for invalid parameters.
//
if (RecordData == NULL) {
return EFI_INVALID_PARAMETER;
}
TokenToGet = 0;
switch (ForType9InputData->SlotDesignation) {
case STR_MISC_SYSTEM_SLOT_PCIEX16_1:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCIEX16_1);
break;
case STR_MISC_SYSTEM_SLOT_PCIEX16_2:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCIEX16_2);
break;
case STR_MISC_SYSTEM_SLOT_PCIEX4:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCIEX4);
break;
case STR_MISC_SYSTEM_SLOT_PCIEX1_1:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCIEX1_1);
break;
case STR_MISC_SYSTEM_SLOT_PCIEX1_2:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCIEX1_2);
break;
case STR_MISC_SYSTEM_SLOT_PCIEX1_3:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCIEX1_3);
break;
case STR_MISC_SYSTEM_SLOT_PCI1:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCI1);
break;
case STR_MISC_SYSTEM_SLOT_PCI2:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCI2);
break;
case STR_MISC_SYSTEM_SLOT_PCI3:
TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SLOT_PCI3);
break;
default:
break;
}
SlotDesignation = SmbiosMiscGetString (TokenToGet);
SlotDesignationStrLen = StrLen(SlotDesignation);
if (SlotDesignationStrLen > SMBIOS_STRING_MAX_LENGTH) {
return EFI_UNSUPPORTED;
}
//
// Two zeros following the last string.
//
SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE9) + SlotDesignationStrLen + 1 + 1);
ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE9) +SlotDesignationStrLen + 1 + 1);
SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_SLOTS;
SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE9);
SmbiosRecord->Hdr.Handle = 0;
SmbiosRecord->SlotDesignation = 1;
SmbiosRecord->SlotType = (UINT8)ForType9InputData->SlotType;
SmbiosRecord->SlotDataBusWidth = (UINT8)ForType9InputData->SlotDataBusWidth;
SmbiosRecord->CurrentUsage = (UINT8)ForType9InputData->SlotUsage;
SmbiosRecord->SlotLength = (UINT8)ForType9InputData->SlotLength;
SmbiosRecord->SlotID = ForType9InputData->SlotId;
//
// Slot Characteristics
//
CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForType9InputData->SlotCharacteristics,2);
OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);
//
// Now we have got the full smbios record, call smbios protocol to add this record.
//
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios-> Add(
Smbios,
NULL,
&SmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
);
FreePool(SmbiosRecord);
return Status;
}
|
fb31f41f38a5cf5461024feaad65596227357364
|
7664f318ed04bd0680f3d82321c18896e3ef6ad5
|
/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h
|
15e878175015f5b6504ea25c9683b7b1d5ad49a2
|
[] |
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
| 1,184
|
h
|
z_en_kanban.h
|
#ifndef Z_EN_KANBAN_H
#define Z_EN_KANBAN_H
#include "ultra64.h"
#include "global.h"
struct EnKanban;
typedef struct EnKanban {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[4];
/* 0x0150 */ u8 frameCount;
/* 0x0152 */ s16 airTimer;
/* 0x0154 */ u8 actionState;
/* 0x0156 */ u16 partFlags;
/* 0x0158 */ u8 partCount;
/* 0x015A */ s16 invincibilityTimer;
/* 0x015C */ Vec3f offset;
/* 0x0168 */ Vec3s spinRot;
/* 0x016E */ Vec3s spinVel;
/* 0x0174 */ s8 spinXFlag;
/* 0x0175 */ s8 spinZFlag;
/* 0x0176 */ s16 bounceX;
/* 0x0178 */ s16 bounceZ;
/* 0x017A */ u8 bounceCount;
/* 0x017C */ f32 pieceWidth;
/* 0x0180 */ f32 pieceHeight;
/* 0x0184 */ s16 direction;
/* 0x0188 */ Vec3f floorRot;
/* 0x0194 */ u8 cutType;
/* 0x0195 */ u8 pieceType;
/* 0x0196 */ s16 cutMarkTimer;
/* 0x0198 */ s16 cutMarkAlpha;
/* 0x019A */ s16 zTargetTimer;
/* 0x019C */ u8 msgFlag;
/* 0x019D */ u8 msgTimer;
/* 0x019E */ u8 ocarinaFlag;
/* 0x01A0 */ ColliderCylinder collider;
} EnKanban; // size = 0x01EC
#define ENKANBAN_PIECE ((s16)0xFFDD)
#define ENKANBAN_FISHING 0x300
#endif
|
5a1441d693763d1a47c099ff70a76ebf159b2078
|
7d7900e1c25b729fc8c208673a449c0520ba466e
|
/examples/matrix1/matrix1.c
|
2c741884397fe4140bba1eb705e179872ecad261
|
[
"MIT",
"BSD-2-Clause"
] |
permissive
|
pocl/pocl
|
384091e15c8f6abf29fd2c6deace34a7de5a6ac6
|
5a99e12d0bb78427ad948ac368589135507f1b59
|
refs/heads/main
| 2023-09-02T14:16:21.381680
| 2023-08-21T12:13:47
| 2023-08-21T12:13:47
| 12,292,999
| 775
| 250
|
MIT
| 2023-09-14T06:50:34
| 2013-08-22T09:26:12
|
C
|
UTF-8
|
C
| false
| false
| 14,366
|
c
|
matrix1.c
|
/* matrix1 - SGEMM example with verification.
Copyright (c) 2018 Michal Babej / Tampere University of Technology
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.
*/
// For srandom
#define _DEFAULT_SOURCE
#define _BSD_SOURCE
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "pocl_opencl.h"
#ifdef _WIN32
# include "vccompat.hpp"
#endif
#ifndef min
#define min(X, Y) X < Y ? X : Y
#endif
int
exec_matrix_kernel (cl_context context, cl_device_id device,
cl_command_queue cmd_queue, cl_program program, cl_uint n,
cl_float *srcA, cl_float *srcB, cl_float *dst,
const char *kernel_name, const size_t *global_work_size,
const size_t *local_work_size, int transpose)
{
cl_kernel kernel = NULL;
cl_mem memobjs[3] = { 0, 0, 0 };
cl_int err = CL_SUCCESS;
cl_mem temp = NULL;
poclu_bswap_cl_float_array (device, (cl_float *)srcA, n * n);
poclu_bswap_cl_float_array (device, (cl_float *)srcB, n * n);
memobjs[0]
= clCreateBuffer (context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
sizeof (cl_float) * n * n, srcA, &err);
CHECK_CL_ERROR2 (err);
if (transpose)
{
temp = clCreateBuffer (context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
sizeof (cl_float) * n * n, srcB, &err);
CHECK_CL_ERROR2 (err);
memobjs[1] = clCreateBuffer (context, CL_MEM_READ_WRITE,
sizeof (cl_float) * n * n, NULL, &err);
CHECK_CL_ERROR2 (err);
kernel = clCreateKernel (program, "transpose", NULL);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 0, sizeof (cl_uint), (void *)&n);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 1, sizeof (cl_uint), (void *)&n);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 2, sizeof (cl_mem), (void *)&temp);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 3, sizeof (cl_mem), (void *)&memobjs[1]);
CHECK_CL_ERROR2 (err);
size_t global[2] = { n, n };
size_t local[2] = { 8, 8 };
err = clEnqueueNDRangeKernel (cmd_queue, kernel, 2, NULL, global, local,
0, NULL, NULL);
CHECK_CL_ERROR2 (err);
}
else
{
memobjs[1]
= clCreateBuffer (context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
sizeof (cl_float) * n * n, srcB, &err);
CHECK_CL_ERROR2 (err);
}
memobjs[2] = clCreateBuffer (context, CL_MEM_WRITE_ONLY,
sizeof (cl_float) * n * n, NULL, &err);
CHECK_CL_ERROR2 (err);
kernel = clCreateKernel (program, kernel_name, NULL);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 0, sizeof (cl_mem), (void *)&memobjs[0]);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 1, sizeof (cl_mem), (void *)&memobjs[1]);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 2, sizeof (cl_mem), (void *)&memobjs[2]);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 3, sizeof (cl_uint), (void *)&n);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 4, sizeof (cl_uint), (void *)&n);
CHECK_CL_ERROR2 (err);
err = clSetKernelArg (kernel, 5, sizeof (cl_uint), (void *)&n);
CHECK_CL_ERROR2 (err);
cl_event ev;
printf ("gws: %lu %lu lws: %lu %lu\n", global_work_size[0],
global_work_size[1], local_work_size[0], local_work_size[1]);
err = clEnqueueNDRangeKernel (cmd_queue, kernel, 2, NULL, global_work_size,
local_work_size, 0, NULL, &ev);
CHECK_CL_ERROR2 (err);
err = clEnqueueReadBuffer (cmd_queue, memobjs[2], CL_TRUE, 0,
n * n * sizeof (cl_float), dst, 0, NULL, NULL);
CHECK_CL_ERROR2 (err);
cl_ulong startTime;
cl_ulong endTime;
// Get kernel profiling info
err = clGetEventProfilingInfo (ev, CL_PROFILING_COMMAND_START,
sizeof (cl_ulong), &startTime, 0);
CHECK_CL_ERROR2 (err);
err = clGetEventProfilingInfo (ev, CL_PROFILING_COMMAND_END,
sizeof (cl_ulong), &endTime, 0);
CHECK_CL_ERROR2 (err);
cl_ulong ev_nsec = endTime - startTime;
double nsec = (double)ev_nsec;
double msec = ev_nsec / 1000000.0;
size_t f = 2UL * n * n * n;
double flops = (double)f;
double gflops = f / 1000000000.0;
double perf = flops / nsec;
printf ("Performance: %lf GFLOPS/s | Time: %lf msec | Total Ops to "
"execute: %lf G \n",
perf, msec, gflops);
clReleaseEvent (ev);
poclu_bswap_cl_float_array (device, (cl_float *)dst, n * n);
ERROR:
if (temp)
clReleaseMemObject (temp);
clReleaseMemObject (memobjs[0]);
clReleaseMemObject (memobjs[1]);
clReleaseMemObject (memobjs[2]);
clReleaseKernel (kernel);
return err;
}
int
main (int argc, char **argv)
{
cl_float *srcA = NULL;
cl_float *srcB = NULL;
cl_float *dst = NULL;
long *sums = NULL;
long i, j, sum;
int is_binary = 0;
int spir = 0;
int spirv = 0;
int poclbin = 0;
int use_locals = 0;
int use_2d_reg_block = 0;
int use_fma = 0;
cl_int err;
cl_context context = NULL;
cl_device_id device = NULL;
cl_platform_id platform = NULL;
cl_command_queue queue = NULL;
cl_program program = NULL;
size_t max_wg_size = 0;
cl_ulong local_mem_size = 0;
unsigned local_wg = 0;
long matrix_size = 0;
const char *explicit_binary_path = NULL;
printf ("argc: %i \n", argc);
err = poclu_get_any_device2 (&context, &device, &queue, &platform);
CHECK_OPENCL_ERROR_IN ("clCreateContext");
if (argc > 1)
{
errno = 0;
matrix_size = strtol (argv[1], NULL, 10);
}
if (matrix_size < 64 || matrix_size > 65536 || errno)
{
printf ("USAGE: matrix1 MATRIX_SIZE [options] [path-to-binary]\n"
"Matrix width must be power-of-4, in [64, 65536] range\n");
return EXIT_FAILURE;
}
/**************************************************************************/
long matrix_2d_size = matrix_size * matrix_size;
int arg_i = 2;
while ((argc > arg_i) && (argv[arg_i][0] == '-'))
{
if (argv[arg_i][1] == 's')
spir = 1;
if (argv[arg_i][1] == 'v')
spirv = 1;
if (argv[arg_i][1] == 'b')
poclbin = 1;
if (argv[arg_i][1] == 'l')
use_locals = 1;
if (argv[arg_i][1] == 'r')
use_2d_reg_block = 1;
if (argv[arg_i][1] == 'f')
use_fma = 1;
++arg_i;
}
if ((spir + spirv + poclbin) > 1)
{
printf ("only one type of binary can be specified \n");
return EXIT_FAILURE;
}
is_binary = (spir + spirv + poclbin);
if ((argc > arg_i) && (argv[arg_i][0] != '-'))
explicit_binary_path = argv[arg_i];
printf ("OPTIONS: SPIR %i SPIR-V %i POCLBIN %i USE_LOCALS %i USE_REGS %i "
"USE_FMA %i \n"
"EXPLICIT BINARY: %s \n",
spir, spirv, poclbin, use_locals, use_2d_reg_block, use_fma,
explicit_binary_path);
if (explicit_binary_path && ((spir + spirv + poclbin) == 0))
{
printf ("explicit binary given, but no binary type specified!\n");
return EXIT_FAILURE;
}
/**************************************************************************/
err = clGetDeviceInfo (device, CL_DEVICE_MAX_WORK_GROUP_SIZE,
sizeof (max_wg_size), &max_wg_size, NULL);
CHECK_OPENCL_ERROR_IN ("clGetDeviceInfo");
err = clGetDeviceInfo (device, CL_DEVICE_LOCAL_MEM_SIZE,
sizeof (local_mem_size), &local_mem_size, NULL);
CHECK_OPENCL_ERROR_IN ("clGetDeviceInfo");
/**************************************************************************/
local_wg = 1;
while (local_wg * local_wg < max_wg_size)
local_wg <<= 1;
if (local_wg * local_wg > max_wg_size)
local_wg >>= 1;
assert (local_wg > 0);
if (is_binary)
{
use_fma = 0;
local_wg = 32;
printf ("Binary local_wg: %u \n", local_wg);
if (local_wg * local_wg > max_wg_size)
{
printf ("Local WG size of the binary exceeds this "
"device's capabilities.\nTest SKIPPED\n");
return 0;
}
}
else
{
printf ("Autodetected local_wg: %u max wg size: %lu\n", local_wg,
max_wg_size);
}
/**************************************************************************/
size_t global_work_size[2];
size_t local_work_size[2];
const char *kernel_name = NULL;
const char *fma = use_fma ? "-DFMA " : "";
char extra_opts[1024];
extra_opts[0] = 0;
/* simple */
if (!use_locals && !use_2d_reg_block)
{
printf ("Using simplest kernel (myGEMM2)\n");
global_work_size[0] = global_work_size[1] = matrix_size;
local_work_size[0] = local_work_size[1] = local_wg; // TODO
kernel_name = "myGEMM2";
if (use_fma)
strcpy (extra_opts, fma);
}
/* myGEMM4 */
if (use_locals)
{
kernel_name = "myGEMM4";
printf ("Using locals (myGEMM4)\n");
if (is_binary)
{
if (local_wg * local_wg * 8 > local_mem_size)
{
printf ("required local memory exceeds this device's "
"capabilities.\n");
return 0;
}
}
else
{
/* 8 = 2x array: float[local_wg][local_wg] */
while (local_wg * local_wg * 8 > local_mem_size)
local_wg >>= 1;
}
#define WPT (local_wg / 4)
global_work_size[0] = matrix_size;
global_work_size[1] = matrix_size / WPT;
local_work_size[0] = local_wg;
local_work_size[1] = 4;
#undef WPT
snprintf (extra_opts, 1024, "%s-DMYGEMM4 -DLOCAL_SIZE=%u", fma,
local_wg);
printf ("Using local group size: [%u, %u]\n", local_wg, 4);
}
/* myGEMM6 */
if (use_2d_reg_block)
{
kernel_name = "myGEMM6";
printf ("using 2d reg block (myGEMM6)\n");
#define WPT 8
/* const size_t global[2] = { M/WPTM, N/WPTN }; */
/* const size_t local[2] = { TSM/WPTM, TSN/WPTN }; */
global_work_size[0] = global_work_size[1] = matrix_size / WPT;
local_wg >>= 2;
local_work_size[0] = local_work_size[1] = local_wg;
size_t TSM = local_wg * WPT;
size_t TSK = local_wg;
if (is_binary)
{
if ((TSM * TSK * 2 * 4) > local_mem_size)
{
printf ("required local memory exceeds this device's "
"capabilities.\n");
return 0;
}
}
else
{
/* 2 buffers x sizeof(float) * [TSK][TSM] */
while ((TSK < 8) && (TSM * TSK * 2 * 4 < local_mem_size))
TSK <<= 1;
}
snprintf (extra_opts, 1024, "%s-DMYGEMM6 -DTSM=%zu -DTSN=%zu -DTSK=%zu",
fma, TSM, TSM, TSK);
printf ("GLOBAL: [%zu, %zu] LOCAL: [%zu, %zu] TSM/TSN: %zu TSK: %zu\n",
global_work_size[0], global_work_size[1], local_work_size[0],
local_work_size[1], TSM, TSK);
}
/*****************************************************************************/
err = poclu_load_program (context, device, "matrix1", spir, spirv, poclbin,
explicit_binary_path, extra_opts, &program);
if (err != CL_SUCCESS)
goto FINISH;
srcA = (cl_float *)malloc (matrix_2d_size * sizeof (cl_float));
srcB = (cl_float *)malloc (matrix_2d_size * sizeof (cl_float));
dst = (cl_float *)malloc (matrix_2d_size * sizeof (cl_float));
sums = (long *)calloc (matrix_size, sizeof (long));
srandom (time (NULL));
for (i = 0; i < matrix_size; ++i)
{
for (j = 0; j < matrix_size; ++j)
{
long r = random ();
int r1 = (r >> 8) % 64;
int r2 = (r >> 16) % 64;
sums[j] += r2;
long x = i * matrix_size + j;
srcA[x] = (cl_float) (r1);
srcB[x] = (cl_float) (r2);
dst[x] = 0.0f;
}
}
sum = 0;
for (i = 0; i < matrix_size; ++i)
{
for (j = 0; j < matrix_size; ++j)
{
long x = i * matrix_size + j;
long tmp = srcA[x] * sums[i];
sum += tmp;
}
}
printf ("\nExpected sum of all elements: %lu \n", sum);
err = 0;
local_work_size[0] = min (global_work_size[0], local_work_size[0]);
local_work_size[1] = min (global_work_size[1], local_work_size[1]);
if (exec_matrix_kernel (context, device, queue, program, matrix_size, srcA,
srcB, dst, kernel_name, global_work_size,
local_work_size, use_2d_reg_block))
{
printf ("Error running the tests\n");
err = 1;
goto FINISH;
}
long total = 0;
for (i = 0; i < (matrix_2d_size); ++i)
{
if (isnormal (dst[i]))
total += (long)dst[i];
}
printf ("Sum of all elements: %li \n", total);
if (total == sum)
printf ("OK\n");
else
printf ("FAIL\n");
FINISH:
CHECK_CL_ERROR (clReleaseProgram (program));
CHECK_CL_ERROR (clReleaseCommandQueue (queue));
CHECK_CL_ERROR (clReleaseContext (context));
CHECK_CL_ERROR (clUnloadPlatformCompiler (platform));
free (dst);
free (srcA);
free (srcB);
free (sums);
return err;
}
|
921f7c0193963ac7a84c9643275530319205d739
|
5835b9bd44fb6a886b58e3c433b9fee2b28590b3
|
/0322_coin_change/coin_change.c
|
10c8244f3dc59a86ba768ca251b0d82fc629ea3f
|
[
"MIT"
] |
permissive
|
begeekmyfriend/leetcode
|
feef7a21f43a4a3b21756ee5b614f3a31e8af526
|
f88bcf8006a12047bcc045ea25f2a46813baeb53
|
refs/heads/master
| 2023-07-08T10:28:18.623237
| 2023-01-09T11:45:36
| 2023-01-09T11:45:36
| 37,474,686
| 3,346
| 982
|
MIT
| 2021-10-05T16:10:15
| 2015-06-15T15:44:58
|
C
|
UTF-8
|
C
| false
| false
| 954
|
c
|
coin_change.c
|
#include <stdio.h>
#include <stdlib.h>
int coinChange(int* coins, int coinsSize, int amount)
{
int i, j;
int *dp = malloc((amount + 1) * sizeof(int));
for (i = 1; i <= amount; i++) {
/* INT_MAX */
dp[i] = amount + 1;
}
dp[0] = 0;
for (i = 1; i <= amount; i++) {
for (j = 0; j < coinsSize; j++) {
if (i - coins[j] >= 0) {
int tmp = 1 + dp[i - coins[j]];
dp[i] = tmp < dp[i] ? tmp : dp[i];
}
}
}
return dp[amount] == amount + 1 ? -1 : dp[amount];
}
int main(int argc, char **argv)
{
if (argc < 3) {
fprintf(stderr, "Usage: ./test 11 1 2 5");
exit(-1);
}
int amount = atoi(argv[1]);
int i, size = argc - 2;
int *coins = malloc(size * sizeof(int));
for (i = 0; i < size; i++) {
coins[i] = atoi(argv[i + 2]);
}
printf("%d\n", coinChange(coins, size, amount));
return 0;
}
|
c717fa5994d5eeae5358169f6324ff797e1f6ea4
|
992aacbef11c1e6b4ab903a4d59a89ca0a200532
|
/Kernels/Kernel-P01.c
|
cc22c08f031d4b0ad6aa0f134ccd473d7050e110
|
[] |
no_license
|
LegacyNsfw/PcmHacks
|
eb2f61cf9523efdf91f9155e3d464b1c45288f8d
|
292f44f7ed50bd5761a4f1a3616ece256b0f3d61
|
refs/heads/develop
| 2023-08-31T17:33:06.600448
| 2023-08-26T12:01:39
| 2023-08-26T12:01:39
| 120,572,247
| 133
| 75
| null | 2023-09-10T01:16:19
| 2018-02-07T06:20:10
|
C#
|
UTF-8
|
C
| false
| false
| 13,042
|
c
|
Kernel-P01.c
|
///////////////////////////////////////////////////////////////////////////////
// This kernel can read PCM memory and supports uploading a replacement kernel.
///////////////////////////////////////////////////////////////////////////////
#include "common.h"
#include "flash.h"
uint32_t __attribute((section(".kerneldata"))) flashIdentifier;
// This kernel uses Mode 3D extensively, because apparently nothing else does. Submodes are:
//
// 00 - Get kernel version
// 01 - Query flash chip
// 02 - Query CRC
// 03 - unlock flash
// 04 - lock flash
// 05 - erase calibration
// 06 - erase everything? (not until everything else is thoroughly proven)
// FF - send debug info (because I was curious about the stack address)
//
// Writes to flash use mode 35 and mode 36, like writing to RAM.
///////////////////////////////////////////////////////////////////////////////
// Send a success or failure message.
///////////////////////////////////////////////////////////////////////////////
void SendReply(unsigned char success, unsigned char submode, unsigned char code, unsigned char data)
{
MessageBuffer[0] = 0x6C;
MessageBuffer[1] = 0xF0;
MessageBuffer[2] = 0x10;
if (success)
{
MessageBuffer[3] = 0x7D;
MessageBuffer[4] = submode;
MessageBuffer[5] = code;
MessageBuffer[6] = data;
}
else
{
MessageBuffer[3] = 0x7F;
MessageBuffer[4] = 0x3D;
MessageBuffer[5] = submode;
MessageBuffer[6] = code;
MessageBuffer[7] = data;
}
WriteMessage(MessageBuffer, success ? 7 : 8, Complete);
}
///////////////////////////////////////////////////////////////////////////////
// Get the manufacturer and type of flash chip.
///////////////////////////////////////////////////////////////////////////////
void HandleFlashChipQuery()
{
ScratchWatchdog();
// Try the Intel method first
flashIdentifier = Intel_GetFlashId();
ScratchWatchdog();
// If the ID query is unsuccessful, we wont get the Intel ID, so try AMD
if ((flashIdentifier >> 16) != 0x0089)
{
// Try the AMD method next
flashIdentifier = Amd_GetFlashId();
}
ScratchWatchdog();
// The AllPro and ScanTool devices need a short delay to switch from
// sending to receiving. Otherwise they'll miss the response.
VariableSleep(1);
MessageBuffer[0] = 0x6C;
MessageBuffer[1] = 0xF0;
MessageBuffer[2] = 0x10;
MessageBuffer[3] = 0x7D;
MessageBuffer[4] = 0x01;
MessageBuffer[5] = flashIdentifier >> 24;
MessageBuffer[6] = flashIdentifier >> 16;
MessageBuffer[7] = flashIdentifier >> 8;
MessageBuffer[8] = flashIdentifier;
WriteMessage(MessageBuffer, 9, Complete);
}
///////////////////////////////////////////////////////////////////////////////
// The the CRC of a memory range.
// This takes just long enough for the app to time out. So we pause just long
// enough for the reply to come back before the second timeout.
///////////////////////////////////////////////////////////////////////////////
void HandleCrcQuery()
{
unsigned length = (MessageBuffer[5] << 16) + (MessageBuffer[6] << 8) + MessageBuffer[7];
unsigned address = (MessageBuffer[8] << 16) + (MessageBuffer[9] << 8) + MessageBuffer[10];
// Convert to names and types that match the CRC code.
unsigned char *message = (unsigned char*)address;
int nBytes = length;
char path;
if (!crcIsStarted(message, nBytes))
{
path = 1;
crcStart(message, nBytes);
}
else
{
path = 2;
crcProcessSlice();
}
ElmSleep();
if (crcIsDone(message, nBytes))
{
unsigned crc = crcGetResult();
MessageBuffer[0] = 0x6C;
MessageBuffer[1] = 0xF0;
MessageBuffer[2] = 0x10;
MessageBuffer[3] = 0x7D;
MessageBuffer[4] = 0x02;
MessageBuffer[5] = (char)(crcLength >> 16);
MessageBuffer[6] = (char)(crcLength >> 8);
MessageBuffer[7] = (char)crcLength;
MessageBuffer[8] = (char)((uint32_t)crcStartAddress >> 16);
MessageBuffer[9] = (char)((uint32_t)crcStartAddress >> 8);
MessageBuffer[10] = (char)(uint32_t)crcStartAddress;
MessageBuffer[11] = (char)(crc >> 24);
MessageBuffer[12] = (char)(crc >> 16);
MessageBuffer[13] = (char)(crc >> 8);
MessageBuffer[14] = (char)crc;
WriteMessage(MessageBuffer, 15, Complete);
}
else
{
// This is an abuse of the protocol, but I want to keep these
// messages short, and using 7F 3D 02 would make it hard to tell
// whether CRC is in progress or the kernel just isn't loaded.
// So this reply has a legitimate mode, and a bogus submode.
MessageBuffer[0] = 0x6C;
MessageBuffer[1] = 0xF0;
MessageBuffer[2] = 0x10;
MessageBuffer[3] = 0x7D;
MessageBuffer[4] = 0xFF;
MessageBuffer[5] = path;
WriteMessage(MessageBuffer, 6, Complete);
}
}
///////////////////////////////////////////////////////////////////////////////
// Tell the app which OS is installed on this PCM.
//
// It was tempting to just implement the same OS ID query as the PCM software,
// but then the app would need to do a kernel request of some type to determine
// whether the PCM is running the GM OS or the kernel. However, in almost all
// cases, the PCM will be running the GM OS, and that kernel request would slow
// down the most common usage scenario.
//
// So we keep the common scenario fast by having the standard OS ID request
// succeed only when the standard operating system is running. When it fails,
// that puts the app into a slower path were it checks for a kernel and then
// asks the kernel what OS is installed. Or it checks for recovery mode, loads
// the kernel, and then asks the kernel what OS is installed.
///////////////////////////////////////////////////////////////////////////////
void HandleOperatingSystemQuery()
{
ElmSleep();
#if defined P10
uint8_t *osid = (uint8_t*)0x52E;
#elif defined P12
uint8_t *osid = (uint8_t*)0x8004;
#else
uint8_t *osid = (uint8_t*)0x504;
#endif
MessageBuffer[0] = 0x6C;
MessageBuffer[1] = 0xF0;
MessageBuffer[2] = 0x10;
MessageBuffer[3] = 0x7D;
MessageBuffer[4] = 0x03;
MessageBuffer[5] = osid[0];
MessageBuffer[6] = osid[1];
MessageBuffer[7] = osid[2];
MessageBuffer[8] = osid[3];
WriteMessage(MessageBuffer, 9, Complete);
}
///////////////////////////////////////////////////////////////////////////////
// Erase the given block.
///////////////////////////////////////////////////////////////////////////////
void HandleEraseBlock()
{
unsigned address = (MessageBuffer[5] << 16) + (MessageBuffer[6] << 8) + MessageBuffer[7];
uint8_t status = 0;
switch (flashIdentifier)
{
case FLASH_ID_INTEL_28F400B:
case FLASH_ID_INTEL_28F800B:
status = Intel_EraseBlock(address);
break;
case FLASH_ID_AMD_AM29F800BB:
case FLASH_ID_AMD_AM29BL162C:
case FLASH_ID_AMD_AM29BL802C:
status = Amd_EraseBlock(address);
break;
default:
VariableSleep(2);
SendReply(0, 0x05, 0xFF, 0xFF);
return;
}
// The AllPro and ScanTool devices need a short delay to switch from
// sending to receiving. Otherwise they'll miss the response.
// Also, give the lock-flash operation time to take full effect, because
// the signal quality is degraded and the AllPro and ScanTool can't read
// messages when the PCM is in that state.
VariableSleep(2);
SendReply(1, 0x05, status, 0x00);
}
///////////////////////////////////////////////////////////////////////////////
// Erase everything? Nope, not yet.
///////////////////////////////////////////////////////////////////////////////
void HandleEraseEverythingRequest()
{
MessageBuffer[0] = 0x6C;
MessageBuffer[1] = 0xF0;
MessageBuffer[2] = 0x10;
MessageBuffer[3] = 0x7F; // Reject
MessageBuffer[4] = 0x3D;
MessageBuffer[5] = 0x06;
MessageBuffer[6] = 0x00;
WriteMessage(MessageBuffer, 7, Complete);
}
///////////////////////////////////////////////////////////////////////////////
// This is available for arbitrary diagnostic / troubleshooting use.
///////////////////////////////////////////////////////////////////////////////
extern unsigned int *crcTable;
void HandleDebugQuery()
{
uint32_t value = 0x12345678;
MessageBuffer[0] = 0x6C;
MessageBuffer[1] = 0xF0;
MessageBuffer[2] = 0x10;
MessageBuffer[3] = 0x7D;
MessageBuffer[4] = 0xFF;
MessageBuffer[5] = (char)(value >> 24);
MessageBuffer[6] = (char)(value >> 16);
MessageBuffer[7] = (char)(value >> 8);
MessageBuffer[8] = (char)(value >> 0);
WriteMessage(MessageBuffer, 9, Complete);
}
///////////////////////////////////////////////////////////////////////////////
// Write data to flash memory.
// This is invoked by HandleWriteMode36 in common-readwrite.c
// read-kernel.c has a stub to keep the compiler happy until this is released.
///////////////////////////////////////////////////////////////////////////////
unsigned char WriteToFlash(unsigned int payloadLengthInBytes, unsigned int startAddress, unsigned char *payloadBytes, int testWrite)
{
switch (flashIdentifier)
{
case FLASH_ID_INTEL_28F400B:
case FLASH_ID_INTEL_28F800B:
return Intel_WriteToFlash(payloadLengthInBytes, startAddress, payloadBytes, testWrite);
case FLASH_ID_AMD_AM29F800BB:
case FLASH_ID_AMD_AM29BL162C:
case FLASH_ID_AMD_AM29BL802C:
return Amd_WriteToFlash(payloadLengthInBytes, startAddress, payloadBytes, testWrite);
default:
return 0xEE;
}
}
///////////////////////////////////////////////////////////////////////////////
// Process an incoming message.
///////////////////////////////////////////////////////////////////////////////
void ProcessMessage(int iterations)
{
if ((MessageBuffer[1] != 0x10) && (MessageBuffer[1] != 0xFE))
{
// We're not the destination, ignore this message.
return;
}
if (MessageBuffer[2] != 0xF0)
{
// This didn't come from the tool, ignore this message.
return;
}
switch (MessageBuffer[3])
{
case 0x20:
LongSleepWithWatchdog();
Reboot(0xCC000000 | iterations);
break;
case 0x34:
HandleWriteRequestMode34();
ClearBreadcrumbBuffer();
break;
case 0x35:
HandleReadMode35();
break;
case 0x36:
if (MessageBuffer[0] == 0x6D)
{
HandleWriteMode36();
}
break;
case 0x37:
// ReadMode37();
SendToolPresent(0xB2, MessageBuffer[3], 0, 0);
break;
case 0x3D:
switch(MessageBuffer[4])
{
case 0x00:
HandleVersionQuery();
break;
case 0x01:
HandleFlashChipQuery();
break;
case 0x02:
HandleCrcQuery();
break;
case 0x03:
HandleOperatingSystemQuery();
break;
case 0x04:
// This submode is available for future use.
//
// It was originally intended for flash lock (0x03 was for unlock) but that
// creates so much noise on the VPW line that communication stops working.
break;
case 0x05:
HandleEraseBlock();
crcReset();
break;
case 0xFF:
HandleDebugQuery();
break;
default:
SendToolPresent(
0x3D,
MessageBuffer[4],
0,
0);
break;
}
break;
case 0x3F:
// Ignore tool-present messages.
break;
default:
SendToolPresent(
0xAA,
MessageBuffer[2],
MessageBuffer[3],
MessageBuffer[4]);
break;
}
}
///////////////////////////////////////////////////////////////////////////////
// This is the entry point for the kernel.
///////////////////////////////////////////////////////////////////////////////
int
__attribute__((section(".kernelstart")))
KernelStart(void)
{
// Disable peripheral interrupts
asm("ORI #0x700, %SR");
ScratchWatchdog();
DLC_INTERRUPTCONFIGURATION = 0x00;
crcInit();
// Flush the DLC
DLC_TRANSMIT_COMMAND = 0x03;
DLC_TRANSMIT_FIFO = 0x00;
ClearMessageBuffer();
WasteTime();
ScratchWatchdog();
// The factory code jumps into the kernel before sending this message
SendWriteSuccess(0);
// This message proves that the kernel is now running (if you're watching the data bus).
SendToolPresent(1, 2, 3, 4);
LongSleepWithWatchdog();
uint32_t iterations = 0;
uint32_t timeout = 2500; // Timeout of 2500 = 2.2 seconds between messages. 5,000 = 3.9 seconds.
uint32_t lastMessage = (iterations - timeout) + 1;
uint32_t lastActivity = iterations - timeout;
for(;;)
{
iterations++;
ScratchWatchdog();
char completionCode = 0xFF;
char readState = 0xFF;
int length = ReadMessage(&completionCode, &readState);
if (length == 0)
{
if (iterations > (lastActivity + timeout))
{
SendToolPresent(110, 115, 102, 119);
lastActivity = iterations;
}
///////////////////////////////////////////////////////////////////////////////
// For now the plan is to let the kernel run indefinitely, and give the app
// an exit-kernel button. This should give us some flexibility in recovering
// from failed flashes, especially those involving the boot block.
//
// // If no message received for N iterations, reboot.
// if (iterations > (lastMessage + timeout))
// {
// Reboot(0xFFFFFFFF);
// }
continue;
}
if ((completionCode & 0x30) != 0x00)
{
// This is a transmit error. Just ignore it and wait for the tool to retry.
continue;
}
if (readState != 1)
{
SendToolPresent(0xBB, 0xBB, readState, readState);
continue;
}
lastMessage = iterations;
lastActivity = iterations;
ProcessMessage(iterations);
}
// This shouldn't happen. But, just in case...
Reboot(0xFF000000 | iterations);
}
|
0289ad386f741085ee15263ce98ac3a35487efbf
|
b970e053302588f44ee1c6b7187c4769934c857f
|
/ajax/libs/openlayers/5.0.0/style/Style.js
|
27534aefbddd888f1d03fa8c5d22e9163634ade4
|
[
"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
| 13,935
|
js
|
Style.js
|
/**
* @module ol/style/Style
*/
/**
* Feature styles.
*
* If no style is defined, the following default style is used:
* ```js
* import {Fill, Stroke, Circle, Style} from 'ol/style';
*
* var fill = new Fill({
* color: 'rgba(255,255,255,0.4)'
* });
* var stroke = new Stroke({
* color: '#3399CC',
* width: 1.25
* });
* var styles = [
* new Style({
* image: new Circle({
* fill: fill,
* stroke: stroke,
* radius: 5
* }),
* fill: fill,
* stroke: stroke
* })
* ];
* ```
*
* A separate editing style has the following defaults:
* ```js
* import {Fill, Stroke, Circle, Style} from 'ol/style';
* import GeometryType from 'ol/geom/GeometryType';
*
* var white = [255, 255, 255, 1];
* var blue = [0, 153, 255, 1];
* var width = 3;
* styles[GeometryType.POLYGON] = [
* new Style({
* fill: new Fill({
* color: [255, 255, 255, 0.5]
* })
* })
* ];
* styles[GeometryType.MULTI_POLYGON] =
* styles[GeometryType.POLYGON];
* styles[GeometryType.LINE_STRING] = [
* new Style({
* stroke: new Stroke({
* color: white,
* width: width + 2
* })
* }),
* new Style({
* stroke: new Stroke({
* color: blue,
* width: width
* })
* })
* ];
* styles[GeometryType.MULTI_LINE_STRING] =
* styles[GeometryType.LINE_STRING];
* styles[GeometryType.POINT] = [
* new Style({
* image: new Circle({
* radius: width * 2,
* fill: new Fill({
* color: blue
* }),
* stroke: new Stroke({
* color: white,
* width: width / 2
* })
* }),
* zIndex: Infinity
* })
* ];
* styles[GeometryType.MULTI_POINT] =
* styles[GeometryType.POINT];
* styles[GeometryType.GEOMETRY_COLLECTION] =
* styles[GeometryType.POLYGON].concat(
* styles[GeometryType.LINE_STRING],
* styles[GeometryType.POINT]
* );
* ```
*/
import {assert} from '../asserts.js';
import GeometryType from '../geom/GeometryType.js';
import CircleStyle from '../style/Circle.js';
import Fill from '../style/Fill.js';
import Stroke from '../style/Stroke.js';
/**
* A function that takes an {@link module:ol/Feature} and a `{number}`
* representing the view's resolution. The function should return a
* {@link module:ol/style/Style} or an array of them. This way e.g. a
* vector layer can be styled.
*
* @typedef {function((module:ol/Feature|module:ol/render/Feature), number):
* (module:ol/style/Style|Array.<module:ol/style/Style>)} StyleFunction
*/
/**
* A function that takes an {@link module:ol/Feature} as argument and returns an
* {@link module:ol/geom/Geometry} that will be rendered and styled for the feature.
*
* @typedef {function((module:ol/Feature|module:ol/render/Feature)):
* (module:ol/geom/Geometry|module:ol/render/Feature|undefined)} GeometryFunction
*/
/**
* Custom renderer function. Takes two arguments:
*
* 1. The pixel coordinates of the geometry in GeoJSON notation.
* 2. The {@link module:ol/render~State} of the layer renderer.
*
* @typedef {function((module:ol/coordinate~Coordinate|Array<module:ol/coordinate~Coordinate>|Array.<Array.<module:ol/coordinate~Coordinate>>),module:ol/render~State)}
* RenderFunction
*/
/**
* @typedef {Object} Options
* @property {string|module:ol/geom/Geometry|module:ol/style/Style~GeometryFunction} [geometry] Feature property or geometry
* or function returning a geometry to render for this style.
* @property {module:ol/style/Fill} [fill] Fill style.
* @property {module:ol/style/Image} [image] Image style.
* @property {module:ol/style/Style~RenderFunction} [renderer] Custom renderer. When configured, `fill`, `stroke` and `image` will be
* ignored, and the provided function will be called with each render frame for each geometry.
* @property {module:ol/style/Stroke} [stroke] Stroke style.
* @property {module:ol/style/Text} [text] Text style.
* @property {number} [zIndex] Z index.
*/
/**
* @classdesc
* Container for vector feature rendering styles. Any changes made to the style
* or its children through `set*()` methods will not take effect until the
* feature or layer that uses the style is re-rendered.
*
* @constructor
* @struct
* @param {module:ol/style/Style~Options=} opt_options Style options.
* @api
*/
const Style = function(opt_options) {
const options = opt_options || {};
/**
* @private
* @type {string|module:ol/geom/Geometry|module:ol/style/Style~GeometryFunction}
*/
this.geometry_ = null;
/**
* @private
* @type {!module:ol/style/Style~GeometryFunction}
*/
this.geometryFunction_ = defaultGeometryFunction;
if (options.geometry !== undefined) {
this.setGeometry(options.geometry);
}
/**
* @private
* @type {module:ol/style/Fill}
*/
this.fill_ = options.fill !== undefined ? options.fill : null;
/**
* @private
* @type {module:ol/style/Image}
*/
this.image_ = options.image !== undefined ? options.image : null;
/**
* @private
* @type {module:ol/style/Style~RenderFunction|null}
*/
this.renderer_ = options.renderer !== undefined ? options.renderer : null;
/**
* @private
* @type {module:ol/style/Stroke}
*/
this.stroke_ = options.stroke !== undefined ? options.stroke : null;
/**
* @private
* @type {module:ol/style/Text}
*/
this.text_ = options.text !== undefined ? options.text : null;
/**
* @private
* @type {number|undefined}
*/
this.zIndex_ = options.zIndex;
};
/**
* Clones the style.
* @return {module:ol/style/Style} The cloned style.
* @api
*/
Style.prototype.clone = function() {
let geometry = this.getGeometry();
if (geometry && geometry.clone) {
geometry = geometry.clone();
}
return new Style({
geometry: geometry,
fill: this.getFill() ? this.getFill().clone() : undefined,
image: this.getImage() ? this.getImage().clone() : undefined,
stroke: this.getStroke() ? this.getStroke().clone() : undefined,
text: this.getText() ? this.getText().clone() : undefined,
zIndex: this.getZIndex()
});
};
/**
* Get the custom renderer function that was configured with
* {@link #setRenderer} or the `renderer` constructor option.
* @return {module:ol/style/Style~RenderFunction|null} Custom renderer function.
* @api
*/
Style.prototype.getRenderer = function() {
return this.renderer_;
};
/**
* Sets a custom renderer function for this style. When set, `fill`, `stroke`
* and `image` options of the style will be ignored.
* @param {module:ol/style/Style~RenderFunction|null} renderer Custom renderer function.
* @api
*/
Style.prototype.setRenderer = function(renderer) {
this.renderer_ = renderer;
};
/**
* Get the geometry to be rendered.
* @return {string|module:ol/geom/Geometry|module:ol/style/Style~GeometryFunction}
* Feature property or geometry or function that returns the geometry that will
* be rendered with this style.
* @api
*/
Style.prototype.getGeometry = function() {
return this.geometry_;
};
/**
* Get the function used to generate a geometry for rendering.
* @return {!module:ol/style/Style~GeometryFunction} Function that is called with a feature
* and returns the geometry to render instead of the feature's geometry.
* @api
*/
Style.prototype.getGeometryFunction = function() {
return this.geometryFunction_;
};
/**
* Get the fill style.
* @return {module:ol/style/Fill} Fill style.
* @api
*/
Style.prototype.getFill = function() {
return this.fill_;
};
/**
* Set the fill style.
* @param {module:ol/style/Fill} fill Fill style.
* @api
*/
Style.prototype.setFill = function(fill) {
this.fill_ = fill;
};
/**
* Get the image style.
* @return {module:ol/style/Image} Image style.
* @api
*/
Style.prototype.getImage = function() {
return this.image_;
};
/**
* Set the image style.
* @param {module:ol/style/Image} image Image style.
* @api
*/
Style.prototype.setImage = function(image) {
this.image_ = image;
};
/**
* Get the stroke style.
* @return {module:ol/style/Stroke} Stroke style.
* @api
*/
Style.prototype.getStroke = function() {
return this.stroke_;
};
/**
* Set the stroke style.
* @param {module:ol/style/Stroke} stroke Stroke style.
* @api
*/
Style.prototype.setStroke = function(stroke) {
this.stroke_ = stroke;
};
/**
* Get the text style.
* @return {module:ol/style/Text} Text style.
* @api
*/
Style.prototype.getText = function() {
return this.text_;
};
/**
* Set the text style.
* @param {module:ol/style/Text} text Text style.
* @api
*/
Style.prototype.setText = function(text) {
this.text_ = text;
};
/**
* Get the z-index for the style.
* @return {number|undefined} ZIndex.
* @api
*/
Style.prototype.getZIndex = function() {
return this.zIndex_;
};
/**
* Set a geometry that is rendered instead of the feature's geometry.
*
* @param {string|module:ol/geom/Geometry|module:ol/style/Style~GeometryFunction} geometry
* Feature property or geometry or function returning a geometry to render
* for this style.
* @api
*/
Style.prototype.setGeometry = function(geometry) {
if (typeof geometry === 'function') {
this.geometryFunction_ = geometry;
} else if (typeof geometry === 'string') {
this.geometryFunction_ = function(feature) {
return (
/** @type {module:ol/geom/Geometry} */ (feature.get(geometry))
);
};
} else if (!geometry) {
this.geometryFunction_ = defaultGeometryFunction;
} else if (geometry !== undefined) {
this.geometryFunction_ = function() {
return (
/** @type {module:ol/geom/Geometry} */ (geometry)
);
};
}
this.geometry_ = geometry;
};
/**
* Set the z-index.
*
* @param {number|undefined} zIndex ZIndex.
* @api
*/
Style.prototype.setZIndex = function(zIndex) {
this.zIndex_ = zIndex;
};
/**
* Convert the provided object into a style function. Functions passed through
* unchanged. Arrays of module:ol/style/Style or single style objects wrapped in a
* new style function.
* @param {module:ol/style/Style~StyleFunction|Array.<module:ol/style/Style>|module:ol/style/Style} obj
* A style function, a single style, or an array of styles.
* @return {module:ol/style/Style~StyleFunction} A style function.
*/
export function toFunction(obj) {
let styleFunction;
if (typeof obj === 'function') {
styleFunction = obj;
} else {
/**
* @type {Array.<module:ol/style/Style>}
*/
let styles;
if (Array.isArray(obj)) {
styles = obj;
} else {
assert(obj instanceof Style,
41); // Expected an `module:ol/style/Style~Style` or an array of `module:ol/style/Style~Style`
styles = [obj];
}
styleFunction = function() {
return styles;
};
}
return styleFunction;
}
/**
* @type {Array.<module:ol/style/Style>}
*/
let defaultStyles = null;
/**
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature.
* @param {number} resolution Resolution.
* @return {Array.<module:ol/style/Style>} Style.
*/
export function createDefaultStyle(feature, resolution) {
// We don't use an immediately-invoked function
// and a closure so we don't get an error at script evaluation time in
// browsers that do not support Canvas. (module:ol/style/Circle~CircleStyle does
// canvas.getContext('2d') at construction time, which will cause an.error
// in such browsers.)
if (!defaultStyles) {
const fill = new Fill({
color: 'rgba(255,255,255,0.4)'
});
const stroke = new Stroke({
color: '#3399CC',
width: 1.25
});
defaultStyles = [
new Style({
image: new CircleStyle({
fill: fill,
stroke: stroke,
radius: 5
}),
fill: fill,
stroke: stroke
})
];
}
return defaultStyles;
}
/**
* Default styles for editing features.
* @return {Object.<module:ol/geom/GeometryType, Array.<module:ol/style/Style>>} Styles
*/
export function createEditingStyle() {
/** @type {Object.<module:ol/geom/GeometryType, Array.<module:ol/style/Style>>} */
const styles = {};
const white = [255, 255, 255, 1];
const blue = [0, 153, 255, 1];
const width = 3;
styles[GeometryType.POLYGON] = [
new Style({
fill: new Fill({
color: [255, 255, 255, 0.5]
})
})
];
styles[GeometryType.MULTI_POLYGON] =
styles[GeometryType.POLYGON];
styles[GeometryType.LINE_STRING] = [
new Style({
stroke: new Stroke({
color: white,
width: width + 2
})
}),
new Style({
stroke: new Stroke({
color: blue,
width: width
})
})
];
styles[GeometryType.MULTI_LINE_STRING] =
styles[GeometryType.LINE_STRING];
styles[GeometryType.CIRCLE] =
styles[GeometryType.POLYGON].concat(
styles[GeometryType.LINE_STRING]
);
styles[GeometryType.POINT] = [
new Style({
image: new CircleStyle({
radius: width * 2,
fill: new Fill({
color: blue
}),
stroke: new Stroke({
color: white,
width: width / 2
})
}),
zIndex: Infinity
})
];
styles[GeometryType.MULTI_POINT] =
styles[GeometryType.POINT];
styles[GeometryType.GEOMETRY_COLLECTION] =
styles[GeometryType.POLYGON].concat(
styles[GeometryType.LINE_STRING],
styles[GeometryType.POINT]
);
return styles;
}
/**
* Function that is called with a feature and returns its default geometry.
* @param {module:ol/Feature|module:ol/render/Feature} feature Feature to get the geometry for.
* @return {module:ol/geom/Geometry|module:ol/render/Feature|undefined} Geometry to render.
*/
function defaultGeometryFunction(feature) {
return feature.getGeometry();
}
export default Style;
|
297b2ea740cdc7d155dd8ae74ae973c56a2d7d54
|
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
|
/hackathon/zhi/NeuronStudio_zhi/ns-math.h
|
d10d525425e123dcc3b9ce327dc0731700e9ed00
|
[
"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
| 1,126
|
h
|
ns-math.h
|
#ifndef __NS_MATH_H__
#define __NS_MATH_H__
#include <nsconfigure.h>
#include <math/nsaabbox.h>
#include <math/nsaabboxdecls.h>
#include <math/nscircle.h>
#include <math/nscircledecls.h>
#include <math/nsconv.h>
#include <math/nsconvdecls.h>
#include <math/nscube.h>
#include <math/nscubedecls.h>
#include <math/nsdragrect.h>
#include <math/nsdragrectdecls.h>
#include <math/nsfrustum.h>
#include <math/nsfrustumdecls.h>
#include <math/nsinterpolate.h>
#include <math/nsline.h>
#include <math/nslinedecls.h>
#include <math/nsmatrix.h>
#include <math/nsmatrixdecls.h>
#include <math/nsoctree.h>
#include <math/nsplane.h>
#include <math/nsplanedecls.h>
#include <math/nspoint.h>
#include <math/nspointdecls.h>
#include <math/nsprojector.h>
#include <math/nsrandom.h>
#include <math/nsray.h>
#include <math/nsraydecls.h>
#include <math/nssphere.h>
#include <math/nsspheredecls.h>
#include <math/nstriangle.h>
#include <math/nstriangledecls.h>
#include <math/nstuple.h>
#include <math/nstupledecls.h>
#include <math/nsvector.h>
#include <math/nsvectordecls.h>
#endif/* __NS_MATH_H__ */
|
4cbe7ed873d32a6d4fe3a462259b4b8f052ef079
|
2898fa4f2ad766afa0495a837f59fe95daa081a7
|
/examples/c/error-codes/undefined/UB-FD6-bad-static.c
|
1bdea43f7c9ed371d0441e877d2f608fa39b62b8
|
[
"NCSA"
] |
permissive
|
kframework/c-semantics
|
12fcc1b1bf1f7792636d1c37f6f7bb1b89a392b5
|
e6879d14455771aa0cb3e3d201131d4d763a73a2
|
refs/heads/master
| 2023-07-31T23:57:03.316456
| 2022-02-01T17:50:31
| 2022-02-01T17:50:31
| 11,747,541
| 312
| 52
|
NOASSERTION
| 2022-02-01T17:50:33
| 2013-07-29T19:13:25
|
C
|
UTF-8
|
C
| false
| false
| 147
|
c
|
UB-FD6-bad-static.c
|
// Copyright (c) 2015 Runtime Verification, Inc. (RV-Match team). All Rights Reserved.
// kcc-assert-error(00026)
int main(float x, char** y){
}
|
58234c560373d3529db479ddc4d8f5c790f5fe5e
|
58fe7cb3949dd1930e709696659a0296500b64a6
|
/tests/unit/s2n_kex_test.c
|
9013f0323a0cd551d7b837c29abd911bcf554b3d
|
[
"Apache-2.0",
"MIT"
] |
permissive
|
aws/s2n-tls
|
3344638a6a69c6f20665cf6847e1bc4b85f2e558
|
62dc7a6d4876e5eee0dea3690d528a4c7080a1d5
|
refs/heads/main
| 2023-08-31T23:26:33.780048
| 2023-08-31T05:17:33
| 2023-08-31T05:17:33
| 21,287,076
| 513
| 213
|
Apache-2.0
| 2023-09-13T23:52:29
| 2014-06-27T19:37:59
|
C
|
UTF-8
|
C
| false
| false
| 3,220
|
c
|
s2n_kex_test.c
|
/*
* Copyright Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 "tls/s2n_kex.h"
#include "tests/s2n_test.h"
int main(int argc, char **argv)
{
BEGIN_TEST();
EXPECT_SUCCESS(s2n_disable_tls13_in_test());
/* Test safety checks */
{
struct s2n_connection conn = { 0 };
struct s2n_blob blob = { 0 };
struct s2n_kex_raw_server_data test_raw_server_data = { 0 };
struct s2n_cipher_suite test_cipher = s2n_ecdhe_rsa_with_aes_256_cbc_sha;
struct s2n_cipher_suite test_cipher_with_null_kex = test_cipher;
test_cipher_with_null_kex.key_exchange_alg = NULL;
/* Null cipher suite kex - possible with tls1.3 cipher suites */
EXPECT_ERROR(s2n_configure_kex(NULL, &conn));
EXPECT_ERROR(s2n_configure_kex(&test_cipher_with_null_kex, NULL));
/* Null kex -- possible with tls1.3 cipher suites */
bool is_ephemeral = false;
EXPECT_ERROR(s2n_kex_is_ephemeral(NULL, &is_ephemeral));
EXPECT_ERROR(s2n_kex_is_ephemeral(&s2n_rsa, NULL));
EXPECT_ERROR(s2n_kex_server_key_recv_parse_data(NULL, &conn, &test_raw_server_data));
EXPECT_ERROR(s2n_kex_server_key_recv_read_data(NULL, &conn, &blob, &test_raw_server_data));
EXPECT_ERROR(s2n_kex_server_key_send(NULL, &conn, &blob));
EXPECT_ERROR(s2n_kex_client_key_recv(NULL, &conn, &blob));
EXPECT_ERROR(s2n_kex_client_key_send(NULL, &conn, &blob));
EXPECT_ERROR(s2n_kex_tls_prf(NULL, &conn, &blob));
};
/* Test s2n_kex_includes */
{
/* True if same kex */
EXPECT_TRUE(s2n_kex_includes(NULL, NULL));
EXPECT_TRUE(s2n_kex_includes(&s2n_rsa, &s2n_rsa));
EXPECT_TRUE(s2n_kex_includes(&s2n_hybrid_ecdhe_kem, &s2n_hybrid_ecdhe_kem));
/* False if different kex */
EXPECT_FALSE(s2n_kex_includes(&s2n_rsa, &s2n_dhe));
EXPECT_FALSE(s2n_kex_includes(&s2n_kem, &s2n_ecdhe));
/* True if hybrid that contains */
EXPECT_TRUE(s2n_kex_includes(&s2n_hybrid_ecdhe_kem, &s2n_ecdhe));
EXPECT_TRUE(s2n_kex_includes(&s2n_hybrid_ecdhe_kem, &s2n_kem));
/* False if hybrid "contains" relationship reversed */
EXPECT_FALSE(s2n_kex_includes(&s2n_ecdhe, &s2n_hybrid_ecdhe_kem));
EXPECT_FALSE(s2n_kex_includes(&s2n_kem, &s2n_hybrid_ecdhe_kem));
/* False if hybrid that does not contain */
EXPECT_FALSE(s2n_kex_includes(&s2n_hybrid_ecdhe_kem, &s2n_rsa));
EXPECT_FALSE(s2n_kex_includes(&s2n_hybrid_ecdhe_kem, &s2n_dhe));
/* False if one kex null */
EXPECT_FALSE(s2n_kex_includes(&s2n_rsa, NULL));
EXPECT_FALSE(s2n_kex_includes(NULL, &s2n_rsa));
};
END_TEST();
}
|
f7427196d23e2f0914907e8e0f0051a1c549de18
|
0ab34cafb4fce823bdb64588375a5e0320c4d5da
|
/src/profiler/configuration.h
|
52fe89fdaa951830ed924cedc4e843edeaac7608
|
[
"Artistic-2.0",
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain"
] |
permissive
|
MoarVM/MoarVM
|
00eb8de04ef3eb43d8dd108a016a5fbd644f7cb7
|
2f8234c222dea886da28a9e369e34f3cff18ad8a
|
refs/heads/main
| 2023-08-24T03:30:58.906341
| 2023-08-23T03:28:20
| 2023-08-23T03:28:20
| 10,411,154
| 616
| 228
|
NOASSERTION
| 2023-08-23T03:28:33
| 2013-05-31T19:02:30
|
C
|
UTF-8
|
C
| false
| false
| 1,577
|
h
|
configuration.h
|
#define MVM_PROGRAM_ENTRYPOINT_PROFILER_STATIC 0
#define MVM_PROGRAM_ENTRYPOINT_PROFILER_DYNAMIC 1
#define MVM_PROGRAM_ENTRYPOINT_SPESH 2
#define MVM_PROGRAM_ENTRYPOINT_JIT 3
#define MVM_PROGRAM_ENTRYPOINT_HEAPSNAPSHOT 4
#define MVM_PROGRAM_ENTRYPOINT_COUNT 5
#define MVM_CONFPROG_SF_RESULT_TO_BE_DETERMINED 0
#define MVM_CONFPROG_SF_RESULT_NEVER 1
#define MVM_CONFPROG_SF_RESULT_DYNAMIC_SUGGEST_NO 2
#define MVM_CONFPROG_SF_RESULT_DYNAMIC_SUGGEST_YES 3
#define MVM_CONFPROG_SF_RESULT_ALWAYS 4
#define MVM_CONFPROG_HEAPSNAPSHOT_RESULT_NOTHING 0
#define MVM_CONFPROG_HEAPSNAPSHOT_RESULT_SNAPSHOT 1
#define MVM_CONFPROG_HEAPSNAPSHOT_RESULT_STATS 2
#define MVM_CONFPROG_HEAPSNAPSHOT_RESULT_SNAPSHOT_WITH_STATS 3
struct MVMConfigurationProgramEntryPoint {
MVMuint32 offset;
};
struct MVMConfigurationProgram {
MVMuint8 *bytecode;
MVMObject *string_heap;
MVMuint8 *reg_types;
MVMuint16 reg_count;
MVMuint32 bytecode_length;
MVMint16 entrypoints[MVM_PROGRAM_ENTRYPOINT_COUNT];
AO_t return_counts[16];
AO_t last_return_time[16];
AO_t invoke_counts[MVM_PROGRAM_ENTRYPOINT_COUNT];
MVMuint8 debugging_level;
};
MVMuint8 MVM_confprog_has_entrypoint(MVMThreadContext *tc, MVMuint8 entrypoint);
MVMint64 MVM_confprog_run(MVMThreadContext *tc, void *subject, MVMuint8 entrypoint, MVMint64 initial_feature_value);
void MVM_confprog_mark(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMHeapSnapshotState *snapshot);
void MVM_confprog_install(MVMThreadContext *tc, MVMObject *bytecode, MVMObject *string_array, MVMObject *entrypoints);
|
4c0a9539f3bf2550510cd6c786ab58d35f5cb749
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/Vango/v85xx/Libraries/CMSIS/Vango/V85xx/Source/lib_LoadNVR.c
|
d75753b048061d7b6e08197aaa31d58301e13579
|
[
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 19,003
|
c
|
lib_LoadNVR.c
|
/**
******************************************************************************
* @file lib_LoadNVR.c
* @author Application Team
* @version V4.7.0
* @date 2019-12-12
* @brief Load information from NVR.
******************************************************************************
* @attention
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lib_LoadNVR.h"
/**
* @breif Load Analog trim data from NVR manually.
* @note Successful Operation:
* - Load [0x40DC0] or [0x40DD0] to ANA registers(B C D E), return 0.
* Operation failed:
* - return 1.
* @param None
* @retval 0: Function succeeded.
1: Function failed(Checksum error).
*/
uint32_t NVR_LoadANADataManual(void)
{
uint32_t checksum;
uint32_t op_reg;
uint32_t ana_data;
uint32_t key_reg = 0xFFFFFFFF;
/* Get Analog data1 */
ana_data = *NVR_ANA_TRIMDATA1;
op_reg = *NVR_ANA_OPREG1;
/* Calculate checksum1 */
checksum = ~(ana_data + op_reg + key_reg);
/* Compare checksum1 */
if (checksum == (*NVR_ANA_CHECKSUM1))
{
ANA->REGB = (uint8_t)(ana_data);
ANA->REGC = (uint8_t)(ana_data >> 8);
ANA->REGD = (uint8_t)(ana_data >> 16);
ANA->REGE = (uint8_t)(ana_data >> 24);
return 0;
}
/* Get Analog data2 */
ana_data = *NVR_ANA_TRIMDATA2;
op_reg = *NVR_ANA_OPREG2;
/* Calculate checksum2 */
checksum = ~(ana_data + op_reg + key_reg);
/* Compare checksum2 */
if (checksum == (*NVR_ANA_CHECKSUM2))
{
ANA->REGB = (uint8_t)(ana_data);
ANA->REGC = (uint8_t)(ana_data >> 8);
ANA->REGD = (uint8_t)(ana_data >> 16);
ANA->REGE = (uint8_t)(ana_data >> 24);
return 0;
}
else
{
return 1;
}
}
/**
* @breif Get the parameters of ADC voltage measuring.
* @note Voltage(unit:V) = aParameter*ADC_DATA + bParameter
* ADC_DATA: ADC channel original data
* aParameter/bParameter: Get from this function
* @param [in]Mode:
* NVR_3V_EXTERNAL_NODIV
* NVR_3V_EXTERNAL_RESDIV
* NVR_3V_EXTERNAL_CAPDIV
* NVR_3V_VDD_RESDIV
* NVR_3V_VDD_CAPDIV
* NVR_3V_BATRTC_RESDIV
* NVR_3V_BATRTC_CAPDIV
* NVR_5V_EXTERNAL_NODIV
* NVR_5V_EXTERNAL_RESDIV
* NVR_5V_EXTERNAL_CAPDIV
* NVR_5V_VDD_RESDIV
* NVR_5V_VDD_CAPDIV
* NVR_5V_BATRTC_RESDIV
* NVR_5V_BATRTC_CAPDIV
* @param [out]Parameter: The parameters get from NVR
* @retval 0: Function succeeded.
1: Function failed(Checksum error).
*/
uint32_t NVR_GetADCVoltageParameter(uint32_t Mode, NVR_ADCVOLPARA *Parameter)
{
uint32_t checksum;
uint32_t i;
int32_t tmp_int;
/* Check the parameters */
assert_parameters(IS_NVR_ADCVOL_MODE(Mode));
/*----- Power supply: 5V -----*/
if (0x100UL & Mode)
{
checksum = 0UL;
for (i=0; i<14; i++)
checksum += *(NVR_5VPARA_BASEADDR1+i);
checksum = ~(checksum);
if (checksum != *(NVR_5VPARA_BASEADDR1+i)) /* Checksum1 error */
{
checksum = 0UL;
for (i=0; i<14; i++)
checksum += *(NVR_5VPARA_BASEADDR2+i);
checksum = ~(checksum);
if (checksum != *(NVR_5VPARA_BASEADDR2+i)) /* Checksum2 error */
{
return 1;
}
else
{
tmp_int = (int32_t)*(NVR_5VPARA_BASEADDR2+2*(Mode-0x100UL));
Parameter->aParameter = (float)(tmp_int / 100000000.0);
tmp_int = (int32_t)*(NVR_5VPARA_BASEADDR2+2*(Mode-0x100UL)+1);
Parameter->bParameter = (float)(tmp_int / 100000000.0);
return 0;
}
}
else
{
tmp_int = (int32_t)*(NVR_5VPARA_BASEADDR1+2*(Mode-0x100UL));
Parameter->aParameter = (float)(tmp_int / 100000000.0);
tmp_int = (int32_t)*(NVR_5VPARA_BASEADDR1+2*(Mode-0x100UL)+1);
Parameter->bParameter = (float)(tmp_int / 100000000.0);
return 0;
}
}
/*----- Power supply: 3.3V -----*/
else
{
checksum = 0UL;
for (i=0; i<14; i++)
checksum += *(NVR_3VPARA_BASEADDR1+i);
checksum = ~(checksum);
if (checksum != *(NVR_3VPARA_BASEADDR1+i)) /* Checksum1 error */
{
checksum = 0UL;
for (i=0; i<14; i++)
checksum += *(NVR_3VPARA_BASEADDR2+i);
checksum = ~(checksum);
if (checksum != *(NVR_3VPARA_BASEADDR2+i)) /* Checksum2 error */
{
return 1;
}
else
{
tmp_int = (int32_t)*(NVR_3VPARA_BASEADDR2+2*(Mode));
Parameter->aParameter = (float)(tmp_int / 100000000.0);
tmp_int = (int32_t)*(NVR_3VPARA_BASEADDR2+2*(Mode)+1);
Parameter->bParameter = (float)(tmp_int / 100000000.0);
return 0;
}
}
else
{
tmp_int = (int32_t)*(NVR_3VPARA_BASEADDR1+2*(Mode));
Parameter->aParameter = (float)(tmp_int / 100000000.0);
tmp_int = (int32_t)*(NVR_3VPARA_BASEADDR1+2*(Mode)+1);
Parameter->bParameter = (float)(tmp_int / 100000000.0);
return 0;
}
}
}
/**
* @breif Get BAT Measure result.
* @param [out]MEAResult The pointer to struct NVR_BATMEARES.
* @retval 0: Function succeeded.
1: Function failed(Checksum error).
*/
uint32_t NVR_GetBATOffset(NVR_BATMEARES *MEAResult)
{
uint32_t bat_r;
uint32_t bat_c;
uint32_t checksum;
bat_r = *NVR_BAT_R1;
bat_c = *NVR_BAT_C1;
/* Calculate checksum1 */
checksum = ~(bat_r + bat_c);
if (checksum == (*NVR_BATMEA_CHECHSUM1))
{
MEAResult->BATRESResult = (float)((int32_t)bat_r / 1000.0);
MEAResult->BATCAPResult = (float)((int32_t)bat_c / 1000.0);
return 0;
}
bat_r = *NVR_BAT_R2;
bat_c = *NVR_BAT_C2;
/* Calculate checksum2 */
checksum = ~(bat_r + bat_c);
if (checksum == (*NVR_BATMEA_CHECHSUM2))
{
MEAResult->BATRESResult = (float)((int32_t)bat_r / 1000.0);
MEAResult->BATCAPResult = (float)((int32_t)bat_c / 1000.0);
return 0;
}
else
{
return 1;
}
}
/**
* @breif Load RTC ACPx pramameters from NVR to RTC registers.
Get RTC pramameters.
* @param [out]RTCTempData The pointer to struct NVR_RTCINFO.
* @retval 0: Function succeeded.
!0: Function not succeeded, load default value to registers.
bit[0]=1: Temperature Measure delta information checksum error, default value is 0.
bit[1]=1: P paramters checksum error, default value as follows
[P0]-214, [P1]1060, [P2]-19746971, [P5]6444, [P6]1342, [P7]0
bit[2]=1: P4 checksum error, default value is 0
bit[3]=1: ACKx checksum error, default value as follows
[K1]20827, [K2]21496, [K3]22020, [K4]24517, [K5]25257
bit[4]=1: ACTI checksum error, default value is 0x1800(24.0)
bit[5]=1: ACKTEMP checksum error, defalut value is 0x3C2800EC
*/
uint32_t NVR_GetInfo_LoadRTCData(NVR_RTCINFO *RTCTempData)
{
uint32_t real_temp, mea_temp;
uint32_t rtc_data1, rtc_data2, rtc_data3, rtc_data4;
uint32_t rtc_p4;
uint32_t rtc_ack[5];
uint32_t rtc_acti;
uint32_t rtc_acktemp;
uint32_t checksum;
float pclk_mul;
int16_t TempDelta;
uint32_t retval = 0;
/*------------------------ Temperature Measure delta -------------------------*/
real_temp = *NVR_REALTEMP1;
mea_temp = *NVR_MEATEMP1;
/* Calculate checksum1 */
checksum = ~(real_temp + mea_temp);
if (checksum == (*NVR_TEMP_CHECKSUM1)) //checksum1 true
{
TempDelta = (int16_t)real_temp - (int16_t)mea_temp;
}
else
{
real_temp = *NVR_REALTEMP2;
mea_temp = *NVR_MEATEMP2;
/* Calculate checksum2 */
checksum = ~(real_temp + mea_temp);
if (checksum == (*NVR_TEMP_CHECKSUM2)) //checksum2 true
{
TempDelta = (int16_t)real_temp - (int16_t)mea_temp;
}
else
{
TempDelta = 0;
retval |= BIT0;
}
}
/* Get Measure delta information */
RTCTempData->RTCTempDelta = TempDelta;
/*------------------------------ P parameters --------------------------------*/
/* Wait until the RTC registers be synchronized */
RTC_WaitForSynchro();
/* Disable RTC Registers write-protection */
RTC_WriteProtection(DISABLE);
/* Get PCLK */
RTCTempData->APBClock = CLK_GetPCLKFreq();
pclk_mul = RTCTempData->APBClock / 6553600.0;
rtc_data1 = *NVR_RTC1_P1_P0;
rtc_data2 = *NVR_RTC1_P2;
rtc_data3 = *NVR_RTC1_P5_P4;
rtc_data4 = *NVR_RTC1_P7_P6;
/* Calculate checksum1 */
checksum = ~(rtc_data1 + rtc_data2 + rtc_data3 + rtc_data4);
if (checksum == (*NVR_RTC1_PCHECHSUM)) //checksum1 true
{
/* Get information */
RTCTempData->RTCTempP0 = (int16_t)(rtc_data1);
RTCTempData->RTCTempP1 = (int16_t)(rtc_data1 >> 16);
RTCTempData->RTCTempP2 = (int32_t)((int32_t)rtc_data2 + (((int32_t)TempDelta)*256));
RTCTempData->RTCTempP5 = (int16_t)(rtc_data3 >> 16);
RTCTempData->RTCTempP6 = (int16_t)(rtc_data4 * pclk_mul);
RTCTempData->RTCTempP7 = (int16_t)(rtc_data4 >> 16);
/* Load data to ACPx register */
RTC->ACP0 = (uint16_t)(rtc_data1 & 0xFFFF);
RTC->ACP1 = (uint16_t)((rtc_data1 >> 16) & 0xFFFF);
RTC->ACP2 = (uint32_t)((int32_t)rtc_data2 + (((int32_t)TempDelta)*256));
RTC->ACP5 = (uint16_t)((rtc_data3 >> 16) & 0xFFFF);
RTC->ACP6 = (uint16_t)((int16_t)(rtc_data4 * pclk_mul));
RTC->ACP7 = (uint16_t)((rtc_data4 >> 16) & 0xFFFF);
}
else
{
rtc_data1 = *NVR_RTC2_P1_P0;
rtc_data2 = *NVR_RTC2_P2;
rtc_data3 = *NVR_RTC2_P5_P4;
rtc_data4 = *NVR_RTC2_P7_P6;
/* Calculate checksum2 */
checksum = ~(rtc_data1 + rtc_data2 + rtc_data3 + rtc_data4);
if (checksum == (*NVR_RTC2_PCHECHSUM)) //checksum2 true
{
/* Get information */
RTCTempData->RTCTempP0 = (int16_t)(rtc_data1);
RTCTempData->RTCTempP1 = (int16_t)(rtc_data1 >> 16);
RTCTempData->RTCTempP2 = (int32_t)((int32_t)rtc_data2 + (((int32_t)TempDelta)*256));
RTCTempData->RTCTempP5 = (int16_t)(rtc_data3 >> 16);
RTCTempData->RTCTempP6 = (int16_t)(rtc_data4 * pclk_mul);
RTCTempData->RTCTempP7 = (int16_t)(rtc_data4 >> 16);
/* Load data to ACPx register */
RTC->ACP0 = (uint16_t)(rtc_data1 & 0xFFFF);
RTC->ACP1 = (uint16_t)((rtc_data1 >> 16) & 0xFFFF);
RTC->ACP2 = (uint32_t)((int32_t)rtc_data2 + (((int32_t)TempDelta)*256));
RTC->ACP5 = (uint16_t)((rtc_data3 >> 16) & 0xFFFF);
RTC->ACP6 = (uint16_t)((int16_t)(rtc_data4 * pclk_mul));
RTC->ACP7 = (uint16_t)((rtc_data4 >> 16) & 0xFFFF);
}
else
{
/* Get information */
RTCTempData->RTCTempP0 = -214;
RTCTempData->RTCTempP1 = 1060;
RTCTempData->RTCTempP2 = -19746971 + (TempDelta*256);
RTCTempData->RTCTempP5 = 6444;
RTCTempData->RTCTempP6 = (uint32_t)((int32_t)(1342*pclk_mul));
RTCTempData->RTCTempP7 = 0;
/* Load data to ACPx register */
RTC->ACP0 = (uint16_t)(-214);
RTC->ACP1 = (uint16_t)(1060);
RTC->ACP2 = (uint32_t)(-19746971 + (TempDelta*256));
RTC->ACP5 = (uint16_t)(6444);
RTC->ACP6 = (uint16_t)((int32_t)(1342*pclk_mul));
RTC->ACP7 = (uint16_t)(0);
retval |= BIT1;
}
}
/*----------------------------------- P4 -------------------------------------*/
/* Calculate checksum1 */
rtc_p4 = *NVR_RTC1_P4;
checksum = ~rtc_p4;
if (checksum == (*NVR_RTC1_P4_CHKSUM))//checksum1 true
{
/* Get information */
RTCTempData->RTCTempP4 = (int16_t)(*NVR_RTC1_P4);
RTC->ACP4 = *NVR_RTC1_P4;
}
else
{
rtc_p4 = *NVR_RTC2_P4;
checksum = ~rtc_p4;
if (checksum == (*NVR_RTC2_P4_CHKSUM))//checksum2 true
{
/* Get information */
RTCTempData->RTCTempP4 = (int16_t)(*NVR_RTC1_P4);
RTC->ACP4 = *NVR_RTC1_P4;
}
else
{
RTCTempData->RTCTempP4 = 0;
RTC->ACP4 = 0;
retval |= BIT2;
}
}
/*-------------------------- RTC ACKx parameters -----------------------------*/
rtc_ack[0] = *NVR_RTC1_ACK1;
rtc_ack[1] = *NVR_RTC1_ACK2;
rtc_ack[2] = *NVR_RTC1_ACK3;
rtc_ack[3] = *NVR_RTC1_ACK4;
rtc_ack[4] = *NVR_RTC1_ACK5;
checksum = ~(rtc_ack[0] + rtc_ack[1] + rtc_ack[2] + rtc_ack[3] + rtc_ack[4]);
if (checksum == (*NVR_RTC1_ACK_CHKSUM))//checksum1 true
{
/* Get information */
RTCTempData->RTCTempK1 = rtc_ack[0];
RTCTempData->RTCTempK2 = rtc_ack[1];
RTCTempData->RTCTempK3 = rtc_ack[2];
RTCTempData->RTCTempK4 = rtc_ack[3];
RTCTempData->RTCTempK5 = rtc_ack[4];
/* Load data to ACKx register */
RTC->ACK1 = rtc_ack[0];
RTC->ACK2 = rtc_ack[1];
RTC->ACK3 = rtc_ack[2];
RTC->ACK4 = rtc_ack[3];
RTC->ACK5 = rtc_ack[4];
}
else
{
rtc_ack[0] = *NVR_RTC2_ACK1;
rtc_ack[1] = *NVR_RTC2_ACK2;
rtc_ack[2] = *NVR_RTC2_ACK3;
rtc_ack[3] = *NVR_RTC2_ACK4;
rtc_ack[4] = *NVR_RTC2_ACK5;
checksum = ~(rtc_ack[0] + rtc_ack[1] + rtc_ack[2] + rtc_ack[3] + rtc_ack[4]);
if (checksum == (*NVR_RTC2_ACK_CHKSUM))//checksum2 true
{
/* Get information */
RTCTempData->RTCTempK1 = rtc_ack[0];
RTCTempData->RTCTempK2 = rtc_ack[1];
RTCTempData->RTCTempK3 = rtc_ack[2];
RTCTempData->RTCTempK4 = rtc_ack[3];
RTCTempData->RTCTempK5 = rtc_ack[4];
/* Load data to ACKx register */
RTC->ACK1 = rtc_ack[0];
RTC->ACK2 = rtc_ack[1];
RTC->ACK3 = rtc_ack[2];
RTC->ACK4 = rtc_ack[3];
RTC->ACK5 = rtc_ack[4];
}
else
{
/* Get information */
RTCTempData->RTCTempK1 = 20827;
RTCTempData->RTCTempK2 = 21496;
RTCTempData->RTCTempK3 = 22020;
RTCTempData->RTCTempK4 = 24517;
RTCTempData->RTCTempK5 = 25257;
/* Load data to ACKx register */
RTC->ACK1 = 20827;
RTC->ACK2 = 21496;
RTC->ACK3 = 22020;
RTC->ACK4 = 24517;
RTC->ACK5 = 25257;
retval |= BIT3;
}
}
/*-------------------------- RTC ACTI parameters -----------------------------*/
rtc_acti = *NVR_RTC1_ACTI;
checksum = ~rtc_acti;
if (checksum == (*NVR_RTC1_ACTI_CHKSUM))
{
/* Get information */
RTCTempData->RTCACTI = rtc_acti;
/* Load data to ACKx register */
RTC->ACTI = rtc_acti;
}
else
{
rtc_acti = *NVR_RTC2_ACTI;
checksum = ~rtc_acti;
if (checksum == (*NVR_RTC2_ACTI_CHKSUM))
{
/* Get information */
RTCTempData->RTCACTI = rtc_acti;
/* Load data to ACKx register */
RTC->ACTI = rtc_acti;
}
else
{
/* Get information */
RTCTempData->RTCACTI = 0x1800;
RTC->ACTI = 0x1800;
retval |= BIT4;
}
}
/*------------------------- RTC ACKTemp parameters ---------------------------*/
rtc_acktemp = *NVR_RTC1_ACKTEMP;
checksum = ~rtc_acktemp;
if (checksum == (*NVR_RTC1_ACKTEMP_CHKSUM))
{
/* Get information */
RTCTempData->RTCACKTemp = rtc_acktemp;
/* Load data to ACKx register */
RTC->ACKTEMP = rtc_acktemp;
}
else
{
rtc_acktemp = *NVR_RTC2_ACKTEMP;
checksum = ~rtc_acktemp;
if (checksum == (*NVR_RTC2_ACKTEMP_CHKSUM))
{
/* Get information */
RTCTempData->RTCACKTemp = rtc_acktemp;
/* Load data to ACKx register */
RTC->ACKTEMP = rtc_acktemp;
}
else
{
/* Get information */
RTCTempData->RTCACKTemp = 0x3C2800EC;
RTC->ACKTEMP = 0x3C2800EC;
retval |= BIT5;
}
}
/*--------------------------------- ACF200 -----------------------------------*/
RTCTempData->RTCACF200 = (uint32_t)((int32_t)(pclk_mul*0x320000));
RTC->ACF200 = (uint32_t)((int32_t)(pclk_mul*0x320000));
/* Enable RTC Registers write-protection */
RTC_WriteProtection(ENABLE);
/* Wait until the RTC registers be synchronized */
RTC_WaitForSynchro();
return retval;
}
/**
* @breif Get Power/Clock Measure result.
* @param [out]MEAResult The pointer to struct NVR_PWRMEARES.
* @retval 0: Function succeeded.
1: Function failed(Checksum error).
*/
uint32_t NVR_GetMISCGain(NVR_MISCGain *MEAResult)
{
uint32_t avcc_data, dvcc_data, bgp_data, rcl_data, rch_data;
uint32_t checksum;
avcc_data = *NVR_AVCC_MEA1;
dvcc_data = *NVR_DVCC_MEA1;
bgp_data = *NVR_BGP_MEA1;
rcl_data = *NVR_RCL_MEA1;
rch_data = *NVR_RCH_MEA1;
/* Calculate checksum1 */
checksum = ~(avcc_data + dvcc_data + bgp_data + rcl_data + rch_data);
if (checksum == (*NVR_PWR_CHECKSUM1))
{
MEAResult->AVCCMEAResult = avcc_data;
MEAResult->DVCCMEAResult = dvcc_data;
MEAResult->BGPMEAResult = bgp_data;
MEAResult->RCLMEAResult = rcl_data;
MEAResult->RCHMEAResult = rch_data;
return 0;
}
avcc_data = *NVR_AVCC_MEA2;
dvcc_data = *NVR_DVCC_MEA2;
bgp_data = *NVR_BGP_MEA2;
rcl_data = *NVR_RCL_MEA2;
rch_data = *NVR_RCH_MEA2;
/* Calculate checksum2 */
checksum = ~(avcc_data + dvcc_data + bgp_data + rcl_data + rch_data);
if (checksum == (*NVR_PWR_CHECKSUM2))
{
MEAResult->AVCCMEAResult = avcc_data;
MEAResult->DVCCMEAResult = dvcc_data;
MEAResult->BGPMEAResult = bgp_data;
MEAResult->RCLMEAResult = rcl_data;
MEAResult->RCHMEAResult = rch_data;
return 0;
}
else
{
return 1;
}
}
/**
* @breif Get Chip ID.
* @param [out]ChipID The pointer to struct NVR_CHIPID.
* @retval 0: Function succeeded.
1: Function failed(Checksum error).
*/
uint32_t NVR_GetChipID(NVR_CHIPID *ChipID)
{
uint32_t id0, id1;
uint32_t checksum;
id0 = *NVR_CHIP1_ID0;
id1 = *NVR_CHIP1_ID1;
/* Calculate checksum1 */
checksum = ~(id0 + id1);
if (checksum == (*NVR_CHIP1_CHECKSUM))
{
ChipID->ChipID0 = id0;
ChipID->ChipID1 = id1;
return 0;
}
id0 = *NVR_CHIP2_ID0;
id1 = *NVR_CHIP2_ID1;
/* Calculate checksum2 */
checksum = ~(id0 + id1);
if (checksum == (*NVR_CHIP2_CHECKSUM))
{
ChipID->ChipID0 = id0;
ChipID->ChipID1 = id1;
return 0;
}
else
{
return 1;
}
}
/**
* @breif Get LCD information.
* @param [out]LCDInfo The pointer to struct NVR_LCDINFO.
* @retval 0: Function succeeded.
1: Function failed(Checksum error).
*/
uint32_t NVR_GetLCDInfo(NVR_LCDINFO *LCDInfo)
{
uint32_t lcd_ldo, lcd_vol;
uint32_t checksum;
lcd_ldo = *NVR_LCD_LDO1;
lcd_vol = *NVR_LCD_VOL1;
/* Calculate checksum1 */
checksum = ~(lcd_ldo + lcd_vol);
if (checksum == (*NVR_LCD_CHECKSUM1))
{
LCDInfo->MEALCDLDO = lcd_ldo;
LCDInfo->MEALCDVol = lcd_vol;
return 0;
}
lcd_ldo = *NVR_LCD_LDO2;
lcd_vol = *NVR_LCD_VOL2;
/* Calculate checksum2 */
checksum = ~(lcd_ldo + lcd_vol);
if (checksum == (*NVR_LCD_CHECKSUM2))
{
LCDInfo->MEALCDLDO = lcd_ldo;
LCDInfo->MEALCDVol = lcd_vol;
return 0;
}
else
{
return 1;
}
}
/*********************************** END OF FILE ******************************/
|
7d6a26f8fadf02d09f78b7d03142ff6bee8b98dd
|
e1cddfd754d952134e72dfd03522c5ea4fb6008e
|
/src/plugins/lisp/lisp-cp/gid_dictionary.c
|
a0cc9c09e3c1ff65243608111fd3632aa05ec1cc
|
[
"Apache-2.0"
] |
permissive
|
FDio/vpp
|
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
|
f234b0d4626d7e686422cc9dfd25958584f4931e
|
refs/heads/master
| 2023-08-31T16:09:04.068646
| 2022-03-14T09:49:15
| 2023-08-31T09:50:00
| 96,556,718
| 1,048
| 630
|
Apache-2.0
| 2023-06-21T05:39:17
| 2017-07-07T16:29:40
|
C
|
UTF-8
|
C
| false
| false
| 27,815
|
c
|
gid_dictionary.c
|
/*
* Copyright (c) 2016 Cisco and/or its affiliates.
* 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 <lisp/lisp-cp/gid_dictionary.h>
typedef struct
{
void *arg;
ip_prefix_t src;
foreach_subprefix_match_cb_t cb;
union
{
gid_ip4_table_t *ip4_table;
gid_ip6_table_t *ip6_table;
};
} sfib_entry_arg_t;
static u32 ip4_lookup (gid_ip4_table_t * db, u32 vni, ip_prefix_t * key);
static u32 ip6_lookup (gid_ip6_table_t * db, u32 vni, ip_prefix_t * key);
static int
foreach_sfib4_subprefix (BVT (clib_bihash_kv) * kvp, void *arg)
{
sfib_entry_arg_t *a = arg;
u32 ip = (u32) kvp->key[0];
ip4_address_t *mask;
u8 plen = ip_prefix_len (&a->src);
ASSERT (plen <= 32);
mask = &a->ip4_table->ip4_fib_masks[plen];
u32 src_ip = ip_prefix_v4 (&a->src).as_u32;
src_ip &= mask->as_u32;
ip &= mask->as_u32;
if (src_ip == ip)
{
/* found sub-prefix of src prefix */
(a->cb) (kvp->value, a->arg);
}
return (BIHASH_WALK_CONTINUE);
}
static void
gid_dict_foreach_ip4_subprefix (gid_dictionary_t * db, u32 vni,
ip_prefix_t * src, ip_prefix_t * dst,
foreach_subprefix_match_cb_t cb, void *arg)
{
u32 sfi;
gid_ip4_table_t *sfib4;
sfib_entry_arg_t a;
sfi = ip4_lookup (&db->dst_ip4_table, vni, dst);
if (GID_LOOKUP_MISS == sfi)
return;
sfib4 = pool_elt_at_index (db->src_ip4_table_pool, sfi);
a.arg = arg;
a.cb = cb;
a.src = src[0];
a.ip4_table = sfib4;
BV (clib_bihash_foreach_key_value_pair) (&sfib4->ip4_lookup_table,
foreach_sfib4_subprefix, &a);
}
static int
foreach_sfib6_subprefix (BVT (clib_bihash_kv) * kvp, void *arg)
{
sfib_entry_arg_t *a = arg;
ip6_address_t ip;
ip6_address_t *mask;
u8 plen = ip_prefix_len (&a->src);
mask = &a->ip6_table->ip6_fib_masks[plen];
ip.as_u64[0] = kvp->key[0];
ip.as_u64[1] = kvp->key[1];
if (ip6_address_is_equal_masked (&ip_prefix_v6 (&a->src), &ip, mask))
{
/* found sub-prefix of src prefix */
(a->cb) (kvp->value, a->arg);
}
return (BIHASH_WALK_CONTINUE);
}
static void
gid_dict_foreach_ip6_subprefix (gid_dictionary_t * db, u32 vni,
ip_prefix_t * src, ip_prefix_t * dst,
foreach_subprefix_match_cb_t cb, void *arg)
{
u32 sfi;
gid_ip6_table_t *sfib6;
sfib_entry_arg_t a;
sfi = ip6_lookup (&db->dst_ip6_table, vni, dst);
if (GID_LOOKUP_MISS == sfi)
return;
sfib6 = pool_elt_at_index (db->src_ip6_table_pool, sfi);
a.arg = arg;
a.cb = cb;
a.src = src[0];
a.ip6_table = sfib6;
BV (clib_bihash_foreach_key_value_pair) (&sfib6->ip6_lookup_table,
foreach_sfib6_subprefix, &a);
}
void
gid_dict_foreach_subprefix (gid_dictionary_t * db, gid_address_t * eid,
foreach_subprefix_match_cb_t cb, void *arg)
{
ip_prefix_t *ippref = &gid_address_sd_dst_ippref (eid);
if (AF_IP4 == ip_prefix_version (ippref))
gid_dict_foreach_ip4_subprefix (db, gid_address_vni (eid),
&gid_address_sd_src_ippref (eid),
&gid_address_sd_dst_ippref (eid), cb,
arg);
else
gid_dict_foreach_ip6_subprefix (db, gid_address_vni (eid),
&gid_address_sd_src_ippref (eid),
&gid_address_sd_dst_ippref (eid), cb,
arg);
}
void
gid_dict_foreach_l2_arp_ndp_entry (gid_dictionary_t * db,
BV (clib_bihash_foreach_key_value_pair_cb)
cb, void *ht)
{
gid_l2_arp_ndp_table_t *tab = &db->arp_ndp_table;
BV (clib_bihash_foreach_key_value_pair) (&tab->arp_ndp_lookup_table, cb,
ht);
}
static void
make_mac_sd_key (BVT (clib_bihash_kv) * kv, u32 vni, u8 src_mac[6],
u8 dst_mac[6])
{
kv->key[0] = (u64) vni;
kv->key[1] = mac_to_u64 (dst_mac);
kv->key[2] = src_mac ? mac_to_u64 (src_mac) : (u64) 0;
}
static u32
mac_sd_lookup (gid_mac_table_t * db, u32 vni, u8 * dst, u8 * src)
{
int rv;
BVT (clib_bihash_kv) kv, value;
make_mac_sd_key (&kv, vni, src, dst);
rv = BV (clib_bihash_search_inline_2) (&db->mac_lookup_table, &kv, &value);
/* no match, try with src 0, catch all for dst */
if (rv != 0)
{
kv.key[2] = 0;
rv = BV (clib_bihash_search_inline_2) (&db->mac_lookup_table, &kv,
&value);
if (rv == 0)
return value.value;
}
else
return value.value;
return GID_LOOKUP_MISS;
}
static u32
ip4_lookup_exact_match (gid_ip4_table_t * db, u32 vni, ip_prefix_t * key)
{
int rv;
BVT (clib_bihash_kv) kv, value;
ip4_address_t *mask;
mask = &db->ip4_fib_masks[ip_prefix_len (key)];
kv.key[0] = ((u64) vni << 32) | (ip_prefix_v4 (key).as_u32 & mask->as_u32);
kv.key[1] = 0;
kv.key[2] = 0;
rv = BV (clib_bihash_search_inline_2) (&db->ip4_lookup_table, &kv, &value);
if (rv == 0)
return value.value;
return GID_LOOKUP_MISS;
}
static u32
ip4_lookup (gid_ip4_table_t * db, u32 vni, ip_prefix_t * key)
{
int i, len;
int rv;
BVT (clib_bihash_kv) kv, value;
len = vec_len (db->ip4_prefix_lengths_in_search_order);
for (i = 0; i < len; i++)
{
int dst_address_length = db->ip4_prefix_lengths_in_search_order[i];
ip4_address_t *mask;
ASSERT (dst_address_length >= 0 && dst_address_length <= 32);
mask = &db->ip4_fib_masks[dst_address_length];
kv.key[0] =
((u64) vni << 32) | (ip_prefix_v4 (key).as_u32 & mask->as_u32);
kv.key[1] = 0;
kv.key[2] = 0;
rv =
BV (clib_bihash_search_inline_2) (&db->ip4_lookup_table, &kv, &value);
if (rv == 0)
return value.value;
}
return GID_LOOKUP_MISS;
}
static u32
ip6_lookup_exact_match (gid_ip6_table_t * db, u32 vni, ip_prefix_t * key)
{
int rv;
BVT (clib_bihash_kv) kv, value;
ip6_address_t *mask;
mask = &db->ip6_fib_masks[ip_prefix_len (key)];
kv.key[0] = ip_prefix_v6 (key).as_u64[0] & mask->as_u64[0];
kv.key[1] = ip_prefix_v6 (key).as_u64[1] & mask->as_u64[1];
kv.key[2] = (u64) vni;
rv = BV (clib_bihash_search_inline_2) (&db->ip6_lookup_table, &kv, &value);
if (rv == 0)
return value.value;
return GID_LOOKUP_MISS;
}
static u32
ip6_lookup (gid_ip6_table_t * db, u32 vni, ip_prefix_t * key)
{
int i, len;
int rv;
BVT (clib_bihash_kv) kv, value;
len = vec_len (db->ip6_prefix_lengths_in_search_order);
for (i = 0; i < len; i++)
{
int dst_address_length = db->ip6_prefix_lengths_in_search_order[i];
ip6_address_t *mask;
ASSERT (dst_address_length >= 0 && dst_address_length <= 128);
mask = &db->ip6_fib_masks[dst_address_length];
kv.key[0] = ip_prefix_v6 (key).as_u64[0] & mask->as_u64[0];
kv.key[1] = ip_prefix_v6 (key).as_u64[1] & mask->as_u64[1];
kv.key[2] = (u64) vni;
rv =
BV (clib_bihash_search_inline_2) (&db->ip6_lookup_table, &kv, &value);
if (rv == 0)
return value.value;
}
return GID_LOOKUP_MISS;
}
static u32
ip_sd_lookup (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst,
ip_prefix_t * src)
{
u32 sfi;
gid_ip4_table_t *sfib4;
gid_ip6_table_t *sfib6;
switch (ip_prefix_version (dst))
{
case AF_IP4:
sfi = ip4_lookup (&db->dst_ip4_table, vni, dst);
if (GID_LOOKUP_MISS != sfi)
sfib4 = pool_elt_at_index (db->src_ip4_table_pool, sfi);
else
return GID_LOOKUP_MISS;
if (!src)
{
ip_prefix_t sp;
clib_memset (&sp, 0, sizeof (sp));
return ip4_lookup_exact_match (sfib4, 0, &sp);
}
else
return ip4_lookup (sfib4, 0, src);
break;
case AF_IP6:
sfi = ip6_lookup (&db->dst_ip6_table, vni, dst);
if (GID_LOOKUP_MISS != sfi)
sfib6 = pool_elt_at_index (db->src_ip6_table_pool, sfi);
else
return GID_LOOKUP_MISS;
if (!src)
{
ip_prefix_t sp;
clib_memset (&sp, 0, sizeof (sp));
ip_prefix_version (&sp) = AF_IP6;
return ip6_lookup_exact_match (sfib6, 0, &sp);
}
else
return ip6_lookup (sfib6, 0, src);
break;
default:
clib_warning ("address type %d not supported!",
ip_prefix_version (dst));
break;
}
return GID_LOOKUP_MISS;
}
static void
make_arp_ndp_key (BVT (clib_bihash_kv) * kv, u32 bd, ip_address_t * addr)
{
kv->key[0] = ((u64) bd << 32) | (u32) ip_addr_version (addr);
if (ip_addr_version (addr) == AF_IP4)
{
kv->key[1] = (u64) ip_addr_v4 (addr).as_u32;
kv->key[2] = (u64) 0;
}
else
{
kv->key[1] = (u64) ip_addr_v6 (addr).as_u64[0];
kv->key[2] = (u64) ip_addr_v6 (addr).as_u64[1];
}
}
static void
make_nsh_key (BVT (clib_bihash_kv) * kv, u32 vni, u32 spi, u8 si)
{
kv->key[0] = (u64) vni;
kv->key[1] = (u64) spi;
kv->key[2] = (u64) si;
}
static u64
arp_ndp_lookup (gid_l2_arp_ndp_table_t * db, u32 bd, ip_address_t * key)
{
int rv;
BVT (clib_bihash_kv) kv, value;
make_arp_ndp_key (&kv, bd, key);
rv = BV (clib_bihash_search_inline_2) (&db->arp_ndp_lookup_table, &kv,
&value);
if (rv == 0)
return value.value;
return GID_LOOKUP_MISS_L2;
}
static u32
nsh_lookup (gid_nsh_table_t * db, u32 vni, u32 spi, u8 si)
{
int rv;
BVT (clib_bihash_kv) kv, value;
make_nsh_key (&kv, vni, spi, si);
rv = BV (clib_bihash_search_inline_2) (&db->nsh_lookup_table, &kv, &value);
if (rv == 0)
return value.value;
return GID_LOOKUP_MISS;
}
u64
gid_dictionary_lookup (gid_dictionary_t * db, gid_address_t * key)
{
switch (gid_address_type (key))
{
case GID_ADDR_IP_PREFIX:
return ip_sd_lookup (db, gid_address_vni (key),
&gid_address_ippref (key), 0);
case GID_ADDR_MAC:
return mac_sd_lookup (&db->sd_mac_table, gid_address_vni (key),
gid_address_mac (key), 0);
case GID_ADDR_SRC_DST:
switch (gid_address_sd_dst_type (key))
{
case FID_ADDR_IP_PREF:
return ip_sd_lookup (db, gid_address_vni (key),
&gid_address_sd_dst_ippref (key),
&gid_address_sd_src_ippref (key));
break;
case FID_ADDR_MAC:
return mac_sd_lookup (&db->sd_mac_table, gid_address_vni (key),
gid_address_sd_dst_mac (key),
gid_address_sd_src_mac (key));
break;
default:
clib_warning ("Source/Dest address type %d not supported!",
gid_address_sd_dst_type (key));
break;
}
break;
case GID_ADDR_ARP:
case GID_ADDR_NDP:
return arp_ndp_lookup (&db->arp_ndp_table, gid_address_arp_ndp_bd (key),
&gid_address_arp_ndp_ip (key));
case GID_ADDR_NSH:
return nsh_lookup (&db->nsh_table, gid_address_vni (key),
gid_address_nsh_spi (key), gid_address_nsh_si (key));
default:
clib_warning ("address type %d not supported!", gid_address_type (key));
break;
}
return GID_LOOKUP_MISS;
}
u32
gid_dictionary_sd_lookup (gid_dictionary_t * db, gid_address_t * dst,
gid_address_t * src)
{
switch (gid_address_type (dst))
{
case GID_ADDR_IP_PREFIX:
return ip_sd_lookup (db, gid_address_vni (dst),
&gid_address_ippref (dst),
&gid_address_ippref (src));
case GID_ADDR_MAC:
return mac_sd_lookup (&db->sd_mac_table, gid_address_vni (dst),
gid_address_mac (dst), gid_address_mac (src));
case GID_ADDR_SRC_DST:
switch (gid_address_sd_dst_type (dst))
{
case FID_ADDR_IP_PREF:
return ip_sd_lookup (db, gid_address_vni (dst),
&gid_address_sd_dst_ippref (dst),
&gid_address_sd_src_ippref (dst));
break;
case FID_ADDR_MAC:
return mac_sd_lookup (&db->sd_mac_table, gid_address_vni (dst),
gid_address_sd_dst_mac (dst),
gid_address_sd_src_mac (dst));
break;
default:
clib_warning ("Source/Dest address type %d not supported!",
gid_address_sd_dst_type (dst));
break;
}
break;
case GID_ADDR_NSH:
return gid_dictionary_lookup (db, dst);
break;
default:
clib_warning ("address type %d not supported!", gid_address_type (dst));
break;
}
return GID_LOOKUP_MISS;
}
static void
ip4_compute_prefix_lengths_in_search_order (gid_ip4_table_t * db)
{
int i;
vec_reset_length (db->ip4_prefix_lengths_in_search_order);
/* Note: bitmap reversed so this is in fact a longest prefix match */
/* *INDENT-OFF* */
clib_bitmap_foreach (i, db->ip4_non_empty_dst_address_length_bitmap)
{
int dst_address_length = 32 - i;
vec_add1 (db->ip4_prefix_lengths_in_search_order, dst_address_length);
}
/* *INDENT-ON* */
}
static u32
add_del_ip4_key (gid_ip4_table_t * db, u32 vni, ip_prefix_t * pref, u32 val,
u8 is_add)
{
BVT (clib_bihash_kv) kv, value;
u32 old_val = ~0;
ip4_address_t key;
u8 plen = ip_prefix_len (pref);
clib_memcpy (&key, &ip_prefix_v4 (pref), sizeof (key));
key.as_u32 &= db->ip4_fib_masks[plen].as_u32;
if (is_add)
{
db->ip4_non_empty_dst_address_length_bitmap =
clib_bitmap_set (db->ip4_non_empty_dst_address_length_bitmap,
32 - plen, 1);
ip4_compute_prefix_lengths_in_search_order (db);
db->ip4_prefix_len_refcount[plen]++;
}
else
{
ASSERT (db->ip4_prefix_len_refcount[plen] != 0);
db->ip4_prefix_len_refcount[plen]--;
if (db->ip4_prefix_len_refcount[plen] == 0)
{
db->ip4_non_empty_dst_address_length_bitmap =
clib_bitmap_set (db->ip4_non_empty_dst_address_length_bitmap,
32 - plen, 0);
ip4_compute_prefix_lengths_in_search_order (db);
}
}
kv.key[0] = ((u64) vni << 32) | key.as_u32;
kv.key[1] = 0;
kv.key[2] = 0;
if (BV (clib_bihash_search) (&db->ip4_lookup_table, &kv, &value) == 0)
old_val = value.value;
if (!is_add)
{
BV (clib_bihash_add_del) (&db->ip4_lookup_table, &kv, 0 /* is_add */ );
db->count--;
}
else
{
kv.value = val;
BV (clib_bihash_add_del) (&db->ip4_lookup_table, &kv, 1 /* is_add */ );
db->count++;
}
return old_val;
}
static void
ip4_lookup_init (gid_ip4_table_t * db)
{
BVT (clib_bihash_init2_args) _a, *a = &_a;
uword i;
clib_memset (db->ip4_prefix_len_refcount, 0,
sizeof (db->ip4_prefix_len_refcount));
for (i = 0; i < ARRAY_LEN (db->ip4_fib_masks); i++)
{
u32 m;
if (i < 32)
m = pow2_mask (i) << (32 - i);
else
m = ~0;
db->ip4_fib_masks[i].as_u32 = clib_host_to_net_u32 (m);
}
if (db->ip4_lookup_table_nbuckets == 0)
db->ip4_lookup_table_nbuckets = IP4_LOOKUP_DEFAULT_HASH_NUM_BUCKETS;
db->ip4_lookup_table_nbuckets =
1 << max_log2 (db->ip4_lookup_table_nbuckets);
if (db->ip4_lookup_table_size == 0)
db->ip4_lookup_table_size = IP4_LOOKUP_DEFAULT_HASH_MEMORY_SIZE;
/*
* Danger Will Robinson, Danger! gid_ip4_table_t's are allocated from
* a pool. They MUST NOT be listed on the clib_all_bihashes list...
*/
memset (a, 0, sizeof (*a));
a->h = &db->ip4_lookup_table;
a->name = "LISP ip4 lookup table";
a->nbuckets = db->ip4_lookup_table_nbuckets;
a->memory_size = db->ip4_lookup_table_size;
a->dont_add_to_all_bihash_list = 1; /* See comment above */
BV (clib_bihash_init2) (a);
}
static u32
add_del_sd_ip4_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref,
ip_prefix_t * src_pref, u32 val, u8 is_add)
{
u32 sfi, old_val = ~0;
gid_ip4_table_t *sfib;
sfi = ip4_lookup_exact_match (&db->dst_ip4_table, vni, dst_pref);
if (is_add)
{
if (GID_LOOKUP_MISS == sfi)
{
pool_get (db->src_ip4_table_pool, sfib);
ip4_lookup_init (sfib);
add_del_ip4_key (&db->dst_ip4_table, vni, dst_pref,
sfib - db->src_ip4_table_pool, is_add);
if (src_pref)
add_del_ip4_key (sfib, 0 /* vni */ , src_pref, val, is_add);
else
{
ip_prefix_t sp;
clib_memset (&sp, 0, sizeof (sp));
add_del_ip4_key (sfib, 0 /* vni */ , &sp, val, is_add);
}
}
else
{
ASSERT (!pool_is_free_index (db->src_ip4_table_pool, sfi));
sfib = pool_elt_at_index (db->src_ip4_table_pool, sfi);
if (src_pref)
{
old_val = ip4_lookup_exact_match (sfib, 0, src_pref);
add_del_ip4_key (sfib, 0 /* vni */ , src_pref, val, is_add);
}
else
{
ip_prefix_t sp;
clib_memset (&sp, 0, sizeof (sp));
old_val =
add_del_ip4_key (sfib, 0 /* vni */ , &sp, val, is_add);
}
}
}
else
{
if (GID_LOOKUP_MISS != sfi)
{
sfib = pool_elt_at_index (db->src_ip4_table_pool, sfi);
if (src_pref)
old_val = add_del_ip4_key (sfib, 0, src_pref, 0, is_add);
else
{
ip_prefix_t sp;
clib_memset (&sp, 0, sizeof (sp));
old_val = add_del_ip4_key (sfib, 0, &sp, 0, is_add);
}
if (sfib->count == 0)
add_del_ip4_key (&db->dst_ip4_table, vni, dst_pref, 0, is_add);
}
else
clib_warning ("cannot delete dst mapping %U!", format_ip_prefix,
dst_pref);
}
return old_val;
}
static void
ip6_compute_prefix_lengths_in_search_order (gid_ip6_table_t * db)
{
int i;
vec_reset_length (db->ip6_prefix_lengths_in_search_order);
/* Note: bitmap reversed so this is in fact a longest prefix match */
/* *INDENT-OFF* */
clib_bitmap_foreach (i, db->ip6_non_empty_dst_address_length_bitmap)
{
int dst_address_length = 128 - i;
vec_add1 (db->ip6_prefix_lengths_in_search_order, dst_address_length);
}
/* *INDENT-ON* */
}
static u32
add_del_ip6_key (gid_ip6_table_t * db, u32 vni, ip_prefix_t * pref, u32 val,
u8 is_add)
{
BVT (clib_bihash_kv) kv, value;
u32 old_val = ~0;
ip6_address_t key;
u8 plen = ip_prefix_len (pref);
clib_memcpy (&key, &ip_prefix_v6 (pref), sizeof (key));
ip6_address_mask (&key, &db->ip6_fib_masks[plen]);
if (is_add)
{
db->ip6_non_empty_dst_address_length_bitmap =
clib_bitmap_set (db->ip6_non_empty_dst_address_length_bitmap,
128 - plen, 1);
ip6_compute_prefix_lengths_in_search_order (db);
db->ip6_prefix_len_refcount[plen]++;
}
else
{
ASSERT (db->ip6_prefix_len_refcount[plen] != 0);
db->ip6_prefix_len_refcount[plen]--;
if (db->ip6_prefix_len_refcount[plen] == 0)
{
db->ip6_non_empty_dst_address_length_bitmap =
clib_bitmap_set (db->ip6_non_empty_dst_address_length_bitmap,
128 - plen, 0);
ip6_compute_prefix_lengths_in_search_order (db);
}
}
kv.key[0] = key.as_u64[0];
kv.key[1] = key.as_u64[1];
kv.key[2] = (u64) vni;
// kv.key[2] = ((u64)((fib - im->fibs))<<32) | ip_prefix_len(key);
if (BV (clib_bihash_search) (&db->ip6_lookup_table, &kv, &value) == 0)
old_val = value.value;
if (!is_add)
{
BV (clib_bihash_add_del) (&db->ip6_lookup_table, &kv, 0 /* is_add */ );
db->count--;
}
else
{
kv.value = val;
BV (clib_bihash_add_del) (&db->ip6_lookup_table, &kv, 1 /* is_add */ );
db->count++;
}
return old_val;
}
static u32
add_del_mac (gid_mac_table_t * db, u32 vni, u8 * dst_mac, u8 * src_mac,
u32 val, u8 is_add)
{
BVT (clib_bihash_kv) kv, value;
u32 old_val = ~0;
make_mac_sd_key (&kv, vni, src_mac, dst_mac);
if (BV (clib_bihash_search) (&db->mac_lookup_table, &kv, &value) == 0)
old_val = value.value;
if (!is_add)
{
BV (clib_bihash_add_del) (&db->mac_lookup_table, &kv, 0 /* is_add */ );
db->count--;
}
else
{
kv.value = val;
BV (clib_bihash_add_del) (&db->mac_lookup_table, &kv, 1 /* is_add */ );
db->count++;
}
return old_val;
}
static void
ip6_lookup_init (gid_ip6_table_t * db)
{
uword i;
BVT (clib_bihash_init2_args) _a, *a = &_a;
clib_memset (db->ip6_prefix_len_refcount, 0,
sizeof (db->ip6_prefix_len_refcount));
for (i = 0; i < ARRAY_LEN (db->ip6_fib_masks); i++)
{
u32 j, i0, i1;
i0 = i / 32;
i1 = i % 32;
for (j = 0; j < i0; j++)
db->ip6_fib_masks[i].as_u32[j] = ~0;
if (i1)
db->ip6_fib_masks[i].as_u32[i0] =
clib_host_to_net_u32 (pow2_mask (i1) << (32 - i1));
}
if (db->ip6_lookup_table_nbuckets == 0)
db->ip6_lookup_table_nbuckets = IP6_LOOKUP_DEFAULT_HASH_NUM_BUCKETS;
db->ip6_lookup_table_nbuckets =
1 << max_log2 (db->ip6_lookup_table_nbuckets);
if (db->ip6_lookup_table_size == 0)
db->ip6_lookup_table_size = IP6_LOOKUP_DEFAULT_HASH_MEMORY_SIZE;
/*
* Danger Will Robinson, Danger! gid_ip6_table_t's are allocated from
* a pool. They MUST NOT be listed on the clib_all_bihashes list...
*/
memset (a, 0, sizeof (*a));
a->h = &db->ip6_lookup_table;
a->name = "LISP ip6 lookup table";
a->nbuckets = db->ip6_lookup_table_nbuckets;
a->memory_size = db->ip6_lookup_table_size;
a->dont_add_to_all_bihash_list = 1; /* See comment above */
BV (clib_bihash_init2) (a);
}
static u32
add_del_sd_ip6_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref,
ip_prefix_t * src_pref, u32 val, u8 is_add)
{
u32 sfi, old_val = ~0;
gid_ip6_table_t *sfib;
sfi = ip6_lookup_exact_match (&db->dst_ip6_table, vni, dst_pref);
if (is_add)
{
if (GID_LOOKUP_MISS == sfi)
{
pool_get (db->src_ip6_table_pool, sfib);
ip6_lookup_init (sfib);
add_del_ip6_key (&db->dst_ip6_table, vni, dst_pref,
sfib - db->src_ip6_table_pool, is_add);
if (src_pref)
add_del_ip6_key (sfib, 0 /* vni */ , src_pref, val, is_add);
else
{
ip_prefix_t sp;
clib_memset (&sp, 0, sizeof (sp));
ip_prefix_version (&sp) = AF_IP6;
add_del_ip6_key (sfib, 0 /* vni */ , &sp, val, is_add);
}
}
else
{
ASSERT (!pool_is_free_index (db->src_ip6_table_pool, sfi));
sfib = pool_elt_at_index (db->src_ip6_table_pool, sfi);
if (src_pref)
{
old_val = ip6_lookup_exact_match (sfib, 0, src_pref);
add_del_ip6_key (sfib, 0 /* vni */ , src_pref, val, is_add);
}
else
{
ip_prefix_t sp;
clib_memset (&sp, 0, sizeof (sp));
ip_prefix_version (&sp) = AF_IP6;
old_val =
add_del_ip6_key (sfib, 0 /* vni */ , &sp, val, is_add);
}
}
}
else
{
if (GID_LOOKUP_MISS != sfi)
{
sfib = pool_elt_at_index (db->src_ip6_table_pool, sfi);
if (src_pref)
old_val = add_del_ip6_key (sfib, 0, src_pref, 0, is_add);
else
{
ip_prefix_t sp;
clib_memset (&sp, 0, sizeof (sp));
ip_prefix_version (&sp) = AF_IP6;
old_val = add_del_ip6_key (sfib, 0, &sp, 0, is_add);
}
if (sfib->count == 0)
add_del_ip6_key (&db->dst_ip6_table, vni, dst_pref, 0, is_add);
}
else
clib_warning ("cannot delete dst mapping %U!", format_ip_prefix,
dst_pref);
}
return old_val;
}
static u32
add_del_ip (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_key,
ip_prefix_t * src_key, u32 value, u8 is_add)
{
switch (ip_prefix_version (dst_key))
{
case AF_IP4:
return add_del_sd_ip4_key (db, vni, dst_key, src_key, value, is_add);
break;
case AF_IP6:
return add_del_sd_ip6_key (db, vni, dst_key, src_key, value, is_add);
break;
default:
clib_warning ("address type %d not supported!",
ip_prefix_version (dst_key));
break;
}
return ~0;
}
static u32
add_del_sd (gid_dictionary_t * db, u32 vni, source_dest_t * key, u32 value,
u8 is_add)
{
switch (sd_dst_type (key))
{
case FID_ADDR_IP_PREF:
add_del_ip (db, vni, &sd_dst_ippref (key), &sd_src_ippref (key),
value, is_add);
case FID_ADDR_MAC:
return add_del_mac (&db->sd_mac_table, vni, sd_dst_mac (key),
sd_src_mac (key), value, is_add);
default:
clib_warning ("SD address type %d not supported!", sd_dst_type (key));
break;
}
return ~0;
}
static u64
add_del_arp_ndp (gid_l2_arp_ndp_table_t * db, u32 bd, ip_address_t * key,
u64 value, u8 is_add)
{
BVT (clib_bihash_kv) kv, result;
u32 old_val = ~0;
make_arp_ndp_key (&kv, bd, key);
if (BV (clib_bihash_search) (&db->arp_ndp_lookup_table, &kv, &result) == 0)
old_val = result.value;
if (is_add)
{
kv.value = value;
BV (clib_bihash_add_del) (&db->arp_ndp_lookup_table, &kv,
1 /* is_add */ );
db->count++;
}
else
{
BV (clib_bihash_add_del) (&db->arp_ndp_lookup_table, &kv,
0 /* is_add */ );
db->count--;
}
return old_val;
}
static u32
add_del_nsh (gid_nsh_table_t * db, u32 vni, u32 spi, u8 si, u32 value,
u8 is_add)
{
BVT (clib_bihash_kv) kv, result;
u32 old_val = ~0;
make_nsh_key (&kv, vni, spi, si);
if (BV (clib_bihash_search) (&db->nsh_lookup_table, &kv, &result) == 0)
old_val = result.value;
if (is_add)
{
kv.value = value;
BV (clib_bihash_add_del) (&db->nsh_lookup_table, &kv, 1 /* is_add */ );
db->count++;
}
else
{
BV (clib_bihash_add_del) (&db->nsh_lookup_table, &kv, 0 /* is_add */ );
db->count--;
}
return old_val;
}
u32
gid_dictionary_add_del (gid_dictionary_t * db, gid_address_t * key, u64 value,
u8 is_add)
{
switch (gid_address_type (key))
{
case GID_ADDR_IP_PREFIX:
return add_del_ip (db, gid_address_vni (key), &gid_address_ippref (key),
0, (u32) value, is_add);
case GID_ADDR_MAC:
return add_del_mac (&db->sd_mac_table, gid_address_vni (key),
gid_address_mac (key), 0, (u32) value, is_add);
case GID_ADDR_SRC_DST:
return add_del_sd (db, gid_address_vni (key), &gid_address_sd (key),
(u32) value, is_add);
case GID_ADDR_ARP:
case GID_ADDR_NDP:
return add_del_arp_ndp (&db->arp_ndp_table,
gid_address_arp_ndp_bd (key),
&gid_address_arp_ndp_ip (key), value, is_add);
case GID_ADDR_NSH:
return add_del_nsh (&db->nsh_table, gid_address_vni (key),
gid_address_nsh_spi (key), gid_address_nsh_si (key),
value, is_add);
default:
clib_warning ("address type %d not supported!", gid_address_type (key));
break;
}
return ~0;
}
static void
mac_lookup_init (gid_mac_table_t * db)
{
if (db->mac_lookup_table_nbuckets == 0)
db->mac_lookup_table_nbuckets = MAC_LOOKUP_DEFAULT_HASH_NUM_BUCKETS;
db->mac_lookup_table_nbuckets =
1 << max_log2 (db->mac_lookup_table_nbuckets);
if (db->mac_lookup_table_size == 0)
db->mac_lookup_table_size = MAC_LOOKUP_DEFAULT_HASH_MEMORY_SIZE;
BV (clib_bihash_init) (&db->mac_lookup_table, "mac lookup table",
db->mac_lookup_table_nbuckets,
db->mac_lookup_table_size);
}
static void
arp_ndp_lookup_init (gid_l2_arp_ndp_table_t * db)
{
if (db->arp_ndp_lookup_table_nbuckets == 0)
db->arp_ndp_lookup_table_nbuckets =
ARP_NDP_LOOKUP_DEFAULT_HASH_NUM_BUCKETS;
db->arp_ndp_lookup_table_nbuckets =
1 << max_log2 (db->arp_ndp_lookup_table_nbuckets);
if (db->arp_ndp_lookup_table_size == 0)
db->arp_ndp_lookup_table_size = ARP_NDP_LOOKUP_DEFAULT_HASH_MEMORY_SIZE;
BV (clib_bihash_init) (&db->arp_ndp_lookup_table, "arp ndp lookup table",
db->arp_ndp_lookup_table_nbuckets,
db->arp_ndp_lookup_table_size);
}
static void
nsh_lookup_init (gid_nsh_table_t * db)
{
if (db->nsh_lookup_table_nbuckets == 0)
db->nsh_lookup_table_nbuckets = MAC_LOOKUP_DEFAULT_HASH_NUM_BUCKETS;
db->nsh_lookup_table_nbuckets =
1 << max_log2 (db->nsh_lookup_table_nbuckets);
if (db->nsh_lookup_table_size == 0)
db->nsh_lookup_table_size = MAC_LOOKUP_DEFAULT_HASH_MEMORY_SIZE;
BV (clib_bihash_init) (&db->nsh_lookup_table, "nsh lookup table",
db->nsh_lookup_table_nbuckets,
db->nsh_lookup_table_size);
}
void
gid_dictionary_init (gid_dictionary_t * db)
{
ip4_lookup_init (&db->dst_ip4_table);
ip6_lookup_init (&db->dst_ip6_table);
mac_lookup_init (&db->sd_mac_table);
arp_ndp_lookup_init (&db->arp_ndp_table);
nsh_lookup_init (&db->nsh_table);
}
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|
fddaaeb9ec58b821a6af5bdd3a1251d36853b183
|
ce6b2c3d3676316d30832d1fbe9611d407f9b718
|
/lib/keccak/keccak.c
|
286ea9d324566238edbdc4d2e8828c9517bd6359
|
[
"Apache-2.0"
] |
permissive
|
chfast/ethash
|
86c57fd6b5c0261e5addcc1cef9f1f7e60b0686b
|
8e18c3d715d3d759f44ac10f70f9c93b227e18c2
|
refs/heads/master
| 2023-05-25T09:49:40.148276
| 2023-04-03T20:30:42
| 2023-04-03T20:30:42
| 122,413,081
| 156
| 128
|
Apache-2.0
| 2023-09-12T15:42:55
| 2018-02-22T00:52:39
|
C++
|
UTF-8
|
C
| false
| false
| 10,817
|
c
|
keccak.c
|
// ethash: C/C++ implementation of Ethash, the Ethereum Proof of Work algorithm.
// Copyright 2018 Pawel Bylica.
// SPDX-License-Identifier: Apache-2.0
#include "../support/attributes.h"
#include <ethash/keccak.h>
#if !__has_builtin(__builtin_memcpy) && !defined(__GNUC__)
#include <string.h>
#define __builtin_memcpy memcpy
#endif
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define to_le64(X) __builtin_bswap64(X)
#else
#define to_le64(X) X
#endif
/// Loads 64-bit integer from given memory location as little-endian number.
static inline ALWAYS_INLINE uint64_t load_le(const uint8_t* data)
{
/* memcpy is the best way of expressing the intention. Every compiler will
optimize is to single load instruction if the target architecture
supports unaligned memory access (GCC and clang even in O0).
This is great trick because we are violating C/C++ memory alignment
restrictions with no performance penalty. */
uint64_t word;
__builtin_memcpy(&word, data, sizeof(word));
return to_le64(word);
}
/// Rotates the bits of x left by the count value specified by s.
/// The s must be in range <0, 64> exclusively, otherwise the result is undefined.
static inline uint64_t rol(uint64_t x, unsigned s)
{
return (x << s) | (x >> (64 - s));
}
static const uint64_t round_constants[24] = { //
0x0000000000000001, 0x0000000000008082, 0x800000000000808a, 0x8000000080008000,
0x000000000000808b, 0x0000000080000001, 0x8000000080008081, 0x8000000000008009,
0x000000000000008a, 0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
0x000000008000808b, 0x800000000000008b, 0x8000000000008089, 0x8000000000008003,
0x8000000000008002, 0x8000000000000080, 0x000000000000800a, 0x800000008000000a,
0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008};
/// The Keccak-f[1600] function.
///
/// The implementation of the Keccak-f function with 1600-bit width of the permutation (b).
/// The size of the state is also 1600 bit what gives 25 64-bit words.
///
/// @param state The state of 25 64-bit words on which the permutation is to be performed.
///
/// The implementation based on:
/// - "simple" implementation by Ronny Van Keer, included in "Reference and optimized code in C",
/// https://keccak.team/archives.html, CC0-1.0 / Public Domain.
static inline ALWAYS_INLINE void keccakf1600_implementation(uint64_t state[25])
{
uint64_t Aba, Abe, Abi, Abo, Abu;
uint64_t Aga, Age, Agi, Ago, Agu;
uint64_t Aka, Ake, Aki, Ako, Aku;
uint64_t Ama, Ame, Ami, Amo, Amu;
uint64_t Asa, Ase, Asi, Aso, Asu;
uint64_t Eba, Ebe, Ebi, Ebo, Ebu;
uint64_t Ega, Ege, Egi, Ego, Egu;
uint64_t Eka, Eke, Eki, Eko, Eku;
uint64_t Ema, Eme, Emi, Emo, Emu;
uint64_t Esa, Ese, Esi, Eso, Esu;
uint64_t Ba, Be, Bi, Bo, Bu;
uint64_t Da, De, Di, Do, Du;
Aba = state[0];
Abe = state[1];
Abi = state[2];
Abo = state[3];
Abu = state[4];
Aga = state[5];
Age = state[6];
Agi = state[7];
Ago = state[8];
Agu = state[9];
Aka = state[10];
Ake = state[11];
Aki = state[12];
Ako = state[13];
Aku = state[14];
Ama = state[15];
Ame = state[16];
Ami = state[17];
Amo = state[18];
Amu = state[19];
Asa = state[20];
Ase = state[21];
Asi = state[22];
Aso = state[23];
Asu = state[24];
for (size_t n = 0; n < 24; n += 2)
{
// Round (n + 0): Axx -> Exx
Ba = Aba ^ Aga ^ Aka ^ Ama ^ Asa;
Be = Abe ^ Age ^ Ake ^ Ame ^ Ase;
Bi = Abi ^ Agi ^ Aki ^ Ami ^ Asi;
Bo = Abo ^ Ago ^ Ako ^ Amo ^ Aso;
Bu = Abu ^ Agu ^ Aku ^ Amu ^ Asu;
Da = Bu ^ rol(Be, 1);
De = Ba ^ rol(Bi, 1);
Di = Be ^ rol(Bo, 1);
Do = Bi ^ rol(Bu, 1);
Du = Bo ^ rol(Ba, 1);
Ba = Aba ^ Da;
Be = rol(Age ^ De, 44);
Bi = rol(Aki ^ Di, 43);
Bo = rol(Amo ^ Do, 21);
Bu = rol(Asu ^ Du, 14);
Eba = Ba ^ (~Be & Bi) ^ round_constants[n];
Ebe = Be ^ (~Bi & Bo);
Ebi = Bi ^ (~Bo & Bu);
Ebo = Bo ^ (~Bu & Ba);
Ebu = Bu ^ (~Ba & Be);
Ba = rol(Abo ^ Do, 28);
Be = rol(Agu ^ Du, 20);
Bi = rol(Aka ^ Da, 3);
Bo = rol(Ame ^ De, 45);
Bu = rol(Asi ^ Di, 61);
Ega = Ba ^ (~Be & Bi);
Ege = Be ^ (~Bi & Bo);
Egi = Bi ^ (~Bo & Bu);
Ego = Bo ^ (~Bu & Ba);
Egu = Bu ^ (~Ba & Be);
Ba = rol(Abe ^ De, 1);
Be = rol(Agi ^ Di, 6);
Bi = rol(Ako ^ Do, 25);
Bo = rol(Amu ^ Du, 8);
Bu = rol(Asa ^ Da, 18);
Eka = Ba ^ (~Be & Bi);
Eke = Be ^ (~Bi & Bo);
Eki = Bi ^ (~Bo & Bu);
Eko = Bo ^ (~Bu & Ba);
Eku = Bu ^ (~Ba & Be);
Ba = rol(Abu ^ Du, 27);
Be = rol(Aga ^ Da, 36);
Bi = rol(Ake ^ De, 10);
Bo = rol(Ami ^ Di, 15);
Bu = rol(Aso ^ Do, 56);
Ema = Ba ^ (~Be & Bi);
Eme = Be ^ (~Bi & Bo);
Emi = Bi ^ (~Bo & Bu);
Emo = Bo ^ (~Bu & Ba);
Emu = Bu ^ (~Ba & Be);
Ba = rol(Abi ^ Di, 62);
Be = rol(Ago ^ Do, 55);
Bi = rol(Aku ^ Du, 39);
Bo = rol(Ama ^ Da, 41);
Bu = rol(Ase ^ De, 2);
Esa = Ba ^ (~Be & Bi);
Ese = Be ^ (~Bi & Bo);
Esi = Bi ^ (~Bo & Bu);
Eso = Bo ^ (~Bu & Ba);
Esu = Bu ^ (~Ba & Be);
// Round (n + 1): Exx -> Axx
Ba = Eba ^ Ega ^ Eka ^ Ema ^ Esa;
Be = Ebe ^ Ege ^ Eke ^ Eme ^ Ese;
Bi = Ebi ^ Egi ^ Eki ^ Emi ^ Esi;
Bo = Ebo ^ Ego ^ Eko ^ Emo ^ Eso;
Bu = Ebu ^ Egu ^ Eku ^ Emu ^ Esu;
Da = Bu ^ rol(Be, 1);
De = Ba ^ rol(Bi, 1);
Di = Be ^ rol(Bo, 1);
Do = Bi ^ rol(Bu, 1);
Du = Bo ^ rol(Ba, 1);
Ba = Eba ^ Da;
Be = rol(Ege ^ De, 44);
Bi = rol(Eki ^ Di, 43);
Bo = rol(Emo ^ Do, 21);
Bu = rol(Esu ^ Du, 14);
Aba = Ba ^ (~Be & Bi) ^ round_constants[n + 1];
Abe = Be ^ (~Bi & Bo);
Abi = Bi ^ (~Bo & Bu);
Abo = Bo ^ (~Bu & Ba);
Abu = Bu ^ (~Ba & Be);
Ba = rol(Ebo ^ Do, 28);
Be = rol(Egu ^ Du, 20);
Bi = rol(Eka ^ Da, 3);
Bo = rol(Eme ^ De, 45);
Bu = rol(Esi ^ Di, 61);
Aga = Ba ^ (~Be & Bi);
Age = Be ^ (~Bi & Bo);
Agi = Bi ^ (~Bo & Bu);
Ago = Bo ^ (~Bu & Ba);
Agu = Bu ^ (~Ba & Be);
Ba = rol(Ebe ^ De, 1);
Be = rol(Egi ^ Di, 6);
Bi = rol(Eko ^ Do, 25);
Bo = rol(Emu ^ Du, 8);
Bu = rol(Esa ^ Da, 18);
Aka = Ba ^ (~Be & Bi);
Ake = Be ^ (~Bi & Bo);
Aki = Bi ^ (~Bo & Bu);
Ako = Bo ^ (~Bu & Ba);
Aku = Bu ^ (~Ba & Be);
Ba = rol(Ebu ^ Du, 27);
Be = rol(Ega ^ Da, 36);
Bi = rol(Eke ^ De, 10);
Bo = rol(Emi ^ Di, 15);
Bu = rol(Eso ^ Do, 56);
Ama = Ba ^ (~Be & Bi);
Ame = Be ^ (~Bi & Bo);
Ami = Bi ^ (~Bo & Bu);
Amo = Bo ^ (~Bu & Ba);
Amu = Bu ^ (~Ba & Be);
Ba = rol(Ebi ^ Di, 62);
Be = rol(Ego ^ Do, 55);
Bi = rol(Eku ^ Du, 39);
Bo = rol(Ema ^ Da, 41);
Bu = rol(Ese ^ De, 2);
Asa = Ba ^ (~Be & Bi);
Ase = Be ^ (~Bi & Bo);
Asi = Bi ^ (~Bo & Bu);
Aso = Bo ^ (~Bu & Ba);
Asu = Bu ^ (~Ba & Be);
}
state[0] = Aba;
state[1] = Abe;
state[2] = Abi;
state[3] = Abo;
state[4] = Abu;
state[5] = Aga;
state[6] = Age;
state[7] = Agi;
state[8] = Ago;
state[9] = Agu;
state[10] = Aka;
state[11] = Ake;
state[12] = Aki;
state[13] = Ako;
state[14] = Aku;
state[15] = Ama;
state[16] = Ame;
state[17] = Ami;
state[18] = Amo;
state[19] = Amu;
state[20] = Asa;
state[21] = Ase;
state[22] = Asi;
state[23] = Aso;
state[24] = Asu;
}
static void keccakf1600_generic(uint64_t state[25])
{
keccakf1600_implementation(state);
}
/// The pointer to the best Keccak-f[1600] function implementation,
/// selected during runtime initialization.
static void (*keccakf1600_best)(uint64_t[25]) = keccakf1600_generic;
#if !defined(_MSC_VER) && defined(__x86_64__) && __has_attribute(target)
__attribute__((target("bmi,bmi2"))) static void keccakf1600_bmi(uint64_t state[25])
{
keccakf1600_implementation(state);
}
__attribute__((constructor)) static void select_keccakf1600_implementation(void)
{
// Init CPU information.
// This is needed on macOS because of the bug: https://bugs.llvm.org/show_bug.cgi?id=48459.
__builtin_cpu_init();
// Check if both BMI and BMI2 are supported. Some CPUs like Intel E5-2697 v2 incorrectly
// report BMI2 but not BMI being available.
if (__builtin_cpu_supports("bmi") && __builtin_cpu_supports("bmi2"))
keccakf1600_best = keccakf1600_bmi;
}
#endif
static inline ALWAYS_INLINE void keccak(
uint64_t* out, size_t bits, const uint8_t* data, size_t size)
{
static const size_t word_size = sizeof(uint64_t);
const size_t hash_size = bits / 8;
const size_t block_size = (1600 - bits * 2) / 8;
size_t i;
uint64_t* state_iter;
uint64_t last_word = 0;
uint8_t* last_word_iter = (uint8_t*)&last_word;
uint64_t state[25] = {0};
while (size >= block_size)
{
for (i = 0; i < (block_size / word_size); ++i)
{
state[i] ^= load_le(data);
data += word_size;
}
keccakf1600_best(state);
size -= block_size;
}
state_iter = state;
while (size >= word_size)
{
*state_iter ^= load_le(data);
++state_iter;
data += word_size;
size -= word_size;
}
while (size > 0)
{
*last_word_iter = *data;
++last_word_iter;
++data;
--size;
}
*last_word_iter = 0x01;
*state_iter ^= to_le64(last_word);
state[(block_size / word_size) - 1] ^= 0x8000000000000000;
keccakf1600_best(state);
for (i = 0; i < (hash_size / word_size); ++i)
out[i] = to_le64(state[i]);
}
union ethash_hash256 ethash_keccak256(const uint8_t* data, size_t size)
{
union ethash_hash256 hash;
keccak(hash.word64s, 256, data, size);
return hash;
}
union ethash_hash256 ethash_keccak256_32(const uint8_t data[32])
{
union ethash_hash256 hash;
keccak(hash.word64s, 256, data, 32);
return hash;
}
union ethash_hash512 ethash_keccak512(const uint8_t* data, size_t size)
{
union ethash_hash512 hash;
keccak(hash.word64s, 512, data, size);
return hash;
}
union ethash_hash512 ethash_keccak512_64(const uint8_t data[64])
{
union ethash_hash512 hash;
keccak(hash.word64s, 512, data, 64);
return hash;
}
|
77845b9c136c18a7fc255237cd07d09aa6c4da20
|
72f6d3ad72b2a4a9b6c5f93c5d1b744e2940b884
|
/lib/core/configurator.c
|
de7f27bc9b0ecd04350768d3e5eab855004af4f9
|
[
"MIT"
] |
permissive
|
h2o/h2o
|
70012b6527ceb54e9e2819c9c75242b18e381485
|
b165770ce704c782ddee7428ea4a0b23c8bb7894
|
refs/heads/master
| 2023-08-16T13:16:35.018003
| 2023-08-16T03:56:28
| 2023-08-16T03:56:28
| 23,029,617
| 9,377
| 983
|
MIT
| 2023-09-12T04:49:14
| 2014-08-16T23:59:03
|
C
|
UTF-8
|
C
| false
| false
| 57,560
|
c
|
configurator.c
|
/*
* Copyright (c) 2014-2016 DeNA Co., Ltd., Kazuho Oku, Fastly, 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.
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <sys/types.h>
#include <netinet/udp.h>
#include "h2o.h"
#include "h2o/configurator.h"
struct st_core_config_vars_t {
struct {
unsigned reprioritize_blocking_assets : 1;
unsigned push_preload : 1;
unsigned allow_cross_origin_push : 1;
h2o_casper_conf_t casper;
} http2;
struct {
unsigned emit_request_errors : 1;
} error_log;
};
struct st_core_configurator_t {
h2o_configurator_t super;
struct st_core_config_vars_t *vars, _vars_stack[H2O_CONFIGURATOR_NUM_LEVELS + 1];
};
static h2o_configurator_context_t *create_context(h2o_configurator_context_t *parent, int is_custom_handler)
{
h2o_configurator_context_t *ctx = h2o_mem_alloc(sizeof(*ctx));
if (parent == NULL) {
*ctx = (h2o_configurator_context_t){NULL};
return ctx;
}
*ctx = *parent;
if (ctx->env != NULL)
h2o_mem_addref_shared(ctx->env);
ctx->parent = parent;
return ctx;
}
static void destroy_context(h2o_configurator_context_t *ctx)
{
if (ctx->env != NULL) {
if (ctx->pathconf != NULL)
ctx->pathconf->env = ctx->env;
else
h2o_mem_release_shared(ctx->env);
}
free(ctx);
}
static int on_core_enter(h2o_configurator_t *_self, h2o_configurator_context_t *ctx, yoml_t *node)
{
struct st_core_configurator_t *self = (void *)_self;
++self->vars;
self->vars[0] = self->vars[-1];
return 0;
}
static int on_core_exit(h2o_configurator_t *_self, h2o_configurator_context_t *ctx, yoml_t *node)
{
struct st_core_configurator_t *self = (void *)_self;
if (ctx->hostconf != NULL && ctx->pathconf == NULL) {
/* exitting from host-level configuration */
ctx->hostconf->http2.reprioritize_blocking_assets = self->vars->http2.reprioritize_blocking_assets;
ctx->hostconf->http2.push_preload = self->vars->http2.push_preload;
ctx->hostconf->http2.allow_cross_origin_push = self->vars->http2.allow_cross_origin_push;
ctx->hostconf->http2.casper = self->vars->http2.casper;
} else if (ctx->pathconf != NULL) {
/* exitting from path or extension-level configuration */
ctx->pathconf->error_log.emit_request_errors = self->vars->error_log.emit_request_errors;
}
--self->vars;
return 0;
}
static void destroy_configurator(h2o_configurator_t *configurator)
{
if (configurator->dispose != NULL)
configurator->dispose(configurator);
free(configurator->commands.entries);
free(configurator);
}
static int setup_configurators(h2o_configurator_context_t *ctx, int is_enter, yoml_t *node)
{
h2o_linklist_t *n;
for (n = ctx->globalconf->configurators.next; n != &ctx->globalconf->configurators; n = n->next) {
h2o_configurator_t *c = H2O_STRUCT_FROM_MEMBER(h2o_configurator_t, _link, n);
if (is_enter) {
if (c->enter != NULL && c->enter(c, ctx, node) != 0)
return -1;
} else {
if (c->exit != NULL && c->exit(c, ctx, node) != 0)
return -1;
}
}
return 0;
}
static int config_timeout(h2o_configurator_command_t *cmd, yoml_t *node, uint64_t *slot)
{
uint64_t timeout_in_secs;
if (h2o_configurator_scanf(cmd, node, "%" SCNu64, &timeout_in_secs) != 0)
return -1;
*slot = timeout_in_secs * 1000;
return 0;
}
int h2o_configurator_apply_commands(h2o_configurator_context_t *ctx, yoml_t *node, int flags_mask, const char **ignore_commands)
{
struct st_cmd_value_t {
h2o_configurator_command_t *cmd;
yoml_t *value;
};
H2O_VECTOR(struct st_cmd_value_t) deferred = {NULL}, semi_deferred = {NULL};
int ret = -1;
if (node != NULL && node->type != YOML_TYPE_MAPPING) {
h2o_configurator_errprintf(NULL, node, "node must be a MAPPING");
goto Exit;
}
/* call on_enter of every configurator */
if (setup_configurators(ctx, 1, node) != 0)
goto Exit;
/* handle the configuration commands */
if (node != NULL) {
size_t i;
for (i = 0; i != node->data.mapping.size; ++i) {
yoml_t *key = node->data.mapping.elements[i].key, *value = node->data.mapping.elements[i].value;
h2o_configurator_command_t *cmd;
/* obtain the target command */
if (key->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(NULL, key, "command must be a string");
goto Exit;
}
if (ignore_commands != NULL) {
size_t i;
for (i = 0; ignore_commands[i] != NULL; ++i)
if (strcmp(ignore_commands[i], key->data.scalar) == 0)
goto SkipCommand;
}
if ((cmd = h2o_configurator_get_command(ctx->globalconf, key->data.scalar)) == NULL) {
h2o_configurator_errprintf(NULL, key, "unknown command: %s", key->data.scalar);
goto Exit;
}
if ((cmd->flags & flags_mask) == 0) {
h2o_configurator_errprintf(cmd, key, "the command cannot be used at this level");
goto Exit;
}
/* check value type */
if ((cmd->flags & (H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR | H2O_CONFIGURATOR_FLAG_EXPECT_SEQUENCE |
H2O_CONFIGURATOR_FLAG_EXPECT_MAPPING)) != 0) {
switch (value->type) {
case YOML_TYPE_SCALAR:
if ((cmd->flags & H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR) == 0) {
h2o_configurator_errprintf(cmd, value, "argument cannot be a scalar");
goto Exit;
}
break;
case YOML_TYPE_SEQUENCE:
if ((cmd->flags & H2O_CONFIGURATOR_FLAG_EXPECT_SEQUENCE) == 0) {
h2o_configurator_errprintf(cmd, value, "argument cannot be a sequence");
goto Exit;
}
break;
case YOML_TYPE_MAPPING:
if ((cmd->flags & H2O_CONFIGURATOR_FLAG_EXPECT_MAPPING) == 0) {
h2o_configurator_errprintf(cmd, value, "argument cannot be a mapping");
goto Exit;
}
break;
default:
assert(!"unreachable");
break;
}
}
/* handle the command (or keep it for later execution) */
if ((cmd->flags & H2O_CONFIGURATOR_FLAG_SEMI_DEFERRED) != 0) {
h2o_vector_reserve(NULL, &semi_deferred, semi_deferred.size + 1);
semi_deferred.entries[semi_deferred.size++] = (struct st_cmd_value_t){cmd, value};
} else if ((cmd->flags & H2O_CONFIGURATOR_FLAG_DEFERRED) != 0) {
h2o_vector_reserve(NULL, &deferred, deferred.size + 1);
deferred.entries[deferred.size++] = (struct st_cmd_value_t){cmd, value};
} else {
if (cmd->cb(cmd, ctx, value) != 0)
goto Exit;
}
SkipCommand:;
}
for (i = 0; i != semi_deferred.size; ++i) {
struct st_cmd_value_t *pair = semi_deferred.entries + i;
if (pair->cmd->cb(pair->cmd, ctx, pair->value) != 0)
goto Exit;
}
for (i = 0; i != deferred.size; ++i) {
struct st_cmd_value_t *pair = deferred.entries + i;
if (pair->cmd->cb(pair->cmd, ctx, pair->value) != 0)
goto Exit;
}
}
/* call on_exit of every configurator */
if (setup_configurators(ctx, 0, node) != 0)
goto Exit;
ret = 0;
Exit:
free(deferred.entries);
free(semi_deferred.entries);
return ret;
}
static yoml_t *convert_path_config_node(h2o_configurator_command_t *cmd, yoml_t *node)
{
size_t i, j;
switch (node->type) {
case YOML_TYPE_MAPPING:
break;
case YOML_TYPE_SEQUENCE: {
/* convert to mapping */
yoml_t *map = h2o_mem_alloc(sizeof(yoml_t));
*map = (yoml_t){YOML_TYPE_MAPPING};
if (node->filename != NULL)
map->filename = h2o_strdup(NULL, node->filename, SIZE_MAX).base;
map->line = node->line;
map->column = node->column;
if (node->anchor != NULL)
map->anchor = h2o_strdup(NULL, node->anchor, SIZE_MAX).base;
map->_refcnt = 1;
for (i = 0; i != node->data.sequence.size; ++i) {
yoml_t *elem = node->data.sequence.elements[i];
if (elem->type != YOML_TYPE_MAPPING) {
yoml_free(map, NULL);
goto Error;
}
for (j = 0; j != elem->data.mapping.size; ++j) {
yoml_t *elemkey = elem->data.mapping.elements[j].key;
yoml_t *elemvalue = elem->data.mapping.elements[j].value;
map = h2o_mem_realloc(map, offsetof(yoml_t, data.mapping.elements) +
sizeof(yoml_mapping_element_t) * (map->data.mapping.size + 1));
map->data.mapping.elements[map->data.mapping.size].key = elemkey;
map->data.mapping.elements[map->data.mapping.size].value = elemvalue;
++map->data.mapping.size;
++elemkey->_refcnt;
++elemvalue->_refcnt;
}
}
return map;
} break;
default:
Error:
h2o_configurator_errprintf(cmd, node, "value must be a mapping or sequence of mapping");
return NULL;
}
++node->_refcnt;
return node;
}
static int config_path(h2o_configurator_context_t *parent_ctx, h2o_pathconf_t *pathconf, yoml_t *node)
{
h2o_configurator_context_t *path_ctx = create_context(parent_ctx, 0);
path_ctx->pathconf = pathconf;
path_ctx->mimemap = &pathconf->mimemap;
int ret = h2o_configurator_apply_commands(path_ctx, node, H2O_CONFIGURATOR_FLAG_PATH, NULL);
destroy_context(path_ctx);
return ret;
}
static int on_config_paths(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
size_t i;
/* sort by the length of the path (descending) */
for (i = 0; i != node->data.mapping.size; ++i) {
yoml_t *key = node->data.mapping.elements[i].key;
if (key->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(cmd, key, "key (representing the virtual path) must be a string");
return -1;
}
if (strlen(key->data.scalar) == 0) {
h2o_configurator_errprintf(cmd, key, "key (representing the virtual path) must not be an empty string");
return -1;
}
}
for (i = 0; i != node->data.mapping.size; ++i) {
yoml_t *key = node->data.mapping.elements[i].key, *value;
if ((value = convert_path_config_node(cmd, node->data.mapping.elements[i].value)) == NULL)
return -1;
h2o_pathconf_t *pathconf = h2o_config_register_path(ctx->hostconf, key->data.scalar, 0);
int cmd_ret = config_path(ctx, pathconf, value);
yoml_free(value, NULL);
if (cmd_ret != 0)
return cmd_ret;
}
/* configure fallback path along with ordinary paths */
return config_path(ctx, &ctx->hostconf->fallback_path, NULL);
}
static int on_config_hosts(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
size_t i;
if (node->data.mapping.size == 0) {
h2o_configurator_errprintf(cmd, node, "the mapping cannot be empty");
return -1;
}
for (i = 0; i != node->data.mapping.size; ++i) {
yoml_t *key = node->data.mapping.elements[i].key;
yoml_t *value = node->data.mapping.elements[i].value;
h2o_iovec_t hostname;
uint16_t port;
if (key->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(cmd, key, "key (representing the hostname) must be a string");
return -1;
}
if (h2o_url_parse_hostport(key->data.scalar, strlen(key->data.scalar), &hostname, &port) == NULL) {
h2o_configurator_errprintf(cmd, key, "invalid key (must be either `host` or `host:port`)");
return -1;
}
assert(hostname.len != 0);
if ((hostname.base[0] == '*' && !(hostname.len == 1 || hostname.base[1] == '.')) ||
memchr(hostname.base + 1, '*', hostname.len - 1) != NULL) {
h2o_configurator_errprintf(cmd, key, "wildcard (*) can only be used at the start of the hostname");
return -1;
}
h2o_configurator_context_t *host_ctx = create_context(ctx, 0);
if ((host_ctx->hostconf = h2o_config_register_host(host_ctx->globalconf, hostname, port)) == NULL) {
h2o_configurator_errprintf(cmd, key, "duplicate host entry");
destroy_context(host_ctx);
return -1;
}
host_ctx->mimemap = &host_ctx->hostconf->mimemap;
int cmd_ret = h2o_configurator_apply_commands(host_ctx, value, H2O_CONFIGURATOR_FLAG_HOST, NULL);
destroy_context(host_ctx);
if (cmd_ret != 0)
return -1;
if (yoml_get(value, "paths") == NULL) {
h2o_configurator_errprintf(NULL, value, "mandatory configuration directive `paths` is missing");
return -1;
}
}
return 0;
}
static int on_config_strict_match(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
h2o_hostconf_t *hostconf = ctx->hostconf;
ssize_t on;
if ((on = h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1)
return -1;
hostconf->strict_match = (uint8_t)on;
return 0;
}
static int on_config_limit_request_body(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return h2o_configurator_scanf(cmd, node, "%zu", &ctx->globalconf->max_request_entity_size);
}
static int on_config_max_delegations(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return h2o_configurator_scanf(cmd, node, "%u", &ctx->globalconf->max_delegations);
}
static int on_config_max_reprocesses(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return h2o_configurator_scanf(cmd, node, "%u", &ctx->globalconf->max_reprocesses);
}
static int on_config_handshake_timeout(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return config_timeout(cmd, node, &ctx->globalconf->handshake_timeout);
}
static int on_config_http1_request_timeout(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return config_timeout(cmd, node, &ctx->globalconf->http1.req_timeout);
}
static int on_config_http1_request_io_timeout(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return config_timeout(cmd, node, &ctx->globalconf->http1.req_io_timeout);
}
static int on_config_http1_upgrade_to_http2(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
ssize_t ret = h2o_configurator_get_one_of(cmd, node, "OFF,ON");
if (ret == -1)
return -1;
ctx->globalconf->http1.upgrade_to_http2 = (int)ret;
return 0;
}
static int on_config_http2_idle_timeout(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return config_timeout(cmd, node, &ctx->globalconf->http2.idle_timeout);
}
static int on_config_http2_graceful_shutdown_timeout(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return config_timeout(cmd, node, &ctx->globalconf->http2.graceful_shutdown_timeout);
}
static int on_config_http2_max_concurrent_requests_per_connection(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx,
yoml_t *node)
{
return h2o_configurator_scanf(cmd, node, "%zu", &ctx->globalconf->http2.max_concurrent_requests_per_connection);
}
static int on_config_http2_max_concurrent_streaming_requests_per_connection(h2o_configurator_command_t *cmd,
h2o_configurator_context_t *ctx, yoml_t *node)
{
return h2o_configurator_scanf(cmd, node, "%zu", &ctx->globalconf->http2.max_concurrent_streaming_requests_per_connection);
}
static int on_config_http2_input_window_size(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
uint32_t v;
if (h2o_configurator_scanf(cmd, node, "%" SCNu32, &v) != 0)
return -1;
if (!(H2O_HTTP2_MIN_STREAM_WINDOW_SIZE <= v && v <= H2O_HTTP2_MAX_STREAM_WINDOW_SIZE)) {
h2o_configurator_errprintf(cmd, node, "window size must be between %" PRIu32 " and %" PRIu32,
(uint32_t)H2O_HTTP2_MIN_STREAM_WINDOW_SIZE, (uint32_t)H2O_HTTP2_MAX_STREAM_WINDOW_SIZE);
return -1;
}
ctx->globalconf->http2.active_stream_window_size = v;
return 0;
}
static int on_config_http2_latency_optimization_min_rtt(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx,
yoml_t *node)
{
return h2o_configurator_scanf(cmd, node, "%u", &ctx->globalconf->http2.latency_optimization.min_rtt);
}
static int on_config_http2_latency_optimization_max_additional_delay(h2o_configurator_command_t *cmd,
h2o_configurator_context_t *ctx, yoml_t *node)
{
double ratio;
if (h2o_configurator_scanf(cmd, node, "%lf", &ratio) != 0)
return -1;
if (!(0.0 < ratio)) {
h2o_configurator_errprintf(cmd, node, "ratio must be a positive number");
return -1;
}
ctx->globalconf->http2.latency_optimization.max_additional_delay = 100 * ratio;
return 0;
}
static int on_config_http2_latency_optimization_max_cwnd(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx,
yoml_t *node)
{
return h2o_configurator_scanf(cmd, node, "%u", &ctx->globalconf->http2.latency_optimization.max_cwnd);
}
static int on_config_http2_reprioritize_blocking_assets(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx,
yoml_t *node)
{
struct st_core_configurator_t *self = (void *)cmd->configurator;
ssize_t on;
if ((on = h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1)
return -1;
self->vars->http2.reprioritize_blocking_assets = (int)on;
return 0;
}
static int on_config_http2_push_preload(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
struct st_core_configurator_t *self = (void *)cmd->configurator;
ssize_t on;
if ((on = h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1)
return -1;
self->vars->http2.push_preload = (int)on;
return 0;
}
static int on_config_http2_allow_cross_origin_push(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
struct st_core_configurator_t *self = (void *)cmd->configurator;
ssize_t on;
if ((on = h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1)
return -1;
self->vars->http2.allow_cross_origin_push = (int)on;
return 0;
}
static int on_config_http2_casper(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
static const h2o_casper_conf_t defaults = {
13, /* casper_bits: default (2^13 ~= 100 assets * 1/0.01 collision probability) */
0 /* track blocking assets only */
};
struct st_core_configurator_t *self = (void *)cmd->configurator;
switch (node->type) {
case YOML_TYPE_SCALAR:
if (strcasecmp(node->data.scalar, "OFF") == 0) {
self->vars->http2.casper = (h2o_casper_conf_t){0};
} else if (strcasecmp(node->data.scalar, "ON") == 0) {
self->vars->http2.casper = defaults;
}
break;
case YOML_TYPE_MAPPING: {
/* set to default */
self->vars->http2.casper = defaults;
/* override the attributes defined */
yoml_t **capacity_bits, **tracking_types;
if (h2o_configurator_parse_mapping(cmd, node, NULL, "capacity-bits:s,tracking-types:*", &capacity_bits, &tracking_types) !=
0)
return -1;
if (capacity_bits != NULL) {
if (!(sscanf((*capacity_bits)->data.scalar, "%u", &self->vars->http2.casper.capacity_bits) == 1 &&
self->vars->http2.casper.capacity_bits < 16)) {
h2o_configurator_errprintf(cmd, *capacity_bits, "value of `capacity-bits` must be an integer between 0 to 15");
return -1;
}
}
if (tracking_types != NULL && (self->vars->http2.casper.track_all_types =
(int)h2o_configurator_get_one_of(cmd, *tracking_types, "blocking-assets,all")) == -1)
return -1;
} break;
default:
h2o_configurator_errprintf(cmd, node, "value must be `OFF`,`ON` or a mapping containing the necessary attributes");
return -1;
}
return 0;
}
static int on_config_http3_idle_timeout(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return config_timeout(cmd, node, &ctx->globalconf->http3.idle_timeout);
}
static int on_config_http3_graceful_shutdown_timeout(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
return config_timeout(cmd, node, &ctx->globalconf->http3.graceful_shutdown_timeout);
}
static int on_config_http3_input_window_size(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
uint32_t v;
if (h2o_configurator_scanf(cmd, node, "%" SCNu32, &v) != 0)
return -1;
if (v < H2O_HTTP3_INITIAL_REQUEST_STREAM_WINDOW_SIZE) {
h2o_configurator_errprintf(cmd, node, "window size must be no less than %u",
(unsigned)H2O_HTTP3_INITIAL_REQUEST_STREAM_WINDOW_SIZE);
return -1;
}
ctx->globalconf->http3.active_stream_window_size = v;
return 0;
}
static int on_config_http3_ack_frequency(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
double v;
if (h2o_configurator_scanf(cmd, node, "%lf", &v) != 0)
return -1;
if (!(0 <= v && v <= 1)) {
h2o_configurator_errprintf(cmd, node, "ack frequency must be between 0 and 1");
return -1;
}
ctx->globalconf->http3.ack_frequency = (uint16_t)(v * 1024);
return 0;
}
static int on_config_http3_allow_delayed_ack(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
ssize_t on;
if ((on = h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1)
return -1;
ctx->globalconf->http3.allow_delayed_ack = (uint8_t)on;
return 0;
}
static int on_config_http3_gso(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
ssize_t on;
if ((on = h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1)
return -1;
#if !defined(UDP_SEGMENT)
if (on) {
h2o_configurator_errprintf(cmd, node, "this build does not support UDP GSO");
return -1;
}
#endif
ctx->globalconf->http3.use_gso = (uint8_t)on;
return 0;
}
static int assert_is_mimetype(h2o_configurator_command_t *cmd, yoml_t *node)
{
if (node->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(cmd, node, "expected a scalar (mime-type)");
return -1;
}
if (strchr(node->data.scalar, '/') == NULL) {
h2o_configurator_errprintf(cmd, node, "the string \"%s\" does not look like a mime-type", node->data.scalar);
return -1;
}
return 0;
}
static int assert_is_extension(h2o_configurator_command_t *cmd, yoml_t *node)
{
if (node->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(cmd, node, "expected a scalar (extension)");
return -1;
}
if (node->data.scalar[0] != '.') {
h2o_configurator_errprintf(cmd, node, "given extension \"%s\" does not start with a \".\"", node->data.scalar);
return -1;
}
if (node->data.scalar[1] == '\0') {
h2o_configurator_errprintf(cmd, node, "given extension \".\" is invalid: at least 2 characters are required");
return -1;
}
return 0;
}
static int set_mimetypes(h2o_configurator_command_t *cmd, h2o_mimemap_t *mimemap, yoml_t *node)
{
size_t i, j;
assert(node->type == YOML_TYPE_MAPPING);
for (i = 0; i != node->data.mapping.size; ++i) {
yoml_t *key = node->data.mapping.elements[i].key;
yoml_t *value = node->data.mapping.elements[i].value;
if (assert_is_mimetype(cmd, key) != 0)
return -1;
switch (value->type) {
case YOML_TYPE_SCALAR:
if (assert_is_extension(cmd, value) != 0)
return -1;
h2o_mimemap_define_mimetype(mimemap, value->data.scalar + 1, key->data.scalar, NULL);
break;
case YOML_TYPE_SEQUENCE:
for (j = 0; j != value->data.sequence.size; ++j) {
yoml_t *ext_node = value->data.sequence.elements[j];
if (assert_is_extension(cmd, ext_node) != 0)
return -1;
h2o_mimemap_define_mimetype(mimemap, ext_node->data.scalar + 1, key->data.scalar, NULL);
}
break;
case YOML_TYPE_MAPPING: {
yoml_t **is_compressible, **priority, **extensions;
h2o_mime_attributes_t attr;
h2o_mimemap_get_default_attributes(key->data.scalar, &attr);
if (h2o_configurator_parse_mapping(cmd, value, "extensions:a", "is_compressible:*,priority:*", &extensions,
&is_compressible, &priority) != 0)
return -1;
if (is_compressible != NULL) {
switch (h2o_configurator_get_one_of(cmd, *is_compressible, "YES,NO")) {
case 0:
attr.is_compressible = 1;
break;
case 1:
attr.is_compressible = 0;
break;
default:
return -1;
}
}
if (priority != NULL) {
switch (h2o_configurator_get_one_of(cmd, *priority, "normal,highest")) {
case 0:
attr.priority = H2O_MIME_ATTRIBUTE_PRIORITY_NORMAL;
break;
case 1:
attr.priority = H2O_MIME_ATTRIBUTE_PRIORITY_HIGHEST;
break;
default:
return -1;
}
}
for (j = 0; j != (*extensions)->data.sequence.size; ++j) {
yoml_t *ext_node = (*extensions)->data.sequence.elements[j];
if (assert_is_extension(cmd, ext_node) != 0)
return -1;
h2o_mimemap_define_mimetype(mimemap, ext_node->data.scalar + 1, key->data.scalar, &attr);
}
} break;
default:
h2o_fatal("logic flaw");
}
}
return 0;
}
static int on_config_mime_settypes(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
h2o_mimemap_t *newmap = h2o_mimemap_create();
h2o_mimemap_clear_types(newmap);
h2o_mimemap_set_default_type(newmap, h2o_mimemap_get_default_type(*ctx->mimemap)->data.mimetype.base, NULL);
if (set_mimetypes(cmd, newmap, node) != 0) {
h2o_mem_release_shared(newmap);
return -1;
}
h2o_mem_release_shared(*ctx->mimemap);
*ctx->mimemap = newmap;
return 0;
}
static void clone_mimemap_if_clean(h2o_configurator_context_t *ctx)
{
if (ctx->parent == NULL)
return;
if (*ctx->mimemap != *ctx->parent->mimemap)
return;
h2o_mem_release_shared(*ctx->mimemap);
/* even after release, ctx->mimemap is still retained by the parent and therefore we can use it as the argument to clone */
*ctx->mimemap = h2o_mimemap_clone(*ctx->mimemap);
}
static int on_config_mime_addtypes(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
clone_mimemap_if_clean(ctx);
return set_mimetypes(cmd, *ctx->mimemap, node);
}
static int on_config_mime_removetypes(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
size_t i;
clone_mimemap_if_clean(ctx);
for (i = 0; i != node->data.sequence.size; ++i) {
yoml_t *ext_node = node->data.sequence.elements[i];
if (assert_is_extension(cmd, ext_node) != 0)
return -1;
h2o_mimemap_remove_type(*ctx->mimemap, ext_node->data.scalar + 1);
}
return 0;
}
static int on_config_mime_setdefaulttype(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
if (assert_is_mimetype(cmd, node) != 0)
return -1;
clone_mimemap_if_clean(ctx);
h2o_mimemap_set_default_type(*ctx->mimemap, node->data.scalar, NULL);
return 0;
}
static const char *normalize_ext(h2o_configurator_command_t *cmd, yoml_t *node)
{
if (strcmp(node->data.scalar, "default") == 0) {
/* empty string means default */
return "";
} else if (assert_is_extension(cmd, node) == 0) {
return node->data.scalar + 1;
} else {
return NULL;
}
}
static int on_config_custom_handler(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
static const char *ignore_commands[] = {"extension", NULL};
yoml_t *ext_node;
const char **exts;
h2o_mimemap_type_t *type = NULL;
if (node->type != YOML_TYPE_MAPPING) {
h2o_configurator_errprintf(cmd, node, "argument must be a MAPPING");
return -1;
}
if ((ext_node = yoml_get(node, "extension")) == NULL) {
h2o_configurator_errprintf(cmd, node, "mandatory key `extension` is missing");
return -1;
}
/* create dynamic type */
switch (ext_node->type) {
case YOML_TYPE_SCALAR:
exts = alloca(2 * sizeof(*exts));
if ((exts[0] = normalize_ext(cmd, ext_node)) == NULL)
return -1;
exts[1] = NULL;
break;
case YOML_TYPE_SEQUENCE: {
exts = alloca((ext_node->data.sequence.size + 1) * sizeof(*exts));
size_t i;
for (i = 0; i != ext_node->data.sequence.size; ++i) {
yoml_t *n = ext_node->data.sequence.elements[i];
if ((exts[i] = normalize_ext(cmd, n)) == NULL)
return -1;
}
exts[i] = NULL;
} break;
default:
h2o_configurator_errprintf(cmd, ext_node, "`extensions` must be a scalar or sequence of scalar");
return -1;
}
clone_mimemap_if_clean(ctx);
type = h2o_mimemap_define_dynamic(*ctx->mimemap, exts, ctx->globalconf);
/* apply the configuration commands */
h2o_configurator_context_t *ext_ctx = create_context(ctx, 1);
ext_ctx->pathconf = &type->data.dynamic.pathconf;
ext_ctx->mimemap = NULL;
int cmd_ret = h2o_configurator_apply_commands(ext_ctx, node, H2O_CONFIGURATOR_FLAG_EXTENSION, ignore_commands);
destroy_context(ext_ctx);
if (cmd_ret != 0)
return cmd_ret;
switch (type->data.dynamic.pathconf.handlers.size) {
case 1:
break;
case 0:
h2o_configurator_errprintf(cmd, node, "no handler declared for given extension");
return -1;
default:
h2o_configurator_errprintf(cmd, node, "cannot assign more than one handler for given extension");
return -1;
}
return 0;
}
static void inherit_env_if_necessary(h2o_configurator_context_t *ctx)
{
if (ctx->env == (ctx->parent != NULL ? ctx->parent->env : NULL))
ctx->env = h2o_config_create_envconf(ctx->env);
}
static int on_config_setenv(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
size_t i;
inherit_env_if_necessary(ctx);
for (i = 0; i != node->data.mapping.size; ++i) {
yoml_t *key = node->data.mapping.elements[i].key, *value = node->data.mapping.elements[i].value;
if (key->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(cmd, key, "key must be a scalar");
return -1;
}
if (value->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(cmd, value, "value must be a scalar");
return -1;
}
h2o_config_setenv(ctx->env, key->data.scalar, value->data.scalar);
}
return 0;
}
static int on_config_unsetenv(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
inherit_env_if_necessary(ctx);
switch (node->type) {
case YOML_TYPE_SCALAR:
h2o_config_unsetenv(ctx->env, node->data.scalar);
break;
case YOML_TYPE_SEQUENCE: {
size_t i;
for (i = 0; i != node->data.sequence.size; ++i) {
yoml_t *element = node->data.sequence.elements[i];
if (element->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(cmd, element, "element of a sequence passed to unsetenv must be a scalar");
return -1;
}
h2o_config_unsetenv(ctx->env, element->data.scalar);
}
} break;
default:
h2o_configurator_errprintf(cmd, node, "argument to unsetenv must be either a scalar or a sequence");
return -1;
}
return 0;
}
static int on_config_server_name(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
ctx->globalconf->server_name = h2o_strdup(NULL, node->data.scalar, SIZE_MAX);
return 0;
}
static int on_config_send_server_name(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
switch (h2o_configurator_get_one_of(cmd, node, "OFF,ON,preserve")) {
case 0: /* off */
ctx->globalconf->server_name = h2o_iovec_init(H2O_STRLIT(""));
break;
case 1: /* on */
break;
case 2: /* preserve */
ctx->globalconf->server_name = h2o_iovec_init(H2O_STRLIT(""));
ctx->globalconf->proxy.preserve_server_header = 1;
break;
default:
return -1;
}
return 0;
}
static int on_config_error_log_emit_request_errors(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
struct st_core_configurator_t *self = (void *)cmd->configurator;
ssize_t on;
if ((on = h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1)
return -1;
self->vars->error_log.emit_request_errors = (int)on;
return 0;
}
static int on_config_send_informational(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
switch (h2o_configurator_get_one_of(cmd, node, "except-h1,none,all")) {
case 0:
ctx->globalconf->send_informational_mode = H2O_SEND_INFORMATIONAL_MODE_EXCEPT_H1;
break;
case 1:
ctx->globalconf->send_informational_mode = H2O_SEND_INFORMATIONAL_MODE_NONE;
break;
case 2:
ctx->globalconf->send_informational_mode = H2O_SEND_INFORMATIONAL_MODE_ALL;
break;
default:
return -1;
}
return 0;
}
static int on_config_stash(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
/* do nothing */
return 0;
}
static int on_config_usdt_selective_tracing(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
ssize_t on;
if ((on = h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1)
return -1;
ctx->globalconf->usdt_selective_tracing = (int)on;
return 0;
}
void h2o_configurator__init_core(h2o_globalconf_t *conf)
{
/* check if already initialized */
if (h2o_configurator_get_command(conf, "files") != NULL)
return;
{ /* `hosts` and `paths` */
h2o_configurator_t *c = h2o_configurator_create(conf, sizeof(*c));
h2o_configurator_define_command(
c, "hosts", H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_MAPPING | H2O_CONFIGURATOR_FLAG_DEFERRED,
on_config_hosts);
h2o_configurator_define_command(
c, "paths", H2O_CONFIGURATOR_FLAG_HOST | H2O_CONFIGURATOR_FLAG_EXPECT_MAPPING | H2O_CONFIGURATOR_FLAG_DEFERRED,
on_config_paths);
h2o_configurator_define_command(c, "strict-match", H2O_CONFIGURATOR_FLAG_HOST | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_strict_match);
};
{ /* setup global configurators */
struct st_core_configurator_t *c = (void *)h2o_configurator_create(conf, sizeof(*c));
c->super.enter = on_core_enter;
c->super.exit = on_core_exit;
c->vars = c->_vars_stack;
c->vars->http2.reprioritize_blocking_assets = 1; /* defaults to ON */
c->vars->http2.push_preload = 1; /* defaults to ON */
c->vars->error_log.emit_request_errors = 1; /* defaults to ON */
h2o_configurator_define_command(&c->super, "limit-request-body",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_limit_request_body);
h2o_configurator_define_command(&c->super, "max-delegations",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_max_delegations);
h2o_configurator_define_command(&c->super, "max-reprocesses",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_max_reprocesses);
h2o_configurator_define_command(&c->super, "handshake-timeout",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_handshake_timeout);
h2o_configurator_define_command(&c->super, "http1-request-timeout",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http1_request_timeout);
h2o_configurator_define_command(&c->super, "http1-request-io-timeout",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http1_request_io_timeout);
h2o_configurator_define_command(&c->super, "http1-upgrade-to-http2",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http1_upgrade_to_http2);
h2o_configurator_define_command(&c->super, "http2-idle-timeout",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_idle_timeout);
h2o_configurator_define_command(&c->super, "http2-graceful-shutdown-timeout",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_graceful_shutdown_timeout);
h2o_configurator_define_command(&c->super, "http2-max-concurrent-requests-per-connection",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_max_concurrent_requests_per_connection);
h2o_configurator_define_command(&c->super, "http2-max-concurrent-streaming-requests-per-connection",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_max_concurrent_streaming_requests_per_connection);
h2o_configurator_define_command(&c->super, "http2-input-window-size",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_input_window_size);
h2o_configurator_define_command(&c->super, "http2-latency-optimization-min-rtt",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_latency_optimization_min_rtt);
h2o_configurator_define_command(&c->super, "http2-latency-optimization-max-additional-delay",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_latency_optimization_max_additional_delay);
h2o_configurator_define_command(&c->super, "http2-latency-optimization-max-cwnd",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_latency_optimization_max_cwnd);
h2o_configurator_define_command(&c->super, "http2-reprioritize-blocking-assets",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_HOST |
H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_reprioritize_blocking_assets);
h2o_configurator_define_command(&c->super, "http2-push-preload",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_HOST |
H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_push_preload);
h2o_configurator_define_command(&c->super, "http2-allow-cross-origin-push",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_PATH |
H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http2_allow_cross_origin_push);
h2o_configurator_define_command(&c->super, "http2-casper", H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_HOST,
on_config_http2_casper);
h2o_configurator_define_command(&c->super, "http3-idle-timeout",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http3_idle_timeout);
h2o_configurator_define_command(&c->super, "http3-graceful-shutdown-timeout",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http3_graceful_shutdown_timeout);
h2o_configurator_define_command(&c->super, "http3-input-window-size",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http3_input_window_size);
h2o_configurator_define_command(&c->super, "http3-ack-frequency",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http3_ack_frequency);
h2o_configurator_define_command(&c->super, "http3-allow-delayed-ack",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http3_allow_delayed_ack);
h2o_configurator_define_command(&c->super, "http3-gso", H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_http3_gso);
h2o_configurator_define_command(&c->super, "file.mime.settypes",
(H2O_CONFIGURATOR_FLAG_ALL_LEVELS & ~H2O_CONFIGURATOR_FLAG_EXTENSION) |
H2O_CONFIGURATOR_FLAG_EXPECT_MAPPING,
on_config_mime_settypes);
h2o_configurator_define_command(&c->super, "file.mime.addtypes",
(H2O_CONFIGURATOR_FLAG_ALL_LEVELS & ~H2O_CONFIGURATOR_FLAG_EXTENSION) |
H2O_CONFIGURATOR_FLAG_EXPECT_MAPPING,
on_config_mime_addtypes);
h2o_configurator_define_command(&c->super, "file.mime.removetypes",
(H2O_CONFIGURATOR_FLAG_ALL_LEVELS & ~H2O_CONFIGURATOR_FLAG_EXTENSION) |
H2O_CONFIGURATOR_FLAG_EXPECT_SEQUENCE,
on_config_mime_removetypes);
h2o_configurator_define_command(&c->super, "file.mime.setdefaulttype",
(H2O_CONFIGURATOR_FLAG_ALL_LEVELS & ~H2O_CONFIGURATOR_FLAG_EXTENSION) |
H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_mime_setdefaulttype);
h2o_configurator_define_command(&c->super, "file.custom-handler",
(H2O_CONFIGURATOR_FLAG_ALL_LEVELS & ~H2O_CONFIGURATOR_FLAG_EXTENSION) |
H2O_CONFIGURATOR_FLAG_SEMI_DEFERRED,
on_config_custom_handler);
h2o_configurator_define_command(&c->super, "setenv",
H2O_CONFIGURATOR_FLAG_ALL_LEVELS | H2O_CONFIGURATOR_FLAG_EXPECT_MAPPING, on_config_setenv);
h2o_configurator_define_command(&c->super, "unsetenv", H2O_CONFIGURATOR_FLAG_ALL_LEVELS, on_config_unsetenv);
h2o_configurator_define_command(&c->super, "server-name",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR, on_config_server_name);
h2o_configurator_define_command(&c->super, "send-server-name",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR |
H2O_CONFIGURATOR_FLAG_DEFERRED,
on_config_send_server_name);
h2o_configurator_define_command(&c->super, "error-log.emit-request-errors",
H2O_CONFIGURATOR_FLAG_ALL_LEVELS | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_error_log_emit_request_errors);
h2o_configurator_define_command(&c->super, "send-informational",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_send_informational);
h2o_configurator_define_command(&c->super, "stash", H2O_CONFIGURATOR_FLAG_ALL_LEVELS, on_config_stash);
h2o_configurator_define_command(&c->super, "usdt-selective-tracing",
H2O_CONFIGURATOR_FLAG_GLOBAL | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_usdt_selective_tracing);
}
}
void h2o_configurator__dispose_configurators(h2o_globalconf_t *conf)
{
while (!h2o_linklist_is_empty(&conf->configurators)) {
h2o_configurator_t *c = H2O_STRUCT_FROM_MEMBER(h2o_configurator_t, _link, conf->configurators.next);
h2o_linklist_unlink(&c->_link);
if (c->dispose != NULL)
c->dispose(c);
destroy_configurator(c);
}
}
h2o_configurator_t *h2o_configurator_create(h2o_globalconf_t *conf, size_t sz)
{
h2o_configurator_t *c;
assert(sz >= sizeof(*c));
c = h2o_mem_alloc(sz);
memset(c, 0, sz);
h2o_linklist_insert(&conf->configurators, &c->_link);
return c;
}
void h2o_configurator_define_command(h2o_configurator_t *configurator, const char *name, int flags, h2o_configurator_command_cb cb)
{
h2o_configurator_command_t *cmd;
h2o_vector_reserve(NULL, &configurator->commands, configurator->commands.size + 1);
cmd = configurator->commands.entries + configurator->commands.size++;
cmd->configurator = configurator;
cmd->flags = flags;
cmd->name = name;
cmd->cb = cb;
}
h2o_configurator_command_t *h2o_configurator_get_command(h2o_globalconf_t *conf, const char *name)
{
h2o_linklist_t *node;
size_t i;
for (node = conf->configurators.next; node != &conf->configurators; node = node->next) {
h2o_configurator_t *configurator = H2O_STRUCT_FROM_MEMBER(h2o_configurator_t, _link, node);
for (i = 0; i != configurator->commands.size; ++i) {
h2o_configurator_command_t *cmd = configurator->commands.entries + i;
if (strcmp(cmd->name, name) == 0) {
return cmd;
}
}
}
return NULL;
}
int h2o_configurator_apply(h2o_globalconf_t *config, yoml_t *node, int dry_run)
{
h2o_configurator_context_t *ctx = create_context(NULL, 0);
ctx->globalconf = config;
ctx->mimemap = &ctx->globalconf->mimemap;
ctx->dry_run = dry_run;
int cmd_ret = h2o_configurator_apply_commands(ctx, node, H2O_CONFIGURATOR_FLAG_GLOBAL, NULL);
destroy_context(ctx);
if (cmd_ret != 0)
return cmd_ret;
if (config->hosts[0] == NULL) {
h2o_configurator_errprintf(NULL, node, "mandatory configuration directive `hosts` is missing");
return -1;
}
return 0;
}
void h2o_configurator_errprintf(h2o_configurator_command_t *cmd, yoml_t *node, const char *reason, ...)
{
char buf[1024];
va_list args;
h2o_error_printf("[%s:%zu] ", node->filename ? node->filename : "-", node->line + 1);
if (cmd != NULL)
h2o_error_printf("in command %s, ", cmd->name);
va_start(args, reason);
vsnprintf(buf, sizeof(buf), reason, args);
va_end(args);
h2o_error_printf("%s\n", buf);
}
int h2o_configurator_scanf(h2o_configurator_command_t *cmd, yoml_t *node, const char *fmt, ...)
{
va_list args;
int sscan_ret;
if (node->type != YOML_TYPE_SCALAR)
goto Error;
va_start(args, fmt);
sscan_ret = vsscanf(node->data.scalar, fmt, args);
va_end(args);
if (sscan_ret != 1)
goto Error;
return 0;
Error:
h2o_configurator_errprintf(cmd, node, "argument must match the format: %s", fmt);
return -1;
}
ssize_t h2o_configurator_get_one_of(h2o_configurator_command_t *cmd, yoml_t *node, const char *candidates)
{
const char *config_str, *cand_str;
ssize_t config_str_len, cand_index;
if (node->type != YOML_TYPE_SCALAR)
goto Error;
config_str = node->data.scalar;
config_str_len = strlen(config_str);
cand_str = candidates;
for (cand_index = 0;; ++cand_index) {
if (strncasecmp(cand_str, config_str, config_str_len) == 0 &&
(cand_str[config_str_len] == '\0' || cand_str[config_str_len] == ',')) {
/* found */
return cand_index;
}
cand_str = strchr(cand_str, ',');
if (cand_str == NULL)
goto Error;
cand_str += 1; /* skip ',' */
}
/* not reached */
Error:
h2o_configurator_errprintf(cmd, node, "argument must be one of: %s", candidates);
return -1;
}
static const char *get_next_key(const char *start, h2o_iovec_t *output, unsigned *type_mask)
{
const char *p = strchr(start, ':');
if (p == NULL)
goto Error;
/* set output */
*output = h2o_iovec_init(start, p - start);
/* parse attributes */
*type_mask = 0;
for (++p; *p != '\0'; ++p) {
switch (*p) {
case ',':
return p + 1;
case 's':
*type_mask |= 1u << YOML_TYPE_SCALAR;
break;
case 'a':
*type_mask |= 1u << YOML_TYPE_SEQUENCE;
break;
case 'm':
*type_mask |= 1u << YOML_TYPE_MAPPING;
break;
case '*':
*type_mask |= (1u << YOML_TYPE_SCALAR) | (1u << YOML_TYPE_SEQUENCE) | (1u << YOML_TYPE_MAPPING);
break;
default:
goto Error;
}
}
return NULL;
Error:
h2o_fatal("detected invalid or missing type specifier; input is: %s\n", start);
}
int h2o_configurator__do_parse_mapping(h2o_configurator_command_t *cmd, yoml_t *node, const char *keys_required,
const char *keys_optional, yoml_t ****values, size_t num_values)
{
struct {
h2o_iovec_t key;
int is_required;
unsigned type_mask;
} *keys = alloca(sizeof(keys[0]) * num_values);
size_t i, j;
assert(node->type == YOML_TYPE_MAPPING);
/* parse keys */
i = 0;
if (keys_required != NULL) {
const char *p = keys_required;
for (; p != NULL; ++i) {
assert(i < num_values);
p = get_next_key(p, &keys[i].key, &keys[i].type_mask);
keys[i].is_required = 1;
}
}
if (keys_optional != NULL) {
const char *p = keys_optional;
for (; p != NULL; ++i) {
assert(i < num_values);
p = get_next_key(p, &keys[i].key, &keys[i].type_mask);
keys[i].is_required = 0;
}
}
assert(i == num_values);
/* clear the output */
for (i = 0; i != num_values; ++i)
*values[i] = NULL;
/* extract the attributes */
for (i = 0; i != node->data.mapping.size; ++i) {
yoml_mapping_element_t *element = node->data.mapping.elements + i;
if (element->key->type != YOML_TYPE_SCALAR) {
h2o_configurator_errprintf(cmd, element->key, "key must be a scalar");
return -1;
}
size_t element_key_len = strlen(element->key->data.scalar);
for (j = 0; j != num_values; ++j)
if (keys[j].key.len == element_key_len &&
strncasecmp(keys[j].key.base, element->key->data.scalar, element_key_len) == 0)
goto Found;
/* not found */
h2o_configurator_errprintf(cmd, element->key, "unexpected key:%s", element->key->data.scalar);
return -1;
Found:
if (*values[j] != NULL) {
h2o_configurator_errprintf(cmd, element->key, "duplicate key found");
return -1;
}
if ((keys[j].type_mask & (1u << element->value->type)) == 0) {
char permitted_types[sizeof(" or a scalar or a sequence or a mapping")] = "";
snprintf(permitted_types, sizeof(permitted_types), "%s%s%s",
(keys[j].type_mask & (1u << YOML_TYPE_SCALAR)) != 0 ? " or a scalar" : "",
(keys[j].type_mask & (1u << YOML_TYPE_SEQUENCE)) != 0 ? " or a sequence" : "",
(keys[j].type_mask & (1u << YOML_TYPE_MAPPING)) != 0 ? " or a mapping" : "");
assert(strlen(permitted_types) != 0);
h2o_configurator_errprintf(cmd, element->value, "attribute `%s` must be %s", element->key->data.scalar,
permitted_types + 4);
return -1;
}
*values[j] = &element->value;
}
/* check if any of the required keys are missing */
for (i = 0; i < num_values && keys[i].is_required; ++i) {
if (*values[i] == NULL) {
h2o_configurator_errprintf(cmd, node, "cannot find mandatory attribute: %.*s", (int)keys[i].key.len, keys[i].key.base);
return -1;
}
}
return 0;
}
char *h2o_configurator_get_cmd_path(const char *cmd)
{
char *root, *cmd_fullpath;
/* just return the cmd (being strdup'ed) in case we do not need to prefix the value */
if (cmd[0] == '/' || strchr(cmd, '/') == NULL)
goto ReturnOrig;
/* obtain root */
if ((root = getenv("H2O_ROOT")) == NULL) {
root = H2O_TO_STR(H2O_ROOT);
}
/* build full-path and return */
cmd_fullpath = h2o_mem_alloc(strlen(root) + strlen(cmd) + 2);
sprintf(cmd_fullpath, "%s/%s", root, cmd);
return cmd_fullpath;
ReturnOrig:
return h2o_strdup(NULL, cmd, SIZE_MAX).base;
}
|
5eb01eb75d99550781b1a181d755a8dcc80741cd
|
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
|
/PWGPP/T0/spectrum/EventStructT0.h
|
c97d305794267f6910d9d5cbddc5d757de2db1c5
|
[] |
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
| 4,208
|
h
|
EventStructT0.h
|
#ifndef EventStructT0_cxx
#define EventStructT0_cxx
#include "TTree.h"
#include "TObjString.h"
#include "Rtypes.h"
struct EventStructT0 {
//V0 timing
Float_t fTimeV0A;
Float_t fTimeV0C;
//Pileup
Bool_t fIsPileup;
Bool_t fIsPileupLowMult;
//Physics selection
Bool_t fIsPhysSel;
//SPD vertex variables
Int_t fNcontSPD;
Float_t fVertexSPD_Z;
Double_t fVtxSPDresZ;
//Track vertex variables
Int_t fNcontTrack;
Float_t fVertexTrack_Z;
Double_t fVtxTrackResZ;
//Global vertex variables
Int_t fNcontGlobal;
Float_t fVertexGlobal_Z;
Double_t fVtxGlobalResZ;
//EventID
ULong64_t fOrbit;
unsigned int fBC;
//Centrality(not used)
Float_t fCentralityV0M;
//T0 trigger
UShort_t fTriggerT0;
Bool_t fIsT0fired;
//CTP trigger
TObjString fTrigger;
ULong64_t fTriggerMask;
ULong64_t fTriggerMaskNext50;
void clear() {
fTimeV0A=-9999;
fTimeV0C=-9999;
fIsPileup=kFALSE;
fIsPileupLowMult=kFALSE;
fIsPhysSel=kFALSE;
fNcontSPD=-1;
fVertexSPD_Z=-9999;
fVtxSPDresZ=-9999;
fNcontTrack=-1;
fVertexTrack_Z=-9999;
fVtxTrackResZ=-9999;
fNcontGlobal=-1;
fVertexGlobal_Z=-9999;
fVtxGlobalResZ=-9999;
fOrbit=0;
fBC=0;
fCentralityV0M=-300;
fTriggerT0=0;
fIsT0fired=kFALSE;
fTrigger="";
fTriggerMask=0;
fTriggerMaskNext50=0;
}
void makeTree(TTree *treeInput) {
//V0 timing
treeInput->Branch("fTimeV0A", &fTimeV0A);
treeInput->Branch("fTimeV0C", &fTimeV0C);
//Pileup
treeInput->Branch("fIsPileup", &fIsPileup);
treeInput->Branch("fIsPileupLowMult", &fIsPileupLowMult);
//Physics selection
treeInput->Branch("fIsPhysSel",&fIsPhysSel);
//Vertex SPD
treeInput->Branch("fNcontSPD",&fNcontSPD);
treeInput->Branch("fVertexSPD_Z",&fVertexSPD_Z);
treeInput->Branch("fVtxSPDresZ",&fVtxSPDresZ);
//Vertex Track
treeInput->Branch("fNcontTrack",&fNcontTrack);
treeInput->Branch("fVertexTrack_Z",&fVertexTrack_Z);
treeInput->Branch("fVtxTrackResZ",&fVtxTrackResZ);
//Vertex Global
treeInput->Branch("fNcontGlobal",&fNcontGlobal);
treeInput->Branch("fVertexGlobal_Z",&fVertexGlobal_Z);
treeInput->Branch("fVtxGlobalResZ",&fVtxGlobalResZ);
//Event ID
treeInput->Branch("fOrbit", &fOrbit);
treeInput->Branch("fBC", &fBC);
//Centrality (not used)
// treeInput->Branch("fCentralityV0M", &fCentralityV0M);
//T0 trigger
treeInput->Branch("fTriggerT0", &fTriggerT0);
treeInput->Branch("fIsT0fired", &fIsT0fired);
//CTP trigger
treeInput->Branch("fTriggerMask", &fTriggerMask);
treeInput->Branch("fTriggerMaskNext50", &fTriggerMaskNext50);
}
void connectTree(TTree *treeInput) {
//V0 timing
treeInput->SetBranchAddress("fTimeV0A", &fTimeV0A);
treeInput->SetBranchAddress("fTimeV0C", &fTimeV0C);
//Pileup
treeInput->SetBranchAddress("fIsPileup", &fIsPileup);
treeInput->SetBranchAddress("fIsPileupLowMult", &fIsPileupLowMult);
//Physics selection
treeInput->SetBranchAddress("fIsPhysSel",&fIsPhysSel);
//Vertex SPD
treeInput->SetBranchAddress("fNcontSPD",&fNcontSPD);
treeInput->SetBranchAddress("fVertexSPD_Z",&fVertexSPD_Z);
treeInput->SetBranchAddress("fVtxSPDresZ",&fVtxSPDresZ);
//Vertex Track
treeInput->SetBranchAddress("fNcontTrack",&fNcontTrack);
treeInput->SetBranchAddress("fVertexTrack_Z",&fVertexTrack_Z);
treeInput->SetBranchAddress("fVtxTrackResZ",&fVtxTrackResZ);
//Vertex Global
treeInput->SetBranchAddress("fNcontGlobal",&fNcontGlobal);
treeInput->SetBranchAddress("fVertexGlobal_Z",&fVertexGlobal_Z);
treeInput->SetBranchAddress("fVtxGlobalResZ",&fVtxGlobalResZ);
//Event ID
treeInput->SetBranchAddress("fOrbit", &fOrbit);
treeInput->SetBranchAddress("fBC", &fBC);
//Centrality (not used)
// treeInput->SetBranchAddress("fCentralityV0M", &fCentralityV0M);
//T0 trigger
treeInput->SetBranchAddress("fTriggerT0", &fTriggerT0);
treeInput->SetBranchAddress("fIsT0fired", &fIsT0fired);
//CTP trigger
treeInput->SetBranchAddress("fTriggerMask", &fTriggerMask);
treeInput->SetBranchAddress("fTriggerMaskNext50", &fTriggerMaskNext50);
}
};
#endif
|
455658a10bb5c2e1845be85a67a48af6051a53db
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/converters/iconv-extra/files/patch-ces__unicode-1-1-utf-7.c
|
c138e3a8f6145d49c21d901094a71a6ff7eafbd3
|
[
"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
| 270
|
c
|
patch-ces__unicode-1-1-utf-7.c
|
--- ces/unicode-1-1-utf-7.c 2002/03/17 11:20:12 1.1
+++ ces/unicode-1-1-utf-7.c 2002/03/17 11:20:21
@@ -33,7 +33,7 @@
#include <stdlib.h>
#define ICONV_INTERNAL
-#include <iconv.h>
+#include <biconv.h>
static inline int
lackofbytes(int bytes, size_t *bytesleft)
|
889e4d7b537a615be6297f262e21c0aaf5d91aeb
|
78dc9f153549b281be709227bc9897931b06260d
|
/generation/WinSDK/RecompiledIdlHeaders/um/d3dnthal.h
|
ffe8bdd9a72742508afa972187f576eabcd4230c
|
[
"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
| 95,261
|
h
|
d3dnthal.h
|
/*==========================================================================
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: d3dnthal.h
* Content: Direct3D HAL include file for NT
*
***************************************************************************/
#ifndef _D3DNTHAL_H_
#define _D3DNTHAL_H_
#include <winapifamily.h>
#pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#include <ddrawint.h>
#ifndef _WINDOWS_
#define _WINDOWS_
#include <d3dtypes.h>
#include <d3dcaps.h>
#undef _WINDOWS_
#else
#include <d3dtypes.h>
#include <d3dcaps.h>
#endif
/*
* If the HAL driver does not implement clipping, it must reserve at least
* this much space at the end of the LocalVertexBuffer for use by the HEL
* clipping. I.e. the vertex buffer contain dwNumVertices+dwNumClipVertices
* vertices. No extra space is needed by the HEL clipping in the
* LocalHVertexBuffer.
*/
#define D3DNTHAL_NUMCLIPVERTICES 20
/*
* If no dwNumVertices is given, this is what will be used.
*/
#define D3DNTHAL_DEFAULT_TL_NUM ((32 * 1024) / sizeof (D3DTLVERTEX))
#define D3DNTHAL_DEFAULT_H_NUM ((32 * 1024) / sizeof (D3DHVERTEX))
/*
* Description for a device.
* This is used to describe a device that is to be created or to query
* the current device.
*
* For DX5 and subsequent runtimes, D3DNTDEVICEDESC is a user-visible
* structure that is not seen by the device drivers. The runtime
* stitches a D3DNTDEVICEDESC together using the D3DNTDEVICEDESC_V1
* embedded in the GLOBALDRIVERDATA and the extended caps queried
* from the driver using GetDriverInfo.
*/
typedef struct _D3DNTHALDeviceDesc_V1
{
DWORD dwSize; // Size of D3DNTHALDEVICEDESC_V1 structure
DWORD dwFlags; // Indicates which fields have valid data
D3DCOLORMODEL dcmColorModel; // Color model of device
DWORD dwDevCaps; // Capabilities of device
D3DTRANSFORMCAPS dtcTransformCaps; // Capabilities of transform
BOOL bClipping; // Device can do 3D clipping
D3DLIGHTINGCAPS dlcLightingCaps; // Capabilities of lighting
D3DPRIMCAPS dpcLineCaps;
D3DPRIMCAPS dpcTriCaps;
DWORD dwDeviceRenderBitDepth; // One of DDBB_8, 16, etc..
DWORD dwDeviceZBufferBitDepth; // One of DDBD_16, 32, etc..
DWORD dwMaxBufferSize; // Maximum execute buffer size */
DWORD dwMaxVertexCount; // Maximum vertex count */
} D3DNTHALDEVICEDESC_V1, *LPD3DNTHALDEVICEDESC_V1;
#define D3DNTHALDEVICEDESCSIZE_V1 (sizeof(D3DNTHALDEVICEDESC_V1))
/*
* This is equivalent to the D3DNTDEVICEDESC understood by DX5, available only
* from DX6. It is the same as D3DNTDEVICEDESC structure in DX5.
* D3DNTDEVICEDESC is still the user-visible structure that is not seen by the
* device drivers. The runtime stitches a D3DNTDEVICEDESC together using the
* D3DNTDEVICEDESC_V1 embedded in the GLOBALDRIVERDATA and the extended caps
* queried from the driver using GetDriverInfo.
*/
typedef struct _D3DNTHALDeviceDesc_V2
{
DWORD dwSize; // Size of D3DNTDEVICEDESC structure
DWORD dwFlags; // Indicates which fields have valid data
D3DCOLORMODEL dcmColorModel; // Color model of device
DWORD dwDevCaps; // Capabilities of device
D3DTRANSFORMCAPS dtcTransformCaps; // Capabilities of transform
BOOL bClipping; // Device can do 3D clipping
D3DLIGHTINGCAPS dlcLightingCaps; // Capabilities of lighting
D3DPRIMCAPS dpcLineCaps;
D3DPRIMCAPS dpcTriCaps;
DWORD dwDeviceRenderBitDepth; // One of DDBD_16, etc..
DWORD dwDeviceZBufferBitDepth; // One of DDBD_16, 32, etc..
DWORD dwMaxBufferSize; // Maximum execute buffer size
DWORD dwMaxVertexCount; // Maximum vertex count
DWORD dwMinTextureWidth, dwMinTextureHeight;
DWORD dwMaxTextureWidth, dwMaxTextureHeight;
DWORD dwMinStippleWidth, dwMaxStippleWidth;
DWORD dwMinStippleHeight, dwMaxStippleHeight;
} D3DNTHALDEVICEDESC_V2, *LPD3DNTHALDEVICEDESC_V2;
#define D3DNTHALDEVICEDESCSIZE_V2 (sizeof(D3DNTHALDEVICEDESC_V2))
#if(DIRECT3D_VERSION >= 0x0700)
/*
* This is equivalent to the D3DNTDEVICEDESC understood by DX6, available only
* from DX6. It is the same as D3DNTDEVICEDESC structure in DX6.
* D3DNTDEVICEDESC is still the user-visible structure that is not seen by the
* device drivers. The runtime stitches a D3DNTDEVICEDESC together using the
* D3DNTDEVICEDESC_V1 embedded in the GLOBALDRIVERDATA and the extended caps
* queried from the driver using GetDriverInfo.
*/
typedef struct _D3DNTDeviceDesc_V3
{
DWORD dwSize; // Size of D3DNTDEVICEDESC structure
DWORD dwFlags; // Indicates which fields have valid data
D3DCOLORMODEL dcmColorModel; // Color model of device
DWORD dwDevCaps; // Capabilities of device
D3DTRANSFORMCAPS dtcTransformCaps; // Capabilities of transform
BOOL bClipping; // Device can do 3D clipping
D3DLIGHTINGCAPS dlcLightingCaps; // Capabilities of lighting
D3DPRIMCAPS dpcLineCaps;
D3DPRIMCAPS dpcTriCaps;
DWORD dwDeviceRenderBitDepth; // One of DDBD_16, etc..
DWORD dwDeviceZBufferBitDepth; // One of DDBD_16, 32, etc..
DWORD dwMaxBufferSize; // Maximum execute buffer size
DWORD dwMaxVertexCount; // Maximum vertex count
DWORD dwMinTextureWidth, dwMinTextureHeight;
DWORD dwMaxTextureWidth, dwMaxTextureHeight;
DWORD dwMinStippleWidth, dwMaxStippleWidth;
DWORD dwMinStippleHeight, dwMaxStippleHeight;
DWORD dwMaxTextureRepeat;
DWORD dwMaxTextureAspectRatio;
DWORD dwMaxAnisotropy;
D3DVALUE dvGuardBandLeft;
D3DVALUE dvGuardBandTop;
D3DVALUE dvGuardBandRight;
D3DVALUE dvGuardBandBottom;
D3DVALUE dvExtentsAdjust;
DWORD dwStencilCaps;
DWORD dwFVFCaps; // low 4 bits: 0 implies TLVERTEX only, 1..8 imply FVF aware
DWORD dwTextureOpCaps;
WORD wMaxTextureBlendStages;
WORD wMaxSimultaneousTextures;
} D3DNTDEVICEDESC_V3, *LPD3DNTDEVICEDESC_V3;
#define D3DNTDEVICEDESCSIZE_V3 (sizeof(D3DNTDEVICEDESC_V3))
#endif /* DIRECT3D_VERSION >= 0x0700 */
/* --------------------------------------------------------------
* Instantiated by the HAL driver on driver connection.
*
* Regarding dwNumVertices, specify 0 if you are relying on the HEL to do
* everything and you do not need the resultant TLVertex buffer to reside
* in device memory.
* The HAL driver will be asked to allocate dwNumVertices + dwNumClipVertices
* in the case described above.
*/
typedef struct _D3DNTHAL_GLOBALDRIVERDATA
{
DWORD dwSize; // Size of this structure
D3DNTHALDEVICEDESC_V1 hwCaps; // Capabilities of the hardware
DWORD dwNumVertices; // see following comment
DWORD dwNumClipVertices; // see following comment
DWORD dwNumTextureFormats; // Number of texture formats
LPDDSURFACEDESC lpTextureFormats; // Pointer to texture formats
} D3DNTHAL_GLOBALDRIVERDATA;
typedef D3DNTHAL_GLOBALDRIVERDATA *LPD3DNTHAL_GLOBALDRIVERDATA;
#define D3DNTHAL_GLOBALDRIVERDATASIZE (sizeof(D3DNTHAL_GLOBALDRIVERDATA))
#if(DIRECT3D_VERSION >= 0x0700)
/* --------------------------------------------------------------
* Extended caps introduced with DX5 and queried with
* GetDriverInfo (GUID_D3DExtendedCaps).
*/
typedef struct _D3DNTHAL_D3DDX6EXTENDEDCAPS
{
DWORD dwSize; // Size of this structure
DWORD dwMinTextureWidth, dwMaxTextureWidth;
DWORD dwMinTextureHeight, dwMaxTextureHeight;
DWORD dwMinStippleWidth, dwMaxStippleWidth;
DWORD dwMinStippleHeight, dwMaxStippleHeight;
// fields added for DX6
DWORD dwMaxTextureRepeat;
DWORD dwMaxTextureAspectRatio;
DWORD dwMaxAnisotropy;
D3DVALUE dvGuardBandLeft;
D3DVALUE dvGuardBandTop;
D3DVALUE dvGuardBandRight;
D3DVALUE dvGuardBandBottom;
D3DVALUE dvExtentsAdjust;
DWORD dwStencilCaps;
DWORD dwFVFCaps; // low 4 bits: 0 implies TLVERTEX only, 1..8 imply FVF aware
DWORD dwTextureOpCaps;
WORD wMaxTextureBlendStages;
WORD wMaxSimultaneousTextures;
} D3DNTHAL_D3DDX6EXTENDEDCAPS;
#endif /* DIRECT3D_VERSION >= 0x0700 */
/* --------------------------------------------------------------
* Extended caps introduced with DX5 and queried with
* GetDriverInfo (GUID_D3DExtendedCaps).
*/
typedef struct _D3DNTHAL_D3DEXTENDEDCAPS
{
DWORD dwSize; // Size of this structure
DWORD dwMinTextureWidth, dwMaxTextureWidth;
DWORD dwMinTextureHeight, dwMaxTextureHeight;
DWORD dwMinStippleWidth, dwMaxStippleWidth;
DWORD dwMinStippleHeight, dwMaxStippleHeight;
// fields added for DX6
DWORD dwMaxTextureRepeat;
DWORD dwMaxTextureAspectRatio;
DWORD dwMaxAnisotropy;
D3DVALUE dvGuardBandLeft;
D3DVALUE dvGuardBandTop;
D3DVALUE dvGuardBandRight;
D3DVALUE dvGuardBandBottom;
D3DVALUE dvExtentsAdjust;
DWORD dwStencilCaps;
DWORD dwFVFCaps; // 0 implies TLVERTEX only, 1..8 imply full FVF aware */
DWORD dwTextureOpCaps;
WORD wMaxTextureBlendStages;
WORD wMaxSimultaneousTextures;
#if(DIRECT3D_VERSION >= 0x0700)
/* fields added for DX7 */
DWORD dwMaxActiveLights;
D3DVALUE dvMaxVertexW;
WORD wMaxUserClipPlanes;
WORD wMaxVertexBlendMatrices;
DWORD dwVertexProcessingCaps;
DWORD dwReserved1;
DWORD dwReserved2;
DWORD dwReserved3;
DWORD dwReserved4;
#endif /* DIRECT3D_VERSION >= 0x0700 */
} D3DNTHAL_D3DEXTENDEDCAPS;
typedef D3DNTHAL_D3DEXTENDEDCAPS *LPD3DNTHAL_D3DEXTENDEDCAPS;
#define D3DNTHAL_D3DEXTENDEDCAPSSIZE (sizeof(D3DNTHAL_D3DEXTENDEDCAPS))
// This is a temporary fix to make older NT drivers to compile
#define dvVertexProcessingCaps dwVertexProcessingCaps
#if(DIRECT3D_VERSION >= 0x0700)
typedef D3DNTHAL_D3DDX6EXTENDEDCAPS *LPD3DNTHAL_D3DDX6EXTENDEDCAPS;
#define D3DNTHAL_D3DDX6EXTENDEDCAPSSIZE (sizeof(D3DNTHAL_D3DDX6EXTENDEDCAPS))
#endif /* DIRECT3D_VERSION >= 0x0700 */
/* --------------------------------------------------------------
* Argument to the HAL functions.
*/
typedef ULONG_PTR D3DINTHAL_BUFFERHANDLE, *LPD3DINTHAL_BUFFERHANDLE;
typedef struct _D3DNTHAL_CONTEXTCREATEDATA
{
union
{
PDD_DIRECTDRAW_GLOBAL lpDDGbl; // in: obsolete
PDD_DIRECTDRAW_LOCAL lpDDLcl; // in: Driver struct
};
union
{
PDD_SURFACE_LOCAL lpDDS; // in: obsolete
PDD_SURFACE_LOCAL lpDDSLcl; // in: Surface to be used as target
};
union
{
PDD_SURFACE_LOCAL lpDDSZ; // in: obsolete
PDD_SURFACE_LOCAL lpDDSZLcl; // in: Surface to be used as Z
};
DWORD dwPID; // in: Current process id
ULONG_PTR dwhContext; // in/out: Context handle
HRESULT ddrval; // out: Return value
} D3DNTHAL_CONTEXTCREATEDATA;
typedef D3DNTHAL_CONTEXTCREATEDATA *LPD3DNTHAL_CONTEXTCREATEDATA;
typedef struct _D3DNTHAL_CONTEXTDESTROYDATA
{
ULONG_PTR dwhContext; // in: Context handle
HRESULT ddrval; // out: Return value
} D3DNTHAL_CONTEXTDESTROYDATA;
typedef D3DNTHAL_CONTEXTDESTROYDATA *LPD3DNTHAL_CONTEXTDESTROYDATA;
typedef struct _D3DNTHAL_CONTEXTDESTROYALLDATA
{
DWORD dwPID; // in: Process id to destroy contexts for
HRESULT ddrval; // out: Return value
} D3DNTHAL_CONTEXTDESTROYALLDATA;
typedef D3DNTHAL_CONTEXTDESTROYALLDATA *LPD3DNTHAL_CONTEXTDESTROYALLDATA;
typedef struct _D3DNTHAL_SCENECAPTUREDATA
{
ULONG_PTR dwhContext; // in: Context handle
DWORD dwFlag; // in: Indicates beginning or end
HRESULT ddrval; // out: Return value
} D3DNTHAL_SCENECAPTUREDATA;
typedef D3DNTHAL_SCENECAPTUREDATA *LPD3DNTHAL_SCENECAPTUREDATA;
typedef struct _D3DNTHAL_TEXTURECREATEDATA
{
ULONG_PTR dwhContext; // in: Context handle
HANDLE hDDS; // in: Handle to surface object
ULONG_PTR dwHandle; // out: Handle to texture
HRESULT ddrval; // out: Return value
} D3DNTHAL_TEXTURECREATEDATA;
typedef D3DNTHAL_TEXTURECREATEDATA *LPD3DNTHAL_TEXTURECREATEDATA;
typedef struct _D3DNTHAL_TEXTUREDESTROYDATA
{
ULONG_PTR dwhContext; // in: Context handle
ULONG_PTR dwHandle; // in: Handle to texture
HRESULT ddrval; // out: Return value
} D3DNTHAL_TEXTUREDESTROYDATA;
typedef D3DNTHAL_TEXTUREDESTROYDATA *LPD3DNTHAL_TEXTUREDESTROYDATA;
typedef struct _D3DNTHAL_TEXTURESWAPDATA
{
ULONG_PTR dwhContext; // in: Context handle
ULONG_PTR dwHandle1; // in: Handle to texture 1
ULONG_PTR dwHandle2; // in: Handle to texture 2
HRESULT ddrval; // out: Return value
} D3DNTHAL_TEXTURESWAPDATA;
typedef D3DNTHAL_TEXTURESWAPDATA *LPD3DNTHAL_TEXTURESWAPDATA;
typedef struct _D3DNTHAL_TEXTUREGETSURFDATA
{
ULONG_PTR dwhContext; // in: Context handle
HANDLE hDDS; // out: Handle to surface object
ULONG_PTR dwHandle; // in: Handle to texture
HRESULT ddrval; // out: Return value
} D3DNTHAL_TEXTUREGETSURFDATA;
typedef D3DNTHAL_TEXTUREGETSURFDATA *LPD3DNTHAL_TEXTUREGETSURFDATA;
/* --------------------------------------------------------------
* Flags for the data parameters.
*/
/*
* SceneCapture()
* This is used as an indication to the driver that a scene is about to
* start or end, and that it should capture data if required.
*/
#define D3DNTHAL_SCENE_CAPTURE_START 0x00000000L
#define D3DNTHAL_SCENE_CAPTURE_END 0x00000001L
/* --------------------------------------------------------------
* Return values from HAL functions.
*/
/*
* The context passed in was bad.
*/
#define D3DNTHAL_CONTEXT_BAD 0x000000200L
/*
* No more contexts left.
*/
#define D3DNTHAL_OUTOFCONTEXTS 0x000000201L
/* --------------------------------------------------------------
* Direct3D HAL Table.
* Instantiated by the HAL driver on connection.
*
* Calls take the form of:
* retcode = HalCall(HalCallData* lpData);
*/
typedef DWORD (APIENTRY *LPD3DNTHAL_CONTEXTCREATECB)(LPD3DNTHAL_CONTEXTCREATEDATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_CONTEXTDESTROYCB)(LPD3DNTHAL_CONTEXTDESTROYDATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_CONTEXTDESTROYALLCB)(LPD3DNTHAL_CONTEXTDESTROYALLDATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_SCENECAPTURECB)(LPD3DNTHAL_SCENECAPTUREDATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_TEXTURECREATECB)(LPD3DNTHAL_TEXTURECREATEDATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_TEXTUREDESTROYCB)(LPD3DNTHAL_TEXTUREDESTROYDATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_TEXTURESWAPCB)(LPD3DNTHAL_TEXTURESWAPDATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_TEXTUREGETSURFCB)(LPD3DNTHAL_TEXTUREGETSURFDATA);
typedef struct _D3DNTHAL_CALLBACKS
{
DWORD dwSize;
// Device context
LPD3DNTHAL_CONTEXTCREATECB ContextCreate;
LPD3DNTHAL_CONTEXTDESTROYCB ContextDestroy;
LPD3DNTHAL_CONTEXTDESTROYALLCB ContextDestroyAll;
// Scene Capture
LPD3DNTHAL_SCENECAPTURECB SceneCapture;
// Execution
LPVOID dwReserved10; // Must be zero (was Execute)
LPVOID dwReserved11; // Must be zero (was ExecuteClipped)
LPVOID dwReserved22; // Must be zero (was RenderState)
LPVOID dwReserved23; // Must be zero (was RenderPrimitive)
ULONG_PTR dwReserved; // Must be zero
// Textures
LPD3DNTHAL_TEXTURECREATECB TextureCreate;
LPD3DNTHAL_TEXTUREDESTROYCB TextureDestroy;
LPD3DNTHAL_TEXTURESWAPCB TextureSwap;
LPD3DNTHAL_TEXTUREGETSURFCB TextureGetSurf;
LPVOID dwReserved12; // Must be zero
LPVOID dwReserved13; // Must be zero
LPVOID dwReserved14; // Must be zero
LPVOID dwReserved15; // Must be zero
LPVOID dwReserved16; // Must be zero
LPVOID dwReserved17; // Must be zero
LPVOID dwReserved18; // Must be zero
LPVOID dwReserved19; // Must be zero
LPVOID dwReserved20; // Must be zero
LPVOID dwReserved21; // Must be zero
// Pipeline state
LPVOID dwReserved24; // Was GetState;
ULONG_PTR dwReserved0; // Must be zero
ULONG_PTR dwReserved1; // Must be zero
ULONG_PTR dwReserved2; // Must be zero
ULONG_PTR dwReserved3; // Must be zero
ULONG_PTR dwReserved4; // Must be zero
ULONG_PTR dwReserved5; // Must be zero
ULONG_PTR dwReserved6; // Must be zero
ULONG_PTR dwReserved7; // Must be zero
ULONG_PTR dwReserved8; // Must be zero
ULONG_PTR dwReserved9; // Must be zero
} D3DNTHAL_CALLBACKS;
typedef D3DNTHAL_CALLBACKS *LPD3DNTHAL_CALLBACKS;
#define D3DNTHAL_SIZE_V1 sizeof(D3DNTHAL_CALLBACKS)
typedef struct _D3DNTHAL_SETRENDERTARGETDATA
{
ULONG_PTR dwhContext; // in: Context handle
PDD_SURFACE_LOCAL lpDDS; // in: new render target
PDD_SURFACE_LOCAL lpDDSZ; // in: new Z buffer
HRESULT ddrval; // out: Return value
} D3DNTHAL_SETRENDERTARGETDATA;
typedef D3DNTHAL_SETRENDERTARGETDATA *LPD3DNTHAL_SETRENDERTARGETDATA;
typedef DWORD (APIENTRY *LPD3DNTHAL_SETRENDERTARGETCB)(LPD3DNTHAL_SETRENDERTARGETDATA);
typedef struct _D3DNTHAL_CALLBACKS2
{
DWORD dwSize; // size of struct
DWORD dwFlags; // flags for callbacks
LPD3DNTHAL_SETRENDERTARGETCB SetRenderTarget;
LPVOID dwReserved1; // was Clear
LPVOID dwReserved2; // was DrawOnePrimitive
LPVOID dwReserved3; // was DrawOneIndexedPrimitive
LPVOID dwReserved4; // was DrawPrimitives
} D3DNTHAL_CALLBACKS2;
typedef D3DNTHAL_CALLBACKS2 *LPD3DNTHAL_CALLBACKS2;
#define D3DNTHAL2_CB32_SETRENDERTARGET 0x00000001L
typedef struct _D3DNTHAL_CLEAR2DATA
{
ULONG_PTR dwhContext; // in: Context handle
// dwFlags can contain D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER
DWORD dwFlags; // in: surfaces to clear
DWORD dwFillColor; // in: Color value for rtarget
D3DVALUE dvFillDepth; // in: Depth value for
// Z-buffer (0.0-1.0)
DWORD dwFillStencil; // in: value used to clear stencil buffer
LPD3DRECT lpRects; // in: Rectangles to clear
DWORD dwNumRects; // in: Number of rectangles
HRESULT ddrval; // out: Return value
} D3DNTHAL_CLEAR2DATA;
typedef D3DNTHAL_CLEAR2DATA FAR *LPD3DNTHAL_CLEAR2DATA;
typedef struct _D3DNTHAL_VALIDATETEXTURESTAGESTATEDATA
{
ULONG_PTR dwhContext; // in: Context handle
DWORD dwFlags; // in: Flags, currently set to 0
ULONG_PTR dwReserved; //
DWORD dwNumPasses; // out: Number of passes the hardware
// can perform the operation in
HRESULT ddrval; // out: return value
} D3DNTHAL_VALIDATETEXTURESTAGESTATEDATA;
typedef D3DNTHAL_VALIDATETEXTURESTAGESTATEDATA FAR *LPD3DNTHAL_VALIDATETEXTURESTAGESTATEDATA;
//-----------------------------------------------------------------------------
// DrawPrimitives2 DDI
//-----------------------------------------------------------------------------
//
// Command structure for vertex buffer rendering
//
typedef struct _D3DNTHAL_DP2COMMAND
{
BYTE bCommand; // vertex command
BYTE bReserved;
union
{
WORD wPrimitiveCount; // primitive count for unconnected primitives
WORD wStateCount; // count of render states to follow
};
} D3DNTHAL_DP2COMMAND, *LPDNT3DHAL_DP2COMMAND;
//
// DrawPrimitives2 commands:
//
typedef enum _D3DNTHAL_DP2OPERATION
{
D3DNTDP2OP_POINTS = 1,
D3DNTDP2OP_INDEXEDLINELIST = 2,
D3DNTDP2OP_INDEXEDTRIANGLELIST = 3,
D3DNTDP2OP_RENDERSTATE = 8,
D3DNTDP2OP_LINELIST = 15,
D3DNTDP2OP_LINESTRIP = 16,
D3DNTDP2OP_INDEXEDLINESTRIP = 17,
D3DNTDP2OP_TRIANGLELIST = 18,
D3DNTDP2OP_TRIANGLESTRIP = 19,
D3DNTDP2OP_INDEXEDTRIANGLESTRIP = 20,
D3DNTDP2OP_TRIANGLEFAN = 21,
D3DNTDP2OP_INDEXEDTRIANGLEFAN = 22,
D3DNTDP2OP_TRIANGLEFAN_IMM = 23,
D3DNTDP2OP_LINELIST_IMM = 24,
D3DNTDP2OP_TEXTURESTAGESTATE = 25,
D3DNTDP2OP_INDEXEDTRIANGLELIST2 = 26,
D3DNTDP2OP_INDEXEDLINELIST2 = 27,
D3DNTDP2OP_VIEWPORTINFO = 28,
D3DNTDP2OP_WINFO = 29,
D3DNTDP2OP_SETPALETTE = 30,
D3DNTDP2OP_UPDATEPALETTE = 31,
#if(DIRECT3D_VERSION >= 0x0700)
//new for DX7
D3DNTDP2OP_ZRANGE = 32,
D3DNTDP2OP_SETMATERIAL = 33,
D3DNTDP2OP_SETLIGHT = 34,
D3DNTDP2OP_CREATELIGHT = 35,
D3DNTDP2OP_SETTRANSFORM = 36,
D3DNTDP2OP_TEXBLT = 38,
D3DNTDP2OP_STATESET = 39,
D3DNTDP2OP_SETPRIORITY = 40,
#endif /* DIRECT3D_VERSION >= 0x0700 */
D3DNTDP2OP_SETRENDERTARGET = 41,
D3DNTDP2OP_CLEAR = 42,
#if(DIRECT3D_VERSION >= 0x0700)
D3DNTDP2OP_SETTEXLOD = 43,
D3DNTDP2OP_SETCLIPPLANE = 44,
#endif /* DIRECT3D_VERSION >= 0x0700 */
#if(DIRECT3D_VERSION >= 0x0800)
D3DNTDP2OP_CREATEVERTEXSHADER = 45,
D3DNTDP2OP_DELETEVERTEXSHADER = 46,
D3DNTDP2OP_SETVERTEXSHADER = 47,
D3DNTDP2OP_SETVERTEXSHADERCONST = 48,
D3DNTDP2OP_SETSTREAMSOURCE = 49,
D3DNTDP2OP_SETSTREAMSOURCEUM = 50,
D3DNTDP2OP_SETINDICES = 51,
D3DNTDP2OP_DRAWPRIMITIVE = 52,
D3DNTDP2OP_DRAWINDEXEDPRIMITIVE = 53,
D3DNTDP2OP_CREATEPIXELSHADER = 54,
D3DNTDP2OP_DELETEPIXELSHADER = 55,
D3DNTDP2OP_SETPIXELSHADER = 56,
D3DNTDP2OP_SETPIXELSHADERCONST = 57,
D3DNTDP2OP_CLIPPEDTRIANGLEFAN = 58,
D3DNTDP2OP_DRAWPRIMITIVE2 = 59,
D3DNTDP2OP_DRAWINDEXEDPRIMITIVE2 = 60,
D3DNTDP2OP_DRAWRECTPATCH = 61,
D3DNTDP2OP_DRAWTRIPATCH = 62,
D3DNTDP2OP_VOLUMEBLT = 63,
D3DNTDP2OP_BUFFERBLT = 64,
D3DNTDP2OP_MULTIPLYTRANSFORM = 65,
D3DNTDP2OP_ADDDIRTYRECT = 66,
D3DNTDP2OP_ADDDIRTYBOX = 67,
#endif /* DIRECT3D_VERSION >= 0x0800 */
#if(DIRECT3D_VERSION >= 0x0900)
D3DNTDP2OP_CREATEVERTEXSHADERDECL = 71,
D3DNTDP2OP_DELETEVERTEXSHADERDECL = 72,
D3DNTDP2OP_SETVERTEXSHADERDECL = 73,
D3DNTDP2OP_CREATEVERTEXSHADERFUNC = 74,
D3DNTDP2OP_DELETEVERTEXSHADERFUNC = 75,
D3DNTDP2OP_SETVERTEXSHADERFUNC = 76,
D3DNTDP2OP_SETVERTEXSHADERCONSTI = 77,
D3DNTDP2OP_SETSCISSORRECT = 79,
D3DNTDP2OP_SETSTREAMSOURCE2 = 80,
D3DNTDP2OP_BLT = 81,
D3DNTDP2OP_COLORFILL = 82,
D3DNTDP2OP_SETVERTEXSHADERCONSTB = 83,
D3DNTDP2OP_CREATEQUERY = 84,
D3DNTDP2OP_SETRENDERTARGET2 = 85,
D3DNTDP2OP_SETDEPTHSTENCIL = 86,
D3DNTDP2OP_RESPONSECONTINUE = 87, // Can come only from driver
D3DNTDP2OP_RESPONSEQUERY = 88, // Can come only from driver
D3DNTDP2OP_GENERATEMIPSUBLEVELS = 89,
D3DNTDP2OP_DELETEQUERY = 90,
D3DNTDP2OP_ISSUEQUERY = 91,
D3DNTDP2OP_SETPIXELSHADERCONSTI = 93,
D3DNTDP2OP_SETPIXELSHADERCONSTB = 94,
D3DNTDP2OP_SETSTREAMSOURCEFREQ = 95,
D3DNTDP2OP_SURFACEBLT = 96,
D3DNTDP2OP_SETCONVOLUTIONKERNELMONO = 97,
D3DNTDP2OP_COMPOSERECTS = 98,
#endif /* DIRECT3D_VERSION >= 0x0900 */
} D3DNTHAL_DP2OPERATION;
//
// DrawPrimitives2 point primitives
//
typedef struct _D3DNTHAL_DP2POINTS
{
WORD wCount;
WORD wVStart;
} D3DNTHAL_DP2POINTS;
//
// DrawPrimitives2 line primitives
//
typedef struct _D3DNTHAL_DP2STARTVERTEX
{
WORD wVStart;
} D3DNTHAL_DP2STARTVERTEX, *LPD3DNTHAL_DP2STARTVERTEX;
typedef struct _D3DNTHAL_DP2LINELIST
{
WORD wVStart;
} D3DNTHAL_DP2LINELIST;
typedef struct _D3DNTHAL_DP2INDEXEDLINELIST
{
WORD wV1;
WORD wV2;
} D3DNTHAL_DP2INDEXEDLINELIST;
typedef struct _D3DNTHAL_DP2LINESTRIP
{
WORD wVStart;
} D3DNTHAL_DP2LINESTRIP;
typedef struct _D3DNTHAL_DP2INDEXEDLINESTRIP
{
WORD wV[2];
} D3DNTHAL_DP2INDEXEDLINESTRIP;
//
// DrawPrimitives2 triangle primitives
//
typedef struct _D3DNTHAL_DP2TRIANGLELIST
{
WORD wVStart;
} D3DNTHAL_DP2TRIANGLELIST;
typedef struct _D3DNTHAL_DP2INDEXEDTRIANGLELIST
{
WORD wV1;
WORD wV2;
WORD wV3;
WORD wFlags;
} D3DNTHAL_DP2INDEXEDTRIANGLELIST;
typedef struct _D3DNTHAL_DP2INDEXEDTRIANGLELIST2 {
WORD wV1;
WORD wV2;
WORD wV3;
} D3DNTHAL_DP2INDEXEDTRIANGLELIST2, *LPD3DNTHAL_DP2INDEXEDTRIANGLELIST2;
typedef struct _D3DNTHAL_DP2TRIANGLESTRIP
{
WORD wVStart;
} D3DNTHAL_DP2TRIANGLESTRIP;
typedef struct _D3DNTHAL_DP2INDEXEDTRIANGLESTRIP
{
WORD wV[3];
} D3DNTHAL_DP2INDEXEDTRIANGLESTRIP;
typedef struct _D3DNTHAL_DP2TRIANGLEFAN
{
WORD wVStart;
} D3DNTHAL_DP2TRIANGLEFAN;
typedef struct _D3DNTHAL_DP2INDEXEDTRIANGLEFAN
{
WORD wV[3];
} D3DNTHAL_DP2INDEXEDTRIANGLEFAN;
typedef struct _D3DNTHAL_DP2TRIANGLEFAN_IMM
{
DWORD dwEdgeFlags;
} D3DNTHAL_DP2TRIANGLEFAN_IMM, *LPD3DNTHAL_DP2TRIANGLEFAN_IMM;
//
// DrawPrimitives2 Renderstate changes
//
typedef struct _D3DNTHAL_DP2RENDERSTATE
{
D3DRENDERSTATETYPE RenderState;
union
{
D3DVALUE fState;
DWORD dwState;
};
} D3DNTHAL_DP2RENDERSTATE;
typedef D3DNTHAL_DP2RENDERSTATE * LPD3DNTHAL_DP2RENDERSTATE;
typedef struct _D3DNTHAL_DP2TEXTURESTAGESTATE
{
WORD wStage;
WORD TSState;
DWORD dwValue;
} D3DNTHAL_DP2TEXTURESTAGESTATE;
typedef D3DNTHAL_DP2TEXTURESTAGESTATE *LPD3DNTHAL_DP2TEXTURESTAGESTATE;
typedef struct _D3DNTHAL_DP2VIEWPORTINFO
{
DWORD dwX;
DWORD dwY;
DWORD dwWidth;
DWORD dwHeight;
} D3DNTHAL_DP2VIEWPORTINFO;
typedef D3DNTHAL_DP2VIEWPORTINFO *LPD3DNTHAL_DP2VIEWPORTINFO;
typedef struct _D3DNTHAL_DP2WINFO
{
D3DVALUE dvWNear;
D3DVALUE dvWFar;
} D3DNTHAL_DP2WINFO;
typedef D3DNTHAL_DP2WINFO *LPD3DNTHAL_DP2WINFO;
typedef struct _D3DNTHAL_DP2SETPALETTE
{
DWORD dwPaletteHandle;
DWORD dwPaletteFlags;
DWORD dwSurfaceHandle;
} D3DNTHAL_DP2SETPALETTE;
typedef D3DNTHAL_DP2SETPALETTE *LPD3DNTHAL_DP2SETPALETTE;
typedef struct _D3DNTHAL_DP2UPDATEPALETTE
{
DWORD dwPaletteHandle;
WORD wStartIndex;
WORD wNumEntries;
} D3DNTHAL_DP2UPDATEPALETTE;
typedef D3DNTHAL_DP2UPDATEPALETTE *LPD3DNTHAL_DP2UPDATEPALETTE;
typedef struct _D3DNTHAL_DP2SETRENDERTARGET
{
DWORD hRenderTarget;
DWORD hZBuffer;
} D3DNTHAL_DP2SETRENDERTARGET;
typedef D3DNTHAL_DP2SETRENDERTARGET *LPD3DNTHAL_DP2SETRENDERTARGET;
#if(DIRECT3D_VERSION >= 0x0700)
// Values for dwOperations in the D3DHAL_DP2STATESET
#define D3DHAL_STATESETBEGIN 0
#define D3DHAL_STATESETEND 1
#define D3DHAL_STATESETDELETE 2
#define D3DHAL_STATESETEXECUTE 3
#define D3DHAL_STATESETCAPTURE 4
typedef struct _D3DNTHAL_DP2STATESET
{
DWORD dwOperation;
DWORD dwParam; // State set handle passed with D3DHAL_STATESETBEGIN,
// D3DHAL_STATESETEXECUTE, D3DHAL_STATESETDELETE
// D3DHAL_STATESETCAPTURE
D3DSTATEBLOCKTYPE sbType; // Type use with D3DHAL_STATESETBEGIN/END
} D3DNTHAL_DP2STATESET;
typedef D3DNTHAL_DP2STATESET *LPD3DNTHAL_DP2STATESET;
//
// T&L Hal specific stuff
//
typedef struct _D3DNTHAL_DP2ZRANGE
{
D3DVALUE dvMinZ;
D3DVALUE dvMaxZ;
} D3DNTHAL_DP2ZRANGE;
typedef D3DNTHAL_DP2ZRANGE *LPD3DNTHAL_DP2ZRANGE;
typedef D3DMATERIAL7 D3DNTHAL_DP2SETMATERIAL, *LPD3DNTHAL_DP2SETMATERIAL;
typedef struct _D3DNTHAL_DP2SETLIGHT
{
DWORD dwIndex;
union {
DWORD lightData;
DWORD dwDataType;
};
} D3DNTHAL_DP2SETLIGHT;
typedef D3DNTHAL_DP2SETLIGHT *LPD3DNTHAL_DP2SETLIGHT;
typedef struct _D3DNTHAL_DP2SETCLIPPLANE
{
DWORD dwIndex;
D3DVALUE plane[4];
} D3DNTHAL_DP2SETCLIPPLANE;
typedef D3DNTHAL_DP2SETCLIPPLANE *LPD3DNTHAL_DP2SETCLIPPLANE;
typedef struct _D3DNTHAL_DP2CREATELIGHT
{
DWORD dwIndex;
} D3DNTHAL_DP2CREATELIGHT;
typedef D3DNTHAL_DP2CREATELIGHT *LPD3DNTHAL_DP2CREATELIGHT;
typedef struct _D3DNTHAL_DP2SETTRANSFORM
{
D3DTRANSFORMSTATETYPE xfrmType;
D3DMATRIX matrix;
} D3DNTHAL_DP2SETTRANSFORM;
typedef D3DNTHAL_DP2SETTRANSFORM *LPD3DNTHAL_DP2SETTRANSFORM;
typedef struct _D3DNTHAL_DP2EXT
{
DWORD dwExtToken;
DWORD dwSize;
} D3DNTHAL_DP2EXT;
typedef D3DNTHAL_DP2EXT *LPD3DNTHAL_DP2EXT;
typedef struct _D3DNTHAL_DP2TEXBLT
{
DWORD dwDDDestSurface; // dest surface
DWORD dwDDSrcSurface; // src surface
POINT pDest;
RECTL rSrc; // src rect
DWORD dwFlags; // blt flags
} D3DNTHAL_DP2TEXBLT;
typedef D3DNTHAL_DP2TEXBLT *LPD3DNTHAL_DP2TEXBLT;
typedef struct _D3DNTHAL_DP2SETPRIORITY
{
DWORD dwDDDestSurface; // dest surface
DWORD dwPriority;
} D3DNTHAL_DP2SETPRIORITY;
typedef D3DNTHAL_DP2SETPRIORITY *LPD3DNTHAL_DP2SETPRIORITY;
typedef struct _D3DNTHAL_DP2CLEAR
{
// dwFlags can contain D3DCLEAR_TARGET, D3DCLEAR_ZBUFFER, and/or D3DCLEAR_STENCIL
DWORD dwFlags; // in: surfaces to clear
DWORD dwFillColor; // in: Color value for rtarget
D3DVALUE dvFillDepth; // in: Depth value for Z buffer (0.0-1.0)
DWORD dwFillStencil; // in: value used to clear stencil buffer
RECT Rects[1]; // in: Rectangles to clear
} D3DNTHAL_DP2CLEAR;
typedef D3DNTHAL_DP2CLEAR *LPD3DNTHAL_DP2CLEAR;
typedef struct _D3DNTHAL_DP2SETTEXLOD
{
DWORD dwDDSurface;
DWORD dwLOD;
} D3DNTHAL_DP2SETTEXLOD;
typedef D3DNTHAL_DP2SETTEXLOD *LPD3DNTHAL_DP2SETTEXLOD;
#endif /* DIRECT3D_VERSION >= 0x0700 */
typedef struct _D3DNTHAL_DRAWPRIMITIVES2DATA
{
ULONG_PTR dwhContext; // in: Context handle
DWORD dwFlags; // in: flags (look below)
DWORD dwVertexType; // in: vertex type
PDD_SURFACE_LOCAL lpDDCommands; // in: vertex buffer command data
DWORD dwCommandOffset; // in: offset to start of vb commands
DWORD dwCommandLength; // in: number of bytes of command data
union
{
PDD_SURFACE_LOCAL lpDDVertex; // in: surface containing vertex data
LPVOID lpVertices; // in: User mode pointer to vertices
};
DWORD dwVertexOffset; // in: offset to start of vertex data
DWORD dwVertexLength; // in: number of vertices of vertex data
DWORD dwReqVertexBufSize; // in: number of bytes required for
// the next vertex buffer
DWORD dwReqCommandBufSize; // in: number if bytes required for
// the next commnand buffer
LPDWORD lpdwRStates; // in: Pointer to the array where render states are updated
union
{
DWORD dwVertexSize; // in: Size of each vertex in bytes
HRESULT ddrval; // out: return value
};
DWORD dwErrorOffset; // out: offset in LPDDVBCOMMAND to
// first failed D3DNTHAL_VBCOMMAND
} D3DNTHAL_DRAWPRIMITIVES2DATA;
typedef D3DNTHAL_DRAWPRIMITIVES2DATA FAR *LPD3DNTHAL_DRAWPRIMITIVES2DATA;
// Indicates that the lpVertices field in the DrawPrimitives2 data is
// valid, i.e. user allocated memory.
#define D3DNTHALDP2_USERMEMVERTICES 0x00000001L
// Indicates that the command buffer and vertex buffer are a system memory execute buffer
// resulting from the use of the Execute buffer API.
#define D3DNTHALDP2_EXECUTEBUFFER 0x00000002L
// The swap flags indicate if it is OK for the driver to swap the submitted buffers with new
// buffers and asyncronously work on the submitted buffers.
#define D3DNTHALDP2_SWAPVERTEXBUFFER 0x00000004L
#define D3DNTHALDP2_SWAPCOMMANDBUFFER 0x00000008L
// The requested flags are present if the new buffers which the driver can allocate need to be
// of atleast a given size. If any of these flags are set, the corresponding dwReq* field in
// D3DNTHAL_DRAWPRIMITIVES2DATA will also be set with the requested size in bytes.
#define D3DNTHALDP2_REQVERTEXBUFSIZE 0x00000010L
#define D3DNTHALDP2_REQCOMMANDBUFSIZE 0x00000020L
// These flags are set by the driver upon return from DrawPrimitives2 indicating if the new
// buffers are not in system memory.
#define D3DNTHALDP2_VIDMEMVERTEXBUF 0x00000040L
#define D3DNTHALDP2_VIDMEMCOMMANDBUF 0x00000080L
// Return values for the driver callback used in DP2 implementations
// Used by the driver to ask runtime to parse the execute buffer
#define D3DNTERR_COMMAND_UNPARSED MAKE_DDHRESULT(3000)
typedef DWORD (APIENTRY *LPD3DNTHAL_CLEAR2CB)(LPD3DNTHAL_CLEAR2DATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_VALIDATETEXTURESTAGESTATECB)(LPD3DNTHAL_VALIDATETEXTURESTAGESTATEDATA);
typedef DWORD (APIENTRY *LPD3DNTHAL_DRAWPRIMITIVES2CB)(LPD3DNTHAL_DRAWPRIMITIVES2DATA);
typedef struct _D3DNTHAL_CALLBACKS3
{
DWORD dwSize; // size of struct
DWORD dwFlags; // flags for callbacks
LPD3DNTHAL_CLEAR2CB Clear2;
LPVOID lpvReserved;
LPD3DNTHAL_VALIDATETEXTURESTAGESTATECB ValidateTextureStageState;
LPD3DNTHAL_DRAWPRIMITIVES2CB DrawPrimitives2;
} D3DNTHAL_CALLBACKS3;
typedef D3DNTHAL_CALLBACKS3 *LPD3DNTHAL_CALLBACKS3;
#define D3DNTHAL3_CB32_CLEAR2 0x00000001L
#define D3DNTHAL3_CB32_RESERVED 0x00000002L
#define D3DNTHAL3_CB32_VALIDATETEXTURESTAGESTATE 0x00000004L
#define D3DNTHAL3_CB32_DRAWPRIMITIVES2 0x00000008L
// typedef for the Callback that the drivers can use to parse unknown commands
// passed to them via the DrawPrimitives2 callback. The driver obtains this
// callback thru a GetDriverInfo call with GUID_D3DParseUnknownCommandCallback
// made by ddraw somewhere around the initialization time.
typedef HRESULT (CALLBACK *PFND3DNTPARSEUNKNOWNCOMMAND)(LPVOID lpvCommands,
LPVOID *lplpvReturnedCommand);
/* --------------------------------------------------------------
* Texture stage renderstate mapping definitions.
*
* 256 renderstate slots [256, 511] are reserved for texture processing
* stage controls, which provides for 8 texture processing stages each
* with 32 DWORD controls.
*
* The renderstates within each stage are indexed by the
* D3DTEXTURESTAGESTATETYPE enumerants by adding the appropriate
* enumerant to the base for a given texture stage.
*
* Note, "state overrides" bias the renderstate by 256, so the two
* ranges overlap. Overrides are enabled for exebufs only, so all
* this means is that Texture3 cannot be used with exebufs.
*/
/*
* Base of all texture stage state values in renderstate array.
*/
#define D3DNTHAL_TSS_RENDERSTATEBASE 256UL
/*
* Maximum number of stages allowed.
*/
#define D3DNTHAL_TSS_MAXSTAGES 8
/*
* Number of state DWORDS per stage.
*/
#define D3DNTHAL_TSS_STATESPERSTAGE 64
/*
* Texture handle's offset into the 32-DWORD cascade state vector
*/
#ifndef D3DTSS_TEXTUREMAP
#define D3DTSS_TEXTUREMAP 0
#endif
#if(DIRECT3D_VERSION >= 0x0900)
/* --------------------------------------------------------------
* Texture sampler renderstate.
*
* D3DSAMPLERSTATETYPE (D3DSAMP_*) sampler states exist to
* separate sampler state from the rest of the D3DTSS_* states.
* D3DSAMP_* states are only visible at the API level;
* the runtime simply maps these to D3DTSS_* for drivers.
*
*/
/*
* Maximum number of texture samplers allowed.
*
* If this number gets bigger than 32, some retooling
* will be needed, as DWORD bitfields are used all over the place.
*/
#define D3DHAL_SAMPLER_MAXSAMP 16
/*
* Maximum number of samplers in vertex shaders (must be power of 2)
*/
#define D3DHAL_SAMPLER_MAXVERTEXSAMP 4
/*
* Number of state DWORDS per sampler.
*/
#define D3DHAL_SAMPLER_STATESPERSAMP D3DSAMP_MAX
/*
* D3DTSS_* states that have been removed from the D3DTEXTURESTAGESTATETYPE
* and turned into the D3DSAMP_* enum D3DTEXTURESAMPLERTYPE.
* These defines allow D3DSAMP_* to be mapped to D3DTSS_* through the DDI
* so that drivers can simply understand D3DTSS_* and do not have to know
* about D3DSAMP_* at all.
* These defines are now labelled as D3DTSS_RESERVEDn in the public
* header definition of D3DTEXTURESTAGESTATETYPE.
*/
#ifndef D3DTSS_ADDRESSU
#define D3DTSS_ADDRESSU ((D3DTEXTURESTAGESTATETYPE)13)
#define D3DTSS_ADDRESSV ((D3DTEXTURESTAGESTATETYPE)14)
#define D3DTSS_BORDERCOLOR ((D3DTEXTURESTAGESTATETYPE)15)
#define D3DTSS_MAGFILTER ((D3DTEXTURESTAGESTATETYPE)16)
#define D3DTSS_MINFILTER ((D3DTEXTURESTAGESTATETYPE)17)
#define D3DTSS_MIPFILTER ((D3DTEXTURESTAGESTATETYPE)18)
#define D3DTSS_MIPMAPLODBIAS ((D3DTEXTURESTAGESTATETYPE)19)
#define D3DTSS_MAXMIPLEVEL ((D3DTEXTURESTAGESTATETYPE)20)
#define D3DTSS_MAXANISOTROPY ((D3DTEXTURESTAGESTATETYPE)21)
#define D3DTSS_ADDRESSW ((D3DTEXTURESTAGESTATETYPE)25)
#define D3DTSS_SRGBTEXTURE ((D3DTEXTURESTAGESTATETYPE)29)
#define D3DTSS_ELEMENTINDEX ((D3DTEXTURESTAGESTATETYPE)30)
#define D3DTSS_DMAPOFFSET ((D3DTEXTURESTAGESTATETYPE)31)
#endif
// These renderstates were retired in DX8:
#ifndef D3DRS_SOFTWAREVERTEXPROCESSING
#define D3DRS_SOFTWAREVERTEXPROCESSING ((D3DRENDERSTATETYPE)153)
#endif
// These renderstates were retired in DX9:
#ifndef D3DRS_PATCHSEGMENTS
#define D3DRS_LINEPATTERN ((D3DRENDERSTATETYPE)10)
#define D3DRS_ZVISIBLE ((D3DRENDERSTATETYPE)30)
#define D3DRS_PATCHSEGMENTS ((D3DRENDERSTATETYPE)164)
#endif
// These are line related states and caps that have been retired
typedef struct __NT_D3DLINEPATTERN {
WORD wRepeatFactor;
WORD wLinePattern;
} _NT_D3DLINEPATTERN;
#ifndef D3DPMISCCAPS_LINEPATTERNREP
#define D3DPMISCCAPS_LINEPATTERNREP 0x00000004L
#endif
// These are old filter caps that have been retired.
#ifndef D3DTEXF_FLATCUBIC
#define D3DTEXF_FLATCUBIC ((D3DTEXTUREFILTERTYPE)4)
#endif
#ifndef D3DTEXF_GAUSSIANCUBIC
#define D3DTEXF_GAUSSIANCUBIC ((D3DTEXTUREFILTERTYPE)5)
#endif
#ifndef D3DRS_ZBIAS
#define D3DRS_ZBIAS ((D3DRENDERSTATETYPE)47) // replaced by depthbias
#endif
#ifndef D3DRS_MAXVERTEXSHADERINST
#define D3DRS_MAXVERTEXSHADERINST 196 // DDI only: vs_3_0+ num instructions to execute.
#endif
#ifndef D3DRS_MAXPIXELSHADERINST
#define D3DRS_MAXPIXELSHADERINST 197 // DDI only: ps_3_0+ num instructions to execute.
#endif
#endif /* DIRECT3D_VERSION >= 0x0900 */
/*
* DDI only renderstates.
*/
#define D3DRENDERSTATE_EVICTMANAGEDTEXTURES 61 // DDI render state only to Evict textures
#define D3DRENDERSTATE_SCENECAPTURE 62 // DDI only to replace SceneCapture
#define _NT_D3DRS_DELETERTPATCH 169 // DDI only to delete high order patch
// Default values for D3DRS_MAXVERTEXSHADERINST and D3DRS_MAXPIXELSHADERINST
#define D3DINFINITEINSTRUCTIONS 0xffffffff
#if(DIRECT3D_VERSION >= 0x0800 )
// New values for dwOperations in the D3DHAL_DP2STATESET
#define D3DNTHAL_STATESETCREATE 5
// This bit is the same as D3DCLEAR_RESERVED0 in d3d8types.h
// When set it means that driver has to cull rects against current viewport.
// The bit is set only for pure devices
//
#define D3DNTCLEAR_COMPUTERECTS 0x00000008l
typedef struct _D3DNTHAL_DP2MULTIPLYTRANSFORM
{
D3DTRANSFORMSTATETYPE xfrmType;
D3DMATRIX matrix;
} D3DNTHAL_DP2MULTIPLYTRANSFORM;
typedef D3DNTHAL_DP2MULTIPLYTRANSFORM *LPD3DNTHAL_DP2MULTIPLYTRANSFORM;
// Used by SetVertexShader and DeleteVertexShader
typedef struct _D3DNTHAL_DP2VERTEXSHADER
{
// Vertex shader handle.
// The handle could be 0, meaning that the current vertex shader is invalid
// (not set). When driver recieves handle 0, it should invalidate all
// streams pointer
DWORD dwHandle;
} D3DNTHAL_DP2VERTEXSHADER;
typedef D3DNTHAL_DP2VERTEXSHADER *LPD3DNTHAL_DP2VERTEXSHADER;
typedef struct _D3DNTHAL_DP2CREATEVERTEXSHADER
{
DWORD dwHandle; // Shader handle
DWORD dwDeclSize; // Shader declaration size in bytes
DWORD dwCodeSize; // Shader code size in bytes
// Declaration follows
// Shader code follows
} D3DNTHAL_DP2CREATEVERTEXSHADER;
typedef D3DNTHAL_DP2CREATEVERTEXSHADER *LPD3DNTHAL_DP2CREATEVERTEXSHADER;
typedef struct _D3DNTHAL_DP2SETVERTEXSHADERCONST
{
DWORD dwRegister; // Const register to start copying
DWORD dwCount; // Number of 4-float vectors to copy for D3DDP2OP_SETVERTEXSHADERCONST
// Number of 4-integer vectors to copy for D3DDP2OP_SETVERTEXSHADERCONSTI
// Number of BOOL values to copy for D3DDP2OP_SETVERTEXSHADERCONSTB
// Data follows
} D3DNTHAL_DP2SETVERTEXSHADERCONST;
typedef D3DNTHAL_DP2SETVERTEXSHADERCONST *LPD3DNTHAL_DP2SETVERTEXSHADERCONST;
typedef struct _D3DNTHAL_DP2SETSTREAMSOURCE
{
DWORD dwStream; // Stream index, starting from zero
DWORD dwVBHandle; // Vertex buffer handle
DWORD dwStride; // Vertex size in bytes
} D3DNTHAL_DP2SETSTREAMSOURCE;
typedef D3DNTHAL_DP2SETSTREAMSOURCE *LPD3DNTHAL_DP2SETSTREAMSOURCE;
typedef struct _D3DNTHAL_DP2SETSTREAMSOURCEUM
{
DWORD dwStream; // Stream index, starting from zero
DWORD dwStride; // Vertex size in bytes
} D3DNTHAL_DP2SETSTREAMSOURCEUM;
typedef D3DNTHAL_DP2SETSTREAMSOURCEUM *LPD3DNTHAL_DP2SETSTREAMSOURCEUM;
typedef struct _D3DNTHAL_DP2SETINDICES
{
DWORD dwVBHandle; // Index buffer handle
DWORD dwStride; // Index size in bytes (2 or 4)
} D3DNTHAL_DP2SETINDICES;
typedef D3DNTHAL_DP2SETINDICES *LPD3DNTHAL_DP2SETINDICES;
typedef struct _D3DNTHAL_DP2DRAWPRIMITIVE
{
D3DPRIMITIVETYPE primType;
DWORD VStart;
DWORD PrimitiveCount;
} D3DNTHAL_DP2DRAWPRIMITIVE;
typedef D3DNTHAL_DP2DRAWPRIMITIVE *LPD3DNTHAL_DP2DRAWPRIMITIVE;
typedef struct _D3DNTHAL_DP2DRAWINDEXEDPRIMITIVE
{
D3DPRIMITIVETYPE primType;
INT BaseVertexIndex; // Vertex which corresponds to index 0
DWORD MinIndex; // Min vertex index in the vertex buffer
DWORD NumVertices; // Number of vertices starting from MinIndex
DWORD StartIndex; // Start index in the index buffer
DWORD PrimitiveCount;
} D3DNTHAL_DP2DRAWINDEXEDPRIMITIVE;
typedef D3DNTHAL_DP2DRAWINDEXEDPRIMITIVE *LPD3DNTHAL_DP2DRAWINDEXEDPRIMITIVE;
typedef struct _D3DNTHAL_CLIPPEDTRIANGLEFAN
{
DWORD FirstVertexOffset; // Offset in bytes in the current stream 0
DWORD dwEdgeFlags;
DWORD PrimitiveCount;
} D3DNTHAL_CLIPPEDTRIANGLEFAN;
typedef D3DNTHAL_CLIPPEDTRIANGLEFAN *LPD3DNTHAL_CLIPPEDTRIANGLEFAN;
typedef struct _D3DNTHAL_DP2DRAWPRIMITIVE2
{
D3DPRIMITIVETYPE primType;
DWORD FirstVertexOffset; // Offset in bytes in the stream 0
DWORD PrimitiveCount;
} D3DNTHAL_DP2DRAWPRIMITIVE2;
typedef D3DNTHAL_DP2DRAWPRIMITIVE2 *LPD3DNTHAL_DP2DRAWPRIMITIVE2;
typedef struct _D3DNTHAL_DP2DRAWINDEXEDPRIMITIVE2
{
D3DPRIMITIVETYPE primType;
INT BaseVertexOffset; // Stream 0 offset of the vertex which
// corresponds to index 0. This offset could be
// negative, but when an index is added to the
// offset the result is positive
DWORD MinIndex; // Min vertex index in the vertex buffer
DWORD NumVertices; // Number of vertices starting from MinIndex
DWORD StartIndexOffset; // Offset of the start index in the index buffer
DWORD PrimitiveCount; // Number of triangles (points, lines)
} D3DNTHAL_DP2DRAWINDEXEDPRIMITIVE2;
typedef D3DNTHAL_DP2DRAWINDEXEDPRIMITIVE2 *LPD3DNTHAL_DP2DRAWINDEXEDPRIMITIVE2;
// Used by SetPixelShader and DeletePixelShader
typedef struct _D3DNTHAL_DP2PIXELSHADER
{
// Pixel shader handle.
// The handle could be 0, meaning that the current pixel shader is invalid
// (not set).
DWORD dwHandle;
} D3DNTHAL_DP2PIXELSHADER;
typedef D3DNTHAL_DP2PIXELSHADER *LPD3DNTHAL_DP2PIXELSHADER;
typedef struct _D3DNTHAL_DP2CREATEPIXELSHADER
{
DWORD dwHandle; // Shader handle
DWORD dwCodeSize; // Shader code size in bytes
// Shader code follows
} D3DNTHAL_DP2CREATEPIXELSHADER;
typedef D3DNTHAL_DP2CREATEPIXELSHADER *LPD3DNTHAL_DP2CREATEPIXELSHADER;
typedef struct _D3DNTHAL_DP2SETPIXELSHADERCONST
{
DWORD dwRegister; // Const register to start copying
DWORD dwCount; // Number of 4-float vectors to copy for D3DDP2OP_SETPIXELSHADERCONST
// Number of 4-integer vectors to copy for D3DDP2OP_SETPIXELSHADERCONSTI
// Number of BOOL values to copy for D3DDP2OP_SETPIXELSHADERCONSTB
// Data follows
} D3DNTHAL_DP2SETPIXELSHADERCONST;
typedef D3DNTHAL_DP2SETPIXELSHADERCONST *LPD3DNTHAL_DP2SETPIXELSHADERCONST;
// Flags that can be supplied to DRAWRECTPATCH and DRAWTRIPATCH
#define _NT_RTPATCHFLAG_HASSEGS 0x00000001L
#define _NT_RTPATCHFLAG_HASINFO 0x00000002L
typedef struct _D3DNTHAL_DP2DRAWRECTPATCH
{
DWORD Handle;
DWORD Flags;
// Optionally followed by D3DFLOAT[4] NumSegments and/or D3DRECTPATCH_INFO
} D3DNTHAL_DP2DRAWRECTPATCH;
typedef D3DNTHAL_DP2DRAWRECTPATCH *LPD3DNTHAL_DP2DRAWRECTPATCH;
typedef struct _D3DNTHAL_DP2DRAWTRIPATCH
{
DWORD Handle;
DWORD Flags;
// Optionally followed by D3DFLOAT[3] NumSegments and/or D3DTRIPATCH_INFO
} D3DNTHAL_DP2DRAWTRIPATCH;
typedef D3DNTHAL_DP2DRAWTRIPATCH *LPD3DNTHAL_DP2DRAWTRIPATCH;
typedef struct _D3DNTHAL_DP2VOLUMEBLT
{
DWORD dwDDDestSurface; // dest surface
DWORD dwDDSrcSurface; // src surface
DWORD dwDestX; // dest X (width)
DWORD dwDestY; // dest Y (height)
DWORD dwDestZ; // dest Z (depth)
D3DBOX srcBox; // src box
DWORD dwFlags; // blt flags
} D3DNTHAL_DP2VOLUMEBLT;
typedef D3DNTHAL_DP2VOLUMEBLT *LPD3DNTHAL_DP2VOLUMEBLT;
typedef struct _D3DNTHAL_DP2BUFFERBLT
{
DWORD dwDDDestSurface; // dest surface
DWORD dwDDSrcSurface; // src surface
DWORD dwOffset; // Offset in the dest surface (in BYTES)
D3DRANGE rSrc; // src range
DWORD dwFlags; // blt flags
} D3DNTHAL_DP2BUFFERBLT;
typedef D3DNTHAL_DP2BUFFERBLT *LPD3DNTHAL_DP2BUFFERBLT;
typedef struct _D3DNTHAL_DP2ADDDIRTYRECT
{
DWORD dwSurface; // Driver managed surface
RECTL rDirtyArea; // Area marked dirty
} D3DNTHAL_DP2ADDDIRTYRECT;
typedef D3DNTHAL_DP2ADDDIRTYRECT *LPD3DNTHAL_DP2ADDDIRTYRECT;
typedef struct _D3DNTHAL_DP2ADDDIRTYBOX
{
DWORD dwSurface; // Driver managed volume
D3DBOX DirtyBox; // Box marked dirty
} D3DNTHAL_DP2ADDDIRTYBOX;
typedef D3DNTHAL_DP2ADDDIRTYBOX *LPD3DNTHAL_DP2ADDDIRTYBOX;
#if(DIRECT3D_VERSION >= 0x0900 )
typedef struct _D3DNTHAL_DP2CREATEVERTEXSHADERDECL
{
DWORD dwHandle; // Shader function handle
DWORD dwNumVertexElements; // Number of vertex elements
// D3DVERTEXELEMENT9 VertexElements[] that follow
} D3DNTHAL_DP2CREATEVERTEXSHADERDECL ;
typedef D3DNTHAL_DP2CREATEVERTEXSHADERDECL *LPD3DNTHAL_DP2CREATEVERTEXSHADERDECL;
typedef struct _D3DNTHAL_DP2CREATEVERTEXSHADERFUNC
{
DWORD dwHandle; // Shader function handle
DWORD dwSize; // Shader function size in bytes
// Shader declaration follows
} D3DNTHAL_DP2CREATEVERTEXSHADERFUNC ;
typedef D3DNTHAL_DP2CREATEVERTEXSHADERFUNC *LPD3DNTHAL_DP2CREATEVERTEXSHADERFUNC;
typedef struct _D3DNTHAL_DP2SETSTREAMSOURCE2
{
DWORD dwStream; // Stream index, starting from zero
DWORD dwVBHandle; // Vertex buffer handle
DWORD dwOffset; // Offset of the first vertex size in bytes
DWORD dwStride; // Vertex size in bytes
} D3DNTHAL_DP2SETSTREAMSOURCE2;
typedef D3DNTHAL_DP2SETSTREAMSOURCE2 *LPD3DNTHAL_DP2SETSTREAMSOURCE2;
typedef struct _D3DNTHAL_DP2SETSTREAMSOURCEFREQ
{
DWORD dwStream; // Stream index, starting from zero
DWORD dwDivider; // Stream source divider
} D3DNTHAL_DP2SETSTREAMSOURCEFREQ;
typedef D3DNTHAL_DP2SETSTREAMSOURCEFREQ *LPD3DNTHAL_DP2SETSTREAMSOURCEFREQ;
#define D3DNTHAL_ROW_WEIGHTS 1
#define D3DNTHAL_COL_WEIGHTS 2
typedef struct _D3DNTHAL_DP2SETCONVOLUTIONKERNELMONO
{
DWORD dwWidth; // Kernel width
DWORD dwHeight; // Kernel height
DWORD dwFlags;
// If dwFlags & D3DNTHAL_ROW_WEIGHTS, then width floats follow. Otherwise row weights are 1.0.
// If dwFlags & D3DNTHAL_COL_WEIGHTS, then height floats follow. Otherwise column weights are 1.0.
} D3DNTHAL_DP2SETCONVOLUTIONKERNELMONO;
typedef D3DNTHAL_DP2SETCONVOLUTIONKERNELMONO *LPD3DNTHAL_DP2SETCONVOLUTIONKERNELMONO;
typedef struct _D3DNTHAL_DP2COMPOSERECTS
{
DWORD SrcSurfaceHandle;
DWORD DstSurfaceHandle;
DWORD SrcRectDescsVBHandle;
UINT NumRects;
DWORD DstRectDescsVBHandle;
D3DCOMPOSERECTSOP Operation;
INT XOffset;
INT YOffset;
} D3DNTHAL_DP2COMPOSERECTS;
typedef D3DNTHAL_DP2COMPOSERECTS *LPD3DNTHAL_DP2COMPOSERECTS;
typedef RECT D3DNTHAL_DP2SETSCISSORRECT;
typedef D3DNTHAL_DP2SETSCISSORRECT *LPD3DNTHAL_DP2SETSCISSORRECT;
typedef struct _D3DNTHAL_DP2BLT
{
DWORD dwSource; // Source surface
RECTL rSource; // Source rectangle
DWORD dwSourceMipLevel; // Miplevel of lightweight surface
DWORD dwDest; // Dest surface
RECTL rDest; // Dest rectangle
DWORD dwDestMipLevel; // Miplevel of lightweight surface
DWORD Flags; // Can be DP2BLT_POINT, DP2BLT_LINEAR
} D3DNTHAL_DP2BLT;
typedef D3DNTHAL_DP2BLT *LPD3DNTHAL_DP2BLT;
#define DP2BLT_POINT 0x00000001L
#define DP2BLT_LINEAR 0x00000002L
typedef struct _D3DNTHAL_DP2COLORFILL
{
DWORD dwSurface; // Surface getting filled
RECTL rRect; // Surface dimensions to fill
D3DCOLOR Color; // A8R8G8B8 fill color
} D3DNTHAL_DP2COLORFILL;
typedef D3DNTHAL_DP2COLORFILL *LPD3DNTHAL_DP2COLORFILL;
typedef struct _D3DNTHAL_DP2SURFACEBLT
{
DWORD dwSource; // Source surface
RECTL rSource; // Source rectangle
DWORD dwSourceMipLevel; // Miplevel of lightweight surface
DWORD dwDest; // Dest surface
RECTL rDest; // Dest rectangle
DWORD dwDestMipLevel; // Miplevel of lightweight surface
DWORD Flags; // No flags currently defined
} D3DNTHAL_DP2SURFACEBLT;
typedef D3DNTHAL_DP2SURFACEBLT *LPD3DNTHAL_DP2SURFACEBLT;
typedef D3DNTHAL_DP2SETVERTEXSHADERCONST D3DNTHAL_DP2SETVERTEXSHADERCONSTB;
typedef D3DNTHAL_DP2SETVERTEXSHADERCONSTB *LPD3DNTHAL_DP2SETVERTEXSHADERCONSTB;
typedef D3DNTHAL_DP2SETVERTEXSHADERCONST D3DNTHAL_DP2SETVERTEXSHADERCONSTI;
typedef D3DNTHAL_DP2SETVERTEXSHADERCONSTI *LPD3DNTHAL_DP2SETVERTEXSHADERCONSTI;
typedef D3DNTHAL_DP2SETPIXELSHADERCONST D3DNTHAL_DP2SETPIXELSHADERCONSTB;
typedef D3DNTHAL_DP2SETPIXELSHADERCONSTB *LPD3DNTHAL_DP2SETPIXELSHADERCONSTB;
typedef D3DNTHAL_DP2SETPIXELSHADERCONST D3DNTHAL_DP2SETPIXELSHADERCONSTI;
typedef D3DNTHAL_DP2SETPIXELSHADERCONSTI *LPD3DNTHAL_DP2SETPIXELSHADERCONSTI;
typedef struct _D3DNTHAL_DP2CREATEQUERY
{
DWORD dwQueryID;
D3DQUERYTYPE QueryType;
} D3DNTHAL_DP2CREATEQUERY;
typedef D3DNTHAL_DP2CREATEQUERY *LPD3DNTHAL_DP2CREATEQUERY;
typedef struct _D3DNTHAL_DP2DELETEQUERY
{
DWORD dwQueryID;
} D3DNTHAL_DP2DELETEQUERY;
typedef D3DNTHAL_DP2DELETEQUERY *LPD3DNTHAL_DP2DELETEQUERY;
typedef struct _D3DNTHAL_DP2ISSUEQUERY
{
DWORD dwQueryID;
DWORD dwFlags;
} D3DNTHAL_DP2ISSUEQUERY;
typedef D3DNTHAL_DP2ISSUEQUERY *LPD3DNTHAL_DP2ISSUEQUERY;
typedef struct _D3DNTHAL_DP2SETRENDERTARGET2
{
DWORD RTIndex;
DWORD hRenderTarget;
} D3DNTHAL_DP2SETRENDERTARGET2;
typedef D3DNTHAL_DP2SETRENDERTARGET2 *LPD3DNTHAL_DP2SETRENDERTARGET2;
typedef struct _D3DNTHAL_DP2SETDEPTHSTENCIL
{
DWORD hZBuffer;
} D3DNTHAL_DP2SETDEPTHSTENCIL;
typedef D3DNTHAL_DP2SETDEPTHSTENCIL *LPD3DNTHAL_DP2SETDEPTHSTENCIL;
typedef struct _D3DNTHAL_DP2GENERATEMIPSUBLEVELS
{
DWORD hSurface;
D3DTEXTUREFILTERTYPE Filter;
} D3DNTHAL_DP2GENERATEMIPSUBLEVELS;
typedef D3DNTHAL_DP2GENERATEMIPSUBLEVELS *LPD3DNTHAL_DP2GENERATEMIPSUBLEVELS;
#define DDBLT_EXTENDED_PRESENTATION_STRETCHFACTOR 0x00000010l /* old DDBLT_ALPHAEDGEBLEND */
//
// Command structure for driver responses:
//
typedef struct _D3DNTHAL_DP2RESPONSE
{
BYTE bCommand; // response/ command id
BYTE bReserved;
WORD wStateCount; // count of responses to follow
DWORD dwTotalSize; // total size of response (including the DP2REPONSE struct) to enable skipping over.
} D3DNTHAL_DP2RESPONSE, *LPD3DNTHAL_DP2RESPONSE;
// Begin Responses
typedef struct _D3DNTHAL_DP2RESPONSEQUERY
{
DWORD dwQueryID;
DWORD dwSize;
} D3DNTHAL_DP2RESPONSEQUERY;
typedef D3DNTHAL_DP2RESPONSEQUERY *LPD3DNTHAL_DP2RESPONSEQUERY;
// End Responses
#endif // (DIRECT3D_VERSION >= 0x0900 )
// Macros to access shader binary code
#define _NT_D3DSI_GETREGNUM(token) (token & D3DSP_REGNUM_MASK)
#define _NT_D3DSI_GETOPCODE(command) (command & D3DSI_OPCODE_MASK)
#define _NT_D3DSI_GETWRITEMASK(token) (token & D3DSP_WRITEMASK_ALL)
#define _NT_D3DVS_GETSWIZZLECOMP(source, component) \
(source >> ((component << 1) + 16) & 0x3)
#define _NT_D3DVS_GETSWIZZLE(token) (token & D3DVS_SWIZZLE_MASK)
#define _NT_D3DVS_GETSRCMODIFIER(token) (token & D3DSP_SRCMOD_MASK)
#define _NT_D3DVS_GETADDRESSMODE(token) (token & D3DVS_ADDRESSMODE_MASK)
#if(DIRECT3D_VERSION < 0x0900)
#define _NT_D3DSI_GETREGTYPE(token) ((D3DSHADER_PARAM_REGISTER_TYPE)(token & D3DSP_REGTYPE_MASK))
#else
#define _NT_D3DSI_GETREGTYPE(token) ((D3DSHADER_PARAM_REGISTER_TYPE)(((token & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) | \
((token & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2)))
#define _NT_D3DSI_GETUSAGE(token) ((token & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT)
#define _NT_D3DSI_GETUSAGEINDEX(token) ((token & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT)
#define _NT_D3DSI_GETINSTLENGTH(token) ((token & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT)
#define _NT_D3DSI_GETCOMPARISON(token) ((D3DSHADER_COMPARISON)((token & D3DSHADER_COMPARISON_MASK) >> D3DSHADER_COMPARISON_SHIFT))
#define _NT_D3DSI_GETREGISTERPROPERTIES(token) (token & D3DSP_REGISTERPROPERTIES_MASK)
#define _NT_D3DSI_GETTEXTURETYPE(token) (token & D3DSP_TEXTURETYPE_MASK)
#define _NT_D3DSI_GETDSTMODIFIER(token) (token & D3DSP_DSTMOD_MASK))
#define _NT_D3DSI_GETSWIZZLECOMP(source, component) (source >> ((component << 1) + 16) & 0x3)
#define _NT_D3DSI_GETSWIZZLE(token) (token & D3DVS_SWIZZLE_MASK)
#define _NT_D3DSI_GETSRCMODIFIER(token) (token & D3DSP_SRCMOD_MASK)
#define _NT_D3DSI_GETADDRESSMODE(token) (token & D3DVS_ADDRESSMODE_MASK)
#ifdef __cplusplus
// This gets regtype, and also maps D3DSPR_CONSTn to D3DSPR_CONST (for easier parsing)
inline
D3DSHADER_PARAM_REGISTER_TYPE
_NT_D3DSI_GETREGTYPE_RESOLVING_CONSTANTS(
DWORD token)
{
D3DSHADER_PARAM_REGISTER_TYPE RegType = _NT_D3DSI_GETREGTYPE(token);
switch (RegType)
{
case D3DSPR_CONST4:
case D3DSPR_CONST3:
case D3DSPR_CONST2:
return D3DSPR_CONST;
default:
return RegType;
}
}
// The inline function below retrieves register number for an opcode,
// taking into account that: if the type is a
// D3DSPR_CONSTn, the register number needs to be remapped.
//
// D3DSPR_CONST is for c0-c2047
// D3DSPR_CONST2 is for c2048-c4095
// D3DSPR_CONST3 is for c4096-c6143
// D3DSPR_CONST4 is for c6144-c8191
//
// For example if the instruction token specifies type D3DSPR_CONST4, reg# 3,
// the register number retrieved is 6147.
// For other register types, the register number is just returned unchanged.
inline
UINT
_NT_D3DSI_GETREGNUM_RESOLVING_CONSTANTS(
DWORD token)
{
D3DSHADER_PARAM_REGISTER_TYPE RegType = _NT_D3DSI_GETREGTYPE(token);
UINT RegNum = _NT_D3DSI_GETREGNUM(token);
switch(RegType)
{
case D3DSPR_CONST4:
return RegNum + 6144;
case D3DSPR_CONST3:
return RegNum + 4096;
case D3DSPR_CONST2:
return RegNum + 2048;
default:
return RegNum;
}
}
#endif // __cplusplus
#endif
//-----------------------------------------------------------------------------
//
// DirectX 8.0's new driver info querying mechanism.
//
// How to handle the new driver info query mechanism.
//
// DirectX 8.0 utilizes an extension to GetDriverInfo() to query for
// additional information from the driver. Currently this mechanism is only
// used for querying for DX8 style D3D caps but it may be used for other
// information over time.
//
// This extension to GetDriverInfo takes the form of a GetDriverInfo call
// with the GUID GUID_GetDriverInfo2. When a GetDriverInfo call with this
// GUID is received by the driver the driver must check the data passed
// in the lpvData field of the DD_GETDRIVERINFODATA data structure to see
// what information is being requested.
//
// It is important to note that the GUID GUID_GetDriverInfo2 is, in fact,
// the same as the GUID_DDStereoMode. If you driver doesn't handle
// GUID_DDStereoMode this is not an issue. However, if you wish your driver
// to handle GUID_DDStereoMode as well as GUID_GetDriverInfo2 special action
// must be taken. When a call tp GetDriverInfo with the GUID
// GUID_GetDriverInfo2/GUID_DDStereoMode is made the runtime sets the
// dwHeight field of the DD_STEREOMODE structure to the special value
// D3DGDI2_MAGIC. In this way you can determine when the request is a
// stereo mode call or a GetDriverInfo2 call. The dwHeight field of
// DD_STEREOMODE corresponds to the dwMagic field of the
// DD_GETDRIVERINFO2DATA structure.
//
// The dwExpectedSize field of the DD_GETDRIVERINFODATA structure is not
// used by when a GetDriverInfo2 request is being made and should be
// ignored. The actual expected size of the data is found in the
// dwExpectedSize of the DD_GETDRIVERINFO2DATA structure.
//
// Once the driver has determined that this is a call to
// GetDriverInfo2 it must then determine the type of information being
// requested by the runtime. This type is contained in the dwType field
// of the DD_GETDRIVERINFO2DATA data structure.
//
// Finally, once the driver knows this is a GetDriverInfo2 request of a
// particular type it can copy the requested data into the data buffer.
// It is important to note that the lpvData field of the DD_GETDRIVERINFODATA
// data structure points to data buffer in which to copy your data. lpvData
// also points to the DD_GETDRIVERINFO2DATA structure. This means that the
// data returned by the driver will overwrite the DD_GETDRIVERINFO2DATA
// structure and, hence, the DD_GETDRIVERINFO2DATA structure occupies the
// first few DWORDs of the buffer.
//
// The following code fragment demonstrates how to handle GetDriverInfo2.
//
// D3DCAPS8 myD3DCaps8;
//
// DWORD CALLBACK
// DdGetDriverInfo(LPDDHAL_GETDRIVERINFODATA lpData)
// {
// if (MATCH_GUID((lpData->guidInfo), GUID_GetDriverInfo2) )
// {
// ASSERT(NULL != lpData);
// ASSERT(NULL != lpData->lpvData);
//
// // Is this a call to GetDriverInfo2 or DDStereoMode?
// if (((DD_GETDRIVERINFO2DATA*)(lpData->lpvData))->dwMagic == D3DGDI2_MAGIC)
// {
// // Yes, its a call to GetDriverInfo2, fetch the
// // DD_GETDRIVERINFO2DATA data structure.
// DD_GETDRIVERINFO2DATA* pgdi2 = lpData->lpvData;
// ASSERT(NULL != pgdi2);
//
// // What type of request is this?
// switch (pgdi2->dwType)
// {
// case D3DGDI2_TYPE_GETD3DCAPS8:
// {
// // The runtime is requesting the DX8 D3D caps so
// // copy them over now.
//
// // It should be noted that the dwExpectedSize field
// // of DD_GETDRIVERINFODATA is not used for
// // GetDriverInfo2 calls and should be ignored.
// size_t copySize = min(sizeof(myD3DCaps8), pgdi2->dwExpectedSize);
// memcpy(lpData->lpvData, &myD3DCaps8, copySize);
// lpData->dwActualSize = copySize;
// lpData->ddRVal = DD_OK;
// return DDHAL_DRIVER_HANDLED;
// }
// default:
// // For any other GetDriverInfo2 types not handled
// // or understood by the driver set an ddRVal of
// // DDERR_CURRENTLYNOTAVAIL and return
// // DDHAL_DRIVER_HANDLED.
// lpData->dwActualSize = 0;
// lpData->ddRVal = DDERR_CURRENTLYNOTAVAIL;
// return DDHAL_DRIVER_HANDLED;
// }
// }
// else
// {
// // It must be a call a request for stereo mode support.
// // Fetch the stereo mode data
// DD_STEREOMODE* pStereoMode = lpData->lpvData;
// ASSERT(NULL != pStereoMode);
//
// // Process the stereo mode request...
// lpData->dwActualSize = sizeof(DD_STEREOMODE);
// lpData->ddRVal = DD_OK;
// return DDHAL_DRIVER_HANDLED;
// }
// }
//
// // Handle any other device GUIDs...
//
// } // DdGetDriverInfo
//
//-----------------------------------------------------------------------------
//
// The data structure which is passed to the driver when GetDriverInfo is
// called with a GUID of GUID_GetDriverInfo2.
//
// NOTE: Although the fields listed below are all read only this data
// structure is actually the first four DWORDs of the data buffer into
// which the driver writes the requested infomation. As such, these fields
// (and the entire data structure) are overwritten by the data returned by
// the driver.
//
typedef struct _DDNT_GETDRIVERINFO2DATA
{
DWORD dwReserved; // Reserved Field.
// Driver should not read or write this field.
DWORD dwMagic; // Magic Number. Has the value D3DGDI2_MAGIC if
// this is a GetDriverInfo2 call. Otherwise
// this structure is, in fact, a DD_STEREOMODE
// call.
// Driver should only read this field.
DWORD dwType; // Type of information requested. This field
// contains one of the DDGDI2_TYPE_ #defines
// listed below.
// Driver should only read (not write) this
// field.
DWORD dwExpectedSize; // Expected size of the information requested.
// Driver should only read (not write) this
// field.
// The remainder of the data buffer (beyond the first four DWORDs)
// follows here.
} DDNT_GETDRIVERINFO2DATA;
//
// IMPORTANT NOTE: This GUID has exactly the same value as GUID_DDStereoMode
// and as such you must be very careful when using it. If your driver needs
// to handle both GetDriverInfo2 and DDStereoMode it must have a single
// check for the shared GUID and then distinguish between which use of that
// GUID is being requested.
//
#define _NT_GUID_GetDriverInfo2 (GUID_DDStereoMode)
//
// Magic value used to determine whether a GetDriverInfo call with the
// GUID GUID_GetDriverInfo2/GUID_DDStereoMode is a GetDriverInfo2 request
// or a query about stereo capabilities. This magic number is stored in
// the dwHeight field of the DD_STEREOMODE data structure.
//
#define _NT_D3DGDI2_MAGIC (0xFFFFFFFFul)
//
// The types of information which can be requested from the driver via
// GetDriverInfo2.
//
#define _NT_D3DGDI2_TYPE_GETD3DCAPS8 (0x00000001ul) // Return the D3DCAPS8 data
#define _NT_D3DGDI2_TYPE_GETFORMATCOUNT (0x00000002ul) // Return the number of supported formats
#define _NT_D3DGDI2_TYPE_GETFORMAT (0x00000003ul) // Return a particular format
#define _NT_D3DGDI2_TYPE_DXVERSION (0x00000004ul) // Notify driver of current DX Version
#define _NT_D3DGDI2_TYPE_DEFERRED_AGP_AWARE (0x00000018ul) // Runtime is aware of deferred AGP frees, and will send following
#define _NT_D3DGDI2_TYPE_FREE_DEFERRED_AGP (0x00000019ul) // Free any deferred-freed AGP allocations for this process
#define _NT_D3DGDI2_TYPE_DEFER_AGP_FREES (0x00000020ul) // Start Deferring AGP frees for this process
#if(DIRECT3D_VERSION >= 0x0900)
#define _NT_D3DGDI2_TYPE_GETD3DCAPS9 (0x00000010ul) // Return the D3DCAPS9 data
#define _NT_D3DGDI2_TYPE_GETEXTENDEDMODECOUNT (0x00000011ul) // Return the number of supported extended mode
#define _NT_D3DGDI2_TYPE_GETEXTENDEDMODE (0x00000012ul) // Return a particular extended mode
#define _NT_D3DGDI2_TYPE_GETADAPTERGROUP (0x00000013ul) // Return a adapter group information
#define _NT_D3DGDI2_TYPE_GETMULTISAMPLEQUALITYLEVELS (0x00000016ul) // Return the number of multisample quality levels
#define _NT_D3DGDI2_TYPE_GETD3DQUERYCOUNT (0x00000021ul) // Return the number of suported queries
#define _NT_D3DGDI2_TYPE_GETD3DQUERY (0x00000022ul) // Return supported query
#define _NT_D3DGDI2_TYPE_GETDDIVERSION (0x00000023ul) // Return DX9_DDI_VERSION
#endif // (DIRECT3D_VERSION >= 0x0900)
//
// This data structure is returned by the driver in response to a
// GetDriverInfo2 query with the type D3DGDI2_TYPE_GETFORMATCOUNT. It simply
// gives the number of surface formats supported by the driver. Currently this
// structure consists of a single member giving the number of supported
// surface formats.
//
typedef struct _DDNT_GETFORMATCOUNTDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
DWORD dwFormatCount; // [out] Number of supported surface formats
DWORD dwReserved; // Reserved
} DDNT_GETFORMATCOUNTDATA;
//
// This data structure is used to request a specific surface format from the
// driver. It is guaranteed that the requested format will be greater than or
// equal to zero and less that the format count reported by the driver from
// the preceeding D3DGDI2_TYPE_GETFORMATCOUNT request.
//
typedef struct _DDNT_GETFORMATDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
DWORD dwFormatIndex; // [in] The format to return
DDPIXELFORMAT format; // [out] The actual format
} DDNT_GETFORMATDATA;
//
// This data structure is used to notify drivers about the DirectX version
// number. This is the value that is denoted as DD_RUNTIME_VERSION in the
// DDK headers.
//
typedef struct _DDNT_DXVERSION
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
DWORD dwDXVersion; // [in] The Version of DX
DWORD dwReserved; // Reserved
} DDNT_DXVERSION;
// Informs driver that runtime will send a notification after last outstanding AGP
// lock has been released.
typedef struct _DDNT_DEFERRED_AGP_AWARE_DATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
} DDNT_DEFERRED_AGP_AWARE_DATA;
// Notification that the last AGP lock has been released. Driver can free all deferred AGP
// allocations for this process.
typedef struct _DDNT_FREE_DEFERRED_AGP_DATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
DWORD dwProcessId; // [in] Process ID for whom to free deferred AGP
} DDNT_FREE_DEFERRED_AGP_DATA;
#if(DIRECT3D_VERSION >= 0x0900)
//
// This data structure is returned by the driver in response to a
// GetDriverInfo2 query with the type D3DGDI2_TYPE_GETEXTENDEDMODECOUNT. It simply
// gives the number of extended video modes supported by the driver. Currently this
// structure consists of a single member giving the number of supported extended
// video modes.
//
typedef struct _DDNT_GETEXTENDEDMODECOUNTDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
DWORD dwModeCount; // [out] Number of supported extended video modes
DWORD dwReserved; // Reserved
} DDNT_GETEXTENDEDMODECOUNTDATA;
//
// This data structure is used to request a specific extended video mode from the
// driver. It is guaranteed that the requested format will be greater than or
// equal to zero and less that the format count reported by the driver from
// the preceeding D3DGDI2_TYPE_GETEXTENDEDMODECOUNT request.
//
typedef struct _DDNT_GETEXTENDEDMODEDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
DWORD dwModeIndex; // [in] The format to return
D3DDISPLAYMODE mode; // [out] The actual format
} DDNT_GETEXTENDEDMODEDATA;
//
// This data structure is used to request a adapter group information from the driver.
// A adapter group is a set of adapters which share video hardware (like video memory,
// 3D accelerator). Thus it is mainly for DualView video adapter. Direct3D runtime
// will share surface resources (like texture, vertex buffers) across adapters within
// a adapter group upon application's request.
//
typedef struct _DDNT_GETADAPTERGROUPDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
ULONG_PTR ulUniqueAdapterGroupId; // [out] The unique id of adapter group that this adapter belonging to
DWORD dwReserved1; // Reserved, must be 0
DWORD dwReserved2; // Reserved, must be 0
} DDNT_GETADAPTERGROUPDATA;
// This data structure used to request the supported quality levels for a given sample count,
// presentation type, and pixel format.
typedef struct _DDNT_MULTISAMPLEQUALITYLEVELSDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; //[in/out] GetDriverInfo2 data
D3DFORMAT Format; //[in] Format of multi-sampled render-target
BOOL bFlip : 1; //[in] FALSE means blt-style resolution
D3DMULTISAMPLE_TYPE MSType : 31; //[in]
DWORD QualityLevels; //[out]
} DDNT_MULTISAMPLEQUALITYLEVELSDATA;
typedef struct _DDNT_GETD3DQUERYCOUNTDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
DWORD dwNumQueries; // [out] Number of queries
} DDNT_GETD3DQUERYCOUNTDATA;
typedef struct _DDNT_GETD3DQUERYDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
union
{
DWORD dwQueryIndex; // [in] Index of cap
D3DQUERYTYPE QueryType; // [out] Query cap
};
} DDNT_GETD3DQUERYDATA;
typedef struct _DDNT_GETDDIVERSIONDATA
{
DDNT_GETDRIVERINFO2DATA gdi2; // [in/out] GetDriverInfo2 data
DWORD dwDXVersion; // [in] DX Version (9 for DX9, etc.)
DWORD dwDDIVersion; // [out] DX9_DDI_VERSION
} DDNT_GETDDIVERSIONDATA;
#define DX9_DDI_VERSION 4
#endif // (DIRECT3D_VERSION >= 0x0900 )
#if(DIRECT3D_VERSION >= 0x0900)
// GetDriverState IDs - D3DDEVINFO structures used for query mechanism in public headers
// This was eliminated in DX9 but was exposed in DX8.1 so the drivers still need it
#define D3DFMT_W11V11U10 (D3DFORMAT)65
#endif // (DIRECT3D_VERSION >= 0x0900 )
// New Caps that are not API visible that the driver exposes.
#define _NT_D3DDEVCAPS_HWVERTEXBUFFER 0x02000000L // Device supports Driver Allocated Vertex Buffers
#define _NT_D3DDEVCAPS_HWINDEXBUFFER 0x04000000L // Device supports Driver Allocated Index Buffers
#define _NT_D3DDEVCAPS_SUBVOLUMELOCK 0x08000000L // Device supports locking a part of volume texture
#define _NT_D3DPMISCCAPS_FOGINFVF 0x00002000L // Device supports separate fog value in the FVF
// New FVF flags that are not API visible but accessed by the driver
// Note, that D3DFVF_RESERVED2 includes this flag and should not be used for validation
#define _NT_D3DFVF_FOG 0x00002000L // There is a separate fog value in the FVF vertex
// Flags that drivers need to expose for DX8 but were removed from the DX9 headers
#if(DIRECT3D_VERSION >= 0x0900)
#ifndef D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
#define D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE 0x00800000L
#endif /* D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE */
#ifndef D3DPRASTERCAPS_PAT
#define D3DPRASTERCAPS_PAT D3DPRASTERCAPS_RESERVED2
#endif
#endif
//
// This stuff is not API visible but should be DDI visible.
// Should be in Sync with d3d8types.h
//
#define _NT_D3DFMT_D32 (D3DFORMAT)71
#define _NT_D3DFMT_S1D15 (D3DFORMAT)72
#define _NT_D3DFMT_D15S1 (D3DFORMAT)73
#define _NT_D3DFMT_S8D24 (D3DFORMAT)74
#define _NT_D3DFMT_D24S8 (D3DFORMAT)75
#define _NT_D3DFMT_X8D24 (D3DFORMAT)76
#define _NT_D3DFMT_D24X8 (D3DFORMAT)77
#define _NT_D3DFMT_X4S4D24 (D3DFORMAT)78
#define _NT_D3DFMT_D24X4S4 (D3DFORMAT)79
//---------------- Vertex shader defines -------------------------------
// Vertex Shader register limits. D3D device must provide at least
// specified number of registers
// This one was used in DX8 only.
#define _NT_D3DVS_MAXINSTRUCTIONCOUNT_V1_1 128
// Max number of labels in a shader
#define _NT_D3DVS_LABEL_MAX_V3_0 2048
// Max number of output texture coordinates
#define _NT_D3DVS_TCRDOUTREG_MAX_V1_1 8
#define _NT_D3DVS_TCRDOUTREG_MAX_V2_0 8
#define _NT_D3DVS_TCRDOUTREG_MAX_V2_1 8
#define _NT_D3DVS_OUTPUTREG_MAX_V3_0 12
#define _NT_D3DVS_OUTPUTREG_MAX_SW_DX9 16
// Max number of output attributes (colors)
#define _NT_D3DVS_ATTROUTREG_MAX_V1_1 2
#define _NT_D3DVS_ATTROUTREG_MAX_V2_0 2
#define _NT_D3DVS_ATTROUTREG_MAX_V2_1 2
// Max number of input registers
#define _NT_D3DVS_INPUTREG_MAX_V1_1 16
#define _NT_D3DVS_INPUTREG_MAX_V2_0 16
#define _NT_D3DVS_INPUTREG_MAX_V2_1 16
#define _NT_D3DVS_INPUTREG_MAX_V3_0 16
// Max number of temp registers
#define _NT_D3DVS_TEMPREG_MAX_V1_1 12
#define _NT_D3DVS_TEMPREG_MAX_V2_0 12
#define _NT_D3DVS_TEMPREG_MAX_V2_1 32
#define _NT_D3DVS_TEMPREG_MAX_V3_0 32
// Max number of constant float vector registers
#define _NT_D3DVS_CONSTREG_MAX_V1_1 96
#define _NT_D3DVS_CONSTREG_MAX_V2_0 8192
#define _NT_D3DVS_CONSTREG_MAX_V2_1 8192
#define _NT_D3DVS_CONSTREG_MAX_V3_0 8192
// The number of INTEGER constants for software is limited only by the binary opcode specification: ;internal
#define _NT_D3DVS_CONSTINTREG_MAX_SW_DX9 2048
// Max number of integer constant registers
#define _NT_D3DVS_CONSTINTREG_MAX_V2_0 16
#define _NT_D3DVS_CONSTINTREG_MAX_V2_1 16
#define _NT_D3DVS_CONSTINTREG_MAX_V3_0 16
// The number of BOOL constants for software is limited only by the binary opcode specification: ;internal
#define _NT_D3DVS_CONSTBOOLREG_MAX_SW_DX9 2048
// Max number of BOOL constant registers
#define _NT_D3DVS_CONSTBOOLREG_MAX_V2_0 16
#define _NT_D3DVS_CONSTBOOLREG_MAX_V2_1 16
#define _NT_D3DVS_CONSTBOOLREG_MAX_V3_0 16
// Max number of vector address registers
#define _NT_D3DVS_ADDRREG_MAX_V1_1 1
#define _NT_D3DVS_ADDRREG_MAX_V2_0 1
#define _NT_D3DVS_ADDRREG_MAX_V2_1 1
#define _NT_D3DVS_ADDRREG_MAX_V3_0 1
// Max absolute value of the loop step
#define _NT_D3DVS_MAXLOOPSTEP_V2_0 128
#define _NT_D3DVS_MAXLOOPSTEP_V2_1 128
#define _NT_D3DVS_MAXLOOPSTEP_V3_0 128
// Max absolute value of the loop initial valuep
#define _NT_D3DVS_MAXLOOPINITVALUE_V2_0 255
#define _NT_D3DVS_MAXLOOPINITVALUE_V2_1 255
#define _NT_D3DVS_MAXLOOPINITVALUE_V3_0 255
// Max loop interation count
#define _NT_D3DVS_MAXLOOPITERATIONCOUNT_V2_0 255
#define _NT_D3DVS_MAXLOOPITERATIONCOUNT_V2_1 255
#define _NT_D3DVS_MAXLOOPITERATIONCOUNT_V3_0 255
// Number of PREDICATE registers
#define _NT_D3DVS_PREDICATE_MAX_V2_1 1
#define _NT_D3DVS_PREDICATE_MAX_V3_0 1
//---------------- End vertex shader defines -------------------------------
//---------------- Pixel shader defines ----------------------------------
// Pixel Shader register limits. D3D device must provide at least
// specified number of registers
// Number of INPUT registers based on shader version
#define _NT_D3DPS_INPUTREG_MAX_V1_1 2
#define _NT_D3DPS_INPUTREG_MAX_V1_2 2
#define _NT_D3DPS_INPUTREG_MAX_V1_3 2
#define _NT_D3DPS_INPUTREG_MAX_V1_4 2
#define _NT_D3DPS_INPUTREG_MAX_V2_0 2
#define _NT_D3DPS_INPUTREG_MAX_V2_1 2
#define _NT_D3DPS_INPUTREG_MAX_V3_0 12
// Number of TEMP registers based on shader version
#define _NT_D3DPS_TEMPREG_MAX_V1_1 2
#define _NT_D3DPS_TEMPREG_MAX_V1_2 2
#define _NT_D3DPS_TEMPREG_MAX_V1_3 2
#define _NT_D3DPS_TEMPREG_MAX_V1_4 6
#define _NT_D3DPS_TEMPREG_MAX_V2_0 12
#define _NT_D3DPS_TEMPREG_MAX_V2_1 32
#define _NT_D3DPS_TEMPREG_MAX_V3_0 32
// Number of TEXTURE registers based on shader version
#define _NT_D3DPS_TEXTUREREG_MAX_V1_1 4
#define _NT_D3DPS_TEXTUREREG_MAX_V1_2 4
#define _NT_D3DPS_TEXTUREREG_MAX_V1_3 4
#define _NT_D3DPS_TEXTUREREG_MAX_V1_4 6
#define _NT_D3DPS_TEXTUREREG_MAX_V2_0 8
#define _NT_D3DPS_TEXTUREREG_MAX_V2_1 8
#define _NT_D3DPS_TEXTUREREG_MAX_V3_0 0
// Number of COLOROUT registers based on shader version
#define _NT_D3DPS_COLOROUT_MAX_V2_0 4
#define _NT_D3DPS_COLOROUT_MAX_V2_1 4
#define _NT_D3DPS_COLOROUT_MAX_V3_0 4
// Number of PREDICATE registers based on shader version
#define _NT_D3DPS_PREDICATE_MAX_V2_1 1
#define _NT_D3DPS_PREDICATE_MAX_V3_0 1
// The number of FLOAT constants for software is limited only by the binary opcode specification: ;internal
#define _NT_D3DPS_CONSTREG_MAX_SW_DX9 8192
// Number of FLOAT constants based on shader version
#define _NT_D3DPS_CONSTREG_MAX_V1_1 8
#define _NT_D3DPS_CONSTREG_MAX_V1_2 8
#define _NT_D3DPS_CONSTREG_MAX_V1_3 8
#define _NT_D3DPS_CONSTREG_MAX_V1_4 8
#define _NT_D3DPS_CONSTREG_MAX_V2_0 32
#define _NT_D3DPS_CONSTREG_MAX_V2_1 32
#define _NT_D3DPS_CONSTREG_MAX_V3_0 224
// The number of BOOL constants for software is limited only by the binary opcode specification: ;internal
#define _NT_D3DPS_CONSTBOOLREG_MAX_SW_DX9 2048
// Max number of pixel shader hardware BOOL constant registers
#define _NT_D3DPS_CONSTBOOLREG_MAX_V2_1 16
#define _NT_D3DPS_CONSTBOOLREG_MAX_V3_0 16
// The number of INTEGER constants for software is limited only by the binary opcode specification: ;internal
#define _NT_D3DPS_CONSTINTREG_MAX_SW_DX9 2048
// Max number of pixel shader hardware INTEGER constant registers
#define _NT_D3DPS_CONSTINTREG_MAX_V2_1 16
#define _NT_D3DPS_CONSTINTREG_MAX_V3_0 16
// Max absolute value for loop step
#define _NT_D3DPS_MAXLOOPSTEP_V2_1 128
#define _NT_D3DPS_MAXLOOPSTEP_V3_0 128
// Max absolute value for loop initial value
#define _NT_D3DPS_MAXLOOPINITVALUE_V2_1 255
#define _NT_D3DPS_MAXLOOPINITVALUE_V3_0 255
// Max loop interation count
#define _NT_D3DPS_MAXLOOPITERATIONCOUNT_V2_1 255
#define _NT_D3DPS_MAXLOOPITERATIONCOUNT_V3_0 255
//---------------- End pixel shader defines -------------------------------
// Pixel Shader DX8 register limits. D3D device will have at most these
// specified number of registers
//
// Sync up d3d?dm.hpp with D3DPS_*_MAX_DX8 ;internal
#define _NT_D3DPS_INPUTREG_MAX_DX8 8
#define _NT_D3DPS_TEMPREG_MAX_DX8 8
#define _NT_D3DPS_CONSTREG_MAX_DX8 8
#define _NT_D3DPS_TEXTUREREG_MAX_DX8 8
#endif /* DIRECT3D_VERSION >= 0x0800 */
#if(DIRECT3D_VERSION >= 0x0900)
// bit declarations for _Type fields
#define D3DVSDT_FLOAT1 0x00 // 1D float expanded to (value, 0., 0., 1.)
#define D3DVSDT_FLOAT2 0x01 // 2D float expanded to (value, value, 0., 1.)
#define D3DVSDT_FLOAT3 0x02 // 3D float expanded to (value, value, value, 1.)
#define D3DVSDT_FLOAT4 0x03 // 4D float
#define D3DVSDT_D3DCOLOR 0x04 // 4D packed unsigned bytes mapped to 0. to 1. range
// Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A)
#define D3DVSDT_UBYTE4 0x05 // 4D unsigned byte
#define D3DVSDT_SHORT2 0x06 // 2D signed short expanded to (value, value, 0., 1.)
#define D3DVSDT_SHORT4 0x07 // 4D signed short
#define D3DVSDE_POSITION 0
#define D3DVSDE_BLENDWEIGHT 1
#define D3DVSDE_BLENDINDICES 2
#define D3DVSDE_NORMAL 3
#define D3DVSDE_PSIZE 4
#define D3DVSDE_DIFFUSE 5
#define D3DVSDE_SPECULAR 6
#define D3DVSDE_TEXCOORD0 7
#define D3DVSDE_TEXCOORD1 8
#define D3DVSDE_TEXCOORD2 9
#define D3DVSDE_TEXCOORD3 10
#define D3DVSDE_TEXCOORD4 11
#define D3DVSDE_TEXCOORD5 12
#define D3DVSDE_TEXCOORD6 13
#define D3DVSDE_TEXCOORD7 14
#define D3DVSDE_POSITION2 15
#define D3DVSDE_NORMAL2 16
/* DX8 style vertex declaration
Vertex Shader Declaration
The declaration portion of a vertex shader defines the static external
interface of the shader. The information in the declaration includes:
- Assignments of vertex shader input registers to data streams. These
assignments bind a specific vertex register to a single component within a
vertex stream. A vertex stream element is identified by a byte offset
within the stream and a type. The type specifies the arithmetic data type
plus the dimensionality (1, 2, 3, or 4 values). Stream data which is
less than 4 values are always expanded out to 4 values with zero or more
0.F values and one 1.F value.
- Assignment of vertex shader input registers to implicit data from the
primitive tessellator. This controls the loading of vertex data which is
not loaded from a stream, but rather is generated during primitive
tessellation prior to the vertex shader.
- Loading data into the constant memory at the time a shader is set as the
current shader. Each token specifies values for one or more contiguous 4
DWORD constant registers. This allows the shader to update an arbitrary
subset of the constant memory, overwriting the device state (which
contains the current values of the constant memory). Note that these
values can be subsequently overwritten (between DrawPrimitive calls)
during the time a shader is bound to a device via the
SetVertexShaderConstant method.
Declaration arrays are single-dimensional arrays of DWORDs composed of
multiple tokens each of which is one or more DWORDs. The single-DWORD
token value 0xFFFFFFFF is a special token used to indicate the end of the
declaration array. The single DWORD token value 0x00000000 is a NOP token
with is ignored during the declaration parsing. Note that 0x00000000 is a
valid value for DWORDs following the first DWORD for multiple word tokens.
[31:29] TokenType
0x0 - NOP (requires all DWORD bits to be zero)
0x1 - stream selector
0x2 - stream data definition (map to vertex input memory)
0x3 - vertex input memory from tessellator
0x4 - constant memory from shader
0x5 - extension
0x6 - reserved
0x7 - end-of-array (requires all DWORD bits to be 1)
NOP Token (single DWORD token)
[31:29] 0x0
[28:00] 0x0
Stream Selector (single DWORD token)
[31:29] 0x1
[28] indicates whether this is a tessellator stream
[27:04] 0x0
[03:00] stream selector (0..15)
Stream Data Definition (single DWORD token)
Vertex Input Register Load
[31:29] 0x2
[28] 0x0
[27:20] 0x0
[19:16] type (dimensionality and data type)
[15:04] 0x0
[03:00] vertex register address (0..15)
Data Skip (no register load)
[31:29] 0x2
[28] 0x1
[27:20] 0x0
[19:16] count of DWORDS to skip over (0..15)
[15:00] 0x0
Vertex Input Memory from Tessellator Data (single DWORD token)
[31:29] 0x3
[28] indicates whether data is normals or u/v
[27:24] 0x0
[23:20] vertex register address (0..15)
[19:16] type (dimensionality)
[15:04] 0x0
[03:00] vertex register address (0..15)
Constant Memory from Shader (multiple DWORD token)
[31:29] 0x4
[28:25] count of 4*DWORD constants to load (0..15)
[24:07] 0x0
[06:00] constant memory address (0..95)
Extension Token (single or multiple DWORD token)
[31:29] 0x5
[28:24] count of additional DWORDs in token (0..31)
[23:00] extension-specific information
End-of-array token (single DWORD token)
[31:29] 0x7
[28:00] 0x1fffffff
The stream selector token must be immediately followed by a contiguous set of stream data definition tokens. This token sequence fully defines that stream, including the set of elements within the stream, the order in which the elements appear, the type of each element, and the vertex register into which to load an element.
Streams are allowed to include data which is not loaded into a vertex register, thus allowing data which is not used for this shader to exist in the vertex stream. This skipped data is defined only by a count of DWORDs to skip over, since the type information is irrelevant.
The token sequence:
Stream Select: stream=0
Stream Data Definition (Load): type=FLOAT3; register=3
Stream Data Definition (Load): type=FLOAT3; register=4
Stream Data Definition (Skip): count=2
Stream Data Definition (Load): type=FLOAT2; register=7
defines stream zero to consist of 4 elements, 3 of which are loaded into registers and the fourth skipped over. Register 3 is loaded with the first three DWORDs in each vertex interpreted as FLOAT data. Register 4 is loaded with the 4th, 5th, and 6th DWORDs interpreted as FLOAT data. The next two DWORDs (7th and 8th) are skipped over and not loaded into any vertex input register. Register 7 is loaded with the 9th and 10th DWORDS interpreted as FLOAT data.
Placing of tokens other than NOPs between the Stream Selector and Stream Data Definition tokens is disallowed.
*/
#ifndef __COMMONHALDEFINES
#define __COMMONHALDEFINES
typedef enum _D3DVSD_TOKENTYPE
{
D3DVSD_TOKEN_NOP = 0, // NOP or extension
D3DVSD_TOKEN_STREAM, // stream selector
D3DVSD_TOKEN_STREAMDATA, // stream data definition (map to vertex input memory)
D3DVSD_TOKEN_TESSELLATOR, // vertex input memory from tessellator
D3DVSD_TOKEN_CONSTMEM, // constant memory from shader
D3DVSD_TOKEN_EXT, // extension
D3DVSD_TOKEN_END = 7, // end-of-array (requires all DWORD bits to be 1)
D3DVSD_FORCE_DWORD = 0x7fffffff,// force 32-bit size enum
} D3DVSD_TOKENTYPE;
#endif // __COMMONHALDEFINES
#define D3DVSD_TOKENTYPESHIFT 29
#define D3DVSD_TOKENTYPEMASK (7 << D3DVSD_TOKENTYPESHIFT)
#define D3DVSD_STREAMNUMBERSHIFT 0
#define D3DVSD_STREAMNUMBERMASK (0xF << D3DVSD_STREAMNUMBERSHIFT)
#define D3DVSD_DATALOADTYPESHIFT 28
#define D3DVSD_DATALOADTYPEMASK (0x1 << D3DVSD_DATALOADTYPESHIFT)
#define D3DVSD_DATATYPESHIFT 16
#define D3DVSD_DATATYPEMASK (0xF << D3DVSD_DATATYPESHIFT)
#define D3DVSD_SKIPCOUNTSHIFT 16
#define D3DVSD_SKIPCOUNTMASK (0xF << D3DVSD_SKIPCOUNTSHIFT)
#define D3DVSD_VERTEXREGSHIFT 0
#define D3DVSD_VERTEXREGMASK (0x1F << D3DVSD_VERTEXREGSHIFT)
#define D3DVSD_VERTEXREGINSHIFT 20
#define D3DVSD_VERTEXREGINMASK (0xF << D3DVSD_VERTEXREGINSHIFT)
#define D3DVSD_CONSTCOUNTSHIFT 25
#define D3DVSD_CONSTCOUNTMASK (0xF << D3DVSD_CONSTCOUNTSHIFT)
#define D3DVSD_CONSTADDRESSSHIFT 0
#define D3DVSD_CONSTADDRESSMASK (0x7F << D3DVSD_CONSTADDRESSSHIFT)
#define D3DVSD_CONSTRSSHIFT 16
#define D3DVSD_CONSTRSMASK (0x1FFF << D3DVSD_CONSTRSSHIFT)
#define D3DVSD_EXTCOUNTSHIFT 24
#define D3DVSD_EXTCOUNTMASK (0x1F << D3DVSD_EXTCOUNTSHIFT)
#define D3DVSD_EXTINFOSHIFT 0
#define D3DVSD_EXTINFOMASK (0xFFFFFF << D3DVSD_EXTINFOSHIFT)
#define D3DVSD_MAKETOKENTYPE(tokenType) ((tokenType << D3DVSD_TOKENTYPESHIFT) & D3DVSD_TOKENTYPEMASK)
// macros for generation of CreateVertexShader Declaration token array
// Set current stream
// _StreamNumber [0..(MaxStreams-1)] stream to get data from
//
#define D3DVSD_STREAM( _StreamNumber ) \
(D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (_StreamNumber))
// Set tessellator stream
//
#define D3DVSD_STREAMTESSSHIFT 28
#define D3DVSD_STREAMTESSMASK (1 << D3DVSD_STREAMTESSSHIFT)
#define D3DVSD_STREAM_TESS( ) \
(D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAM) | (D3DVSD_STREAMTESSMASK))
// bind single vertex register to vertex element from vertex stream
//
// _VertexRegister [0..15] address of the vertex register
// _Type [D3DVSDT_*] dimensionality and arithmetic data type
#define D3DVSD_REG( _VertexRegister, _Type ) \
(D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | \
((_Type) << D3DVSD_DATATYPESHIFT) | (_VertexRegister))
// Skip _DWORDCount DWORDs in vertex
//
#define D3DVSD_SKIP( _DWORDCount ) \
(D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_STREAMDATA) | 0x10000000 | \
((_DWORDCount) << D3DVSD_SKIPCOUNTSHIFT))
// load data into vertex shader constant memory
//
// _ConstantAddress [0..95] - address of constant array to begin filling data
// _Count [0..15] - number of constant vectors to load (4 DWORDs each)
// followed by 4*_Count DWORDS of data
//
#define D3DVSD_CONST( _ConstantAddress, _Count ) \
(D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_CONSTMEM) | \
((_Count) << D3DVSD_CONSTCOUNTSHIFT) | (_ConstantAddress))
// enable tessellator generated normals
//
// _VertexRegisterIn [0..15] address of vertex register whose input stream
// will be used in normal computation
// _VertexRegisterOut [0..15] address of vertex register to output the normal to
//
#define D3DVSD_TESSNORMAL( _VertexRegisterIn, _VertexRegisterOut ) \
(D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | \
((_VertexRegisterIn) << D3DVSD_VERTEXREGINSHIFT) | \
((0x02) << D3DVSD_DATATYPESHIFT) | (_VertexRegisterOut))
// enable tessellator generated surface parameters
//
// _VertexRegister [0..15] address of vertex register to output parameters
//
#define D3DVSD_TESSUV( _VertexRegister ) \
(D3DVSD_MAKETOKENTYPE(D3DVSD_TOKEN_TESSELLATOR) | 0x10000000 | \
((0x01) << D3DVSD_DATATYPESHIFT) | (_VertexRegister))
// Generates END token
//
#define D3DVSD_END() 0xFFFFFFFF
// Generates NOP token
#define D3DVSD_NOP() 0x00000000
#endif /* DIRECT3D_VERSION >= 0x0900 */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
#pragma endregion
#endif /* _D3DNTHAL_H */
|
5d9f69adda40ed163b287b9ed4cedb35b88f2daa
|
010279e2ba272d09e9d2c4e903722e5faba2cf7a
|
/contrib/tools/python3/src/Modules/_blake2/impl/blake2s-round.h
|
3af4be35bee5d4231639e277131eb6461101cfd9
|
[
"LicenseRef-scancode-python-cwi",
"LicenseRef-scancode-other-copyleft",
"Python-2.0",
"BSD-3-Clause",
"0BSD",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
catboost/catboost
|
854c1a1f439a96f1ae6b48e16644be20aa04dba2
|
f5042e35b945aded77b23470ead62d7eacefde92
|
refs/heads/master
| 2023-09-01T12:14:14.174108
| 2023-09-01T10:01:01
| 2023-09-01T10:22:12
| 97,556,265
| 8,012
| 1,425
|
Apache-2.0
| 2023-09-11T03:32:32
| 2017-07-18T05:29:04
|
Python
|
UTF-8
|
C
| false
| false
| 2,938
|
h
|
blake2s-round.h
|
/*
BLAKE2 reference source code package - optimized C implementations
Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#pragma once
#ifndef __BLAKE2S_ROUND_H__
#define __BLAKE2S_ROUND_H__
#define LOAD(p) _mm_load_si128( (__m128i *)(p) )
#define STORE(p,r) _mm_store_si128((__m128i *)(p), r)
#define LOADU(p) _mm_loadu_si128( (__m128i *)(p) )
#define STOREU(p,r) _mm_storeu_si128((__m128i *)(p), r)
#define TOF(reg) _mm_castsi128_ps((reg))
#define TOI(reg) _mm_castps_si128((reg))
#define LIKELY(x) __builtin_expect((x),1)
/* Microarchitecture-specific macros */
#ifndef HAVE_XOP
#ifdef HAVE_SSSE3
#define _mm_roti_epi32(r, c) ( \
(8==-(c)) ? _mm_shuffle_epi8(r,r8) \
: (16==-(c)) ? _mm_shuffle_epi8(r,r16) \
: _mm_xor_si128(_mm_srli_epi32( (r), -(c) ),_mm_slli_epi32( (r), 32-(-(c)) )) )
#else
#define _mm_roti_epi32(r, c) _mm_xor_si128(_mm_srli_epi32( (r), -(c) ),_mm_slli_epi32( (r), 32-(-(c)) ))
#endif
#else
/* ... */
#endif
#define G1(row1,row2,row3,row4,buf) \
row1 = _mm_add_epi32( _mm_add_epi32( row1, buf), row2 ); \
row4 = _mm_xor_si128( row4, row1 ); \
row4 = _mm_roti_epi32(row4, -16); \
row3 = _mm_add_epi32( row3, row4 ); \
row2 = _mm_xor_si128( row2, row3 ); \
row2 = _mm_roti_epi32(row2, -12);
#define G2(row1,row2,row3,row4,buf) \
row1 = _mm_add_epi32( _mm_add_epi32( row1, buf), row2 ); \
row4 = _mm_xor_si128( row4, row1 ); \
row4 = _mm_roti_epi32(row4, -8); \
row3 = _mm_add_epi32( row3, row4 ); \
row2 = _mm_xor_si128( row2, row3 ); \
row2 = _mm_roti_epi32(row2, -7);
#define DIAGONALIZE(row1,row2,row3,row4) \
row4 = _mm_shuffle_epi32( row4, _MM_SHUFFLE(2,1,0,3) ); \
row3 = _mm_shuffle_epi32( row3, _MM_SHUFFLE(1,0,3,2) ); \
row2 = _mm_shuffle_epi32( row2, _MM_SHUFFLE(0,3,2,1) );
#define UNDIAGONALIZE(row1,row2,row3,row4) \
row4 = _mm_shuffle_epi32( row4, _MM_SHUFFLE(0,3,2,1) ); \
row3 = _mm_shuffle_epi32( row3, _MM_SHUFFLE(1,0,3,2) ); \
row2 = _mm_shuffle_epi32( row2, _MM_SHUFFLE(2,1,0,3) );
#if defined(HAVE_XOP)
#include "blake2s-load-xop.h"
#elif defined(HAVE_SSE4_1)
#include "blake2s-load-sse41.h"
#else
#include "blake2s-load-sse2.h"
#endif
#define ROUND(r) \
LOAD_MSG_ ##r ##_1(buf1); \
G1(row1,row2,row3,row4,buf1); \
LOAD_MSG_ ##r ##_2(buf2); \
G2(row1,row2,row3,row4,buf2); \
DIAGONALIZE(row1,row2,row3,row4); \
LOAD_MSG_ ##r ##_3(buf3); \
G1(row1,row2,row3,row4,buf3); \
LOAD_MSG_ ##r ##_4(buf4); \
G2(row1,row2,row3,row4,buf4); \
UNDIAGONALIZE(row1,row2,row3,row4); \
#endif
|
98b73b698dbdeff3fa8ea6eb0e502108191d1479
|
ed7189bcb31973648dca4cb9f0d67cb4653d0e70
|
/tests/posix/pthread_schedparam.c
|
dde70fb820dee0ff3f6dc269b8dcc207ec7b52d5
|
[
"MIT"
] |
permissive
|
managarm/mlibc
|
6dedaa86ed74f26a52e300d97f6e5949bac0f93c
|
74efefb5e9e546adab60a5730d95165334d7ee15
|
refs/heads/master
| 2023-09-01T05:17:26.709378
| 2023-08-29T08:33:01
| 2023-08-29T08:33:01
| 63,353,495
| 717
| 173
|
MIT
| 2023-09-10T10:55:53
| 2016-07-14T16:46:51
|
C
|
UTF-8
|
C
| false
| false
| 643
|
c
|
pthread_schedparam.c
|
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
int main() {
struct sched_param param = {
.sched_priority = 100,
};
int policy = 0xDEADBEEF;
int ret = pthread_getschedparam(pthread_self(), &policy, ¶m);
assert(policy == SCHED_OTHER);
assert(!ret);
param.sched_priority = 10;
ret = pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m);
assert(!ret || ret == EPERM);
if(ret == EPERM) {
exit(0);
}
param.sched_priority = 0xDEADBEEF;
ret = pthread_getschedparam(pthread_self(), &policy, ¶m);
assert(policy == SCHED_FIFO);
assert(param.sched_priority == 10);
assert(!ret);
}
|
8b46fc4938b5712a4e8409f86d3d458f8209a309
|
d61b532db0d3e08818338cfaac530a1ced1ffe3b
|
/util/int/do_incdec.c
|
97a5e2bff47f709cb4755542e5e04b3280e9b323
|
[
"LicenseRef-scancode-other-permissive"
] |
permissive
|
davidgiven/ack
|
61049c7a8e95ff61a77b1edd3c22bb290720e276
|
db5a32c68c4a60ca26a3927a799ea662b5b2b0e5
|
refs/heads/default
| 2023-08-29T07:33:12.771205
| 2023-07-08T20:17:27
| 2023-07-08T20:17:27
| 37,686,316
| 376
| 74
|
NOASSERTION
| 2023-07-08T20:17:28
| 2015-06-18T21:33:42
|
C
|
UTF-8
|
C
| false
| false
| 2,379
|
c
|
do_incdec.c
|
/** @file
* Sources of the "INCREMENT/DECREMENT/ZERO" group instructions
*/
/* $Id$ */
#include "em_abs.h"
#include "global.h"
#include "log.h"
#include "nofloat.h"
#include "trap.h"
#include "mem.h"
#include "data.h"
#include "text.h"
#include "stack.h"
#include "fra.h"
#include "warn.h"
#include "switch.h"
PRIVATE long inc(long), dec(long);
/** INC -: Increment word on top of stack by 1 (*) */
void DoINC(void)
{
LOG(("@Z6 DoINC()"));
spoilFRA();
wpush(inc(swpop()));
}
/** INL l: Increment local or parameter (*) */
void DoINL(register long l)
{
register ptr p;
LOG(("@Z6 DoINL(%ld)", l));
spoilFRA();
p = loc_addr(arg_l(l));
st_stw(p, inc(st_ldsw(p)));
}
/** INE g: Increment external (*) */
void DoINE(register long arg)
{
register ptr p = i2p(arg);
LOG(("@Z6 DoINE(%lu)", p));
spoilFRA();
p = arg_g(p);
dt_stw(p, inc(dt_ldsw(p)));
}
/** DEC -: Decrement word on top of stack by 1 (*) */
void DoDEC(void)
{
LOG(("@Z6 DoDEC()"));
spoilFRA();
wpush(dec(swpop()));
}
/** DEL l: Decrement local or parameter (*) */
void DoDEL(register long l)
{
register ptr p;
LOG(("@Z6 DoDEL(%ld)", l));
spoilFRA();
l = arg_l(l);
p = loc_addr(l);
st_stw(p, dec(st_ldsw(p)));
}
/** DEE g: Decrement external (*) */
void DoDEE(register long arg)
{
register ptr p = i2p(arg);
LOG(("@Z6 DoDEE(%lu)", p));
spoilFRA();
p = arg_g(p);
dt_stw(p, dec(dt_ldsw(p)));
}
/** ZRL l: Zero local or parameter */
void DoZRL(register long l)
{
LOG(("@Z6 DoZRL(%ld)", l));
spoilFRA();
l = arg_l(l);
st_stw(loc_addr(l), 0L);
}
/** ZRE g: Zero external */
void DoZRE(register long arg)
{
register ptr p = i2p(arg);
LOG(("@Z6 DoZRE(%lu)", p));
spoilFRA();
dt_stw(arg_g(p), 0L);
}
/** ZRF w: Load a floating zero of size w */
void DoZRF(register size l)
{
#ifndef NOFLOAT
LOG(("@Z6 DoZRF(%ld)", l));
spoilFRA();
fpush(0.0, arg_wf(l));
#else /* NOFLOAT */
arg = arg;
nofloat();
#endif /* NOFLOAT */
}
/** ZER w: Load w zero bytes */
void DoZER(register size l)
{
LOG(("@Z6 DoZER(%ld)", l));
spoilFRA();
npush(0L, arg_w(l));
/*
for (i = arg_w(l); i; i -= wsize)
wpush(0L);
*/
}
PRIVATE long inc(long l)
{
if (must_test && !(IgnMask&BIT(EIOVFL))) {
if (l == i_maxsw)
trap(EIOVFL);
}
return (l + 1);
}
PRIVATE long dec(long l)
{
if (must_test && !(IgnMask&BIT(EIOVFL))) {
if (l == i_minsw)
trap(EIOVFL);
}
return (l - 1);
}
|
f82f45b8917a3c69d456f6c721dbc9c929ba9890
|
3e064d155503ea3a6a4a496f46d7c389092d97c7
|
/sw/pp3.c
|
331a46a3c6a56778a9f414c6ebaa5aa25c540530
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
jaromir-sukuba/a-p-prog
|
f2ff36015a59bba43cc4859747d8cf07e8c78102
|
e0cd51af6bf72db63d944fa89551e2f89062aec0
|
refs/heads/master
| 2022-12-12T21:51:59.245620
| 2022-03-04T21:27:03
| 2022-03-04T21:27:03
| 46,782,832
| 127
| 44
|
MIT
| 2022-12-06T14:26:05
| 2015-11-24T10:00:36
|
Stata
|
UTF-8
|
C
| false
| false
| 39,774
|
c
|
pp3.c
|
#include <stdlib.h>
#include <fcntl.h>
#include <stdarg.h>
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#if defined(__linux__) || defined(__APPLE__)
#include <termios.h>
#else
#include <windows.h>
#endif
int setCPUtype(char* cpu);
int parse_hex (char * filename, unsigned char * progmem, unsigned char * config);
size_t getlinex(char **lineptr, size_t *n, FILE *stream) ;
void comErr(char *fmt, ...);
void flsprintf(FILE* f, char *fmt, ...);
char * COM = "";
char * PP_VERSION = "0.99";
#define PROGMEM_LEN 260000
#define CONFIG_LEN 32
#define CF_P16F_A 0
#define CF_P18F_A 1
#define CF_P16F_B 2
#define CF_P18F_B 3
#define CF_P18F_C 4
#define CF_P18F_D 5
#define CF_P18F_E 6
#define CF_P16F_C 7
#define CF_P16F_D 8
#define CF_P18F_F 9
#define CF_P18F_G 10
#define CF_P18F_Q 11
int verbose = 1,verify = 1,program = 1,sleep_time = 0;
int devid_expected,devid_mask,baudRate,com,flash_size,page_size,chip_family,config_size;
unsigned char file_image[70000],progmem[PROGMEM_LEN], config_bytes[CONFIG_LEN];
//*********************************************************************************//
//*********************************************************************************//
//*********************************************************************************//
// serial IO interfaces for Linux and windows
//*********************************************************************************//
//*********************************************************************************//
//*********************************************************************************//
#if defined(__linux__) || defined(__APPLE__)
void initSerialPort()
{
baudRate=B57600;
if (verbose>2)
printf("Opening: %s at %d\n",COM,baudRate);
com = open(COM, O_RDWR | O_NOCTTY | O_NDELAY);
if (com <0) comErr("Failed to open serial port");
struct termios opts;
memset (&opts,0,sizeof (opts));
fcntl(com, F_SETFL, 0);
if (tcgetattr(com, &opts)!=0) printf("Err tcgetattr\n");
cfsetispeed(&opts, baudRate);
cfsetospeed(&opts, baudRate);
opts.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
opts.c_cflag |= (CLOCAL | CREAD);
opts.c_cflag &= ~PARENB;
opts.c_cflag &= ~CSTOPB;
opts.c_cflag &= ~CSIZE;
opts.c_cflag |= CS8;
opts.c_oflag &= ~OPOST;
opts.c_iflag &= ~INPCK;
opts.c_iflag &= ~ICRNL; //do NOT translate CR to NL
opts.c_iflag &= ~(IXON | IXOFF | IXANY);
opts.c_cc[ VMIN ] = 0;
opts.c_cc[ VTIME ] = 10;//0.1 sec
if (tcsetattr(com, TCSANOW, &opts) != 0)
{
perror(COM);
printf("set attr error");
abort();
}
tcflush(com,TCIOFLUSH); // just in case some crap is the buffers
}
void putByte(int byte)
{
char buf = byte;
if (verbose>3) flsprintf(stdout,"TX: 0x%02X\n", byte);
int n = write(com, &buf, 1);
if (n != 1) comErr("Serial port failed to send a byte, write returned %d\n", n);
}
void putBytes (unsigned char * data, int len)
{
int i;
for (i=0; i<len; i++)
putByte(data[i]);
/*
if (verbose>3)
flsprintf(stdout,"TXP: %d B\n", len);
int n = write(com, data, len);
if (n != len)
comErr("Serial port failed to send %d bytes, write returned %d\n", len,n);
*/
}
int getByte()
{
char buf;
int n = read(com, &buf, 1);
if (verbose>3) flsprintf(stdout,n<1?"RX: fail\n":"RX: 0x%02X\n", buf & 0xFF);
if (n == 1) return buf & 0xFF;
comErr("Serial port failed to receive a byte, read returned %d\n", n);
return -1; // never reached
}
#else
HANDLE port_handle;
void initSerialPort()
{
char mode[40],portname[20];
COMMTIMEOUTS timeout_sets;
DCB port_sets;
strcpy(portname,"\\\\.\\");
strcat(portname,COM);
port_handle = CreateFileA(portname,
GENERIC_READ|GENERIC_WRITE,
0, /* no share */
NULL, /* no security */
OPEN_EXISTING,
0, /* no threads */
NULL); /* no templates */
if(port_handle==INVALID_HANDLE_VALUE)
{
printf("unable to open port %s -> %s\n",COM, portname);
exit(0);
}
strcpy (mode,"baud=57600 data=8 parity=n stop=1");
memset(&port_sets, 0, sizeof(port_sets)); /* clear the new struct */
port_sets.DCBlength = sizeof(port_sets);
if(!BuildCommDCBA(mode, &port_sets))
{
printf("dcb settings failed\n");
CloseHandle(port_handle);
exit(0);
}
if(!SetCommState(port_handle, &port_sets))
{
printf("cfg settings failed\n");
CloseHandle(port_handle);
exit(0);
}
timeout_sets.ReadIntervalTimeout = 1;
timeout_sets.ReadTotalTimeoutMultiplier = 1000;
timeout_sets.ReadTotalTimeoutConstant = 1;
timeout_sets.WriteTotalTimeoutMultiplier = 1000;
timeout_sets.WriteTotalTimeoutConstant = 1;
if(!SetCommTimeouts(port_handle, &timeout_sets))
{
printf("timeout settings failed\n");
CloseHandle(port_handle);
exit(0);
}
}
void putByte(int byte)
{
int n;
if (verbose>3) flsprintf(stdout,"TX: 0x%02X\n", byte);
WriteFile(port_handle, &byte, 1, (LPDWORD)((void *)&n), NULL);
if (n != 1) comErr("Serial port failed to send a byte, write returned %d\n", n);
}
void putBytes (unsigned char * data, int len)
{
/*
int i;
for (i=0;i<len;i++)
putByte(data[i]);
*/
int n;
WriteFile(port_handle, data, len, (LPDWORD)((void *)&n), NULL);
if (n != len) comErr("Serial port failed to send a byte, write returned %d\n", n);
}
int getByte()
{
unsigned char buf[2];
int n;
ReadFile(port_handle, buf, 1, (LPDWORD)((void *)&n), NULL);
if (verbose>3) flsprintf(stdout,n<1?"RX: fail\n":"RX: 0x%02X\n", buf[0] & 0xFF);
if (n == 1) return buf[0] & 0xFF;
comErr("Serial port failed to receive a byte, read returned %d\n", n);
return -1; // never reached
}
#endif
//*********************************************************************************//
//*********************************************************************************//
//*********************************************************************************//
// generic routines
//*********************************************************************************//
//*********************************************************************************//
//*********************************************************************************//
void comErr(char *fmt, ...)
{
char buf[ 500 ];
va_list va;
va_start(va, fmt);
vsnprintf(buf, sizeof(buf), fmt, va);
fprintf(stderr,"%s", buf);
perror(COM);
va_end(va);
abort();
}
void flsprintf(FILE* f, char *fmt, ...)
{
char buf[ 500 ];
va_list va;
va_start(va, fmt);
vsnprintf(buf, sizeof(buf), fmt, va);
fprintf(f,"%s", buf);
fflush(f);
va_end(va);
}
int is_empty (unsigned char * buff, int len)
{
int i,empty;
empty = 1;
for (i=0; i<len; i++)
if (buff[i]!=0xFF) empty = 0;
return empty;
}
//get line replacement
size_t getlinex(char **lineptr, size_t *n, FILE *stream)
{
char *bufptr = NULL;
char *p = bufptr;
size_t size;
int c;
if (lineptr == NULL)return -1;
if (stream == NULL) return -1;
if (n == NULL) return -1;
bufptr = *lineptr;
size = *n;
c = fgetc(stream);
if (c == EOF) return -1;
if (bufptr == NULL)
{
bufptr = malloc(128);
if (bufptr == NULL)
{
return -1;
}
size = 128;
}
p = bufptr;
while(c != EOF)
{
if ((p - bufptr) > (size - 1))
{
size = size + 128;
bufptr = realloc(bufptr, size);
if (bufptr == NULL)
{
return -1;
}
}
*p++ = c;
if (c == '\n')
{
break;
}
c = fgetc(stream);
}
*p++ = '\0';
*lineptr = bufptr;
*n = size;
return p - bufptr - 1;
}
void sleep_ms (int num)
{
struct timespec tspec;
tspec.tv_sec=num/1000;
tspec.tv_nsec=(num%1000)*1000000;
nanosleep(&tspec,0);
}
void printHelp()
{
flsprintf(stdout,"pp programmer\n");
exit(0);
}
void parseArgs(int argc, char *argv[])
{
int c;
while ((c = getopt (argc, argv, "c:nps:t:v:")) != -1)
{
switch (c)
{
case 'c' :
COM=optarg;
break;
case 'n':
verify = 0;
break;
case 'p':
program = 0;
break;
case 's' :
sscanf(optarg,"%d",&sleep_time);
break;
case 't' :
setCPUtype(optarg);
break;
case 'v' :
sscanf(optarg,"%d",&verbose);
break;
case '?' :
if (isprint (optopt))
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
else
fprintf (stderr,"Unknown option character `\\x%x'.\n",optopt);
default:
fprintf (stderr,"Bug, unhandled option '%c'\n",c);
abort ();
}
}
if (argc<=1)
printHelp();
}
//*********************************************************************************//
//*********************************************************************************//
//*********************************************************************************//
// programming routines
//*********************************************************************************//
//*********************************************************************************//
//*********************************************************************************//
int setCPUtype(char* cpu)
{
int name_len,i,read;
name_len = strlen (cpu);
for(i = 0; i<name_len; i++) cpu[i] = tolower(cpu[i]);
char * line = NULL;
char * filename = "pp3_devices.dat";
char read_cpu_type[20], read_algo_type[20];
int read_flash_size, read_page_size, read_id, read_mask;
size_t len = 0;
if (verbose>2) printf ("Opening filename %s \n", filename);
FILE* sf = fopen(filename, "r");
if (sf==0)
{
return -1;
if (verbose>0) printf ("Can't open database file %s\n",filename);
}
if (verbose>2) printf ("File open\n");
while ((read = getlinex(&line, &len, sf)) != -1)
{
if (verbose>3) printf("\nRead %d chars: %s",read,line);
if (line[0]!='#')
{
sscanf (line,"%s %d %d %x %x %s",(char*)&read_cpu_type,&read_flash_size,&read_page_size,&read_id,&read_mask,(char*)&read_algo_type);
if (verbose>3) printf("\n*** %s,%d,%d,%x,%x,%s",read_cpu_type,read_flash_size,read_page_size,read_id,read_mask,read_algo_type);
if (strcmp(read_cpu_type,cpu)==0)
{
flash_size = read_flash_size;
page_size = read_page_size;
devid_expected = read_id;
devid_mask = read_mask;
if (verbose>1) printf("Found database match %s,%d,%d,%x,%x,%s\n",read_cpu_type,read_flash_size,read_page_size,read_id,read_mask,read_algo_type);
if (strcmp("CF_P16F_A",read_algo_type)==0) chip_family = CF_P16F_A;
if (strcmp("CF_P16F_B",read_algo_type)==0) chip_family = CF_P16F_B;
if (strcmp("CF_P16F_C",read_algo_type)==0) chip_family = CF_P16F_C;
if (strcmp("CF_P16F_D",read_algo_type)==0) chip_family = CF_P16F_D;
if (strcmp("CF_P18F_A",read_algo_type)==0) chip_family = CF_P18F_A;
if (strcmp("CF_P18F_B",read_algo_type)==0) chip_family = CF_P18F_B;
if (strcmp("CF_P18F_C",read_algo_type)==0) chip_family = CF_P18F_C;
if (strcmp("CF_P18F_D",read_algo_type)==0) chip_family = CF_P18F_D;
if (strcmp("CF_P18F_E",read_algo_type)==0) chip_family = CF_P18F_E;
if (strcmp("CF_P18F_F",read_algo_type)==0) chip_family = CF_P18F_F;
if (strcmp("CF_P18F_G",read_algo_type)==0) chip_family = CF_P18F_G;
if (strcmp("CF_P18F_Q",read_algo_type)==0) chip_family = CF_P18F_Q;
if (chip_family == CF_P18F_A) config_size = 16;
if (chip_family == CF_P18F_B) config_size = 8;
if (chip_family == CF_P18F_C)
{
config_size = 16;
chip_family = CF_P18F_B;
}
if (chip_family == CF_P18F_D) config_size = 16;
if (chip_family == CF_P18F_E) config_size = 16;
if (chip_family == CF_P18F_F) config_size = 12;
if (chip_family == CF_P18F_Q) config_size = 12;
if (chip_family == CF_P18F_G)
{
config_size = 10;
chip_family = CF_P18F_F;
}
if (verbose>2) printf("chip family:%d, config size:%d\n",chip_family,config_size);
}
}
}
fclose(sf);
return 0;
}
int p16a_rst_pointer (void)
{
if (verbose>2) flsprintf(stdout,"Resetting PC\n");
if (chip_family==CF_P16F_D)
putByte(0x09); //operation number
else
putByte(0x03); //operation number
putByte(0x00); //number of bytes remaining
getByte(); //return result - no check for its value
return 0;
}
int p16a_mass_erase (void)
{
if (verbose>2) flsprintf(stdout,"Mass erase\n");
putByte(0x07);
putByte(0x00);
getByte();
return 0;
}
int p16a_load_config (void)
{
if (verbose>2) flsprintf(stdout,"Load config\n");
putByte(0x04);
putByte(0x00);
getByte();
return 0;
}
int p16a_inc_pointer (unsigned char num)
{
if (verbose>2) flsprintf(stdout,"Inc pointer %d\n",num);
putByte(0x05);
putByte(0x01);
putByte(num);
getByte();
return 0;
}
int p16a_program_page (unsigned int ptr, unsigned char num, unsigned char slow)
{
// unsigned char i;
if (verbose>2) flsprintf(stdout,"Programming page of %d bytes at 0x%4.4x\n", num,ptr);
putByte(0x08);
putByte(num+2);
putByte(num);
putByte(slow);
/*
for (i=0;i<num;i++)
putByte(file_image[ptr+i]);
*/
putBytes(&file_image[ptr],num);
getByte();
return 0;
}
int p16a_read_page (unsigned char * data, unsigned char num)
{
unsigned char i;
if (verbose>2) flsprintf(stdout,"Reading page of %d bytes\n", num);
putByte(0x06);
putByte(0x01);
putByte(num/2);
getByte();
for (i=0; i<num; i++) *data++ = getByte();
return 0;
}
int p16a_get_devid (void)
{
unsigned char tdat[20],devid_lo,devid_hi;
unsigned int retval;
p16a_rst_pointer();
p16a_load_config();
p16a_inc_pointer(6);
p16a_read_page(tdat, 4);
devid_hi = tdat[(2*0)+1];
devid_lo = tdat[(2*0)+0];
if (verbose>2) flsprintf(stdout,"Getting devid - lo:%2.2x,hi:%2.2x\n",devid_lo,devid_hi);
retval = (((unsigned int)(devid_lo))<<0) + (((unsigned int)(devid_hi))<<8);
retval = retval & devid_mask;
return retval;
}
int p16a_get_config (unsigned char n)
{
unsigned char tdat[20],devid_lo,devid_hi;
unsigned int retval;
p16a_rst_pointer();
p16a_load_config();
p16a_inc_pointer(n);
p16a_read_page(tdat, 4);
devid_hi = tdat[(2*0)+1];
devid_lo = tdat[(2*0)+0];
retval = (((unsigned int)(devid_lo))<<0) + (((unsigned int)(devid_hi))<<8);
if (verbose>2) flsprintf(stdout,"Getting config +%d - lo:%2.2x,hi:%2.2x = %4.4x\n",n,devid_lo,devid_hi,retval);
return retval;
}
int p16a_program_config(void)
{
p16a_rst_pointer();
p16a_load_config();
p16a_inc_pointer(7);
p16a_program_page(2*0x8007,2,1);
p16a_program_page(2*0x8008,2,1);
if ((chip_family==CF_P16F_B)|(chip_family==CF_P16F_D)) p16a_program_page(2*0x8009,2,1);
if (chip_family==CF_P16F_D) p16a_program_page(2*0x800A,2,1);
return 0;
}
int p18a_read_page (unsigned char * data, int address, unsigned char num)
{
unsigned char i;
if (verbose>2) flsprintf(stdout,"Reading page of %d bytes at 0x%6.6x\n", num, address);
putByte(0x11);
putByte(0x04);
putByte(num/2);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
getByte();
for (i=0; i<num; i++)
{
*data++ = getByte();
}
return 0;
}
int p18a_mass_erase (void)
{
if (verbose>2) flsprintf(stdout,"Mass erase\n");
putByte(0x13);
putByte(0x00);
getByte();
return 0;
}
int p18b_mass_erase (void)
{
if (verbose>2) flsprintf(stdout,"Mass erase\n");
putByte(0x23);
putByte(0x00);
getByte();
return 0;
}
int p18d_mass_erase_part (unsigned long data)
{
if (verbose>2) flsprintf(stdout,"Mass erase part of 0x%6.6x\n",data);
putByte(0x30);
putByte(0x03);
putByte((data>>16)&0xFF);
putByte((data>>8)&0xFF);
putByte((data>>0)&0xFF);
getByte();
return 0;
}
int p18d_mass_erase (void)
{
if (verbose>2) flsprintf(stdout,"Mass erase\n");
p18d_mass_erase_part(0x800104);
p18d_mass_erase_part(0x800204);
p18d_mass_erase_part(0x800404);
p18d_mass_erase_part(0x800804);
/*
p18d_mass_erase_part(0x801004);
p18d_mass_erase_part(0x802004);
p18d_mass_erase_part(0x804004);
p18d_mass_erase_part(0x808004);
*/
p18d_mass_erase_part(0x800004);
p18d_mass_erase_part(0x800005);
p18d_mass_erase_part(0x800002);
return 0;
}
int p18e_mass_erase (void)
{
if (verbose>2) flsprintf(stdout,"Mass erase\n");
p18d_mass_erase_part(0x800104);
p18d_mass_erase_part(0x800204);
p18d_mass_erase_part(0x800404);
p18d_mass_erase_part(0x800804);
p18d_mass_erase_part(0x801004);
p18d_mass_erase_part(0x802004);
p18d_mass_erase_part(0x804004);
p18d_mass_erase_part(0x808004);
p18d_mass_erase_part(0x800004);
p18d_mass_erase_part(0x800005);
p18d_mass_erase_part(0x800002);
return 0;
}
int p18a_write_page (unsigned char * data, int address, unsigned char num)
{
unsigned char i,empty;
empty = 0;
for (i=0; i<num; i++)
{
if (data[i]!=0xFF) empty = 0;
}
if (empty==1)
{
if (verbose>3)
flsprintf(stdout,"~");
return 0;
}
if (verbose>2) flsprintf(stdout,"Writing A page of %d bytes at 0x%6.6x\n", num, address);
putByte(0x12);
putByte(4+num);
putByte(num);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
for (i=0; i<num; i++)
putByte(data[i]);
getByte();
return 0;
}
int p18d_write_page (unsigned char * data, int address, unsigned char num)
{
unsigned char i,empty;
empty = 0;
for (i=0; i<num; i++)
{
if (data[i]!=0xFF) empty = 0;
}
if (empty==1)
{
if (verbose>3)
flsprintf(stdout,"~");
return 0;
}
if (verbose>2) flsprintf(stdout,"Writing D page of %d bytes at 0x%6.6x\n", num, address);
putByte(0x31);
putByte(4+num);
putByte(num);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
for (i=0; i<num; i++)
putByte(data[i]);
getByte();
return 0;
}
int p18a_write_cfg (unsigned char data1, unsigned char data2, int address)
{
if (verbose>2) flsprintf(stdout,"Writing cfg 0x%2.2x 0x%2.2x at 0x%6.6x\n", data1, data2, address);
putByte(0x14);
putByte(6);
putByte(0);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
putByte(data1);
putByte(data2);
getByte();
return 0;
}
int p18d_write_cfg (unsigned char data1, unsigned char data2, int address)
{
if (verbose>2) flsprintf(stdout,"Writing cfg 0x%2.2x 0x%2.2x at 0x%6.6x\n", data1, data2, address);
putByte(0x32);
putByte(6);
putByte(0);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
putByte(data1);
putByte(data2);
getByte();
return 0;
}
int p16c_mass_erase (void)
{
if (verbose>2) flsprintf(stdout,"Mass erase\n");
putByte(0x43);
putByte(0x00);
getByte();
return 0;
}
int p16c_read_page (unsigned char * data, int address, unsigned char num)
{
unsigned char i;
address = address / 2;
if (verbose>2) flsprintf(stdout,"Reading page of %d bytes at 0x%6.6x\n", num, address);
putByte(0x41);
putByte(0x04);
putByte(num/2);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
getByte();
for (i=0; i<num; i++)
{
*data++ = getByte();
}
// for (i=0; i<num; i++) if (verbose>2) flsprintf(stdout,"%2.2x ", data[i]);
return 0;
}
int p16c_write_page (unsigned char * data, int address, unsigned char num)
{
unsigned char i, empty;
address = address / 2;
empty = 1;
for (i=0; i<num; i=i+2)
{
if ((data[i]!=0xFF)|(data[i+1]!=0xFF))
empty = 0;
}
if (verbose>2) flsprintf(stdout,"Writing A page of %d bytes at 0x%6.6x\n", num, address);
if (empty==1)
{
if (verbose>3)
flsprintf(stdout,"~");
return 0;
}
putByte(0x42);
putByte(4+num);
putByte(num);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
for (i=0; i<num; i++)
putByte(data[i]);
getByte();
return 0;
}
int p16c_get_devid (void)
{
unsigned char tdat[20],devid_lo,devid_hi;
unsigned int retval;
p16c_read_page(tdat, 0x8006*2,4);
devid_hi = tdat[(2*0)+1];
devid_lo = tdat[(2*0)+0];
if (verbose>2) flsprintf(stdout,"Getting devid - lo:%2.2x,hi:%2.2x\n",devid_lo,devid_hi);
retval = (((unsigned int)(devid_lo))<<0) + (((unsigned int)(devid_hi))<<8);
retval = retval & devid_mask;
return retval;
}
int p16c_write_single_cfg (unsigned char data1, unsigned char data2, int address)
{
if (verbose>2) flsprintf(stdout,"Writing cfg 0x%2.2x 0x%2.2x at 0x%6.6x\n", data1, data2, address);
putByte(0x44);
putByte(6);
putByte(0);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
putByte(data1);
putByte(data2);
getByte();
return 0;
}
int p18q_write_single_cfg (unsigned char data1, unsigned char data2, int address)
{
if (verbose>2) flsprintf(stdout,"Writing cfg 0x%2.2x 0x%2.2x at 0x%6.6x\n", data1, data2, address);
putByte(0x45);
putByte(6);
putByte(0);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
putByte(data1);
putByte(data2);
getByte();
return 0;
}
int p18q_write_page (unsigned char * data, int address, unsigned char num)
{
unsigned char i, empty;
address = address / 2;
empty = 1;
for (i=0; i<num; i=i+2)
{
if ((data[i]!=0xFF)|(data[i+1]!=0xFF))
empty = 0;
}
if (verbose>2) flsprintf(stdout,"Writing A page of %d bytes at 0x%6.6x\n", num, address);
if (empty==1)
{
if (verbose>3)
flsprintf(stdout,"~");
return 0;
}
putByte(0x46);
putByte(4+num);
putByte(num);
putByte((address>>16)&0xFF);
putByte((address>>8)&0xFF);
putByte((address>>0)&0xFF);
for (i=0; i<num; i++)
putByte(data[i]);
getByte();
return 0;
}
int p16c_write_cfg (void)
{
p16c_write_single_cfg(config_bytes[1],config_bytes[0],0x8007);
p16c_write_single_cfg(config_bytes[3],config_bytes[2],0x8008);
p16c_write_single_cfg(config_bytes[5],config_bytes[4],0x8009);
p16c_write_single_cfg(config_bytes[7],config_bytes[6],0x800A);
p16c_write_single_cfg(config_bytes[9],config_bytes[8],0x800B);
return 0;
}
int prog_enter_progmode (void)
{
if (verbose>2) flsprintf(stdout,"Entering programming mode\n");
if (chip_family==CF_P16F_A) putByte(0x01);
else if (chip_family==CF_P16F_B) putByte(0x01);
else if (chip_family==CF_P16F_D) putByte(0x01);
else if (chip_family==CF_P18F_A) putByte(0x10);
else if (chip_family==CF_P18F_B) putByte(0x10);
else if (chip_family==CF_P18F_D) putByte(0x10);
else if (chip_family==CF_P18F_E) putByte(0x10);
else if (chip_family==CF_P16F_C) putByte(0x40);
else if (chip_family==CF_P18F_F) putByte(0x40);
else if (chip_family==CF_P18F_Q) putByte(0x40);
putByte(0x00);
getByte();
return 0;
}
int prog_exit_progmode (void)
{
if (verbose>2) flsprintf(stdout,"Exiting programming mode\n");
putByte(0x02);
putByte(0x00);
getByte();
return 0;
}
int prog_get_device_id (void)
{
unsigned char mem_str[10];
unsigned int devid;
if (verbose>2) flsprintf(stdout,"getting ID for family %d\n",chip_family);
if ((chip_family==CF_P16F_A)|(chip_family==CF_P16F_B)|(chip_family==CF_P16F_D))
return p16a_get_devid();
if ((chip_family==CF_P16F_C))
return p16c_get_devid();
else if ((chip_family==CF_P18F_A)|(chip_family==CF_P18F_B)|(chip_family==CF_P18F_D)|(chip_family==CF_P18F_E))
{
p18a_read_page((unsigned char *)&mem_str, 0x3FFFFE, 2);
devid = (((unsigned int)(mem_str[1]))<<8) + (((unsigned int)(mem_str[0]))<<0);
devid = devid & devid_mask;
return devid;
}
if ((chip_family==CF_P18F_F)|(chip_family==CF_P18F_Q))
{
p16c_read_page(mem_str, 0x3FFFFE*2,2);
devid = (((unsigned int)(mem_str[1]))<<8) + (((unsigned int)(mem_str[0]))<<0);
devid = devid & devid_mask;
return devid;
}
return 0;
}
//*********************************************************************************//
//*********************************************************************************//
//*********************************************************************************//
// hex parse and main function
//*********************************************************************************//
//*********************************************************************************//
//*********************************************************************************//
int parse_hex (char * filename, unsigned char * progmem, unsigned char * config)
{
char * line = NULL;
unsigned char line_content[128];
size_t len = 0;
int i,temp, read,line_len, line_type, line_address, line_address_offset,effective_address;
int p16_cfg = 0;
if (verbose>2) printf ("Opening filename %s \n", filename);
FILE* sf = fopen(filename, "r");
if (sf==0)
return -1;
line_address_offset = 0;
if (chip_family==CF_P16F_A) p16_cfg = 1;
if (chip_family==CF_P16F_B) p16_cfg = 1;
if (chip_family==CF_P16F_C) p16_cfg = 1;
if (chip_family==CF_P16F_D) p16_cfg = 1;
if (verbose>2) printf ("File open\n");
while ((read = getlinex(&line, &len, sf)) != -1)
{
if (verbose>2) printf("\nRead %d chars: %s",read,line);
if (line[0]!=':')
{
if (verbose>1) printf("--- : invalid\n");
return -1;
}
sscanf(line+1,"%2X",&line_len);
sscanf(line+3,"%4X",&line_address);
sscanf(line+7,"%2X",&line_type);
effective_address = line_address+(65536*line_address_offset);
if (verbose>2) printf("Line len %d B, type %d, address 0x%4.4x offset 0x%4.4x, EFF 0x%6.6x\n",line_len,line_type,line_address,line_address_offset,effective_address);
if (line_type==0)
{
for (i=0; i<line_len; i++)
{
sscanf(line+9+i*2,"%2X",&temp);
line_content[i] = temp;
}
if (effective_address<flash_size)
{
if (verbose>2) printf("PM ");
for (i=0; i<line_len; i++) progmem[effective_address+i] = line_content[i];
}
if ((line_address_offset==0x30)&((chip_family==CF_P18F_A)|(chip_family==CF_P18F_D)|(chip_family==CF_P18F_E)|(chip_family==CF_P18F_F)|(chip_family==CF_P18F_Q)))
{
if (verbose>2) printf("CB ");
for (i=0; i<line_len; i++) config[i] = line_content[i];
}
if ((chip_family==CF_P18F_B)&(effective_address==(flash_size-config_size)))
{
if (verbose>2) printf("CB ");
for (i=0; i<line_len; i++) config[i] = line_content[i];
}
if ((line_address_offset==0x01)&(p16_cfg==1))
{
if (verbose>2) printf("CB ");
for (i=0; i<line_len; i++) config[line_address+i-0x0E] = line_content[i];
}
}
if (line_type==4)
{
sscanf(line+9,"%4X",&line_address_offset);
}
if (verbose>2) for (i=0; i<line_len; i++) printf("%2.2X",line_content[i]);
if (verbose>2) printf("\n");
}
fclose(sf);
return 0;
}
int main(int argc, char *argv[])
{
int i,j,pages_performed,config,econfig;
unsigned char * pm_point, * cm_point;
unsigned char tdat[200];
parseArgs(argc,argv);
if (verbose>0) printf ("PP programmer, version %s\n",PP_VERSION);
if (verbose>1) printf ("Opening serial port\n");
initSerialPort();
if (sleep_time>0)
{
if (verbose>0) printf ("Sleeping for %d ms while arduino bootloader expires\n", sleep_time);
fflush(stdout);
sleep_ms (sleep_time);
}
for (i=0; i<PROGMEM_LEN; i++) progmem[i] = 0xFF; //assume erased memories (0xFF)
for (i=0; i<CONFIG_LEN; i++) config_bytes[i] = 0xFF;
char* filename=argv[argc-1];
pm_point = (unsigned char *)(&progmem);
cm_point = (unsigned char *)(&config_bytes);
parse_hex(filename,pm_point,cm_point); //parse and write content of hex file into buffers
//now this is ugly kludge
//my original programmer expected only file_image holding the image of memory to be programmed
//for PIC18, it is divided into two regions, program memory and config. to glue those two
//different approaches, I made this. not particulary proud of having this mess
for (i=0; i<70000; i++) file_image [i] = progmem[i];
for (i=0; i<10; i++) file_image [2*0x8007 + i] = config_bytes[i];
// for (i=0; i<10; i++) printf ("%2.2x",config_bytes[i]);
for (i=0; i<70000; i++)
{
if ((i%2)!=0)
file_image[i] = 0x3F&file_image[i];
}
prog_enter_progmode(); //enter programming mode and probe the target
i = prog_get_device_id();
if (i==devid_expected)
{
if (verbose>0) printf ("Device ID: %4.4x \n", i);
}
else
{
printf ("Wrong device ID: %4.4x, expected: %4.4x\n", i,devid_expected);
printf ("Check for connection to target MCU, exiting now\n");
prog_exit_progmode();
return 1;
}
//ah, I need to unify programming interfaces for PIC16 and PIC18
if ((chip_family==CF_P18F_A)|(chip_family==CF_P18F_B)|(chip_family==CF_P18F_D)|(chip_family==CF_P18F_E)|(chip_family==CF_P18F_F)|(chip_family==CF_P18F_Q))
{
if (program==1)
{
pages_performed = 0;
if (chip_family==CF_P18F_A) //erase whole device
p18a_mass_erase();
if (chip_family==CF_P18F_B)
p18b_mass_erase();
if (chip_family==CF_P18F_D)
p18d_mass_erase();
if (chip_family==CF_P18F_E)
p18e_mass_erase();
if ((chip_family==CF_P18F_F)|(chip_family==CF_P18F_Q))
p16c_mass_erase();
if (verbose>0) printf ("Programming FLASH (%d B in %d pages per %d bytes): \n",flash_size,flash_size/page_size,page_size);
fflush(stdout);
for (i=0; i<flash_size; i=i+page_size)
{
if (is_empty(progmem+i,page_size)==0)
{
if ((chip_family==CF_P18F_D)|(chip_family==CF_P18F_E))
p18d_write_page(progmem+i,i,page_size);
else if (chip_family==CF_P18F_F)
p16c_write_page(progmem+i,i*2,page_size);
else if (chip_family==CF_P18F_Q)
p18q_write_page(progmem+i,i*2,page_size);
else
p18a_write_page(progmem+i,i,page_size);
pages_performed++;
if (verbose>1)
{
printf ("#");
fflush(stdout);
}
}
else if (verbose>2)
{
printf (".");
fflush(stdout);
}
}
if (verbose>0) printf ("\n%d pages programmed\n",pages_performed);
if (verbose>0) printf ("Programming config\n");
for (i=0; i<config_size; i=i+2) //write config bytes for PIC18Fxxxx and 18FxxKxx devices
{
if (chip_family==CF_P18F_A) p18a_write_cfg(config_bytes[i],config_bytes[i+1],0x300000+i);
if (chip_family==CF_P18F_D) p18d_write_cfg(config_bytes[i],config_bytes[i+1],0x300000+i);
if (chip_family==CF_P18F_E) p18d_write_cfg(config_bytes[i],config_bytes[i+1],0x300000+i);
if (chip_family==CF_P18F_F) p16c_write_single_cfg (config_bytes[i+1],config_bytes[i],0x300000+i);
if (chip_family==CF_P18F_Q) p18q_write_single_cfg (config_bytes[i+1],config_bytes[i],0x300000+i);
}
//for PIC18FxxJxx, config bytes are at the end of FLASH memory
}
if (verify==1)
{
pages_performed = 0;
if (verbose>0) printf ("Verifying FLASH (%d B in %d pages per %d bytes): \n",flash_size,flash_size/page_size,page_size);
for (i=0; i<flash_size; i=i+page_size)
{
if (is_empty(progmem+i,page_size))
{
if (verbose>2)
{
printf ("#");
fflush(stdout);
}
}
else
{
if ((chip_family==CF_P18F_F)|(chip_family==CF_P18F_Q))
p16c_read_page(tdat,i*2,page_size);
else
p18a_read_page(tdat,i,page_size);
pages_performed++;
if (verbose>3) printf ("Verifying page at 0x%4.4X\n",i);
if (verbose>1)
{
printf ("#");
fflush(stdout);
}
for (j=0; j<page_size; j++)
{
if (progmem[i+j] != tdat[j])
{
printf ("Error at 0x%4.4X E:0x%2.2X R:0x%2.2X\n",i+j,progmem[i+j],tdat[j]);
printf ("Exiting now\n");
prog_exit_progmode();
exit(0);
}
}
}
}
if (verbose>0) printf ("\n%d pages verified\n",pages_performed);
if ((chip_family==CF_P18F_F)|(chip_family==CF_P18F_Q))
p16c_read_page(tdat,0x300000*2,page_size);
else
p18a_read_page(tdat,0x300000,page_size);
if (verbose>0) printf ("Verifying config...");
for (i=0; i<config_size; i++)
{
if (config_bytes[i] != tdat[i])
{
printf ("Error at 0x%2.2X E:0x%2.2X R:0x%2.2X\n",i,config_bytes[i],tdat[i]);
printf ("Exiting now\n");
prog_exit_progmode();
exit(0);
}
}
if (verbose>0) printf ("OK\n");
}
}
else
{
if (program==1)
{
if ((chip_family==CF_P16F_A)|(chip_family==CF_P16F_B)|(chip_family==CF_P16F_D)) p16a_mass_erase();
if ((chip_family==CF_P16F_C)) p16c_mass_erase();
if ((chip_family==CF_P16F_A)|(chip_family==CF_P16F_B)|(chip_family==CF_P16F_D)) p16a_rst_pointer(); //pointer reset is needed before every "big" operation
if (verbose>0) printf ("Programming FLASH (%d B in %d pages)",flash_size,flash_size/page_size);
fflush(stdout);
for (i=0; i<flash_size; i=i+page_size)
{
if (verbose>1)
{
printf (".");
fflush(stdout);
}
if ((chip_family==CF_P16F_A)|(chip_family==CF_P16F_B)|(chip_family==CF_P16F_D)) p16a_program_page(i,page_size,0);
if ((chip_family==CF_P16F_C)) p16c_write_page(progmem+i,i,page_size);
}
if (verbose>0) printf ("\n");
if (verbose>0) printf ("Programming config\n");
if ((chip_family==CF_P16F_A)|(chip_family==CF_P16F_B)|(chip_family==CF_P16F_D)) p16a_program_config();
if (chip_family==CF_P16F_C) p16c_write_cfg();
}
if (verify==1)
{
if (verbose>0) printf ("Verifying FLASH (%d B in %d pages)",flash_size,flash_size/page_size);
fflush(stdout);
if ((chip_family==CF_P16F_A)|(chip_family==CF_P16F_B)|(chip_family==CF_P16F_D)) p16a_rst_pointer();
for (i=0; i<flash_size; i=i+page_size)
{
if (verbose>1)
{
printf (".");
fflush(stdout);
}
if ((chip_family==CF_P16F_A)|(chip_family==CF_P16F_B)|(chip_family==CF_P16F_D)) p16a_read_page(tdat,page_size);
if ((chip_family==CF_P16F_C)) p16c_read_page(tdat,i,page_size);
for (j=0; j<page_size; j++)
{
if (file_image[i+j] != tdat[j])
{
printf ("Error at 0x%4.4X E:0x%2.2X R:0x%2.2X\n",i+j,file_image[i+j],tdat[j]);
prog_exit_progmode();
exit(0);
}
}
}
if (verbose>0) printf ("\n");
if (verbose>0) printf ("Verifying config\n");
if ((chip_family==CF_P16F_A)|(chip_family==CF_P16F_B)|(chip_family==CF_P16F_D))
{
config = p16a_get_config(7);
econfig = (((unsigned int)(file_image[2*0x8007]))<<0) + (((unsigned int)(file_image[2*0x8007+1]))<<8);
if (config==econfig)
{
if (verbose>1) printf ("config 1 OK: %4.4X\n",config);
}
else printf ("config 1 error: E:0x%4.4X R:0x%4.4X\n",config,econfig);
config = p16a_get_config(8);
econfig = (((unsigned int)(file_image[2*0x8008]))<<0) + (((unsigned int)(file_image[2*0x8008+1]))<<8);
if (config==econfig)
{
if (verbose>1) printf ("config 2 OK: %4.4X\n",config);
}
else printf ("config 2 error: E:0x%4.4X R:0x%4.4X\n",config,econfig);
}
if (chip_family==CF_P16F_C)
{
p16c_read_page(tdat,0x8007*2,page_size);
for (j=0; j<10; j++)
{
if (config_bytes[j] != tdat[j])
{
printf ("Error at 0x%4.4X E:0x%2.2X R:0x%2.2X\n",i+j,config_bytes[j],tdat[j]);
prog_exit_progmode();
exit(0);
}
}
}
}
}
prog_exit_progmode();
return 0;
}
|
02ef396ff06e3f95a79428b6c4008417ad213415
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/games/libretro-beetle_pcfx/files/patch-libretro-common_rthreads_rthreads.c
|
711eba8689ed113b957c52bee5b2d62f2fb9c47e
|
[
"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
| 234
|
c
|
patch-libretro-common_rthreads_rthreads.c
|
--- libretro-common/rthreads/rthreads.c.orig 2020-03-17 18:50:48 UTC
+++ libretro-common/rthreads/rthreads.c
@@ -66,6 +66,8 @@
#include <mach/mach.h>
#endif
+#include <sys/time.h>
+
struct thread_data
{
void (*func)(void*);
|
0591359f18763fd5cbb5cee7c392eb447fcd4e78
|
24b8175be069aceb1280b261e8362009f016a692
|
/mbf_utility/include/mbf_utility/types.h
|
1e4046fe629479366872c4cf9c3844de906f7fe5
|
[
"BSD-3-Clause"
] |
permissive
|
magazino/move_base_flex
|
607ff35b665645b626f658f4cff4b4d17d05e66e
|
6c467b26ce708ecd0f1e7b6241dccf79e9d6e54a
|
refs/heads/master
| 2023-09-01T05:31:56.380034
| 2023-08-10T07:56:19
| 2023-08-18T09:45:06
| 95,447,017
| 389
| 164
|
BSD-3-Clause
| 2023-09-13T04:48:46
| 2017-06-26T13:03:21
|
C++
|
UTF-8
|
C
| false
| false
| 2,305
|
h
|
types.h
|
/*
* Copyright 2018, Sebastian Pütz
*
* 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.
*
* abstract_planner.h
*
* author: Jannik Abbenseth <jba@ipa.fhg.de>
*
*/
#ifndef MBF_UTILITY__TYPES_H_
#define MBF_UTILITY__TYPES_H_
#include <boost/shared_ptr.hpp>
#include <ros/common.h>
#if ROS_VERSION_MINIMUM (1, 14, 0) // if current ros version is >= 1.14.0
// Melodic uses TF2
#include <tf2_ros/buffer.h>
typedef boost::shared_ptr<tf2_ros::Buffer> TFPtr;
typedef tf2_ros::Buffer TF;
typedef tf2::TransformException TFException;
#else
// Previous versions still using TF
#define USE_OLD_TF
#include <tf/transform_listener.h>
typedef boost::shared_ptr<tf::TransformListener> TFPtr;
typedef tf::TransformListener TF;
typedef tf::TransformException TFException;
#endif
#endif
|
45a92d01ba9c0a558e98947e671c0d368ecc8d7e
|
78dc9f153549b281be709227bc9897931b06260d
|
/generation/WinSDK/RecompiledIdlHeaders/shared/vmgenerationcounter.h
|
f48944f62ab27f201c379d9af0e933489550729a
|
[
"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
| 986
|
h
|
vmgenerationcounter.h
|
/*++
Copyright (c) Microsoft Corporation. All Rights Reserved.
Module Name:
vmgenerationcounter.h
Abstract:
This file implements the published interface for the virtual machine
generation counter.
--*/
#ifdef _MSC_VER
#pragma once
#endif
#pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#if (NTDDI_VERSION >= NTDDI_WINXP)
// {3ff2c92b-6598-4e60-8e1c-0ccf4927e319}
DEFINE_GUID(GUID_DEVINTERFACE_VM_GENCOUNTER,
0x3ff2c92b, 0x6598, 0x4e60, 0x8e, 0x1c, 0x0c, 0xcf, 0x49, 0x27, 0xe3, 0x19);
#define VM_GENCOUNTER_SYMBOLIC_LINK_NAME L"\\VmGenerationCounter"
#define IOCTL_VMGENCOUNTER_READ CTL_CODE(FILE_DEVICE_ACPI, 0x1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
typedef struct _VM_GENCOUNTER
{
ULONGLONG GenerationCount;
ULONGLONG GenerationCountHigh;
} VM_GENCOUNTER, *PVM_GENCOUNTER;
#endif // (NTDDI_VERSION >= NTDDI_WINXP)
#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#pragma endregion
|
0eda882cd3f484603fd7c140865cfa88e9b87816
|
3a2071c34e3c35847b2bcc2a5d3b3a74114daa0f
|
/subversion/svn/props.c
|
b4a75f54ff79f15c379663490250aea16d26dde3
|
[
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-other-permissive",
"X11",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"HPND-Markus-Kuhn",
"LicenseRef-scancode-unicode",
"Apache-2.0",
"FSFAP"
] |
permissive
|
apache/subversion
|
18a9142afe63f060ffc0814fe0c758c91ad8bd31
|
dd957c4991e61bde23cc60d13449ea8b65f80c43
|
refs/heads/trunk
| 2023-09-04T15:22:36.755177
| 2023-08-29T19:55:03
| 2023-08-29T19:55:03
| 454,263
| 520
| 207
|
Apache-2.0
| 2023-08-26T14:17:30
| 2009-12-31T09:00:10
|
C
|
UTF-8
|
C
| false
| false
| 10,258
|
c
|
props.c
|
/*
* props.c: Utility functions for property handling
*
* ====================================================================
* 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.
* ====================================================================
*/
/* ==================================================================== */
/*** Includes. ***/
#include <stdlib.h>
#include <apr_hash.h>
#include "svn_hash.h"
#include "svn_cmdline.h"
#include "svn_string.h"
#include "svn_error.h"
#include "svn_sorts.h"
#include "svn_subst.h"
#include "svn_props.h"
#include "svn_string.h"
#include "svn_opt.h"
#include "svn_xml.h"
#include "svn_base64.h"
#include "cl.h"
#include "private/svn_string_private.h"
#include "private/svn_cmdline_private.h"
#include "svn_private_config.h"
svn_error_t *
svn_cl__revprop_prepare(const svn_opt_revision_t *revision,
const apr_array_header_t *targets,
const char **URL,
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
const char *target;
if (revision->kind != svn_opt_revision_number
&& revision->kind != svn_opt_revision_date
&& revision->kind != svn_opt_revision_head)
return svn_error_create
(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("Must specify the revision as a number, a date or 'HEAD' "
"when operating on a revision property"));
/* There must be exactly one target at this point. If it was optional and
unspecified by the user, the caller has already added the implicit '.'. */
if (targets->nelts != 1)
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("Wrong number of targets specified"));
/* (The docs say the target must be either a URL or implicit '.', but
explicit WC targets are also accepted.) */
target = APR_ARRAY_IDX(targets, 0, const char *);
SVN_ERR(svn_client_url_from_path2(URL, target, ctx, pool, pool));
if (*URL == NULL)
return svn_error_create
(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
_("Either a URL or versioned item is required"));
return SVN_NO_ERROR;
}
void
svn_cl__check_boolean_prop_val(const char *propname, const char *propval,
apr_pool_t *pool)
{
svn_stringbuf_t *propbuf;
if (!svn_prop_is_boolean(propname))
return;
propbuf = svn_stringbuf_create(propval, pool);
svn_stringbuf_strip_whitespace(propbuf);
if (propbuf->data[0] == '\0'
|| svn_cstring_casecmp(propbuf->data, "0") == 0
|| svn_cstring_casecmp(propbuf->data, "no") == 0
|| svn_cstring_casecmp(propbuf->data, "off") == 0
|| svn_cstring_casecmp(propbuf->data, "false") == 0)
{
svn_error_t *err = svn_error_createf
(SVN_ERR_BAD_PROPERTY_VALUE, NULL,
_("To turn off the %s property, use 'svn propdel';\n"
"setting the property to '%s' will not turn it off."),
propname, propval);
svn_handle_warning2(stderr, err, "svn: ");
svn_error_clear(err);
}
}
static const char*
force_prop_option_message(svn_cl__prop_use_t prop_use, const char *prop_name,
apr_pool_t *scratch_pool)
{
switch (prop_use)
{
case svn_cl__prop_use_set:
return apr_psprintf(
scratch_pool,
_("Use '--force' to set the '%s' property."),
prop_name);
case svn_cl__prop_use_edit:
return apr_psprintf(
scratch_pool,
_("Use '--force' to edit the '%s' property."),
prop_name);
case svn_cl__prop_use_use:
default:
return apr_psprintf(
scratch_pool,
_("Use '--force' to use the '%s' property'."),
prop_name);
}
}
static const char*
wrong_prop_error_message(svn_cl__prop_use_t prop_use, const char *prop_name,
apr_pool_t *scratch_pool)
{
switch (prop_use)
{
case svn_cl__prop_use_set:
return apr_psprintf(
scratch_pool,
_("'%s' is not a valid %s property name; use '--force' to set it"),
prop_name, SVN_PROP_PREFIX);
case svn_cl__prop_use_edit:
return apr_psprintf(
scratch_pool,
_("'%s' is not a valid %s property name; use '--force' to edit it"),
prop_name, SVN_PROP_PREFIX);
case svn_cl__prop_use_use:
default:
return apr_psprintf(
scratch_pool,
_("'%s' is not a valid %s property name; use '--force' to use it"),
prop_name, SVN_PROP_PREFIX);
}
}
svn_error_t *
svn_cl__check_svn_prop_name(const char *propname,
svn_boolean_t revprop,
svn_cl__prop_use_t prop_use,
apr_pool_t *scratch_pool)
{
static const char *const nodeprops[] =
{
SVN_PROP_NODE_ALL_PROPS
};
static const apr_size_t nodeprops_len = sizeof(nodeprops)/sizeof(*nodeprops);
static const char *const revprops[] =
{
SVN_PROP_REVISION_ALL_PROPS
};
static const apr_size_t revprops_len = sizeof(revprops)/sizeof(*revprops);
const char *const *const proplist = (revprop ? revprops : nodeprops);
const apr_size_t numprops = (revprop ? revprops_len : nodeprops_len);
svn_cl__simcheck_t **propkeys;
svn_cl__simcheck_t *propbuf;
apr_size_t i;
svn_string_t propstring;
svn_string_t prefix;
svn_membuf_t buffer;
propstring.data = propname;
propstring.len = strlen(propname);
prefix.data = SVN_PROP_PREFIX;
prefix.len = strlen(SVN_PROP_PREFIX);
svn_membuf__create(&buffer, 0, scratch_pool);
/* First, check if the name is even close to being in the svn: namespace.
It must contain a colon in the right place, and we only allow
one-char typos or a single transposition. */
if (propstring.len < prefix.len
|| propstring.data[prefix.len - 1] != prefix.data[prefix.len - 1])
return SVN_NO_ERROR; /* Wrong prefix, ignore */
else
{
apr_size_t lcs;
const apr_size_t name_len = propstring.len;
propstring.len = prefix.len; /* Only check up to the prefix length */
svn_string__similarity(&propstring, &prefix, &buffer, &lcs);
propstring.len = name_len; /* Restore the original propname length */
if (lcs < prefix.len - 1)
return SVN_NO_ERROR; /* Wrong prefix, ignore */
/* If the prefix is slightly different, the rest must be
identical in order to trigger the error. */
if (lcs == prefix.len - 1)
{
for (i = 0; i < numprops; ++i)
{
if (0 == strcmp(proplist[i] + prefix.len, propname + prefix.len))
return svn_error_quick_wrap(svn_error_createf(
SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
_("'%s' is not a valid %s property name;"
" did you mean '%s'?"),
propname, SVN_PROP_PREFIX, proplist[i]),
force_prop_option_message(prop_use, propname, scratch_pool));
}
return SVN_NO_ERROR;
}
}
/* Now find the closest match from amongst the set of reserved
node or revision property names. Skip the prefix while matching,
we already know that it's the same and looking at it would only
skew the results. */
propkeys = apr_palloc(scratch_pool,
numprops * sizeof(svn_cl__simcheck_t*));
propbuf = apr_palloc(scratch_pool,
numprops * sizeof(svn_cl__simcheck_t));
propstring.data += prefix.len;
propstring.len -= prefix.len;
for (i = 0; i < numprops; ++i)
{
propkeys[i] = &propbuf[i];
propbuf[i].token.data = proplist[i] + prefix.len;
propbuf[i].token.len = strlen(propbuf[i].token.data);
propbuf[i].data = proplist[i];
}
switch (svn_cl__similarity_check(
propstring.data, propkeys, numprops, scratch_pool))
{
case 0:
return SVN_NO_ERROR; /* We found an exact match. */
case 1:
/* The best alternative isn't good enough */
return svn_error_create(
SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
wrong_prop_error_message(prop_use, propname, scratch_pool));
case 2:
/* There is only one good candidate */
return svn_error_quick_wrap(svn_error_createf(
SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
_("'%s' is not a valid %s property name; did you mean '%s'?"),
propname, SVN_PROP_PREFIX,
(const char *)propkeys[0]->data),
force_prop_option_message(prop_use, propname, scratch_pool));
case 3:
/* Suggest a list of the most likely candidates */
return svn_error_quick_wrap(svn_error_createf(
SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
_("'%s' is not a valid %s property name; "
"did you mean '%s' or '%s'?"),
propname, SVN_PROP_PREFIX,
(const char *)propkeys[0]->data, (const char *)propkeys[1]->data),
force_prop_option_message(prop_use, propname, scratch_pool));
default:
/* Never suggest more than three candidates */
return svn_error_quick_wrap(svn_error_createf(
SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
_("'%s' is not a valid %s property name; "
"did you mean '%s', '%s' or '%s'?"),
propname, SVN_PROP_PREFIX,
(const char *)propkeys[0]->data,
(const char *)propkeys[1]->data, (const char *)propkeys[2]->data),
force_prop_option_message(prop_use, propname, scratch_pool));
}
}
|
9372126066061df9d46166e187cdd68acbee41fa
|
b39dba38a99bc970d7c861517ab82bb92f5fc548
|
/include/portaudio/include/pa_asio.h
|
27cbd3b81c99725bb23174e0b4f3db7e62343f78
|
[
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
OpenMPT/openmpt
|
711aef385c6a098a9a2aaefa25f6563e4501d2e8
|
41c5bde364ed61afb414ac38792715ee9433c01c
|
refs/heads/master
| 2023-09-01T21:37:18.329917
| 2023-09-01T10:10:22
| 2023-09-01T10:10:22
| 82,913,630
| 501
| 87
|
BSD-3-Clause
| 2023-07-14T08:47:12
| 2017-02-23T10:04:01
|
C++
|
UTF-8
|
C
| false
| false
| 5,697
|
h
|
pa_asio.h
|
#ifndef PA_ASIO_H
#define PA_ASIO_H
/*
* $Id$
* PortAudio Portable Real-Time Audio Library
* ASIO specific extensions
*
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
*
* 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.
*/
/*
* The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* license above.
*/
/** @file
@ingroup public_header
@brief ASIO-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/** Retrieve legal native buffer sizes for the specified device, in sample frames.
@param device The global index of the device about which the query is being made.
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
@param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
@param preferredBufferSizeFrames A pointer to the location which will receive the preferred buffer size value.
@param granularity A pointer to the location which will receive the "granularity". This value determines
the step size used to compute the legal values between minBufferSizeFrames and maxBufferSizeFrames.
If granularity is -1 then available buffer size values are powers of two.
@see ASIOGetBufferSize in the ASIO SDK.
@note: this function used to be called PaAsio_GetAvailableLatencyValues. There is a
#define that maps PaAsio_GetAvailableLatencyValues to this function for backwards compatibility.
*/
PaError PaAsio_GetAvailableBufferSizes( PaDeviceIndex device,
long *minBufferSizeFrames, long *maxBufferSizeFrames, long *preferredBufferSizeFrames, long *granularity );
/** Backwards compatibility alias for PaAsio_GetAvailableBufferSizes
@see PaAsio_GetAvailableBufferSizes
*/
#define PaAsio_GetAvailableLatencyValues PaAsio_GetAvailableBufferSizes
/** Display the ASIO control panel for the specified device.
@param device The global index of the device whose control panel is to be displayed.
@param systemSpecific On Windows, the calling application's main window handle,
on Macintosh this value should be zero.
*/
PaError PaAsio_ShowControlPanel( PaDeviceIndex device, void* systemSpecific );
/** Retrieve a pointer to a string containing the name of the specified
input channel. The string is valid until Pa_Terminate is called.
The string will be no longer than 32 characters including the null terminator.
*/
PaError PaAsio_GetInputChannelName( PaDeviceIndex device, int channelIndex,
const char** channelName );
/** Retrieve a pointer to a string containing the name of the specified
input channel. The string is valid until Pa_Terminate is called.
The string will be no longer than 32 characters including the null terminator.
*/
PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex,
const char** channelName );
/** Set the sample rate of an open paASIO stream.
@param stream The stream to operate on.
@param sampleRate The new sample rate.
Note that this function may fail if the stream is already running and the
ASIO driver does not support switching the sample rate of a running stream.
Returns paIncompatibleStreamHostApi if stream is not a paASIO stream.
*/
PaError PaAsio_SetStreamSampleRate( PaStream* stream, double sampleRate );
#define paAsioUseChannelSelectors (0x01)
typedef struct PaAsioStreamInfo{
unsigned long size; /**< sizeof(PaAsioStreamInfo) */
PaHostApiTypeId hostApiType; /**< paASIO */
unsigned long version; /**< 1 */
unsigned long flags;
/* Support for opening only specific channels of an ASIO device.
If the paAsioUseChannelSelectors flag is set, channelSelectors is a
pointer to an array of integers specifying the device channels to use.
When used, the length of the channelSelectors array must match the
corresponding channelCount parameter to Pa_OpenStream() otherwise a
crash may result.
The values in the selectors array must specify channels within the
range of supported channels for the device or paInvalidChannelCount will
result.
*/
int *channelSelectors;
}PaAsioStreamInfo;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PA_ASIO_H */
|
2ee85185c4bd939ccd3332eeb622a3da0c593ece
|
f085956afa0ff005e887a079eab410242865d831
|
/thirdparty/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h
|
21560c4a5d1cfccdd391026f4e0bf51b6b3f09c1
|
[
"MIT",
"Apache-2.0",
"GPL-2.0-or-later"
] |
permissive
|
vlang/v
|
844f108863477626a61bd7580a7fb8f3365ec3e5
|
93d54651b5aae1299239d30b1276439d8c142d88
|
refs/heads/master
| 2023-09-01T05:13:11.841452
| 2023-08-31T23:04:58
| 2023-08-31T23:04:58
| 169,677,297
| 38,639
| 3,871
|
MIT
| 2023-09-14T21:45:03
| 2019-02-08T02:57:06
|
V
|
UTF-8
|
C
| false
| false
| 10,800
|
h
|
FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h
|
/* Copyright (c) INRIA and Microsoft Corporation. All rights reserved.
Licensed under the Apache 2.0 License. */
/* This file was generated by KreMLin <https://github.com/FStarLang/kremlin>
* KreMLin invocation: ../krml -fc89 -fparentheses -fno-shadow -header /mnt/e/everest/verify/hdrB9w -minimal -fparentheses -fcurly-braces -fno-shadow -header copyright-header.txt -minimal -tmpdir dist/minimal -skip-compilation -extract-uints -add-include <inttypes.h> -add-include <stdbool.h> -add-include "kremlin/internal/compat.h" -add-include "kremlin/internal/types.h" -bundle FStar.UInt64+FStar.UInt32+FStar.UInt16+FStar.UInt8=* extracted/prims.krml extracted/FStar_Pervasives_Native.krml extracted/FStar_Pervasives.krml extracted/FStar_Mul.krml extracted/FStar_Squash.krml extracted/FStar_Classical.krml extracted/FStar_StrongExcludedMiddle.krml extracted/FStar_FunctionalExtensionality.krml extracted/FStar_List_Tot_Base.krml extracted/FStar_List_Tot_Properties.krml extracted/FStar_List_Tot.krml extracted/FStar_Seq_Base.krml extracted/FStar_Seq_Properties.krml extracted/FStar_Seq.krml extracted/FStar_Math_Lib.krml extracted/FStar_Math_Lemmas.krml extracted/FStar_BitVector.krml extracted/FStar_UInt.krml extracted/FStar_UInt32.krml extracted/FStar_Int.krml extracted/FStar_Int16.krml extracted/FStar_Preorder.krml extracted/FStar_Ghost.krml extracted/FStar_ErasedLogic.krml extracted/FStar_UInt64.krml extracted/FStar_Set.krml extracted/FStar_PropositionalExtensionality.krml extracted/FStar_PredicateExtensionality.krml extracted/FStar_TSet.krml extracted/FStar_Monotonic_Heap.krml extracted/FStar_Heap.krml extracted/FStar_Map.krml extracted/FStar_Monotonic_HyperHeap.krml extracted/FStar_Monotonic_HyperStack.krml extracted/FStar_HyperStack.krml extracted/FStar_Monotonic_Witnessed.krml extracted/FStar_HyperStack_ST.krml extracted/FStar_HyperStack_All.krml extracted/FStar_Date.krml extracted/FStar_Universe.krml extracted/FStar_GSet.krml extracted/FStar_ModifiesGen.krml extracted/LowStar_Monotonic_Buffer.krml extracted/LowStar_Buffer.krml extracted/Spec_Loops.krml extracted/LowStar_BufferOps.krml extracted/C_Loops.krml extracted/FStar_UInt8.krml extracted/FStar_Kremlin_Endianness.krml extracted/FStar_UInt63.krml extracted/FStar_Exn.krml extracted/FStar_ST.krml extracted/FStar_All.krml extracted/FStar_Dyn.krml extracted/FStar_Int63.krml extracted/FStar_Int64.krml extracted/FStar_Int32.krml extracted/FStar_Int8.krml extracted/FStar_UInt16.krml extracted/FStar_Int_Cast.krml extracted/FStar_UInt128.krml extracted/C_Endianness.krml extracted/FStar_List.krml extracted/FStar_Float.krml extracted/FStar_IO.krml extracted/C.krml extracted/FStar_Char.krml extracted/FStar_String.krml extracted/LowStar_Modifies.krml extracted/C_String.krml extracted/FStar_Bytes.krml extracted/FStar_HyperStack_IO.krml extracted/C_Failure.krml extracted/TestLib.krml extracted/FStar_Int_Cast_Full.krml
* F* version: 059db0c8
* KreMLin version: 916c37ac
*/
#ifndef __FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8_H
#define __FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8_H
#include <inttypes.h>
#include <stdbool.h>
#include "kremlin/internal/compat.h"
#include "kremlin/internal/types.h"
extern Prims_int FStar_UInt64_n;
extern Prims_int FStar_UInt64_v(uint64_t x0);
extern uint64_t FStar_UInt64_uint_to_t(Prims_int x0);
extern uint64_t FStar_UInt64_add(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_add_underspec(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_add_mod(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_sub(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_sub_underspec(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_sub_mod(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_mul(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_mul_underspec(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_mul_mod(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_mul_div(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_div(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_rem(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_logand(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_logxor(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_logor(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_lognot(uint64_t x0);
extern uint64_t FStar_UInt64_shift_right(uint64_t x0, uint32_t x1);
extern uint64_t FStar_UInt64_shift_left(uint64_t x0, uint32_t x1);
extern bool FStar_UInt64_eq(uint64_t x0, uint64_t x1);
extern bool FStar_UInt64_gt(uint64_t x0, uint64_t x1);
extern bool FStar_UInt64_gte(uint64_t x0, uint64_t x1);
extern bool FStar_UInt64_lt(uint64_t x0, uint64_t x1);
extern bool FStar_UInt64_lte(uint64_t x0, uint64_t x1);
extern uint64_t FStar_UInt64_minus(uint64_t x0);
extern uint32_t FStar_UInt64_n_minus_one;
uint64_t FStar_UInt64_eq_mask(uint64_t a, uint64_t b);
uint64_t FStar_UInt64_gte_mask(uint64_t a, uint64_t b);
extern Prims_string FStar_UInt64_to_string(uint64_t x0);
extern uint64_t FStar_UInt64_of_string(Prims_string x0);
extern Prims_int FStar_UInt32_n;
extern Prims_int FStar_UInt32_v(uint32_t x0);
extern uint32_t FStar_UInt32_uint_to_t(Prims_int x0);
extern uint32_t FStar_UInt32_add(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_add_underspec(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_add_mod(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_sub(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_sub_underspec(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_sub_mod(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_mul(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_mul_underspec(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_mul_mod(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_mul_div(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_div(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_rem(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_logand(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_logxor(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_logor(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_lognot(uint32_t x0);
extern uint32_t FStar_UInt32_shift_right(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_shift_left(uint32_t x0, uint32_t x1);
extern bool FStar_UInt32_eq(uint32_t x0, uint32_t x1);
extern bool FStar_UInt32_gt(uint32_t x0, uint32_t x1);
extern bool FStar_UInt32_gte(uint32_t x0, uint32_t x1);
extern bool FStar_UInt32_lt(uint32_t x0, uint32_t x1);
extern bool FStar_UInt32_lte(uint32_t x0, uint32_t x1);
extern uint32_t FStar_UInt32_minus(uint32_t x0);
extern uint32_t FStar_UInt32_n_minus_one;
uint32_t FStar_UInt32_eq_mask(uint32_t a, uint32_t b);
uint32_t FStar_UInt32_gte_mask(uint32_t a, uint32_t b);
extern Prims_string FStar_UInt32_to_string(uint32_t x0);
extern uint32_t FStar_UInt32_of_string(Prims_string x0);
extern Prims_int FStar_UInt16_n;
extern Prims_int FStar_UInt16_v(uint16_t x0);
extern uint16_t FStar_UInt16_uint_to_t(Prims_int x0);
extern uint16_t FStar_UInt16_add(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_add_underspec(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_add_mod(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_sub(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_sub_underspec(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_sub_mod(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_mul(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_mul_underspec(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_mul_mod(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_mul_div(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_div(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_rem(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_logand(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_logxor(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_logor(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_lognot(uint16_t x0);
extern uint16_t FStar_UInt16_shift_right(uint16_t x0, uint32_t x1);
extern uint16_t FStar_UInt16_shift_left(uint16_t x0, uint32_t x1);
extern bool FStar_UInt16_eq(uint16_t x0, uint16_t x1);
extern bool FStar_UInt16_gt(uint16_t x0, uint16_t x1);
extern bool FStar_UInt16_gte(uint16_t x0, uint16_t x1);
extern bool FStar_UInt16_lt(uint16_t x0, uint16_t x1);
extern bool FStar_UInt16_lte(uint16_t x0, uint16_t x1);
extern uint16_t FStar_UInt16_minus(uint16_t x0);
extern uint32_t FStar_UInt16_n_minus_one;
uint16_t FStar_UInt16_eq_mask(uint16_t a, uint16_t b);
uint16_t FStar_UInt16_gte_mask(uint16_t a, uint16_t b);
extern Prims_string FStar_UInt16_to_string(uint16_t x0);
extern uint16_t FStar_UInt16_of_string(Prims_string x0);
extern Prims_int FStar_UInt8_n;
extern Prims_int FStar_UInt8_v(uint8_t x0);
extern uint8_t FStar_UInt8_uint_to_t(Prims_int x0);
extern uint8_t FStar_UInt8_add(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_add_underspec(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_add_mod(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_sub(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_sub_underspec(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_sub_mod(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_mul(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_mul_underspec(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_mul_mod(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_mul_div(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_div(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_rem(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_logand(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_logxor(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_logor(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_lognot(uint8_t x0);
extern uint8_t FStar_UInt8_shift_right(uint8_t x0, uint32_t x1);
extern uint8_t FStar_UInt8_shift_left(uint8_t x0, uint32_t x1);
extern bool FStar_UInt8_eq(uint8_t x0, uint8_t x1);
extern bool FStar_UInt8_gt(uint8_t x0, uint8_t x1);
extern bool FStar_UInt8_gte(uint8_t x0, uint8_t x1);
extern bool FStar_UInt8_lt(uint8_t x0, uint8_t x1);
extern bool FStar_UInt8_lte(uint8_t x0, uint8_t x1);
extern uint8_t FStar_UInt8_minus(uint8_t x0);
extern uint32_t FStar_UInt8_n_minus_one;
uint8_t FStar_UInt8_eq_mask(uint8_t a, uint8_t b);
uint8_t FStar_UInt8_gte_mask(uint8_t a, uint8_t b);
extern Prims_string FStar_UInt8_to_string(uint8_t x0);
extern uint8_t FStar_UInt8_of_string(Prims_string x0);
typedef uint8_t FStar_UInt8_byte;
#define __FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8_H_DEFINED
#endif
|
3a0253b8022db38bad7f2d3e487899bc8d410646
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/powerpc/platforms/85xx/xes_mpc85xx.c
|
dcbf7e42dce79100881ac66ea4ab93e9a8b5571c
|
[
"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
| 5,186
|
c
|
xes_mpc85xx.c
|
/*
* Copyright (C) 2009 Extreme Engineering Solutions, Inc.
*
* X-ES board-specific functionality
*
* Based on mpc85xx_ds code from Freescale Semiconductor, Inc.
*
* Author: Nate Case <ncase@xes-inc.com>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/stddef.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/kdev_t.h>
#include <linux/delay.h>
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/of_platform.h>
#include <asm/time.h>
#include <asm/machdep.h>
#include <asm/pci-bridge.h>
#include <mm/mmu_decl.h>
#include <asm/prom.h>
#include <asm/udbg.h>
#include <asm/mpic.h>
#include <sysdev/fsl_soc.h>
#include <sysdev/fsl_pci.h>
#include "smp.h"
#include "mpc85xx.h"
/* A few bit definitions needed for fixups on some boards */
#define MPC85xx_L2CTL_L2E 0x80000000 /* L2 enable */
#define MPC85xx_L2CTL_L2I 0x40000000 /* L2 flash invalidate */
#define MPC85xx_L2CTL_L2SIZ_MASK 0x30000000 /* L2 SRAM size (R/O) */
void __init xes_mpc85xx_pic_init(void)
{
struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN,
0, 256, " OpenPIC ");
BUG_ON(mpic == NULL);
mpic_init(mpic);
}
static void xes_mpc85xx_configure_l2(void __iomem *l2_base)
{
volatile uint32_t ctl, tmp;
asm volatile("msync; isync");
tmp = in_be32(l2_base);
/*
* xMon may have enabled part of L2 as SRAM, so we need to set it
* up for all cache mode just to be safe.
*/
printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n");
ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I;
if (of_machine_is_compatible("MPC8540") ||
of_machine_is_compatible("MPC8560"))
/*
* Assume L2 SRAM is used fully for cache, so set
* L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3).
*/
ctl |= (tmp & MPC85xx_L2CTL_L2SIZ_MASK) >> 2;
asm volatile("msync; isync");
out_be32(l2_base, ctl);
asm volatile("msync; isync");
}
static void xes_mpc85xx_fixups(void)
{
struct device_node *np;
int err;
/*
* Legacy xMon firmware on some X-ES boards does not enable L2
* as cache. We must ensure that they get enabled here.
*/
for_each_node_by_name(np, "l2-cache-controller") {
struct resource r[2];
void __iomem *l2_base;
/* Only MPC8548, MPC8540, and MPC8560 boards are affected */
if (!of_device_is_compatible(np,
"fsl,mpc8548-l2-cache-controller") &&
!of_device_is_compatible(np,
"fsl,mpc8540-l2-cache-controller") &&
!of_device_is_compatible(np,
"fsl,mpc8560-l2-cache-controller"))
continue;
err = of_address_to_resource(np, 0, &r[0]);
if (err) {
printk(KERN_WARNING "xes_mpc85xx: Could not get "
"resource for device tree node '%s'",
np->full_name);
continue;
}
l2_base = ioremap(r[0].start, resource_size(&r[0]));
xes_mpc85xx_configure_l2(l2_base);
}
}
/*
* Setup the architecture
*/
static void __init xes_mpc85xx_setup_arch(void)
{
struct device_node *root;
const char *model = "Unknown";
root = of_find_node_by_path("/");
if (root == NULL)
return;
model = of_get_property(root, "model", NULL);
printk(KERN_INFO "X-ES MPC85xx-based single-board computer: %s\n",
model + strlen("xes,"));
xes_mpc85xx_fixups();
mpc85xx_smp_init();
fsl_pci_assign_primary();
}
machine_arch_initcall(xes_mpc8572, mpc85xx_common_publish_devices);
machine_arch_initcall(xes_mpc8548, mpc85xx_common_publish_devices);
machine_arch_initcall(xes_mpc8540, mpc85xx_common_publish_devices);
/*
* Called very early, device-tree isn't unflattened
*/
static int __init xes_mpc8572_probe(void)
{
unsigned long root = of_get_flat_dt_root();
return of_flat_dt_is_compatible(root, "xes,MPC8572");
}
static int __init xes_mpc8548_probe(void)
{
unsigned long root = of_get_flat_dt_root();
return of_flat_dt_is_compatible(root, "xes,MPC8548");
}
static int __init xes_mpc8540_probe(void)
{
unsigned long root = of_get_flat_dt_root();
return of_flat_dt_is_compatible(root, "xes,MPC8540");
}
define_machine(xes_mpc8572) {
.name = "X-ES MPC8572",
.probe = xes_mpc8572_probe,
.setup_arch = xes_mpc85xx_setup_arch,
.init_IRQ = xes_mpc85xx_pic_init,
#ifdef CONFIG_PCI
.pcibios_fixup_bus = fsl_pcibios_fixup_bus,
#endif
.get_irq = mpic_get_irq,
.restart = fsl_rstcr_restart,
.calibrate_decr = generic_calibrate_decr,
.progress = udbg_progress,
};
define_machine(xes_mpc8548) {
.name = "X-ES MPC8548",
.probe = xes_mpc8548_probe,
.setup_arch = xes_mpc85xx_setup_arch,
.init_IRQ = xes_mpc85xx_pic_init,
#ifdef CONFIG_PCI
.pcibios_fixup_bus = fsl_pcibios_fixup_bus,
#endif
.get_irq = mpic_get_irq,
.restart = fsl_rstcr_restart,
.calibrate_decr = generic_calibrate_decr,
.progress = udbg_progress,
};
define_machine(xes_mpc8540) {
.name = "X-ES MPC8540",
.probe = xes_mpc8540_probe,
.setup_arch = xes_mpc85xx_setup_arch,
.init_IRQ = xes_mpc85xx_pic_init,
#ifdef CONFIG_PCI
.pcibios_fixup_bus = fsl_pcibios_fixup_bus,
#endif
.get_irq = mpic_get_irq,
.restart = fsl_rstcr_restart,
.calibrate_decr = generic_calibrate_decr,
.progress = udbg_progress,
};
|
fcc1102d70d84d2fe8aa9930453cec6e895cc380
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/tests/lib/libc/sys/t_futex_ops.c
|
2941d4e2b6c6fa0219e570c002a9dd1da852a257
|
[] |
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
| 38,141
|
c
|
t_futex_ops.c
|
/* $NetBSD: t_futex_ops.c,v 1.5 2020/05/06 05:14:27 thorpej Exp $ */
/*-
* Copyright (c) 2019, 2020 The NetBSD Foundation, 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 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>
__COPYRIGHT("@(#) Copyright (c) 2019, 2020\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_futex_ops.c,v 1.5 2020/05/06 05:14:27 thorpej Exp $");
#include <sys/fcntl.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <atomic.h>
#include <errno.h>
#include <lwp.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <limits.h>
#include <sched.h>
#include <unistd.h>
#include <atf-c.h>
#include <libc/include/futex_private.h>
#define LOAD(x) (*(volatile int *)(x))
#define STORE(x, y) *(volatile int *)(x) = (y)
#if 0
#define DPRINTF(x) printf x
#else
#define DPRINTF(x) __nothing
#endif
#define STACK_SIZE 65536
static volatile int futex_word;
static volatile int futex_word1;
static volatile unsigned int nlwps_running;
struct lwp_data {
ucontext_t context;
void (*func)(void *);
void *stack_base;
lwpid_t lwpid;
pid_t child;
lwpid_t threadid;
int wait_op;
int op_flags;
int bitset;
volatile int *futex_ptr;
volatile int *error_ptr;
int block_val;
void (*exit_func)(void);
int futex_error;
};
#define WAITER_LWP0 0
#define WAITER_LWP1 1
#define WAITER_LWP2 2
#define WAITER_LWP3 3
#define WAITER_LWP4 4
#define WAITER_LWP5 5
#define NLWPS 6
struct lwp_data lwp_data[NLWPS];
static const char *bs_path = "t_futex_ops_backing_store";
static int bs_fd = -1;
static int *bs_addr = MAP_FAILED;
static void *bs_source_buffer = NULL;
static void *bs_verify_buffer = NULL;
static long bs_pagesize;
static void
create_lwp_waiter(struct lwp_data *d)
{
ATF_REQUIRE(_lwp_create(&d->context, 0, &d->lwpid) == 0);
}
static void
exit_lwp_waiter(void)
{
_lwp_exit();
}
static void
reap_lwp_waiter(struct lwp_data *d)
{
ATF_REQUIRE(_lwp_wait(d->lwpid, NULL) == 0);
}
static void
create_proc_waiter(struct lwp_data *d)
{
pid_t pid;
ATF_REQUIRE((pid = fork()) != -1);
if (pid == 0) {
(*d->func)(d);
_exit(666); /* backstop */
} else
d->child = pid;
}
static void
exit_proc_waiter(void)
{
_exit(0);
}
static void
reap_proc_waiter(struct lwp_data *d)
{
int status;
ATF_REQUIRE(waitpid(d->child, &status, 0) == d->child);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE(WEXITSTATUS(status) == 0);
}
static void
setup_lwp_context(struct lwp_data *d, void (*func)(void *))
{
memset(d, 0, sizeof(*d));
d->stack_base = mmap(NULL, STACK_SIZE, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_STACK | MAP_PRIVATE, -1, 0);
ATF_REQUIRE(d->stack_base != MAP_FAILED);
_lwp_makecontext(&d->context, func, d, NULL, d->stack_base, STACK_SIZE);
d->threadid = 0;
d->func = func;
}
static void
simple_test_waiter_lwp(void *arg)
{
struct lwp_data *d = arg;
d->threadid = _lwp_self();
membar_producer();
atomic_inc_uint(&nlwps_running);
membar_sync();
if (__futex(d->futex_ptr, d->wait_op | d->op_flags,
d->block_val, NULL, NULL, 0, d->bitset) == -1) {
d->futex_error = errno;
membar_sync();
atomic_dec_uint(&nlwps_running);
_lwp_exit();
} else {
d->futex_error = 0;
}
membar_sync();
atomic_dec_uint(&nlwps_running);
_lwp_exit();
}
static bool
verify_zero_bs(void)
{
if (bs_verify_buffer == NULL) {
bs_verify_buffer = malloc(bs_pagesize);
ATF_REQUIRE(bs_verify_buffer != NULL);
}
ATF_REQUIRE(pread(bs_fd, bs_verify_buffer,
bs_pagesize, 0) == bs_pagesize);
return (memcmp(bs_verify_buffer, bs_source_buffer, bs_pagesize) == 0);
}
static void
create_bs(int map_flags)
{
bs_pagesize = sysconf(_SC_PAGESIZE);
ATF_REQUIRE(bs_pagesize > 0);
if ((map_flags & (MAP_FILE | MAP_ANON)) == MAP_FILE) {
bs_source_buffer = calloc(1, bs_pagesize);
ATF_REQUIRE(bs_source_buffer != NULL);
bs_fd = open(bs_path, O_RDWR | O_CREAT | O_EXCL, 0644);
ATF_REQUIRE(bs_fd != -1);
ATF_REQUIRE(pwrite(bs_fd, bs_source_buffer,
bs_pagesize, 0) == bs_pagesize);
ATF_REQUIRE(verify_zero_bs());
}
bs_addr = mmap(NULL, bs_pagesize, PROT_READ | PROT_WRITE,
map_flags | MAP_HASSEMAPHORE, bs_fd, 0);
ATF_REQUIRE(bs_addr != MAP_FAILED);
}
static void
cleanup_bs(void)
{
if (bs_fd != -1) {
(void) close(bs_fd);
bs_fd = -1;
(void) unlink(bs_path);
}
if (bs_source_buffer != NULL) {
free(bs_source_buffer);
bs_source_buffer = NULL;
}
if (bs_verify_buffer != NULL) {
free(bs_verify_buffer);
bs_verify_buffer = NULL;
}
if (bs_addr != MAP_FAILED) {
munmap(bs_addr, bs_pagesize);
bs_addr = MAP_FAILED;
}
}
static void
do_cleanup(void)
{
int i;
for (i = 0; i < NLWPS; i++) {
struct lwp_data *d = &lwp_data[i];
if (d->stack_base != NULL && d->stack_base != MAP_FAILED) {
(void) munmap(d->stack_base, STACK_SIZE);
}
}
memset(lwp_data, 0, sizeof(lwp_data));
STORE(&futex_word, 0);
STORE(&futex_word1, 0);
nlwps_running = 0;
cleanup_bs();
}
/*****************************************************************************/
static void
wait_wake_test_waiter_lwp(void *arg)
{
struct lwp_data *d = arg;
d->threadid = _lwp_self();
STORE(d->futex_ptr, 1);
membar_sync();
/* This will block because *futex_ptr == 1. */
if (__futex(d->futex_ptr, FUTEX_WAIT | d->op_flags,
1, NULL, NULL, 0, 0) == -1) {
STORE(d->error_ptr, errno);
(*d->exit_func)();
} else {
STORE(d->error_ptr, 0);
}
do {
membar_sync();
sleep(1);
} while (LOAD(d->futex_ptr) != 0);
STORE(d->futex_ptr, 2);
membar_sync();
do {
membar_sync();
sleep(1);
} while (LOAD(d->futex_ptr) != 3);
/* This will not block because futex_word != 666. */
if (__futex(d->futex_ptr, FUTEX_WAIT | d->op_flags,
666, NULL, NULL, 0, 0) == -1) {
/* This SHOULD be EAGAIN. */
STORE(d->error_ptr, errno);
}
STORE(d->futex_ptr, 4);
membar_sync();
(*d->exit_func)();
}
static void
do_futex_wait_wake_test(volatile int *futex_ptr, volatile int *error_ptr,
void (*create_func)(struct lwp_data *),
void (*exit_func)(void),
void (*reap_func)(struct lwp_data *),
int flags)
{
struct lwp_data *wlwp = &lwp_data[WAITER_LWP0];
int tries;
if (error_ptr == NULL)
error_ptr = &wlwp->futex_error;
if (create_func == NULL)
create_func = create_lwp_waiter;
if (exit_func == NULL)
exit_func = exit_lwp_waiter;
if (reap_func == NULL)
reap_func = reap_lwp_waiter;
setup_lwp_context(wlwp, wait_wake_test_waiter_lwp);
DPRINTF(("futex_basic_wait_wake: testing with flags 0x%x\n", flags));
wlwp->op_flags = flags;
wlwp->error_ptr = error_ptr;
STORE(error_ptr, -1);
wlwp->futex_ptr = futex_ptr;
STORE(futex_ptr, 0);
wlwp->exit_func = exit_func;
membar_sync();
DPRINTF(("futex_basic_wait_wake: creating watier LWP\n"));
(*create_func)(wlwp);
DPRINTF(("futex_basic_wait_wake: waiting for LWP %d to enter futex\n",
wlwp->lwpid));
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (LOAD(futex_ptr) == 1)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(LOAD(futex_ptr) == 1);
/*
* If the LWP is blocked in the futex, it will not have yet
* modified *error_ptr.
*/
DPRINTF(("futex_basic_wait_wake: checking for successful wait (%d)\n",
LOAD(error_ptr)));
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (LOAD(error_ptr) == -1)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(LOAD(error_ptr) == -1);
/* Make sure invalid #wakes in rejected. */
ATF_REQUIRE_ERRNO(EINVAL,
__futex(futex_ptr, FUTEX_WAKE | flags,
-1, NULL, NULL, 0, 0) == -1);
DPRINTF(("futex_basic_wait_wake: waking 1 waiter\n"));
ATF_REQUIRE(__futex(futex_ptr, FUTEX_WAKE | flags,
1, NULL, NULL, 0, 0) == 1);
DPRINTF(("futex_basic_wait_wake: checking for successful wake (%d)\n",
LOAD(error_ptr)));
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (LOAD(error_ptr) == 0)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(LOAD(error_ptr) == 0);
STORE(futex_ptr, 0);
membar_sync();
DPRINTF(("futex_basic_wait_wake: waiting for LWP to advance (2)\n"));
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (LOAD(futex_ptr) == 2)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(LOAD(futex_ptr) == 2);
STORE(futex_ptr, 3);
membar_sync();
DPRINTF(("futex_basic_wait_wake: waiting for LWP to advance (4)\n"));
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (LOAD(futex_ptr) == 4)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(LOAD(futex_ptr) == 4);
DPRINTF(("futex_basic_wait_wake: checking for expected EGAIN\n"));
ATF_REQUIRE(LOAD(error_ptr) == EAGAIN);
DPRINTF(("futex_basic_wait_wake: reaping LWP %d\n", wlwp->lwpid));
(*reap_func)(wlwp);
}
ATF_TC_WITH_CLEANUP(futex_basic_wait_wake_private);
ATF_TC_HEAD(futex_basic_wait_wake_private, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests basic futex WAIT + WAKE operations (PRIVATE)");
}
ATF_TC_BODY(futex_basic_wait_wake_private, tc)
{
do_futex_wait_wake_test(&futex_word, NULL,
NULL, NULL, NULL,
FUTEX_PRIVATE_FLAG);
}
ATF_TC_CLEANUP(futex_basic_wait_wake_private, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_basic_wait_wake_shared);
ATF_TC_HEAD(futex_basic_wait_wake_shared, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests basic futex WAIT + WAKE operations (SHARED)");
}
ATF_TC_BODY(futex_basic_wait_wake_shared, tc)
{
do_futex_wait_wake_test(&futex_word, NULL,
NULL, NULL, NULL,
0);
}
ATF_TC_CLEANUP(futex_basic_wait_wake_shared, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_anon_bs_private);
ATF_TC_HEAD(futex_wait_wake_anon_bs_private, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT + WAKE operations (MAP_ANON + PRIVATE)");
}
ATF_TC_BODY(futex_wait_wake_anon_bs_private, tc)
{
create_bs(MAP_ANON | MAP_PRIVATE);
do_futex_wait_wake_test(&bs_addr[0], NULL,
NULL, NULL, NULL,
FUTEX_PRIVATE_FLAG);
}
ATF_TC_CLEANUP(futex_wait_wake_anon_bs_private, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_anon_bs_shared);
ATF_TC_HEAD(futex_wait_wake_anon_bs_shared, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT + WAKE operations (MAP_ANON + SHARED)");
}
ATF_TC_BODY(futex_wait_wake_anon_bs_shared, tc)
{
create_bs(MAP_ANON | MAP_PRIVATE);
do_futex_wait_wake_test(&bs_addr[0], NULL,
NULL, NULL, NULL,
0);
}
ATF_TC_CLEANUP(futex_wait_wake_anon_bs_shared, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_file_bs_private);
ATF_TC_HEAD(futex_wait_wake_file_bs_private, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT + WAKE operations (MAP_FILE + PRIVATE)");
}
ATF_TC_BODY(futex_wait_wake_file_bs_private, tc)
{
/*
* This combination (non-COW mapped file + PRIVATE futex)
* doesn't really make sense, but we should make sure it
* works as expected.
*/
create_bs(MAP_FILE | MAP_SHARED);
do_futex_wait_wake_test(&bs_addr[0], NULL,
NULL, NULL, NULL,
FUTEX_PRIVATE_FLAG);
ATF_REQUIRE(! verify_zero_bs());
}
ATF_TC_CLEANUP(futex_wait_wake_file_bs_private, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_file_bs_cow_private);
ATF_TC_HEAD(futex_wait_wake_file_bs_cow_private, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT + WAKE operations (MAP_FILE COW + PRIVATE)");
}
ATF_TC_BODY(futex_wait_wake_file_bs_cow_private, tc)
{
create_bs(MAP_FILE | MAP_PRIVATE);
do_futex_wait_wake_test(&bs_addr[0], NULL,
NULL, NULL, NULL,
FUTEX_PRIVATE_FLAG);
ATF_REQUIRE(verify_zero_bs());
}
ATF_TC_CLEANUP(futex_wait_wake_file_bs_cow_private, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_file_bs_shared);
ATF_TC_HEAD(futex_wait_wake_file_bs_shared, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT + WAKE operations (MAP_FILE + SHARED)");
}
ATF_TC_BODY(futex_wait_wake_file_bs_shared, tc)
{
create_bs(MAP_FILE | MAP_SHARED);
do_futex_wait_wake_test(&bs_addr[0], NULL,
NULL, NULL, NULL,
0);
ATF_REQUIRE(! verify_zero_bs());
}
ATF_TC_CLEANUP(futex_wait_wake_file_bs_shared, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_file_bs_cow_shared);
ATF_TC_HEAD(futex_wait_wake_file_bs_cow_shared, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT + WAKE operations (MAP_FILE COW + SHARED)");
}
ATF_TC_BODY(futex_wait_wake_file_bs_cow_shared, tc)
{
/*
* This combination (COW mapped file + SHARED futex)
* doesn't really make sense, but we should make sure it
* works as expected.
*/
create_bs(MAP_FILE | MAP_PRIVATE);
do_futex_wait_wake_test(&bs_addr[0], NULL,
NULL, NULL, NULL,
0);
ATF_REQUIRE(verify_zero_bs());
}
ATF_TC_CLEANUP(futex_wait_wake_file_bs_cow_shared, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_anon_bs_shared_proc);
ATF_TC_HEAD(futex_wait_wake_anon_bs_shared_proc, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests multiproc futex WAIT + WAKE operations (MAP_ANON + SHARED)");
}
ATF_TC_BODY(futex_wait_wake_anon_bs_shared_proc, tc)
{
create_bs(MAP_ANON | MAP_SHARED);
do_futex_wait_wake_test(&bs_addr[0], &bs_addr[1],
create_proc_waiter,
exit_proc_waiter,
reap_proc_waiter,
0);
}
ATF_TC_CLEANUP(futex_wait_wake_anon_bs_shared_proc, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_file_bs_shared_proc);
ATF_TC_HEAD(futex_wait_wake_file_bs_shared_proc, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests multiproc futex WAIT + WAKE operations (MAP_ANON + SHARED)");
}
ATF_TC_BODY(futex_wait_wake_file_bs_shared_proc, tc)
{
create_bs(MAP_FILE | MAP_SHARED);
do_futex_wait_wake_test(&bs_addr[0], &bs_addr[1],
create_proc_waiter,
exit_proc_waiter,
reap_proc_waiter,
0);
}
ATF_TC_CLEANUP(futex_wait_wake_file_bs_shared_proc, tc)
{
do_cleanup();
}
/*****************************************************************************/
ATF_TC(futex_wait_pointless_bitset);
ATF_TC_HEAD(futex_wait_pointless_bitset, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests basic futex WAIT + WAKE operations (SHARED)");
}
ATF_TC_BODY(futex_wait_pointless_bitset, tc)
{
futex_word = 1;
ATF_REQUIRE_ERRNO(EINVAL,
__futex(&futex_word, FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG,
1, NULL, NULL, 0, 0) == -1);
}
static void
do_futex_wait_wake_bitset_test(int flags)
{
struct lwp_data *wlwp0 = &lwp_data[WAITER_LWP0];
struct lwp_data *wlwp1 = &lwp_data[WAITER_LWP1];
int i, tries;
for (i = WAITER_LWP0; i <= WAITER_LWP1; i++) {
setup_lwp_context(&lwp_data[i], simple_test_waiter_lwp);
lwp_data[i].op_flags = flags;
lwp_data[i].futex_error = -1;
lwp_data[i].bitset = __BIT(i);
lwp_data[i].wait_op = FUTEX_WAIT_BITSET;
lwp_data[i].futex_ptr = &futex_word;
lwp_data[i].block_val = 1;
}
STORE(&futex_word, 1);
membar_sync();
ATF_REQUIRE(_lwp_create(&wlwp0->context, 0, &wlwp0->lwpid) == 0);
ATF_REQUIRE(_lwp_create(&wlwp1->context, 0, &wlwp1->lwpid) == 0);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 2)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 2, "waiters failed to start");
/* Ensure they're blocked. */
ATF_REQUIRE(wlwp0->futex_error == -1);
ATF_REQUIRE(wlwp1->futex_error == -1);
/* Make sure invalid #wakes in rejected. */
ATF_REQUIRE_ERRNO(EINVAL,
__futex(&futex_word, FUTEX_WAKE_BITSET | flags,
-1, NULL, NULL, 0, 0) == -1);
/* This should result in no wakeups because no bits are set. */
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_BITSET | flags,
INT_MAX, NULL, NULL, 0, 0) == 0);
/* This should result in no wakeups because the wrongs bits are set. */
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_BITSET | flags,
INT_MAX, NULL, NULL, 0,
~(wlwp0->bitset | wlwp1->bitset)) == 0);
/* Trust, but verify. */
sleep(1);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 2)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 2, "waiters exited unexpectedly");
/* Wake up the first LWP. */
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_BITSET | flags,
INT_MAX, NULL, NULL, 0,
wlwp0->bitset) == 1);
sleep(1);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 1)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(nlwps_running == 1);
ATF_REQUIRE(wlwp0->futex_error == 0);
ATF_REQUIRE(_lwp_wait(wlwp0->lwpid, NULL) == 0);
/* Wake up the second LWP. */
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_BITSET | flags,
INT_MAX, NULL, NULL, 0,
wlwp1->bitset) == 1);
sleep(1);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 0)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(nlwps_running == 0);
ATF_REQUIRE(wlwp1->futex_error == 0);
ATF_REQUIRE(_lwp_wait(wlwp1->lwpid, NULL) == 0);
}
ATF_TC_WITH_CLEANUP(futex_wait_wake_bitset);
ATF_TC_HEAD(futex_wait_wake_bitset, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT_BITSET + WAKE_BITSET operations");
}
ATF_TC_BODY(futex_wait_wake_bitset, tc)
{
do_futex_wait_wake_bitset_test(FUTEX_PRIVATE_FLAG);
}
ATF_TC_CLEANUP(futex_wait_wake_bitset, tc)
{
do_cleanup();
}
/*****************************************************************************/
static void
do_futex_requeue_test(int flags, int op)
{
struct lwp_data *wlwp0 = &lwp_data[WAITER_LWP0];
struct lwp_data *wlwp1 = &lwp_data[WAITER_LWP1];
struct lwp_data *wlwp2 = &lwp_data[WAITER_LWP2];
struct lwp_data *wlwp3 = &lwp_data[WAITER_LWP3];
const int good_val3 = (op == FUTEX_CMP_REQUEUE) ? 1 : 0;
const int bad_val3 = (op == FUTEX_CMP_REQUEUE) ? 666 : 0;
int i, tries;
for (i = WAITER_LWP0; i <= WAITER_LWP3; i++) {
setup_lwp_context(&lwp_data[i], simple_test_waiter_lwp);
lwp_data[i].op_flags = flags;
lwp_data[i].futex_error = -1;
lwp_data[i].futex_ptr = &futex_word;
lwp_data[i].block_val = 1;
lwp_data[i].bitset = 0;
lwp_data[i].wait_op = FUTEX_WAIT;
}
STORE(&futex_word, 1);
STORE(&futex_word1, 1);
membar_sync();
ATF_REQUIRE(_lwp_create(&wlwp0->context, 0, &wlwp0->lwpid) == 0);
ATF_REQUIRE(_lwp_create(&wlwp1->context, 0, &wlwp1->lwpid) == 0);
ATF_REQUIRE(_lwp_create(&wlwp2->context, 0, &wlwp2->lwpid) == 0);
ATF_REQUIRE(_lwp_create(&wlwp3->context, 0, &wlwp3->lwpid) == 0);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 4)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 4, "waiters failed to start");
/* Ensure they're blocked. */
ATF_REQUIRE(wlwp0->futex_error == -1);
ATF_REQUIRE(wlwp1->futex_error == -1);
ATF_REQUIRE(wlwp2->futex_error == -1);
ATF_REQUIRE(wlwp3->futex_error == -1);
/* Make sure invalid #wakes and #requeues are rejected. */
ATF_REQUIRE_ERRNO(EINVAL,
__futex(&futex_word, op | flags,
-1, NULL, &futex_word1, INT_MAX, bad_val3) == -1);
ATF_REQUIRE_ERRNO(EINVAL,
__futex(&futex_word, op | flags,
0, NULL, &futex_word1, -1, bad_val3) == -1);
/*
* FUTEX 0: 4 LWPs
* FUTEX 1: 0 LWPs
*/
if (op == FUTEX_CMP_REQUEUE) {
/* This should fail because the futex_word value is 1. */
ATF_REQUIRE_ERRNO(EAGAIN,
__futex(&futex_word, op | flags,
0, NULL, &futex_word1, INT_MAX, bad_val3) == -1);
}
/*
* FUTEX 0: 4 LWPs
* FUTEX 1: 0 LWPs
*/
/* Move all waiters from 0 to 1. */
ATF_REQUIRE(__futex(&futex_word, op | flags,
0, NULL, &futex_word1, INT_MAX, good_val3) == 0);
/*
* FUTEX 0: 0 LWPs
* FUTEX 1: 4 LWPs
*/
if (op == FUTEX_CMP_REQUEUE) {
/* This should fail because the futex_word1 value is 1. */
ATF_REQUIRE_ERRNO(EAGAIN,
__futex(&futex_word1, op | flags,
1, NULL, &futex_word, 1, bad_val3) == -1);
}
/*
* FUTEX 0: 0 LWPs
* FUTEX 1: 4 LWPs
*/
/* Wake one waiter on 1, move one waiter to 0. */
ATF_REQUIRE(__futex(&futex_word1, op | flags,
1, NULL, &futex_word, 1, good_val3) == 1);
/*
* FUTEX 0: 1 LWP
* FUTEX 1: 2 LWPs
*/
/* Wake all waiters on 0 (should be 1). */
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE | flags,
INT_MAX, NULL, NULL, 0, 0) == 1);
/* Wake all waiters on 1 (should be 2). */
ATF_REQUIRE(__futex(&futex_word1, FUTEX_WAKE | flags,
INT_MAX, NULL, NULL, 0, 0) == 2);
/* Trust, but verify. */
sleep(1);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 0)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 0, "waiters failed to exit");
ATF_REQUIRE(_lwp_wait(wlwp0->lwpid, NULL) == 0);
ATF_REQUIRE(_lwp_wait(wlwp1->lwpid, NULL) == 0);
ATF_REQUIRE(_lwp_wait(wlwp2->lwpid, NULL) == 0);
ATF_REQUIRE(_lwp_wait(wlwp3->lwpid, NULL) == 0);
}
ATF_TC_WITH_CLEANUP(futex_requeue);
ATF_TC_HEAD(futex_requeue, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex REQUEUE operations");
}
ATF_TC_BODY(futex_requeue, tc)
{
do_futex_requeue_test(FUTEX_PRIVATE_FLAG, FUTEX_REQUEUE);
}
ATF_TC_CLEANUP(futex_requeue, tc)
{
do_cleanup();
}
ATF_TC_WITH_CLEANUP(futex_cmp_requeue);
ATF_TC_HEAD(futex_cmp_requeue, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex CMP_REQUEUE operations");
}
ATF_TC_BODY(futex_cmp_requeue, tc)
{
do_futex_requeue_test(FUTEX_PRIVATE_FLAG, FUTEX_CMP_REQUEUE);
}
ATF_TC_CLEANUP(futex_cmp_requeue, tc)
{
do_cleanup();
}
/*****************************************************************************/
static void
do_futex_wake_op_op_test(int flags)
{
int op;
futex_word = 0;
futex_word1 = 0;
/*
* The op= operations should work even if there are no waiters.
*/
/*
* Because these operations use both futex addresses, exercise
* rejecting unaligned futex addresses here.
*/
op = FUTEX_OP(FUTEX_OP_SET, 1, FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE_ERRNO(EINVAL,
__futex((int *)1, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 0, op) == -1);
ATF_REQUIRE(futex_word1 == 0);
ATF_REQUIRE_ERRNO(EINVAL,
__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, (int *)1, 0, op) == -1);
ATF_REQUIRE(futex_word == 0);
/* Check unmapped uaddr2 handling, too. */
ATF_REQUIRE_ERRNO(EFAULT,
__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, NULL, 0, op) == -1);
ATF_REQUIRE(futex_word == 0);
op = FUTEX_OP(FUTEX_OP_SET, 1, FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 0, op) == 0);
ATF_REQUIRE(futex_word1 == 1);
op = FUTEX_OP(FUTEX_OP_ADD, 1, FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 0, op) == 0);
ATF_REQUIRE(futex_word1 == 2);
op = FUTEX_OP(FUTEX_OP_OR, 2, FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 0, op) == 0);
ATF_REQUIRE(futex_word1 == 2);
/* This should fail because of invalid shift value 32. */
op = FUTEX_OP(FUTEX_OP_OR | FUTEX_OP_OPARG_SHIFT, 32,
FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE_ERRNO(EINVAL,
__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 0, op) == -1);
ATF_REQUIRE(futex_word1 == 2);
op = FUTEX_OP(FUTEX_OP_OR | FUTEX_OP_OPARG_SHIFT, 31,
FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 0, op) == 0);
ATF_REQUIRE(futex_word1 == (int)0x80000002);
op = FUTEX_OP(FUTEX_OP_ANDN | FUTEX_OP_OPARG_SHIFT, 31,
FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 0, op) == 0);
ATF_REQUIRE(futex_word1 == 2);
op = FUTEX_OP(FUTEX_OP_XOR, 2, FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 0, op) == 0);
ATF_REQUIRE(futex_word1 == 0);
}
ATF_TC_WITH_CLEANUP(futex_wake_op_op);
ATF_TC_HEAD(futex_wake_op_op, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAKE_OP OP operations");
}
ATF_TC_BODY(futex_wake_op_op, tc)
{
do_futex_wake_op_op_test(FUTEX_PRIVATE_FLAG);
}
ATF_TC_CLEANUP(futex_wake_op_op, tc)
{
do_cleanup();
}
static void
create_wake_op_test_lwps(int flags)
{
int i;
futex_word1 = 0;
membar_sync();
for (i = WAITER_LWP0; i <= WAITER_LWP5; i++) {
setup_lwp_context(&lwp_data[i], simple_test_waiter_lwp);
lwp_data[i].op_flags = flags;
lwp_data[i].futex_error = -1;
lwp_data[i].futex_ptr = &futex_word1;
lwp_data[i].block_val = 0;
lwp_data[i].bitset = 0;
lwp_data[i].wait_op = FUTEX_WAIT;
ATF_REQUIRE(_lwp_create(&lwp_data[i].context, 0,
&lwp_data[i].lwpid) == 0);
}
for (i = 0; i < 5; i++) {
membar_sync();
if (nlwps_running == 6)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 6, "waiters failed to start");
/* Ensure they're blocked. */
for (i = WAITER_LWP0; i <= WAITER_LWP5; i++) {
ATF_REQUIRE(lwp_data[i].futex_error == -1);
}
}
static void
reap_wake_op_test_lwps(void)
{
int i;
for (i = WAITER_LWP0; i <= WAITER_LWP5; i++) {
ATF_REQUIRE(_lwp_wait(lwp_data[i].lwpid, NULL) == 0);
}
}
static void
do_futex_wake_op_cmp_test(int flags)
{
int tries, op;
futex_word = 0;
membar_sync();
/*
* Verify and negative and positive for each individual
* compare.
*/
create_wake_op_test_lwps(flags);
/* #LWPs = 6 */
op = FUTEX_OP(FUTEX_OP_SET, 0, FUTEX_OP_CMP_EQ, 1);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 0);
ATF_REQUIRE(futex_word1 == 0);
op = FUTEX_OP(FUTEX_OP_SET, 1, FUTEX_OP_CMP_EQ, 0);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 1);
ATF_REQUIRE(futex_word1 == 1);
/* #LWPs = 5 */
op = FUTEX_OP(FUTEX_OP_SET, 1, FUTEX_OP_CMP_NE, 1);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 0);
ATF_REQUIRE(futex_word1 == 1);
op = FUTEX_OP(FUTEX_OP_SET, 2, FUTEX_OP_CMP_NE, 2);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 1);
ATF_REQUIRE(futex_word1 == 2);
/* #LWPs = 4 */
op = FUTEX_OP(FUTEX_OP_SET, 2, FUTEX_OP_CMP_LT, 2);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 0);
ATF_REQUIRE(futex_word1 == 2);
op = FUTEX_OP(FUTEX_OP_SET, 2, FUTEX_OP_CMP_LT, 3);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 1);
ATF_REQUIRE(futex_word1 == 2);
/* #LWPs = 3 */
op = FUTEX_OP(FUTEX_OP_SET, 1, FUTEX_OP_CMP_LE, 1);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 0);
ATF_REQUIRE(futex_word1 == 1);
op = FUTEX_OP(FUTEX_OP_SET, 1, FUTEX_OP_CMP_LE, 1);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 1);
ATF_REQUIRE(futex_word1 == 1);
/* #LWPs = 2 */
op = FUTEX_OP(FUTEX_OP_SET, 3, FUTEX_OP_CMP_GT, 3);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 0);
ATF_REQUIRE(futex_word1 == 3);
op = FUTEX_OP(FUTEX_OP_SET, 2, FUTEX_OP_CMP_GT, 2);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 1);
ATF_REQUIRE(futex_word1 == 2);
/* #LWPs = 1 */
op = FUTEX_OP(FUTEX_OP_SET, 3, FUTEX_OP_CMP_GE, 4);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 0);
ATF_REQUIRE(futex_word1 == 3);
op = FUTEX_OP(FUTEX_OP_SET, 2, FUTEX_OP_CMP_GE, 3);
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE_OP | flags,
0, NULL, &futex_word1, 1, op) == 1);
ATF_REQUIRE(futex_word1 == 2);
/* #LWPs = 0 */
/* Trust, but verify. */
sleep(1);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 0)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 0, "waiters failed to exit");
reap_wake_op_test_lwps();
/*
* Verify wakes on uaddr work even if the uaddr2 comparison
* fails.
*/
create_wake_op_test_lwps(flags);
/* #LWPs = 6 */
ATF_REQUIRE(futex_word == 0);
op = FUTEX_OP(FUTEX_OP_SET, 0, FUTEX_OP_CMP_EQ, 666);
ATF_REQUIRE(__futex(&futex_word1, FUTEX_WAKE_OP | flags,
INT_MAX, NULL, &futex_word, 0, op) == 6);
ATF_REQUIRE(futex_word == 0);
/* #LWPs = 0 */
/* Trust, but verify. */
sleep(1);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 0)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 0, "waiters failed to exit");
reap_wake_op_test_lwps();
}
ATF_TC_WITH_CLEANUP(futex_wake_op_cmp);
ATF_TC_HEAD(futex_wake_op_cmp, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAKE_OP CMP operations");
}
ATF_TC_BODY(futex_wake_op_cmp, tc)
{
do_futex_wake_op_cmp_test(FUTEX_PRIVATE_FLAG);
}
ATF_TC_CLEANUP(futex_wake_op_cmp, tc)
{
do_cleanup();
}
/*****************************************************************************/
static void
do_futex_wait_timeout(bool relative, clockid_t clock)
{
struct timespec ts;
struct timespec deadline;
int op = relative ? FUTEX_WAIT : FUTEX_WAIT_BITSET;
if (clock == CLOCK_REALTIME)
op |= FUTEX_CLOCK_REALTIME;
ATF_REQUIRE(clock_gettime(clock, &deadline) == 0);
deadline.tv_sec += 2;
if (relative) {
ts.tv_sec = 2;
ts.tv_nsec = 0;
} else {
ts = deadline;
}
futex_word = 1;
ATF_REQUIRE_ERRNO(ETIMEDOUT,
__futex(&futex_word, op | FUTEX_PRIVATE_FLAG,
1, &ts, NULL, 0, FUTEX_BITSET_MATCH_ANY) == -1);
/* Can't reliably check CLOCK_REALTIME in the presence of NTP. */
if (clock != CLOCK_REALTIME) {
ATF_REQUIRE(clock_gettime(clock, &ts) == 0);
ATF_REQUIRE(ts.tv_sec >= deadline.tv_sec);
ATF_REQUIRE(ts.tv_sec > deadline.tv_sec ||
ts.tv_nsec >= deadline.tv_nsec);
}
}
ATF_TC(futex_wait_timeout_relative);
ATF_TC_HEAD(futex_wait_timeout_relative, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT with relative timeout");
}
ATF_TC_BODY(futex_wait_timeout_relative, tc)
{
do_futex_wait_timeout(true, CLOCK_MONOTONIC);
}
ATF_TC(futex_wait_timeout_relative_rt);
ATF_TC_HEAD(futex_wait_timeout_relative_rt, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT with relative timeout (REALTIME)");
}
ATF_TC_BODY(futex_wait_timeout_relative_rt, tc)
{
do_futex_wait_timeout(true, CLOCK_REALTIME);
}
ATF_TC(futex_wait_timeout_deadline);
ATF_TC_HEAD(futex_wait_timeout_deadline, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT with absolute deadline");
}
ATF_TC_BODY(futex_wait_timeout_deadline, tc)
{
do_futex_wait_timeout(false, CLOCK_MONOTONIC);
}
ATF_TC(futex_wait_timeout_deadline_rt);
ATF_TC_HEAD(futex_wait_timeout_deadline_rt, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT with absolute deadline (REALTIME)");
}
ATF_TC_BODY(futex_wait_timeout_deadline_rt, tc)
{
do_futex_wait_timeout(false, CLOCK_REALTIME);
}
/*****************************************************************************/
static void
sig_noop(int sig __unused)
{
}
static void (*old_act)(int) = SIG_DFL;
static void
do_futex_wait_evil_unmapped(int map_flags)
{
int i;
create_bs(map_flags);
old_act = signal(SIGUSR1, sig_noop);
ATF_REQUIRE(old_act != SIG_ERR);
setup_lwp_context(&lwp_data[0], simple_test_waiter_lwp);
lwp_data[0].op_flags = 0;
lwp_data[0].futex_error = -1;
lwp_data[0].futex_ptr = &bs_addr[0];
lwp_data[0].block_val = 0;
lwp_data[0].bitset = 0;
lwp_data[0].wait_op = FUTEX_WAIT;
ATF_REQUIRE(_lwp_create(&lwp_data[0].context, 0,
&lwp_data[0].lwpid) == 0);
for (i = 0; i < 5; i++) {
membar_sync();
if (nlwps_running == 1)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 1, "waiters failed to start");
/* Ensure it's blocked. */
ATF_REQUIRE(lwp_data[0].futex_error == -1);
/* Rudely unmap the backing store. */
cleanup_bs();
/* Signal the waiter so that it leaves the futex. */
ATF_REQUIRE(_lwp_kill(lwp_data[0].threadid, SIGUSR1) == 0);
/* Yay! No panic! */
reap_lwp_waiter(&lwp_data[0]);
}
ATF_TC_WITH_CLEANUP(futex_wait_evil_unmapped_anon);
ATF_TC_HEAD(futex_wait_evil_unmapped_anon, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests futex WAIT while futex is unmapped - anon memory");
}
ATF_TC_BODY(futex_wait_evil_unmapped_anon, tc)
{
do_futex_wait_evil_unmapped(MAP_ANON);
}
ATF_TC_CLEANUP(futex_wait_evil_unmapped_anon, tc)
{
signal(SIGUSR1, old_act);
do_cleanup();
}
/*****************************************************************************/
static int pri_min;
static int pri_max;
static void
lowpri_simple_test_waiter_lwp(void *arg)
{
struct lwp_data *d = arg;
struct sched_param sp;
int policy;
d->threadid = _lwp_self();
ATF_REQUIRE(_sched_getparam(getpid(), d->threadid, &policy, &sp) == 0);
policy = SCHED_RR;
sp.sched_priority = pri_min;
ATF_REQUIRE(_sched_setparam(getpid(), d->threadid, policy, &sp) == 0);
simple_test_waiter_lwp(arg);
}
static void
highpri_simple_test_waiter_lwp(void *arg)
{
struct lwp_data *d = arg;
struct sched_param sp;
int policy;
d->threadid = _lwp_self();
ATF_REQUIRE(_sched_getparam(getpid(), d->threadid, &policy, &sp) == 0);
policy = SCHED_RR;
sp.sched_priority = pri_max;
ATF_REQUIRE(_sched_setparam(getpid(), d->threadid, policy, &sp) == 0);
simple_test_waiter_lwp(arg);
}
static void
do_test_wake_highest_pri(void)
{
lwpid_t waiter;
int tries;
long pri;
ATF_REQUIRE((pri = sysconf(_SC_SCHED_PRI_MIN)) != -1);
pri_min = (int)pri;
ATF_REQUIRE((pri = sysconf(_SC_SCHED_PRI_MAX)) != -1);
pri_max = (int)pri;
futex_word = 0;
membar_sync();
setup_lwp_context(&lwp_data[0], lowpri_simple_test_waiter_lwp);
lwp_data[0].op_flags = FUTEX_PRIVATE_FLAG;
lwp_data[0].futex_error = -1;
lwp_data[0].futex_ptr = &futex_word;
lwp_data[0].block_val = 0;
lwp_data[0].bitset = 0;
lwp_data[0].wait_op = FUTEX_WAIT;
ATF_REQUIRE(_lwp_create(&lwp_data[0].context, 0,
&lwp_data[0].lwpid) == 0);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 1)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 1, "lowpri waiter failed to start");
/* Ensure it's blocked. */
ATF_REQUIRE(lwp_data[0].futex_error == -1);
setup_lwp_context(&lwp_data[1], highpri_simple_test_waiter_lwp);
lwp_data[1].op_flags = FUTEX_PRIVATE_FLAG;
lwp_data[1].futex_error = -1;
lwp_data[1].futex_ptr = &futex_word;
lwp_data[1].block_val = 0;
lwp_data[1].bitset = 0;
lwp_data[1].wait_op = FUTEX_WAIT;
ATF_REQUIRE(_lwp_create(&lwp_data[1].context, 0,
&lwp_data[1].lwpid) == 0);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 2)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE_EQ_MSG(nlwps_running, 2, "highpri waiter failed to start");
/* Ensure it's blocked. */
ATF_REQUIRE(lwp_data[1].futex_error == -1);
/* Wake the first LWP. We should get the highpri thread. */
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE | FUTEX_PRIVATE_FLAG,
1, NULL, NULL, 0, 0) == 1);
sleep(1);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 1)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(nlwps_running == 1);
ATF_REQUIRE(_lwp_wait(0, &waiter) == 0);
ATF_REQUIRE(waiter == lwp_data[1].threadid);
/* Wake the second LWP. We should get the lowpri thread. */
ATF_REQUIRE(__futex(&futex_word, FUTEX_WAKE | FUTEX_PRIVATE_FLAG,
1, NULL, NULL, 0, 0) == 1);
sleep(1);
for (tries = 0; tries < 5; tries++) {
membar_sync();
if (nlwps_running == 0)
break;
sleep(1);
}
membar_sync();
ATF_REQUIRE(nlwps_running == 0);
ATF_REQUIRE(_lwp_wait(0, &waiter) == 0);
ATF_REQUIRE(waiter == lwp_data[0].threadid);
}
ATF_TC_WITH_CLEANUP(futex_wake_highest_pri);
ATF_TC_HEAD(futex_wake_highest_pri, tc)
{
atf_tc_set_md_var(tc, "descr",
"tests that futex WAKE wakes the highest priority waiter");
atf_tc_set_md_var(tc, "require.user", "root");
}
ATF_TC_BODY(futex_wake_highest_pri, tc)
{
atf_tc_expect_fail("PR kern/55230");
do_test_wake_highest_pri();
}
ATF_TC_CLEANUP(futex_wake_highest_pri, tc)
{
do_cleanup();
}
/*****************************************************************************/
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, futex_basic_wait_wake_private);
ATF_TP_ADD_TC(tp, futex_basic_wait_wake_shared);
ATF_TP_ADD_TC(tp, futex_wait_wake_anon_bs_private);
ATF_TP_ADD_TC(tp, futex_wait_wake_anon_bs_shared);
ATF_TP_ADD_TC(tp, futex_wait_wake_file_bs_private);
ATF_TP_ADD_TC(tp, futex_wait_wake_file_bs_shared);
ATF_TP_ADD_TC(tp, futex_wait_wake_file_bs_cow_private);
ATF_TP_ADD_TC(tp, futex_wait_wake_file_bs_cow_shared);
ATF_TP_ADD_TC(tp, futex_wait_wake_anon_bs_shared_proc);
ATF_TP_ADD_TC(tp, futex_wait_wake_file_bs_shared_proc);
ATF_TP_ADD_TC(tp, futex_wait_pointless_bitset);
ATF_TP_ADD_TC(tp, futex_wait_wake_bitset);
ATF_TP_ADD_TC(tp, futex_wait_timeout_relative);
ATF_TP_ADD_TC(tp, futex_wait_timeout_relative_rt);
ATF_TP_ADD_TC(tp, futex_wait_timeout_deadline);
ATF_TP_ADD_TC(tp, futex_wait_timeout_deadline_rt);
ATF_TP_ADD_TC(tp, futex_wait_evil_unmapped_anon);
ATF_TP_ADD_TC(tp, futex_requeue);
ATF_TP_ADD_TC(tp, futex_cmp_requeue);
ATF_TP_ADD_TC(tp, futex_wake_op_op);
ATF_TP_ADD_TC(tp, futex_wake_op_cmp);
ATF_TP_ADD_TC(tp, futex_wake_highest_pri);
return atf_no_error();
}
|
fe0ed2c952ab61bed295cfa8873ed24226ed972d
|
e552c5408e825acc3a00ae8ab8e0697beddf7a0a
|
/projects/stm8s103/STM8S_StdPeriph_Lib/Libraries/STM8S_StdPeriph_Driver/inc/stm8s_awu.h
|
9f2b0cf708acb0dd2f029e0d19f8091add63e682
|
[
"MIT",
"PostgreSQL",
"ISC",
"BSD-3-Clause",
"BSL-1.0",
"BSD-2-Clause"
] |
permissive
|
xhawk18/s_task
|
f81dda8252bbb0631b564eb8775c8008bc4f5583
|
d1e9a348a570433f0f5655f64c8dd3b94a6d1cbe
|
refs/heads/master
| 2023-08-13T08:11:27.712894
| 2023-04-11T12:29:43
| 2023-04-11T12:29:43
| 242,364,894
| 552
| 88
| null | null | null | null |
UTF-8
|
C
| false
| false
| 5,065
|
h
|
stm8s_awu.h
|
/**
******************************************************************************
* @file stm8s_awu.h
* @author MCD Application Team
* @version V2.2.0
* @date 30-September-2014
* @brief This file contains all functions prototype and macros for the AWU peripheral.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM8S_AWU_H
#define __STM8S_AWU_H
/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"
/* Exported types ------------------------------------------------------------*/
/** @addtogroup AWU_Exported_Types
* @{
*/
/**
* @brief AWU TimeBase selection
*/
typedef enum
{
AWU_TIMEBASE_NO_IT = (uint8_t)0, /*!< No AWU interrupt selected */
AWU_TIMEBASE_250US = (uint8_t)1, /*!< AWU Timebase equals 0.25 ms */
AWU_TIMEBASE_500US = (uint8_t)2, /*!< AWU Timebase equals 0.5 ms */
AWU_TIMEBASE_1MS = (uint8_t)3, /*!< AWU Timebase equals 1 ms */
AWU_TIMEBASE_2MS = (uint8_t)4, /*!< AWU Timebase equals 2 ms */
AWU_TIMEBASE_4MS = (uint8_t)5, /*!< AWU Timebase equals 4 ms */
AWU_TIMEBASE_8MS = (uint8_t)6, /*!< AWU Timebase equals 8 ms */
AWU_TIMEBASE_16MS = (uint8_t)7, /*!< AWU Timebase equals 16 ms */
AWU_TIMEBASE_32MS = (uint8_t)8, /*!< AWU Timebase equals 32 ms */
AWU_TIMEBASE_64MS = (uint8_t)9, /*!< AWU Timebase equals 64 ms */
AWU_TIMEBASE_128MS = (uint8_t)10, /*!< AWU Timebase equals 128 ms */
AWU_TIMEBASE_256MS = (uint8_t)11, /*!< AWU Timebase equals 256 ms */
AWU_TIMEBASE_512MS = (uint8_t)12, /*!< AWU Timebase equals 512 ms */
AWU_TIMEBASE_1S = (uint8_t)13, /*!< AWU Timebase equals 1 s */
AWU_TIMEBASE_2S = (uint8_t)14, /*!< AWU Timebase equals 2 s */
AWU_TIMEBASE_12S = (uint8_t)15, /*!< AWU Timebase equals 12 s */
AWU_TIMEBASE_30S = (uint8_t)16 /*!< AWU Timebase equals 30 s */
} AWU_Timebase_TypeDef;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @addtogroup AWU_Exported_Constants
* @{
*/
#define LSI_FREQUENCY_MIN ((uint32_t)110000) /*!< LSI minimum value in Hertz */
#define LSI_FREQUENCY_MAX ((uint32_t)150000) /*!< LSI maximum value in Hertz */
/**
* @}
*/
/* Exported macros ------------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup AWU_Private_Macros
* @{
*/
/**
* @brief Macro used by the assert function to check the different functions parameters.
*/
/**
* @brief Macro used by the assert function to check the AWU timebases
*/
#define IS_AWU_TIMEBASE_OK(TB) \
(((TB) == AWU_TIMEBASE_NO_IT) || \
((TB) == AWU_TIMEBASE_250US) || \
((TB) == AWU_TIMEBASE_500US) || \
((TB) == AWU_TIMEBASE_1MS) || \
((TB) == AWU_TIMEBASE_2MS) || \
((TB) == AWU_TIMEBASE_4MS) || \
((TB) == AWU_TIMEBASE_8MS) || \
((TB) == AWU_TIMEBASE_16MS) || \
((TB) == AWU_TIMEBASE_32MS) || \
((TB) == AWU_TIMEBASE_64MS) || \
((TB) == AWU_TIMEBASE_128MS) || \
((TB) == AWU_TIMEBASE_256MS) || \
((TB) == AWU_TIMEBASE_512MS) || \
((TB) == AWU_TIMEBASE_1S) || \
((TB) == AWU_TIMEBASE_2S) || \
((TB) == AWU_TIMEBASE_12S) || \
((TB) == AWU_TIMEBASE_30S))
/**
* @brief Macro used by the assert function to check the LSI frequency (in Hz)
*/
#define IS_LSI_FREQUENCY_OK(FREQ) \
(((FREQ) >= LSI_FREQUENCY_MIN) && \
((FREQ) <= LSI_FREQUENCY_MAX))
/**
* @}
*/
/* Exported functions ------------------------------------------------------- */
/** @addtogroup AWU_Exported_Functions
* @{
*/
void AWU_DeInit(void);
void AWU_Init(AWU_Timebase_TypeDef AWU_TimeBase);
void AWU_Cmd(FunctionalState NewState);
void AWU_LSICalibrationConfig(uint32_t LSIFreqHz);
void AWU_IdleModeEnable(void);
FlagStatus AWU_GetFlagStatus(void);
/**
* @}
*/
#endif /* __STM8S_AWU_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
d720fd9b394fe593554914fa43fb4fff1ec264a0
|
f3225136ecf40bab9061f704876999c0fc6c50ed
|
/roslz4/include/roslz4/lz4s.h
|
545e2ce6095a8f3f6198bbfa02aa5f5df490228c
|
[
"Apache-2.0"
] |
permissive
|
rospypi/simple
|
cf6cc6c9dba9b020894016e6e1d3c13620ed80c8
|
ff55829d2533a41e535a3ff5f920cf659ed94918
|
refs/heads/master
| 2023-04-29T22:17:24.572291
| 2023-04-16T23:49:25
| 2023-04-16T23:49:25
| 216,167,622
| 108
| 14
|
Apache-2.0
| 2023-04-16T23:49:26
| 2019-10-19T07:35:31
|
Python
|
UTF-8
|
C
| false
| false
| 3,759
|
h
|
lz4s.h
|
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2014, Ben Charrow
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
********************************************************************/
#ifndef ROSLZ4_LZ4S_H
#define ROSLZ4_LZ4S_H
#include <lz4.h>
#include <ros/macros.h>
// Import/export for windows dll's and visibility for gcc shared libraries.
#ifdef ROS_BUILD_SHARED_LIBS // ros is being built around shared libraries
#ifdef roslz4_EXPORTS // we are building a shared lib/dll
#define ROSLZ4S_DECL ROS_HELPER_EXPORT
#else // we are using shared lib/dll
#define ROSLZ4S_DECL ROS_HELPER_IMPORT
#endif
#else // ros is being built around static libraries
#define ROSLZ4S_DECL
#endif
#ifdef __cplusplus
extern "C" {
#endif
// Return codes
#define ROSLZ4_MEMORY_ERROR -5
#define ROSLZ4_PARAM_ERROR -4
#define ROSLZ4_DATA_ERROR -3
#define ROSLZ4_OUTPUT_SMALL -2
#define ROSLZ4_ERROR -1
#define ROSLZ4_OK 0
#define ROSLZ4_STREAM_END 2
// Actions
#define ROSLZ4_RUN 0
#define ROSLZ4_FINISH 1
typedef struct {
char *input_next;
int input_left;
char *output_next;
int output_left;
int total_in;
int total_out;
int block_size_id;
// Internal use
void *state;
} roslz4_stream;
// Low level functions
ROSLZ4S_DECL int roslz4_blockSizeFromIndex(int block_id);
ROSLZ4S_DECL int roslz4_compressStart(roslz4_stream *stream, int block_size_id);
ROSLZ4S_DECL int roslz4_compress(roslz4_stream *stream, int action);
ROSLZ4S_DECL void roslz4_compressEnd(roslz4_stream *stream);
ROSLZ4S_DECL int roslz4_decompressStart(roslz4_stream *stream);
ROSLZ4S_DECL int roslz4_decompress(roslz4_stream *stream);
ROSLZ4S_DECL void roslz4_decompressEnd(roslz4_stream *str);
// Oneshot compression / decompression
ROSLZ4S_DECL int roslz4_buffToBuffCompress(char *input, unsigned int input_size,
char *output, unsigned int *output_size,
int block_size_id);
ROSLZ4S_DECL int roslz4_buffToBuffDecompress(char *input, unsigned int input_size,
char *output, unsigned int *output_size);
#ifdef __cplusplus
}
#endif
#endif // ROSLZ4_LZ4S_H
|
8db02f448c38fabcbc499f332338ef25543ffc62
|
50dd46b8ece33f3cdd174284b15d1d51f89669d4
|
/third_party/edk2/EdkCompatibilityPkg/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h
|
00ae0a806aea263fa795ef6f9087c43fb2cb15b1
|
[
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause",
"OpenSSL"
] |
permissive
|
google/google-ctf
|
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
|
df02323eaf945d15e124801c74abaadca2749dc7
|
refs/heads/master
| 2023-08-31T14:30:27.548081
| 2023-08-29T13:04:20
| 2023-08-29T13:04:20
| 131,317,137
| 4,136
| 607
|
Apache-2.0
| 2023-08-30T22:17:02
| 2018-04-27T15:56:03
|
Go
|
UTF-8
|
C
| false
| false
| 2,361
|
h
|
LegacyRegion.h
|
/*++
Copyright (c) 1999 - 2006, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
LegacyRegion.h
Abstract:
This protocol manages the legacy memory regions between 0xc0000 - 0xfffff
Revision History
The EFI Legacy Region Protocol is compliant with CSM spec 0.96.
--*/
#ifndef _EFI_LEGACY_REGION_H_
#define _EFI_LEGACY_REGION_H_
#define EFI_LEGACY_REGION_PROTOCOL_GUID \
{ \
0xfc9013a, 0x568, 0x4ba9, {0x9b, 0x7e, 0xc9, 0xc3, 0x90, 0xa6, 0x60, 0x9b} \
}
EFI_FORWARD_DECLARATION (EFI_LEGACY_REGION_PROTOCOL);
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_REGION_DECODE) (
IN EFI_LEGACY_REGION_PROTOCOL * This,
IN UINT32 Start,
IN UINT32 Length,
IN BOOLEAN *On
);
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_REGION_LOCK) (
IN EFI_LEGACY_REGION_PROTOCOL * This,
IN UINT32 Start,
IN UINT32 Length,
OUT UINT32 *Granularity OPTIONAL
);
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_REGION_BOOT_LOCK) (
IN EFI_LEGACY_REGION_PROTOCOL * This,
IN UINT32 Start,
IN UINT32 Length,
OUT UINT32 *Granularity OPTIONAL
);
typedef
EFI_STATUS
(EFIAPI *EFI_LEGACY_REGION_UNLOCK) (
IN EFI_LEGACY_REGION_PROTOCOL * This,
IN UINT32 Start,
IN UINT32 Length,
OUT UINT32 *Granularity OPTIONAL
);
struct _EFI_LEGACY_REGION_PROTOCOL {
EFI_LEGACY_REGION_DECODE Decode;
EFI_LEGACY_REGION_LOCK Lock;
EFI_LEGACY_REGION_BOOT_LOCK BootLock;
EFI_LEGACY_REGION_UNLOCK UnLock;
};
extern EFI_GUID gEfiLegacyRegionProtocolGuid;
#endif
|
841ddcd215b0283fba63cdbf85692d46731ca55f
|
da1500e0d3040497614d5327d2461a22e934b4d8
|
/third_party/llvm-project/compiler-rt/test/builtins/Unit/ppc/qsub_test.c
|
0e00a5c820b202d808fa85d7f6be2deb43618fd9
|
[
"NCSA",
"MIT",
"LLVM-exception",
"Apache-2.0",
"BSD-3-Clause",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] |
permissive
|
youtube/cobalt
|
34085fc93972ebe05b988b15410e99845efd1968
|
acefdaaadd3ef46f10f63d1acae2259e4024d383
|
refs/heads/main
| 2023-09-01T13:09:47.225174
| 2023-09-01T08:54:54
| 2023-09-01T08:54:54
| 50,049,789
| 169
| 80
|
BSD-3-Clause
| 2023-09-14T21:50:50
| 2016-01-20T18:11:34
| null |
UTF-8
|
C
| false
| false
| 230,075
|
c
|
qsub_test.c
|
// REQUIRES: target-is-powerpc64le
// RUN: %clang_builtins %s %librt -o %t && %run %t
#include <stdio.h>
#include "DD.h"
long double __gcc_qsub(long double x, long double y);
int memcmp(const void *, const void *, __typeof__(sizeof(0)));
double testAccuracy();
int testEdgeCases();
int main(int argc, char *argv[]) {
if (testEdgeCases())
return 1;
if (testAccuracy() > 1.0)
return 1;
return 0;
}
struct testVector {
double xhi; double xlo;
double yhi; double ylo;
double rhi; double rlo;
};
#define INFINITY __builtin_inf()
#define HUGE 0x1.fffffffffffffp1023
#define QNAN __builtin_nan("")
const struct testVector edgeCases[] = {
{ 0.0, 0.0, -0.0, 0.0, 0.0, 0.0 },
{ -0.0, 0.0, -0.0, 0.0, 0.0, 0.0 },
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
{ -0.0, 0.0, 0.0, 0.0, -0.0, 0.0 },
{ INFINITY, 0.0, -0.0, 0.0, INFINITY, 0.0 },
{ -INFINITY, 0.0, -0.0, 0.0, -INFINITY, 0.0 },
{ INFINITY, 0.0, 0.0, 0.0, INFINITY, 0.0 },
{ -INFINITY, 0.0, 0.0, 0.0, -INFINITY, 0.0 },
{ INFINITY, 0.0, -1.0, 0.0, INFINITY, 0.0 },
{ -INFINITY, 0.0, -1.0, 0.0, -INFINITY, 0.0 },
{ INFINITY, 0.0, 1.0, 0.0, INFINITY, 0.0 },
{ -INFINITY, 0.0, 1.0, 0.0, -INFINITY, 0.0 },
{ INFINITY, 0.0, -HUGE, 0.0, INFINITY, 0.0 },
{ -INFINITY, 0.0, -HUGE, 0.0, -INFINITY, 0.0 },
{ INFINITY, 0.0, HUGE, 0.0, INFINITY, 0.0 },
{ -INFINITY, 0.0, HUGE, 0.0, -INFINITY, 0.0 },
{ INFINITY, 0.0, -INFINITY, 0.0, INFINITY, 0.0 },
{ -INFINITY, 0.0, -INFINITY, 0.0, QNAN, 0.0 },
{ INFINITY, 0.0, INFINITY, 0.0, QNAN, 0.0 },
{ -INFINITY, 0.0, INFINITY, 0.0, -INFINITY, 0.0 },
{ 0.0, 0.0, -INFINITY, 0.0, INFINITY, 0.0 },
{ 0.0, 0.0, INFINITY, 0.0, -INFINITY, 0.0 },
{ -0.0, 0.0, -INFINITY, 0.0, INFINITY, 0.0 },
{ -0.0, 0.0, INFINITY, 0.0, -INFINITY, 0.0 },
{ 1.0, 0.0, -INFINITY, 0.0, INFINITY, 0.0 },
{ 1.0, 0.0, INFINITY, 0.0, -INFINITY, 0.0 },
{ -1.0, 0.0, -INFINITY, 0.0, INFINITY, 0.0 },
{ -1.0, 0.0, INFINITY, 0.0, -INFINITY, 0.0 },
{ HUGE, 0.0, -INFINITY, 0.0, INFINITY, 0.0 },
{ HUGE, 0.0, INFINITY, 0.0, -INFINITY, 0.0 },
{ -HUGE, 0.0, -INFINITY, 0.0, INFINITY, 0.0 },
{ -HUGE, 0.0, INFINITY, 0.0, -INFINITY, 0.0 },
{ QNAN, 0.0, -0.0, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, -0.0, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, 0.0, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, 0.0, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, -1.0, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, -1.0, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, 1.0, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, 1.0, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, -HUGE, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, -HUGE, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, HUGE, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, HUGE, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, -INFINITY, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, -INFINITY, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, INFINITY, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, INFINITY, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ QNAN, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ -QNAN, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ 0.0, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ 0.0, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ -0.0, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ -0.0, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ 1.0, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ 1.0, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ -1.0, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ -1.0, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ HUGE, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ HUGE, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ -HUGE, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ -HUGE, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ INFINITY, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ INFINITY, 0.0, QNAN, 0.0, QNAN, 0.0 },
{ -INFINITY, 0.0, -QNAN, 0.0, QNAN, 0.0 },
{ -INFINITY, 0.0, QNAN, 0.0, QNAN, 0.0 },
};
const int numEdgeCases = sizeof(edgeCases) / sizeof(struct testVector);
int testEdgeCases() {
int i;
DD a, b, c, r;
for (i=0; i<numEdgeCases; ++i) {
a.hi = edgeCases[i].xhi;
a.lo = edgeCases[i].xlo;
b.hi = edgeCases[i].yhi;
b.lo = edgeCases[i].ylo;
r.hi = edgeCases[i].rhi;
r.lo = edgeCases[i].rlo;
int error;
long double computed = __gcc_qsub(a.ld, b.ld);
DD c = { .ld = computed };
if (r.hi != r.hi) {
if (c.hi == c.hi)
error = 1;
else if (c.lo != 0.0)
error = 1;
else
error = 0;
}
else if (r.hi == 0.0)
error = memcmp(&c, &r, sizeof(DD));
else
error = ((c.hi != r.hi) || (c.lo != r.lo));
if (error) {
printf("Error on edge case %a - %a: expected (%a, %a), got (%a, %a).\n", a.hi, b.hi, r.hi, r.lo, c.hi, c.lo);
return 1;
}
}
return 0;
}
/*
Code for generating the test cases, requires the mpfr package to run.
#include <stdio.h>
#include <stdlib.h>
#include <mpfr.h>
#ifdef __x86_64__
#define randlength 2
#else
#define randlength 4
#endif
int main(int argc, char *argv[]) {
MPFR_DECL_INIT(a, 106);
MPFR_DECL_INIT(b, 106);
MPFR_DECL_INIT(c, 106);
MPFR_DECL_INIT(tmp, 53);
int exponent_range = atoi(argv[1]);
int i;
for (i=0; i<128; ++i) {
mpfr_random2(a, randlength, exponent_range);
mpfr_random2(b, randlength, exponent_range);
mpfr_add(c, a, b, GMP_RNDN);
double ahi = mpfr_get_d(a, GMP_RNDN);
mpfr_set_d(tmp, ahi, GMP_RNDN);
mpfr_sub(tmp, a, tmp, GMP_RNDN);
double alo = mpfr_get_d(tmp, GMP_RNDN);
printf("{%0.13a, %0.13a, ", ahi, alo);
double bhi = mpfr_get_d(b, GMP_RNDN);
mpfr_set_d(tmp, bhi, GMP_RNDN);
mpfr_sub(tmp, b, tmp, GMP_RNDN);
double blo = mpfr_get_d(tmp, GMP_RNDN);
printf("%0.13a, %0.13a, ", bhi, blo);
double chi = mpfr_get_d(c, GMP_RNDN);
mpfr_set_d(tmp, chi, GMP_RNDN);
mpfr_sub(tmp, c, tmp, GMP_RNDN);
double clo = mpfr_get_d(tmp, GMP_RNDN);
printf("%0.13a, %0.13a},\n", chi, clo);
mpfr_neg(b, b, GMP_RNDN);
mpfr_add(c, a, b, GMP_RNDN);
ahi = mpfr_get_d(a, GMP_RNDN);
mpfr_set_d(tmp, ahi, GMP_RNDN);
mpfr_sub(tmp, a, tmp, GMP_RNDN);
alo = mpfr_get_d(tmp, GMP_RNDN);
printf("{%0.13a, %0.13a, ", ahi, alo);
bhi = mpfr_get_d(b, GMP_RNDN);
mpfr_set_d(tmp, bhi, GMP_RNDN);
mpfr_sub(tmp, b, tmp, GMP_RNDN);
blo = mpfr_get_d(tmp, GMP_RNDN);
printf("%0.13a, %0.13a, ", bhi, blo);
chi = mpfr_get_d(c, GMP_RNDN);
mpfr_set_d(tmp, chi, GMP_RNDN);
mpfr_sub(tmp, c, tmp, GMP_RNDN);
clo = mpfr_get_d(tmp, GMP_RNDN);
printf("%0.13a, %0.13a},\n", chi, clo);
mpfr_neg(a, a, GMP_RNDN);
mpfr_neg(b, b, GMP_RNDN);
mpfr_add(c, a, b, GMP_RNDN);
ahi = mpfr_get_d(a, GMP_RNDN);
mpfr_set_d(tmp, ahi, GMP_RNDN);
mpfr_sub(tmp, a, tmp, GMP_RNDN);
alo = mpfr_get_d(tmp, GMP_RNDN);
printf("{%0.13a, %0.13a, ", ahi, alo);
bhi = mpfr_get_d(b, GMP_RNDN);
mpfr_set_d(tmp, bhi, GMP_RNDN);
mpfr_sub(tmp, b, tmp, GMP_RNDN);
blo = mpfr_get_d(tmp, GMP_RNDN);
printf("%0.13a, %0.13a, ", bhi, blo);
chi = mpfr_get_d(c, GMP_RNDN);
mpfr_set_d(tmp, chi, GMP_RNDN);
mpfr_sub(tmp, c, tmp, GMP_RNDN);
clo = mpfr_get_d(tmp, GMP_RNDN);
printf("%0.13a, %0.13a},\n", chi, clo);
mpfr_neg(b, b, GMP_RNDN);
mpfr_add(c, a, b, GMP_RNDN);
ahi = mpfr_get_d(a, GMP_RNDN);
mpfr_set_d(tmp, ahi, GMP_RNDN);
mpfr_sub(tmp, a, tmp, GMP_RNDN);
alo = mpfr_get_d(tmp, GMP_RNDN);
printf("{%0.13a, %0.13a, ", ahi, alo);
bhi = mpfr_get_d(b, GMP_RNDN);
mpfr_set_d(tmp, bhi, GMP_RNDN);
mpfr_sub(tmp, b, tmp, GMP_RNDN);
blo = mpfr_get_d(tmp, GMP_RNDN);
printf("%0.13a, %0.13a, ", bhi, blo);
chi = mpfr_get_d(c, GMP_RNDN);
mpfr_set_d(tmp, chi, GMP_RNDN);
mpfr_sub(tmp, c, tmp, GMP_RNDN);
clo = mpfr_get_d(tmp, GMP_RNDN);
printf("%0.13a, %0.13a},\n", chi, clo);
}
return 0;
}
*/
const struct testVector accuracyTests[] = {
// Some test cases that cover the whole exponent range:
{0x1.0000000000002p+366, -0x1.ffc0ffff90000p+302, 0x1.0003ffffffffcp+140, 0x1.ffffc00000000p+53, 0x1.0000000000002p+366, -0x1.ffc0ffff90000p+302},
{0x1.0000000000002p+366, -0x1.ffc0ffff90000p+302, -0x1.0003ffffffffcp+140, -0x1.ffffc00000000p+53, 0x1.0000000000002p+366, -0x1.ffc0ffff90000p+302},
{-0x1.0000000000002p+366, 0x1.ffc0ffff90000p+302, 0x1.0003ffffffffcp+140, 0x1.ffffc00000000p+53, -0x1.0000000000002p+366, 0x1.ffc0ffff90000p+302},
{-0x1.0000000000002p+366, 0x1.ffc0ffff90000p+302, -0x1.0003ffffffffcp+140, -0x1.ffffc00000000p+53, -0x1.0000000000002p+366, 0x1.ffc0ffff90000p+302},
{0x1.0000100000000p-746, -0x1.0000000000000p-808, 0x1.0000000004000p-636, -0x1.ffffe00fc0200p-692, 0x1.0000000004000p-636, -0x1.ffffe00fc0200p-692},
{0x1.0000100000000p-746, -0x1.0000000000000p-808, -0x1.0000000004000p-636, 0x1.ffffe00fc0200p-692, -0x1.0000000004000p-636, 0x1.ffffe00fc0200p-692},
{-0x1.0000100000000p-746, 0x1.0000000000000p-808, 0x1.0000000004000p-636, -0x1.ffffe00fc0200p-692, 0x1.0000000004000p-636, -0x1.ffffe00fc0200p-692},
{-0x1.0000100000000p-746, 0x1.0000000000000p-808, -0x1.0000000004000p-636, 0x1.ffffe00fc0200p-692, -0x1.0000000004000p-636, 0x1.ffffe00fc0200p-692},
{0x1.0000000800000p+426, -0x1.0000000000000p+354, 0x1.000003fffc002p-730, -0x1.0000000000000p-835, 0x1.0000000800000p+426, -0x1.0000000000000p+354},
{0x1.0000000800000p+426, -0x1.0000000000000p+354, -0x1.000003fffc002p-730, 0x1.0000000000000p-835, 0x1.0000000800000p+426, -0x1.0000000000000p+354},
{-0x1.0000000800000p+426, 0x1.0000000000000p+354, 0x1.000003fffc002p-730, -0x1.0000000000000p-835, -0x1.0000000800000p+426, 0x1.0000000000000p+354},
{-0x1.0000000800000p+426, 0x1.0000000000000p+354, -0x1.000003fffc002p-730, 0x1.0000000000000p-835, -0x1.0000000800000p+426, 0x1.0000000000000p+354},
{0x1.0000000000000p-262, 0x1.ffc001ffffe00p-317, 0x1.000003fff8000p-258, 0x1.fffc000fc0000p-329, 0x1.100003fff8000p-258, 0x1.ffe001c000dc0p-317},
{0x1.0000000000000p-262, 0x1.ffc001ffffe00p-317, -0x1.000003fff8000p-258, -0x1.fffc000fc0000p-329, -0x1.e00007fff0000p-259, 0x1.ffa0023ffee40p-317},
{-0x1.0000000000000p-262, -0x1.ffc001ffffe00p-317, 0x1.000003fff8000p-258, 0x1.fffc000fc0000p-329, 0x1.e00007fff0000p-259, -0x1.ffa0023ffee40p-317},
{-0x1.0000000000000p-262, -0x1.ffc001ffffe00p-317, -0x1.000003fff8000p-258, -0x1.fffc000fc0000p-329, -0x1.100003fff8000p-258, -0x1.ffe001c000dc0p-317},
{0x1.0000000000003p+980, 0x1.fc00001fff800p+916, 0x1.0000000000020p+626, -0x1.fc01ffe002000p+562, 0x1.0000000000003p+980, 0x1.fc00001fff800p+916},
{0x1.0000000000003p+980, 0x1.fc00001fff800p+916, -0x1.0000000000020p+626, 0x1.fc01ffe002000p+562, 0x1.0000000000003p+980, 0x1.fc00001fff800p+916},
{-0x1.0000000000003p+980, -0x1.fc00001fff800p+916, 0x1.0000000000020p+626, -0x1.fc01ffe002000p+562, -0x1.0000000000003p+980, -0x1.fc00001fff800p+916},
{-0x1.0000000000003p+980, -0x1.fc00001fff800p+916, -0x1.0000000000020p+626, 0x1.fc01ffe002000p+562, -0x1.0000000000003p+980, -0x1.fc00001fff800p+916},
{0x1.0000000000000p-800, 0x1.fffff00001ffep-854, 0x1.0000000000000p+470, 0x1.ff00000ffff80p+410, 0x1.0000000000000p+470, 0x1.ff00000ffff80p+410},
{0x1.0000000000000p-800, 0x1.fffff00001ffep-854, -0x1.0000000000000p+470, -0x1.ff00000ffff80p+410, -0x1.0000000000000p+470, -0x1.ff00000ffff80p+410},
{-0x1.0000000000000p-800, -0x1.fffff00001ffep-854, 0x1.0000000000000p+470, 0x1.ff00000ffff80p+410, 0x1.0000000000000p+470, 0x1.ff00000ffff80p+410},
{-0x1.0000000000000p-800, -0x1.fffff00001ffep-854, -0x1.0000000000000p+470, -0x1.ff00000ffff80p+410, -0x1.0000000000000p+470, -0x1.ff00000ffff80p+410},
{0x1.0000000000000p+925, 0x1.ffffffffffc00p+862, 0x1.0000200000000p-454, -0x1.ffc0000080000p-526, 0x1.0000000000000p+925, 0x1.ffffffffffc00p+862},
{0x1.0000000000000p+925, 0x1.ffffffffffc00p+862, -0x1.0000200000000p-454, 0x1.ffc0000080000p-526, 0x1.0000000000000p+925, 0x1.ffffffffffc00p+862},
{-0x1.0000000000000p+925, -0x1.ffffffffffc00p+862, 0x1.0000200000000p-454, -0x1.ffc0000080000p-526, -0x1.0000000000000p+925, -0x1.ffffffffffc00p+862},
{-0x1.0000000000000p+925, -0x1.ffffffffffc00p+862, -0x1.0000200000000p-454, 0x1.ffc0000080000p-526, -0x1.0000000000000p+925, -0x1.ffffffffffc00p+862},
{0x1.0000000000800p+265, -0x1.fffc000000010p+208, 0x1.0000000000008p-204, -0x1.ffe03fffff010p-261, 0x1.0000000000800p+265, -0x1.fffc000000010p+208},
{0x1.0000000000800p+265, -0x1.fffc000000010p+208, -0x1.0000000000008p-204, 0x1.ffe03fffff010p-261, 0x1.0000000000800p+265, -0x1.fffc000000010p+208},
{-0x1.0000000000800p+265, 0x1.fffc000000010p+208, 0x1.0000000000008p-204, -0x1.ffe03fffff010p-261, -0x1.0000000000800p+265, 0x1.fffc000000010p+208},
{-0x1.0000000000800p+265, 0x1.fffc000000010p+208, -0x1.0000000000008p-204, 0x1.ffe03fffff010p-261, -0x1.0000000000800p+265, 0x1.fffc000000010p+208},
{0x1.0000000000000p-690, 0x1.fffef0ffff000p-753, 0x1.0000100000000p+763, -0x1.fff8000000800p+699, 0x1.0000100000000p+763, -0x1.fff8000000800p+699},
{0x1.0000000000000p-690, 0x1.fffef0ffff000p-753, -0x1.0000100000000p+763, 0x1.fff8000000800p+699, -0x1.0000100000000p+763, 0x1.fff8000000800p+699},
{-0x1.0000000000000p-690, -0x1.fffef0ffff000p-753, 0x1.0000100000000p+763, -0x1.fff8000000800p+699, 0x1.0000100000000p+763, -0x1.fff8000000800p+699},
{-0x1.0000000000000p-690, -0x1.fffef0ffff000p-753, -0x1.0000100000000p+763, 0x1.fff8000000800p+699, -0x1.0000100000000p+763, 0x1.fff8000000800p+699},
{0x1.07c00007ffff0p-506, 0x1.fffc00f800000p-582, 0x1.0000007ffffe0p-302, 0x1.f000000000000p-373, 0x1.0000007ffffe0p-302, 0x1.f000000000000p-373},
{0x1.07c00007ffff0p-506, 0x1.fffc00f800000p-582, -0x1.0000007ffffe0p-302, -0x1.f000000000000p-373, -0x1.0000007ffffe0p-302, -0x1.f000000000000p-373},
{-0x1.07c00007ffff0p-506, -0x1.fffc00f800000p-582, 0x1.0000007ffffe0p-302, 0x1.f000000000000p-373, 0x1.0000007ffffe0p-302, 0x1.f000000000000p-373},
{-0x1.07c00007ffff0p-506, -0x1.fffc00f800000p-582, -0x1.0000007ffffe0p-302, -0x1.f000000000000p-373, -0x1.0000007ffffe0p-302, -0x1.f000000000000p-373},
{0x1.0000000000000p-958, 0x1.ff800fffff800p-1014, 0x1.0000000000000p+373, 0x1.fffc0000ffff8p+317, 0x1.0000000000000p+373, 0x1.fffc0000ffff8p+317},
{0x1.0000000000000p-958, 0x1.ff800fffff800p-1014, -0x1.0000000000000p+373, -0x1.fffc0000ffff8p+317, -0x1.0000000000000p+373, -0x1.fffc0000ffff8p+317},
{-0x1.0000000000000p-958, -0x1.ff800fffff800p-1014, 0x1.0000000000000p+373, 0x1.fffc0000ffff8p+317, 0x1.0000000000000p+373, 0x1.fffc0000ffff8p+317},
{-0x1.0000000000000p-958, -0x1.ff800fffff800p-1014, -0x1.0000000000000p+373, -0x1.fffc0000ffff8p+317, -0x1.0000000000000p+373, -0x1.fffc0000ffff8p+317},
{0x1.0000000008000p+114, -0x1.ffff807ffe002p+60, 0x1.0000000800000p-783, -0x1.ffffff8000008p-839, 0x1.0000000008000p+114, -0x1.ffff807ffe002p+60},
{0x1.0000000008000p+114, -0x1.ffff807ffe002p+60, -0x1.0000000800000p-783, 0x1.ffffff8000008p-839, 0x1.0000000008000p+114, -0x1.ffff807ffe002p+60},
{-0x1.0000000008000p+114, 0x1.ffff807ffe002p+60, 0x1.0000000800000p-783, -0x1.ffffff8000008p-839, -0x1.0000000008000p+114, 0x1.ffff807ffe002p+60},
{-0x1.0000000008000p+114, 0x1.ffff807ffe002p+60, -0x1.0000000800000p-783, 0x1.ffffff8000008p-839, -0x1.0000000008000p+114, 0x1.ffff807ffe002p+60},
{0x1.0000000000020p+340, -0x1.0000000000000p+257, 0x1.0000000000000p-442, 0x1.fffff000003c0p-501, 0x1.0000000000020p+340, -0x1.0000000000000p+257},
{0x1.0000000000020p+340, -0x1.0000000000000p+257, -0x1.0000000000000p-442, -0x1.fffff000003c0p-501, 0x1.0000000000020p+340, -0x1.0000000000000p+257},
{-0x1.0000000000020p+340, 0x1.0000000000000p+257, 0x1.0000000000000p-442, 0x1.fffff000003c0p-501, -0x1.0000000000020p+340, 0x1.0000000000000p+257},
{-0x1.0000000000020p+340, 0x1.0000000000000p+257, -0x1.0000000000000p-442, -0x1.fffff000003c0p-501, -0x1.0000000000020p+340, 0x1.0000000000000p+257},
{0x1.0000001ffff80p+385, 0x1.fffffdfffff8ep+331, 0x1.0000000200000p+69, -0x1.0000000000000p+0, 0x1.0000001ffff80p+385, 0x1.fffffdfffff8ep+331},
{0x1.0000001ffff80p+385, 0x1.fffffdfffff8ep+331, -0x1.0000000200000p+69, 0x1.0000000000000p+0, 0x1.0000001ffff80p+385, 0x1.fffffdfffff8ep+331},
{-0x1.0000001ffff80p+385, -0x1.fffffdfffff8ep+331, 0x1.0000000200000p+69, -0x1.0000000000000p+0, -0x1.0000001ffff80p+385, -0x1.fffffdfffff8ep+331},
{-0x1.0000001ffff80p+385, -0x1.fffffdfffff8ep+331, -0x1.0000000200000p+69, 0x1.0000000000000p+0, -0x1.0000001ffff80p+385, -0x1.fffffdfffff8ep+331},
{0x1.01ffffff80400p-140, -0x1.c7ffffc000100p-198, 0x1.0000000000000p-934, 0x1.8fff01fffff00p-994, 0x1.01ffffff80400p-140, -0x1.c7ffffc000100p-198},
{0x1.01ffffff80400p-140, -0x1.c7ffffc000100p-198, -0x1.0000000000000p-934, -0x1.8fff01fffff00p-994, 0x1.01ffffff80400p-140, -0x1.c7ffffc000100p-198},
{-0x1.01ffffff80400p-140, 0x1.c7ffffc000100p-198, 0x1.0000000000000p-934, 0x1.8fff01fffff00p-994, -0x1.01ffffff80400p-140, 0x1.c7ffffc000100p-198},
{-0x1.01ffffff80400p-140, 0x1.c7ffffc000100p-198, -0x1.0000000000000p-934, -0x1.8fff01fffff00p-994, -0x1.01ffffff80400p-140, 0x1.c7ffffc000100p-198},
{0x1.0000000000008p+975, -0x1.ffffc00800000p+902, 0x1.00003ffe00002p-979, -0x1.ffffffc180000p-1039, 0x1.0000000000008p+975, -0x1.ffffc00800000p+902},
{0x1.0000000000008p+975, -0x1.ffffc00800000p+902, -0x1.00003ffe00002p-979, 0x1.ffffffc180000p-1039, 0x1.0000000000008p+975, -0x1.ffffc00800000p+902},
{-0x1.0000000000008p+975, 0x1.ffffc00800000p+902, 0x1.00003ffe00002p-979, -0x1.ffffffc180000p-1039, -0x1.0000000000008p+975, 0x1.ffffc00800000p+902},
{-0x1.0000000000008p+975, 0x1.ffffc00800000p+902, -0x1.00003ffe00002p-979, 0x1.ffffffc180000p-1039, -0x1.0000000000008p+975, 0x1.ffffc00800000p+902},
{0x1.000000ffffff8p+56, 0x1.ffffffc000000p-1, 0x1.0000000000000p-40, 0x1.ffffffe000000p-98, 0x1.000000ffffff8p+56, 0x1.ffffffc002000p-1},
{0x1.000000ffffff8p+56, 0x1.ffffffc000000p-1, -0x1.0000000000000p-40, -0x1.ffffffe000000p-98, 0x1.000000ffffff8p+56, 0x1.ffffffbffe000p-1},
{-0x1.000000ffffff8p+56, -0x1.ffffffc000000p-1, 0x1.0000000000000p-40, 0x1.ffffffe000000p-98, -0x1.000000ffffff8p+56, -0x1.ffffffbffe000p-1},
{-0x1.000000ffffff8p+56, -0x1.ffffffc000000p-1, -0x1.0000000000000p-40, -0x1.ffffffe000000p-98, -0x1.000000ffffff8p+56, -0x1.ffffffc002000p-1},
{0x1.0000000020000p-764, -0x1.0000000000000p-869, 0x1.0000000000400p-403, -0x1.ff1ffffff4000p-470, 0x1.0000000000400p-403, -0x1.ff1ffffff4000p-470},
{0x1.0000000020000p-764, -0x1.0000000000000p-869, -0x1.0000000000400p-403, 0x1.ff1ffffff4000p-470, -0x1.0000000000400p-403, 0x1.ff1ffffff4000p-470},
{-0x1.0000000020000p-764, 0x1.0000000000000p-869, 0x1.0000000000400p-403, -0x1.ff1ffffff4000p-470, 0x1.0000000000400p-403, -0x1.ff1ffffff4000p-470},
{-0x1.0000000020000p-764, 0x1.0000000000000p-869, -0x1.0000000000400p-403, 0x1.ff1ffffff4000p-470, -0x1.0000000000400p-403, 0x1.ff1ffffff4000p-470},
{0x1.0000ff8020000p-469, -0x1.fffffa0000000p-531, 0x1.0000000001ff0p-14, 0x1.f700000ffe000p-80, 0x1.0000000001ff0p-14, 0x1.f700000ffe000p-80},
{0x1.0000ff8020000p-469, -0x1.fffffa0000000p-531, -0x1.0000000001ff0p-14, -0x1.f700000ffe000p-80, -0x1.0000000001ff0p-14, -0x1.f700000ffe000p-80},
{-0x1.0000ff8020000p-469, 0x1.fffffa0000000p-531, 0x1.0000000001ff0p-14, 0x1.f700000ffe000p-80, 0x1.0000000001ff0p-14, 0x1.f700000ffe000p-80},
{-0x1.0000ff8020000p-469, 0x1.fffffa0000000p-531, -0x1.0000000001ff0p-14, -0x1.f700000ffe000p-80, -0x1.0000000001ff0p-14, -0x1.f700000ffe000p-80},
{0x1.0000020000000p+518, -0x1.0000000000000p+454, 0x1.003e00001f800p+772, 0x1.ffde000001e00p+710, 0x1.003e00001f800p+772, 0x1.ffde000001e00p+710},
{0x1.0000020000000p+518, -0x1.0000000000000p+454, -0x1.003e00001f800p+772, -0x1.ffde000001e00p+710, -0x1.003e00001f800p+772, -0x1.ffde000001e00p+710},
{-0x1.0000020000000p+518, 0x1.0000000000000p+454, 0x1.003e00001f800p+772, 0x1.ffde000001e00p+710, 0x1.003e00001f800p+772, 0x1.ffde000001e00p+710},
{-0x1.0000020000000p+518, 0x1.0000000000000p+454, -0x1.003e00001f800p+772, -0x1.ffde000001e00p+710, -0x1.003e00001f800p+772, -0x1.ffde000001e00p+710},
{0x1.0007e3ffe0000p-546, 0x1.fe0ffffffe000p-610, 0x1.0000000000000p+567, 0x1.fffffe07fff00p+506, 0x1.0000000000000p+567, 0x1.fffffe07fff00p+506},
{0x1.0007e3ffe0000p-546, 0x1.fe0ffffffe000p-610, -0x1.0000000000000p+567, -0x1.fffffe07fff00p+506, -0x1.0000000000000p+567, -0x1.fffffe07fff00p+506},
{-0x1.0007e3ffe0000p-546, -0x1.fe0ffffffe000p-610, 0x1.0000000000000p+567, 0x1.fffffe07fff00p+506, 0x1.0000000000000p+567, 0x1.fffffe07fff00p+506},
{-0x1.0007e3ffe0000p-546, -0x1.fe0ffffffe000p-610, -0x1.0000000000000p+567, -0x1.fffffe07fff00p+506, -0x1.0000000000000p+567, -0x1.fffffe07fff00p+506},
{0x1.00000000fe000p-853, 0x1.ff00004000000p-920, 0x1.000003fffff80p+382, 0x1.fff8400000000p+322, 0x1.000003fffff80p+382, 0x1.fff8400000000p+322},
{0x1.00000000fe000p-853, 0x1.ff00004000000p-920, -0x1.000003fffff80p+382, -0x1.fff8400000000p+322, -0x1.000003fffff80p+382, -0x1.fff8400000000p+322},
{-0x1.00000000fe000p-853, -0x1.ff00004000000p-920, 0x1.000003fffff80p+382, 0x1.fff8400000000p+322, 0x1.000003fffff80p+382, 0x1.fff8400000000p+322},
{-0x1.00000000fe000p-853, -0x1.ff00004000000p-920, -0x1.000003fffff80p+382, -0x1.fff8400000000p+322, -0x1.000003fffff80p+382, -0x1.fff8400000000p+322},
{0x1.0000800000000p-529, -0x1.0000000000000p-585, 0x1.0000000000000p-716, 0x1.fffffffc1fc00p-779, 0x1.0000800000000p-529, -0x1.0000000000000p-585},
{0x1.0000800000000p-529, -0x1.0000000000000p-585, -0x1.0000000000000p-716, -0x1.fffffffc1fc00p-779, 0x1.0000800000000p-529, -0x1.0000000000000p-585},
{-0x1.0000800000000p-529, 0x1.0000000000000p-585, 0x1.0000000000000p-716, 0x1.fffffffc1fc00p-779, -0x1.0000800000000p-529, 0x1.0000000000000p-585},
{-0x1.0000800000000p-529, 0x1.0000000000000p-585, -0x1.0000000000000p-716, -0x1.fffffffc1fc00p-779, -0x1.0000800000000p-529, 0x1.0000000000000p-585},
{0x1.0000000000000p+545, 0x1.ff000ff3ffe00p+491, 0x1.0000000000000p-565, 0x1.fe0003fffc000p-624, 0x1.0000000000000p+545, 0x1.ff000ff3ffe00p+491},
{0x1.0000000000000p+545, 0x1.ff000ff3ffe00p+491, -0x1.0000000000000p-565, -0x1.fe0003fffc000p-624, 0x1.0000000000000p+545, 0x1.ff000ff3ffe00p+491},
{-0x1.0000000000000p+545, -0x1.ff000ff3ffe00p+491, 0x1.0000000000000p-565, 0x1.fe0003fffc000p-624, -0x1.0000000000000p+545, -0x1.ff000ff3ffe00p+491},
{-0x1.0000000000000p+545, -0x1.ff000ff3ffe00p+491, -0x1.0000000000000p-565, -0x1.fe0003fffc000p-624, -0x1.0000000000000p+545, -0x1.ff000ff3ffe00p+491},
{0x1.000000e000010p-739, -0x1.ffffffc020000p-809, 0x1.00000001f0000p+66, 0x1.8000000000000p-38, 0x1.00000001f0000p+66, 0x1.8000000000000p-38},
{0x1.000000e000010p-739, -0x1.ffffffc020000p-809, -0x1.00000001f0000p+66, -0x1.8000000000000p-38, -0x1.00000001f0000p+66, -0x1.8000000000000p-38},
{-0x1.000000e000010p-739, 0x1.ffffffc020000p-809, 0x1.00000001f0000p+66, 0x1.8000000000000p-38, 0x1.00000001f0000p+66, 0x1.8000000000000p-38},
{-0x1.000000e000010p-739, 0x1.ffffffc020000p-809, -0x1.00000001f0000p+66, -0x1.8000000000000p-38, -0x1.00000001f0000p+66, -0x1.8000000000000p-38},
{0x1.000003ff00000p-980, 0x1.8000000000000p-1057, 0x1.0001ffffe0000p-313, 0x1.f800000100000p-386, 0x1.0001ffffe0000p-313, 0x1.f800000100000p-386},
{0x1.000003ff00000p-980, 0x1.8000000000000p-1057, -0x1.0001ffffe0000p-313, -0x1.f800000100000p-386, -0x1.0001ffffe0000p-313, -0x1.f800000100000p-386},
{-0x1.000003ff00000p-980, -0x1.8000000000000p-1057, 0x1.0001ffffe0000p-313, 0x1.f800000100000p-386, 0x1.0001ffffe0000p-313, 0x1.f800000100000p-386},
{-0x1.000003ff00000p-980, -0x1.8000000000000p-1057, -0x1.0001ffffe0000p-313, -0x1.f800000100000p-386, -0x1.0001ffffe0000p-313, -0x1.f800000100000p-386},
{0x1.0000000000200p+292, -0x1.ffffffffffc08p+236, 0x1.0000000000000p-660, 0x1.ffffffffffffep-714, 0x1.0000000000200p+292, -0x1.ffffffffffc08p+236},
{0x1.0000000000200p+292, -0x1.ffffffffffc08p+236, -0x1.0000000000000p-660, -0x1.ffffffffffffep-714, 0x1.0000000000200p+292, -0x1.ffffffffffc08p+236},
{-0x1.0000000000200p+292, 0x1.ffffffffffc08p+236, 0x1.0000000000000p-660, 0x1.ffffffffffffep-714, -0x1.0000000000200p+292, 0x1.ffffffffffc08p+236},
{-0x1.0000000000200p+292, 0x1.ffffffffffc08p+236, -0x1.0000000000000p-660, -0x1.ffffffffffffep-714, -0x1.0000000000200p+292, 0x1.ffffffffffc08p+236},
{0x1.0000000040000p-475, -0x1.fffff80002000p-541, 0x1.0000000000000p-741, 0x1.ffc01ffff3c00p-804, 0x1.0000000040000p-475, -0x1.fffff80002000p-541},
{0x1.0000000040000p-475, -0x1.fffff80002000p-541, -0x1.0000000000000p-741, -0x1.ffc01ffff3c00p-804, 0x1.0000000040000p-475, -0x1.fffff80002000p-541},
{-0x1.0000000040000p-475, 0x1.fffff80002000p-541, 0x1.0000000000000p-741, 0x1.ffc01ffff3c00p-804, -0x1.0000000040000p-475, 0x1.fffff80002000p-541},
{-0x1.0000000040000p-475, 0x1.fffff80002000p-541, -0x1.0000000000000p-741, -0x1.ffc01ffff3c00p-804, -0x1.0000000040000p-475, 0x1.fffff80002000p-541},
{0x1.0000800000000p+1022, -0x1.0000000000000p+917, 0x1.0000003800001p-290, 0x1.fffffe000003ep-344, 0x1.0000800000000p+1022, -0x1.0000000000000p+917},
{0x1.0000800000000p+1022, -0x1.0000000000000p+917, -0x1.0000003800001p-290, -0x1.fffffe000003ep-344, 0x1.0000800000000p+1022, -0x1.0000000000000p+917},
{-0x1.0000800000000p+1022, 0x1.0000000000000p+917, 0x1.0000003800001p-290, 0x1.fffffe000003ep-344, -0x1.0000800000000p+1022, 0x1.0000000000000p+917},
{-0x1.0000800000000p+1022, 0x1.0000000000000p+917, -0x1.0000003800001p-290, -0x1.fffffe000003ep-344, -0x1.0000800000000p+1022, 0x1.0000000000000p+917},
{0x1.0f00000020000p-425, -0x1.fffe000000100p-479, 0x1.0000000400000p-527, -0x1.ffffffc004000p-594, 0x1.0f00000020000p-425, -0x1.fffe0000000f0p-479},
{0x1.0f00000020000p-425, -0x1.fffe000000100p-479, -0x1.0000000400000p-527, 0x1.ffffffc004000p-594, 0x1.0f00000020000p-425, -0x1.fffe000000110p-479},
{-0x1.0f00000020000p-425, 0x1.fffe000000100p-479, 0x1.0000000400000p-527, -0x1.ffffffc004000p-594, -0x1.0f00000020000p-425, 0x1.fffe000000110p-479},
{-0x1.0f00000020000p-425, 0x1.fffe000000100p-479, -0x1.0000000400000p-527, 0x1.ffffffc004000p-594, -0x1.0f00000020000p-425, 0x1.fffe0000000f0p-479},
{0x1.003fe00020000p+720, -0x1.ffffffffe8000p+652, 0x1.0000000000400p+142, -0x1.ffff800007ffcp+87, 0x1.003fe00020000p+720, -0x1.ffffffffe8000p+652},
{0x1.003fe00020000p+720, -0x1.ffffffffe8000p+652, -0x1.0000000000400p+142, 0x1.ffff800007ffcp+87, 0x1.003fe00020000p+720, -0x1.ffffffffe8000p+652},
{-0x1.003fe00020000p+720, 0x1.ffffffffe8000p+652, 0x1.0000000000400p+142, -0x1.ffff800007ffcp+87, -0x1.003fe00020000p+720, 0x1.ffffffffe8000p+652},
{-0x1.003fe00020000p+720, 0x1.ffffffffe8000p+652, -0x1.0000000000400p+142, 0x1.ffff800007ffcp+87, -0x1.003fe00020000p+720, 0x1.ffffffffe8000p+652},
{0x1.ffff00fffffc4p+71, -0x1.8080000000000p-11, 0x1.0000020000000p-926, -0x1.0000000000000p-1002, 0x1.ffff00fffffc4p+71, -0x1.8080000000000p-11},
{0x1.ffff00fffffc4p+71, -0x1.8080000000000p-11, -0x1.0000020000000p-926, 0x1.0000000000000p-1002, 0x1.ffff00fffffc4p+71, -0x1.8080000000000p-11},
{-0x1.ffff00fffffc4p+71, 0x1.8080000000000p-11, 0x1.0000020000000p-926, -0x1.0000000000000p-1002, -0x1.ffff00fffffc4p+71, 0x1.8080000000000p-11},
{-0x1.ffff00fffffc4p+71, 0x1.8080000000000p-11, -0x1.0000020000000p-926, 0x1.0000000000000p-1002, -0x1.ffff00fffffc4p+71, 0x1.8080000000000p-11},
{0x1.0000000000040p-915, -0x1.8000000800000p-990, 0x1.0000000002000p-454, -0x1.0000000000000p-558, 0x1.0000000002000p-454, -0x1.0000000000000p-558},
{0x1.0000000000040p-915, -0x1.8000000800000p-990, -0x1.0000000002000p-454, 0x1.0000000000000p-558, -0x1.0000000002000p-454, 0x1.0000000000000p-558},
{-0x1.0000000000040p-915, 0x1.8000000800000p-990, 0x1.0000000002000p-454, -0x1.0000000000000p-558, 0x1.0000000002000p-454, -0x1.0000000000000p-558},
{-0x1.0000000000040p-915, 0x1.8000000800000p-990, -0x1.0000000002000p-454, 0x1.0000000000000p-558, -0x1.0000000002000p-454, 0x1.0000000000000p-558},
{0x1.0000000800000p-123, -0x1.ffffc02000000p-201, 0x1.7fffe00800000p+593, -0x1.0000000000000p+488, 0x1.7fffe00800000p+593, -0x1.0000000000000p+488},
{0x1.0000000800000p-123, -0x1.ffffc02000000p-201, -0x1.7fffe00800000p+593, 0x1.0000000000000p+488, -0x1.7fffe00800000p+593, 0x1.0000000000000p+488},
{-0x1.0000000800000p-123, 0x1.ffffc02000000p-201, 0x1.7fffe00800000p+593, -0x1.0000000000000p+488, 0x1.7fffe00800000p+593, -0x1.0000000000000p+488},
{-0x1.0000000800000p-123, 0x1.ffffc02000000p-201, -0x1.7fffe00800000p+593, 0x1.0000000000000p+488, -0x1.7fffe00800000p+593, 0x1.0000000000000p+488},
{0x1.0000400000000p+352, -0x1.0000000000000p+261, 0x1.4000000000000p-216, -0x1.ffffffff00020p-274, 0x1.0000400000000p+352, -0x1.0000000000000p+261},
{0x1.0000400000000p+352, -0x1.0000000000000p+261, -0x1.4000000000000p-216, 0x1.ffffffff00020p-274, 0x1.0000400000000p+352, -0x1.0000000000000p+261},
{-0x1.0000400000000p+352, 0x1.0000000000000p+261, 0x1.4000000000000p-216, -0x1.ffffffff00020p-274, -0x1.0000400000000p+352, 0x1.0000000000000p+261},
{-0x1.0000400000000p+352, 0x1.0000000000000p+261, -0x1.4000000000000p-216, 0x1.ffffffff00020p-274, -0x1.0000400000000p+352, 0x1.0000000000000p+261},
{0x1.0000000000000p-714, 0x1.03eff7ff3fff0p-771, 0x1.00001fffc0000p-889, 0x1.f80001f000f80p-949, 0x1.0000000000000p-714, 0x1.03eff7ff3fff0p-771},
{0x1.0000000000000p-714, 0x1.03eff7ff3fff0p-771, -0x1.00001fffc0000p-889, -0x1.f80001f000f80p-949, 0x1.0000000000000p-714, 0x1.03eff7ff3fff0p-771},
{-0x1.0000000000000p-714, -0x1.03eff7ff3fff0p-771, 0x1.00001fffc0000p-889, 0x1.f80001f000f80p-949, -0x1.0000000000000p-714, -0x1.03eff7ff3fff0p-771},
{-0x1.0000000000000p-714, -0x1.03eff7ff3fff0p-771, -0x1.00001fffc0000p-889, -0x1.f80001f000f80p-949, -0x1.0000000000000p-714, -0x1.03eff7ff3fff0p-771},
{0x1.03ffffffffffep-517, 0x1.8000000000000p-621, 0x1.0000040000000p-478, -0x1.0000000000000p-583, 0x1.0000040002080p-478, -0x1.0002000000000p-568},
{0x1.03ffffffffffep-517, 0x1.8000000000000p-621, -0x1.0000040000000p-478, 0x1.0000000000000p-583, -0x1.000003fffdf80p-478, -0x1.fffc000000000p-569},
{-0x1.03ffffffffffep-517, -0x1.8000000000000p-621, 0x1.0000040000000p-478, -0x1.0000000000000p-583, 0x1.000003fffdf80p-478, 0x1.fffc000000000p-569},
{-0x1.03ffffffffffep-517, -0x1.8000000000000p-621, -0x1.0000040000000p-478, 0x1.0000000000000p-583, -0x1.0000040002080p-478, 0x1.0002000000000p-568},
{0x1.0007ffffcfffcp-566, 0x1.ff01fffe00000p-640, 0x1.01fff08000000p-12, -0x1.fffffe0000020p-66, 0x1.01fff08000000p-12, -0x1.fffffe0000020p-66},
{0x1.0007ffffcfffcp-566, 0x1.ff01fffe00000p-640, -0x1.01fff08000000p-12, 0x1.fffffe0000020p-66, -0x1.01fff08000000p-12, 0x1.fffffe0000020p-66},
{-0x1.0007ffffcfffcp-566, -0x1.ff01fffe00000p-640, 0x1.01fff08000000p-12, -0x1.fffffe0000020p-66, 0x1.01fff08000000p-12, -0x1.fffffe0000020p-66},
{-0x1.0007ffffcfffcp-566, -0x1.ff01fffe00000p-640, -0x1.01fff08000000p-12, 0x1.fffffe0000020p-66, -0x1.01fff08000000p-12, 0x1.fffffe0000020p-66},
{0x1.00000000007fep-907, 0x1.ff00003ffff00p-968, 0x1.004000e000008p+829, -0x1.ffffe02000000p+751, 0x1.004000e000008p+829, -0x1.ffffe02000000p+751},
{0x1.00000000007fep-907, 0x1.ff00003ffff00p-968, -0x1.004000e000008p+829, 0x1.ffffe02000000p+751, -0x1.004000e000008p+829, 0x1.ffffe02000000p+751},
{-0x1.00000000007fep-907, -0x1.ff00003ffff00p-968, 0x1.004000e000008p+829, -0x1.ffffe02000000p+751, 0x1.004000e000008p+829, -0x1.ffffe02000000p+751},
{-0x1.00000000007fep-907, -0x1.ff00003ffff00p-968, -0x1.004000e000008p+829, 0x1.ffffe02000000p+751, -0x1.004000e000008p+829, 0x1.ffffe02000000p+751},
{0x1.00000003ff000p-540, 0x1.ffff000000000p-629, 0x1.0000fffff8000p-864, 0x1.f003ffe0003e0p-922, 0x1.00000003ff000p-540, 0x1.ffff000000000p-629},
{0x1.00000003ff000p-540, 0x1.ffff000000000p-629, -0x1.0000fffff8000p-864, -0x1.f003ffe0003e0p-922, 0x1.00000003ff000p-540, 0x1.ffff000000000p-629},
{-0x1.00000003ff000p-540, -0x1.ffff000000000p-629, 0x1.0000fffff8000p-864, 0x1.f003ffe0003e0p-922, -0x1.00000003ff000p-540, -0x1.ffff000000000p-629},
{-0x1.00000003ff000p-540, -0x1.ffff000000000p-629, -0x1.0000fffff8000p-864, -0x1.f003ffe0003e0p-922, -0x1.00000003ff000p-540, -0x1.ffff000000000p-629},
{0x1.0000000000000p+14, 0x1.ffe001c0003c0p-45, 0x1.01fffffe00000p-954, 0x1.ffffffffffc00p-1012, 0x1.0000000000000p+14, 0x1.ffe001c0003c0p-45},
{0x1.0000000000000p+14, 0x1.ffe001c0003c0p-45, -0x1.01fffffe00000p-954, -0x1.ffffffffffc00p-1012, 0x1.0000000000000p+14, 0x1.ffe001c0003c0p-45},
{-0x1.0000000000000p+14, -0x1.ffe001c0003c0p-45, 0x1.01fffffe00000p-954, 0x1.ffffffffffc00p-1012, -0x1.0000000000000p+14, -0x1.ffe001c0003c0p-45},
{-0x1.0000000000000p+14, -0x1.ffe001c0003c0p-45, -0x1.01fffffe00000p-954, -0x1.ffffffffffc00p-1012, -0x1.0000000000000p+14, -0x1.ffe001c0003c0p-45},
{0x1.00003ff808000p-919, -0x1.ffe0000800000p-980, 0x1.000001ffff000p-62, 0x1.ff80000000000p-136, 0x1.000001ffff000p-62, 0x1.ff80000000000p-136},
{0x1.00003ff808000p-919, -0x1.ffe0000800000p-980, -0x1.000001ffff000p-62, -0x1.ff80000000000p-136, -0x1.000001ffff000p-62, -0x1.ff80000000000p-136},
{-0x1.00003ff808000p-919, 0x1.ffe0000800000p-980, 0x1.000001ffff000p-62, 0x1.ff80000000000p-136, 0x1.000001ffff000p-62, 0x1.ff80000000000p-136},
{-0x1.00003ff808000p-919, 0x1.ffe0000800000p-980, -0x1.000001ffff000p-62, -0x1.ff80000000000p-136, -0x1.000001ffff000p-62, -0x1.ff80000000000p-136},
{0x1.0000000000000p-665, 0x1.fc007f0ff0000p-727, 0x1.0000000007f80p-960, 0x1.ff0007f802000p-1024, 0x1.0000000000000p-665, 0x1.fc007f0ff0000p-727},
{0x1.0000000000000p-665, 0x1.fc007f0ff0000p-727, -0x1.0000000007f80p-960, -0x1.ff0007f802000p-1024, 0x1.0000000000000p-665, 0x1.fc007f0ff0000p-727},
{-0x1.0000000000000p-665, -0x1.fc007f0ff0000p-727, 0x1.0000000007f80p-960, 0x1.ff0007f802000p-1024, -0x1.0000000000000p-665, -0x1.fc007f0ff0000p-727},
{-0x1.0000000000000p-665, -0x1.fc007f0ff0000p-727, -0x1.0000000007f80p-960, -0x1.ff0007f802000p-1024, -0x1.0000000000000p-665, -0x1.fc007f0ff0000p-727},
{0x1.0020000000000p+107, -0x1.0000000000000p+30, 0x1.000001ffff802p-529, -0x1.ffffffc000040p-588, 0x1.0020000000000p+107, -0x1.0000000000000p+30},
{0x1.0020000000000p+107, -0x1.0000000000000p+30, -0x1.000001ffff802p-529, 0x1.ffffffc000040p-588, 0x1.0020000000000p+107, -0x1.0000000000000p+30},
{-0x1.0020000000000p+107, 0x1.0000000000000p+30, 0x1.000001ffff802p-529, -0x1.ffffffc000040p-588, -0x1.0020000000000p+107, 0x1.0000000000000p+30},
{-0x1.0020000000000p+107, 0x1.0000000000000p+30, -0x1.000001ffff802p-529, 0x1.ffffffc000040p-588, -0x1.0020000000000p+107, 0x1.0000000000000p+30},
{0x1.0000000000800p+985, -0x1.ffe0000400000p+923, 0x1.0000000000038p+697, 0x1.e100000000000p+623, 0x1.0000000000800p+985, -0x1.ffe0000400000p+923},
{0x1.0000000000800p+985, -0x1.ffe0000400000p+923, -0x1.0000000000038p+697, -0x1.e100000000000p+623, 0x1.0000000000800p+985, -0x1.ffe0000400000p+923},
{-0x1.0000000000800p+985, 0x1.ffe0000400000p+923, 0x1.0000000000038p+697, 0x1.e100000000000p+623, -0x1.0000000000800p+985, 0x1.ffe0000400000p+923},
{-0x1.0000000000800p+985, 0x1.ffe0000400000p+923, -0x1.0000000000038p+697, -0x1.e100000000000p+623, -0x1.0000000000800p+985, 0x1.ffe0000400000p+923},
{0x1.0000000000020p+26, -0x1.8007ffff80c04p-29, 0x1.0000000000000p+576, 0x1.ffffe00000c00p+513, 0x1.0000000000000p+576, 0x1.ffffe00000c00p+513},
{0x1.0000000000020p+26, -0x1.8007ffff80c04p-29, -0x1.0000000000000p+576, -0x1.ffffe00000c00p+513, -0x1.0000000000000p+576, -0x1.ffffe00000c00p+513},
{-0x1.0000000000020p+26, 0x1.8007ffff80c04p-29, 0x1.0000000000000p+576, 0x1.ffffe00000c00p+513, 0x1.0000000000000p+576, 0x1.ffffe00000c00p+513},
{-0x1.0000000000020p+26, 0x1.8007ffff80c04p-29, -0x1.0000000000000p+576, -0x1.ffffe00000c00p+513, -0x1.0000000000000p+576, -0x1.ffffe00000c00p+513},
{0x1.7fffffff80000p-290, 0x1.f000000000000p-367, 0x1.000007ffffffep-351, 0x1.ffffff8000000p-427, 0x1.7fffffff80000p-290, 0x1.0001f80000000p-351},
{0x1.7fffffff80000p-290, 0x1.f000000000000p-367, -0x1.000007ffffffep-351, -0x1.ffffff8000000p-427, 0x1.7fffffff80000p-290, -0x1.fffc300000000p-352},
{-0x1.7fffffff80000p-290, -0x1.f000000000000p-367, 0x1.000007ffffffep-351, 0x1.ffffff8000000p-427, -0x1.7fffffff80000p-290, 0x1.fffc300000000p-352},
{-0x1.7fffffff80000p-290, -0x1.f000000000000p-367, -0x1.000007ffffffep-351, -0x1.ffffff8000000p-427, -0x1.7fffffff80000p-290, -0x1.0001f80000000p-351},
{0x1.0000000010000p-869, -0x1.0000000000000p-955, 0x1.0000000000000p-250, 0x1.c000003ffc3fep-304, 0x1.0000000000000p-250, 0x1.c000003ffc3fep-304},
{0x1.0000000010000p-869, -0x1.0000000000000p-955, -0x1.0000000000000p-250, -0x1.c000003ffc3fep-304, -0x1.0000000000000p-250, -0x1.c000003ffc3fep-304},
{-0x1.0000000010000p-869, 0x1.0000000000000p-955, 0x1.0000000000000p-250, 0x1.c000003ffc3fep-304, 0x1.0000000000000p-250, 0x1.c000003ffc3fep-304},
{-0x1.0000000010000p-869, 0x1.0000000000000p-955, -0x1.0000000000000p-250, -0x1.c000003ffc3fep-304, -0x1.0000000000000p-250, -0x1.c000003ffc3fep-304},
{0x1.00000ffff0800p-239, -0x1.fff80000ffc20p-297, 0x1.0000000000002p-749, -0x1.0000000000000p-854, 0x1.00000ffff0800p-239, -0x1.fff80000ffc20p-297},
{0x1.00000ffff0800p-239, -0x1.fff80000ffc20p-297, -0x1.0000000000002p-749, 0x1.0000000000000p-854, 0x1.00000ffff0800p-239, -0x1.fff80000ffc20p-297},
{-0x1.00000ffff0800p-239, 0x1.fff80000ffc20p-297, 0x1.0000000000002p-749, -0x1.0000000000000p-854, -0x1.00000ffff0800p-239, 0x1.fff80000ffc20p-297},
{-0x1.00000ffff0800p-239, 0x1.fff80000ffc20p-297, -0x1.0000000000002p-749, 0x1.0000000000000p-854, -0x1.00000ffff0800p-239, 0x1.fff80000ffc20p-297},
{0x1.000ffffc00000p+483, 0x1.fffff00000000p+414, 0x1.0000000000040p+210, -0x1.0000000000000p+105, 0x1.000ffffc00000p+483, 0x1.fffff00000000p+414},
{0x1.000ffffc00000p+483, 0x1.fffff00000000p+414, -0x1.0000000000040p+210, 0x1.0000000000000p+105, 0x1.000ffffc00000p+483, 0x1.fffff00000000p+414},
{-0x1.000ffffc00000p+483, -0x1.fffff00000000p+414, 0x1.0000000000040p+210, -0x1.0000000000000p+105, -0x1.000ffffc00000p+483, -0x1.fffff00000000p+414},
{-0x1.000ffffc00000p+483, -0x1.fffff00000000p+414, -0x1.0000000000040p+210, 0x1.0000000000000p+105, -0x1.000ffffc00000p+483, -0x1.fffff00000000p+414},
{0x1.0004000000000p-94, -0x1.0000000000000p-162, 0x1.0000000200000p-175, -0x1.ffbffffff8020p-233, 0x1.0004000000000p-94, -0x1.fff0000000000p-163},
{0x1.0004000000000p-94, -0x1.0000000000000p-162, -0x1.0000000200000p-175, 0x1.ffbffffff8020p-233, 0x1.0004000000000p-94, -0x1.0008000000000p-162},
{-0x1.0004000000000p-94, 0x1.0000000000000p-162, 0x1.0000000200000p-175, -0x1.ffbffffff8020p-233, -0x1.0004000000000p-94, 0x1.0008000000000p-162},
{-0x1.0004000000000p-94, 0x1.0000000000000p-162, -0x1.0000000200000p-175, 0x1.ffbffffff8020p-233, -0x1.0004000000000p-94, 0x1.fff0000000000p-163},
{0x1.0000000000000p-421, 0x1.e0001e7fbff00p-482, 0x1.0000001fffffep-395, 0x0.0000000000000p+0, 0x1.0000005fffffep-395, 0x1.e000000000000p-482},
{0x1.0000000000000p-421, 0x1.e0001e7fbff00p-482, -0x1.0000001fffffep-395, 0x0.0000000000000p+0, -0x1.ffffffbfffffcp-396, 0x1.e000200000000p-482},
{-0x1.0000000000000p-421, -0x1.e0001e7fbff00p-482, 0x1.0000001fffffep-395, 0x0.0000000000000p+0, 0x1.ffffffbfffffcp-396, -0x1.e000200000000p-482},
{-0x1.0000000000000p-421, -0x1.e0001e7fbff00p-482, -0x1.0000001fffffep-395, 0x0.0000000000000p+0, -0x1.0000005fffffep-395, -0x1.e000000000000p-482},
{0x1.0000000000fffp-362, 0x1.fffff3e000000p-435, 0x1.001ffe0000000p+872, 0x1.fffffffffffc0p+813, 0x1.001ffe0000000p+872, 0x1.fffffffffffc0p+813},
{0x1.0000000000fffp-362, 0x1.fffff3e000000p-435, -0x1.001ffe0000000p+872, -0x1.fffffffffffc0p+813, -0x1.001ffe0000000p+872, -0x1.fffffffffffc0p+813},
{-0x1.0000000000fffp-362, -0x1.fffff3e000000p-435, 0x1.001ffe0000000p+872, 0x1.fffffffffffc0p+813, 0x1.001ffe0000000p+872, 0x1.fffffffffffc0p+813},
{-0x1.0000000000fffp-362, -0x1.fffff3e000000p-435, -0x1.001ffe0000000p+872, -0x1.fffffffffffc0p+813, -0x1.001ffe0000000p+872, -0x1.fffffffffffc0p+813},
{0x1.0000080000000p+509, -0x1.0000000000000p+404, 0x1.0000000080000p-689, -0x1.0000000000000p-744, 0x1.0000080000000p+509, -0x1.0000000000000p+404},
{0x1.0000080000000p+509, -0x1.0000000000000p+404, -0x1.0000000080000p-689, 0x1.0000000000000p-744, 0x1.0000080000000p+509, -0x1.0000000000000p+404},
{-0x1.0000080000000p+509, 0x1.0000000000000p+404, 0x1.0000000080000p-689, -0x1.0000000000000p-744, -0x1.0000080000000p+509, 0x1.0000000000000p+404},
{-0x1.0000080000000p+509, 0x1.0000000000000p+404, -0x1.0000000080000p-689, 0x1.0000000000000p-744, -0x1.0000080000000p+509, 0x1.0000000000000p+404},
{0x1.003ffffffffe0p+511, 0x1.ffffe03800000p+435, 0x1.0000000002000p+705, -0x1.0000000000000p+652, 0x1.0000000002000p+705, -0x1.0000000000000p+652},
{0x1.003ffffffffe0p+511, 0x1.ffffe03800000p+435, -0x1.0000000002000p+705, 0x1.0000000000000p+652, -0x1.0000000002000p+705, 0x1.0000000000000p+652},
{-0x1.003ffffffffe0p+511, -0x1.ffffe03800000p+435, 0x1.0000000002000p+705, -0x1.0000000000000p+652, 0x1.0000000002000p+705, -0x1.0000000000000p+652},
{-0x1.003ffffffffe0p+511, -0x1.ffffe03800000p+435, -0x1.0000000002000p+705, 0x1.0000000000000p+652, -0x1.0000000002000p+705, 0x1.0000000000000p+652},
{0x1.0000000000008p-749, -0x1.ff000007ffc00p-809, 0x1.0000000060000p+866, 0x1.ffffff8000000p+786, 0x1.0000000060000p+866, 0x1.ffffff8000000p+786},
{0x1.0000000000008p-749, -0x1.ff000007ffc00p-809, -0x1.0000000060000p+866, -0x1.ffffff8000000p+786, -0x1.0000000060000p+866, -0x1.ffffff8000000p+786},
{-0x1.0000000000008p-749, 0x1.ff000007ffc00p-809, 0x1.0000000060000p+866, 0x1.ffffff8000000p+786, 0x1.0000000060000p+866, 0x1.ffffff8000000p+786},
{-0x1.0000000000008p-749, 0x1.ff000007ffc00p-809, -0x1.0000000060000p+866, -0x1.ffffff8000000p+786, -0x1.0000000060000p+866, -0x1.ffffff8000000p+786},
{0x1.0000000000080p+921, -0x1.0000000000000p+816, 0x1.01ffffff80001p+85, -0x1.ff90000000000p-8, 0x1.0000000000080p+921, -0x1.0000000000000p+816},
{0x1.0000000000080p+921, -0x1.0000000000000p+816, -0x1.01ffffff80001p+85, 0x1.ff90000000000p-8, 0x1.0000000000080p+921, -0x1.0000000000000p+816},
{-0x1.0000000000080p+921, 0x1.0000000000000p+816, 0x1.01ffffff80001p+85, -0x1.ff90000000000p-8, -0x1.0000000000080p+921, 0x1.0000000000000p+816},
{-0x1.0000000000080p+921, 0x1.0000000000000p+816, -0x1.01ffffff80001p+85, 0x1.ff90000000000p-8, -0x1.0000000000080p+921, 0x1.0000000000000p+816},
{0x1.0000000000800p-666, -0x1.fffff80002000p-732, 0x1.0008000000000p-639, -0x1.0000000000000p-718, 0x1.0008002000000p-639, 0x1.ffbffe0000000p-708},
{0x1.0000000000800p-666, -0x1.fffff80002000p-732, -0x1.0008000000000p-639, 0x1.0000000000000p-718, -0x1.0007ffe000000p-639, 0x1.001fff0000000p-707},
{-0x1.0000000000800p-666, 0x1.fffff80002000p-732, 0x1.0008000000000p-639, -0x1.0000000000000p-718, 0x1.0007ffe000000p-639, -0x1.001fff0000000p-707},
{-0x1.0000000000800p-666, 0x1.fffff80002000p-732, -0x1.0008000000000p-639, 0x1.0000000000000p-718, -0x1.0008002000000p-639, -0x1.ffbffe0000000p-708},
{0x1.0000000000002p+14, -0x1.ffffffe200000p-60, 0x1.0003fffffffc0p+133, 0x1.ffffe00000400p+70, 0x1.0003fffffffc0p+133, 0x1.ffffe00000400p+70},
{0x1.0000000000002p+14, -0x1.ffffffe200000p-60, -0x1.0003fffffffc0p+133, -0x1.ffffe00000400p+70, -0x1.0003fffffffc0p+133, -0x1.ffffe00000400p+70},
{-0x1.0000000000002p+14, 0x1.ffffffe200000p-60, 0x1.0003fffffffc0p+133, 0x1.ffffe00000400p+70, 0x1.0003fffffffc0p+133, 0x1.ffffe00000400p+70},
{-0x1.0000000000002p+14, 0x1.ffffffe200000p-60, -0x1.0003fffffffc0p+133, -0x1.ffffe00000400p+70, -0x1.0003fffffffc0p+133, -0x1.ffffe00000400p+70},
{0x1.000003f000000p+120, 0x1.fffffffe00000p+59, 0x1.0000000000ff0p+144, 0x1.c03fff0e00000p+70, 0x1.000001000102fp+144, 0x1.c07fff0e00000p+70},
{0x1.000003f000000p+120, 0x1.fffffffe00000p+59, -0x1.0000000000ff0p+144, -0x1.c03fff0e00000p+70, -0x1.fffffe0001f62p+143, -0x1.bfffff0e00000p+70},
{-0x1.000003f000000p+120, -0x1.fffffffe00000p+59, 0x1.0000000000ff0p+144, 0x1.c03fff0e00000p+70, 0x1.fffffe0001f62p+143, 0x1.bfffff0e00000p+70},
{-0x1.000003f000000p+120, -0x1.fffffffe00000p+59, -0x1.0000000000ff0p+144, -0x1.c03fff0e00000p+70, -0x1.000001000102fp+144, -0x1.c07fff0e00000p+70},
{0x1.0000000018000p+68, 0x1.fffffe0000000p-14, 0x1.0000100000000p+766, -0x1.0000000000000p+661, 0x1.0000100000000p+766, -0x1.0000000000000p+661},
{0x1.0000000018000p+68, 0x1.fffffe0000000p-14, -0x1.0000100000000p+766, 0x1.0000000000000p+661, -0x1.0000100000000p+766, 0x1.0000000000000p+661},
{-0x1.0000000018000p+68, -0x1.fffffe0000000p-14, 0x1.0000100000000p+766, -0x1.0000000000000p+661, 0x1.0000100000000p+766, -0x1.0000000000000p+661},
{-0x1.0000000018000p+68, -0x1.fffffe0000000p-14, -0x1.0000100000000p+766, 0x1.0000000000000p+661, -0x1.0000100000000p+766, 0x1.0000000000000p+661},
{0x1.0000000000001p-191, -0x1.fffffc1000000p-258, 0x1.1ffffff01f000p+311, 0x1.ffffc000060fcp+256, 0x1.1ffffff01f000p+311, 0x1.ffffc000060fcp+256},
{0x1.0000000000001p-191, -0x1.fffffc1000000p-258, -0x1.1ffffff01f000p+311, -0x1.ffffc000060fcp+256, -0x1.1ffffff01f000p+311, -0x1.ffffc000060fcp+256},
{-0x1.0000000000001p-191, 0x1.fffffc1000000p-258, 0x1.1ffffff01f000p+311, 0x1.ffffc000060fcp+256, 0x1.1ffffff01f000p+311, 0x1.ffffc000060fcp+256},
{-0x1.0000000000001p-191, 0x1.fffffc1000000p-258, -0x1.1ffffff01f000p+311, -0x1.ffffc000060fcp+256, -0x1.1ffffff01f000p+311, -0x1.ffffc000060fcp+256},
{0x1.0000003800000p-790, 0x1.ffe000001fffcp-845, 0x1.0000007fffff0p-815, 0x1.fe1ffffc00000p-877, 0x1.000000b800004p-790, 0x1.ffdfc0021e1fcp-845},
{0x1.0000003800000p-790, 0x1.ffe000001fffcp-845, -0x1.0000007fffff0p-815, -0x1.fe1ffffc00000p-877, 0x1.ffffff6fffff8p-791, 0x1.ffe03ffe21dfcp-845},
{-0x1.0000003800000p-790, -0x1.ffe000001fffcp-845, 0x1.0000007fffff0p-815, 0x1.fe1ffffc00000p-877, -0x1.ffffff6fffff8p-791, -0x1.ffe03ffe21dfcp-845},
{-0x1.0000003800000p-790, -0x1.ffe000001fffcp-845, -0x1.0000007fffff0p-815, -0x1.fe1ffffc00000p-877, -0x1.000000b800004p-790, -0x1.ffdfc0021e1fcp-845},
{0x1.0000001fffc00p-770, 0x1.f00007ffe0000p-834, 0x1.0000000000180p+996, 0x1.fffffe0000800p+932, 0x1.0000000000180p+996, 0x1.fffffe0000800p+932},
{0x1.0000001fffc00p-770, 0x1.f00007ffe0000p-834, -0x1.0000000000180p+996, -0x1.fffffe0000800p+932, -0x1.0000000000180p+996, -0x1.fffffe0000800p+932},
{-0x1.0000001fffc00p-770, -0x1.f00007ffe0000p-834, 0x1.0000000000180p+996, 0x1.fffffe0000800p+932, 0x1.0000000000180p+996, 0x1.fffffe0000800p+932},
{-0x1.0000001fffc00p-770, -0x1.f00007ffe0000p-834, -0x1.0000000000180p+996, -0x1.fffffe0000800p+932, -0x1.0000000000180p+996, -0x1.fffffe0000800p+932},
{0x1.0000000008000p+440, -0x1.c0000007ffe04p+385, 0x1.00000fffffffep-521, 0x1.fc00000000000p-620, 0x1.0000000008000p+440, -0x1.c0000007ffe04p+385},
{0x1.0000000008000p+440, -0x1.c0000007ffe04p+385, -0x1.00000fffffffep-521, -0x1.fc00000000000p-620, 0x1.0000000008000p+440, -0x1.c0000007ffe04p+385},
{-0x1.0000000008000p+440, 0x1.c0000007ffe04p+385, 0x1.00000fffffffep-521, 0x1.fc00000000000p-620, -0x1.0000000008000p+440, 0x1.c0000007ffe04p+385},
{-0x1.0000000008000p+440, 0x1.c0000007ffe04p+385, -0x1.00000fffffffep-521, -0x1.fc00000000000p-620, -0x1.0000000008000p+440, 0x1.c0000007ffe04p+385},
{0x1.0000003e00004p-731, -0x1.fe00040000000p-801, 0x1.00007c0001e00p+483, 0x1.fffe13ffe0000p+419, 0x1.00007c0001e00p+483, 0x1.fffe13ffe0000p+419},
{0x1.0000003e00004p-731, -0x1.fe00040000000p-801, -0x1.00007c0001e00p+483, -0x1.fffe13ffe0000p+419, -0x1.00007c0001e00p+483, -0x1.fffe13ffe0000p+419},
{-0x1.0000003e00004p-731, 0x1.fe00040000000p-801, 0x1.00007c0001e00p+483, 0x1.fffe13ffe0000p+419, 0x1.00007c0001e00p+483, 0x1.fffe13ffe0000p+419},
{-0x1.0000003e00004p-731, 0x1.fe00040000000p-801, -0x1.00007c0001e00p+483, -0x1.fffe13ffe0000p+419, -0x1.00007c0001e00p+483, -0x1.fffe13ffe0000p+419},
{0x1.03fffffffc000p-192, 0x1.ffffffc000000p-267, 0x1.0003ffffff000p+649, 0x1.ffc0000000000p+554, 0x1.0003ffffff000p+649, 0x1.ffc0000000000p+554},
{0x1.03fffffffc000p-192, 0x1.ffffffc000000p-267, -0x1.0003ffffff000p+649, -0x1.ffc0000000000p+554, -0x1.0003ffffff000p+649, -0x1.ffc0000000000p+554},
{-0x1.03fffffffc000p-192, -0x1.ffffffc000000p-267, 0x1.0003ffffff000p+649, 0x1.ffc0000000000p+554, 0x1.0003ffffff000p+649, 0x1.ffc0000000000p+554},
{-0x1.03fffffffc000p-192, -0x1.ffffffc000000p-267, -0x1.0003ffffff000p+649, -0x1.ffc0000000000p+554, -0x1.0003ffffff000p+649, -0x1.ffc0000000000p+554},
{0x1.07ffffff80000p+301, 0x1.8007ffffc0000p+230, 0x1.0000000000004p-464, -0x1.fffc000200000p-533, 0x1.07ffffff80000p+301, 0x1.8007ffffc0000p+230},
{0x1.07ffffff80000p+301, 0x1.8007ffffc0000p+230, -0x1.0000000000004p-464, 0x1.fffc000200000p-533, 0x1.07ffffff80000p+301, 0x1.8007ffffc0000p+230},
{-0x1.07ffffff80000p+301, -0x1.8007ffffc0000p+230, 0x1.0000000000004p-464, -0x1.fffc000200000p-533, -0x1.07ffffff80000p+301, -0x1.8007ffffc0000p+230},
{-0x1.07ffffff80000p+301, -0x1.8007ffffc0000p+230, -0x1.0000000000004p-464, 0x1.fffc000200000p-533, -0x1.07ffffff80000p+301, -0x1.8007ffffc0000p+230},
{0x1.00003ffffff80p-1007, 0x1.0000000000000p-1068, 0x1.00003fffffff8p+0, 0x0.0000000000000p+0, 0x1.00003fffffff8p+0, 0x0.0000000000000p+0},
{0x1.00003ffffff80p-1007, 0x1.0000000000000p-1068, -0x1.00003fffffff8p+0, 0x0.0000000000000p+0, -0x1.00003fffffff8p+0, 0x0.0000000000000p+0},
{-0x1.00003ffffff80p-1007, -0x1.0000000000000p-1068, 0x1.00003fffffff8p+0, 0x0.0000000000000p+0, 0x1.00003fffffff8p+0, 0x0.0000000000000p+0},
{-0x1.00003ffffff80p-1007, -0x1.0000000000000p-1068, -0x1.00003fffffff8p+0, 0x0.0000000000000p+0, -0x1.00003fffffff8p+0, 0x0.0000000000000p+0},
{0x1.0000010000000p-912, -0x1.0000000000000p-1017, 0x1.00f81ffffff81p+122, 0x1.fffff03c00000p+60, 0x1.00f81ffffff81p+122, 0x1.fffff03c00000p+60},
{0x1.0000010000000p-912, -0x1.0000000000000p-1017, -0x1.00f81ffffff81p+122, -0x1.fffff03c00000p+60, -0x1.00f81ffffff81p+122, -0x1.fffff03c00000p+60},
{-0x1.0000010000000p-912, 0x1.0000000000000p-1017, 0x1.00f81ffffff81p+122, 0x1.fffff03c00000p+60, 0x1.00f81ffffff81p+122, 0x1.fffff03c00000p+60},
{-0x1.0000010000000p-912, 0x1.0000000000000p-1017, -0x1.00f81ffffff81p+122, -0x1.fffff03c00000p+60, -0x1.00f81ffffff81p+122, -0x1.fffff03c00000p+60},
{0x1.0000000000004p+652, -0x1.fff0008000000p+588, 0x1.0000000100000p+402, -0x1.fffffe0004000p+335, 0x1.0000000000004p+652, -0x1.fff0008000000p+588},
{0x1.0000000000004p+652, -0x1.fff0008000000p+588, -0x1.0000000100000p+402, 0x1.fffffe0004000p+335, 0x1.0000000000004p+652, -0x1.fff0008000000p+588},
{-0x1.0000000000004p+652, 0x1.fff0008000000p+588, 0x1.0000000100000p+402, -0x1.fffffe0004000p+335, -0x1.0000000000004p+652, 0x1.fff0008000000p+588},
{-0x1.0000000000004p+652, 0x1.fff0008000000p+588, -0x1.0000000100000p+402, 0x1.fffffe0004000p+335, -0x1.0000000000004p+652, 0x1.fff0008000000p+588},
{0x1.0000000000800p-11, -0x1.0000000000000p-89, 0x1.0000010000000p+68, -0x1.0000000000000p-35, 0x1.0000010000000p+68, 0x1.fffffe0000000p-12},
{0x1.0000000000800p-11, -0x1.0000000000000p-89, -0x1.0000010000000p+68, 0x1.0000000000000p-35, -0x1.0000010000000p+68, 0x1.0000010000000p-11},
{-0x1.0000000000800p-11, 0x1.0000000000000p-89, 0x1.0000010000000p+68, -0x1.0000000000000p-35, 0x1.0000010000000p+68, -0x1.0000010000000p-11},
{-0x1.0000000000800p-11, 0x1.0000000000000p-89, -0x1.0000010000000p+68, 0x1.0000000000000p-35, -0x1.0000010000000p+68, -0x1.fffffe0000000p-12},
{0x1.00000007fff00p+898, 0x1.fffc1ffff87f0p+842, 0x1.0000007c00000p-1007, 0x0.0000000000000p+0, 0x1.00000007fff00p+898, 0x1.fffc1ffff87f0p+842},
{0x1.00000007fff00p+898, 0x1.fffc1ffff87f0p+842, -0x1.0000007c00000p-1007, -0x0.0000000000000p+0, 0x1.00000007fff00p+898, 0x1.fffc1ffff87f0p+842},
{-0x1.00000007fff00p+898, -0x1.fffc1ffff87f0p+842, 0x1.0000007c00000p-1007, 0x0.0000000000000p+0, -0x1.00000007fff00p+898, -0x1.fffc1ffff87f0p+842},
{-0x1.00000007fff00p+898, -0x1.fffc1ffff87f0p+842, -0x1.0000007c00000p-1007, -0x0.0000000000000p+0, -0x1.00000007fff00p+898, -0x1.fffc1ffff87f0p+842},
{0x1.fffffffe00000p+397, 0x1.e000001fff800p+333, 0x1.00000001ffffep+347, 0x0.0000000000000p+0, 0x1.fffffffe00004p+397, 0x1.e000801ff7800p+333},
{0x1.fffffffe00000p+397, 0x1.e000001fff800p+333, -0x1.00000001ffffep+347, 0x0.0000000000000p+0, 0x1.fffffffdffffcp+397, 0x1.dfff802007800p+333},
{-0x1.fffffffe00000p+397, -0x1.e000001fff800p+333, 0x1.00000001ffffep+347, 0x0.0000000000000p+0, -0x1.fffffffdffffcp+397, -0x1.dfff802007800p+333},
{-0x1.fffffffe00000p+397, -0x1.e000001fff800p+333, -0x1.00000001ffffep+347, 0x0.0000000000000p+0, -0x1.fffffffe00004p+397, -0x1.e000801ff7800p+333},
{0x1.0000000000008p-231, -0x1.fffff00400000p-303, 0x1.00003ffffe000p-829, 0x1.ffffe00000000p-901, 0x1.0000000000008p-231, -0x1.fffff00400000p-303},
{0x1.0000000000008p-231, -0x1.fffff00400000p-303, -0x1.00003ffffe000p-829, -0x1.ffffe00000000p-901, 0x1.0000000000008p-231, -0x1.fffff00400000p-303},
{-0x1.0000000000008p-231, 0x1.fffff00400000p-303, 0x1.00003ffffe000p-829, 0x1.ffffe00000000p-901, -0x1.0000000000008p-231, 0x1.fffff00400000p-303},
{-0x1.0000000000008p-231, 0x1.fffff00400000p-303, -0x1.00003ffffe000p-829, -0x1.ffffe00000000p-901, -0x1.0000000000008p-231, 0x1.fffff00400000p-303},
{0x1.0000000000000p-479, 0x1.ffffffffffc00p-542, 0x1.000001ffe0000p-355, 0x1.ff87ff9f801c0p-414, 0x1.000001ffe0000p-355, 0x1.ff87ff9f801c0p-414},
{0x1.0000000000000p-479, 0x1.ffffffffffc00p-542, -0x1.000001ffe0000p-355, -0x1.ff87ff9f801c0p-414, -0x1.000001ffe0000p-355, -0x1.ff87ff9f801c0p-414},
{-0x1.0000000000000p-479, -0x1.ffffffffffc00p-542, 0x1.000001ffe0000p-355, 0x1.ff87ff9f801c0p-414, 0x1.000001ffe0000p-355, 0x1.ff87ff9f801c0p-414},
{-0x1.0000000000000p-479, -0x1.ffffffffffc00p-542, -0x1.000001ffe0000p-355, -0x1.ff87ff9f801c0p-414, -0x1.000001ffe0000p-355, -0x1.ff87ff9f801c0p-414},
{0x1.0000000000400p-496, -0x1.f800000002000p-557, 0x1.03fffffffff00p-62, 0x1.fffe7fffffffep-116, 0x1.03fffffffff00p-62, 0x1.fffe7fffffffep-116},
{0x1.0000000000400p-496, -0x1.f800000002000p-557, -0x1.03fffffffff00p-62, -0x1.fffe7fffffffep-116, -0x1.03fffffffff00p-62, -0x1.fffe7fffffffep-116},
{-0x1.0000000000400p-496, 0x1.f800000002000p-557, 0x1.03fffffffff00p-62, 0x1.fffe7fffffffep-116, 0x1.03fffffffff00p-62, 0x1.fffe7fffffffep-116},
{-0x1.0000000000400p-496, 0x1.f800000002000p-557, -0x1.03fffffffff00p-62, -0x1.fffe7fffffffep-116, -0x1.03fffffffff00p-62, -0x1.fffe7fffffffep-116},
{0x1.0000000000000p+267, 0x1.fffffffffff00p+211, 0x1.000007c000000p+439, 0x1.fff8000000000p+383, 0x1.000007c000000p+439, 0x1.fff8000000000p+383},
{0x1.0000000000000p+267, 0x1.fffffffffff00p+211, -0x1.000007c000000p+439, -0x1.fff8000000000p+383, -0x1.000007c000000p+439, -0x1.fff8000000000p+383},
{-0x1.0000000000000p+267, -0x1.fffffffffff00p+211, 0x1.000007c000000p+439, 0x1.fff8000000000p+383, 0x1.000007c000000p+439, 0x1.fff8000000000p+383},
{-0x1.0000000000000p+267, -0x1.fffffffffff00p+211, -0x1.000007c000000p+439, -0x1.fff8000000000p+383, -0x1.000007c000000p+439, -0x1.fff8000000000p+383},
{0x1.0000000000400p-383, -0x1.fffc0003fffd0p-440, 0x1.0000000000000p+249, 0x1.fffffff800000p+193, 0x1.0000000000000p+249, 0x1.fffffff800000p+193},
{0x1.0000000000400p-383, -0x1.fffc0003fffd0p-440, -0x1.0000000000000p+249, -0x1.fffffff800000p+193, -0x1.0000000000000p+249, -0x1.fffffff800000p+193},
{-0x1.0000000000400p-383, 0x1.fffc0003fffd0p-440, 0x1.0000000000000p+249, 0x1.fffffff800000p+193, 0x1.0000000000000p+249, 0x1.fffffff800000p+193},
{-0x1.0000000000400p-383, 0x1.fffc0003fffd0p-440, -0x1.0000000000000p+249, -0x1.fffffff800000p+193, -0x1.0000000000000p+249, -0x1.fffffff800000p+193},
{0x1.0000000002000p-673, -0x1.ffff040000000p-744, 0x1.03fffff800000p+930, 0x1.fffffe0000000p+862, 0x1.03fffff800000p+930, 0x1.fffffe0000000p+862},
{0x1.0000000002000p-673, -0x1.ffff040000000p-744, -0x1.03fffff800000p+930, -0x1.fffffe0000000p+862, -0x1.03fffff800000p+930, -0x1.fffffe0000000p+862},
{-0x1.0000000002000p-673, 0x1.ffff040000000p-744, 0x1.03fffff800000p+930, 0x1.fffffe0000000p+862, 0x1.03fffff800000p+930, 0x1.fffffe0000000p+862},
{-0x1.0000000002000p-673, 0x1.ffff040000000p-744, -0x1.03fffff800000p+930, -0x1.fffffe0000000p+862, -0x1.03fffff800000p+930, -0x1.fffffe0000000p+862},
{0x1.0000008000000p+436, -0x1.ffffff8200000p+379, 0x1.000fff8000000p-8, 0x1.fffffe0000000p-70, 0x1.0000008000000p+436, -0x1.ffffff8200000p+379},
{0x1.0000008000000p+436, -0x1.ffffff8200000p+379, -0x1.000fff8000000p-8, -0x1.fffffe0000000p-70, 0x1.0000008000000p+436, -0x1.ffffff8200000p+379},
{-0x1.0000008000000p+436, 0x1.ffffff8200000p+379, 0x1.000fff8000000p-8, 0x1.fffffe0000000p-70, -0x1.0000008000000p+436, 0x1.ffffff8200000p+379},
{-0x1.0000008000000p+436, 0x1.ffffff8200000p+379, -0x1.000fff8000000p-8, -0x1.fffffe0000000p-70, -0x1.0000008000000p+436, 0x1.ffffff8200000p+379},
{0x1.0000000000000p+138, 0x1.0001f9e000000p+78, 0x1.0000000000040p+438, -0x1.fffffc0080000p+366, 0x1.0000000000040p+438, -0x1.fffffc0080000p+366},
{0x1.0000000000000p+138, 0x1.0001f9e000000p+78, -0x1.0000000000040p+438, 0x1.fffffc0080000p+366, -0x1.0000000000040p+438, 0x1.fffffc0080000p+366},
{-0x1.0000000000000p+138, -0x1.0001f9e000000p+78, 0x1.0000000000040p+438, -0x1.fffffc0080000p+366, 0x1.0000000000040p+438, -0x1.fffffc0080000p+366},
{-0x1.0000000000000p+138, -0x1.0001f9e000000p+78, -0x1.0000000000040p+438, 0x1.fffffc0080000p+366, -0x1.0000000000040p+438, 0x1.fffffc0080000p+366},
{0x1.0000ff0007e00p+955, 0x1.ffc001ff00000p+888, 0x1.0000010000000p+582, -0x1.ffc007ffffe20p+524, 0x1.0000ff0007e00p+955, 0x1.ffc001ff00000p+888},
{0x1.0000ff0007e00p+955, 0x1.ffc001ff00000p+888, -0x1.0000010000000p+582, 0x1.ffc007ffffe20p+524, 0x1.0000ff0007e00p+955, 0x1.ffc001ff00000p+888},
{-0x1.0000ff0007e00p+955, -0x1.ffc001ff00000p+888, 0x1.0000010000000p+582, -0x1.ffc007ffffe20p+524, -0x1.0000ff0007e00p+955, -0x1.ffc001ff00000p+888},
{-0x1.0000ff0007e00p+955, -0x1.ffc001ff00000p+888, -0x1.0000010000000p+582, 0x1.ffc007ffffe20p+524, -0x1.0000ff0007e00p+955, -0x1.ffc001ff00000p+888},
{0x1.07ffffff1fe00p+791, 0x1.fc00000000000p+694, 0x1.0040000000000p-580, -0x1.c000000400000p-641, 0x1.07ffffff1fe00p+791, 0x1.fc00000000000p+694},
{0x1.07ffffff1fe00p+791, 0x1.fc00000000000p+694, -0x1.0040000000000p-580, 0x1.c000000400000p-641, 0x1.07ffffff1fe00p+791, 0x1.fc00000000000p+694},
{-0x1.07ffffff1fe00p+791, -0x1.fc00000000000p+694, 0x1.0040000000000p-580, -0x1.c000000400000p-641, -0x1.07ffffff1fe00p+791, -0x1.fc00000000000p+694},
{-0x1.07ffffff1fe00p+791, -0x1.fc00000000000p+694, -0x1.0040000000000p-580, 0x1.c000000400000p-641, -0x1.07ffffff1fe00p+791, -0x1.fc00000000000p+694},
{0x1.0080000000000p-806, -0x1.0000000000000p-911, 0x1.00000001fffc0p+613, 0x1.fffff80f80000p+541, 0x1.00000001fffc0p+613, 0x1.fffff80f80000p+541},
{0x1.0080000000000p-806, -0x1.0000000000000p-911, -0x1.00000001fffc0p+613, -0x1.fffff80f80000p+541, -0x1.00000001fffc0p+613, -0x1.fffff80f80000p+541},
{-0x1.0080000000000p-806, 0x1.0000000000000p-911, 0x1.00000001fffc0p+613, 0x1.fffff80f80000p+541, 0x1.00000001fffc0p+613, 0x1.fffff80f80000p+541},
{-0x1.0080000000000p-806, 0x1.0000000000000p-911, -0x1.00000001fffc0p+613, -0x1.fffff80f80000p+541, -0x1.00000001fffc0p+613, -0x1.fffff80f80000p+541},
{0x1.000000003ff00p-698, 0x0.0000000000000p+0, 0x1.0000000000000p-302, 0x1.f83007ffffe00p-362, 0x1.0000000000000p-302, 0x1.f83007ffffe00p-362},
{0x1.000000003ff00p-698, 0x0.0000000000000p+0, -0x1.0000000000000p-302, -0x1.f83007ffffe00p-362, -0x1.0000000000000p-302, -0x1.f83007ffffe00p-362},
{-0x1.000000003ff00p-698, 0x0.0000000000000p+0, 0x1.0000000000000p-302, 0x1.f83007ffffe00p-362, 0x1.0000000000000p-302, 0x1.f83007ffffe00p-362},
{-0x1.000000003ff00p-698, 0x0.0000000000000p+0, -0x1.0000000000000p-302, -0x1.f83007ffffe00p-362, -0x1.0000000000000p-302, -0x1.f83007ffffe00p-362},
{0x1.00003fffffe00p-546, 0x1.fffffc0000380p-606, 0x1.0000010000000p-330, -0x1.ffffff8000008p-386, 0x1.0000010000000p-330, -0x1.ffffff8000008p-386},
{0x1.00003fffffe00p-546, 0x1.fffffc0000380p-606, -0x1.0000010000000p-330, 0x1.ffffff8000008p-386, -0x1.0000010000000p-330, 0x1.ffffff8000008p-386},
{-0x1.00003fffffe00p-546, -0x1.fffffc0000380p-606, 0x1.0000010000000p-330, -0x1.ffffff8000008p-386, 0x1.0000010000000p-330, -0x1.ffffff8000008p-386},
{-0x1.00003fffffe00p-546, -0x1.fffffc0000380p-606, -0x1.0000010000000p-330, 0x1.ffffff8000008p-386, -0x1.0000010000000p-330, 0x1.ffffff8000008p-386},
{0x1.0000000080000p-450, -0x1.fffffc0010000p-519, 0x1.3fffff8000000p-829, 0x1.fffff800fe000p-895, 0x1.0000000080000p-450, -0x1.fffffc0010000p-519},
{0x1.0000000080000p-450, -0x1.fffffc0010000p-519, -0x1.3fffff8000000p-829, -0x1.fffff800fe000p-895, 0x1.0000000080000p-450, -0x1.fffffc0010000p-519},
{-0x1.0000000080000p-450, 0x1.fffffc0010000p-519, 0x1.3fffff8000000p-829, 0x1.fffff800fe000p-895, -0x1.0000000080000p-450, 0x1.fffffc0010000p-519},
{-0x1.0000000080000p-450, 0x1.fffffc0010000p-519, -0x1.3fffff8000000p-829, -0x1.fffff800fe000p-895, -0x1.0000000080000p-450, 0x1.fffffc0010000p-519},
{0x1.0003f001fc3f0p+850, 0x1.fffffc0000000p+794, 0x1.0000000000000p+214, 0x1.fc1fffc0000fep+160, 0x1.0003f001fc3f0p+850, 0x1.fffffc0000000p+794},
{0x1.0003f001fc3f0p+850, 0x1.fffffc0000000p+794, -0x1.0000000000000p+214, -0x1.fc1fffc0000fep+160, 0x1.0003f001fc3f0p+850, 0x1.fffffc0000000p+794},
{-0x1.0003f001fc3f0p+850, -0x1.fffffc0000000p+794, 0x1.0000000000000p+214, 0x1.fc1fffc0000fep+160, -0x1.0003f001fc3f0p+850, -0x1.fffffc0000000p+794},
{-0x1.0003f001fc3f0p+850, -0x1.fffffc0000000p+794, -0x1.0000000000000p+214, -0x1.fc1fffc0000fep+160, -0x1.0003f001fc3f0p+850, -0x1.fffffc0000000p+794},
{0x1.0000000000000p+702, 0x1.fffffffffffc0p+643, 0x1.0000000000000p-646, 0x1.ffffffffffe00p-708, 0x1.0000000000000p+702, 0x1.fffffffffffc0p+643},
{0x1.0000000000000p+702, 0x1.fffffffffffc0p+643, -0x1.0000000000000p-646, -0x1.ffffffffffe00p-708, 0x1.0000000000000p+702, 0x1.fffffffffffc0p+643},
{-0x1.0000000000000p+702, -0x1.fffffffffffc0p+643, 0x1.0000000000000p-646, 0x1.ffffffffffe00p-708, -0x1.0000000000000p+702, -0x1.fffffffffffc0p+643},
{-0x1.0000000000000p+702, -0x1.fffffffffffc0p+643, -0x1.0000000000000p-646, -0x1.ffffffffffe00p-708, -0x1.0000000000000p+702, -0x1.fffffffffffc0p+643},
{0x1.0000000100000p+167, -0x1.0000000000000p+88, 0x1.0000004000000p+455, -0x1.0000000000000p+375, 0x1.0000004000000p+455, -0x1.0000000000000p+375},
{0x1.0000000100000p+167, -0x1.0000000000000p+88, -0x1.0000004000000p+455, 0x1.0000000000000p+375, -0x1.0000004000000p+455, 0x1.0000000000000p+375},
{-0x1.0000000100000p+167, 0x1.0000000000000p+88, 0x1.0000004000000p+455, -0x1.0000000000000p+375, 0x1.0000004000000p+455, -0x1.0000000000000p+375},
{-0x1.0000000100000p+167, 0x1.0000000000000p+88, -0x1.0000004000000p+455, 0x1.0000000000000p+375, -0x1.0000004000000p+455, 0x1.0000000000000p+375},
{0x1.0000010000000p+394, -0x1.ffffe00001000p+338, 0x1.000ffffff007fp-145, 0x1.ffffc00000000p-226, 0x1.0000010000000p+394, -0x1.ffffe00001000p+338},
{0x1.0000010000000p+394, -0x1.ffffe00001000p+338, -0x1.000ffffff007fp-145, -0x1.ffffc00000000p-226, 0x1.0000010000000p+394, -0x1.ffffe00001000p+338},
{-0x1.0000010000000p+394, 0x1.ffffe00001000p+338, 0x1.000ffffff007fp-145, 0x1.ffffc00000000p-226, -0x1.0000010000000p+394, 0x1.ffffe00001000p+338},
{-0x1.0000010000000p+394, 0x1.ffffe00001000p+338, -0x1.000ffffff007fp-145, -0x1.ffffc00000000p-226, -0x1.0000010000000p+394, 0x1.ffffe00001000p+338},
{0x1.1000fffffc000p+16, 0x1.fffffc003f000p-40, 0x1.0000000001000p+243, -0x1.0000000000000p+138, 0x1.0000000001000p+243, -0x1.0000000000000p+138},
{0x1.1000fffffc000p+16, 0x1.fffffc003f000p-40, -0x1.0000000001000p+243, 0x1.0000000000000p+138, -0x1.0000000001000p+243, 0x1.0000000000000p+138},
{-0x1.1000fffffc000p+16, -0x1.fffffc003f000p-40, 0x1.0000000001000p+243, -0x1.0000000000000p+138, 0x1.0000000001000p+243, -0x1.0000000000000p+138},
{-0x1.1000fffffc000p+16, -0x1.fffffc003f000p-40, -0x1.0000000001000p+243, 0x1.0000000000000p+138, -0x1.0000000001000p+243, 0x1.0000000000000p+138},
{0x1.00000fff80000p+494, 0x1.fffe000000000p+409, 0x1.0000001f00000p-623, 0x1.fffffff000000p-700, 0x1.00000fff80000p+494, 0x1.fffe000000000p+409},
{0x1.00000fff80000p+494, 0x1.fffe000000000p+409, -0x1.0000001f00000p-623, -0x1.fffffff000000p-700, 0x1.00000fff80000p+494, 0x1.fffe000000000p+409},
{-0x1.00000fff80000p+494, -0x1.fffe000000000p+409, 0x1.0000001f00000p-623, 0x1.fffffff000000p-700, -0x1.00000fff80000p+494, -0x1.fffe000000000p+409},
{-0x1.00000fff80000p+494, -0x1.fffe000000000p+409, -0x1.0000001f00000p-623, -0x1.fffffff000000p-700, -0x1.00000fff80000p+494, -0x1.fffe000000000p+409},
{0x1.3fdfffff02000p-533, -0x1.0000000000000p-611, 0x1.0000000000000p-602, 0x1.ffffffffffe00p-663, 0x1.3fdfffff02000p-533, 0x1.ff00000000000p-603},
{0x1.3fdfffff02000p-533, -0x1.0000000000000p-611, -0x1.0000000000000p-602, -0x1.ffffffffffe00p-663, 0x1.3fdfffff02000p-533, -0x1.0080000000000p-602},
{-0x1.3fdfffff02000p-533, 0x1.0000000000000p-611, 0x1.0000000000000p-602, 0x1.ffffffffffe00p-663, -0x1.3fdfffff02000p-533, 0x1.0080000000000p-602},
{-0x1.3fdfffff02000p-533, 0x1.0000000000000p-611, -0x1.0000000000000p-602, -0x1.ffffffffffe00p-663, -0x1.3fdfffff02000p-533, -0x1.ff00000000000p-603},
{0x1.0000000000008p-274, -0x1.e0ffffd002000p-340, 0x1.0000000000400p-229, 0x1.ffffffff03ffep-283, 0x1.0000000000480p-229, 0x1.ffffffff04ffep-283},
{0x1.0000000000008p-274, -0x1.e0ffffd002000p-340, -0x1.0000000000400p-229, -0x1.ffffffff03ffep-283, -0x1.0000000000380p-229, -0x1.ffffffff02ffep-283},
{-0x1.0000000000008p-274, 0x1.e0ffffd002000p-340, 0x1.0000000000400p-229, 0x1.ffffffff03ffep-283, 0x1.0000000000380p-229, 0x1.ffffffff02ffep-283},
{-0x1.0000000000008p-274, 0x1.e0ffffd002000p-340, -0x1.0000000000400p-229, -0x1.ffffffff03ffep-283, -0x1.0000000000480p-229, -0x1.ffffffff04ffep-283},
{0x1.000000fffe020p-113, -0x1.f800100000000p-186, 0x1.0001fff80ffc0p+13, 0x1.ff00000000000p-84, 0x1.0001fff80ffc0p+13, 0x1.ff00000000000p-84},
{0x1.000000fffe020p-113, -0x1.f800100000000p-186, -0x1.0001fff80ffc0p+13, -0x1.ff00000000000p-84, -0x1.0001fff80ffc0p+13, -0x1.ff00000000000p-84},
{-0x1.000000fffe020p-113, 0x1.f800100000000p-186, 0x1.0001fff80ffc0p+13, 0x1.ff00000000000p-84, 0x1.0001fff80ffc0p+13, 0x1.ff00000000000p-84},
{-0x1.000000fffe020p-113, 0x1.f800100000000p-186, -0x1.0001fff80ffc0p+13, -0x1.ff00000000000p-84, -0x1.0001fff80ffc0p+13, -0x1.ff00000000000p-84},
{0x1.4000000000000p+455, -0x1.0000000000000p+350, 0x1.0000000000010p-968, 0x1.e000000000000p-1036, 0x1.4000000000000p+455, -0x1.0000000000000p+350},
{0x1.4000000000000p+455, -0x1.0000000000000p+350, -0x1.0000000000010p-968, -0x1.e000000000000p-1036, 0x1.4000000000000p+455, -0x1.0000000000000p+350},
{-0x1.4000000000000p+455, 0x1.0000000000000p+350, 0x1.0000000000010p-968, 0x1.e000000000000p-1036, -0x1.4000000000000p+455, 0x1.0000000000000p+350},
{-0x1.4000000000000p+455, 0x1.0000000000000p+350, -0x1.0000000000010p-968, -0x1.e000000000000p-1036, -0x1.4000000000000p+455, 0x1.0000000000000p+350},
{0x1.2000000000000p+333, -0x1.fffffff01ff20p+276, 0x1.0000000000000p+701, 0x1.fff8003ff0000p+644, 0x1.0000000000000p+701, 0x1.fff8003ff0000p+644},
{0x1.2000000000000p+333, -0x1.fffffff01ff20p+276, -0x1.0000000000000p+701, -0x1.fff8003ff0000p+644, -0x1.0000000000000p+701, -0x1.fff8003ff0000p+644},
{-0x1.2000000000000p+333, 0x1.fffffff01ff20p+276, 0x1.0000000000000p+701, 0x1.fff8003ff0000p+644, 0x1.0000000000000p+701, 0x1.fff8003ff0000p+644},
{-0x1.2000000000000p+333, 0x1.fffffff01ff20p+276, -0x1.0000000000000p+701, -0x1.fff8003ff0000p+644, -0x1.0000000000000p+701, -0x1.fff8003ff0000p+644},
{0x1.2000000000000p+275, -0x1.fc08000000000p+183, 0x1.0000000038004p+750, -0x1.fffffc4000000p+681, 0x1.0000000038004p+750, -0x1.fffffc4000000p+681},
{0x1.2000000000000p+275, -0x1.fc08000000000p+183, -0x1.0000000038004p+750, 0x1.fffffc4000000p+681, -0x1.0000000038004p+750, 0x1.fffffc4000000p+681},
{-0x1.2000000000000p+275, 0x1.fc08000000000p+183, 0x1.0000000038004p+750, -0x1.fffffc4000000p+681, 0x1.0000000038004p+750, -0x1.fffffc4000000p+681},
{-0x1.2000000000000p+275, 0x1.fc08000000000p+183, -0x1.0000000038004p+750, 0x1.fffffc4000000p+681, -0x1.0000000038004p+750, 0x1.fffffc4000000p+681},
{0x1.0000000000200p+680, 0x0.0000000000000p+0, 0x1.00001ffff0000p-146, 0x1.ffff80001f000p-203, 0x1.0000000000200p+680, 0x0.0000000000000p+0},
{0x1.0000000000200p+680, 0x0.0000000000000p+0, -0x1.00001ffff0000p-146, -0x1.ffff80001f000p-203, 0x1.0000000000200p+680, 0x0.0000000000000p+0},
{-0x1.0000000000200p+680, 0x0.0000000000000p+0, 0x1.00001ffff0000p-146, 0x1.ffff80001f000p-203, -0x1.0000000000200p+680, 0x0.0000000000000p+0},
{-0x1.0000000000200p+680, 0x0.0000000000000p+0, -0x1.00001ffff0000p-146, -0x1.ffff80001f000p-203, -0x1.0000000000200p+680, 0x0.0000000000000p+0},
{0x1.0000100000000p-400, -0x1.0000000000000p-505, 0x1.0038000800000p-754, -0x1.fffffe0000080p-814, 0x1.0000100000000p-400, -0x1.0000000000000p-505},
{0x1.0000100000000p-400, -0x1.0000000000000p-505, -0x1.0038000800000p-754, 0x1.fffffe0000080p-814, 0x1.0000100000000p-400, -0x1.0000000000000p-505},
{-0x1.0000100000000p-400, 0x1.0000000000000p-505, 0x1.0038000800000p-754, -0x1.fffffe0000080p-814, -0x1.0000100000000p-400, 0x1.0000000000000p-505},
{-0x1.0000100000000p-400, 0x1.0000000000000p-505, -0x1.0038000800000p-754, 0x1.fffffe0000080p-814, -0x1.0000100000000p-400, 0x1.0000000000000p-505},
{0x1.0000000000004p+838, -0x1.ffffe00400000p+765, 0x1.0000000000000p-355, 0x1.ffffffffffff8p-411, 0x1.0000000000004p+838, -0x1.ffffe00400000p+765},
{0x1.0000000000004p+838, -0x1.ffffe00400000p+765, -0x1.0000000000000p-355, -0x1.ffffffffffff8p-411, 0x1.0000000000004p+838, -0x1.ffffe00400000p+765},
{-0x1.0000000000004p+838, 0x1.ffffe00400000p+765, 0x1.0000000000000p-355, 0x1.ffffffffffff8p-411, -0x1.0000000000004p+838, 0x1.ffffe00400000p+765},
{-0x1.0000000000004p+838, 0x1.ffffe00400000p+765, -0x1.0000000000000p-355, -0x1.ffffffffffff8p-411, -0x1.0000000000004p+838, 0x1.ffffe00400000p+765},
{0x1.0000000000100p+877, -0x1.ffffe7e400000p+807, 0x1.1ffe000008000p+922, -0x1.fffc000004000p+855, 0x1.1ffe000008080p+922, -0x1.fffbfc0004000p+855},
{0x1.0000000000100p+877, -0x1.ffffe7e400000p+807, -0x1.1ffe000008000p+922, 0x1.fffc000004000p+855, -0x1.1ffe000007f80p+922, 0x1.fffc040004000p+855},
{-0x1.0000000000100p+877, 0x1.ffffe7e400000p+807, 0x1.1ffe000008000p+922, -0x1.fffc000004000p+855, 0x1.1ffe000007f80p+922, -0x1.fffc040004000p+855},
{-0x1.0000000000100p+877, 0x1.ffffe7e400000p+807, -0x1.1ffe000008000p+922, 0x1.fffc000004000p+855, -0x1.1ffe000008080p+922, 0x1.fffbfc0004000p+855},
{0x1.0000000000004p-490, -0x1.0000000000000p-595, 0x1.00000007ffffep-352, 0x1.ffffe000f0000p-413, 0x1.00000007ffffep-352, 0x1.ffffe000f0000p-413},
{0x1.0000000000004p-490, -0x1.0000000000000p-595, -0x1.00000007ffffep-352, -0x1.ffffe000f0000p-413, -0x1.00000007ffffep-352, -0x1.ffffe000f0000p-413},
{-0x1.0000000000004p-490, 0x1.0000000000000p-595, 0x1.00000007ffffep-352, 0x1.ffffe000f0000p-413, 0x1.00000007ffffep-352, 0x1.ffffe000f0000p-413},
{-0x1.0000000000004p-490, 0x1.0000000000000p-595, -0x1.00000007ffffep-352, -0x1.ffffe000f0000p-413, -0x1.00000007ffffep-352, -0x1.ffffe000f0000p-413},
{0x1.0000000000000p-458, 0x1.fffffff000000p-519, 0x1.0001fffc00001p+791, -0x1.0000000000000p+712, 0x1.0001fffc00001p+791, -0x1.0000000000000p+712},
{0x1.0000000000000p-458, 0x1.fffffff000000p-519, -0x1.0001fffc00001p+791, 0x1.0000000000000p+712, -0x1.0001fffc00001p+791, 0x1.0000000000000p+712},
{-0x1.0000000000000p-458, -0x1.fffffff000000p-519, 0x1.0001fffc00001p+791, -0x1.0000000000000p+712, 0x1.0001fffc00001p+791, -0x1.0000000000000p+712},
{-0x1.0000000000000p-458, -0x1.fffffff000000p-519, -0x1.0001fffc00001p+791, 0x1.0000000000000p+712, -0x1.0001fffc00001p+791, 0x1.0000000000000p+712},
{0x1.00007fdfffff0p-745, 0x1.fff000f803fe0p-803, 0x1.0080000000000p-983, -0x0.0000000000000p+0, 0x1.00007fdfffff0p-745, 0x1.fff000f803fe0p-803},
{0x1.00007fdfffff0p-745, 0x1.fff000f803fe0p-803, -0x1.0080000000000p-983, 0x0.0000000000000p+0, 0x1.00007fdfffff0p-745, 0x1.fff000f803fe0p-803},
{-0x1.00007fdfffff0p-745, -0x1.fff000f803fe0p-803, 0x1.0080000000000p-983, -0x0.0000000000000p+0, -0x1.00007fdfffff0p-745, -0x1.fff000f803fe0p-803},
{-0x1.00007fdfffff0p-745, -0x1.fff000f803fe0p-803, -0x1.0080000000000p-983, 0x0.0000000000000p+0, -0x1.00007fdfffff0p-745, -0x1.fff000f803fe0p-803},
{0x1.0000000000080p-788, 0x0.0000000000000p+0, 0x1.0000080000000p+973, -0x1.0000000000000p+888, 0x1.0000080000000p+973, -0x1.0000000000000p+888},
{0x1.0000000000080p-788, 0x0.0000000000000p+0, -0x1.0000080000000p+973, 0x1.0000000000000p+888, -0x1.0000080000000p+973, 0x1.0000000000000p+888},
{-0x1.0000000000080p-788, 0x0.0000000000000p+0, 0x1.0000080000000p+973, -0x1.0000000000000p+888, 0x1.0000080000000p+973, -0x1.0000000000000p+888},
{-0x1.0000000000080p-788, 0x0.0000000000000p+0, -0x1.0000080000000p+973, 0x1.0000000000000p+888, -0x1.0000080000000p+973, 0x1.0000000000000p+888},
{0x1.0400000000000p-287, -0x1.0000000000000p-392, 0x1.0000000000400p+736, -0x1.fffff00008000p+680, 0x1.0000000000400p+736, -0x1.fffff00008000p+680},
{0x1.0400000000000p-287, -0x1.0000000000000p-392, -0x1.0000000000400p+736, 0x1.fffff00008000p+680, -0x1.0000000000400p+736, 0x1.fffff00008000p+680},
{-0x1.0400000000000p-287, 0x1.0000000000000p-392, 0x1.0000000000400p+736, -0x1.fffff00008000p+680, 0x1.0000000000400p+736, -0x1.fffff00008000p+680},
{-0x1.0400000000000p-287, 0x1.0000000000000p-392, -0x1.0000000000400p+736, 0x1.fffff00008000p+680, -0x1.0000000000400p+736, 0x1.fffff00008000p+680},
{0x1.0000000000001p+232, -0x1.fc0000c004000p+167, 0x1.0000000000200p+192, -0x1.ffe0000200000p+124, 0x1.0000000001001p+232, -0x1.fbffc0c004000p+167},
{0x1.0000000000001p+232, -0x1.fc0000c004000p+167, -0x1.0000000000200p+192, 0x1.ffe0000200000p+124, 0x1.fffffffffe002p+231, -0x1.fc0040c004000p+167},
{-0x1.0000000000001p+232, 0x1.fc0000c004000p+167, 0x1.0000000000200p+192, -0x1.ffe0000200000p+124, -0x1.fffffffffe002p+231, 0x1.fc0040c004000p+167},
{-0x1.0000000000001p+232, 0x1.fc0000c004000p+167, -0x1.0000000000200p+192, 0x1.ffe0000200000p+124, -0x1.0000000001001p+232, 0x1.fbffc0c004000p+167},
{0x1.00000c0000004p+583, -0x1.ff80000800000p+515, 0x1.18003ffff8000p-786, 0x1.ffffff8000000p-852, 0x1.00000c0000004p+583, -0x1.ff80000800000p+515},
{0x1.00000c0000004p+583, -0x1.ff80000800000p+515, -0x1.18003ffff8000p-786, -0x1.ffffff8000000p-852, 0x1.00000c0000004p+583, -0x1.ff80000800000p+515},
{-0x1.00000c0000004p+583, 0x1.ff80000800000p+515, 0x1.18003ffff8000p-786, 0x1.ffffff8000000p-852, -0x1.00000c0000004p+583, 0x1.ff80000800000p+515},
{-0x1.00000c0000004p+583, 0x1.ff80000800000p+515, -0x1.18003ffff8000p-786, -0x1.ffffff8000000p-852, -0x1.00000c0000004p+583, 0x1.ff80000800000p+515},
{0x1.1ffff80000040p+488, -0x1.0000000000000p+398, 0x1.000000000fe00p-510, 0x1.ffff7e0003ff8p-566, 0x1.1ffff80000040p+488, -0x1.0000000000000p+398},
{0x1.1ffff80000040p+488, -0x1.0000000000000p+398, -0x1.000000000fe00p-510, -0x1.ffff7e0003ff8p-566, 0x1.1ffff80000040p+488, -0x1.0000000000000p+398},
{-0x1.1ffff80000040p+488, 0x1.0000000000000p+398, 0x1.000000000fe00p-510, 0x1.ffff7e0003ff8p-566, -0x1.1ffff80000040p+488, 0x1.0000000000000p+398},
{-0x1.1ffff80000040p+488, 0x1.0000000000000p+398, -0x1.000000000fe00p-510, -0x1.ffff7e0003ff8p-566, -0x1.1ffff80000040p+488, 0x1.0000000000000p+398},
{0x1.3fc0000040000p+871, -0x1.fffffff802000p+815, 0x1.fffffffffff00p-663, 0x0.0000000000000p+0, 0x1.3fc0000040000p+871, -0x1.fffffff802000p+815},
{0x1.3fc0000040000p+871, -0x1.fffffff802000p+815, -0x1.fffffffffff00p-663, 0x0.0000000000000p+0, 0x1.3fc0000040000p+871, -0x1.fffffff802000p+815},
{-0x1.3fc0000040000p+871, 0x1.fffffff802000p+815, 0x1.fffffffffff00p-663, 0x0.0000000000000p+0, -0x1.3fc0000040000p+871, 0x1.fffffff802000p+815},
{-0x1.3fc0000040000p+871, 0x1.fffffff802000p+815, -0x1.fffffffffff00p-663, 0x0.0000000000000p+0, -0x1.3fc0000040000p+871, 0x1.fffffff802000p+815},
{0x1.00000001fffffp-628, 0x1.00001f8000000p-699, 0x1.0000000000200p-312, -0x1.0000000000000p-417, 0x1.0000000000200p-312, -0x1.0000000000000p-417},
{0x1.00000001fffffp-628, 0x1.00001f8000000p-699, -0x1.0000000000200p-312, 0x1.0000000000000p-417, -0x1.0000000000200p-312, 0x1.0000000000000p-417},
{-0x1.00000001fffffp-628, -0x1.00001f8000000p-699, 0x1.0000000000200p-312, -0x1.0000000000000p-417, 0x1.0000000000200p-312, -0x1.0000000000000p-417},
{-0x1.00000001fffffp-628, -0x1.00001f8000000p-699, -0x1.0000000000200p-312, 0x1.0000000000000p-417, -0x1.0000000000200p-312, 0x1.0000000000000p-417},
{0x1.0000000010000p+23, -0x1.0000000000000p-54, 0x1.1fff010000000p+322, 0x1.ff8c0000007fep+268, 0x1.1fff010000000p+322, 0x1.ff8c0000007fep+268},
{0x1.0000000010000p+23, -0x1.0000000000000p-54, -0x1.1fff010000000p+322, -0x1.ff8c0000007fep+268, -0x1.1fff010000000p+322, -0x1.ff8c0000007fep+268},
{-0x1.0000000010000p+23, 0x1.0000000000000p-54, 0x1.1fff010000000p+322, 0x1.ff8c0000007fep+268, 0x1.1fff010000000p+322, 0x1.ff8c0000007fep+268},
{-0x1.0000000010000p+23, 0x1.0000000000000p-54, -0x1.1fff010000000p+322, -0x1.ff8c0000007fep+268, -0x1.1fff010000000p+322, -0x1.ff8c0000007fep+268},
{0x1.0000000000002p-4, -0x1.0000000000000p-91, 0x1.0000000000200p+643, -0x1.0000000000000p+558, 0x1.0000000000200p+643, -0x1.0000000000000p+558},
{0x1.0000000000002p-4, -0x1.0000000000000p-91, -0x1.0000000000200p+643, 0x1.0000000000000p+558, -0x1.0000000000200p+643, 0x1.0000000000000p+558},
{-0x1.0000000000002p-4, 0x1.0000000000000p-91, 0x1.0000000000200p+643, -0x1.0000000000000p+558, 0x1.0000000000200p+643, -0x1.0000000000000p+558},
{-0x1.0000000000002p-4, 0x1.0000000000000p-91, -0x1.0000000000200p+643, 0x1.0000000000000p+558, -0x1.0000000000200p+643, 0x1.0000000000000p+558},
{0x1.0000000000002p-252, -0x1.ffff800008000p-319, 0x1.000000003fffep-236, 0x1.f81fc007c0000p-307, 0x1.000100003fffep-236, 0x1.1f7ffc00fc000p-303},
{0x1.0000000000002p-252, -0x1.ffff800008000p-319, -0x1.000000003fffep-236, -0x1.f81fc007c0000p-307, -0x1.fffe00007fffcp-237, 0x1.c0f8080008000p-304},
{-0x1.0000000000002p-252, 0x1.ffff800008000p-319, 0x1.000000003fffep-236, 0x1.f81fc007c0000p-307, 0x1.fffe00007fffcp-237, -0x1.c0f8080008000p-304},
{-0x1.0000000000002p-252, 0x1.ffff800008000p-319, -0x1.000000003fffep-236, -0x1.f81fc007c0000p-307, -0x1.000100003fffep-236, -0x1.1f7ffc00fc000p-303},
{0x1.7ffffffff0000p-1014, 0x0.0000000000000p+0, 0x1.000000000ffe0p-894, 0x1.ff0000003c000p-957, 0x1.000000000ffe0p-894, 0x1.ff0000003c000p-957},
{0x1.7ffffffff0000p-1014, 0x0.0000000000000p+0, -0x1.000000000ffe0p-894, -0x1.ff0000003c000p-957, -0x1.000000000ffe0p-894, -0x1.ff0000003c000p-957},
{-0x1.7ffffffff0000p-1014, -0x0.0000000000000p+0, 0x1.000000000ffe0p-894, 0x1.ff0000003c000p-957, 0x1.000000000ffe0p-894, 0x1.ff0000003c000p-957},
{-0x1.7ffffffff0000p-1014, -0x0.0000000000000p+0, -0x1.000000000ffe0p-894, -0x1.ff0000003c000p-957, -0x1.000000000ffe0p-894, -0x1.ff0000003c000p-957},
{0x1.00007fff00080p+981, -0x1.ffffff0001000p+916, 0x1.00000000007c0p-918, 0x1.ffffff8000000p-985, 0x1.00007fff00080p+981, -0x1.ffffff0001000p+916},
{0x1.00007fff00080p+981, -0x1.ffffff0001000p+916, -0x1.00000000007c0p-918, -0x1.ffffff8000000p-985, 0x1.00007fff00080p+981, -0x1.ffffff0001000p+916},
{-0x1.00007fff00080p+981, 0x1.ffffff0001000p+916, 0x1.00000000007c0p-918, 0x1.ffffff8000000p-985, -0x1.00007fff00080p+981, 0x1.ffffff0001000p+916},
{-0x1.00007fff00080p+981, 0x1.ffffff0001000p+916, -0x1.00000000007c0p-918, -0x1.ffffff8000000p-985, -0x1.00007fff00080p+981, 0x1.ffffff0001000p+916},
{0x1.1fff81ff00000p-768, 0x1.e007ffff00000p-825, 0x1.1ffffffff8000p-236, 0x1.fe001ffffffe0p-292, 0x1.1ffffffff8000p-236, 0x1.fe001ffffffe0p-292},
{0x1.1fff81ff00000p-768, 0x1.e007ffff00000p-825, -0x1.1ffffffff8000p-236, -0x1.fe001ffffffe0p-292, -0x1.1ffffffff8000p-236, -0x1.fe001ffffffe0p-292},
{-0x1.1fff81ff00000p-768, -0x1.e007ffff00000p-825, 0x1.1ffffffff8000p-236, 0x1.fe001ffffffe0p-292, 0x1.1ffffffff8000p-236, 0x1.fe001ffffffe0p-292},
{-0x1.1fff81ff00000p-768, -0x1.e007ffff00000p-825, -0x1.1ffffffff8000p-236, -0x1.fe001ffffffe0p-292, -0x1.1ffffffff8000p-236, -0x1.fe001ffffffe0p-292},
{0x1.0000000000000p-141, 0x1.fffc03fe00700p-202, 0x1.0000000000001p-845, -0x1.fff8060000f34p-900, 0x1.0000000000000p-141, 0x1.fffc03fe00700p-202},
{0x1.0000000000000p-141, 0x1.fffc03fe00700p-202, -0x1.0000000000001p-845, 0x1.fff8060000f34p-900, 0x1.0000000000000p-141, 0x1.fffc03fe00700p-202},
{-0x1.0000000000000p-141, -0x1.fffc03fe00700p-202, 0x1.0000000000001p-845, -0x1.fff8060000f34p-900, -0x1.0000000000000p-141, -0x1.fffc03fe00700p-202},
{-0x1.0000000000000p-141, -0x1.fffc03fe00700p-202, -0x1.0000000000001p-845, 0x1.fff8060000f34p-900, -0x1.0000000000000p-141, -0x1.fffc03fe00700p-202},
{0x1.001ffffc00080p+872, -0x1.fe00000200000p+811, 0x1.0000000001000p-359, -0x1.fe3ffffff0080p-419, 0x1.001ffffc00080p+872, -0x1.fe00000200000p+811},
{0x1.001ffffc00080p+872, -0x1.fe00000200000p+811, -0x1.0000000001000p-359, 0x1.fe3ffffff0080p-419, 0x1.001ffffc00080p+872, -0x1.fe00000200000p+811},
{-0x1.001ffffc00080p+872, 0x1.fe00000200000p+811, 0x1.0000000001000p-359, -0x1.fe3ffffff0080p-419, -0x1.001ffffc00080p+872, 0x1.fe00000200000p+811},
{-0x1.001ffffc00080p+872, 0x1.fe00000200000p+811, -0x1.0000000001000p-359, 0x1.fe3ffffff0080p-419, -0x1.001ffffc00080p+872, 0x1.fe00000200000p+811},
{0x1.00001fffff800p-894, 0x1.ffffff801ffc0p-953, 0x1.0000000002000p-720, -0x1.0000000000000p-825, 0x1.0000000002000p-720, -0x1.0000000000000p-825},
{0x1.00001fffff800p-894, 0x1.ffffff801ffc0p-953, -0x1.0000000002000p-720, 0x1.0000000000000p-825, -0x1.0000000002000p-720, 0x1.0000000000000p-825},
{-0x1.00001fffff800p-894, -0x1.ffffff801ffc0p-953, 0x1.0000000002000p-720, -0x1.0000000000000p-825, 0x1.0000000002000p-720, -0x1.0000000000000p-825},
{-0x1.00001fffff800p-894, -0x1.ffffff801ffc0p-953, -0x1.0000000002000p-720, 0x1.0000000000000p-825, -0x1.0000000002000p-720, 0x1.0000000000000p-825},
{0x1.0000000000000p-30, 0x1.ffff83ffbfff0p-86, 0x1.0000000000000p-240, 0x1.ffffffffe0000p-296, 0x1.0000000000000p-30, 0x1.ffff83ffbfff0p-86},
{0x1.0000000000000p-30, 0x1.ffff83ffbfff0p-86, -0x1.0000000000000p-240, -0x1.ffffffffe0000p-296, 0x1.0000000000000p-30, 0x1.ffff83ffbfff0p-86},
{-0x1.0000000000000p-30, -0x1.ffff83ffbfff0p-86, 0x1.0000000000000p-240, 0x1.ffffffffe0000p-296, -0x1.0000000000000p-30, -0x1.ffff83ffbfff0p-86},
{-0x1.0000000000000p-30, -0x1.ffff83ffbfff0p-86, -0x1.0000000000000p-240, -0x1.ffffffffe0000p-296, -0x1.0000000000000p-30, -0x1.ffff83ffbfff0p-86},
{0x1.0000000000000p-874, 0x1.fffe7ff3dff00p-935, 0x1.000007f830000p-977, 0x1.fff0001000000p-1038, 0x1.0000000000000p-874, 0x1.fffe7ff3e0300p-935},
{0x1.0000000000000p-874, 0x1.fffe7ff3dff00p-935, -0x1.000007f830000p-977, -0x1.fff0001000000p-1038, 0x1.0000000000000p-874, 0x1.fffe7ff3dfb00p-935},
{-0x1.0000000000000p-874, -0x1.fffe7ff3dff00p-935, 0x1.000007f830000p-977, 0x1.fff0001000000p-1038, -0x1.0000000000000p-874, -0x1.fffe7ff3dfb00p-935},
{-0x1.0000000000000p-874, -0x1.fffe7ff3dff00p-935, -0x1.000007f830000p-977, -0x1.fff0001000000p-1038, -0x1.0000000000000p-874, -0x1.fffe7ff3e0300p-935},
{0x1.00000ffffe000p-269, 0x1.fffffffffc000p-336, 0x1.0000000000002p+226, -0x1.fffffe01f8004p+171, 0x1.0000000000002p+226, -0x1.fffffe01f8004p+171},
{0x1.00000ffffe000p-269, 0x1.fffffffffc000p-336, -0x1.0000000000002p+226, 0x1.fffffe01f8004p+171, -0x1.0000000000002p+226, 0x1.fffffe01f8004p+171},
{-0x1.00000ffffe000p-269, -0x1.fffffffffc000p-336, 0x1.0000000000002p+226, -0x1.fffffe01f8004p+171, 0x1.0000000000002p+226, -0x1.fffffe01f8004p+171},
{-0x1.00000ffffe000p-269, -0x1.fffffffffc000p-336, -0x1.0000000000002p+226, 0x1.fffffe01f8004p+171, -0x1.0000000000002p+226, 0x1.fffffe01f8004p+171},
{0x1.0000000000060p+403, 0x1.fffe3fff00000p+340, 0x1.0000000002000p+783, -0x1.ffe0002000000p+726, 0x1.0000000002000p+783, -0x1.ffe0002000000p+726},
{0x1.0000000000060p+403, 0x1.fffe3fff00000p+340, -0x1.0000000002000p+783, 0x1.ffe0002000000p+726, -0x1.0000000002000p+783, 0x1.ffe0002000000p+726},
{-0x1.0000000000060p+403, -0x1.fffe3fff00000p+340, 0x1.0000000002000p+783, -0x1.ffe0002000000p+726, 0x1.0000000002000p+783, -0x1.ffe0002000000p+726},
{-0x1.0000000000060p+403, -0x1.fffe3fff00000p+340, -0x1.0000000002000p+783, 0x1.ffe0002000000p+726, -0x1.0000000002000p+783, 0x1.ffe0002000000p+726},
{0x1.0003ffffffff8p-273, 0x1.ffffe07e00000p-347, 0x1.07ff000008000p-591, -0x1.e000020000000p-652, 0x1.0003ffffffff8p-273, 0x1.ffffe07e00000p-347},
{0x1.0003ffffffff8p-273, 0x1.ffffe07e00000p-347, -0x1.07ff000008000p-591, 0x1.e000020000000p-652, 0x1.0003ffffffff8p-273, 0x1.ffffe07e00000p-347},
{-0x1.0003ffffffff8p-273, -0x1.ffffe07e00000p-347, 0x1.07ff000008000p-591, -0x1.e000020000000p-652, -0x1.0003ffffffff8p-273, -0x1.ffffe07e00000p-347},
{-0x1.0003ffffffff8p-273, -0x1.ffffe07e00000p-347, -0x1.07ff000008000p-591, 0x1.e000020000000p-652, -0x1.0003ffffffff8p-273, -0x1.ffffe07e00000p-347},
// Some test cases where a and b are guaranteed to overlap:
{0x1.0000000000002p-39, -0x1.ffc0ffff90000p-103, 0x1.0003ffffffffcp-35, 0x1.ffffc00000000p-122, 0x1.1003ffffffffcp-35, 0x1.ffe003f400068p-91},
{0x1.0000000000002p-39, -0x1.ffc0ffff90000p-103, -0x1.0003ffffffffcp-35, -0x1.ffffc00000000p-122, -0x1.e007ffffffff8p-36, 0x1.ffe003ec00078p-91},
{-0x1.0000000000002p-39, 0x1.ffc0ffff90000p-103, 0x1.0003ffffffffcp-35, 0x1.ffffc00000000p-122, 0x1.e007ffffffff8p-36, -0x1.ffe003ec00078p-91},
{-0x1.0000000000002p-39, 0x1.ffc0ffff90000p-103, -0x1.0003ffffffffcp-35, -0x1.ffffc00000000p-122, -0x1.1003ffffffffcp-35, -0x1.ffe003f400068p-91},
{0x1.0000100000000p+23, -0x1.0000000000000p-39, 0x1.0000000004000p-41, -0x1.ffffe00fc0200p-97, 0x1.0000100000000p+23, -0x1.7ffffffffe000p-40},
{0x1.0000100000000p+23, -0x1.0000000000000p-39, -0x1.0000000004000p-41, 0x1.ffffe00fc0200p-97, 0x1.0000100000000p+23, -0x1.4000000001000p-39},
{-0x1.0000100000000p+23, 0x1.0000000000000p-39, 0x1.0000000004000p-41, -0x1.ffffe00fc0200p-97, -0x1.0000100000000p+23, 0x1.4000000001000p-39},
{-0x1.0000100000000p+23, 0x1.0000000000000p-39, -0x1.0000000004000p-41, 0x1.ffffe00fc0200p-97, -0x1.0000100000000p+23, 0x1.7ffffffffe000p-40},
{0x1.0000000800000p-42, -0x1.0000000000000p-114, 0x1.000003fffc002p-41, -0x1.0000000000000p-146, 0x1.80000403fc002p-41, -0x1.0000000100000p-114},
{0x1.0000000800000p-42, -0x1.0000000000000p-114, -0x1.000003fffc002p-41, 0x1.0000000000000p-146, -0x1.000007f7f8004p-42, -0x1.fffffffe00000p-115},
{-0x1.0000000800000p-42, 0x1.0000000000000p-114, 0x1.000003fffc002p-41, -0x1.0000000000000p-146, 0x1.000007f7f8004p-42, 0x1.fffffffe00000p-115},
{-0x1.0000000800000p-42, 0x1.0000000000000p-114, -0x1.000003fffc002p-41, 0x1.0000000000000p-146, -0x1.80000403fc002p-41, 0x1.0000000100000p-114},
{0x1.0000000000000p+46, 0x1.ffc001ffffe00p-9, 0x1.000003fff8000p-19, 0x1.fffc000fc0000p-90, 0x1.0000000000000p+46, 0x1.000001007fef0p-8},
{0x1.0000000000000p+46, 0x1.ffc001ffffe00p-9, -0x1.000003fff8000p-19, -0x1.fffc000fc0000p-90, 0x1.0000000000000p+46, 0x1.ff8001feffe20p-9},
{-0x1.0000000000000p+46, -0x1.ffc001ffffe00p-9, 0x1.000003fff8000p-19, 0x1.fffc000fc0000p-90, -0x1.0000000000000p+46, -0x1.ff8001feffe20p-9},
{-0x1.0000000000000p+46, -0x1.ffc001ffffe00p-9, -0x1.000003fff8000p-19, -0x1.fffc000fc0000p-90, -0x1.0000000000000p+46, -0x1.000001007fef0p-8},
{0x1.0000000000003p+33, 0x1.fc00001fff800p-31, 0x1.0000000000020p+40, -0x1.fc01ffe002000p-24, 0x1.0200000000020p+40, 0x1.781fd80080f80p-18},
{0x1.0000000000003p+33, 0x1.fc00001fff800p-31, -0x1.0000000000020p+40, 0x1.fc01ffe002000p-24, -0x1.fc00000000040p+39, 0x1.87ffe7ff81080p-18},
{-0x1.0000000000003p+33, -0x1.fc00001fff800p-31, 0x1.0000000000020p+40, -0x1.fc01ffe002000p-24, 0x1.fc00000000040p+39, -0x1.87ffe7ff81080p-18},
{-0x1.0000000000003p+33, -0x1.fc00001fff800p-31, -0x1.0000000000020p+40, 0x1.fc01ffe002000p-24, -0x1.0200000000020p+40, -0x1.781fd80080f80p-18},
{0x1.0000000000000p-42, 0x1.fffff00001ffep-96, 0x1.0000000000000p-9, 0x1.ff00000ffff80p-69, 0x1.0000000080000p-9, 0x1.ff00004ffff80p-69},
{0x1.0000000000000p-42, 0x1.fffff00001ffep-96, -0x1.0000000000000p-9, -0x1.ff00000ffff80p-69, -0x1.ffffffff00000p-10, -0x1.feffffcffff80p-69},
{-0x1.0000000000000p-42, -0x1.fffff00001ffep-96, 0x1.0000000000000p-9, 0x1.ff00000ffff80p-69, 0x1.ffffffff00000p-10, 0x1.feffffcffff80p-69},
{-0x1.0000000000000p-42, -0x1.fffff00001ffep-96, -0x1.0000000000000p-9, -0x1.ff00000ffff80p-69, -0x1.0000000080000p-9, -0x1.ff00004ffff80p-69},
{0x1.0000000000000p-46, 0x1.ffffffffffc00p-109, 0x1.0000200000000p+11, -0x1.ffc0000080000p-61, 0x1.0000200000000p+11, 0x1.fff800fffffe0p-47},
{0x1.0000000000000p-46, 0x1.ffffffffffc00p-109, -0x1.0000200000000p+11, 0x1.ffc0000080000p-61, -0x1.0000200000000p+11, 0x1.0003ff8000010p-46},
{-0x1.0000000000000p-46, -0x1.ffffffffffc00p-109, 0x1.0000200000000p+11, -0x1.ffc0000080000p-61, 0x1.0000200000000p+11, -0x1.0003ff8000010p-46},
{-0x1.0000000000000p-46, -0x1.ffffffffffc00p-109, -0x1.0000200000000p+11, 0x1.ffc0000080000p-61, -0x1.0000200000000p+11, -0x1.fff800fffffe0p-47},
{0x1.0000000000800p-4, -0x1.fffc000000010p-61, 0x1.0000000000008p-2, -0x1.ffe03fffff010p-59, 0x1.4000000000208p-2, -0x1.3fef9fffff808p-58},
{0x1.0000000000800p-4, -0x1.fffc000000010p-61, -0x1.0000000000008p-2, 0x1.ffe03fffff010p-59, -0x1.7fffffffffc10p-3, 0x1.7fe13fffff010p-59},
{-0x1.0000000000800p-4, 0x1.fffc000000010p-61, 0x1.0000000000008p-2, -0x1.ffe03fffff010p-59, 0x1.7fffffffffc10p-3, -0x1.7fe13fffff010p-59},
{-0x1.0000000000800p-4, 0x1.fffc000000010p-61, -0x1.0000000000008p-2, 0x1.ffe03fffff010p-59, -0x1.4000000000208p-2, 0x1.3fef9fffff808p-58},
{0x1.0000000000000p-39, 0x1.fffef0ffff000p-102, 0x1.0000100000000p-7, -0x1.fff8000000800p-71, 0x1.0000100100000p-7, -0x1.fff7fffc00800p-71},
{0x1.0000000000000p-39, 0x1.fffef0ffff000p-102, -0x1.0000100000000p-7, 0x1.fff8000000800p-71, -0x1.00000fff00000p-7, 0x1.fff8000400800p-71},
{-0x1.0000000000000p-39, -0x1.fffef0ffff000p-102, 0x1.0000100000000p-7, -0x1.fff8000000800p-71, 0x1.00000fff00000p-7, -0x1.fff8000400800p-71},
{-0x1.0000000000000p-39, -0x1.fffef0ffff000p-102, -0x1.0000100000000p-7, 0x1.fff8000000800p-71, -0x1.0000100100000p-7, 0x1.fff7fffc00800p-71},
{0x1.07c00007ffff0p-15, 0x1.fffc00f800000p-91, 0x1.0000007ffffe0p-11, 0x1.f000000000000p-82, 0x1.107c00807ffdfp-11, 0x1.f0fffe0080000p-82},
{0x1.07c00007ffff0p-15, 0x1.fffc00f800000p-91, -0x1.0000007ffffe0p-11, -0x1.f000000000000p-82, -0x1.df0800fefffc2p-12, -0x1.ef0001ff80000p-82},
{-0x1.07c00007ffff0p-15, -0x1.fffc00f800000p-91, 0x1.0000007ffffe0p-11, 0x1.f000000000000p-82, 0x1.df0800fefffc2p-12, 0x1.ef0001ff80000p-82},
{-0x1.07c00007ffff0p-15, -0x1.fffc00f800000p-91, -0x1.0000007ffffe0p-11, -0x1.f000000000000p-82, -0x1.107c00807ffdfp-11, -0x1.f0fffe0080000p-82},
{0x1.0000000000000p+37, 0x1.ff800fffff800p-19, 0x1.0000000000000p-32, 0x1.fffc0000ffff8p-88, 0x1.0000000000000p+37, 0x1.ff880fffff800p-19},
{0x1.0000000000000p+37, 0x1.ff800fffff800p-19, -0x1.0000000000000p-32, -0x1.fffc0000ffff8p-88, 0x1.0000000000000p+37, 0x1.ff780fffff800p-19},
{-0x1.0000000000000p+37, -0x1.ff800fffff800p-19, 0x1.0000000000000p-32, 0x1.fffc0000ffff8p-88, -0x1.0000000000000p+37, -0x1.ff780fffff800p-19},
{-0x1.0000000000000p+37, -0x1.ff800fffff800p-19, -0x1.0000000000000p-32, -0x1.fffc0000ffff8p-88, -0x1.0000000000000p+37, -0x1.ff880fffff800p-19},
{0x1.0000000008000p+44, -0x1.ffff807ffe002p-10, 0x1.0000000800000p-6, -0x1.ffffff8000008p-62, 0x1.0000000008004p+44, -0x1.ffff7ffffe004p-10},
{0x1.0000000008000p+44, -0x1.ffff807ffe002p-10, -0x1.0000000800000p-6, 0x1.ffffff8000008p-62, 0x1.0000000007ffcp+44, -0x1.ffff80fffe000p-10},
{-0x1.0000000008000p+44, 0x1.ffff807ffe002p-10, 0x1.0000000800000p-6, -0x1.ffffff8000008p-62, -0x1.0000000007ffcp+44, 0x1.ffff80fffe000p-10},
{-0x1.0000000008000p+44, 0x1.ffff807ffe002p-10, -0x1.0000000800000p-6, 0x1.ffffff8000008p-62, -0x1.0000000008004p+44, 0x1.ffff7ffffe004p-10},
{0x1.0000000000020p-53, -0x1.0000000000000p-136, 0x1.0000000000000p+33, 0x1.fffff000003c0p-26, 0x1.0000000000000p+33, 0x1.fffff020003c0p-26},
{0x1.0000000000020p-53, -0x1.0000000000000p-136, -0x1.0000000000000p+33, -0x1.fffff000003c0p-26, -0x1.0000000000000p+33, -0x1.ffffefe0003c0p-26},
{-0x1.0000000000020p-53, 0x1.0000000000000p-136, 0x1.0000000000000p+33, 0x1.fffff000003c0p-26, 0x1.0000000000000p+33, 0x1.ffffefe0003c0p-26},
{-0x1.0000000000020p-53, 0x1.0000000000000p-136, -0x1.0000000000000p+33, -0x1.fffff000003c0p-26, -0x1.0000000000000p+33, -0x1.fffff020003c0p-26},
{0x1.0000001ffff80p-7, 0x1.fffffdfffff8ep-61, 0x1.0000000200000p-27, -0x1.0000000000000p-96, 0x1.0000101ffff82p-7, 0x1.fffffdffdff8ep-61},
{0x1.0000001ffff80p-7, 0x1.fffffdfffff8ep-61, -0x1.0000000200000p-27, 0x1.0000000000000p-96, 0x1.ffffe03fffefdp-8, -0x1.ffe0072000000p-85},
{-0x1.0000001ffff80p-7, -0x1.fffffdfffff8ep-61, 0x1.0000000200000p-27, -0x1.0000000000000p-96, -0x1.ffffe03fffefdp-8, 0x1.ffe0072000000p-85},
{-0x1.0000001ffff80p-7, -0x1.fffffdfffff8ep-61, -0x1.0000000200000p-27, 0x1.0000000000000p-96, -0x1.0000101ffff82p-7, -0x1.fffffdffdff8ep-61},
{0x1.01ffffff80400p-38, -0x1.c7ffffc000100p-96, 0x1.0000000000000p-47, 0x1.8fff01fffff00p-107, 0x1.027fffff80400p-38, -0x1.c7cdffdfc0100p-96},
{0x1.01ffffff80400p-38, -0x1.c7ffffc000100p-96, -0x1.0000000000000p-47, -0x1.8fff01fffff00p-107, 0x1.017fffff80400p-38, -0x1.c831ffa040100p-96},
{-0x1.01ffffff80400p-38, 0x1.c7ffffc000100p-96, 0x1.0000000000000p-47, 0x1.8fff01fffff00p-107, -0x1.017fffff80400p-38, 0x1.c831ffa040100p-96},
{-0x1.01ffffff80400p-38, 0x1.c7ffffc000100p-96, -0x1.0000000000000p-47, -0x1.8fff01fffff00p-107, -0x1.027fffff80400p-38, 0x1.c7cdffdfc0100p-96},
{0x1.0000000000008p-27, -0x1.ffffc00800000p-100, 0x1.00003ffe00002p+16, -0x1.ffffffc180080p-44, 0x1.00003ffe00202p+16, -0x1.ffffffc080080p-44},
{0x1.0000000000008p-27, -0x1.ffffc00800000p-100, -0x1.00003ffe00002p+16, 0x1.ffffffc180080p-44, -0x1.00003ffdffe02p+16, 0x1.ffffffc280080p-44},
{-0x1.0000000000008p-27, 0x1.ffffc00800000p-100, 0x1.00003ffe00002p+16, -0x1.ffffffc180080p-44, 0x1.00003ffdffe02p+16, -0x1.ffffffc280080p-44},
{-0x1.0000000000008p-27, 0x1.ffffc00800000p-100, -0x1.00003ffe00002p+16, 0x1.ffffffc180080p-44, -0x1.00003ffe00202p+16, 0x1.ffffffc080080p-44},
{0x1.000000ffffff8p+16, 0x1.ffffffc000000p-41, 0x1.0000000000000p+8, 0x1.ffffffe000000p-50, 0x1.010000ffffff8p+16, 0x1.007fffdff8000p-40},
{0x1.000000ffffff8p+16, 0x1.ffffffc000000p-41, -0x1.0000000000000p+8, -0x1.ffffffe000000p-50, 0x1.fe0001ffffff0p+15, 0x1.feffffc010000p-41},
{-0x1.000000ffffff8p+16, -0x1.ffffffc000000p-41, 0x1.0000000000000p+8, 0x1.ffffffe000000p-50, -0x1.fe0001ffffff0p+15, -0x1.feffffc010000p-41},
{-0x1.000000ffffff8p+16, -0x1.ffffffc000000p-41, -0x1.0000000000000p+8, -0x1.ffffffe000000p-50, -0x1.010000ffffff8p+16, -0x1.007fffdff8000p-40},
{0x1.0000000020000p-39, -0x1.0000000000000p-144, 0x1.0000000000400p-40, -0x1.ff1ffffff4000p-107, 0x1.8000000020200p-39, -0x1.ff20000000000p-107},
{0x1.0000000020000p-39, -0x1.0000000000000p-144, -0x1.0000000000400p-40, 0x1.ff1ffffff4000p-107, 0x1.000000003fc00p-40, 0x1.ff1fffffec000p-107},
{-0x1.0000000020000p-39, 0x1.0000000000000p-144, 0x1.0000000000400p-40, -0x1.ff1ffffff4000p-107, -0x1.000000003fc00p-40, -0x1.ff1fffffec000p-107},
{-0x1.0000000020000p-39, 0x1.0000000000000p-144, -0x1.0000000000400p-40, 0x1.ff1ffffff4000p-107, -0x1.8000000020200p-39, 0x1.ff20000000000p-107},
{0x1.0000ff8020000p-18, -0x1.fffffa0000000p-80, 0x1.0000000001ff0p+30, 0x1.f700000ffe000p-36, 0x1.0000000002000p+30, 0x1.7d402003ff800p-34},
{0x1.0000ff8020000p-18, -0x1.fffffa0000000p-80, -0x1.0000000001ff0p+30, -0x1.f700000ffe000p-36, -0x1.0000000001fe0p+30, 0x1.03803ff801000p-35},
{-0x1.0000ff8020000p-18, 0x1.fffffa0000000p-80, 0x1.0000000001ff0p+30, 0x1.f700000ffe000p-36, 0x1.0000000001fe0p+30, -0x1.03803ff801000p-35},
{-0x1.0000ff8020000p-18, 0x1.fffffa0000000p-80, -0x1.0000000001ff0p+30, -0x1.f700000ffe000p-36, -0x1.0000000002000p+30, -0x1.7d402003ff800p-34},
{0x1.0000020000000p+8, -0x1.0000000000000p-56, 0x1.003e00001f800p-14, 0x1.ffde000001e00p-76, 0x1.00000600f8000p+8, 0x1.f400007ff7800p-50},
{0x1.0000020000000p+8, -0x1.0000000000000p-56, -0x1.003e00001f800p-14, -0x1.ffde000001e00p-76, 0x1.fffffbfe10000p+7, -0x1.fc00007ff7800p-50},
{-0x1.0000020000000p+8, 0x1.0000000000000p-56, 0x1.003e00001f800p-14, 0x1.ffde000001e00p-76, -0x1.fffffbfe10000p+7, 0x1.fc00007ff7800p-50},
{-0x1.0000020000000p+8, 0x1.0000000000000p-56, -0x1.003e00001f800p-14, -0x1.ffde000001e00p-76, -0x1.00000600f8000p+8, -0x1.f400007ff7800p-50},
{0x1.0007e3ffe0000p-24, 0x1.fe0ffffffe000p-88, 0x1.0000000000000p+0, 0x1.fffffe07fff00p-61, 0x1.0000010007e40p+0, -0x1.000000dc1f080p-60},
{0x1.0007e3ffe0000p-24, 0x1.fe0ffffffe000p-88, -0x1.0000000000000p+0, -0x1.fffffe07fff00p-61, -0x1.fffffdfff0380p-1, -0x1.7fffff720f7c0p-59},
{-0x1.0007e3ffe0000p-24, -0x1.fe0ffffffe000p-88, 0x1.0000000000000p+0, 0x1.fffffe07fff00p-61, 0x1.fffffdfff0380p-1, 0x1.7fffff720f7c0p-59},
{-0x1.0007e3ffe0000p-24, -0x1.fe0ffffffe000p-88, -0x1.0000000000000p+0, -0x1.fffffe07fff00p-61, -0x1.0000010007e40p+0, 0x1.000000dc1f080p-60},
{0x1.00000000fe000p+38, 0x1.ff00004000000p-29, 0x1.000003fffff80p-32, 0x1.fff8400000000p-92, 0x1.00000000fe000p+38, 0x1.0f80006000000p-28},
{0x1.00000000fe000p+38, 0x1.ff00004000000p-29, -0x1.000003fffff80p-32, -0x1.fff8400000000p-92, 0x1.00000000fe000p+38, 0x1.deffffc000000p-29},
{-0x1.00000000fe000p+38, -0x1.ff00004000000p-29, 0x1.000003fffff80p-32, 0x1.fff8400000000p-92, -0x1.00000000fe000p+38, -0x1.deffffc000000p-29},
{-0x1.00000000fe000p+38, -0x1.ff00004000000p-29, -0x1.000003fffff80p-32, -0x1.fff8400000000p-92, -0x1.00000000fe000p+38, -0x1.0f80006000000p-28},
{0x1.0000800000000p-9, -0x1.0000000000000p-65, 0x1.0000000000000p-51, 0x1.fffffffc1fc00p-114, 0x1.0000800000400p-9, -0x1.fffffffffffe0p-66},
{0x1.0000800000000p-9, -0x1.0000000000000p-65, -0x1.0000000000000p-51, -0x1.fffffffc1fc00p-114, 0x1.00007fffffc00p-9, -0x1.0000000000010p-65},
{-0x1.0000800000000p-9, 0x1.0000000000000p-65, 0x1.0000000000000p-51, 0x1.fffffffc1fc00p-114, -0x1.00007fffffc00p-9, 0x1.0000000000010p-65},
{-0x1.0000800000000p-9, 0x1.0000000000000p-65, -0x1.0000000000000p-51, -0x1.fffffffc1fc00p-114, -0x1.0000800000400p-9, 0x1.fffffffffffe0p-66},
{0x1.0000000000000p-40, 0x1.ff000ff3ffe00p-94, 0x1.0000000000000p-18, 0x1.fe0003fffc000p-77, 0x1.0000040000000p-18, 0x1.fe01038003f80p-77},
{0x1.0000000000000p-40, 0x1.ff000ff3ffe00p-94, -0x1.0000000000000p-18, -0x1.fe0003fffc000p-77, -0x1.fffff80000000p-19, -0x1.fdff047ff4060p-77},
{-0x1.0000000000000p-40, -0x1.ff000ff3ffe00p-94, 0x1.0000000000000p-18, 0x1.fe0003fffc000p-77, 0x1.fffff80000000p-19, 0x1.fdff047ff4060p-77},
{-0x1.0000000000000p-40, -0x1.ff000ff3ffe00p-94, -0x1.0000000000000p-18, -0x1.fe0003fffc000p-77, -0x1.0000040000000p-18, -0x1.fe01038003f80p-77},
{0x1.000000e000010p-12, -0x1.ffffffc020000p-82, 0x1.00000001f0000p-4, 0x1.8000000000000p-108, 0x1.01000002d0000p-4, 0x1.fffff00000050p-61},
{0x1.000000e000010p-12, -0x1.ffffffc020000p-82, -0x1.00000001f0000p-4, -0x1.8000000000000p-108, -0x1.fe00000220000p-5, 0x1.ffffefffffff0p-61},
{-0x1.000000e000010p-12, 0x1.ffffffc020000p-82, 0x1.00000001f0000p-4, 0x1.8000000000000p-108, 0x1.fe00000220000p-5, -0x1.ffffefffffff0p-61},
{-0x1.000000e000010p-12, 0x1.ffffffc020000p-82, -0x1.00000001f0000p-4, -0x1.8000000000000p-108, -0x1.01000002d0000p-4, -0x1.fffff00000050p-61},
{0x1.000003ff00000p+23, 0x1.8000000000000p-54, 0x1.0001ffffe0000p-39, 0x1.f800000100000p-112, 0x1.000003ff00000p+23, 0x1.0004ffffe0000p-39},
{0x1.000003ff00000p+23, 0x1.8000000000000p-54, -0x1.0001ffffe0000p-39, -0x1.f800000100000p-112, 0x1.000003ff00000p+23, -0x1.fffdffffc0000p-40},
{-0x1.000003ff00000p+23, -0x1.8000000000000p-54, 0x1.0001ffffe0000p-39, 0x1.f800000100000p-112, -0x1.000003ff00000p+23, 0x1.fffdffffc0000p-40},
{-0x1.000003ff00000p+23, -0x1.8000000000000p-54, -0x1.0001ffffe0000p-39, -0x1.f800000100000p-112, -0x1.000003ff00000p+23, -0x1.0004ffffe0000p-39},
{0x1.0000000000200p+14, -0x1.ffffffffffc08p-42, 0x1.0000000000000p-48, 0x1.ffffffffffffep-102, 0x1.0000000000200p+14, -0x1.fbffffffffc08p-42},
{0x1.0000000000200p+14, -0x1.ffffffffffc08p-42, -0x1.0000000000000p-48, -0x1.ffffffffffffep-102, 0x1.0000000000200p+14, -0x1.01ffffffffe04p-41},
{-0x1.0000000000200p+14, 0x1.ffffffffffc08p-42, 0x1.0000000000000p-48, 0x1.ffffffffffffep-102, -0x1.0000000000200p+14, 0x1.01ffffffffe04p-41},
{-0x1.0000000000200p+14, 0x1.ffffffffffc08p-42, -0x1.0000000000000p-48, -0x1.ffffffffffffep-102, -0x1.0000000000200p+14, 0x1.fbffffffffc08p-42},
{0x1.0000000040000p+37, -0x1.fffff80002000p-29, 0x1.0000000000000p-21, 0x1.ffc01ffff3c00p-84, 0x1.0000000040000p+37, 0x1.fc00000ffffc0p-22},
{0x1.0000000040000p+37, -0x1.fffff80002000p-29, -0x1.0000000000000p-21, -0x1.ffc01ffff3c00p-84, 0x1.0000000040000p+37, -0x1.01fffff800020p-21},
{-0x1.0000000040000p+37, 0x1.fffff80002000p-29, 0x1.0000000000000p-21, 0x1.ffc01ffff3c00p-84, -0x1.0000000040000p+37, 0x1.01fffff800020p-21},
{-0x1.0000000040000p+37, 0x1.fffff80002000p-29, -0x1.0000000000000p-21, -0x1.ffc01ffff3c00p-84, -0x1.0000000040000p+37, -0x1.fc00000ffffc0p-22},
{0x1.0000800000000p+25, -0x1.0000000000000p-80, 0x1.0000003800001p-52, 0x1.fffffe000003ep-106, 0x1.0000800000000p+25, 0x1.0000003000000p-52},
{0x1.0000800000000p+25, -0x1.0000000000000p-80, -0x1.0000003800001p-52, -0x1.fffffe000003ep-106, 0x1.0000800000000p+25, -0x1.0000005000000p-52},
{-0x1.0000800000000p+25, 0x1.0000000000000p-80, 0x1.0000003800001p-52, 0x1.fffffe000003ep-106, -0x1.0000800000000p+25, 0x1.0000005000000p-52},
{-0x1.0000800000000p+25, 0x1.0000000000000p-80, -0x1.0000003800001p-52, -0x1.fffffe000003ep-106, -0x1.0000800000000p+25, -0x1.0000003000000p-52},
{0x1.0f00000020000p-4, -0x1.fffe000000100p-58, 0x1.0000000400000p-7, -0x1.ffffffc004000p-74, 0x1.2f000000a0000p-4, -0x1.ffffffffffd00p-58},
{0x1.0f00000020000p-4, -0x1.fffe000000100p-58, -0x1.0000000400000p-7, 0x1.ffffffc004000p-74, 0x1.ddffffff3ffffp-5, 0x1.ffffffd800000p-73},
{-0x1.0f00000020000p-4, 0x1.fffe000000100p-58, 0x1.0000000400000p-7, -0x1.ffffffc004000p-74, -0x1.ddffffff3ffffp-5, -0x1.ffffffd800000p-73},
{-0x1.0f00000020000p-4, 0x1.fffe000000100p-58, -0x1.0000000400000p-7, 0x1.ffffffc004000p-74, -0x1.2f000000a0000p-4, 0x1.ffffffffffd00p-58},
{0x1.003fe00020000p-13, -0x1.ffffffffe8000p-81, 0x1.0000000000400p-48, -0x1.ffff800007ffcp-103, 0x1.003fe00040000p-13, -0x1.ff8007ffe8000p-81},
{0x1.003fe00020000p-13, -0x1.ffffffffe8000p-81, -0x1.0000000000400p-48, 0x1.ffff800007ffcp-103, 0x1.003fe00000000p-13, -0x1.003ffbfff4000p-80},
{-0x1.003fe00020000p-13, 0x1.ffffffffe8000p-81, 0x1.0000000000400p-48, -0x1.ffff800007ffcp-103, -0x1.003fe00000000p-13, 0x1.003ffbfff4000p-80},
{-0x1.003fe00020000p-13, 0x1.ffffffffe8000p-81, -0x1.0000000000400p-48, 0x1.ffff800007ffcp-103, -0x1.003fe00040000p-13, 0x1.ff8007ffe8000p-81},
{0x1.ffff00fffffc4p-6, -0x1.8080000000000p-88, 0x1.0000020000000p-1, -0x1.0000000000000p-77, 0x1.0ffffa07ffffep-1, 0x1.ffffeffcff000p-57},
{0x1.ffff00fffffc4p-6, -0x1.8080000000000p-88, -0x1.0000020000000p-1, 0x1.0000000000000p-77, -0x1.e00013f000004p-2, 0x1.000007fe7f800p-56},
{-0x1.ffff00fffffc4p-6, 0x1.8080000000000p-88, 0x1.0000020000000p-1, -0x1.0000000000000p-77, 0x1.e00013f000004p-2, -0x1.000007fe7f800p-56},
{-0x1.ffff00fffffc4p-6, 0x1.8080000000000p-88, -0x1.0000020000000p-1, 0x1.0000000000000p-77, -0x1.0ffffa07ffffep-1, -0x1.ffffeffcff000p-57},
{0x1.0000000000040p+36, -0x1.8000000800000p-39, 0x1.0000000002000p+30, -0x1.0000000000000p-74, 0x1.04000000000c0p+36, -0x1.8000000800000p-39},
{0x1.0000000000040p+36, -0x1.8000000800000p-39, -0x1.0000000002000p+30, 0x1.0000000000000p-74, 0x1.f7fffffffff80p+35, -0x1.8000000800000p-39},
{-0x1.0000000000040p+36, 0x1.8000000800000p-39, 0x1.0000000002000p+30, -0x1.0000000000000p-74, -0x1.f7fffffffff80p+35, 0x1.8000000800000p-39},
{-0x1.0000000000040p+36, 0x1.8000000800000p-39, -0x1.0000000002000p+30, 0x1.0000000000000p-74, -0x1.04000000000c0p+36, 0x1.8000000800000p-39},
{0x1.0000000800000p-29, -0x1.ffffc02000000p-107, 0x1.7fffe00800000p-48, -0x1.0000000000000p-153, 0x1.00003007fc010p-29, -0x1.ffffc02000000p-107},
{0x1.0000000800000p-29, -0x1.ffffc02000000p-107, -0x1.7fffe00800000p-48, 0x1.0000000000000p-153, 0x1.ffffa01007fe0p-30, -0x1.ffffc02000000p-107},
{-0x1.0000000800000p-29, 0x1.ffffc02000000p-107, 0x1.7fffe00800000p-48, -0x1.0000000000000p-153, -0x1.ffffa01007fe0p-30, 0x1.ffffc02000000p-107},
{-0x1.0000000800000p-29, 0x1.ffffc02000000p-107, -0x1.7fffe00800000p-48, 0x1.0000000000000p-153, -0x1.00003007fc010p-29, 0x1.ffffc02000000p-107},
{0x1.0000400000000p+11, -0x1.0000000000000p-80, 0x1.4000000000000p+51, -0x1.ffffffff00020p-7, 0x1.4000000001000p+51, -0x1.fffffffe00040p-8},
{0x1.0000400000000p+11, -0x1.0000000000000p-80, -0x1.4000000000000p+51, 0x1.ffffffff00020p-7, -0x1.3fffffffff000p+51, 0x1.7fffffff80010p-6},
{-0x1.0000400000000p+11, 0x1.0000000000000p-80, 0x1.4000000000000p+51, -0x1.ffffffff00020p-7, 0x1.3fffffffff000p+51, -0x1.7fffffff80010p-6},
{-0x1.0000400000000p+11, 0x1.0000000000000p-80, -0x1.4000000000000p+51, 0x1.ffffffff00020p-7, -0x1.4000000001000p+51, 0x1.fffffffe00040p-8},
{0x1.0000000000000p+42, 0x1.03eff7ff3fff0p-15, 0x1.00001fffc0000p-1, 0x1.f80001f000f80p-61, 0x1.0000000000200p+42, 0x1.0befe7ff40070p-15},
{0x1.0000000000000p+42, 0x1.03eff7ff3fff0p-15, -0x1.00001fffc0000p-1, -0x1.f80001f000f80p-61, 0x1.ffffffffffc00p+41, 0x1.f7e00ffe7fee0p-16},
{-0x1.0000000000000p+42, -0x1.03eff7ff3fff0p-15, 0x1.00001fffc0000p-1, 0x1.f80001f000f80p-61, -0x1.ffffffffffc00p+41, -0x1.f7e00ffe7fee0p-16},
{-0x1.0000000000000p+42, -0x1.03eff7ff3fff0p-15, -0x1.00001fffc0000p-1, -0x1.f80001f000f80p-61, -0x1.0000000000200p+42, -0x1.0befe7ff40070p-15},
{0x1.03ffffffffffep-18, 0x1.8000000000000p-122, 0x1.0000040000000p+49, -0x1.0000000000000p-56, 0x1.0000040000000p+49, 0x1.03fffffffc000p-18},
{0x1.03ffffffffffep-18, 0x1.8000000000000p-122, -0x1.0000040000000p+49, 0x1.0000000000000p-56, -0x1.0000040000000p+49, 0x1.0400000004000p-18},
{-0x1.03ffffffffffep-18, -0x1.8000000000000p-122, 0x1.0000040000000p+49, -0x1.0000000000000p-56, 0x1.0000040000000p+49, -0x1.0400000004000p-18},
{-0x1.03ffffffffffep-18, -0x1.8000000000000p-122, -0x1.0000040000000p+49, 0x1.0000000000000p-56, -0x1.0000040000000p+49, -0x1.03fffffffc000p-18},
{0x1.0007ffffcfffcp+9, 0x1.ff01fffe00000p-65, 0x1.01fff08000000p-5, -0x1.fffffe0000020p-59, 0x1.000c07ff91ffcp+9, -0x1.f803f60008000p-59},
{0x1.0007ffffcfffcp+9, 0x1.ff01fffe00000p-65, -0x1.01fff08000000p-5, 0x1.fffffe0000020p-59, 0x1.0003f8000dffcp+9, 0x1.03fe02fffc000p-58},
{-0x1.0007ffffcfffcp+9, -0x1.ff01fffe00000p-65, 0x1.01fff08000000p-5, -0x1.fffffe0000020p-59, -0x1.0003f8000dffcp+9, -0x1.03fe02fffc000p-58},
{-0x1.0007ffffcfffcp+9, -0x1.ff01fffe00000p-65, -0x1.01fff08000000p-5, 0x1.fffffe0000020p-59, -0x1.000c07ff91ffcp+9, 0x1.f803f60008000p-59},
{0x1.00000000007fep-4, 0x1.ff00003ffff00p-65, 0x1.004000e000008p+5, -0x1.ffffe02000000p-73, 0x1.00c000e00000cp+5, -0x1.ff017fffd0100p-56},
{0x1.00000000007fep-4, 0x1.ff00003ffff00p-65, -0x1.004000e000008p+5, 0x1.ffffe02000000p-73, -0x1.ff8001c000008p+4, -0x1.feff7fffeff00p-56},
{-0x1.00000000007fep-4, -0x1.ff00003ffff00p-65, 0x1.004000e000008p+5, -0x1.ffffe02000000p-73, 0x1.ff8001c000008p+4, 0x1.feff7fffeff00p-56},
{-0x1.00000000007fep-4, -0x1.ff00003ffff00p-65, -0x1.004000e000008p+5, 0x1.ffffe02000000p-73, -0x1.00c000e00000cp+5, 0x1.ff017fffd0100p-56},
{0x1.00000003ff000p-41, 0x1.ffff000000000p-130, 0x1.0000fffff8000p-20, 0x1.f003ffe0003e0p-78, 0x1.000107fff8002p-20, 0x1.d003ffe0003e0p-78},
{0x1.00000003ff000p-41, 0x1.ffff000000000p-130, -0x1.0000fffff8000p-20, -0x1.f003ffe0003e0p-78, -0x1.0000f7fff7ffep-20, -0x1.0801fff0001f0p-77},
{-0x1.00000003ff000p-41, -0x1.ffff000000000p-130, 0x1.0000fffff8000p-20, 0x1.f003ffe0003e0p-78, 0x1.0000f7fff7ffep-20, 0x1.0801fff0001f0p-77},
{-0x1.00000003ff000p-41, -0x1.ffff000000000p-130, -0x1.0000fffff8000p-20, -0x1.f003ffe0003e0p-78, -0x1.000107fff8002p-20, -0x1.d003ffe0003e0p-78},
{0x1.0000000000000p-41, 0x1.ffe001c0003c0p-100, 0x1.01fffffe00000p+41, 0x1.ffffffffffc00p-17, 0x1.01fffffe00000p+41, 0x1.0000007fffe00p-16},
{0x1.0000000000000p-41, 0x1.ffe001c0003c0p-100, -0x1.01fffffe00000p+41, -0x1.ffffffffffc00p-17, -0x1.01fffffe00000p+41, -0x1.fffffeffffc00p-17},
{-0x1.0000000000000p-41, -0x1.ffe001c0003c0p-100, 0x1.01fffffe00000p+41, 0x1.ffffffffffc00p-17, 0x1.01fffffe00000p+41, 0x1.fffffeffffc00p-17},
{-0x1.0000000000000p-41, -0x1.ffe001c0003c0p-100, -0x1.01fffffe00000p+41, -0x1.ffffffffffc00p-17, -0x1.01fffffe00000p+41, -0x1.0000007fffe00p-16},
{0x1.00003ff808000p+36, -0x1.ffe0000800000p-25, 0x1.000001ffff000p+41, 0x1.ff80000000000p-33, 0x1.080003ffbf400p+41, -0x1.fde0800800000p-25},
{0x1.00003ff808000p+36, -0x1.ffe0000800000p-25, -0x1.000001ffff000p+41, -0x1.ff80000000000p-33, -0x1.f00000007d800p+40, -0x1.00efc00400000p-24},
{-0x1.00003ff808000p+36, 0x1.ffe0000800000p-25, 0x1.000001ffff000p+41, 0x1.ff80000000000p-33, 0x1.f00000007d800p+40, 0x1.00efc00400000p-24},
{-0x1.00003ff808000p+36, 0x1.ffe0000800000p-25, -0x1.000001ffff000p+41, -0x1.ff80000000000p-33, -0x1.080003ffbf400p+41, 0x1.fde0800800000p-25},
{0x1.0000000000000p+6, 0x1.fc007f0ff0000p-56, 0x1.0000000007f80p-50, 0x1.ff0007f802000p-114, 0x1.0000000000000p+6, 0x1.07f001fc47b80p-50},
{0x1.0000000000000p+6, 0x1.fc007f0ff0000p-56, -0x1.0000000007f80p-50, -0x1.ff0007f802000p-114, 0x1.0000000000000p+6, -0x1.f01ffc0790700p-51},
{-0x1.0000000000000p+6, -0x1.fc007f0ff0000p-56, 0x1.0000000007f80p-50, 0x1.ff0007f802000p-114, -0x1.0000000000000p+6, 0x1.f01ffc0790700p-51},
{-0x1.0000000000000p+6, -0x1.fc007f0ff0000p-56, -0x1.0000000007f80p-50, -0x1.ff0007f802000p-114, -0x1.0000000000000p+6, -0x1.07f001fc47b80p-50},
{0x1.0020000000000p+12, -0x1.0000000000000p-65, 0x1.000001ffff802p-4, -0x1.ffffffc000040p-63, 0x1.0021000002000p+12, -0x1.ff811fffffe00p-46},
{0x1.0020000000000p+12, -0x1.0000000000000p-65, -0x1.000001ffff802p-4, 0x1.ffffffc000040p-63, 0x1.001efffffe000p+12, 0x1.ff80dfffffe00p-46},
{-0x1.0020000000000p+12, 0x1.0000000000000p-65, 0x1.000001ffff802p-4, -0x1.ffffffc000040p-63, -0x1.001efffffe000p+12, -0x1.ff80dfffffe00p-46},
{-0x1.0020000000000p+12, 0x1.0000000000000p-65, -0x1.000001ffff802p-4, 0x1.ffffffc000040p-63, -0x1.0021000002000p+12, 0x1.ff811fffffe00p-46},
{0x1.0000000000800p-45, -0x1.ffe0000400000p-107, 0x1.0000000000038p+25, 0x1.e100000000000p-49, 0x1.0000000000038p+25, 0x1.1e10000000000p-45},
{0x1.0000000000800p-45, -0x1.ffe0000400000p-107, -0x1.0000000000038p+25, -0x1.e100000000000p-49, -0x1.0000000000038p+25, 0x1.c3e0000000000p-46},
{-0x1.0000000000800p-45, 0x1.ffe0000400000p-107, 0x1.0000000000038p+25, 0x1.e100000000000p-49, 0x1.0000000000038p+25, -0x1.c3e0000000000p-46},
{-0x1.0000000000800p-45, 0x1.ffe0000400000p-107, -0x1.0000000000038p+25, -0x1.e100000000000p-49, -0x1.0000000000038p+25, -0x1.1e10000000000p-45},
{0x1.0000000000020p-31, -0x1.8007ffff80c04p-86, 0x1.0000000000000p+50, 0x1.ffffe00000c00p-13, 0x1.0000000000000p+50, 0x1.0000100000600p-12},
{0x1.0000000000020p-31, -0x1.8007ffff80c04p-86, -0x1.0000000000000p+50, -0x1.ffffe00000c00p-13, -0x1.0000000000000p+50, -0x1.ffffa00000c00p-13},
{-0x1.0000000000020p-31, 0x1.8007ffff80c04p-86, 0x1.0000000000000p+50, 0x1.ffffe00000c00p-13, 0x1.0000000000000p+50, 0x1.ffffa00000c00p-13},
{-0x1.0000000000020p-31, 0x1.8007ffff80c04p-86, -0x1.0000000000000p+50, -0x1.ffffe00000c00p-13, -0x1.0000000000000p+50, -0x1.0000100000600p-12},
{0x1.7fffffff80000p+1, 0x1.f000000000000p-76, 0x1.000007ffffffep-41, 0x1.ffffff8000000p-117, 0x1.7fffffff80400p+1, 0x1.0007bffc00000p-62},
{0x1.7fffffff80000p+1, 0x1.f000000000000p-76, -0x1.000007ffffffep-41, -0x1.ffffff8000000p-117, 0x1.7fffffff7fc00p+1, -0x1.fff07ff800000p-63},
{-0x1.7fffffff80000p+1, -0x1.f000000000000p-76, 0x1.000007ffffffep-41, 0x1.ffffff8000000p-117, -0x1.7fffffff7fc00p+1, 0x1.fff07ff800000p-63},
{-0x1.7fffffff80000p+1, -0x1.f000000000000p-76, -0x1.000007ffffffep-41, -0x1.ffffff8000000p-117, -0x1.7fffffff80400p+1, -0x1.0007bffc00000p-62},
{0x1.0000000010000p+45, -0x1.0000000000000p-41, 0x1.0000000000000p+5, 0x1.c000003ffc3fep-49, 0x1.0000000011000p+45, -0x1.fc80000000000p-42},
{0x1.0000000010000p+45, -0x1.0000000000000p-41, -0x1.0000000000000p+5, -0x1.c000003ffc3fep-49, 0x1.000000000f000p+45, -0x1.01c0000000000p-41},
{-0x1.0000000010000p+45, 0x1.0000000000000p-41, 0x1.0000000000000p+5, 0x1.c000003ffc3fep-49, -0x1.000000000f000p+45, 0x1.01c0000000000p-41},
{-0x1.0000000010000p+45, 0x1.0000000000000p-41, -0x1.0000000000000p+5, -0x1.c000003ffc3fep-49, -0x1.0000000011000p+45, 0x1.fc80000000000p-42},
{0x1.00000ffff0800p-14, -0x1.fff80000ffc20p-72, 0x1.0000000000002p-19, -0x1.0000000000000p-124, 0x1.08000ffff0800p-14, 0x1.0003ffff801f0p-71},
{0x1.00000ffff0800p-14, -0x1.fff80000ffc20p-72, -0x1.0000000000002p-19, 0x1.0000000000000p-124, 0x1.f0001fffe1000p-15, -0x1.7ffe00003ff08p-70},
{-0x1.00000ffff0800p-14, 0x1.fff80000ffc20p-72, 0x1.0000000000002p-19, -0x1.0000000000000p-124, -0x1.f0001fffe1000p-15, 0x1.7ffe00003ff08p-70},
{-0x1.00000ffff0800p-14, 0x1.fff80000ffc20p-72, -0x1.0000000000002p-19, 0x1.0000000000000p-124, -0x1.08000ffff0800p-14, -0x1.0003ffff801f0p-71},
{0x1.000ffffc00000p+49, 0x1.fffff00000000p-20, 0x1.0000000000040p+45, -0x1.0000000000000p-60, 0x1.100ffffc00004p+49, 0x1.fffff00000000p-20},
{0x1.000ffffc00000p+49, 0x1.fffff00000000p-20, -0x1.0000000000040p+45, 0x1.0000000000000p-60, 0x1.e01ffff7ffff8p+48, 0x1.fffff00000000p-20},
{-0x1.000ffffc00000p+49, -0x1.fffff00000000p-20, 0x1.0000000000040p+45, -0x1.0000000000000p-60, -0x1.e01ffff7ffff8p+48, -0x1.fffff00000000p-20},
{-0x1.000ffffc00000p+49, -0x1.fffff00000000p-20, -0x1.0000000000040p+45, 0x1.0000000000000p-60, -0x1.100ffffc00004p+49, -0x1.fffff00000000p-20},
{0x1.0004000000000p+14, -0x1.0000000000000p-54, 0x1.0000000200000p-4, -0x1.ffbffffff8020p-62, 0x1.0004400000008p+14, -0x1.01ffc00000000p-54},
{0x1.0004000000000p+14, -0x1.0000000000000p-54, -0x1.0000000200000p-4, 0x1.ffbffffff8020p-62, 0x1.0003bfffffff8p+14, -0x1.fc00800000000p-55},
{-0x1.0004000000000p+14, 0x1.0000000000000p-54, 0x1.0000000200000p-4, -0x1.ffbffffff8020p-62, -0x1.0003bfffffff8p+14, 0x1.fc00800000000p-55},
{-0x1.0004000000000p+14, 0x1.0000000000000p-54, -0x1.0000000200000p-4, 0x1.ffbffffff8020p-62, -0x1.0004400000008p+14, 0x1.01ffc00000000p-54},
{0x1.0000000000000p-1, 0x1.e0001e7fbff00p-62, 0x1.0000001fffffep+43, 0x0.0000000000000p+0, 0x1.00000020000fep+43, 0x1.0000000000000p-61},
{0x1.0000000000000p-1, 0x1.e0001e7fbff00p-62, -0x1.0000001fffffep+43, 0x0.0000000000000p+0, -0x1.0000001fffefep+43, 0x1.0000000000000p-61},
{-0x1.0000000000000p-1, -0x1.e0001e7fbff00p-62, 0x1.0000001fffffep+43, 0x0.0000000000000p+0, 0x1.0000001fffefep+43, -0x1.0000000000000p-61},
{-0x1.0000000000000p-1, -0x1.e0001e7fbff00p-62, -0x1.0000001fffffep+43, 0x0.0000000000000p+0, -0x1.00000020000fep+43, -0x1.0000000000000p-61},
{0x1.0000000000fffp-39, 0x1.fffff3e000000p-112, 0x1.001ffe0000000p-15, 0x1.fffffffffffc0p-74, 0x1.001fff0000000p-15, 0x1.03ffc00003fe0p-73},
{0x1.0000000000fffp-39, 0x1.fffff3e000000p-112, -0x1.001ffe0000000p-15, -0x1.fffffffffffc0p-74, -0x1.001ffd0000000p-15, -0x1.f8007ffff7fc0p-74},
{-0x1.0000000000fffp-39, -0x1.fffff3e000000p-112, 0x1.001ffe0000000p-15, 0x1.fffffffffffc0p-74, 0x1.001ffd0000000p-15, 0x1.f8007ffff7fc0p-74},
{-0x1.0000000000fffp-39, -0x1.fffff3e000000p-112, -0x1.001ffe0000000p-15, -0x1.fffffffffffc0p-74, -0x1.001fff0000000p-15, -0x1.03ffc00003fe0p-73},
{0x1.0000080000000p-27, -0x1.0000000000000p-132, 0x1.0000000080000p-48, -0x1.0000000000000p-103, 0x1.0000100000000p-27, 0x1.fffff7ffffffcp-82},
{0x1.0000080000000p-27, -0x1.0000000000000p-132, -0x1.0000000080000p-48, 0x1.0000000000000p-103, 0x1.0000000000000p-27, -0x1.fffff80000004p-82},
{-0x1.0000080000000p-27, 0x1.0000000000000p-132, 0x1.0000000080000p-48, -0x1.0000000000000p-103, -0x1.0000000000000p-27, 0x1.fffff80000004p-82},
{-0x1.0000080000000p-27, 0x1.0000000000000p-132, -0x1.0000000080000p-48, 0x1.0000000000000p-103, -0x1.0000100000000p-27, -0x1.fffff7ffffffcp-82},
{0x1.003ffffffffe0p-31, 0x1.ffffe03800000p-107, 0x1.0000000002000p-53, -0x1.0000000000000p-106, 0x1.004003fffffe0p-31, 0x1.ffffffff80e00p-93},
{0x1.003ffffffffe0p-31, 0x1.ffffe03800000p-107, -0x1.0000000002000p-53, 0x1.0000000000000p-106, 0x1.003ffbfffffe0p-31, -0x1.fff000007f200p-93},
{-0x1.003ffffffffe0p-31, -0x1.ffffe03800000p-107, 0x1.0000000002000p-53, -0x1.0000000000000p-106, -0x1.003ffbfffffe0p-31, 0x1.fff000007f200p-93},
{-0x1.003ffffffffe0p-31, -0x1.ffffe03800000p-107, -0x1.0000000002000p-53, 0x1.0000000000000p-106, -0x1.004003fffffe0p-31, -0x1.ffffffff80e00p-93},
{0x1.0000000000008p+23, -0x1.ff000007ffc00p-37, 0x1.0000000060000p+36, 0x1.ffffff8000000p-44, 0x1.0008000060000p+36, 0x1.ff813ffffdc00p-27},
{0x1.0000000000008p+23, -0x1.ff000007ffc00p-37, -0x1.0000000060000p+36, -0x1.ffffff8000000p-44, -0x1.fff00000c0000p+35, 0x1.ff7f3ffffe400p-27},
{-0x1.0000000000008p+23, 0x1.ff000007ffc00p-37, 0x1.0000000060000p+36, 0x1.ffffff8000000p-44, 0x1.fff00000c0000p+35, -0x1.ff7f3ffffe400p-27},
{-0x1.0000000000008p+23, 0x1.ff000007ffc00p-37, -0x1.0000000060000p+36, -0x1.ffffff8000000p-44, -0x1.0008000060000p+36, -0x1.ff813ffffdc00p-27},
{0x1.0000000000080p+25, -0x1.0000000000000p-80, 0x1.01ffffff80001p+15, -0x1.ff90000000000p-78, 0x1.00407fffffe80p+25, 0x1.fffffffffdc00p-38},
{0x1.0000000000080p+25, -0x1.0000000000000p-80, -0x1.01ffffff80001p+15, 0x1.ff90000000000p-78, 0x1.ff7f000000500p+24, -0x1.fffffffffe400p-38},
{-0x1.0000000000080p+25, 0x1.0000000000000p-80, 0x1.01ffffff80001p+15, -0x1.ff90000000000p-78, -0x1.ff7f000000500p+24, 0x1.fffffffffe400p-38},
{-0x1.0000000000080p+25, 0x1.0000000000000p-80, -0x1.01ffffff80001p+15, 0x1.ff90000000000p-78, -0x1.00407fffffe80p+25, -0x1.fffffffffdc00p-38},
{0x1.0000000000800p+7, -0x1.fffff80002000p-59, 0x1.0008000000000p+50, -0x1.0000000000000p-29, 0x1.0008000000200p+50, -0x1.f000000000000p-30},
{0x1.0000000000800p+7, -0x1.fffff80002000p-59, -0x1.0008000000000p+50, 0x1.0000000000000p-29, -0x1.0007ffffffe00p+50, 0x1.0800000000000p-29},
{-0x1.0000000000800p+7, 0x1.fffff80002000p-59, 0x1.0008000000000p+50, -0x1.0000000000000p-29, 0x1.0007ffffffe00p+50, -0x1.0800000000000p-29},
{-0x1.0000000000800p+7, 0x1.fffff80002000p-59, -0x1.0008000000000p+50, 0x1.0000000000000p-29, -0x1.0008000000200p+50, 0x1.f000000000000p-30},
{0x1.0000000000002p+26, -0x1.ffffffe200000p-48, 0x1.0003fffffffc0p+27, 0x1.ffffe00000400p-36, 0x1.8003fffffffc1p+27, 0x1.ffdfe00002000p-36},
{0x1.0000000000002p+26, -0x1.ffffffe200000p-48, -0x1.0003fffffffc0p+27, -0x1.ffffe00000400p-36, -0x1.0007fffffff7ep+26, -0x1.000fefffff300p-35},
{-0x1.0000000000002p+26, 0x1.ffffffe200000p-48, 0x1.0003fffffffc0p+27, 0x1.ffffe00000400p-36, 0x1.0007fffffff7ep+26, 0x1.000fefffff300p-35},
{-0x1.0000000000002p+26, 0x1.ffffffe200000p-48, -0x1.0003fffffffc0p+27, -0x1.ffffe00000400p-36, -0x1.8003fffffffc1p+27, -0x1.ffdfe00002000p-36},
{0x1.000003f000000p+13, 0x1.fffffffe00000p-48, 0x1.0000000000ff0p+50, 0x1.c03fff0e00000p-24, 0x1.0000000008ff0p+50, 0x1.f807010004380p-10},
{0x1.000003f000000p+13, 0x1.fffffffe00000p-48, -0x1.0000000000ff0p+50, -0x1.c03fff0e00000p-24, -0x1.fffffffff1fe0p+49, 0x1.f7f8ff000bc80p-10},
{-0x1.000003f000000p+13, -0x1.fffffffe00000p-48, 0x1.0000000000ff0p+50, 0x1.c03fff0e00000p-24, 0x1.fffffffff1fe0p+49, -0x1.f7f8ff000bc80p-10},
{-0x1.000003f000000p+13, -0x1.fffffffe00000p-48, -0x1.0000000000ff0p+50, -0x1.c03fff0e00000p-24, -0x1.0000000008ff0p+50, -0x1.f807010004380p-10},
{0x1.0000000018000p-6, 0x1.fffffe0000000p-88, 0x1.0000100000000p+32, -0x1.0000000000000p-73, 0x1.0000100004000p+32, 0x1.7ffffffe00000p-42},
{0x1.0000000018000p-6, 0x1.fffffe0000000p-88, -0x1.0000100000000p+32, 0x1.0000000000000p-73, -0x1.00000ffffc000p+32, 0x1.8000000200000p-42},
{-0x1.0000000018000p-6, -0x1.fffffe0000000p-88, 0x1.0000100000000p+32, -0x1.0000000000000p-73, 0x1.00000ffffc000p+32, -0x1.8000000200000p-42},
{-0x1.0000000018000p-6, -0x1.fffffe0000000p-88, -0x1.0000100000000p+32, 0x1.0000000000000p-73, -0x1.0000100004000p+32, -0x1.7ffffffe00000p-42},
{0x1.0000000000001p+35, -0x1.fffffc1000000p-32, 0x1.1ffffff01f000p+36, 0x1.ffffc000060fcp-19, 0x1.9ffffff01f001p+36, -0x1.00081fffed382p-18},
{0x1.0000000000001p+35, -0x1.fffffc1000000p-32, -0x1.1ffffff01f000p+36, -0x1.ffffc000060fcp-19, -0x1.3fffffe03e000p+35, 0x1.fff0400019704p-19},
{-0x1.0000000000001p+35, 0x1.fffffc1000000p-32, 0x1.1ffffff01f000p+36, 0x1.ffffc000060fcp-19, 0x1.3fffffe03e000p+35, -0x1.fff0400019704p-19},
{-0x1.0000000000001p+35, 0x1.fffffc1000000p-32, -0x1.1ffffff01f000p+36, -0x1.ffffc000060fcp-19, -0x1.9ffffff01f001p+36, 0x1.00081fffed382p-18},
{0x1.0000003800000p+43, 0x1.ffe000001fffcp-12, 0x1.0000007fffff0p+50, 0x1.fe1ffffc00000p-12, 0x1.020000806fff0p+50, 0x1.fefffffe10000p-11},
{0x1.0000003800000p+43, 0x1.ffe000001fffcp-12, -0x1.0000007fffff0p+50, -0x1.fe1ffffc00000p-12, -0x1.fc0000ff1ffe0p+49, 0x1.c000042000000p-20},
{-0x1.0000003800000p+43, -0x1.ffe000001fffcp-12, 0x1.0000007fffff0p+50, 0x1.fe1ffffc00000p-12, 0x1.fc0000ff1ffe0p+49, -0x1.c000042000000p-20},
{-0x1.0000003800000p+43, -0x1.ffe000001fffcp-12, -0x1.0000007fffff0p+50, -0x1.fe1ffffc00000p-12, -0x1.020000806fff0p+50, -0x1.fefffffe10000p-11},
{0x1.0000001fffc00p+32, 0x1.f00007ffe0000p-32, 0x1.0000000000180p+25, 0x1.fffffe0000800p-39, 0x1.0200001fffc03p+32, 0x1.f40007fbe0000p-32},
{0x1.0000001fffc00p+32, 0x1.f00007ffe0000p-32, -0x1.0000000000180p+25, -0x1.fffffe0000800p-39, 0x1.fc00003fff7fap+31, 0x1.ec000803e0000p-32},
{-0x1.0000001fffc00p+32, -0x1.f00007ffe0000p-32, 0x1.0000000000180p+25, 0x1.fffffe0000800p-39, -0x1.fc00003fff7fap+31, -0x1.ec000803e0000p-32},
{-0x1.0000001fffc00p+32, -0x1.f00007ffe0000p-32, -0x1.0000000000180p+25, -0x1.fffffe0000800p-39, -0x1.0200001fffc03p+32, -0x1.f40007fbe0000p-32},
{0x1.0000000008000p+19, -0x1.c0000007ffe04p-36, 0x1.00000fffffffep-53, 0x1.fc00000000000p-152, 0x1.0000000008000p+19, -0x1.bfff8007f7e04p-36},
{0x1.0000000008000p+19, -0x1.c0000007ffe04p-36, -0x1.00000fffffffep-53, -0x1.fc00000000000p-152, 0x1.0000000008000p+19, -0x1.c000800807e04p-36},
{-0x1.0000000008000p+19, 0x1.c0000007ffe04p-36, 0x1.00000fffffffep-53, 0x1.fc00000000000p-152, -0x1.0000000008000p+19, 0x1.c000800807e04p-36},
{-0x1.0000000008000p+19, 0x1.c0000007ffe04p-36, -0x1.00000fffffffep-53, -0x1.fc00000000000p-152, -0x1.0000000008000p+19, 0x1.bfff8007f7e04p-36},
{0x1.0000003e00004p+43, -0x1.fe00040000000p-27, 0x1.00007c0001e00p+8, 0x1.fffe13ffe0000p-56, 0x1.0000003e20005p+43, -0x1.000f78001f800p-14},
{0x1.0000003e00004p+43, -0x1.fe00040000000p-27, -0x1.00007c0001e00p+8, -0x1.fffe13ffe0000p-56, 0x1.0000003de0003p+43, 0x1.ffdf2fffbf000p-15},
{-0x1.0000003e00004p+43, 0x1.fe00040000000p-27, 0x1.00007c0001e00p+8, 0x1.fffe13ffe0000p-56, -0x1.0000003de0003p+43, -0x1.ffdf2fffbf000p-15},
{-0x1.0000003e00004p+43, 0x1.fe00040000000p-27, -0x1.00007c0001e00p+8, -0x1.fffe13ffe0000p-56, -0x1.0000003e20005p+43, 0x1.000f78001f800p-14},
{0x1.03fffffffc000p+44, 0x1.ffffffc000000p-31, 0x1.0003ffffff000p-28, 0x1.ffc0000000000p-123, 0x1.03fffffffc000p+44, 0x1.4003fff800000p-28},
{0x1.03fffffffc000p+44, 0x1.ffffffc000000p-31, -0x1.0003ffffff000p-28, -0x1.ffc0000000000p-123, 0x1.03fffffffc000p+44, -0x1.8008001000000p-29},
{-0x1.03fffffffc000p+44, -0x1.ffffffc000000p-31, 0x1.0003ffffff000p-28, 0x1.ffc0000000000p-123, -0x1.03fffffffc000p+44, 0x1.8008001000000p-29},
{-0x1.03fffffffc000p+44, -0x1.ffffffc000000p-31, -0x1.0003ffffff000p-28, -0x1.ffc0000000000p-123, -0x1.03fffffffc000p+44, -0x1.4003fff800000p-28},
{0x1.07ffffff80000p+48, 0x1.8007ffffc0000p-23, 0x1.0000000000004p-5, -0x1.fffc000200000p-74, 0x1.07ffffff80001p+48, -0x1.ffff3ffbffffap-6},
{0x1.07ffffff80000p+48, 0x1.8007ffffc0000p-23, -0x1.0000000000004p-5, 0x1.fffc000200000p-74, 0x1.07ffffff80000p+48, -0x1.ffff3ffc0000ap-6},
{-0x1.07ffffff80000p+48, -0x1.8007ffffc0000p-23, 0x1.0000000000004p-5, -0x1.fffc000200000p-74, -0x1.07ffffff80000p+48, 0x1.ffff3ffc0000ap-6},
{-0x1.07ffffff80000p+48, -0x1.8007ffffc0000p-23, -0x1.0000000000004p-5, 0x1.fffc000200000p-74, -0x1.07ffffff80001p+48, 0x1.ffff3ffbffffap-6},
{0x1.00003ffffff80p-25, 0x1.ffff0000ffe00p-87, 0x1.00003fffffff8p-48, 0x0.0000000000000p+0, 0x1.0000420000780p-25, 0x1.ffbf0000ffe00p-87},
{0x1.00003ffffff80p-25, 0x1.ffff0000ffe00p-87, -0x1.00003fffffff8p-48, 0x0.0000000000000p+0, 0x1.00003dffff780p-25, 0x1.001f80007ff00p-86},
{-0x1.00003ffffff80p-25, -0x1.ffff0000ffe00p-87, 0x1.00003fffffff8p-48, 0x0.0000000000000p+0, -0x1.00003dffff780p-25, -0x1.001f80007ff00p-86},
{-0x1.00003ffffff80p-25, -0x1.ffff0000ffe00p-87, -0x1.00003fffffff8p-48, 0x0.0000000000000p+0, -0x1.0000420000780p-25, -0x1.ffbf0000ffe00p-87},
{0x1.0000010000000p+29, -0x1.0000000000000p-76, 0x1.00f81ffffff81p-9, 0x1.fffff03c00000p-71, 0x1.000001000403ep+29, 0x1.ffffff81007e0p-29},
{0x1.0000010000000p+29, -0x1.0000000000000p-76, -0x1.00f81ffffff81p-9, -0x1.fffff03c00000p-71, 0x1.000000fffbfc2p+29, -0x1.ffffff8100820p-29},
{-0x1.0000010000000p+29, 0x1.0000000000000p-76, 0x1.00f81ffffff81p-9, 0x1.fffff03c00000p-71, -0x1.000000fffbfc2p+29, 0x1.ffffff8100820p-29},
{-0x1.0000010000000p+29, 0x1.0000000000000p-76, -0x1.00f81ffffff81p-9, -0x1.fffff03c00000p-71, -0x1.000001000403ep+29, -0x1.ffffff81007e0p-29},
{0x1.0000000000004p+5, -0x1.fff0008000000p-59, 0x1.0000000100000p+48, -0x1.fffffe0004000p-19, 0x1.0000000100200p+48, -0x1.fffffdc004000p-19},
{0x1.0000000000004p+5, -0x1.fff0008000000p-59, -0x1.0000000100000p+48, 0x1.fffffe0004000p-19, -0x1.00000000ffe00p+48, 0x1.fffffe4004000p-19},
{-0x1.0000000000004p+5, 0x1.fff0008000000p-59, 0x1.0000000100000p+48, -0x1.fffffe0004000p-19, 0x1.00000000ffe00p+48, -0x1.fffffe4004000p-19},
{-0x1.0000000000004p+5, 0x1.fff0008000000p-59, -0x1.0000000100000p+48, 0x1.fffffe0004000p-19, -0x1.0000000100200p+48, 0x1.fffffdc004000p-19},
{0x1.0000000000800p+23, -0x1.0000000000000p-55, 0x1.0000010000000p+11, -0x1.0000000000000p-92, 0x1.0010000010800p+23, -0x1.0000000000000p-55},
{0x1.0000000000800p+23, -0x1.0000000000000p-55, -0x1.0000010000000p+11, 0x1.0000000000000p-92, 0x1.ffdfffffe1000p+22, -0x1.0000000000000p-55},
{-0x1.0000000000800p+23, 0x1.0000000000000p-55, 0x1.0000010000000p+11, -0x1.0000000000000p-92, -0x1.ffdfffffe1000p+22, 0x1.0000000000000p-55},
{-0x1.0000000000800p+23, 0x1.0000000000000p-55, -0x1.0000010000000p+11, 0x1.0000000000000p-92, -0x1.0010000010800p+23, 0x1.0000000000000p-55},
{0x1.00000007fff00p-25, 0x1.fffc1ffff87f0p-81, 0x1.0000007c00000p-2, 0x1.fff0000000000p-73, 0x1.0000027c00001p-2, -0x1.bfc2007c00000p-70},
{0x1.00000007fff00p-25, 0x1.fffc1ffff87f0p-81, -0x1.0000007c00000p-2, -0x1.fff0000000000p-73, -0x1.fffffcf7ffffep-3, -0x1.1fdf003e00000p-69},
{-0x1.00000007fff00p-25, -0x1.fffc1ffff87f0p-81, 0x1.0000007c00000p-2, 0x1.fff0000000000p-73, 0x1.fffffcf7ffffep-3, 0x1.1fdf003e00000p-69},
{-0x1.00000007fff00p-25, -0x1.fffc1ffff87f0p-81, -0x1.0000007c00000p-2, -0x1.fff0000000000p-73, -0x1.0000027c00001p-2, 0x1.bfc2007c00000p-70},
{0x1.fffffffe00000p+40, 0x1.e000001fff800p-24, 0x1.00000001ffffep-36, 0x0.0000000000000p+0, 0x1.fffffffe00000p+40, 0x1.e010001fff800p-24},
{0x1.fffffffe00000p+40, 0x1.e000001fff800p-24, -0x1.00000001ffffep-36, 0x0.0000000000000p+0, 0x1.fffffffe00000p+40, 0x1.dff0001fff800p-24},
{-0x1.fffffffe00000p+40, -0x1.e000001fff800p-24, 0x1.00000001ffffep-36, 0x0.0000000000000p+0, -0x1.fffffffe00000p+40, -0x1.dff0001fff800p-24},
{-0x1.fffffffe00000p+40, -0x1.e000001fff800p-24, -0x1.00000001ffffep-36, 0x0.0000000000000p+0, -0x1.fffffffe00000p+40, -0x1.e010001fff800p-24},
{0x1.0000000000008p+12, -0x1.fffff00400000p-60, 0x1.00003ffffe000p-40, 0x1.ffffe00000000p-112, 0x1.0000000000009p+12, 0x1.ffffeffc00000p-60},
{0x1.0000000000008p+12, -0x1.fffff00400000p-60, -0x1.00003ffffe000p-40, -0x1.ffffe00000000p-112, 0x1.0000000000007p+12, -0x1.7ffff40100000p-58},
{-0x1.0000000000008p+12, 0x1.fffff00400000p-60, 0x1.00003ffffe000p-40, 0x1.ffffe00000000p-112, -0x1.0000000000007p+12, 0x1.7ffff40100000p-58},
{-0x1.0000000000008p+12, 0x1.fffff00400000p-60, -0x1.00003ffffe000p-40, -0x1.ffffe00000000p-112, -0x1.0000000000009p+12, -0x1.ffffeffc00000p-60},
{0x1.0000000000000p-26, 0x1.ffffffffffc00p-89, 0x1.000001ffe0000p+32, 0x1.ff87ff9f801c0p-27, 0x1.000001ffe0000p+32, 0x1.ffc3ffcfc00e0p-26},
{0x1.0000000000000p-26, 0x1.ffffffffffc00p-89, -0x1.000001ffe0000p+32, -0x1.ff87ff9f801c0p-27, -0x1.000001ffe0000p+32, 0x1.e00181ff90000p-37},
{-0x1.0000000000000p-26, -0x1.ffffffffffc00p-89, 0x1.000001ffe0000p+32, 0x1.ff87ff9f801c0p-27, 0x1.000001ffe0000p+32, -0x1.e00181ff90000p-37},
{-0x1.0000000000000p-26, -0x1.ffffffffffc00p-89, -0x1.000001ffe0000p+32, -0x1.ff87ff9f801c0p-27, -0x1.000001ffe0000p+32, -0x1.ffc3ffcfc00e0p-26},
{0x1.0000000000400p+5, -0x1.f800000002000p-56, 0x1.03fffffffff00p+2, 0x1.fffe7fffffffep-52, 0x1.20800000003e0p+5, 0x1.e07e7fffffe00p-52},
{0x1.0000000000400p+5, -0x1.f800000002000p-56, -0x1.03fffffffff00p+2, -0x1.fffe7fffffffep-52, 0x1.bf00000000840p+4, -0x1.0fbf400000100p-51},
{-0x1.0000000000400p+5, 0x1.f800000002000p-56, 0x1.03fffffffff00p+2, 0x1.fffe7fffffffep-52, -0x1.bf00000000840p+4, 0x1.0fbf400000100p-51},
{-0x1.0000000000400p+5, 0x1.f800000002000p-56, -0x1.03fffffffff00p+2, -0x1.fffe7fffffffep-52, -0x1.20800000003e0p+5, -0x1.e07e7fffffe00p-52},
{0x1.0000000000000p+13, 0x1.fffffffffff00p-43, 0x1.000007c000000p-28, 0x1.fff8000000000p-84, 0x1.0000000000800p+13, 0x1.01f0000000780p-42},
{0x1.0000000000000p+13, 0x1.fffffffffff00p-43, -0x1.000007c000000p-28, -0x1.fff8000000000p-84, 0x1.ffffffffff000p+12, 0x1.fc1ffffffef00p-43},
{-0x1.0000000000000p+13, -0x1.fffffffffff00p-43, 0x1.000007c000000p-28, 0x1.fff8000000000p-84, -0x1.ffffffffff000p+12, -0x1.fc1ffffffef00p-43},
{-0x1.0000000000000p+13, -0x1.fffffffffff00p-43, -0x1.000007c000000p-28, -0x1.fff8000000000p-84, -0x1.0000000000800p+13, -0x1.01f0000000780p-42},
{0x1.0000000000400p-35, -0x1.fffc0003fffd0p-92, 0x1.0000000000000p+4, 0x1.fffffff800000p-52, 0x1.0000000002000p+4, 0x1.0000003bff000p-51},
{0x1.0000000000400p-35, -0x1.fffc0003fffd0p-92, -0x1.0000000000000p+4, -0x1.fffffff800000p-52, -0x1.fffffffffc000p+3, -0x1.ffffff7802000p-52},
{-0x1.0000000000400p-35, 0x1.fffc0003fffd0p-92, 0x1.0000000000000p+4, 0x1.fffffff800000p-52, 0x1.fffffffffc000p+3, 0x1.ffffff7802000p-52},
{-0x1.0000000000400p-35, 0x1.fffc0003fffd0p-92, -0x1.0000000000000p+4, -0x1.fffffff800000p-52, -0x1.0000000002000p+4, -0x1.0000003bff000p-51},
{0x1.0000000002000p-51, -0x1.ffff040000000p-122, 0x1.03fffff800000p-40, 0x1.fffffe0000000p-108, 0x1.041ffff800004p-40, 0x1.fff7fe03f0000p-108},
{0x1.0000000002000p-51, -0x1.ffff040000000p-122, -0x1.03fffff800000p-40, -0x1.fffffe0000000p-108, -0x1.03dffff7ffffcp-40, -0x1.0003fefe08000p-107},
{-0x1.0000000002000p-51, 0x1.ffff040000000p-122, 0x1.03fffff800000p-40, 0x1.fffffe0000000p-108, 0x1.03dffff7ffffcp-40, 0x1.0003fefe08000p-107},
{-0x1.0000000002000p-51, 0x1.ffff040000000p-122, -0x1.03fffff800000p-40, -0x1.fffffe0000000p-108, -0x1.041ffff800004p-40, -0x1.fff7fe03f0000p-108},
{0x1.0000008000000p-21, -0x1.ffffff8200000p-78, 0x1.000fff8000000p+9, 0x1.fffffe0000000p-53, 0x1.000fff8400000p+9, 0x1.03fffffa00000p-46},
{0x1.0000008000000p-21, -0x1.ffffff8200000p-78, -0x1.000fff8000000p+9, -0x1.fffffe0000000p-53, -0x1.000fff7c00000p+9, 0x1.f800000400000p-47},
{-0x1.0000008000000p-21, 0x1.ffffff8200000p-78, 0x1.000fff8000000p+9, 0x1.fffffe0000000p-53, 0x1.000fff7c00000p+9, -0x1.f800000400000p-47},
{-0x1.0000008000000p-21, 0x1.ffffff8200000p-78, -0x1.000fff8000000p+9, -0x1.fffffe0000000p-53, -0x1.000fff8400000p+9, -0x1.03fffffa00000p-46},
{0x1.0000000000000p-33, 0x1.0001f9e000000p-93, 0x1.0000000000040p+19, -0x1.fffffc0080000p-53, 0x1.0000000000041p+19, -0x1.fffffc0080000p-53},
{0x1.0000000000000p-33, 0x1.0001f9e000000p-93, -0x1.0000000000040p+19, 0x1.fffffc0080000p-53, -0x1.000000000003fp+19, 0x1.fffffc0080000p-53},
{-0x1.0000000000000p-33, -0x1.0001f9e000000p-93, 0x1.0000000000040p+19, -0x1.fffffc0080000p-53, 0x1.000000000003fp+19, -0x1.fffffc0080000p-53},
{-0x1.0000000000000p-33, -0x1.0001f9e000000p-93, -0x1.0000000000040p+19, 0x1.fffffc0080000p-53, -0x1.0000000000041p+19, 0x1.fffffc0080000p-53},
{0x1.0000ff0007e00p-13, 0x1.ffc001ff00000p-80, 0x1.0000010000000p-33, -0x1.ffc007ffffe20p-91, 0x1.00010f0007f00p-13, 0x1.ff8009fe00000p-80},
{0x1.0000ff0007e00p-13, 0x1.ffc001ff00000p-80, -0x1.0000010000000p-33, 0x1.ffc007ffffe20p-91, 0x1.0000ef0007d00p-13, 0x1.fffffa0000000p-80},
{-0x1.0000ff0007e00p-13, -0x1.ffc001ff00000p-80, 0x1.0000010000000p-33, -0x1.ffc007ffffe20p-91, -0x1.0000ef0007d00p-13, -0x1.fffffa0000000p-80},
{-0x1.0000ff0007e00p-13, -0x1.ffc001ff00000p-80, -0x1.0000010000000p-33, 0x1.ffc007ffffe20p-91, -0x1.00010f0007f00p-13, -0x1.ff8009fe00000p-80},
{0x1.07ffffff1fe00p-53, 0x1.fc00000000000p-150, 0x1.0040000000000p-23, -0x1.c000000400000p-84, 0x1.0040000420000p-23, -0x1.1808000200000p-83},
{0x1.07ffffff1fe00p-53, 0x1.fc00000000000p-150, -0x1.0040000000000p-23, 0x1.c000000400000p-84, -0x1.003ffffbe0000p-23, 0x1.4ff0000400000p-84},
{-0x1.07ffffff1fe00p-53, -0x1.fc00000000000p-150, 0x1.0040000000000p-23, -0x1.c000000400000p-84, 0x1.003ffffbe0000p-23, -0x1.4ff0000400000p-84},
{-0x1.07ffffff1fe00p-53, -0x1.fc00000000000p-150, -0x1.0040000000000p-23, 0x1.c000000400000p-84, -0x1.0040000420000p-23, 0x1.1808000200000p-83},
{0x1.0080000000000p+15, -0x1.0000000000000p-90, 0x1.00000001fffc0p-35, 0x1.fffff80f80000p-107, 0x1.0080000000004p+15, 0x1.fffbfe0000000p-67},
{0x1.0080000000000p+15, -0x1.0000000000000p-90, -0x1.00000001fffc0p-35, -0x1.fffff80f80000p-107, 0x1.007fffffffffcp+15, -0x1.fffc020000000p-67},
{-0x1.0080000000000p+15, 0x1.0000000000000p-90, 0x1.00000001fffc0p-35, 0x1.fffff80f80000p-107, -0x1.007fffffffffcp+15, 0x1.fffc020000000p-67},
{-0x1.0080000000000p+15, 0x1.0000000000000p-90, -0x1.00000001fffc0p-35, -0x1.fffff80f80000p-107, -0x1.0080000000004p+15, -0x1.fffbfe0000000p-67},
{0x1.000000003ff00p+2, 0x0.0000000000000p+0, 0x1.0000000000000p+46, 0x1.f83007ffffe00p-14, 0x1.0000000000100p+46, 0x1.f83047efffe00p-14},
{0x1.000000003ff00p+2, 0x0.0000000000000p+0, -0x1.0000000000000p+46, -0x1.f83007ffffe00p-14, -0x1.ffffffffffe00p+45, -0x1.f82fc80fffe00p-14},
{-0x1.000000003ff00p+2, 0x0.0000000000000p+0, 0x1.0000000000000p+46, 0x1.f83007ffffe00p-14, 0x1.ffffffffffe00p+45, 0x1.f82fc80fffe00p-14},
{-0x1.000000003ff00p+2, 0x0.0000000000000p+0, -0x1.0000000000000p+46, -0x1.f83007ffffe00p-14, -0x1.0000000000100p+46, -0x1.f83047efffe00p-14},
{0x1.00003fffffe00p+13, 0x1.fffffc0000380p-47, 0x1.0000010000000p-8, -0x1.ffffff8000008p-64, 0x1.000047ffffe80p+13, 0x1.fffefc0000780p-47},
{0x1.00003fffffe00p+13, 0x1.fffffc0000380p-47, -0x1.0000010000000p-8, 0x1.ffffff8000008p-64, 0x1.000037ffffd80p+13, 0x1.00007dfffffc0p-46},
{-0x1.00003fffffe00p+13, -0x1.fffffc0000380p-47, 0x1.0000010000000p-8, -0x1.ffffff8000008p-64, -0x1.000037ffffd80p+13, -0x1.00007dfffffc0p-46},
{-0x1.00003fffffe00p+13, -0x1.fffffc0000380p-47, -0x1.0000010000000p-8, 0x1.ffffff8000008p-64, -0x1.000047ffffe80p+13, -0x1.fffefc0000780p-47},
{0x1.0000000080000p+13, -0x1.fffffc0010000p-56, 0x1.3fffff8000000p-19, 0x1.fffff800fe000p-85, 0x1.00000001c0000p+13, -0x1.001fffffbf010p-44},
{0x1.0000000080000p+13, -0x1.fffffc0010000p-56, -0x1.3fffff8000000p-19, -0x1.fffff800fe000p-85, 0x1.fffffffe80000p+12, 0x1.ffc000007dfe0p-45},
{-0x1.0000000080000p+13, 0x1.fffffc0010000p-56, 0x1.3fffff8000000p-19, 0x1.fffff800fe000p-85, -0x1.fffffffe80000p+12, -0x1.ffc000007dfe0p-45},
{-0x1.0000000080000p+13, 0x1.fffffc0010000p-56, -0x1.3fffff8000000p-19, -0x1.fffff800fe000p-85, -0x1.00000001c0000p+13, 0x1.001fffffbf010p-44},
{0x1.0003f001fc3f0p-13, 0x1.fffffc0000000p-69, 0x1.0000000000000p+27, 0x1.fc1fffc0000fep-27, 0x1.0000000001001p+27, -0x1.07df81303f702p-27},
{0x1.0003f001fc3f0p-13, 0x1.fffffc0000000p-69, -0x1.0000000000000p+27, -0x1.fc1fffc0000fep-27, -0x1.fffffffffe001p+26, 0x1.ffc0fe9f80e04p-28},
{-0x1.0003f001fc3f0p-13, -0x1.fffffc0000000p-69, 0x1.0000000000000p+27, 0x1.fc1fffc0000fep-27, 0x1.fffffffffe001p+26, -0x1.ffc0fe9f80e04p-28},
{-0x1.0003f001fc3f0p-13, -0x1.fffffc0000000p-69, -0x1.0000000000000p+27, -0x1.fc1fffc0000fep-27, -0x1.0000000001001p+27, 0x1.07df81303f702p-27},
{0x1.0000000000000p+49, 0x1.fffffffffffc0p-10, 0x1.0000000000000p+12, 0x1.ffffffffffe00p-50, 0x1.0000000008000p+49, 0x1.0000000000fe0p-9},
{0x1.0000000000000p+49, 0x1.fffffffffffc0p-10, -0x1.0000000000000p+12, -0x1.ffffffffffe00p-50, 0x1.fffffffff0000p+48, 0x1.fffffffffdfc0p-10},
{-0x1.0000000000000p+49, -0x1.fffffffffffc0p-10, 0x1.0000000000000p+12, 0x1.ffffffffffe00p-50, -0x1.fffffffff0000p+48, -0x1.fffffffffdfc0p-10},
{-0x1.0000000000000p+49, -0x1.fffffffffffc0p-10, -0x1.0000000000000p+12, -0x1.ffffffffffe00p-50, -0x1.0000000008000p+49, -0x1.0000000000fe0p-9},
{0x1.0000000100000p-51, -0x1.0000000000000p-130, 0x1.0000004000000p+23, -0x1.0000000000000p-57, 0x1.0000004000000p+23, 0x1.f800000000000p-52},
{0x1.0000000100000p-51, -0x1.0000000000000p-130, -0x1.0000004000000p+23, 0x1.0000000000000p-57, -0x1.0000004000000p+23, 0x1.0400000000000p-51},
{-0x1.0000000100000p-51, 0x1.0000000000000p-130, 0x1.0000004000000p+23, -0x1.0000000000000p-57, 0x1.0000004000000p+23, -0x1.0400000000000p-51},
{-0x1.0000000100000p-51, 0x1.0000000000000p-130, -0x1.0000004000000p+23, 0x1.0000000000000p-57, -0x1.0000004000000p+23, -0x1.f800000000000p-52},
{0x1.0000010000000p-27, -0x1.ffffe00001000p-83, 0x1.000ffffff007fp-2, 0x1.ffffc00000000p-83, 0x1.0010007ff0087p-2, -0x1.0000000000000p-102},
{0x1.0000010000000p-27, -0x1.ffffe00001000p-83, -0x1.000ffffff007fp-2, -0x1.ffffc00000000p-83, -0x1.000fff7ff0077p-2, -0x1.ffffd00000000p-82},
{-0x1.0000010000000p-27, 0x1.ffffe00001000p-83, 0x1.000ffffff007fp-2, 0x1.ffffc00000000p-83, 0x1.000fff7ff0077p-2, 0x1.ffffd00000000p-82},
{-0x1.0000010000000p-27, 0x1.ffffe00001000p-83, -0x1.000ffffff007fp-2, -0x1.ffffc00000000p-83, -0x1.0010007ff0087p-2, 0x1.0000000000000p-102},
{0x1.1000fffffc000p+50, 0x1.fffffc003f000p-6, 0x1.0000000001000p+30, -0x1.0000000000000p-75, 0x1.10010ffffc000p+50, 0x1.07fffe001f800p-5},
{0x1.1000fffffc000p+50, 0x1.fffffc003f000p-6, -0x1.0000000001000p+30, 0x1.0000000000000p-75, 0x1.1000effffc000p+50, 0x1.effffc003f000p-6},
{-0x1.1000fffffc000p+50, -0x1.fffffc003f000p-6, 0x1.0000000001000p+30, -0x1.0000000000000p-75, -0x1.1000effffc000p+50, -0x1.effffc003f000p-6},
{-0x1.1000fffffc000p+50, -0x1.fffffc003f000p-6, -0x1.0000000001000p+30, 0x1.0000000000000p-75, -0x1.10010ffffc000p+50, -0x1.07fffe001f800p-5},
{0x1.00000fff80000p+32, 0x1.fffe000000000p-53, 0x1.0000001f00000p+41, 0x1.fffffff000000p-36, 0x1.00800026ffc00p+41, 0x1.00007ff800000p-35},
{0x1.00000fff80000p+32, 0x1.fffe000000000p-53, -0x1.0000001f00000p+41, -0x1.fffffff000000p-36, -0x1.ff00002e00800p+40, -0x1.fffefff000000p-36},
{-0x1.00000fff80000p+32, -0x1.fffe000000000p-53, 0x1.0000001f00000p+41, 0x1.fffffff000000p-36, 0x1.ff00002e00800p+40, 0x1.fffefff000000p-36},
{-0x1.00000fff80000p+32, -0x1.fffe000000000p-53, -0x1.0000001f00000p+41, -0x1.fffffff000000p-36, -0x1.00800026ffc00p+41, -0x1.00007ff800000p-35},
{0x1.3fdfffff02000p+34, -0x1.0000000000000p-44, 0x1.0000000000000p+31, 0x1.ffffffffffe00p-30, 0x1.5fdfffff02000p+34, 0x1.fffc000000000p-30},
{0x1.3fdfffff02000p+34, -0x1.0000000000000p-44, -0x1.0000000000000p+31, -0x1.ffffffffffe00p-30, 0x1.1fdfffff02000p+34, -0x1.0002000000000p-29},
{-0x1.3fdfffff02000p+34, 0x1.0000000000000p-44, 0x1.0000000000000p+31, 0x1.ffffffffffe00p-30, -0x1.1fdfffff02000p+34, 0x1.0002000000000p-29},
{-0x1.3fdfffff02000p+34, 0x1.0000000000000p-44, -0x1.0000000000000p+31, -0x1.ffffffffffe00p-30, -0x1.5fdfffff02000p+34, -0x1.fffc000000000p-30},
{0x1.0000000000008p+41, -0x1.e0ffffd002000p-25, 0x1.0000000000400p+36, 0x1.ffffffff03ffep-18, 0x1.0800000000028p+41, 0x1.fc3dffff63fc0p-18},
{0x1.0000000000008p+41, -0x1.e0ffffd002000p-25, -0x1.0000000000400p+36, -0x1.ffffffff03ffep-18, 0x1.effffffffffd0p+40, -0x1.01e0ffff52020p-17},
{-0x1.0000000000008p+41, 0x1.e0ffffd002000p-25, 0x1.0000000000400p+36, 0x1.ffffffff03ffep-18, -0x1.effffffffffd0p+40, 0x1.01e0ffff52020p-17},
{-0x1.0000000000008p+41, 0x1.e0ffffd002000p-25, -0x1.0000000000400p+36, -0x1.ffffffff03ffep-18, -0x1.0800000000028p+41, -0x1.fc3dffff63fc0p-18},
{0x1.000000fffe020p+17, -0x1.f800100000000p-56, 0x1.0001fff80ffc0p+20, 0x1.ff00000000000p-77, 0x1.200200180fbc4p+20, -0x1.f800000800000p-56},
{0x1.000000fffe020p+17, -0x1.f800100000000p-56, -0x1.0001fff80ffc0p+20, -0x1.ff00000000000p-77, -0x1.c003ffb020778p+19, -0x1.f8001ff800000p-56},
{-0x1.000000fffe020p+17, 0x1.f800100000000p-56, 0x1.0001fff80ffc0p+20, 0x1.ff00000000000p-77, 0x1.c003ffb020778p+19, 0x1.f8001ff800000p-56},
{-0x1.000000fffe020p+17, 0x1.f800100000000p-56, -0x1.0001fff80ffc0p+20, -0x1.ff00000000000p-77, -0x1.200200180fbc4p+20, 0x1.f800000800000p-56},
{0x1.4000000000000p+46, -0x1.0000000000000p-59, 0x1.0000000000010p-11, 0x1.e000000000000p-79, 0x1.4000000000000p+46, 0x1.0000000000000p-11},
{0x1.4000000000000p+46, -0x1.0000000000000p-59, -0x1.0000000000010p-11, -0x1.e000000000000p-79, 0x1.4000000000000p+46, -0x1.0000000000020p-11},
{-0x1.4000000000000p+46, 0x1.0000000000000p-59, 0x1.0000000000010p-11, 0x1.e000000000000p-79, -0x1.4000000000000p+46, 0x1.0000000000020p-11},
{-0x1.4000000000000p+46, 0x1.0000000000000p-59, -0x1.0000000000010p-11, -0x1.e000000000000p-79, -0x1.4000000000000p+46, -0x1.0000000000000p-11},
{0x1.2000000000000p+0, -0x1.fffffff01ff20p-57, 0x1.0000000000000p-33, 0x1.fff8003ff0000p-90, 0x1.2000000080000p+0, -0x1.ffffffef1ff60p-57},
{0x1.2000000000000p+0, -0x1.fffffff01ff20p-57, -0x1.0000000000000p-33, -0x1.fff8003ff0000p-90, 0x1.1fffffff80000p+0, -0x1.fffffff11fee0p-57},
{-0x1.2000000000000p+0, 0x1.fffffff01ff20p-57, 0x1.0000000000000p-33, 0x1.fff8003ff0000p-90, -0x1.1fffffff80000p+0, 0x1.fffffff11fee0p-57},
{-0x1.2000000000000p+0, 0x1.fffffff01ff20p-57, -0x1.0000000000000p-33, -0x1.fff8003ff0000p-90, -0x1.2000000080000p+0, 0x1.ffffffef1ff60p-57},
{0x1.2000000000000p+14, -0x1.fc08000000000p-78, 0x1.0000000038004p+6, -0x1.fffffc4000000p-63, 0x1.2100000000380p+14, 0x1.ffff7fff02ec0p-45},
{0x1.2000000000000p+14, -0x1.fc08000000000p-78, -0x1.0000000038004p+6, 0x1.fffffc4000000p-63, 0x1.1effffffffc80p+14, -0x1.ffff8000fef40p-45},
{-0x1.2000000000000p+14, 0x1.fc08000000000p-78, 0x1.0000000038004p+6, -0x1.fffffc4000000p-63, -0x1.1effffffffc80p+14, 0x1.ffff8000fef40p-45},
{-0x1.2000000000000p+14, 0x1.fc08000000000p-78, -0x1.0000000038004p+6, 0x1.fffffc4000000p-63, -0x1.2100000000380p+14, -0x1.ffff7fff02ec0p-45},
{0x1.0000000000200p+30, 0x0.0000000000000p+0, 0x1.00001ffff0000p+10, 0x1.ffff80001f000p-47, 0x1.0000100002200p+30, -0x1.ffffe00008000p-27},
{0x1.0000000000200p+30, 0x0.0000000000000p+0, -0x1.00001ffff0000p+10, -0x1.ffff80001f000p-47, 0x1.ffffdffffc400p+29, 0x1.ffffe00008000p-27},
{-0x1.0000000000200p+30, 0x0.0000000000000p+0, 0x1.00001ffff0000p+10, 0x1.ffff80001f000p-47, -0x1.ffffdffffc400p+29, -0x1.ffffe00008000p-27},
{-0x1.0000000000200p+30, 0x0.0000000000000p+0, -0x1.00001ffff0000p+10, -0x1.ffff80001f000p-47, -0x1.0000100002200p+30, 0x1.ffffe00008000p-27},
{0x1.0000100000000p-17, -0x1.0000000000000p-122, 0x1.0038000800000p+15, -0x1.fffffe0000080p-45, 0x1.0038000900001p+15, -0x1.fffffe0000080p-45},
{0x1.0000100000000p-17, -0x1.0000000000000p-122, -0x1.0038000800000p+15, 0x1.fffffe0000080p-45, -0x1.00380006fffffp+15, 0x1.fffffe0000080p-45},
{-0x1.0000100000000p-17, 0x1.0000000000000p-122, 0x1.0038000800000p+15, -0x1.fffffe0000080p-45, 0x1.00380006fffffp+15, -0x1.fffffe0000080p-45},
{-0x1.0000100000000p-17, 0x1.0000000000000p-122, -0x1.0038000800000p+15, 0x1.fffffe0000080p-45, -0x1.0038000900001p+15, 0x1.fffffe0000080p-45},
{0x1.0000000000004p-11, -0x1.ffffe00400000p-84, 0x1.0000000000000p-12, 0x1.ffffffffffff8p-68, 0x1.8000000000004p-11, 0x1.fffe00001ffc0p-68},
{0x1.0000000000004p-11, -0x1.ffffe00400000p-84, -0x1.0000000000000p-12, -0x1.ffffffffffff8p-68, 0x1.0000000000008p-12, -0x1.0000fffff001cp-67},
{-0x1.0000000000004p-11, 0x1.ffffe00400000p-84, 0x1.0000000000000p-12, 0x1.ffffffffffff8p-68, -0x1.0000000000008p-12, 0x1.0000fffff001cp-67},
{-0x1.0000000000004p-11, 0x1.ffffe00400000p-84, -0x1.0000000000000p-12, -0x1.ffffffffffff8p-68, -0x1.8000000000004p-11, -0x1.fffe00001ffc0p-68},
{0x1.0000000000100p-33, -0x1.ffffe7e400000p-103, 0x1.1ffe000008000p-33, -0x1.fffc000004000p-100, 0x1.0fff000004080p-32, -0x1.1ffdfe7e40000p-99},
{0x1.0000000000100p-33, -0x1.ffffe7e400000p-103, -0x1.1ffe000008000p-33, 0x1.fffc000004000p-100, -0x1.ffe000007f000p-37, 0x1.bffc030384000p-100},
{-0x1.0000000000100p-33, 0x1.ffffe7e400000p-103, 0x1.1ffe000008000p-33, -0x1.fffc000004000p-100, 0x1.ffe000007f000p-37, -0x1.bffc030384000p-100},
{-0x1.0000000000100p-33, 0x1.ffffe7e400000p-103, -0x1.1ffe000008000p-33, 0x1.fffc000004000p-100, -0x1.0fff000004080p-32, 0x1.1ffdfe7e40000p-99},
{0x1.0000000000004p-52, -0x1.0000000000000p-157, 0x1.00000007ffffep-10, 0x1.ffffe000f0000p-71, 0x1.00000008003fep-10, 0x1.ffffe002f0000p-71},
{0x1.0000000000004p-52, -0x1.0000000000000p-157, -0x1.00000007ffffep-10, -0x1.ffffe000f0000p-71, -0x1.00000007ffbfep-10, -0x1.ffffdffef0000p-71},
{-0x1.0000000000004p-52, 0x1.0000000000000p-157, 0x1.00000007ffffep-10, 0x1.ffffe000f0000p-71, 0x1.00000007ffbfep-10, 0x1.ffffdffef0000p-71},
{-0x1.0000000000004p-52, 0x1.0000000000000p-157, -0x1.00000007ffffep-10, -0x1.ffffe000f0000p-71, -0x1.00000008003fep-10, -0x1.ffffe002f0000p-71},
{0x1.0000000000000p+3, 0x1.fffffff000000p-58, 0x1.0001fffc00001p-42, -0x1.0000000000000p-121, 0x1.0000000000080p+3, 0x1.fffdfff808000p-57},
{0x1.0000000000000p+3, 0x1.fffffff000000p-58, -0x1.0001fffc00001p-42, 0x1.0000000000000p-121, 0x1.fffffffffff00p+2, 0x1.fff7f80000000p-73},
{-0x1.0000000000000p+3, -0x1.fffffff000000p-58, 0x1.0001fffc00001p-42, -0x1.0000000000000p-121, -0x1.fffffffffff00p+2, -0x1.fff7f80000000p-73},
{-0x1.0000000000000p+3, -0x1.fffffff000000p-58, -0x1.0001fffc00001p-42, 0x1.0000000000000p-121, -0x1.0000000000080p+3, -0x1.fffdfff808000p-57},
{0x1.00007fdfffff0p+50, 0x1.fff000f803fe0p-8, 0x1.0080000000000p-8, -0x1.0000000000000p-100, 0x1.00007fdfffff0p+50, 0x1.8038007c01ff0p-7},
{0x1.00007fdfffff0p+50, 0x1.fff000f803fe0p-8, -0x1.0080000000000p-8, 0x1.0000000000000p-100, 0x1.00007fdfffff0p+50, 0x1.fee001f007fc0p-9},
{-0x1.00007fdfffff0p+50, -0x1.fff000f803fe0p-8, 0x1.0080000000000p-8, -0x1.0000000000000p-100, -0x1.00007fdfffff0p+50, -0x1.fee001f007fc0p-9},
{-0x1.00007fdfffff0p+50, -0x1.fff000f803fe0p-8, -0x1.0080000000000p-8, 0x1.0000000000000p-100, -0x1.00007fdfffff0p+50, -0x1.8038007c01ff0p-7},
{0x1.0000000000080p+4, 0x0.0000000000000p+0, 0x1.0000080000000p+20, -0x1.0000000000000p-65, 0x1.0001080000000p+20, 0x1.fffffe0000000p-42},
{0x1.0000000000080p+4, 0x0.0000000000000p+0, -0x1.0000080000000p+20, 0x1.0000000000000p-65, -0x1.fffe100000000p+19, 0x1.0000010000000p-41},
{-0x1.0000000000080p+4, 0x0.0000000000000p+0, 0x1.0000080000000p+20, -0x1.0000000000000p-65, 0x1.fffe100000000p+19, -0x1.0000010000000p-41},
{-0x1.0000000000080p+4, 0x0.0000000000000p+0, -0x1.0000080000000p+20, 0x1.0000000000000p-65, -0x1.0001080000000p+20, -0x1.fffffe0000000p-42},
{0x1.0400000000000p+20, -0x1.0000000000000p-85, 0x1.0000000000400p+5, -0x1.fffff00008000p-51, 0x1.0402000000000p+20, 0x1.fff000007ffe0p-38},
{0x1.0400000000000p+20, -0x1.0000000000000p-85, -0x1.0000000000400p+5, 0x1.fffff00008000p-51, 0x1.03fe000000000p+20, -0x1.fff0000080020p-38},
{-0x1.0400000000000p+20, 0x1.0000000000000p-85, 0x1.0000000000400p+5, -0x1.fffff00008000p-51, -0x1.03fe000000000p+20, 0x1.fff0000080020p-38},
{-0x1.0400000000000p+20, 0x1.0000000000000p-85, -0x1.0000000000400p+5, 0x1.fffff00008000p-51, -0x1.0402000000000p+20, -0x1.fff000007ffe0p-38},
{0x1.0000000000001p+43, -0x1.fc0000c004000p-22, 0x1.0000000000200p+29, -0x1.ffe0000200000p-39, 0x1.0004000000001p+43, 0x1.fc07fdfe9ff80p-15},
{0x1.0000000000001p+43, -0x1.fc0000c004000p-22, -0x1.0000000000200p+29, 0x1.ffe0000200000p-39, 0x1.fff8000000002p+42, -0x1.01fbff00d0040p-14},
{-0x1.0000000000001p+43, 0x1.fc0000c004000p-22, 0x1.0000000000200p+29, -0x1.ffe0000200000p-39, -0x1.fff8000000002p+42, 0x1.01fbff00d0040p-14},
{-0x1.0000000000001p+43, 0x1.fc0000c004000p-22, -0x1.0000000000200p+29, 0x1.ffe0000200000p-39, -0x1.0004000000001p+43, -0x1.fc07fdfe9ff80p-15},
{0x1.00000c0000004p+1, -0x1.ff80000800000p-67, 0x1.18003ffff8000p+4, 0x1.ffffff8000000p-62, 0x1.3800417ff8001p+4, -0x1.ffe0ffc008040p-50},
{0x1.00000c0000004p+1, -0x1.ff80000800000p-67, -0x1.18003ffff8000p+4, -0x1.ffffff8000000p-62, -0x1.f0007cffeffffp+3, -0x1.07fdffc020000p-61},
{-0x1.00000c0000004p+1, 0x1.ff80000800000p-67, 0x1.18003ffff8000p+4, 0x1.ffffff8000000p-62, 0x1.f0007cffeffffp+3, 0x1.07fdffc020000p-61},
{-0x1.00000c0000004p+1, 0x1.ff80000800000p-67, -0x1.18003ffff8000p+4, -0x1.ffffff8000000p-62, -0x1.3800417ff8001p+4, 0x1.ffe0ffc008040p-50},
{0x1.1ffff80000040p+31, -0x1.0000000000000p-59, 0x1.000000000fe00p+44, 0x1.ffff7e0003ff8p-12, 0x1.0008ffffcfe00p+44, 0x1.0fffbf0001fecp-11},
{0x1.1ffff80000040p+31, -0x1.0000000000000p-59, -0x1.000000000fe00p+44, -0x1.ffff7e0003ff8p-12, -0x1.ffee00009fc00p+43, -0x1.dfff7e0004018p-12},
{-0x1.1ffff80000040p+31, 0x1.0000000000000p-59, 0x1.000000000fe00p+44, 0x1.ffff7e0003ff8p-12, 0x1.ffee00009fc00p+43, 0x1.dfff7e0004018p-12},
{-0x1.1ffff80000040p+31, 0x1.0000000000000p-59, -0x1.000000000fe00p+44, -0x1.ffff7e0003ff8p-12, -0x1.0008ffffcfe00p+44, -0x1.0fffbf0001fecp-11},
{0x1.3fc0000040000p-13, -0x1.fffffff802000p-69, 0x1.fffffffffff00p+30, 0x0.0000000000000p+0, 0x1.00000000000c0p+31, -0x1.fffffe0000100p-24},
{0x1.3fc0000040000p-13, -0x1.fffffff802000p-69, -0x1.fffffffffff00p+30, 0x0.0000000000000p+0, -0x1.ffffffffffc80p+30, -0x1.fffffe0000100p-24},
{-0x1.3fc0000040000p-13, 0x1.fffffff802000p-69, 0x1.fffffffffff00p+30, 0x0.0000000000000p+0, 0x1.ffffffffffc80p+30, 0x1.fffffe0000100p-24},
{-0x1.3fc0000040000p-13, 0x1.fffffff802000p-69, -0x1.fffffffffff00p+30, 0x0.0000000000000p+0, -0x1.00000000000c0p+31, 0x1.fffffe0000100p-24},
{0x1.00000001fffffp-1, 0x1.00001f8000000p-72, 0x1.0000000000200p-15, -0x1.0000000000000p-120, 0x1.00040001fffffp-1, 0x1.000400007e000p-58},
{0x1.00000001fffffp-1, 0x1.00001f8000000p-72, -0x1.0000000000200p-15, 0x1.0000000000000p-120, 0x1.fff80003ffffep-2, -0x1.fff7ffff04000p-59},
{-0x1.00000001fffffp-1, -0x1.00001f8000000p-72, 0x1.0000000000200p-15, -0x1.0000000000000p-120, -0x1.fff80003ffffep-2, 0x1.fff7ffff04000p-59},
{-0x1.00000001fffffp-1, -0x1.00001f8000000p-72, -0x1.0000000000200p-15, 0x1.0000000000000p-120, -0x1.00040001fffffp-1, -0x1.000400007e000p-58},
{0x1.0000000010000p+26, -0x1.0000000000000p-51, 0x1.1fff010000000p-53, 0x1.ff8c0000007fep-107, 0x1.0000000010000p+26, -0x1.70007f8000000p-52},
{0x1.0000000010000p+26, -0x1.0000000000000p-51, -0x1.1fff010000000p-53, -0x1.ff8c0000007fep-107, 0x1.0000000010000p+26, -0x1.47ffc04000000p-51},
{-0x1.0000000010000p+26, 0x1.0000000000000p-51, 0x1.1fff010000000p-53, 0x1.ff8c0000007fep-107, -0x1.0000000010000p+26, 0x1.47ffc04000000p-51},
{-0x1.0000000010000p+26, 0x1.0000000000000p-51, -0x1.1fff010000000p-53, -0x1.ff8c0000007fep-107, -0x1.0000000010000p+26, 0x1.70007f8000000p-52},
{0x1.0000000000002p-44, -0x1.0000000000000p-131, 0x1.0000000000200p+33, -0x1.0000000000000p-52, 0x1.0000000000200p+33, 0x1.fe00000000000p-45},
{0x1.0000000000002p-44, -0x1.0000000000000p-131, -0x1.0000000000200p+33, 0x1.0000000000000p-52, -0x1.0000000000200p+33, 0x1.0100000000000p-44},
{-0x1.0000000000002p-44, 0x1.0000000000000p-131, 0x1.0000000000200p+33, -0x1.0000000000000p-52, 0x1.0000000000200p+33, -0x1.0100000000000p-44},
{-0x1.0000000000002p-44, 0x1.0000000000000p-131, -0x1.0000000000200p+33, 0x1.0000000000000p-52, -0x1.0000000000200p+33, -0x1.fe00000000000p-45},
{0x1.0000000000002p+32, -0x1.ffff800008000p-35, 0x1.000000003fffep-25, 0x1.f81fc007c0000p-96, 0x1.0000000000002p+32, 0x1.ff0000407ffc0p-26},
{0x1.0000000000002p+32, -0x1.ffff800008000p-35, -0x1.000000003fffep-25, -0x1.f81fc007c0000p-96, 0x1.0000000000002p+32, -0x1.007fffe040020p-25},
{-0x1.0000000000002p+32, 0x1.ffff800008000p-35, 0x1.000000003fffep-25, 0x1.f81fc007c0000p-96, -0x1.0000000000002p+32, 0x1.007fffe040020p-25},
{-0x1.0000000000002p+32, 0x1.ffff800008000p-35, -0x1.000000003fffep-25, -0x1.f81fc007c0000p-96, -0x1.0000000000002p+32, -0x1.ff0000407ffc0p-26},
{0x1.7ffffffff0000p+18, 0x1.ffff07fffc000p-46, 0x1.000000000ffe0p-32, 0x1.ff0000003c000p-95, 0x1.7ffffffff0004p+18, 0x1.ffff0bff7c000p-46},
{0x1.7ffffffff0000p+18, 0x1.ffff07fffc000p-46, -0x1.000000000ffe0p-32, -0x1.ff0000003c000p-95, 0x1.7fffffffefffcp+18, 0x1.ffff04007c000p-46},
{-0x1.7ffffffff0000p+18, -0x1.ffff07fffc000p-46, 0x1.000000000ffe0p-32, 0x1.ff0000003c000p-95, -0x1.7fffffffefffcp+18, -0x1.ffff04007c000p-46},
{-0x1.7ffffffff0000p+18, -0x1.ffff07fffc000p-46, -0x1.000000000ffe0p-32, -0x1.ff0000003c000p-95, -0x1.7ffffffff0004p+18, -0x1.ffff0bff7c000p-46},
{0x1.00007fff00080p-52, -0x1.ffffff0001000p-117, 0x1.00000000007c0p+41, 0x1.ffffff8000000p-26, 0x1.00000000007c0p+41, 0x1.ffffffc000000p-26},
{0x1.00007fff00080p-52, -0x1.ffffff0001000p-117, -0x1.00000000007c0p+41, -0x1.ffffff8000000p-26, -0x1.00000000007c0p+41, -0x1.ffffff4000000p-26},
{-0x1.00007fff00080p-52, 0x1.ffffff0001000p-117, 0x1.00000000007c0p+41, 0x1.ffffff8000000p-26, 0x1.00000000007c0p+41, 0x1.ffffff4000000p-26},
{-0x1.00007fff00080p-52, 0x1.ffffff0001000p-117, -0x1.00000000007c0p+41, -0x1.ffffff8000000p-26, -0x1.00000000007c0p+41, -0x1.ffffffc000000p-26},
{0x1.1fff81ff00000p+13, 0x1.e007ffff00000p-44, 0x1.1ffffffff8000p-5, 0x1.fe001ffffffe0p-61, 0x1.1fffc9ff00000p+13, -0x1.0ffb808078000p-43},
{0x1.1fff81ff00000p+13, 0x1.e007ffff00000p-44, -0x1.1ffffffff8000p-5, -0x1.fe001ffffffe0p-61, 0x1.1fff39ff00000p+13, 0x1.7801c03fbc000p-42},
{-0x1.1fff81ff00000p+13, -0x1.e007ffff00000p-44, 0x1.1ffffffff8000p-5, 0x1.fe001ffffffe0p-61, -0x1.1fff39ff00000p+13, -0x1.7801c03fbc000p-42},
{-0x1.1fff81ff00000p+13, -0x1.e007ffff00000p-44, -0x1.1ffffffff8000p-5, -0x1.fe001ffffffe0p-61, -0x1.1fffc9ff00000p+13, 0x1.0ffb808078000p-43},
{0x1.0000000000000p+15, 0x1.fffc03fe00700p-46, 0x1.0000000000001p+24, -0x1.fff8060000f34p-31, 0x1.0080000000001p+24, -0x1.fff40607f8f74p-31},
{0x1.0000000000000p+15, 0x1.fffc03fe00700p-46, -0x1.0000000000001p+24, 0x1.fff8060000f34p-31, -0x1.ff00000000002p+23, 0x1.fffc05f808ef4p-31},
{-0x1.0000000000000p+15, -0x1.fffc03fe00700p-46, 0x1.0000000000001p+24, -0x1.fff8060000f34p-31, 0x1.ff00000000002p+23, -0x1.fffc05f808ef4p-31},
{-0x1.0000000000000p+15, -0x1.fffc03fe00700p-46, -0x1.0000000000001p+24, 0x1.fff8060000f34p-31, -0x1.0080000000001p+24, 0x1.fff40607f8f74p-31},
{0x1.001ffffc00080p+19, -0x1.fe00000200000p-42, 0x1.0000000001000p-24, -0x1.fe3ffffff0080p-84, 0x1.001ffffc00280p+19, -0x1.fdfffc0200800p-42},
{0x1.001ffffc00080p+19, -0x1.fe00000200000p-42, -0x1.0000000001000p-24, 0x1.fe3ffffff0080p-84, 0x1.001ffffbffe80p+19, -0x1.fe000401ff800p-42},
{-0x1.001ffffc00080p+19, 0x1.fe00000200000p-42, 0x1.0000000001000p-24, -0x1.fe3ffffff0080p-84, -0x1.001ffffbffe80p+19, 0x1.fe000401ff800p-42},
{-0x1.001ffffc00080p+19, 0x1.fe00000200000p-42, -0x1.0000000001000p-24, 0x1.fe3ffffff0080p-84, -0x1.001ffffc00280p+19, 0x1.fdfffc0200800p-42},
{0x1.00001fffff800p+37, 0x1.ffffff801ffc0p-22, 0x1.0000000002000p+12, -0x1.0000000000000p-93, 0x1.0000207fff800p+37, 0x1.03ffffc00ffe0p-21},
{0x1.00001fffff800p+37, 0x1.ffffff801ffc0p-22, -0x1.0000000002000p+12, 0x1.0000000000000p-93, 0x1.00001f7fff800p+37, 0x1.f7ffff801ffc0p-22},
{-0x1.00001fffff800p+37, -0x1.ffffff801ffc0p-22, 0x1.0000000002000p+12, -0x1.0000000000000p-93, -0x1.00001f7fff800p+37, -0x1.f7ffff801ffc0p-22},
{-0x1.00001fffff800p+37, -0x1.ffffff801ffc0p-22, -0x1.0000000002000p+12, 0x1.0000000000000p-93, -0x1.0000207fff800p+37, -0x1.03ffffc00ffe0p-21},
{0x1.0000000000000p-40, 0x1.ffff83ffbfff0p-96, 0x1.0000000000000p-34, 0x1.ffffffffe0000p-90, 0x1.0400000000000p-34, 0x1.03ffff07ef800p-89},
{0x1.0000000000000p-40, 0x1.ffff83ffbfff0p-96, -0x1.0000000000000p-34, -0x1.ffffffffe0000p-90, -0x1.f800000000000p-35, -0x1.f80001efe1000p-90},
{-0x1.0000000000000p-40, -0x1.ffff83ffbfff0p-96, 0x1.0000000000000p-34, 0x1.ffffffffe0000p-90, 0x1.f800000000000p-35, 0x1.f80001efe1000p-90},
{-0x1.0000000000000p-40, -0x1.ffff83ffbfff0p-96, -0x1.0000000000000p-34, -0x1.ffffffffe0000p-90, -0x1.0400000000000p-34, -0x1.03ffff07ef800p-89},
{0x1.0000000000000p+39, 0x1.fffe7ff3dff00p-22, 0x1.000007f830000p+13, 0x1.fff0000ffe100p-48, 0x1.0000004000020p+39, -0x1.e4000bfc61208p-17},
{0x1.0000000000000p+39, 0x1.fffe7ff3dff00p-22, -0x1.000007f830000p+13, -0x1.fff0000ffe100p-48, 0x1.ffffff7ffffc0p+38, 0x1.01fff9fdcf8fcp-16},
{-0x1.0000000000000p+39, -0x1.fffe7ff3dff00p-22, 0x1.000007f830000p+13, 0x1.fff0000ffe100p-48, -0x1.ffffff7ffffc0p+38, -0x1.01fff9fdcf8fcp-16},
{-0x1.0000000000000p+39, -0x1.fffe7ff3dff00p-22, -0x1.000007f830000p+13, -0x1.fff0000ffe100p-48, -0x1.0000004000020p+39, 0x1.e4000bfc61208p-17},
{0x1.00000ffffe000p+18, 0x1.fffffffffc000p-49, 0x1.0000000000002p-46, -0x1.fffffe01f8004p-101, 0x1.00000ffffe000p+18, 0x1.3fffffffff800p-46},
{0x1.00000ffffe000p+18, 0x1.fffffffffc000p-49, -0x1.0000000000002p-46, 0x1.fffffe01f8004p-101, 0x1.00000ffffe000p+18, -0x1.8000000001000p-47},
{-0x1.00000ffffe000p+18, -0x1.fffffffffc000p-49, 0x1.0000000000002p-46, -0x1.fffffe01f8004p-101, -0x1.00000ffffe000p+18, 0x1.8000000001000p-47},
{-0x1.00000ffffe000p+18, -0x1.fffffffffc000p-49, -0x1.0000000000002p-46, 0x1.fffffe01f8004p-101, -0x1.00000ffffe000p+18, -0x1.3fffffffff800p-46},
{0x1.0000000000060p+41, 0x1.fffe3fff00000p-22, 0x1.0000000002000p+4, -0x1.ffe0002000000p-53, 0x1.0000000008060p+41, 0x1.00031ffd80200p-21},
{0x1.0000000000060p+41, 0x1.fffe3fff00000p-22, -0x1.0000000002000p+4, 0x1.ffe0002000000p-53, 0x1.fffffffff00c0p+40, 0x1.fff64002ffc00p-22},
{-0x1.0000000000060p+41, -0x1.fffe3fff00000p-22, 0x1.0000000002000p+4, -0x1.ffe0002000000p-53, -0x1.fffffffff00c0p+40, -0x1.fff64002ffc00p-22},
{-0x1.0000000000060p+41, -0x1.fffe3fff00000p-22, -0x1.0000000002000p+4, 0x1.ffe0002000000p-53, -0x1.0000000008060p+41, -0x1.00031ffd80200p-21},
{0x1.0003ffffffff8p-50, 0x1.ffffe07e00000p-124, 0x1.07ff000008000p+19, -0x1.e000020000000p-42, 0x1.07ff000008000p+19, -0x1.defffe0000000p-42},
{0x1.0003ffffffff8p-50, 0x1.ffffe07e00000p-124, -0x1.07ff000008000p+19, 0x1.e000020000000p-42, -0x1.07ff000008000p+19, 0x1.e100060000000p-42},
{-0x1.0003ffffffff8p-50, -0x1.ffffe07e00000p-124, 0x1.07ff000008000p+19, -0x1.e000020000000p-42, 0x1.07ff000008000p+19, -0x1.e100060000000p-42},
{-0x1.0003ffffffff8p-50, -0x1.ffffe07e00000p-124, -0x1.07ff000008000p+19, 0x1.e000020000000p-42, -0x1.07ff000008000p+19, 0x1.defffe0000000p-42},
// Some test cases drawn only from the [0.5,1] binade:
{0x1.0000000000002p-1, -0x1.ffc0ffff90000p-65, 0x1.0003ffffffffcp-1, 0x1.ffffc00000000p-88, 0x1.0001fffffffffp+0, -0x1.ffc0fbff90000p-65},
{0x1.0000000000002p-1, -0x1.ffc0ffff90000p-65, -0x1.0003ffffffffcp-1, -0x1.ffffc00000000p-88, -0x1.ffffffffd0010p-16, 0x1.f7e0038400000p-76},
{-0x1.0000000000002p-1, 0x1.ffc0ffff90000p-65, 0x1.0003ffffffffcp-1, 0x1.ffffc00000000p-88, 0x1.ffffffffd0010p-16, -0x1.f7e0038400000p-76},
{-0x1.0000000000002p-1, 0x1.ffc0ffff90000p-65, -0x1.0003ffffffffcp-1, -0x1.ffffc00000000p-88, -0x1.0001fffffffffp+0, 0x1.ffc0fbff90000p-65},
{0x1.0000100000000p-1, -0x1.0000000000000p-63, 0x1.0000000004000p-1, -0x1.ffffe00fc0200p-57, 0x1.0000080002000p+0, -0x1.01fff007e0100p-56},
{0x1.0000100000000p-1, -0x1.0000000000000p-63, -0x1.0000000004000p-1, 0x1.ffffe00fc0200p-57, 0x1.ffff80003f800p-22, -0x1.ff03fe0000000p-77},
{-0x1.0000100000000p-1, 0x1.0000000000000p-63, 0x1.0000000004000p-1, -0x1.ffffe00fc0200p-57, -0x1.ffff80003f800p-22, 0x1.ff03fe0000000p-77},
{-0x1.0000100000000p-1, 0x1.0000000000000p-63, -0x1.0000000004000p-1, 0x1.ffffe00fc0200p-57, -0x1.0000080002000p+0, 0x1.01fff007e0100p-56},
{0x1.0000000800000p-1, -0x1.0000000000000p-73, 0x1.000003fffc002p-1, -0x1.0000000000000p-106, 0x1.00000203fe001p+0, -0x1.0000000000000p-73},
{0x1.0000000800000p-1, -0x1.0000000000000p-73, -0x1.000003fffc002p-1, 0x1.0000000000000p-106, -0x1.fbfe001000008p-24, 0x1.0000000000000p-106},
{-0x1.0000000800000p-1, 0x1.0000000000000p-73, 0x1.000003fffc002p-1, -0x1.0000000000000p-106, 0x1.fbfe001000008p-24, -0x1.0000000000000p-106},
{-0x1.0000000800000p-1, 0x1.0000000000000p-73, -0x1.000003fffc002p-1, 0x1.0000000000000p-106, -0x1.00000203fe001p+0, 0x1.0000000000000p-73},
{0x1.0000000000000p-1, 0x1.ffc001ffffe00p-56, 0x1.000003fff8000p-1, 0x1.fffc000fc0000p-72, 0x1.000001fffc000p+0, 0x1.ffc201fbfff00p-56},
{0x1.0000000000000p-1, 0x1.ffc001ffffe00p-56, -0x1.000003fff8000p-1, -0x1.fffc000fc0000p-72, -0x1.fffbfffe00420p-24, 0x1.01ffe82000000p-79},
{-0x1.0000000000000p-1, -0x1.ffc001ffffe00p-56, 0x1.000003fff8000p-1, 0x1.fffc000fc0000p-72, 0x1.fffbfffe00420p-24, -0x1.01ffe82000000p-79},
{-0x1.0000000000000p-1, -0x1.ffc001ffffe00p-56, -0x1.000003fff8000p-1, -0x1.fffc000fc0000p-72, -0x1.000001fffc000p+0, -0x1.ffc201fbfff00p-56},
{0x1.0000000000003p-1, 0x1.fc00001fff800p-65, 0x1.0000000000020p-1, -0x1.fc01ffe002000p-65, 0x1.0000000000011p+0, 0x1.ffffffc007ffcp-54},
{0x1.0000000000003p-1, 0x1.fc00001fff800p-65, -0x1.0000000000020p-1, 0x1.fc01ffe002000p-65, -0x1.cffc07fe00000p-49, 0x1.8000000000000p-105},
{-0x1.0000000000003p-1, -0x1.fc00001fff800p-65, 0x1.0000000000020p-1, -0x1.fc01ffe002000p-65, 0x1.cffc07fe00000p-49, -0x1.8000000000000p-105},
{-0x1.0000000000003p-1, -0x1.fc00001fff800p-65, -0x1.0000000000020p-1, 0x1.fc01ffe002000p-65, -0x1.0000000000011p+0, -0x1.ffffffc007ffcp-54},
{0x1.0000000000000p-1, 0x1.fffff00001ffep-55, 0x1.0000000000000p-1, 0x1.ff00000ffff80p-61, 0x1.0000000000000p+0, 0x1.03fdf80020ffep-54},
{0x1.0000000000000p-1, 0x1.fffff00001ffep-55, -0x1.0000000000000p-1, -0x1.ff00000ffff80p-61, 0x1.f803efffc2000p-55, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.fffff00001ffep-55, 0x1.0000000000000p-1, 0x1.ff00000ffff80p-61, -0x1.f803efffc2000p-55, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.fffff00001ffep-55, -0x1.0000000000000p-1, -0x1.ff00000ffff80p-61, -0x1.0000000000000p+0, -0x1.03fdf80020ffep-54},
{0x1.0000000000000p-1, 0x1.ffffffffffc00p-64, 0x1.0000200000000p-1, -0x1.ffc0000080000p-73, 0x1.0000100000000p+0, 0x1.ff001fffff800p-64},
{0x1.0000000000000p-1, 0x1.ffffffffffc00p-64, -0x1.0000200000000p-1, 0x1.ffc0000080000p-73, -0x1.ffffffffffbfep-21, -0x1.0000000000000p-83},
{-0x1.0000000000000p-1, -0x1.ffffffffffc00p-64, 0x1.0000200000000p-1, -0x1.ffc0000080000p-73, 0x1.ffffffffffbfep-21, 0x1.0000000000000p-83},
{-0x1.0000000000000p-1, -0x1.ffffffffffc00p-64, -0x1.0000200000000p-1, 0x1.ffc0000080000p-73, -0x1.0000100000000p+0, -0x1.ff001fffff800p-64},
{0x1.0000000000800p-1, -0x1.fffc000000010p-58, 0x1.0000000000008p-1, -0x1.ffe03fffff010p-58, 0x1.0000000000404p+0, -0x1.ffee1fffff810p-57},
{0x1.0000000000800p-1, -0x1.fffc000000010p-58, -0x1.0000000000008p-1, 0x1.ffe03fffff010p-58, 0x1.fdffffc880000p-43, -0x1.0000000000000p-98},
{-0x1.0000000000800p-1, 0x1.fffc000000010p-58, 0x1.0000000000008p-1, -0x1.ffe03fffff010p-58, -0x1.fdffffc880000p-43, 0x1.0000000000000p-98},
{-0x1.0000000000800p-1, 0x1.fffc000000010p-58, -0x1.0000000000008p-1, 0x1.ffe03fffff010p-58, -0x1.0000000000404p+0, 0x1.ffee1fffff810p-57},
{0x1.0000000000000p-1, 0x1.fffef0ffff000p-64, 0x1.0000100000000p-1, -0x1.fff8000000800p-65, 0x1.0000080000000p+0, 0x1.0002f0ffff000p-64},
{0x1.0000000000000p-1, 0x1.fffef0ffff000p-64, -0x1.0000100000000p-1, 0x1.fff8000000800p-65, -0x1.ffffffffff400p-22, -0x1.43c0003000000p-78},
{-0x1.0000000000000p-1, -0x1.fffef0ffff000p-64, 0x1.0000100000000p-1, -0x1.fff8000000800p-65, 0x1.ffffffffff400p-22, 0x1.43c0003000000p-78},
{-0x1.0000000000000p-1, -0x1.fffef0ffff000p-64, -0x1.0000100000000p-1, 0x1.fff8000000800p-65, -0x1.0000080000000p+0, -0x1.0002f0ffff000p-64},
{0x1.07c00007ffff0p-1, 0x1.fffc00f800000p-77, 0x1.0000007ffffe0p-1, 0x1.f000000000000p-72, 0x1.03e00043fffe8p+0, 0x1.ffffe00800000p-72},
{0x1.07c00007ffff0p-1, 0x1.fffc00f800000p-77, -0x1.0000007ffffe0p-1, -0x1.f000000000000p-72, 0x1.efffe20000400p-7, -0x1.e0001ff840000p-72},
{-0x1.07c00007ffff0p-1, -0x1.fffc00f800000p-77, 0x1.0000007ffffe0p-1, 0x1.f000000000000p-72, -0x1.efffe20000400p-7, 0x1.e0001ff840000p-72},
{-0x1.07c00007ffff0p-1, -0x1.fffc00f800000p-77, -0x1.0000007ffffe0p-1, -0x1.f000000000000p-72, -0x1.03e00043fffe8p+0, -0x1.ffffe00800000p-72},
{0x1.0000000000000p-1, 0x1.ff800fffff800p-57, 0x1.0000000000000p-1, 0x1.fffc0000ffff8p-57, 0x1.0000000000000p+0, 0x1.ffbe08007fc00p-56},
{0x1.0000000000000p-1, 0x1.ff800fffff800p-57, -0x1.0000000000000p-1, -0x1.fffc0000ffff8p-57, -0x1.efc00401fe000p-67, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.ff800fffff800p-57, 0x1.0000000000000p-1, 0x1.fffc0000ffff8p-57, 0x1.efc00401fe000p-67, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.ff800fffff800p-57, -0x1.0000000000000p-1, -0x1.fffc0000ffff8p-57, -0x1.0000000000000p+0, -0x1.ffbe08007fc00p-56},
{0x1.0000000008000p-1, -0x1.ffff807ffe002p-55, 0x1.0000000800000p-1, -0x1.ffffff8000008p-57, 0x1.0000000404000p+0, -0x1.3fffc02fff002p-54},
{0x1.0000000008000p-1, -0x1.ffff807ffe002p-55, -0x1.0000000800000p-1, 0x1.ffffff8000008p-57, -0x1.fe00017fff80ap-31, 0x1.0000000000000p-94},
{-0x1.0000000008000p-1, 0x1.ffff807ffe002p-55, 0x1.0000000800000p-1, -0x1.ffffff8000008p-57, 0x1.fe00017fff80ap-31, -0x1.0000000000000p-94},
{-0x1.0000000008000p-1, 0x1.ffff807ffe002p-55, -0x1.0000000800000p-1, 0x1.ffffff8000008p-57, -0x1.0000000404000p+0, 0x1.3fffc02fff002p-54},
{0x1.0000000000020p-1, -0x1.0000000000000p-84, 0x1.0000000000000p-1, 0x1.fffff000003c0p-60, 0x1.0000000000010p+0, 0x1.ffffef0000400p-60},
{0x1.0000000000020p-1, -0x1.0000000000000p-84, -0x1.0000000000000p-1, -0x1.fffff000003c0p-60, 0x1.ffc00001e0000p-49, -0x1.e000000000000p-103},
{-0x1.0000000000020p-1, 0x1.0000000000000p-84, 0x1.0000000000000p-1, 0x1.fffff000003c0p-60, -0x1.ffc00001e0000p-49, 0x1.e000000000000p-103},
{-0x1.0000000000020p-1, 0x1.0000000000000p-84, -0x1.0000000000000p-1, -0x1.fffff000003c0p-60, -0x1.0000000000010p+0, -0x1.ffffef0000400p-60},
{0x1.0000001ffff80p-1, 0x1.fffffdfffff8ep-55, 0x1.0000000200000p-1, -0x1.0000000000000p-70, 0x1.00000010fffc0p+0, 0x1.fffdfdfffff90p-55},
{0x1.0000001ffff80p-1, 0x1.fffffdfffff8ep-55, -0x1.0000000200000p-1, 0x1.0000000000000p-70, 0x1.dfff8080007f8p-29, -0x1.c800000000000p-101},
{-0x1.0000001ffff80p-1, -0x1.fffffdfffff8ep-55, 0x1.0000000200000p-1, -0x1.0000000000000p-70, -0x1.dfff8080007f8p-29, 0x1.c800000000000p-101},
{-0x1.0000001ffff80p-1, -0x1.fffffdfffff8ep-55, -0x1.0000000200000p-1, 0x1.0000000000000p-70, -0x1.00000010fffc0p+0, -0x1.fffdfdfffff90p-55},
{0x1.01ffffff80400p-1, -0x1.c7ffffc000100p-59, 0x1.0000000000000p-1, 0x1.8fff01fffff00p-61, 0x1.00ffffffc0200p+0, -0x1.64003f4000140p-59},
{0x1.01ffffff80400p-1, -0x1.c7ffffc000100p-59, -0x1.0000000000000p-1, -0x1.8fff01fffff00p-61, 0x1.ffffff803fff7p-9, 0x1.4003fbffff400p-63},
{-0x1.01ffffff80400p-1, 0x1.c7ffffc000100p-59, 0x1.0000000000000p-1, 0x1.8fff01fffff00p-61, -0x1.ffffff803fff7p-9, -0x1.4003fbffff400p-63},
{-0x1.01ffffff80400p-1, 0x1.c7ffffc000100p-59, -0x1.0000000000000p-1, -0x1.8fff01fffff00p-61, -0x1.00ffffffc0200p+0, 0x1.64003f4000140p-59},
{0x1.0000000000008p-1, -0x1.ffffc00800000p-74, 0x1.00003ffe00002p-1, -0x1.ffffffc180080p-61, 0x1.00001fff00005p+0, -0x1.0007ffdfc0200p-60},
{0x1.0000000000008p-1, -0x1.ffffc00800000p-74, -0x1.00003ffe00002p-1, 0x1.ffffffc180080p-61, -0x1.ffeffffcff001p-20, 0x1.fff86ff900000p-74},
{-0x1.0000000000008p-1, 0x1.ffffc00800000p-74, 0x1.00003ffe00002p-1, -0x1.ffffffc180080p-61, 0x1.ffeffffcff001p-20, -0x1.fff86ff900000p-74},
{-0x1.0000000000008p-1, 0x1.ffffc00800000p-74, -0x1.00003ffe00002p-1, 0x1.ffffffc180080p-61, -0x1.00001fff00005p+0, 0x1.0007ffdfc0200p-60},
{0x1.000000ffffff8p-1, 0x1.ffffffc000000p-58, 0x1.0000000000000p-1, 0x1.ffffffe000000p-59, 0x1.0000007fffffcp+0, 0x1.7fffffd800000p-57},
{0x1.000000ffffff8p-1, 0x1.ffffffc000000p-58, -0x1.0000000000000p-1, -0x1.ffffffe000000p-59, 0x1.ffffff0100000p-26, -0x1.8000000000000p-85},
{-0x1.000000ffffff8p-1, -0x1.ffffffc000000p-58, 0x1.0000000000000p-1, 0x1.ffffffe000000p-59, -0x1.ffffff0100000p-26, 0x1.8000000000000p-85},
{-0x1.000000ffffff8p-1, -0x1.ffffffc000000p-58, -0x1.0000000000000p-1, -0x1.ffffffe000000p-59, -0x1.0000007fffffcp+0, -0x1.7fffffd800000p-57},
{0x1.0000000020000p-1, -0x1.0000000000000p-106, 0x1.0000000000400p-1, -0x1.ff1ffffff4000p-68, 0x1.0000000010200p+0, -0x1.ff1ffffff8000p-68},
{0x1.0000000020000p-1, -0x1.0000000000000p-106, -0x1.0000000000400p-1, 0x1.ff1ffffff4000p-68, 0x1.fc000003fe400p-37, -0x1.0000000000000p-104},
{-0x1.0000000020000p-1, 0x1.0000000000000p-106, 0x1.0000000000400p-1, -0x1.ff1ffffff4000p-68, -0x1.fc000003fe400p-37, 0x1.0000000000000p-104},
{-0x1.0000000020000p-1, 0x1.0000000000000p-106, -0x1.0000000000400p-1, 0x1.ff1ffffff4000p-68, -0x1.0000000010200p+0, 0x1.ff1ffffff8000p-68},
{0x1.0000ff8020000p-1, -0x1.fffffa0000000p-63, 0x1.0000000001ff0p-1, 0x1.f700000ffe000p-67, 0x1.00007fc010ff8p+0, -0x1.e08ff9ff00000p-63},
{0x1.0000ff8020000p-1, -0x1.fffffa0000000p-63, -0x1.0000000001ff0p-1, -0x1.f700000ffe000p-67, 0x1.ff003c01ffef0p-18, 0x1.200bfe0040000p-72},
{-0x1.0000ff8020000p-1, 0x1.fffffa0000000p-63, 0x1.0000000001ff0p-1, 0x1.f700000ffe000p-67, -0x1.ff003c01ffef0p-18, -0x1.200bfe0040000p-72},
{-0x1.0000ff8020000p-1, 0x1.fffffa0000000p-63, -0x1.0000000001ff0p-1, -0x1.f700000ffe000p-67, -0x1.00007fc010ff8p+0, 0x1.e08ff9ff00000p-63},
{0x1.0000020000000p-1, -0x1.0000000000000p-65, 0x1.003e00001f800p-1, 0x1.ffde000001e00p-63, 0x1.001f01000fc00p+0, 0x1.bfde000002000p-63},
{0x1.0000020000000p-1, -0x1.0000000000000p-65, -0x1.003e00001f800p-1, -0x1.ffde000001e00p-63, -0x1.eff000fc00004p-12, -0x1.fef000000f000p-66},
{-0x1.0000020000000p-1, 0x1.0000000000000p-65, 0x1.003e00001f800p-1, 0x1.ffde000001e00p-63, 0x1.eff000fc00004p-12, 0x1.fef000000f000p-66},
{-0x1.0000020000000p-1, 0x1.0000000000000p-65, -0x1.003e00001f800p-1, -0x1.ffde000001e00p-63, -0x1.001f01000fc00p+0, -0x1.bfde000002000p-63},
{0x1.0007e3ffe0000p-1, 0x1.fe0ffffffe000p-65, 0x1.0000000000000p-1, 0x1.fffffe07fff00p-62, 0x1.0003f1fff0000p+0, 0x1.1fe0ff03ffe00p-61},
{0x1.0007e3ffe0000p-1, 0x1.fe0ffffffe000p-65, -0x1.0000000000000p-1, -0x1.fffffe07fff00p-62, 0x1.f8fff7fffffc8p-15, -0x1.eff0400180000p-73},
{-0x1.0007e3ffe0000p-1, -0x1.fe0ffffffe000p-65, 0x1.0000000000000p-1, 0x1.fffffe07fff00p-62, -0x1.f8fff7fffffc8p-15, 0x1.eff0400180000p-73},
{-0x1.0007e3ffe0000p-1, -0x1.fe0ffffffe000p-65, -0x1.0000000000000p-1, -0x1.fffffe07fff00p-62, -0x1.0003f1fff0000p+0, -0x1.1fe0ff03ffe00p-61},
{0x1.00000000fe000p-1, 0x1.ff00004000000p-68, 0x1.000003fffff80p-1, 0x1.fff8400000000p-61, 0x1.000002007efc0p+0, 0x1.01fb200040000p-60},
{0x1.00000000fe000p-1, 0x1.ff00004000000p-68, -0x1.000003fffff80p-1, -0x1.fff8400000000p-61, -0x1.ff80fc000fdfdp-24, -0x1.fffc000000000p-80},
{-0x1.00000000fe000p-1, -0x1.ff00004000000p-68, 0x1.000003fffff80p-1, 0x1.fff8400000000p-61, 0x1.ff80fc000fdfdp-24, 0x1.fffc000000000p-80},
{-0x1.00000000fe000p-1, -0x1.ff00004000000p-68, -0x1.000003fffff80p-1, -0x1.fff8400000000p-61, -0x1.000002007efc0p+0, -0x1.01fb200040000p-60},
{0x1.0000800000000p-1, -0x1.0000000000000p-57, 0x1.0000000000000p-1, 0x1.fffffffc1fc00p-64, 0x1.0000400000000p+0, -0x1.f80000000f800p-58},
{0x1.0000800000000p-1, -0x1.0000000000000p-57, -0x1.0000000000000p-1, -0x1.fffffffc1fc00p-64, 0x1.fffffffffbf00p-19, 0x1.f020000000000p-95},
{-0x1.0000800000000p-1, 0x1.0000000000000p-57, 0x1.0000000000000p-1, 0x1.fffffffc1fc00p-64, -0x1.fffffffffbf00p-19, -0x1.f020000000000p-95},
{-0x1.0000800000000p-1, 0x1.0000000000000p-57, -0x1.0000000000000p-1, -0x1.fffffffc1fc00p-64, -0x1.0000400000000p+0, 0x1.f80000000f800p-58},
{0x1.0000000000000p-1, 0x1.ff000ff3ffe00p-55, 0x1.0000000000000p-1, 0x1.fe0003fffc000p-60, 0x1.0000000000000p+0, 0x1.07780809ffe00p-54},
{0x1.0000000000000p-1, 0x1.ff000ff3ffe00p-55, -0x1.0000000000000p-1, -0x1.fe0003fffc000p-60, 0x1.ef100fd400000p-55, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.ff000ff3ffe00p-55, 0x1.0000000000000p-1, 0x1.fe0003fffc000p-60, -0x1.ef100fd400000p-55, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.ff000ff3ffe00p-55, -0x1.0000000000000p-1, -0x1.fe0003fffc000p-60, -0x1.0000000000000p+0, -0x1.07780809ffe00p-54},
{0x1.000000e000010p-1, -0x1.ffffffc020000p-71, 0x1.00000001f0000p-1, 0x1.8000000000000p-105, 0x1.00000070f8008p+0, -0x1.ffffffbfc0000p-71},
{0x1.000000e000010p-1, -0x1.ffffffc020000p-71, -0x1.00000001f0000p-1, -0x1.8000000000000p-105, 0x1.bc2001fffff00p-26, 0x1.fc00000000000p-98},
{-0x1.000000e000010p-1, 0x1.ffffffc020000p-71, 0x1.00000001f0000p-1, 0x1.8000000000000p-105, -0x1.bc2001fffff00p-26, -0x1.fc00000000000p-98},
{-0x1.000000e000010p-1, 0x1.ffffffc020000p-71, -0x1.00000001f0000p-1, -0x1.8000000000000p-105, -0x1.00000070f8008p+0, 0x1.ffffffbfc0000p-71},
{0x1.000003ff00000p-1, 0x1.8000000000000p-78, 0x1.0001ffffe0000p-1, 0x1.f800000100000p-74, 0x1.000101ff70000p+0, 0x1.0800000000000p-73},
{0x1.000003ff00000p-1, 0x1.8000000000000p-78, -0x1.0001ffffe0000p-1, -0x1.f800000100000p-74, -0x1.fc00e00000000p-17, -0x1.e000000100000p-74},
{-0x1.000003ff00000p-1, -0x1.8000000000000p-78, 0x1.0001ffffe0000p-1, 0x1.f800000100000p-74, 0x1.fc00e00000000p-17, 0x1.e000000100000p-74},
{-0x1.000003ff00000p-1, -0x1.8000000000000p-78, -0x1.0001ffffe0000p-1, -0x1.f800000100000p-74, -0x1.000101ff70000p+0, -0x1.0800000000000p-73},
{0x1.0000000000200p-1, -0x1.ffffffffffc08p-57, 0x1.0000000000000p-1, 0x1.ffffffffffffep-55, 0x1.0000000000100p+0, 0x1.80000000000fcp-55},
{0x1.0000000000200p-1, -0x1.ffffffffffc08p-57, -0x1.0000000000000p-1, -0x1.ffffffffffffep-55, 0x1.ff60000000000p-45, 0x1.0000000000000p-99},
{-0x1.0000000000200p-1, 0x1.ffffffffffc08p-57, 0x1.0000000000000p-1, 0x1.ffffffffffffep-55, -0x1.ff60000000000p-45, -0x1.0000000000000p-99},
{-0x1.0000000000200p-1, 0x1.ffffffffffc08p-57, -0x1.0000000000000p-1, -0x1.ffffffffffffep-55, -0x1.0000000000100p+0, -0x1.80000000000fcp-55},
{0x1.0000000040000p-1, -0x1.fffff80002000p-67, 0x1.0000000000000p-1, 0x1.ffc01ffff3c00p-64, 0x1.0000000020000p+0, 0x1.bfc020fff3800p-64},
{0x1.0000000040000p-1, -0x1.fffff80002000p-67, -0x1.0000000000000p-1, -0x1.ffc01ffff3c00p-64, 0x1.ffffffdc03fe1p-36, 0x1.8000000000000p-101},
{-0x1.0000000040000p-1, 0x1.fffff80002000p-67, 0x1.0000000000000p-1, 0x1.ffc01ffff3c00p-64, -0x1.ffffffdc03fe1p-36, -0x1.8000000000000p-101},
{-0x1.0000000040000p-1, 0x1.fffff80002000p-67, -0x1.0000000000000p-1, -0x1.ffc01ffff3c00p-64, -0x1.0000000020000p+0, -0x1.bfc020fff3800p-64},
{0x1.0000800000000p-1, -0x1.0000000000000p-106, 0x1.0000003800001p-1, 0x1.fffffe000003ep-55, 0x1.0000401c00001p+0, -0x1.000000fffffe2p-54},
{0x1.0000800000000p-1, -0x1.0000000000000p-106, -0x1.0000003800001p-1, -0x1.fffffe000003ep-55, 0x1.ff1fffffa0000p-19, 0x1.fffffc0000000p-79},
{-0x1.0000800000000p-1, 0x1.0000000000000p-106, 0x1.0000003800001p-1, 0x1.fffffe000003ep-55, -0x1.ff1fffffa0000p-19, -0x1.fffffc0000000p-79},
{-0x1.0000800000000p-1, 0x1.0000000000000p-106, -0x1.0000003800001p-1, -0x1.fffffe000003ep-55, -0x1.0000401c00001p+0, 0x1.000000fffffe2p-54},
{0x1.0f00000020000p-1, -0x1.fffe000000100p-55, 0x1.0000000400000p-1, -0x1.ffffffc004000p-68, 0x1.0780000210000p+0, -0x1.0006ffffff080p-54},
{0x1.0f00000020000p-1, -0x1.fffe000000100p-55, -0x1.0000000400000p-1, 0x1.ffffffc004000p-68, 0x1.dfffff83ffff0p-6, 0x1.1fffffdf02000p-67},
{-0x1.0f00000020000p-1, 0x1.fffe000000100p-55, 0x1.0000000400000p-1, -0x1.ffffffc004000p-68, -0x1.dfffff83ffff0p-6, -0x1.1fffffdf02000p-67},
{-0x1.0f00000020000p-1, 0x1.fffe000000100p-55, -0x1.0000000400000p-1, 0x1.ffffffc004000p-68, -0x1.0780000210000p+0, 0x1.0006ffffff080p-54},
{0x1.003fe00020000p-1, -0x1.ffffffffe8000p-69, 0x1.0000000000400p-1, -0x1.ffff800007ffcp-56, 0x1.001ff00010200p+0, -0x1.0007c00003ff8p-55},
{0x1.003fe00020000p-1, -0x1.ffffffffe8000p-69, -0x1.0000000000400p-1, 0x1.ffff800007ffcp-56, 0x1.ff0000fe00200p-12, -0x1.07ffff7ff8000p-68},
{-0x1.003fe00020000p-1, 0x1.ffffffffe8000p-69, 0x1.0000000000400p-1, -0x1.ffff800007ffcp-56, -0x1.ff0000fe00200p-12, 0x1.07ffff7ff8000p-68},
{-0x1.003fe00020000p-1, 0x1.ffffffffe8000p-69, -0x1.0000000000400p-1, 0x1.ffff800007ffcp-56, -0x1.001ff00010200p+0, 0x1.0007c00003ff8p-55},
{0x1.ffff00fffffc4p-1, -0x1.8080000000000p-83, 0x1.0000020000000p-1, -0x1.0000000000000p-77, 0x1.7fff817ffffe2p+0, -0x1.0602000000000p-77},
{0x1.ffff00fffffc4p-1, -0x1.8080000000000p-83, -0x1.0000020000000p-1, 0x1.0000000000000p-77, 0x1.fffdfdfffff88p-2, 0x1.f3fc000000000p-78},
{-0x1.ffff00fffffc4p-1, 0x1.8080000000000p-83, 0x1.0000020000000p-1, -0x1.0000000000000p-77, -0x1.fffdfdfffff88p-2, -0x1.f3fc000000000p-78},
{-0x1.ffff00fffffc4p-1, 0x1.8080000000000p-83, -0x1.0000020000000p-1, 0x1.0000000000000p-77, -0x1.7fff817ffffe2p+0, 0x1.0602000000000p-77},
{0x1.0000000000040p-1, -0x1.8000000800000p-76, 0x1.0000000002000p-1, -0x1.0000000000000p-105, 0x1.0000000001020p+0, -0x1.8000001000000p-76},
{0x1.0000000000040p-1, -0x1.8000000800000p-76, -0x1.0000000002000p-1, 0x1.0000000000000p-105, -0x1.fc00000030000p-41, 0x0.0000000000000p+0},
{-0x1.0000000000040p-1, 0x1.8000000800000p-76, 0x1.0000000002000p-1, -0x1.0000000000000p-105, 0x1.fc00000030000p-41, 0x0.0000000000000p+0},
{-0x1.0000000000040p-1, 0x1.8000000800000p-76, -0x1.0000000002000p-1, 0x1.0000000000000p-105, -0x1.0000000001020p+0, 0x1.8000001000000p-76},
{0x1.0000000800000p-1, -0x1.ffffc02000000p-79, 0x1.7fffe00800000p-1, -0x1.0000000000000p-106, 0x1.3ffff00800000p+0, -0x1.ffffc04000000p-79},
{0x1.0000000800000p-1, -0x1.ffffc02000000p-79, -0x1.7fffe00800000p-1, 0x1.0000000000000p-106, -0x1.ffff800000000p-3, -0x1.ffffc00000000p-79},
{-0x1.0000000800000p-1, 0x1.ffffc02000000p-79, 0x1.7fffe00800000p-1, -0x1.0000000000000p-106, 0x1.ffff800000000p-3, 0x1.ffffc00000000p-79},
{-0x1.0000000800000p-1, 0x1.ffffc02000000p-79, -0x1.7fffe00800000p-1, 0x1.0000000000000p-106, -0x1.3ffff00800000p+0, 0x1.ffffc04000000p-79},
{0x1.0000400000000p-1, -0x1.0000000000000p-92, 0x1.4000000000000p-1, -0x1.ffffffff00020p-59, 0x1.2000200000000p+0, -0x1.ffffffff80000p-59},
{0x1.0000400000000p-1, -0x1.0000000000000p-92, -0x1.4000000000000p-1, 0x1.ffffffff00020p-59, -0x1.fffe000000000p-4, 0x1.fffffffe80020p-59},
{-0x1.0000400000000p-1, 0x1.0000000000000p-92, 0x1.4000000000000p-1, -0x1.ffffffff00020p-59, 0x1.fffe000000000p-4, -0x1.fffffffe80020p-59},
{-0x1.0000400000000p-1, 0x1.0000000000000p-92, -0x1.4000000000000p-1, 0x1.ffffffff00020p-59, -0x1.2000200000000p+0, 0x1.ffffffff80000p-59},
{0x1.0000000000000p-1, 0x1.03eff7ff3fff0p-58, 0x1.00001fffc0000p-1, 0x1.f80001f000f80p-61, 0x1.00000fffe0000p+0, 0x1.42eff83d401e0p-58},
{0x1.0000000000000p-1, 0x1.03eff7ff3fff0p-58, -0x1.00001fffc0000p-1, -0x1.f80001f000f80p-61, -0x1.fffbfffff9d88p-21, -0x1.07d8040000000p-79},
{-0x1.0000000000000p-1, -0x1.03eff7ff3fff0p-58, 0x1.00001fffc0000p-1, 0x1.f80001f000f80p-61, 0x1.fffbfffff9d88p-21, 0x1.07d8040000000p-79},
{-0x1.0000000000000p-1, -0x1.03eff7ff3fff0p-58, -0x1.00001fffc0000p-1, -0x1.f80001f000f80p-61, -0x1.00000fffe0000p+0, -0x1.42eff83d401e0p-58},
{0x1.03ffffffffffep-1, 0x1.8000000000000p-105, 0x1.0000040000000p-1, -0x1.0000000000000p-106, 0x1.020001fffffffp+0, 0x1.0000000000000p-105},
{0x1.03ffffffffffep-1, 0x1.8000000000000p-105, -0x1.0000040000000p-1, 0x1.0000000000000p-106, 0x1.fffdfffffff00p-8, 0x1.0000000000000p-104},
{-0x1.03ffffffffffep-1, -0x1.8000000000000p-105, 0x1.0000040000000p-1, -0x1.0000000000000p-106, -0x1.fffdfffffff00p-8, -0x1.0000000000000p-104},
{-0x1.03ffffffffffep-1, -0x1.8000000000000p-105, -0x1.0000040000000p-1, 0x1.0000000000000p-106, -0x1.020001fffffffp+0, -0x1.0000000000000p-105},
{0x1.0007ffffcfffcp-1, 0x1.ff01fffe00000p-75, 0x1.01fff08000000p-1, -0x1.fffffe0000020p-55, 0x1.0103f83fe7ffep+0, -0x1.ffffde0fe0020p-55},
{0x1.0007ffffcfffcp-1, 0x1.ff01fffe00000p-75, -0x1.01fff08000000p-1, 0x1.fffffe0000020p-55, -0x1.f7f0803000380p-9, 0x1.df02001e00000p-75},
{-0x1.0007ffffcfffcp-1, -0x1.ff01fffe00000p-75, 0x1.01fff08000000p-1, -0x1.fffffe0000020p-55, 0x1.f7f0803000380p-9, -0x1.df02001e00000p-75},
{-0x1.0007ffffcfffcp-1, -0x1.ff01fffe00000p-75, -0x1.01fff08000000p-1, 0x1.fffffe0000020p-55, -0x1.0103f83fe7ffep+0, 0x1.ffffde0fe0020p-55},
{0x1.00000000007fep-1, 0x1.ff00003ffff00p-62, 0x1.004000e000008p-1, -0x1.ffffe02000000p-79, 0x1.0020007000403p+0, 0x1.feff00400fe00p-62},
{0x1.00000000007fep-1, 0x1.ff00003ffff00p-62, -0x1.004000e000008p-1, 0x1.ffffe02000000p-79, -0x1.00037ffe027fcp-11, -0x1.fdff802000000p-71},
{-0x1.00000000007fep-1, -0x1.ff00003ffff00p-62, 0x1.004000e000008p-1, -0x1.ffffe02000000p-79, 0x1.00037ffe027fcp-11, 0x1.fdff802000000p-71},
{-0x1.00000000007fep-1, -0x1.ff00003ffff00p-62, -0x1.004000e000008p-1, 0x1.ffffe02000000p-79, -0x1.0020007000403p+0, -0x1.feff00400fe00p-62},
{0x1.00000003ff000p-1, 0x1.ffff000000000p-90, 0x1.0000fffff8000p-1, 0x1.f003ffe0003e0p-59, 0x1.00008001fb800p+0, 0x1.f003ffe4003c0p-59},
{0x1.00000003ff000p-1, 0x1.ffff000000000p-90, -0x1.0000fffff8000p-1, -0x1.f003ffe0003e0p-59, -0x1.fff7f20000f80p-18, -0x1.ffee002000000p-74},
{-0x1.00000003ff000p-1, -0x1.ffff000000000p-90, 0x1.0000fffff8000p-1, 0x1.f003ffe0003e0p-59, 0x1.fff7f20000f80p-18, 0x1.ffee002000000p-74},
{-0x1.00000003ff000p-1, -0x1.ffff000000000p-90, -0x1.0000fffff8000p-1, -0x1.f003ffe0003e0p-59, -0x1.00008001fb800p+0, -0x1.f003ffe4003c0p-59},
{0x1.0000000000000p-1, 0x1.ffe001c0003c0p-60, 0x1.01fffffe00000p-1, 0x1.ffffffffffc00p-59, 0x1.00ffffff00000p+0, 0x1.7ff8006ffff00p-58},
{0x1.0000000000000p-1, 0x1.ffe001c0003c0p-60, -0x1.01fffffe00000p-1, -0x1.ffffffffffc00p-59, -0x1.fffffe0000004p-9, -0x1.ffe3fff440000p-72},
{-0x1.0000000000000p-1, -0x1.ffe001c0003c0p-60, 0x1.01fffffe00000p-1, 0x1.ffffffffffc00p-59, 0x1.fffffe0000004p-9, 0x1.ffe3fff440000p-72},
{-0x1.0000000000000p-1, -0x1.ffe001c0003c0p-60, -0x1.01fffffe00000p-1, -0x1.ffffffffffc00p-59, -0x1.00ffffff00000p+0, -0x1.7ff8006ffff00p-58},
{0x1.00003ff808000p-1, -0x1.ffe0000800000p-62, 0x1.000001ffff000p-1, 0x1.ff80000000000p-75, 0x1.000020fc03800p+0, -0x1.ffd0040800000p-62},
{0x1.00003ff808000p-1, -0x1.ffe0000800000p-62, -0x1.000001ffff000p-1, -0x1.ff80000000000p-75, 0x1.efc047ffff800p-20, 0x1.003f800000000p-74},
{-0x1.00003ff808000p-1, 0x1.ffe0000800000p-62, 0x1.000001ffff000p-1, 0x1.ff80000000000p-75, -0x1.efc047ffff800p-20, -0x1.003f800000000p-74},
{-0x1.00003ff808000p-1, 0x1.ffe0000800000p-62, -0x1.000001ffff000p-1, -0x1.ff80000000000p-75, -0x1.000020fc03800p+0, 0x1.ffd0040800000p-62},
{0x1.0000000000000p-1, 0x1.fc007f0ff0000p-63, 0x1.0000000007f80p-1, 0x1.ff0007f802000p-65, 0x1.0000000003fc0p+0, 0x1.3de04086f8400p-62},
{0x1.0000000000000p-1, 0x1.fc007f0ff0000p-63, -0x1.0000000007f80p-1, -0x1.ff0007f802000p-65, -0x1.fdfffe83bf82fp-39, 0x1.ef80000000000p-95},
{-0x1.0000000000000p-1, -0x1.fc007f0ff0000p-63, 0x1.0000000007f80p-1, 0x1.ff0007f802000p-65, 0x1.fdfffe83bf82fp-39, -0x1.ef80000000000p-95},
{-0x1.0000000000000p-1, -0x1.fc007f0ff0000p-63, -0x1.0000000007f80p-1, -0x1.ff0007f802000p-65, -0x1.0000000003fc0p+0, -0x1.3de04086f8400p-62},
{0x1.0020000000000p-1, -0x1.0000000000000p-78, 0x1.000001ffff802p-1, -0x1.ffffffc000040p-60, 0x1.001000ffffc01p+0, -0x1.00001fe000000p-59},
{0x1.0020000000000p-1, -0x1.0000000000000p-78, -0x1.000001ffff802p-1, 0x1.ffffffc000040p-60, 0x1.ffe00007fe040p-13, -0x1.00fffff000000p-78},
{-0x1.0020000000000p-1, 0x1.0000000000000p-78, 0x1.000001ffff802p-1, -0x1.ffffffc000040p-60, -0x1.ffe00007fe040p-13, 0x1.00fffff000000p-78},
{-0x1.0020000000000p-1, 0x1.0000000000000p-78, -0x1.000001ffff802p-1, 0x1.ffffffc000040p-60, -0x1.001000ffffc01p+0, 0x1.00001fe000000p-59},
{0x1.0000000000800p-1, -0x1.ffe0000400000p-63, 0x1.0000000000038p-1, 0x1.e100000000000p-75, 0x1.000000000041cp+0, -0x1.ffc1f00400000p-63},
{0x1.0000000000800p-1, -0x1.ffe0000400000p-63, -0x1.0000000000038p-1, -0x1.e100000000000p-75, 0x1.f1ffe0001effcp-43, 0x0.0000000000000p+0},
{-0x1.0000000000800p-1, 0x1.ffe0000400000p-63, 0x1.0000000000038p-1, 0x1.e100000000000p-75, -0x1.f1ffe0001effcp-43, 0x0.0000000000000p+0},
{-0x1.0000000000800p-1, 0x1.ffe0000400000p-63, -0x1.0000000000038p-1, -0x1.e100000000000p-75, -0x1.000000000041cp+0, 0x1.ffc1f00400000p-63},
{0x1.0000000000020p-1, -0x1.8007ffff80c04p-56, 0x1.0000000000000p-1, 0x1.ffffe00000c00p-64, 0x1.0000000000010p+0, -0x1.7e08001f80bf8p-56},
{0x1.0000000000020p-1, -0x1.8007ffff80c04p-56, -0x1.0000000000000p-1, -0x1.ffffe00000c00p-64, 0x1.fcfbf00040fe8p-49, -0x1.0000000000000p-104},
{-0x1.0000000000020p-1, 0x1.8007ffff80c04p-56, 0x1.0000000000000p-1, 0x1.ffffe00000c00p-64, -0x1.fcfbf00040fe8p-49, 0x1.0000000000000p-104},
{-0x1.0000000000020p-1, 0x1.8007ffff80c04p-56, -0x1.0000000000000p-1, -0x1.ffffe00000c00p-64, -0x1.0000000000010p+0, 0x1.7e08001f80bf8p-56},
{0x1.7fffffff80000p-1, 0x1.f000000000000p-78, 0x1.000007ffffffep-1, 0x1.ffffff8000000p-77, 0x1.400003ffbffffp+0, 0x1.7bffffc000000p-76},
{0x1.7fffffff80000p-1, 0x1.f000000000000p-78, -0x1.000007ffffffep-1, -0x1.ffffff8000000p-77, 0x1.ffffdffe00008p-3, -0x1.07ffff8000000p-77},
{-0x1.7fffffff80000p-1, -0x1.f000000000000p-78, 0x1.000007ffffffep-1, 0x1.ffffff8000000p-77, -0x1.ffffdffe00008p-3, 0x1.07ffff8000000p-77},
{-0x1.7fffffff80000p-1, -0x1.f000000000000p-78, -0x1.000007ffffffep-1, -0x1.ffffff8000000p-77, -0x1.400003ffbffffp+0, -0x1.7bffffc000000p-76},
{0x1.0000000010000p-1, -0x1.0000000000000p-87, 0x1.0000000000000p-1, 0x1.c000003ffc3fep-55, 0x1.0000000008000p+0, 0x1.c000003efc400p-55},
{0x1.0000000010000p-1, -0x1.0000000000000p-87, -0x1.0000000000000p-1, -0x1.c000003ffc3fep-55, 0x1.ffff1fffffdf8p-38, 0x1.e010000000000p-94},
{-0x1.0000000010000p-1, 0x1.0000000000000p-87, 0x1.0000000000000p-1, 0x1.c000003ffc3fep-55, -0x1.ffff1fffffdf8p-38, -0x1.e010000000000p-94},
{-0x1.0000000010000p-1, 0x1.0000000000000p-87, -0x1.0000000000000p-1, -0x1.c000003ffc3fep-55, -0x1.0000000008000p+0, -0x1.c000003efc400p-55},
{0x1.00000ffff0800p-1, -0x1.fff80000ffc20p-59, 0x1.0000000000002p-1, -0x1.0000000000000p-106, 0x1.000007fff8401p+0, -0x1.fff80000ffc40p-59},
{0x1.00000ffff0800p-1, -0x1.fff80000ffc20p-59, -0x1.0000000000002p-1, 0x1.0000000000000p-106, 0x1.fffe0ffbf0004p-22, -0x1.ff80000000000p-92},
{-0x1.00000ffff0800p-1, 0x1.fff80000ffc20p-59, 0x1.0000000000002p-1, -0x1.0000000000000p-106, -0x1.fffe0ffbf0004p-22, 0x1.ff80000000000p-92},
{-0x1.00000ffff0800p-1, 0x1.fff80000ffc20p-59, -0x1.0000000000002p-1, 0x1.0000000000000p-106, -0x1.000007fff8401p+0, 0x1.fff80000ffc40p-59},
{0x1.000ffffc00000p-1, 0x1.fffff00000000p-70, 0x1.0000000000040p-1, -0x1.0000000000000p-106, 0x1.0007fffe00020p+0, 0x1.fffff00000000p-70},
{0x1.000ffffc00000p-1, 0x1.fffff00000000p-70, -0x1.0000000000040p-1, 0x1.0000000000000p-106, 0x1.ffff7fff80000p-14, 0x1.fffff00010000p-70},
{-0x1.000ffffc00000p-1, -0x1.fffff00000000p-70, 0x1.0000000000040p-1, -0x1.0000000000000p-106, -0x1.ffff7fff80000p-14, -0x1.fffff00010000p-70},
{-0x1.000ffffc00000p-1, -0x1.fffff00000000p-70, -0x1.0000000000040p-1, 0x1.0000000000000p-106, -0x1.0007fffe00020p+0, -0x1.fffff00000000p-70},
{0x1.0004000000000p-1, -0x1.0000000000000p-69, 0x1.0000000200000p-1, -0x1.ffbffffff8020p-59, 0x1.0002000100000p+0, -0x1.fffffffff8000p-59},
{0x1.0004000000000p-1, -0x1.0000000000000p-69, -0x1.0000000200000p-1, 0x1.ffbffffff8020p-59, 0x1.ffff0000003ffp-16, -0x1.ff80000000000p-97},
{-0x1.0004000000000p-1, 0x1.0000000000000p-69, 0x1.0000000200000p-1, -0x1.ffbffffff8020p-59, -0x1.ffff0000003ffp-16, 0x1.ff80000000000p-97},
{-0x1.0004000000000p-1, 0x1.0000000000000p-69, -0x1.0000000200000p-1, 0x1.ffbffffff8020p-59, -0x1.0002000100000p+0, 0x1.fffffffff8000p-59},
{0x1.0000000000000p-1, 0x1.e0001e7fbff00p-62, 0x1.0000001fffffep-1, 0x0.0000000000000p+0, 0x1.0000000ffffffp+0, 0x1.e0001e7fc0000p-62},
{0x1.0000000000000p-1, 0x1.e0001e7fbff00p-62, -0x1.0000001fffffep-1, 0x0.0000000000000p+0, -0x1.fffffdff0ffffp-29, -0x1.8040100000000p-86},
{-0x1.0000000000000p-1, -0x1.e0001e7fbff00p-62, 0x1.0000001fffffep-1, 0x0.0000000000000p+0, 0x1.fffffdff0ffffp-29, 0x1.8040100000000p-86},
{-0x1.0000000000000p-1, -0x1.e0001e7fbff00p-62, -0x1.0000001fffffep-1, 0x0.0000000000000p+0, -0x1.0000000ffffffp+0, -0x1.e0001e7fc0000p-62},
{0x1.0000000000fffp-1, 0x1.fffff3e000000p-74, 0x1.001ffe0000000p-1, 0x1.fffffffffffc0p-60, 0x1.000fff0000800p+0, -0x1.f7ffe00000c20p-54},
{0x1.0000000000fffp-1, 0x1.fffff3e000000p-74, -0x1.001ffe0000000p-1, -0x1.fffffffffffc0p-60, -0x1.ffdffff001040p-13, 0x1.fffff3e100000p-74},
{-0x1.0000000000fffp-1, -0x1.fffff3e000000p-74, 0x1.001ffe0000000p-1, 0x1.fffffffffffc0p-60, 0x1.ffdffff001040p-13, -0x1.fffff3e100000p-74},
{-0x1.0000000000fffp-1, -0x1.fffff3e000000p-74, -0x1.001ffe0000000p-1, -0x1.fffffffffffc0p-60, -0x1.000fff0000800p+0, 0x1.f7ffe00000c20p-54},
{0x1.0000080000000p-1, -0x1.0000000000000p-106, 0x1.0000000080000p-1, -0x1.0000000000000p-56, 0x1.0000040040000p+0, -0x1.0000000000000p-56},
{0x1.0000080000000p-1, -0x1.0000000000000p-106, -0x1.0000000080000p-1, 0x1.0000000000000p-56, 0x1.ffe0000080000p-23, -0x1.0000000000000p-106},
{-0x1.0000080000000p-1, 0x1.0000000000000p-106, 0x1.0000000080000p-1, -0x1.0000000000000p-56, -0x1.ffe0000080000p-23, 0x1.0000000000000p-106},
{-0x1.0000080000000p-1, 0x1.0000000000000p-106, -0x1.0000000080000p-1, 0x1.0000000000000p-56, -0x1.0000040040000p+0, 0x1.0000000000000p-56},
{0x1.003ffffffffe0p-1, 0x1.ffffe03800000p-77, 0x1.0000000002000p-1, -0x1.0000000000000p-54, 0x1.0020000000ff0p+0, -0x1.fffff800007f0p-55},
{0x1.003ffffffffe0p-1, 0x1.ffffe03800000p-77, -0x1.0000000002000p-1, 0x1.0000000000000p-54, 0x1.ffffffeff0400p-12, 0x1.ffffe03800000p-77},
{-0x1.003ffffffffe0p-1, -0x1.ffffe03800000p-77, 0x1.0000000002000p-1, -0x1.0000000000000p-54, -0x1.ffffffeff0400p-12, -0x1.ffffe03800000p-77},
{-0x1.003ffffffffe0p-1, -0x1.ffffe03800000p-77, -0x1.0000000002000p-1, 0x1.0000000000000p-54, -0x1.0020000000ff0p+0, 0x1.fffff800007f0p-55},
{0x1.0000000000008p-1, -0x1.ff000007ffc00p-61, 0x1.0000000060000p-1, 0x1.ffffff8000000p-81, 0x1.0000000030004p+0, -0x1.feffe007ffc00p-61},
{0x1.0000000000008p-1, -0x1.ff000007ffc00p-61, -0x1.0000000060000p-1, -0x1.ffffff8000000p-81, -0x1.7ffe007fc0080p-35, -0x1.ffee000000000p-91},
{-0x1.0000000000008p-1, 0x1.ff000007ffc00p-61, 0x1.0000000060000p-1, 0x1.ffffff8000000p-81, 0x1.7ffe007fc0080p-35, 0x1.ffee000000000p-91},
{-0x1.0000000000008p-1, 0x1.ff000007ffc00p-61, -0x1.0000000060000p-1, -0x1.ffffff8000000p-81, -0x1.0000000030004p+0, 0x1.feffe007ffc00p-61},
{0x1.0000000000080p-1, -0x1.0000000000000p-106, 0x1.01ffffff80001p-1, -0x1.ff90000000000p-94, 0x1.00ffffffc0040p+0, 0x1.fffffffffe006p-54},
{0x1.0000000000080p-1, -0x1.0000000000000p-106, -0x1.01ffffff80001p-1, 0x1.ff90000000000p-94, -0x1.ffffff7ff8100p-9, 0x1.ff80000000000p-94},
{-0x1.0000000000080p-1, 0x1.0000000000000p-106, 0x1.01ffffff80001p-1, -0x1.ff90000000000p-94, 0x1.ffffff7ff8100p-9, -0x1.ff80000000000p-94},
{-0x1.0000000000080p-1, 0x1.0000000000000p-106, -0x1.01ffffff80001p-1, 0x1.ff90000000000p-94, -0x1.00ffffffc0040p+0, -0x1.fffffffffe006p-54},
{0x1.0000000000800p-1, -0x1.fffff80002000p-67, 0x1.0008000000000p-1, -0x1.0000000000000p-80, 0x1.0004000000400p+0, -0x1.0003fc0000000p-66},
{0x1.0000000000800p-1, -0x1.fffff80002000p-67, -0x1.0008000000000p-1, 0x1.0000000000000p-80, -0x1.ffffffe000002p-15, 0x1.00ffffc000000p-80},
{-0x1.0000000000800p-1, 0x1.fffff80002000p-67, 0x1.0008000000000p-1, -0x1.0000000000000p-80, 0x1.ffffffe000002p-15, -0x1.00ffffc000000p-80},
{-0x1.0000000000800p-1, 0x1.fffff80002000p-67, -0x1.0008000000000p-1, 0x1.0000000000000p-80, -0x1.0004000000400p+0, 0x1.0003fc0000000p-66},
{0x1.0000000000002p-1, -0x1.ffffffe200000p-75, 0x1.0003fffffffc0p-1, 0x1.ffffe00000400p-64, 0x1.0001fffffffe1p+0, 0x1.ffbfe00004000p-64},
{0x1.0000000000002p-1, -0x1.ffffffe200000p-75, -0x1.0003fffffffc0p-1, -0x1.ffffe00000400p-64, -0x1.fffffffdf0020p-16, -0x1.feffffe400000p-75},
{-0x1.0000000000002p-1, 0x1.ffffffe200000p-75, 0x1.0003fffffffc0p-1, 0x1.ffffe00000400p-64, 0x1.fffffffdf0020p-16, 0x1.feffffe400000p-75},
{-0x1.0000000000002p-1, 0x1.ffffffe200000p-75, -0x1.0003fffffffc0p-1, -0x1.ffffe00000400p-64, -0x1.0001fffffffe1p+0, -0x1.ffbfe00004000p-64},
{0x1.000003f000000p-1, 0x1.fffffffe00000p-62, 0x1.0000000000ff0p-1, 0x1.c03fff0e00000p-75, 0x1.000001f8007f8p+0, 0x1.000700fefc400p-61},
{0x1.000003f000000p-1, 0x1.fffffffe00000p-62, -0x1.0000000000ff0p-1, -0x1.c03fff0e00000p-75, 0x1.f7ff808007ffcp-24, 0x1.fdfe079000000p-78},
{-0x1.000003f000000p-1, -0x1.fffffffe00000p-62, 0x1.0000000000ff0p-1, 0x1.c03fff0e00000p-75, -0x1.f7ff808007ffcp-24, -0x1.fdfe079000000p-78},
{-0x1.000003f000000p-1, -0x1.fffffffe00000p-62, -0x1.0000000000ff0p-1, -0x1.c03fff0e00000p-75, -0x1.000001f8007f8p+0, -0x1.000700fefc400p-61},
{0x1.0000000018000p-1, 0x1.fffffe0000000p-83, 0x1.0000100000000p-1, -0x1.0000000000000p-106, 0x1.000008000c000p+0, 0x1.fffffc0000000p-83},
{0x1.0000000018000p-1, 0x1.fffffe0000000p-83, -0x1.0000100000000p-1, 0x1.0000000000000p-106, -0x1.fffd000000000p-22, 0x1.0000000000000p-82},
{-0x1.0000000018000p-1, -0x1.fffffe0000000p-83, 0x1.0000100000000p-1, -0x1.0000000000000p-106, 0x1.fffd000000000p-22, -0x1.0000000000000p-82},
{-0x1.0000000018000p-1, -0x1.fffffe0000000p-83, -0x1.0000100000000p-1, 0x1.0000000000000p-106, -0x1.000008000c000p+0, -0x1.fffffc0000000p-83},
{0x1.0000000000001p-1, -0x1.fffffc1000000p-68, 0x1.1ffffff01f000p-1, 0x1.ffffc000060fcp-56, 0x1.0ffffff80f801p+0, -0x1.80080fffeebc0p-54},
{0x1.0000000000001p-1, -0x1.fffffc1000000p-68, -0x1.1ffffff01f000p-1, -0x1.ffffc000060fcp-56, -0x1.ffffff01efff4p-5, -0x1.fbfffc70fc000p-68},
{-0x1.0000000000001p-1, 0x1.fffffc1000000p-68, 0x1.1ffffff01f000p-1, 0x1.ffffc000060fcp-56, 0x1.ffffff01efff4p-5, 0x1.fbfffc70fc000p-68},
{-0x1.0000000000001p-1, 0x1.fffffc1000000p-68, -0x1.1ffffff01f000p-1, -0x1.ffffc000060fcp-56, -0x1.0ffffff80f801p+0, 0x1.80080fffeebc0p-54},
{0x1.0000003800000p-1, 0x1.ffe000001fffcp-56, 0x1.0000007fffff0p-1, 0x1.fe1ffffc00000p-63, 0x1.0000005bffff8p+0, 0x1.01ee20000c000p-55},
{0x1.0000003800000p-1, 0x1.ffe000001fffcp-56, -0x1.0000007fffff0p-1, -0x1.fe1ffffc00000p-63, -0x1.1ffffbf020e20p-27, 0x1.3ffe000000000p-91},
{-0x1.0000003800000p-1, -0x1.ffe000001fffcp-56, 0x1.0000007fffff0p-1, 0x1.fe1ffffc00000p-63, 0x1.1ffffbf020e20p-27, -0x1.3ffe000000000p-91},
{-0x1.0000003800000p-1, -0x1.ffe000001fffcp-56, -0x1.0000007fffff0p-1, -0x1.fe1ffffc00000p-63, -0x1.0000005bffff8p+0, -0x1.01ee20000c000p-55},
{0x1.0000001fffc00p-1, 0x1.f00007ffe0000p-65, 0x1.0000000000180p-1, 0x1.fffffe0000800p-65, 0x1.0000000fffec0p+0, 0x1.f80002fff0000p-64},
{0x1.0000001fffc00p-1, 0x1.f00007ffe0000p-65, -0x1.0000000000180p-1, -0x1.fffffe0000800p-65, 0x1.fffa7fffff000p-29, 0x1.3ffbf00000000p-86},
{-0x1.0000001fffc00p-1, -0x1.f00007ffe0000p-65, 0x1.0000000000180p-1, 0x1.fffffe0000800p-65, -0x1.fffa7fffff000p-29, -0x1.3ffbf00000000p-86},
{-0x1.0000001fffc00p-1, -0x1.f00007ffe0000p-65, -0x1.0000000000180p-1, -0x1.fffffe0000800p-65, -0x1.0000000fffec0p+0, -0x1.f80002fff0000p-64},
{0x1.0000000008000p-1, -0x1.c0000007ffe04p-56, 0x1.00000fffffffep-1, 0x1.fc00000000000p-100, 0x1.0000080003fffp+0, -0x1.c0000007ffc08p-56},
{0x1.0000000008000p-1, -0x1.c0000007ffe04p-56, -0x1.00000fffffffep-1, -0x1.fc00000000000p-100, -0x1.fffefffc70000p-22, -0x1.0000000000000p-85},
{-0x1.0000000008000p-1, 0x1.c0000007ffe04p-56, 0x1.00000fffffffep-1, 0x1.fc00000000000p-100, 0x1.fffefffc70000p-22, 0x1.0000000000000p-85},
{-0x1.0000000008000p-1, 0x1.c0000007ffe04p-56, -0x1.00000fffffffep-1, -0x1.fc00000000000p-100, -0x1.0000080003fffp+0, 0x1.c0000007ffc08p-56},
{0x1.0000003e00004p-1, -0x1.fe00040000000p-71, 0x1.00007c0001e00p-1, 0x1.fffe13ffe0000p-65, 0x1.00003e1f00f02p+0, 0x1.f80613efe0000p-65},
{0x1.0000003e00004p-1, -0x1.fe00040000000p-71, -0x1.00007c0001e00p-1, -0x1.fffe13ffe0000p-65, -0x1.ef08077f00082p-19, 0x1.3d7e040000000p-78},
{-0x1.0000003e00004p-1, 0x1.fe00040000000p-71, 0x1.00007c0001e00p-1, 0x1.fffe13ffe0000p-65, 0x1.ef08077f00082p-19, -0x1.3d7e040000000p-78},
{-0x1.0000003e00004p-1, 0x1.fe00040000000p-71, -0x1.00007c0001e00p-1, -0x1.fffe13ffe0000p-65, -0x1.00003e1f00f02p+0, -0x1.f80613efe0000p-65},
{0x1.03fffffffc000p-1, 0x1.ffffffc000000p-76, 0x1.0003ffffff000p-1, 0x1.ffc0000000000p-96, 0x1.0201fffffd800p+0, 0x1.00000fe000000p-75},
{0x1.03fffffffc000p-1, 0x1.ffffffc000000p-76, -0x1.0003ffffff000p-1, -0x1.ffc0000000000p-96, 0x1.fdfffffe80000p-8, 0x1.ffffdfc400000p-76},
{-0x1.03fffffffc000p-1, -0x1.ffffffc000000p-76, 0x1.0003ffffff000p-1, 0x1.ffc0000000000p-96, -0x1.fdfffffe80000p-8, -0x1.ffffdfc400000p-76},
{-0x1.03fffffffc000p-1, -0x1.ffffffc000000p-76, -0x1.0003ffffff000p-1, -0x1.ffc0000000000p-96, -0x1.0201fffffd800p+0, -0x1.00000fe000000p-75},
{0x1.07ffffff80000p-1, 0x1.8007ffffc0000p-72, 0x1.0000000000004p-1, -0x1.fffc000200000p-70, 0x1.03ffffffc0002p+0, -0x1.9ffa000200000p-70},
{0x1.07ffffff80000p-1, 0x1.8007ffffc0000p-72, -0x1.0000000000004p-1, 0x1.fffc000200000p-70, 0x1.ffffffdffff00p-7, 0x1.2fff0000f8000p-69},
{-0x1.07ffffff80000p-1, -0x1.8007ffffc0000p-72, 0x1.0000000000004p-1, -0x1.fffc000200000p-70, -0x1.ffffffdffff00p-7, -0x1.2fff0000f8000p-69},
{-0x1.07ffffff80000p-1, -0x1.8007ffffc0000p-72, -0x1.0000000000004p-1, 0x1.fffc000200000p-70, -0x1.03ffffffc0002p+0, 0x1.9ffa000200000p-70},
{0x1.00003ffffff80p-1, 0x1.ffff0000ffe00p-63, 0x1.00003fffffff8p-1, 0x0.0000000000000p+0, 0x1.00003ffffffbcp+0, 0x1.ffff000100000p-63},
{0x1.00003ffffff80p-1, 0x1.ffff0000ffe00p-63, -0x1.00003fffffff8p-1, 0x0.0000000000000p+0, -0x1.dffe0000ffff0p-47, -0x1.0000000000000p-106},
{-0x1.00003ffffff80p-1, -0x1.ffff0000ffe00p-63, 0x1.00003fffffff8p-1, 0x0.0000000000000p+0, 0x1.dffe0000ffff0p-47, 0x1.0000000000000p-106},
{-0x1.00003ffffff80p-1, -0x1.ffff0000ffe00p-63, -0x1.00003fffffff8p-1, 0x0.0000000000000p+0, -0x1.00003ffffffbcp+0, -0x1.ffff000100000p-63},
{0x1.0000010000000p-1, -0x1.0000000000000p-106, 0x1.00f81ffffff81p-1, 0x1.fffff03c00000p-63, 0x1.007c107ffffc1p+0, -0x1.ff000007e2000p-54},
{0x1.0000010000000p-1, -0x1.0000000000000p-106, -0x1.00f81ffffff81p-1, -0x1.fffff03c00000p-63, -0x1.f03dfffff0201p-10, 0x1.f87ffc0000000p-84},
{-0x1.0000010000000p-1, 0x1.0000000000000p-106, 0x1.00f81ffffff81p-1, 0x1.fffff03c00000p-63, 0x1.f03dfffff0201p-10, -0x1.f87ffc0000000p-84},
{-0x1.0000010000000p-1, 0x1.0000000000000p-106, -0x1.00f81ffffff81p-1, -0x1.fffff03c00000p-63, -0x1.007c107ffffc1p+0, 0x1.ff000007e2000p-54},
{0x1.0000000000004p-1, -0x1.fff0008000000p-65, 0x1.0000000100000p-1, -0x1.fffffe0004000p-68, 0x1.0000000080002p+0, -0x1.1ff8002000000p-64},
{0x1.0000000000004p-1, -0x1.fff0008000000p-65, -0x1.0000000100000p-1, 0x1.fffffe0004000p-68, -0x1.ffff80037fe00p-34, -0x1.7fff000000000p-90},
{-0x1.0000000000004p-1, 0x1.fff0008000000p-65, 0x1.0000000100000p-1, -0x1.fffffe0004000p-68, 0x1.ffff80037fe00p-34, 0x1.7fff000000000p-90},
{-0x1.0000000000004p-1, 0x1.fff0008000000p-65, -0x1.0000000100000p-1, 0x1.fffffe0004000p-68, -0x1.0000000080002p+0, 0x1.1ff8002000000p-64},
{0x1.0000000000800p-1, -0x1.0000000000000p-79, 0x1.0000010000000p-1, -0x1.0000000000000p-104, 0x1.0000008000400p+0, -0x1.0000008000000p-79},
{0x1.0000000000800p-1, -0x1.0000000000000p-79, -0x1.0000010000000p-1, 0x1.0000000000000p-104, -0x1.ffff000000000p-26, -0x1.ffffff0000000p-80},
{-0x1.0000000000800p-1, 0x1.0000000000000p-79, 0x1.0000010000000p-1, -0x1.0000000000000p-104, 0x1.ffff000000000p-26, 0x1.ffffff0000000p-80},
{-0x1.0000000000800p-1, 0x1.0000000000000p-79, -0x1.0000010000000p-1, 0x1.0000000000000p-104, -0x1.0000008000400p+0, 0x1.0000008000000p-79},
{0x1.00000007fff00p-1, 0x1.fffc1ffff87f0p-57, 0x1.0000007c00000p-1, 0x1.fff0000000000p-72, 0x1.00000041fff80p+0, 0x1.00000feffc3f8p-56},
{0x1.00000007fff00p-1, 0x1.fffc1ffff87f0p-57, -0x1.0000007c00000p-1, -0x1.fff0000000000p-72, -0x1.d0003ff8001f8p-27, 0x1.ff87f00000000p-85},
{-0x1.00000007fff00p-1, -0x1.fffc1ffff87f0p-57, 0x1.0000007c00000p-1, 0x1.fff0000000000p-72, 0x1.d0003ff8001f8p-27, -0x1.ff87f00000000p-85},
{-0x1.00000007fff00p-1, -0x1.fffc1ffff87f0p-57, -0x1.0000007c00000p-1, -0x1.fff0000000000p-72, -0x1.00000041fff80p+0, -0x1.00000feffc3f8p-56},
{0x1.fffffffe00000p-1, 0x1.e000001fff800p-65, 0x1.00000001ffffep-1, 0x0.0000000000000p+0, 0x1.7ffffffffffffp+0, 0x1.e000002000000p-65},
{0x1.fffffffe00000p-1, 0x1.e000001fff800p-65, -0x1.00000001ffffep-1, 0x0.0000000000000p+0, 0x1.fffffff800004p-2, 0x1.e000001fff800p-65},
{-0x1.fffffffe00000p-1, -0x1.e000001fff800p-65, 0x1.00000001ffffep-1, 0x0.0000000000000p+0, -0x1.fffffff800004p-2, -0x1.e000001fff800p-65},
{-0x1.fffffffe00000p-1, -0x1.e000001fff800p-65, -0x1.00000001ffffep-1, 0x0.0000000000000p+0, -0x1.7ffffffffffffp+0, -0x1.e000002000000p-65},
{0x1.0000000000008p-1, -0x1.fffff00400000p-73, 0x1.00003ffffe000p-1, 0x1.ffffe00000000p-73, 0x1.00001fffff004p+0, -0x1.0040000000000p-93},
{0x1.0000000000008p-1, -0x1.fffff00400000p-73, -0x1.00003ffffe000p-1, -0x1.ffffe00000000p-73, -0x1.ffffeffc00002p-20, 0x1.7fe0000000000p-92},
{-0x1.0000000000008p-1, 0x1.fffff00400000p-73, 0x1.00003ffffe000p-1, 0x1.ffffe00000000p-73, 0x1.ffffeffc00002p-20, -0x1.7fe0000000000p-92},
{-0x1.0000000000008p-1, 0x1.fffff00400000p-73, -0x1.00003ffffe000p-1, -0x1.ffffe00000000p-73, -0x1.00001fffff004p+0, 0x1.0040000000000p-93},
{0x1.0000000000000p-1, 0x1.ffffffffffc00p-64, 0x1.000001ffe0000p-1, 0x1.ff87ff9f801c0p-60, 0x1.000000fff0000p+0, 0x1.0fc3ffcfc00c0p-59},
{0x1.0000000000000p-1, 0x1.ffffffffffc00p-64, -0x1.000001ffe0000p-1, -0x1.ff87ff9f801c0p-60, -0x1.ffe000003bf10p-25, 0x1.81ff800000000p-86},
{-0x1.0000000000000p-1, -0x1.ffffffffffc00p-64, 0x1.000001ffe0000p-1, 0x1.ff87ff9f801c0p-60, 0x1.ffe000003bf10p-25, -0x1.81ff800000000p-86},
{-0x1.0000000000000p-1, -0x1.ffffffffffc00p-64, -0x1.000001ffe0000p-1, -0x1.ff87ff9f801c0p-60, -0x1.000000fff0000p+0, -0x1.0fc3ffcfc00c0p-59},
{0x1.0000000000400p-1, -0x1.f800000002000p-62, 0x1.03fffffffff00p-1, 0x1.fffe7fffffffep-55, 0x1.0200000000180p+0, 0x1.fc0e7ffffffc0p-55},
{0x1.0000000000400p-1, -0x1.f800000002000p-62, -0x1.03fffffffff00p-1, -0x1.fffe7fffffffep-55, -0x1.ffffffffd8040p-8, -0x1.f740000001f00p-62},
{-0x1.0000000000400p-1, 0x1.f800000002000p-62, 0x1.03fffffffff00p-1, 0x1.fffe7fffffffep-55, 0x1.ffffffffd8040p-8, 0x1.f740000001f00p-62},
{-0x1.0000000000400p-1, 0x1.f800000002000p-62, -0x1.03fffffffff00p-1, -0x1.fffe7fffffffep-55, -0x1.0200000000180p+0, -0x1.fc0e7ffffffc0p-55},
{0x1.0000000000000p-1, 0x1.fffffffffff00p-57, 0x1.000007c000000p-1, 0x1.fff8000000000p-57, 0x1.000003e000000p+0, 0x1.fffbfffffff80p-56},
{0x1.0000000000000p-1, 0x1.fffffffffff00p-57, -0x1.000007c000000p-1, -0x1.fff8000000000p-57, -0x1.effffffffffe0p-23, -0x1.0000000000000p-101},
{-0x1.0000000000000p-1, -0x1.fffffffffff00p-57, 0x1.000007c000000p-1, 0x1.fff8000000000p-57, 0x1.effffffffffe0p-23, 0x1.0000000000000p-101},
{-0x1.0000000000000p-1, -0x1.fffffffffff00p-57, -0x1.000007c000000p-1, -0x1.fff8000000000p-57, -0x1.000003e000000p+0, -0x1.fffbfffffff80p-56},
{0x1.0000000000400p-1, -0x1.fffc0003fffd0p-58, 0x1.0000000000000p-1, 0x1.fffffff800000p-57, 0x1.0000000000200p+0, 0x1.0001fff600020p-57},
{0x1.0000000000400p-1, -0x1.fffc0003fffd0p-58, -0x1.0000000000000p-1, -0x1.fffffff800000p-57, 0x1.ffe8001000300p-44, 0x1.8000000000000p-105},
{-0x1.0000000000400p-1, 0x1.fffc0003fffd0p-58, 0x1.0000000000000p-1, 0x1.fffffff800000p-57, -0x1.ffe8001000300p-44, -0x1.8000000000000p-105},
{-0x1.0000000000400p-1, 0x1.fffc0003fffd0p-58, -0x1.0000000000000p-1, -0x1.fffffff800000p-57, -0x1.0000000000200p+0, -0x1.0001fff600020p-57},
{0x1.0000000002000p-1, -0x1.ffff040000000p-72, 0x1.03fffff800000p-1, 0x1.fffffe0000000p-69, 0x1.01fffffc01000p+0, 0x1.c0001d8000000p-69},
{0x1.0000000002000p-1, -0x1.ffff040000000p-72, -0x1.03fffff800000p-1, -0x1.fffffe0000000p-69, -0x1.fffffbff00000p-8, -0x1.1fffef4000000p-68},
{-0x1.0000000002000p-1, 0x1.ffff040000000p-72, 0x1.03fffff800000p-1, 0x1.fffffe0000000p-69, 0x1.fffffbff00000p-8, 0x1.1fffef4000000p-68},
{-0x1.0000000002000p-1, 0x1.ffff040000000p-72, -0x1.03fffff800000p-1, -0x1.fffffe0000000p-69, -0x1.01fffffc01000p+0, -0x1.c0001d8000000p-69},
{0x1.0000008000000p-1, -0x1.ffffff8200000p-58, 0x1.000fff8000000p-1, 0x1.fffffe0000000p-63, 0x1.0008000000000p+0, -0x1.efffff9200000p-58},
{0x1.0000008000000p-1, -0x1.ffffff8200000p-58, -0x1.000fff8000000p-1, -0x1.fffffe0000000p-63, -0x1.ffe0000000210p-14, 0x1.1c00000000000p-83},
{-0x1.0000008000000p-1, 0x1.ffffff8200000p-58, 0x1.000fff8000000p-1, 0x1.fffffe0000000p-63, 0x1.ffe0000000210p-14, -0x1.1c00000000000p-83},
{-0x1.0000008000000p-1, 0x1.ffffff8200000p-58, -0x1.000fff8000000p-1, -0x1.fffffe0000000p-63, -0x1.0008000000000p+0, 0x1.efffff9200000p-58},
{0x1.0000000000000p-1, 0x1.0001f9e000000p-61, 0x1.0000000000040p-1, -0x1.fffffc0080000p-73, 0x1.0000000000020p+0, 0x1.ffc3f3c080000p-62},
{0x1.0000000000000p-1, 0x1.0001f9e000000p-61, -0x1.0000000000040p-1, 0x1.fffffc0080000p-73, -0x1.fff7fef031020p-48, 0x1.0000000000000p-106},
{-0x1.0000000000000p-1, -0x1.0001f9e000000p-61, 0x1.0000000000040p-1, -0x1.fffffc0080000p-73, 0x1.fff7fef031020p-48, -0x1.0000000000000p-106},
{-0x1.0000000000000p-1, -0x1.0001f9e000000p-61, -0x1.0000000000040p-1, 0x1.fffffc0080000p-73, -0x1.0000000000020p+0, -0x1.ffc3f3c080000p-62},
{0x1.0000ff0007e00p-1, 0x1.ffc001ff00000p-68, 0x1.0000010000000p-1, -0x1.ffc007ffffe20p-59, 0x1.0000800003f00p+0, -0x1.fec027ff00600p-59},
{0x1.0000ff0007e00p-1, 0x1.ffc001ff00000p-68, -0x1.0000010000000p-1, 0x1.ffc007ffffe20p-59, 0x1.fc000fc001006p-18, -0x1.7ff009e000000p-79},
{-0x1.0000ff0007e00p-1, -0x1.ffc001ff00000p-68, 0x1.0000010000000p-1, -0x1.ffc007ffffe20p-59, -0x1.fc000fc001006p-18, 0x1.7ff009e000000p-79},
{-0x1.0000ff0007e00p-1, -0x1.ffc001ff00000p-68, -0x1.0000010000000p-1, 0x1.ffc007ffffe20p-59, -0x1.0000800003f00p+0, 0x1.fec027ff00600p-59},
{0x1.07ffffff1fe00p-1, 0x1.fc00000000000p-98, 0x1.0040000000000p-1, -0x1.c000000400000p-62, 0x1.041fffff8ff00p+0, -0x1.c0000003e0400p-62},
{0x1.07ffffff1fe00p-1, 0x1.fc00000000000p-98, -0x1.0040000000000p-1, 0x1.c000000400000p-62, 0x1.efffffc7f8000p-7, 0x1.c00000041fc00p-62},
{-0x1.07ffffff1fe00p-1, -0x1.fc00000000000p-98, 0x1.0040000000000p-1, -0x1.c000000400000p-62, -0x1.efffffc7f8000p-7, -0x1.c00000041fc00p-62},
{-0x1.07ffffff1fe00p-1, -0x1.fc00000000000p-98, -0x1.0040000000000p-1, 0x1.c000000400000p-62, -0x1.041fffff8ff00p+0, 0x1.c0000003e0400p-62},
{0x1.0080000000000p-1, -0x1.0000000000000p-106, 0x1.00000001fffc0p-1, 0x1.fffff80f80000p-73, 0x1.00400000fffe0p+0, 0x1.fffff80f00000p-73},
{0x1.0080000000000p-1, -0x1.0000000000000p-106, -0x1.00000001fffc0p-1, -0x1.fffff80f80000p-73, 0x1.fffff80010000p-11, -0x1.fffff81000000p-73},
{-0x1.0080000000000p-1, 0x1.0000000000000p-106, 0x1.00000001fffc0p-1, 0x1.fffff80f80000p-73, -0x1.fffff80010000p-11, 0x1.fffff81000000p-73},
{-0x1.0080000000000p-1, 0x1.0000000000000p-106, -0x1.00000001fffc0p-1, -0x1.fffff80f80000p-73, -0x1.00400000fffe0p+0, -0x1.fffff80f00000p-73},
{0x1.000000003ff00p-1, 0x0.0000000000000p+0, 0x1.0000000000000p-1, 0x1.f83007ffffe00p-61, 0x1.000000001ff80p+0, 0x1.f83007ffffe00p-61},
{0x1.000000003ff00p-1, 0x0.0000000000000p+0, -0x1.0000000000000p-1, -0x1.f83007ffffe00p-61, 0x1.ff7fff03e7fc0p-36, 0x1.0000000000000p-104},
{-0x1.000000003ff00p-1, 0x0.0000000000000p+0, 0x1.0000000000000p-1, 0x1.f83007ffffe00p-61, -0x1.ff7fff03e7fc0p-36, -0x1.0000000000000p-104},
{-0x1.000000003ff00p-1, 0x0.0000000000000p+0, -0x1.0000000000000p-1, -0x1.f83007ffffe00p-61, -0x1.000000001ff80p+0, -0x1.f83007ffffe00p-61},
{0x1.00003fffffe00p-1, 0x1.fffffc0000380p-61, 0x1.0000010000000p-1, -0x1.ffffff8000008p-57, 0x1.0000207ffff00p+0, -0x1.dfffffbffffd0p-57},
{0x1.00003fffffe00p-1, 0x1.fffffc0000380p-61, -0x1.0000010000000p-1, 0x1.ffffff8000008p-57, 0x1.f7ffff0011000p-20, -0x1.7ffff80000000p-82},
{-0x1.00003fffffe00p-1, -0x1.fffffc0000380p-61, 0x1.0000010000000p-1, -0x1.ffffff8000008p-57, -0x1.f7ffff0011000p-20, 0x1.7ffff80000000p-82},
{-0x1.00003fffffe00p-1, -0x1.fffffc0000380p-61, -0x1.0000010000000p-1, 0x1.ffffff8000008p-57, -0x1.0000207ffff00p+0, 0x1.dfffffbffffd0p-57},
{0x1.0000000080000p-1, -0x1.fffffc0010000p-70, 0x1.3fffff8000000p-1, 0x1.fffff800fe000p-67, 0x1.1fffffc040000p+0, 0x1.bffff880fc000p-67},
{0x1.0000000080000p-1, -0x1.fffffc0010000p-70, -0x1.3fffff8000000p-1, -0x1.fffff800fe000p-67, -0x1.fffffbfc00000p-4, -0x1.1ffffbc080000p-66},
{-0x1.0000000080000p-1, 0x1.fffffc0010000p-70, 0x1.3fffff8000000p-1, 0x1.fffff800fe000p-67, 0x1.fffffbfc00000p-4, 0x1.1ffffbc080000p-66},
{-0x1.0000000080000p-1, 0x1.fffffc0010000p-70, -0x1.3fffff8000000p-1, -0x1.fffff800fe000p-67, -0x1.1fffffc040000p+0, -0x1.bffff880fc000p-67},
{0x1.0003f001fc3f0p-1, 0x1.fffffc0000000p-57, 0x1.0000000000000p-1, 0x1.fc1fffc0000fep-55, 0x1.0001f800fe1f8p+0, 0x1.3e0fff6000080p-54},
{0x1.0003f001fc3f0p-1, 0x1.fffffc0000000p-57, -0x1.0000000000000p-1, -0x1.fc1fffc0000fep-55, 0x1.f800fe1f7d07cp-16, -0x1.80001fc000000p-80},
{-0x1.0003f001fc3f0p-1, -0x1.fffffc0000000p-57, 0x1.0000000000000p-1, 0x1.fc1fffc0000fep-55, -0x1.f800fe1f7d07cp-16, 0x1.80001fc000000p-80},
{-0x1.0003f001fc3f0p-1, -0x1.fffffc0000000p-57, -0x1.0000000000000p-1, -0x1.fc1fffc0000fep-55, -0x1.0001f800fe1f8p+0, -0x1.3e0fff6000080p-54},
{0x1.0000000000000p-1, 0x1.fffffffffffc0p-60, 0x1.0000000000000p-1, 0x1.ffffffffffe00p-63, 0x1.0000000000000p+0, 0x1.1ffffffffffc0p-59},
{0x1.0000000000000p-1, 0x1.fffffffffffc0p-60, -0x1.0000000000000p-1, -0x1.ffffffffffe00p-63, 0x1.c000000000000p-60, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.fffffffffffc0p-60, 0x1.0000000000000p-1, 0x1.ffffffffffe00p-63, -0x1.c000000000000p-60, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.fffffffffffc0p-60, -0x1.0000000000000p-1, -0x1.ffffffffffe00p-63, -0x1.0000000000000p+0, -0x1.1ffffffffffc0p-59},
{0x1.0000000100000p-1, -0x1.0000000000000p-80, 0x1.0000004000000p-1, -0x1.0000000000000p-81, 0x1.0000002080000p+0, -0x1.8000000000000p-80},
{0x1.0000000100000p-1, -0x1.0000000000000p-80, -0x1.0000004000000p-1, 0x1.0000000000000p-81, -0x1.f800000000000p-28, -0x1.0000000000000p-81},
{-0x1.0000000100000p-1, 0x1.0000000000000p-80, 0x1.0000004000000p-1, -0x1.0000000000000p-81, 0x1.f800000000000p-28, 0x1.0000000000000p-81},
{-0x1.0000000100000p-1, 0x1.0000000000000p-80, -0x1.0000004000000p-1, 0x1.0000000000000p-81, -0x1.0000002080000p+0, 0x1.8000000000000p-80},
{0x1.0000010000000p-1, -0x1.ffffe00001000p-57, 0x1.000ffffff007fp-1, 0x1.ffffc00000000p-82, 0x1.0008007ff803fp+0, 0x1.c000041fffdc0p-54},
{0x1.0000010000000p-1, -0x1.ffffe00001000p-57, -0x1.000ffffff007fp-1, -0x1.ffffc00000000p-82, -0x1.ffdffe00fe400p-14, 0x1.effff20000000p-77},
{-0x1.0000010000000p-1, 0x1.ffffe00001000p-57, 0x1.000ffffff007fp-1, 0x1.ffffc00000000p-82, 0x1.ffdffe00fe400p-14, -0x1.effff20000000p-77},
{-0x1.0000010000000p-1, 0x1.ffffe00001000p-57, -0x1.000ffffff007fp-1, -0x1.ffffc00000000p-82, -0x1.0008007ff803fp+0, -0x1.c000041fffdc0p-54},
{0x1.1000fffffc000p-1, 0x1.fffffc003f000p-57, 0x1.0000000001000p-1, -0x1.0000000000000p-106, 0x1.08007ffffe800p+0, 0x1.fffffc003f000p-57},
{0x1.1000fffffc000p-1, 0x1.fffffc003f000p-57, -0x1.0000000001000p-1, 0x1.0000000000000p-106, 0x1.000fffffb0002p-5, -0x1.ffe07fc000000p-80},
{-0x1.1000fffffc000p-1, -0x1.fffffc003f000p-57, 0x1.0000000001000p-1, -0x1.0000000000000p-106, -0x1.000fffffb0002p-5, 0x1.ffe07fc000000p-80},
{-0x1.1000fffffc000p-1, -0x1.fffffc003f000p-57, -0x1.0000000001000p-1, 0x1.0000000000000p-106, -0x1.08007ffffe800p+0, -0x1.fffffc003f000p-57},
{0x1.00000fff80000p-1, 0x1.fffe000000000p-86, 0x1.0000001f00000p-1, 0x1.fffffff000000p-78, 0x1.0000080f40000p+0, 0x1.00ffff0000000p-77},
{0x1.00000fff80000p-1, 0x1.fffe000000000p-86, -0x1.0000001f00000p-1, -0x1.fffffff000000p-78, 0x1.fc10000000000p-22, -0x1.fe0001f000000p-78},
{-0x1.00000fff80000p-1, -0x1.fffe000000000p-86, 0x1.0000001f00000p-1, 0x1.fffffff000000p-78, -0x1.fc10000000000p-22, 0x1.fe0001f000000p-78},
{-0x1.00000fff80000p-1, -0x1.fffe000000000p-86, -0x1.0000001f00000p-1, -0x1.fffffff000000p-78, -0x1.0000080f40000p+0, -0x1.00ffff0000000p-77},
{0x1.3fdfffff02000p-1, -0x1.0000000000000p-79, 0x1.0000000000000p-1, 0x1.ffffffffffe00p-62, 0x1.1fefffff81000p+0, 0x1.ffff7fffffe00p-62},
{0x1.3fdfffff02000p-1, -0x1.0000000000000p-79, -0x1.0000000000000p-1, -0x1.ffffffffffe00p-62, 0x1.fefffff810000p-4, -0x1.00003ffffff00p-61},
{-0x1.3fdfffff02000p-1, 0x1.0000000000000p-79, 0x1.0000000000000p-1, 0x1.ffffffffffe00p-62, -0x1.fefffff810000p-4, 0x1.00003ffffff00p-61},
{-0x1.3fdfffff02000p-1, 0x1.0000000000000p-79, -0x1.0000000000000p-1, -0x1.ffffffffffe00p-62, -0x1.1fefffff81000p+0, -0x1.ffff7fffffe00p-62},
{0x1.0000000000008p-1, -0x1.e0ffffd002000p-67, 0x1.0000000000400p-1, 0x1.ffffffff03ffep-55, 0x1.0000000000204p+0, 0x1.ffe1efff06ffcp-55},
{0x1.0000000000008p-1, -0x1.e0ffffd002000p-67, -0x1.0000000000400p-1, -0x1.ffffffff03ffep-55, -0x1.fc4003c1ffe02p-44, 0x0.0000000000000p+0},
{-0x1.0000000000008p-1, 0x1.e0ffffd002000p-67, 0x1.0000000000400p-1, 0x1.ffffffff03ffep-55, 0x1.fc4003c1ffe02p-44, 0x0.0000000000000p+0},
{-0x1.0000000000008p-1, 0x1.e0ffffd002000p-67, -0x1.0000000000400p-1, -0x1.ffffffff03ffep-55, -0x1.0000000000204p+0, -0x1.ffe1efff06ffcp-55},
{0x1.000000fffe020p-1, -0x1.f800100000000p-74, 0x1.0001fff80ffc0p-1, 0x1.ff00000000000p-98, 0x1.0001007c06ff0p+0, -0x1.f8000e0000000p-74},
{0x1.000000fffe020p-1, -0x1.f800100000000p-74, -0x1.0001fff80ffc0p-1, -0x1.ff00000000000p-98, -0x1.fef811fa00000p-17, -0x1.f80011ff00000p-74},
{-0x1.000000fffe020p-1, 0x1.f800100000000p-74, 0x1.0001fff80ffc0p-1, 0x1.ff00000000000p-98, 0x1.fef811fa00000p-17, 0x1.f80011ff00000p-74},
{-0x1.000000fffe020p-1, 0x1.f800100000000p-74, -0x1.0001fff80ffc0p-1, -0x1.ff00000000000p-98, -0x1.0001007c06ff0p+0, 0x1.f8000e0000000p-74},
{0x1.4000000000000p-1, -0x1.0000000000000p-106, 0x1.0000000000010p-1, 0x1.e000000000000p-69, 0x1.2000000000008p+0, 0x1.e000000000000p-69},
{0x1.4000000000000p-1, -0x1.0000000000000p-106, -0x1.0000000000010p-1, -0x1.e000000000000p-69, 0x1.fffffffffff80p-4, -0x1.e000000008000p-69},
{-0x1.4000000000000p-1, 0x1.0000000000000p-106, 0x1.0000000000010p-1, 0x1.e000000000000p-69, -0x1.fffffffffff80p-4, 0x1.e000000008000p-69},
{-0x1.4000000000000p-1, 0x1.0000000000000p-106, -0x1.0000000000010p-1, -0x1.e000000000000p-69, -0x1.2000000000008p+0, -0x1.e000000000000p-69},
{0x1.2000000000000p-1, -0x1.fffffff01ff20p-58, 0x1.0000000000000p-1, 0x1.fff8003ff0000p-58, 0x1.1000000000000p+0, -0x1.ffec0bfc80000p-72},
{0x1.2000000000000p-1, -0x1.fffffff01ff20p-58, -0x1.0000000000000p-1, -0x1.fff8003ff0000p-58, 0x1.ffffffffffffep-5, 0x1.fff3fc0380000p-72},
{-0x1.2000000000000p-1, 0x1.fffffff01ff20p-58, 0x1.0000000000000p-1, 0x1.fff8003ff0000p-58, -0x1.ffffffffffffep-5, -0x1.fff3fc0380000p-72},
{-0x1.2000000000000p-1, 0x1.fffffff01ff20p-58, -0x1.0000000000000p-1, -0x1.fff8003ff0000p-58, -0x1.1000000000000p+0, 0x1.ffec0bfc80000p-72},
{0x1.2000000000000p-1, -0x1.fc08000000000p-93, 0x1.0000000038004p-1, -0x1.fffffc4000000p-70, 0x1.100000001c002p+0, -0x1.0000001c00000p-69},
{0x1.2000000000000p-1, -0x1.fc08000000000p-93, -0x1.0000000038004p-1, 0x1.fffffc4000000p-70, 0x1.fffffffc7ffc0p-5, 0x1.fffff847f0000p-70},
{-0x1.2000000000000p-1, 0x1.fc08000000000p-93, 0x1.0000000038004p-1, -0x1.fffffc4000000p-70, -0x1.fffffffc7ffc0p-5, -0x1.fffff847f0000p-70},
{-0x1.2000000000000p-1, 0x1.fc08000000000p-93, -0x1.0000000038004p-1, 0x1.fffffc4000000p-70, -0x1.100000001c002p+0, 0x1.0000001c00000p-69},
{0x1.0000000000200p-1, 0x0.0000000000000p+0, 0x1.00001ffff0000p-1, 0x1.ffff80001f000p-58, 0x1.00000ffff8100p+0, 0x1.ffff80001f000p-58},
{0x1.0000000000200p-1, 0x0.0000000000000p+0, -0x1.00001ffff0000p-1, -0x1.ffff80001f000p-58, -0x1.fffefe0010000p-21, 0x1.ffff840000000p-76},
{-0x1.0000000000200p-1, 0x0.0000000000000p+0, 0x1.00001ffff0000p-1, 0x1.ffff80001f000p-58, 0x1.fffefe0010000p-21, -0x1.ffff840000000p-76},
{-0x1.0000000000200p-1, 0x0.0000000000000p+0, -0x1.00001ffff0000p-1, -0x1.ffff80001f000p-58, -0x1.00000ffff8100p+0, -0x1.ffff80001f000p-58},
{0x1.0000100000000p-1, -0x1.0000000000000p-106, 0x1.0038000800000p-1, -0x1.fffffe0000080p-61, 0x1.001c080400000p+0, -0x1.fffffe0000100p-61},
{0x1.0000100000000p-1, -0x1.0000000000000p-106, -0x1.0038000800000p-1, 0x1.fffffe0000080p-61, -0x1.bf803fffffff0p-12, -0x1.0000000000000p-84},
{-0x1.0000100000000p-1, 0x1.0000000000000p-106, 0x1.0038000800000p-1, -0x1.fffffe0000080p-61, 0x1.bf803fffffff0p-12, 0x1.0000000000000p-84},
{-0x1.0000100000000p-1, 0x1.0000000000000p-106, -0x1.0038000800000p-1, 0x1.fffffe0000080p-61, -0x1.001c080400000p+0, 0x1.fffffe0000100p-61},
{0x1.0000000000004p-1, -0x1.ffffe00400000p-74, 0x1.0000000000000p-1, 0x1.ffffffffffff8p-57, 0x1.0000000000002p+0, 0x1.ffff00000ffe0p-57},
{0x1.0000000000004p-1, -0x1.ffffe00400000p-74, -0x1.0000000000000p-1, -0x1.ffffffffffff8p-57, 0x1.effff800007ffp-52, 0x1.0000000000000p-106},
{-0x1.0000000000004p-1, 0x1.ffffe00400000p-74, 0x1.0000000000000p-1, 0x1.ffffffffffff8p-57, -0x1.effff800007ffp-52, -0x1.0000000000000p-106},
{-0x1.0000000000004p-1, 0x1.ffffe00400000p-74, -0x1.0000000000000p-1, -0x1.ffffffffffff8p-57, -0x1.0000000000002p+0, -0x1.ffff00000ffe0p-57},
{0x1.0000000000100p-1, -0x1.ffffe7e400000p-71, 0x1.1ffe000008000p-1, -0x1.fffc000004000p-68, 0x1.0fff000004080p+0, -0x1.1ffdfe7e40000p-67},
{0x1.0000000000100p-1, -0x1.ffffe7e400000p-71, -0x1.1ffe000008000p-1, 0x1.fffc000004000p-68, -0x1.ffe000007f000p-5, 0x1.bffc030384000p-68},
{-0x1.0000000000100p-1, 0x1.ffffe7e400000p-71, 0x1.1ffe000008000p-1, -0x1.fffc000004000p-68, 0x1.ffe000007f000p-5, -0x1.bffc030384000p-68},
{-0x1.0000000000100p-1, 0x1.ffffe7e400000p-71, -0x1.1ffe000008000p-1, 0x1.fffc000004000p-68, -0x1.0fff000004080p+0, 0x1.1ffdfe7e40000p-67},
{0x1.0000000000004p-1, -0x1.0000000000000p-106, 0x1.00000007ffffep-1, 0x1.ffffe000f0000p-62, 0x1.0000000400001p+0, 0x1.ffffe000f0000p-62},
{0x1.0000000000004p-1, -0x1.0000000000000p-106, -0x1.00000007ffffep-1, -0x1.ffffe000f0000p-62, -0x1.ffffe803ffffcp-31, -0x1.e020000000000p-95},
{-0x1.0000000000004p-1, 0x1.0000000000000p-106, 0x1.00000007ffffep-1, 0x1.ffffe000f0000p-62, 0x1.ffffe803ffffcp-31, 0x1.e020000000000p-95},
{-0x1.0000000000004p-1, 0x1.0000000000000p-106, -0x1.00000007ffffep-1, -0x1.ffffe000f0000p-62, -0x1.0000000400001p+0, -0x1.ffffe000f0000p-62},
{0x1.0000000000000p-1, 0x1.fffffff000000p-62, 0x1.0001fffc00001p-1, -0x1.0000000000000p-80, 0x1.0000fffe00001p+0, -0x1.fe00004010000p-54},
{0x1.0000000000000p-1, 0x1.fffffff000000p-62, -0x1.0001fffc00001p-1, 0x1.0000000000000p-80, -0x1.fffc00000ff00p-17, 0x1.ff80000000000p-81},
{-0x1.0000000000000p-1, -0x1.fffffff000000p-62, 0x1.0001fffc00001p-1, -0x1.0000000000000p-80, 0x1.fffc00000ff00p-17, -0x1.ff80000000000p-81},
{-0x1.0000000000000p-1, -0x1.fffffff000000p-62, -0x1.0001fffc00001p-1, 0x1.0000000000000p-80, -0x1.0000fffe00001p+0, 0x1.fe00004010000p-54},
{0x1.00007fdfffff0p-1, 0x1.fff000f803fe0p-59, 0x1.0080000000000p-1, -0x1.0000000000000p-93, 0x1.00403fefffff8p+0, 0x1.fff000f7c4000p-59},
{0x1.00007fdfffff0p-1, 0x1.fff000f803fe0p-59, -0x1.0080000000000p-1, 0x1.0000000000000p-93, -0x1.fe00800003fe0p-11, -0x1.ffe0f78040000p-72},
{-0x1.00007fdfffff0p-1, -0x1.fff000f803fe0p-59, 0x1.0080000000000p-1, -0x1.0000000000000p-93, 0x1.fe00800003fe0p-11, 0x1.ffe0f78040000p-72},
{-0x1.00007fdfffff0p-1, -0x1.fff000f803fe0p-59, -0x1.0080000000000p-1, 0x1.0000000000000p-93, -0x1.00403fefffff8p+0, -0x1.fff000f7c4000p-59},
{0x1.0000000000080p-1, 0x0.0000000000000p+0, 0x1.0000080000000p-1, -0x1.0000000000000p-86, 0x1.0000040000040p+0, -0x1.0000000000000p-86},
{0x1.0000000000080p-1, 0x0.0000000000000p+0, -0x1.0000080000000p-1, 0x1.0000000000000p-86, -0x1.fffffe0000000p-23, 0x1.0000000000000p-86},
{-0x1.0000000000080p-1, 0x0.0000000000000p+0, 0x1.0000080000000p-1, -0x1.0000000000000p-86, 0x1.fffffe0000000p-23, -0x1.0000000000000p-86},
{-0x1.0000000000080p-1, 0x0.0000000000000p+0, -0x1.0000080000000p-1, 0x1.0000000000000p-86, -0x1.0000040000040p+0, 0x1.0000000000000p-86},
{0x1.0400000000000p-1, -0x1.0000000000000p-106, 0x1.0000000000400p-1, -0x1.fffff00008000p-57, 0x1.0200000000200p+0, -0x1.fffff00008000p-57},
{0x1.0400000000000p-1, -0x1.0000000000000p-106, -0x1.0000000000400p-1, 0x1.fffff00008000p-57, 0x1.ffffffffe0010p-8, -0x1.ffff001000000p-78},
{-0x1.0400000000000p-1, 0x1.0000000000000p-106, 0x1.0000000000400p-1, -0x1.fffff00008000p-57, -0x1.ffffffffe0010p-8, 0x1.ffff001000000p-78},
{-0x1.0400000000000p-1, 0x1.0000000000000p-106, -0x1.0000000000400p-1, 0x1.fffff00008000p-57, -0x1.0200000000200p+0, 0x1.fffff00008000p-57},
{0x1.0000000000001p-1, -0x1.fc0000c004000p-66, 0x1.0000000000200p-1, -0x1.ffe0000200000p-69, 0x1.0000000000100p+0, 0x1.ffdc403ff3fbcp-54},
{0x1.0000000000001p-1, -0x1.fc0000c004000p-66, -0x1.0000000000200p-1, 0x1.ffe0000200000p-69, -0x1.ff000de020060p-45, 0x1.e000000000000p-101},
{-0x1.0000000000001p-1, 0x1.fc0000c004000p-66, 0x1.0000000000200p-1, -0x1.ffe0000200000p-69, 0x1.ff000de020060p-45, -0x1.e000000000000p-101},
{-0x1.0000000000001p-1, 0x1.fc0000c004000p-66, -0x1.0000000000200p-1, 0x1.ffe0000200000p-69, -0x1.0000000000100p+0, -0x1.ffdc403ff3fbcp-54},
{0x1.00000c0000004p-1, -0x1.ff80000800000p-69, 0x1.18003ffff8000p-1, 0x1.ffffff8000000p-67, 0x1.0c0025fffc002p+0, 0x1.801fff7e00000p-67},
{0x1.00000c0000004p-1, -0x1.ff80000800000p-69, -0x1.18003ffff8000p-1, -0x1.ffffff8000000p-67, -0x1.80033fff7ffc0p-5, -0x1.3fefffc100000p-66},
{-0x1.00000c0000004p-1, 0x1.ff80000800000p-69, 0x1.18003ffff8000p-1, 0x1.ffffff8000000p-67, 0x1.80033fff7ffc0p-5, 0x1.3fefffc100000p-66},
{-0x1.00000c0000004p-1, 0x1.ff80000800000p-69, -0x1.18003ffff8000p-1, -0x1.ffffff8000000p-67, -0x1.0c0025fffc002p+0, -0x1.801fff7e00000p-67},
{0x1.1ffff80000040p-1, -0x1.0000000000000p-91, 0x1.000000000fe00p-1, 0x1.ffff7e0003ff8p-57, 0x1.0ffffc0007f20p+0, 0x1.ffff7dffc4000p-57},
{0x1.1ffff80000040p-1, -0x1.0000000000000p-91, -0x1.000000000fe00p-1, -0x1.ffff7e0003ff8p-57, 0x1.ffff7fff023fep-5, 0x1.03ff780100000p-74},
{-0x1.1ffff80000040p-1, 0x1.0000000000000p-91, 0x1.000000000fe00p-1, 0x1.ffff7e0003ff8p-57, -0x1.ffff7fff023fep-5, -0x1.03ff780100000p-74},
{-0x1.1ffff80000040p-1, 0x1.0000000000000p-91, -0x1.000000000fe00p-1, -0x1.ffff7e0003ff8p-57, -0x1.0ffffc0007f20p+0, -0x1.ffff7dffc4000p-57},
{0x1.3fc0000040000p-1, -0x1.fffffff802000p-57, 0x1.fffffffffff00p-1, 0x0.0000000000000p+0, 0x1.9fe000001ff80p+0, -0x1.fffffff802000p-57},
{0x1.3fc0000040000p-1, -0x1.fffffff802000p-57, -0x1.fffffffffff00p-1, 0x0.0000000000000p+0, -0x1.807fffff7fe00p-2, -0x1.fffffff802000p-57},
{-0x1.3fc0000040000p-1, 0x1.fffffff802000p-57, 0x1.fffffffffff00p-1, 0x0.0000000000000p+0, 0x1.807fffff7fe00p-2, 0x1.fffffff802000p-57},
{-0x1.3fc0000040000p-1, 0x1.fffffff802000p-57, -0x1.fffffffffff00p-1, 0x0.0000000000000p+0, -0x1.9fe000001ff80p+0, 0x1.fffffff802000p-57},
{0x1.00000001fffffp-1, 0x1.00001f8000000p-72, 0x1.0000000000200p-1, -0x1.0000000000000p-106, 0x1.0000000100100p+0, -0x1.ffffbffff8200p-54},
{0x1.00000001fffffp-1, 0x1.00001f8000000p-72, -0x1.0000000000200p-1, 0x1.0000000000000p-106, 0x1.ffdff00002000p-33, 0x1.f804000000000p-92},
{-0x1.00000001fffffp-1, -0x1.00001f8000000p-72, 0x1.0000000000200p-1, -0x1.0000000000000p-106, -0x1.ffdff00002000p-33, -0x1.f804000000000p-92},
{-0x1.00000001fffffp-1, -0x1.00001f8000000p-72, -0x1.0000000000200p-1, 0x1.0000000000000p-106, -0x1.0000000100100p+0, 0x1.ffffbffff8200p-54},
{0x1.0000000010000p-1, -0x1.0000000000000p-78, 0x1.1fff010000000p-1, 0x1.ff8c0000007fep-55, 0x1.0fff808008000p+0, 0x1.ff8bfe0000800p-55},
{0x1.0000000010000p-1, -0x1.0000000000000p-78, -0x1.1fff010000000p-1, -0x1.ff8c0000007fep-55, -0x1.fff00fff00008p-5, 0x1.cff7fffe00800p-65},
{-0x1.0000000010000p-1, 0x1.0000000000000p-78, 0x1.1fff010000000p-1, 0x1.ff8c0000007fep-55, 0x1.fff00fff00008p-5, -0x1.cff7fffe00800p-65},
{-0x1.0000000010000p-1, 0x1.0000000000000p-78, -0x1.1fff010000000p-1, -0x1.ff8c0000007fep-55, -0x1.0fff808008000p+0, -0x1.ff8bfe0000800p-55},
{0x1.0000000000002p-1, -0x1.0000000000000p-88, 0x1.0000000000200p-1, -0x1.0000000000000p-86, 0x1.0000000000101p+0, -0x1.4000000000000p-86},
{0x1.0000000000002p-1, -0x1.0000000000000p-88, -0x1.0000000000200p-1, 0x1.0000000000000p-86, -0x1.fdffffffffa00p-45, 0x0.0000000000000p+0},
{-0x1.0000000000002p-1, 0x1.0000000000000p-88, 0x1.0000000000200p-1, -0x1.0000000000000p-86, 0x1.fdffffffffa00p-45, 0x0.0000000000000p+0},
{-0x1.0000000000002p-1, 0x1.0000000000000p-88, -0x1.0000000000200p-1, 0x1.0000000000000p-86, -0x1.0000000000101p+0, 0x1.4000000000000p-86},
{0x1.0000000000002p-1, -0x1.ffff800008000p-68, 0x1.000000003fffep-1, 0x1.f81fc007c0000p-72, 0x1.0000000020000p+0, -0x1.e07d83ff90000p-68},
{0x1.0000000000002p-1, -0x1.ffff800008000p-68, -0x1.000000003fffep-1, -0x1.f81fc007c0000p-72, -0x1.fffe00021f818p-36, 0x1.ffbe000000000p-91},
{-0x1.0000000000002p-1, 0x1.ffff800008000p-68, 0x1.000000003fffep-1, 0x1.f81fc007c0000p-72, 0x1.fffe00021f818p-36, -0x1.ffbe000000000p-91},
{-0x1.0000000000002p-1, 0x1.ffff800008000p-68, -0x1.000000003fffep-1, -0x1.f81fc007c0000p-72, -0x1.0000000020000p+0, 0x1.e07d83ff90000p-68},
{0x1.7ffffffff0000p-1, 0x1.ffff07fffc000p-65, 0x1.000000000ffe0p-1, 0x1.ff0000003c000p-64, 0x1.3fffffffffff0p+0, 0x1.7f7fc2001d000p-63},
{0x1.7ffffffff0000p-1, 0x1.ffff07fffc000p-65, -0x1.000000000ffe0p-1, -0x1.ff0000003c000p-64, 0x1.ffffffff80080p-3, -0x1.fe00f8007c000p-65},
{-0x1.7ffffffff0000p-1, -0x1.ffff07fffc000p-65, 0x1.000000000ffe0p-1, 0x1.ff0000003c000p-64, -0x1.ffffffff80080p-3, 0x1.fe00f8007c000p-65},
{-0x1.7ffffffff0000p-1, -0x1.ffff07fffc000p-65, -0x1.000000000ffe0p-1, -0x1.ff0000003c000p-64, -0x1.3fffffffffff0p+0, -0x1.7f7fc2001d000p-63},
{0x1.00007fff00080p-1, -0x1.ffffff0001000p-66, 0x1.00000000007c0p-1, 0x1.ffffff8000000p-68, 0x1.00003fff80420p+0, -0x1.7fffff2000000p-66},
{0x1.00007fff00080p-1, -0x1.ffffff0001000p-66, -0x1.00000000007c0p-1, -0x1.ffffff8000000p-68, 0x1.fffbfe2ffffb0p-19, 0x1.1fff000000000p-90},
{-0x1.00007fff00080p-1, 0x1.ffffff0001000p-66, 0x1.00000000007c0p-1, 0x1.ffffff8000000p-68, -0x1.fffbfe2ffffb0p-19, -0x1.1fff000000000p-90},
{-0x1.00007fff00080p-1, 0x1.ffffff0001000p-66, -0x1.00000000007c0p-1, -0x1.ffffff8000000p-68, -0x1.00003fff80420p+0, 0x1.7fffff2000000p-66},
{0x1.1fff81ff00000p-1, 0x1.e007ffff00000p-58, 0x1.1ffffffff8000p-1, 0x1.fe001ffffffe0p-57, 0x1.1fffc0ff7c000p+0, 0x1.77020fffbfff0p-56},
{0x1.1fff81ff00000p-1, 0x1.e007ffff00000p-58, -0x1.1ffffffff8000p-1, -0x1.fe001ffffffe0p-57, -0x1.f803e0000437fp-19, -0x1.0003fff000000p-76},
{-0x1.1fff81ff00000p-1, -0x1.e007ffff00000p-58, 0x1.1ffffffff8000p-1, 0x1.fe001ffffffe0p-57, 0x1.f803e0000437fp-19, 0x1.0003fff000000p-76},
{-0x1.1fff81ff00000p-1, -0x1.e007ffff00000p-58, -0x1.1ffffffff8000p-1, -0x1.fe001ffffffe0p-57, -0x1.1fffc0ff7c000p+0, -0x1.77020fffbfff0p-56},
{0x1.0000000000000p-1, 0x1.fffc03fe00700p-62, 0x1.0000000000001p-1, -0x1.fff8060000f34p-56, 0x1.0000000000000p+0, 0x1.8201fa83fdc3ap-54},
{0x1.0000000000000p-1, 0x1.fffc03fe00700p-62, -0x1.0000000000001p-1, 0x1.fff8060000f34p-56, -0x1.7e02027c01c2cp-54, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.fffc03fe00700p-62, 0x1.0000000000001p-1, -0x1.fff8060000f34p-56, 0x1.7e02027c01c2cp-54, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.fffc03fe00700p-62, -0x1.0000000000001p-1, 0x1.fff8060000f34p-56, -0x1.0000000000000p+0, -0x1.8201fa83fdc3ap-54},
{0x1.001ffffc00080p-1, -0x1.fe00000200000p-62, 0x1.0000000001000p-1, -0x1.fe3ffffff0080p-61, 0x1.000ffffe00840p+0, -0x1.7ea0000078000p-60},
{0x1.001ffffc00080p-1, -0x1.fe00000200000p-62, -0x1.0000000001000p-1, 0x1.fe3ffffff0080p-61, 0x1.ffffbff080010p-13, -0x1.8000021ff0000p-70},
{-0x1.001ffffc00080p-1, 0x1.fe00000200000p-62, 0x1.0000000001000p-1, -0x1.fe3ffffff0080p-61, -0x1.ffffbff080010p-13, 0x1.8000021ff0000p-70},
{-0x1.001ffffc00080p-1, 0x1.fe00000200000p-62, -0x1.0000000001000p-1, 0x1.fe3ffffff0080p-61, -0x1.000ffffe00840p+0, 0x1.7ea0000078000p-60},
{0x1.00001fffff800p-1, 0x1.ffffff801ffc0p-60, 0x1.0000000002000p-1, -0x1.0000000000000p-106, 0x1.0000100000c00p+0, 0x1.ffffff801ff80p-60},
{0x1.00001fffff800p-1, 0x1.ffffff801ffc0p-60, -0x1.0000000002000p-1, 0x1.0000000000000p-106, 0x1.ffffd80004000p-21, -0x1.ff80000000000p-86},
{-0x1.00001fffff800p-1, -0x1.ffffff801ffc0p-60, 0x1.0000000002000p-1, -0x1.0000000000000p-106, -0x1.ffffd80004000p-21, 0x1.ff80000000000p-86},
{-0x1.00001fffff800p-1, -0x1.ffffff801ffc0p-60, -0x1.0000000002000p-1, 0x1.0000000000000p-106, -0x1.0000100000c00p+0, -0x1.ffffff801ff80p-60},
{0x1.0000000000000p-1, 0x1.ffff83ffbfff0p-57, 0x1.0000000000000p-1, 0x1.ffffffffe0000p-57, 0x1.0000000000000p+0, 0x1.ffffc1ffcfff8p-56},
{0x1.0000000000000p-1, 0x1.ffff83ffbfff0p-57, -0x1.0000000000000p-1, -0x1.ffffffffe0000p-57, -0x1.f000800400000p-75, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.ffff83ffbfff0p-57, 0x1.0000000000000p-1, 0x1.ffffffffe0000p-57, 0x1.f000800400000p-75, 0x0.0000000000000p+0},
{-0x1.0000000000000p-1, -0x1.ffff83ffbfff0p-57, -0x1.0000000000000p-1, -0x1.ffffffffe0000p-57, -0x1.0000000000000p+0, -0x1.ffffc1ffcfff8p-56},
{0x1.0000000000000p-1, 0x1.fffe7ff3dff00p-62, 0x1.000007f830000p-1, 0x1.fff0000ffe100p-62, 0x1.000003fc18000p+0, 0x1.fff74001ef000p-61},
{0x1.0000000000000p-1, 0x1.fffe7ff3dff00p-62, -0x1.000007f830000p-1, -0x1.fff0000ffe100p-62, -0x1.fe0bffffffffep-23, -0x1.801c1e2000000p-78},
{-0x1.0000000000000p-1, -0x1.fffe7ff3dff00p-62, 0x1.000007f830000p-1, 0x1.fff0000ffe100p-62, 0x1.fe0bffffffffep-23, 0x1.801c1e2000000p-78},
{-0x1.0000000000000p-1, -0x1.fffe7ff3dff00p-62, -0x1.000007f830000p-1, -0x1.fff0000ffe100p-62, -0x1.000003fc18000p+0, -0x1.fff74001ef000p-61},
{0x1.00000ffffe000p-1, 0x1.fffffffffc000p-68, 0x1.0000000000002p-1, -0x1.fffffe01f8004p-56, 0x1.000007ffff001p+0, -0x1.ffdffe01f8008p-56},
{0x1.00000ffffe000p-1, 0x1.fffffffffc000p-68, -0x1.0000000000002p-1, 0x1.fffffe01f8004p-56, 0x1.ffffbffc80080p-22, -0x1.fe08000000000p-80},
{-0x1.00000ffffe000p-1, -0x1.fffffffffc000p-68, 0x1.0000000000002p-1, -0x1.fffffe01f8004p-56, -0x1.ffffbffc80080p-22, 0x1.fe08000000000p-80},
{-0x1.00000ffffe000p-1, -0x1.fffffffffc000p-68, -0x1.0000000000002p-1, 0x1.fffffe01f8004p-56, -0x1.000007ffff001p+0, 0x1.ffdffe01f8008p-56},
{0x1.0000000000060p-1, 0x1.fffe3fff00000p-64, 0x1.0000000002000p-1, -0x1.ffe0002000000p-58, 0x1.0000000001030p+0, -0x1.f7e0072004000p-58},
{0x1.0000000000060p-1, 0x1.fffe3fff00000p-64, -0x1.0000000002000p-1, 0x1.ffe0002000000p-58, -0x1.f9fefc1003700p-41, -0x1.0000000000000p-96},
{-0x1.0000000000060p-1, -0x1.fffe3fff00000p-64, 0x1.0000000002000p-1, -0x1.ffe0002000000p-58, 0x1.f9fefc1003700p-41, 0x1.0000000000000p-96},
{-0x1.0000000000060p-1, -0x1.fffe3fff00000p-64, -0x1.0000000002000p-1, 0x1.ffe0002000000p-58, -0x1.0000000001030p+0, 0x1.f7e0072004000p-58},
{0x1.0003ffffffff8p-1, 0x1.ffffe07e00000p-75, 0x1.07ff000008000p-1, -0x1.e000020000000p-62, 0x1.0401800003ffcp+0, -0x1.dff00200fc000p-62},
{0x1.0003ffffffff8p-1, 0x1.ffffe07e00000p-75, -0x1.07ff000008000p-1, 0x1.e000020000000p-62, -0x1.fec0000200200p-7, 0x1.e01001ff03f00p-62},
{-0x1.0003ffffffff8p-1, -0x1.ffffe07e00000p-75, 0x1.07ff000008000p-1, -0x1.e000020000000p-62, 0x1.fec0000200200p-7, -0x1.e01001ff03f00p-62},
{-0x1.0003ffffffff8p-1, -0x1.ffffe07e00000p-75, -0x1.07ff000008000p-1, 0x1.e000020000000p-62, -0x1.0401800003ffcp+0, 0x1.dff00200fc000p-62},
};
const int numAccuracyTests = sizeof(accuracyTests) / sizeof(struct testVector);
#include <math.h>
double testAccuracy() {
int i;
DD a, b, c, r;
double worstUlps = 0.5;
for (i=0; i<numAccuracyTests; ++i) {
a.hi = accuracyTests[i].xhi;
a.lo = accuracyTests[i].xlo;
b.hi = -accuracyTests[i].yhi;
b.lo = -accuracyTests[i].ylo;
r.hi = accuracyTests[i].rhi;
r.lo = accuracyTests[i].rlo;
DD c = { .ld = __gcc_qsub(a.ld, b.ld) };
double error = __builtin_fabs(((r.hi - c.hi) + r.lo) - c.lo);
if (error != 0.0) {
int exponent = ilogb(r.hi);
exponent = (exponent < -1022 ? -1022 : exponent);
double ulpError = scalbn(error, 106 - exponent);
if (ulpError > worstUlps) {
#ifdef PRINT_ACCURACY_INFORMATION
printf("New worst rounding error for (%a,%a) + (%a,%a):\n", a.hi, a.lo, b.hi, b.lo);
printf("\tExpected: (%a,%a)\n", r.hi, r.lo);
printf("\tComputed: (%a,%a)\n", c.hi, c.lo);
printf("\tError: %f ulps\n", ulpError);
#endif
worstUlps = ulpError;
}
}
}
return worstUlps;
}
|
0d447020bc941d3d7788789f31773e23b75aa800
|
2b4867ce106d3068b67f2244019247df9cf6f341
|
/tests/runner-tests/func/void-pointer.c
|
c3ae8cf50be78ae7ef6775b3a46bd8187c2ef7c6
|
[
"BSD-3-Clause"
] |
permissive
|
jyn514/saltwater
|
d22b29ac40a4e3deb6128d904759d9183f081ab4
|
097c72d30e325de57fbed8a506431754a0560374
|
refs/heads/master
| 2023-05-09T05:44:43.147928
| 2021-06-03T02:53:32
| 2021-06-03T02:53:32
| 190,940,981
| 131
| 25
|
BSD-3-Clause
| 2021-04-07T22:58:39
| 2019-06-08T22:26:45
|
Rust
|
UTF-8
|
C
| false
| false
| 35
|
c
|
void-pointer.c
|
// no-main
int signal(int, void*);
|
cac3801a0d3e1576d7a401a23fdd8f3eba82eba1
|
4d54680efc2f8eb89031096378f46f965ec4753f
|
/src/utils/transcendental.c
|
920b18b443741e9a4449060edb2a2e397a9617cd
|
[
"MIT"
] |
permissive
|
introlab/odas
|
ae7ef5097e4773875ecd467800622b6ddfbca690
|
a07e6276a91c46f14b57b66ef2f28360e50af02d
|
refs/heads/master
| 2023-05-28T10:22:43.365407
| 2023-03-28T18:38:38
| 2023-03-28T18:38:38
| 96,141,583
| 666
| 227
|
MIT
| 2023-05-23T20:51:55
| 2017-07-03T18:57:58
|
C
|
UTF-8
|
C
| false
| false
| 3,398
|
c
|
transcendental.c
|
/**
* \file transcendental.c
* \author François Grondin <francois.grondin2@usherbrooke.ca>
* \version 2.0
* \date 2018-03-18
* \copyright
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <utils/transcendental.h>
transcendental_obj * transcendental_construct_zero(const float minValue, const float maxValue, const unsigned int nElements) {
transcendental_obj * obj;
unsigned int iElement;
float v;
float g;
float intPart;
float fracPart;
const float table[21] = {0.75008f,0.93640f,1.11688f,1.28852f,1.45013f,1.60184f,1.74422f,
1.87812f,2.00448f,2.12417f,2.23799f,2.34656f,2.45053f,2.55031f,
2.64646f,2.73921f,2.82895f,2.91602f,3.00049f,3.08265f,3.16270f};
obj = (transcendental_obj *) malloc(sizeof(transcendental_obj));
obj->minValue = minValue;
obj->maxValue = maxValue;
obj->interval = (maxValue-minValue) / ((float) (nElements-1));
obj->array = (float *) malloc(sizeof(float) * nElements);
memset(obj->array, 0x00, sizeof(float) * nElements);
obj->nElements = nElements;
v = 0.0f;
for (iElement = 0; iElement < nElements; iElement++) {
if (v <= 9.5f) {
intPart = floorf(2.0f * v);
fracPart = 2.0f * v - intPart;
g = ((1-fracPart) * table[((unsigned int) intPart)] + fracPart * table[((unsigned int) intPart) + 1]) / sqrtf(v + 0.0001f);
}
else {
g = 1.0f;
}
obj->array[iElement] = g;
v += obj->interval;
}
return obj;
}
void transcendental_destroy(transcendental_obj * obj) {
free((void *) obj->array);
free((void *) obj);
}
float transcendental_process(const transcendental_obj * obj, const float value) {
signed int iElement;
iElement = ((signed int) floorf(value / obj->interval)) + 1;
if (iElement < 0) {
iElement = 0;
}
if (iElement > (obj->nElements - 1)) {
iElement = obj->nElements - 1;
}
return obj->array[iElement];
}
|
77020cfa2fe0d7dae3927b7aa414f3f4599453fe
|
d169de4c5c6b281984df35536430dcc931a957a9
|
/source/hal/driver/GigaDevice/GD32VF103/common/usb/usb_common.c
|
03a5b6a754e6a3b68edacaa7300d22dc03c4aed7
|
[
"LGPL-2.1-only",
"Apache-2.0"
] |
permissive
|
vsfteam/vsf
|
2ba968ba2ef53b036668019c6c6746149a63c38a
|
522a52ff2ee4ed149b52789a5bd366f80c08c458
|
refs/heads/master
| 2023-08-27T07:32:08.339123
| 2023-08-26T17:46:07
| 2023-08-26T17:46:07
| 181,911,464
| 273
| 83
|
Apache-2.0
| 2023-08-29T03:08:36
| 2019-04-17T14:43:42
|
C
|
UTF-8
|
C
| false
| false
| 3,315
|
c
|
usb_common.c
|
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* 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. *
* *
****************************************************************************/
/*============================ INCLUDES ======================================*/
//#include "../common.h"
#include "./usb.h"
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/
/*============================ IMPLEMENTATION ================================*/
vsf_err_t gd32vf103_usb_init(gd32vf103_usb_t *usb, vsf_arch_prio_t priority)
{
struct dwcotg_core_global_regs_t *global_regs;
const gd32vf103_usb_const_t *param = usb->param;
uint_fast32_t usbfs_prescaler;
// TODO: get real ckpll_clock
uint_fast32_t ckpll_clock = 96000000;
if (ckpll_clock == 48000000) {
usbfs_prescaler = RCU_CKUSB_CKPLL_DIV1;
} else if (ckpll_clock == 72000000) {
usbfs_prescaler = RCU_CKUSB_CKPLL_DIV1_5;
} else if (ckpll_clock == 96000000) {
usbfs_prescaler = RCU_CKUSB_CKPLL_DIV2;
} else if (ckpll_clock == 120000000) {
usbfs_prescaler = RCU_CKUSB_CKPLL_DIV2_5;
} else {
VSF_HAL_ASSERT(false);
}
rcu_usb_clock_config(usbfs_prescaler);
rcu_periph_clock_enable(RCU_USBFS);
global_regs = param->reg;
global_regs->gahbcfg &= ~USB_OTG_GAHBCFG_GINT;
if (priority != vsf_arch_prio_invalid) {
eclic_set_irq_lvl(param->irq, priority << (8 - VSF_ARCH_PRI_BIT));
eclic_enable_interrupt(param->irq);
} else {
eclic_disable_interrupt(param->irq);
}
return VSF_ERR_NONE;
}
void gd32vf103_usb_irq(gd32vf103_usb_t *usb)
{
if (usb->callback.irqhandler != NULL) {
usb->callback.irqhandler(usb->callback.param);
}
}
|
8a693b48f8e4cb46ab52644c1986773d8f246976
|
1f17f2d91e294cafeb5ae70ad9892786ca2a5fb9
|
/EmbeddedLapack/src/LinearAlgebra/quadprog.c
|
ca1afaa70d98e0a1c905539decd05e14ddd17889
|
[
"MIT"
] |
permissive
|
DanielMartensson/EmbeddedLapack
|
d0fad48a18a8eb2fe5489a09a3d38d50caff8360
|
904eabec28a6eaf2b1288f882b3f711b94bbf256
|
refs/heads/master
| 2023-08-13T08:11:41.781481
| 2023-07-31T01:11:39
| 2023-07-31T01:11:39
| 165,274,437
| 115
| 24
|
MIT
| 2020-12-06T19:47:18
| 2019-01-11T16:27:57
|
C
|
UTF-8
|
C
| false
| false
| 1,148
|
c
|
quadprog.c
|
/*
* quadprog.c
*
* Created on: 28 oct. 2019
* Author: Daniel Mårtensson
*/
#include "declareFunctions.h"
/*
* This will minimize
* 1/2*u^THu + g^Tu
*
* With S.t
* ulb_vec <= u <= uub_vec
* ylb_vec <= Au <= yub_vec
*
* H is a hessian(symmetric) positive positive semidefinite matrix
*
* Notice that if you want to solve Ax = b with constraints, just set
* H = A^T*A
* g = A^T*b
*
* Set nWSR to a number > 0 so QP can do its sets
* Set SHOW_QP_OUTPUT to TRUE to begin with in declareFunctions.h
* I recommend to read the qpOASES_e manual
*/
void quadprog(double* H, double* g, double* A, double* ulb_vec, double* uub_vec, double* ylb_vec, double* yub_vec, int* nWSR, double* u, int columnH, int rowA) {
// Setting up QProblem object J = U^T*H*U + g^T*U
QProblem objective;
Options options;
int nV = columnH;
int nC = rowA;
QProblemCON(&objective, nV, nC, HST_UNKNOWN);
Options_setToDefault(&options);
QProblem_setOptions(&objective, options);
// Solve
QProblem_init(&objective, H, g, A, ulb_vec, uub_vec, ylb_vec, yub_vec, nWSR, 0);
// Get the u
QProblem_getPrimalSolution(&objective, u);
}
|
b0fd278eb0a2e4bafd003d62fad7b9065e2030f1
|
f4ac515f7d98202ca2a05c2036373eeef8e78916
|
/src/collision/unary.cc
|
b0964a79870c8ae3f231d62f075f3ffef96d2f1f
|
[
"BSD-3-Clause"
] |
permissive
|
lanl/vpic
|
b5b52de384292985f4d9f98147ccc63108018799
|
5d1aa3cceac48c5ff36e131cd26c89a85b118d75
|
refs/heads/master
| 2023-04-11T22:08:48.789627
| 2023-02-16T15:55:15
| 2023-02-16T15:55:15
| 51,323,352
| 136
| 76
|
NOASSERTION
| 2023-02-16T15:55:17
| 2016-02-08T20:04:21
|
C++
|
UTF-8
|
C
| false
| false
| 3,256
|
cc
|
unary.cc
|
#define IN_collision
#include "unary.h"
/* Private interface *********************************************************/
//----------------------------------------------------------------------------//
// Top level function to select and call proper apply_unary_collision_model
// function.
//----------------------------------------------------------------------------//
void
apply_unary_collision_model( unary_collision_model_t * cm )
{
if ( cm->interval < 1 ||
( cm->sp->g->step % cm->interval ) )
{
return;
}
// Conditionally execute this when more abstractions are available.
apply_unary_collision_model_pipeline( cm );
}
void
checkpt_unary_collision_model( const collision_op_t * cop )
{
const unary_collision_model_t * cm =
( const unary_collision_model_t * ) cop->params;
CHECKPT( cm, 1 );
CHECKPT_STR( cm->name );
CHECKPT_SYM( cm->rate_constant );
CHECKPT_SYM( cm->collision );
CHECKPT_PTR( cm->params );
CHECKPT_PTR( cm->sp );
CHECKPT_PTR( cm->rp );
checkpt_collision_op_internal( cop );
}
collision_op_t *
restore_unary_collision_model( void )
{
unary_collision_model_t * cm;
RESTORE( cm );
RESTORE_STR( cm->name );
RESTORE_SYM( cm->rate_constant );
RESTORE_SYM( cm->collision );
RESTORE_PTR( cm->params );
RESTORE_PTR( cm->sp );
RESTORE_PTR( cm->rp );
return restore_collision_op_internal( cm );
}
void
delete_unary_collision_model( collision_op_t * cop )
{
unary_collision_model_t * cm = ( unary_collision_model_t * ) cop->params;
FREE( cm->name );
FREE( cm );
delete_collision_op_internal( cop );
}
/* Public interface **********************************************************/
collision_op_t *
unary_collision_model( const char * RESTRICT name,
unary_rate_constant_func_t rate_constant,
unary_collision_func_t collision,
void * RESTRICT params,
species_t * RESTRICT sp,
rng_pool_t * RESTRICT rp,
int interval )
{
unary_collision_model_t * cm;
size_t len = name ? strlen(name) : 0;
if ( !rate_constant ||
!collision ||
!sp ||
!rp ||
rp->n_rng < N_PIPELINE )
{
ERROR( ( "Bad args" ) );
}
if ( !len )
{
ERROR( ( "Cannot specify a nameless collision model." ) );
}
if ( params &&
!object_id( params ) )
{
ERROR( ( "collision model parameters must be checkpoint registered." ) );
}
MALLOC( cm, 1 );
MALLOC( cm->name, len+1 );
strcpy( cm->name, name );
cm->rate_constant = rate_constant;
cm->collision = collision;
cm->params = params;
cm->sp = sp;
cm->rp = rp;
cm->interval = interval;
return new_collision_op_internal( cm,
( collision_op_func_t ) apply_unary_collision_model,
delete_unary_collision_model,
( checkpt_func_t ) checkpt_unary_collision_model,
( restore_func_t ) restore_unary_collision_model,
NULL );
}
|
f8cd5540216dd0d0eeaa7b64a1d446d04d101301
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/sys/dev/usb/if_runvar.h
|
28ec1eaf70856506715895a8d24087c6c0b79e7e
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 4,932
|
h
|
if_runvar.h
|
/* $OpenBSD: if_runvar.h,v 1.13 2020/11/27 14:45:03 krw Exp $ */
/*-
* Copyright (c) 2008,2009 Damien Bergamini <damien.bergamini@free.fr>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define RUN_MAX_RXSZ \
4096
#if 0
(sizeof (uint32_t) + \
sizeof (struct rt2860_rxwi) + \
sizeof (uint16_t) + \
MCLBYTES + \
sizeof (struct rt2870_rxd))
#endif
/* NB: "11" is the maximum number of padding bytes needed for Tx */
#define RUN_MAX_TXSZ \
(sizeof (struct rt2870_txd) + \
sizeof (struct rt2860_txwi) + \
MCLBYTES + 11)
#define RUN_TX_TIMEOUT 5000 /* ms */
#define RUN_RX_RING_COUNT 1
#define RUN_TX_RING_COUNT 8
#define RT2870_WCID_MAX 64
#define RUN_AID2WCID(aid) ((aid) & 0xff)
struct run_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
uint8_t wr_flags;
uint8_t wr_rate;
uint16_t wr_chan_freq;
uint16_t wr_chan_flags;
uint8_t wr_dbm_antsignal;
uint8_t wr_antenna;
uint8_t wr_antsignal;
} __packed;
#define RUN_RX_RADIOTAP_PRESENT \
(1 << IEEE80211_RADIOTAP_FLAGS | \
1 << IEEE80211_RADIOTAP_RATE | \
1 << IEEE80211_RADIOTAP_CHANNEL | \
1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \
1 << IEEE80211_RADIOTAP_ANTENNA | \
1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)
struct run_tx_radiotap_header {
struct ieee80211_radiotap_header wt_ihdr;
uint8_t wt_flags;
uint8_t wt_rate;
uint16_t wt_chan_freq;
uint16_t wt_chan_flags;
} __packed;
#define RUN_TX_RADIOTAP_PRESENT \
(1 << IEEE80211_RADIOTAP_FLAGS | \
1 << IEEE80211_RADIOTAP_RATE | \
1 << IEEE80211_RADIOTAP_CHANNEL)
struct run_softc;
struct run_tx_data {
struct run_softc *sc;
struct usbd_xfer *xfer;
uint8_t *buf;
uint8_t qid;
};
struct run_rx_data {
struct run_softc *sc;
struct usbd_xfer *xfer;
uint8_t *buf;
};
struct run_tx_ring {
struct run_tx_data data[RUN_TX_RING_COUNT];
struct usbd_pipe *pipeh;
int cur;
int queued;
uint8_t pipe_no;
};
struct run_rx_ring {
struct run_rx_data data[RUN_RX_RING_COUNT];
struct usbd_pipe *pipeh;
uint8_t pipe_no;
};
struct run_host_cmd {
void (*cb)(struct run_softc *, void *);
uint8_t data[256];
};
struct run_cmd_newstate {
enum ieee80211_state state;
int arg;
};
struct run_cmd_key {
struct ieee80211_key key;
struct ieee80211_node *ni;
};
#define RUN_HOST_CMD_RING_COUNT 32
struct run_host_cmd_ring {
struct run_host_cmd cmd[RUN_HOST_CMD_RING_COUNT];
int cur;
int next;
int queued;
};
struct run_node {
struct ieee80211_node ni;
uint8_t ridx[IEEE80211_RATE_MAXSIZE];
uint8_t ctl_ridx[IEEE80211_RATE_MAXSIZE];
};
struct run_softc {
struct device sc_dev;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);
int (*sc_srom_read)(struct run_softc *,
uint16_t, uint16_t *);
struct usbd_device *sc_udev;
struct usbd_interface *sc_iface;
uint16_t mac_ver;
uint16_t mac_rev;
uint16_t rf_rev;
uint8_t freq;
uint8_t ntxchains;
uint8_t nrxchains;
int fixed_ridx;
uint8_t bbp25;
uint8_t bbp26;
uint8_t rf24_20mhz;
uint8_t rf24_40mhz;
uint8_t patch_dac;
uint8_t rfswitch;
uint8_t ext_2ghz_lna;
uint8_t ext_5ghz_lna;
uint8_t calib_2ghz;
uint8_t calib_5ghz;
uint8_t txmixgain_2ghz;
uint8_t txmixgain_5ghz;
int8_t txpow1[54];
int8_t txpow2[54];
int8_t txpow3[54];
int8_t rssi_2ghz[3];
int8_t rssi_5ghz[3];
uint8_t lna[4];
struct {
uint8_t reg;
uint8_t val;
} bbp[10], rf[10];
uint8_t leds;
uint16_t led[3];
uint32_t txpow20mhz[5];
uint32_t txpow40mhz_2ghz[5];
uint32_t txpow40mhz_5ghz[5];
struct usb_task sc_task;
struct ieee80211_amrr amrr;
struct ieee80211_amrr_node amn;
struct timeout scan_to;
struct timeout calib_to;
struct run_rx_ring rxq;
struct run_tx_ring txq[4];
struct run_host_cmd_ring cmdq;
uint8_t qfullmsk;
int sc_tx_timer;
#if NBPFILTER > 0
caddr_t sc_drvbpf;
union {
struct run_rx_radiotap_header th;
uint8_t pad[64];
} sc_rxtapu;
#define sc_rxtap sc_rxtapu.th
int sc_rxtap_len;
union {
struct run_tx_radiotap_header th;
uint8_t pad[64];
} sc_txtapu;
#define sc_txtap sc_txtapu.th
int sc_txtap_len;
#endif
int sc_key_tasks;
};
|
d2cdcac9899bf9ca2a436825ea211e0bdea4c95b
|
dcbef06d5a00f07756339b9e62c684dec2fee425
|
/nuitka/build/static_src/HelpersOperationBinaryAddUtils.c
|
cab30373a546cfb6775b9a9bb63073a885cb1c05
|
[
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
Nuitka/Nuitka
|
f9543d8d95bfa0b81d4e60af0dfad99fb72893a4
|
d87faf2f7e1d6ed9bfe4cf8c1d648f34307e33f2
|
refs/heads/develop
| 2023-08-28T14:00:32.861328
| 2023-08-27T09:16:45
| 2023-08-27T09:16:45
| 9,626,741
| 8,573
| 599
|
Apache-2.0
| 2023-09-13T02:49:41
| 2013-04-23T15:40:33
|
Python
|
UTF-8
|
C
| false
| false
| 16,700
|
c
|
HelpersOperationBinaryAddUtils.c
|
// Copyright 2023, Kay Hayen, mailto:kay.hayen@gmail.com
//
// Part of "Nuitka", an optimizing Python compiler that is compatible and
// integrates with CPython, but also works on its own.
//
// 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.
//
/* These slots are still manually coded and are used by the generated code.
*
* The plan should be to generate these as well, so e.g. we can have a slot
* SLOT_nb_add_LONG_INT that is optimal too.
*/
// This file is included from another C file, help IDEs to still parse it on
// its own.
#ifdef __IDE_ONLY__
#include "nuitka/prelude.h"
#endif
static PyObject *LIST_CONCAT(PyObject *operand1, PyObject *operand2) {
CHECK_OBJECT(operand1);
assert(PyList_CheckExact(operand1));
CHECK_OBJECT(operand2);
assert(PyList_CheckExact(operand2));
Py_ssize_t size = Py_SIZE(operand1) + Py_SIZE(operand2);
PyListObject *result = (PyListObject *)MAKE_LIST_EMPTY(size);
if (unlikely(result == NULL)) {
return NULL;
}
PyObject **src = ((PyListObject *)operand1)->ob_item;
PyObject **dest = result->ob_item;
for (Py_ssize_t i = 0; i < Py_SIZE(operand1); i++) {
PyObject *v = src[i];
Py_INCREF(v);
dest[i] = v;
}
src = ((PyListObject *)operand2)->ob_item;
dest = result->ob_item + Py_SIZE(operand1);
for (Py_ssize_t i = 0; i < Py_SIZE(operand2); i++) {
PyObject *v = src[i];
Py_INCREF(v);
dest[i] = v;
}
return (PyObject *)result;
}
// Convert single digit to sdigit (int32_t)
#define MEDIUM_VALUE(x) \
(Py_SIZE(x) < 0 ? -(sdigit)((PyLongObject *)(x))->ob_digit[0] \
: (Py_SIZE(x) == 0 ? (sdigit)0 : (sdigit)((PyLongObject *)(x))->ob_digit[0]))
// Needed for offsetof
#include <stddef.h>
#define MAX_LONG_DIGITS ((PY_SSIZE_T_MAX - offsetof(PyLongObject, ob_digit)) / sizeof(digit))
#define Nuitka_LongGetDigitPointer(value) (&(((PyLongObject *)value)->ob_digit[0]))
#define Nuitka_LongGetDigitSize(value) (Py_ABS(Py_SIZE(value)))
// Our version of _PyLong_New(size);
static PyLongObject *Nuitka_LongNew(Py_ssize_t size) {
assert(size < (Py_ssize_t)MAX_LONG_DIGITS);
#if PYTHON_VERSION >= 0x300
PyLongObject *result;
result = (PyLongObject *)PyObject_MALLOC(offsetof(PyLongObject, ob_digit) + size * sizeof(digit));
return (PyLongObject *)PyObject_INIT_VAR(result, &PyLong_Type, size);
#else
return (PyLongObject *)PyObject_NEW_VAR(PyLongObject, &PyLong_Type, size);
#endif
}
static PyObject *Nuitka_LongRealloc(PyObject *value, Py_ssize_t size) {
PyLongObject *result = Nuitka_LongNew(size);
Py_SET_SIZE(result, size);
Py_DECREF(value);
return (PyObject *)result;
}
static PyObject *Nuitka_LongFromCLong(long ival) {
#if PYTHON_VERSION < 0x300
if (ival == 0) {
PyLongObject *result = Nuitka_LongNew(0);
return (PyObject *)result;
}
#else
if (ival >= NUITKA_STATIC_SMALLINT_VALUE_MIN && ival < NUITKA_STATIC_SMALLINT_VALUE_MAX) {
PyObject *result = Nuitka_Long_GetSmallValue(ival);
Py_INCREF(result);
return result;
}
#endif
// We go via unsigned long to avoid overflows when shifting and we need
// the sign separate in the end anyway.
unsigned long abs_ival;
bool negative;
if (ival < 0) {
abs_ival = 0U - (unsigned long)ival;
negative = true;
} else {
abs_ival = (unsigned long)ival;
negative = false;
}
// Fast path for single digit values
if (!(abs_ival >> PyLong_SHIFT)) {
PyLongObject *result = Nuitka_LongNew(1);
assert(result != NULL);
if (negative) {
Py_SET_SIZE(result, -1);
}
result->ob_digit[0] = (digit)abs_ival;
return (PyObject *)result;
}
// Fast path for two digit values on suitable platforms.
#if PyLong_SHIFT == 15
if (!(abs_ival >> 2 * PyLong_SHIFT)) {
PyLongObject *result = Nuitka_LongNew(2);
assert(result != NULL);
if (negative) {
Py_SIZE(result) = -2;
}
result->ob_digit[0] = (digit)(abs_ival & PyLong_MASK);
result->ob_digit[1] = (digit)(abs_ival >> PyLong_SHIFT);
return (PyObject *)result;
}
#endif
// Slow path for the rest.
unsigned long t = abs_ival;
Py_ssize_t ndigits = 0;
// First determine the number of digits needed.
while (t != 0) {
++ndigits;
t >>= PyLong_SHIFT;
}
PyLongObject *result = _PyLong_New(ndigits);
assert(result != NULL);
Py_SET_SIZE(result, negative ? -ndigits : ndigits);
digit *d = result->ob_digit;
// Now copy the digits
t = abs_ival;
while (t != 0) {
*d++ = (digit)(t & PyLong_MASK);
t >>= PyLong_SHIFT;
}
return (PyObject *)result;
}
static void Nuitka_LongUpdateFromCLong(PyObject **value, long ival) {
assert(Py_REFCNT(*value) == 1);
#if PYTHON_VERSION < 0x300
if (ival == 0) {
if (Py_SIZE(*value) == 0) {
return;
}
Py_DECREF(*value);
*value = (PyObject *)Nuitka_LongNew(0);
return;
}
#else
if (ival >= NUITKA_STATIC_SMALLINT_VALUE_MIN && ival < NUITKA_STATIC_SMALLINT_VALUE_MAX) {
Py_DECREF(*value);
*value = Nuitka_Long_GetSmallValue(ival);
Py_INCREF(*value);
return;
}
#endif
// We go via unsigned long to avoid overflows when shifting and we need
// the sign separate in the end anyway.
unsigned long abs_ival;
bool negative;
if (ival < 0) {
abs_ival = 0U - (unsigned long)ival;
negative = true;
} else {
abs_ival = (unsigned long)ival;
negative = false;
}
// Fast path for single digit values
if (!(abs_ival >> PyLong_SHIFT)) {
PyLongObject *result;
if (unlikely(Py_SIZE(*value) == 0)) {
*value = Nuitka_LongRealloc(*value, 1);
CHECK_OBJECT(*value);
result = (PyLongObject *)*value;
} else {
result = (PyLongObject *)(*value);
}
Py_SET_SIZE(result, negative ? -1 : 1);
result->ob_digit[0] = (digit)abs_ival;
return;
}
// Fast path for two digit values on suitable platforms, e.g. armv7l
#if PyLong_SHIFT == 15
if (!(abs_ival >> 2 * PyLong_SHIFT)) {
PyLongObject *result;
if (unlikely(Py_ABS(Py_SIZE(*value)) < 2)) {
*value = Nuitka_LongRealloc(*value, 2);
CHECK_OBJECT(*value);
result = (PyLongObject *)*value;
} else {
result = (PyLongObject *)(*value);
}
Py_SIZE(result) = negative ? -2 : 2;
result->ob_digit[0] = (digit)(abs_ival & PyLong_MASK);
result->ob_digit[1] = (digit)(abs_ival >> PyLong_SHIFT);
return;
}
#endif
// Slow path for the rest.
unsigned long t = abs_ival;
Py_ssize_t ndigits = 0;
// First determine the number of digits needed.
while (t != 0) {
ndigits++;
t >>= PyLong_SHIFT;
}
if (unlikely(Py_ABS(Py_SIZE(*value)) < ndigits)) {
*value = Nuitka_LongRealloc(*value, ndigits);
}
CHECK_OBJECT(*value);
Py_SET_SIZE(*value, negative ? -ndigits : ndigits);
digit *d = ((PyLongObject *)(*value))->ob_digit;
// Now copy the digits
t = abs_ival;
while (t) {
*d++ = (digit)(t & PyLong_MASK);
t >>= PyLong_SHIFT;
}
return;
}
#if 0
// Note: We are manually inlining this so far.
static PyLongObject *Nuitka_LongStripZeros(PyLongObject *v) {
Py_ssize_t j = Py_ABS(Py_SIZE(v));
Py_ssize_t i = j;
while (i > 0 && v->ob_digit[i - 1] == 0) {
i -= 1;
}
if (i != j) {
Py_SIZE(v) = (Py_SIZE(v) < 0) ? -i : i;
}
return v;
}
#endif
static PyLongObject *_Nuitka_LongAddDigits(digit const *a, Py_ssize_t size_a, digit const *b, Py_ssize_t size_b) {
// Make sure we know a is the longest value.
if (size_a < size_b) {
{
digit const *temp = a;
a = b;
b = temp;
}
{
Py_ssize_t temp = size_a;
size_a = size_b;
size_b = temp;
}
}
// We do not know ahead of time, if we need a new digit, lets just allocate it.
PyLongObject *result = Nuitka_LongNew(size_a + 1);
CHECK_OBJECT(result);
digit *r = &result->ob_digit[0];
digit carry = 0;
// First common digits.
Py_ssize_t i;
for (i = 0; i < size_b; i++) {
carry += a[i] + b[i];
r[i] = carry & PyLong_MASK;
carry >>= PyLong_SHIFT;
}
// Digits from longest one only.
for (; i < size_a; i++) {
carry += a[i];
r[i] = carry & PyLong_MASK;
carry >>= PyLong_SHIFT;
}
// Only the top digit can be zero, so we can strip this faster.
if (carry) {
r[i] = carry;
} else {
Py_SET_SIZE(result, Py_SIZE(result) - 1);
}
return result;
}
static PyObject *_Nuitka_LongAddInplaceDigits(PyObject *left, digit const *b, Py_ssize_t size_b) {
digit const *a = Nuitka_LongGetDigitPointer(left);
Py_ssize_t size_a = Nuitka_LongGetDigitSize(left);
digit const *aa = a;
digit const *bb = b;
// Make sure we know aa is the longest value by swapping a/b attributes.
if (size_a < size_b) {
{
aa = b;
bb = a;
}
{
Py_ssize_t temp = size_a;
size_a = size_b;
size_b = temp;
}
}
digit carry = 0;
// First common digits.
Py_ssize_t i;
for (i = 0; i < size_b; i++) {
carry += aa[i] + bb[i];
carry >>= PyLong_SHIFT;
}
// Digits from longest one only might cause a new digit through carry.
Py_ssize_t needed = size_a;
for (; i < size_a; i++) {
carry += aa[i];
carry >>= PyLong_SHIFT;
// No more carry, that means size cannot increase.
if (carry == 0) {
break;
}
}
// Final digit needs to be added.
if (carry) {
needed = i + 1;
}
// Need to keep the old value around, or else we commit use after free potentially.
PyObject *old = left;
if (needed > Nuitka_LongGetDigitSize(left)) {
left = (PyObject *)Nuitka_LongNew(needed);
} else {
Py_INCREF(old);
}
digit *r = Nuitka_LongGetDigitPointer(left);
// Now do the real thing, with actual storage to left digits.
carry = 0;
// First common digits.
for (i = 0; i < size_b; i++) {
carry += aa[i] + bb[i];
r[i] = carry & PyLong_MASK;
carry >>= PyLong_SHIFT;
}
// Digits from longest one only.
for (; i < size_a; i++) {
carry += aa[i];
r[i] = carry & PyLong_MASK;
carry >>= PyLong_SHIFT;
}
// Final digit from the carry.
if (carry != 0) {
r[i] = carry;
Py_SET_SIZE(left, i + 1);
} else {
Py_SET_SIZE(left, i);
}
// Release reference to old value
Py_DECREF(old);
return left;
}
static PyLongObject *_Nuitka_LongSubDigits(digit const *a, Py_ssize_t size_a, digit const *b, Py_ssize_t size_b) {
// Sign of the result.
int sign = 1;
// Make sure we know a is the largest value.
if (size_a < size_b) {
sign = -1;
{
digit const *temp = a;
a = b;
b = temp;
}
{
Py_ssize_t temp = size_a;
size_a = size_b;
size_b = temp;
}
} else if (size_a == size_b) {
// Find highest digit where a and b differ:
Py_ssize_t i = size_a;
while (--i >= 0 && a[i] == b[i]) {
}
if (i < 0) {
#if PYTHON_VERSION < 0x300
return (PyLongObject *)Nuitka_LongFromCLong(0);
#else
// For Python3, we have this prepared.
PyObject *result = Nuitka_Long_GetSmallValue(0);
Py_INCREF(result);
return (PyLongObject *)result;
#endif
}
if (a[i] < b[i]) {
sign = -1;
{
digit const *temp = a;
a = b;
b = temp;
}
}
size_a = size_b = i + 1;
}
PyLongObject *result = Nuitka_LongNew(size_a);
CHECK_OBJECT(result);
digit *r = &result->ob_digit[0];
digit borrow = 0;
Py_ssize_t i;
// First common digits.
for (i = 0; i < size_b; i++) {
borrow = a[i] - b[i] - borrow;
r[i] = borrow & PyLong_MASK;
borrow >>= PyLong_SHIFT;
borrow &= 1;
}
// Digits from largest one only.
for (; i < size_a; i++) {
borrow = a[i] - borrow;
r[i] = borrow & PyLong_MASK;
borrow >>= PyLong_SHIFT;
borrow &= 1;
}
assert(borrow == 0);
// Strip leading zeros.
while (i > 0 && r[i - 1] == 0) {
i -= 1;
}
Py_SET_SIZE(result, (sign < 0) ? -i : i);
#if PYTHON_VERSION >= 0x300
// Normalize small integers.
if (i <= 1) {
long ival = MEDIUM_VALUE(result);
if (ival >= NUITKA_STATIC_SMALLINT_VALUE_MIN && ival < NUITKA_STATIC_SMALLINT_VALUE_MAX) {
Py_DECREF(result);
result = (PyLongObject *)Nuitka_Long_GetSmallValue(ival);
Py_INCREF(result);
}
}
#endif
return result;
}
static PyObject *_Nuitka_LongSubInplaceDigits(PyObject *left, digit const *b, Py_ssize_t size_b, int sign) {
digit const *a = Nuitka_LongGetDigitPointer(left);
Py_ssize_t size_a = Nuitka_LongGetDigitSize(left);
digit const *aa = a;
digit const *bb = b;
// Make sure we know a is the largest value.
if (size_a < size_b) {
// Invert the sign of the result by swapping the order.
sign *= -1;
{
aa = b;
bb = a;
}
{
Py_ssize_t temp = size_a;
size_a = size_b;
size_b = temp;
}
} else if (size_a == size_b) {
// Find highest digit where a and b differ:
Py_ssize_t i = size_a;
while (--i >= 0 && a[i] == b[i]) {
}
// TODO: This will benefit a lot by being in a template.
if (i < 0) {
#if PYTHON_VERSION < 0x300
PyObject *r = const_long_0;
#else
PyObject *r = Nuitka_Long_GetSmallValue(0);
#endif
Py_INCREF(r);
Py_DECREF(left);
return r;
}
if (aa[i] < bb[i]) {
sign *= -1;
{
aa = b;
bb = a;
}
}
size_a = size_b = i + 1;
}
Py_ssize_t needed = size_a;
// Need to keep the old value around, or else we commit use after free potentially.
PyObject *old = left;
if (needed > Nuitka_LongGetDigitSize(left)) {
left = (PyObject *)Nuitka_LongNew(needed);
} else {
Py_INCREF(old);
}
digit *r = Nuitka_LongGetDigitPointer(left);
digit borrow = 0;
Py_ssize_t i;
// First common digits.
for (i = 0; i < size_b; i++) {
borrow = aa[i] - bb[i] - borrow;
r[i] = borrow & PyLong_MASK;
borrow >>= PyLong_SHIFT;
borrow &= 1;
}
// Digits from largest one only.
for (; i < size_a; i++) {
borrow = aa[i] - borrow;
r[i] = borrow & PyLong_MASK;
borrow >>= PyLong_SHIFT;
borrow &= 1;
}
assert(borrow == 0);
// Strip leading zeros.
while (i > 0 && r[i - 1] == 0) {
i -= 1;
}
Py_SET_SIZE(left, (sign < 0) ? -i : i);
// Release reference to old value
Py_DECREF(old);
#if PYTHON_VERSION >= 0x300
// Normalize small integers.
if (i <= 1) {
long ival = MEDIUM_VALUE(left);
if (ival >= NUITKA_STATIC_SMALLINT_VALUE_MIN && ival < NUITKA_STATIC_SMALLINT_VALUE_MAX) {
Py_DECREF(left);
left = Nuitka_Long_GetSmallValue(ival);
Py_INCREF(left);
}
}
#endif
return left;
}
|
0c51062c5e9918267b9576a4ef42754a5fa5efd1
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/s390/kvm/kvm-s390.c
|
412fbc5dc688be09a94ce3bcf4230a440e74eeb3
|
[
"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
| 26,960
|
c
|
kvm-s390.c
|
/*
* hosting zSeries kernel virtual machines
*
* Copyright IBM Corp. 2008, 2009
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2 only)
* as published by the Free Software Foundation.
*
* Author(s): Carsten Otte <cotte@de.ibm.com>
* Christian Borntraeger <borntraeger@de.ibm.com>
* Heiko Carstens <heiko.carstens@de.ibm.com>
* Christian Ehrhardt <ehrhardt@de.ibm.com>
*/
#include <linux/compiler.h>
#include <linux/err.h>
#include <linux/fs.h>
#include <linux/hrtimer.h>
#include <linux/init.h>
#include <linux/kvm.h>
#include <linux/kvm_host.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <asm/asm-offsets.h>
#include <asm/lowcore.h>
#include <asm/pgtable.h>
#include <asm/nmi.h>
#include <asm/switch_to.h>
#include <asm/sclp.h>
#include "kvm-s390.h"
#include "gaccess.h"
#define CREATE_TRACE_POINTS
#include "trace.h"
#include "trace-s390.h"
#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
struct kvm_stats_debugfs_item debugfs_entries[] = {
{ "userspace_handled", VCPU_STAT(exit_userspace) },
{ "exit_null", VCPU_STAT(exit_null) },
{ "exit_validity", VCPU_STAT(exit_validity) },
{ "exit_stop_request", VCPU_STAT(exit_stop_request) },
{ "exit_external_request", VCPU_STAT(exit_external_request) },
{ "exit_external_interrupt", VCPU_STAT(exit_external_interrupt) },
{ "exit_instruction", VCPU_STAT(exit_instruction) },
{ "exit_program_interruption", VCPU_STAT(exit_program_interruption) },
{ "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) },
{ "instruction_lctlg", VCPU_STAT(instruction_lctlg) },
{ "instruction_lctl", VCPU_STAT(instruction_lctl) },
{ "deliver_emergency_signal", VCPU_STAT(deliver_emergency_signal) },
{ "deliver_external_call", VCPU_STAT(deliver_external_call) },
{ "deliver_service_signal", VCPU_STAT(deliver_service_signal) },
{ "deliver_virtio_interrupt", VCPU_STAT(deliver_virtio_interrupt) },
{ "deliver_stop_signal", VCPU_STAT(deliver_stop_signal) },
{ "deliver_prefix_signal", VCPU_STAT(deliver_prefix_signal) },
{ "deliver_restart_signal", VCPU_STAT(deliver_restart_signal) },
{ "deliver_program_interruption", VCPU_STAT(deliver_program_int) },
{ "exit_wait_state", VCPU_STAT(exit_wait_state) },
{ "instruction_stidp", VCPU_STAT(instruction_stidp) },
{ "instruction_spx", VCPU_STAT(instruction_spx) },
{ "instruction_stpx", VCPU_STAT(instruction_stpx) },
{ "instruction_stap", VCPU_STAT(instruction_stap) },
{ "instruction_storage_key", VCPU_STAT(instruction_storage_key) },
{ "instruction_stsch", VCPU_STAT(instruction_stsch) },
{ "instruction_chsc", VCPU_STAT(instruction_chsc) },
{ "instruction_stsi", VCPU_STAT(instruction_stsi) },
{ "instruction_stfl", VCPU_STAT(instruction_stfl) },
{ "instruction_tprot", VCPU_STAT(instruction_tprot) },
{ "instruction_sigp_sense", VCPU_STAT(instruction_sigp_sense) },
{ "instruction_sigp_sense_running", VCPU_STAT(instruction_sigp_sense_running) },
{ "instruction_sigp_external_call", VCPU_STAT(instruction_sigp_external_call) },
{ "instruction_sigp_emergency", VCPU_STAT(instruction_sigp_emergency) },
{ "instruction_sigp_stop", VCPU_STAT(instruction_sigp_stop) },
{ "instruction_sigp_set_arch", VCPU_STAT(instruction_sigp_arch) },
{ "instruction_sigp_set_prefix", VCPU_STAT(instruction_sigp_prefix) },
{ "instruction_sigp_restart", VCPU_STAT(instruction_sigp_restart) },
{ "diagnose_10", VCPU_STAT(diagnose_10) },
{ "diagnose_44", VCPU_STAT(diagnose_44) },
{ "diagnose_9c", VCPU_STAT(diagnose_9c) },
{ NULL }
};
static unsigned long long *facilities;
/* Section: not file related */
int kvm_arch_hardware_enable(void)
{
/* every s390 is virtualization enabled ;-) */
return 0;
}
int kvm_arch_hardware_setup(void)
{
return 0;
}
void kvm_arch_hardware_unsetup(void)
{
}
int kvm_arch_init(void *opaque)
{
return 0;
}
/* Section: device related */
long kvm_arch_dev_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
{
if (ioctl == KVM_S390_ENABLE_SIE)
return s390_enable_sie();
return -EINVAL;
}
int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
{
int r;
switch (ext) {
case KVM_CAP_S390_PSW:
case KVM_CAP_S390_GMAP:
case KVM_CAP_SYNC_MMU:
#ifdef CONFIG_KVM_S390_UCONTROL
case KVM_CAP_S390_UCONTROL:
#endif
case KVM_CAP_SYNC_REGS:
case KVM_CAP_ONE_REG:
case KVM_CAP_ENABLE_CAP:
case KVM_CAP_S390_CSS_SUPPORT:
case KVM_CAP_IOEVENTFD:
r = 1;
break;
case KVM_CAP_NR_VCPUS:
case KVM_CAP_MAX_VCPUS:
r = KVM_MAX_VCPUS;
break;
case KVM_CAP_NR_MEMSLOTS:
r = KVM_USER_MEM_SLOTS;
break;
case KVM_CAP_S390_COW:
r = MACHINE_HAS_ESOP;
break;
default:
r = 0;
}
return r;
}
/* Section: vm related */
/*
* Get (and clear) the dirty memory log for a memory slot.
*/
int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
struct kvm_dirty_log *log)
{
return 0;
}
long kvm_arch_vm_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
{
struct kvm *kvm = filp->private_data;
void __user *argp = (void __user *)arg;
int r;
switch (ioctl) {
case KVM_S390_INTERRUPT: {
struct kvm_s390_interrupt s390int;
r = -EFAULT;
if (copy_from_user(&s390int, argp, sizeof(s390int)))
break;
r = kvm_s390_inject_vm(kvm, &s390int);
break;
}
default:
r = -ENOTTY;
}
return r;
}
int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
{
int rc;
char debug_name[16];
rc = -EINVAL;
#ifdef CONFIG_KVM_S390_UCONTROL
if (type & ~KVM_VM_S390_UCONTROL)
goto out_err;
if ((type & KVM_VM_S390_UCONTROL) && (!capable(CAP_SYS_ADMIN)))
goto out_err;
#else
if (type)
goto out_err;
#endif
rc = s390_enable_sie();
if (rc)
goto out_err;
rc = -ENOMEM;
kvm->arch.sca = (struct sca_block *) get_zeroed_page(GFP_KERNEL);
if (!kvm->arch.sca)
goto out_err;
sprintf(debug_name, "kvm-%u", current->pid);
kvm->arch.dbf = debug_register(debug_name, 8, 2, 8 * sizeof(long));
if (!kvm->arch.dbf)
goto out_nodbf;
spin_lock_init(&kvm->arch.float_int.lock);
INIT_LIST_HEAD(&kvm->arch.float_int.list);
debug_register_view(kvm->arch.dbf, &debug_sprintf_view);
VM_EVENT(kvm, 3, "%s", "vm created");
if (type & KVM_VM_S390_UCONTROL) {
kvm->arch.gmap = NULL;
} else {
kvm->arch.gmap = gmap_alloc(current->mm);
if (!kvm->arch.gmap)
goto out_nogmap;
}
kvm->arch.css_support = 0;
return 0;
out_nogmap:
debug_unregister(kvm->arch.dbf);
out_nodbf:
free_page((unsigned long)(kvm->arch.sca));
out_err:
return rc;
}
void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
{
VCPU_EVENT(vcpu, 3, "%s", "free cpu");
trace_kvm_s390_destroy_vcpu(vcpu->vcpu_id);
if (!kvm_is_ucontrol(vcpu->kvm)) {
clear_bit(63 - vcpu->vcpu_id,
(unsigned long *) &vcpu->kvm->arch.sca->mcn);
if (vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda ==
(__u64) vcpu->arch.sie_block)
vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda = 0;
}
smp_mb();
if (kvm_is_ucontrol(vcpu->kvm))
gmap_free(vcpu->arch.gmap);
free_page((unsigned long)(vcpu->arch.sie_block));
kvm_vcpu_uninit(vcpu);
kfree(vcpu);
}
static void kvm_free_vcpus(struct kvm *kvm)
{
unsigned int i;
struct kvm_vcpu *vcpu;
kvm_for_each_vcpu(i, vcpu, kvm)
kvm_arch_vcpu_destroy(vcpu);
mutex_lock(&kvm->lock);
for (i = 0; i < atomic_read(&kvm->online_vcpus); i++)
kvm->vcpus[i] = NULL;
atomic_set(&kvm->online_vcpus, 0);
mutex_unlock(&kvm->lock);
}
void kvm_arch_destroy_vm(struct kvm *kvm)
{
kvm_free_vcpus(kvm);
free_page((unsigned long)(kvm->arch.sca));
debug_unregister(kvm->arch.dbf);
if (!kvm_is_ucontrol(kvm))
gmap_free(kvm->arch.gmap);
}
/* Section: vcpu related */
int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
{
if (kvm_is_ucontrol(vcpu->kvm)) {
vcpu->arch.gmap = gmap_alloc(current->mm);
if (!vcpu->arch.gmap)
return -ENOMEM;
return 0;
}
vcpu->arch.gmap = vcpu->kvm->arch.gmap;
vcpu->run->kvm_valid_regs = KVM_SYNC_PREFIX |
KVM_SYNC_GPRS |
KVM_SYNC_ACRS |
KVM_SYNC_CRS;
return 0;
}
void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
{
save_fp_regs(&vcpu->arch.host_fpregs);
save_access_regs(vcpu->arch.host_acrs);
vcpu->arch.guest_fpregs.fpc &= FPC_VALID_MASK;
restore_fp_regs(&vcpu->arch.guest_fpregs);
restore_access_regs(vcpu->run->s.regs.acrs);
gmap_enable(vcpu->arch.gmap);
atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags);
}
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
{
atomic_clear_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags);
gmap_disable(vcpu->arch.gmap);
save_fp_regs(&vcpu->arch.guest_fpregs);
save_access_regs(vcpu->run->s.regs.acrs);
restore_fp_regs(&vcpu->arch.host_fpregs);
restore_access_regs(vcpu->arch.host_acrs);
}
static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
{
/* this equals initial cpu reset in pop, but we don't switch to ESA */
vcpu->arch.sie_block->gpsw.mask = 0UL;
vcpu->arch.sie_block->gpsw.addr = 0UL;
kvm_s390_set_prefix(vcpu, 0);
vcpu->arch.sie_block->cputm = 0UL;
vcpu->arch.sie_block->ckc = 0UL;
vcpu->arch.sie_block->todpr = 0;
memset(vcpu->arch.sie_block->gcr, 0, 16 * sizeof(__u64));
vcpu->arch.sie_block->gcr[0] = 0xE0UL;
vcpu->arch.sie_block->gcr[14] = 0xC2000000UL;
vcpu->arch.guest_fpregs.fpc = 0;
asm volatile("lfpc %0" : : "Q" (vcpu->arch.guest_fpregs.fpc));
vcpu->arch.sie_block->gbea = 1;
atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
}
int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
{
return 0;
}
int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
{
atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH |
CPUSTAT_SM |
CPUSTAT_STOPPED);
vcpu->arch.sie_block->ecb = 6;
vcpu->arch.sie_block->eca = 0xC1002001U;
vcpu->arch.sie_block->fac = (int) (long) facilities;
hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
tasklet_init(&vcpu->arch.tasklet, kvm_s390_tasklet,
(unsigned long) vcpu);
vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup;
get_cpu_id(&vcpu->arch.cpu_id);
vcpu->arch.cpu_id.version = 0xff;
return 0;
}
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
unsigned int id)
{
struct kvm_vcpu *vcpu;
int rc = -EINVAL;
if (id >= KVM_MAX_VCPUS)
goto out;
rc = -ENOMEM;
vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
if (!vcpu)
goto out;
vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
get_zeroed_page(GFP_KERNEL);
if (!vcpu->arch.sie_block)
goto out_free_cpu;
vcpu->arch.sie_block->icpua = id;
if (!kvm_is_ucontrol(kvm)) {
if (!kvm->arch.sca) {
WARN_ON_ONCE(1);
goto out_free_cpu;
}
if (!kvm->arch.sca->cpu[id].sda)
kvm->arch.sca->cpu[id].sda =
(__u64) vcpu->arch.sie_block;
vcpu->arch.sie_block->scaoh =
(__u32)(((__u64)kvm->arch.sca) >> 32);
vcpu->arch.sie_block->scaol = (__u32)(__u64)kvm->arch.sca;
set_bit(63 - id, (unsigned long *) &kvm->arch.sca->mcn);
}
spin_lock_init(&vcpu->arch.local_int.lock);
INIT_LIST_HEAD(&vcpu->arch.local_int.list);
vcpu->arch.local_int.float_int = &kvm->arch.float_int;
spin_lock(&kvm->arch.float_int.lock);
kvm->arch.float_int.local_int[id] = &vcpu->arch.local_int;
init_waitqueue_head(&vcpu->arch.local_int.wq);
vcpu->arch.local_int.cpuflags = &vcpu->arch.sie_block->cpuflags;
spin_unlock(&kvm->arch.float_int.lock);
rc = kvm_vcpu_init(vcpu, kvm, id);
if (rc)
goto out_free_sie_block;
VM_EVENT(kvm, 3, "create cpu %d at %p, sie block at %p", id, vcpu,
vcpu->arch.sie_block);
trace_kvm_s390_create_vcpu(id, vcpu, vcpu->arch.sie_block);
return vcpu;
out_free_sie_block:
free_page((unsigned long)(vcpu->arch.sie_block));
out_free_cpu:
kfree(vcpu);
out:
return ERR_PTR(rc);
}
int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
{
/* kvm common code refers to this, but never calls it */
BUG();
return 0;
}
int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
{
/* kvm common code refers to this, but never calls it */
BUG();
return 0;
}
static int kvm_arch_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu,
struct kvm_one_reg *reg)
{
int r = -EINVAL;
switch (reg->id) {
case KVM_REG_S390_TODPR:
r = put_user(vcpu->arch.sie_block->todpr,
(u32 __user *)reg->addr);
break;
case KVM_REG_S390_EPOCHDIFF:
r = put_user(vcpu->arch.sie_block->epoch,
(u64 __user *)reg->addr);
break;
case KVM_REG_S390_CPU_TIMER:
r = put_user(vcpu->arch.sie_block->cputm,
(u64 __user *)reg->addr);
break;
case KVM_REG_S390_CLOCK_COMP:
r = put_user(vcpu->arch.sie_block->ckc,
(u64 __user *)reg->addr);
break;
default:
break;
}
return r;
}
static int kvm_arch_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
struct kvm_one_reg *reg)
{
int r = -EINVAL;
switch (reg->id) {
case KVM_REG_S390_TODPR:
r = get_user(vcpu->arch.sie_block->todpr,
(u32 __user *)reg->addr);
break;
case KVM_REG_S390_EPOCHDIFF:
r = get_user(vcpu->arch.sie_block->epoch,
(u64 __user *)reg->addr);
break;
case KVM_REG_S390_CPU_TIMER:
r = get_user(vcpu->arch.sie_block->cputm,
(u64 __user *)reg->addr);
break;
case KVM_REG_S390_CLOCK_COMP:
r = get_user(vcpu->arch.sie_block->ckc,
(u64 __user *)reg->addr);
break;
default:
break;
}
return r;
}
static int kvm_arch_vcpu_ioctl_initial_reset(struct kvm_vcpu *vcpu)
{
kvm_s390_vcpu_initial_reset(vcpu);
return 0;
}
int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
{
memcpy(&vcpu->run->s.regs.gprs, ®s->gprs, sizeof(regs->gprs));
return 0;
}
int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
{
memcpy(®s->gprs, &vcpu->run->s.regs.gprs, sizeof(regs->gprs));
return 0;
}
int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
struct kvm_sregs *sregs)
{
memcpy(&vcpu->run->s.regs.acrs, &sregs->acrs, sizeof(sregs->acrs));
memcpy(&vcpu->arch.sie_block->gcr, &sregs->crs, sizeof(sregs->crs));
restore_access_regs(vcpu->run->s.regs.acrs);
return 0;
}
int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
struct kvm_sregs *sregs)
{
memcpy(&sregs->acrs, &vcpu->run->s.regs.acrs, sizeof(sregs->acrs));
memcpy(&sregs->crs, &vcpu->arch.sie_block->gcr, sizeof(sregs->crs));
return 0;
}
int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
{
memcpy(&vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs));
vcpu->arch.guest_fpregs.fpc = fpu->fpc & FPC_VALID_MASK;
restore_fp_regs(&vcpu->arch.guest_fpregs);
return 0;
}
int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
{
memcpy(&fpu->fprs, &vcpu->arch.guest_fpregs.fprs, sizeof(fpu->fprs));
fpu->fpc = vcpu->arch.guest_fpregs.fpc;
return 0;
}
static int kvm_arch_vcpu_ioctl_set_initial_psw(struct kvm_vcpu *vcpu, psw_t psw)
{
int rc = 0;
if (!(atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_STOPPED))
rc = -EBUSY;
else {
vcpu->run->psw_mask = psw.mask;
vcpu->run->psw_addr = psw.addr;
}
return rc;
}
int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
struct kvm_translation *tr)
{
return -EINVAL; /* not implemented yet */
}
int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
struct kvm_guest_debug *dbg)
{
return -EINVAL; /* not implemented yet */
}
int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
struct kvm_mp_state *mp_state)
{
return -EINVAL; /* not implemented yet */
}
int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
struct kvm_mp_state *mp_state)
{
return -EINVAL; /* not implemented yet */
}
static int __vcpu_run(struct kvm_vcpu *vcpu)
{
int rc;
memcpy(&vcpu->arch.sie_block->gg14, &vcpu->run->s.regs.gprs[14], 16);
if (need_resched())
schedule();
if (test_thread_flag(TIF_MCCK_PENDING))
s390_handle_mcck();
if (!kvm_is_ucontrol(vcpu->kvm))
kvm_s390_deliver_pending_interrupts(vcpu);
vcpu->arch.sie_block->icptcode = 0;
VCPU_EVENT(vcpu, 6, "entering sie flags %x",
atomic_read(&vcpu->arch.sie_block->cpuflags));
trace_kvm_s390_sie_enter(vcpu,
atomic_read(&vcpu->arch.sie_block->cpuflags));
/*
* As PF_VCPU will be used in fault handler, between guest_enter
* and guest_exit should be no uaccess.
*/
preempt_disable();
kvm_guest_enter();
preempt_enable();
rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
kvm_guest_exit();
VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
vcpu->arch.sie_block->icptcode);
trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
if (rc) {
if (kvm_is_ucontrol(vcpu->kvm)) {
rc = SIE_INTERCEPT_UCONTROL;
} else {
VCPU_EVENT(vcpu, 3, "%s", "fault in sie instruction");
trace_kvm_s390_sie_fault(vcpu);
rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
}
}
memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
return rc;
}
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
int rc;
sigset_t sigsaved;
rerun_vcpu:
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
atomic_clear_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
BUG_ON(vcpu->kvm->arch.float_int.local_int[vcpu->vcpu_id] == NULL);
switch (kvm_run->exit_reason) {
case KVM_EXIT_S390_SIEIC:
case KVM_EXIT_UNKNOWN:
case KVM_EXIT_INTR:
case KVM_EXIT_S390_RESET:
case KVM_EXIT_S390_UCONTROL:
case KVM_EXIT_S390_TSCH:
break;
default:
BUG();
}
vcpu->arch.sie_block->gpsw.mask = kvm_run->psw_mask;
vcpu->arch.sie_block->gpsw.addr = kvm_run->psw_addr;
if (kvm_run->kvm_dirty_regs & KVM_SYNC_PREFIX) {
kvm_run->kvm_dirty_regs &= ~KVM_SYNC_PREFIX;
kvm_s390_set_prefix(vcpu, kvm_run->s.regs.prefix);
}
if (kvm_run->kvm_dirty_regs & KVM_SYNC_CRS) {
kvm_run->kvm_dirty_regs &= ~KVM_SYNC_CRS;
memcpy(&vcpu->arch.sie_block->gcr, &kvm_run->s.regs.crs, 128);
kvm_s390_set_prefix(vcpu, kvm_run->s.regs.prefix);
}
might_fault();
do {
rc = __vcpu_run(vcpu);
if (rc)
break;
if (kvm_is_ucontrol(vcpu->kvm))
rc = -EOPNOTSUPP;
else
rc = kvm_handle_sie_intercept(vcpu);
} while (!signal_pending(current) && !rc);
if (rc == SIE_INTERCEPT_RERUNVCPU)
goto rerun_vcpu;
if (signal_pending(current) && !rc) {
kvm_run->exit_reason = KVM_EXIT_INTR;
rc = -EINTR;
}
#ifdef CONFIG_KVM_S390_UCONTROL
if (rc == SIE_INTERCEPT_UCONTROL) {
kvm_run->exit_reason = KVM_EXIT_S390_UCONTROL;
kvm_run->s390_ucontrol.trans_exc_code =
current->thread.gmap_addr;
kvm_run->s390_ucontrol.pgm_code = 0x10;
rc = 0;
}
#endif
if (rc == -EOPNOTSUPP) {
/* intercept cannot be handled in-kernel, prepare kvm-run */
kvm_run->exit_reason = KVM_EXIT_S390_SIEIC;
kvm_run->s390_sieic.icptcode = vcpu->arch.sie_block->icptcode;
kvm_run->s390_sieic.ipa = vcpu->arch.sie_block->ipa;
kvm_run->s390_sieic.ipb = vcpu->arch.sie_block->ipb;
rc = 0;
}
if (rc == -EREMOTE) {
/* intercept was handled, but userspace support is needed
* kvm_run has been prepared by the handler */
rc = 0;
}
kvm_run->psw_mask = vcpu->arch.sie_block->gpsw.mask;
kvm_run->psw_addr = vcpu->arch.sie_block->gpsw.addr;
kvm_run->s.regs.prefix = vcpu->arch.sie_block->prefix;
memcpy(&kvm_run->s.regs.crs, &vcpu->arch.sie_block->gcr, 128);
if (vcpu->sigset_active)
sigprocmask(SIG_SETMASK, &sigsaved, NULL);
vcpu->stat.exit_userspace++;
return rc;
}
static int __guestcopy(struct kvm_vcpu *vcpu, u64 guestdest, void *from,
unsigned long n, int prefix)
{
if (prefix)
return copy_to_guest(vcpu, guestdest, from, n);
else
return copy_to_guest_absolute(vcpu, guestdest, from, n);
}
/*
* store status at address
* we use have two special cases:
* KVM_S390_STORE_STATUS_NOADDR: -> 0x1200 on 64 bit
* KVM_S390_STORE_STATUS_PREFIXED: -> prefix
*/
int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
{
unsigned char archmode = 1;
int prefix;
if (addr == KVM_S390_STORE_STATUS_NOADDR) {
if (copy_to_guest_absolute(vcpu, 163ul, &archmode, 1))
return -EFAULT;
addr = SAVE_AREA_BASE;
prefix = 0;
} else if (addr == KVM_S390_STORE_STATUS_PREFIXED) {
if (copy_to_guest(vcpu, 163ul, &archmode, 1))
return -EFAULT;
addr = SAVE_AREA_BASE;
prefix = 1;
} else
prefix = 0;
/*
* The guest FPRS and ACRS are in the host FPRS/ACRS due to the lazy
* copying in vcpu load/put. Lets update our copies before we save
* it into the save area
*/
save_fp_regs(&vcpu->arch.guest_fpregs);
save_access_regs(vcpu->run->s.regs.acrs);
if (__guestcopy(vcpu, addr + offsetof(struct save_area, fp_regs),
vcpu->arch.guest_fpregs.fprs, 128, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, gp_regs),
vcpu->run->s.regs.gprs, 128, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, psw),
&vcpu->arch.sie_block->gpsw, 16, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, pref_reg),
&vcpu->arch.sie_block->prefix, 4, prefix))
return -EFAULT;
if (__guestcopy(vcpu,
addr + offsetof(struct save_area, fp_ctrl_reg),
&vcpu->arch.guest_fpregs.fpc, 4, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, tod_reg),
&vcpu->arch.sie_block->todpr, 4, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, timer),
&vcpu->arch.sie_block->cputm, 8, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, clk_cmp),
&vcpu->arch.sie_block->ckc, 8, prefix))
return -EFAULT;
if (__guestcopy(vcpu, addr + offsetof(struct save_area, acc_regs),
&vcpu->run->s.regs.acrs, 64, prefix))
return -EFAULT;
if (__guestcopy(vcpu,
addr + offsetof(struct save_area, ctrl_regs),
&vcpu->arch.sie_block->gcr, 128, prefix))
return -EFAULT;
return 0;
}
static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
struct kvm_enable_cap *cap)
{
int r;
if (cap->flags)
return -EINVAL;
switch (cap->cap) {
case KVM_CAP_S390_CSS_SUPPORT:
if (!vcpu->kvm->arch.css_support) {
vcpu->kvm->arch.css_support = 1;
trace_kvm_s390_enable_css(vcpu->kvm);
}
r = 0;
break;
default:
r = -EINVAL;
break;
}
return r;
}
long kvm_arch_vcpu_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
{
struct kvm_vcpu *vcpu = filp->private_data;
void __user *argp = (void __user *)arg;
long r;
switch (ioctl) {
case KVM_S390_INTERRUPT: {
struct kvm_s390_interrupt s390int;
r = -EFAULT;
if (copy_from_user(&s390int, argp, sizeof(s390int)))
break;
r = kvm_s390_inject_vcpu(vcpu, &s390int);
break;
}
case KVM_S390_STORE_STATUS:
r = kvm_s390_vcpu_store_status(vcpu, arg);
break;
case KVM_S390_SET_INITIAL_PSW: {
psw_t psw;
r = -EFAULT;
if (copy_from_user(&psw, argp, sizeof(psw)))
break;
r = kvm_arch_vcpu_ioctl_set_initial_psw(vcpu, psw);
break;
}
case KVM_S390_INITIAL_RESET:
r = kvm_arch_vcpu_ioctl_initial_reset(vcpu);
break;
case KVM_SET_ONE_REG:
case KVM_GET_ONE_REG: {
struct kvm_one_reg reg;
r = -EFAULT;
if (copy_from_user(®, argp, sizeof(reg)))
break;
if (ioctl == KVM_SET_ONE_REG)
r = kvm_arch_vcpu_ioctl_set_one_reg(vcpu, ®);
else
r = kvm_arch_vcpu_ioctl_get_one_reg(vcpu, ®);
break;
}
#ifdef CONFIG_KVM_S390_UCONTROL
case KVM_S390_UCAS_MAP: {
struct kvm_s390_ucas_mapping ucasmap;
if (copy_from_user(&ucasmap, argp, sizeof(ucasmap))) {
r = -EFAULT;
break;
}
if (!kvm_is_ucontrol(vcpu->kvm)) {
r = -EINVAL;
break;
}
r = gmap_map_segment(vcpu->arch.gmap, ucasmap.user_addr,
ucasmap.vcpu_addr, ucasmap.length);
break;
}
case KVM_S390_UCAS_UNMAP: {
struct kvm_s390_ucas_mapping ucasmap;
if (copy_from_user(&ucasmap, argp, sizeof(ucasmap))) {
r = -EFAULT;
break;
}
if (!kvm_is_ucontrol(vcpu->kvm)) {
r = -EINVAL;
break;
}
r = gmap_unmap_segment(vcpu->arch.gmap, ucasmap.vcpu_addr,
ucasmap.length);
break;
}
#endif
case KVM_S390_VCPU_FAULT: {
r = gmap_fault(arg, vcpu->arch.gmap);
if (!IS_ERR_VALUE(r))
r = 0;
break;
}
case KVM_ENABLE_CAP:
{
struct kvm_enable_cap cap;
r = -EFAULT;
if (copy_from_user(&cap, argp, sizeof(cap)))
break;
r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
break;
}
default:
r = -ENOTTY;
}
return r;
}
int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
{
#ifdef CONFIG_KVM_S390_UCONTROL
if ((vmf->pgoff == KVM_S390_SIE_PAGE_OFFSET)
&& (kvm_is_ucontrol(vcpu->kvm))) {
vmf->page = virt_to_page(vcpu->arch.sie_block);
get_page(vmf->page);
return 0;
}
#endif
return VM_FAULT_SIGBUS;
}
int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
unsigned long npages)
{
return 0;
}
/* Section: memory related */
int kvm_arch_prepare_memory_region(struct kvm *kvm,
struct kvm_memory_slot *memslot,
struct kvm_userspace_memory_region *mem,
enum kvm_mr_change change)
{
/* A few sanity checks. We can have memory slots which have to be
located/ended at a segment boundary (1MB). The memory in userland is
ok to be fragmented into various different vmas. It is okay to mmap()
and munmap() stuff in this slot after doing this call at any time */
if (mem->userspace_addr & 0xffffful)
return -EINVAL;
if (mem->memory_size & 0xffffful)
return -EINVAL;
return 0;
}
void kvm_arch_commit_memory_region(struct kvm *kvm,
struct kvm_userspace_memory_region *mem,
const struct kvm_memory_slot *old,
enum kvm_mr_change change)
{
int rc;
/* If the basics of the memslot do not change, we do not want
* to update the gmap. Every update causes several unnecessary
* segment translation exceptions. This is usually handled just
* fine by the normal fault handler + gmap, but it will also
* cause faults on the prefix page of running guest CPUs.
*/
if (old->userspace_addr == mem->userspace_addr &&
old->base_gfn * PAGE_SIZE == mem->guest_phys_addr &&
old->npages * PAGE_SIZE == mem->memory_size)
return;
rc = gmap_map_segment(kvm->arch.gmap, mem->userspace_addr,
mem->guest_phys_addr, mem->memory_size);
if (rc)
printk(KERN_WARNING "kvm-s390: failed to commit memory region\n");
return;
}
static int __init kvm_s390_init(void)
{
int ret;
ret = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
if (ret)
return ret;
/*
* guests can ask for up to 255+1 double words, we need a full page
* to hold the maximum amount of facilities. On the other hand, we
* only set facilities that are known to work in KVM.
*/
facilities = (unsigned long long *) get_zeroed_page(GFP_KERNEL|GFP_DMA);
if (!facilities) {
kvm_exit();
return -ENOMEM;
}
memcpy(facilities, S390_lowcore.stfle_fac_list, 16);
facilities[0] &= 0xff00fff3f47c0000ULL;
facilities[1] &= 0x001c000000000000ULL;
return 0;
}
static void __exit kvm_s390_exit(void)
{
free_page((unsigned long) facilities);
kvm_exit();
}
module_init(kvm_s390_init);
module_exit(kvm_s390_exit);
|
b06d604e9256dbcade6a7e4972a619deadab47f0
|
e8c76797b194bce6702adf9721a96c2b440efd5c
|
/modules/tls/tls_conf.h
|
e924412d5483eca26ceb876a1317e4409672c545
|
[
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain",
"Apache-2.0",
"LicenseRef-scancode-zeusbench",
"BSD-3-Clause",
"RSA-MD",
"LicenseRef-scancode-rsa-1990",
"Beerware",
"LicenseRef-scancode-other-permissive",
"Spencer-94",
"metamail",
"LicenseRef-scancode-rsa-md4",
"HPND-sell-variant"
] |
permissive
|
apache/httpd
|
86bfac3d6e2e9b48f5bfca5be7ec616fa9b14e9a
|
b9e029c8036fd036281ac266010db91aed6079b2
|
refs/heads/trunk
| 2023-09-04T07:18:59.681233
| 2023-08-30T12:56:11
| 2023-08-30T12:56:11
| 205,423
| 3,159
| 1,329
|
Apache-2.0
| 2023-09-11T13:50:41
| 2009-05-20T02:02:59
|
C
|
UTF-8
|
C
| false
| false
| 8,277
|
h
|
tls_conf.h
|
/* 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.
*/
#ifndef tls_conf_h
#define tls_conf_h
/* Configuration flags */
#define TLS_FLAG_UNSET (-1)
#define TLS_FLAG_FALSE (0)
#define TLS_FLAG_TRUE (1)
struct tls_proto_conf_t;
struct tls_cert_reg_t;
struct tls_cert_root_stores_t;
struct tls_cert_verifiers_t;
struct ap_socache_instance_t;
struct ap_socache_provider_t;
struct apr_global_mutex_t;
/* disabled, since rustls support is lacking
* - x.509 retrieval of certificate fields and extensions
* - certificate revocation lists (CRL)
* - x.509 access to issuer of trust chain in x.509 CA store:
* server CA has ca1, ca2, ca3
* client present certA
* rustls verifies that it is signed by *one of* ca* certs
* OCSP check needs (certA, issuing cert) for query
*/
#define TLS_CLIENT_CERTS 0
/* support for this exists as PR <https://github.com/rustls/rustls-ffi/pull/128>
*/
#define TLS_MACHINE_CERTS 1
typedef enum {
TLS_CLIENT_AUTH_UNSET,
TLS_CLIENT_AUTH_NONE,
TLS_CLIENT_AUTH_REQUIRED,
TLS_CLIENT_AUTH_OPTIONAL,
} tls_client_auth_t;
typedef enum {
TLS_CONF_ST_INIT,
TLS_CONF_ST_INCOMING_DONE,
TLS_CONF_ST_OUTGOING_DONE,
TLS_CONF_ST_DONE,
} tls_conf_status_t;
/* The global module configuration, created after post-config
* and then readonly.
*/
typedef struct {
server_rec *ap_server; /* the global server we initialized on */
const char *module_version;
const char *crustls_version;
tls_conf_status_t status;
int mod_proxy_post_config_done; /* if mod_proxy did its post-config things */
server_addr_rec *tls_addresses; /* the addresses/ports our engine is enabled on */
apr_array_header_t *proxy_configs; /* tls_conf_proxy_t* collected from everywhere */
struct tls_proto_conf_t *proto; /* TLS protocol/rustls specific globals */
apr_hash_t *var_lookups; /* variable lookup functions by var name */
struct tls_cert_reg_t *cert_reg; /* all certified keys loaded */
struct tls_cert_root_stores_t *stores; /* loaded certificate stores */
struct tls_cert_verifiers_t *verifiers; /* registry of certificate verifiers */
const char *session_cache_spec; /* how the session cache was specified */
const struct ap_socache_provider_t *session_cache_provider; /* provider used for session cache */
struct ap_socache_instance_t *session_cache; /* session cache instance */
struct apr_global_mutex_t *session_cache_mutex; /* global mutex for access to session cache */
const rustls_server_config *rustls_hello_config; /* used for initial client hello parsing */
} tls_conf_global_t;
/* The module configuration for a server (vhost).
* Populated during config parsing, merged and completed
* in the post config phase. Readonly after that.
*/
typedef struct {
server_rec *server; /* server this config belongs to */
tls_conf_global_t *global; /* global module config, singleton */
int enabled; /* TLS_FLAG_TRUE if mod_tls is active on this server */
apr_array_header_t *cert_specs; /* array of (tls_cert_spec_t*) of configured certificates */
int tls_protocol_min; /* the minimum TLS protocol version to use */
apr_array_header_t *tls_pref_ciphers; /* List of apr_uint16_t cipher ids to prefer */
apr_array_header_t *tls_supp_ciphers; /* List of apr_uint16_t cipher ids to suppress */
const apr_array_header_t *ciphersuites; /* Computed post-config, ordered list of rustls cipher suites */
int honor_client_order; /* honor client cipher ordering */
int strict_sni;
const char *client_ca; /* PEM file with trust anchors for client certs */
tls_client_auth_t client_auth; /* how client authentication with certificates is used */
const char *var_user_name; /* which SSL variable to use as user name */
apr_array_header_t *certified_keys; /* rustls_certified_key list configured */
int base_server; /* != 0 iff this is the base server */
int service_unavailable; /* TLS not trustworthy configured, return 503s */
} tls_conf_server_t;
typedef struct {
server_rec *defined_in; /* the server/host defining this dir_conf */
tls_conf_global_t *global; /* global module config, singleton */
const char *proxy_ca; /* PEM file with trust anchors for proxied remote server certs */
int proxy_protocol_min; /* the minimum TLS protocol version to use for proxy connections */
apr_array_header_t *proxy_pref_ciphers; /* List of apr_uint16_t cipher ids to prefer */
apr_array_header_t *proxy_supp_ciphers; /* List of apr_uint16_t cipher ids to suppress */
apr_array_header_t *machine_cert_specs; /* configured machine certificates specs */
apr_array_header_t *machine_certified_keys; /* rustls_certified_key list */
const rustls_client_config *rustls_config;
} tls_conf_proxy_t;
typedef struct {
int std_env_vars;
int export_cert_vars;
int proxy_enabled; /* TLS_FLAG_TRUE if mod_tls is active on outgoing connections */
const char *proxy_ca; /* PEM file with trust anchors for proxied remote server certs */
int proxy_protocol_min; /* the minimum TLS protocol version to use for proxy connections */
apr_array_header_t *proxy_pref_ciphers; /* List of apr_uint16_t cipher ids to prefer */
apr_array_header_t *proxy_supp_ciphers; /* List of apr_uint16_t cipher ids to suppress */
apr_array_header_t *proxy_machine_cert_specs; /* configured machine certificates specs */
tls_conf_proxy_t *proxy_config;
} tls_conf_dir_t;
/* our static registry of configuration directives. */
extern const command_rec tls_conf_cmds[];
/* create the modules configuration for a server_rec. */
void *tls_conf_create_svr(apr_pool_t *pool, server_rec *s);
/* merge (inherit) server configurations for the module.
* Settings in 'add' overwrite the ones in 'base' and unspecified
* settings shine through. */
void *tls_conf_merge_svr(apr_pool_t *pool, void *basev, void *addv);
/* create the modules configuration for a directory. */
void *tls_conf_create_dir(apr_pool_t *pool, char *dir);
/* merge (inherit) directory configurations for the module.
* Settings in 'add' overwrite the ones in 'base' and unspecified
* settings shine through. */
void *tls_conf_merge_dir(apr_pool_t *pool, void *basev, void *addv);
/* Get the server specific module configuration. */
tls_conf_server_t *tls_conf_server_get(server_rec *s);
/* Get the directory specific module configuration for the request. */
tls_conf_dir_t *tls_conf_dir_get(request_rec *r);
/* Get the directory specific module configuration for the server. */
tls_conf_dir_t *tls_conf_dir_server_get(server_rec *s);
/* If any configuration values are unset, supply the global server defaults. */
apr_status_t tls_conf_server_apply_defaults(tls_conf_server_t *sc, apr_pool_t *p);
/* If any configuration values are unset, supply the global dir defaults. */
apr_status_t tls_conf_dir_apply_defaults(tls_conf_dir_t *dc, apr_pool_t *p);
/* create a new proxy configuration from directory config in server */
tls_conf_proxy_t *tls_conf_proxy_make(
apr_pool_t *p, tls_conf_dir_t *dc, tls_conf_global_t *gc, server_rec *s);
int tls_proxy_section_post_config(
apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s,
ap_conf_vector_t *section_config);
#endif /* tls_conf_h */
|
96894513b00e5d1e4ae89637b4d6262a1d05c751
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/acm32/acm32f4xx-nucleo/libraries/HAL_Driver/Src/HAL_CAN.c
|
972eb8bcb26702c35188f9231e0e0a73f2fbf880
|
[
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 30,210
|
c
|
HAL_CAN.c
|
/*
******************************************************************************
* @file HAL_Can.c
* @version V1.0.0
* @date 2020
* @brief CAN HAL module driver.
* This file provides firmware functions to manage the following
* functionalities of the Universal Asynchronous Receiver Transmitter Peripheral (CAN).
* @ Initialization and de-initialization functions
* @ IO operation functions
* @ Peripheral Control functions
******************************************************************************
*/
#include "ACM32Fxx_HAL.h"
/*********************************************************************************
* Function : HAL_CAN_OperatingModeRequest
* Description : Select the CAN Operation mode.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Input : CAN_OperatingMode:CAN Operating Mode. This parameter can be one of @ref CAN_OperatingMode enumeration.
* Output : HAL status
* Author : CWT Data : 2020
**********************************************************************************/
HAL_StatusTypeDef HAL_CAN_OperatingModeRequest(CAN_HandleTypeDef *hcan, uint8_t CAN_OperatingMode)
{
uint8_t status = HAL_ERROR;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return HAL_ERROR;
if(!IS_CAN_OPERATING_MODE(CAN_OperatingMode)) return HAL_ERROR;
if (CAN_OperatingMode == CAN_OperatingMode_Initialization)
{
hcan->Instance->MOD |= CAN_OperatingMode_Initialization; // enter Initialization
if ((hcan->Instance->MOD & CAN_MOD_RM) != CAN_OperatingMode_Initialization)
{
status = HAL_ERROR;
}
else
{
status = HAL_OK;
}
}
else if(CAN_OperatingMode == CAN_OperatingMode_Normal)
{
hcan->Instance->MOD &=~ CAN_OperatingMode_Initialization; //1-->0 enter Normal
if ((hcan->Instance->MOD & CAN_MOD_RM) != CAN_OperatingMode_Normal)
{
status = HAL_ERROR;
}
else
{
status = HAL_OK;
}
}
else if (CAN_OperatingMode == CAN_OperatingMode_Sleep)
{
hcan->Instance->MOD |= CAN_OperatingMode_Sleep; // enter Normal
if ((hcan->Instance->MOD & CAN_MOD_SM) != CAN_OperatingMode_Sleep)
{
status = HAL_ERROR;
}
else
{
status = HAL_OK;
}
}
else if(CAN_OperatingMode == CAN_OperatingMode_Listen)
{
hcan->Instance->MOD |= CAN_OperatingMode_Listen; // enter Normal
if((hcan->Instance->MOD & CAN_MOD_LOM) != CAN_OperatingMode_Listen)
{
status = HAL_ERROR;
}
else
{
status = HAL_OK;
}
}
else
{
status = HAL_ERROR;
}
return (uint8_t) status;
}
/*********************************************************************************
* Function : HAL_CAN_MspInit
* Description : Initialize the CAN MSP.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
__weak void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan)
{
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_UART_MspInit can be implemented in the user file
*/
/* For Example */
GPIO_InitTypeDef GPIO_InitStruct;
if(hcan->Instance==CAN1)
{
/* Enable CAN clock */
System_Module_Enable(EN_CAN1);
GPIO_InitTypeDef GPIO_InitStructure;
/* Initialization GPIO */
/* PA11:Rx */ /* PA12:Tx */
GPIO_InitStructure.Pin = GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStructure.Alternate=GPIO_FUNCTION_5;
GPIO_InitStructure.Pull=GPIO_PULLUP;
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
}
else if(hcan->Instance==CAN2)
{
/* Enable CAN clock */
System_Module_Enable(EN_CAN2);
GPIO_InitTypeDef GPIO_InitStructure;
/* Initialization GPIO */
/* PB5:Rx */ /* PB6:Tx */
GPIO_InitStructure.Pin = GPIO_PIN_5|GPIO_PIN_6;
GPIO_InitStructure.Alternate=GPIO_FUNCTION_5;
GPIO_InitStructure.Pull=GPIO_PULLUP;
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Enable the CAN Receive interrupt */
hcan->Instance->IER |= CAN_IER_RIE;
NVIC_ClearPendingIRQ(CAN2_IRQn);
NVIC_SetPriority(CAN2_IRQn, 5);
NVIC_EnableIRQ(CAN2_IRQn);
}
}
/*********************************************************************************
* Function : HAL_CAN_MspDeInit
* Description : CAN MSP De-Initialization
* This function frees the hardware resources used in this example:
* - Disable the Peripheral's clock
* - Revert GPIO configuration to their default state
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
void HAL_CAN_MspDeInit(CAN_HandleTypeDef *hcan)
{
if(hcan->Instance==CAN1)
{
/* Reset CAN clock */
System_Module_Disable(EN_CAN1);
GPIO_InitTypeDef GPIO_InitStructure;
/* Initialization GPIO */
/* PA11:Rx */ /* PA12:Tx */
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12);
}
else if(hcan->Instance==CAN2)
{
/* Reset CAN clock */
System_Module_Disable(EN_CAN2);
GPIO_InitTypeDef GPIO_InitStructure;
/* Initialization GPIO */
/* PB5:Rx */ /* PB6:Tx */
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
}
}
/*********************************************************************************
* Function : HAL_CAN_Init
* Description : Initializes the CAN peripheral according to the specified parameters in the CAN_HandleTypeDef..
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output : HAL status
* Author : CWT Data : 2020
**********************************************************************************/
HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef *hcan)
{
uint8_t InitStatus = HAL_ERROR;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return HAL_ERROR;
if(!IS_CAN_MODE(hcan->Init.CAN_Mode)) return HAL_ERROR;
if(!IS_CAN_SJW(hcan->Init.CAN_SJW)) return HAL_ERROR;
if(!IS_CAN_TSEG1(hcan->Init.CAN_TSEG1)) return HAL_ERROR;
if(!IS_CAN_TSEG2(hcan->Init.CAN_TSEG2)) return HAL_ERROR;
if(!IS_CAN_BRP(hcan->Init.CAN_BRP)) return HAL_ERROR;
if(!IS_CAN_SAM(hcan->Init.CAN_SAM)) return HAL_ERROR;
/* Reset the CANx */
if(hcan->Instance==CAN1)
{
System_Module_Reset(RST_CAN1);
}
else
{
System_Module_Reset(RST_CAN2);
}
HAL_CAN_MspInit(hcan);
HAL_CAN_OperatingModeRequest(hcan,CAN_OperatingMode_Initialization);//enter CAN_OperatingMode_Initialization
hcan->Instance->BTR0=0xff;
hcan->Instance->BTR0=(hcan->Init.CAN_SJW<<6)|(hcan->Init.CAN_BRP);
hcan->Instance->BTR1=(hcan->Init.CAN_SAM<<7)|(hcan->Init.CAN_TSEG2<<4)|(hcan->Init.CAN_TSEG1);
HAL_CAN_OperatingModeRequest(hcan,CAN_OperatingMode_Normal);//enter CAN_OperatingMode_Normal
return HAL_OK;
}
/*********************************************************************************
* Function : HAL_CAN_DeInit
* Description : Deinitializes the CAN peripheral registers to their default
* reset values.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output : HAL status
* Author : CWT Data : 2020
**********************************************************************************/
HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef *hcan)
{
/* Check CAN handle */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return HAL_ERROR;
HAL_CAN_MspDeInit(hcan);
/* Reset the CAN peripheral */
SET_BIT(hcan->Instance->MOD, CAN_MOD_RM);
/* Return function status */
return HAL_OK;
}
/*********************************************************************************
* Function : HAL_CAN_Transmit
* Description : Initiates the transmission of a message.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Input : TxMessage : ppointer to a structure which contains CAN Id, CAN
* DLC and CAN data.
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
HAL_StatusTypeDef HAL_CAN_Transmit(CAN_HandleTypeDef *hcan, CanTxRxMsg* TxMessage)
{
uint8_t i = 0;
uint8_t can_id[4];
uint32_t frame_header;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return HAL_ERROR ;
if(!IS_CAN_IDTYPE(TxMessage->IDE)) return HAL_ERROR;
if(!IS_CAN_RTR(TxMessage->RTR)) return HAL_ERROR;
if(!IS_CAN_DLC(TxMessage->DLC)) return HAL_ERROR;
/* Set up the DLC */
frame_header =TxMessage->DLC & 0x0F; // standard data frame
/* Set up the Id */
if(TxMessage->IDE==CAN_Id_Standard)//Standard ID
{
can_id[0] = TxMessage->StdId >>3;
can_id[1] = (TxMessage->StdId&0x07)<<5;
for(i=0;i<2;i++)
{
hcan->Instance->DF.DATABUF[1+i] = can_id[i];
}
}
else//Id_Extended
{
can_id[0] = TxMessage->ExtId>>21;
can_id[1] = (TxMessage->ExtId&0x1FE000)>>13;
can_id[2] = (TxMessage->ExtId&0x1FE0)>>5;
can_id[3] = (TxMessage->ExtId&0x1F)<<3;
frame_header |= (CAN_Id_Extended<<7); // extended data frame
for(i=0;i<4;i++)
{
hcan->Instance->DF.DATABUF[1+i] = can_id[i];
}
}
if(TxMessage->RTR==CAN_RTR_Data)//CAN_RTR_Data
{
frame_header&=~(CAN_RTR_Remote<<6);
for(i=0; i<TxMessage->DLC; i++)
{
hcan->Instance->DF.DATABUF[3+(TxMessage->IDE*2)+i] = TxMessage->Data[i];
}
}
else//CAN_RTR_Remote
{
frame_header|=(CAN_RTR_Remote<<6);
}
hcan->Instance->DF.DATABUF[0]=frame_header;
hcan->Instance->CMR = CAN_CMR_TR; // transfer request
while((hcan->Instance->SR & CAN_SR_TCS)==0x00); //wait for send ok
return HAL_OK;
}
/*********************************************************************************
* Function : HAL_CAN_CancelTransmit
* Description : Cancels a transmit request.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
void HAL_CAN_CancelTransmit(CAN_HandleTypeDef *hcan)
{
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return ;
/* abort transmission */
hcan->Instance->CMR |= CAN_CMR_AT; //Abort Transmission
}
/*********************************************************************************
* Function : HAL_CAN_Receive
* Description : Receives a message.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Input : RxMessage : pointer to a structure receive message which contains
* CAN Id, CAN DLC, CAN datas .
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef *hcan, CanTxRxMsg* RxMessage)
{
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return HAL_ERROR ;
hcan->RxMessage=RxMessage;
/* Enable the CAN Receive interrupt */
hcan->Instance->IER |= CAN_IER_RIE;
NVIC_ClearPendingIRQ(CAN1_IRQn);
NVIC_SetPriority(CAN1_IRQn, 5);
NVIC_EnableIRQ(CAN1_IRQn);
return HAL_OK;
}
/*********************************************************************************
* Function : HAL_CAN_Receive
* Description : Receives a message.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Input : RxMessage : pointer to a structure receive message which contains
* CAN Id, CAN DLC, CAN datas .
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef *hcan, CanTxRxMsg* RxMessage)
{
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return HAL_ERROR ;
while(!(hcan->Instance->SR & CAN_SR_RBS));
HAL_CAN_GetRxMessage(hcan, RxMessage);
return HAL_OK;
}
void HAL_CAN_GetRxMessage(CAN_HandleTypeDef *hcan, CanTxRxMsg* RxMessage)
{
uint8_t i=0;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return ;
if(0 == (hcan->Instance->SR & CAN_SR_RBS) ) return; // receive fifo not empty
/* Get the IDE */
RxMessage->IDE = (uint8_t)(0x80 & hcan->Instance->DF.DATABUF[0])>>7;
/* Get the RTR */
RxMessage->RTR = (uint8_t)(0x40 & hcan->Instance->DF.DATABUF[0])>>6;
/* Get the DLC */
RxMessage->DLC = (uint8_t)0x0F & hcan->Instance->DF.DATABUF[0];
if (RxMessage->IDE == CAN_Id_Standard)
{
RxMessage->StdId = (uint32_t)(( hcan->Instance->DF.DATABUF[1]<<8) | hcan->Instance->DF.DATABUF[2])>>5;;
for(i=0; i<RxMessage->DLC; i++)
{
RxMessage->Data[i] = hcan->Instance->DF.DATABUF[3+i];
}
}
else
{
RxMessage->ExtId = (uint32_t)(( hcan->Instance->DF.DATABUF[1]<<24) | ( hcan->Instance->DF.DATABUF[2]<<16) | ( hcan->Instance->DF.DATABUF[3]<<8) | (hcan->Instance->DF.DATABUF[4] ))>>3;;
for(i=0; i<RxMessage->DLC; i++)
{
RxMessage->Data[i] = hcan->Instance->DF.DATABUF[5+i];
}
}
/* Release the FIFO */
hcan->Instance->CMR |= CAN_CMR_RRB; //Release Receive Buffer
}
/**
* @brief Initializes the CAN peripheral according to the specified
* parameters in the CAN_FilterInitStruct.
* @param CANx: where x can be 1 or 2 to to select the CAN peripheral.
CAN_FilterInitStruct: pointer to a CAN_FilterInitTypeDef
* structure that contains the configuration
* information.
* @retval None.
*/
/*********************************************************************************
* Function : HAL_CAN_ConfigFilter
* Description : Initializes the CAN peripheral according to the specified parameters in the CAN_FilterInitStruct.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Input : CAN_FilterInitStruct : pointer to a CAN_FilterInitTypeDef structure that contains the configuration
* information.
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
void HAL_CAN_ConfigFilter(CAN_HandleTypeDef *hcan,CAN_FilterInitTypeDef* CAN_FilterInitStruct)
{
HAL_CAN_OperatingModeRequest(hcan,CAN_OperatingMode_Initialization);//enter CAN_OperatingMode_Initialization
/* Filter Mode */
if (CAN_FilterInitStruct->CAN_FilterMode ==CAN_FilterMode_Dual) /*Dual mode*/
{
hcan->Instance->MOD &= ~CAN_MOD_AFM;
/*Dual mode ACR set*/
hcan->Instance->DF.FILTER.ACR[0] = (CAN_FilterInitStruct->CAN_FilterId1&0x1FE00000)>>21; /*Dual mode ACR0=ID28...ID21 of ID1*/
hcan->Instance->DF.FILTER.ACR[1] = (CAN_FilterInitStruct->CAN_FilterId1&0x1FE000)>>13; /*Dual mode ACR0=ID20...ID13 of ID1*/
hcan->Instance->DF.FILTER.ACR[2] = (CAN_FilterInitStruct->CAN_FilterId2&0x1FE00000)>>21; /*Dual mode ACR0=ID28...ID21 of ID2*/
hcan->Instance->DF.FILTER.ACR[3] = (CAN_FilterInitStruct->CAN_FilterId2&0x1FE000)>>13; /*Dual mode ACR0=ID20...ID13 of ID2*/
/*Dual mode AMR set*/
hcan->Instance->DF.FILTER.AMR[0] = (CAN_FilterInitStruct->CAN_FilterMaskId1)>>24;
hcan->Instance->DF.FILTER.AMR[1] = (CAN_FilterInitStruct->CAN_FilterMaskId1&0xFF0000)>>16;
hcan->Instance->DF.FILTER.AMR[2] = (CAN_FilterInitStruct->CAN_FilterMaskId2)>>24;
hcan->Instance->DF.FILTER.AMR[3] = (CAN_FilterInitStruct->CAN_FilterMaskId2&0xFF0000)>>16;
}
else /*Single mode*/
{
hcan->Instance->MOD |= CAN_MOD_AFM;
/*Single mode ACR set*/
hcan->Instance->DF.FILTER.ACR[0] = (CAN_FilterInitStruct->CAN_FilterId1&0x1FE00000)>>21; /*Single mode ACR0=ID28...ID21*/
hcan->Instance->DF.FILTER.ACR[1] = (CAN_FilterInitStruct->CAN_FilterId1&0x1FE000)>>13; /*Single mode ACR1=ID20...ID13*/
hcan->Instance->DF.FILTER.ACR[2] = (CAN_FilterInitStruct->CAN_FilterId1&0x1FE0)>>5; /*Single mode ACR2=ID12...ID5*/
hcan->Instance->DF.FILTER.ACR[3] = (CAN_FilterInitStruct->CAN_FilterId1&0x1F)<<3; /*Single mode ACR3=ID4...ID0*/
/*Single mode AMR set*/
hcan->Instance->DF.FILTER.AMR[0] = (CAN_FilterInitStruct->CAN_FilterMaskId1)>>24;
hcan->Instance->DF.FILTER.AMR[1] = (CAN_FilterInitStruct->CAN_FilterMaskId1&0xFF0000)>>16;
hcan->Instance->DF.FILTER.AMR[2] = (CAN_FilterInitStruct->CAN_FilterMaskId1&0xFF00)>>8;
hcan->Instance->DF.FILTER.AMR[3] = (CAN_FilterInitStruct->CAN_FilterMaskId1&0xFF);
}
HAL_CAN_OperatingModeRequest(hcan,CAN_OperatingMode_Normal);//enter CAN_OperatingMode_Initialization
}
/*********************************************************************************
* Function : HAL_CAN_Sleep
* Description : Enters the sleep mode.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
HAL_StatusTypeDef HAL_CAN_Sleep(CAN_HandleTypeDef *hcan)
{
HAL_StatusTypeDef status;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return HAL_ERROR;
/* Request Sleep mode */
hcan->Instance->MOD |= CAN_MOD_SM; //Enter Sleep Mode
/* Sleep mode status */
if ((hcan->Instance->MOD & CAN_MOD_SM) == CAN_MOD_SM)
{
/* Sleep mode entered */
status= HAL_OK;
}else
{
status=HAL_ERROR;
}
/* return sleep mode status */
return status;
}
/*********************************************************************************
* Function : HAL_CAN_WakeUp
* Description : Wakes the CAN up.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan)
{
HAL_StatusTypeDef status;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return HAL_ERROR;
/* sleep wake mode */
hcan->Instance->MOD &=~ CAN_MOD_SM; //Enter Sleep Mode
/* sleep wake status */
if ((hcan->Instance->MOD & CAN_MOD_SM)== CAN_MOD_SM)
{
/* sleep wake not entered */
status= HAL_ERROR;
}else
{
status=HAL_OK;
}
/* return sleep mode status */
return status;
}
/*********************************************************************************
* Function : HAL_CAN_GetTransmitErrorCounter
* Description : Returns the CANx Transmit Error Counter(TXERR).
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
int8_t HAL_CAN_GetTransmitErrorCounter(CAN_HandleTypeDef *hcan)
{
uint8_t counter=0;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return -1;
/* Get the CANx Transmit Error Counter(TXERR) */
counter = (uint8_t)(hcan->Instance->TXERR);
/* Return the CANx Transmit Error Counter(TXERR) */
return counter;
}
/*********************************************************************************
* Function : HAL_CAN_GetReceiveErrorCounter
* Description : Returns the CANx Receive Error Counter(RXERR).
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
int8_t HAL_CAN_GetReceiveErrorCounter(CAN_HandleTypeDef *hcan)
{
uint8_t counter=0;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return -1;
/* Get the CANx Receive Error Counter(RXERR) */
counter = (uint8_t)(hcan->Instance->RXERR);
/* Return the CANx Receive Error Counter(RXERR) */
return counter;
}
/*********************************************************************************
* Function : HAL_CAN_GetErrorCode
* Description : Returns the CANx's error code (ECC).
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Input : Error_Type:This parameter can be one of the following flags:
* CAN_ErrorType_SegCode
* CAN_ErrorType_Direction
* CAN_ErrorType_ErrCode
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
int8_t HAL_CAN_GetErrorCode(CAN_HandleTypeDef *hcan,uint32_t Error_Type)
{
uint8_t ErrorCode=0;
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return -1;
if(!IS_CAN_ErrorType(Error_Type)) return -1;
/* Get the CANx Error SegCode */
if(Error_Type==CAN_ErrorType_SegCode)
{
ErrorCode= (uint8_t)(hcan->Instance->ECC & CAN_ErrorType_SegCode);
}
/* Get the CANx Error Direction */
else if(Error_Type==CAN_ErrorType_Direction)
{
ErrorCode= (uint8_t)((hcan->Instance->ECC & CAN_ErrorType_Direction)>>5);
}
/* Get the CANx Error ErrCode */
else
{
ErrorCode= (uint8_t)((hcan->Instance->ECC & CAN_ErrorType_ErrCode)>>6);
}
return ErrorCode;
}
/*********************************************************************************
* Function : HAL_CAN_GetErrorAlarmCounter
* Description : Returns the CANx Error Alarm Counter(EWLR).
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
int8_t HAL_CAN_GetErrorAlarmCounter(CAN_HandleTypeDef *hcan)
{
uint8_t counter=0;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return -1;
/* Get the CANx Error Alarm Counter(EWLR) */
counter = (uint8_t)(hcan->Instance->EWLR);
/* Return the CANx Error Alarm Counter(EWLR) */
return counter;
}
/*********************************************************************************
* Function : HAL_CAN_GetArbitrationErrorPosition
* Description : Returns the CANx Arbitration Error Position(ALC).
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
int8_t HAL_CAN_GetArbitrationErrorPosition(CAN_HandleTypeDef *hcan)
{
uint8_t position=0;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return -1;
/* Get the CANx Arbitration Error Counter(ALC) */
position = (uint8_t)((hcan->Instance->ALC)+1);
/* Return the CANx Arbitration Error Counter(ALC) */
return position;
}
/*********************************************************************************
* Function : HAL_CAN_GetReceiveFiFoCounter
* Description : Returns the CANx Receive FiFo Counter(RMC).
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
int8_t HAL_CAN_GetReceiveFiFoCounter(CAN_HandleTypeDef *hcan)
{
uint8_t counter=0;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return -1;
/* Get the CANx Receive FiFo Counter(RMC) */
counter = (uint8_t)(hcan->Instance->RMC);
/* Return the CANx Receive FiFo Counter(RMC) */
return counter;
}
/*********************************************************************************
* Function : HAL_CAN_GetReceiveFiFoAddr
* Description : Returns the CANx Receive FiFo start address(RBSA).
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
int8_t HAL_CAN_GetReceiveFiFoAddr(CAN_HandleTypeDef *hcan)
{
uint8_t addr=0;
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return -1;
/* Get the CANx Receive FiFo start address(RBSA) */
addr = (uint8_t)(hcan->Instance->RBSA);
/* Return the CANx Receive FiFo start address(RBSA) */
return addr;
}
/*********************************************************************************
* Function : HAL_CAN_ReleaseReceiveFIFO
* Description : Releases the Receive FIFO.
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
void HAL_CAN_ReleaseReceiveFIFO(CAN_HandleTypeDef *hcan)
{
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return;
/* Releases the Receive FIFO. */
hcan->Instance->CMR|=CAN_CMR_RRB;
}
/*********************************************************************************
* Function : HAL_CAN_ClearOverload
* Description : Clear Overload
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
void HAL_CAN_ClearOverload(CAN_HandleTypeDef *hcan)
{
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return;
/* Clear Overload. */
hcan->Instance->CMR|=CAN_CMR_CDO;
}
/*********************************************************************************
* Function : HAL_CAN_SlefReceive
* Description : Slef Receive
* Input : hcan : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Output :
* Author : CWT Data : 2020
**********************************************************************************/
void HAL_CAN_SelfReceive(CAN_HandleTypeDef *hcan)
{
/* Check the parameters */
if(!IS_CAN_ALL_PERIPH(hcan->Instance)) return;
/* Slef Receive. */
hcan->Instance->CMR|=CAN_CMR_SRR;
while((hcan->Instance->SR & CAN_SR_TCS)==0x00); //wait for send ok
}
/*********************************************************************************
* Function : HAL_CAN_IRQHandler
* Description : This function handles CAN interrupt request.
* Input : hdma : pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for CAN module
* Outpu :
* Author : Chris_Kyle Data : 2020
**********************************************************************************/
void HAL_CAN_IRQHandler(CAN_HandleTypeDef *hcan)
{
volatile uint32_t lu32_IR;
lu32_IR = hcan->Instance->IR;//read clear
if(lu32_IR & CAN_IR_RI) //RI
{
/* CAN ReceiveIT complete callback */
HAL_CAN_GetRxMessage(hcan, hcan->RxMessage);
hcan->CAN_ReceiveIT_Callback(hcan);
}
if(lu32_IR & CAN_IR_TI) //TI
{
/* CAN TransmitIT complete callback */
hcan->CAN_TransmitIT_Callback(hcan);
}
}
|
c1c19c4a3a0036dd1f9f062c58cfef238d966d81
|
0bcd128368e2de959ca648960ffd7944067fcf27
|
/src/utils/SkMultiPictureDocumentPriv.h
|
a33bcd99c1fae39a13b4f6a5a9867d9032eec0ab
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
google/skia
|
ac6e39179cd33cf0c8a46d29c1a70bf78b4d74ee
|
bf6b239838d3eb56562fffd0856f4047867ae771
|
refs/heads/main
| 2023-08-31T21:03:04.620734
| 2023-08-31T18:24:15
| 2023-08-31T20:20:26
| 15,773,229
| 8,064
| 1,487
|
BSD-3-Clause
| 2023-09-11T13:42:07
| 2014-01-09T17:09:57
|
C++
|
UTF-8
|
C
| false
| false
| 638
|
h
|
SkMultiPictureDocumentPriv.h
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkMultiPictureDocumentPriv_DEFINED
#define SkMultiPictureDocumentPriv_DEFINED
#include "src/utils/SkMultiPictureDocument.h"
/**
* Additional API allows one to read the array of page-sizes without parsing
* the entire file. Used by DM.
*/
bool SkMultiPictureDocumentReadPageSizes(SkStreamSeekable* src,
SkDocumentPage* dstArray,
int dstArrayCount);
#endif // SkMultiPictureDocumentPriv_DEFINED
|
42efd6c1eb48c2d866c4777742ccfa0630dd3284
|
62bf09400de89c1aa77d8c2570d7f66cec0b5d36
|
/fnet_stack/service/fs/fnet_fs.c
|
b65e86feae22350d2594a3f2ee32c4bc8a545e70
|
[
"Apache-2.0"
] |
permissive
|
butok/FNET
|
41b1d2ec4cc683c1b5c188a17ab6a4bb890a6af6
|
ea43715752e6f6823bfcc8bdc94e440443112e7c
|
refs/heads/master
| 2023-08-03T16:32:09.317085
| 2023-07-20T07:01:55
| 2023-07-20T07:01:55
| 50,664,554
| 115
| 40
|
Apache-2.0
| 2023-07-20T07:01:56
| 2016-01-29T13:39:30
|
C
|
UTF-8
|
C
| false
| false
| 20,362
|
c
|
fnet_fs.c
|
/**************************************************************************
*
* Copyright 2008-2018 by Andrey Butok. FNET Community.
*
***************************************************************************
*
* 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 System API Implementation.
*
***************************************************************************/
#include "fnet.h"
#if FNET_CFG_FS
#include "fnet_fs_prv.h"
#include "fnet_fs_root.h"
/* Mount point list */
struct fnet_fs_mount_point fnet_fs_mount_list[FNET_CFG_FS_MOUNT_MAX];
/* File&dir descriptor list */
static struct fnet_fs_desc fnet_fs_desc_list[FNET_CFG_FS_DESC_MAX];
/* The list of registered FSs. */
static struct fnet_fs *fnet_fs_list;
static struct fnet_fs_mount_point *_fnet_fs_find_mount( const fnet_char_t **name );
/************************************************************************
* DESCRIPTION: This function initializes FNET FS interface.
*************************************************************************/
fnet_return_t fnet_fs_init( void )
{
fnet_return_t result = FNET_ERR;
if(fnet_fs_list == 0) /* If no init before. */
{
_fnet_fs_root_register();
result = fnet_fs_mount( FNET_FS_ROOT_NAME, "", 0 );
}
return result;
}
/************************************************************************
* DESCRIPTION: This function releases FNET FS interface.
*************************************************************************/
void fnet_fs_release( void )
{
fnet_fs_unmount("");
_fnet_fs_root_unregister();
/* Clear the rest. */
fnet_memset_zero( fnet_fs_mount_list, sizeof(struct fnet_fs_mount_point)*FNET_CFG_FS_MOUNT_MAX);
fnet_memset_zero( fnet_fs_desc_list, sizeof(struct fnet_fs_desc)*FNET_CFG_FS_DESC_MAX);
fnet_fs_list = 0;
}
/************************************************************************
* DESCRIPTION: This function registers a FS.
*************************************************************************/
void _fnet_fs_register( struct fnet_fs *fs )
{
if(fs)
{
fs->_next = fnet_fs_list;
if(fs->_next != 0)
{
fs->_next->_prev = fs;
}
fs->_prev = 0;
fnet_fs_list = fs;
}
}
/************************************************************************
* DESCRIPTION: This function unregisters a FS.
*************************************************************************/
void _fnet_fs_unregister( struct fnet_fs *fs )
{
if(fs)
{
fnet_service_mutex_lock();
if(fs->_prev == 0)
{
fnet_fs_list = fs->_next;
}
else
{
fs->_prev->_next = fs->_next;
}
if(fs->_next != 0)
{
fs->_next->_prev = fs->_prev;
}
fnet_service_mutex_unlock();
}
}
/************************************************************************
* DESCRIPTION: Returns a FS given its name.
*************************************************************************/
struct fnet_fs *_fnet_fs_find_name( fnet_char_t *name )
{
struct fnet_fs *fs;
struct fnet_fs *result = 0;
if(name)
{
for (fs = fnet_fs_list; fs != 0; fs = fs->_next)
{
if(fnet_strcmp(name, fs->name) == 0)
{
result = fs;
break;
}
}
}
return result;
}
/************************************************************************
* DESCRIPTION: Mounts a FS.
*************************************************************************/
fnet_return_t fnet_fs_mount( fnet_char_t *fs_name, const fnet_char_t *mount_name, const void *arg )
{
fnet_return_t result = FNET_ERR;
struct fnet_fs_mount_point *mount_point = 0;
struct fnet_fs *fs;
fnet_index_t i;
if(fs_name && mount_name)
{
fnet_service_mutex_lock();
fs = _fnet_fs_find_name(fs_name);
if(fs)
{
for(i = 0U; i < FNET_CFG_FS_MOUNT_MAX; i++)
{
if(fnet_fs_mount_list[i].fs == 0)
{
mount_point = &fnet_fs_mount_list[i]; /* found free mount point */
break;
}
}
if(mount_point)
{
if((fs->operations) && (fs->operations->mount))
{
result = fs->operations->mount(arg);
}
else
{
result = FNET_OK;
}
if(result == FNET_OK) /* Mount is successful */
{
mount_point->arg = arg; /* Fill mount info structure. */
mount_point->fs = fs;
fnet_strlcpy( mount_point->name, mount_name, FNET_CFG_FS_MOUNT_NAME_MAX + 1U );
}
}
}
fnet_service_mutex_unlock();
}
return result;
}
/****************************************************************/
fnet_int32_t _fnet_fs_path_cmp( const fnet_char_t **path, const fnet_char_t *name)
{
fnet_int32_t result;
/* No checks for 0 */
const fnet_char_t *s1p = *path;
const fnet_char_t *s2p = name;
while(*s1p == ' ')
{
s1p++; /* Strip leading spaces */
}
while(*s1p == FNET_FS_SPLITTER)
{
s1p++; /* Strip heading slash */
}
while((*s2p != '\0') && (*s1p == *s2p) )
{
++s1p;
++s2p;
if (*s1p == FNET_FS_SPLITTER)
{
break; /* next path element */
}
}
if(*s1p == FNET_FS_SPLITTER)
{
result = 0;
}
else
{
result = (fnet_int32_t)(*s1p) - (fnet_int32_t)(*s2p);
}
if(result == 0) /* Save end of compare */
{
*path = s1p;
}
return result;
}
/************************************************************************
* DESCRIPTION: Find mount point given its name and remove mount name from
* the path.
*************************************************************************/
static struct fnet_fs_mount_point *_fnet_fs_find_mount( const fnet_char_t **name )
{
struct fnet_fs_mount_point *result = 0;
struct fnet_fs_mount_point *tmp;
fnet_index_t i;
if(name && (*name))
{
for(i = 0U; i < FNET_CFG_FS_MOUNT_MAX; i++)
{
tmp = &fnet_fs_mount_list[i];
if((tmp->fs) && (_fnet_fs_path_cmp(name, tmp->name) == 0))
{
result = tmp;
break;
}
}
}
return result;
}
/************************************************************************
* DESCRIPTION: Unmounts a FS.
*************************************************************************/
fnet_return_t fnet_fs_unmount( const fnet_char_t *mount_name )
{
fnet_return_t result = FNET_ERR;
struct fnet_fs_mount_point *mount_point;
struct fnet_fs *fs;
if(mount_name)
{
fnet_service_mutex_lock();
mount_point = _fnet_fs_find_mount(&mount_name);
if(mount_point)
{
fs = mount_point->fs;
if(fs && (fs->operations) && (fs->operations->unmount) )
{
fs->operations->unmount(mount_point->arg);
}
fnet_memset_zero( mount_point, sizeof(struct fnet_fs_mount_point) );
result = FNET_OK;
}
fnet_service_mutex_unlock();
}
return result;
}
/************************************************************************
* DESCRIPTION: Open DIR stream.
*************************************************************************/
fnet_fs_dir_t fnet_fs_opendir( const fnet_char_t *dirname)
{
fnet_fs_dir_t result = 0;
fnet_index_t i;
struct fnet_fs_desc *dir = 0;
struct fnet_fs_mount_point *mount_point;
if(dirname)
{
fnet_service_mutex_lock();
for(i = 0U; i < FNET_CFG_FS_DESC_MAX; i++) /* Free descriptor? */
{
if(fnet_fs_desc_list[i].id == 0u)
{
dir = &fnet_fs_desc_list[i]; /* found free DIR descriptor */
break;
}
}
if(dir) /* Found free descriptor. */
{
mount_point = _fnet_fs_find_mount(&dirname);
if(mount_point && (mount_point->fs) && (mount_point->fs->dir_operations)
&& (mount_point->fs->dir_operations->opendir))
{
dir->mount = mount_point;
if(mount_point->fs->dir_operations->opendir(dir, dirname) == FNET_OK)
{
result = dir;
}
else
{
fnet_memset_zero( dir, sizeof(struct fnet_fs_desc) ); /* clear dir structure */
}
}
}
fnet_service_mutex_unlock();
}
return result;
}
/************************************************************************
* DESCRIPTION: Close DIR stream.
*************************************************************************/
fnet_return_t fnet_fs_closedir( fnet_fs_dir_t dir)
{
fnet_return_t result = FNET_ERR;
struct fnet_fs_desc *dirp = (struct fnet_fs_desc *)dir;
if(dirp)
{
fnet_service_mutex_lock();
fnet_memset_zero( dirp, sizeof(struct fnet_fs_desc) ); /* clear dir structure */
fnet_service_mutex_unlock();
result = FNET_OK;
}
return result;
}
/************************************************************************
* DESCRIPTION: Returns a pointer to a structure representing the directory
* entry.
*************************************************************************/
fnet_return_t fnet_fs_readdir(fnet_fs_dir_t dir, fnet_fs_dirent_t *dirent)
{
fnet_return_t result = FNET_ERR;
struct fnet_fs_desc *dirp = (struct fnet_fs_desc *) dir;
if(dirp)
{
if((dirp->mount) && (dirp->mount->fs)
&& (dirp->mount->fs->dir_operations)
&& (dirp->mount->fs->dir_operations->readdir))
{
fnet_service_mutex_lock();
result = dirp->mount->fs->dir_operations->readdir(dirp, dirent);
fnet_service_mutex_unlock();
}
}
return result;
}
/************************************************************************
* DESCRIPTION: Resets the position of the directory stream.
*************************************************************************/
void fnet_fs_rewinddir( fnet_fs_dir_t dir )
{
struct fnet_fs_desc *dirp = (struct fnet_fs_desc *) dir;
if(dirp)
{
fnet_service_mutex_lock();
/* Reset current index. */
dirp->pos = 0U;
fnet_service_mutex_unlock();
}
}
/************************************************************************
* DESCRIPTION: Opens the specified file.
*************************************************************************/
fnet_fs_file_t fnet_fs_fopen(const fnet_char_t *filename, const fnet_char_t *mode)
{
fnet_fs_file_t result;
result = fnet_fs_fopen_re(filename, mode, 0 );
return result;
}
/************************************************************************
* DESCRIPTION: Opens the specified file relative to.
*************************************************************************/
fnet_fs_file_t fnet_fs_fopen_re(const fnet_char_t *filename, const fnet_char_t *mode, fnet_fs_dir_t dir )
{
fnet_uint8_t mode_in = 0U;
fnet_fs_file_t result = 0;
fnet_index_t i;
struct fnet_fs_desc *file = 0;
struct fnet_fs_mount_point *mount_point;
struct fnet_fs_desc *cur_dir = (struct fnet_fs_desc *) dir;
if(filename && mode)
{
fnet_service_mutex_lock();
/* Parse the file mode. */
switch(*mode)
{
case 'r':
mode_in = FNET_FS_MODE_READ | FNET_FS_MODE_OPEN_EXISTING;
break;
case 'w':
mode_in = FNET_FS_MODE_WRITE | FNET_FS_MODE_OPEN_ALWAYS | FNET_FS_MODE_OPEN_TRUNC;
break;
case 'a':
mode_in = FNET_FS_MODE_WRITE | FNET_FS_MODE_OPEN_ALWAYS | FNET_FS_MODE_END;
break;
default:
break;
}
if(mode_in) /* Is mode correct? */
{
mode++;
if(*mode == 'b') /* Text and binary is the same for us. */
{
mode++;
}
if(*mode == '+')
{
mode_in |= FNET_FS_MODE_READ | FNET_FS_MODE_WRITE;
}
for(i = 0u; i < FNET_CFG_FS_DESC_MAX; i++) /* Free descriptor? */
{
if(fnet_fs_desc_list[i].id == 0u)
{
file = &fnet_fs_desc_list[i]; /* found free DIR descriptor */
break;
}
}
if(file) /* Found free descriptor. */
{
if(cur_dir)
{
mount_point = cur_dir->mount;
}
else
{
mount_point = _fnet_fs_find_mount(&filename);
}
if(mount_point && (mount_point->fs)
&& (mount_point->fs->file_operations)
&& (mount_point->fs->file_operations->fopen))
{
file->mount = mount_point;
if(mount_point->fs->file_operations->fopen(file, filename, mode_in, cur_dir) == FNET_OK)
{
result = file;
}
else
{
fnet_memset_zero( file, sizeof(struct fnet_fs_desc) ); /* clear file structure */
}
}
}
}
fnet_service_mutex_unlock();
}
return result;
}
/************************************************************************
* DESCRIPTION: Close DIR stream.
*************************************************************************/
fnet_return_t fnet_fs_fclose( fnet_fs_file_t file)
{
fnet_return_t result = FNET_ERR;
struct fnet_fs_desc *filep = (struct fnet_fs_desc *)file;
if(filep)
{
fnet_service_mutex_lock();
fnet_memset_zero( filep, sizeof(struct fnet_fs_desc) ); /* clear file structure */
fnet_service_mutex_unlock();
result = FNET_OK;
}
return result;
}
/************************************************************************
* DESCRIPTION: Resets the position of the file stream.
*************************************************************************/
void fnet_fs_rewind(fnet_fs_file_t file)
{
struct fnet_fs_desc *filep = (struct fnet_fs_desc *) file;
if(filep)
{
fnet_service_mutex_lock();
/* Reset current pos. */
filep->pos = 0u;
fnet_service_mutex_unlock();
}
}
/************************************************************************
* DESCRIPTION:
*************************************************************************/
fnet_size_t fnet_fs_fread(void *buf, fnet_size_t size, fnet_fs_file_t file)
{
fnet_size_t result = 0u;
struct fnet_fs_desc *filep = (struct fnet_fs_desc *) file;
fnet_size_t bytes = size;
if(filep && bytes && buf)
{
if((filep->mount) && (filep->mount->fs)
&& (filep->mount->fs->file_operations)
&& (filep->mount->fs->file_operations->fread))
{
fnet_service_mutex_lock();
result = filep->mount->fs->file_operations->fread(filep, buf, bytes);
fnet_service_mutex_unlock();
}
}
return result;
}
/************************************************************************
* DESCRIPTION: A nonzero value signifies that the end of the file has been
* reached; a value of zero signifies that it has not.
* In virtually all cases, there's no need to use feof at all.
*(feof, or more likely ferror, may be useful after a stdio call has
* returned EOF or NULL, to distinguish between an end-of-file condition
* and a read error.
*************************************************************************/
fnet_bool_t fnet_fs_feof(fnet_fs_file_t file)
{
fnet_bool_t result = FNET_FALSE;
struct fnet_fs_desc *filep = (struct fnet_fs_desc *) file;
if(filep && (filep->pos == (fnet_uint32_t)FNET_FS_EOF))
{
result = FNET_TRUE;
}
return result;
}
/************************************************************************
* DESCRIPTION: If successful, fgetc returns the next byte or character from the stream
* If unsuccessful, fgetc returns EOF.
*************************************************************************/
fnet_int32_t fnet_fs_fgetc(fnet_fs_file_t file)
{
fnet_int32_t result = FNET_FS_EOF;
struct fnet_fs_desc *filep = (struct fnet_fs_desc *) file;
fnet_uint8_t buf;
if(filep)
{
if((filep->mount) && (filep->mount->fs)
&& (filep->mount->fs->file_operations)
&& (filep->mount->fs->file_operations->fread))
{
fnet_service_mutex_lock();
if(filep->mount->fs->file_operations->fread(filep, &buf, 1u) != 0u)
{
result = (fnet_int32_t)buf;
}
fnet_service_mutex_unlock();
}
}
return result;
}
/************************************************************************
* DESCRIPTION: Change the file position indicator for the specified file.
*************************************************************************/
fnet_return_t fnet_fs_fseek (fnet_fs_file_t file, fnet_int32_t offset, fnet_fs_seek_origin_t origin)
{
fnet_return_t result = FNET_ERR;
struct fnet_fs_desc *filep = (struct fnet_fs_desc *) file;
if(filep)
{
if((filep->mount) && (filep->mount->fs)
&& (filep->mount->fs->file_operations)
&& (filep->mount->fs->file_operations->fseek))
{
fnet_service_mutex_lock();
result = filep->mount->fs->file_operations->fseek(filep, offset, origin);
fnet_service_mutex_unlock();
}
}
return result;
}
/************************************************************************
* DESCRIPTION: Returns the current offset in a stream in relation to the first byte.
*************************************************************************/
fnet_int32_t fnet_fs_ftell (fnet_fs_file_t file)
{
fnet_int32_t result = FNET_ERR;
struct fnet_fs_desc *filep = (struct fnet_fs_desc *) file;
if(filep)
{
fnet_service_mutex_lock();
result = (fnet_int32_t) filep->pos;
fnet_service_mutex_unlock();
}
return result;
}
/************************************************************************
* DESCRIPTION: Reads file info data.
*************************************************************************/
fnet_return_t fnet_fs_finfo (fnet_fs_file_t file, fnet_fs_dirent_t *dirent)
{
fnet_return_t result = FNET_ERR;
struct fnet_fs_desc *filep = (struct fnet_fs_desc *) file;
if(filep)
{
if((filep->mount) && (filep->mount->fs)
&& (filep->mount->fs->file_operations)
&& (filep->mount->fs->file_operations->finfo))
{
fnet_service_mutex_lock();
result = filep->mount->fs->file_operations->finfo(filep, dirent);
fnet_service_mutex_unlock();
}
}
return result;
}
#endif /* FNET_CFG_FS */
|
57f56b81db0614e9ee54821772a97d3f199e77e0
|
35c04ea32351dc95bc18d46e5c70dda9c1e08668
|
/Examples/KDS/tinyK20/LoRaMac-node/src/boards/tinyK20/i2c-board.c
|
24e80cf54eca1d6c9f0792a4f50e06289d6ee3b9
|
[
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
ErichStyger/mcuoneclipse
|
0f8e7a2056a26ed79d9d4a0afd64777ff0b2b2fe
|
04ad311b11860ae5f8285316010961a87fa06d0c
|
refs/heads/master
| 2023-08-28T22:54:08.501719
| 2023-08-25T15:11:44
| 2023-08-25T15:11:44
| 7,446,094
| 620
| 1,191
|
NOASSERTION
| 2020-10-16T03:13:28
| 2013-01-04T19:38:12
|
Batchfile
|
UTF-8
|
C
| false
| false
| 1,523
|
c
|
i2c-board.c
|
/**
* \file i2c-board.c
* \author Alexander Winiger (alexander.winiger@hslu.ch)
* \date 15.09.2015
* \brief Target board I2C driver implementation
*
*/
#include "board.h"
#include "i2c-board.h"
/*----------------------- Local Definitions ------------------------------*/
/*!
* The value of the maximal timeout for I2C waiting loops
*/
#define TIMEOUT_MAX 0x8000
/*!
* MCU I2C peripherals enumeration
*/
typedef enum {
I2C_0 = (uint32_t) I2C0_BASE_PTR
} I2cName;
/*------------------------ Local Variables -------------------------------*/
I2cAddrSize I2cInternalAddrSize = I2C_ADDR_SIZE_8;
void I2cMcuInit(I2c_t *obj, PinNames scl, PinNames sda)
{
}
void I2cMcuFormat(I2c_t *obj, I2cMode mode, I2cDutyCycle dutyCycle, bool I2cAckEnable,
I2cAckAddrMode AckAddrMode, uint32_t I2cFrequency)
{
}
void I2cMcuDeInit(I2c_t *obj)
{
GpioInit(&obj->Scl, obj->Scl.pin, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0);
GpioInit(&obj->Sda, obj->Sda.pin, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0);
}
void I2cSetAddrSize(I2c_t *obj, I2cAddrSize addrSize)
{
I2cInternalAddrSize = addrSize;
}
uint8_t I2cMcuWriteBuffer(I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer,
uint16_t size)
{
return SUCCESS;
}
uint8_t I2cMcuReadBuffer(I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer,
uint16_t size)
{
return SUCCESS;
}
/* Implementation of I2C0 handler named in startup code. */
void I2C0_IRQHandler(void)
{
}
|
20d6c40fcfaa885795194ed7fea32ed442967cdf
|
d9ea45dbc964799991b9191ae620d2f150652a3d
|
/Backends/Graphics5/Direct3D12/Sources/kinc/backend/graphics5/rendertarget.h
|
569ffebf13265c02eb964994a1d6395c106a3ec2
|
[
"Zlib"
] |
permissive
|
Kode/Kinc
|
6ebb1cfa11c6e9ed0e153c486f573f1d7dca5664
|
d90b7478b192c8270e0ee32c0c3ee18977becd7a
|
refs/heads/main
| 2023-08-08T16:50:01.534587
| 2023-08-07T20:22:46
| 2023-08-07T20:22:46
| 10,254,751
| 283
| 249
|
Zlib
| 2023-08-26T12:27:36
| 2013-05-23T22:22:58
|
C
|
UTF-8
|
C
| false
| false
| 751
|
h
|
rendertarget.h
|
#pragma once
#include "d3d12mini.h"
#ifdef __cplusplus
extern "C" {
#endif
enum RenderTargetResourceState { RenderTargetResourceStateUndefined, RenderTargetResourceStateRenderTarget, RenderTargetResourceStateTexture };
typedef struct {
struct ID3D12Resource *renderTarget;
struct ID3D12Resource *renderTargetReadback;
struct ID3D12DescriptorHeap *renderTargetDescriptorHeap;
struct ID3D12DescriptorHeap *srvDescriptorHeap;
struct ID3D12DescriptorHeap *depthStencilDescriptorHeap;
struct ID3D12DescriptorHeap *srvDepthDescriptorHeap;
struct ID3D12Resource *depthStencilTexture;
struct D3D12Viewport viewport;
struct D3D12Rect scissor;
int stage;
int stage_depth;
int framebuffer_index;
} RenderTarget5Impl;
#ifdef __cplusplus
}
#endif
|
c6526cd6af44db91e19101208766ba4bed2c32e3
|
6f286be4a4e16867cc6e488080b8e3eced1dcd62
|
/src/tools-TEST/GenesToApproved_Test.h
|
5082f8fe3892c9fe3e84dbc4c88f914163c8fe5f
|
[
"MIT"
] |
permissive
|
imgag/ngs-bits
|
3587404be01687d52c5a77b933874ca77faf8e6b
|
0597c96f6bc09067598c2364877d11091350bed8
|
refs/heads/master
| 2023-09-03T20:20:16.975954
| 2023-09-01T13:17:35
| 2023-09-01T13:17:35
| 38,034,492
| 110
| 36
|
MIT
| 2023-09-12T14:21:59
| 2015-06-25T07:23:55
|
C++
|
UTF-8
|
C
| false
| false
| 1,245
|
h
|
GenesToApproved_Test.h
|
#include "TestFramework.h"
#include "Settings.h"
#include "NGSD.h"
TEST_CLASS(GenesToApproved_Test)
{
Q_OBJECT
private slots:
void default_parameters()
{
if (!NGSD::isAvailable(true)) SKIP("Test needs access to the NGSD test database!");
//init
NGSD db(true);
db.init();
EXECUTE("NGSDImportHGNC", "-test -in " + TESTDATA("data_in/NGSDImportHGNC_in1.txt") + " -ensembl " + TESTDATA("data_in/NGSDImportEnsembl_in.gff3"));
//test
EXECUTE("GenesToApproved", "-test -in " + TESTDATA("data_in/GenesToApproved_in1.txt") + " -out out/GenesToApproved_out1.txt");
COMPARE_FILES("out/GenesToApproved_out1.txt", TESTDATA("data_out/GenesToApproved_out1.txt"));
}
void with_report_ambiguous()
{
if (!NGSD::isAvailable(true)) SKIP("Test needs access to the NGSD test database!");
//init
NGSD db(true);
db.init();
EXECUTE("NGSDImportHGNC", "-test -in " + TESTDATA("data_in/NGSDImportHGNC_in1.txt") + " -ensembl " + TESTDATA("data_in/NGSDImportEnsembl_in.gff3"));
//test
EXECUTE("GenesToApproved", "-test -in " + TESTDATA("data_in/GenesToApproved_in1.txt") + " -report_ambiguous -out out/GenesToApproved_out2.txt");
COMPARE_FILES("out/GenesToApproved_out2.txt", TESTDATA("data_out/GenesToApproved_out2.txt"));
}
};
|
54041e24fc019f4ae9a4f4d56a9f67b05c16c64b
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/nuvoton/libraries/n9h30/Driver/Include/nu_lcd.h
|
69b7c747a8bbadb6bc8f58fea3e082ae19beb63f
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 11,676
|
h
|
nu_lcd.h
|
/**************************************************************************//**
* @file lcd.h
* @version V1.00
* @brief N9H30 LCD driver header file
*
* SPDX-License-Identifier: Apache-2.0
* @copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
#ifndef __NU_LCD_H__
#define __NU_LCD_H__
#ifdef __cplusplus
extern "C"
{
#endif
/** @addtogroup N9H30_Device_Driver N9H30 Device Driver
@{
*/
/** @addtogroup N9H30_LCD_Driver LCD Driver
@{
*/
/** @addtogroup N9H30_LCD_EXPORTED_CONSTANTS LCD Exported Constants
@{
*/
/// @cond HIDDEN_SYMBOLS
/* bit definition of REG_LCM_DCCS register */
#define VPOSTB_HC_EN ((UINT32)1<<31)
#define VPOSTB_DISP_ON (1<<25)
#define VPOSTB_ITUEN (1<<15)
#define VPOSTB_OSD_SRC_YUV422 (0<<12)
#define VPOSTB_OSD_SRC_YCBCR422 (1<<12)
#define VPOSTB_OSD_SRC_RGB888 (2<<12)
#define VPOSTB_OSD_SRC_RGB666 (3<<12)
#define VPOSTB_OSD_SRC_RGB565 (4<<12)
#define VPOSTB_OSD_SRC_RGB444_LOW (5<<12)
#define VPOSTB_OSD_SRC_RGB444_HIGH (7<<12)
#define VPOSTB_VA_SRC_YUV422 (0<<8 )
#define VPOSTB_VA_SRC_YCBCR422 (1<<8 )
#define VPOSTB_VA_SRC_RGB888 (2<<8 )
#define VPOSTB_VA_SRC_RGB666 (3<<8 )
#define VPOSTB_VA_SRC_RGB565 (4<<8 )
#define VPOSTB_VA_SRC_RGB444_LOW (5<<8 )
#define VPOSTB_VA_SRC_RGB444_HIGH (7<<8 )
#define VPOSTB_SINGLE (1<<7 )
#define VPOSTB_FIELD_INTR (1<<6 )
#define VPOSTB_CMD_ON (1<<5 )
#define VPOSTB_DISP_INT_EN (1<<4 )
#define VPOSTB_DISP_OUT_EN (1<<3 )
#define VPOSTB_OSD_EN (1<<2 )
#define VPOSTB_VA_EN (1<<1 )
#define VPOSTB_ENG_RST (1)
/* bit definition of REG_LCM_DEV_CTRL register */
#define VPOSTB_CMDHIGH (0)
#define VPOSTB_CMDLOW ((UINT32)1<<31)
#define VPOSTB_CM16t18LOW (0)
#define VPOSTB_CM16t18HIGH ((UINT32)1<<30)
#define VPOSTB_CMD8 (0)
#define VPOSTB_CMD16 ((UINT32)1<<29)
#define VPOSTB_IM256K_9or18 (0)
#define VPOSTB_IM256K_8or16 ((UINT32)1<<28)
#define VPOSTB_MPU80 (0)
#define VPOSTB_MPU68 (1<<27)
#define VPOSTB_DATA8or9 (0)
#define VPOSTB_DATA16or18 (1<<26)
#define VPOSTB_COLORTYPE_4K (0)
#define VPOSTB_COLORTYPE_64K (1<<24)
#define VPOSTB_COLORTYPE_256K (2<<24)
#define VPOSTB_COLORTYPE_16M (3<<24)
#define VPOSTB_LACE (1<<23)
#define VPOSTB_VR_LACE (1<<22)
#define VPOSTB_V_POL (1<<21)
#define VPOSTB_H_POL (1<<20)
#define VPOSTB_FAL_D (1<<19)
#define VPOSTB_YUV2CCIR (1<<16)
#define VPOSTB_DEVICE_SYNC_YUV422 (0)
#define VPOSTB_DEVICE_SYNC_UNIPAC (4<<5)
#define VPOSTB_DEVICE_SYNC_EPSON (5<<5)
#define VPOSTB_DEVICE_SYNC_HIGHCOLOR (6<<5)
#define VPOSTB_DEVICE_MPU (7<<5)
#define VPOSTB_SWAP_YUYV (1<<1)
/* bit definition of REG_LCM_INT_CS register */
#define VPOSTB_DISP_F_INT ((UINT32)1<<31)
#define VPOSTB_DISP_F_STATUS (1<<30)
#define VPOSTB_UNDERRUN_INT (1<<29)
#define VPOSTB_BUS_ERROR_INT (1<<28)
#define VPOSTB_FLY_ERR (1<<27)
#define VPOSTB_UNDERRUN_EN (1<<1)
#define VPOSTB_DISP_F_EN (1)
/* bit definition of REG_LCM_VA_FBCTRL register */
#define VPOSTB_DB_EN ((UINT32)1<<31)
#define VPOSTB_FLY_EN (1<<12)
/* bit definition of REG_LCM_OSD_OVERLAY register */
#define VPOSTB_BLI_ON (1<<9)
#define VPOSTB_CKEY_ON (1<<8)
#define DISPLAY_VIDEO (0)
#define DISPLAY_OSD (1)
#define DISPLAY_SYNTHESIZED (2)
/// @endcond HIDDEN_SYMBOLS
#define VA_SRC_YUV422 (0<<8 ) /*!< YUV422 format */
#define VA_SRC_YCBCR422 (1<<8 ) /*!< YCBCR422 format */
#define VA_SRC_RGB888 (2<<8 ) /*!< RGB888 format */
#define VA_SRC_RGB666 (3<<8 ) /*!< RGB666 format */
#define VA_SRC_RGB565 (4<<8 ) /*!< RGB565 format */
#define VA_SRC_RGB444_LOW (5<<8 ) /*!< RGB444 low nibble format */
#define VA_SRC_RGB444_HIGH (7<<8 ) /*!< RGB444 high nibble format */
#define OSD_SRC_YUV422 (0<<12) /*!< YUV422 format */
#define OSD_SRC_YCBCR422 (1<<12) /*!< YCBCR422 format */
#define OSD_SRC_RGB888 (2<<12) /*!< RGB888 format */
#define OSD_SRC_RGB666 (3<<12) /*!< RGB666 format */
#define OSD_SRC_RGB565 (4<<12) /*!< RGB565 format */
#define OSD_SRC_RGB444_LOW (5<<12) /*!< RGB444 low nibble format */
#define OSD_SRC_RGB444_HIGH (7<<12) /*!< RGB444 high nibble format */
#define OSD_SRC_RGB332 (6<<12) /*!< RGB332 format */
#define VPOST_DISPLAY_SINGLE 1 /*!< Single display mode */
#define VPOST_DISPLAY_CONTINUOUS 0 /*!< Continuous display mode */
#define VPOSTB_OSD_VUP_1X (0<<16) /*!< OSD vertical scale up 1x */
#define VPOSTB_OSD_VUP_2X (1<<16) /*!< OSD vertical scale up 2x */
#define VPOSTB_OSD_VUP_4X (2<<16) /*!< OSD vertical scale up 4x */
#define DISPLAY_VIDEO (0) /*!< Display video data */
#define DISPLAY_OSD (1) /*!< Display OSD data */
#define DISPLAY_SYNTHESIZED (2) /*!< Display synthesized data */
#define VA_SCALE_INTERPOLATION (0) /*!< Scale mode is interpolation */
#define VA_SCALE_DUPLICATION (1<<15) /*!< Scale mode is duplication */
#pragma anon_unions
typedef enum va_hcmode_e
{
HC_MODE0, /*!< 32X32X2bpp 4 color */
HC_MODE1, /*!< 32X32X2bpp 3 color and 1 transparent */
HC_MODE2, /*!< 64X64X2bpp 4 color */
HC_MODE3, /*!< 64X64X2bpp 3 color and 1 transparent */
HC_MODE4, /*!< 128X128X1bpp 2 color */
HC_MODE5 /*!< 128X128X1bpp 1 color and 1 transparent */
} VA_HCMODE_E;
typedef struct
{
uint32_t ucVASrcFormat; /*!< User input Display source format */
uint32_t nScreenWidth; /*!< Driver output,LCD width */
uint32_t nScreenHeight; /*!< Driver output,LCD height */
uint32_t nFrameBufferSize; /*!< Driver output,Frame buffer size(malloc by driver) */
uint8_t ucROT90; /*!< Rotate 90 degree or not */
} LCDFORMATEX;
typedef struct
{
uint32_t ucOSDSrcFormat; /*!< User input, OSD source format */
uint32_t nXstart; /*!< User input, OSD X axis position */
uint32_t nYstart; /*!< User input, OSD Y axis position */
uint32_t nOSDWidth; /*!< User input, OSD width */
uint32_t nOSDHeight; /*!< User input, OSD height */
uint32_t nImageWidth; /*!< User input, The width of OSD source image width */
uint32_t *pFrameBuffer; /*!< User input, The address of OSD source image */
} OSDFORMATEX;
enum DIS_PANEL
{
DIS_PANEL_E50A2V1 = 0,
DIS_PANEL_ILI9341_MPU80,
DIS_LSA40AT9001,
DIS_PANEL_FW070TFT,
DIS_PANEL_FW043TFT,
DIS_PANEL_FW070TFT_WSVGA,
DIS_PANEL_CNT
};
typedef struct
{
uint32_t u32DevWidth; /*!< Panel width */
uint32_t u32DevHeight; /*!< Panel height */
uint32_t u32CmdLow; /*!< MPU command line low indicator */
uint32_t u32Cmd16t18; /*!< MPU command width */
uint32_t u32CmdBusWidth; /*!< MPU bus width */
uint32_t u32DataBusWidth; /*!< Display bus width */
uint32_t u32MPU_Mode; /*!< MPU mode */
uint32_t u32DisplayColors; /*!< Display colors */
uint32_t u32DevType; /*!< Type of display panel */
union
{
uint32_t u32Reg_CRTCSIZE; /*!< CRTCSIZE register value */
struct
{
uint32_t HTT: 11; /*!< Horizontal Total Pixels */
uint32_t : 5;
uint32_t VTT: 11; /*!< Vertical Total Scan Lines */
uint32_t : 5;
} sCRTCSIZE;
};
union
{
uint32_t u32Reg_CRTCDEND; /*!< CRTCDEND register value */
struct
{
uint32_t HDEND: 11; /*!< Horizontal Display Enable End */
uint32_t : 5;
uint32_t VDEND: 11; /*!< Vertical Display Enable End */
uint32_t : 5;
} sCRTCDEND;
};
union
{
uint32_t u32Reg_CRTCHR; /*!< CRTCHR register value */
struct
{
uint32_t HRS: 11; /*!< Internal Horizontal Retrace Start Timing */
uint32_t : 5;
uint32_t HRE: 11; /*!< Internal Horizontal Retrace End Low */
uint32_t : 5;
} sCRTCHR;
};
union
{
uint32_t u32Reg_CRTCHSYNC; /*!< CRTCHSYNC register value */
struct
{
uint32_t HSYNC_S: 11; /*!< Horizontal Sync Start Timing */
uint32_t : 5;
uint32_t HSYNC_E: 11; /*!< Horizontal Sync End Timing */
uint32_t : 3;
uint32_t HSYNC_SHIFT: 2; /*!< Hsync Signal Adjustment For Multi-Cycles Per Pixel Mode Of Sync-Based Unipac-LCD */
} sCRTCHSYNC;
};
union
{
uint32_t u32Reg_CRTCVR; /*!< CRTCVR register value */
struct
{
uint32_t VRS: 11; /*!< Vertical Internal Retrace Start Timing */
uint32_t : 5;
uint32_t VRE: 11; /*!< Vertical Internal Retrace End Low */
uint32_t : 5;
} sCRTCVR;
};
} VPOST_T;
#define LCM_ERR_ID 0xFFFF0400 /*!< LCM library ID */
/* error code */
#define ERR_NULL_BUF (LCM_ERR_ID | 0x04) /*!< error memory location */
#define ERR_NO_DEVICE (LCM_ERR_ID | 0x05) /*!< error no device */
#define ERR_BAD_PARAMETER (LCM_ERR_ID | 0x06) /*!< error for bad parameter */
#define ERR_POWER_STATE (LCM_ERR_ID | 0x07) /*!< error power state control */
/*@}*/ /* end of group N9H30_LCD_EXPORTED_CONSTANTS */
/** @addtogroup N9H30_LCD_EXPORTED_FUNCTIONS LCD Exported Functions
@{
*/
void vpostLCMInit(uint32_t u32DisplayPanelID);
uint8_t *vpostGetFrameBuffer(void);
uint8_t *vpostGetMultiFrameBuffer(uint32_t u32Cnt);
void vpostLCMDeinit(void);
void vpostSetDisplayMode(uint8_t u8DisplayMode);
void vpostSetVASrc(uint32_t u32VASrcType);
void vpostVAStartTrigger(void);
void vpostVAStopTrigger(void);
void vpostVAScalingCtrl(uint8_t u8HIntegral, uint16_t u16HDecimal, uint8_t u8VIntegral, uint16_t u16VDecimal, uint32_t u32Mode);
void vpostOSDSetColKey(uint8_t u8CKeyColorR, uint8_t u8CKeyColorG, uint8_t u8CKeyColorB);
void vpostOSDSetColMask(uint8_t u8MaskColorR, uint8_t u8MaskColorG, uint8_t u8MaskColorB);
void vpostOSDSetBlinking(uint8_t u8OSDBlinkVcnt);
void vpostOSDDisableBlinking(void);
void vpostSetOSDSrc(uint32_t u32OSDSrcType);
uint8_t *vpostGetOSDBuffer(void);
void vpostOSDEnable(void);
void vpostOSDDisable(void);
void vpostOSDScalingCtrl(uint8_t u8HIntegral, uint16_t u16HDecimal, uint8_t u8VScall);
void vpostOSDSetWindow(uint32_t u32XStart, uint32_t u32YStart, uint32_t u32Width, uint32_t u32Height);
void vpostHCInit(uint32_t *u32CursorBMPBuff, VA_HCMODE_E ucMode);
void vpostHCPosCtrl(uint32_t u32CursorX, uint32_t u32CursorY);
void vpostOSDSetOverlay(uint8_t u8OSDDisplayMatch, uint8_t u8OSDDisplayUnMatch, uint8_t u8OSDSynW);
void vpostMPUWriteAddr(uint16_t uscmd);
void vpostMPUWriteData(uint16_t usdata);
uint32_t vpostMPUReadData(void);
VPOST_T *vpostLCMGetInstance(uint32_t u32DisplayPanelID);
void vpostSetFrameBuffer(uint8_t *pu8BufPtr);
void vpostSetOSDBuffer(uint8_t *pu8BufPtr);
uint8_t *vpostGetMultiOSDBuffer(uint32_t u32Cnt);
/*@}*/ /* end of group N9H30_LCD_EXPORTED_FUNCTIONS */
/*@}*/ /* end of group N9H30_LCD_Driver */
/*@}*/ /* end of group N9H30_Device_Driver */
#ifdef __cplusplus
}
#endif
#endif //__NU_LCD_H__
|
cbee2f8476583772be98ca52c0d30d33f9206e36
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/os/board/rtl8721csm/src/component/common/bluetooth/realtek/sdk/inc/gap_privacy.h
|
66cfed3e05bfdf9376bb5adc2f52c51716b88053
|
[
"Apache-2.0",
"GPL-1.0-or-later",
"BSD-3-Clause",
"ISC",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive"
] |
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
| 10,765
|
h
|
gap_privacy.h
|
/**
*****************************************************************************************
* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
*****************************************************************************************
* @file gap_privacy.h
* @brief This file contains all the functions prototypes for the GAP bond and pairing
* related functions.
* @details
* @author ranhui
* @date 2016-02-18
* @version v1.0
* *************************************************************************************
*/
/*============================================================================*
* Define to prevent recursive inclusion
*============================================================================*/
#ifndef GAP_PRIVACY_H
#define GAP_PRIVACY_H
#ifdef __cplusplus
extern "C"
{
#endif
/*============================================================================*
* Header Files
*============================================================================*/
#include <bt_flags.h>
#if F_BT_LE_PRIVACY_SUPPORT
#include <gap_le.h>
#include <gap_conn_le.h>
#include <gap_storage_le.h>
/** @defgroup GAP_PRIVACY_MODULE GAP LE Privacy
* @brief GAP LE privacy
* @{
*/
/*============================================================================*
* Types
*============================================================================*/
/** @defgroup Gap_Privacy_Exported_Types GAP Privacy Exported Types
* @{
*/
/** @brief Define the privacy callback type */
#define GAP_MSG_LE_PRIVACY_RESOLUTION_STATUS_INFO 0x00 /*!<Notification msg type for resolution status */
#define GAP_MSG_LE_PRIVACY_SET_RESOLV_PRIV_ADDR_TIMEOUT 0x01 /*!<response msg type for le_privacy_set_resolv_priv_addr_timeout */
#define GAP_MSG_LE_PRIVACY_MODIFY_RESOLV_LIST 0x02 /*!<response msg type for le_privacy_modify_resolv_list */
#define GAP_MSG_LE_PRIVACY_READ_PEER_RESOLV_ADDR 0x03 /*!<response msg type for le_privacy_read_peer_resolv_addr */
#define GAP_MSG_LE_PRIVACY_READ_LOCAL_RESOLV_ADDR 0x04 /*!<response msg type for le_privacy_read_local_resolv_addr */
#define GAP_MSG_LE_PRIVACY_SET_MODE 0x05 /*!<response msg type for le_privacy_set_mode */
/** @brief Define the subtype of Message IO_MSG_TYPE_BT_STATUS */
typedef enum
{
GAP_PARAM_PRIVACY_TIMEOUT = 0x300, /*!< Timeout value for privacy */
GAP_PARAM_PRIVACY_RESOLUTION_STATE = 0x301, /*!< Resolution state */
GAP_PARAM_PRIVACY_RESOLV_LIST_SIZE = 0x302, /*!< Resolvable list size */
} T_LE_PRIVACY_PARAM_TYPE;
/** @brief Define the privacy state */
typedef enum
{
LE_PRIVACY_RESOLUTION_DISABLED,
LE_PRIVACY_RESOLUTION_DISABLING,
LE_PRIVACY_RESOLUTION_ENABLING,
LE_PRIVACY_RESOLUTION_ENABLED
} T_LE_PRIVACY_STATE;
/** @brief LE resolution status info */
typedef struct
{
T_LE_PRIVACY_STATE status;
uint16_t cause;
} T_LE_PRIVACY_RESOLUTION_STATUS_INFO;
/** @brief Response of le set resolvable private address timeout request.*/
typedef struct
{
uint16_t cause;
} T_LE_PRIVACY_SET_RESOLV_PRIV_ADDR_TIMEOUT_RSP;
/** @brief Response of le modify resolvable list request.*/
typedef struct
{
T_GAP_RESOLV_LIST_OP operation;
uint16_t cause;
} T_LE_PRIVACY_MODIFY_RESOLV_LIST_RSP;
/** @brief Response of le read peer resolvable address request.*/
typedef struct
{
uint16_t cause;
uint8_t peer_resolv_addr[6];
} T_LE_PRIVACY_READ_PEER_RESOLV_ADDR_RSP;
/** @brief Response of le read local resolvable address request.*/
typedef struct
{
uint16_t cause;
uint8_t local_resolv_addr[6];
} T_LE_PRIVACY_READ_LOCAL_RESOLV_ADDR_RSP;
/** @brief Response of set privacy mode.*/
typedef struct
{
uint16_t cause;
} T_LE_PRIVACY_SET_MODE_RSP;
/** @brief LE privacy callback data */
typedef union
{
T_LE_PRIVACY_RESOLUTION_STATUS_INFO le_privacy_resolution_status_info;
T_LE_PRIVACY_SET_RESOLV_PRIV_ADDR_TIMEOUT_RSP *p_le_privacy_set_resolv_priv_addr_timeout_rsp;
T_LE_PRIVACY_MODIFY_RESOLV_LIST_RSP *p_le_privacy_modify_resolv_list_rsp;
T_LE_PRIVACY_READ_PEER_RESOLV_ADDR_RSP *p_le_privacy_read_peer_resolv_addr_rsp;
T_LE_PRIVACY_READ_LOCAL_RESOLV_ADDR_RSP *p_le_privacy_read_local_resolv_addr_rsp;
T_LE_PRIVACY_SET_MODE_RSP *p_le_privacy_set_mode_rsp;
} T_LE_PRIVACY_CB_DATA;
/**
* @brief Callback for gap to notify app
* @param[in] msg_type Callback msy type
* @param[in] msg_data Message data @ref T_LE_PRIVACY_CB_DATA.
* @return result
* @retval results @ref T_APP_RESULT
*/
typedef T_APP_RESULT(*P_FUN_PRIVACY_CB)(uint8_t msg_type, T_LE_PRIVACY_CB_DATA msg_data);
/** End of Gap_Privacy_Exported_Types
* @}
*/
/*============================================================================*
* Functions
*============================================================================*/
/** @defgroup Gap_Privacy_Exported_Functions GAP Privacy Exported Functions
* @{
*/
/**
* @brief Set a LE privacy parameter.
*
* NOTE: You can call this function with a LE Privacy Parameter type and it will set the
* LE Privacy Parameter. LE Privacy Parameters are defined in @ref T_LE_PRIVACY_PARAM_TYPE.
* @param[in] param LE Privacy parameter type: @ref T_LE_PRIVACY_PARAM_TYPE.
* @param[in] len Length of data to write.
* @param[in] p_value Pointer to data to write.
* @return Operation result.
* @retval GAP_CAUSE_SUCCESS Operation success.
* @retval Others Operation failure.
*/
T_GAP_CAUSE le_privacy_set_param(T_LE_PRIVACY_PARAM_TYPE param, uint8_t len, void *p_value);
/**
* @brief Get a LE privacy parameter.
*
* NOTE: You can call this function with a LE Privacy Parameter type and it will get a
* LE Privacy Parameter. LE Privacy Parameters are defined in @ref T_LE_PRIVACY_PARAM_TYPE.
*
* @param[in] param GAP parameter type: @ref T_LE_PRIVACY_PARAM_TYPE
* @param[in,out] p_value Pointer to location to get the parameter value. This is dependent on
* the parameter ID and WILL be cast to the appropriate
* data type (For example: if data type of param is uint16_t, p_value will be cast to
* pointer of uint16_t).
* @return Operation result.
* @retval GAP_CAUSE_SUCCESS Operation success.
* @retval Others Operation failure.
*/
T_GAP_CAUSE le_privacy_get_param(T_LE_PRIVACY_PARAM_TYPE param, void *p_value);
/**
* @brief Register privacy callback to stack.
* @param[in] p_privacy_cb Callback function provided by the APP to handle le privacy messages sent from the BT Stack.
* @arg NULL -> Use gap defualt callback function.
* @arg Other -> Use application defined callback function.
* @return none
*/
void le_privacy_register_cb(P_FUN_PRIVACY_CB p_privacy_cb);
/**
* @brief Enable/disable le privacy address resolution mode.
* @param[in] enable Enable or disable address resolution.
* @return Operation result
* @retval GAP_CAUSE_SUCCESS Operation success.
* @retval Others Operation failure.
*/
T_GAP_CAUSE le_privacy_set_addr_resolution(bool enable);
/**
* @brief Read peer resolvable random address.
* @param[in] peer_identity_address_type Peer identity address type.
* @param[in] peer_identity_address Peer identity address.
* @return Operation result
* @retval GAP_CAUSE_SUCCESS Operation success.
* @retval Others Operation failure.
*/
T_GAP_CAUSE le_privacy_read_peer_resolv_addr(T_GAP_IDENT_ADDR_TYPE peer_identity_address_type,
uint8_t *peer_identity_address);
/**
* @brief Read local resolvable random address.
* @param[in] peer_identity_address_type Peer identity address type.
* @param[in] peer_identity_address Peer identity address.
* @return Operation result
* @retval GAP_CAUSE_SUCCESS Operation success.
* @retval Others Operation failure.
*/
T_GAP_CAUSE le_privacy_read_local_resolv_addr(T_GAP_IDENT_ADDR_TYPE peer_identity_address_type,
uint8_t *peer_identity_address);
/**
* @brief Set resolvable private address timeout.
* @return Operation result
* @retval GAP_CAUSE_SUCCESS Operation success.
* @retval Others Operation failure.
*/
T_GAP_CAUSE le_privacy_set_resolv_priv_addr_timeout(void);
/**
* @brief Modicy local resolvable device list.
* NOTE: You can call this function to add, remove or clear the resolvable list
*
* @param[in] operation type, @ref T_GAP_RESOLV_LIST_OP.
* @param[in] peer_identity_address_type Peer identity address type.
* @param[in] peer_identity_address Peer identity address.
* @return Operation result
* @retval GAP_CAUSE_SUCCESS Operation success.
* @retval Others Operation failure.
*/
T_GAP_CAUSE le_privacy_modify_resolv_list(T_GAP_RESOLV_LIST_OP operation,
T_GAP_IDENT_ADDR_TYPE peer_identity_address_type,
uint8_t *peer_identity_address);
/**
* @brief Set privacy mode.
* @param[in] peer_identity_address_type Peer identity address type.
* @param[in] peer_identity_address Peer identity address.
* @param[in] privacy_mode Privacy mode @ref T_GAP_PRIVACY_MODE.
* @return Operation result
* @retval GAP_CAUSE_SUCCESS Operation success.
* @retval GAP_CAUSE_SEND_REQ_FAILED Operation failure.
*/
T_GAP_CAUSE le_privacy_set_mode(T_GAP_IDENT_ADDR_TYPE peer_identity_address_type,
uint8_t *peer_identity_address,
T_GAP_PRIVACY_MODE privacy_mode);
/**
* @brief Convert remote bluetooth device address type to identity address type.
* @param[in] type Bluetooth device address type @ref T_GAP_REMOTE_ADDR_TYPE.
* @return Identity address type @ref T_GAP_IDENT_ADDR_TYPE
* @retval GAP_IDENT_ADDR_PUBLIC Public identity address.
* @retval GAP_IDENT_ADDR_RAND Random identity address.
*/
T_GAP_IDENT_ADDR_TYPE le_privacy_convert_addr_type(T_GAP_REMOTE_ADDR_TYPE type);
/** @} */ /* End of group Gap_Privacy_Exported_Functions */
/** @} */ /* End of group GAP_PRIVACY_MODULE */
#endif
#ifdef __cplusplus
}
#endif
#endif /* GAP_PRIVACY_H */
|
7e192db81335f05141b05745f3b6215ff85e575a
|
e683a0b8dbb87c7ceb99e0d06896174a559d2c67
|
/Tools/swat/termcap/tparam.c
|
24702899a8346881845868ee29fd9edff8f8e936
|
[
"GPL-2.0-only",
"Apache-2.0"
] |
permissive
|
bluewaysw/pcgeos
|
f093d79567d977d992f47065056d14d5a04b9f14
|
c6ae4c8e77b54b9ff654c3916f2191f8b1a1b65d
|
refs/heads/master
| 2023-08-31T00:17:54.481175
| 2023-08-29T19:00:49
| 2023-08-29T19:00:49
| 157,968,410
| 603
| 88
|
Apache-2.0
| 2023-09-13T07:44:06
| 2018-11-17T09:09:55
|
Assembly
|
UTF-8
|
C
| false
| false
| 7,519
|
c
|
tparam.c
|
/* Merge parameters into a termcap entry string.
Copyright (C) 1985, 87, 93, 95 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, 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; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#else /* not HAVE_CONFIG_H */
#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
#define bcopy(s, d, n) memcpy ((d), (s), (n))
#endif
#ifdef STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#else
char *malloc ();
char *realloc ();
#endif
#endif /* not HAVE_CONFIG_H */
#ifndef NULL
#define NULL (char *) 0
#endif
#ifndef emacs
static void
memory_out ()
{
write (2, "virtual memory exhausted\n", 25);
exit (1);
}
static char *
xmalloc (size)
unsigned size;
{
register char *tem = malloc (size);
if (!tem)
memory_out ();
return tem;
}
static char *
xrealloc (ptr, size)
char *ptr;
unsigned size;
{
register char *tem = realloc (ptr, size);
if (!tem)
memory_out ();
return tem;
}
#endif /* not emacs */
/* Assuming STRING is the value of a termcap string entry
containing `%' constructs to expand parameters,
merge in parameter values and store result in block OUTSTRING points to.
LEN is the length of OUTSTRING. If more space is needed,
a block is allocated with `malloc'.
The value returned is the address of the resulting string.
This may be OUTSTRING or may be the address of a block got with `malloc'.
In the latter case, the caller must free the block.
The fourth and following args to tparam serve as the parameter values. */
static char *tparam1 ();
/* VARARGS 2 */
char *
tparam (string, outstring, len, arg0, arg1, arg2, arg3)
char *string;
char *outstring;
int len;
int arg0, arg1, arg2, arg3;
{
int arg[4];
arg[0] = arg0;
arg[1] = arg1;
arg[2] = arg2;
arg[3] = arg3;
return tparam1 (string, outstring, len, NULL, NULL, arg);
}
char *BC;
char *UP;
static char tgoto_buf[50];
char *
tgoto (cm, hpos, vpos)
char *cm;
int hpos, vpos;
{
int args[2];
if (!cm)
return NULL;
args[0] = vpos;
args[1] = hpos;
return tparam1 (cm, tgoto_buf, 50, UP, BC, args);
}
static char *
tparam1 (string, outstring, len, up, left, argp)
char *string;
char *outstring;
int len;
char *up, *left;
register int *argp;
{
register int c;
register char *p = string;
register char *op = outstring;
char *outend;
int outlen = 0;
register int tem;
int *old_argp = argp;
int doleft = 0;
int doup = 0;
outend = outstring + len;
while (1)
{
/* If the buffer might be too short, make it bigger. */
if (op + 5 >= outend)
{
register char *new;
if (outlen == 0)
{
outlen = len + 40;
new = (char *) xmalloc (outlen);
outend += 40;
bcopy (outstring, new, op - outstring);
}
else
{
outend += outlen;
outlen *= 2;
new = (char *) xrealloc (outstring, outlen);
}
op += new - outstring;
outend += new - outstring;
outstring = new;
}
c = *p++;
if (!c)
break;
if (c == '%')
{
c = *p++;
tem = *argp;
switch (c)
{
case 'd': /* %d means output in decimal. */
if (tem < 10)
goto onedigit;
if (tem < 100)
goto twodigit;
case '3': /* %3 means output in decimal, 3 digits. */
if (tem > 999)
{
*op++ = tem / 1000 + '0';
tem %= 1000;
}
*op++ = tem / 100 + '0';
case '2': /* %2 means output in decimal, 2 digits. */
twodigit:
tem %= 100;
*op++ = tem / 10 + '0';
onedigit:
*op++ = tem % 10 + '0';
argp++;
break;
case 'C':
/* For c-100: print quotient of value by 96, if nonzero,
then do like %+. */
if (tem >= 96)
{
*op++ = tem / 96;
tem %= 96;
}
case '+': /* %+x means add character code of char x. */
tem += *p++;
case '.': /* %. means output as character. */
if (left)
{
/* If want to forbid output of 0 and \n and \t,
and this is one of them, increment it. */
while (tem == 0 || tem == '\n' || tem == '\t')
{
tem++;
if (argp == old_argp)
doup++, outend -= strlen (up);
else
doleft++, outend -= strlen (left);
}
}
*op++ = tem ? tem : 0200;
case 'f': /* %f means discard next arg. */
argp++;
break;
case 'b': /* %b means back up one arg (and re-use it). */
argp--;
break;
case 'r': /* %r means interchange following two args. */
argp[0] = argp[1];
argp[1] = tem;
old_argp++;
break;
case '>': /* %>xy means if arg is > char code of x, */
if (argp[0] > *p++) /* then add char code of y to the arg, */
argp[0] += *p; /* and in any case don't output. */
p++; /* Leave the arg to be output later. */
break;
case 'a': /* %a means arithmetic. */
/* Next character says what operation.
Add or subtract either a constant or some other arg. */
/* First following character is + to add or - to subtract
or = to assign. */
/* Next following char is 'p' and an arg spec
(0100 plus position of that arg relative to this one)
or 'c' and a constant stored in a character. */
tem = p[2] & 0177;
if (p[1] == 'p')
tem = argp[tem - 0100];
if (p[0] == '-')
argp[0] -= tem;
else if (p[0] == '+')
argp[0] += tem;
else if (p[0] == '*')
argp[0] *= tem;
else if (p[0] == '/')
argp[0] /= tem;
else
argp[0] = tem;
p += 3;
break;
case 'i': /* %i means add one to arg, */
argp[0] ++; /* and leave it to be output later. */
argp[1] ++; /* Increment the following arg, too! */
break;
case '%': /* %% means output %; no arg. */
goto ordinary;
case 'n': /* %n means xor each of next two args with 140. */
argp[0] ^= 0140;
argp[1] ^= 0140;
break;
case 'm': /* %m means xor each of next two args with 177. */
argp[0] ^= 0177;
argp[1] ^= 0177;
break;
case 'B': /* %B means express arg as BCD char code. */
argp[0] += 6 * (tem / 10);
break;
case 'D': /* %D means weird Delta Data transformation. */
argp[0] -= 2 * (tem % 16);
break;
}
}
else
/* Ordinary character in the argument string. */
ordinary:
*op++ = c;
}
*op = 0;
while (doup-- > 0)
strcat (op, up);
while (doleft-- > 0)
strcat (op, left);
return outstring;
}
#ifdef DEBUG
main (argc, argv)
int argc;
char **argv;
{
char buf[50];
int args[3];
args[0] = atoi (argv[2]);
args[1] = atoi (argv[3]);
args[2] = atoi (argv[4]);
tparam1 (argv[1], buf, "LEFT", "UP", args);
printf ("%s\n", buf);
return 0;
}
#endif /* DEBUG */
|
d014cdc44bff5c4154d1a1ccc8e65e3642570e96
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/pinctrl/vt8500/pinctrl-vt8500.c
|
f2fe9f85cfa6672685e1944a3aa01b6944bb49b3
|
[
"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
| 15,558
|
c
|
pinctrl-vt8500.c
|
/*
* Pinctrl data for VIA VT8500 SoC
*
* Copyright (c) 2013 Tony Prisk <linux@prisktech.co.nz>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*/
#include <linux/io.h>
#include <linux/module.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include "pinctrl-wmt.h"
/*
* Describe the register offsets within the GPIO memory space
* The dedicated external GPIO's should always be listed in bank 0
* so they are exported in the 0..31 range which is what users
* expect.
*
* Do not reorder these banks as it will change the pin numbering
*/
static const struct wmt_pinctrl_bank_registers vt8500_banks[] = {
WMT_PINCTRL_BANK(NO_REG, 0x3C, 0x5C, 0x7C, NO_REG, NO_REG), /* 0 */
WMT_PINCTRL_BANK(0x00, 0x20, 0x40, 0x60, NO_REG, NO_REG), /* 1 */
WMT_PINCTRL_BANK(0x04, 0x24, 0x44, 0x64, NO_REG, NO_REG), /* 2 */
WMT_PINCTRL_BANK(0x08, 0x28, 0x48, 0x68, NO_REG, NO_REG), /* 3 */
WMT_PINCTRL_BANK(0x0C, 0x2C, 0x4C, 0x6C, NO_REG, NO_REG), /* 4 */
WMT_PINCTRL_BANK(0x10, 0x30, 0x50, 0x70, NO_REG, NO_REG), /* 5 */
WMT_PINCTRL_BANK(0x14, 0x34, 0x54, 0x74, NO_REG, NO_REG), /* 6 */
};
/* Please keep sorted by bank/bit */
#define WMT_PIN_EXTGPIO0 WMT_PIN(0, 0)
#define WMT_PIN_EXTGPIO1 WMT_PIN(0, 1)
#define WMT_PIN_EXTGPIO2 WMT_PIN(0, 2)
#define WMT_PIN_EXTGPIO3 WMT_PIN(0, 3)
#define WMT_PIN_EXTGPIO4 WMT_PIN(0, 4)
#define WMT_PIN_EXTGPIO5 WMT_PIN(0, 5)
#define WMT_PIN_EXTGPIO6 WMT_PIN(0, 6)
#define WMT_PIN_EXTGPIO7 WMT_PIN(0, 7)
#define WMT_PIN_EXTGPIO8 WMT_PIN(0, 8)
#define WMT_PIN_UART0RTS WMT_PIN(1, 0)
#define WMT_PIN_UART0TXD WMT_PIN(1, 1)
#define WMT_PIN_UART0CTS WMT_PIN(1, 2)
#define WMT_PIN_UART0RXD WMT_PIN(1, 3)
#define WMT_PIN_UART1RTS WMT_PIN(1, 4)
#define WMT_PIN_UART1TXD WMT_PIN(1, 5)
#define WMT_PIN_UART1CTS WMT_PIN(1, 6)
#define WMT_PIN_UART1RXD WMT_PIN(1, 7)
#define WMT_PIN_SPI0CLK WMT_PIN(1, 8)
#define WMT_PIN_SPI0SS WMT_PIN(1, 9)
#define WMT_PIN_SPI0MISO WMT_PIN(1, 10)
#define WMT_PIN_SPI0MOSI WMT_PIN(1, 11)
#define WMT_PIN_SPI1CLK WMT_PIN(1, 12)
#define WMT_PIN_SPI1SS WMT_PIN(1, 13)
#define WMT_PIN_SPI1MISO WMT_PIN(1, 14)
#define WMT_PIN_SPI1MOSI WMT_PIN(1, 15)
#define WMT_PIN_SPI2CLK WMT_PIN(1, 16)
#define WMT_PIN_SPI2SS WMT_PIN(1, 17)
#define WMT_PIN_SPI2MISO WMT_PIN(1, 18)
#define WMT_PIN_SPI2MOSI WMT_PIN(1, 19)
#define WMT_PIN_SDDATA0 WMT_PIN(2, 0)
#define WMT_PIN_SDDATA1 WMT_PIN(2, 1)
#define WMT_PIN_SDDATA2 WMT_PIN(2, 2)
#define WMT_PIN_SDDATA3 WMT_PIN(2, 3)
#define WMT_PIN_MMCDATA0 WMT_PIN(2, 4)
#define WMT_PIN_MMCDATA1 WMT_PIN(2, 5)
#define WMT_PIN_MMCDATA2 WMT_PIN(2, 6)
#define WMT_PIN_MMCDATA3 WMT_PIN(2, 7)
#define WMT_PIN_SDCLK WMT_PIN(2, 8)
#define WMT_PIN_SDWP WMT_PIN(2, 9)
#define WMT_PIN_SDCMD WMT_PIN(2, 10)
#define WMT_PIN_MSDATA0 WMT_PIN(2, 16)
#define WMT_PIN_MSDATA1 WMT_PIN(2, 17)
#define WMT_PIN_MSDATA2 WMT_PIN(2, 18)
#define WMT_PIN_MSDATA3 WMT_PIN(2, 19)
#define WMT_PIN_MSCLK WMT_PIN(2, 20)
#define WMT_PIN_MSBS WMT_PIN(2, 21)
#define WMT_PIN_MSINS WMT_PIN(2, 22)
#define WMT_PIN_I2C0SCL WMT_PIN(2, 24)
#define WMT_PIN_I2C0SDA WMT_PIN(2, 25)
#define WMT_PIN_I2C1SCL WMT_PIN(2, 26)
#define WMT_PIN_I2C1SDA WMT_PIN(2, 27)
#define WMT_PIN_MII0RXD0 WMT_PIN(3, 0)
#define WMT_PIN_MII0RXD1 WMT_PIN(3, 1)
#define WMT_PIN_MII0RXD2 WMT_PIN(3, 2)
#define WMT_PIN_MII0RXD3 WMT_PIN(3, 3)
#define WMT_PIN_MII0RXCLK WMT_PIN(3, 4)
#define WMT_PIN_MII0RXDV WMT_PIN(3, 5)
#define WMT_PIN_MII0RXERR WMT_PIN(3, 6)
#define WMT_PIN_MII0PHYRST WMT_PIN(3, 7)
#define WMT_PIN_MII0TXD0 WMT_PIN(3, 8)
#define WMT_PIN_MII0TXD1 WMT_PIN(3, 9)
#define WMT_PIN_MII0TXD2 WMT_PIN(3, 10)
#define WMT_PIN_MII0TXD3 WMT_PIN(3, 11)
#define WMT_PIN_MII0TXCLK WMT_PIN(3, 12)
#define WMT_PIN_MII0TXEN WMT_PIN(3, 13)
#define WMT_PIN_MII0TXERR WMT_PIN(3, 14)
#define WMT_PIN_MII0PHYPD WMT_PIN(3, 15)
#define WMT_PIN_MII0COL WMT_PIN(3, 16)
#define WMT_PIN_MII0CRS WMT_PIN(3, 17)
#define WMT_PIN_MII0MDIO WMT_PIN(3, 18)
#define WMT_PIN_MII0MDC WMT_PIN(3, 19)
#define WMT_PIN_SEECS WMT_PIN(3, 20)
#define WMT_PIN_SEECK WMT_PIN(3, 21)
#define WMT_PIN_SEEDI WMT_PIN(3, 22)
#define WMT_PIN_SEEDO WMT_PIN(3, 23)
#define WMT_PIN_IDEDREQ0 WMT_PIN(3, 24)
#define WMT_PIN_IDEDREQ1 WMT_PIN(3, 25)
#define WMT_PIN_IDEIOW WMT_PIN(3, 26)
#define WMT_PIN_IDEIOR WMT_PIN(3, 27)
#define WMT_PIN_IDEDACK WMT_PIN(3, 28)
#define WMT_PIN_IDEIORDY WMT_PIN(3, 29)
#define WMT_PIN_IDEINTRQ WMT_PIN(3, 30)
#define WMT_PIN_VDIN0 WMT_PIN(4, 0)
#define WMT_PIN_VDIN1 WMT_PIN(4, 1)
#define WMT_PIN_VDIN2 WMT_PIN(4, 2)
#define WMT_PIN_VDIN3 WMT_PIN(4, 3)
#define WMT_PIN_VDIN4 WMT_PIN(4, 4)
#define WMT_PIN_VDIN5 WMT_PIN(4, 5)
#define WMT_PIN_VDIN6 WMT_PIN(4, 6)
#define WMT_PIN_VDIN7 WMT_PIN(4, 7)
#define WMT_PIN_VDOUT0 WMT_PIN(4, 8)
#define WMT_PIN_VDOUT1 WMT_PIN(4, 9)
#define WMT_PIN_VDOUT2 WMT_PIN(4, 10)
#define WMT_PIN_VDOUT3 WMT_PIN(4, 11)
#define WMT_PIN_VDOUT4 WMT_PIN(4, 12)
#define WMT_PIN_VDOUT5 WMT_PIN(4, 13)
#define WMT_PIN_NANDCLE0 WMT_PIN(4, 14)
#define WMT_PIN_NANDCLE1 WMT_PIN(4, 15)
#define WMT_PIN_VDOUT6_7 WMT_PIN(4, 16)
#define WMT_PIN_VHSYNC WMT_PIN(4, 17)
#define WMT_PIN_VVSYNC WMT_PIN(4, 18)
#define WMT_PIN_TSDIN0 WMT_PIN(5, 8)
#define WMT_PIN_TSDIN1 WMT_PIN(5, 9)
#define WMT_PIN_TSDIN2 WMT_PIN(5, 10)
#define WMT_PIN_TSDIN3 WMT_PIN(5, 11)
#define WMT_PIN_TSDIN4 WMT_PIN(5, 12)
#define WMT_PIN_TSDIN5 WMT_PIN(5, 13)
#define WMT_PIN_TSDIN6 WMT_PIN(5, 14)
#define WMT_PIN_TSDIN7 WMT_PIN(5, 15)
#define WMT_PIN_TSSYNC WMT_PIN(5, 16)
#define WMT_PIN_TSVALID WMT_PIN(5, 17)
#define WMT_PIN_TSCLK WMT_PIN(5, 18)
#define WMT_PIN_LCDD0 WMT_PIN(6, 0)
#define WMT_PIN_LCDD1 WMT_PIN(6, 1)
#define WMT_PIN_LCDD2 WMT_PIN(6, 2)
#define WMT_PIN_LCDD3 WMT_PIN(6, 3)
#define WMT_PIN_LCDD4 WMT_PIN(6, 4)
#define WMT_PIN_LCDD5 WMT_PIN(6, 5)
#define WMT_PIN_LCDD6 WMT_PIN(6, 6)
#define WMT_PIN_LCDD7 WMT_PIN(6, 7)
#define WMT_PIN_LCDD8 WMT_PIN(6, 8)
#define WMT_PIN_LCDD9 WMT_PIN(6, 9)
#define WMT_PIN_LCDD10 WMT_PIN(6, 10)
#define WMT_PIN_LCDD11 WMT_PIN(6, 11)
#define WMT_PIN_LCDD12 WMT_PIN(6, 12)
#define WMT_PIN_LCDD13 WMT_PIN(6, 13)
#define WMT_PIN_LCDD14 WMT_PIN(6, 14)
#define WMT_PIN_LCDD15 WMT_PIN(6, 15)
#define WMT_PIN_LCDD16 WMT_PIN(6, 16)
#define WMT_PIN_LCDD17 WMT_PIN(6, 17)
#define WMT_PIN_LCDCLK WMT_PIN(6, 18)
#define WMT_PIN_LCDDEN WMT_PIN(6, 19)
#define WMT_PIN_LCDLINE WMT_PIN(6, 20)
#define WMT_PIN_LCDFRM WMT_PIN(6, 21)
#define WMT_PIN_LCDBIAS WMT_PIN(6, 22)
static const struct pinctrl_pin_desc vt8500_pins[] = {
PINCTRL_PIN(WMT_PIN_EXTGPIO0, "extgpio0"),
PINCTRL_PIN(WMT_PIN_EXTGPIO1, "extgpio1"),
PINCTRL_PIN(WMT_PIN_EXTGPIO2, "extgpio2"),
PINCTRL_PIN(WMT_PIN_EXTGPIO3, "extgpio3"),
PINCTRL_PIN(WMT_PIN_EXTGPIO4, "extgpio4"),
PINCTRL_PIN(WMT_PIN_EXTGPIO5, "extgpio5"),
PINCTRL_PIN(WMT_PIN_EXTGPIO6, "extgpio6"),
PINCTRL_PIN(WMT_PIN_EXTGPIO7, "extgpio7"),
PINCTRL_PIN(WMT_PIN_EXTGPIO8, "extgpio8"),
PINCTRL_PIN(WMT_PIN_UART0RTS, "uart0_rts"),
PINCTRL_PIN(WMT_PIN_UART0TXD, "uart0_txd"),
PINCTRL_PIN(WMT_PIN_UART0CTS, "uart0_cts"),
PINCTRL_PIN(WMT_PIN_UART0RXD, "uart0_rxd"),
PINCTRL_PIN(WMT_PIN_UART1RTS, "uart1_rts"),
PINCTRL_PIN(WMT_PIN_UART1TXD, "uart1_txd"),
PINCTRL_PIN(WMT_PIN_UART1CTS, "uart1_cts"),
PINCTRL_PIN(WMT_PIN_UART1RXD, "uart1_rxd"),
PINCTRL_PIN(WMT_PIN_SPI0CLK, "spi0_clk"),
PINCTRL_PIN(WMT_PIN_SPI0SS, "spi0_ss"),
PINCTRL_PIN(WMT_PIN_SPI0MISO, "spi0_miso"),
PINCTRL_PIN(WMT_PIN_SPI0MOSI, "spi0_mosi"),
PINCTRL_PIN(WMT_PIN_SPI1CLK, "spi1_clk"),
PINCTRL_PIN(WMT_PIN_SPI1SS, "spi1_ss"),
PINCTRL_PIN(WMT_PIN_SPI1MISO, "spi1_miso"),
PINCTRL_PIN(WMT_PIN_SPI1MOSI, "spi1_mosi"),
PINCTRL_PIN(WMT_PIN_SPI2CLK, "spi2_clk"),
PINCTRL_PIN(WMT_PIN_SPI2SS, "spi2_ss"),
PINCTRL_PIN(WMT_PIN_SPI2MISO, "spi2_miso"),
PINCTRL_PIN(WMT_PIN_SPI2MOSI, "spi2_mosi"),
PINCTRL_PIN(WMT_PIN_SDDATA0, "sd_data0"),
PINCTRL_PIN(WMT_PIN_SDDATA1, "sd_data1"),
PINCTRL_PIN(WMT_PIN_SDDATA2, "sd_data2"),
PINCTRL_PIN(WMT_PIN_SDDATA3, "sd_data3"),
PINCTRL_PIN(WMT_PIN_MMCDATA0, "mmc_data0"),
PINCTRL_PIN(WMT_PIN_MMCDATA1, "mmc_data1"),
PINCTRL_PIN(WMT_PIN_MMCDATA2, "mmc_data2"),
PINCTRL_PIN(WMT_PIN_MMCDATA3, "mmc_data3"),
PINCTRL_PIN(WMT_PIN_SDCLK, "sd_clk"),
PINCTRL_PIN(WMT_PIN_SDWP, "sd_wp"),
PINCTRL_PIN(WMT_PIN_SDCMD, "sd_cmd"),
PINCTRL_PIN(WMT_PIN_MSDATA0, "ms_data0"),
PINCTRL_PIN(WMT_PIN_MSDATA1, "ms_data1"),
PINCTRL_PIN(WMT_PIN_MSDATA2, "ms_data2"),
PINCTRL_PIN(WMT_PIN_MSDATA3, "ms_data3"),
PINCTRL_PIN(WMT_PIN_MSCLK, "ms_clk"),
PINCTRL_PIN(WMT_PIN_MSBS, "ms_bs"),
PINCTRL_PIN(WMT_PIN_MSINS, "ms_ins"),
PINCTRL_PIN(WMT_PIN_I2C0SCL, "i2c0_scl"),
PINCTRL_PIN(WMT_PIN_I2C0SDA, "i2c0_sda"),
PINCTRL_PIN(WMT_PIN_I2C1SCL, "i2c1_scl"),
PINCTRL_PIN(WMT_PIN_I2C1SDA, "i2c1_sda"),
PINCTRL_PIN(WMT_PIN_MII0RXD0, "mii0_rxd0"),
PINCTRL_PIN(WMT_PIN_MII0RXD1, "mii0_rxd1"),
PINCTRL_PIN(WMT_PIN_MII0RXD2, "mii0_rxd2"),
PINCTRL_PIN(WMT_PIN_MII0RXD3, "mii0_rxd3"),
PINCTRL_PIN(WMT_PIN_MII0RXCLK, "mii0_rxclk"),
PINCTRL_PIN(WMT_PIN_MII0RXDV, "mii0_rxdv"),
PINCTRL_PIN(WMT_PIN_MII0RXERR, "mii0_rxerr"),
PINCTRL_PIN(WMT_PIN_MII0PHYRST, "mii0_phyrst"),
PINCTRL_PIN(WMT_PIN_MII0TXD0, "mii0_txd0"),
PINCTRL_PIN(WMT_PIN_MII0TXD1, "mii0_txd1"),
PINCTRL_PIN(WMT_PIN_MII0TXD2, "mii0_txd2"),
PINCTRL_PIN(WMT_PIN_MII0TXD3, "mii0_txd3"),
PINCTRL_PIN(WMT_PIN_MII0TXCLK, "mii0_txclk"),
PINCTRL_PIN(WMT_PIN_MII0TXEN, "mii0_txen"),
PINCTRL_PIN(WMT_PIN_MII0TXERR, "mii0_txerr"),
PINCTRL_PIN(WMT_PIN_MII0PHYPD, "mii0_phypd"),
PINCTRL_PIN(WMT_PIN_MII0COL, "mii0_col"),
PINCTRL_PIN(WMT_PIN_MII0CRS, "mii0_crs"),
PINCTRL_PIN(WMT_PIN_MII0MDIO, "mii0_mdio"),
PINCTRL_PIN(WMT_PIN_MII0MDC, "mii0_mdc"),
PINCTRL_PIN(WMT_PIN_SEECS, "see_cs"),
PINCTRL_PIN(WMT_PIN_SEECK, "see_ck"),
PINCTRL_PIN(WMT_PIN_SEEDI, "see_di"),
PINCTRL_PIN(WMT_PIN_SEEDO, "see_do"),
PINCTRL_PIN(WMT_PIN_IDEDREQ0, "ide_dreq0"),
PINCTRL_PIN(WMT_PIN_IDEDREQ1, "ide_dreq1"),
PINCTRL_PIN(WMT_PIN_IDEIOW, "ide_iow"),
PINCTRL_PIN(WMT_PIN_IDEIOR, "ide_ior"),
PINCTRL_PIN(WMT_PIN_IDEDACK, "ide_dack"),
PINCTRL_PIN(WMT_PIN_IDEIORDY, "ide_iordy"),
PINCTRL_PIN(WMT_PIN_IDEINTRQ, "ide_intrq"),
PINCTRL_PIN(WMT_PIN_VDIN0, "vdin0"),
PINCTRL_PIN(WMT_PIN_VDIN1, "vdin1"),
PINCTRL_PIN(WMT_PIN_VDIN2, "vdin2"),
PINCTRL_PIN(WMT_PIN_VDIN3, "vdin3"),
PINCTRL_PIN(WMT_PIN_VDIN4, "vdin4"),
PINCTRL_PIN(WMT_PIN_VDIN5, "vdin5"),
PINCTRL_PIN(WMT_PIN_VDIN6, "vdin6"),
PINCTRL_PIN(WMT_PIN_VDIN7, "vdin7"),
PINCTRL_PIN(WMT_PIN_VDOUT0, "vdout0"),
PINCTRL_PIN(WMT_PIN_VDOUT1, "vdout1"),
PINCTRL_PIN(WMT_PIN_VDOUT2, "vdout2"),
PINCTRL_PIN(WMT_PIN_VDOUT3, "vdout3"),
PINCTRL_PIN(WMT_PIN_VDOUT4, "vdout4"),
PINCTRL_PIN(WMT_PIN_VDOUT5, "vdout5"),
PINCTRL_PIN(WMT_PIN_NANDCLE0, "nand_cle0"),
PINCTRL_PIN(WMT_PIN_NANDCLE1, "nand_cle1"),
PINCTRL_PIN(WMT_PIN_VDOUT6_7, "vdout6_7"),
PINCTRL_PIN(WMT_PIN_VHSYNC, "vhsync"),
PINCTRL_PIN(WMT_PIN_VVSYNC, "vvsync"),
PINCTRL_PIN(WMT_PIN_TSDIN0, "tsdin0"),
PINCTRL_PIN(WMT_PIN_TSDIN1, "tsdin1"),
PINCTRL_PIN(WMT_PIN_TSDIN2, "tsdin2"),
PINCTRL_PIN(WMT_PIN_TSDIN3, "tsdin3"),
PINCTRL_PIN(WMT_PIN_TSDIN4, "tsdin4"),
PINCTRL_PIN(WMT_PIN_TSDIN5, "tsdin5"),
PINCTRL_PIN(WMT_PIN_TSDIN6, "tsdin6"),
PINCTRL_PIN(WMT_PIN_TSDIN7, "tsdin7"),
PINCTRL_PIN(WMT_PIN_TSSYNC, "tssync"),
PINCTRL_PIN(WMT_PIN_TSVALID, "tsvalid"),
PINCTRL_PIN(WMT_PIN_TSCLK, "tsclk"),
PINCTRL_PIN(WMT_PIN_LCDD0, "lcd_d0"),
PINCTRL_PIN(WMT_PIN_LCDD1, "lcd_d1"),
PINCTRL_PIN(WMT_PIN_LCDD2, "lcd_d2"),
PINCTRL_PIN(WMT_PIN_LCDD3, "lcd_d3"),
PINCTRL_PIN(WMT_PIN_LCDD4, "lcd_d4"),
PINCTRL_PIN(WMT_PIN_LCDD5, "lcd_d5"),
PINCTRL_PIN(WMT_PIN_LCDD6, "lcd_d6"),
PINCTRL_PIN(WMT_PIN_LCDD7, "lcd_d7"),
PINCTRL_PIN(WMT_PIN_LCDD8, "lcd_d8"),
PINCTRL_PIN(WMT_PIN_LCDD9, "lcd_d9"),
PINCTRL_PIN(WMT_PIN_LCDD10, "lcd_d10"),
PINCTRL_PIN(WMT_PIN_LCDD11, "lcd_d11"),
PINCTRL_PIN(WMT_PIN_LCDD12, "lcd_d12"),
PINCTRL_PIN(WMT_PIN_LCDD13, "lcd_d13"),
PINCTRL_PIN(WMT_PIN_LCDD14, "lcd_d14"),
PINCTRL_PIN(WMT_PIN_LCDD15, "lcd_d15"),
PINCTRL_PIN(WMT_PIN_LCDD16, "lcd_d16"),
PINCTRL_PIN(WMT_PIN_LCDD17, "lcd_d17"),
PINCTRL_PIN(WMT_PIN_LCDCLK, "lcd_clk"),
PINCTRL_PIN(WMT_PIN_LCDDEN, "lcd_den"),
PINCTRL_PIN(WMT_PIN_LCDLINE, "lcd_line"),
PINCTRL_PIN(WMT_PIN_LCDFRM, "lcd_frm"),
PINCTRL_PIN(WMT_PIN_LCDBIAS, "lcd_bias"),
};
/* Order of these names must match the above list */
static const char * const vt8500_groups[] = {
"extgpio0",
"extgpio1",
"extgpio2",
"extgpio3",
"extgpio4",
"extgpio5",
"extgpio6",
"extgpio7",
"extgpio8",
"uart0_rts",
"uart0_txd",
"uart0_cts",
"uart0_rxd",
"uart1_rts",
"uart1_txd",
"uart1_cts",
"uart1_rxd",
"spi0_clk",
"spi0_ss",
"spi0_miso",
"spi0_mosi",
"spi1_clk",
"spi1_ss",
"spi1_miso",
"spi1_mosi",
"spi2_clk",
"spi2_ss",
"spi2_miso",
"spi2_mosi",
"sd_data0",
"sd_data1",
"sd_data2",
"sd_data3",
"mmc_data0",
"mmc_data1",
"mmc_data2",
"mmc_data3",
"sd_clk",
"sd_wp",
"sd_cmd",
"ms_data0",
"ms_data1",
"ms_data2",
"ms_data3",
"ms_clk",
"ms_bs",
"ms_ins",
"i2c0_scl",
"i2c0_sda",
"i2c1_scl",
"i2c1_sda",
"mii0_rxd0",
"mii0_rxd1",
"mii0_rxd2",
"mii0_rxd3",
"mii0_rxclk",
"mii0_rxdv",
"mii0_rxerr",
"mii0_phyrst",
"mii0_txd0",
"mii0_txd1",
"mii0_txd2",
"mii0_txd3",
"mii0_txclk",
"mii0_txen",
"mii0_txerr",
"mii0_phypd",
"mii0_col",
"mii0_crs",
"mii0_mdio",
"mii0_mdc",
"see_cs",
"see_ck",
"see_di",
"see_do",
"ide_dreq0",
"ide_dreq1",
"ide_iow",
"ide_ior",
"ide_dack",
"ide_iordy",
"ide_intrq",
"vdin0",
"vdin1",
"vdin2",
"vdin3",
"vdin4",
"vdin5",
"vdin6",
"vdin7",
"vdout0",
"vdout1",
"vdout2",
"vdout3",
"vdout4",
"vdout5",
"nand_cle0",
"nand_cle1",
"vdout6_7",
"vhsync",
"vvsync",
"tsdin0",
"tsdin1",
"tsdin2",
"tsdin3",
"tsdin4",
"tsdin5",
"tsdin6",
"tsdin7",
"tssync",
"tsvalid",
"tsclk",
"lcd_d0",
"lcd_d1",
"lcd_d2",
"lcd_d3",
"lcd_d4",
"lcd_d5",
"lcd_d6",
"lcd_d7",
"lcd_d8",
"lcd_d9",
"lcd_d10",
"lcd_d11",
"lcd_d12",
"lcd_d13",
"lcd_d14",
"lcd_d15",
"lcd_d16",
"lcd_d17",
"lcd_clk",
"lcd_den",
"lcd_line",
"lcd_frm",
"lcd_bias",
};
static int vt8500_pinctrl_probe(struct platform_device *pdev)
{
struct wmt_pinctrl_data *data;
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(&pdev->dev, "failed to allocate data\n");
return -ENOMEM;
}
data->banks = vt8500_banks;
data->nbanks = ARRAY_SIZE(vt8500_banks);
data->pins = vt8500_pins;
data->npins = ARRAY_SIZE(vt8500_pins);
data->groups = vt8500_groups;
data->ngroups = ARRAY_SIZE(vt8500_groups);
return wmt_pinctrl_probe(pdev, data);
}
static int vt8500_pinctrl_remove(struct platform_device *pdev)
{
return wmt_pinctrl_remove(pdev);
}
static struct of_device_id wmt_pinctrl_of_match[] = {
{ .compatible = "via,vt8500-pinctrl" },
{ /* sentinel */ },
};
static struct platform_driver wmt_pinctrl_driver = {
.probe = vt8500_pinctrl_probe,
.remove = vt8500_pinctrl_remove,
.driver = {
.name = "pinctrl-vt8500",
.owner = THIS_MODULE,
.of_match_table = wmt_pinctrl_of_match,
},
};
module_platform_driver(wmt_pinctrl_driver);
MODULE_AUTHOR("Tony Prisk <linux@prisktech.co.nz>");
MODULE_DESCRIPTION("VIA VT8500 Pincontrol driver");
MODULE_LICENSE("GPL v2");
MODULE_DEVICE_TABLE(of, wmt_pinctrl_of_match);
|
5f973a9aba6c4707cf1fb40de09df9752830a3dd
|
de21f9075f55640514c29ef0f1fe3f0690845764
|
/src/util/nondet_bool.h
|
b1bc0e4badd26e9b27d5686e91f2ae6b92102444
|
[
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-4-Clause"
] |
permissive
|
diffblue/cbmc
|
975a074ac445febb3b5715f8792beb545522dc18
|
decd2839c2f51a54b2ad0f3e89fdc1b4bf78cd16
|
refs/heads/develop
| 2023-08-31T05:52:05.342195
| 2023-08-30T13:31:51
| 2023-08-30T13:31:51
| 51,877,056
| 589
| 309
|
NOASSERTION
| 2023-09-14T18:49:17
| 2016-02-16T23:03:52
|
C++
|
UTF-8
|
C
| false
| false
| 792
|
h
|
nondet_bool.h
|
/*******************************************************************\
Module: Nondeterministic boolean helper
Author: Chris Smowton, chris@smowton.net
\*******************************************************************/
/// \file
/// Nondeterministic boolean helper
#ifndef CPROVER_UTIL_NONDET_BOOL_H
#define CPROVER_UTIL_NONDET_BOOL_H
#include "std_expr.h"
/// \param type: desired type (C_bool or plain bool)
/// \param source_location: source location
/// \return nondet expr of that type
inline exprt
get_nondet_bool(const typet &type, const source_locationt &source_location)
{
// We force this to 0 and 1 and won't consider
// other values.
return typecast_exprt(
side_effect_expr_nondett(bool_typet(), source_location), type);
}
#endif // CPROVER_UTIL_NONDET_BOOL_H
|
395443ae3ec6ccd317efa0becbcbf5a0eb4cbd31
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/input/ff-memless.c
|
74c0d8c6002aca6f74957c7f3a596f63e550199c
|
[
"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
| 14,537
|
c
|
ff-memless.c
|
/*
* Force feedback support for memoryless devices
*
* Copyright (c) 2006 Anssi Hannula <anssi.hannula@gmail.com>
* Copyright (c) 2006 Dmitry Torokhov <dtor@mail.ru>
*/
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* #define DEBUG */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/jiffies.h>
#include <linux/fixp-arith.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Anssi Hannula <anssi.hannula@gmail.com>");
MODULE_DESCRIPTION("Force feedback support for memoryless devices");
/* Number of effects handled with memoryless devices */
#define FF_MEMLESS_EFFECTS 16
/* Envelope update interval in ms */
#define FF_ENVELOPE_INTERVAL 50
#define FF_EFFECT_STARTED 0
#define FF_EFFECT_PLAYING 1
#define FF_EFFECT_ABORTING 2
struct ml_effect_state {
struct ff_effect *effect;
unsigned long flags; /* effect state (STARTED, PLAYING, etc) */
int count; /* loop count of the effect */
unsigned long play_at; /* start time */
unsigned long stop_at; /* stop time */
unsigned long adj_at; /* last time the effect was sent */
};
struct ml_device {
void *private;
struct ml_effect_state states[FF_MEMLESS_EFFECTS];
int gain;
struct timer_list timer;
struct input_dev *dev;
int (*play_effect)(struct input_dev *dev, void *data,
struct ff_effect *effect);
};
static const struct ff_envelope *get_envelope(const struct ff_effect *effect)
{
static const struct ff_envelope empty_envelope;
switch (effect->type) {
case FF_PERIODIC:
return &effect->u.periodic.envelope;
case FF_CONSTANT:
return &effect->u.constant.envelope;
default:
return &empty_envelope;
}
}
/*
* Check for the next time envelope requires an update on memoryless devices
*/
static unsigned long calculate_next_time(struct ml_effect_state *state)
{
const struct ff_envelope *envelope = get_envelope(state->effect);
unsigned long attack_stop, fade_start, next_fade;
if (envelope->attack_length) {
attack_stop = state->play_at +
msecs_to_jiffies(envelope->attack_length);
if (time_before(state->adj_at, attack_stop))
return state->adj_at +
msecs_to_jiffies(FF_ENVELOPE_INTERVAL);
}
if (state->effect->replay.length) {
if (envelope->fade_length) {
/* check when fading should start */
fade_start = state->stop_at -
msecs_to_jiffies(envelope->fade_length);
if (time_before(state->adj_at, fade_start))
return fade_start;
/* already fading, advance to next checkpoint */
next_fade = state->adj_at +
msecs_to_jiffies(FF_ENVELOPE_INTERVAL);
if (time_before(next_fade, state->stop_at))
return next_fade;
}
return state->stop_at;
}
return state->play_at;
}
static void ml_schedule_timer(struct ml_device *ml)
{
struct ml_effect_state *state;
unsigned long now = jiffies;
unsigned long earliest = 0;
unsigned long next_at;
int events = 0;
int i;
pr_debug("calculating next timer\n");
for (i = 0; i < FF_MEMLESS_EFFECTS; i++) {
state = &ml->states[i];
if (!test_bit(FF_EFFECT_STARTED, &state->flags))
continue;
if (test_bit(FF_EFFECT_PLAYING, &state->flags))
next_at = calculate_next_time(state);
else
next_at = state->play_at;
if (time_before_eq(now, next_at) &&
(++events == 1 || time_before(next_at, earliest)))
earliest = next_at;
}
if (!events) {
pr_debug("no actions\n");
del_timer(&ml->timer);
} else {
pr_debug("timer set\n");
mod_timer(&ml->timer, earliest);
}
}
/*
* Apply an envelope to a value
*/
static int apply_envelope(struct ml_effect_state *state, int value,
struct ff_envelope *envelope)
{
struct ff_effect *effect = state->effect;
unsigned long now = jiffies;
int time_from_level;
int time_of_envelope;
int envelope_level;
int difference;
if (envelope->attack_length &&
time_before(now,
state->play_at + msecs_to_jiffies(envelope->attack_length))) {
pr_debug("value = 0x%x, attack_level = 0x%x\n",
value, envelope->attack_level);
time_from_level = jiffies_to_msecs(now - state->play_at);
time_of_envelope = envelope->attack_length;
envelope_level = min_t(u16, envelope->attack_level, 0x7fff);
} else if (envelope->fade_length && effect->replay.length &&
time_after(now,
state->stop_at - msecs_to_jiffies(envelope->fade_length)) &&
time_before(now, state->stop_at)) {
time_from_level = jiffies_to_msecs(state->stop_at - now);
time_of_envelope = envelope->fade_length;
envelope_level = min_t(u16, envelope->fade_level, 0x7fff);
} else
return value;
difference = abs(value) - envelope_level;
pr_debug("difference = %d\n", difference);
pr_debug("time_from_level = 0x%x\n", time_from_level);
pr_debug("time_of_envelope = 0x%x\n", time_of_envelope);
difference = difference * time_from_level / time_of_envelope;
pr_debug("difference = %d\n", difference);
return value < 0 ?
-(difference + envelope_level) : (difference + envelope_level);
}
/*
* Return the type the effect has to be converted into (memless devices)
*/
static int get_compatible_type(struct ff_device *ff, int effect_type)
{
if (test_bit(effect_type, ff->ffbit))
return effect_type;
if (effect_type == FF_PERIODIC && test_bit(FF_RUMBLE, ff->ffbit))
return FF_RUMBLE;
pr_err("invalid type in get_compatible_type()\n");
return 0;
}
/*
* Only left/right direction should be used (under/over 0x8000) for
* forward/reverse motor direction (to keep calculation fast & simple).
*/
static u16 ml_calculate_direction(u16 direction, u16 force,
u16 new_direction, u16 new_force)
{
if (!force)
return new_direction;
if (!new_force)
return direction;
return (((u32)(direction >> 1) * force +
(new_direction >> 1) * new_force) /
(force + new_force)) << 1;
}
/*
* Combine two effects and apply gain.
*/
static void ml_combine_effects(struct ff_effect *effect,
struct ml_effect_state *state,
int gain)
{
struct ff_effect *new = state->effect;
unsigned int strong, weak, i;
int x, y;
fixp_t level;
switch (new->type) {
case FF_CONSTANT:
i = new->direction * 360 / 0xffff;
level = fixp_new16(apply_envelope(state,
new->u.constant.level,
&new->u.constant.envelope));
x = fixp_mult(fixp_sin(i), level) * gain / 0xffff;
y = fixp_mult(-fixp_cos(i), level) * gain / 0xffff;
/*
* here we abuse ff_ramp to hold x and y of constant force
* If in future any driver wants something else than x and y
* in s8, this should be changed to something more generic
*/
effect->u.ramp.start_level =
clamp_val(effect->u.ramp.start_level + x, -0x80, 0x7f);
effect->u.ramp.end_level =
clamp_val(effect->u.ramp.end_level + y, -0x80, 0x7f);
break;
case FF_RUMBLE:
strong = (u32)new->u.rumble.strong_magnitude * gain / 0xffff;
weak = (u32)new->u.rumble.weak_magnitude * gain / 0xffff;
if (effect->u.rumble.strong_magnitude + strong)
effect->direction = ml_calculate_direction(
effect->direction,
effect->u.rumble.strong_magnitude,
new->direction, strong);
else if (effect->u.rumble.weak_magnitude + weak)
effect->direction = ml_calculate_direction(
effect->direction,
effect->u.rumble.weak_magnitude,
new->direction, weak);
else
effect->direction = 0;
effect->u.rumble.strong_magnitude =
min(strong + effect->u.rumble.strong_magnitude,
0xffffU);
effect->u.rumble.weak_magnitude =
min(weak + effect->u.rumble.weak_magnitude, 0xffffU);
break;
case FF_PERIODIC:
i = apply_envelope(state, abs(new->u.periodic.magnitude),
&new->u.periodic.envelope);
/* here we also scale it 0x7fff => 0xffff */
i = i * gain / 0x7fff;
if (effect->u.rumble.strong_magnitude + i)
effect->direction = ml_calculate_direction(
effect->direction,
effect->u.rumble.strong_magnitude,
new->direction, i);
else
effect->direction = 0;
effect->u.rumble.strong_magnitude =
min(i + effect->u.rumble.strong_magnitude, 0xffffU);
effect->u.rumble.weak_magnitude =
min(i + effect->u.rumble.weak_magnitude, 0xffffU);
break;
default:
pr_err("invalid type in ml_combine_effects()\n");
break;
}
}
/*
* Because memoryless devices have only one effect per effect type active
* at one time we have to combine multiple effects into one
*/
static int ml_get_combo_effect(struct ml_device *ml,
unsigned long *effect_handled,
struct ff_effect *combo_effect)
{
struct ff_effect *effect;
struct ml_effect_state *state;
int effect_type;
int i;
memset(combo_effect, 0, sizeof(struct ff_effect));
for (i = 0; i < FF_MEMLESS_EFFECTS; i++) {
if (__test_and_set_bit(i, effect_handled))
continue;
state = &ml->states[i];
effect = state->effect;
if (!test_bit(FF_EFFECT_STARTED, &state->flags))
continue;
if (time_before(jiffies, state->play_at))
continue;
/*
* here we have started effects that are either
* currently playing (and may need be aborted)
* or need to start playing.
*/
effect_type = get_compatible_type(ml->dev->ff, effect->type);
if (combo_effect->type != effect_type) {
if (combo_effect->type != 0) {
__clear_bit(i, effect_handled);
continue;
}
combo_effect->type = effect_type;
}
if (__test_and_clear_bit(FF_EFFECT_ABORTING, &state->flags)) {
__clear_bit(FF_EFFECT_PLAYING, &state->flags);
__clear_bit(FF_EFFECT_STARTED, &state->flags);
} else if (effect->replay.length &&
time_after_eq(jiffies, state->stop_at)) {
__clear_bit(FF_EFFECT_PLAYING, &state->flags);
if (--state->count <= 0) {
__clear_bit(FF_EFFECT_STARTED, &state->flags);
} else {
state->play_at = jiffies +
msecs_to_jiffies(effect->replay.delay);
state->stop_at = state->play_at +
msecs_to_jiffies(effect->replay.length);
}
} else {
__set_bit(FF_EFFECT_PLAYING, &state->flags);
state->adj_at = jiffies;
ml_combine_effects(combo_effect, state, ml->gain);
}
}
return combo_effect->type != 0;
}
static void ml_play_effects(struct ml_device *ml)
{
struct ff_effect effect;
DECLARE_BITMAP(handled_bm, FF_MEMLESS_EFFECTS);
memset(handled_bm, 0, sizeof(handled_bm));
while (ml_get_combo_effect(ml, handled_bm, &effect))
ml->play_effect(ml->dev, ml->private, &effect);
ml_schedule_timer(ml);
}
static void ml_effect_timer(unsigned long timer_data)
{
struct input_dev *dev = (struct input_dev *)timer_data;
struct ml_device *ml = dev->ff->private;
unsigned long flags;
pr_debug("timer: updating effects\n");
spin_lock_irqsave(&dev->event_lock, flags);
ml_play_effects(ml);
spin_unlock_irqrestore(&dev->event_lock, flags);
}
/*
* Sets requested gain for FF effects. Called with dev->event_lock held.
*/
static void ml_ff_set_gain(struct input_dev *dev, u16 gain)
{
struct ml_device *ml = dev->ff->private;
int i;
ml->gain = gain;
for (i = 0; i < FF_MEMLESS_EFFECTS; i++)
__clear_bit(FF_EFFECT_PLAYING, &ml->states[i].flags);
ml_play_effects(ml);
}
/*
* Start/stop specified FF effect. Called with dev->event_lock held.
*/
static int ml_ff_playback(struct input_dev *dev, int effect_id, int value)
{
struct ml_device *ml = dev->ff->private;
struct ml_effect_state *state = &ml->states[effect_id];
if (value > 0) {
pr_debug("initiated play\n");
__set_bit(FF_EFFECT_STARTED, &state->flags);
state->count = value;
state->play_at = jiffies +
msecs_to_jiffies(state->effect->replay.delay);
state->stop_at = state->play_at +
msecs_to_jiffies(state->effect->replay.length);
state->adj_at = state->play_at;
} else {
pr_debug("initiated stop\n");
if (test_bit(FF_EFFECT_PLAYING, &state->flags))
__set_bit(FF_EFFECT_ABORTING, &state->flags);
else
__clear_bit(FF_EFFECT_STARTED, &state->flags);
}
ml_play_effects(ml);
return 0;
}
static int ml_ff_upload(struct input_dev *dev,
struct ff_effect *effect, struct ff_effect *old)
{
struct ml_device *ml = dev->ff->private;
struct ml_effect_state *state = &ml->states[effect->id];
spin_lock_irq(&dev->event_lock);
if (test_bit(FF_EFFECT_STARTED, &state->flags)) {
__clear_bit(FF_EFFECT_PLAYING, &state->flags);
state->play_at = jiffies +
msecs_to_jiffies(state->effect->replay.delay);
state->stop_at = state->play_at +
msecs_to_jiffies(state->effect->replay.length);
state->adj_at = state->play_at;
ml_schedule_timer(ml);
}
spin_unlock_irq(&dev->event_lock);
return 0;
}
static void ml_ff_destroy(struct ff_device *ff)
{
struct ml_device *ml = ff->private;
kfree(ml->private);
}
/**
* input_ff_create_memless() - create memoryless force-feedback device
* @dev: input device supporting force-feedback
* @data: driver-specific data to be passed into @play_effect
* @play_effect: driver-specific method for playing FF effect
*/
int input_ff_create_memless(struct input_dev *dev, void *data,
int (*play_effect)(struct input_dev *, void *, struct ff_effect *))
{
struct ml_device *ml;
struct ff_device *ff;
int error;
int i;
ml = kzalloc(sizeof(struct ml_device), GFP_KERNEL);
if (!ml)
return -ENOMEM;
ml->dev = dev;
ml->private = data;
ml->play_effect = play_effect;
ml->gain = 0xffff;
setup_timer(&ml->timer, ml_effect_timer, (unsigned long)dev);
set_bit(FF_GAIN, dev->ffbit);
error = input_ff_create(dev, FF_MEMLESS_EFFECTS);
if (error) {
kfree(ml);
return error;
}
ff = dev->ff;
ff->private = ml;
ff->upload = ml_ff_upload;
ff->playback = ml_ff_playback;
ff->set_gain = ml_ff_set_gain;
ff->destroy = ml_ff_destroy;
/* we can emulate periodic effects with RUMBLE */
if (test_bit(FF_RUMBLE, ff->ffbit)) {
set_bit(FF_PERIODIC, dev->ffbit);
set_bit(FF_SINE, dev->ffbit);
set_bit(FF_TRIANGLE, dev->ffbit);
set_bit(FF_SQUARE, dev->ffbit);
}
for (i = 0; i < FF_MEMLESS_EFFECTS; i++)
ml->states[i].effect = &ff->effects[i];
return 0;
}
EXPORT_SYMBOL_GPL(input_ff_create_memless);
|
07eece41e7e6e736a5454bf49b5d90a9770005d5
|
a11e4bdd6157b22067288d860507fa20abea033d
|
/src/bin/e_sha1.h
|
7e8b1a4f5b5fce1b733c250cad163e0cbc707d62
|
[
"BSD-2-Clause"
] |
permissive
|
JeffHoogland/moksha
|
85a0f39dc97daa61d35e64a511013d21552db288
|
c56013644d8cd8e32101bb38a8d1e4ebd9d47f37
|
refs/heads/master
| 2023-08-24T05:39:13.415948
| 2023-08-22T19:49:32
| 2023-08-22T19:49:32
| 34,704,822
| 179
| 51
|
NOASSERTION
| 2023-09-06T14:41:31
| 2015-04-28T02:59:19
|
C
|
UTF-8
|
C
| false
| false
| 560
|
h
|
e_sha1.h
|
#ifdef E_TYPEDEFS
#else
#ifndef E_SHA1_H
#define E_SHA1_H
#ifndef EAPI
# ifdef WIN32
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
# endif
# else
# ifdef __GNUC__
# if __GNUC__ >= 4
/* BROKEN in gcc 4 on amd64 */
#if 0
# pragma GCC visibility push(hidden)
#endif
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
# endif
#endif
EAPI int e_sha1_sum(unsigned char *data, int size, unsigned char *dst);
#endif
#endif
|
b71aa3d5a5f0221066707ef3060d43fe68d1bab3
|
08db5520055df5865d09c7e2bc888e7219666d3c
|
/hdrs/help.h
|
c2f58d9cb7f1507fb1f7e98ca28609b2b3bbbdcf
|
[
"Artistic-1.0"
] |
permissive
|
pennmush/pennmush
|
9ab3f8d368bd01c4c1b919a936c4ffc3d222ad38
|
6c6173eca6865f88a97e0b5cd1fadbab49f1afad
|
refs/heads/master
| 2023-09-02T03:52:35.455020
| 2023-08-19T20:16:55
| 2023-08-19T20:16:55
| 32,365,792
| 121
| 83
| null | 2023-08-19T20:16:56
| 2015-03-17T02:13:05
|
C
|
UTF-8
|
C
| false
| false
| 716
|
h
|
help.h
|
/**
* \file help.h
*
* \brief Header file for the PennMUSH help system
*/
#ifndef __HELP_H
#define __HELP_H
#include <stddef.h>
#include "mushtype.h"
/** A help command.
* Multiple help commands can be defined, each associated with a help
* file and an in-memory index.
*/
typedef struct {
char *command; /**< The name of the help command */
char *file; /**< The file of help text */
int admin; /**< Is this an admin-only help command? */
} help_file;
void init_help_files(void);
void close_help_files(void);
void add_help_file(const char *command_name, const char *filename, int admin);
void help_rebuild(dbref player);
bool help_rebuild_by_name(const char *filename);
#endif /* __HELP_H */
|
446ae2707f34cec2885200a7b2332c114d82dfa9
|
2af283f8a587bcc3d2a744f7d86007ab2428f9bc
|
/src/http2/iotx_http2.c
|
d73eb968fabb8c7438de293ded69698a3e6939ba
|
[
"Apache-2.0"
] |
permissive
|
aliyun/iotkit-embedded
|
bfda585c8a5db3fea215ad15fe7699cebde1dfc8
|
3010153fb53865ce3925f8e43900adbbfa358874
|
refs/heads/v3.0.1
| 2023-03-12T23:14:04.902446
| 2022-11-11T07:12:05
| 2022-11-11T09:01:43
| 106,364,205
| 544
| 289
|
Apache-2.0
| 2023-08-22T06:00:04
| 2017-10-10T03:30:08
|
C
|
UTF-8
|
C
| false
| false
| 28,395
|
c
|
iotx_http2.c
|
/*
* Copyright (C) 2015-2018 Alibaba Group Holding Limited
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "nghttp2.h"
#include "nghttp2_session.h"
#include "infra_httpc.h"
#include "http2_internal.h"
#include "http2_wrapper.h"
#define MAX_HTTP2_HOST_LEN (128)
#define NGHTTP2_DBG h2_info
typedef enum {
PING_IDLE,
PING_SENDING,
PING_SENT,
PING_RECVED,
} http2_ping_state_t;
enum { IO_NONE, WANT_READ, WANT_WRITE };
typedef struct _http2_request_struct_ {
/* Stream ID for this request. */
int32_t stream_id;
} http2_request;
extern const char *iotx_ca_get(void);
extern int httpclient_connect(httpclient_t *client);
static int http2_nv_copy_nghttp2_nv(nghttp2_nv *nva, int start, http2_header *nva_copy, int end);
/*static int http2_parse_host(char *url, char *host, size_t maxHostLen);*/
static http2_ping_state_t ping_state = PING_IDLE;
int g_recv_timeout = 10;
int set_http2_recv_timeout(int timeout)
{
g_recv_timeout = timeout;
return 1;
}
static ssize_t send_callback(nghttp2_session *session, const uint8_t *data,
size_t length, int flags, void *user_data)
{
http2_connection_t *connection;
httpclient_t *client;
int rv;
connection = (http2_connection_t *)user_data;
if (connection == NULL) {
return 0;
}
NGHTTP2_DBG("send_callback data len %d, session->remote_window_size=%d!\r\n", (int)length,
session->remote_window_size);
if (session->remote_window_size < length * 2) {
HAL_SleepMs(50);
NGHTTP2_DBG("wait a munite ....");
}
/*if(length < 50)
LITE_hexdump("data:", data, length);*/
client = (httpclient_t *)connection->network;
rv = client->net.write(&client->net, (char *)data, length, 5000);
NGHTTP2_DBG("send_callback data ends len = %d!\r\n", rv);
if (rv < 0 || rv < length) {
rv = NGHTTP2_ERR_CALLBACK_FAILURE;
}
return rv;
}
/**
* @brief The implementation of nghttp2_recv_callback type. Here we read |data| from the network
* and write them in |buf|. The capacity of |buf| is |length| bytes. Returns the number of
* bytes stored in |buf|. See the documentation of nghttp2_recv_callback for the details.
* To set this callback to :type:`nghttp2_session_callbacks`, use
* `nghttp2_session_callbacks_set_on_frame_send_callback()`.
* @param[in] session: nghttp2 session.
* @param[in] buf: receive data buffer.
* @param[in] length: data length.
* @param[in] flags: no using.
* @param[in] user_data: user data.
* @return Received data length.
*/
static ssize_t recv_callback(nghttp2_session *session, uint8_t *buf,
size_t length, int flags, void *user_data)
{
http2_connection_t *connection;
int rv;
httpclient_t *client;
connection = (http2_connection_t *)user_data;
if (connection == NULL) {
return 0;
}
client = (httpclient_t *)connection->network;
rv = client->net.read(&client->net, (char *)buf, length, g_recv_timeout);
/* NGHTTP2_DBG("recv_callback len= %d\r\n", rv); */
if (rv < 0) {
rv = NGHTTP2_ERR_CALLBACK_FAILURE;
} else if (rv == 0) {
rv = 0;
}
return rv;
}
/**
* @brief Callback function invoked after the frame |frame| is sent.
* To set this callback to :type:`nghttp2_session_callbacks`, use
* `nghttp2_session_callbacks_set_on_frame_send_callback()`.
* @param[in] session: nghttp2 session.
* @param[in] frame: nghttp2 frame.
* @param[in] user_data: The |user_data| pointer is the third argument passed in to the call to
* `nghttp2_session_client_new()` or `nghttp2_session_server_new()`
* @return The implementation of this function must return 0 if it succeeds.
* If nonzero is returned, it is treated as fatal error and `nghttp2_session_send()`
* and `nghttp2_session_mem_send()` functions immediately return :enum:
* `NGHTTP2_ERR_CALLBACK_FAILURE`.
*/
static int on_frame_send_callback(nghttp2_session *session,
const nghttp2_frame *frame,
void *user_data)
{
size_t i;
http2_connection_t *connection = (http2_connection_t *)user_data;
if (connection == NULL) {
return 0;
}
switch (frame->hd.type) {
case NGHTTP2_HEADERS: {
const nghttp2_nv *nva = frame->headers.nva;
NGHTTP2_DBG("[INFO] C ---------> S (HEADERS) stream_id [%d]\n", frame->hd.stream_id);
for (i = 0; i < frame->headers.nvlen; ++i) {
NGHTTP2_DBG("> %s: %s\n", nva[i].name, nva[i].value);
}
(void)nva;
} break;
case NGHTTP2_RST_STREAM: {
NGHTTP2_DBG("[INFO] C ---------> S (RST_STREAM)\n");
} break;
case NGHTTP2_GOAWAY: {
NGHTTP2_DBG("[INFO] C ---------> S (GOAWAY) code = %d\n",frame->goaway.error_code);
} break;
case NGHTTP2_PING: {
NGHTTP2_DBG("[INFO] C ---------> S (PING)\n");
ping_state = PING_SENDING;
} break;
default: break;
}
if (connection->cbs && connection->cbs->on_user_frame_send_cb) {
connection->cbs->on_user_frame_send_cb(frame->hd.stream_id, frame->hd.type, frame->hd.flags);
}
return 0;
}
/**
* @brief Callback function invoked by `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` when a frame is received.
* If frame is HEADERS or PUSH_PROMISE, the ``nva`` and ``nvlen``member of their data structure are always
* ``NULL`` and 0 respectively. The header name/value pairs are emitted via:type:`nghttp2_on_header_callback`
* To set this callback to :type:`nghttp2_session_callbacks`, use`nghttp2_session_callbacks_set_on_frame_send_callback()`.
* For HEADERS, PUSH_PROMISE and DATA frames, this callback may be called after stream is closed (see:type:
* `nghttp2_on_stream_close_callback`). The application should check that stream is still alive using its own stream
* management or :func:`nghttp2_session_get_stream_user_data()`.
* Only HEADERS and DATA frame can signal the end of incoming data. If ``frame->hd.flags & NGHTTP2_FLAG_END_STREAM``
* is nonzero, the|frame| is the last frame from the remote peer in this stream.
* This callback won't be called for CONTINUATION frames.
* HEADERS/PUSH_PROMISE + CONTINUATIONs are treated as single frame.
* @param[in] session: nghttp2 session.
* @param[in] frame: nghttp2 frame.
* @param[in] user_data: The |user_data| pointer is the third argument passed in to the call to
* `nghttp2_session_client_new()` or `nghttp2_session_server_new()`
* @return The implementation of this function must return 0 if it succeeds.
* If nonzero is returned, it is treated as fatal error and `nghttp2_session_send()`
* and `nghttp2_session_mem_send()` functions immediately return :enum:
* `NGHTTP2_ERR_CALLBACK_FAILURE`.
*/
static int on_frame_recv_callback(nghttp2_session *session,
const nghttp2_frame *frame,
void *user_data)
{
http2_connection_t *connection = (http2_connection_t *)user_data;
http2_request *req;
NGHTTP2_DBG("on_frame_recv_callback, type = %d\n", frame->hd.type);
NGHTTP2_DBG("on_frame_recv_callback, stream_id = %d\n", frame->hd.stream_id);
if (connection == NULL) {
return 0;
}
req = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
if (req == NULL) {
NGHTTP2_DBG("stream user data is not exist\n");
}
switch (frame->hd.type) {
case NGHTTP2_HEADERS: {
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE) {
}
} break;
case NGHTTP2_RST_STREAM: {
connection->status = 0;
NGHTTP2_DBG("[INFO] C <--------- S (RST_STREAM)\n");
} break;
case NGHTTP2_GOAWAY: {
connection->status = 0;
NGHTTP2_DBG("[INFO] C <--------- S (GOAWAY) code = %d\n",frame->goaway.error_code);
} break;
case NGHTTP2_DATA: {
if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
NGHTTP2_DBG("end stream flag\r\n");
}
} break;
case NGHTTP2_PING: {
NGHTTP2_DBG("[INFO] C <--------- S (PING)\n");
ping_state = PING_RECVED;
} break;
}
if (connection->cbs && connection->cbs->on_user_frame_recv_cb) {
connection->cbs->on_user_frame_recv_cb(frame->hd.stream_id, frame->hd.type, frame->hd.flags);
}
return 0;
}
/**
* @brief Callback function invoked when the stream |stream_id| is closed.
* We use this function to know if the response is fully received. Since we just fetch 1 resource in this program, after
* the response is received, we submit GOAWAY and close the session.
* @param[in] session: nghttp2 session.
* @param[in] stream_id: stream id.
* @param[in] error_code: The reason of closure.
* Usually one of :enum:`nghttp2_error_code`, but that is not guaranteed. The stream_user_data, which was specified in
* `nghttp2_submit_request()` or `nghttp2_submit_headers()`, is still available in this function.
* @param[in] user_data: The |user_data| pointer is the third argument passed in to the call to
* `nghttp2_session_client_new()` or `nghttp2_session_server_new()`
* @return The implementation of this function must return 0 if it succeeds.
* If nonzero is returned, it is treated as fatal error and `nghttp2_session_send()`
* and `nghttp2_session_mem_send()` functions immediately return :enum:
* `NGHTTP2_ERR_CALLBACK_FAILURE`.
*/
static int on_h2_stream_close_callback(nghttp2_session *session, int32_t stream_id,
uint32_t error_code,
void *user_data)
{
http2_request *req;
http2_connection_t *connection = (http2_connection_t *)user_data;
if (connection == NULL) {
return 0;
}
req = nghttp2_session_get_stream_user_data(session, stream_id);
if (req) {
int rv;
rv = nghttp2_session_terminate_session(session, NGHTTP2_NO_ERROR);
if (rv != 0) {
NGHTTP2_DBG("stream close nghttp2_session_terminate_session\r\n");
}
}
if (connection->cbs && connection->cbs->on_user_stream_close_cb) {
connection->cbs->on_user_stream_close_cb(stream_id, error_code);
}
return 0;
}
/**
* @brief Callback function invoked when a chunk of data in DATA frame is received.
* The implementation of nghttp2_on_data_chunk_recv_callback type. We use this function to print the received response body.
* @param[in] session: nghttp2 session.
* @param[in] flags: no using.
* @param[in] stream_id: the stream ID this DATA frame belongs to.
* @param[in] data: receive data.
* @param[in] len: data length.
* @param[in] user_data: The |user_data| pointer is the third argument passed in to the call to
* `nghttp2_session_client_new()` or `nghttp2_session_server_new()`
* @return The implementation of this function must return 0 if it succeeds.
* If nonzero is returned, it is treated as fatal error and `nghttp2_session_send()`
* and `nghttp2_session_mem_send()` functions immediately return :enum:
* `NGHTTP2_ERR_CALLBACK_FAILURE`.
*/
static int on_data_chunk_recv_callback(nghttp2_session *session,
uint8_t flags, int32_t stream_id,
const uint8_t *data, size_t len,
void *user_data)
{
http2_request *req;
http2_connection_t *connection = (http2_connection_t *)user_data;
if (connection == NULL) {
return 0;
}
req = nghttp2_session_get_stream_user_data(session, stream_id);
if (req) {
NGHTTP2_DBG("stream user data is not exist\n");
}
NGHTTP2_DBG("[INFO] C <----------- S (DATA chunk) stream_id [%d] :: %lu bytes\n", stream_id, (unsigned long int)len);
if (connection->cbs && connection->cbs->on_user_chunk_recv_cb) {
connection->cbs->on_user_chunk_recv_cb(stream_id, data, len, flags);
}
nghttp2_session_consume_connection(session, len);
nghttp2_session_consume(session, stream_id, len);
nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 0, len);
nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, stream_id, len);
nghttp2_session_send(session);
return 0;
}
/**
* @brief Callback function invoked when a header name/value pair is received.
* The implementation of nghttp2_on_data_chunk_recv_callback type. We use this function to print the received response body.
* @param[in] session: nghttp2 session.
* @param[in] frame: nghttp2 frame.
* @param[in] name: header name.
* @param[in] namelen: length of header name.
* @param[in] value: header value.
* @param[in] valuelen: length of header value.
* @param[in] flags: no using.
* @param[in] user_data: The |user_data| pointer is the third argument passed in to the call to
* `nghttp2_session_client_new()` or `nghttp2_session_server_new()`
* @return The implementation of this function must return 0 if it succeeds.
* If nonzero is returned, it is treated as fatal error and `nghttp2_session_send()`
* and `nghttp2_session_mem_send()` functions immediately return :enum:
* `NGHTTP2_ERR_CALLBACK_FAILURE`.
*/
static int on_header_callback(nghttp2_session *session,
const nghttp2_frame *frame, const uint8_t *name,
size_t namelen, const uint8_t *value,
size_t valuelen, uint8_t flags,
void *user_data)
{
http2_connection_t *connection = (http2_connection_t *)user_data;
if (connection == NULL) {
return 0;
}
switch (frame->hd.type) {
case NGHTTP2_HEADERS:
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE) {
http2_connection_t *connection = (http2_connection_t *)user_data;
/* Print response headers for the initiated request. */
NGHTTP2_DBG("< %s: %s\n", name, value);
if (connection->cbs && connection->cbs->on_user_header_cb) {
connection->cbs->on_user_header_cb(frame->hd.stream_id, (int)frame->headers.cat, name, namelen, value, valuelen, flags);
}
break;
}
}
return 0;
}
/**
* @brief Called when nghttp2 library gets started to receive header block.
* @param[in] session: nghttp2 session.
* @param[in] frame: nghttp2 frame.
* @param[in] user_data: The |user_data| pointer is the third argument passed in to the call to
* `nghttp2_session_client_new()` or `nghttp2_session_server_new()`
* @return The implementation of this function must return 0 if it succeeds.
* If nonzero is returned, it is treated as fatal error and `nghttp2_session_send()`
* and `nghttp2_session_mem_send()` functions immediately return :enum:
* `NGHTTP2_ERR_CALLBACK_FAILURE`.
*/
static int on_begin_headers_callback(nghttp2_session *session,
const nghttp2_frame *frame,
void *user_data)
{
switch (frame->hd.type) {
case NGHTTP2_HEADERS:
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE) {
NGHTTP2_DBG("[INFO] C <--------- S (HEADERS) stream_id [%d]\n", (int)frame->hd.stream_id);
}
break;
}
return 0;
}
/**
* @brief Setup callback functions.
* nghttp2 API offers many callback functions, but most of them are optional. The send_callback is always required.
* Since we use nghttp2_session_recv(), the recv_callback is also required.
* @param[in|out] callbacks: nghttp2 callbacks.
* @return None.
*/
static void setup_nghttp2_callbacks(nghttp2_session_callbacks *callbacks)
{
nghttp2_session_callbacks_set_send_callback(callbacks, send_callback);
nghttp2_session_callbacks_set_recv_callback(callbacks, recv_callback);
nghttp2_session_callbacks_set_on_frame_send_callback(callbacks,
on_frame_send_callback);
nghttp2_session_callbacks_set_on_frame_recv_callback(callbacks,
on_frame_recv_callback);
nghttp2_session_callbacks_set_on_stream_close_callback(
callbacks, on_h2_stream_close_callback);
nghttp2_session_callbacks_set_on_data_chunk_recv_callback(
callbacks, on_data_chunk_recv_callback);
nghttp2_session_callbacks_set_on_header_callback(callbacks,
on_header_callback);
nghttp2_session_callbacks_set_on_begin_headers_callback(
callbacks, on_begin_headers_callback);
}
static ssize_t data_read_callback(nghttp2_session *session, int32_t stream_id,
uint8_t *buf, size_t length,
uint32_t *data_flags,
nghttp2_data_source *source,
void *user_data)
{
int len = 0;
http2_connection_t *connection = (http2_connection_t *)user_data;
if (connection == NULL) {
return 0;
}
if (source->ptr == NULL) {
return 0;
}
if (connection != NULL && connection->flag != NGHTTP2_FLAG_END_STREAM) {
*data_flags |= NGHTTP2_DATA_FLAG_NO_END_STREAM;
connection->flag = NGHTTP2_FLAG_NONE;
}
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
/*len = strlen((char *)source->ptr);*/
len = source->len;
if (length < len) {
len = length;
}
memcpy(buf, source->ptr, len);
return len;
}
static int http2_nv_copy_nghttp2_nv(nghttp2_nv *nva, int start, http2_header *nva_copy, int end)
{
int i, j;
for (i = start, j = 0; j < end; i++, j++) {
nva[i].flags = NGHTTP2_NV_FLAG_NONE;
nva[i].name = (uint8_t *)nva_copy[j].name;
nva[i].value = (uint8_t *)nva_copy[j].value;
nva[i].namelen = nva_copy[j].namelen;
nva[i].valuelen = nva_copy[j].valuelen;
}
return i;
}
/**
* @brief Connect the SSL client.
* @param[in] pclient: http client.
* @param[in] url. destination url.
* @param[in] port. destination port.
* @param[in] ssl_config: custome config.
* @return The result. 0 is ok.
*/
static int http2_client_conn(httpclient_t *pclient, char *url, int port)
{
int ret = 0;
/*char host[MAX_HTTP2_HOST_LEN] = { 0 };*/
/*http2_parse_host(url, host, sizeof(host));*/
if (0 == pclient->net.handle) {
/* Establish connection if no. */
extern const char *iotx_ca_crt;
ret = iotx_net_init(&pclient->net, url, port, iotx_ca_crt);
if (0 != ret) {
return ret;
}
ret = httpclient_connect(pclient);
if (0 != ret) {
h2_err("http2client_connect is error, ret = %d", ret);
httpclient_close(pclient);
return ret;
}
}
return ret;
}
int iotx_http2_client_send(http2_connection_t *conn, http2_data *h2_data)
{
int send_flag = 0;
int rv = 0;
nghttp2_data_provider data_prd;
nghttp2_nv *nva = NULL;
int nva_size = 0;
http2_header *header = h2_data->header;
int header_count = h2_data->header_count;
char *data = h2_data->data;
int len = h2_data->len;
int stream_id = h2_data->stream_id;
int flags = h2_data->flag;
if (conn == NULL) {
return -1;
}
if (header != NULL && header_count != 0) {
nva = (nghttp2_nv *)HTTP2_STREAM_MALLOC(sizeof(nghttp2_nv) * header_count);
if (nva == NULL) {
return -1;
}
nva_size = http2_nv_copy_nghttp2_nv(nva, nva_size, header, header_count);
}
/*upload to server*/
if (data != NULL && len != 0) {
data_prd.source.ptr = data;
data_prd.source.len = len;
data_prd.read_callback = data_read_callback;
if (nva_size != 0) {
rv = nghttp2_submit_request(conn->session, NULL, nva, nva_size, &data_prd, NULL);
h2_data->stream_id = rv;
} else {
rv = nghttp2_submit_data(conn->session, flags, stream_id, &data_prd);
}
} else {
rv = nghttp2_submit_request(conn->session, NULL, nva, nva_size, NULL, NULL);
h2_data->stream_id = rv;
}
HTTP2_STREAM_FREE(nva);
if (rv < 0) {
return rv;
}
send_flag = nghttp2_session_want_write(conn->session);
if (send_flag) {
rv = nghttp2_session_send(conn->session);
NGHTTP2_DBG("nghttp2_session_send %d\r\n", rv);
}
return rv;
}
int iotx_http2_client_recv(http2_connection_t *conn, char *data, int data_len, int *len, int timeout)
{
int rv = 0;
int read_flag = 0;
if (conn == NULL) {
return -1;
}
set_http2_recv_timeout(timeout);
read_flag = nghttp2_session_want_read(conn->session);
if (read_flag) {
rv = nghttp2_session_recv(conn->session);
NGHTTP2_DBG("nghttp2_client_recv %d\r\n", rv);
if (rv < 0) {
read_flag = 0;
}
}
return rv;
}
/**
* @brief the http2 client connect.
* @param[in] pclient: http client.
* @return http2 client connection handler.
*/
http2_connection_t *iotx_http2_client_connect(void *pclient, char *url, int port)
{
http2_connection_t *connection;
nghttp2_session_callbacks *callbacks;
int rv;
int ret = 0;
connection = HTTP2_STREAM_MALLOC(sizeof(http2_connection_t));
if (connection == NULL) {
return NULL;
}
memset(connection, 0, sizeof(http2_connection_t));
if (0 != (ret = http2_client_conn((httpclient_t *)pclient, url, port))) {
NGHTTP2_DBG("https_client_conn failed %d\r\n", ret);
HTTP2_STREAM_FREE(connection);
return NULL;
}
connection->network = pclient;
rv = nghttp2_session_callbacks_new(&callbacks);
if (rv != 0) {
NGHTTP2_DBG("nghttp2_session_callbacks_new1 %d", rv);
HTTP2_STREAM_FREE(connection);
return NULL;
}
setup_nghttp2_callbacks(callbacks);
rv = nghttp2_session_client_new((nghttp2_session **)&connection->session, callbacks, connection);
if (rv != 0) {
NGHTTP2_DBG("nghttp2_session_client_new3 %d", rv);
HTTP2_STREAM_FREE(connection);
return NULL;
}
nghttp2_session_callbacks_del(callbacks);
nghttp2_submit_settings(connection->session, NGHTTP2_FLAG_NONE, NULL, 0);
#if 0
parse_uri(&uri, url);
request_init(&req, &uri);
/* Submit the HTTP request to the outbound queue. */
submit_request(connection, &req);
#endif
rv = nghttp2_session_send(connection->session);
/*request_free(&req);*/
if (rv < 0) {
NGHTTP2_DBG("nghttp2_session_send fail %d", rv);
HTTP2_STREAM_FREE(connection);
return NULL;
}
connection->status = 1;
return connection;
}
/**
* @brief the http2 client connect.
* @param[in] pclient: http client.
* @return http2 client connection handler.
*/
http2_connection_t *iotx_http2_client_connect_with_cb(void *pclient, char *url, int port, http2_user_cb_t *cb)
{
http2_connection_t *connection;
nghttp2_session_callbacks *callbacks;
int rv;
int ret = 0;
connection = HTTP2_STREAM_MALLOC(sizeof(http2_connection_t));
if (connection == NULL) {
return NULL;
}
memset(connection, 0, sizeof(http2_connection_t));
if (0 != (ret = http2_client_conn((httpclient_t *)pclient, url, port))) {
NGHTTP2_DBG("https_client_conn failed %d\r\n", ret);
HTTP2_STREAM_FREE(connection);
return NULL;
}
connection->network = pclient;
rv = nghttp2_session_callbacks_new(&callbacks);
if (rv != 0) {
NGHTTP2_DBG("nghttp2_session_callbacks_new1 %d", rv);
HTTP2_STREAM_FREE(connection);
return NULL;
}
connection->cbs = cb;
setup_nghttp2_callbacks(callbacks);
rv = nghttp2_session_client_new((nghttp2_session **)&connection->session, callbacks, connection);
if (rv != 0) {
NGHTTP2_DBG("nghttp2_session_client_new3 %d", rv);
nghttp2_session_callbacks_del(callbacks);
HTTP2_STREAM_FREE(connection);
return NULL;
}
nghttp2_session_callbacks_del(callbacks);
nghttp2_submit_settings(connection->session, NGHTTP2_FLAG_NONE, NULL, 0);
#if 0
parse_uri(&uri, url);
request_init(&req, &uri);
/* Submit the HTTP request to the outbound queue. */
submit_request(connection, &req);
#endif
rv = nghttp2_session_send(connection->session);
/*request_free(&req);*/
if (rv < 0) {
nghttp2_session_del(connection->session);
NGHTTP2_DBG("nghttp2_session_send fail %d", rv);
HTTP2_STREAM_FREE(connection);
return NULL;
}
connection->status = 1;
return connection;
}
int iotx_http2_client_disconnect(http2_connection_t *conn)
{
/* Resource cleanup */
if (conn == NULL) {
return -1;
}
httpclient_close((httpclient_t *)conn->network);
nghttp2_session_del(conn->session);
HTTP2_STREAM_FREE(conn);
return 0;
}
int iotx_http2_client_send_ping(http2_connection_t *conn)
{
int rv = 0;
int send_flag;
ping_state = PING_IDLE;
if (conn == NULL) {
return -1;
}
rv = nghttp2_submit_ping(conn->session, NGHTTP2_FLAG_NONE, NULL);
if (rv < 0) {
return rv;
}
send_flag = nghttp2_session_want_write(conn->session);
if (send_flag) {
rv = nghttp2_session_send(conn->session);
NGHTTP2_DBG("nghttp2_session_send %d\r\n", rv);
if (rv < 0) {
return rv;
}
}
ping_state = PING_SENDING;
return 0;
}
int iotx_http2_client_recv_ping(void)
{
if (ping_state == PING_RECVED || ping_state == PING_IDLE) {
NGHTTP2_DBG("ping recv secceed\r\n");
return 0;
}
else {
NGHTTP2_DBG("ping recv timeout");
return -1;
}
}
int iotx_http2_get_available_window_size(http2_connection_t *conn)
{
int windows_size = 0;
if (conn == NULL) {
return -1;
}
windows_size = nghttp2_session_get_remote_window_size(conn->session);
return windows_size;
}
int iotx_http2_update_window_size(http2_connection_t *conn)
{
int rv;
if (conn == NULL) {
return -1;
}
rv = nghttp2_session_recv(conn->session);
if (rv < 0) {
return -1;
}
return 0;
}
/*
* Performs the network I/O.
*/
int iotx_http2_exec_io(http2_connection_t *connection)
{
if (connection == NULL) {
return -1;
}
if (nghttp2_session_want_read(connection->session) /*||
nghttp2_session_want_write(connection->session)*/) {
int rv;
rv = nghttp2_session_recv(connection->session);
if (rv < 0) {
NGHTTP2_DBG("nghttp2_session_recv error");
return -1;
}
/* rv = nghttp2_session_send(connection->session); */
/* if (rv < 0) { */
/* NGHTTP2_DBG("nghttp2_session_send error"); */
/* return -1; */
/* } */
}
return 0;
}
int iotx_http2_reset_stream(http2_connection_t *connection, int32_t stream_id)
{
int rv = 0;
if(connection == NULL){
return -1;
}
if(!nghttp2_session_get_stream_local_close(connection->session,stream_id)) {
rv = nghttp2_submit_rst_stream(connection->session,0, stream_id, NGHTTP2_NO_ERROR);
}
if (rv < 0) {
return rv;
}
rv = nghttp2_session_want_write(connection->session);
if (rv) {
rv = nghttp2_session_send(connection->session);
NGHTTP2_DBG("nghttp2_session_send %d\r\n", rv);
}
return rv;
}
|
ea4ba15b78411b733421f32360f806c4afa91409
|
f666464581426f91931bafeb67ac9785d53403b8
|
/lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.h
|
27e05d3a21a3d109905e80c5a494822d84c1f731
|
[
"MIT"
] |
permissive
|
adafruit/Adafruit_nRF52_Bootloader
|
f2d5aead812c1aa3c0d4bdbe5093778dd8d09657
|
7210c3914db0cf28e7b2c9850293817338259757
|
refs/heads/master
| 2023-08-03T21:24:00.549206
| 2023-08-01T13:51:33
| 2023-08-01T13:51:33
| 118,896,384
| 356
| 337
|
MIT
| 2023-08-01T13:51:36
| 2018-01-25T10:08:38
|
C
|
UTF-8
|
C
| false
| false
| 995
|
h
|
bootloader_settings.h
|
/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/
/**@file
*
* @defgroup nrf_bootloader_settings Bootloader settings API.
* @{
*
* @brief Bootloader settings module interface.
*/
#ifndef BOOTLOADER_SETTINGS_H__
#define BOOTLOADER_SETTINGS_H__
#include <stdint.h>
#include "bootloader_types.h"
/**@brief Function for getting the bootloader settings.
*
* @param[out] pp_bootloader_settings Bootloader settings.
*/
void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings);
#endif // BOOTLOADER_SETTINGS_H__
/**@} */
|
9859708a075472948f91fdb5c03fcefbfb2079fb
|
2c73a693c2b3c162eae2ab94f649d8c4494878ba
|
/components/multimedia/amr_decode/amr_wb/dec/src/isp_isf.c
|
8cc13b525e6a54771360a245481092c268c74e21
|
[
"MIT"
] |
permissive
|
openLuat/LuatOS
|
185e1e140aed908434168133571ddcafe98f4e12
|
4b29d5121ab4f7133630331e8502c526c7856897
|
refs/heads/master
| 2023-08-23T04:57:23.263539
| 2023-08-23T04:46:46
| 2023-08-23T04:46:46
| 230,403,844
| 378
| 93
|
MIT
| 2021-12-17T02:19:30
| 2019-12-27T08:29:19
|
C
|
UTF-8
|
C
| false
| false
| 6,311
|
c
|
isp_isf.c
|
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* 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.
* -------------------------------------------------------------------
*/
/****************************************************************************************
Portions of this file are derived from the following 3GPP standard:
3GPP TS 26.173
ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec
Available from http://www.3gpp.org
(C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
Permission to distribute, modify and use this file under the standard license
terms listed above has been obtained from the copyright holder.
****************************************************************************************/
/*
------------------------------------------------------------------------------
Filename: isp_isf.cpp
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
int16 isf[], (i) Q15 : isf[m] normalized (range: 0.0<=val<=0.5)
int16 isp[], (o) Q15 : isp[m] (range: -1<=val<1)
int16 m (i) : LPC order
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Isf_isp Transformation isf to isp
The transformation from isf[i] to isp[i] is
approximated by a look-up table and interpolation.
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_amr_wb_type_defs.h"
#include "pvamrwbdecoder_basic_op.h"
#include "pvamrwbdecoder_acelp.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/* Look-up table for transformations */
/* table of cos(x) in Q15 */
static const int16 table[129] =
{
32767,
32758, 32729, 32679, 32610, 32522, 32413, 32286, 32138,
31972, 31786, 31581, 31357, 31114, 30853, 30572, 30274,
29957, 29622, 29269, 28899, 28511, 28106, 27684, 27246,
26791, 26320, 25833, 25330, 24812, 24279, 23732, 23170,
22595, 22006, 21403, 20788, 20160, 19520, 18868, 18205,
17531, 16846, 16151, 15447, 14733, 14010, 13279, 12540,
11793, 11039, 10279, 9512, 8740, 7962, 7180, 6393,
5602, 4808, 4011, 3212, 2411, 1608, 804, 0,
-804, -1608, -2411, -3212, -4011, -4808, -5602, -6393,
-7180, -7962, -8740, -9512, -10279, -11039, -11793, -12540,
-13279, -14010, -14733, -15447, -16151, -16846, -17531, -18205,
-18868, -19520, -20160, -20788, -21403, -22006, -22595, -23170,
-23732, -24279, -24812, -25330, -25833, -26320, -26791, -27246,
-27684, -28106, -28511, -28899, -29269, -29622, -29957, -30274,
-30572, -30853, -31114, -31357, -31581, -31786, -31972, -32138,
-32286, -32413, -32522, -32610, -32679, -32729, -32758, -32768
};
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void Isf_isp(
int16 isf[], /* (i) Q15 : isf[m] normalized (range: 0.0<=val<=0.5) */
int16 isp[], /* (o) Q15 : isp[m] (range: -1<=val<1) */
int16 m /* (i) : LPC order */
)
{
int16 i, ind, offset;
int32 L_tmp;
for (i = 0; i < m - 1; i++)
{
isp[i] = isf[i];
}
isp[m - 1] = shl_int16(isf[m - 1], 1);
for (i = 0; i < m; i++)
{
ind = isp[i] >> 7; /* ind = b7-b15 of isf[i] */
offset = (isp[i] & 0x007f); /* offset = b0-b6 of isf[i] */
/* isp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 128 */
L_tmp = mul_16by16_to_int32(table[ind + 1] - table[ind], offset);
isp[i] = add_int16(table[ind], (int16)(L_tmp >> 8));
}
return;
}
|
b9916f10c2e49ea0b2f35d47427af0acc439f2e4
|
76369dba56fa9d3b265486b9ab10279cd16de5e9
|
/c/aprovados.c
|
b522da4db57e0bd91b62105892bf7922c9aebba5
|
[] |
no_license
|
acenelio/curso-algoritmos
|
29f24e49865a9a2626af7b67fa453c183ec060dc
|
71a46ddc6e7871e999cec529637b0e199a87b716
|
refs/heads/master
| 2023-01-13T06:43:17.099401
| 2023-01-03T23:55:37
| 2023-01-03T23:55:37
| 220,841,002
| 403
| 191
| null | 2022-12-13T01:59:29
| 2019-11-10T19:40:30
|
Java
|
UTF-8
|
C
| false
| false
| 813
|
c
|
aprovados.c
|
#include <stdio.h>
void limpar_entrada() {
char c;
while ((c = getchar()) != '\n' && c != EOF) {}
}
void ler_texto(char *buffer, int length) {
fgets(buffer, length, stdin);
strtok(buffer, "\n");
}
int main(){
int n;
double media;
printf("Quantos alunos serao digitados? ");
scanf("%d", &n);
char nomes[n][50];
double notas1[n], notas2[n];
for (int i=0; i<n; i++) {
printf("Digite nome, primeira e segunda nota do %do aluno:\n", i + 1);
limpar_entrada();
ler_texto(nomes[i], 50);
scanf("%lf %lf", ¬as1[i], ¬as2[i]);
}
printf("Alunos aprovados:\n");
for (int i=0; i<n; i++) {
media = (notas1[i] + notas2[i]) / 2;
if(media >= 6.0) {
printf("%s\n", nomes[i]);
}
}
return 0;
}
|
d122d63f6bdc2b18089ad3f0fdcf2880de21ffb3
|
e683a0b8dbb87c7ceb99e0d06896174a559d2c67
|
/Tools/swat/value.c
|
edb08b8a2bbfa9fe22d8f390dd40234878e13638
|
[
"Apache-2.0"
] |
permissive
|
bluewaysw/pcgeos
|
f093d79567d977d992f47065056d14d5a04b9f14
|
c6ae4c8e77b54b9ff654c3916f2191f8b1a1b65d
|
refs/heads/master
| 2023-08-31T00:17:54.481175
| 2023-08-29T19:00:49
| 2023-08-29T19:00:49
| 157,968,410
| 603
| 88
|
Apache-2.0
| 2023-09-13T07:44:06
| 2018-11-17T09:09:55
|
Assembly
|
UTF-8
|
C
| false
| false
| 36,158
|
c
|
value.c
|
/***********************************************************************
*
* Copyright (c) Berkeley Softworks 1988 -- All Rights Reserved
*
* PROJECT: PCGEOS
* MODULE: SWAT -- value formatting/fetching/storing
* FILE: value.c
*
* AUTHOR: Adam de Boor: Nov 29, 1988
*
* ROUTINES:
* Name Description
* ---- -----------
* Value_HistoryStore Store an address tuple in the value history
* Value_HistoryFetch Fetch an address tuple from the value history
*
* REVISION HISTORY:
* Date Name Description
* ---- ---- -----------
* 11/29/88 ardeb Initial version
*
* DESCRIPTION:
* Functions for the formatting, printing, fetching and storing of
* values (mostly from the tcl level). Also the maintenance of the
* value-history.
*
***********************************************************************/
#ifndef lint
static char *rcsid =
"$Id: value.c,v 4.20 97/04/18 17:01:29 dbaumann Exp $";
#endif lint
#include <config.h>
#include "swat.h"
#include "cache.h"
#include "cmd.h"
#include "event.h"
#include "expr.h"
#include "private.h"
#include "sym.h"
#include "type.h"
#include "ui.h"
#include "value.h"
#include "var.h"
#include "file.h"
#include "cmdNZ.h"
#include <compat/stdlib.h>
#include <compat/string.h>
#include <buf.h>
#include <ctype.h>
static Cache history;
static int nextHistNum;
extern char wrongNumArgsString[];
typedef struct {
int number; /* History number */
Handle handle; /* Handle of address */
Address offset; /* Offset of address */
Type type; /* Type of element */
} ValueHistRec, *ValueHistPtr;
/***********************************************************************
* ValueHistoryInterest
***********************************************************************
* SYNOPSIS: Interest procedure for handles stored in the
* history
* CALLED BY: Handle module
* RETURN: Nothing
* SIDE EFFECTS: If status is HANDLE_FREE, the entry is nuked from
* the history.
*
* STRATEGY:
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 5/ 3/89 Initial Revision
*
***********************************************************************/
static void
ValueHistoryInterest(Handle handle,
Handle_Status status,
Opaque data)
{
Cache_Entry entry = (Cache_Entry)data;
if (status == HANDLE_FREE) {
/*
* Remove the history entry from the history. ValueHistoryDestroy
* will unregister interest.
*/
Cache_InvalidateOne(history, entry);
}
}
/*-
*-----------------------------------------------------------------------
* ValueHistoryDestroy --
* Callback function for history cache to free up memory associated
* with a history entry.
*
* Results:
* None.
*
* Side Effects:
* The data associated with the history entry are freed.
*
*-----------------------------------------------------------------------
*/
static void
ValueHistoryDestroy(Cache cache,
Cache_Entry entry)
{
ValueHistPtr histPtr;
histPtr = (ValueHistPtr)Cache_GetValue(entry);
assert(VALIDTPTR(histPtr, TAG_VALUE));
if (histPtr->handle != NullHandle) {
Handle_NoInterest(histPtr->handle,
ValueHistoryInterest,
(Opaque)entry);
}
free((char *)histPtr);
}
/*-
*-----------------------------------------------------------------------
* Value_HistoryStore --
* Store a new element in the history list.
*
* Results:
* The number under which the value was stored.
*
* Side Effects:
* A previous history element may be booted.
*
*-----------------------------------------------------------------------
*/
int
Value_HistoryStore(Handle handle,
Address offset,
Type type)
{
ValueHistPtr histPtr;
Cache_Entry entry;
histPtr = (ValueHistPtr)malloc_tagged(sizeof(ValueHistRec), TAG_VALUE);
histPtr->number = nextHistNum;
histPtr->handle = handle;
histPtr->offset = offset;
histPtr->type = type;
entry = Cache_Enter(history, (Address)histPtr->number,
(Boolean *)NULL);
Cache_SetValue(entry, histPtr);
/*
* If handle given, register interest in it so we're told if the
* thing is freed. This allows us to purge bogus entries from
* the value history.
*/
if (handle != NullHandle) {
Handle_Interest(handle, ValueHistoryInterest, (Opaque)entry);
}
return (nextHistNum++);
}
/*-
*-----------------------------------------------------------------------
* Value_HistoryFetch --
* Find the value and type of a history member.
*
* Results:
* TRUE if the requested element is in the history.
*
* Side Effects:
* None.
*
*-----------------------------------------------------------------------
*/
Boolean
Value_HistoryFetch(int number, /* Number of element to fetch. 0
* if should fetch most-recent one
*/
Handle *handlePtr, /* Place to store handle */
Address *offsetPtr, /* Place to store offset */
Type *typePtr) /* Place to store type */
{
Cache_Entry entry;
ValueHistPtr histPtr;
/*
* Adjust number if it's 0
*/
if (number <= 0) {
number = nextHistNum - 1 + number;
}
entry = Cache_Lookup(history, (Address)number);
if (entry == NullEntry) {
return(FALSE);
} else {
histPtr = (ValueHistPtr)Cache_GetValue(entry);
assert(VALIDTPTR(histPtr,TAG_VALUE));
*handlePtr = histPtr->handle;
*offsetPtr = histPtr->offset;
*typePtr = histPtr->type;
return(TRUE);
}
}
typedef struct {
Buffer buf; /* Buffer into which to format it */
genptr value; /* Base of structure being formatted */
} ValueCmdData;
typedef struct {
const char **fields;/* Broken-down list of fields */
int fieldNum; /* Field being unformatted */
genptr value; /* Base of structure */
} ValueCmdUndata;
static Boolean ValueCmdFormatField(Type, const char *, int, int, Type, ClientData);
static Boolean ValueCmdFormatUnionField(Type, const char *, int, int, Type, ClientData);
static Boolean ValueCmdUnformatField(Type, const char *, int, int, Type, ClientData);
/***********************************************************************
* ValueCmdFormat
***********************************************************************
* SYNOPSIS: Format an individual value into a buffer
* CALLED BY: ValueCmdFormatField, ValueCmd
* RETURN: Nothing
* SIDE EFFECTS: Yeah
*
* STRATEGY:
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 11/29/88 Initial Revision
*
***********************************************************************/
static void
ValueCmdFormat(Buffer buf,
genptr value,
Type type)
{
switch(Type_Class(type)) {
case TYPE_STRUCT:
{
ValueCmdData vcd;
vcd.buf = buf;
vcd.value = value;
Type_ForEachField(type, ValueCmdFormatField,
(Opaque)&vcd);
break;
}
case TYPE_UNION:
{
/*
* This is a little different from that for a structure as
* we have to swap and unswap the data for each type of field.
*/
ValueCmdData vcd;
vcd.buf = buf;
vcd.value = value;
Type_ForEachField(type, ValueCmdFormatUnionField,
(Opaque)&vcd);
break;
}
case TYPE_ARRAY:
{
int top;
Type base;
int bsize;
genptr vp;
int i;
Type_GetArrayData(type, (int *)0, &top, (Type *)0, &base);
bsize = Type_Sizeof(base);
for (i = 0, vp = value; i <= top; i++, vp += bsize) {
Buf_AddByte(buf, (Byte)'{');
ValueCmdFormat(buf, vp, base);
if (i != top) {
Buf_AddBytes(buf, 2, (Byte *)"} ");
} else {
Buf_AddByte(buf, (Byte)'}');
break;
}
}
break;
}
case TYPE_FLOAT:
{
int size = Type_Sizeof(type);
union {
long double l;
double d;
float f;
byte b[10];
} val;
char aval[320]; /* this is the size of the internal
* buffer used by sprintf */
/*
* Convert the fetched value into something we can manipulate.
* NOTE: We cannot simply cast "value" into a pointer of the
* appropriate type, as the thing may not be properly
* aligned for the current machine.
*/
if (size > 10) {
strcpy(aval, "Infinity");
} else {
double d;
bcopy(value, val.b, size);
/* just print everything as a double as sprintf doesn't
* know about long doubles
*/
if (size == 4) {
d = val.f;
} else if (size == 8) {
d = val.d;
} else {
d = val.l;
}
if (d > 1000000000L) {
/* if this thing is this big, just put it into
* exponential form for easier reading
*/
sprintf(aval, "%e", d);
} else {
sprintf(aval, "%f", d);
}
}
Buf_AddBytes(buf, strlen(aval), (Byte *)aval);
break;
}
case TYPE_CHAR:
{
unsigned char c = *(unsigned char *)value;
switch(c) {
case '\\':
Buf_AddBytes(buf, 2, (Byte *)"\\\\");
break;
case '{':
Buf_AddBytes(buf, 2, (Byte *)"\\{");
break;
case '}':
Buf_AddBytes(buf, 2, (Byte *)"\\}");
break;
case '\n':
Buf_AddBytes(buf, 2, (Byte *)"\\n");
break;
case '\b':
Buf_AddBytes(buf, 2, (Byte *)"\\b");
break;
case '\r':
Buf_AddBytes(buf, 2, (Byte *)"\\r");
break;
case '\f':
Buf_AddBytes(buf, 2, (Byte *)"\\f");
break;
case '\033':
Buf_AddBytes(buf, 2, (Byte *)"\\e");
break;
default:
if (!isprint(c)) {
char b[5];
sprintf(b, "\\%03o", c);
Buf_AddBytes(buf, 4, (Byte *)b);
} else {
Buf_AddByte(buf, c);
}
}
break;
}
case TYPE_INT:
default:
{
int size = Type_Sizeof(type);
int val;
int mask;
char aval[16];
/*
* Convert the fetched value into something we can manipulate.
* NOTE: We cannot simply cast "value" into a pointer of the
* appropriate type, as the thing may not be properly
* aligned for the current machine.
*/
if (size == 1) {
val = *(char *)((signed char *)value);
} else if (size == 2) {
if (swap) {
val = (((signed char *)value)[0] << 8) |
(((signed char *)value)[1] & 0xff);
} else {
val = (((signed char *)value)[1] << 8) |
(((signed char *)value)[0] & 0xff);
}
} else {
if (swap) {
val = (((signed char *)value)[0] << 24) |
((((signed char *)value)[1] & 0xff) << 16) |
((((signed char *)value)[2] & 0xff) << 8) |
(((signed char *)value)[3] & 0xff);
} else {
val = (((signed char *)value)[3] << 24) |
((((signed char *)value)[2] & 0xff) << 16) |
((((signed char *)value)[1] & 0xff) << 8) |
(((signed char *)value)[0] & 0xff);
}
}
mask = (1 << (size * 8)) - 1;
/*
* On the sparc (and possibly others), a shift count of 32
* is considered a shift count of 0. This will give us 1 - 1
* or a 0 mask, which isn't good...
*/
if (mask) {
val &= mask;
} else {
mask = -1;
}
if (Type_IsSigned(type)) {
/*
* Trim the integer to be the appropriate size and then,
* if the high bit is set, sign extend the beast to the
* full length of an integer before printing it.
*/
if (val & (mask & ~(mask >> 1))) {
val |= ~mask;
}
sprintf(aval, "%d", val);
} else {
sprintf(aval, "%u", (val & mask));
}
Buf_AddBytes(buf, strlen(aval), (Byte *)aval);
break;
}
}
}
/***********************************************************************
* ValueCmdFormatField
***********************************************************************
* SYNOPSIS: Format a field of a structure into a 3-tuple.
* CALLED BY: ValueCmd/ValueCmdFormat via Type_ForEachField
* RETURN: 0
* SIDE EFFECTS: yeah.
*
* STRATEGY: Install the first two elements of the tuple,
* preceeded by a {, as required by tcl.
* Call ValueCmdFormat to format the value.
* Tack on the final } and return.
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 11/29/88 Initial Revision
*
***********************************************************************/
static Boolean
ValueCmdFormatField(Type stype,
const char *fname,
int offset,
int length,
Type ftype,
ClientData data)
{
ValueCmdData *vcd = (ValueCmdData *)data;
char tname[48];
Buf_AddByte(vcd->buf, (Byte)'{');
if (*fname != '\0') {
Buf_AddBytes(vcd->buf, strlen(fname), (Byte *)fname);
} else {
Buf_AddBytes(vcd->buf, 2, (Byte *)"{}");
}
sprintf(tname, " {%s} {", Type_ToAscii(ftype));
Buf_AddBytes(vcd->buf, strlen(tname), (Byte *)tname);
if ((length != Type_Sizeof(ftype) * 8) || (offset & 0x7)) {
/*
* If it's not of a byte-divisible length and on a byte boundary, we
* have to extract the field into our own thing of the appropriate
* size (so when we pass its address, we're actually pointing to the
* beast, not to some unimportant higher bytes...), then format that
* according to the field's type.
*/
Boolean isSigned = Type_IsSigned(ftype);
if (Type_Class(ftype) != TYPE_INT) {
switch(Type_Sizeof(ftype)) {
case 1:
{
byte val;
val = (byte)Var_ExtractBits(vcd->value, offset, length,
isSigned);
ValueCmdFormat(vcd->buf, (genptr)&val, ftype);
break;
}
case 2:
{
word val;
val = (word)Var_ExtractBits(vcd->value, offset, length,
isSigned);
if (Type_IsRecord(ftype)) {
/*
* Need to be in the target byte order if it's a record
*/
Var_SwapValue(VAR_STORE, type_Word, 2, (genptr)&val);
}
ValueCmdFormat(vcd->buf, (genptr)&val, ftype);
break;
}
default:
case 4:
{
dword val;
val = (dword)Var_ExtractBits(vcd->value, offset, length,
isSigned);
ValueCmdFormat(vcd->buf, (genptr)&val, ftype);
break;
}
}
} else {
unsigned val;
char aval[8];
val = Var_ExtractBits(vcd->value, offset, length, isSigned);
if (isSigned) {
sprintf(aval, "%d", val);
} else {
sprintf(aval, "%u", val);
}
Buf_AddBytes(vcd->buf, strlen(aval), (Byte *)aval);
}
} else {
ValueCmdFormat(vcd->buf, vcd->value + (offset/8), ftype);
}
Buf_AddBytes(vcd->buf, 3, (Byte *)"}} ");
return(0);
}
/***********************************************************************
* ValueCmdFormatUnionField
***********************************************************************
* SYNOPSIS: Format a field of a union into a 3-tuple.
* CALLED BY: ValueCmd/ValueCmdFormat via Type_ForEachField
* RETURN: 0
* SIDE EFFECTS: yeah.
*
* STRATEGY: Swap the union according to the type of the current
* field Install the first two elements of the tuple,
* preceeded by a {, as required by tcl.
* Call ValueCmdFormat to format the value.
* Tack on the final }
* Swap the union back and return.
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 11/29/88 Initial Revision
*
***********************************************************************/
static Boolean
ValueCmdFormatUnionField(Type stype,
const char *fname,
int offset,
int length,
Type ftype,
ClientData data)
{
ValueCmdData *vcd = (ValueCmdData *)data;
char tname[48];
Buf_AddByte(vcd->buf, (Byte)'{');
if (*fname != '\0') {
Buf_AddBytes(vcd->buf, strlen(fname), (Byte *)fname);
} else {
Buf_AddBytes(vcd->buf, 2, (Byte *)"{}");
}
sprintf(tname, " {%s} {", Type_ToAscii(ftype));
Buf_AddBytes(vcd->buf, strlen(tname), (Byte *)tname);
if (length != Type_Sizeof(ftype) * 8) {
/*
* If it's not of a byte-divisible length, we have to extract the
* field into our own thing of the appropriate size (so when we
* pass its address, we're actually pointing to the beast, not to
* some unimportant higher bytes...), then format that according
* to the field's type.
*/
Boolean isSigned = Type_IsSigned(ftype);
if (Type_Class(ftype) != TYPE_INT) {
switch(Type_Sizeof(ftype)) {
case 1:
{
byte val;
val = (byte)Var_ExtractBits(vcd->value, offset, length,
isSigned);
ValueCmdFormat(vcd->buf, (genptr)&val, ftype);
break;
}
case 2:
{
word val;
val = (word)Var_ExtractBits(vcd->value, offset, length,
isSigned);
ValueCmdFormat(vcd->buf, (genptr)&val, ftype);
break;
}
default:
case 4:
{
dword val;
val = (dword)Var_ExtractBits(vcd->value, offset, length,
isSigned);
ValueCmdFormat(vcd->buf, (genptr)&val, ftype);
break;
}
}
} else {
unsigned val;
char aval[8];
val = (unsigned)Var_ExtractBits(vcd->value, offset, length,
isSigned);
if (isSigned) {
sprintf(aval, "%d", val);
} else {
sprintf(aval, "%u", val);
}
Buf_AddBytes(vcd->buf, strlen(aval), (Byte *)aval);
}
} else {
if (swap) {
Var_SwapValue(VAR_FETCH, ftype, length/8, vcd->value+(offset/8));
}
ValueCmdFormat(vcd->buf, vcd->value + (offset/8), ftype);
if (swap) {
Var_SwapValue(VAR_STORE, ftype, length/8, vcd->value+(offset/8));
}
}
Buf_AddBytes(vcd->buf, 3, (Byte *)"}} ");
return(0);
}
/***********************************************************************
* Value_ConvertToString
***********************************************************************
* SYNOPSIS: Convert a hunk of data from the patient into a
* string based on the type of data.
* CALLED BY: ValueCmd, EXTERNAL
* RETURN: A dynamically allocated string holding the value
* as a TCL list.
* SIDE EFFECTS: None.
*
* STRATEGY:
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 12/17/89 Initial Revision
*
***********************************************************************/
char *
Value_ConvertToString(Type type, /* Type of data to convert */
Opaque value) /* Data to convert */
{
Buffer buf;
char *retval;
buf = Buf_Init(0);
ValueCmdFormat(buf, value, type);
Buf_AddByte(buf, (Byte)0);
retval = (char *)Buf_GetAll(buf, (int *)NULL);
Buf_Destroy(buf, FALSE);
return(retval);
}
/***********************************************************************
* ValueCmdUnformat
***********************************************************************
* SYNOPSIS: Parse out a unit from the string, storing it in the
* buffer passed.
* CALLED BY: Value_ConvertFromString, ValueCmdUnformatField, self
* RETURN: non-zero if happy, zero if malformed string
* on error, a message is left in the system-wide tcl
* interpreter's return value, in case we were called
* by a tcl function.
* SIDE EFFECTS: Buffer overwritten
*
* STRATEGY:
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 12/17/89 Initial Revision
*
***********************************************************************/
static int
ValueCmdUnformat(Type type, /* Type of data in string */
const char *str, /* String to parse */
Opaque value) /* Buffer for storage */
{
switch(Type_Class(type)) {
case TYPE_STRUCT:
{
/*
* XXX: Do fieldname-keyed storage instead of linear? Would make
* life easier, but what to do with uninitialized fields?
*/
ValueCmdUndata vcu;
int nfields;
if (Tcl_SplitList(interp, str, &nfields, (char ***)&vcu.fields) !=
TCL_OK)
{
return(0);
}
vcu.fieldNum = 0;
vcu.value = value;
Type_ForEachField(type, ValueCmdUnformatField,
(Opaque)&vcu);
free((char *)vcu.fields);
/*
* If didn't make it all the way through, one of the fields was
* malformed, so return 0.
*/
if (vcu.fieldNum != nfields) {
return(0);
}
break;
}
case TYPE_ARRAY:
{
int top;
Type base;
int bsize;
genptr vp;
int i;
int nels;
char **els;
Type_GetArrayData(type, (int *)0, &top, (Type *)0, &base);
bsize = Type_Sizeof(base);
/*
* Break the string down to its component pieces and make sure we
* were given the right number of them.
*/
if (Tcl_SplitList(interp, str, &nels, &els) != TCL_OK) {
return (0);
}
if (nels != top+1) {
free((char *)els);
Tcl_Return(interp, "incorrect number of elements for array",
TCL_STATIC);
return(0);
}
/*
* Unformat the individual pieces, stopping if we get an error
* back for any of them.
*/
for (i = 0, vp = value; i <= top; i++, vp += bsize) {
if (!ValueCmdUnformat(base, els[i], (Opaque)vp)) {
free((char *)els);
return(0);
}
}
free((char *)els);
break;
}
case TYPE_CHAR:
{
if (*str == '\\') {
int n;
*(unsigned char *)value = Tcl_Backslash(str, &n);
/*
* If character escape didn't consume the entire string,
* we consider it an error.
*/
if (str[n] != '\0') {
Tcl_RetPrintf(interp, "\"%s\" not valid character escape",
str);
return(0);
}
} else {
/*
* Store the character away as given.
*/
*(unsigned char *)value = *str;
}
break;
}
case TYPE_INT:
default:
{
int size = Type_Sizeof(type);
int val;
char *endStr;
val = cvtnum(str, &endStr);
if (*endStr != '\0') {
/*
* If number not the whole thing, it's an error
*/
Tcl_RetPrintf(interp, "\"%s\" not valid scalar", str);
return(0);
}
/*
* Store the converted value away, based on the size of the
* data type we're storing.
* NOTE: We cannot simply cast "value" into a pointer of the
* appropriate type, as the thing may not be properly
* aligned for the current machine.
*/
if (swap) {
/*
* Native order big-endian: lsb goes up high.
*/
((byte *)value)[size-1] = val;
if (size > 1) {
val >>= 8;
((byte *)value)[size-2] = val;
if (size > 2) {
val >>= 8;
((byte *)value)[size-3] = val;
if (size > 3) {
val >>= 8;
((byte *)value)[size-4] = val;
}
}
}
} else {
/*
* Native order little-endian: lsb goes down low
*/
*(byte *)value = val;
if (size > 1) {
val >>= 8;
((byte *)value)[1] = val;
if (size > 2) {
val >>= 8;
((byte *)value)[2] = val;
if (size > 3) {
val >>= 8;
((byte *)value)[3] = val;
}
}
}
}
break;
}
case TYPE_VOID:
break;
case TYPE_UNION:
Tcl_Return(interp, "cannot store unions (yet?)", TCL_STATIC);
return(0);
}
return(1);
}
/***********************************************************************
* ValueCmdUnformatField
***********************************************************************
* SYNOPSIS: Convert a field of a structure given in ascii to binary.
* CALLED BY: ValueCmdUnformat via Type_ForEach
* RETURN: 0 if ok, non-zero if unhappy with the string.
* SIDE EFFECTS: The buffer given in the ValueCmdUndata is overwritten.
* vcu->fieldNum is incremented
*
* STRATEGY:
*
* XXX: Should this insist on matching field names?
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 12/17/89 Initial Revision
*
***********************************************************************/
static Boolean
ValueCmdUnformatField(Type stype,
const char *fname,
int offset,
int length,
Type ftype,
ClientData data)
{
ValueCmdUndata *vcu = (ValueCmdUndata *)data;
char **els;
int nels;
int retval = 0;
/*
* Break the value into its proper three-part list.
*/
if (Tcl_SplitList(interp, vcu->fields[vcu->fieldNum], &nels, &els)!=TCL_OK)
{
/*
* Stop traversal -- leaving fieldNum unincremented will signal our
* displeasure.
*/
return(1);
}
/*
* Make sure list contains the right number of elements.
*/
if (nels != 3) {
Tcl_Return(interp, "structure field must be described by a 3-list",
TCL_STATIC);
free((char *)els);
return(1);
}
/* XXX: Compare field names? types? */
if (length != Type_Sizeof(ftype) * 8) {
/*
* If it's not of a byte-divisible length, we have to store the
* field specially. Value must be a lone integer.
*/
char *endStr;
word val;
val = cvtnum(els[2], &endStr);
if (*endStr != '\0') {
Tcl_RetPrintf(interp, "\"%s\" improperly formed bit-field",
els[2]);
retval = 1;
} else {
Var_InsertBits(vcu->value, offset, length, val);
}
} else {
retval = !ValueCmdUnformat(ftype, els[2], vcu->value + (offset/8));
}
if (!retval) {
vcu->fieldNum += 1;
}
free((char *)els);
return(retval);
}
/***********************************************************************
* Value_ConvertFromString
***********************************************************************
* SYNOPSIS: Convert a structured string, as produced by
* Value_ConvertToString, into a block of binary data
* for shipment to the pc.
* CALLED BY: ValueCmd, EXTERNAL
* RETURN: Pointer to the data buffer allocated. The data are
* stored in our native byte-order
* SIDE EFFECTS: None
*
* STRATEGY:
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 12/17/89 Initial Revision
*
***********************************************************************/
Opaque
Value_ConvertFromString(Type type, /* Type describing string */
const char *str) /* String to convert */
{
int size = Type_Sizeof(type);
Opaque value = (Opaque)malloc_tagged(size, TAG_DVAL);
if (!ValueCmdUnformat(type, str, value)) {
/*
* Malformed string -- return NULL to indicate error
*/
free((char *)value);
value = NullOpaque;
}
return(value);
}
/***********************************************************************
* ValueCmd
***********************************************************************
* SYNOPSIS: Implementation of the Tcl "value" command
* CALLED BY: Tcl
* RETURN: TCL_OK or TCL_ERROR
* SIDE EFFECTS: None
*
* STRATEGY:
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* ardeb 11/29/88 Initial Revision
*
***********************************************************************/
#define VALUE_FETCH (ClientData)0
#define VALUE_STORE (ClientData)1
#define VALUE_HFETCH (ClientData)2
#define VALUE_HSTORE (ClientData)3
#define VALUE_HSET (ClientData)4
#define VALUE_LOG (ClientData)5
static const CmdSubRec valueCmds[] = {
{"fetch", VALUE_FETCH, 1, 2, "<address> [<type>]"},
{"store", VALUE_STORE, 2, 3, "<address> <value> [<type>]"},
{"hfetch", VALUE_HFETCH, 1, 1, "<number>"},
{"hstore", VALUE_HSTORE, 1, 1, "<addr-list>"},
{"hset", VALUE_HSET, 1, 1, "<numberSaved>"},
{"log", VALUE_LOG, 2, 3, "<address> <stream> [<type>]"},
{NULL, (ClientData)NULL, 0, 0, NULL}
};
DEFCMD(value,Value,0,valueCmds,swat_prog.patient|swat_prog.memory,
"Usage:\n\
value fetch <addr> [<type>]\n\
value store <addr> <value> [<type>]\n\
value hfetch <num>\n\
value hstore <addr-list>\n\
value hset <number-saved>\n\
value log <addr> <stream> <type>]\n\
\n\
Examples:\n\
\"value fetch ds:si [type word]\" Fetch a word from ds:si\n\
\"value store ds:si 0 [type word]\" Store 0 to the word at ds:si\n\
\"value hfetch 36\" Fetch the 36th address list stored\n\
in the value history.\n\
\"value hstore $a\" Store the address list in $a into\n\
the value history.\n\
\"value hset 50\" Keep track of up to 50 address lists\n\
in the value history.\n\
\"value log ds:si $s [type word]\" Fetch a word from ds:si and dump the binary \n\
data to stream $s \n\
\n\
Synopsis:\n\
This command allows you to fetch and alter values in the target PC. It is\n\
also the maintainer of the value history, which you normally access via\n\
@<number> terms in address expressions.\n\
\n\
Notes:\n\
* \"value fetch\" returns a value list that contains the data at the\n\
given address. If the address has an implied data type (it involves\n\
a named variable or a structure field), then you do not need to give the\n\
<type> argument.\n\
\n\
All integers and enumerated types are returned in decimal. 32-bit\n\
pointers are returned as a single decimal integer whose high 16 bits are\n\
the high 16 bits (segment or handle) of the pointer. 16-bit pointers\n\
are likewise returned as a single decimal integer.\n\
\n\
Characters are returned as characters, with non-printable characters\n\
converted to the appropriate backslash escapes (for example, newline\n\
is returned as \\n).\n\
\n\
Arrays are returned as a list of value lists, one element per element\n\
of the array.\n\
\n\
Structures, unions and records are returned as a list of elements,\n\
each of which is a 3-element list: {<field-name> <type> <value>}\n\
<field-name> is the name of the field, <type> is the type token for\n\
the type of data stored in the field, and <value> is the value list\n\
for the data in the field, appropriate to its data type.\n\
\n\
* You will note that the description of value lists is recursive.\n\
For example, if a structure has a field that is an array, the <value>\n\
element in the list that describes that particular field will be itself\n\
a list whose elements are the elements of the array. If that array were\n\
an array of structures, each element of that list would again be a list\n\
of {<field-name> <type> <value>} lists.\n\
\n\
* The \"field\" command is very useful when you want to extract the value\n\
for a structure field from a value list.\n\
\n\
* As for \"value fetch\", you do not need to give the <type> argument to\n\
\"value store\" if the <addr> has an implied data type. The <value>\n\
argument is a value list appropriate to the type of data being stored,\n\
as described above.\n\
\n\
* \"value hstore\" returns the number assigned to the stored address list.\n\
These numbers always increase, starting from 1.\n\
\n\
* If no address list is stored for a given number, \"value hfetch\" will\n\
generate an error.\n\
\n\
* \"value hset\" controls the maximum number of address lists the value\n\
history will hold. The value history is a FIFO queue; if it holds\n\
50 entries, and the 51st entry is added to it, the 1st entry will be\n\
thrown out.\n\
\n\
* \"value log\" has the same functionality as value fetch except that data fetched \n\
from the PC are dumped into the stream as raw binary data. \n\
\n\
See also:\n\
addr-parse, assign, field\n\
")
{
switch((int)clientData) {
case VALUE_STORE:
case VALUE_FETCH:
case VALUE_LOG:
{
genptr value;
GeosAddr addr;
Type type;
int typeIndex;
if (!Expr_Eval(argv[2], NullFrame, &addr, &type, TRUE)) {
Tcl_Error(interp, "value: couldn't parse address");
}
if (clientData == VALUE_STORE || clientData == VALUE_LOG) {
typeIndex = 4;
} else {
typeIndex = 3;
}
if (argc > typeIndex) {
static struct {
char *typeName;
Type *typeDesc;
} predefs[] = {
{"byte", &type_Byte},
{"word", &type_Word},
{"dword", &type_DWord},
{"sbyte", &type_SByte},
{"short", &type_Short},
{"long", &type_Long},
{"char", &type_Char},
{"wchar", &type_WChar},
{"sword", &type_Short},
{"sdword", &type_Long}
};
type = Type_ToToken(argv[typeIndex]);
if (Type_IsNull(type)) {
/*
* KLUDGE: check to see if it's a predefined type. The proper
* way to do this is with a nested "type" command, but
* people insist on just being able to ask for a "word",
* so rather than listening to complaints, I've decided
* to just put this here.
*
* 3/30/92: conduct this search *first* as a lot of Tcl
* code now uses just "word" or whatever and the speed
* difference is incredibly noticeable. -- ardeb
*/
int i;
for (i = Number(predefs)-1; i >= 0; i--) {
if (!ustrcmp(argv[typeIndex], predefs[i].typeName)) {
type = *predefs[i].typeDesc;
break;
}
}
}
if (Type_IsNull(type)) {
Sym sym = Sym_Lookup(argv[typeIndex], SYM_TYPE,
curPatient->global);
if (!Sym_IsNull(sym)) {
type = Sym_GetTypeData(sym);
}
}
if (Type_IsNull(type)) {
Tcl_RetPrintf(interp, "value: %s: invalid type",
argv[typeIndex]);
return(TCL_ERROR);
}
}
if (Type_IsNull(type)) {
Tcl_Error(interp, "value: need type of data to fetch/store");
}
if (clientData == VALUE_STORE) {
value = Value_ConvertFromString(type, argv[3]);
if (value == NULL) {
Tcl_Error(interp, "value store: couldn't convert string");
}
Var_Store(type, value, addr.handle, addr.offset);
} else {
if (!Var_FetchAlloc(type, addr.handle, addr.offset, &value)) {
Tcl_Return(interp, "value: couldn't fetch data", TCL_STATIC);
return(TCL_ERROR);
}
if (clientData == VALUE_FETCH) {
Tcl_Return(interp, Value_ConvertToString(type, value), TCL_DYNAMIC);
} else {
int size;
Stream *stream = 0;
stream = (Stream *)atoi(argv[3]);
if (!VALIDTPTR(stream,TAG_STREAM)) {
Tcl_RetPrintf(interp, "%s: not a stream", argv[3]);
return(TCL_ERROR);
}
size = Type_Sizeof(type);
if (stream->type == STREAM_SOCKET) {
if (write(stream->sock, (char*)value, size) < size) {
stream->sockErr = TRUE;
}
} else {
(void)fwrite((char*)value, size, 1, stream->file);
}
}
}
free((char *)value);
break;
}
case VALUE_HFETCH:
{
Handle handle;
Address offset;
Type type;
if (!Value_HistoryFetch(atoi(argv[2]), &handle, &offset, &type)) {
Tcl_RetPrintf(interp, "%s: not in value history", argv[2]);
return(TCL_ERROR);
} else {
Tcl_RetPrintf(interp, "%d %d {%s}", handle, offset,
Type_ToAscii(type));
}
break;
}
case VALUE_HSTORE:
{
Handle handle;
Address offset;
Type type;
char **fields;
int nfields;
if (Tcl_SplitList(interp, argv[2], &nfields, &fields) != TCL_OK) {
return(TCL_ERROR);
}
if (nfields != 3) {
Tcl_Error(interp, "value hstore: <addr-list> needs three fields");
}
/*
* Convert the three fields individually. Note that atoi("nil") yields
* 0, so there's no need to deal with it specially.
*/
handle = (Handle)atoi(fields[0]);
offset = (Address)atoi(fields[1]);
type = Type_ToToken(fields[2]);
free((char *)fields);
Tcl_RetPrintf(interp, "%d", Value_HistoryStore(handle, offset, type));
break;
}
case VALUE_HSET:
{
int length = cvtnum(argv[2], NULL);
if (length >= 1) {
Cache_SetMaxSize(history, length);
return(TCL_OK);
} else {
Tcl_Error(interp, "value hset: history must contain at least one entry");
}
}
}
return(TCL_OK);
}
/*-
*-----------------------------------------------------------------------
* Value_Init --
* Initialize our data for this patient.
*
* Results:
* None.
*
* Side Effects:
* A ValuePrivRec is created and attached to the patient.
*
*-----------------------------------------------------------------------
*/
void
Value_Init(void)
{
nextHistNum = 1;
history = Cache_Create(0, 50, CACHE_ADDRESS, ValueHistoryDestroy);
Cmd_Create(&ValueCmdRec);
}
|
e3403e60350920ab67bfda34756423d860dbfb85
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/driver/xf86-video-intel/src/sna/fb/fbline.c
|
e134e23e14abb6c8a78c5aff61340994bc6dc33b
|
[
"HPND-sell-variant",
"MIT"
] |
permissive
|
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
| 4,579
|
c
|
fbline.c
|
/*
* Copyright © 1998 Keith Packard
* Copyright © 2012 Intel Corporation
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "fb.h"
#include <mi.h>
#include <micoord.h>
#include <miline.h>
#include <scrnintstr.h>
#define POLYLINE fbPolyline8
#define POLYSEGMENT fbPolySegment8
#define BITS BYTE
#define BITS2 CARD16
#define BITS4 CARD32
#include "fblinebits.h"
#undef BITS
#undef BITS2
#undef BITS4
#undef POLYSEGMENT
#undef POLYLINE
#define POLYLINE fbPolyline16
#define POLYSEGMENT fbPolySegment16
#define BITS CARD16
#define BITS2 CARD32
#include "fblinebits.h"
#undef BITS
#undef BITS2
#undef POLYSEGMENT
#undef POLYLINE
#define POLYLINE fbPolyline32
#define POLYSEGMENT fbPolySegment32
#define BITS CARD32
#include "fblinebits.h"
#undef BITS
#undef POLYSEGMENT
#undef POLYLINE
static void
fbZeroLine(DrawablePtr drawable, GCPtr gc, int mode, int n, DDXPointPtr pt)
{
int x1, y1, x2, y2;
int x, y;
int dashOffset;
x = drawable->x;
y = drawable->y;
x1 = pt->x;
y1 = pt->y;
dashOffset = gc->dashOffset;
while (--n) {
++pt;
x2 = pt->x;
y2 = pt->y;
if (mode == CoordModePrevious) {
x2 += x1;
y2 += y1;
}
fbSegment(drawable, gc,
x1 + x, y1 + y,
x2 + x, y2 + y,
n == 1 && gc->capStyle != CapNotLast, &dashOffset);
x1 = x2;
y1 = y2;
}
}
static void
fbZeroSegment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg)
{
int dashOffset;
int16_t x, y;
Bool drawLast = gc->capStyle != CapNotLast;
x = drawable->x;
y = drawable->y;
while (n--) {
dashOffset = gc->dashOffset;
fbSegment(drawable, gc,
seg->x1 + x, seg->y1 + y,
seg->x2 + x, seg->y2 + y,
drawLast, &dashOffset);
seg++;
}
}
void
fbFixCoordModePrevious(int n, DDXPointPtr pt)
{
int16_t x = pt->x;
int16_t y = pt->y;
while (--n) {
pt++;
x = (pt->x += x);
y = (pt->y += y);
}
}
void
fbPolyLine(DrawablePtr drawable, GCPtr gc, int mode, int n, DDXPointPtr pt)
{
void (*raster)(DrawablePtr, GCPtr, int mode, int n, DDXPointPtr pt);
DBG(("%s x %d, width=%d, fill=%d [solid? %d], line=%d [solid? %d], bpp=%d\n",
__FUNCTION__, n, gc->lineWidth,
gc->fillStyle, gc->fillStyle == FillSolid,
gc->lineStyle, gc->lineStyle == LineSolid,
drawable->bitsPerPixel));
if (gc->lineWidth == 0) {
raster = fbZeroLine;
if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid) {
switch (drawable->bitsPerPixel) {
case 8:
raster = fbPolyline8;
break;
case 16:
raster = fbPolyline16;
break;
case 32:
raster = fbPolyline32;
break;
}
}
} else {
if (gc->lineStyle != LineSolid)
raster = miWideDash;
else
raster = miWideLine;
}
raster(drawable, gc, mode, n, pt);
}
void
fbPolySegment(DrawablePtr drawable, GCPtr gc, int n, xSegment *seg)
{
void (*raster)(DrawablePtr drawable, GCPtr gc, int n, xSegment * seg);
DBG(("%s x %d, width=%d, fill=%d [solid? %d], line=%d [solid? %d], bpp=%d\n",
__FUNCTION__, n, gc->lineWidth,
gc->fillStyle, gc->fillStyle == FillSolid,
gc->lineStyle, gc->lineStyle == LineSolid,
drawable->bitsPerPixel));
if (gc->lineWidth == 0) {
raster = fbZeroSegment;
if (gc->fillStyle == FillSolid && gc->lineStyle == LineSolid) {
switch (drawable->bitsPerPixel) {
case 8:
raster = fbPolySegment8;
break;
case 16:
raster = fbPolySegment16;
break;
case 32:
raster = fbPolySegment32;
break;
}
}
} else
raster = miPolySegment;
raster(drawable, gc, n, seg);
}
|
90734d539498df7aca5f5d2fa53dc8bc99398990
|
ecea7c1f53661a57736d9b3f6deec97712ff22fc
|
/SecurityExploits/Android/Mali/CVE_2022_46395/mempool_utils.h
|
41156691da2444eb54279389e7d9645aafe54088
|
[
"MIT"
] |
permissive
|
github/securitylab
|
088d785622a1a1e86fa171f9296d2a66542bc88f
|
80e2d6abadad8cb77e8c9f659e32eaee6b3a98ed
|
refs/heads/main
| 2023-09-03T04:21:06.795016
| 2023-07-06T15:31:30
| 2023-07-06T15:31:30
| 221,101,274
| 1,079
| 225
|
MIT
| 2023-08-16T16:41:27
| 2019-11-12T01:14:24
|
C
|
UTF-8
|
C
| false
| false
| 461
|
h
|
mempool_utils.h
|
#ifndef MEMPOOL_UTILS_H
#define MEMPOOL_UTILS_H
#include <unistd.h>
#include "mali.h"
#include "mali_base_jm_kernel.h"
#include "log_utils.h"
void mem_alloc(int fd, union kbase_ioctl_mem_alloc* alloc);
void reserve_pages(int mali_fd, int pages, int nents, uint64_t* reserved_va);
void map_reserved(int mali_fd, int pages, int nents, uint64_t* reserved_va);
uint64_t drain_mem_pool(int mali_fd);
void release_mem_pool(int mali_fd, uint64_t drain);
#endif
|
617dbf05c34b7499265c885c86efdfa8debef142
|
de21f9075f55640514c29ef0f1fe3f0690845764
|
/regression/crangler/remove-static-regex/remove_static1.c
|
10df0a9e61141bae93dc6a06a56a6ea530ec1543
|
[
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-4-Clause"
] |
permissive
|
diffblue/cbmc
|
975a074ac445febb3b5715f8792beb545522dc18
|
decd2839c2f51a54b2ad0f3e89fdc1b4bf78cd16
|
refs/heads/develop
| 2023-08-31T05:52:05.342195
| 2023-08-30T13:31:51
| 2023-08-30T13:31:51
| 51,877,056
| 589
| 309
|
NOASSERTION
| 2023-09-14T18:49:17
| 2016-02-16T23:03:52
|
C++
|
UTF-8
|
C
| false
| false
| 92
|
c
|
remove_static1.c
|
int foo()
{
return 0;
}
int bar();
static void foobar1()
{
}
void static foobar2()
{
}
|
4b0921b410bea645c559349cf7bc4eae97183a8a
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/sysutils/daemontools-encore/files/patch-sleeper.c
|
a57faebf62b46fa796b99566cc4aba9275655aa6
|
[
"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
| 1,062
|
c
|
patch-sleeper.c
|
--- sleeper.c.orig 2018-10-14 00:48:50 UTC
+++ sleeper.c
@@ -11,16 +11,16 @@ static void catch_sig(int sig)
int ignored;
int i;
switch (sig) {
- case SIGALRM: name = "ALRM"; break;
- case SIGCONT: name = "CONT"; break;
- case SIGHUP: name = "HUP"; break;
- case SIGINT: name = "INT"; break;
- case SIGQUIT: name = "QUIT"; break;
- case SIGTERM: name = "TERM"; break;
- case SIGUSR1: name = "USR1"; break;
- case SIGUSR2: name = "USR2"; break;
- case SIGWINCH: name = "WINCH"; break;
- default: name = "unknown signal";
+ case SIGALRM: name = "Caught ALRM\n"; break;
+ case SIGCONT: name = "Caught CONT\n"; break;
+ case SIGHUP: name = "Caught HUP\n"; break;
+ case SIGINT: name = "Caught INT\n"; break;
+ case SIGQUIT: name = "Caught QUIT\n"; break;
+ case SIGTERM: name = "Caught TERM\n"; break;
+ case SIGUSR1: name = "Caught USR1\n"; break;
+ case SIGUSR2: name = "Caught USR2\n"; break;
+ case SIGWINCH: name = "Caught WINCH\n"; break;
+ default: name = "unknown signal\n";
}
i = str_len(name);
byte_copy(buf+7,i,name);
|
3b4f1125983e94f8bd1ef763eff08fa937f234eb
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/sqlite/src/ext/misc/btreeinfo.c
|
22f8268139f6e1303461df84ea3210c86295fd46
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"blessing",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 12,959
|
c
|
btreeinfo.c
|
/*
** 2017-10-24
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains an implementation of the "sqlite_btreeinfo" virtual table.
**
** The sqlite_btreeinfo virtual table is a read-only eponymous-only virtual
** table that shows information about all btrees in an SQLite database file.
** The schema is like this:
**
** CREATE TABLE sqlite_btreeinfo(
** type TEXT, -- "table" or "index"
** name TEXT, -- Name of table or index for this btree.
** tbl_name TEXT, -- Associated table
** rootpage INT, -- The root page of the btree
** sql TEXT, -- SQL for this btree - from sqlite_schema
** hasRowid BOOLEAN, -- True if the btree has a rowid
** nEntry INT, -- Estimated number of entries
** nPage INT, -- Estimated number of pages
** depth INT, -- Depth of the btree
** szPage INT, -- Size of each page in bytes
** zSchema TEXT HIDDEN -- The schema to which this btree belongs
** );
**
** The first 5 fields are taken directly from the sqlite_schema table.
** Considering only the first 5 fields, the only difference between
** this virtual table and the sqlite_schema table is that this virtual
** table omits all entries that have a 0 or NULL rowid - in other words
** it omits triggers and views.
**
** The value added by this table comes in the next 5 fields.
**
** Note that nEntry and nPage are *estimated*. They are computed doing
** a single search from the root to a leaf, counting the number of cells
** at each level, and assuming that unvisited pages have a similar number
** of cells.
**
** The sqlite_dbpage virtual table must be available for this virtual table
** to operate.
**
** USAGE EXAMPLES:
**
** Show the table btrees in a schema order with the tables with the most
** rows occuring first:
**
** SELECT name, nEntry
** FROM sqlite_btreeinfo
** WHERE type='table'
** ORDER BY nEntry DESC, name;
**
** Show the names of all WITHOUT ROWID tables:
**
** SELECT name FROM sqlite_btreeinfo
** WHERE type='table' AND NOT hasRowid;
*/
#if !defined(SQLITEINT_H)
#include "sqlite3ext.h"
#endif
SQLITE_EXTENSION_INIT1
#include <string.h>
#include <assert.h>
/* Columns available in this virtual table */
#define BINFO_COLUMN_TYPE 0
#define BINFO_COLUMN_NAME 1
#define BINFO_COLUMN_TBL_NAME 2
#define BINFO_COLUMN_ROOTPAGE 3
#define BINFO_COLUMN_SQL 4
#define BINFO_COLUMN_HASROWID 5
#define BINFO_COLUMN_NENTRY 6
#define BINFO_COLUMN_NPAGE 7
#define BINFO_COLUMN_DEPTH 8
#define BINFO_COLUMN_SZPAGE 9
#define BINFO_COLUMN_SCHEMA 10
/* Forward declarations */
typedef struct BinfoTable BinfoTable;
typedef struct BinfoCursor BinfoCursor;
/* A cursor for the sqlite_btreeinfo table */
struct BinfoCursor {
sqlite3_vtab_cursor base; /* Base class. Must be first */
sqlite3_stmt *pStmt; /* Query against sqlite_schema */
int rc; /* Result of previous sqlite_step() call */
int hasRowid; /* hasRowid value. Negative if unknown. */
sqlite3_int64 nEntry; /* nEntry value */
int nPage; /* nPage value */
int depth; /* depth value */
int szPage; /* size of a btree page. 0 if unknown */
char *zSchema; /* Schema being interrogated */
};
/* The sqlite_btreeinfo table */
struct BinfoTable {
sqlite3_vtab base; /* Base class. Must be first */
sqlite3 *db; /* The databse connection */
};
/*
** Connect to the sqlite_btreeinfo virtual table.
*/
static int binfoConnect(
sqlite3 *db,
void *pAux,
int argc, const char *const*argv,
sqlite3_vtab **ppVtab,
char **pzErr
){
BinfoTable *pTab = 0;
int rc = SQLITE_OK;
rc = sqlite3_declare_vtab(db,
"CREATE TABLE x(\n"
" type TEXT,\n"
" name TEXT,\n"
" tbl_name TEXT,\n"
" rootpage INT,\n"
" sql TEXT,\n"
" hasRowid BOOLEAN,\n"
" nEntry INT,\n"
" nPage INT,\n"
" depth INT,\n"
" szPage INT,\n"
" zSchema TEXT HIDDEN\n"
")");
if( rc==SQLITE_OK ){
pTab = (BinfoTable *)sqlite3_malloc64(sizeof(BinfoTable));
if( pTab==0 ) rc = SQLITE_NOMEM;
}
assert( rc==SQLITE_OK || pTab==0 );
if( pTab ){
pTab->db = db;
}
*ppVtab = (sqlite3_vtab*)pTab;
return rc;
}
/*
** Disconnect from or destroy a btreeinfo virtual table.
*/
static int binfoDisconnect(sqlite3_vtab *pVtab){
sqlite3_free(pVtab);
return SQLITE_OK;
}
/*
** idxNum:
**
** 0 Use "main" for the schema
** 1 Schema identified by parameter ?1
*/
static int binfoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
int i;
pIdxInfo->estimatedCost = 10000.0; /* Cost estimate */
pIdxInfo->estimatedRows = 100;
for(i=0; i<pIdxInfo->nConstraint; i++){
struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[i];
if( p->usable
&& p->iColumn==BINFO_COLUMN_SCHEMA
&& p->op==SQLITE_INDEX_CONSTRAINT_EQ
){
pIdxInfo->estimatedCost = 1000.0;
pIdxInfo->idxNum = 1;
pIdxInfo->aConstraintUsage[i].argvIndex = 1;
pIdxInfo->aConstraintUsage[i].omit = 1;
break;
}
}
return SQLITE_OK;
}
/*
** Open a new btreeinfo cursor.
*/
static int binfoOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
BinfoCursor *pCsr;
pCsr = (BinfoCursor *)sqlite3_malloc64(sizeof(BinfoCursor));
if( pCsr==0 ){
return SQLITE_NOMEM;
}else{
memset(pCsr, 0, sizeof(BinfoCursor));
pCsr->base.pVtab = pVTab;
}
*ppCursor = (sqlite3_vtab_cursor *)pCsr;
return SQLITE_OK;
}
/*
** Close a btreeinfo cursor.
*/
static int binfoClose(sqlite3_vtab_cursor *pCursor){
BinfoCursor *pCsr = (BinfoCursor *)pCursor;
sqlite3_finalize(pCsr->pStmt);
sqlite3_free(pCsr->zSchema);
sqlite3_free(pCsr);
return SQLITE_OK;
}
/*
** Move a btreeinfo cursor to the next entry in the file.
*/
static int binfoNext(sqlite3_vtab_cursor *pCursor){
BinfoCursor *pCsr = (BinfoCursor *)pCursor;
pCsr->rc = sqlite3_step(pCsr->pStmt);
pCsr->hasRowid = -1;
return pCsr->rc==SQLITE_ERROR ? SQLITE_ERROR : SQLITE_OK;
}
/* We have reached EOF if previous sqlite3_step() returned
** anything other than SQLITE_ROW;
*/
static int binfoEof(sqlite3_vtab_cursor *pCursor){
BinfoCursor *pCsr = (BinfoCursor *)pCursor;
return pCsr->rc!=SQLITE_ROW;
}
/* Position a cursor back to the beginning.
*/
static int binfoFilter(
sqlite3_vtab_cursor *pCursor,
int idxNum, const char *idxStr,
int argc, sqlite3_value **argv
){
BinfoCursor *pCsr = (BinfoCursor *)pCursor;
BinfoTable *pTab = (BinfoTable *)pCursor->pVtab;
char *zSql;
int rc;
sqlite3_free(pCsr->zSchema);
if( idxNum==1 && sqlite3_value_type(argv[0])!=SQLITE_NULL ){
pCsr->zSchema = sqlite3_mprintf("%s", sqlite3_value_text(argv[0]));
}else{
pCsr->zSchema = sqlite3_mprintf("main");
}
zSql = sqlite3_mprintf(
"SELECT 0, 'table','sqlite_schema','sqlite_schema',1,NULL "
"UNION ALL "
"SELECT rowid, type, name, tbl_name, rootpage, sql"
" FROM \"%w\".sqlite_schema WHERE rootpage>=1",
pCsr->zSchema);
sqlite3_finalize(pCsr->pStmt);
pCsr->pStmt = 0;
pCsr->hasRowid = -1;
rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);
sqlite3_free(zSql);
if( rc==SQLITE_OK ){
rc = binfoNext(pCursor);
}
return rc;
}
/* Decode big-endian integers */
static unsigned int get_uint16(unsigned char *a){
return (a[0]<<8)|a[1];
}
static unsigned int get_uint32(unsigned char *a){
return (a[0]<<24)|(a[1]<<16)|(a[2]<<8)|a[3];
}
/* Examine the b-tree rooted at pgno and estimate its size.
** Return non-zero if anything goes wrong.
*/
static int binfoCompute(sqlite3 *db, int pgno, BinfoCursor *pCsr){
sqlite3_int64 nEntry = 1;
int nPage = 1;
unsigned char *aData;
sqlite3_stmt *pStmt = 0;
int rc = SQLITE_OK;
int pgsz = 0;
int nCell;
int iCell;
rc = sqlite3_prepare_v2(db,
"SELECT data FROM sqlite_dbpage('main') WHERE pgno=?1", -1,
&pStmt, 0);
if( rc ) return rc;
pCsr->depth = 1;
while(1){
sqlite3_bind_int(pStmt, 1, pgno);
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ){
rc = SQLITE_ERROR;
break;
}
pCsr->szPage = pgsz = sqlite3_column_bytes(pStmt, 0);
aData = (unsigned char*)sqlite3_column_blob(pStmt, 0);
if( aData==0 ){
rc = SQLITE_NOMEM;
break;
}
if( pgno==1 ){
aData += 100;
pgsz -= 100;
}
pCsr->hasRowid = aData[0]!=2 && aData[0]!=10;
nCell = get_uint16(aData+3);
nEntry *= (nCell+1);
if( aData[0]==10 || aData[0]==13 ) break;
nPage *= (nCell+1);
if( nCell<=1 ){
pgno = get_uint32(aData+8);
}else{
iCell = get_uint16(aData+12+2*(nCell/2));
if( pgno==1 ) iCell -= 100;
if( iCell<=12 || iCell>=pgsz-4 ){
rc = SQLITE_CORRUPT;
break;
}
pgno = get_uint32(aData+iCell);
}
pCsr->depth++;
sqlite3_reset(pStmt);
}
sqlite3_finalize(pStmt);
pCsr->nPage = nPage;
pCsr->nEntry = nEntry;
if( rc==SQLITE_ROW ) rc = SQLITE_OK;
return rc;
}
/* Return a column for the sqlite_btreeinfo table */
static int binfoColumn(
sqlite3_vtab_cursor *pCursor,
sqlite3_context *ctx,
int i
){
BinfoCursor *pCsr = (BinfoCursor *)pCursor;
if( i>=BINFO_COLUMN_HASROWID && i<=BINFO_COLUMN_SZPAGE && pCsr->hasRowid<0 ){
int pgno = sqlite3_column_int(pCsr->pStmt, BINFO_COLUMN_ROOTPAGE+1);
sqlite3 *db = sqlite3_context_db_handle(ctx);
int rc = binfoCompute(db, pgno, pCsr);
if( rc ){
pCursor->pVtab->zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(db));
return SQLITE_ERROR;
}
}
switch( i ){
case BINFO_COLUMN_NAME:
case BINFO_COLUMN_TYPE:
case BINFO_COLUMN_TBL_NAME:
case BINFO_COLUMN_ROOTPAGE:
case BINFO_COLUMN_SQL: {
sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pStmt, i+1));
break;
}
case BINFO_COLUMN_HASROWID: {
sqlite3_result_int(ctx, pCsr->hasRowid);
break;
}
case BINFO_COLUMN_NENTRY: {
sqlite3_result_int64(ctx, pCsr->nEntry);
break;
}
case BINFO_COLUMN_NPAGE: {
sqlite3_result_int(ctx, pCsr->nPage);
break;
}
case BINFO_COLUMN_DEPTH: {
sqlite3_result_int(ctx, pCsr->depth);
break;
}
case BINFO_COLUMN_SCHEMA: {
sqlite3_result_text(ctx, pCsr->zSchema, -1, SQLITE_STATIC);
break;
}
}
return SQLITE_OK;
}
/* Return the ROWID for the sqlite_btreeinfo table */
static int binfoRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
BinfoCursor *pCsr = (BinfoCursor *)pCursor;
*pRowid = sqlite3_column_int64(pCsr->pStmt, 0);
return SQLITE_OK;
}
/*
** Invoke this routine to register the "sqlite_btreeinfo" virtual table module
*/
int sqlite3BinfoRegister(sqlite3 *db){
static sqlite3_module binfo_module = {
0, /* iVersion */
0, /* xCreate */
binfoConnect, /* xConnect */
binfoBestIndex, /* xBestIndex */
binfoDisconnect, /* xDisconnect */
0, /* xDestroy */
binfoOpen, /* xOpen - open a cursor */
binfoClose, /* xClose - close a cursor */
binfoFilter, /* xFilter - configure scan constraints */
binfoNext, /* xNext - advance a cursor */
binfoEof, /* xEof - check for end of scan */
binfoColumn, /* xColumn - read data */
binfoRowid, /* xRowid - read data */
0, /* xUpdate */
0, /* xBegin */
0, /* xSync */
0, /* xCommit */
0, /* xRollback */
0, /* xFindMethod */
0, /* xRename */
0, /* xSavepoint */
0, /* xRelease */
0, /* xRollbackTo */
0 /* xShadowName */
};
return sqlite3_create_module(db, "sqlite_btreeinfo", &binfo_module, 0);
}
#ifdef _WIN32
__declspec(dllexport)
#endif
int sqlite3_btreeinfo_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
SQLITE_EXTENSION_INIT2(pApi);
return sqlite3BinfoRegister(db);
}
|
1feb6a0c640fbb74fc058f41465017c271771c32
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/thead-smart/drivers/dw_timer.h
|
f61fa249f6c069cfbc4dd1b04813d20240fcddb4
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 1,394
|
h
|
dw_timer.h
|
/*
* Copyright (C) 2017-2019 Alibaba Group Holding Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-20 zx.chen header file for timer driver
*/
#ifndef __DW_TIMER_H
#define __DW_TIMER_H
#include <stdio.h>
#include "soc.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* define the bits for TxControl
*/
#define DW_TIMER_TXCONTROL_ENABLE (1UL << 0)
#define DW_TIMER_TXCONTROL_MODE (1UL << 1)
#define DW_TIMER_TXCONTROL_INTMASK (1UL << 2)
#define DW_TIMER_TXCONTROL_TRIGGER (1UL << 4)
#define DW_TIMER_INIT_DEFAULT_VALUE (0xffffffff / drv_get_timer_freq(0) * 1000000)
typedef struct
{
__IOM uint32_t TxLoadCount; /* Offset: 0x000 (R/W) Receive buffer register */
__IM uint32_t TxCurrentValue; /* Offset: 0x004 (R) Transmission hold register */
__IOM uint8_t TxControl: 5; /* Offset: 0x008 (R/W) Clock frequency division low section register */
uint8_t RESERVED0[3];
__IM uint8_t TxEOI: 1; /* Offset: 0x00c (R) Clock frequency division high section register */
uint8_t RESERVED1[3];
__IM uint8_t TxIntStatus: 1; /* Offset: 0x010 (R) Interrupt enable register */
uint8_t RESERVED2[3];
} dw_timer_reg_t;
#ifdef __cplusplus
}
#endif
#endif /* __DW_TIMER_H */
|
d0c42a17c99ded7e709317cb793cd8fd72d45cd5
|
e814383d36a10839104efaa4df277996ab220fa3
|
/ompi/mca/topo/base/base.h
|
f04a1cbff9fa24fa4d929943ade9a5dc6d7526bd
|
[
"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
| 8,240
|
h
|
base.h
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2013 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2012-2013 Inria. All rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
* Copyright (c) 2018 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef MCA_TOPO_BASE_H
#define MCA_TOPO_BASE_H
#include "ompi_config.h"
#include "opal/class/opal_list.h"
#include "ompi/mca/mca.h"
#include "ompi/mca/topo/topo.h"
#include "ompi/proc/proc.h"
#include "ompi/communicator/communicator.h"
#include "ompi/info/info.h"
/*
* All stuff goes in here
*/
BEGIN_C_DECLS
/* Lazily initialize the framework (if it wasn't already) */
OMPI_DECLSPEC int mca_topo_base_lazy_init(void);
/*
* MCA Framework
*/
OMPI_DECLSPEC extern mca_base_framework_t ompi_topo_base_framework;
/* Select a topo module for a particular type of topology */
OMPI_DECLSPEC int
mca_topo_base_comm_select(const ompi_communicator_t* comm,
mca_topo_base_module_t* preferred_module,
mca_topo_base_module_t** selected_module,
uint32_t type);
/* Select a topo module for a particular type of topology */
OMPI_DECLSPEC int
mca_topo_base_group_select (const ompi_group_t *group,
mca_topo_base_module_t *preferred_module,
mca_topo_base_module_t **selected_module,
uint32_t type);
/* Find all components that want to be considered in this job */
OMPI_DECLSPEC int
mca_topo_base_find_available(bool enable_progress_threads,
bool enable_mpi_threads);
/*
* All the glue functions which we will provide to the users by
* default. The component authors need to only write back-end
* functions for cart_create(), graph_create(), graph_map(), and
* cart_map() for their topology components. But they can implement
* these glue functions if they want.
*
* These glue functions
*/
OMPI_DECLSPEC int
mca_topo_base_cart_create(mca_topo_base_module_t *topo_module,
ompi_communicator_t* old_comm,
int ndims,
const int *dims,
const int *periods,
bool reorder,
ompi_communicator_t** comm_topo);
OMPI_DECLSPEC int
mca_topo_base_cart_coords(ompi_communicator_t *comm,
int rank,
int maxdims,
int *coords);
OMPI_DECLSPEC int
mca_topo_base_cartdim_get(ompi_communicator_t *comm,
int *ndims);
OMPI_DECLSPEC int
mca_topo_base_cart_get(ompi_communicator_t *comm,
int maxdims,
int *dims,
int *periods,
int *coords);
OMPI_DECLSPEC int
mca_topo_base_cart_map(ompi_communicator_t * comm,
int ndims,
const int *dims, const int *periods, int *newrank);
OMPI_DECLSPEC int
mca_topo_base_cart_rank(ompi_communicator_t *comm,
const int *coords,
int *rank);
OMPI_DECLSPEC int
mca_topo_base_cart_shift(ompi_communicator_t *comm,
int direction,
int disp,
int *rank_source,
int *rank_dest);
OMPI_DECLSPEC int
mca_topo_base_cart_sub(ompi_communicator_t *comm,
const int *remain_dims,
ompi_communicator_t **new_comm);
OMPI_DECLSPEC int
mca_topo_base_graphdims_get(ompi_communicator_t *comm,
int *nodes,
int *nedges);
OMPI_DECLSPEC int
mca_topo_base_graph_create(mca_topo_base_module_t *topo_module,
ompi_communicator_t* old_comm,
int nnodes,
const int *index,
const int *edges,
bool reorder,
ompi_communicator_t** new_comm);
OMPI_DECLSPEC int
mca_topo_base_graph_get(ompi_communicator_t *comm,
int maxindex,
int maxedges,
int *index,
int *edges);
OMPI_DECLSPEC int
mca_topo_base_graph_map(ompi_communicator_t * comm,
int nnodes,
const int *index, const int *edges, int *newrank);
OMPI_DECLSPEC int
mca_topo_base_graph_neighbors(ompi_communicator_t *comm,
int rank,
int maxneighbors,
int *neighbors);
OMPI_DECLSPEC int
mca_topo_base_graph_neighbors_count(ompi_communicator_t *comm,
int rank,
int *nneighbors);
/**
* Efficiently distribute the information about the distributed graph as
* submitted through the distributed graph interface.
*/
OMPI_DECLSPEC int
mca_topo_base_dist_graph_distribute(mca_topo_base_module_t* module,
ompi_communicator_t *comm,
int n, const int nodes[],
const int degrees[], const int targets[],
const int weights[],
mca_topo_base_comm_dist_graph_2_2_0_t** ptopo);
OMPI_DECLSPEC int
mca_topo_base_dist_graph_create(mca_topo_base_module_t* module,
ompi_communicator_t *old_comm,
int n, const int nodes[],
const int degrees[], const int targets[], const int weights[],
opal_info_t *info, int reorder,
ompi_communicator_t **new_comm);
OMPI_DECLSPEC int
mca_topo_base_dist_graph_create_adjacent(mca_topo_base_module_t* module,
ompi_communicator_t *old_comm,
int indegree, const int sources[],
const int sourceweights[], int outdegree,
const int destinations[], const int destweights[],
opal_info_t *info, int reorder,
ompi_communicator_t **comm_dist_graph);
OMPI_DECLSPEC int
mca_topo_base_dist_graph_neighbors(ompi_communicator_t *comm,
int maxindegree,
int sources[], int sourceweights[],
int maxoutdegree, int destinations[],
int destweights[]);
OMPI_DECLSPEC int
mca_topo_base_dist_graph_neighbors_count(ompi_communicator_t *comm,
int *inneighbors, int *outneighbors, int *weighted);
int mca_topo_base_neighbor_count (ompi_communicator_t *comm, int *indegree, int *outdegree);
END_C_DECLS
#endif /* MCA_BASE_TOPO_H */
|
e90392bb0900db4fcb491e41c565b3c6bf51761f
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/media/usb/dvb-usb/dvb-usb-firmware.c
|
733a7ff7b207819bcd05f2a816388fa21e9f69b5
|
[
"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
| 3,956
|
c
|
dvb-usb-firmware.c
|
/* dvb-usb-firmware.c is part of the DVB USB library.
*
* Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
* see dvb-usb-init.c for copyright information.
*
* This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices.
*
* FIXME: This part does actually not belong to dvb-usb, but to the usb-subsystem.
*/
#include "dvb-usb-common.h"
#include <linux/usb.h>
struct usb_cypress_controller {
int id;
const char *name; /* name of the usb controller */
u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */
};
static struct usb_cypress_controller cypress[] = {
{ .id = DEVICE_SPECIFIC, .name = "Device specific", .cpu_cs_register = 0 },
{ .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 },
{ .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 },
{ .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 },
};
/*
* load a firmware packet to the device
*/
static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len)
{
return usb_control_msg(udev, usb_sndctrlpipe(udev,0),
0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000);
}
int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
{
struct hexline hx;
u8 reset;
int ret,pos=0;
/* stop the CPU */
reset = 1;
if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
err("could not stop the USB controller CPU.");
while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) {
deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk);
ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len);
if (ret != hx.len) {
err("error while transferring firmware "
"(transferred size: %d, block size: %d)",
ret,hx.len);
ret = -EINVAL;
break;
}
}
if (ret < 0) {
err("firmware download failed at %d with %d",pos,ret);
return ret;
}
if (ret == 0) {
/* restart the CPU */
reset = 0;
if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {
err("could not restart the USB controller CPU.");
ret = -EINVAL;
}
} else
ret = -EIO;
return ret;
}
EXPORT_SYMBOL(usb_cypress_load_firmware);
int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_device_properties *props)
{
int ret;
const struct firmware *fw = NULL;
if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) {
err("did not find the firmware file. (%s) "
"Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
props->firmware,ret);
return ret;
}
info("downloading firmware from file '%s'",props->firmware);
switch (props->usb_ctrl) {
case CYPRESS_AN2135:
case CYPRESS_AN2235:
case CYPRESS_FX2:
ret = usb_cypress_load_firmware(udev, fw, props->usb_ctrl);
break;
case DEVICE_SPECIFIC:
if (props->download_firmware)
ret = props->download_firmware(udev,fw);
else {
err("BUG: driver didn't specified a download_firmware-callback, although it claims to have a DEVICE_SPECIFIC one.");
ret = -EINVAL;
}
break;
default:
ret = -EINVAL;
break;
}
release_firmware(fw);
return ret;
}
int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
int *pos)
{
u8 *b = (u8 *) &fw->data[*pos];
int data_offs = 4;
if (*pos >= fw->size)
return 0;
memset(hx,0,sizeof(struct hexline));
hx->len = b[0];
if ((*pos + hx->len + 4) >= fw->size)
return -EINVAL;
hx->addr = b[1] | (b[2] << 8);
hx->type = b[3];
if (hx->type == 0x04) {
/* b[4] and b[5] are the Extended linear address record data field */
hx->addr |= (b[4] << 24) | (b[5] << 16);
/* hx->len -= 2;
data_offs += 2; */
}
memcpy(hx->data,&b[data_offs],hx->len);
hx->chk = b[hx->len + data_offs];
*pos += hx->len + 5;
return *pos;
}
EXPORT_SYMBOL(dvb_usb_get_hexline);
|
17ac1313e47dd902a76e8fad48716b4f95b109df
|
55540f3e86f1d5d86ef6b5d295a63518e274efe3
|
/customer_app/peripheral/demo_wdg/demo_wdg/demo_wdg_feed.c
|
26ef3d1171837f963f63d5dbc2d9d66505e3c5f0
|
[
"Apache-2.0"
] |
permissive
|
bouffalolab/bl_iot_sdk
|
bc5eaf036b70f8c65dd389439062b169f8d09daa
|
b90664de0bd4c1897a9f1f5d9e360a9631d38b34
|
refs/heads/master
| 2023-08-31T03:38:03.369853
| 2023-08-16T08:50:33
| 2023-08-18T09:13:27
| 307,347,250
| 244
| 101
|
Apache-2.0
| 2023-08-28T06:29:02
| 2020-10-26T11:16:30
|
C
|
UTF-8
|
C
| false
| false
| 652
|
c
|
demo_wdg_feed.c
|
/**
* Copyright (c) 2016-2021 Bouffalolab Co., Ltd.
*
* Contact information:
* web site: https://www.bouffalolab.com/
*/
#include <stdio.h>
#include <cli.h>
#include <hosal_wdg.h>
#include <blog.h>
void demo_hosal_wdg_feed(void)
{
hosal_wdg_dev_t wdg;
int ret = -1;
/* wdg port set */
wdg.port = 0;
/* max timeout is 65532/16 ms */
wdg.config.timeout = 3000;
/* init wdg with the given settings */
hosal_wdg_init(&wdg);
blog_info("wdg will not trig reboot\r\n");
/* feed wdg every 2s */
while(1) {
hosal_wdg_reload(&wdg);
vTaskDelay(2000);
}
hosal_wdg_finalize(&wdg);
}
|
52054deb182a59a9117e871b7d87fcb1bcce9a01
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/powerpc/platforms/cell/celleb_scc_sio.c
|
9c339ec646f5543aa355362a952581fd74fe745a
|
[
"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
| 2,565
|
c
|
celleb_scc_sio.c
|
/*
* setup serial port in SCC
*
* (C) Copyright 2006-2007 TOSHIBA CORPORATION
*
* 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.
*/
#include <linux/tty.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <linux/console.h>
#include <asm/io.h>
#include <asm/prom.h>
/* sio irq0=0xb00010022 irq0=0xb00010023 irq2=0xb00010024
mmio=0xfff000-0x1000,0xff2000-0x1000 */
static int txx9_serial_bitmap __initdata;
static struct {
uint32_t offset;
uint32_t index;
} txx9_scc_tab[3] __initdata = {
{ 0x300, 0 }, /* 0xFFF300 */
{ 0x400, 0 }, /* 0xFFF400 */
{ 0x800, 1 } /* 0xFF2800 */
};
static int __init txx9_serial_init(void)
{
extern int early_serial_txx9_setup(struct uart_port *port);
struct device_node *node;
int i;
struct uart_port req;
struct of_irq irq;
struct resource res;
for_each_compatible_node(node, "serial", "toshiba,sio-scc") {
for (i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) {
if (!(txx9_serial_bitmap & (1<<i)))
continue;
if (of_irq_map_one(node, i, &irq))
continue;
if (of_address_to_resource(node,
txx9_scc_tab[i].index, &res))
continue;
memset(&req, 0, sizeof(req));
req.line = i;
req.iotype = UPIO_MEM;
req.mapbase = res.start + txx9_scc_tab[i].offset;
#ifdef CONFIG_SERIAL_TXX9_CONSOLE
req.membase = ioremap(req.mapbase, 0x24);
#endif
req.irq = irq_create_of_mapping(irq.controller,
irq.specifier, irq.size);
req.flags |= UPF_IOREMAP | UPF_BUGGY_UART
/*HAVE_CTS_LINE*/;
req.uartclk = 83300000;
early_serial_txx9_setup(&req);
}
}
return 0;
}
static int __init txx9_serial_config(char *ptr)
{
int i;
for (;;) {
switch (get_option(&ptr, &i)) {
default:
return 0;
case 2:
txx9_serial_bitmap |= 1 << i;
break;
case 1:
txx9_serial_bitmap |= 1 << i;
return 0;
}
}
}
__setup("txx9_serial=", txx9_serial_config);
console_initcall(txx9_serial_init);
|
c94e146b86a93e0af278f3639b314ccbfeabfbde
|
ecce427678ecff2a93a47f3b1b664202c7d27617
|
/levels/jrb/sliding_box/collision.inc.c
|
5ed92ee309786be71e270939eaf195e7f2c3cefb
|
[] |
no_license
|
sm64pc/sm64ex
|
ecf37f31b3f7426c4874254660d856030d789714
|
54cd27ccee45a2403b45f07a00d6043c51149969
|
refs/heads/nightly
| 2023-08-11T12:14:34.424168
| 2023-07-01T11:45:50
| 2023-07-01T11:45:50
| 262,091,731
| 795
| 238
| null | 2023-07-01T11:45:51
| 2020-05-07T15:43:27
|
C
|
UTF-8
|
C
| false
| false
| 704
|
c
|
collision.inc.c
|
// 0x0700C8A8 - 0x0700C92C
const Collision jrb_seg7_collision_floating_box[] = {
COL_INIT(),
COL_VERTEX_INIT(0x8),
COL_VERTEX(-101, 0, 77),
COL_VERTEX(-101, 0, -76),
COL_VERTEX(102, 0, -76),
COL_VERTEX(102, 0, 77),
COL_VERTEX(102, 154, 77),
COL_VERTEX(-101, 154, 77),
COL_VERTEX(102, 154, -76),
COL_VERTEX(-101, 154, -76),
COL_TRI_INIT(SURFACE_DEFAULT, 12),
COL_TRI(0, 1, 2),
COL_TRI(0, 2, 3),
COL_TRI(3, 4, 5),
COL_TRI(4, 6, 7),
COL_TRI(4, 7, 5),
COL_TRI(2, 6, 4),
COL_TRI(2, 4, 3),
COL_TRI(1, 6, 2),
COL_TRI(1, 7, 6),
COL_TRI(0, 5, 7),
COL_TRI(0, 7, 1),
COL_TRI(3, 5, 0),
COL_TRI_STOP(),
COL_END(),
};
|
538175a758b8b6116d5384368f783b63a95a6890
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/print/tex-xdvik/files/patch-texk-xdvik-dvi-draw.c
|
5ed34b6408975dfb6f06e2d363e025ab7e137b06
|
[
"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
| 29,468
|
c
|
patch-texk-xdvik-dvi-draw.c
|
--- texk/xdvik/dvi-draw.c.orig 2022-02-13 02:57:24 UTC
+++ texk/xdvik/dvi-draw.c
@@ -56,6 +56,9 @@ in xdvi.c.
#include "statusline.h"
#include "hypertex.h"
#include "special.h"
+#ifdef PTEX
+#include "ptexmap.h"
+#endif
#include "my-snprintf.h"
#include "kpathsea/tex-file.h"
#include "mag.h"
@@ -531,8 +534,8 @@ print_char(ubyte ch, struct glyph *g)
}
static const char *dvi_table1[] = {
- "SET1", "SET2", NULL, NULL, "SETRULE", "PUT1", "PUT2", NULL,
- NULL, "PUTRULE", "NOP", "BOP", "EOP", "PUSH", "POP", "RIGHT1",
+ "SET1", "SET2", "SET3", "SET4", "SETRULE", "PUT1", "PUT2", "PUT3",
+ "PUT4", "PUTRULE", "NOP", "BOP", "EOP", "PUSH", "POP", "RIGHT1",
"RIGHT2", "RIGHT3", "RIGHT4", "W0", "W1", "W2", "W3", "W4",
"X0", "X1", "X2", "X3", "X4", "DOWN1", "DOWN2", "DOWN3",
"DOWN4", "Y0", "Y1", "Y2", "Y3", "Y4", "Z0", "Z1",
@@ -542,7 +545,12 @@ static const char *dvi_table1[] = {
static const char *dvi_table2[] = {
"FNT1", "FNT2", "FNT3", "FNT4", "XXX1", "XXX2", "XXX3", "XXX4",
"FNTDEF1", "FNTDEF2", "FNTDEF3", "FNTDEF4", "PRE", "POST", "POSTPOST",
- "SREFL", "EREFL", NULL, NULL, NULL, NULL
+ "SREFL", "EREFL", NULL, NULL, NULL,
+#ifdef PTEX
+ "DIRECTION"
+#else /* !PTEX */
+ NULL
+#endif /* !PTEX */
};
static void
@@ -667,6 +675,146 @@ sample(bmUnitT *bits, int bytes_wide, int bit_skip, in
return n;
}
+extern double bbox_matrix[2][2];
+extern Boolean bbox_scaled, bbox_rotated;
+
+static void moveH(int dir, long dx)
+{
+ int pint=TATE;
+ if (pint&2) { pint&=1; dx=-dx;}
+ if (pint) {
+ DVI_H -= dx * bbox_matrix[1][0];
+ DVI_V += dx * bbox_matrix[0][0];
+ } else {
+ DVI_H += dir * dx * bbox_matrix[0][0];
+ DVI_V += dir * dx * bbox_matrix[1][0];
+ }
+ PXL_V = pixel_conv(DVI_V);
+}
+
+static void moveV(int dir, long dy)
+{
+ int pint=TATE;
+ if (pint&2) { pint&=1; dy=-dy;}
+ if (pint) {
+ DVI_H -= dy * bbox_matrix[1][1];
+ DVI_V += dy * bbox_matrix[0][1];
+ } else {
+ DVI_H += dir * dy * bbox_matrix[0][1];
+ DVI_V += dir * dy * bbox_matrix[1][1];
+ }
+ PXL_V = pixel_conv(DVI_V);
+}
+
+#define PUSH_POSITION do { \
+ dvi_h_sav = DVI_H; \
+ dvi_v_sav = DVI_V; \
+ pxl_v_sav = PXL_V; } while (0)
+#define POP_POSITION do { \
+ DVI_H = dvi_h_sav; \
+ DVI_V = dvi_v_sav; \
+ PXL_V = pxl_v_sav; } while (0)
+#define DEFINE_POSITION_VAL \
+ long dvi_h_sav, dvi_v_sav, pxl_v_sav
+
+#ifndef WORDS_BIGENDIAN
+#define EXTREME_LEFT_BIT (1 << 0)
+#define EXTREME_RIGHT_BIT ((bmUnitT)(1 << (BMBITS-1)))
+#define SHIFT_RIGHT(a) ((a) <<= 1)
+#else /* WORDS_BIGENDIAN */
+#define EXTREME_LEFT_BIT ((bmUnitT)(1 << (BMBITS-1)))
+#define EXTREME_RIGHT_BIT (1 << 0)
+#define SHIFT_RIGHT(a) ((a) >>= 1)
+#endif /* WORDS_BIGENDIAN */
+
+static void
+bbox_scale_bitmap(struct glyph *g)
+{
+ bmUnitT *new_ptr;
+ int xmax, ymax, xmin, ymin, x, y;
+ double d;
+
+ if (g->bitmap3.bits) {
+ if (g->matrix[0][0] == (float) bbox_matrix[0][0]
+ && g->matrix[0][1] == (float) bbox_matrix[0][1]
+ && g->matrix[1][0] == (float) bbox_matrix[1][0]
+ && g->matrix[1][1] == (float) bbox_matrix[1][1])
+ return;
+ else
+ free(g->bitmap.bits);
+ } else {
+ g->bitmap3 = g->bitmap;
+ g->x3 = g->x;
+ g->y3 = g->y;
+ }
+
+ xmax = ymax = xmin = ymin = 0;
+ x = g->bitmap3.w * bbox_matrix[0][0];
+ y = g->bitmap3.w * bbox_matrix[1][0];
+ if (xmax < x) xmax = x;
+ else if (xmin > x) xmin = x;
+ if (ymax < y) ymax = y;
+ else if (ymin > y) ymin = y;
+ x = g->bitmap3.w * bbox_matrix[0][0] + g->bitmap3.h * bbox_matrix[0][1];
+ y = g->bitmap3.w * bbox_matrix[1][0] + g->bitmap3.h * bbox_matrix[1][1];
+ if (xmax < x) xmax = x;
+ else if (xmin > x) xmin = x;
+ if (ymax < y) ymax = y;
+ else if (ymin > y) ymin = y;
+ x = g->bitmap3.h * bbox_matrix[0][1];
+ y = g->bitmap3.h * bbox_matrix[1][1];
+ if (xmax < x) xmax = x;
+ else if (xmin > x) xmin = x;
+ if (ymax < y) ymax = y;
+ else if (ymin > y) ymin = y;
+ xmin--; ymin--; xmax++; ymax++;
+
+ d = bbox_matrix[0][0] * bbox_matrix[1][1]
+ - bbox_matrix[0][1] * bbox_matrix[1][0];
+
+ g->x = g->x3 * bbox_matrix[0][0] + g->y3 * bbox_matrix[0][1] - xmin;
+ g->y = g->x3 * bbox_matrix[1][0] + g->y3 * bbox_matrix[1][1] - ymin;
+ g->matrix[0][0] = (float) bbox_matrix[0][0];
+ g->matrix[0][1] = (float) bbox_matrix[0][1];
+ g->matrix[1][0] = (float) bbox_matrix[1][0];
+ g->matrix[1][1] = (float) bbox_matrix[1][1];
+
+ free_bitmap2(g);
+ g->bitmap.w = xmax - xmin + 1;
+ g->bitmap.h = ymax - ymin + 1;
+ alloc_bitmap(&g->bitmap);
+ clear_bitmap(&g->bitmap);
+
+ new_ptr = (bmUnitT *) g->bitmap.bits;
+ for (y = ymin; y <= ymax; y++) {
+ register bmUnitT m, *cp;
+
+ cp = new_ptr;
+ m = EXTREME_LEFT_BIT;
+ for (x = xmin; x <= xmax; x++) {
+ int bx, by;
+ bx = (x * bbox_matrix[1][1] - y * bbox_matrix[0][1]) / d;
+ by = (y * bbox_matrix[0][0] - x * bbox_matrix[1][0]) / d;
+ if (bx >= 0 && bx < g->bitmap3.w
+ && by >= 0 && by < g->bitmap3.h
+ && *((bmUnitT *)g->bitmap3.bits
+ + by * (g->bitmap3.bytes_wide / BMBYTES) + bx / BMBITS)
+#ifndef WORDS_BIGENDIAN
+ & (1 << (bx % BMBITS)))
+#else
+ & (1 << (BMBITS - 1 - bx % BMBITS)))
+#endif
+ *cp |= m;
+ if (m == EXTREME_RIGHT_BIT) {
+ m = EXTREME_LEFT_BIT;
+ ++cp;
+ }
+ else SHIFT_RIGHT(m);
+ }
+ new_ptr = ADD(new_ptr, g->bitmap.bytes_wide);
+ }
+}
+
static void
shrink_glyph(struct glyph *g)
{
@@ -757,6 +905,89 @@ shrink_glyph(struct glyph *g)
print_bitmap(&g->bitmap2);
}
+#ifdef PTEX
+void
+rotate_bitmap(struct bitmap *bm)
+{
+ struct bitmap new_bm;
+ bmUnitT *old_ptr, *new_ptr, *cp;
+ int x, y;
+ bmUnitT m1, m2;
+
+ new_bm.h = bm->w;
+ new_bm.w = bm->h;
+ alloc_bitmap(&new_bm);
+ clear_bitmap(&new_bm);
+ old_ptr = ADD(bm->bits, bm->bytes_wide * bm->h);
+ new_ptr = (bmUnitT *)new_bm.bits;
+
+ m1 = EXTREME_LEFT_BIT;
+ for (y = 0; y < bm->h; y++) {
+ old_ptr = SUB(old_ptr, bm->bytes_wide);
+ cp = old_ptr;
+ m2 = EXTREME_LEFT_BIT;
+ for (x = 0; x < bm->w; x++) {
+ if (*cp & m2)
+ *ADD(new_ptr, x*new_bm.bytes_wide) |= m1;
+ if (m2 == EXTREME_RIGHT_BIT) {
+ m2 = EXTREME_LEFT_BIT;
+ ++cp;
+ }
+ else SHIFT_RIGHT(m2);
+ }
+ if (m1 == EXTREME_RIGHT_BIT) {
+ m1 = EXTREME_LEFT_BIT;
+ ++new_ptr;
+ }
+ else SHIFT_RIGHT(m1);
+ }
+
+ free(bm->bits);
+ *bm = new_bm;
+}
+
+
+void
+reverse_rotate_bitmap(struct bitmap *bm)
+{
+ struct bitmap new_bm;
+ bmUnitT *old_ptr, *new_ptr, *cp;
+ int x, y;
+ bmUnitT m1, m2;
+
+ new_bm.h = bm->w;
+ new_bm.w = bm->h;
+ alloc_bitmap(&new_bm);
+ clear_bitmap(&new_bm);
+ old_ptr = (bmUnitT *)bm->bits;
+ new_ptr = (bmUnitT *)new_bm.bits;
+
+ m1 = EXTREME_LEFT_BIT;
+ for (y = 0; y < bm->h; y++) {
+ cp = old_ptr;
+ old_ptr = ADD(old_ptr, bm->bytes_wide);
+ m2 = EXTREME_LEFT_BIT;
+ for (x = bm->w; x--;) {
+ if (*cp & m2)
+ *ADD(new_ptr, x * new_bm.bytes_wide) |= m1;
+ if (m2 == EXTREME_RIGHT_BIT) {
+ m2 = EXTREME_LEFT_BIT;
+ ++cp;
+ }
+ else SHIFT_RIGHT(m2);
+ }
+ if (m1 == EXTREME_RIGHT_BIT) {
+ m1 = EXTREME_LEFT_BIT;
+ ++new_ptr;
+ }
+ else SHIFT_RIGHT(m1);
+ }
+
+ free(bm->bits);
+ *bm = new_bm;
+}
+#endif /* PTEX */
+
#ifdef GREY
#ifdef RGB_ANTI_ALIASING
@@ -969,6 +1200,7 @@ shrink_glyph_grey(struct glyph *g)
BMBITS, 0);
size = g->image2->bytes_per_line * g->bitmap2.h;
g->pixmap2 = g->image2->data = xmalloc(size != 0 ? size : 1);
+ ASSERT(g->pixmap2_gc2 == NULL, "pixmap2_gc2 is not NULL.");
}
/* ... and the pixmap used for globals.gc.fore2: */
if (globals.gc.fore2 != NULL && g->pixmap2_gc2 == NULL) {
@@ -1281,8 +1513,13 @@ static ubyte scantable[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 2, /* SET1,SET2 (128,129) */
- /* -,-,SETRULE,PUT1,PUT2,-,-,PUTRULE,NOP,BOP (130-139) */
+#ifdef PTEX
+ /* SET3,SET4,SETRULE,PUT1,PUT2,PUT3,PUT4,PUTRULE,NOP,BOP (130-139) */
+ 3, 4, 8, 1, 2, 3, 4, 8, 0, 44,
+#else
+ /* -,-,SETRULE,PUT1,PUT2,-,-,PUTRULE,NOP,BOP (132-139) */
M4, M4, 8, 1, 2, M4, M4, 8, 0, 44,
+#endif
M1, 0, 0, 1, 2, 3, 4, 0, 1, 2, /* EOP,PUSH,POP,RIGHT1-4,W0M2 (140-149) */
3, 4, 0, 1, 2, 3, 4, 1, 2, 3, /* W3-4,X0-4,DOWN1-3 (150-159) */
4, 0, 1, 2, 3, 4, 0, 1, 2, 3, /* DOWN4,Y0-4,Z0-3 (160-169) */
@@ -1335,9 +1572,11 @@ spcl_scan(Boolean (*spcl_proc)(char *str, int str_len,
ch = xone(fp);
xskip(fp, (long)ch + (long)xone(fp));
break;
+#ifndef PTEX
case M4: /* unrecognizable */
XDVI_FATAL((stderr, "unknown op-code %d", ch));
break;
+#endif /* !PTEX */
case M5: /* doesn't belong */
dvi_fmt_error("spcl_scan: shouldn't happen: %s encountered",
dvi_table2[ch - (FNTNUM0 + 64)]);
@@ -1451,6 +1690,46 @@ prescan(FILE *fp)
* Routines to print characters.
*/
+#ifdef PTEX
+static void
+set_char_rotate_glyph(struct glyph *g)
+{
+ int tmp, rot = TATE - g->tdir;
+ if (rot<0) rot+=4;
+ switch(rot) {
+ case 2:
+ rotate_bitmap(&g->bitmap);
+ tmp = g->x;
+ g->x = g->bitmap.w - g->y;
+ g->y = tmp;
+ g->tdir = TATE;
+ free_bitmap2(g);
+ case 1:
+ rotate_bitmap(&g->bitmap);
+ tmp = g->x;
+ g->x = g->bitmap.w - g->y;
+ g->y = tmp;
+ g->tdir = TATE;
+ free_bitmap2(g);
+ break;
+ case 3:
+ reverse_rotate_bitmap(&g->bitmap);
+ tmp = g->x;
+ g->x = g->y;
+ g->y = g->bitmap.h - tmp;
+ g->tdir = TATE;
+ free_bitmap2(g);
+ }
+}
+#endif /* PTEX */
+
+static setcharRetvalT
+common_set_char(
+#ifdef TEXXET
+ wide_ubyte,
+#endif
+ struct glyph *);
+
setcharRetvalT
set_char(
#ifdef TEXXET
@@ -1459,9 +1738,6 @@ set_char(
wide_ubyte ch)
{
struct glyph *g;
-#ifdef TEXXET
- long dvi_h_sav;
-#endif
if (ch > maxchar)
realloc_font(currinf.fontp, (wide_ubyte)ch);
@@ -1495,14 +1771,41 @@ set_char(
print_char((ubyte) ch, g);
currinf.fontp->timestamp = ++current_timestamp;
}
+#ifdef PTEX
+ set_char_rotate_glyph(g);
+#endif /* PTEX */
+#ifdef TEXXET
+ common_set_char(cmd, g);
+#else
+ return common_set_char(g);
+#endif
+}
+static setcharRetvalT
+common_set_char(
#ifdef TEXXET
- dvi_h_sav = DVI_H;
- if (currinf.dir < 0)
- DVI_H -= g->dvi_adv;
+ wide_ubyte cmd,
+#endif
+ struct glyph *g)
+{
+#ifdef TEXXET
+ DEFINE_POSITION_VAL;
+ PUSH_POSITION;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, -g->dvi_adv);
if (scan_frame == NULL) {
#endif
+ if (bbox_scaled)
+ bbox_scale_bitmap(g);
+ else if (g->bitmap3.bits) {
+ free(g->bitmap.bits);
+ g->bitmap = g->bitmap3;
+ g->bitmap3.bits = NULL;
+ g->x = g->x3;
+ g->y = g->y3;
+ free_bitmap2(g);
+ }
#ifdef RGB_ANTI_ALIASING
if (currwin.shrinkfactor == -1) {
@@ -1544,9 +1847,9 @@ set_char(
#ifdef TEXXET
}
if (cmd == PUT1 || (resource.omega && cmd == PUT2))
- DVI_H = dvi_h_sav;
- else if (currinf.dir > 0)
- DVI_H += g->dvi_adv;
+ POP_POSITION;
+ else if (TATE || currinf.dir > 0)
+ moveH(1, g->dvi_adv);
return;
#else
return g->dvi_adv;
@@ -1601,7 +1904,34 @@ set_empty_char(
#endif
}
+#ifdef PTEX
setcharRetvalT
+set_char2(
+#ifdef TEXXET
+ wide_ubyte cmd,
+#endif
+ wide_ubyte ch)
+{
+ struct glyph *g;
+
+ if (ch > currinf.fontp->maxchar ||
+ (g = currinf.fontp->kglyph[ch]) == NULL || g->bitmap.bits == NULL) {
+ (*currinf.fontp->read_char)(currinf.fontp, ch);
+ g = currinf.fontp->kglyph[ch];
+ free_bitmap2(g);
+ g->tdir = currinf.fontp->dir;
+ if (globals.debug & DBG_BITMAP) print_char((ubyte) ch, g);
+ }
+ set_char_rotate_glyph(g);
+#ifdef TEXXET
+ common_set_char(cmd, g);
+#else
+ return common_set_char(g);
+#endif
+}
+#endif /* PTEX */
+
+setcharRetvalT
load_n_set_char(
#ifdef TEXXET
wide_ubyte cmd,
@@ -1648,7 +1978,7 @@ set_vf_char(
wide_ubyte oldmaxchar;
static ubyte c;
#ifdef TEXXET
- long dvi_h_sav;
+ DEFINE_POSITION_VAL;
#endif
if (ch > maxchar)
@@ -1664,9 +1994,9 @@ set_vf_char(
#endif
}
#ifdef TEXXET
- dvi_h_sav = DVI_H;
- if (currinf.dir < 0)
- DVI_H -= m->dvi_adv;
+ PUSH_POSITION;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, -m->dvi_adv);
if (scan_frame == NULL) {
#endif
oldinfo = currinf;
@@ -1691,9 +2021,9 @@ set_vf_char(
#ifdef TEXXET
}
if (cmd == PUT1 || (resource.omega && cmd == PUT2))
- DVI_H = dvi_h_sav;
- else if (currinf.dir > 0)
- DVI_H += m->dvi_adv;
+ POP_POSITION;
+ else if (TATE || currinf.dir > 0)
+ moveH(1, m->dvi_adv);
return;
#else
return m->dvi_adv;
@@ -1811,9 +2141,64 @@ set_no_char(
* Set rule. Arguments are coordinates of lower left corner.
*/
+static void
+set_rotated_rule(long h, long w)
+{
+ XPoint points[4];
+ int pint = TATE;
+ if (pint&2) { pint&=1;
+ w=-w; h=-h;
+ }
+ points[0].x = PXL_H - currwin.base_x;
+ points[0].y = PXL_V - currwin.base_y;
+#ifdef PTEX
+ if (pint) {
+ points[1].x = -w * bbox_matrix[1][0];
+ points[1].y = w * bbox_matrix[0][0];
+ points[2].x = h * bbox_matrix[1][1];
+ points[2].y = -h * bbox_matrix[0][1];
+ } else
+#endif /* PTEX */
+ {
+ points[1].x = DIR * w * bbox_matrix[0][0];
+ points[1].y = DIR * w * bbox_matrix[1][0];
+ points[2].x = -h * bbox_matrix[0][1];
+ points[2].y = -h * bbox_matrix[1][1];
+ }
+ points[3].x = -points[1].x;
+ points[3].y = -points[1].y;
+
+ if (--globals.ev.ctr == 0) {
+ if (read_events(EV_NOWAIT) & EV_GE_MAG_GONE) {
+ /* fprintf(stderr, "longjmp1!\n"); */
+ longjmp(globals.ev.canit, 1);
+ }
+ }
+#if COLOR
+ if (fg_active != fg_current)
+ do_color_change();
+#endif
+ XFillPolygon(DISP, currwin.win,
+ htex_inside_href ? globals.gc.high: globals.gc.rule,
+ points, 4, Convex, CoordModePrevious);
+}
+
static void
set_rule(int h, int w)
{
+ if (bbox_rotated) {
+ set_rotated_rule(h, w);
+ return;
+ }
+ h = h * bbox_matrix[1][1];
+ w = w * bbox_matrix[0][0];
+#ifdef PTEX
+ if (TATE==1)
+ put_rule(PXL_H, PXL_V, (unsigned int)h, (unsigned int)w);
+ else if (TATE==3) /* dtou */
+ put_rule(PXL_H - h + 1, PXL_V - w + 1, (unsigned int)h, (unsigned int)w);
+ else
+#endif /* PTEX */
#ifdef TEXXET
put_rule(PXL_H - (currinf.dir < 0 ? w - 1 : 0), PXL_V - h + 1,
(unsigned int)w, (unsigned int)h);
@@ -1858,7 +2243,7 @@ draw_part(FILE *fp, struct frame *minframe, double cur
#ifdef TEXXET
(*currinf.set_char_p) (ch, ch);
#else
- DVI_H += (*currinf.set_char_p) (ch);
+ moveH(1, (*currinf.set_char_p) (ch));
#endif
}
else if (FNTNUM0 <= ch && ch <= (ubyte) (FNTNUM0 + 63)) {
@@ -1875,7 +2260,7 @@ draw_part(FILE *fp, struct frame *minframe, double cur
#else
a = (*currinf.set_char_p) (xone(fp));
if (ch != PUT1)
- DVI_H += a;
+ moveH(1, a);
#endif
break;
@@ -1890,11 +2275,43 @@ draw_part(FILE *fp, struct frame *minframe, double cur
#else
a = (*currinf.set_char_p) (xnum(fp, 2));
if (ch != PUT2)
- DVI_H += a;
+ moveH(1, a);
#endif
}
break;
+ case SET3:
+ case PUT3:
+ if (!resource.omega)
+ dvi_fmt_error("%s:%d: draw_part: op-code %d only works with the \"-omega\" option",
+ __FILE__, __LINE__, ch);
+ else {
+#ifdef TEXXET
+ (*currinf.set_char_p) (ch, xnum(fp, 3));
+#else
+ a = (*currinf.set_char_p) (xnum(fp, 3));
+ if (ch != PUT3)
+ moveH(1, a);
+#endif
+ }
+ break;
+
+ case SET4:
+ case PUT4:
+ if (!resource.omega)
+ dvi_fmt_error("%s:%d: draw_part: op-code %d only works with the \"-omega\" option",
+ __FILE__, __LINE__, ch);
+ else {
+#ifdef TEXXET
+ (*currinf.set_char_p) (ch, xnum(fp, 4));
+#else
+ a = (*currinf.set_char_p) (xnum(fp, 4));
+ if (ch != PUT4)
+ moveH(1, a);
+#endif
+ }
+ break;
+
case SETRULE:
/* Be careful, dvicopy outputs rules with
height = 0x80000000. We don't want any
@@ -1908,7 +2325,7 @@ draw_part(FILE *fp, struct frame *minframe, double cur
) {
set_rule(pixel_round(xspell_conv(a)), pixel_round(b));
}
- DVI_H += DIR * b;
+ moveH(DIR, b);
break;
case PUTRULE:
@@ -1932,6 +2349,9 @@ draw_part(FILE *fp, struct frame *minframe, double cur
DVI_V = OFFSET_Y;
PXL_V = pixel_conv(DVI_V);
WW = XX = YY = ZZ = 0;
+ bbox_matrix[0][0] = bbox_matrix[1][1] = 1.0;
+ bbox_matrix[0][1] = bbox_matrix[1][0] = 0.0;
+ bbox_scaled = bbox_rotated = False;
break;
case EOP:
@@ -2026,7 +2446,7 @@ draw_part(FILE *fp, struct frame *minframe, double cur
case RIGHT2:
case RIGHT3:
case RIGHT4:
- DVI_H += DIR * xspell_conv(xsnum(fp, ch - RIGHT1 + 1));
+ moveH(DIR, xspell_conv(xsnum(fp, ch - RIGHT1 + 1)));
break;
case W1:
@@ -2035,7 +2455,7 @@ draw_part(FILE *fp, struct frame *minframe, double cur
case W4:
WW = xspell_conv(xsnum(fp, ch - W0));
case W0:
- DVI_H += DIR * WW;
+ moveH(DIR, WW);
break;
case X1:
@@ -2044,15 +2464,14 @@ draw_part(FILE *fp, struct frame *minframe, double cur
case X4:
XX = xspell_conv(xsnum(fp, ch - X0));
case X0:
- DVI_H += DIR * XX;
+ moveH(DIR, XX);
break;
case DOWN1:
case DOWN2:
case DOWN3:
case DOWN4:
- DVI_V += xspell_conv(xsnum(fp, ch - DOWN1 + 1));
- PXL_V = pixel_conv(DVI_V);
+ moveV(1, xspell_conv(xsnum(fp, ch - DOWN1 + 1)));
break;
case Y1:
@@ -2061,8 +2480,7 @@ draw_part(FILE *fp, struct frame *minframe, double cur
case Y4:
YY = xspell_conv(xsnum(fp, ch - Y0));
case Y0:
- DVI_V += YY;
- PXL_V = pixel_conv(DVI_V);
+ moveV(1, YY);
break;
case Z1:
@@ -2071,8 +2489,7 @@ draw_part(FILE *fp, struct frame *minframe, double cur
case Z4:
ZZ = xspell_conv(xsnum(fp, ch - Z0));
case Z0:
- DVI_V += ZZ;
- PXL_V = pixel_conv(DVI_V);
+ moveV(1, ZZ);
break;
case FNT1:
@@ -2119,6 +2536,11 @@ draw_part(FILE *fp, struct frame *minframe, double cur
dvi_fmt_error("%s:%d: draw_part: shouldn't happen: %s encountered",
__FILE__, __LINE__, dvi_table2[ch - (FNTNUM0 + 64)]);
break;
+#ifdef PTEX
+ case TDIR:
+ TATE = xone(fp);
+ break;
+#endif /* PTEX */
default:
dvi_fmt_error("%s:%d: draw_part: unknown op-code %d", __FILE__, __LINE__, ch);
@@ -2305,7 +2727,7 @@ draw_page(void)
psp.endpage();
#endif
if (currwin.win == mane.win && resource.postscript != 1) {
- display_bboxes();
+ display_bboxes();
}
if (search_have_match(current_page)) {
/* highlight search match */
@@ -2915,7 +3337,15 @@ do_char(wide_ubyte ch,
last_dvi_h1 = DVI_H;
last_u_glyph = u_glyph;
last_pxl_v = pxl_v1;
+#ifdef PTEX
+ if (currinf.fontp->flags & FONT_KANJI) {
+ last_dvi_h2 = DVI_H + currinf.fontp->kglyph[ch]->dvi_adv;
+ } else {
+#endif /* PTEX */
last_dvi_h2 = DVI_H + currinf.fontp->glyph[ch].dvi_adv;
+#ifdef PTEX
+ }
+#endif /* PTEX */
last_x = x2;
}
@@ -2929,6 +3359,10 @@ text_do_char(FILE *fp, struct scan_info *info, wide_ub
return 0; /* error; we'll catch it later */
maxchar = currinf.fontp->maxchar;
currinf.set_char_p = currinf.fontp->set_char_p;
+#if FREETYPE
+ if (currinf.set_char_p == set_ft_char)
+ do_load_freetype_font();
+#endif
}
if (currinf.set_char_p == set_empty_char)
@@ -2961,10 +3395,6 @@ text_do_char(FILE *fp, struct scan_info *info, wide_ub
}
maxchar = currinf.fontp->maxchar;
currinf.set_char_p = currinf.fontp->set_char_p;
-#if FREETYPE
- if (currinf.set_char_p == set_ft_char)
- do_load_freetype_font();
-#endif
}
if (currinf.set_char_p == set_char) {
@@ -2992,25 +3422,56 @@ text_do_char(FILE *fp, struct scan_info *info, wide_ub
}
#ifdef TEXXET
if (geom_scan_frame == NULL) {
- long dvi_h_sav = DVI_H;
- if (currinf.dir < 0)
- DVI_H -= g->dvi_adv;
+ DEFINE_POSITION_VAL;
+ PUSH_POSITION;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, -g->dvi_adv);
#endif
x = G_PXL_H - g->x;
y = PXL_V - g->y;
do_char(ch, currinf, info, PXL_V, y, x, x + g->bitmap.w - 1, g);
#ifdef TEXXET
- DVI_H = dvi_h_sav;
+ POP_POSITION;
}
#endif
return DIR * g->dvi_adv;
}
+#ifdef PTEX
+ else if (currinf.set_char_p == set_char2) {
+ struct glyph *g;
+ long x, y;
+
+ g = currinf.fontp->kglyph[ch];
+ if (g == NULL || g->bitmap.bits == NULL) {
+ (*currinf.fontp->read_char)(currinf.fontp, ch);
+ g = currinf.fontp->kglyph[ch];
+ free_bitmap2(g);
+ g->tdir = currinf.fontp->dir;
+ }
+
+#ifdef TEXXET
+ if (geom_scan_frame == NULL) {
+ DEFINE_POSITION_VAL;
+ PUSH_POSITION;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, -g->dvi_adv);
+#endif
+ x = G_PXL_H - g->x;
+ y = PXL_V - g->y;
+ do_char(ch, currinf, info, PXL_V, y, x, x + g->bitmap.w - 1, g);
+#ifdef TEXXET
+ POP_POSITION;
+ }
+#endif
+ return DIR * g->dvi_adv;
+ }
+#endif /* PTEX */
else if (currinf.set_char_p == set_vf_char) {
struct macro *m;
struct drawinf oldinfo;
wide_ubyte oldmaxchar;
#ifdef TEXXET
- long dvi_h_sav;
+ DEFINE_POSITION_VAL;
#endif
if (ch > maxchar)
@@ -3018,9 +3479,9 @@ text_do_char(FILE *fp, struct scan_info *info, wide_ub
if ((m = &currinf.fontp->macro[ch])->pos == NULL)
return 0; /* catch the error later */
#ifdef TEXXET
- dvi_h_sav = DVI_H;
- if (currinf.dir < 0)
- DVI_H -= m->dvi_adv;
+ PUSH_POSITION;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, -m->dvi_adv);
if (geom_scan_frame == NULL) {
#endif
oldinfo = currinf;
@@ -3036,7 +3497,7 @@ text_do_char(FILE *fp, struct scan_info *info, wide_ub
currinf = oldinfo;
maxchar = oldmaxchar;
#ifdef TEXXET
- DVI_H = dvi_h_sav;
+ POP_POSITION;
}
#endif
return DIR * m->dvi_adv;
@@ -3048,6 +3509,11 @@ text_do_char(FILE *fp, struct scan_info *info, wide_ub
return 0;
}
+#define xmoveH(dir,dx) \
+ do { moveH(dir,dx); PXL_V = xpixel_conv(DVI_V); } while(0)
+#define xmoveV(dir,dy) \
+ do { moveV(dir,dy); PXL_V = xpixel_conv(DVI_V); } while(0)
+
/*
* Handle a character in geometric scanning routine.
*/
@@ -3063,6 +3529,10 @@ geom_do_char(FILE *fp, struct scan_info *info, wide_ub
return 0; /* error; we'll catch it later */
maxchar = currinf.fontp->maxchar;
currinf.set_char_p = currinf.fontp->set_char_p;
+#if FREETYPE
+ if (currinf.set_char_p == set_ft_char)
+ do_load_freetype_font();
+#endif
}
if (currinf.set_char_p == set_empty_char)
@@ -3095,10 +3565,6 @@ geom_do_char(FILE *fp, struct scan_info *info, wide_ub
}
maxchar = currinf.fontp->maxchar;
currinf.set_char_p = currinf.fontp->set_char_p;
-#if FREETYPE
- if (currinf.set_char_p == set_ft_char)
- do_load_freetype_font();
-#endif
}
if (currinf.set_char_p == set_char) {
@@ -3126,27 +3592,58 @@ geom_do_char(FILE *fp, struct scan_info *info, wide_ub
}
#ifdef TEXXET
if (geom_scan_frame == NULL) {
- long dvi_h_sav = DVI_H;
- if (currinf.dir < 0)
- DVI_H -= g->dvi_adv;
+ DEFINE_POSITION_VAL;
+ PUSH_POSITION;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, -g->dvi_adv);
#endif
x = G_PXL_H - g->x;
y = PXL_V - g->y;
g_info->geom_box(info, x, y,
x + g->bitmap.w - 1, y + g->bitmap.h - 1);
+#ifdef TEXXET
+ POP_POSITION;
+ }
+#endif
+ return DIR * g->dvi_adv;
+ }
+#ifdef PTEX
+ else if (currinf.set_char_p == set_char2) {
+ struct glyph *g;
+ long x, y;
+ g = currinf.fontp->kglyph[ch];
+ if (g == NULL || g->bitmap.bits == NULL) {
+ (*currinf.fontp->read_char)(currinf.fontp, ch);
+ g = currinf.fontp->kglyph[ch];
+ free_bitmap2(g);
+ g->tdir = currinf.fontp->dir;
+ }
+
#ifdef TEXXET
- DVI_H = dvi_h_sav;
+ if (geom_scan_frame == NULL) {
+ DEFINE_POSITION_VAL;
+ PUSH_POSITION;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, -g->dvi_adv);
+#endif
+ x = G_PXL_H - g->x;
+ y = PXL_V - g->y;
+ g_info->geom_box(info, x, y,
+ x + g->bitmap.w - 1, y + g->bitmap.h - 1);
+#ifdef TEXXET
+ POP_POSITION;
}
#endif
return DIR * g->dvi_adv;
}
+#endif /* PTEX */
else if (currinf.set_char_p == set_vf_char) {
struct macro *m;
struct drawinf oldinfo;
wide_ubyte oldmaxchar;
#ifdef TEXXET
- long dvi_h_sav;
+ DEFINE_POSITION_VAL;
#endif
if (ch > maxchar)
@@ -3154,9 +3651,9 @@ geom_do_char(FILE *fp, struct scan_info *info, wide_ub
if ((m = &currinf.fontp->macro[ch])->pos == NULL)
return 0; /* catch the error later */
#ifdef TEXXET
- dvi_h_sav = DVI_H;
- if (currinf.dir < 0)
- DVI_H -= m->dvi_adv;
+ PUSH_POSITION;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, -m->dvi_adv);
if (geom_scan_frame == NULL) {
#endif
oldinfo = currinf;
@@ -3172,7 +3669,7 @@ geom_do_char(FILE *fp, struct scan_info *info, wide_ub
currinf = oldinfo;
maxchar = oldmaxchar;
#ifdef TEXXET
- DVI_H = dvi_h_sav;
+ POP_POSITION;
}
#endif
return DIR * m->dvi_adv;
@@ -3192,21 +3689,35 @@ static void
geom_do_rule(struct scan_info *info, long h, long w)
{
long x, y;
+ struct geom_info *g_info = info->data;
#ifdef TEXXET
- long dvi_h_save = DVI_H;
+ DEFINE_POSITION_VAL;
+ PUSH_POSITION;
#endif
- struct geom_info *g_info = info->data;
-
+
+ if (bbox_rotated) {
+ fprintf(stderr, "geom_do_rotated_rule(h, w) is not implemented!\n");
+ return;
+ }
+ h = h * bbox_matrix[1][1];
+ w = w * bbox_matrix[0][0];
+
#ifdef TEXXET
- if (currinf.dir < 0)
- DVI_H -= w - 1;
+ if (! TATE && currinf.dir < 0)
+ moveH(1, - w + 1);
#endif
x = G_PXL_H;
y = PXL_V;
+#ifdef PTEX
+ if (TATE)
+ g_info->geom_box(info, x, y, x + xpixel_round(h) - 1,
+ y + xpixel_round(w) - 1);
+ else
+#endif /* PTEX */
g_info->geom_box(info, x, y - xpixel_round(h) + 1,
x + xpixel_round(w) - 1, y);
#ifdef TEXXET
- DVI_H = dvi_h_save;
+ POP_POSITION;
#endif
}
@@ -3236,7 +3747,7 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
for (;;) {
ch = xone(fp);
if (ch <= (ubyte)(SETCHAR0 + 127))
- DVI_H += char_proc(fp, info, ch);
+ xmoveH(1, char_proc(fp, info, ch));
else if (FNTNUM0 <= ch && ch <= (ubyte) (FNTNUM0 + 63)) {
change_font((unsigned long)(ch - FNTNUM0));
}
@@ -3248,7 +3759,7 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
case PUT1:
a = char_proc(fp, info, xone(fp));
if (ch != PUT1)
- DVI_H += a;
+ xmoveH(1, a);
break;
case SET2:
@@ -3262,11 +3773,43 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
#else
a = char_proc(fp, info, xnum(fp, 2));
if (ch != PUT2)
- DVI_H += a;
+ xmoveH(1, a);
#endif
}
break;
+ case SET3:
+ case PUT3:
+ if (!resource.omega)
+ dvi_fmt_error("%s:%d: draw_part: op-code %d only works with the \"-omega\" option",
+ __FILE__, __LINE__, ch);
+ else {
+#ifdef TEXXET
+ char_proc(fp, info, xnum(fp, 3));
+#else
+ a = char_proc(fp, info, xnum(fp, 3));
+ if (ch != PUT3)
+ xmoveH(1, a);
+#endif
+ }
+ break;
+
+ case SET4:
+ case PUT4:
+ if (!resource.omega)
+ dvi_fmt_error("%s:%d: draw_part: op-code %d only works with the \"-omega\" option",
+ __FILE__, __LINE__, ch);
+ else {
+#ifdef TEXXET
+ char_proc(fp, info, xnum(fp, 4));
+#else
+ a = char_proc(fp, info, xnum(fp, 4));
+ if (ch != PUT4)
+ xmoveH(1, a);
+#endif
+ }
+ break;
+
case SETRULE:
/* Be careful, dvicopy outputs rules with
height = 0x80000000. We don't want any
@@ -3282,7 +3825,7 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
if (info->geom_special != NULL)
geom_do_rule(info, xspell_conv(a), b);
}
- DVI_H += DIR * b;
+ moveH(DIR, b);
break;
case PUTRULE:
@@ -3403,7 +3946,7 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
case RIGHT2:
case RIGHT3:
case RIGHT4:
- DVI_H += DIR * xspell_conv(xsnum(fp, ch - RIGHT1 + 1));
+ xmoveH(DIR, xspell_conv(xsnum(fp, ch - RIGHT1 + 1)));
break;
case W1:
@@ -3412,7 +3955,7 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
case W4:
WW = xspell_conv(xsnum(fp, ch - W0));
case W0:
- DVI_H += DIR * WW;
+ xmoveH(DIR, WW);
break;
case X1:
@@ -3421,15 +3964,14 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
case X4:
XX = xspell_conv(xsnum(fp, ch - X0));
case X0:
- DVI_H += DIR * XX;
+ xmoveH(DIR, XX);
break;
case DOWN1:
case DOWN2:
case DOWN3:
case DOWN4:
- DVI_V += xspell_conv(xsnum(fp, ch - DOWN1 + 1));
- PXL_V = xpixel_conv(DVI_V);
+ xmoveV(1, xspell_conv(xsnum(fp, ch - DOWN1 + 1)));
break;
case Y1:
@@ -3438,8 +3980,7 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
case Y4:
YY = xspell_conv(xsnum(fp, ch - Y0));
case Y0:
- DVI_V += YY;
- PXL_V = xpixel_conv(DVI_V);
+ xmoveV(1, YY);
break;
case Z1:
@@ -3448,8 +3989,7 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
case Z4:
ZZ = xspell_conv(xsnum(fp, ch - Z0));
case Z0:
- DVI_V += ZZ;
- PXL_V = xpixel_conv(DVI_V);
+ xmoveV(1, ZZ);
break;
case FNT1:
@@ -3485,6 +4025,12 @@ geom_scan_part(long(*char_proc)(FILE *, struct scan_in
a = (long)xone(fp);
xskip(fp, a + (long)xone(fp));
break;
+
+#ifdef PTEX
+ case TDIR:
+ TATE = xone(fp);
+ break;
+#endif /* PTEX */
#ifndef TEXXET
case SREFL:
|
9ff6bf92d3b766c7aabe6fef07e4bc7cbe1b49d0
|
475035dbb7e2647fbfd85a0ee01233da1e6b2b15
|
/sdk/inc/azure/core/internal/az_log_internal.h
|
562b0450d0f2a790b4887b55e89fc38f457219ec
|
[
"BSD-3-Clause",
"Zlib",
"EPL-1.0",
"BSL-1.0",
"curl",
"Apache-2.0",
"OpenSSL",
"LGPL-2.1-or-later",
"BSD-2-Clause",
"EPL-2.0",
"MIT",
"LicenseRef-scancode-generic-cla"
] |
permissive
|
Azure/azure-sdk-for-c
|
0bbdd4323a811ea363dbd3fb5e30ba31744693c8
|
e37b28e1a89a523631dd92e733186da001b936df
|
refs/heads/main
| 2023-09-01T06:12:06.834142
| 2023-08-29T04:54:55
| 2023-08-29T04:54:55
| 195,472,455
| 203
| 154
|
MIT
| 2023-09-13T20:28:58
| 2019-07-05T22:14:01
|
C
|
UTF-8
|
C
| false
| false
| 1,221
|
h
|
az_log_internal.h
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
*
* @brief Defines internals used by log.
*
* @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
* prefixed with an underscore ('_') directly in your application code. These symbols
* are part of Azure SDK's internal implementation; we do not document these symbols
* and they are subject to change in future versions of the SDK which would break your code.
*/
#ifndef _az_LOG_INTERNAL_H
#define _az_LOG_INTERNAL_H
#include <azure/core/az_log.h>
#include <azure/core/az_span.h>
#include <stdbool.h>
#include <azure/core/_az_cfg_prefix.h>
#ifndef AZ_NO_LOGGING
bool _az_log_should_write(az_log_classification classification);
void _az_log_write(az_log_classification classification, az_span message);
#define _az_LOG_SHOULD_WRITE(classification) _az_log_should_write(classification)
#define _az_LOG_WRITE(classification, message) _az_log_write(classification, message)
#else
#define _az_LOG_SHOULD_WRITE(classification) false
#define _az_LOG_WRITE(classification, message)
#endif // AZ_NO_LOGGING
#include <azure/core/_az_cfg_suffix.h>
#endif // _az_LOG_INTERNAL_H
|
9d5981f0f548729c54b70f86ee045a028383783a
|
d1a6e586e0ad50da88ac3cf176d40bb9facb6bf6
|
/source/operator/prototype/rnn.c
|
0973a9f24a132df41dfce50d69eba1a4f56a71e1
|
[
"Apache-2.0"
] |
permissive
|
OAID/Tengine
|
025d2521040c863300ee08b0800010587b72192b
|
c73708ceb4322ae7c438e4d468178b737fa44cd0
|
refs/heads/tengine-lite
| 2023-09-03T19:15:08.100078
| 2023-05-18T06:17:39
| 2023-05-18T06:17:39
| 115,765,590
| 5,323
| 1,216
|
Apache-2.0
| 2023-09-05T06:25:47
| 2017-12-30T01:21:41
|
C++
|
UTF-8
|
C
| false
| false
| 2,549
|
c
|
rnn.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.
*/
/*
* Copyright (c) 2021, OPEN AI LAB
* Author: qli@openailab.com
*/
#include "rnn_param.h"
#include "api/c_api.h"
#include "graph/tensor.h"
#include "graph/node.h"
#include "graph/graph.h"
#include "module/module.h"
#include "utility/sys_port.h"
static int infer_shape(struct node* node)
{
struct graph* graph = node->graph;
struct tensor* input = get_ir_graph_tensor(graph, node->input_tensors[0]);
struct tensor* output = get_ir_graph_tensor(graph, node->output_tensors[0]);
struct rnn_param* rnn_param = (struct rnn_param*)(node->op.param_mem);
int dims[3];
// input tensors:
// 0 --- input: [seq_length, batch_size,input_size]
// 1 --- kernel [ (input_size+hidden_size),hidden_state_size]
// others: optional
// output tensor: [output_len,batch_size,hidden_size]
int batch_size = input->dims[1];
dims[0] = rnn_param->output_len;
dims[1] = batch_size;
dims[2] = rnn_param->hidden_size;
set_ir_tensor_shape(output, dims, 3);
return 0;
}
static int init_op(struct op* op)
{
struct rnn_param* rnn_param = (struct rnn_param*)sys_malloc(sizeof(struct rnn_param));
if (rnn_param == NULL)
{
return -1;
}
rnn_param->inithiddenname = "init_h";
rnn_param->inithiddenname = "bias";
op->param_mem = rnn_param;
op->param_size = sizeof(struct rnn_param);
op->same_shape = 0;
op->infer_shape = infer_shape;
return 0;
}
static void release_op(struct op* op)
{
sys_free(op->param_mem);
}
int register_rnn_op()
{
struct method m;
m.version = 1;
m.init = init_op;
m.release = release_op;
return register_op(OP_RNN, OP_RNN_NAME, &m);
}
int unregister_rnn_op()
{
return unregister_op(OP_RNN, 1);
}
|
1218b9eacfdfb5c381f66c488efb3234ac44af84
|
fb47ab6337a71029dee71933e449cf7f6805fc0f
|
/lib/norfs/test/norfs_test.c
|
669b60e037e42ec4799e34852a2555b4a1ed10be
|
[
"MIT"
] |
permissive
|
littlekernel/lk
|
7e7ba50b87b1f2e0b6e2f052c59249825c91975b
|
30dc320054f70910e1c1ee40a6948ee99672acec
|
refs/heads/master
| 2023-09-02T00:47:52.203963
| 2023-06-21T22:42:35
| 2023-06-21T22:42:35
| 3,058,456
| 3,077
| 618
|
MIT
| 2023-08-30T09:41:31
| 2011-12-27T19:19:36
|
C
|
UTF-8
|
C
| false
| false
| 25,613
|
c
|
norfs_test.c
|
/*
* Copyright (c) 2013 Heather Lee Wilson
*
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#include <unittest.h>
#include <lib/norfs.h>
#include <lib/norfs_inode.h>
#include <lib/norfs_config.h>
#include <norfs_test_helper.h>
#include <dev/flash_nor.h>
#include <stdio.h>
#include <stdlib.h>
#include <lk/err.h>
#include <platform/flash_nor_config.h>
#include <platform.h>
#include <rand.h>
extern uint32_t total_remaining_space;
extern uint8_t num_free_blocks;
static uint8_t *norfs_test_bank;
static uint8_t norfs_test_bank_len;
extern uint32_t norfs_nvram_offset = 0;
static const unsigned char erase_header[4] = {'T', 'O', 'F', 'U'};
static const unsigned char gc_header[4] = {'S', 'O', 'U', 'P'};
/* Object with a good checksum. key = 2; version = 0; obj = {0, 1, 2, 3} */
static const unsigned char good_object[16] = {2, 0, 0, 0, 0, 0, 4, 0, 0, 0xFF,
0x3d, 0x02, 0, 1, 2, 3
};
/* Object with a good checksum. key = 2; version = 1; obj = {5, 4, 3, 2} */
static const unsigned char good_object_v1[16] = {2, 0, 0, 0, 1, 0, 4, 0, 0, 0xFF,
0xbb, 0x9d, 5, 4, 3, 2
};
/* A much later version of good_object to test wrapping of versions. */
static const unsigned char good_object_v127[16] = {2, 0, 0, 0, 0xFF, 0x7F, 4,
0, 0, 0xFF, 0x76, 0x3c, 6,
7, 8, 9
};
/* A much later version of good_object to test wrapping of versions. */
static const unsigned char good_object_v128[16] = {2, 0, 0, 0, 0x00, 0x80, 4,
0, 0, 0xFF, 0x04, 0x24, 6,
7, 8, 9
};
/* Deleted object. key = 2; version = 2 */
static const unsigned char good_object_deleted_v2[12] = {2, 0, 0, 0, 2, 0, 0, 0,
1, 0xFF, 0xb7, 0x8a
};
/* Deleted object. key = 2; version = 3 */
static const unsigned char good_object_deleted_v3[12] = {2, 0, 0, 0, 3, 0, 0, 0,
1, 0xFF, 0xe6, 0x20
};
/* Object with a bad checksum. key = 4; version = 2; obj = {3, 2, 1, 0} */
static const unsigned char bad_object[16] = {4, 0, 0, 0, 2, 0, 4, 0, 0, 0xFF, 4,
7, 3, 2, 1, 0
};
/* Object with a good checksum. key = 0; version = 0; obj = {9, 8, 7, 6} */
static const unsigned char another_good_object[16] = {0, 0, 0, 0, 0, 0, 4, 0, 0,
0xFF, 0x4d, 0x4a, 9, 8, 7,
6
};
const unsigned char NORFS_BLOCK_HEADER[4] = {'T', 'O', 'F', 'U'};
const unsigned char NORFS_BLOCK_GC_STARTED_HEADER[2] = {'S', 'O'};
const unsigned char NORFS_BLOCK_GC_FINISHED_HEADER[2] = {'U', 'P'};
const int NORFS_OBJ_HEADER_SIZE = 12;
/* Stores the current bank for future retrieval. */
static void save_bank(void) {
free(norfs_test_bank);
norfs_test_bank = malloc(8 * FLASH_PAGE_SIZE);
const struct flash_nor_bank *bank;
bank = flash_nor_get_bank(0);
memcpy(norfs_test_bank, (void *)bank->base, 8 * FLASH_PAGE_SIZE);
norfs_test_bank_len = bank->len;
}
static void write_block_header(uint *ptr) {
*ptr += flash_nor_write(0, *ptr, sizeof(NORFS_BLOCK_HEADER),
NORFS_BLOCK_HEADER);
*ptr += flash_nor_write(0, *ptr, sizeof(NORFS_BLOCK_GC_STARTED_HEADER),
NORFS_BLOCK_GC_STARTED_HEADER);
*ptr += flash_nor_write(0, *ptr, sizeof(NORFS_BLOCK_GC_FINISHED_HEADER),
NORFS_BLOCK_GC_FINISHED_HEADER);
}
static bool test_basic_read_write(void) {
BEGIN_TEST;
unsigned char char_array[5] = {4, 6, 7, 2, 1};
uint32_t char_key = 47;
int big_int = 2000000000;
uint32_t int_key = 21;
size_t char_array_bytes_read;
int big_int_buffer;
size_t big_int_bytes_read;
unsigned char *char_array_buffer = malloc(sizeof(unsigned char)*6);
status_t status;
unsigned char alpha[2] = {'a', 'b'};
unsigned char beta[3] = {'c', 'd', 'e'};
size_t obj_len;
int iov_in_count = 2;
iovec_t *iov_in = malloc(iov_in_count*sizeof(iovec_t));
iov_in[0].iov_len = 2;
iov_in[0].iov_base = alpha;
iov_in[1].iov_len = 3;
iov_in[1].iov_base = beta;
int iov_out_count = 3;
iovec_t *iov_out = malloc(iov_out_count*sizeof(iovec_t));
iov_out[0].iov_len = 1;
iov_out[0].iov_base = malloc(sizeof(unsigned char));
iov_out[1].iov_len = 3;
iov_out[1].iov_base = malloc(iov_out_count*sizeof(unsigned char));
iov_out[2].iov_len = 1;
iov_out[2].iov_base = malloc(sizeof(unsigned char));
wipe_fs();
EXPECT_EQ(ERR_NOT_MOUNTED, norfs_put_obj(char_key, char_array, sizeof(char_array),
0), "Calls to file system should fail when not mounted");
EXPECT_EQ(ERR_NOT_MOUNTED, norfs_read_obj(char_key, char_array_buffer,
sizeof(unsigned char)*6, &char_array_bytes_read, 0),
"Calls to file system should fail when not mounted");
EXPECT_EQ(ERR_NOT_MOUNTED, norfs_put_obj_iovec(17, iov_in, iov_in_count, 0),
"Calls to file system should fail when not mounted");
EXPECT_EQ(ERR_NOT_MOUNTED, norfs_read_obj_iovec(17, iov_out, iov_out_count,
&obj_len, 0),
"Calls to file system should fail when not mounted");
EXPECT_EQ(ERR_NOT_MOUNTED, norfs_remove_obj(17),
"Calls to file system should fail when not mounted");
EXPECT_EQ(NO_ERROR, norfs_mount_fs(norfs_nvram_offset), "Error during mount");
status = norfs_put_obj(char_key, char_array, sizeof(char_array), 0);
EXPECT_EQ(NO_ERROR, status, "norfs_put_obj returned error");
status = norfs_put_obj(int_key, (unsigned char *)&big_int, sizeof(big_int), 0);
EXPECT_EQ(NO_ERROR, status, "norfs_put_obj returned error");
status = norfs_read_obj(char_key, char_array_buffer, sizeof(unsigned char)*6,
&char_array_bytes_read, 0);
EXPECT_EQ(NO_ERROR, status, "norfs_read_obj returned error");
if (status)
return false;
status = norfs_read_obj(int_key, (unsigned char *)&big_int_buffer,
sizeof(big_int_buffer), &big_int_bytes_read, 0);
EXPECT_EQ(NO_ERROR, status, "norfs_read_obj returned error");
if (status)
return false;
if (!status) {
EXPECT_EQ(sizeof(char_array), char_array_bytes_read,
"Not all bytes of object read");
EXPECT_EQ(sizeof(big_int), big_int_bytes_read,
"Not all bytes of object read");
for (int i = 0; i < 5; i++) {
EXPECT_EQ(char_array[i], char_array_buffer[i],
"Did not read object from NVRAM correctly");
}
EXPECT_EQ(big_int, big_int_buffer,
"Did not read object from NVRAM correctly");
}
norfs_put_obj_iovec(17, iov_in, iov_in_count, 0);
status = norfs_read_obj_iovec(17, iov_out, iov_out_count, &obj_len, 0);
EXPECT_EQ(NO_ERROR, status, "norfs_read_obj returned error for iovec");
if (!status) {
EXPECT_EQ('a', *((unsigned char *)iov_out[0].iov_base),
"Iovec not retrieved correctly");
EXPECT_EQ('b', *((unsigned char *)iov_out[1].iov_base),
"Iovec not retrieved correctly");
EXPECT_EQ('c', *((unsigned char *)iov_out[1].iov_base + 1),
"Iovec not retrieved correctly");
EXPECT_EQ('d', *((unsigned char *)iov_out[1].iov_base + 2),
"Iovec not retrieved correctly");
EXPECT_EQ('e', *((unsigned char *)iov_out[2].iov_base),
"Iovec not retrieved correctly");
} else {
return false;
}
EXPECT_EQ(5, obj_len, "Iovec did not return length correctly");
/* Ensure static data is cleared when you remount. */
EXPECT_EQ(norfs_mount_fs(norfs_nvram_offset), ERR_ALREADY_MOUNTED, "Remounting should fail");
save_bank();
norfs_unmount_fs();
EXPECT_EQ(NO_ERROR, norfs_mount_fs(norfs_nvram_offset), "Error during mount");
memset(char_array_buffer, 0, sizeof(char_array_buffer));
big_int_buffer = 0;
status = norfs_read_obj(char_key, char_array_buffer, sizeof(unsigned char)*6,
&char_array_bytes_read, 0);
EXPECT_EQ(NO_ERROR, status, "norfs_read_obj returned error");
if (status)
return false;
status = norfs_read_obj(int_key, (unsigned char *)&big_int_buffer,
sizeof(big_int_buffer), &big_int_bytes_read, 0);
EXPECT_EQ(NO_ERROR, status, "norfs_read_obj returned error");
if (status)
return false;
if (!status) {
EXPECT_EQ(char_array_bytes_read, sizeof(char_array),
"Not all bytes of object read");
EXPECT_EQ(big_int_bytes_read, sizeof(big_int),
"Not all bytes of object read");
for (int i = 0; i < 5; i++) {
EXPECT_EQ(char_array[i], char_array_buffer[i],
"Did not read object from NVRAM correctly");
}
EXPECT_EQ(big_int, big_int_buffer,
"Did not read object from NVRAM correctly");
}
status = norfs_read_obj_iovec(17, iov_out, iov_out_count - 1, &obj_len, 0);
EXPECT_EQ(NO_ERROR, status, "norfs_read_obj returned error for iovec");
if (!status) {
EXPECT_EQ('a', *((unsigned char *)iov_out[0].iov_base),
"Iovec not retrieved correctly");
EXPECT_EQ('b', *((unsigned char *)iov_out[1].iov_base),
"Iovec not retrieved correctly");
EXPECT_EQ('c', *((unsigned char *)iov_out[1].iov_base + 1),
"Iovec not retrieved correctly");
EXPECT_EQ('d', *((unsigned char *)iov_out[1].iov_base + 2),
"Iovec not retrieved correctly");
} else {
return false;
}
EXPECT_EQ(4, obj_len, "Iovec did not return length correctly");
status = norfs_remove_obj(17);
EXPECT_EQ(NO_ERROR, status, "Error when removing object");
status = norfs_read_obj_iovec(17, iov_out, 2, &obj_len, 0);
EXPECT_EQ(ERR_NOT_FOUND, status, "Found object when unexpected");
status = norfs_remove_obj(17);
EXPECT_EQ(ERR_NOT_FOUND, status, "Allowed redundant delete of object");
wipe_fs();
END_TEST;
}
/* This test may need to be revised if no longer using round-robin garbage
* collection, since there will be no guarantee the block containing the
* object with key 4 has been collected.
*/
static bool test_garbage_collection(void) {
BEGIN_TEST;
int size = FLASH_PAGE_SIZE/16;
unsigned char array[size];
size_t bytes_read;
status_t status = NO_ERROR;
norfs_mount_fs(norfs_nvram_offset);
/* Store an object that will not be overwritten. */
memset(array, 4, size);
status = norfs_put_obj(4, array, size, 0);
EXPECT_EQ(NO_ERROR, status,
"Error putting object");
/* Store enough versions of objects to ensure block containing
* first object is collected.
*/
for (int i = 0; i < 51; i++) {
for (int j = 0; j < 4; j++) {
memset(array, j, size);
status = norfs_put_obj(j, array, size, 0);
EXPECT_EQ(NO_ERROR, status,
"Error putting object");
if (status)
break;
}
if (status)
break;
}
status = norfs_read_obj(4, array, size, &bytes_read, 0);
EXPECT_EQ(NO_ERROR, status,
"Error reading object");
/* Verify first object still intact. */
for (int i = 0; i < size; i++) {
EXPECT_EQ(4, array[i], "Bad value for object.\n");
}
wipe_fs();
END_TEST;
}
static bool test_total_remaining_space(void) {
BEGIN_TEST;
uint32_t prev_remaining_space;
unsigned char array[4];
wipe_fs();
norfs_mount_fs(norfs_nvram_offset);
norfs_put_obj(0, array, 3, 0);
norfs_put_obj(0, array, 4, 0);
prev_remaining_space = total_remaining_space;
norfs_unmount_fs();
norfs_mount_fs(norfs_nvram_offset);
EXPECT_EQ(total_remaining_space, prev_remaining_space,
"Remaining space incorrectly maintained");
wipe_fs();
END_TEST;
}
static bool test_deletion(void) {
BEGIN_TEST;
status_t status;
struct norfs_inode *inode = NULL;
uint ptr = 0;
wipe_fs();
ptr += flash_nor_write(0, ptr, sizeof(erase_header), erase_header);
ptr += flash_nor_write(0, ptr, sizeof(gc_header), gc_header);
ptr += flash_nor_write(0, ptr, sizeof(good_object), good_object);
ptr += flash_nor_write(0, ptr, sizeof(good_object_deleted_v2),
good_object_deleted_v2);
EXPECT_EQ(NO_ERROR, norfs_mount_fs(norfs_nvram_offset), "Error during mount");
status = get_inode(2, &inode);
EXPECT_EQ(true, status,
"Inode should be in list since references remain");
if (!status)
return false;
EXPECT_EQ(2, (inode)->reference_count,
"Reference count should count one non-deleted version of object");
EXPECT_EQ(24, (inode)->location, "Not pointing to current version");
write_pointer = FLASH_PAGE_SIZE + sizeof(erase_header);
write_pointer += flash_nor_write(0, write_pointer, sizeof(erase_header),
erase_header);
EXPECT_EQ(NO_ERROR, collect_block(0, &write_pointer),
"Error when collecting block");
EXPECT_EQ(false, get_inode(2, &inode),
"Inode still in list after references have been collected");
wipe_fs();
ptr = 0;
ptr += flash_nor_write(0, ptr, sizeof(erase_header), erase_header);
ptr += flash_nor_write(0, ptr, sizeof(gc_header), gc_header);
ptr += flash_nor_write(0, ptr, sizeof(good_object_deleted_v2),
good_object_deleted_v2);
EXPECT_EQ(NO_ERROR, norfs_mount_fs(norfs_nvram_offset), "Error during mount");
EXPECT_EQ(true, get_inode(2, &inode),
"Inode should be in list");
wipe_fs();
END_TEST;
}
static bool test_corruption(void) {
BEGIN_TEST;
unsigned char buff[4];
size_t bytes_read;
wipe_fs();
norfs_mount_fs(norfs_nvram_offset);
uint ptr = 4;
ptr += flash_nor_write(0, ptr, 4, gc_header);
ptr += flash_nor_write(0, ptr, 16, good_object);
EXPECT_EQ(24, ptr, "Write failed");
ptr += flash_nor_write(0, ptr, 16, bad_object);
EXPECT_EQ(40, ptr, "Write failed");
ptr += flash_nor_write(0, ptr, 16, good_object_v1);
EXPECT_EQ(56, ptr, "Write failed");
ptr += flash_nor_write(0, ptr, 16, another_good_object);
EXPECT_EQ(72, ptr, "Write failed");
norfs_unmount_fs();
norfs_mount_fs(norfs_nvram_offset);
status_t status = norfs_read_obj(2, buff, 4, &bytes_read, 0);
EXPECT_EQ(NO_ERROR, status,
"Object prior to corruption should still be readable");
/* good_object_v1, appearing after the corruption, should be discarded. */
for (int i = 0; i < 4; i++) {
EXPECT_EQ(i, buff[i],
"First version of object not correctly retrieved");
}
status = norfs_read_obj(4, buff, 4, &bytes_read, 0);
EXPECT_EQ(ERR_NOT_FOUND, status, "Corrupted object should not be found");
status = norfs_read_obj(0, buff, 4, &bytes_read, 0);
EXPECT_EQ(ERR_NOT_FOUND, status,
"Object after corrupted object should not be found");
wipe_fs();
END_TEST;
}
static bool test_deletion_objects_retained_during_gc(void) {
BEGIN_TEST;
static const uint16_t BLOCK_HEADER_SIZE = 8, OBJ_HEADER_LENGTH = 12;
/* Define an object size that will tightly fill a block with objects. */
uint16_t obj_len = (FLASH_PAGE_SIZE - BLOCK_HEADER_SIZE) / 20
- OBJ_HEADER_LENGTH;
status_t status;
unsigned char obj[obj_len];
uint32_t key = 17;
size_t bytes_read;
memset(obj, 7, obj_len);
wipe_fs();
EXPECT_EQ(NO_ERROR, norfs_mount_fs(norfs_nvram_offset), "Error during mount");
for (int i = 0; i < 20; i++) {
status = norfs_put_obj(key, obj, obj_len, 0);
EXPECT_EQ(NO_ERROR, status, "Error putting object");
}
status = norfs_remove_obj(key);
EXPECT_EQ(status, NO_ERROR, "Error removing object");
status = norfs_read_obj(key, obj, obj_len, &bytes_read, 0);
EXPECT_EQ(ERR_NOT_FOUND, status, "Object not removed");
find_free_block(&write_pointer);
status = norfs_read_obj(key, obj, obj_len, &bytes_read, 0);
EXPECT_EQ(ERR_NOT_FOUND, status,
"Error: Object removal lost after garbage collection");
status = norfs_put_obj(key, obj, obj_len, 0);
EXPECT_EQ(NO_ERROR, status, "Error putting object");
wipe_fs();
END_TEST;
}
static bool test_garbage_collection_interruption(void) {
BEGIN_TEST;
wipe_fs();
size_t obj_len;
uint32_t ptr = 0;
unsigned char buffer[16];
/* Write partial block header, indicating interrupted garbage collection. */
ptr += flash_nor_write(0, ptr, sizeof(NORFS_BLOCK_HEADER),
NORFS_BLOCK_HEADER);
ptr += flash_nor_write(0, ptr, sizeof(NORFS_BLOCK_GC_STARTED_HEADER),
NORFS_BLOCK_GC_STARTED_HEADER);
ptr += sizeof(NORFS_BLOCK_GC_FINISHED_HEADER);
flash_nor_write(0, ptr, sizeof(good_object), good_object);
/* Move to second block. */
ptr = FLASH_PAGE_SIZE;
write_block_header(&ptr);
flash_nor_write(0, ptr, sizeof(another_good_object), another_good_object);
EXPECT_EQ(NO_ERROR, norfs_mount_fs(norfs_nvram_offset), "Error during mount");
EXPECT_EQ(NO_ERROR, norfs_read_obj(0, buffer, sizeof(buffer), &obj_len, 0),
"Failed to read object in block with correct header");
EXPECT_EQ(ERR_NOT_FOUND, norfs_read_obj(2, buffer, sizeof(buffer), &obj_len, 0),
"Object in corrupt block should not be readable");
wipe_fs();
END_TEST;
}
static bool test_thrash_fs(void) {
status_t status;
size_t bytes_read;
int int_buff;
int state[16];
for (int i = 0; i < 16; i++) {
state[i] = -1;
}
BEGIN_TEST;
wipe_fs();
norfs_mount_fs(norfs_nvram_offset);
srand(current_time());
iovec_t *iov = malloc(sizeof(iovec_t));
iov->iov_len = sizeof(int);
for (int i = 0; i < 10000; i++) {
int action = rand() % 6;
uint16_t key = (uint16_t)(rand() % 16);
switch (action) {
case 0:
status = norfs_remove_obj(key);
if (state[key] == -1) {
EXPECT_EQ(ERR_NOT_FOUND, status,
"Removed object not returning correctly from read");
} else {
EXPECT_EQ(NO_ERROR, status,
"Object not returning correctly from remove");
if (status) {
dump_bank();
return false;
}
}
state[key] = -1;
break;
case 1:
iov->iov_base = &i;
status = norfs_put_obj_iovec(key, iov, 1, 0);
EXPECT_EQ(NO_ERROR, status,
"Object not returning correctly from put");
state[key] = i;
break;
case 2:
status = norfs_put_obj(key, (unsigned char *)&i, sizeof(i), 0);
EXPECT_EQ(NO_ERROR, status,
"Object not returning correctly from put");
state[key] = i;
break;
case 3:
iov->iov_base = &int_buff;
status = norfs_read_obj_iovec(key, iov, 1, &bytes_read, 0);
if (state[key] == -1) {
EXPECT_EQ(ERR_NOT_FOUND, status,
"Removed object not returning correctly from read");
} else {
EXPECT_EQ(NO_ERROR, status,
"Object not returning correctly from read");
EXPECT_EQ(state[key], *(int *)iov->iov_base, "Object not correct value");
if (status || state[key] != *(int *)iov->iov_base) {
dump_bank();
return false;
}
}
break;
case 4:
status = norfs_read_obj(key, (unsigned char *)&int_buff, sizeof(int),
&bytes_read, 0);
if (state[key] == -1) {
EXPECT_EQ(ERR_NOT_FOUND, status,
"Removed object not returning correctly from read");
} else {
EXPECT_EQ(NO_ERROR, status,
"Object not returning correctly from read");
EXPECT_EQ(state[key], int_buff, "Object not correct value");
if (status || state[key] != int_buff) {
dump_bank();
return false;
}
}
break;
case 5:
norfs_unmount_fs();
norfs_mount_fs(norfs_nvram_offset);
break;
default:
/* Should not end up here. */
return false;
}
EXPECT_GE(8 * FLASH_PAGE_SIZE - 1, write_pointer,
"Write pointer has overflowed NVRAM");
}
for (int i = 0; i < 16; i++) {
status = norfs_read_obj(i, (unsigned char *)&int_buff, sizeof(int), &bytes_read, 0);
if (state[i] == -1) {
EXPECT_EQ(ERR_NOT_FOUND, status,
"Removed object not returning correctly from read");
} else {
EXPECT_EQ(NO_ERROR, status,
"Object not returning correctly from read");
EXPECT_EQ(state[i], int_buff, "Object not correct value");
}
}
wipe_fs();
END_TEST;
}
static bool test_overflow_filesystem(void) {
BEGIN_TEST;
wipe_fs();
norfs_mount_fs(norfs_nvram_offset);
int i = 0;
bool filesystem_full;
status_t status;
unsigned char obj = 0b01010101;
while (!filesystem_full) {
status = norfs_put_obj(i, &obj, sizeof(obj), 0);
if (status != NO_ERROR) {
EXPECT_EQ(ERR_NO_MEMORY, status, "put_obj returned unexpected error");
EXPECT_LE(sizeof(obj) + NORFS_OBJ_HEADER_SIZE, total_remaining_space,
"Returning memory error when filesystem not full");
if (status != ERR_TOO_BIG) {
return false;
}
filesystem_full = true;
}
i++;
}
for (int j = i - 1; j >= 0; j--) {
status = norfs_remove_obj(j);
if (total_remaining_space >= sizeof(obj) + NORFS_OBJ_HEADER_SIZE) {
status = norfs_put_obj(i, &obj, sizeof(obj), 0);
EXPECT_EQ(NO_ERROR, status, "Error after clearing space for new objects");
i++;
}
}
wipe_fs();
END_TEST;
}
static bool test_wrapping(void) {
BEGIN_TEST;
size_t bytes_read;
unsigned char buffer[4];
uint ptr = 0;
wipe_fs();
flash_nor_begin(0);
write_block_header(&ptr);
flash_nor_write(0, ptr, sizeof(good_object), good_object);
ptr = FLASH_PAGE_SIZE;
write_block_header(&ptr);
flash_nor_write(0, ptr, sizeof(good_object_v127), good_object_v127);
flash_nor_end(0);
norfs_mount_fs(norfs_nvram_offset);
EXPECT_EQ(NO_ERROR, norfs_read_obj(2, buffer, sizeof(buffer), &bytes_read, 0),
"Error during read");
for (int i = 0; i < 4; i++) {
EXPECT_EQ(*(buffer + i), *(good_object_v127 + NORFS_OBJ_OFFSET + i),
"Object not read correctly");
}
wipe_fs();
flash_nor_begin(0);
ptr = 0;
write_block_header(&ptr);
flash_nor_write(0, ptr, sizeof(good_object), good_object);
ptr = FLASH_PAGE_SIZE;
write_block_header(&ptr);
flash_nor_write(0, ptr, sizeof(good_object_v128), good_object_v128);
flash_nor_end(0);
norfs_mount_fs(norfs_nvram_offset);
EXPECT_EQ(NO_ERROR, norfs_read_obj(2, buffer, sizeof(buffer), &bytes_read,
0),
"Error during read");
for (int i = 0; i < 4; i++) {
EXPECT_EQ(*(buffer + i), *(good_object + NORFS_OBJ_OFFSET + i),
"Object not read correctly when wrapped");
}
wipe_fs();
END_TEST;
}
static void init_tests(void) {
platform_init();
wipe_fs();
}
BEGIN_TEST_CASE(norfs_tests);
init_tests();
RUN_TEST(test_basic_read_write);
RUN_TEST(test_garbage_collection);
RUN_TEST(test_deletion);
RUN_TEST(test_corruption);
RUN_TEST(test_deletion_objects_retained_during_gc);
RUN_TEST(test_garbage_collection_interruption);
RUN_TEST(test_total_remaining_space);
RUN_TEST(test_thrash_fs);
RUN_TEST(test_wrapping);
RUN_TEST(test_overflow_filesystem);
END_TEST_CASE(norfs_tests);
|
72aa468c6acb1260771d37f05d754f766635738b
|
f7dc806f341ef5dbb0e11252a4693003a66853d5
|
/thirdparty/icu4c/common/unicode/utext.h
|
423b281631db65a0c5d002ae7265cf1a58ccddf2
|
[
"LicenseRef-scancode-free-unknown",
"MIT",
"CC-BY-4.0",
"OFL-1.1",
"Bison-exception-2.2",
"CC0-1.0",
"LicenseRef-scancode-nvidia-2002",
"LicenseRef-scancode-other-permissive",
"GPL-3.0-only",
"LicenseRef-scancode-unknown-license-reference",
"Unlicense",
"BSL-1.0",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unicode",
"BSD-2-Clause",
"FTL",
"GPL-3.0-or-later",
"Bitstream-Vera",
"Zlib",
"MPL-2.0",
"MIT-Modern-Variant",
"JSON",
"Libpng",
"ICU",
"NTP",
"NAIST-2003",
"GPL-2.0-or-later",
"LicenseRef-scancode-autoconf-simple-exception",
"Autoconf-exception-generic"
] |
permissive
|
godotengine/godot
|
8a2419750f4851d1426a8f3bcb52cac5c86f23c2
|
970be7afdc111ccc7459d7ef3560de70e6d08c80
|
refs/heads/master
| 2023-08-21T14:37:00.262883
| 2023-08-21T06:26:15
| 2023-08-21T06:26:15
| 15,634,981
| 68,852
| 18,388
|
MIT
| 2023-09-14T21:42:16
| 2014-01-04T16:05:36
|
C++
|
UTF-8
|
C
| false
| false
| 59,495
|
h
|
utext.h
|
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2004-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: utext.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 2004oct06
* created by: Markus W. Scherer
*/
#ifndef __UTEXT_H__
#define __UTEXT_H__
/**
* \file
* \brief C API: Abstract Unicode Text API
*
* The Text Access API provides a means to allow text that is stored in alternative
* formats to work with ICU services. ICU normally operates on text that is
* stored in UTF-16 format, in (UChar *) arrays for the C APIs or as type
* UnicodeString for C++ APIs.
*
* ICU Text Access allows other formats, such as UTF-8 or non-contiguous
* UTF-16 strings, to be placed in a UText wrapper and then passed to ICU services.
*
* There are three general classes of usage for UText:
*
* Application Level Use. This is the simplest usage - applications would
* use one of the utext_open() functions on their input text, and pass
* the resulting UText to the desired ICU service.
*
* Second is usage in ICU Services, such as break iteration, that will need to
* operate on input presented to them as a UText. These implementations
* will need to use the iteration and related UText functions to gain
* access to the actual text.
*
* The third class of UText users are "text providers." These are the
* UText implementations for the various text storage formats. An application
* or system with a unique text storage format can implement a set of
* UText provider functions for that format, which will then allow
* ICU services to operate on that format.
*
*
* <em>Iterating over text</em>
*
* Here is sample code for a forward iteration over the contents of a UText
*
* \code
* UChar32 c;
* UText *ut = whatever();
*
* for (c=utext_next32From(ut, 0); c>=0; c=utext_next32(ut)) {
* // do whatever with the codepoint c here.
* }
* \endcode
*
* And here is similar code to iterate in the reverse direction, from the end
* of the text towards the beginning.
*
* \code
* UChar32 c;
* UText *ut = whatever();
* int textLength = utext_nativeLength(ut);
* for (c=utext_previous32From(ut, textLength); c>=0; c=utext_previous32(ut)) {
* // do whatever with the codepoint c here.
* }
* \endcode
*
* <em>Characters and Indexing</em>
*
* Indexing into text by UText functions is nearly always in terms of the native
* indexing of the underlying text storage. The storage format could be UTF-8
* or UTF-32, for example. When coding to the UText access API, no assumptions
* can be made regarding the size of characters, or how far an index
* may move when iterating between characters.
*
* All indices supplied to UText functions are pinned to the length of the
* text. An out-of-bounds index is not considered to be an error, but is
* adjusted to be in the range 0 <= index <= length of input text.
*
*
* When an index position is returned from a UText function, it will be
* a native index to the underlying text. In the case of multi-unit characters,
* it will always refer to the first position of the character,
* never to the interior. This is essentially the same thing as saying that
* a returned index will always point to a boundary between characters.
*
* When a native index is supplied to a UText function, all indices that
* refer to any part of a multi-unit character representation are considered
* to be equivalent. In the case of multi-unit characters, an incoming index
* will be logically normalized to refer to the start of the character.
*
* It is possible to test whether a native index is on a code point boundary
* by doing a utext_setNativeIndex() followed by a utext_getNativeIndex().
* If the index is returned unchanged, it was on a code point boundary. If
* an adjusted index is returned, the original index referred to the
* interior of a character.
*
* <em>Conventions for calling UText functions</em>
*
* Most UText access functions have as their first parameter a (UText *) pointer,
* which specifies the UText to be used. Unless otherwise noted, the
* pointer must refer to a valid, open UText. Attempting to
* use a closed UText or passing a NULL pointer is a programming error and
* will produce undefined results or NULL pointer exceptions.
*
* The UText_Open family of functions can either open an existing (closed)
* UText, or heap allocate a new UText. Here is sample code for creating
* a stack-allocated UText.
*
* \code
* char *s = whatever(); // A utf-8 string
* U_ErrorCode status = U_ZERO_ERROR;
* UText ut = UTEXT_INITIALIZER;
* utext_openUTF8(ut, s, -1, &status);
* if (U_FAILURE(status)) {
* // error handling
* } else {
* // work with the UText
* }
* \endcode
*
* Any existing UText passed to an open function _must_ have been initialized,
* either by the UTEXT_INITIALIZER, or by having been originally heap-allocated
* by an open function. Passing NULL will cause the open function to
* heap-allocate and fully initialize a new UText.
*
*/
#include "unicode/utypes.h"
#include "unicode/uchar.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#include "unicode/rep.h"
#include "unicode/unistr.h"
#include "unicode/chariter.h"
#endif
U_CDECL_BEGIN
struct UText;
typedef struct UText UText; /**< C typedef for struct UText. @stable ICU 3.6 */
/***************************************************************************************
*
* C Functions for creating UText wrappers around various kinds of text strings.
*
****************************************************************************************/
/**
* Close function for UText instances.
* Cleans up, releases any resources being held by an open UText.
* <p>
* If the UText was originally allocated by one of the utext_open functions,
* the storage associated with the utext will also be freed.
* If the UText storage originated with the application, as it would with
* a local or static instance, the storage will not be deleted.
*
* An open UText can be reset to refer to new string by using one of the utext_open()
* functions without first closing the UText.
*
* @param ut The UText to be closed.
* @return NULL if the UText struct was deleted by the close. If the UText struct
* was originally provided by the caller to the open function, it is
* returned by this function, and may be safely used again in
* a subsequent utext_open.
*
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_close(UText *ut);
/**
* Open a read-only UText implementation for UTF-8 strings.
*
* \htmlonly
* Any invalid UTF-8 in the input will be handled in this way:
* a sequence of bytes that has the form of a truncated, but otherwise valid,
* UTF-8 sequence will be replaced by a single unicode replacement character, \uFFFD.
* Any other illegal bytes will each be replaced by a \uFFFD.
* \endhtmlonly
*
* @param ut Pointer to a UText struct. If NULL, a new UText will be created.
* If non-NULL, must refer to an initialized UText struct, which will then
* be reset to reference the specified UTF-8 string.
* @param s A UTF-8 string. Must not be NULL.
* @param length The length of the UTF-8 string in bytes, or -1 if the string is
* zero terminated.
* @param status Errors are returned here.
* @return A pointer to the UText. If a pre-allocated UText was provided, it
* will always be used and returned.
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);
/**
* Open a read-only UText for UChar * string.
*
* @param ut Pointer to a UText struct. If NULL, a new UText will be created.
* If non-NULL, must refer to an initialized UText struct, which will then
* be reset to reference the specified UChar string.
* @param s A UChar (UTF-16) string
* @param length The number of UChars in the input string, or -1 if the string is
* zero terminated.
* @param status Errors are returned here.
* @return A pointer to the UText. If a pre-allocated UText was provided, it
* will always be used and returned.
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);
#if U_SHOW_CPLUSPLUS_API
/**
* Open a writable UText for a non-const UnicodeString.
*
* @param ut Pointer to a UText struct. If nullptr, a new UText will be created.
* If non-nullptr, must refer to an initialized UText struct, which will then
* be reset to reference the specified input string.
* @param s A UnicodeString.
* @param status Errors are returned here.
* @return Pointer to the UText. If a UText was supplied as input, this
* will always be used and returned.
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_openUnicodeString(UText *ut, icu::UnicodeString *s, UErrorCode *status);
/**
* Open a UText for a const UnicodeString. The resulting UText will not be writable.
*
* @param ut Pointer to a UText struct. If nullptr, a new UText will be created.
* If non-nullptr, must refer to an initialized UText struct, which will then
* be reset to reference the specified input string.
* @param s A const UnicodeString to be wrapped.
* @param status Errors are returned here.
* @return Pointer to the UText. If a UText was supplied as input, this
* will always be used and returned.
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_openConstUnicodeString(UText *ut, const icu::UnicodeString *s, UErrorCode *status);
/**
* Open a writable UText implementation for an ICU Replaceable object.
* @param ut Pointer to a UText struct. If nullptr, a new UText will be created.
* If non-nullptr, must refer to an already existing UText, which will then
* be reset to reference the specified replaceable text.
* @param rep A Replaceable text object.
* @param status Errors are returned here.
* @return Pointer to the UText. If a UText was supplied as input, this
* will always be used and returned.
* @see Replaceable
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_openReplaceable(UText *ut, icu::Replaceable *rep, UErrorCode *status);
/**
* Open a UText implementation over an ICU CharacterIterator.
* @param ut Pointer to a UText struct. If nullptr, a new UText will be created.
* If non-nullptr, must refer to an already existing UText, which will then
* be reset to reference the specified replaceable text.
* @param ci A Character Iterator.
* @param status Errors are returned here.
* @return Pointer to the UText. If a UText was supplied as input, this
* will always be used and returned.
* @see Replaceable
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *status);
#endif
/**
* Clone a UText. This is much like opening a UText where the source text is itself
* another UText.
*
* A deep clone will copy both the UText data structures and the underlying text.
* The original and cloned UText will operate completely independently; modifications
* made to the text in one will not affect the other. Text providers are not
* required to support deep clones. The user of clone() must check the status return
* and be prepared to handle failures.
*
* The standard UText implementations for UTF8, UChar *, UnicodeString and
* Replaceable all support deep cloning.
*
* The UText returned from a deep clone will be writable, assuming that the text
* provider is able to support writing, even if the source UText had been made
* non-writable by means of UText_freeze().
*
* A shallow clone replicates only the UText data structures; it does not make
* a copy of the underlying text. Shallow clones can be used as an efficient way to
* have multiple iterators active in a single text string that is not being
* modified.
*
* A shallow clone operation will not fail, barring truly exceptional conditions such
* as memory allocation failures.
*
* Shallow UText clones should be avoided if the UText functions that modify the
* text are expected to be used, either on the original or the cloned UText.
* Any such modifications can cause unpredictable behavior. Read Only
* shallow clones provide some protection against errors of this type by
* disabling text modification via the cloned UText.
*
* A shallow clone made with the readOnly parameter == false will preserve the
* utext_isWritable() state of the source object. Note, however, that
* write operations must be avoided while more than one UText exists that refer
* to the same underlying text.
*
* A UText and its clone may be safely concurrently accessed by separate threads.
* This is true for read access only with shallow clones, and for both read and
* write access with deep clones.
* It is the responsibility of the Text Provider to ensure that this thread safety
* constraint is met.
*
* @param dest A UText struct to be filled in with the result of the clone operation,
* or NULL if the clone function should heap-allocate a new UText struct.
* If non-NULL, must refer to an already existing UText, which will then
* be reset to become the clone.
* @param src The UText to be cloned.
* @param deep true to request a deep clone, false for a shallow clone.
* @param readOnly true to request that the cloned UText have read only access to the
* underlying text.
* @param status Errors are returned here. For deep clones, U_UNSUPPORTED_ERROR
* will be returned if the text provider is unable to clone the
* original text.
* @return The newly created clone, or NULL if the clone operation failed.
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status);
/**
* Compare two UText objects for equality.
* UTexts are equal if they are iterating over the same text, and
* have the same iteration position within the text.
* If either or both of the parameters are NULL, the comparison is false.
*
* @param a The first of the two UTexts to compare.
* @param b The other UText to be compared.
* @return true if the two UTexts are equal.
* @stable ICU 3.6
*/
U_CAPI UBool U_EXPORT2
utext_equals(const UText *a, const UText *b);
/*****************************************************************************
*
* Functions to work with the text represented by a UText wrapper
*
*****************************************************************************/
/**
* Get the length of the text. Depending on the characteristics
* of the underlying text representation, this may be expensive.
* @see utext_isLengthExpensive()
*
*
* @param ut the text to be accessed.
* @return the length of the text, expressed in native units.
*
* @stable ICU 3.4
*/
U_CAPI int64_t U_EXPORT2
utext_nativeLength(UText *ut);
/**
* Return true if calculating the length of the text could be expensive.
* Finding the length of NUL terminated strings is considered to be expensive.
*
* Note that the value of this function may change
* as the result of other operations on a UText.
* Once the length of a string has been discovered, it will no longer
* be expensive to report it.
*
* @param ut the text to be accessed.
* @return true if determining the length of the text could be time consuming.
* @stable ICU 3.4
*/
U_CAPI UBool U_EXPORT2
utext_isLengthExpensive(const UText *ut);
/**
* Returns the code point at the requested index,
* or U_SENTINEL (-1) if it is out of bounds.
*
* If the specified index points to the interior of a multi-unit
* character - one of the trail bytes of a UTF-8 sequence, for example -
* the complete code point will be returned.
*
* The iteration position will be set to the start of the returned code point.
*
* This function is roughly equivalent to the sequence
* utext_setNativeIndex(index);
* utext_current32();
* (There is a subtle difference if the index is out of bounds by being less than zero -
* utext_setNativeIndex(negative value) sets the index to zero, after which utext_current()
* will return the char at zero. utext_char32At(negative index), on the other hand, will
* return the U_SENTINEL value of -1.)
*
* @param ut the text to be accessed
* @param nativeIndex the native index of the character to be accessed. If the index points
* to other than the first unit of a multi-unit character, it will be adjusted
* to the start of the character.
* @return the code point at the specified index.
* @stable ICU 3.4
*/
U_CAPI UChar32 U_EXPORT2
utext_char32At(UText *ut, int64_t nativeIndex);
/**
*
* Get the code point at the current iteration position,
* or U_SENTINEL (-1) if the iteration has reached the end of
* the input text.
*
* @param ut the text to be accessed.
* @return the Unicode code point at the current iterator position.
* @stable ICU 3.4
*/
U_CAPI UChar32 U_EXPORT2
utext_current32(UText *ut);
/**
* Get the code point at the current iteration position of the UText, and
* advance the position to the first index following the character.
*
* If the position is at the end of the text (the index following
* the last character, which is also the length of the text),
* return U_SENTINEL (-1) and do not advance the index.
*
* This is a post-increment operation.
*
* An inline macro version of this function, UTEXT_NEXT32(),
* is available for performance critical use.
*
* @param ut the text to be accessed.
* @return the Unicode code point at the iteration position.
* @see UTEXT_NEXT32
* @stable ICU 3.4
*/
U_CAPI UChar32 U_EXPORT2
utext_next32(UText *ut);
/**
* Move the iterator position to the character (code point) whose
* index precedes the current position, and return that character.
* This is a pre-decrement operation.
*
* If the initial position is at the start of the text (index of 0)
* return U_SENTINEL (-1), and leave the position unchanged.
*
* An inline macro version of this function, UTEXT_PREVIOUS32(),
* is available for performance critical use.
*
* @param ut the text to be accessed.
* @return the previous UChar32 code point, or U_SENTINEL (-1)
* if the iteration has reached the start of the text.
* @see UTEXT_PREVIOUS32
* @stable ICU 3.4
*/
U_CAPI UChar32 U_EXPORT2
utext_previous32(UText *ut);
/**
* Set the iteration index and return the code point at that index.
* Leave the iteration index at the start of the following code point.
*
* This function is the most efficient and convenient way to
* begin a forward iteration. The results are identical to the those
* from the sequence
* \code
* utext_setIndex();
* utext_next32();
* \endcode
*
* @param ut the text to be accessed.
* @param nativeIndex Iteration index, in the native units of the text provider.
* @return Code point which starts at or before index,
* or U_SENTINEL (-1) if it is out of bounds.
* @stable ICU 3.4
*/
U_CAPI UChar32 U_EXPORT2
utext_next32From(UText *ut, int64_t nativeIndex);
/**
* Set the iteration index, and return the code point preceding the
* one specified by the initial index. Leave the iteration position
* at the start of the returned code point.
*
* This function is the most efficient and convenient way to
* begin a backwards iteration.
*
* @param ut the text to be accessed.
* @param nativeIndex Iteration index in the native units of the text provider.
* @return Code point preceding the one at the initial index,
* or U_SENTINEL (-1) if it is out of bounds.
*
* @stable ICU 3.4
*/
U_CAPI UChar32 U_EXPORT2
utext_previous32From(UText *ut, int64_t nativeIndex);
/**
* Get the current iterator position, which can range from 0 to
* the length of the text.
* The position is a native index into the input text, in whatever format it
* may have (possibly UTF-8 for example), and may not always be the same as
* the corresponding UChar (UTF-16) index.
* The returned position will always be aligned to a code point boundary.
*
* @param ut the text to be accessed.
* @return the current index position, in the native units of the text provider.
* @stable ICU 3.4
*/
U_CAPI int64_t U_EXPORT2
utext_getNativeIndex(const UText *ut);
/**
* Set the current iteration position to the nearest code point
* boundary at or preceding the specified index.
* The index is in the native units of the original input text.
* If the index is out of range, it will be pinned to be within
* the range of the input text.
* <p>
* It will usually be more efficient to begin an iteration
* using the functions utext_next32From() or utext_previous32From()
* rather than setIndex().
* <p>
* Moving the index position to an adjacent character is best done
* with utext_next32(), utext_previous32() or utext_moveIndex32().
* Attempting to do direct arithmetic on the index position is
* complicated by the fact that the size (in native units) of a
* character depends on the underlying representation of the character
* (UTF-8, UTF-16, UTF-32, arbitrary codepage), and is not
* easily knowable.
*
* @param ut the text to be accessed.
* @param nativeIndex the native unit index of the new iteration position.
* @stable ICU 3.4
*/
U_CAPI void U_EXPORT2
utext_setNativeIndex(UText *ut, int64_t nativeIndex);
/**
* Move the iterator position by delta code points. The number of code points
* is a signed number; a negative delta will move the iterator backwards,
* towards the start of the text.
* <p>
* The index is moved by <code>delta</code> code points
* forward or backward, but no further backward than to 0 and
* no further forward than to utext_nativeLength().
* The resulting index value will be in between 0 and length, inclusive.
*
* @param ut the text to be accessed.
* @param delta the signed number of code points to move the iteration position.
* @return true if the position could be moved the requested number of positions while
* staying within the range [0 - text length].
* @stable ICU 3.4
*/
U_CAPI UBool U_EXPORT2
utext_moveIndex32(UText *ut, int32_t delta);
/**
* Get the native index of the character preceding the current position.
* If the iteration position is already at the start of the text, zero
* is returned.
* The value returned is the same as that obtained from the following sequence,
* but without the side effect of changing the iteration position.
*
* \code
* UText *ut = whatever;
* ...
* utext_previous(ut)
* utext_getNativeIndex(ut);
* \endcode
*
* This function is most useful during forwards iteration, where it will get the
* native index of the character most recently returned from utext_next().
*
* @param ut the text to be accessed
* @return the native index of the character preceding the current index position,
* or zero if the current position is at the start of the text.
* @stable ICU 3.6
*/
U_CAPI int64_t U_EXPORT2
utext_getPreviousNativeIndex(UText *ut);
/**
*
* Extract text from a UText into a UChar buffer. The range of text to be extracted
* is specified in the native indices of the UText provider. These may not necessarily
* be UTF-16 indices.
* <p>
* The size (number of 16 bit UChars) of the data to be extracted is returned. The
* full number of UChars is returned, even when the extracted text is truncated
* because the specified buffer size is too small.
* <p>
* The extracted string will (if you are a user) / must (if you are a text provider)
* be NUL-terminated if there is sufficient space in the destination buffer. This
* terminating NUL is not included in the returned length.
* <p>
* The iteration index is left at the position following the last extracted character.
*
* @param ut the UText from which to extract data.
* @param nativeStart the native index of the first character to extract.\
* If the specified index is out of range,
* it will be pinned to be within 0 <= index <= textLength
* @param nativeLimit the native string index of the position following the last
* character to extract. If the specified index is out of range,
* it will be pinned to be within 0 <= index <= textLength.
* nativeLimit must be >= nativeStart.
* @param dest the UChar (UTF-16) buffer into which the extracted text is placed
* @param destCapacity The size, in UChars, of the destination buffer. May be zero
* for precomputing the required size.
* @param status receives any error status.
* U_BUFFER_OVERFLOW_ERROR: the extracted text was truncated because the
* buffer was too small. Returns number of UChars for preflighting.
* @return Number of UChars in the data to be extracted. Does not include a trailing NUL.
*
* @stable ICU 3.4
*/
U_CAPI int32_t U_EXPORT2
utext_extract(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
UChar *dest, int32_t destCapacity,
UErrorCode *status);
/************************************************************************************
*
* #define inline versions of selected performance-critical text access functions
* Caution: do not use auto increment++ or decrement-- expressions
* as parameters to these macros.
*
* For most use, where there is no extreme performance constraint, the
* normal, non-inline functions are a better choice. The resulting code
* will be smaller, and, if the need ever arises, easier to debug.
*
* These are implemented as #defines rather than real functions
* because there is no fully portable way to do inline functions in plain C.
*
************************************************************************************/
#ifndef U_HIDE_INTERNAL_API
/**
* inline version of utext_current32(), for performance-critical situations.
*
* Get the code point at the current iteration position of the UText.
* Returns U_SENTINEL (-1) if the position is at the end of the
* text.
*
* @internal ICU 4.4 technology preview
*/
#define UTEXT_CURRENT32(ut) \
((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \
((ut)->chunkContents)[((ut)->chunkOffset)] : utext_current32(ut))
#endif /* U_HIDE_INTERNAL_API */
/**
* inline version of utext_next32(), for performance-critical situations.
*
* Get the code point at the current iteration position of the UText, and
* advance the position to the first index following the character.
* This is a post-increment operation.
* Returns U_SENTINEL (-1) if the position is at the end of the
* text.
*
* @stable ICU 3.4
*/
#define UTEXT_NEXT32(ut) \
((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \
((ut)->chunkContents)[((ut)->chunkOffset)++] : utext_next32(ut))
/**
* inline version of utext_previous32(), for performance-critical situations.
*
* Move the iterator position to the character (code point) whose
* index precedes the current position, and return that character.
* This is a pre-decrement operation.
* Returns U_SENTINEL (-1) if the position is at the start of the text.
*
* @stable ICU 3.4
*/
#define UTEXT_PREVIOUS32(ut) \
((ut)->chunkOffset > 0 && \
(ut)->chunkContents[(ut)->chunkOffset-1] < 0xd800 ? \
(ut)->chunkContents[--((ut)->chunkOffset)] : utext_previous32(ut))
/**
* inline version of utext_getNativeIndex(), for performance-critical situations.
*
* Get the current iterator position, which can range from 0 to
* the length of the text.
* The position is a native index into the input text, in whatever format it
* may have (possibly UTF-8 for example), and may not always be the same as
* the corresponding UChar (UTF-16) index.
* The returned position will always be aligned to a code point boundary.
*
* @stable ICU 3.6
*/
#define UTEXT_GETNATIVEINDEX(ut) \
((ut)->chunkOffset <= (ut)->nativeIndexingLimit? \
(ut)->chunkNativeStart+(ut)->chunkOffset : \
(ut)->pFuncs->mapOffsetToNative(ut))
/**
* inline version of utext_setNativeIndex(), for performance-critical situations.
*
* Set the current iteration position to the nearest code point
* boundary at or preceding the specified index.
* The index is in the native units of the original input text.
* If the index is out of range, it will be pinned to be within
* the range of the input text.
*
* @stable ICU 3.8
*/
#define UTEXT_SETNATIVEINDEX(ut, ix) UPRV_BLOCK_MACRO_BEGIN { \
int64_t __offset = (ix) - (ut)->chunkNativeStart; \
if (__offset>=0 && __offset<(int64_t)(ut)->nativeIndexingLimit && (ut)->chunkContents[__offset]<0xdc00) { \
(ut)->chunkOffset=(int32_t)__offset; \
} else { \
utext_setNativeIndex((ut), (ix)); \
} \
} UPRV_BLOCK_MACRO_END
/************************************************************************************
*
* Functions related to writing or modifying the text.
* These will work only with modifiable UTexts. Attempting to
* modify a read-only UText will return an error status.
*
************************************************************************************/
/**
* Return true if the text can be written (modified) with utext_replace() or
* utext_copy(). For the text to be writable, the text provider must
* be of a type that supports writing and the UText must not be frozen.
*
* Attempting to modify text when utext_isWriteable() is false will fail -
* the text will not be modified, and an error will be returned from the function
* that attempted the modification.
*
* @param ut the UText to be tested.
* @return true if the text is modifiable.
*
* @see utext_freeze()
* @see utext_replace()
* @see utext_copy()
* @stable ICU 3.4
*
*/
U_CAPI UBool U_EXPORT2
utext_isWritable(const UText *ut);
/**
* Test whether there is meta data associated with the text.
* @see Replaceable::hasMetaData()
*
* @param ut The UText to be tested
* @return true if the underlying text includes meta data.
* @stable ICU 3.4
*/
U_CAPI UBool U_EXPORT2
utext_hasMetaData(const UText *ut);
/**
* Replace a range of the original text with a replacement text.
*
* Leaves the current iteration position at the position following the
* newly inserted replacement text.
*
* This function is only available on UText types that support writing,
* that is, ones where utext_isWritable() returns true.
*
* When using this function, there should be only a single UText opened onto the
* underlying native text string. Behavior after a replace operation
* on a UText is undefined for any other additional UTexts that refer to the
* modified string.
*
* @param ut the UText representing the text to be operated on.
* @param nativeStart the native index of the start of the region to be replaced
* @param nativeLimit the native index of the character following the region to be replaced.
* @param replacementText pointer to the replacement text
* @param replacementLength length of the replacement text, or -1 if the text is NUL terminated.
* @param status receives any error status. Possible errors include
* U_NO_WRITE_PERMISSION
*
* @return The signed number of (native) storage units by which
* the length of the text expanded or contracted.
*
* @stable ICU 3.4
*/
U_CAPI int32_t U_EXPORT2
utext_replace(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
const UChar *replacementText, int32_t replacementLength,
UErrorCode *status);
/**
*
* Copy or move a substring from one position to another within the text,
* while retaining any metadata associated with the text.
* This function is used to duplicate or reorder substrings.
* The destination index must not overlap the source range.
*
* The text to be copied or moved is inserted at destIndex;
* it does not replace or overwrite any existing text.
*
* The iteration position is left following the newly inserted text
* at the destination position.
*
* This function is only available on UText types that support writing,
* that is, ones where utext_isWritable() returns true.
*
* When using this function, there should be only a single UText opened onto the
* underlying native text string. Behavior after a copy operation
* on a UText is undefined in any other additional UTexts that refer to the
* modified string.
*
* @param ut The UText representing the text to be operated on.
* @param nativeStart The native index of the start of the region to be copied or moved
* @param nativeLimit The native index of the character position following the region
* to be copied.
* @param destIndex The native destination index to which the source substring is
* copied or moved.
* @param move If true, then the substring is moved, not copied/duplicated.
* @param status receives any error status. Possible errors include U_NO_WRITE_PERMISSION
*
* @stable ICU 3.4
*/
U_CAPI void U_EXPORT2
utext_copy(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
int64_t destIndex,
UBool move,
UErrorCode *status);
/**
* <p>
* Freeze a UText. This prevents any modification to the underlying text itself
* by means of functions operating on this UText.
* </p>
* <p>
* Once frozen, a UText can not be unfrozen. The intent is to ensure
* that a the text underlying a frozen UText wrapper cannot be modified via that UText.
* </p>
* <p>
* Caution: freezing a UText will disable changes made via the specific
* frozen UText wrapper only; it will not have any effect on the ability to
* directly modify the text by bypassing the UText. Any such backdoor modifications
* are always an error while UText access is occurring because the underlying
* text can get out of sync with UText's buffering.
* </p>
*
* @param ut The UText to be frozen.
* @see utext_isWritable()
* @stable ICU 3.6
*/
U_CAPI void U_EXPORT2
utext_freeze(UText *ut);
/**
* UText provider properties (bit field indexes).
*
* @see UText
* @stable ICU 3.4
*/
enum {
/**
* It is potentially time consuming for the provider to determine the length of the text.
* @stable ICU 3.4
*/
UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1,
/**
* Text chunks remain valid and usable until the text object is modified or
* deleted, not just until the next time the access() function is called
* (which is the default).
* @stable ICU 3.4
*/
UTEXT_PROVIDER_STABLE_CHUNKS = 2,
/**
* The provider supports modifying the text via the replace() and copy()
* functions.
* @see Replaceable
* @stable ICU 3.4
*/
UTEXT_PROVIDER_WRITABLE = 3,
/**
* There is meta data associated with the text.
* @see Replaceable::hasMetaData()
* @stable ICU 3.4
*/
UTEXT_PROVIDER_HAS_META_DATA = 4,
/**
* Text provider owns the text storage.
* Generally occurs as the result of a deep clone of the UText.
* When closing the UText, the associated text must
* also be closed/deleted/freed/ whatever is appropriate.
* @stable ICU 3.6
*/
UTEXT_PROVIDER_OWNS_TEXT = 5
};
/**
* Function type declaration for UText.clone().
*
* clone a UText. Much like opening a UText where the source text is itself
* another UText.
*
* A deep clone will copy both the UText data structures and the underlying text.
* The original and cloned UText will operate completely independently; modifications
* made to the text in one will not effect the other. Text providers are not
* required to support deep clones. The user of clone() must check the status return
* and be prepared to handle failures.
*
* A shallow clone replicates only the UText data structures; it does not make
* a copy of the underlying text. Shallow clones can be used as an efficient way to
* have multiple iterators active in a single text string that is not being
* modified.
*
* A shallow clone operation must not fail except for truly exceptional conditions such
* as memory allocation failures.
*
* A UText and its clone may be safely concurrently accessed by separate threads.
* This is true for both shallow and deep clones.
* It is the responsibility of the Text Provider to ensure that this thread safety
* constraint is met.
*
* @param dest A UText struct to be filled in with the result of the clone operation,
* or NULL if the clone function should heap-allocate a new UText struct.
* @param src The UText to be cloned.
* @param deep true to request a deep clone, false for a shallow clone.
* @param status Errors are returned here. For deep clones, U_UNSUPPORTED_ERROR
* should be returned if the text provider is unable to clone the
* original text.
* @return The newly created clone, or NULL if the clone operation failed.
*
* @stable ICU 3.4
*/
typedef UText * U_CALLCONV
UTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status);
/**
* Function type declaration for UText.nativeLength().
*
* @param ut the UText to get the length of.
* @return the length, in the native units of the original text string.
* @see UText
* @stable ICU 3.4
*/
typedef int64_t U_CALLCONV
UTextNativeLength(UText *ut);
/**
* Function type declaration for UText.access(). Get the description of the text chunk
* containing the text at a requested native index. The UText's iteration
* position will be left at the requested index. If the index is out
* of bounds, the iteration position will be left at the start or end
* of the string, as appropriate.
*
* Chunks must begin and end on code point boundaries. A single code point
* comprised of multiple storage units must never span a chunk boundary.
*
*
* @param ut the UText being accessed.
* @param nativeIndex Requested index of the text to be accessed.
* @param forward If true, then the returned chunk must contain text
* starting from the index, so that start<=index<limit.
* If false, then the returned chunk must contain text
* before the index, so that start<index<=limit.
* @return True if the requested index could be accessed. The chunk
* will contain the requested text.
* False value if a chunk cannot be accessed
* (the requested index is out of bounds).
*
* @see UText
* @stable ICU 3.4
*/
typedef UBool U_CALLCONV
UTextAccess(UText *ut, int64_t nativeIndex, UBool forward);
/**
* Function type declaration for UText.extract().
*
* Extract text from a UText into a UChar buffer. The range of text to be extracted
* is specified in the native indices of the UText provider. These may not necessarily
* be UTF-16 indices.
* <p>
* The size (number of 16 bit UChars) in the data to be extracted is returned. The
* full amount is returned, even when the specified buffer size is smaller.
* <p>
* The extracted string will (if you are a user) / must (if you are a text provider)
* be NUL-terminated if there is sufficient space in the destination buffer.
*
* @param ut the UText from which to extract data.
* @param nativeStart the native index of the first character to extract.
* @param nativeLimit the native string index of the position following the last
* character to extract.
* @param dest the UChar (UTF-16) buffer into which the extracted text is placed
* @param destCapacity The size, in UChars, of the destination buffer. May be zero
* for precomputing the required size.
* @param status receives any error status.
* If U_BUFFER_OVERFLOW_ERROR: Returns number of UChars for
* preflighting.
* @return Number of UChars in the data. Does not include a trailing NUL.
*
* @stable ICU 3.4
*/
typedef int32_t U_CALLCONV
UTextExtract(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
UChar *dest, int32_t destCapacity,
UErrorCode *status);
/**
* Function type declaration for UText.replace().
*
* Replace a range of the original text with a replacement text.
*
* Leaves the current iteration position at the position following the
* newly inserted replacement text.
*
* This function need only be implemented on UText types that support writing.
*
* When using this function, there should be only a single UText opened onto the
* underlying native text string. The function is responsible for updating the
* text chunk within the UText to reflect the updated iteration position,
* taking into account any changes to the underlying string's structure caused
* by the replace operation.
*
* @param ut the UText representing the text to be operated on.
* @param nativeStart the index of the start of the region to be replaced
* @param nativeLimit the index of the character following the region to be replaced.
* @param replacementText pointer to the replacement text
* @param replacmentLength length of the replacement text in UChars, or -1 if the text is NUL terminated.
* @param status receives any error status. Possible errors include
* U_NO_WRITE_PERMISSION
*
* @return The signed number of (native) storage units by which
* the length of the text expanded or contracted.
*
* @stable ICU 3.4
*/
typedef int32_t U_CALLCONV
UTextReplace(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
const UChar *replacementText, int32_t replacmentLength,
UErrorCode *status);
/**
* Function type declaration for UText.copy().
*
* Copy or move a substring from one position to another within the text,
* while retaining any metadata associated with the text.
* This function is used to duplicate or reorder substrings.
* The destination index must not overlap the source range.
*
* The text to be copied or moved is inserted at destIndex;
* it does not replace or overwrite any existing text.
*
* This function need only be implemented for UText types that support writing.
*
* When using this function, there should be only a single UText opened onto the
* underlying native text string. The function is responsible for updating the
* text chunk within the UText to reflect the updated iteration position,
* taking into account any changes to the underlying string's structure caused
* by the replace operation.
*
* @param ut The UText representing the text to be operated on.
* @param nativeStart The index of the start of the region to be copied or moved
* @param nativeLimit The index of the character following the region to be replaced.
* @param nativeDest The destination index to which the source substring is copied or moved.
* @param move If true, then the substring is moved, not copied/duplicated.
* @param status receives any error status. Possible errors include U_NO_WRITE_PERMISSION
*
* @stable ICU 3.4
*/
typedef void U_CALLCONV
UTextCopy(UText *ut,
int64_t nativeStart, int64_t nativeLimit,
int64_t nativeDest,
UBool move,
UErrorCode *status);
/**
* Function type declaration for UText.mapOffsetToNative().
* Map from the current UChar offset within the current text chunk to
* the corresponding native index in the original source text.
*
* This is required only for text providers that do not use native UTF-16 indexes.
*
* @param ut the UText.
* @return Absolute (native) index corresponding to chunkOffset in the current chunk.
* The returned native index should always be to a code point boundary.
*
* @stable ICU 3.4
*/
typedef int64_t U_CALLCONV
UTextMapOffsetToNative(const UText *ut);
/**
* Function type declaration for UText.mapIndexToUTF16().
* Map from a native index to a UChar offset within a text chunk.
* Behavior is undefined if the native index does not fall within the
* current chunk.
*
* This function is required only for text providers that do not use native UTF-16 indexes.
*
* @param ut The UText containing the text chunk.
* @param nativeIndex Absolute (native) text index, chunk->start<=index<=chunk->limit.
* @return Chunk-relative UTF-16 offset corresponding to the specified native
* index.
*
* @stable ICU 3.4
*/
typedef int32_t U_CALLCONV
UTextMapNativeIndexToUTF16(const UText *ut, int64_t nativeIndex);
/**
* Function type declaration for UText.utextClose().
*
* A Text Provider close function is only required for provider types that make
* allocations in their open function (or other functions) that must be
* cleaned when the UText is closed.
*
* The allocation of the UText struct itself and any "extra" storage
* associated with the UText is handled by the common UText implementation
* and does not require provider specific cleanup in a close function.
*
* Most UText provider implementations do not need to implement this function.
*
* @param ut A UText object to be closed.
*
* @stable ICU 3.4
*/
typedef void U_CALLCONV
UTextClose(UText *ut);
/**
* (public) Function dispatch table for UText.
* Conceptually very much like a C++ Virtual Function Table.
* This struct defines the organization of the table.
* Each text provider implementation must provide an
* actual table that is initialized with the appropriate functions
* for the type of text being handled.
* @stable ICU 3.6
*/
struct UTextFuncs {
/**
* (public) Function table size, sizeof(UTextFuncs)
* Intended for use should the table grow to accommodate added
* functions in the future, to allow tests for older format
* function tables that do not contain the extensions.
*
* Fields are placed for optimal alignment on
* 32/64/128-bit-pointer machines, by normally grouping together
* 4 32-bit fields,
* 4 pointers,
* 2 64-bit fields
* in sequence.
* @stable ICU 3.6
*/
int32_t tableSize;
/**
* (private) Alignment padding.
* Do not use, reserved for use by the UText framework only.
* @internal
*/
int32_t reserved1, /** @internal */ reserved2, /** @internal */ reserved3;
/**
* (public) Function pointer for UTextClone
*
* @see UTextClone
* @stable ICU 3.6
*/
UTextClone *clone;
/**
* (public) function pointer for UTextLength
* May be expensive to compute!
*
* @see UTextLength
* @stable ICU 3.6
*/
UTextNativeLength *nativeLength;
/**
* (public) Function pointer for UTextAccess.
*
* @see UTextAccess
* @stable ICU 3.6
*/
UTextAccess *access;
/**
* (public) Function pointer for UTextExtract.
*
* @see UTextExtract
* @stable ICU 3.6
*/
UTextExtract *extract;
/**
* (public) Function pointer for UTextReplace.
*
* @see UTextReplace
* @stable ICU 3.6
*/
UTextReplace *replace;
/**
* (public) Function pointer for UTextCopy.
*
* @see UTextCopy
* @stable ICU 3.6
*/
UTextCopy *copy;
/**
* (public) Function pointer for UTextMapOffsetToNative.
*
* @see UTextMapOffsetToNative
* @stable ICU 3.6
*/
UTextMapOffsetToNative *mapOffsetToNative;
/**
* (public) Function pointer for UTextMapNativeIndexToUTF16.
*
* @see UTextMapNativeIndexToUTF16
* @stable ICU 3.6
*/
UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16;
/**
* (public) Function pointer for UTextClose.
*
* @see UTextClose
* @stable ICU 3.6
*/
UTextClose *close;
/**
* (private) Spare function pointer
* @internal
*/
UTextClose *spare1;
/**
* (private) Spare function pointer
* @internal
*/
UTextClose *spare2;
/**
* (private) Spare function pointer
* @internal
*/
UTextClose *spare3;
};
/**
* Function dispatch table for UText
* @see UTextFuncs
*/
typedef struct UTextFuncs UTextFuncs;
/**
* UText struct. Provides the interface between the generic UText access code
* and the UText provider code that works on specific kinds of
* text (UTF-8, noncontiguous UTF-16, whatever.)
*
* Applications that are using predefined types of text providers
* to pass text data to ICU services will have no need to view the
* internals of the UText structs that they open.
*
* @stable ICU 3.6
*/
struct UText {
/**
* (private) Magic. Used to help detect when UText functions are handed
* invalid or uninitialized UText structs.
* utext_openXYZ() functions take an initialized,
* but not necessarily open, UText struct as an
* optional fill-in parameter. This magic field
* is used to check for that initialization.
* Text provider close functions must NOT clear
* the magic field because that would prevent
* reuse of the UText struct.
* @internal
*/
uint32_t magic;
/**
* (private) Flags for managing the allocation and freeing of
* memory associated with this UText.
* @internal
*/
int32_t flags;
/**
* Text provider properties. This set of flags is maintained by the
* text provider implementation.
* @stable ICU 3.4
*/
int32_t providerProperties;
/**
* (public) sizeOfStruct=sizeof(UText)
* Allows possible backward compatible extension.
*
* @stable ICU 3.4
*/
int32_t sizeOfStruct;
/* ------ 16 byte alignment boundary ----------- */
/**
* (protected) Native index of the first character position following
* the current chunk.
* @stable ICU 3.6
*/
int64_t chunkNativeLimit;
/**
* (protected) Size in bytes of the extra space (pExtra).
* @stable ICU 3.4
*/
int32_t extraSize;
/**
* (protected) The highest chunk offset where native indexing and
* chunk (UTF-16) indexing correspond. For UTF-16 sources, value
* will be equal to chunkLength.
*
* @stable ICU 3.6
*/
int32_t nativeIndexingLimit;
/* ---- 16 byte alignment boundary------ */
/**
* (protected) Native index of the first character in the text chunk.
* @stable ICU 3.6
*/
int64_t chunkNativeStart;
/**
* (protected) Current iteration position within the text chunk (UTF-16 buffer).
* This is the index to the character that will be returned by utext_next32().
* @stable ICU 3.6
*/
int32_t chunkOffset;
/**
* (protected) Length the text chunk (UTF-16 buffer), in UChars.
* @stable ICU 3.6
*/
int32_t chunkLength;
/* ---- 16 byte alignment boundary-- */
/**
* (protected) pointer to a chunk of text in UTF-16 format.
* May refer either to original storage of the source of the text, or
* if conversion was required, to a buffer owned by the UText.
* @stable ICU 3.6
*/
const UChar *chunkContents;
/**
* (public) Pointer to Dispatch table for accessing functions for this UText.
* @stable ICU 3.6
*/
const UTextFuncs *pFuncs;
/**
* (protected) Pointer to additional space requested by the
* text provider during the utext_open operation.
* @stable ICU 3.4
*/
void *pExtra;
/**
* (protected) Pointer to string or text-containing object or similar.
* This is the source of the text that this UText is wrapping, in a format
* that is known to the text provider functions.
* @stable ICU 3.4
*/
const void *context;
/* --- 16 byte alignment boundary--- */
/**
* (protected) Pointer fields available for use by the text provider.
* Not used by UText common code.
* @stable ICU 3.6
*/
const void *p;
/**
* (protected) Pointer fields available for use by the text provider.
* Not used by UText common code.
* @stable ICU 3.6
*/
const void *q;
/**
* (protected) Pointer fields available for use by the text provider.
* Not used by UText common code.
* @stable ICU 3.6
*/
const void *r;
/**
* Private field reserved for future use by the UText framework
* itself. This is not to be touched by the text providers.
* @internal ICU 3.4
*/
void *privP;
/* --- 16 byte alignment boundary--- */
/**
* (protected) Integer field reserved for use by the text provider.
* Not used by the UText framework, or by the client (user) of the UText.
* @stable ICU 3.4
*/
int64_t a;
/**
* (protected) Integer field reserved for use by the text provider.
* Not used by the UText framework, or by the client (user) of the UText.
* @stable ICU 3.4
*/
int32_t b;
/**
* (protected) Integer field reserved for use by the text provider.
* Not used by the UText framework, or by the client (user) of the UText.
* @stable ICU 3.4
*/
int32_t c;
/* ---- 16 byte alignment boundary---- */
/**
* Private field reserved for future use by the UText framework
* itself. This is not to be touched by the text providers.
* @internal ICU 3.4
*/
int64_t privA;
/**
* Private field reserved for future use by the UText framework
* itself. This is not to be touched by the text providers.
* @internal ICU 3.4
*/
int32_t privB;
/**
* Private field reserved for future use by the UText framework
* itself. This is not to be touched by the text providers.
* @internal ICU 3.4
*/
int32_t privC;
};
/**
* Common function for use by Text Provider implementations to allocate and/or initialize
* a new UText struct. To be called in the implementation of utext_open() functions.
* If the supplied UText parameter is null, a new UText struct will be allocated on the heap.
* If the supplied UText is already open, the provider's close function will be called
* so that the struct can be reused by the open that is in progress.
*
* @param ut pointer to a UText struct to be re-used, or null if a new UText
* should be allocated.
* @param extraSpace The amount of additional space to be allocated as part
* of this UText, for use by types of providers that require
* additional storage.
* @param status Errors are returned here.
* @return pointer to the UText, allocated if necessary, with extra space set up if requested.
* @stable ICU 3.4
*/
U_CAPI UText * U_EXPORT2
utext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);
// do not use #ifndef U_HIDE_INTERNAL_API around the following!
/**
* @internal
* Value used to help identify correctly initialized UText structs.
* Note: must be publicly visible so that UTEXT_INITIALIZER can access it.
*/
enum {
UTEXT_MAGIC = 0x345ad82c
};
/**
* initializer to be used with local (stack) instances of a UText
* struct. UText structs must be initialized before passing
* them to one of the utext_open functions.
*
* @stable ICU 3.6
*/
#define UTEXT_INITIALIZER { \
UTEXT_MAGIC, /* magic */ \
0, /* flags */ \
0, /* providerProps */ \
sizeof(UText), /* sizeOfStruct */ \
0, /* chunkNativeLimit */ \
0, /* extraSize */ \
0, /* nativeIndexingLimit */ \
0, /* chunkNativeStart */ \
0, /* chunkOffset */ \
0, /* chunkLength */ \
NULL, /* chunkContents */ \
NULL, /* pFuncs */ \
NULL, /* pExtra */ \
NULL, /* context */ \
NULL, NULL, NULL, /* p, q, r */ \
NULL, /* privP */ \
0, 0, 0, /* a, b, c */ \
0, 0, 0 /* privA,B,C, */ \
}
U_CDECL_END
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
/**
* \class LocalUTextPointer
* "Smart pointer" class, closes a UText via utext_close().
* For most methods see the LocalPointerBase base class.
*
* @see LocalPointerBase
* @see LocalPointer
* @stable ICU 4.4
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUTextPointer, UText, utext_close);
U_NAMESPACE_END
#endif
#endif
|
530f397e71e948211428a7957a63204350c63f6b
|
1efd2de8bf77ec00eb2fcaf5749278495946d920
|
/src/vos/vos_dtx_iter.c
|
b0e8c76382356bfd16b76ce0645288ef55d63f60
|
[
"BSD-2-Clause",
"BSD-2-Clause-Patent"
] |
permissive
|
daos-stack/daos
|
6f55bf3061fd830d5b8d28506e1295e2d3a27c38
|
ed5eed5df43a68571afe123132a743824c02637a
|
refs/heads/master
| 2023-08-31T21:43:37.606145
| 2023-08-31T16:38:00
| 2023-08-31T16:38:00
| 69,390,670
| 631
| 300
|
NOASSERTION
| 2023-09-14T18:55:15
| 2016-09-27T19:21:29
|
C
|
UTF-8
|
C
| false
| false
| 7,767
|
c
|
vos_dtx_iter.c
|
/**
* (C) Copyright 2019-2023 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
/**
* This file is part of daos two-phase commit transaction.
*
* vos/vos_dtx_iter.c
*/
#define D_LOGFAC DD_FAC(vos)
#include <daos_srv/vos.h>
#include "vos_layout.h"
#include "vos_internal.h"
/** Iterator for active-DTX table. */
struct vos_dtx_iter {
/** embedded VOS common iterator */
struct vos_iterator oit_iter;
/** Handle of iterator */
daos_handle_t oit_hdl;
/** Reference to the container */
struct vos_container *oit_cont;
struct vos_dtx_act_ent *oit_cur;
bool oit_linear;
};
static struct vos_dtx_iter *
iter2oiter(struct vos_iterator *iter)
{
return container_of(iter, struct vos_dtx_iter, oit_iter);
}
static int
dtx_iter_fini(struct vos_iterator *iter)
{
struct vos_dtx_iter *oiter = iter2oiter(iter);
int rc = 0;
D_ASSERT(iter->it_type == VOS_ITER_DTX);
if (daos_handle_is_valid(oiter->oit_hdl)) {
rc = dbtree_iter_finish(oiter->oit_hdl);
if (rc != 0)
D_ERROR("oid_iter_fini failed: rc = "DF_RC"\n",
DP_RC(rc));
}
if (oiter->oit_cont != NULL)
vos_cont_decref(oiter->oit_cont);
D_FREE(oiter);
return rc;
}
static int
dtx_iter_prep(vos_iter_type_t type, vos_iter_param_t *param,
struct vos_iterator **iter_pp, struct vos_ts_set *ts_set)
{
struct vos_dtx_iter *oiter;
struct vos_container *cont;
int rc;
if (type != VOS_ITER_DTX) {
D_ERROR("Expected Type: %d, got %d\n", VOS_ITER_DTX, type);
return -DER_INVAL;
}
cont = vos_hdl2cont(param->ip_hdl);
if (cont == NULL)
return -DER_INVAL;
D_ALLOC_PTR(oiter);
if (oiter == NULL)
return -DER_NOMEM;
oiter->oit_iter.it_type = type;
oiter->oit_cont = cont;
vos_cont_addref(cont);
rc = dbtree_iter_prepare(cont->vc_dtx_active_hdl, 0, &oiter->oit_hdl);
if (rc != 0) {
D_ERROR("Failed to prepare DTX iteration: rc = "DF_RC"\n",
DP_RC(rc));
dtx_iter_fini(&oiter->oit_iter);
} else {
*iter_pp = &oiter->oit_iter;
oiter->oit_cur = NULL;
oiter->oit_linear = false;
}
return rc;
}
static int
dtx_iter_probe(struct vos_iterator *iter, daos_anchor_t *anchor, uint32_t next /* Unimplemented */)
{
struct vos_dtx_iter *oiter = iter2oiter(iter);
struct vos_dtx_act_ent *dae;
d_iov_t rec_iov;
int rc = 0;
D_ASSERT(iter->it_type == VOS_ITER_DTX);
if (vos_anchor_is_zero(anchor)) {
oiter->oit_linear = true;
if (d_list_empty(&oiter->oit_cont->vc_dtx_act_list)) {
oiter->oit_cur = NULL;
D_GOTO(out, rc = -DER_NONEXIST);
}
dae = oiter->oit_cur =
d_list_entry(oiter->oit_cont->vc_dtx_act_list.next,
struct vos_dtx_act_ent, dae_link);
} else {
oiter->oit_linear = false;
rc = dbtree_iter_probe(oiter->oit_hdl, BTR_PROBE_GE,
vos_iter_intent(iter), NULL, anchor);
if (rc != 0)
goto out;
d_iov_set(&rec_iov, NULL, 0);
rc = dbtree_iter_fetch(oiter->oit_hdl, NULL, &rec_iov, anchor);
if (rc != 0) {
D_ERROR("Error while fetching DTX info: rc = "DF_RC"\n",
DP_RC(rc));
goto out;
}
D_ASSERT(rec_iov.iov_len == sizeof(struct vos_dtx_act_ent));
dae = rec_iov.iov_buf;
}
while (vos_dae_is_commit(dae) || vos_dae_is_abort(dae) || dae->dae_preparing ||
dae->dae_dth != NULL) {
if (oiter->oit_linear) {
if (dae->dae_link.next ==
&oiter->oit_cont->vc_dtx_act_list) {
oiter->oit_cur = NULL;
D_GOTO(out, rc = -DER_NONEXIST);
}
dae = oiter->oit_cur =
d_list_entry(dae->dae_link.next,
struct vos_dtx_act_ent, dae_link);
} else {
rc = dbtree_iter_next(oiter->oit_hdl);
if (rc != 0)
goto out;
d_iov_set(&rec_iov, NULL, 0);
rc = dbtree_iter_fetch(oiter->oit_hdl, NULL,
&rec_iov, NULL);
if (rc != 0)
goto out;
D_ASSERT(rec_iov.iov_len ==
sizeof(struct vos_dtx_act_ent));
dae = rec_iov.iov_buf;
}
}
out:
return rc;
}
static int
dtx_iter_next(struct vos_iterator *iter, daos_anchor_t *anchor)
{
struct vos_dtx_iter *oiter = iter2oiter(iter);
struct vos_dtx_act_ent *dae;
d_iov_t rec_iov;
int rc = 0;
D_ASSERT(iter->it_type == VOS_ITER_DTX);
do {
if (oiter->oit_linear) {
if (oiter->oit_cur == NULL)
D_GOTO(out, rc = -DER_NONEXIST);
if (oiter->oit_cur->dae_link.next ==
&oiter->oit_cont->vc_dtx_act_list) {
oiter->oit_cur = NULL;
D_GOTO(out, rc = -DER_NONEXIST);
}
dae = oiter->oit_cur =
d_list_entry(oiter->oit_cur->dae_link.next,
struct vos_dtx_act_ent, dae_link);
} else {
rc = dbtree_iter_next(oiter->oit_hdl);
if (rc != 0)
goto out;
d_iov_set(&rec_iov, NULL, 0);
rc = dbtree_iter_fetch(oiter->oit_hdl, NULL,
&rec_iov, NULL);
if (rc != 0)
goto out;
D_ASSERT(rec_iov.iov_len ==
sizeof(struct vos_dtx_act_ent));
dae = rec_iov.iov_buf;
}
} while (vos_dae_is_commit(dae) || vos_dae_is_abort(dae) || dae->dae_preparing ||
dae->dae_dth != NULL);
out:
return rc;
}
static int
dtx_iter_fetch(struct vos_iterator *iter, vos_iter_entry_t *it_entry,
daos_anchor_t *anchor)
{
struct vos_dtx_iter *oiter = iter2oiter(iter);
struct vos_dtx_act_ent *dae;
d_iov_t rec_iov;
int rc;
D_ASSERT(iter->it_type == VOS_ITER_DTX);
if (oiter->oit_linear) {
if (oiter->oit_cur == NULL)
return -DER_NONEXIST;
dae = oiter->oit_cur;
} else {
d_iov_set(&rec_iov, NULL, 0);
rc = dbtree_iter_fetch(oiter->oit_hdl, NULL, &rec_iov, anchor);
if (rc != 0) {
D_ERROR("Error while fetching DTX info: rc = "DF_RC"\n",
DP_RC(rc));
return rc;
}
D_ASSERT(rec_iov.iov_len == sizeof(struct vos_dtx_act_ent));
dae = rec_iov.iov_buf;
}
/* Only return prepared ones. */
D_ASSERT(!vos_dae_is_commit(dae));
D_ASSERT(!vos_dae_is_abort(dae));
D_ASSERT(!dae->dae_preparing);
D_ASSERT(dae->dae_dth == NULL);
/*
* The DTX entry is returned via the iteration. The upper layer caller, for DTX resync
* or DTX cleanup, may abort it sometime later. Before being aborted, it may re-attach
* to some DTX handle for handling resent request. Then there is race between them. So
* before become committable or being committed by RPC handler, needs to check whether
* it has been aborted or not.
*/
dae->dae_need_validation = 1;
it_entry->ie_epoch = DAE_EPOCH(dae);
it_entry->ie_dtx_xid = DAE_XID(dae);
it_entry->ie_dtx_oid = DAE_OID(dae);
it_entry->ie_dtx_ver = DAE_VER(dae);
it_entry->ie_dtx_flags = DAE_FLAGS(dae);
it_entry->ie_dtx_start_time = dae->dae_start_time;
it_entry->ie_dkey_hash = DAE_DKEY_HASH(dae);
if (dae->dae_dbd == NULL) {
/* Unprepared entry, the MBS data is not initialized. */
it_entry->ie_dtx_mbs_flags = 0;
it_entry->ie_dtx_tgt_cnt = 0;
it_entry->ie_dtx_grp_cnt = 0;
it_entry->ie_dtx_mbs_dsize = 0;
it_entry->ie_dtx_mbs = NULL;
} else {
it_entry->ie_dtx_mbs_flags = DAE_MBS_FLAGS(dae);
it_entry->ie_dtx_tgt_cnt = DAE_TGT_CNT(dae);
it_entry->ie_dtx_grp_cnt = DAE_GRP_CNT(dae);
it_entry->ie_dtx_mbs_dsize = DAE_MBS_DSIZE(dae);
if (DAE_MBS_DSIZE(dae) <= sizeof(DAE_MBS_INLINE(dae)))
it_entry->ie_dtx_mbs = DAE_MBS_INLINE(dae);
else
it_entry->ie_dtx_mbs = umem_off2ptr(&oiter->oit_cont->vc_pool->vp_umm,
DAE_MBS_OFF(dae));
}
D_DEBUG(DB_IO, "DTX iterator fetch the one "DF_DTI"\n",
DP_DTI(&DAE_XID(dae)));
return 0;
}
static int
dtx_iter_process(struct vos_iterator *iter, vos_iter_proc_op_t op, void *args)
{
D_ASSERT(iter->it_type == VOS_ITER_DTX);
if (op != VOS_ITER_PROC_OP_DELETE)
return -DER_NOSYS;
D_WARN("NOT allow to remove DTX entry via iteration!\n");
return -DER_NO_PERM;
}
struct vos_iter_ops vos_dtx_iter_ops = {
.iop_prepare = dtx_iter_prep,
.iop_finish = dtx_iter_fini,
.iop_probe = dtx_iter_probe,
.iop_next = dtx_iter_next,
.iop_fetch = dtx_iter_fetch,
.iop_process = dtx_iter_process,
};
|
f5cf0a057fda97ed518c66b7a4591d06c67ecabe
|
d9bde3779ade5dc45058447e7bd5c42b3971977a
|
/print-pim.c
|
2a33c1ffb6796eeb390eb93d2457cab198d16593
|
[
"BSD-3-Clause"
] |
permissive
|
the-tcpdump-group/tcpdump
|
60e6d0e705ba9a6e6c29d5d9782aff214ca4d61b
|
d6734adaa3aba89bf73eec03837b41aa064c8fb5
|
refs/heads/master
| 2023-08-14T06:11:14.949694
| 2023-08-13T07:57:20
| 2023-08-13T07:59:12
| 9,435,882
| 2,394
| 894
|
NOASSERTION
| 2023-09-12T08:53:57
| 2013-04-14T21:46:15
|
C
|
UTF-8
|
C
| false
| false
| 33,846
|
c
|
print-pim.c
|
/*
* Copyright (c) 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* \summary: Protocol Independent Multicast (PIM) printer */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "ip.h"
#include "ip6.h"
#include "ipproto.h"
#include "af.h"
#define PIMV1_TYPE_QUERY 0
#define PIMV1_TYPE_REGISTER 1
#define PIMV1_TYPE_REGISTER_STOP 2
#define PIMV1_TYPE_JOIN_PRUNE 3
#define PIMV1_TYPE_RP_REACHABILITY 4
#define PIMV1_TYPE_ASSERT 5
#define PIMV1_TYPE_GRAFT 6
#define PIMV1_TYPE_GRAFT_ACK 7
static const struct tok pimv1_type_str[] = {
{ PIMV1_TYPE_QUERY, "Query" },
{ PIMV1_TYPE_REGISTER, "Register" },
{ PIMV1_TYPE_REGISTER_STOP, "Register-Stop" },
{ PIMV1_TYPE_JOIN_PRUNE, "Join/Prune" },
{ PIMV1_TYPE_RP_REACHABILITY, "RP-reachable" },
{ PIMV1_TYPE_ASSERT, "Assert" },
{ PIMV1_TYPE_GRAFT, "Graft" },
{ PIMV1_TYPE_GRAFT_ACK, "Graft-ACK" },
{ 0, NULL }
};
#define PIMV2_TYPE_HELLO 0
#define PIMV2_TYPE_REGISTER 1
#define PIMV2_TYPE_REGISTER_STOP 2
#define PIMV2_TYPE_JOIN_PRUNE 3
#define PIMV2_TYPE_BOOTSTRAP 4
#define PIMV2_TYPE_ASSERT 5
#define PIMV2_TYPE_GRAFT 6
#define PIMV2_TYPE_GRAFT_ACK 7
#define PIMV2_TYPE_CANDIDATE_RP 8
#define PIMV2_TYPE_PRUNE_REFRESH 9
#define PIMV2_TYPE_DF_ELECTION 10
#define PIMV2_TYPE_ECMP_REDIRECT 11
static const struct tok pimv2_type_values[] = {
{ PIMV2_TYPE_HELLO, "Hello" },
{ PIMV2_TYPE_REGISTER, "Register" },
{ PIMV2_TYPE_REGISTER_STOP, "Register Stop" },
{ PIMV2_TYPE_JOIN_PRUNE, "Join / Prune" },
{ PIMV2_TYPE_BOOTSTRAP, "Bootstrap" },
{ PIMV2_TYPE_ASSERT, "Assert" },
{ PIMV2_TYPE_GRAFT, "Graft" },
{ PIMV2_TYPE_GRAFT_ACK, "Graft Acknowledgement" },
{ PIMV2_TYPE_CANDIDATE_RP, "Candidate RP Advertisement" },
{ PIMV2_TYPE_PRUNE_REFRESH, "Prune Refresh" },
{ PIMV2_TYPE_DF_ELECTION, "DF Election" },
{ PIMV2_TYPE_ECMP_REDIRECT, "ECMP Redirect" },
{ 0, NULL}
};
#define PIMV2_HELLO_OPTION_HOLDTIME 1
#define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
#define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
#define PIMV2_HELLO_OPTION_DR_PRIORITY 19
#define PIMV2_HELLO_OPTION_GENID 20
#define PIMV2_HELLO_OPTION_REFRESH_CAP 21
#define PIMV2_HELLO_OPTION_BIDIR_CAP 22
#define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
#define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
static const struct tok pimv2_hello_option_values[] = {
{ PIMV2_HELLO_OPTION_HOLDTIME, "Hold Time" },
{ PIMV2_HELLO_OPTION_LANPRUNEDELAY, "LAN Prune Delay" },
{ PIMV2_HELLO_OPTION_DR_PRIORITY_OLD, "DR Priority (Old)" },
{ PIMV2_HELLO_OPTION_DR_PRIORITY, "DR Priority" },
{ PIMV2_HELLO_OPTION_GENID, "Generation ID" },
{ PIMV2_HELLO_OPTION_REFRESH_CAP, "State Refresh Capability" },
{ PIMV2_HELLO_OPTION_BIDIR_CAP, "Bi-Directional Capability" },
{ PIMV2_HELLO_OPTION_ADDRESS_LIST, "Address List" },
{ PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD, "Address List (Old)" },
{ 0, NULL}
};
#define PIMV2_REGISTER_FLAG_LEN 4
#define PIMV2_REGISTER_FLAG_BORDER 0x80000000
#define PIMV2_REGISTER_FLAG_NULL 0x40000000
static const struct tok pimv2_register_flag_values[] = {
{ PIMV2_REGISTER_FLAG_BORDER, "Border" },
{ PIMV2_REGISTER_FLAG_NULL, "Null" },
{ 0, NULL}
};
#define PIMV2_DF_ELECTION_OFFER 1
#define PIMV2_DF_ELECTION_WINNER 2
#define PIMV2_DF_ELECTION_BACKOFF 3
#define PIMV2_DF_ELECTION_PASS 4
static const struct tok pimv2_df_election_flag_values[] = {
{ PIMV2_DF_ELECTION_OFFER, "Offer" },
{ PIMV2_DF_ELECTION_WINNER, "Winner" },
{ PIMV2_DF_ELECTION_BACKOFF, "Backoff" },
{ PIMV2_DF_ELECTION_PASS, "Pass" },
{ 0, NULL}
};
#define PIMV2_DF_ELECTION_PASS_BACKOFF_STR(x) ( \
x == PIMV2_DF_ELECTION_BACKOFF ? "offer" : "new winner" )
/*
* XXX: We consider a case where IPv6 is not ready yet for portability,
* but PIM dependent definitions should be independent of IPv6...
*/
struct pim {
nd_uint8_t pim_typever;
/* upper 4bit: PIM version number; 2 for PIMv2 */
/* lower 4bit: the PIM message type, currently they are:
* Hello, Register, Register-Stop, Join/Prune,
* Bootstrap, Assert, Graft (PIM-DM only),
* Graft-Ack (PIM-DM only), C-RP-Adv
*/
#define PIM_VER(x) (((x) & 0xf0) >> 4)
#define PIM_TYPE(x) ((x) & 0x0f)
nd_uint8_t pim_rsv; /* Reserved in v1, subtype+address length in v2 */
#define PIM_SUBTYPE(x) (((x) & 0xf0) >> 4)
nd_uint16_t pim_cksum; /* IP style check sum */
};
static void pimv2_print(netdissect_options *, const u_char *bp, u_int len, const u_char *);
static void
pimv1_join_prune_print(netdissect_options *ndo,
const u_char *bp, u_int len)
{
u_int ngroups, njoin, nprune;
u_int njp;
/* If it's a single group and a single source, use 1-line output. */
if (ND_TTEST_LEN(bp, 30) && GET_U_1(bp + 11) == 1 &&
((njoin = GET_BE_U_2(bp + 20)) + GET_BE_U_2(bp + 22)) == 1) {
u_int hold;
ND_PRINT(" RPF %s ", GET_IPADDR_STRING(bp));
hold = GET_BE_U_2(bp + 6);
if (hold != 180) {
ND_PRINT("Hold ");
unsigned_relts_print(ndo, hold);
}
ND_PRINT("%s (%s/%u, %s", njoin ? "Join" : "Prune",
GET_IPADDR_STRING(bp + 26), GET_U_1(bp + 25) & 0x3f,
GET_IPADDR_STRING(bp + 12));
if (GET_BE_U_4(bp + 16) != 0xffffffff)
ND_PRINT("/%s", GET_IPADDR_STRING(bp + 16));
ND_PRINT(") %s%s %s",
(GET_U_1(bp + 24) & 0x01) ? "Sparse" : "Dense",
(GET_U_1(bp + 25) & 0x80) ? " WC" : "",
(GET_U_1(bp + 25) & 0x40) ? "RP" : "SPT");
return;
}
if (len < sizeof(nd_ipv4))
goto trunc;
if (ndo->ndo_vflag > 1)
ND_PRINT("\n");
ND_PRINT(" Upstream Nbr: %s", GET_IPADDR_STRING(bp));
bp += 4;
len -= 4;
if (len < 4)
goto trunc;
if (ndo->ndo_vflag > 1)
ND_PRINT("\n");
ND_PRINT(" Hold time: ");
unsigned_relts_print(ndo, GET_BE_U_2(bp + 2));
if (ndo->ndo_vflag < 2)
return;
bp += 4;
len -= 4;
if (len < 4)
goto trunc;
ngroups = GET_U_1(bp + 3);
bp += 4;
len -= 4;
while (ngroups != 0) {
/*
* XXX - does the address have length "addrlen" and the
* mask length "maddrlen"?
*/
if (len < 4)
goto trunc;
ND_PRINT("\n\tGroup: %s", GET_IPADDR_STRING(bp));
bp += 4;
len -= 4;
if (len < 4)
goto trunc;
if (GET_BE_U_4(bp) != 0xffffffff)
ND_PRINT("/%s", GET_IPADDR_STRING(bp));
bp += 4;
len -= 4;
if (len < 4)
goto trunc;
njoin = GET_BE_U_2(bp);
nprune = GET_BE_U_2(bp + 2);
ND_PRINT(" joined: %u pruned: %u", njoin, nprune);
bp += 4;
len -= 4;
for (njp = 0; njp < (njoin + nprune); njp++) {
const char *type;
if (njp < njoin)
type = "Join ";
else
type = "Prune";
if (len < 6)
goto trunc;
ND_PRINT("\n\t%s %s%s%s%s/%u", type,
(GET_U_1(bp) & 0x01) ? "Sparse " : "Dense ",
(GET_U_1(bp + 1) & 0x80) ? "WC " : "",
(GET_U_1(bp + 1) & 0x40) ? "RP " : "SPT ",
GET_IPADDR_STRING(bp + 2),
GET_U_1(bp + 1) & 0x3f);
bp += 6;
len -= 6;
}
ngroups--;
}
return;
trunc:
nd_print_trunc(ndo);
}
void
pimv1_print(netdissect_options *ndo,
const u_char *bp, u_int len)
{
u_char type;
ndo->ndo_protocol = "pimv1";
type = GET_U_1(bp + 1);
ND_PRINT(" %s", tok2str(pimv1_type_str, "[type %u]", type));
switch (type) {
case PIMV1_TYPE_QUERY:
if (ND_TTEST_1(bp + 8)) {
switch (GET_U_1(bp + 8) >> 4) {
case 0:
ND_PRINT(" Dense-mode");
break;
case 1:
ND_PRINT(" Sparse-mode");
break;
case 2:
ND_PRINT(" Sparse-Dense-mode");
break;
default:
ND_PRINT(" mode-%u", GET_U_1(bp + 8) >> 4);
break;
}
}
if (ndo->ndo_vflag) {
ND_PRINT(" (Hold-time ");
unsigned_relts_print(ndo, GET_BE_U_2(bp + 10));
ND_PRINT(")");
}
break;
case PIMV1_TYPE_REGISTER:
ND_TCHECK_LEN(bp + 8, 20); /* ip header */
ND_PRINT(" for %s > %s", GET_IPADDR_STRING(bp + 20),
GET_IPADDR_STRING(bp + 24));
break;
case PIMV1_TYPE_REGISTER_STOP:
ND_PRINT(" for %s > %s", GET_IPADDR_STRING(bp + 8),
GET_IPADDR_STRING(bp + 12));
break;
case PIMV1_TYPE_RP_REACHABILITY:
if (ndo->ndo_vflag) {
ND_PRINT(" group %s", GET_IPADDR_STRING(bp + 8));
if (GET_BE_U_4(bp + 12) != 0xffffffff)
ND_PRINT("/%s", GET_IPADDR_STRING(bp + 12));
ND_PRINT(" RP %s hold ", GET_IPADDR_STRING(bp + 16));
unsigned_relts_print(ndo, GET_BE_U_2(bp + 22));
}
break;
case PIMV1_TYPE_ASSERT:
ND_PRINT(" for %s > %s", GET_IPADDR_STRING(bp + 16),
GET_IPADDR_STRING(bp + 8));
if (GET_BE_U_4(bp + 12) != 0xffffffff)
ND_PRINT("/%s", GET_IPADDR_STRING(bp + 12));
ND_PRINT(" %s pref %u metric %u",
(GET_U_1(bp + 20) & 0x80) ? "RP-tree" : "SPT",
GET_BE_U_4(bp + 20) & 0x7fffffff,
GET_BE_U_4(bp + 24));
break;
case PIMV1_TYPE_JOIN_PRUNE:
case PIMV1_TYPE_GRAFT:
case PIMV1_TYPE_GRAFT_ACK:
if (ndo->ndo_vflag) {
if (len < 8)
goto trunc;
pimv1_join_prune_print(ndo, bp + 8, len - 8);
}
break;
}
if ((GET_U_1(bp + 4) >> 4) != 1)
ND_PRINT(" [v%u]", GET_U_1(bp + 4) >> 4);
return;
trunc:
nd_print_trunc(ndo);
}
/*
* auto-RP is a cisco protocol, documented at
* ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
*
* This implements version 1+, dated Sept 9, 1998.
*/
void
cisco_autorp_print(netdissect_options *ndo,
const u_char *bp, u_int len)
{
u_int type;
u_int numrps;
u_int hold;
ndo->ndo_protocol = "cisco_autorp";
if (len < 8)
goto trunc;
ND_PRINT(" auto-rp ");
type = GET_U_1(bp);
switch (type) {
case 0x11:
ND_PRINT("candidate-advert");
break;
case 0x12:
ND_PRINT("mapping");
break;
default:
ND_PRINT("type-0x%02x", type);
break;
}
numrps = GET_U_1(bp + 1);
ND_PRINT(" Hold ");
hold = GET_BE_U_2(bp + 2);
if (hold)
unsigned_relts_print(ndo, GET_BE_U_2(bp + 2));
else
ND_PRINT("FOREVER");
/* Next 4 bytes are reserved. */
bp += 8; len -= 8;
/*XXX skip unless -v? */
/*
* Rest of packet:
* numrps entries of the form:
* 32 bits: RP
* 6 bits: reserved
* 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
* 8 bits: # of entries for this RP
* each entry: 7 bits: reserved, 1 bit: negative,
* 8 bits: mask 32 bits: source
* lather, rinse, repeat.
*/
while (numrps != 0) {
u_int nentries;
char s;
if (len < 4)
goto trunc;
ND_PRINT(" RP %s", GET_IPADDR_STRING(bp));
bp += 4;
len -= 4;
if (len < 1)
goto trunc;
switch (GET_U_1(bp) & 0x3) {
case 0: ND_PRINT(" PIMv?");
break;
case 1: ND_PRINT(" PIMv1");
break;
case 2: ND_PRINT(" PIMv2");
break;
case 3: ND_PRINT(" PIMv1+2");
break;
}
if (GET_U_1(bp) & 0xfc)
ND_PRINT(" [rsvd=0x%02x]", GET_U_1(bp) & 0xfc);
bp += 1;
len -= 1;
if (len < 1)
goto trunc;
nentries = GET_U_1(bp);
bp += 1;
len -= 1;
s = ' ';
while (nentries != 0) {
if (len < 6)
goto trunc;
ND_PRINT("%c%s%s/%u", s, GET_U_1(bp) & 1 ? "!" : "",
GET_IPADDR_STRING(bp + 2), GET_U_1(bp + 1));
if (GET_U_1(bp) & 0x02) {
ND_PRINT(" bidir");
}
if (GET_U_1(bp) & 0xfc) {
ND_PRINT("[rsvd=0x%02x]", GET_U_1(bp) & 0xfc);
}
s = ',';
bp += 6; len -= 6;
nentries--;
}
numrps--;
}
return;
trunc:
nd_print_trunc(ndo);
}
void
pim_print(netdissect_options *ndo,
const u_char *bp, u_int len, const u_char *bp2)
{
const struct pim *pim = (const struct pim *)bp;
uint8_t pim_typever;
ndo->ndo_protocol = "pim";
pim_typever = GET_U_1(pim->pim_typever);
switch (PIM_VER(pim_typever)) {
case 2:
if (!ndo->ndo_vflag) {
ND_PRINT("PIMv%u, %s, length %u",
PIM_VER(pim_typever),
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim_typever)),
len);
return;
} else {
ND_PRINT("PIMv%u, length %u\n\t%s",
PIM_VER(pim_typever),
len,
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim_typever)));
pimv2_print(ndo, bp, len, bp2);
}
break;
default:
ND_PRINT("PIMv%u, length %u",
PIM_VER(pim_typever),
len);
break;
}
}
/*
* PIMv2 uses encoded address representations.
*
* The last PIM-SM I-D before RFC2117 was published specified the
* following representation for unicast addresses. However, RFC2117
* specified no encoding for unicast addresses with the unicast
* address length specified in the header. Therefore, we have to
* guess which encoding is being used (Cisco's PIMv2 implementation
* uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
* field into a 'unicast-address-length-in-bytes' field. We guess
* that it's the draft encoding if this reserved field is zero.
*
* RFC2362 goes back to the encoded format, and calls the addr length
* field "reserved" again.
*
* The first byte is the address family, from:
*
* 0 Reserved
* 1 IP (IP version 4)
* 2 IP6 (IP version 6)
* 3 NSAP
* 4 HDLC (8-bit multidrop)
* 5 BBN 1822
* 6 802 (includes all 802 media plus Ethernet "canonical format")
* 7 E.163
* 8 E.164 (SMDS, Frame Relay, ATM)
* 9 F.69 (Telex)
* 10 X.121 (X.25, Frame Relay)
* 11 IPX
* 12 Appletalk
* 13 Decnet IV
* 14 Banyan Vines
* 15 E.164 with NSAP format subaddress
*
* In addition, the second byte is an "Encoding". 0 is the default
* encoding for the address family, and no other encodings are currently
* specified.
*
*/
enum pimv2_addrtype {
pimv2_unicast, pimv2_group, pimv2_source
};
/* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Addr Family | Encoding Type | Unicast Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Addr Family | Encoding Type | Reserved | Mask Len |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Group multicast Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Source Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
static int
pimv2_addr_print(netdissect_options *ndo,
const u_char *bp, u_int len, enum pimv2_addrtype at,
u_int addr_len, int silent)
{
u_int af;
int hdrlen;
if (addr_len == 0) {
if (len < 2)
goto trunc;
af = GET_U_1(bp);
switch (af) {
case AFNUM_IP:
addr_len = (u_int)sizeof(nd_ipv4);
break;
case AFNUM_IP6:
addr_len = (u_int)sizeof(nd_ipv6);
break;
default:
return -1;
}
if (GET_U_1(bp + 1) != 0)
return -1;
hdrlen = 2;
} else {
switch (addr_len) {
case sizeof(nd_ipv4):
af = AFNUM_IP;
break;
case sizeof(nd_ipv6):
af = AFNUM_IP6;
break;
default:
return -1;
break;
}
hdrlen = 0;
}
bp += hdrlen;
len -= hdrlen;
switch (at) {
case pimv2_unicast:
if (len < addr_len)
goto trunc;
ND_TCHECK_LEN(bp, addr_len);
if (af == AFNUM_IP) {
if (!silent)
ND_PRINT("%s", GET_IPADDR_STRING(bp));
} else if (af == AFNUM_IP6) {
if (!silent)
ND_PRINT("%s", GET_IP6ADDR_STRING(bp));
}
return hdrlen + addr_len;
case pimv2_group:
case pimv2_source:
if (len < addr_len + 2)
goto trunc;
ND_TCHECK_LEN(bp, addr_len + 2);
if (af == AFNUM_IP) {
if (!silent) {
ND_PRINT("%s", GET_IPADDR_STRING(bp + 2));
if (GET_U_1(bp + 1) != 32)
ND_PRINT("/%u", GET_U_1(bp + 1));
}
} else if (af == AFNUM_IP6) {
if (!silent) {
ND_PRINT("%s", GET_IP6ADDR_STRING(bp + 2));
if (GET_U_1(bp + 1) != 128)
ND_PRINT("/%u", GET_U_1(bp + 1));
}
}
if (GET_U_1(bp) && !silent) {
if (at == pimv2_group) {
ND_PRINT("(0x%02x)", GET_U_1(bp));
} else {
ND_PRINT("(%s%s%s",
GET_U_1(bp) & 0x04 ? "S" : "",
GET_U_1(bp) & 0x02 ? "W" : "",
GET_U_1(bp) & 0x01 ? "R" : "");
if (GET_U_1(bp) & 0xf8) {
ND_PRINT("+0x%02x",
GET_U_1(bp) & 0xf8);
}
ND_PRINT(")");
}
}
return hdrlen + 2 + addr_len;
default:
return -1;
}
trunc:
return -1;
}
enum checksum_status {
CORRECT,
INCORRECT,
UNVERIFIED
};
static enum checksum_status
pimv2_check_checksum(netdissect_options *ndo, const u_char *bp,
const u_char *bp2, u_int len)
{
const struct ip *ip;
u_int cksum;
if (!ND_TTEST_LEN(bp, len)) {
/* We don't have all the data. */
return (UNVERIFIED);
}
ip = (const struct ip *)bp2;
if (IP_V(ip) == 4) {
struct cksum_vec vec[1];
vec[0].ptr = bp;
vec[0].len = len;
cksum = in_cksum(vec, 1);
return (cksum ? INCORRECT : CORRECT);
} else if (IP_V(ip) == 6) {
const struct ip6_hdr *ip6;
ip6 = (const struct ip6_hdr *)bp2;
cksum = nextproto6_cksum(ndo, ip6, bp, len, len, IPPROTO_PIM);
return (cksum ? INCORRECT : CORRECT);
} else {
return (UNVERIFIED);
}
}
static void
pimv2_print(netdissect_options *ndo,
const u_char *bp, u_int len, const u_char *bp2)
{
const struct pim *pim = (const struct pim *)bp;
int advance;
int subtype;
enum checksum_status cksum_status;
u_int pim_typever;
u_int pimv2_addr_len;
ndo->ndo_protocol = "pimv2";
if (len < 2) {
ND_PRINT("[length %u < 2]", len);
nd_print_invalid(ndo);
return;
}
pim_typever = GET_U_1(pim->pim_typever);
/* RFC5015 allocates the high 4 bits of pim_rsv for "subtype". */
pimv2_addr_len = GET_U_1(pim->pim_rsv) & 0x0f;
if (pimv2_addr_len != 0)
ND_PRINT(", RFC2117-encoding");
if (len < 4) {
ND_PRINT("[length %u < 4]", len);
nd_print_invalid(ndo);
return;
}
ND_PRINT(", cksum 0x%04x ", GET_BE_U_2(pim->pim_cksum));
if (GET_BE_U_2(pim->pim_cksum) == 0) {
ND_PRINT("(unverified)");
} else {
if (PIM_TYPE(pim_typever) == PIMV2_TYPE_REGISTER) {
/*
* The checksum only covers the packet header,
* not the encapsulated packet.
*/
cksum_status = pimv2_check_checksum(ndo, bp, bp2, 8);
if (cksum_status == INCORRECT) {
/*
* To quote RFC 4601, "For interoperability
* reasons, a message carrying a checksum
* calculated over the entire PIM Register
* message should also be accepted."
*/
cksum_status = pimv2_check_checksum(ndo, bp, bp2, len);
}
} else {
/*
* The checksum covers the entire packet.
*/
cksum_status = pimv2_check_checksum(ndo, bp, bp2, len);
}
switch (cksum_status) {
case CORRECT:
ND_PRINT("(correct)");
break;
case INCORRECT:
ND_PRINT("(incorrect)");
break;
case UNVERIFIED:
ND_PRINT("(unverified)");
break;
}
}
bp += 4;
len -= 4;
switch (PIM_TYPE(pim_typever)) {
case PIMV2_TYPE_HELLO:
{
uint16_t otype, olen;
while (len > 0) {
if (len < 4)
goto trunc;
otype = GET_BE_U_2(bp);
olen = GET_BE_U_2(bp + 2);
ND_PRINT("\n\t %s Option (%u), length %u, Value: ",
tok2str(pimv2_hello_option_values, "Unknown", otype),
otype,
olen);
bp += 4;
len -= 4;
if (len < olen)
goto trunc;
ND_TCHECK_LEN(bp, olen);
switch (otype) {
case PIMV2_HELLO_OPTION_HOLDTIME:
if (olen != 2) {
ND_PRINT("[option length %u != 2]", olen);
nd_print_invalid(ndo);
return;
} else {
unsigned_relts_print(ndo,
GET_BE_U_2(bp));
}
break;
case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
if (olen != 4) {
ND_PRINT("[option length %u != 4]", olen);
nd_print_invalid(ndo);
return;
} else {
char t_bit;
uint16_t lan_delay, override_interval;
lan_delay = GET_BE_U_2(bp);
override_interval = GET_BE_U_2(bp + 2);
t_bit = (lan_delay & 0x8000)? 1 : 0;
lan_delay &= ~0x8000;
ND_PRINT("\n\t T-bit=%u, LAN delay %ums, Override interval %ums",
t_bit, lan_delay, override_interval);
}
break;
case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
case PIMV2_HELLO_OPTION_DR_PRIORITY:
switch (olen) {
case 0:
ND_PRINT("Bi-Directional Capability (Old)");
break;
case 4:
ND_PRINT("%u", GET_BE_U_4(bp));
break;
default:
ND_PRINT("[option length %u != 4]", olen);
nd_print_invalid(ndo);
return;
break;
}
break;
case PIMV2_HELLO_OPTION_GENID:
if (olen != 4) {
ND_PRINT("[option length %u != 4]", olen);
nd_print_invalid(ndo);
return;
} else {
ND_PRINT("0x%08x", GET_BE_U_4(bp));
}
break;
case PIMV2_HELLO_OPTION_REFRESH_CAP:
if (olen != 4) {
ND_PRINT("[option length %u != 4]", olen);
nd_print_invalid(ndo);
return;
} else {
ND_PRINT("v%u", GET_U_1(bp));
if (GET_U_1(bp + 1) != 0) {
ND_PRINT(", interval ");
unsigned_relts_print(ndo,
GET_U_1(bp + 1));
}
if (GET_BE_U_2(bp + 2) != 0) {
ND_PRINT(" ?0x%04x?",
GET_BE_U_2(bp + 2));
}
}
break;
case PIMV2_HELLO_OPTION_BIDIR_CAP:
break;
case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
case PIMV2_HELLO_OPTION_ADDRESS_LIST:
if (ndo->ndo_vflag > 1) {
const u_char *ptr = bp;
u_int plen = len;
while (ptr < (bp+olen)) {
ND_PRINT("\n\t ");
advance = pimv2_addr_print(ndo, ptr, plen, pimv2_unicast, pimv2_addr_len, 0);
if (advance < 0)
goto trunc;
ptr += advance;
plen -= advance;
}
}
break;
default:
if (ndo->ndo_vflag <= 1)
print_unknown_data(ndo, bp, "\n\t ", olen);
break;
}
/* do we want to see an additionally hexdump ? */
if (ndo->ndo_vflag> 1)
print_unknown_data(ndo, bp, "\n\t ", olen);
bp += olen;
len -= olen;
}
break;
}
case PIMV2_TYPE_REGISTER:
{
const struct ip *ip;
if (len < 4)
goto trunc;
ND_TCHECK_LEN(bp, PIMV2_REGISTER_FLAG_LEN);
ND_PRINT(", Flags [ %s ]\n\t",
tok2str(pimv2_register_flag_values,
"none",
GET_BE_U_4(bp)));
bp += 4; len -= 4;
/* encapsulated multicast packet */
if (len == 0)
goto trunc;
ip = (const struct ip *)bp;
switch (IP_V(ip)) {
case 0: /* Null header */
ND_PRINT("IP-Null-header %s > %s",
GET_IPADDR_STRING(ip->ip_src),
GET_IPADDR_STRING(ip->ip_dst));
break;
case 4: /* IPv4 */
ip_print(ndo, bp, len);
break;
case 6: /* IPv6 */
ip6_print(ndo, bp, len);
break;
default:
ND_PRINT("IP ver %u", IP_V(ip));
break;
}
break;
}
case PIMV2_TYPE_REGISTER_STOP:
ND_PRINT(" group=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance; len -= advance;
ND_PRINT(" source=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance; len -= advance;
break;
case PIMV2_TYPE_JOIN_PRUNE:
case PIMV2_TYPE_GRAFT:
case PIMV2_TYPE_GRAFT_ACK:
/*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |PIM Ver| Type | Addr length | Checksum |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Unicast-Upstream Neighbor Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Reserved | Num groups | Holdtime |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Multicast Group Address-1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Number of Joined Sources | Number of Pruned Sources |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Joined Source Address-1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | . |
* | . |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Joined Source Address-n |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Pruned Source Address-1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | . |
* | . |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Pruned Source Address-n |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | . |
* | . |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encoded-Multicast Group Address-n |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
{
uint8_t ngroup;
uint16_t holdtime;
uint16_t njoin;
uint16_t nprune;
u_int i, j;
if (PIM_TYPE(pim_typever) != 7) { /*not for Graft-ACK*/
ND_PRINT(", upstream-neighbor: ");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance; len -= advance;
}
if (len < 4)
goto trunc;
ND_TCHECK_4(bp);
ngroup = GET_U_1(bp + 1);
holdtime = GET_BE_U_2(bp + 2);
ND_PRINT("\n\t %u group(s)", ngroup);
if (PIM_TYPE(pim_typever) != 7) { /*not for Graft-ACK*/
ND_PRINT(", holdtime: ");
if (holdtime == 0xffff)
ND_PRINT("infinite");
else
unsigned_relts_print(ndo, holdtime);
}
bp += 4; len -= 4;
for (i = 0; i < ngroup; i++) {
ND_PRINT("\n\t group #%u: ", i+1);
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance; len -= advance;
if (len < 4)
goto trunc;
ND_TCHECK_4(bp);
njoin = GET_BE_U_2(bp);
nprune = GET_BE_U_2(bp + 2);
ND_PRINT(", joined sources: %u, pruned sources: %u", njoin, nprune);
bp += 4; len -= 4;
for (j = 0; j < njoin; j++) {
ND_PRINT("\n\t joined source #%u: ", j+1);
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_source, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance; len -= advance;
}
for (j = 0; j < nprune; j++) {
ND_PRINT("\n\t pruned source #%u: ", j+1);
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_source, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance; len -= advance;
}
}
break;
}
case PIMV2_TYPE_BOOTSTRAP:
{
u_int i, j, frpcnt;
/* Fragment Tag, Hash Mask len, and BSR-priority */
if (len < 2)
goto trunc;
ND_PRINT(" tag=%x", GET_BE_U_2(bp));
bp += 2;
len -= 2;
if (len < 1)
goto trunc;
ND_PRINT(" hashmlen=%u", GET_U_1(bp));
if (len < 2)
goto trunc;
ND_TCHECK_1(bp + 2);
ND_PRINT(" BSRprio=%u", GET_U_1(bp + 1));
bp += 2;
len -= 2;
/* Encoded-Unicast-BSR-Address */
ND_PRINT(" BSR=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance;
len -= advance;
for (i = 0; len > 0; i++) {
/* Encoded-Group Address */
ND_PRINT(" (group%u: ", i);
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance;
len -= advance;
/* RP-Count, Frag RP-Cnt, and rsvd */
if (len < 1)
goto trunc;
ND_PRINT(" RPcnt=%u", GET_U_1(bp));
if (len < 2)
goto trunc;
frpcnt = GET_U_1(bp + 1);
ND_PRINT(" FRPcnt=%u", frpcnt);
if (len < 4)
goto trunc;
bp += 4;
len -= 4;
for (j = 0; j < frpcnt && len > 0; j++) {
/* each RP info */
ND_PRINT(" RP%u=", j);
if ((advance = pimv2_addr_print(ndo, bp, len,
pimv2_unicast,
pimv2_addr_len,
0)) < 0)
goto trunc;
bp += advance;
len -= advance;
if (len < 2)
goto trunc;
ND_PRINT(",holdtime=");
unsigned_relts_print(ndo,
GET_BE_U_2(bp));
if (len < 3)
goto trunc;
ND_PRINT(",prio=%u", GET_U_1(bp + 2));
if (len < 4)
goto trunc;
bp += 4;
len -= 4;
}
ND_PRINT(")");
}
break;
}
case PIMV2_TYPE_ASSERT:
ND_PRINT(" group=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance; len -= advance;
ND_PRINT(" src=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance; len -= advance;
if (len < 8)
goto trunc;
ND_TCHECK_8(bp);
if (GET_U_1(bp) & 0x80)
ND_PRINT(" RPT");
ND_PRINT(" pref=%u", GET_BE_U_4(bp) & 0x7fffffff);
ND_PRINT(" metric=%u", GET_BE_U_4(bp + 4));
break;
case PIMV2_TYPE_CANDIDATE_RP:
{
u_int i, pfxcnt;
/* Prefix-Cnt, Priority, and Holdtime */
if (len < 1)
goto trunc;
ND_PRINT(" prefix-cnt=%u", GET_U_1(bp));
pfxcnt = GET_U_1(bp);
if (len < 2)
goto trunc;
ND_PRINT(" prio=%u", GET_U_1(bp + 1));
if (len < 4)
goto trunc;
ND_PRINT(" holdtime=");
unsigned_relts_print(ndo, GET_BE_U_2(bp + 2));
bp += 4;
len -= 4;
/* Encoded-Unicast-RP-Address */
ND_PRINT(" RP=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance;
len -= advance;
/* Encoded-Group Addresses */
for (i = 0; i < pfxcnt && len > 0; i++) {
ND_PRINT(" Group%u=", i);
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance;
len -= advance;
}
break;
}
case PIMV2_TYPE_PRUNE_REFRESH:
ND_PRINT(" src=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance;
len -= advance;
ND_PRINT(" grp=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_group, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance;
len -= advance;
ND_PRINT(" forwarder=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0)
goto trunc;
bp += advance;
len -= advance;
if (len < 2)
goto trunc;
ND_PRINT(" TUNR ");
unsigned_relts_print(ndo, GET_BE_U_2(bp));
break;
case PIMV2_TYPE_DF_ELECTION:
subtype = PIM_SUBTYPE(GET_U_1(pim->pim_rsv));
ND_PRINT("\n\t %s,", tok2str( pimv2_df_election_flag_values,
"Unknown", subtype) );
ND_PRINT(" rpa=");
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) {
goto trunc;
}
bp += advance;
len -= advance;
ND_PRINT(" sender pref=%u", GET_BE_U_4(bp) );
ND_PRINT(" sender metric=%u", GET_BE_U_4(bp + 4));
bp += 8;
len -= 8;
switch (subtype) {
case PIMV2_DF_ELECTION_BACKOFF:
case PIMV2_DF_ELECTION_PASS:
ND_PRINT("\n\t %s addr=", PIMV2_DF_ELECTION_PASS_BACKOFF_STR(subtype));
if ((advance = pimv2_addr_print(ndo, bp, len, pimv2_unicast, pimv2_addr_len, 0)) < 0) {
goto trunc;
}
bp += advance;
len -= advance;
ND_PRINT(" %s pref=%u", PIMV2_DF_ELECTION_PASS_BACKOFF_STR(subtype), GET_BE_U_4(bp) );
ND_PRINT(" %s metric=%u", PIMV2_DF_ELECTION_PASS_BACKOFF_STR(subtype), GET_BE_U_4(bp + 4));
bp += 8;
len -= 8;
if (subtype == PIMV2_DF_ELECTION_BACKOFF) {
ND_PRINT(" interval %dms", GET_BE_U_2(bp));
}
break;
default:
break;
}
break;
default:
ND_PRINT(" [type %u]", PIM_TYPE(pim_typever));
break;
}
return;
trunc:
nd_print_trunc(ndo);
}
|
ab0fda7259c5cfd72903eb85019bae7bf3aafa16
|
a433be376b08ff0f57b66390b706afc517006c2c
|
/common/thread/sleep_queue_posix.h
|
c5ebc885a79cc8906ed26ff64cb4560815141e3a
|
[
"BSD-2-Clause"
] |
permissive
|
wanproxy/wanproxy
|
aac8bb22965cafd447f6e50c2f33eab58a2e4fa2
|
76ca6cc15d8dd87f2bad7e56c935b8dfb765ae68
|
refs/heads/master
| 2021-01-17T07:44:33.711462
| 2018-02-12T07:54:22
| 2018-02-12T07:56:04
| 19,652,500
| 104
| 35
| null | 2015-04-27T06:00:40
| 2014-05-10T21:32:50
|
C++
|
UTF-8
|
C
| false
| false
| 3,547
|
h
|
sleep_queue_posix.h
|
/*
* Copyright (c) 2010-2014 Juli Mallett. 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 AUTHOR 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 AUTHOR 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 COMMON_THREAD_SLEEP_QUEUE_POSIX_H
#define COMMON_THREAD_SLEEP_QUEUE_POSIX_H
#include <unistd.h> /* For _POSIX_TIMERS */
#include <common/time/time.h>
#include "mutex_posix.h"
struct SleepQueueState {
pthread_cond_t cond_;
MutexState *mutex_state_;
bool waiting_;
SleepQueueState(MutexState *mutex_state)
: cond_(),
mutex_state_(mutex_state),
waiting_(false)
{
pthread_condattr_t attr;
int error;
error = pthread_condattr_init(&attr);
ASSERT_ZERO("/sleep/queue/posix/state", error);
/* Match behaviour/clock of NanoTime. */
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
error = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
ASSERT_ZERO("/sleep/queue/posix/state", error);
#endif
error = pthread_cond_init(&cond_, &attr);
ASSERT_ZERO("/sleep/queue/posix/state", error);
error = pthread_condattr_destroy(&attr);
ASSERT_ZERO("/sleep/queue/posix/state", error);
}
~SleepQueueState()
{
int error;
error = pthread_cond_destroy(&cond_);
ASSERT_ZERO("/sleep/queue/posix/state", error);
}
void signal(void)
{
int error;
if (!waiting_)
return;
mutex_state_->lock();
#ifndef NDEBUG
ASSERT("/sleep/queue/posix/state", mutex_state_->owner_ == Thread::selfID());
#endif
error = pthread_cond_signal(&cond_);
#ifndef NDEBUG
ASSERT("/sleep/queue/posix/state", mutex_state_->owner_ == Thread::selfID());
#endif
mutex_state_->unlock();
ASSERT_ZERO("/sleep/queue/posix/state", error);
}
void wait(const NanoTime *deadline)
{
struct timespec ts;
int error;
if (deadline != NULL) {
ts.tv_sec = deadline->seconds_;
ts.tv_nsec = deadline->nanoseconds_;
}
waiting_ = true;
#ifndef NDEBUG
mutex_state_->lock();
mutex_state_->lock_release();
#endif
if (deadline == NULL) {
error = pthread_cond_wait(&cond_, &mutex_state_->mutex_);
ASSERT_ZERO("/sleep/queue/posix/state", error);
} else {
error = pthread_cond_timedwait(&cond_, &mutex_state_->mutex_, &ts);
ASSERT("/sleep/queue/posix/state", error == 0 || error == ETIMEDOUT);
}
#ifndef NDEBUG
mutex_state_->lock_acquire();
mutex_state_->unlock();
#endif
waiting_ = false;
}
};
#endif /* !COMMON_THREAD_SLEEP_QUEUE_POSIX_H */
|
7d719995564884ddf27dd860ad58f690041fbe7f
|
7744859512f027ef0da8b1bde0f8518e631b98eb
|
/soh/src/libultra/io/devmgr.c
|
af7f4d5757effa88afe9b5f2bee17d0779477dc9
|
[] |
no_license
|
HarbourMasters/Shipwright
|
7f70b9470e4f9a117f3fe2d6e4deb776b8742182
|
0e7c6585239c0d7ea2c039b8b8cb7eaedf8928a9
|
refs/heads/develop
| 2023-08-31T20:50:56.253521
| 2023-08-30T17:34:06
| 2023-08-30T17:34:06
| 472,575,717
| 2,104
| 459
| null | 2023-09-14T20:29:01
| 2022-03-22T01:42:52
|
C
|
UTF-8
|
C
| false
| false
| 4,322
|
c
|
devmgr.c
|
#include "global.h"
#include "ultra64/internal.h"
void __osDevMgrMain(void* arg) {
OSIoMesg* ioMesg;
OSMesg sp70;
OSMesg sp6C;
OSMgrArgs* arg0 = (OSMgrArgs*)arg;
__OSTranxInfo* transfer;
__OSBlockInfo* block;
s32 phi_s2;
s32 phi_s0;
u32 sp54;
ioMesg = NULL;
while (true) {
osRecvMesg(arg0->cmdQueue, (OSMesg)&ioMesg, OS_MESG_BLOCK);
if ((ioMesg->piHandle != NULL) && (ioMesg->piHandle->type == DEVICE_TYPE_64DD) &&
((ioMesg->piHandle->transferInfo.cmdType == 0) || (ioMesg->piHandle->transferInfo.cmdType == 1))) {
transfer = &ioMesg->piHandle->transferInfo;
block = &transfer->block[transfer->blockNum];
transfer->sectorNum = -1;
if (transfer->transferMode != 3) {
block->dramAddr = (void*)((uintptr_t)block->dramAddr - block->sectorSize);
}
phi_s2 = ((transfer->transferMode == 2) && (ioMesg->piHandle->transferInfo.cmdType == 0)) ? 1 : 0;
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
__osResetGlobalIntMask(0x00100401);
__osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x80000000);
while (true) {
osRecvMesg(arg0->eventQueue, &sp70, OS_MESG_BLOCK);
transfer = &ioMesg->piHandle->transferInfo;
block = &transfer->block[transfer->blockNum];
if (block->errStatus == 0x1D) {
__osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x10000000);
__osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow);
__osEPiRawReadIo(ioMesg->piHandle, 0x05000508, &sp54);
if (sp54 & 0x02000000) {
__osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x1000000);
}
block->errStatus = 4;
HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR;
__osSetGlobalIntMask(0x00100C01);
}
osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK);
if ((phi_s2 != 1) || (ioMesg->piHandle->transferInfo.block[0].errStatus != 0)) {
break;
}
phi_s2 = 0;
}
osSendMesg(arg0->acccessQueue, 0, OS_MESG_NOBLOCK);
if (ioMesg->piHandle->transferInfo.blockNum == 1) {
osYieldThread();
}
} else {
switch (ioMesg->hdr.type) {
case OS_MESG_TYPE_DMAREAD:
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
phi_s0 = arg0->piDmaCallback(OS_READ, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size);
break;
case OS_MESG_TYPE_DMAWRITE:
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
phi_s0 = arg0->piDmaCallback(OS_WRITE, ioMesg->devAddr, ioMesg->dramAddr, ioMesg->size);
break;
case OS_MESG_TYPE_EDMAREAD:
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
phi_s0 = arg0->epiDmaCallback(ioMesg->piHandle, OS_READ, ioMesg->devAddr, ioMesg->dramAddr,
ioMesg->size);
break;
case OS_MESG_TYPE_EDMAWRITE:
osRecvMesg(arg0->acccessQueue, &sp6C, OS_MESG_BLOCK);
phi_s0 = arg0->epiDmaCallback(ioMesg->piHandle, OS_WRITE, ioMesg->devAddr, ioMesg->dramAddr,
ioMesg->size);
break;
case OS_MESG_TYPE_LOOPBACK:
osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK);
phi_s0 = -1;
break;
default:
phi_s0 = -1;
break;
}
if (phi_s0 == 0) {
osRecvMesg(arg0->eventQueue, &sp70, OS_MESG_BLOCK);
osSendMesg(ioMesg->hdr.retQueue, ioMesg, OS_MESG_NOBLOCK);
osSendMesg(arg0->acccessQueue, NULL, OS_MESG_NOBLOCK);
}
}
}
}
|
e92461eb3000a884a69d5666ac384507d650faaf
|
b0d917e5f5df080c9377a93045ffcda553319ae9
|
/src/lmic/lmic_us_like.h
|
f3e8bfcad34b481d40da0b228dadde9771c084f0
|
[
"MIT"
] |
permissive
|
mcci-catena/arduino-lmic
|
d46943bba58776d197c605eaa8771a32b5487657
|
4ceb2b049b59bb2390491f2db63e4951b986d277
|
refs/heads/master
| 2023-08-17T15:20:22.246976
| 2022-11-21T06:21:10
| 2022-11-21T06:21:10
| 67,839,795
| 610
| 247
|
MIT
| 2023-08-09T02:54:25
| 2016-09-09T23:49:49
|
C
|
UTF-8
|
C
| false
| false
| 5,141
|
h
|
lmic_us_like.h
|
/*
* Copyright (c) 2014-2016 IBM Corporation.
* Copyright (c) 2017, 2019 MCCI 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:
* * 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 <organization> 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 <COPYRIGHT HOLDER> 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 _lmic_us_like_h_
# define _lmic_us_like_h_
// make sure we want US-like code
#if !CFG_LMIC_US_like
# error "lmic not configured for us-like bandplan"
#endif
// TODO(tmm@mcci.com): this should come from the lmic.h or lorabase.h file; and
// it's probably affected by the fix to this issue:
// https://github.com/mcci-catena/arduino-lmic/issues/2
#define DNW2_SAFETY_ZONE ms2osticks(750)
#define IS_CHANNEL_125khz(c) (c<64)
#define IS_CHANNEL_500khz(c) (c>=64 && c<72)
#define ENABLED_CHANNEL(chnl) ((LMIC.channelMap[(chnl >> 4)] & (1<<(chnl & 0x0F))) != 0)
// library functions: called from bandplan
void LMICuslike_initJoinLoop(void);
// provide the isValidBeacon1 function -- int for bool.
static inline int
LMICuslike_isValidBeacon1(const uint8_t *d) {
return os_rlsbf2(&d[OFF_BCN_CRC1]) != os_crc16(d, OFF_BCN_CRC1);
}
#define LMICbandplan_isValidBeacon1(pFrame) LMICuslike_isValidBeacon1(pFrame)
// provide a default for LMICbandplan_isFSK()
#define LMICbandplan_isFSK() (0)
// provide a default LMICbandplan_txDoneFSK()
#define LMICbandplan_txDoneFSK(delay, func) do { } while (0)
// provide a default LMICbandplan_joinAcceptChannelClear()
#define LMICbandplan_joinAcceptChannelClear() do { } while (0)
/// \brief there's a CFList on joins for US-like plans
#define LMICbandplan_hasJoinCFlist() (1)
/// \brief process CFLists from JoinAccept for EU-like regions
void LMICuslike_processJoinAcceptCFList(void);
/// \brief by default, EU-like plans use LMICuslike_processJoinAcceptCFList
#define LMICbandplan_processJoinAcceptCFList LMICuslike_processJoinAcceptCFList
#define LMICbandplan_advanceBeaconChannel() \
do { LMIC.bcnChnl = (LMIC.bcnChnl+1) & 7; } while (0)
// TODO(tmm@mcci.com): decide whether we want to do this on every
// reset or just restore the last sub-band selected by the user.
#define LMICbandplan_resetDefaultChannels() \
LMICbandplan_initDefaultChannels(/* normal */ 0)
void LMICuslike_initDefaultChannels(bit_t fJoin);
#define LMICbandplan_initDefaultChannels(fJoin) LMICuslike_initDefaultChannels(fJoin)
#define LMICbandplan_setSessionInitDefaultChannels() \
do { /* nothing */} while (0)
bit_t LMICuslike_canMapChannels(u1_t chpage, u2_t chmap);
#define LMICbandplan_canMapChannels(chpage, chmap) LMICuslike_canMapChannels(chpage, chmap)
bit_t LMICuslike_mapChannels(u1_t chpage, u2_t chmap);
#define LMICbandplan_mapChannels(chpage, chmap) LMICuslike_mapChannels(chpage, chmap)
ostime_t LMICuslike_nextTx(ostime_t now);
#define LMICbandplan_nextTx(now) LMICuslike_nextTx(now)
ostime_t LMICuslike_nextJoinState(void);
#define LMICbandplan_nextJoinState() LMICuslike_nextJoinState();
static inline ostime_t LMICuslike_nextJoinTime(ostime_t now) {
return now;
}
#define LMICbandplan_nextJoinTime(now) LMICuslike_nextJoinTime(now)
#define LMICbandplan_init() \
do { /* nothing */ } while (0)
void LMICuslike_saveAdrState(lmic_saved_adr_state_t *pStateBuffer);
#define LMICbandplan_saveAdrState(pState) LMICuslike_saveAdrState(pState)
bit_t LMICuslike_compareAdrState(const lmic_saved_adr_state_t *pStateBuffer);
#define LMICbandplan_compareAdrState(pState) LMICuslike_compareAdrState(pState)
void LMICuslike_restoreAdrState(const lmic_saved_adr_state_t *pStateBuffer);
#define LMICbandplan_restoreAdrState(pState) LMICuslike_restoreAdrState(pState)
bit_t LMICuslike_isDataRateFeasible(dr_t dr);
#define LMICbandplan_isDataRateFeasible(dr) LMICuslike_isDataRateFeasible(dr)
#endif // _lmic_us_like_h_
|
bd8c77718d19d55151083cf5cfca1c1cf33607e1
|
488e6c9b8555a253df765edc2232e8750e8b3a1b
|
/firmware-src/sources/commands/ws2812b_cmd.h
|
5dc15e1e4917028ad9ccd2ccc726e068dd64f27d
|
[
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] |
permissive
|
devicehive/esp8266-firmware
|
32edadae1d919438fd13388b562979030cc4472a
|
eb8a61482035bfc93a343db386d4470d17fa13d6
|
refs/heads/develop
| 2021-01-01T16:44:57.970370
| 2019-03-28T12:48:43
| 2019-03-28T12:48:43
| 39,383,605
| 182
| 61
|
MIT
| 2018-05-07T20:43:14
| 2015-07-20T12:53:51
|
C
|
UTF-8
|
C
| false
| false
| 659
|
h
|
ws2812b_cmd.h
|
/**
* @file
* @brief Onewire WS2812B command handlers.
* @copyright 2015 [DeviceHive](http://devicehive.com)
* @author Nikolay Khabarov
*/
#ifndef _COMMANDS_WS2812B_CMD_H_
#define _COMMANDS_WS2812B_CMD_H_
#include "user_config.h"
#if defined(DH_COMMANDS_ONEWIRE) // onewire WS2812B command handlers
#include "dhsender_data.h"
#include "dhcommand_parser.h"
/**
* @brief Handle "onewire/ws2812b/write" command.
*/
void dh_handle_onewire_ws2812b_write(COMMAND_RESULT *cmd_res, const char *command,
const char *params, unsigned int params_len);
#endif /* DH_COMMANDS_ONEWIRE */
#endif /* _COMMANDS_WS2812B_CMD_H_ */
|
d2ef5c88f9124fdaea79953c9852028996ceea7a
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/dev/tc/cfb.c
|
73b0c08bee6af7577ee5a3004bcde49f583f7c6e
|
[] |
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
| 21,189
|
c
|
cfb.c
|
/* $NetBSD: cfb.c,v 1.66 2021/12/06 16:00:07 abs Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Tohru Nishimura.
*
* 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: cfb.c,v 1.66 2021/12/06 16:00:07 abs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/ioctl.h>
#include <sys/bus.h>
#include <sys/intr.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/rasops/rasops.h>
#include <dev/wsfont/wsfont.h>
#include <dev/tc/tcvar.h>
#include <dev/ic/bt459reg.h>
#if defined(pmax)
#define machine_btop(x) mips_btop(MIPS_KSEG1_TO_PHYS(x))
#endif
#if defined(alpha)
#define machine_btop(x) alpha_btop(ALPHA_K0SEG_TO_PHYS(x))
#endif
/*
* N.B., Bt459 registers are 8bit width. Some of TC framebuffers have
* obscure register layout such as 2nd and 3rd Bt459 registers are
* adjacent each other in a word, i.e.,
* struct bt459triplet {
* struct {
* uint8_t u0;
* uint8_t u1;
* uint8_t u2;
* unsigned :8;
* } bt_lo;
* ...
* Although CX has single Bt459, 32bit R/W can be done w/o any trouble.
* struct bt459reg {
* uint32_t bt_lo;
* uint32_t bt_hi;
* uint32_t bt_reg;
* uint32_t bt_cmap;
* };
*/
/* Bt459 hardware registers, memory-mapped in 32bit stride */
#define bt_lo 0x0
#define bt_hi 0x4
#define bt_reg 0x8
#define bt_cmap 0xc
#define REGWRITE32(p,i,v) do { \
*(volatile uint32_t *)((p) + (i)) = (v); tc_wmb(); \
} while (0)
#define VDACSELECT(p,r) do { \
REGWRITE32(p, bt_lo, 0xff & (r)); \
REGWRITE32(p, bt_hi, 0x0f & ((r)>>8)); \
} while (0)
struct hwcmap256 {
#define CMAP_SIZE 256 /* 256 R/G/B entries */
uint8_t r[CMAP_SIZE];
uint8_t g[CMAP_SIZE];
uint8_t b[CMAP_SIZE];
};
struct hwcursor64 {
struct wsdisplay_curpos cc_pos;
struct wsdisplay_curpos cc_hot;
struct wsdisplay_curpos cc_size;
struct wsdisplay_curpos cc_magic;
#define CURSOR_MAX_SIZE 64
uint8_t cc_color[6];
uint64_t cc_image[CURSOR_MAX_SIZE];
uint64_t cc_mask[CURSOR_MAX_SIZE];
};
struct cfb_softc {
vaddr_t sc_vaddr;
size_t sc_size;
struct rasops_info *sc_ri;
struct hwcmap256 sc_cmap; /* software copy of colormap */
struct hwcursor64 sc_cursor; /* software copy of cursor */
int sc_blanked;
int sc_curenb; /* cursor sprite enabled */
int sc_changed; /* need update of hardware */
#define WSDISPLAY_CMAP_DOLUT 0x20
int nscreens;
};
#define CX_MAGIC_X 220
#define CX_MAGIC_Y 35
#define CX_FB_OFFSET 0x000000
#define CX_FB_SIZE 0x100000
#define CX_BT459_OFFSET 0x200000
#define CX_OFFSET_IREQ 0x300000 /* Interrupt req. control */
static int cfbmatch(device_t, cfdata_t, void *);
static void cfbattach(device_t, device_t, void *);
CFATTACH_DECL_NEW(cfb, sizeof(struct cfb_softc),
cfbmatch, cfbattach, NULL, NULL);
static void cfb_common_init(struct rasops_info *);
static struct rasops_info cfb_console_ri;
static tc_addr_t cfb_consaddr;
static struct wsscreen_descr cfb_stdscreen = {
"std", 0, 0,
0, /* textops */
0, 0,
WSSCREEN_REVERSE
};
static const struct wsscreen_descr *_cfb_scrlist[] = {
&cfb_stdscreen,
};
static const struct wsscreen_list cfb_screenlist = {
sizeof(_cfb_scrlist) / sizeof(struct wsscreen_descr *), _cfb_scrlist
};
static int cfbioctl(void *, void *, u_long, void *, int, struct lwp *);
static paddr_t cfbmmap(void *, void *, off_t, int);
static int cfb_alloc_screen(void *, const struct wsscreen_descr *,
void **, int *, int *, long *);
static void cfb_free_screen(void *, void *);
static int cfb_show_screen(void *, void *, int,
void (*) (void *, int, int), void *);
static const struct wsdisplay_accessops cfb_accessops = {
cfbioctl,
cfbmmap,
cfb_alloc_screen,
cfb_free_screen,
cfb_show_screen,
0 /* load_font */
};
int cfb_cnattach(tc_addr_t);
static int cfbintr(void *);
static void cfbhwinit(void *);
static void cfb_cmap_init(struct cfb_softc *);
static int get_cmap(struct cfb_softc *, struct wsdisplay_cmap *);
static int set_cmap(struct cfb_softc *, struct wsdisplay_cmap *);
static int set_cursor(struct cfb_softc *, struct wsdisplay_cursor *);
static int get_cursor(struct cfb_softc *, struct wsdisplay_cursor *);
static void set_curpos(struct cfb_softc *, struct wsdisplay_curpos *);
/*
* Compose 2 bit/pixel cursor image. Bit order will be reversed.
* M M M M I I I I M I M I M I M I
* [ before ] [ after ]
* 3 2 1 0 3 2 1 0 0 0 1 1 2 2 3 3
* 7 6 5 4 7 6 5 4 4 4 5 5 6 6 7 7
*/
static const uint8_t shuffle[256] = {
0x00, 0x40, 0x10, 0x50, 0x04, 0x44, 0x14, 0x54,
0x01, 0x41, 0x11, 0x51, 0x05, 0x45, 0x15, 0x55,
0x80, 0xc0, 0x90, 0xd0, 0x84, 0xc4, 0x94, 0xd4,
0x81, 0xc1, 0x91, 0xd1, 0x85, 0xc5, 0x95, 0xd5,
0x20, 0x60, 0x30, 0x70, 0x24, 0x64, 0x34, 0x74,
0x21, 0x61, 0x31, 0x71, 0x25, 0x65, 0x35, 0x75,
0xa0, 0xe0, 0xb0, 0xf0, 0xa4, 0xe4, 0xb4, 0xf4,
0xa1, 0xe1, 0xb1, 0xf1, 0xa5, 0xe5, 0xb5, 0xf5,
0x08, 0x48, 0x18, 0x58, 0x0c, 0x4c, 0x1c, 0x5c,
0x09, 0x49, 0x19, 0x59, 0x0d, 0x4d, 0x1d, 0x5d,
0x88, 0xc8, 0x98, 0xd8, 0x8c, 0xcc, 0x9c, 0xdc,
0x89, 0xc9, 0x99, 0xd9, 0x8d, 0xcd, 0x9d, 0xdd,
0x28, 0x68, 0x38, 0x78, 0x2c, 0x6c, 0x3c, 0x7c,
0x29, 0x69, 0x39, 0x79, 0x2d, 0x6d, 0x3d, 0x7d,
0xa8, 0xe8, 0xb8, 0xf8, 0xac, 0xec, 0xbc, 0xfc,
0xa9, 0xe9, 0xb9, 0xf9, 0xad, 0xed, 0xbd, 0xfd,
0x02, 0x42, 0x12, 0x52, 0x06, 0x46, 0x16, 0x56,
0x03, 0x43, 0x13, 0x53, 0x07, 0x47, 0x17, 0x57,
0x82, 0xc2, 0x92, 0xd2, 0x86, 0xc6, 0x96, 0xd6,
0x83, 0xc3, 0x93, 0xd3, 0x87, 0xc7, 0x97, 0xd7,
0x22, 0x62, 0x32, 0x72, 0x26, 0x66, 0x36, 0x76,
0x23, 0x63, 0x33, 0x73, 0x27, 0x67, 0x37, 0x77,
0xa2, 0xe2, 0xb2, 0xf2, 0xa6, 0xe6, 0xb6, 0xf6,
0xa3, 0xe3, 0xb3, 0xf3, 0xa7, 0xe7, 0xb7, 0xf7,
0x0a, 0x4a, 0x1a, 0x5a, 0x0e, 0x4e, 0x1e, 0x5e,
0x0b, 0x4b, 0x1b, 0x5b, 0x0f, 0x4f, 0x1f, 0x5f,
0x8a, 0xca, 0x9a, 0xda, 0x8e, 0xce, 0x9e, 0xde,
0x8b, 0xcb, 0x9b, 0xdb, 0x8f, 0xcf, 0x9f, 0xdf,
0x2a, 0x6a, 0x3a, 0x7a, 0x2e, 0x6e, 0x3e, 0x7e,
0x2b, 0x6b, 0x3b, 0x7b, 0x2f, 0x6f, 0x3f, 0x7f,
0xaa, 0xea, 0xba, 0xfa, 0xae, 0xee, 0xbe, 0xfe,
0xab, 0xeb, 0xbb, 0xfb, 0xaf, 0xef, 0xbf, 0xff,
};
static int
cfbmatch(device_t parent, cfdata_t match, void *aux)
{
struct tc_attach_args *ta = aux;
if (strncmp("PMAG-BA ", ta->ta_modname, TC_ROM_LLEN) != 0)
return (0);
return (1);
}
static void
cfbattach(device_t parent, device_t self, void *aux)
{
struct cfb_softc *sc = device_private(self);
struct tc_attach_args *ta = aux;
struct rasops_info *ri;
struct wsemuldisplaydev_attach_args waa;
int console;
console = (ta->ta_addr == cfb_consaddr);
if (console) {
sc->sc_ri = ri = &cfb_console_ri;
ri->ri_flg &= ~RI_NO_AUTO;
sc->nscreens = 1;
}
else {
ri = malloc(sizeof(struct rasops_info),
M_DEVBUF, M_WAITOK | M_ZERO);
ri->ri_hw = (void *)ta->ta_addr;
cfb_common_init(ri);
sc->sc_ri = ri;
}
printf(": %dx%d, %dbpp\n", ri->ri_width, ri->ri_height, ri->ri_depth);
cfb_cmap_init(sc);
sc->sc_vaddr = ta->ta_addr;
sc->sc_cursor.cc_magic.x = CX_MAGIC_X;
sc->sc_cursor.cc_magic.y = CX_MAGIC_Y;
sc->sc_blanked = sc->sc_curenb = 0;
tc_intr_establish(parent, ta->ta_cookie, IPL_TTY, cfbintr, sc);
/* clear any pending interrupts */
*(volatile uint8_t *)((char *)ri->ri_hw + CX_OFFSET_IREQ) = 0;
waa.console = console;
waa.scrdata = &cfb_screenlist;
waa.accessops = &cfb_accessops;
waa.accesscookie = sc;
config_found(self, &waa, wsemuldisplaydevprint, CFARGS_NONE);
}
static void
cfb_cmap_init(struct cfb_softc *sc)
{
struct hwcmap256 *cm;
const uint8_t *p;
int index;
cm = &sc->sc_cmap;
p = rasops_cmap;
for (index = 0; index < CMAP_SIZE; index++, p += 3) {
cm->r[index] = p[0];
cm->g[index] = p[1];
cm->b[index] = p[2];
}
}
static void
cfb_common_init(struct rasops_info *ri)
{
char *base;
int cookie;
base = (void *)ri->ri_hw;
/* initialize colormap and cursor hardware */
cfbhwinit(base);
ri->ri_flg = RI_CENTER;
if (ri == &cfb_console_ri)
ri->ri_flg |= RI_NO_AUTO;
ri->ri_depth = 8;
ri->ri_width = 1024;
ri->ri_height = 864;
ri->ri_stride = 1024;
ri->ri_bits = base + CX_FB_OFFSET;
/* clear the screen */
memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
wsfont_init();
/* prefer 12 pixel wide font */
cookie = wsfont_find(NULL, 12, 0, 0, WSDISPLAY_FONTORDER_L2R,
WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP);
if (cookie <= 0)
cookie = wsfont_find(NULL, 0, 0, 0, WSDISPLAY_FONTORDER_L2R,
WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP);
if (cookie <= 0) {
printf("cfb: font table is empty\n");
return;
}
if (wsfont_lock(cookie, &ri->ri_font)) {
printf("cfb: couldn't lock font\n");
return;
}
ri->ri_wsfcookie = cookie;
rasops_init(ri, 34, 80);
/* XXX shouldn't be global */
cfb_stdscreen.nrows = ri->ri_rows;
cfb_stdscreen.ncols = ri->ri_cols;
cfb_stdscreen.textops = &ri->ri_ops;
cfb_stdscreen.capabilities = ri->ri_caps;
}
static int
cfbioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
{
struct cfb_softc *sc = v;
struct rasops_info *ri = sc->sc_ri;
int turnoff, s;
switch (cmd) {
case WSDISPLAYIO_GTYPE:
*(u_int *)data = WSDISPLAY_TYPE_CFB;
return (0);
case WSDISPLAYIO_GET_FBINFO: {
struct wsdisplayio_fbinfo *fbi = data;
return wsdisplayio_get_fbinfo(sc->sc_ri, fbi);
}
case WSDISPLAYIO_GINFO:
#define wsd_fbip ((struct wsdisplay_fbinfo *)data)
wsd_fbip->height = ri->ri_height;
wsd_fbip->width = ri->ri_width;
wsd_fbip->depth = ri->ri_depth;
wsd_fbip->cmsize = CMAP_SIZE;
#undef fbt
return (0);
case WSDISPLAYIO_GETCMAP:
return get_cmap(sc, (struct wsdisplay_cmap *)data);
case WSDISPLAYIO_PUTCMAP:
return set_cmap(sc, (struct wsdisplay_cmap *)data);
case WSDISPLAYIO_SVIDEO:
turnoff = *(int *)data == WSDISPLAYIO_VIDEO_OFF;
if (sc->sc_blanked != turnoff) {
sc->sc_blanked = turnoff;
/* XXX later XXX */
}
return (0);
case WSDISPLAYIO_GVIDEO:
*(u_int *)data = sc->sc_blanked ?
WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
return (0);
case WSDISPLAYIO_GCURPOS:
*(struct wsdisplay_curpos *)data = sc->sc_cursor.cc_pos;
return (0);
case WSDISPLAYIO_SCURPOS:
s = spltty();
set_curpos(sc, (struct wsdisplay_curpos *)data);
sc->sc_changed |= WSDISPLAY_CURSOR_DOPOS;
splx(s);
return (0);
case WSDISPLAYIO_GCURMAX:
((struct wsdisplay_curpos *)data)->x =
((struct wsdisplay_curpos *)data)->y = CURSOR_MAX_SIZE;
return (0);
case WSDISPLAYIO_GCURSOR:
return get_cursor(sc, (struct wsdisplay_cursor *)data);
case WSDISPLAYIO_SCURSOR:
return set_cursor(sc, (struct wsdisplay_cursor *)data);
case WSDISPLAYIO_SMODE:
if (*(int *)data == WSDISPLAYIO_MODE_EMUL) {
s = spltty();
cfb_cmap_init(sc);
sc->sc_curenb = 0;
sc->sc_blanked = 0;
sc->sc_changed |= (WSDISPLAY_CURSOR_DOCUR |
WSDISPLAY_CMAP_DOLUT);
splx(s);
}
return (0);
}
return EPASSTHROUGH;
}
paddr_t
cfbmmap(void *v, void *vs, off_t offset, int prot)
{
struct cfb_softc *sc = v;
if (offset >= CX_FB_SIZE || offset < 0)
return (-1);
return machine_btop(sc->sc_vaddr + CX_FB_OFFSET + offset);
}
static int
cfb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
int *curxp, int *curyp, long *attrp)
{
struct cfb_softc *sc = v;
struct rasops_info *ri = sc->sc_ri;
long defattr;
if (sc->nscreens > 0)
return (ENOMEM);
*cookiep = ri; /* one and only for now */
*curxp = 0;
*curyp = 0;
(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
*attrp = defattr;
sc->nscreens++;
return (0);
}
static void
cfb_free_screen(void *v, void *cookie)
{
struct cfb_softc *sc = v;
if (sc->sc_ri == &cfb_console_ri)
panic("cfb_free_screen: console");
sc->nscreens--;
}
static int
cfb_show_screen(void *v, void *cookie, int waitok,
void (*cb)(void *, int, int), void *cbarg)
{
return (0);
}
/* EXPORT */ int
cfb_cnattach(tc_addr_t addr)
{
struct rasops_info *ri;
long defattr;
ri = &cfb_console_ri;
ri->ri_hw = (void *)addr;
cfb_common_init(ri);
(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
wsdisplay_cnattach(&cfb_stdscreen, ri, 0, 0, defattr);
cfb_consaddr = addr;
return(0);
}
static int
cfbintr(void *arg)
{
struct cfb_softc *sc = arg;
char *base, *vdac;
int v;
base = (void *)sc->sc_ri->ri_hw;
*(uint8_t *)(base + CX_OFFSET_IREQ) = 0;
if (sc->sc_changed == 0)
return (1);
vdac = base + CX_BT459_OFFSET;
v = sc->sc_changed;
if (v & WSDISPLAY_CURSOR_DOCUR) {
VDACSELECT(vdac, BT459_IREG_CCR);
REGWRITE32(vdac, bt_reg, (sc->sc_curenb) ? 0xc0 : 0x00);
}
if (v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) {
int x, y;
x = sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x;
y = sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y;
x += sc->sc_cursor.cc_magic.x;
y += sc->sc_cursor.cc_magic.y;
VDACSELECT(vdac, BT459_IREG_CURSOR_X_LOW);
REGWRITE32(vdac, bt_reg, x);
REGWRITE32(vdac, bt_reg, x >> 8);
REGWRITE32(vdac, bt_reg, y);
REGWRITE32(vdac, bt_reg, y >> 8);
}
if (v & WSDISPLAY_CURSOR_DOCMAP) {
uint8_t *cp = sc->sc_cursor.cc_color;
VDACSELECT(vdac, BT459_IREG_CCOLOR_2);
REGWRITE32(vdac, bt_reg, cp[1]);
REGWRITE32(vdac, bt_reg, cp[3]);
REGWRITE32(vdac, bt_reg, cp[5]);
REGWRITE32(vdac, bt_reg, cp[0]);
REGWRITE32(vdac, bt_reg, cp[2]);
REGWRITE32(vdac, bt_reg, cp[4]);
}
if (v & WSDISPLAY_CURSOR_DOSHAPE) {
uint8_t *ip, *mp, img, msk;
uint8_t u;
int bcnt;
ip = (uint8_t *)sc->sc_cursor.cc_image;
mp = (uint8_t *)sc->sc_cursor.cc_mask;
bcnt = 0;
VDACSELECT(vdac, BT459_IREG_CRAM_BASE+0);
/* 64 pixel scan line is consisted with 16 byte cursor ram */
while (bcnt < sc->sc_cursor.cc_size.y * 16) {
/* pad right half 32 pixel when smaller than 33 */
if ((bcnt & 0x8) && sc->sc_cursor.cc_size.x < 33) {
REGWRITE32(vdac, bt_reg, 0);
REGWRITE32(vdac, bt_reg, 0);
}
else {
img = *ip++;
msk = *mp++;
img &= msk; /* cookie off image */
u = (msk & 0x0f) << 4 | (img & 0x0f);
REGWRITE32(vdac, bt_reg, shuffle[u]);
u = (msk & 0xf0) | (img & 0xf0) >> 4;
REGWRITE32(vdac, bt_reg, shuffle[u]);
}
bcnt += 2;
}
/* pad unoccupied scan lines */
while (bcnt < CURSOR_MAX_SIZE * 16) {
REGWRITE32(vdac, bt_reg, 0);
REGWRITE32(vdac, bt_reg, 0);
bcnt += 2;
}
}
if (v & WSDISPLAY_CMAP_DOLUT) {
struct hwcmap256 *cm = &sc->sc_cmap;
int index;
VDACSELECT(vdac, 0);
for (index = 0; index < CMAP_SIZE; index++) {
REGWRITE32(vdac, bt_cmap, cm->r[index]);
REGWRITE32(vdac, bt_cmap, cm->g[index]);
REGWRITE32(vdac, bt_cmap, cm->b[index]);
}
}
sc->sc_changed = 0;
return (1);
}
static void
cfbhwinit(void *cfbbase)
{
char *vdac = (char *)cfbbase + CX_BT459_OFFSET;
const uint8_t *p;
int i;
VDACSELECT(vdac, BT459_IREG_COMMAND_0);
REGWRITE32(vdac, bt_reg, 0x40); /* CMD0 */
REGWRITE32(vdac, bt_reg, 0x0); /* CMD1 */
REGWRITE32(vdac, bt_reg, 0xc0); /* CMD2 */
REGWRITE32(vdac, bt_reg, 0xff); /* PRM */
REGWRITE32(vdac, bt_reg, 0); /* 205 */
REGWRITE32(vdac, bt_reg, 0x0); /* PBM */
REGWRITE32(vdac, bt_reg, 0); /* 207 */
REGWRITE32(vdac, bt_reg, 0x0); /* ORM */
REGWRITE32(vdac, bt_reg, 0x0); /* OBM */
REGWRITE32(vdac, bt_reg, 0x0); /* ILV */
REGWRITE32(vdac, bt_reg, 0x0); /* TEST */
VDACSELECT(vdac, BT459_IREG_CCR);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
REGWRITE32(vdac, bt_reg, 0x0);
/* build sane colormap */
VDACSELECT(vdac, 0);
p = rasops_cmap;
for (i = 0; i < CMAP_SIZE; i++, p += 3) {
REGWRITE32(vdac, bt_cmap, p[0]);
REGWRITE32(vdac, bt_cmap, p[1]);
REGWRITE32(vdac, bt_cmap, p[2]);
}
/* clear out cursor image */
VDACSELECT(vdac, BT459_IREG_CRAM_BASE);
for (i = 0; i < 1024; i++)
REGWRITE32(vdac, bt_reg, 0xff);
/*
* 2 bit/pixel cursor. Assign MSB for cursor mask and LSB for
* cursor image. CCOLOR_2 for mask color, while CCOLOR_3 for
* image color. CCOLOR_1 will be never used.
*/
VDACSELECT(vdac, BT459_IREG_CCOLOR_1);
REGWRITE32(vdac, bt_reg, 0xff);
REGWRITE32(vdac, bt_reg, 0xff);
REGWRITE32(vdac, bt_reg, 0xff);
REGWRITE32(vdac, bt_reg, 0);
REGWRITE32(vdac, bt_reg, 0);
REGWRITE32(vdac, bt_reg, 0);
REGWRITE32(vdac, bt_reg, 0xff);
REGWRITE32(vdac, bt_reg, 0xff);
REGWRITE32(vdac, bt_reg, 0xff);
}
static int
get_cmap(struct cfb_softc *sc, struct wsdisplay_cmap *p)
{
u_int index = p->index, count = p->count;
int error;
if (index >= CMAP_SIZE || count > CMAP_SIZE - index)
return (EINVAL);
error = copyout(&sc->sc_cmap.r[index], p->red, count);
if (error)
return error;
error = copyout(&sc->sc_cmap.g[index], p->green, count);
if (error)
return error;
error = copyout(&sc->sc_cmap.b[index], p->blue, count);
return error;
}
static int
set_cmap(struct cfb_softc *sc, struct wsdisplay_cmap *p)
{
struct hwcmap256 cmap;
u_int index = p->index, count = p->count;
int error, s;
if (index >= CMAP_SIZE || count > CMAP_SIZE - index)
return (EINVAL);
error = copyin(p->red, &cmap.r[index], count);
if (error)
return error;
error = copyin(p->green, &cmap.g[index], count);
if (error)
return error;
error = copyin(p->blue, &cmap.b[index], count);
if (error)
return error;
s = spltty();
memcpy(&sc->sc_cmap.r[index], &cmap.r[index], count);
memcpy(&sc->sc_cmap.g[index], &cmap.g[index], count);
memcpy(&sc->sc_cmap.b[index], &cmap.b[index], count);
sc->sc_changed |= WSDISPLAY_CMAP_DOLUT;
splx(s);
return (0);
}
static int
set_cursor(struct cfb_softc *sc, struct wsdisplay_cursor *p)
{
#define cc (&sc->sc_cursor)
u_int v, index = 0, count = 0, icount = 0;
uint8_t r[2], g[2], b[2], image[512], mask[512];
int error, s;
v = p->which;
if (v & WSDISPLAY_CURSOR_DOCMAP) {
index = p->cmap.index;
count = p->cmap.count;
if (index >= 2 || count > 2 - index)
return (EINVAL);
error = copyin(p->cmap.red, &r[index], count);
if (error)
return error;
error = copyin(p->cmap.green, &g[index], count);
if (error)
return error;
error = copyin(p->cmap.blue, &b[index], count);
if (error)
return error;
}
if (v & WSDISPLAY_CURSOR_DOSHAPE) {
if (p->size.x > CURSOR_MAX_SIZE || p->size.y > CURSOR_MAX_SIZE)
return (EINVAL);
icount = ((p->size.x < 33) ? 4 : 8) * p->size.y;
error = copyin(p->image, image, icount);
if (error)
return error;
error = copyin(p->mask, mask, icount);
if (error)
return error;
}
s = spltty();
if (v & WSDISPLAY_CURSOR_DOCUR)
sc->sc_curenb = p->enable;
if (v & WSDISPLAY_CURSOR_DOPOS)
set_curpos(sc, &p->pos);
if (v & WSDISPLAY_CURSOR_DOHOT)
cc->cc_hot = p->hot;
if (v & WSDISPLAY_CURSOR_DOCMAP) {
memcpy(&cc->cc_color[index], &r[index], count);
memcpy(&cc->cc_color[index + 2], &g[index], count);
memcpy(&cc->cc_color[index + 4], &b[index], count);
}
if (v & WSDISPLAY_CURSOR_DOSHAPE) {
cc->cc_size = p->size;
memset(cc->cc_image, 0, sizeof cc->cc_image);
memcpy(cc->cc_image, image, icount);
memset(cc->cc_mask, 0, sizeof cc->cc_mask);
memcpy(cc->cc_mask, mask, icount);
}
sc->sc_changed |= v;
splx(s);
return (0);
#undef cc
}
static int
get_cursor(struct cfb_softc *sc, struct wsdisplay_cursor *p)
{
return (EPASSTHROUGH); /* XXX */
}
static void
set_curpos(struct cfb_softc *sc, struct wsdisplay_curpos *curpos)
{
struct rasops_info *ri = sc->sc_ri;
int x = curpos->x, y = curpos->y;
if (y < 0)
y = 0;
else if (y > ri->ri_height)
y = ri->ri_height;
if (x < 0)
x = 0;
else if (x > ri->ri_width)
x = ri->ri_width;
sc->sc_cursor.cc_pos.x = x;
sc->sc_cursor.cc_pos.y = y;
}
|
5572343d6b2d2b139b0e4765424a3754ca82e7bc
|
03666e5f961946fc1a0ac67781ac1425562ef0d7
|
/src/databases/lata/OperatorDualMesh.C
|
6498741dd4a8c7492304e0286f34f5bba3cfadb0
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
visit-dav/visit
|
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
|
601ae46e0bef2e18425b482a755d03490ade0493
|
refs/heads/develop
| 2023-09-06T08:19:38.397058
| 2023-09-05T21:29:32
| 2023-09-05T21:29:32
| 165,565,988
| 335
| 120
|
BSD-3-Clause
| 2023-09-14T00:53:37
| 2019-01-13T23:27:26
|
C
|
UTF-8
|
C
| false
| false
| 8,986
|
c
|
OperatorDualMesh.C
|
/*****************************************************************************
*
* Copyright (c) 2011, CEA
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * 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 CEA, 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 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 AND 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 <LataFilter.h>
#include <Operator.h>
// Journal level
#define verb_level 4
void build_geometry_(OperatorDualMesh & op,
const DomainUnstructured & src, LataDeriv<Domain> & dest_domain)
{
Journal(verb_level) << "OperatorDualMesh geometry(unstructured) " << src.id_.name_ << endl;
if (!src.faces_ok()) {
Journal() << "Error in OperatorDualMesh::build_geometry: source domain has no faces data" << endl;
throw;
}
const int max_nb_som_face = 3; // for tetrahedra
if (src.elt_type_ != Domain::triangle && src.elt_type_ != Domain::tetra) {
Journal() << "Error in OperatorDualMesh::build_geometry: cannot operate on unstructured mesh with this element type" << endl;
throw;
}
const entier nb_som = src.nodes_.dimension(0);
const entier nb_elem = src.elem_faces_.dimension(0); // Not elements_, in case elem_faces_ has no virtual data.
const entier dim = src.dimension();
DomainUnstructured & dest = dest_domain.instancie(DomainUnstructured);
dest.id_ = src.id_;
dest.id_.name_ += "_dual";
dest.elt_type_ = src.elt_type_;
dest.nodes_ = src.nodes_;
dest.nodes_.resize(nb_som + nb_elem, dim);
src.compute_cell_center_coordinates(dest.nodes_, nb_som);
const entier nb_faces_elem = src.elem_faces_.dimension(1);
const entier nb_som_face = src.faces_.dimension(1);
const entier nb_som_elem = src.elements_.dimension(1);
dest.elements_.resize(nb_elem * nb_faces_elem, nb_som_elem);
int index = 0;
for (int i = 0; i < nb_elem; i++) {
const int central_node = nb_som + i;
for (int j = 0; j < nb_faces_elem; j++) {
const int face = src.elem_faces_(i, j);
dest.elements_(index, 0) = central_node;
for (int k = 0; k < loop_max(nb_som_face, max_nb_som_face); k++) {
dest.elements_(index, k+1) = src.faces_(face, k);
break_loop(k, nb_som_face);
}
index++;
}
}
const entier nb_elem_virt = src.nb_virt_items(LataField_base::ELEM);
dest.set_nb_virt_items(LataField_base::ELEM, nb_elem_virt * nb_faces_elem);
}
// Builds a field on the dual domain from the field on the source domain.
// Source field must be located at faces.
// (destination field is located at the elements. the value for an element
// is the value associated to the adjacent face of the source domain).
template <class TabType>
void build_field_(OperatorDualMesh & op,
const DomainUnstructured & src_domain,
const DomainUnstructured & dest_domain,
const Field<TabType> & src,
Field<TabType> & dest)
{
Journal(verb_level) << "OperatorDualMesh field(unstructured) " << src.id_.uname_ << endl;
dest.component_names_ = src.component_names_;
dest.localisation_ = LataField_base::ELEM;
dest.nature_ = src.nature_;
const entier nb_elem = src_domain.elements_.dimension(0);
const entier nb_face_elem = src_domain.elem_faces_.dimension(1);
const entier nb_comp = src.data_.dimension(1);
dest.data_.resize(nb_elem * nb_face_elem, nb_comp);
int index = 0;
for (int i = 0; i < nb_elem; i++) {
for (int j = 0; j < nb_face_elem; j++) {
const int face = src_domain.elem_faces_(i, j);
for (int k = 0; k < nb_comp; k++)
dest.data_(index, k) = src.data_(face, k);
index++;
}
}
}
void build_geometry_(OperatorDualMesh & op,
const DomainIJK & src, LataDeriv<Domain> & dest_domain)
{
Journal(verb_level) << "OperatorDualMesh geometry(ijk) " << src.id_.name_ << endl;
if (src.elt_type_ != Domain::quadri && src.elt_type_ != Domain::hexa) {
Journal() << "Error in OperatorDualMesh::build_geometry: cannot operate on unstructured mesh with this element type" << endl;
throw;
}
DomainIJK & dest = dest_domain.instancie(DomainIJK);
dest.elt_type_ = src.elt_type_;
const entier dim = src.dimension();
for (entier i_dim = 0; i_dim < dim; i_dim++) {
const ArrOfFloat & c1 = src.coord_[i_dim];
ArrOfFloat & c2 = dest.coord_.add(ArrOfFloat());
const int n = c1.size_array() - 1;
c2.resize_array(n*2+1);
for (int i = 0; i < n; i++) {
c2[i*2] = c1[i];
c2[i*2+1] = (c1[i] + c1[i+1]) * 0.5;
}
c2[n*2] = c1[n];
}
if (src.invalid_connections_.size_array() > 0) {
dest.invalid_connections_.resize_array(dest.nb_elements());
dest.invalid_connections_ = 0;
int index = 0;
const entier ni = dest.coord_[0].size_array()-1;
const entier nj = dest.coord_[1].size_array()-1;
const entier nk = (dim==3) ? (dest.coord_[2].size_array()-1) : 1;
const entier ni_src = src.coord_[0].size_array() - 1;
const entier nj_src = src.coord_[1].size_array() - 1;
for (int k = 0; k < nk; k++) {
const int k_src = k / 2;
for (int j = 0; j < nj; j++) {
const int j_src = j / 2;
const int idx_source = (k_src * nj_src + j_src) * ni_src;
for (int i = 0; i < ni; i++) {
const int idx = idx_source + i / 2;
if (src.invalid_connections_[idx])
dest.invalid_connections_.setbit(index);
index++;
}
}
}
}
dest.virtual_layer_begin_ = 2 * src.virtual_layer_begin_;
dest.virtual_layer_end_ = 2 * src.virtual_layer_end_;
}
#define IJK(i,j,k) (k*nj_ni_src + j*ni_src + i)
template <class TabType>
void build_field_(OperatorDualMesh & op,
const DomainIJK & src_domain,
const DomainIJK & dest_domain,
const Field<TabType> & src,
Field<TabType> & dest)
{
Journal(verb_level) << "OperatorDualMesh field(ijk) " << src.id_.uname_ << endl;
dest.component_names_ = src.component_names_;
dest.localisation_ = LataField_base::ELEM;
dest.nature_ = LataDBField::VECTOR;
const entier dim = src_domain.dimension();
int index = 0;
// Loop on destination elements
const entier ni = dest_domain.coord_[0].size_array()-1;
const entier nj = dest_domain.coord_[1].size_array()-1;
const entier nk = (dim==3) ? (dest_domain.coord_[2].size_array()-1) : 1;
dest.data_.resize(ni*nj*nk, dim);
const entier ni_src = src_domain.coord_[0].size_array();
const entier nj_ni_src = src_domain.coord_[1].size_array() * ni_src;
for (int k = 0; k < nk; k++) {
const int k2 = k/2;
const int k3 = (k+1)/2;
for (int j = 0; j < nj; j++) {
const int j2 = j/2;
const int j3 = (j+1)/2;
for (int i = 0; i < ni; i++) {
const int i2 = i/2;
const int i3 = (i+1)/2;
dest.data_(index, 0) = src.data_(IJK(i3,j2,k2), 0);
dest.data_(index, 1) = src.data_(IJK(i2,j3,k2), 1);
if (dim==3)
dest.data_(index, 2) = src.data_(IJK(i2,j2,k3), 2);
index++;
}
}
}
}
#undef IJK
void OperatorDualMesh::build_geometry(const Domain & src_domain, LataDeriv<Domain> & dest)
{
apply_geometry(*this, src_domain, dest);
}
void OperatorDualMesh::build_field(const Domain & src_domain, const LataField_base & src_field,
const Domain & dest_domain, LataDeriv<LataField_base> & dest)
{
if (src_field.localisation_ != LataField_base::FACES) {
Journal() << "Error in OperatorDualMesh::build_field: source field is not located at faces" << endl;
throw;
}
apply_field(*this, src_domain, src_field, dest_domain, dest);
}
#undef level
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.