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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
422fc5d417f621f1cf84cd9e6cf5d9435aa6b17d
|
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
|
/pkgtools/pbulk/files/pbulk/lib/read_child.c
|
ce3e7b7259511204494ed7acd88bc57c749befbb
|
[] |
no_license
|
NetBSD/pkgsrc
|
a0732c023519650ef821ab89c23ab6ab59e25bdb
|
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
|
refs/heads/trunk
| 2023-09-01T07:40:12.138283
| 2023-09-01T05:25:19
| 2023-09-01T05:25:19
| 88,439,572
| 321
| 138
| null | 2023-07-12T22:34:14
| 2017-04-16T20:04:15
| null |
UTF-8
|
C
| false
| false
| 2,566
|
c
|
read_child.c
|
/* $NetBSD: read_child.c,v 1.4 2013/04/14 17:03:30 dholland Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
* All rights reserved.
*
* This code was developed as part of Google's Summer of Code 2007 program.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS 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 <nbcompat.h>
#include <sys/wait.h>
#include <nbcompat/err.h>
#include <signal.h>
#include <nbcompat/stdlib.h>
#include <nbcompat/string.h>
#include "pbulk.h"
char *
read_from_child(const char *dir, const char *cmd, const char * const *argv)
{
char *buf;
size_t buf_len, cur_len;
ssize_t bytes_read;
int fd, status;
pid_t child;
if ((child = fork_chdir_exec(dir, cmd, argv, &fd)) == -1)
return NULL;
cur_len = 0;
buf_len = 4096;
buf = xmalloc(buf_len + 1);
while ((bytes_read = read(fd, buf + cur_len, buf_len - cur_len)) > 0) {
cur_len += bytes_read;
if (cur_len * 2 < buf_len)
continue;
buf_len *= 2;
buf = xrealloc(buf, buf_len + 1);
}
if (bytes_read == -1) {
warn("read failed");
(void)close(fd);
(void)kill(child, SIGTERM);
(void)waitpid(child, &status, 0);
exit(1);
}
(void)close(fd);
(void)waitpid(child, &status, 0);
if (status != 0 || memchr(buf, 0, cur_len) != NULL) {
free(buf);
return NULL;
}
buf[cur_len] = '\0';
return buf;
}
|
06202b0ba4bdc158a1a9cc53f1f6c665a535ce3a
|
c6759b857e55991fea3ef0b465dbcee53fa38714
|
/libs/gap_lib/img_io/ImgIO.c
|
514edd1cd7d5ef11f608abe689d7389850ea1f2c
|
[
"Apache-2.0"
] |
permissive
|
GreenWaves-Technologies/gap_sdk
|
1b343bba97b7a5ce62a24162bd72eef5cc67e269
|
3fea306d52ee33f923f2423c5a75d9eb1c07e904
|
refs/heads/master
| 2023-09-01T14:38:34.270427
| 2023-08-10T09:04:44
| 2023-08-10T09:04:44
| 133,324,605
| 145
| 96
|
Apache-2.0
| 2023-08-27T19:03:52
| 2018-05-14T07:50:29
|
C
|
UTF-8
|
C
| false
| false
| 17,354
|
c
|
ImgIO.c
|
/*
* Copyright (C) 2017 GreenWaves Technologies
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD license. See the LICENSE file for details.
*
*/
#include "gaplib/ImgIO.h"
#include "stdint.h"
#ifndef SILENT
#define PRINTF printf
#else
#define PRINTF(...) ((void) 0)
#endif
#define Max(a, b) (((a)>(b))?(a):(b))
#define Min(a, b) (((a)<(b))?(a):(b))
#define ALIGN(Value, Size) (((Value)&((1<<(Size))-1))?((((Value)>>(Size))+1)<<(Size)):(Value))
#define CHUNK_SIZE 8192
unsigned char *img_rgb888;
static void progress_bar(char * OutString, int n, int tot)
{
int tot_chars = 30;
printf("%s",OutString);
printf(" [");
int chars = (n*tot_chars)/tot;
for(int i=0;i<tot_chars;i++){
if(i<=chars)
printf("#");
else printf(" ");
}
printf("]");
printf("\n");
}
void SkipCommentAndWhiteSpace(unsigned char *pImg, int buf_len, int *i)
{
int saw_nl = 1;
while (*i < buf_len && (pImg[*i] == '#'||pImg[*i] == ' '||pImg[*i] == '\t'||pImg[*i] == '\r'||pImg[*i] == '\n')) {
if (saw_nl && pImg[*i] == '#') {
while (*i < buf_len && pImg[*i] != '\n') {
//printf("%c", pImg[*i]);
(*i)++;
}
}
saw_nl = (pImg[*i] == '\n');
(*i)++;
}
}
unsigned int ReadValue(unsigned char *pImg, int buf_len, int *i)
{
#define IS_DIGIT(C) (((C) >= '0') && ((C) <= '9'))
unsigned int val = 0;
SkipCommentAndWhiteSpace(pImg, buf_len, i);
while (*i < buf_len && !IS_DIGIT(pImg[*i])) {
(*i)++;
}
while (*i < buf_len && IS_DIGIT(pImg[*i])) {
val = val * 10 + (pImg[*i] - 0x30);
(*i)++;
}
return val;
#undef IS_DIGIT
}
static int ReadPPMHeader(unsigned char *ImgIn, unsigned int *W, unsigned int *H, unsigned int *BytesPerPixel, unsigned int *HeaderLen, int buf_len, unsigned int *InputShort)
{
*W = *H = *BytesPerPixel = *HeaderLen = 0;
if (ImgIn[0] == 'P' && ImgIn[1] == '5' && ImgIn[2] == '\n') *BytesPerPixel = 1;
else if (ImgIn[0] == 'P' && ImgIn[1] == '6' && ImgIn[2] == '\n') *BytesPerPixel = 3;
else return 1;
int i = 3;
*W = ReadValue(ImgIn, buf_len, &i);
*H = ReadValue(ImgIn, buf_len, &i);
unsigned int Val = ReadValue(ImgIn, buf_len, &i);
if (Val != 255 && Val != 65535) return 1;
if (Val == 65535) *InputShort = 1;
else *InputShort = 0;
while (ImgIn[i++] != 0xA) {};
*HeaderLen = i;
return 0;
}
static int GetInputImageInfos(char *Name, unsigned int *W, unsigned int *H, unsigned int *BytesPerPixel, unsigned int *HeaderSize, unsigned int *InputShort)
{
*W = 0; *H = 0; *BytesPerPixel = 0; *HeaderSize = 0;
switch_fs_t fs;
__FS_INIT(fs);
switch_file_t File = __OPEN_READ(fs, Name);
if (!File) {
printf("Unable to open file %s\n", Name);
return 1;
}
unsigned int Err = 0;
unsigned char *Header = (unsigned char *) __ALLOC_L2(256);
Err |= (Header == 0);
if (__READ(File, Header, 256) == 256) {
unsigned int i;
if (ReadPPMHeader(Header, W, H, BytesPerPixel, HeaderSize, 256, InputShort)) {
printf("Unable to load header %s", Name);
Err = 1;
} else {
PRINTF("Image %s: [W: %d, H: %d] Bytes per pixel %d, HeaderSize: %d\n", Name, *W, *H, *BytesPerPixel, *HeaderSize);
//for (i=0; i<*HeaderSize;i++) PRINTF("%c", Header[i]);
//PRINTF("\n");
}
} else {
printf("Unable to read header %s", Name);
Err = 1;
}
__FREE_L2(Header, 256);
__CLOSE(File);
__FS_DEINIT(fs);
return Err;
}
static int ReadMultiChannelImageRGB565(switch_file_t File, unsigned short * InBuffer, int W, int H)
{
unsigned int RowSize = W*3;
unsigned short * pInBuffer = InBuffer;
unsigned char *InputBuf = (unsigned char *) __ALLOC_L2(RowSize * sizeof(unsigned char));
if(InputBuf == NULL)
{
printf("Malloc failed when loading image\n");
return -1;
}
for (int CurRow=0; CurRow < H; CurRow++) {
int RemainBytes = RowSize;
unsigned char *pInpBuf = InputBuf;
while (RemainBytes > 0) {
__int_ssize_t len = __READ(File, pInpBuf, RemainBytes);
if (!len) return 1;
RemainBytes -= len;
pInpBuf += len;
}
for (int j=0, i=0; i < W; i++) {
pInBuffer[W * CurRow + i] = ((((uint16_t)InputBuf[j]&0xf8)<<8)|(((uint16_t)InputBuf[j+1]&0xfc)<<3)|(((uint16_t)InputBuf[j+2]&0xf8)>>3));
j+=3;
}
}
__FREE_L2(InputBuf, RowSize);
return 0;
}
static int ReadMultiChannelImageTranspose2CHW(switch_file_t File, signed char * InBuffer, int W, int H, int BytesPerPixel)
{
unsigned int RowSize = W*BytesPerPixel, ChannelSize = W * H;
signed char * pInBuffer = InBuffer;
unsigned char *InputBuf = (unsigned char *) __ALLOC_L2(RowSize * sizeof(unsigned char));
if(InputBuf == NULL)
{
printf("Malloc failed when loading image\n");
return -1;
}
for (int CurRow=0; CurRow < H; CurRow++) {
int RemainBytes = RowSize;
unsigned char *pInpBuf = InputBuf;
while (RemainBytes > 0) {
__int_ssize_t len = __READ(File, pInpBuf, RemainBytes);
if (!len) return 1;
RemainBytes -= len;
pInpBuf += len;
}
for (int i=0; i < W; i++) {
for (int j=0; j < BytesPerPixel; j++) {
pInBuffer[ChannelSize * j + W * CurRow + i] = InputBuf[i * BytesPerPixel + j];
}
}
}
__FREE_L2(InputBuf, RowSize);
return 0;
}
static int ReadMultiChannelImage(switch_file_t File, signed char * InBuffer, int W, int H, int BytesPerPixel)
{
unsigned int RowSize = W*BytesPerPixel, ChannelSize = W * H;
signed char * pInBuffer = InBuffer;
unsigned char *InputBuf = (unsigned char *) __ALLOC_L2(RowSize * sizeof(unsigned char));
if(InputBuf == NULL)
{
printf("Malloc failed when loading image\n");
return -1;
}
for (int CurRow=0; CurRow < H; CurRow++) {
int RemainBytes = RowSize;
unsigned char *pInpBuf = InputBuf;
while (RemainBytes > 0) {
__int_ssize_t len = __READ(File, pInpBuf, RemainBytes);
if (!len) return 1;
RemainBytes -= len;
pInpBuf += len;
}
for (int i=0; i < W; i++) {
for (int j=0; j < BytesPerPixel; j++) {
pInBuffer[RowSize * CurRow + i * BytesPerPixel + j] = InputBuf[i * BytesPerPixel + j];
}
}
}
__FREE_L2(InputBuf, RowSize);
return 0;
}
static int ReadMultiChannelImageShortTranspose2CHW(switch_file_t File, short int * InBuffer, int W, int H, int BytesPerPixel)
{
unsigned int RowSize = W*BytesPerPixel, ChannelSize = W * H;
short int * pInBuffer = InBuffer;
unsigned char *InputBuf = (unsigned char *) __ALLOC_L2(RowSize * sizeof(unsigned char));
if(InputBuf == NULL)
{
printf("Malloc failed when loading image\n");
return -1;
}
for (int CurRow=0; CurRow < H; CurRow++) {
int RemainBytes = RowSize;
unsigned char *pInpBuf = InputBuf;
while (RemainBytes > 0) {
__int_ssize_t len = __READ(File, pInpBuf, RemainBytes);
if (!len) return 1;
RemainBytes -= len;
pInpBuf += len;
}
for (int i=0; i < W; i++) {
for (int j=0; j < BytesPerPixel; j++) {
pInBuffer[ChannelSize * j + W * CurRow + i] = (short int) (InputBuf[i * BytesPerPixel + j]);
}
}
}
__FREE_L2(InputBuf, RowSize);
return 0;
}
static int ReadMultiChannelImageShort(switch_file_t File, short int * InBuffer, int W, int H, int BytesPerPixel)
{
unsigned int RowSize = W*BytesPerPixel, ChannelSize = W * H;
short int * pInBuffer = InBuffer;
unsigned char *InputBuf = (unsigned char *) __ALLOC_L2(RowSize * sizeof(unsigned char));
if(InputBuf == NULL)
{
printf("Malloc failed when loading image\n");
return -1;
}
for (int CurRow=0; CurRow < H; CurRow++) {
int RemainBytes = RowSize;
unsigned char *pInpBuf = InputBuf;
while (RemainBytes > 0) {
__int_ssize_t len = __READ(File, pInpBuf, RemainBytes);
if (!len) return 1;
RemainBytes -= len;
pInpBuf += len;
}
for (int i=0; i < W; i++) {
for (int j=0; j < BytesPerPixel; j++) {
pInBuffer[RowSize * CurRow + i * BytesPerPixel + j] = (short int) (InputBuf[i * BytesPerPixel + j]);
}
}
}
__FREE_L2(InputBuf, RowSize);
return 0;
}
static int ReadShortImage(switch_file_t File, short int * InBuffer, int W, int H, int BytesPerPixel)
{
unsigned int RowSize = W*BytesPerPixel, ChannelSize = W * H;
short int * pInBuffer = InBuffer;
unsigned char *InputBuf = (unsigned char *) __ALLOC_L2(RowSize * sizeof(unsigned char));
if(InputBuf == NULL)
{
printf("Malloc failed when loading image\n");
return -1;
}
for (int CurRow=0; CurRow < H; CurRow++) {
int RemainBytes = RowSize*2;
unsigned char *pInpBuf = (unsigned char *) InputBuf;
while (RemainBytes > 0) {
__int_ssize_t len = __READ(File, pInpBuf, RemainBytes);
if (!len) return 1;
RemainBytes -= len;
pInpBuf += len;
}
for (int i=0; i < W; i++) {
for (int j=0; j < BytesPerPixel; j++) {
pInBuffer[RowSize * CurRow + i * BytesPerPixel + j] = (short int) (InputBuf[i * BytesPerPixel + j]);
}
}
}
__FREE_L2(InputBuf, RowSize);
return 0;
}
int ReadImageFromFile(char *ImageName, unsigned int DesiredW, unsigned int DesiredH, unsigned int DesiredBytesPerPixel, void *InBuffer, unsigned int BuffSize, img_io_out_t out_type, int Transpose2CHW)
{
switch_file_t File = (switch_file_t) 0;
unsigned int BytesPerPixel, W, H, HeaderSize, Size, ReadSize=0;
unsigned int ImageShort;
if (GetInputImageInfos(ImageName, &W, &H, &BytesPerPixel, &HeaderSize, &ImageShort)) {
printf("Failed to get input images infos, %s\n", ImageName); goto Fail;
}
if (BytesPerPixel != DesiredBytesPerPixel) {
printf("Expecting %d bytes per pixel image, %s\n", BytesPerPixel, ImageName); goto Fail;
}
if (DesiredH != H || DesiredW != W) {
printf("Expecting [%dx%d] image, got [%dx%d] %s\n", DesiredW, DesiredH, W, H, ImageName); goto Fail;
}
switch_fs_t fs;
__FS_INIT(fs);
File = __OPEN_READ(fs, ImageName);
if (File == 0) {
printf("Failed to open file, %s\n", ImageName); goto Fail;
}
Size = W*H*BytesPerPixel*(ImageShort?sizeof(short int):sizeof(unsigned char));
if (out_type == IMGIO_OUTPUT_RGB565) {
if (BuffSize < W*H*2) {
printf("Buffer is too small, %s\n", ImageName); goto Fail;
}
} else {
if (BuffSize < Size) {
printf("Buffer is too small, %s\n", ImageName); goto Fail;
}
}
__SEEK(File, HeaderSize);
int res;
if (ImageShort){
res = ReadShortImage(File, (short int *)InBuffer, W, H, BytesPerPixel);
}
else {
switch (out_type) {
case IMGIO_OUTPUT_CHAR:
if (Transpose2CHW){
res = ReadMultiChannelImageTranspose2CHW(File, (signed char *)InBuffer, W, H, BytesPerPixel);
} else {
res = ReadMultiChannelImage(File, (signed char *)InBuffer, W, H, BytesPerPixel);
}
break;
case IMGIO_OUTPUT_SHORT:
if (Transpose2CHW){
res = ReadMultiChannelImageShortTranspose2CHW(File, (short int *)InBuffer, W, H, BytesPerPixel);
} else {
res = ReadMultiChannelImageShort(File, (short int *)InBuffer, W, H, BytesPerPixel);
}
break;
case IMGIO_OUTPUT_RGB565:
res = ReadMultiChannelImageRGB565(File, (unsigned short *)InBuffer, W, H);
break;
default:
res = 1;
}
}
if (res) {
printf("Input ended unexpectedly or bad format, %s\n", ImageName); goto Fail;
}
__CLOSE(File);
__FS_DEINIT(fs);
PRINTF("Image %s, [W: %d, H: %d], Bytes per pixel %d, Size: %d bytes, Loaded successfully\n", ImageName, W, H, BytesPerPixel, Size);
return 0;
Fail:
__CLOSE(File);
__FS_DEINIT(fs);
printf("Failed to load image %s from flash\n", ImageName);
return 1;
}
static void WritePPMHeader(void *FD, unsigned int W, unsigned int H, unsigned char imgFormat)
{
// BYPASS mode, no need any header
if (imgFormat == BYPASS_IO)
return ;
unsigned int Ind = 0, x, i, L;
unsigned char *Buffer = (unsigned char *) __ALLOC_L2(PPM_HEADER * sizeof(unsigned char));
/* P5<cr>* */
Buffer[Ind++] = 0x50; // P
if (imgFormat == GRAY_SCALE_IO) Buffer[Ind++] = 0x35; // 5
else Buffer[Ind++] = 0x36; // 6
Buffer[Ind++] = 0xA; // <cr>
/* W <space> */
x = W; L=0;
while (x>0)
{
x = x/10;
L++;
}
x = W; i = 1;
while (x>0)
{
Buffer[Ind+L-i] = 0x30 + (x%10);
i++;
x=x/10;
}
Ind += L;
Buffer[Ind++] = 0x20;
/* H <cr> */
x = H; L=0;
while (x>0)
{
x = x/10;
L++;
}
x = H; i = 1;
while (x>0)
{
Buffer[Ind+L-i] = 0x30 + (x%10);
i++;
x=x/10;
}
Ind += L;
Buffer[Ind++] = 0xA;
/* 255 <cr> */
Buffer[Ind++] = 0x32;
Buffer[Ind++] = 0x35;
Buffer[Ind++] = 0x35;
Buffer[Ind++] = 0xA;
for (unsigned int a=0; a<Ind; a++)
{
__WRITE(FD,&(Buffer[a]), sizeof(unsigned char));
}
__FREE_L2(Buffer, PPM_HEADER * sizeof(unsigned char));
}
static void rgb565_to_rgb888 (unsigned char *input, unsigned int input_size, unsigned char *output )
{
unsigned char red, green, blue; // 8-bits each
unsigned short pixel;
unsigned int ind = 0;
// Just a simplest implementation, need to be optimized the performance
for (unsigned int i = 0; i < input_size; i+=2) {
pixel = *(unsigned short *) (input + i);
red = (unsigned short)((pixel & 0xF800) >> 11); // 5
green = (unsigned short)((pixel & 0x07E0) >> 5); // 6
blue = (unsigned short)(pixel & 0x001F); // 5
output[ind] = red << 3; /* red */
output[ind+1] = green << 2; /* green */
output[ind+2] = blue << 3; /* blue */
ind += 3;
}
}
int WriteImageToFile(char *ImageName, unsigned int W, unsigned int H, unsigned char PixelSize, unsigned char *OutBuffer, unsigned char imgFormat)
{
switch_fs_t fs;
__FS_INIT(fs);
void *File = __OPEN_WRITE(fs, ImageName);
int ret = 0;
WritePPMHeader(File,W,H, imgFormat);
if(imgFormat == RGB565_IO)
{
unsigned int rgb888_size = (CHUNK_SIZE/2)*3; // size of 888 image in byte
img_rgb888 = (unsigned char *) __ALLOC_L2(rgb888_size);
int steps = (W*H*PixelSize) / CHUNK_SIZE; // convert and fs write times
for(int i=0;i<steps;i++){
#ifndef SILENT
progress_bar("Writing image ",i,steps);
#endif
rgb565_to_rgb888(OutBuffer+(CHUNK_SIZE*i), CHUNK_SIZE, img_rgb888);
ret+=__WRITE(File, img_rgb888, rgb888_size);
}
if(((W*H*PixelSize) % CHUNK_SIZE) != 0)
{
rgb888_size = ((W*H*PixelSize) % CHUNK_SIZE)/2*3;
rgb565_to_rgb888((OutBuffer+(CHUNK_SIZE*steps)),((W*H*PixelSize) % CHUNK_SIZE) ,img_rgb888);
ret+=__WRITE(File, img_rgb888, rgb888_size);
}
__FREE_L2(img_rgb888, (CHUNK_SIZE/2)*3);
}
else
{
int steps = (W*H*PixelSize) / CHUNK_SIZE;
for(int i=0;i<steps;i++){
#ifndef SILENT
progress_bar("Writing image ",i,steps);
#endif
ret+=__WRITE(File,OutBuffer +(CHUNK_SIZE*i), CHUNK_SIZE);
}
if(((W*H*PixelSize) % CHUNK_SIZE) != 0)
ret+=__WRITE(File,OutBuffer+(CHUNK_SIZE*steps) , ((W*H*PixelSize) % CHUNK_SIZE)*sizeof(unsigned char));
}
__CLOSE(File);
__FS_DEINIT(fs);
return ret;
}
#ifndef __EMUL__
int WriteImageToFileL3(struct pi_device *l3_mem, char *ImageName, unsigned int W, unsigned int H, unsigned char PixelSize, unsigned int OutBuffer, unsigned char imgFormat)
{
switch_fs_t fs;
__FS_INIT(fs);
void *File = __OPEN_WRITE(fs, ImageName);
int ret = 0;
WritePPMHeader(File,W,H, imgFormat);
unsigned char * buff=__ALLOC_L2(CHUNK_SIZE);
if(imgFormat == RGB565_IO)
{
unsigned int rgb888_size = (CHUNK_SIZE/2)*3; // size of 888 image in byte
img_rgb888 = (unsigned char *) __ALLOC_L2(rgb888_size);
int steps = (W*H*PixelSize) / CHUNK_SIZE; // convert and fs write times
for(int i=0;i<steps;i++){
#ifndef SILENT
progress_bar("Writing image ",i,steps);
#endif
pi_ram_read(l3_mem,(uint32_t) OutBuffer+(CHUNK_SIZE*i), buff, (uint32_t) CHUNK_SIZE);
rgb565_to_rgb888(buff, CHUNK_SIZE, img_rgb888);
ret+=__WRITE(File, img_rgb888, rgb888_size);
}
if(((W*H*PixelSize) % CHUNK_SIZE) != 0)
{
rgb888_size = ((W*H*PixelSize) % CHUNK_SIZE)/2*3;
pi_ram_read(l3_mem,(uint32_t) OutBuffer+(CHUNK_SIZE*steps), buff, (uint32_t) ((W*H*PixelSize) % CHUNK_SIZE));
rgb565_to_rgb888(buff,((W*H*PixelSize) % CHUNK_SIZE) ,img_rgb888);
ret+=__WRITE(File, img_rgb888, rgb888_size);
}
__FREE_L2(img_rgb888, (CHUNK_SIZE/2)*3);
}
else
{
int steps = (W*H*PixelSize) / CHUNK_SIZE;
for(int i=0;i<steps;i++){
#ifndef SILENT
progress_bar("Writing image ",i,steps);
#endif
pi_ram_read(l3_mem,(uint32_t) OutBuffer+(CHUNK_SIZE*i), buff, (uint32_t) CHUNK_SIZE);
ret+=__WRITE(File,buff, CHUNK_SIZE);
}
if(((W*H*PixelSize) % CHUNK_SIZE) != 0)
pi_ram_read(l3_mem,(uint32_t) OutBuffer+(CHUNK_SIZE*steps), buff, ((W*H*PixelSize) % CHUNK_SIZE)*sizeof(unsigned char));
ret+=__WRITE(File,buff , ((W*H*PixelSize) % CHUNK_SIZE)*sizeof(unsigned char));
}
__FREE_L2(buff,CHUNK_SIZE);
__CLOSE(File);
__FS_DEINIT(fs);
return ret;
}
#endif
|
bebd0406dbd37eec9912fcba5577c8036159c0fb
|
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
|
/third_party/chibicc/test/constexpr_test.c
|
3734ea3a2fdc81e7d2d71b91d786c1e27a924e47
|
[
"MIT",
"LicenseRef-scancode-free-unknown",
"ISC"
] |
permissive
|
jart/cosmopolitan
|
fb11b5658939023977060a7c6c71a74093d9cb44
|
0d748ad58e1063dd1f8560f18a0c75293b9415b7
|
refs/heads/master
| 2023-09-06T09:17:29.303607
| 2023-09-02T03:49:13
| 2023-09-02T03:50:18
| 272,457,606
| 11,887
| 435
|
ISC
| 2023-09-14T17:47:58
| 2020-06-15T14:16:13
|
C
|
UTF-8
|
C
| false
| false
| 3,812
|
c
|
constexpr_test.c
|
#include "third_party/chibicc/test/test.h"
float g40 = 1.5;
double g41 = 0.0 ? 55 : (0, 1 + 1 * 5.0 / 2 * (double)2 * (int)2.0);
int main(int argc, char *argv[]) {
ASSERT(10, ({
enum { ten = 1 + 2 + 3 + 4 };
ten;
}));
ASSERT(1, ({
int i = 0;
switch (3) {
case 5 - 2 + 0 * 3:
i++;
}
i;
}));
ASSERT(8, ({
int x[1 + 1];
sizeof(x);
}));
ASSERT(6, ({
char x[8 - 2];
sizeof(x);
}));
ASSERT(6, ({
char x[2 * 3];
sizeof(x);
}));
ASSERT(3, ({
char x[12 / 4];
sizeof(x);
}));
ASSERT(2, ({
char x[12 % 10];
sizeof(x);
}));
ASSERT(0b100, ({
char x[0b110 & 0b101];
sizeof(x);
}));
ASSERT(0b111, ({
char x[0b110 | 0b101];
sizeof(x);
}));
ASSERT(0b110, ({
char x[0b111 ^ 0b001];
sizeof(x);
}));
ASSERT(4, ({
char x[1 << 2];
sizeof(x);
}));
ASSERT(2, ({
char x[4 >> 1];
sizeof(x);
}));
ASSERT(2, ({
char x[(1 == 1) + 1];
sizeof(x);
}));
ASSERT(1, ({
char x[(1 != 1) + 1];
sizeof(x);
}));
ASSERT(1, ({
char x[(1 < 1) + 1];
sizeof(x);
}));
ASSERT(2, ({
char x[(1 <= 1) + 1];
sizeof(x);
}));
ASSERT(2, ({
char x[1 ? 2 : 3];
sizeof(x);
}));
ASSERT(3, ({
char x[0 ? 2 : 3];
sizeof(x);
}));
ASSERT(3, ({
char x[(1, 3)];
sizeof(x);
}));
ASSERT(2, ({
char x[!0 + 1];
sizeof(x);
}));
ASSERT(1, ({
char x[!1 + 1];
sizeof(x);
}));
ASSERT(2, ({
char x[~-3];
sizeof(x);
}));
ASSERT(2, ({
char x[(5 || 6) + 1];
sizeof(x);
}));
ASSERT(1, ({
char x[(0 || 0) + 1];
sizeof(x);
}));
ASSERT(2, ({
char x[(1 && 1) + 1];
sizeof(x);
}));
ASSERT(1, ({
char x[(1 && 0) + 1];
sizeof(x);
}));
ASSERT(3, ({
char x[(int)3];
sizeof(x);
}));
ASSERT(15, ({
char x[(char)0xffffff0f];
sizeof(x);
}));
ASSERT(0x10f, ({
char x[(short)0xffff010f];
sizeof(x);
}));
ASSERT(4, ({
char x[(int)0xfffffffffff + 5];
sizeof(x);
}));
ASSERT(8, ({
char x[(int *)0 + 2];
sizeof(x);
}));
ASSERT(12, ({
char x[(int *)16 - 1];
sizeof(x);
}));
ASSERT(3, ({
char x[(int *)16 - (int *)4];
sizeof(x);
}));
ASSERT(4, ({
char x[(-1 >> 31) + 5];
sizeof(x);
}));
ASSERT(255, ({
char x[(unsigned char)0xffffffff];
sizeof(x);
}));
ASSERT(0x800f, ({
char x[(unsigned short)0xffff800f];
sizeof(x);
}));
ASSERT(1, ({
char x[(unsigned int)0xfffffffffff >> 31];
sizeof(x);
}));
ASSERT(1, ({
char x[(long)-1 / ((long)1 << 62) + 1];
sizeof(x);
}));
ASSERT(4, ({
char x[(unsigned long)-1 / ((long)1 << 62) + 1];
sizeof(x);
}));
ASSERT(1, ({
char x[(unsigned)1 < -1];
sizeof(x);
}));
ASSERT(1, ({
char x[(unsigned)1 <= -1];
sizeof(x);
}));
ASSERT(1, g40 == 1.5);
ASSERT(1, g41 == 11);
}
|
6bfaa6579732ff65a77c6afee858e3162a62e8d3
|
d411dcad6fe4f3753a9f3c4308b05afcfc616861
|
/examples/separate.c
|
927912a4421c88c1f2ba0ce0211b0f8e1b53c86e
|
[
"MIT"
] |
permissive
|
alexanderchuranov/Metaresc
|
488abc039f6243dbe22cbb0a2247b6c34b6c3082
|
3c4e281f7d29d8bba4ace4fff9bfecdf5c604840
|
refs/heads/master
| 2023-08-18T01:02:14.081253
| 2023-08-02T20:48:33
| 2023-08-02T20:48:33
| 1,439,401
| 134
| 20
|
NOASSERTION
| 2023-07-24T05:15:14
| 2011-03-04T13:29:04
|
C
|
UTF-8
|
C
| false
| false
| 245
|
c
|
separate.c
|
#include <stdio.h>
#include <stdlib.h>
#include "separate_employee.h"
int
main (int argc, char * argv[])
{
employee_t employee = create_employee ("John", "Doe", 123456);
MR_PRINT ((employee_t, &employee, XML));
return (EXIT_SUCCESS);
}
|
631644d8efe766e305afe81b61f96b598f522493
|
cbb0bd995f5ecb64f93a30d5f1dcd106e3241214
|
/Protocols/config.h
|
f88c3aa8ae6a9bee028edc3507d4512a8b84c30f
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
data61/MP-SPDZ
|
324010a4caaa403f64d769a276d58931e0ed274e
|
5c26feece05e13387fc9bd2ef3f09b2735d6ea4b
|
refs/heads/master
| 2023-08-10T01:25:33.653174
| 2023-08-09T02:13:34
| 2023-08-09T02:13:34
| 152,511,277
| 724
| 277
|
NOASSERTION
| 2023-07-21T04:43:18
| 2018-10-11T01:16:16
|
C++
|
UTF-8
|
C
| false
| false
| 174
|
h
|
config.h
|
/*
* config.h
*
*/
#ifndef PROTOCOLS_CONFIG_H_
#define PROTOCOLS_CONFIG_H_
#ifndef DEFAULT_SECURITY
#define DEFAULT_SECURITY 40
#endif
#endif /* PROTOCOLS_CONFIG_H_ */
|
cff84a5138454aa0ca86128699a7cbabd202f1d2
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/staging/rts5139/trace.h
|
ac58b452ecb8cbc73e4318d9211a856fae4aa90d
|
[
"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
| 3,041
|
h
|
trace.h
|
/* Driver for Realtek RTS51xx USB card reader
* Header file
*
* Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
*
* 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; if not, see <http://www.gnu.org/licenses/>.
*
* Author:
* wwang (wei_wang@realsil.com.cn)
* No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
* Maintainer:
* Edwin Rong (edwin_rong@realsil.com.cn)
* No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
*/
#ifndef __RTS51X_TRACE_H
#define __RTS51X_TRACE_H
#include <linux/string.h>
#include "debug.h"
#define _MSG_TRACE
#ifdef _MSG_TRACE
#define TRACE_RET(chip, ret) \
do { \
const char *_file = kbasename(__FILE__); \
RTS51X_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \
(chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
strncpy((chip)->trace_msg[(chip)->msg_idx].func, \
__func__, MSG_FUNC_LEN-1); \
strncpy((chip)->trace_msg[(chip)->msg_idx].file, \
_file, MSG_FILE_LEN-1); \
get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf,\
TIME_VAL_LEN); \
(chip)->trace_msg[(chip)->msg_idx].valid = 1; \
(chip)->msg_idx++; \
if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \
(chip)->msg_idx = 0; \
} \
return ret; \
} while (0)
#define TRACE_GOTO(chip, label) \
do { \
const char *_file = kbasename(__FILE__); \
RTS51X_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \
(chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
strncpy((chip)->trace_msg[(chip)->msg_idx].func, \
__func__, MSG_FUNC_LEN-1); \
strncpy((chip)->trace_msg[(chip)->msg_idx].file, \
_file, MSG_FILE_LEN-1); \
get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf,\
TIME_VAL_LEN); \
(chip)->trace_msg[(chip)->msg_idx].valid = 1; \
(chip)->msg_idx++; \
if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \
(chip)->msg_idx = 0; \
} \
goto label; \
} while (0)
#else
#define TRACE_RET(chip, ret) return (ret)
#define TRACE_GOTO(chip, label) goto label
#endif
#ifdef CONFIG_RTS5139_DEBUG
#define RTS51X_DUMP(buf, buf_len) \
print_hex_dump(KERN_DEBUG, RTS51X_TIP, DUMP_PREFIX_NONE, \
16, 1, (buf), (buf_len), false)
#define CATCH_TRIGGER(chip) \
do { \
rts51x_ep0_write_register((chip), 0xFC31, 0x01, 0x01); \
RTS51X_DEBUGP("Catch trigger!\n"); \
} while (0)
#else
#define RTS51X_DUMP(buf, buf_len)
#define CATCH_TRIGGER(chip)
#endif
#endif /* __RTS51X_TRACE_H */
|
a6b045147bb097813173f05e9b8d9eb11f2a211c
|
275af38f3b87e907d65b02fa351ddde714836451
|
/src/unix/unix_c/unix_gethostbyaddr_job.c
|
06b718bb1fa1295fb8524ee203c98a2c09429645
|
[
"MIT"
] |
permissive
|
ocsigen/lwt
|
e8fd425b1925308b95ae36a76408b236f8c7161c
|
2eee2a1b9e386cc0eacf455a5a9356150f920edb
|
refs/heads/master
| 2023-08-08T23:37:48.176938
| 2023-08-04T13:08:55
| 2023-08-04T13:08:55
| 11,749,475
| 672
| 199
|
MIT
| 2023-08-23T06:58:15
| 2013-07-29T20:47:51
|
OCaml
|
UTF-8
|
C
| false
| false
| 1,908
|
c
|
unix_gethostbyaddr_job.c
|
/* This file is part of Lwt, released under the MIT license. See LICENSE.md for
details, or visit https://github.com/ocsigen/lwt/blob/master/LICENSE.md. */
#include "lwt_config.h"
#if !defined(LWT_ON_WINDOWS)
#define _GNU_SOURCE
#include <caml/fail.h>
#include <caml/mlvalues.h>
#include <caml/unixsupport.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "lwt_unix.h"
#include "unix_get_network_information_utils.h"
struct job_gethostbyaddr {
struct lwt_unix_job job;
struct in_addr addr;
struct hostent entry;
struct hostent *ptr;
#ifndef NON_R_GETHOSTBYADDR
char buffer[NETDB_BUFFER_SIZE];
#endif
};
static void worker_gethostbyaddr(struct job_gethostbyaddr *job)
{
#if HAS_GETHOSTBYADDR_R == 7
int h_errno;
job->ptr = gethostbyaddr_r(&job->addr, 4, AF_INET, &job->entry, job->buffer,
NETDB_BUFFER_SIZE, &h_errno);
#elif HAS_GETHOSTBYADDR_R == 8
int h_errno;
if (gethostbyaddr_r(&job->addr, 4, AF_INET, &job->entry, job->buffer,
NETDB_BUFFER_SIZE, &job->ptr, &h_errno) != 0)
job->ptr = NULL;
#else
job->ptr = gethostbyaddr(&job->addr, 4, AF_INET);
if (job->ptr) {
job->ptr = hostent_dup(job->ptr);
if (job->ptr) {
job->entry = *job->ptr;
}
}
#endif
}
static value result_gethostbyaddr(struct job_gethostbyaddr *job)
{
if (job->ptr == NULL) {
lwt_unix_free_job(&job->job);
caml_raise_not_found();
} else {
value entry = alloc_host_entry(&job->entry);
#ifdef NON_R_GETHOSTBYADDR
hostent_free(job->ptr);
#endif
lwt_unix_free_job(&job->job);
return entry;
}
}
CAMLprim value lwt_unix_gethostbyaddr_job(value val_addr)
{
LWT_UNIX_INIT_JOB(job, gethostbyaddr, 0);
job->addr = GET_INET_ADDR(val_addr);
return lwt_unix_alloc_job(&job->job);
}
#endif
|
f260c6cbc8a76211e68959c8ebbb315213d164f9
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/ffmpeg/libavcodec/libilbc.c
|
9ca90bf0c668aed8547a48c7350d2f92d74166d1
|
[
"BSD-3-Clause",
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"LGPL-2.1-only",
"LGPL-3.0-only",
"GPL-2.0-only",
"LGPL-2.1-or-later",
"GPL-3.0-or-later",
"LGPL-3.0-or-later",
"IJG",
"LicenseRef-scancode-other-permissive",
"GPL-2.0-or-later",
"GPL-3.0-only"
] |
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
| 6,618
|
c
|
libilbc.c
|
/*
* iLBC decoder/encoder stub
* Copyright (c) 2012 Martin Storsjo
*
* 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 <ilbc.h>
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "encode.h"
#ifndef LIBILBC_VERSION_MAJOR
#define LIBILBC_VERSION_MAJOR 2
#endif
static int get_mode(AVCodecContext *avctx)
{
if (avctx->block_align == 38)
return 20;
else if (avctx->block_align == 50)
return 30;
else if (avctx->bit_rate > 0)
return avctx->bit_rate <= 14000 ? 30 : 20;
else
return -1;
}
typedef struct ILBCDecContext {
const AVClass *class;
#if LIBILBC_VERSION_MAJOR < 3
iLBC_Dec_Inst_t decoder;
#else
IlbcDecoder decoder;
#endif
int enhance;
} ILBCDecContext;
static const AVOption ilbc_dec_options[] = {
{ "enhance", "Enhance the decoded audio (adds delay)", offsetof(ILBCDecContext, enhance), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM },
{ NULL }
};
static const AVClass ilbc_dec_class = {
.class_name = "libilbc",
.item_name = av_default_item_name,
.option = ilbc_dec_options,
.version = LIBAVUTIL_VERSION_INT,
};
static av_cold int ilbc_decode_init(AVCodecContext *avctx)
{
ILBCDecContext *s = avctx->priv_data;
int mode;
if ((mode = get_mode(avctx)) < 0) {
av_log(avctx, AV_LOG_ERROR, "iLBC frame mode not indicated\n");
return AVERROR(EINVAL);
}
WebRtcIlbcfix_InitDecode(&s->decoder, mode, s->enhance);
av_channel_layout_uninit(&avctx->ch_layout);
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
avctx->sample_rate = 8000;
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
static int ilbc_decode_frame(AVCodecContext *avctx, AVFrame *frame,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ILBCDecContext *s = avctx->priv_data;
int ret;
if (s->decoder.no_of_bytes > buf_size) {
#if LIBILBC_VERSION_MAJOR < 3
av_log(avctx, AV_LOG_ERROR, "iLBC frame too short (%u, should be %u)\n",
#else
av_log(avctx, AV_LOG_ERROR, "iLBC frame too short (%u, should be "
"%"SIZE_SPECIFIER")\n",
#endif
buf_size, s->decoder.no_of_bytes);
return AVERROR_INVALIDDATA;
}
frame->nb_samples = s->decoder.blockl;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
WebRtcIlbcfix_DecodeImpl((int16_t *) frame->data[0], (const uint16_t *) buf, &s->decoder, 1);
*got_frame_ptr = 1;
return s->decoder.no_of_bytes;
}
const FFCodec ff_libilbc_decoder = {
.p.name = "libilbc",
CODEC_LONG_NAME("iLBC (Internet Low Bitrate Codec)"),
.p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_ILBC,
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
.priv_data_size = sizeof(ILBCDecContext),
.init = ilbc_decode_init,
FF_CODEC_DECODE_CB(ilbc_decode_frame),
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
.p.priv_class = &ilbc_dec_class,
};
typedef struct ILBCEncContext {
const AVClass *class;
#if LIBILBC_VERSION_MAJOR < 3
iLBC_Enc_Inst_t encoder;
#else
IlbcEncoder encoder;
#endif
int mode;
} ILBCEncContext;
static const AVOption ilbc_enc_options[] = {
{ "mode", "iLBC mode (20 or 30 ms frames)", offsetof(ILBCEncContext, mode), AV_OPT_TYPE_INT, { .i64 = 20 }, 20, 30, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
{ NULL }
};
static const AVClass ilbc_enc_class = {
.class_name = "libilbc",
.item_name = av_default_item_name,
.option = ilbc_enc_options,
.version = LIBAVUTIL_VERSION_INT,
};
static av_cold int ilbc_encode_init(AVCodecContext *avctx)
{
ILBCEncContext *s = avctx->priv_data;
int mode;
if (avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
return AVERROR(EINVAL);
}
if (avctx->ch_layout.nb_channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return AVERROR(EINVAL);
}
if ((mode = get_mode(avctx)) > 0)
s->mode = mode;
else
s->mode = s->mode != 30 ? 20 : 30;
WebRtcIlbcfix_InitEncode(&s->encoder, s->mode);
avctx->block_align = s->encoder.no_of_bytes;
avctx->frame_size = s->encoder.blockl;
return 0;
}
static int ilbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
ILBCEncContext *s = avctx->priv_data;
int ret;
if ((ret = ff_alloc_packet(avctx, avpkt, 50)) < 0)
return ret;
WebRtcIlbcfix_EncodeImpl((uint16_t *) avpkt->data, (const int16_t *) frame->data[0], &s->encoder);
avpkt->size = s->encoder.no_of_bytes;
*got_packet_ptr = 1;
return 0;
}
static const FFCodecDefault ilbc_encode_defaults[] = {
{ "b", "0" },
{ NULL }
};
const FFCodec ff_libilbc_encoder = {
.p.name = "libilbc",
CODEC_LONG_NAME("iLBC (Internet Low Bitrate Codec)"),
.p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_ILBC,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
.priv_data_size = sizeof(ILBCEncContext),
.init = ilbc_encode_init,
FF_CODEC_ENCODE_CB(ilbc_encode_frame),
.p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
.defaults = ilbc_encode_defaults,
.p.priv_class = &ilbc_enc_class,
.p.wrapper_name = "libbilbc",
};
|
217900cbfb349ede4467a31403e50d44ec3802a5
|
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
|
/src/native/external/libunwind/tests/Garm64-test-sve-signal.c
|
52cb9ac6099dacfd7b0d95bb9589a0a32aea0d2e
|
[
"MIT"
] |
permissive
|
dotnet/runtime
|
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
|
47bb554d298e1e34c4e3895d7731e18ad1c47d02
|
refs/heads/main
| 2023-09-03T15:35:46.493337
| 2023-09-03T08:13:23
| 2023-09-03T08:13:23
| 210,716,005
| 13,765
| 5,179
|
MIT
| 2023-09-14T21:58:52
| 2019-09-24T23:36:39
|
C#
|
UTF-8
|
C
| false
| false
| 2,560
|
c
|
Garm64-test-sve-signal.c
|
/*
* Verify that unwinding from a signal handler works when variable width
* SVE registers are pushed onto the stack
*/
#if defined(__ARM_FEATURE_SVE) && defined(__ARM_FEATURE_SVE_VECTOR_OPERATORS)
#include <arm_sve.h>
#include <libunwind.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
int64_t z[100];
void signal_handler(int signum)
{
unw_cursor_t cursor;
unw_context_t context;
const char* expected[] = {
"signal_frame",
"kill",
"sum",
"square",
"main",
};
unw_getcontext(&context);
unw_init_local(&cursor, &context);
for (unsigned int depth = 0; depth < sizeof(expected) / sizeof(expected[0]); ++depth)
{
unw_word_t offset, pc;
int unw_rc = unw_step(&cursor);
if (unw_rc <= 0) {
printf("Frame: %d unw_step error: %d\n", depth, unw_rc);
exit(-1);
}
unw_rc = unw_get_reg(&cursor, UNW_REG_IP, &pc);
if (pc == 0 || unw_rc != 0) {
printf("Frame: %d unw_get_reg error: %d\n", depth, unw_rc);
exit(-1);
}
char sym[256];
unw_rc = unw_is_signal_frame(&cursor);
if (unw_rc > 0)
{
strcpy(sym, "signal_frame");
}
else if (unw_rc < 0)
{
printf("Frame: %d unw_is_signal_frame error: %d\n", depth, unw_rc);
exit(-1);
}
else
{
unw_rc = unw_get_proc_name(&cursor, sym, sizeof(sym), &offset);
if (unw_rc)
{
printf("Frame: %d unw_get_proc_name error: %d\n", depth, unw_rc);
exit(-1);
}
}
if (strcmp(sym, expected[depth]) != 0)
{
printf("Frame: %d expected %s but found %s\n", depth, expected[depth], sym);
exit(-1);
}
}
exit(0); /* PASS */
}
int64_t sum(svint64_t z0)
{
int64_t ret = svaddv_s64(svptrue_b64(), z0);
kill (getpid (), SIGUSR1);
return ret;
}
int64_t square(svint64_t z0)
{
int64_t res = 0;
for (int i = 0; i < 100; ++i)
{
z0 = svmul_s64_z(svptrue_b64(), z0, z0);
res += sum(z0);
}
return res;
}
int main()
{
signal(SIGUSR1, signal_handler);
for (unsigned int i = 0; i < sizeof(z) / sizeof(z[0]); ++i)
z[i] = rand();
svint64_t z0 = svld1(svptrue_b64(), &z[0]);
square(z0);
/*
* Shouldn't get here, exit is called from signal handler
*/
printf("Signal handler wasn't called\n");
return -1;
}
#else /* !__ARM_FEATURE_SVE */
int
main ()
{
return 77; /* SKIP */
}
#endif
|
575a600eb55f2413477a1ef2fbadf9cbd98b9741
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/kern/vfs_cache.c
|
f3db8b0caf272cd4ef5bb385590a2b6eea63674c
|
[] |
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
| 45,366
|
c
|
vfs_cache.c
|
/* $NetBSD: vfs_cache.c,v 1.154 2023/04/29 10:07:22 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* 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.
*/
/*
* Copyright (c) 1989, 1993
* 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 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.
*
* @(#)vfs_cache.c 8.3 (Berkeley) 8/22/94
*/
/*
* Name caching:
*
* Names found by directory scans are retained in a cache for future
* reference. It is managed LRU, so frequently used names will hang
* around. The cache is indexed by hash value obtained from the name.
*
* The name cache is the brainchild of Robert Elz and was introduced in
* 4.3BSD. See "Using gprof to Tune the 4.2BSD Kernel", Marshall Kirk
* McKusick, May 21 1984.
*
* Data structures:
*
* Most Unix namecaches very sensibly use a global hash table to index
* names. The global hash table works well, but can cause concurrency
* headaches for the kernel hacker. In the NetBSD 10.0 implementation
* we are not sensible, and use a per-directory data structure to index
* names, but the cache otherwise functions the same.
*
* The index is a red-black tree. There are no special concurrency
* requirements placed on it, because it's per-directory and protected
* by the namecache's per-directory locks. It should therefore not be
* difficult to experiment with other types of index.
*
* Each cached name is stored in a struct namecache, along with a
* pointer to the associated vnode (nc_vp). Names longer than a
* maximum length of NCHNAMLEN are allocated with kmem_alloc(); they
* occur infrequently, and names shorter than this are stored directly
* in struct namecache. If it is a "negative" entry, (i.e. for a name
* that is known NOT to exist) the vnode pointer will be NULL.
*
* For a directory with 3 cached names for 3 distinct vnodes, the
* various vnodes and namecache structs would be connected like this
* (the root is at the bottom of the diagram):
*
* ...
* ^
* |- vi_nc_tree
* |
* +----o----+ +---------+ +---------+
* | VDIR | | VCHR | | VREG |
* | vnode o-----+ | vnode o-----+ | vnode o------+
* +---------+ | +---------+ | +---------+ |
* ^ | ^ | ^ |
* |- nc_vp |- vi_nc_list |- nc_vp |- vi_nc_list |- nc_vp |
* | | | | | |
* +----o----+ | +----o----+ | +----o----+ |
* +---onamecache|<----+ +---onamecache|<----+ +---onamecache|<-----+
* | +---------+ | +---------+ | +---------+
* | ^ | ^ | ^
* | | | | | |
* | | +----------------------+ | |
* |-nc_dvp | +-------------------------------------------------+
* | |/- vi_nc_tree | |
* | | |- nc_dvp |- nc_dvp
* | +----o----+ | |
* +-->| VDIR |<----------+ |
* | vnode |<------------------------------------+
* +---------+
*
* START HERE
*
* Replacement:
*
* As the cache becomes full, old and unused entries are purged as new
* entries are added. The synchronization overhead in maintaining a
* strict ordering would be prohibitive, so the VM system's "clock" or
* "second chance" page replacement algorithm is aped here. New
* entries go to the tail of the active list. After they age out and
* reach the head of the list, they are moved to the tail of the
* inactive list. Any use of the deactivated cache entry reactivates
* it, saving it from impending doom; if not reactivated, the entry
* eventually reaches the head of the inactive list and is purged.
*
* Concurrency:
*
* From a performance perspective, cache_lookup(nameiop == LOOKUP) is
* what really matters; insertion of new entries with cache_enter() is
* comparatively infrequent, and overshadowed by the cost of expensive
* file system metadata operations (which may involve disk I/O). We
* therefore want to make everything simplest in the lookup path.
*
* struct namecache is mostly stable except for list and tree related
* entries, changes to which don't affect the cached name or vnode.
* For changes to name+vnode, entries are purged in preference to
* modifying them.
*
* Read access to namecache entries is made via tree, list, or LRU
* list. A lock corresponding to the direction of access should be
* held. See definition of "struct namecache" in src/sys/namei.src,
* and the definition of "struct vnode" for the particulars.
*
* Per-CPU statistics, and LRU list totals are read unlocked, since
* an approximate value is OK. We maintain 32-bit sized per-CPU
* counters and 64-bit global counters under the theory that 32-bit
* sized counters are less likely to be hosed by nonatomic increment
* (on 32-bit platforms).
*
* The lock order is:
*
* 1) vi->vi_nc_lock (tree or parent -> child direction,
* used during forward lookup)
*
* 2) vi->vi_nc_listlock (list or child -> parent direction,
* used during reverse lookup)
*
* 3) cache_lru_lock (LRU list direction, used during reclaim)
*
* 4) vp->v_interlock (what the cache entry points to)
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.154 2023/04/29 10:07:22 riastradh Exp $");
#define __NAMECACHE_PRIVATE
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
#include "opt_dtrace.h"
#endif
#include <sys/param.h>
#include <sys/types.h>
#include <sys/atomic.h>
#include <sys/callout.h>
#include <sys/cpu.h>
#include <sys/errno.h>
#include <sys/evcnt.h>
#include <sys/hash.h>
#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/param.h>
#include <sys/pool.h>
#include <sys/sdt.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/time.h>
#include <sys/vnode_impl.h>
#include <miscfs/genfs/genfs.h>
static void cache_activate(struct namecache *);
static void cache_update_stats(void *);
static int cache_compare_nodes(void *, const void *, const void *);
static void cache_deactivate(void);
static void cache_reclaim(void);
static int cache_stat_sysctl(SYSCTLFN_ARGS);
/*
* Global pool cache.
*/
static pool_cache_t cache_pool __read_mostly;
/*
* LRU replacement.
*/
enum cache_lru_id {
LRU_ACTIVE,
LRU_INACTIVE,
LRU_COUNT
};
static struct {
TAILQ_HEAD(, namecache) list[LRU_COUNT];
u_int count[LRU_COUNT];
} cache_lru __cacheline_aligned;
static kmutex_t cache_lru_lock __cacheline_aligned;
/*
* Cache effectiveness statistics. nchstats holds system-wide total.
*/
struct nchstats nchstats;
struct nchstats_percpu _NAMEI_CACHE_STATS(uint32_t);
struct nchcpu {
struct nchstats_percpu cur;
struct nchstats_percpu last;
};
static callout_t cache_stat_callout;
static kmutex_t cache_stat_lock __cacheline_aligned;
#define COUNT(f) do { \
lwp_t *l = curlwp; \
KPREEMPT_DISABLE(l); \
struct nchcpu *nchcpu = curcpu()->ci_data.cpu_nch; \
nchcpu->cur.f++; \
KPREEMPT_ENABLE(l); \
} while (/* CONSTCOND */ 0);
#define UPDATE(nchcpu, f) do { \
uint32_t cur = atomic_load_relaxed(&nchcpu->cur.f); \
nchstats.f += (uint32_t)(cur - nchcpu->last.f); \
nchcpu->last.f = cur; \
} while (/* CONSTCOND */ 0)
/*
* Tunables. cache_maxlen replaces the historical doingcache:
* set it zero to disable caching for debugging purposes.
*/
int cache_lru_maxdeact __read_mostly = 2; /* max # to deactivate */
int cache_lru_maxscan __read_mostly = 64; /* max # to scan/reclaim */
int cache_maxlen __read_mostly = USHRT_MAX; /* max name length to cache */
int cache_stat_interval __read_mostly = 300; /* in seconds */
/*
* sysctl stuff.
*/
static struct sysctllog *cache_sysctllog;
/*
* This is a dummy name that cannot usually occur anywhere in the cache nor
* file system. It's used when caching the root vnode of mounted file
* systems. The name is attached to the directory that the file system is
* mounted on.
*/
static const char cache_mp_name[] = "";
static const int cache_mp_nlen = sizeof(cache_mp_name) - 1;
/*
* Red-black tree stuff.
*/
static const rb_tree_ops_t cache_rbtree_ops = {
.rbto_compare_nodes = cache_compare_nodes,
.rbto_compare_key = cache_compare_nodes,
.rbto_node_offset = offsetof(struct namecache, nc_tree),
.rbto_context = NULL
};
/*
* dtrace probes.
*/
SDT_PROBE_DEFINE1(vfs, namecache, invalidate, done, "struct vnode *");
SDT_PROBE_DEFINE1(vfs, namecache, purge, parents, "struct vnode *");
SDT_PROBE_DEFINE1(vfs, namecache, purge, children, "struct vnode *");
SDT_PROBE_DEFINE2(vfs, namecache, purge, name, "char *", "size_t");
SDT_PROBE_DEFINE1(vfs, namecache, purge, vfs, "struct mount *");
SDT_PROBE_DEFINE3(vfs, namecache, lookup, hit, "struct vnode *",
"char *", "size_t");
SDT_PROBE_DEFINE3(vfs, namecache, lookup, miss, "struct vnode *",
"char *", "size_t");
SDT_PROBE_DEFINE3(vfs, namecache, lookup, toolong, "struct vnode *",
"char *", "size_t");
SDT_PROBE_DEFINE2(vfs, namecache, revlookup, success, "struct vnode *",
"struct vnode *");
SDT_PROBE_DEFINE2(vfs, namecache, revlookup, fail, "struct vnode *",
"int");
SDT_PROBE_DEFINE2(vfs, namecache, prune, done, "int", "int");
SDT_PROBE_DEFINE3(vfs, namecache, enter, toolong, "struct vnode *",
"char *", "size_t");
SDT_PROBE_DEFINE3(vfs, namecache, enter, done, "struct vnode *",
"char *", "size_t");
/*
* rbtree: compare two nodes.
*/
static int
cache_compare_nodes(void *context, const void *n1, const void *n2)
{
const struct namecache *nc1 = n1;
const struct namecache *nc2 = n2;
if (nc1->nc_key < nc2->nc_key) {
return -1;
}
if (nc1->nc_key > nc2->nc_key) {
return 1;
}
KASSERT(nc1->nc_nlen == nc2->nc_nlen);
return memcmp(nc1->nc_name, nc2->nc_name, nc1->nc_nlen);
}
/*
* Compute a key value for the given name. The name length is encoded in
* the key value to try and improve uniqueness, and so that length doesn't
* need to be compared separately for string comparisons.
*/
static inline uint64_t
cache_key(const char *name, size_t nlen)
{
uint64_t key;
KASSERT(nlen <= USHRT_MAX);
key = hash32_buf(name, nlen, HASH32_STR_INIT);
return (key << 32) | nlen;
}
/*
* Remove an entry from the cache. vi_nc_lock must be held, and if dir2node
* is true, then we're locking in the conventional direction and the list
* lock will be acquired when removing the entry from the vnode list.
*/
static void
cache_remove(struct namecache *ncp, const bool dir2node)
{
struct vnode *vp, *dvp = ncp->nc_dvp;
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
KASSERT(rw_write_held(&dvi->vi_nc_lock));
KASSERT(cache_key(ncp->nc_name, ncp->nc_nlen) == ncp->nc_key);
KASSERT(rb_tree_find_node(&dvi->vi_nc_tree, ncp) == ncp);
SDT_PROBE(vfs, namecache, invalidate, done, ncp,
0, 0, 0, 0);
/*
* Remove from the vnode's list. This excludes cache_revlookup(),
* and then it's safe to remove from the LRU lists.
*/
if ((vp = ncp->nc_vp) != NULL) {
vnode_impl_t *vi = VNODE_TO_VIMPL(vp);
if (__predict_true(dir2node)) {
rw_enter(&vi->vi_nc_listlock, RW_WRITER);
TAILQ_REMOVE(&vi->vi_nc_list, ncp, nc_list);
rw_exit(&vi->vi_nc_listlock);
} else {
TAILQ_REMOVE(&vi->vi_nc_list, ncp, nc_list);
}
}
/* Remove from the directory's rbtree. */
rb_tree_remove_node(&dvi->vi_nc_tree, ncp);
/* Remove from the LRU lists. */
mutex_enter(&cache_lru_lock);
TAILQ_REMOVE(&cache_lru.list[ncp->nc_lrulist], ncp, nc_lru);
cache_lru.count[ncp->nc_lrulist]--;
mutex_exit(&cache_lru_lock);
/* Finally, free it. */
if (ncp->nc_nlen > NCHNAMLEN) {
size_t sz = offsetof(struct namecache, nc_name[ncp->nc_nlen]);
kmem_free(ncp, sz);
} else {
pool_cache_put(cache_pool, ncp);
}
}
/*
* Find a single cache entry and return it. vi_nc_lock must be held.
*/
static struct namecache * __noinline
cache_lookup_entry(struct vnode *dvp, const char *name, size_t namelen,
uint64_t key)
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct rb_node *node = dvi->vi_nc_tree.rbt_root;
struct namecache *ncp;
int lrulist, diff;
KASSERT(rw_lock_held(&dvi->vi_nc_lock));
/*
* Search the RB tree for the key. This is an inlined lookup
* tailored for exactly what's needed here (64-bit key and so on)
* that is quite a bit faster than using rb_tree_find_node().
*
* For a matching key memcmp() needs to be called once to confirm
* that the correct name has been found. Very rarely there will be
* a key value collision and the search will continue.
*/
for (;;) {
if (__predict_false(RB_SENTINEL_P(node))) {
return NULL;
}
ncp = (struct namecache *)node;
KASSERT((void *)&ncp->nc_tree == (void *)ncp);
KASSERT(ncp->nc_dvp == dvp);
if (ncp->nc_key == key) {
KASSERT(ncp->nc_nlen == namelen);
diff = memcmp(ncp->nc_name, name, namelen);
if (__predict_true(diff == 0)) {
break;
}
node = node->rb_nodes[diff < 0];
} else {
node = node->rb_nodes[ncp->nc_key < key];
}
}
/*
* If the entry is on the wrong LRU list, requeue it. This is an
* unlocked check, but it will rarely be wrong and even then there
* will be no harm caused.
*/
lrulist = atomic_load_relaxed(&ncp->nc_lrulist);
if (__predict_false(lrulist != LRU_ACTIVE)) {
cache_activate(ncp);
}
return ncp;
}
/*
* Look for a the name in the cache. We don't do this
* if the segment name is long, simply so the cache can avoid
* holding long names (which would either waste space, or
* add greatly to the complexity).
*
* Lookup is called with DVP pointing to the directory to search,
* and CNP providing the name of the entry being sought: cn_nameptr
* is the name, cn_namelen is its length, and cn_flags is the flags
* word from the namei operation.
*
* DVP must be locked.
*
* There are three possible non-error return states:
* 1. Nothing was found in the cache. Nothing is known about
* the requested name.
* 2. A negative entry was found in the cache, meaning that the
* requested name definitely does not exist.
* 3. A positive entry was found in the cache, meaning that the
* requested name does exist and that we are providing the
* vnode.
* In these cases the results are:
* 1. 0 returned; VN is set to NULL.
* 2. 1 returned; VN is set to NULL.
* 3. 1 returned; VN is set to the vnode found.
*
* The additional result argument ISWHT is set to zero, unless a
* negative entry is found that was entered as a whiteout, in which
* case ISWHT is set to one.
*
* The ISWHT_RET argument pointer may be null. In this case an
* assertion is made that the whiteout flag is not set. File systems
* that do not support whiteouts can/should do this.
*
* Filesystems that do support whiteouts should add ISWHITEOUT to
* cnp->cn_flags if ISWHT comes back nonzero.
*
* When a vnode is returned, it is locked, as per the vnode lookup
* locking protocol.
*
* There is no way for this function to fail, in the sense of
* generating an error that requires aborting the namei operation.
*
* (Prior to October 2012, this function returned an integer status,
* and a vnode, and mucked with the flags word in CNP for whiteouts.
* The integer status was -1 for "nothing found", ENOENT for "a
* negative entry found", 0 for "a positive entry found", and possibly
* other errors, and the value of VN might or might not have been set
* depending on what error occurred.)
*/
bool
cache_lookup(struct vnode *dvp, const char *name, size_t namelen,
uint32_t nameiop, uint32_t cnflags,
int *iswht_ret, struct vnode **vn_ret)
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct namecache *ncp;
struct vnode *vp;
uint64_t key;
int error;
bool hit;
krw_t op;
KASSERT(namelen != cache_mp_nlen || name == cache_mp_name);
/* Establish default result values */
if (iswht_ret != NULL) {
*iswht_ret = 0;
}
*vn_ret = NULL;
if (__predict_false(namelen > cache_maxlen)) {
SDT_PROBE(vfs, namecache, lookup, toolong, dvp,
name, namelen, 0, 0);
COUNT(ncs_long);
return false;
}
/* Compute the key up front - don't need the lock. */
key = cache_key(name, namelen);
/* Could the entry be purged below? */
if ((cnflags & ISLASTCN) != 0 &&
((cnflags & MAKEENTRY) == 0 || nameiop == CREATE)) {
op = RW_WRITER;
} else {
op = RW_READER;
}
/* Now look for the name. */
rw_enter(&dvi->vi_nc_lock, op);
ncp = cache_lookup_entry(dvp, name, namelen, key);
if (__predict_false(ncp == NULL)) {
rw_exit(&dvi->vi_nc_lock);
COUNT(ncs_miss);
SDT_PROBE(vfs, namecache, lookup, miss, dvp,
name, namelen, 0, 0);
return false;
}
if (__predict_false((cnflags & MAKEENTRY) == 0)) {
/*
* Last component and we are renaming or deleting,
* the cache entry is invalid, or otherwise don't
* want cache entry to exist.
*/
KASSERT((cnflags & ISLASTCN) != 0);
cache_remove(ncp, true);
rw_exit(&dvi->vi_nc_lock);
COUNT(ncs_badhits);
return false;
}
if (ncp->nc_vp == NULL) {
if (iswht_ret != NULL) {
/*
* Restore the ISWHITEOUT flag saved earlier.
*/
*iswht_ret = ncp->nc_whiteout;
} else {
KASSERT(!ncp->nc_whiteout);
}
if (nameiop == CREATE && (cnflags & ISLASTCN) != 0) {
/*
* Last component and we are preparing to create
* the named object, so flush the negative cache
* entry.
*/
COUNT(ncs_badhits);
cache_remove(ncp, true);
hit = false;
} else {
COUNT(ncs_neghits);
SDT_PROBE(vfs, namecache, lookup, hit, dvp, name,
namelen, 0, 0);
/* found neg entry; vn is already null from above */
hit = true;
}
rw_exit(&dvi->vi_nc_lock);
return hit;
}
vp = ncp->nc_vp;
error = vcache_tryvget(vp);
rw_exit(&dvi->vi_nc_lock);
if (error) {
KASSERT(error == EBUSY);
/*
* This vnode is being cleaned out.
* XXX badhits?
*/
COUNT(ncs_falsehits);
return false;
}
COUNT(ncs_goodhits);
SDT_PROBE(vfs, namecache, lookup, hit, dvp, name, namelen, 0, 0);
/* found it */
*vn_ret = vp;
return true;
}
/*
* Version of the above without the nameiop argument, for NFS.
*/
bool
cache_lookup_raw(struct vnode *dvp, const char *name, size_t namelen,
uint32_t cnflags,
int *iswht_ret, struct vnode **vn_ret)
{
return cache_lookup(dvp, name, namelen, LOOKUP, cnflags | MAKEENTRY,
iswht_ret, vn_ret);
}
/*
* Used by namei() to walk down a path, component by component by looking up
* names in the cache. The node locks are chained along the way: a parent's
* lock is not dropped until the child's is acquired.
*/
bool
cache_lookup_linked(struct vnode *dvp, const char *name, size_t namelen,
struct vnode **vn_ret, krwlock_t **plock,
kauth_cred_t cred)
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct namecache *ncp;
krwlock_t *oldlock, *newlock;
uint64_t key;
int error;
KASSERT(namelen != cache_mp_nlen || name == cache_mp_name);
/* If disabled, or file system doesn't support this, bail out. */
if (__predict_false((dvp->v_mount->mnt_iflag & IMNT_NCLOOKUP) == 0)) {
return false;
}
if (__predict_false(namelen > cache_maxlen)) {
COUNT(ncs_long);
return false;
}
/* Compute the key up front - don't need the lock. */
key = cache_key(name, namelen);
/*
* Acquire the directory lock. Once we have that, we can drop the
* previous one (if any).
*
* The two lock holds mean that the directory can't go away while
* here: the directory must be purged with cache_purge() before
* being freed, and both parent & child's vi_nc_lock must be taken
* before that point is passed.
*
* However if there's no previous lock, like at the root of the
* chain, then "dvp" must be referenced to prevent dvp going away
* before we get its lock.
*
* Note that the two locks can be the same if looking up a dot, for
* example: /usr/bin/. If looking up the parent (..) we can't wait
* on the lock as child -> parent is the wrong direction.
*/
if (*plock != &dvi->vi_nc_lock) {
oldlock = *plock;
newlock = &dvi->vi_nc_lock;
if (!rw_tryenter(&dvi->vi_nc_lock, RW_READER)) {
return false;
}
} else {
oldlock = NULL;
newlock = NULL;
if (*plock == NULL) {
KASSERT(vrefcnt(dvp) > 0);
}
}
/*
* First up check if the user is allowed to look up files in this
* directory.
*/
if (cred != FSCRED) {
if (dvi->vi_nc_mode == VNOVAL) {
if (newlock != NULL) {
rw_exit(newlock);
}
return false;
}
KASSERT(dvi->vi_nc_uid != VNOVAL);
KASSERT(dvi->vi_nc_gid != VNOVAL);
error = kauth_authorize_vnode(cred,
KAUTH_ACCESS_ACTION(VEXEC,
dvp->v_type, dvi->vi_nc_mode & ALLPERMS), dvp, NULL,
genfs_can_access(dvp, cred, dvi->vi_nc_uid, dvi->vi_nc_gid,
dvi->vi_nc_mode & ALLPERMS, NULL, VEXEC));
if (error != 0) {
if (newlock != NULL) {
rw_exit(newlock);
}
COUNT(ncs_denied);
return false;
}
}
/*
* Now look for a matching cache entry.
*/
ncp = cache_lookup_entry(dvp, name, namelen, key);
if (__predict_false(ncp == NULL)) {
if (newlock != NULL) {
rw_exit(newlock);
}
COUNT(ncs_miss);
SDT_PROBE(vfs, namecache, lookup, miss, dvp,
name, namelen, 0, 0);
return false;
}
if (ncp->nc_vp == NULL) {
/* found negative entry; vn is already null from above */
KASSERT(namelen != cache_mp_nlen);
KASSERT(name != cache_mp_name);
COUNT(ncs_neghits);
} else {
COUNT(ncs_goodhits); /* XXX can be "badhits" */
}
SDT_PROBE(vfs, namecache, lookup, hit, dvp, name, namelen, 0, 0);
/*
* Return with the directory lock still held. It will either be
* returned to us with another call to cache_lookup_linked() when
* looking up the next component, or the caller will release it
* manually when finished.
*/
if (oldlock) {
rw_exit(oldlock);
}
if (newlock) {
*plock = newlock;
}
*vn_ret = ncp->nc_vp;
return true;
}
/*
* Scan cache looking for name of directory entry pointing at vp.
* Will not search for "." or "..".
*
* If the lookup succeeds the vnode is referenced and stored in dvpp.
*
* If bufp is non-NULL, also place the name in the buffer which starts
* at bufp, immediately before *bpp, and move bpp backwards to point
* at the start of it. (Yes, this is a little baroque, but it's done
* this way to cater to the whims of getcwd).
*
* Returns 0 on success, -1 on cache miss, positive errno on failure.
*/
int
cache_revlookup(struct vnode *vp, struct vnode **dvpp, char **bpp, char *bufp,
bool checkaccess, accmode_t accmode)
{
vnode_impl_t *vi = VNODE_TO_VIMPL(vp);
struct namecache *ncp;
struct vnode *dvp;
int error, nlen, lrulist;
char *bp;
KASSERT(vp != NULL);
if (cache_maxlen == 0)
goto out;
rw_enter(&vi->vi_nc_listlock, RW_READER);
if (checkaccess) {
/*
* Check if the user is allowed to see. NOTE: this is
* checking for access on the "wrong" directory. getcwd()
* wants to see that there is access on every component
* along the way, not that there is access to any individual
* component. Don't use this to check you can look in vp.
*
* I don't like it, I didn't come up with it, don't blame me!
*/
if (vi->vi_nc_mode == VNOVAL) {
rw_exit(&vi->vi_nc_listlock);
return -1;
}
KASSERT(vi->vi_nc_uid != VNOVAL);
KASSERT(vi->vi_nc_gid != VNOVAL);
error = kauth_authorize_vnode(kauth_cred_get(),
KAUTH_ACCESS_ACTION(VEXEC, vp->v_type, vi->vi_nc_mode &
ALLPERMS), vp, NULL, genfs_can_access(vp, curlwp->l_cred,
vi->vi_nc_uid, vi->vi_nc_gid, vi->vi_nc_mode & ALLPERMS,
NULL, accmode));
if (error != 0) {
rw_exit(&vi->vi_nc_listlock);
COUNT(ncs_denied);
return EACCES;
}
}
TAILQ_FOREACH(ncp, &vi->vi_nc_list, nc_list) {
KASSERT(ncp->nc_vp == vp);
KASSERT(ncp->nc_dvp != NULL);
nlen = ncp->nc_nlen;
/*
* Ignore mountpoint entries.
*/
if (ncp->nc_nlen == cache_mp_nlen) {
continue;
}
/*
* The queue is partially sorted. Once we hit dots, nothing
* else remains but dots and dotdots, so bail out.
*/
if (ncp->nc_name[0] == '.') {
if (nlen == 1 ||
(nlen == 2 && ncp->nc_name[1] == '.')) {
break;
}
}
/*
* Record a hit on the entry. This is an unlocked read but
* even if wrong it doesn't matter too much.
*/
lrulist = atomic_load_relaxed(&ncp->nc_lrulist);
if (lrulist != LRU_ACTIVE) {
cache_activate(ncp);
}
if (bufp) {
bp = *bpp;
bp -= nlen;
if (bp <= bufp) {
*dvpp = NULL;
rw_exit(&vi->vi_nc_listlock);
SDT_PROBE(vfs, namecache, revlookup,
fail, vp, ERANGE, 0, 0, 0);
return (ERANGE);
}
memcpy(bp, ncp->nc_name, nlen);
*bpp = bp;
}
dvp = ncp->nc_dvp;
error = vcache_tryvget(dvp);
rw_exit(&vi->vi_nc_listlock);
if (error) {
KASSERT(error == EBUSY);
if (bufp)
(*bpp) += nlen;
*dvpp = NULL;
SDT_PROBE(vfs, namecache, revlookup, fail, vp,
error, 0, 0, 0);
return -1;
}
*dvpp = dvp;
SDT_PROBE(vfs, namecache, revlookup, success, vp, dvp,
0, 0, 0);
COUNT(ncs_revhits);
return (0);
}
rw_exit(&vi->vi_nc_listlock);
COUNT(ncs_revmiss);
out:
*dvpp = NULL;
return (-1);
}
/*
* Add an entry to the cache.
*/
void
cache_enter(struct vnode *dvp, struct vnode *vp,
const char *name, size_t namelen, uint32_t cnflags)
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct namecache *ncp, *oncp;
int total;
KASSERT(namelen != cache_mp_nlen || name == cache_mp_name);
/* First, check whether we can/should add a cache entry. */
if ((cnflags & MAKEENTRY) == 0 ||
__predict_false(namelen > cache_maxlen)) {
SDT_PROBE(vfs, namecache, enter, toolong, vp, name, namelen,
0, 0);
return;
}
SDT_PROBE(vfs, namecache, enter, done, vp, name, namelen, 0, 0);
/*
* Reclaim some entries if over budget. This is an unlocked check,
* but it doesn't matter. Just need to catch up with things
* eventually: it doesn't matter if we go over temporarily.
*/
total = atomic_load_relaxed(&cache_lru.count[LRU_ACTIVE]);
total += atomic_load_relaxed(&cache_lru.count[LRU_INACTIVE]);
if (__predict_false(total > desiredvnodes)) {
cache_reclaim();
}
/* Now allocate a fresh entry. */
if (__predict_true(namelen <= NCHNAMLEN)) {
ncp = pool_cache_get(cache_pool, PR_WAITOK);
} else {
size_t sz = offsetof(struct namecache, nc_name[namelen]);
ncp = kmem_alloc(sz, KM_SLEEP);
}
/*
* Fill in cache info. For negative hits, save the ISWHITEOUT flag
* so we can restore it later when the cache entry is used again.
*/
ncp->nc_vp = vp;
ncp->nc_dvp = dvp;
ncp->nc_key = cache_key(name, namelen);
ncp->nc_nlen = namelen;
ncp->nc_whiteout = ((cnflags & ISWHITEOUT) != 0);
memcpy(ncp->nc_name, name, namelen);
/*
* Insert to the directory. Concurrent lookups may race for a cache
* entry. If there's a entry there already, purge it.
*/
rw_enter(&dvi->vi_nc_lock, RW_WRITER);
oncp = rb_tree_insert_node(&dvi->vi_nc_tree, ncp);
if (oncp != ncp) {
KASSERT(oncp->nc_key == ncp->nc_key);
KASSERT(oncp->nc_nlen == ncp->nc_nlen);
KASSERT(memcmp(oncp->nc_name, name, namelen) == 0);
cache_remove(oncp, true);
oncp = rb_tree_insert_node(&dvi->vi_nc_tree, ncp);
KASSERT(oncp == ncp);
}
/*
* With the directory lock still held, insert to the tail of the
* ACTIVE LRU list (new) and take the opportunity to incrementally
* balance the lists.
*/
mutex_enter(&cache_lru_lock);
ncp->nc_lrulist = LRU_ACTIVE;
cache_lru.count[LRU_ACTIVE]++;
TAILQ_INSERT_TAIL(&cache_lru.list[LRU_ACTIVE], ncp, nc_lru);
cache_deactivate();
mutex_exit(&cache_lru_lock);
/*
* Finally, insert to the vnode and unlock. With everything set up
* it's safe to let cache_revlookup() see the entry. Partially sort
* the per-vnode list: dots go to back so cache_revlookup() doesn't
* have to consider them.
*/
if (vp != NULL) {
vnode_impl_t *vi = VNODE_TO_VIMPL(vp);
rw_enter(&vi->vi_nc_listlock, RW_WRITER);
if ((namelen == 1 && name[0] == '.') ||
(namelen == 2 && name[0] == '.' && name[1] == '.')) {
TAILQ_INSERT_TAIL(&vi->vi_nc_list, ncp, nc_list);
} else {
TAILQ_INSERT_HEAD(&vi->vi_nc_list, ncp, nc_list);
}
rw_exit(&vi->vi_nc_listlock);
}
rw_exit(&dvi->vi_nc_lock);
}
/*
* Set identity info in cache for a vnode. We only care about directories
* so ignore other updates. The cached info may be marked invalid if the
* inode has an ACL.
*/
void
cache_enter_id(struct vnode *vp, mode_t mode, uid_t uid, gid_t gid, bool valid)
{
vnode_impl_t *vi = VNODE_TO_VIMPL(vp);
if (vp->v_type == VDIR) {
/* Grab both locks, for forward & reverse lookup. */
rw_enter(&vi->vi_nc_lock, RW_WRITER);
rw_enter(&vi->vi_nc_listlock, RW_WRITER);
if (valid) {
vi->vi_nc_mode = mode;
vi->vi_nc_uid = uid;
vi->vi_nc_gid = gid;
} else {
vi->vi_nc_mode = VNOVAL;
vi->vi_nc_uid = VNOVAL;
vi->vi_nc_gid = VNOVAL;
}
rw_exit(&vi->vi_nc_listlock);
rw_exit(&vi->vi_nc_lock);
}
}
/*
* Return true if we have identity for the given vnode, and use as an
* opportunity to confirm that everything squares up.
*
* Because of shared code, some file systems could provide partial
* information, missing some updates, so check the mount flag too.
*/
bool
cache_have_id(struct vnode *vp)
{
if (vp->v_type == VDIR &&
(vp->v_mount->mnt_iflag & IMNT_NCLOOKUP) != 0 &&
atomic_load_relaxed(&VNODE_TO_VIMPL(vp)->vi_nc_mode) != VNOVAL) {
return true;
} else {
return false;
}
}
/*
* Enter a mount point. cvp is the covered vnode, and rvp is the root of
* the mounted file system.
*/
void
cache_enter_mount(struct vnode *cvp, struct vnode *rvp)
{
KASSERT(vrefcnt(cvp) > 0);
KASSERT(vrefcnt(rvp) > 0);
KASSERT(cvp->v_type == VDIR);
KASSERT((rvp->v_vflag & VV_ROOT) != 0);
if (rvp->v_type == VDIR) {
cache_enter(cvp, rvp, cache_mp_name, cache_mp_nlen, MAKEENTRY);
}
}
/*
* Look up a cached mount point. Used in the strongly locked path.
*/
bool
cache_lookup_mount(struct vnode *dvp, struct vnode **vn_ret)
{
bool ret;
ret = cache_lookup(dvp, cache_mp_name, cache_mp_nlen, LOOKUP,
MAKEENTRY, NULL, vn_ret);
KASSERT((*vn_ret != NULL) == ret);
return ret;
}
/*
* Try to cross a mount point. For use with cache_lookup_linked().
*/
bool
cache_cross_mount(struct vnode **dvp, krwlock_t **plock)
{
return cache_lookup_linked(*dvp, cache_mp_name, cache_mp_nlen,
dvp, plock, FSCRED);
}
/*
* Name cache initialization, from vfs_init() when the system is booting.
*/
void
nchinit(void)
{
cache_pool = pool_cache_init(sizeof(struct namecache),
coherency_unit, 0, 0, "namecache", NULL, IPL_NONE, NULL,
NULL, NULL);
KASSERT(cache_pool != NULL);
mutex_init(&cache_lru_lock, MUTEX_DEFAULT, IPL_NONE);
TAILQ_INIT(&cache_lru.list[LRU_ACTIVE]);
TAILQ_INIT(&cache_lru.list[LRU_INACTIVE]);
mutex_init(&cache_stat_lock, MUTEX_DEFAULT, IPL_NONE);
callout_init(&cache_stat_callout, CALLOUT_MPSAFE);
callout_setfunc(&cache_stat_callout, cache_update_stats, NULL);
callout_schedule(&cache_stat_callout, cache_stat_interval * hz);
KASSERT(cache_sysctllog == NULL);
sysctl_createv(&cache_sysctllog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRUCT, "namecache_stats",
SYSCTL_DESCR("namecache statistics"),
cache_stat_sysctl, 0, NULL, 0,
CTL_VFS, CTL_CREATE, CTL_EOL);
}
/*
* Called once for each CPU in the system as attached.
*/
void
cache_cpu_init(struct cpu_info *ci)
{
void *p;
size_t sz;
sz = roundup2(sizeof(struct nchcpu), coherency_unit) + coherency_unit;
p = kmem_zalloc(sz, KM_SLEEP);
ci->ci_data.cpu_nch = (void *)roundup2((uintptr_t)p, coherency_unit);
}
/*
* A vnode is being allocated: set up cache structures.
*/
void
cache_vnode_init(struct vnode *vp)
{
vnode_impl_t *vi = VNODE_TO_VIMPL(vp);
rw_init(&vi->vi_nc_lock);
rw_init(&vi->vi_nc_listlock);
rb_tree_init(&vi->vi_nc_tree, &cache_rbtree_ops);
TAILQ_INIT(&vi->vi_nc_list);
vi->vi_nc_mode = VNOVAL;
vi->vi_nc_uid = VNOVAL;
vi->vi_nc_gid = VNOVAL;
}
/*
* A vnode is being freed: finish cache structures.
*/
void
cache_vnode_fini(struct vnode *vp)
{
vnode_impl_t *vi = VNODE_TO_VIMPL(vp);
KASSERT(RB_TREE_MIN(&vi->vi_nc_tree) == NULL);
KASSERT(TAILQ_EMPTY(&vi->vi_nc_list));
rw_destroy(&vi->vi_nc_lock);
rw_destroy(&vi->vi_nc_listlock);
}
/*
* Helper for cache_purge1(): purge cache entries for the given vnode from
* all directories that the vnode is cached in.
*/
static void
cache_purge_parents(struct vnode *vp)
{
vnode_impl_t *dvi, *vi = VNODE_TO_VIMPL(vp);
struct vnode *dvp, *blocked;
struct namecache *ncp;
SDT_PROBE(vfs, namecache, purge, parents, vp, 0, 0, 0, 0);
blocked = NULL;
rw_enter(&vi->vi_nc_listlock, RW_WRITER);
while ((ncp = TAILQ_FIRST(&vi->vi_nc_list)) != NULL) {
/*
* Locking in the wrong direction. Try for a hold on the
* directory node's lock, and if we get it then all good,
* nuke the entry and move on to the next.
*/
dvp = ncp->nc_dvp;
dvi = VNODE_TO_VIMPL(dvp);
if (rw_tryenter(&dvi->vi_nc_lock, RW_WRITER)) {
cache_remove(ncp, false);
rw_exit(&dvi->vi_nc_lock);
blocked = NULL;
continue;
}
/*
* We can't wait on the directory node's lock with our list
* lock held or the system could deadlock.
*
* Take a hold on the directory vnode to prevent it from
* being freed (taking the vnode & lock with it). Then
* wait for the lock to become available with no other locks
* held, and retry.
*
* If this happens twice in a row, give the other side a
* breather; we can do nothing until it lets go.
*/
vhold(dvp);
rw_exit(&vi->vi_nc_listlock);
rw_enter(&dvi->vi_nc_lock, RW_WRITER);
/* Do nothing. */
rw_exit(&dvi->vi_nc_lock);
holdrele(dvp);
if (blocked == dvp) {
kpause("ncpurge", false, 1, NULL);
}
rw_enter(&vi->vi_nc_listlock, RW_WRITER);
blocked = dvp;
}
rw_exit(&vi->vi_nc_listlock);
}
/*
* Helper for cache_purge1(): purge all cache entries hanging off the given
* directory vnode.
*/
static void
cache_purge_children(struct vnode *dvp)
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct namecache *ncp;
SDT_PROBE(vfs, namecache, purge, children, dvp, 0, 0, 0, 0);
rw_enter(&dvi->vi_nc_lock, RW_WRITER);
while ((ncp = RB_TREE_MIN(&dvi->vi_nc_tree)) != NULL) {
cache_remove(ncp, true);
}
rw_exit(&dvi->vi_nc_lock);
}
/*
* Helper for cache_purge1(): purge cache entry from the given vnode,
* finding it by name.
*/
static void
cache_purge_name(struct vnode *dvp, const char *name, size_t namelen)
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct namecache *ncp;
uint64_t key;
SDT_PROBE(vfs, namecache, purge, name, name, namelen, 0, 0, 0);
key = cache_key(name, namelen);
rw_enter(&dvi->vi_nc_lock, RW_WRITER);
ncp = cache_lookup_entry(dvp, name, namelen, key);
if (ncp) {
cache_remove(ncp, true);
}
rw_exit(&dvi->vi_nc_lock);
}
/*
* Cache flush, a particular vnode; called when a vnode is renamed to
* hide entries that would now be invalid.
*/
void
cache_purge1(struct vnode *vp, const char *name, size_t namelen, int flags)
{
if (flags & PURGE_PARENTS) {
cache_purge_parents(vp);
}
if (flags & PURGE_CHILDREN) {
cache_purge_children(vp);
}
if (name != NULL) {
cache_purge_name(vp, name, namelen);
}
}
/*
* vnode filter for cache_purgevfs().
*/
static bool
cache_vdir_filter(void *cookie, vnode_t *vp)
{
return vp->v_type == VDIR;
}
/*
* Cache flush, a whole filesystem; called when filesys is umounted to
* remove entries that would now be invalid.
*/
void
cache_purgevfs(struct mount *mp)
{
struct vnode_iterator *iter;
vnode_t *dvp;
vfs_vnode_iterator_init(mp, &iter);
for (;;) {
dvp = vfs_vnode_iterator_next(iter, cache_vdir_filter, NULL);
if (dvp == NULL) {
break;
}
cache_purge_children(dvp);
vrele(dvp);
}
vfs_vnode_iterator_destroy(iter);
}
/*
* Re-queue an entry onto the tail of the active LRU list, after it has
* scored a hit.
*/
static void
cache_activate(struct namecache *ncp)
{
mutex_enter(&cache_lru_lock);
TAILQ_REMOVE(&cache_lru.list[ncp->nc_lrulist], ncp, nc_lru);
TAILQ_INSERT_TAIL(&cache_lru.list[LRU_ACTIVE], ncp, nc_lru);
cache_lru.count[ncp->nc_lrulist]--;
cache_lru.count[LRU_ACTIVE]++;
ncp->nc_lrulist = LRU_ACTIVE;
mutex_exit(&cache_lru_lock);
}
/*
* Try to balance the LRU lists. Pick some victim entries, and re-queue
* them from the head of the active list to the tail of the inactive list.
*/
static void
cache_deactivate(void)
{
struct namecache *ncp;
int total, i;
KASSERT(mutex_owned(&cache_lru_lock));
/* If we're nowhere near budget yet, don't bother. */
total = cache_lru.count[LRU_ACTIVE] + cache_lru.count[LRU_INACTIVE];
if (total < (desiredvnodes >> 1)) {
return;
}
/*
* Aim for a 1:1 ratio of active to inactive. This is to allow each
* potential victim a reasonable amount of time to cycle through the
* inactive list in order to score a hit and be reactivated, while
* trying not to cause reactivations too frequently.
*/
if (cache_lru.count[LRU_ACTIVE] < cache_lru.count[LRU_INACTIVE]) {
return;
}
/* Move only a few at a time; will catch up eventually. */
for (i = 0; i < cache_lru_maxdeact; i++) {
ncp = TAILQ_FIRST(&cache_lru.list[LRU_ACTIVE]);
if (ncp == NULL) {
break;
}
KASSERT(ncp->nc_lrulist == LRU_ACTIVE);
ncp->nc_lrulist = LRU_INACTIVE;
TAILQ_REMOVE(&cache_lru.list[LRU_ACTIVE], ncp, nc_lru);
TAILQ_INSERT_TAIL(&cache_lru.list[LRU_INACTIVE], ncp, nc_lru);
cache_lru.count[LRU_ACTIVE]--;
cache_lru.count[LRU_INACTIVE]++;
}
}
/*
* Free some entries from the cache, when we have gone over budget.
*
* We don't want to cause too much work for any individual caller, and it
* doesn't matter if we temporarily go over budget. This is also "just a
* cache" so it's not a big deal if we screw up and throw out something we
* shouldn't. So we take a relaxed attitude to this process to reduce its
* impact.
*/
static void
cache_reclaim(void)
{
struct namecache *ncp;
vnode_impl_t *dvi;
int toscan;
/*
* Scan up to a preset maximum number of entries, but no more than
* 0.8% of the total at once (to allow for very small systems).
*
* On bigger systems, do a larger chunk of work to reduce the number
* of times that cache_lru_lock is held for any length of time.
*/
mutex_enter(&cache_lru_lock);
toscan = MIN(cache_lru_maxscan, desiredvnodes >> 7);
toscan = MAX(toscan, 1);
SDT_PROBE(vfs, namecache, prune, done, cache_lru.count[LRU_ACTIVE] +
cache_lru.count[LRU_INACTIVE], toscan, 0, 0, 0);
while (toscan-- != 0) {
/* First try to balance the lists. */
cache_deactivate();
/* Now look for a victim on head of inactive list (old). */
ncp = TAILQ_FIRST(&cache_lru.list[LRU_INACTIVE]);
if (ncp == NULL) {
break;
}
dvi = VNODE_TO_VIMPL(ncp->nc_dvp);
KASSERT(ncp->nc_lrulist == LRU_INACTIVE);
KASSERT(dvi != NULL);
/*
* Locking in the wrong direction. If we can't get the
* lock, the directory is actively busy, and it could also
* cause problems for the next guy in here, so send the
* entry to the back of the list.
*/
if (!rw_tryenter(&dvi->vi_nc_lock, RW_WRITER)) {
TAILQ_REMOVE(&cache_lru.list[LRU_INACTIVE],
ncp, nc_lru);
TAILQ_INSERT_TAIL(&cache_lru.list[LRU_INACTIVE],
ncp, nc_lru);
continue;
}
/*
* Now have the victim entry locked. Drop the LRU list
* lock, purge the entry, and start over. The hold on
* vi_nc_lock will prevent the vnode from vanishing until
* finished (cache_purge() will be called on dvp before it
* disappears, and that will wait on vi_nc_lock).
*/
mutex_exit(&cache_lru_lock);
cache_remove(ncp, true);
rw_exit(&dvi->vi_nc_lock);
mutex_enter(&cache_lru_lock);
}
mutex_exit(&cache_lru_lock);
}
/*
* For file system code: count a lookup that required a full re-scan of
* directory metadata.
*/
void
namecache_count_pass2(void)
{
COUNT(ncs_pass2);
}
/*
* For file system code: count a lookup that scored a hit in the directory
* metadata near the location of the last lookup.
*/
void
namecache_count_2passes(void)
{
COUNT(ncs_2passes);
}
/*
* Sum the stats from all CPUs into nchstats. This needs to run at least
* once within every window where a 32-bit counter could roll over. It's
* called regularly by timer to ensure this.
*/
static void
cache_update_stats(void *cookie)
{
CPU_INFO_ITERATOR cii;
struct cpu_info *ci;
mutex_enter(&cache_stat_lock);
for (CPU_INFO_FOREACH(cii, ci)) {
struct nchcpu *nchcpu = ci->ci_data.cpu_nch;
UPDATE(nchcpu, ncs_goodhits);
UPDATE(nchcpu, ncs_neghits);
UPDATE(nchcpu, ncs_badhits);
UPDATE(nchcpu, ncs_falsehits);
UPDATE(nchcpu, ncs_miss);
UPDATE(nchcpu, ncs_long);
UPDATE(nchcpu, ncs_pass2);
UPDATE(nchcpu, ncs_2passes);
UPDATE(nchcpu, ncs_revhits);
UPDATE(nchcpu, ncs_revmiss);
UPDATE(nchcpu, ncs_denied);
}
if (cookie != NULL) {
memcpy(cookie, &nchstats, sizeof(nchstats));
}
/* Reset the timer; arrive back here in N minutes at latest. */
callout_schedule(&cache_stat_callout, cache_stat_interval * hz);
mutex_exit(&cache_stat_lock);
}
/*
* Fetch the current values of the stats for sysctl.
*/
static int
cache_stat_sysctl(SYSCTLFN_ARGS)
{
struct nchstats stats;
if (oldp == NULL) {
*oldlenp = sizeof(nchstats);
return 0;
}
if (*oldlenp <= 0) {
*oldlenp = 0;
return 0;
}
/* Refresh the global stats. */
sysctl_unlock();
cache_update_stats(&stats);
sysctl_relock();
*oldlenp = MIN(sizeof(stats), *oldlenp);
return sysctl_copyout(l, &stats, oldp, *oldlenp);
}
/*
* For the debugger, given the address of a vnode, print all associated
* names in the cache.
*/
#ifdef DDB
void
namecache_print(struct vnode *vp, void (*pr)(const char *, ...))
{
struct vnode *dvp = NULL;
struct namecache *ncp;
enum cache_lru_id id;
for (id = 0; id < LRU_COUNT; id++) {
TAILQ_FOREACH(ncp, &cache_lru.list[id], nc_lru) {
if (ncp->nc_vp == vp) {
(*pr)("name %.*s\n", ncp->nc_nlen,
ncp->nc_name);
dvp = ncp->nc_dvp;
}
}
}
if (dvp == NULL) {
(*pr)("name not found\n");
return;
}
for (id = 0; id < LRU_COUNT; id++) {
TAILQ_FOREACH(ncp, &cache_lru.list[id], nc_lru) {
if (ncp->nc_vp == dvp) {
(*pr)("parent %.*s\n", ncp->nc_nlen,
ncp->nc_name);
}
}
}
}
#endif
|
70e1b87020c2d23246cacfa2c821406c5d810221
|
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
|
/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509_macos.c
|
41ba9648259c7600bf0bdb65869d743f50b2f56c
|
[
"MIT"
] |
permissive
|
dotnet/runtime
|
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
|
47bb554d298e1e34c4e3895d7731e18ad1c47d02
|
refs/heads/main
| 2023-09-03T15:35:46.493337
| 2023-09-03T08:13:23
| 2023-09-03T08:13:23
| 210,716,005
| 13,765
| 5,179
|
MIT
| 2023-09-14T21:58:52
| 2019-09-24T23:36:39
|
C#
|
UTF-8
|
C
| false
| false
| 21,088
|
c
|
pal_x509_macos.c
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "pal_x509.h"
#include "pal_x509_macos.h"
#include "pal_utilities.h"
#include <dlfcn.h>
#include <pthread.h>
static const int32_t kErrOutItemsNull = -3;
static const int32_t kErrOutItemsEmpty = -2;
static int32_t ProcessCertificateTypeReturn(CFArrayRef items, SecCertificateRef* pCertOut, SecIdentityRef* pIdentityOut)
{
assert(pCertOut != NULL && *pCertOut == NULL);
assert(pIdentityOut != NULL && *pIdentityOut == NULL);
if (items == NULL)
{
return kErrOutItemsNull;
}
CFIndex itemCount = CFArrayGetCount(items);
if (itemCount == 0)
{
return kErrOutItemsEmpty;
}
CFTypeRef bestItem = NULL;
for (CFIndex i = 0; i < itemCount; i++)
{
CFTypeRef current = CFArrayGetValueAtIndex(items, i);
CFTypeID currentItemType = CFGetTypeID(current);
if (currentItemType == SecIdentityGetTypeID())
{
bestItem = current;
break;
}
else if (bestItem == NULL && currentItemType == SecCertificateGetTypeID())
{
bestItem = current;
}
}
if (bestItem == NULL)
{
return -13;
}
if (CFGetTypeID(bestItem) == SecCertificateGetTypeID())
{
CFRetain(bestItem);
*pCertOut = (SecCertificateRef)CONST_CAST(void *,bestItem);
return 1;
}
if (CFGetTypeID(bestItem) == SecIdentityGetTypeID())
{
CFRetain(bestItem);
*pIdentityOut = (SecIdentityRef)CONST_CAST(void *,bestItem);
return 1;
}
return -19;
}
static int32_t ReadX509(uint8_t* pbData,
int32_t cbData,
PAL_X509ContentType contentType,
CFStringRef cfPfxPassphrase,
SecKeychainRef keychain,
bool exportable,
SecCertificateRef* pCertOut,
SecIdentityRef* pIdentityOut,
CFArrayRef* pCollectionOut,
int32_t* pOSStatus)
{
assert(pbData != NULL);
assert(cbData >= 0);
assert((pCertOut == NULL) == (pIdentityOut == NULL));
assert((pCertOut == NULL) != (pCollectionOut == NULL));
SecExternalFormat dataFormat;
SecExternalItemType itemType;
int32_t ret = 0;
CFArrayRef outItems = NULL;
CFMutableArrayRef keyAttributes = NULL;
SecKeychainRef importKeychain = NULL;
SecItemImportExportKeyParameters importParams;
memset(&importParams, 0, sizeof(SecItemImportExportKeyParameters));
importParams.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;
if (contentType == PAL_Certificate)
{
dataFormat = kSecFormatX509Cert;
itemType = kSecItemTypeCertificate;
}
else if (contentType == PAL_Pkcs7)
{
dataFormat = kSecFormatPKCS7;
itemType = kSecItemTypeAggregate;
}
else if (contentType == PAL_Pkcs12)
{
dataFormat = kSecFormatPKCS12;
itemType = kSecItemTypeAggregate;
importParams.passphrase = cfPfxPassphrase;
importKeychain = keychain;
if (keychain == NULL)
{
return kErrorBadInput;
}
// if keyAttributes is NULL then it uses SENSITIVE | EXTRACTABLE
// so if !exportable was requested, assert SENSITIVE.
if (!exportable)
{
keyAttributes = CFArrayCreateMutable(NULL, 9, &kCFTypeArrayCallBacks);
if (keyAttributes == NULL)
{
*pOSStatus = errSecAllocate;
return 0;
}
int32_t sensitiveValue = CSSM_KEYATTR_SENSITIVE;
CFNumberRef sensitive = CFNumberCreate(NULL, kCFNumberSInt32Type, &sensitiveValue);
if (sensitive == NULL)
{
CFRelease(keyAttributes);
*pOSStatus = errSecAllocate;
return 0;
}
CFArrayAppendValue(keyAttributes, sensitive);
CFRelease(sensitive);
importParams.keyAttributes = keyAttributes;
}
}
else
{
*pOSStatus = errSecUnknownFormat;
return 0;
}
CFDataRef cfData = CFDataCreateWithBytesNoCopy(NULL, pbData, cbData, kCFAllocatorNull);
if (cfData == NULL)
{
*pOSStatus = errSecAllocate;
}
if (*pOSStatus == noErr)
{
*pOSStatus = SecItemImport(cfData, NULL, &dataFormat, &itemType, 0, &importParams, keychain, &outItems);
}
if (contentType == PAL_Pkcs12 && *pOSStatus == errSecPassphraseRequired && cfPfxPassphrase == NULL)
{
if (outItems != NULL)
{
CFRelease(outItems);
outItems = NULL;
}
// Try again with the empty string passphrase.
importParams.passphrase = CFSTR("");
*pOSStatus = SecItemImport(cfData, NULL, &dataFormat, &itemType, 0, &importParams, keychain, &outItems);
CFRelease(importParams.passphrase);
importParams.passphrase = NULL;
}
if (*pOSStatus == noErr)
{
if (pCollectionOut != NULL)
{
CFRetain(outItems);
*pCollectionOut = outItems;
ret = 1;
}
else
{
ret = ProcessCertificateTypeReturn(outItems, pCertOut, pIdentityOut);
}
}
if (keyAttributes != NULL)
{
CFRelease(keyAttributes);
}
if (outItems != NULL)
{
// In the event this is returned via pCollectionOut it was already
// CFRetain()ed, so always CFRelease here.
CFRelease(outItems);
}
CFRelease(cfData);
return ret;
}
int32_t AppleCryptoNative_X509ImportCollection(uint8_t* pbData,
int32_t cbData,
PAL_X509ContentType contentType,
CFStringRef cfPfxPassphrase,
SecKeychainRef keychain,
int32_t exportable,
CFArrayRef* pCollectionOut,
int32_t* pOSStatus)
{
if (pCollectionOut != NULL)
*pCollectionOut = NULL;
if (pOSStatus != NULL)
*pOSStatus = noErr;
if (pbData == NULL || cbData < 0 || pCollectionOut == NULL || pOSStatus == NULL ||
exportable != !!exportable)
{
return kErrorBadInput;
}
return ReadX509(pbData,
cbData,
contentType,
cfPfxPassphrase,
keychain,
(bool)exportable,
NULL,
NULL,
pCollectionOut,
pOSStatus);
}
int32_t AppleCryptoNative_X509ImportCertificate(uint8_t* pbData,
int32_t cbData,
PAL_X509ContentType contentType,
CFStringRef cfPfxPassphrase,
SecKeychainRef keychain,
int32_t exportable,
SecCertificateRef* pCertOut,
SecIdentityRef* pIdentityOut,
int32_t* pOSStatus)
{
if (pCertOut != NULL)
*pCertOut = NULL;
if (pIdentityOut != NULL)
*pIdentityOut = NULL;
if (pOSStatus != NULL)
*pOSStatus = noErr;
if (pbData == NULL || cbData < 0 || pCertOut == NULL || pIdentityOut == NULL || pOSStatus == NULL ||
exportable != !!exportable)
{
return kErrorBadInput;
}
return ReadX509(pbData,
cbData,
contentType,
cfPfxPassphrase,
keychain,
(bool)exportable,
pCertOut,
pIdentityOut,
NULL,
pOSStatus);
}
int32_t AppleCryptoNative_X509ExportData(CFArrayRef data,
PAL_X509ContentType type,
CFStringRef cfExportPassphrase,
CFDataRef* pExportOut,
int32_t* pOSStatus)
{
if (pExportOut != NULL)
*pExportOut = NULL;
if (pOSStatus != NULL)
*pOSStatus = noErr;
if (data == NULL || pExportOut == NULL || pOSStatus == NULL)
{
return kErrorBadInput;
}
SecExternalFormat dataFormat = kSecFormatUnknown;
switch (type)
{
case PAL_Pkcs7:
dataFormat = kSecFormatPKCS7;
break;
case PAL_Pkcs12:
dataFormat = kSecFormatPKCS12;
break;
default:
return kErrorBadInput;
}
SecItemImportExportKeyParameters keyParams;
memset(&keyParams, 0, sizeof(SecItemImportExportKeyParameters));
keyParams.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;
keyParams.passphrase = cfExportPassphrase;
*pOSStatus = SecItemExport(data, dataFormat, 0, &keyParams, pExportOut);
return *pOSStatus == noErr;
}
static OSStatus AddKeyToKeychain(SecKeyRef privateKey, SecKeychainRef targetKeychain, SecKeyRef* importedKey)
{
SecExternalFormat dataFormat = kSecFormatWrappedPKCS8;
CFDataRef exportData = NULL;
SecItemImportExportKeyParameters keyParams;
memset(&keyParams, 0, sizeof(SecItemImportExportKeyParameters));
keyParams.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;
keyParams.passphrase = CFSTR("ExportImportPassphrase");
OSStatus status = SecItemExport(privateKey, dataFormat, 0, &keyParams, &exportData);
SecExternalFormat actualFormat = dataFormat;
SecExternalItemType actualType = kSecItemTypePrivateKey;
CFArrayRef outItems = NULL;
if (status == noErr)
{
status =
SecItemImport(exportData, NULL, &actualFormat, &actualType, 0, &keyParams, targetKeychain, &outItems);
}
if (status == noErr && importedKey != NULL && outItems != NULL && CFArrayGetCount(outItems) == 1)
{
CFTypeRef outItem = CFArrayGetValueAtIndex(outItems, 0);
if (CFGetTypeID(outItem) == SecKeyGetTypeID())
{
CFRetain(outItem);
*importedKey = (SecKeyRef)CONST_CAST(void*, outItem);
}
}
if (exportData != NULL)
CFRelease(exportData);
CFRelease(keyParams.passphrase);
keyParams.passphrase = NULL;
if (outItems != NULL)
CFRelease(outItems);
return status;
}
int32_t AppleCryptoNative_X509CopyWithPrivateKey(SecCertificateRef cert,
SecKeyRef privateKey,
SecKeychainRef targetKeychain,
SecIdentityRef* pIdentityOut,
int32_t* pOSStatus)
{
if (pIdentityOut != NULL)
*pIdentityOut = NULL;
if (pOSStatus != NULL)
*pOSStatus = noErr;
if (cert == NULL || privateKey == NULL || targetKeychain == NULL || pIdentityOut == NULL ||
pOSStatus == NULL)
{
return -1;
}
SecKeychainRef keyKeychain = NULL;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
OSStatus status = SecKeychainItemCopyKeychain((SecKeychainItemRef)privateKey, &keyKeychain);
#pragma clang diagnostic pop
SecKeychainItemRef itemCopy = NULL;
// This only happens with an ephemeral key, so the keychain we're adding it to is temporary.
if (status == errSecNoSuchKeychain)
{
status = AddKeyToKeychain(privateKey, targetKeychain, NULL);
}
if (itemCopy != NULL)
{
CFRelease(itemCopy);
}
CFMutableDictionaryRef query = NULL;
if (status == noErr)
{
query = CFDictionaryCreateMutable(
kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
if (query == NULL)
{
status = errSecAllocate;
}
}
CFArrayRef searchList = NULL;
if (status == noErr)
{
const void *constTargetKeychain = targetKeychain;
searchList = CFArrayCreate(
NULL, (const void**)(&constTargetKeychain), 1, &kCFTypeArrayCallBacks);
if (searchList == NULL)
{
status = errSecAllocate;
}
}
CFArrayRef itemMatch = NULL;
if (status == noErr)
{
const void *constCert = cert;
itemMatch = CFArrayCreate(
NULL, (const void**)(&constCert), 1, &kCFTypeArrayCallBacks);
if (itemMatch == NULL)
{
status = errSecAllocate;
}
}
CFTypeRef result = NULL;
if (status == noErr)
{
CFDictionarySetValue(query, kSecReturnRef, kCFBooleanTrue);
CFDictionarySetValue(query, kSecMatchSearchList, searchList);
CFDictionarySetValue(query, kSecMatchItemList, itemMatch);
CFDictionarySetValue(query, kSecClass, kSecClassIdentity);
status = SecItemCopyMatching(query, &result);
if (status != noErr && result != NULL)
{
CFRelease(result);
result = NULL;
}
bool added = false;
if (status == errSecItemNotFound)
{
status = SecCertificateAddToKeychain(cert, targetKeychain);
added = (status == noErr);
}
if (result == NULL && status == noErr)
{
status = SecItemCopyMatching(query, &result);
}
if (result != NULL && status == noErr)
{
if (CFGetTypeID(result) != SecIdentityGetTypeID())
{
status = errSecItemNotFound;
}
else
{
SecIdentityRef identity = (SecIdentityRef)CONST_CAST(void *, result);
CFRetain(identity);
*pIdentityOut = identity;
}
}
if (added)
{
// The same query that was used to find the identity can be used
// to find/delete the certificate, as long as we fix the class to just the cert.
CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
// Ignore the output status, there's no point in telling the user
// that the cleanup failed, since that just makes them have a dirty keychain
// AND their program didn't work.
SecItemDelete(query);
}
}
if (result != NULL)
CFRelease(result);
if (itemMatch != NULL)
CFRelease(itemMatch);
if (searchList != NULL)
CFRelease(searchList);
if (query != NULL)
CFRelease(query);
if (keyKeychain != NULL)
CFRelease(keyKeychain);
*pOSStatus = status;
return status == noErr;
}
int32_t AppleCryptoNative_X509MoveToKeychain(SecCertificateRef cert,
SecKeychainRef targetKeychain,
SecKeyRef privateKey,
SecIdentityRef* pIdentityOut,
int32_t* pOSStatus)
{
if (pIdentityOut != NULL)
*pIdentityOut = NULL;
if (pOSStatus != NULL)
*pOSStatus = noErr;
if (cert == NULL || targetKeychain == NULL || pIdentityOut == NULL || pOSStatus == NULL)
{
return -1;
}
SecKeychainRef curKeychain = NULL;
SecKeyRef importedKey = NULL;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
OSStatus status = SecKeychainItemCopyKeychain((SecKeychainItemRef)cert, &curKeychain);
#pragma clang diagnostic pop
if (status == errSecNoSuchKeychain)
{
status = noErr;
}
else
{
if (curKeychain != NULL)
{
CFRelease(curKeychain);
}
if (status == noErr)
{
// Usage error: The certificate should have been freshly imported by the PFX loader,
// and therefore have no keychain.
return -2;
}
}
if (status == noErr && privateKey != NULL)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
status = SecKeychainItemCopyKeychain((SecKeychainItemRef)privateKey, &curKeychain);
#pragma clang diagnostic pop
if (status == errSecNoSuchKeychain)
{
status = AddKeyToKeychain(privateKey, targetKeychain, &importedKey);
// A duplicate key import will be the only time that status is noErr
// and importedKey is NULL.
if (status == errSecDuplicateItem)
{
status = noErr;
}
}
else
{
if (curKeychain != NULL)
{
CFRelease(curKeychain);
}
if (status == noErr)
{
// This is a usage error, the only expected call is from the PFX loader,
// which has an ephemeral key reference, therefore no keychain.
return -3;
}
}
}
if (status == noErr)
{
status = SecCertificateAddToKeychain(cert, targetKeychain);
if (status == errSecDuplicateItem)
{
status = noErr;
}
}
if (status == noErr && privateKey != NULL)
{
CFMutableDictionaryRef query = NULL;
CFArrayRef searchList = NULL;
CFArrayRef itemMatch = NULL;
CFTypeRef result = NULL;
if (status == noErr)
{
query = CFDictionaryCreateMutable(
kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
if (query == NULL)
{
status = errSecAllocate;
}
}
if (status == noErr)
{
const void* constTargetKeychain = targetKeychain;
searchList = CFArrayCreate(NULL, (const void**)(&constTargetKeychain), 1, &kCFTypeArrayCallBacks);
if (searchList == NULL)
{
status = errSecAllocate;
}
}
if (status == noErr)
{
const void* constCert = cert;
itemMatch = CFArrayCreate(NULL, (const void**)(&constCert), 1, &kCFTypeArrayCallBacks);
if (itemMatch == NULL)
{
status = errSecAllocate;
}
}
if (status == noErr)
{
CFDictionarySetValue(query, kSecReturnRef, kCFBooleanTrue);
CFDictionarySetValue(query, kSecMatchSearchList, searchList);
CFDictionarySetValue(query, kSecMatchItemList, itemMatch);
CFDictionarySetValue(query, kSecClass, kSecClassIdentity);
status = SecItemCopyMatching(query, &result);
if (status != noErr && result != NULL)
{
CFRelease(result);
result = NULL;
}
if (result != NULL)
{
if (CFGetTypeID(result) == SecIdentityGetTypeID())
{
SecIdentityRef identity = (SecIdentityRef)CONST_CAST(void*, result);
CFRetain(identity);
*pIdentityOut = identity;
}
}
if (status == errSecItemNotFound && importedKey != NULL)
{
// An identity can't be found.
// That means that the private key does not match the certificate public key.
// Since we know we added the key, and nothing will reference it now, try to remove it.
const void* constKey = importedKey;
CFArrayRef newItemMatch = CFArrayCreate(NULL, (const void**)(&constKey), 1, &kCFTypeArrayCallBacks);
CFDictionarySetValue(query, kSecMatchItemList, newItemMatch);
CFRelease(itemMatch);
itemMatch = newItemMatch;
CFDictionarySetValue(query, kSecClass, kSecClassKey);
// Even if the key delete failed, there's nothing the user can do about it now.
// Ignore the result of delete and just return to noErr
SecItemDelete(query);
status = noErr;
}
}
if (result != NULL)
CFRelease(result);
if (itemMatch != NULL)
CFRelease(itemMatch);
if (searchList != NULL)
CFRelease(searchList);
if (query != NULL)
CFRelease(query);
}
if (importedKey != NULL)
CFRelease(importedKey);
*pOSStatus = status;
return status == noErr;
}
|
b8cc81ef471c005700fd03289f2c337b05a69cd9
|
9ca19ee62e2c985be413bd12e5eb63b44833750d
|
/src/platform/pc/textend.c
|
b00e52fee81f9569ece90cfa3c4fbbaaeda424a6
|
[
"MIT"
] |
permissive
|
MitchBradley/cforth
|
4cb523847c552b2e32e5e50a328b8e263a074d85
|
bae39263f2615e1d260426e3eca0ab32816f54ef
|
refs/heads/master
| 2023-08-31T17:23:00.037535
| 2023-08-17T09:01:57
| 2023-08-17T09:01:57
| 12,050,604
| 142
| 43
|
NOASSERTION
| 2023-08-21T16:36:56
| 2013-08-12T07:50:31
|
C
|
UTF-8
|
C
| false
| false
| 2,280
|
c
|
textend.c
|
// Edit this file to include C routines that can be called as Forth words.
// See "ccalls" below.
#include <io.h>
// This is the only thing that we need from forth.h
#define cell long
// Prototypes
cell pcfetch(cell port);
void pcstore(cell port, cell value);
cell pwfetch(cell port);
void pwstore(cell port, cell value);
cell plfetch(cell port);
void plstore(cell port, cell value);
cell cbfetch(cell port);
void cbstore(cell port, cell value);
cell cwfetch(cell port);
void cwstore(cell port, cell value);
cell clfetch(cell port);
void clstore(cell port, cell value);
cell pcfetch(cell port)
{
return inb(port);
}
void pcstore(cell port, cell value)
{
outb(value, port);
}
cell pwfetch(cell port)
{
return inw(port);
}
void pwstore(cell port, cell value)
{
outw(value, port);
}
cell plfetch(cell port)
{
return inl(port);
}
void plstore(cell port, cell value)
{
return outl(value, port);
}
#define CFG_SETUP(cfgadr) outl((cfgadr | 0x80000000) & ~3, 0xcf8)
#define CFG_DATA(cfgadr) (0xcfc + (cfgadr&3))
cell cbfetch(cell cfgadr)
{
CFG_SETUP(cfgadr);
return inb(CFG_DATA(cfgadr));
}
void cbstore(cell cfgadr, cell value)
{
CFG_SETUP(cfgadr);
outb(value, 0xcfc + (cfgadr&3));
}
cell cwfetch(cell cfgadr)
{
CFG_SETUP(cfgadr);
return inw(CFG_DATA(cfgadr));
}
void cwstore(cell cfgadr, cell value)
{
CFG_SETUP(cfgadr);
outw(value, CFG_DATA(cfgadr));
}
cell clfetch(cell cfgadr)
{
CFG_SETUP(cfgadr);
return inl(CFG_DATA(cfgadr));
}
void clstore(cell cfgadr, cell value)
{
CFG_SETUP(cfgadr);
outl(value, CFG_DATA(cfgadr));
}
cell ((* const ccalls[])()) = {
C(pcfetch) //c pc@ { i.port -- i.byte }
C(pcstore) //c pc! { i.byte i.port -- }
C(pwfetch) //c pw@ { i.port -- i.word }
C(pwstore) //c pw! { i.word i.port -- }
C(plfetch) //c pl@ { i.port -- i.long }
C(plstore) //c pl! { i.long i.port -- }
C(cbfetch) //c config-b@ { i.cfgadr -- i.byte }
C(cbstore) //c config-b! { i.byte i.cfgadr -- }
C(cwfetch) //c config-w@ { i.cfgadr -- i.word }
C(cwstore) //c config-w! { i.word i.cfgadr -- }
C(clfetch) //c config-l@ { i.cfgadr -- i.word }
C(clstore) //c config-l! { i.long i.cfgadr -- }
};
|
1ee442926a9e624be6bdd2ac0fc0a4b9b59b8c63
|
e3a97b316fdf07b170341da206163a865f9e812c
|
/vital/bindings/c/common.h
|
c5d0ba6d34ace9488237008c660fdacbef40ad89
|
[
"BSD-3-Clause"
] |
permissive
|
Kitware/kwiver
|
09133ede9d05c33212839cc29d396aa8ca21baaf
|
a422409b83f78f31cda486e448e8009513e75427
|
refs/heads/master
| 2023-08-28T10:41:58.077148
| 2023-07-28T21:18:52
| 2023-07-28T21:18:52
| 23,229,909
| 191
| 92
|
NOASSERTION
| 2023-06-26T17:18:20
| 2014-08-22T15:22:20
|
C++
|
UTF-8
|
C
| false
| false
| 1,077
|
h
|
common.h
|
// This file is part of KWIVER, and is distributed under the
// OSI-approved BSD 3-Clause License. See top-level LICENSE file or
// https://github.com/Kitware/kwiver/blob/master/LICENSE for details.
/**
* \file
* \brief Common C Interface Utilities
*/
#ifndef VITAL_C_COMMON_H_
#define VITAL_C_COMMON_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include <stddef.h>
#include <vital/bindings/c/vital_c_export.h>
/// Simple string structure
typedef struct {
size_t length;
char *str;
} vital_string_t;
/// Allocate a new vital string structure
VITAL_C_EXPORT
vital_string_t* vital_string_new(size_t length, char const* s);
/// Free an allocated string structure
VITAL_C_EXPORT
void vital_string_free( vital_string_t *s );
/// Common function for freeing string lists
VITAL_C_EXPORT
void vital_common_free_string_list( size_t length, char **keys );
/// Other free functions
VITAL_C_EXPORT void vital_free_pointer( void *thing );
VITAL_C_EXPORT void vital_free_double_pointer( size_t length, void **things );
#ifdef __cplusplus
}
#endif
#endif // VITAL_C_COMMON_H_
|
9efc456b066cb6ac781c172673720cd6f088fc68
|
a3d6556180e74af7b555f8d47d3fea55b94bcbda
|
/gpu/command_buffer/service/context_state_autogen.h
|
2cf80d0b154aebe47cf0eaa2777e6662d7cbfbf6
|
[
"BSD-3-Clause"
] |
permissive
|
chromium/chromium
|
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
|
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
|
refs/heads/main
| 2023-08-24T00:35:12.585945
| 2023-08-23T22:01:11
| 2023-08-23T22:01:11
| 120,360,765
| 17,408
| 7,102
|
BSD-3-Clause
| 2023-09-10T23:44:27
| 2018-02-05T20:55:32
| null |
UTF-8
|
C
| false
| false
| 6,361
|
h
|
context_state_autogen.h
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is auto-generated from
// gpu/command_buffer/build_gles2_cmd_buffer.py
// It's formatted by clang-format using chromium coding style:
// clang-format -i -style=chromium filename
// DO NOT EDIT!
// It is included by context_state.h
#ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_AUTOGEN_H_
#define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_AUTOGEN_H_
struct EnableFlags {
EnableFlags();
bool blend;
bool cached_blend;
bool cull_face;
bool cached_cull_face;
bool depth_test;
bool cached_depth_test;
bool dither;
bool cached_dither;
bool framebuffer_srgb_ext;
bool cached_framebuffer_srgb_ext;
bool polygon_offset_fill;
bool cached_polygon_offset_fill;
bool sample_alpha_to_coverage;
bool cached_sample_alpha_to_coverage;
bool sample_coverage;
bool cached_sample_coverage;
bool scissor_test;
bool cached_scissor_test;
bool stencil_test;
bool cached_stencil_test;
bool rasterizer_discard;
bool cached_rasterizer_discard;
bool primitive_restart_fixed_index;
bool cached_primitive_restart_fixed_index;
bool multisample_ext;
bool cached_multisample_ext;
bool sample_alpha_to_one_ext;
bool cached_sample_alpha_to_one_ext;
};
GLfloat blend_color_red;
GLfloat blend_color_green;
GLfloat blend_color_blue;
GLfloat blend_color_alpha;
GLenum blend_equation_rgb;
GLenum blend_equation_alpha;
GLenum blend_source_rgb;
GLenum blend_dest_rgb;
GLenum blend_source_alpha;
GLenum blend_dest_alpha;
GLfloat color_clear_red;
GLfloat color_clear_green;
GLfloat color_clear_blue;
GLfloat color_clear_alpha;
GLclampf depth_clear;
GLint stencil_clear;
GLboolean color_mask_red;
GLboolean cached_color_mask_red;
GLboolean color_mask_green;
GLboolean cached_color_mask_green;
GLboolean color_mask_blue;
GLboolean cached_color_mask_blue;
GLboolean color_mask_alpha;
GLboolean cached_color_mask_alpha;
GLenum cull_mode;
GLenum depth_func;
GLboolean depth_mask;
GLboolean cached_depth_mask;
GLclampf z_near;
GLclampf z_far;
GLenum front_face;
GLenum hint_generate_mipmap;
GLenum hint_fragment_shader_derivative;
GLenum hint_texture_filtering;
GLfloat line_width;
GLint pack_alignment;
GLint unpack_alignment;
GLint pack_row_length;
GLint pack_skip_pixels;
GLint pack_skip_rows;
GLint unpack_row_length;
GLint unpack_image_height;
GLint unpack_skip_pixels;
GLint unpack_skip_rows;
GLint unpack_skip_images;
GLfloat polygon_offset_factor;
GLfloat polygon_offset_units;
GLclampf sample_coverage_value;
GLboolean sample_coverage_invert;
GLint scissor_x;
GLint scissor_y;
GLsizei scissor_width;
GLsizei scissor_height;
GLenum stencil_front_func;
GLint stencil_front_ref;
GLuint stencil_front_mask;
GLenum stencil_back_func;
GLint stencil_back_ref;
GLuint stencil_back_mask;
GLuint stencil_front_writemask;
GLuint cached_stencil_front_writemask;
GLuint stencil_back_writemask;
GLuint cached_stencil_back_writemask;
GLenum stencil_front_fail_op;
GLenum stencil_front_z_fail_op;
GLenum stencil_front_z_pass_op;
GLenum stencil_back_fail_op;
GLenum stencil_back_z_fail_op;
GLenum stencil_back_z_pass_op;
GLint viewport_x;
GLint viewport_y;
GLsizei viewport_width;
GLsizei viewport_height;
GLenum window_rectangles_mode;
GLint num_window_rectangles;
inline void SetDeviceCapabilityState(GLenum cap, bool enable) {
switch (cap) {
case GL_BLEND:
if (enable_flags.cached_blend == enable && !ignore_cached_state)
return;
enable_flags.cached_blend = enable;
break;
case GL_CULL_FACE:
if (enable_flags.cached_cull_face == enable && !ignore_cached_state)
return;
enable_flags.cached_cull_face = enable;
break;
case GL_DEPTH_TEST:
if (enable_flags.cached_depth_test == enable && !ignore_cached_state)
return;
enable_flags.cached_depth_test = enable;
break;
case GL_DITHER:
if (enable_flags.cached_dither == enable && !ignore_cached_state)
return;
enable_flags.cached_dither = enable;
break;
case GL_FRAMEBUFFER_SRGB_EXT:
if (enable_flags.cached_framebuffer_srgb_ext == enable &&
!ignore_cached_state)
return;
enable_flags.cached_framebuffer_srgb_ext = enable;
break;
case GL_POLYGON_OFFSET_FILL:
if (enable_flags.cached_polygon_offset_fill == enable &&
!ignore_cached_state)
return;
enable_flags.cached_polygon_offset_fill = enable;
break;
case GL_SAMPLE_ALPHA_TO_COVERAGE:
if (enable_flags.cached_sample_alpha_to_coverage == enable &&
!ignore_cached_state)
return;
enable_flags.cached_sample_alpha_to_coverage = enable;
break;
case GL_SAMPLE_COVERAGE:
if (enable_flags.cached_sample_coverage == enable && !ignore_cached_state)
return;
enable_flags.cached_sample_coverage = enable;
break;
case GL_SCISSOR_TEST:
if (enable_flags.cached_scissor_test == enable && !ignore_cached_state)
return;
enable_flags.cached_scissor_test = enable;
break;
case GL_STENCIL_TEST:
if (enable_flags.cached_stencil_test == enable && !ignore_cached_state)
return;
enable_flags.cached_stencil_test = enable;
break;
case GL_RASTERIZER_DISCARD:
if (enable_flags.cached_rasterizer_discard == enable &&
!ignore_cached_state)
return;
enable_flags.cached_rasterizer_discard = enable;
break;
case GL_PRIMITIVE_RESTART_FIXED_INDEX:
if (enable_flags.cached_primitive_restart_fixed_index == enable &&
!ignore_cached_state)
return;
enable_flags.cached_primitive_restart_fixed_index = enable;
break;
case GL_MULTISAMPLE_EXT:
if (enable_flags.cached_multisample_ext == enable && !ignore_cached_state)
return;
enable_flags.cached_multisample_ext = enable;
break;
case GL_SAMPLE_ALPHA_TO_ONE_EXT:
if (enable_flags.cached_sample_alpha_to_one_ext == enable &&
!ignore_cached_state)
return;
enable_flags.cached_sample_alpha_to_one_ext = enable;
break;
default:
NOTREACHED();
return;
}
if (enable)
api()->glEnableFn(cap);
else
api()->glDisableFn(cap);
}
#endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_AUTOGEN_H_
|
b90946877aa7d94459bc6b223520490585b5eb75
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/devel/electron25/files/patch-components_performance__manager_public_features.h
|
dc2a6af27cee41c1647781eb77ec6a293b429f0b
|
[
"BSD-3-Clause",
"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
| 497
|
h
|
patch-components_performance__manager_public_features.h
|
--- components/performance_manager/public/features.h.orig 2023-05-25 00:41:51 UTC
+++ components/performance_manager/public/features.h
@@ -28,7 +28,7 @@ BASE_DECLARE_FEATURE(kRunOnDedicatedThreadPoolThread);
#if !BUILDFLAG(IS_ANDROID)
-#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_LINUX)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_BSD)
#define URGENT_DISCARDING_FROM_PERFORMANCE_MANAGER() false
#else
#define URGENT_DISCARDING_FROM_PERFORMANCE_MANAGER() true
|
afdf97de2eadbc08b4a4d2028bcdf91b6f5e3e8a
|
92b1f79b49b5c37ba82172febfeb577dc2ca7130
|
/src/daemon/tmp/gpaste-password-item.h
|
4893049f09df7cc9004dee4b73a96e5515c71cf3
|
[
"BSD-2-Clause"
] |
permissive
|
Keruspe/GPaste
|
67ce4080fe09b7d3ae716641f6611fd4272c02ce
|
734286a8bd76d3a76a9d5f2f1651b8be36be17f9
|
refs/heads/master
| 2023-09-03T00:18:06.425352
| 2023-08-29T11:31:09
| 2023-08-30T11:56:25
| 1,268,515
| 699
| 77
|
BSD-2-Clause
| 2023-05-10T12:44:04
| 2011-01-18T20:42:57
|
C
|
UTF-8
|
C
| false
| false
| 903
|
h
|
gpaste-password-item.h
|
/*
* This file is part of GPaste.
*
* Copyright (c) 2010-2018, Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
*/
#if !defined (__G_PASTE_H_INSIDE__) && !defined (G_PASTE_COMPILATION)
#error "Only <gpaste.h> can be included directly."
#endif
#ifndef __G_PASTE_PASSWORD_ITEM_H__
#define __G_PASTE_PASSWORD_ITEM_H__
#include <gpaste-text-item.h>
G_BEGIN_DECLS
#define G_PASTE_TYPE_PASSWORD_ITEM (g_paste_password_item_get_type ())
G_PASTE_FINAL_TYPE (PasswordItem, password_item, PASSWORD_ITEM, GPasteTextItem)
const gchar *g_paste_password_item_get_name (const GPastePasswordItem *self);
void g_paste_password_item_set_name (GPastePasswordItem *self,
const char *name);
GPasteItem *g_paste_password_item_new (const gchar *name,
const gchar *password);
G_END_DECLS
#endif /*__G_PASTE_PASSWORD_ITEM_H__*/
|
e8cf5141572b90bdd8d441f289fb4af110ec4ae7
|
f62ddee2dcadcae0e90f969be513b04e16dabf58
|
/data/source/yaltools/yalmount/main-option_recovery_password.c
|
dbb52e1354e49caaea0a38b287e29d077f2d5a93
|
[
"Apache-2.0"
] |
permissive
|
libyal/libyal
|
30bccf56471dbf874292fe32d5d9173fd470df0e
|
124111953917f65782a66a80e96a502ce2331b09
|
refs/heads/main
| 2023-07-25T09:25:46.068071
| 2023-07-08T09:56:44
| 2023-07-08T09:56:44
| 23,780,738
| 196
| 30
|
Apache-2.0
| 2022-11-27T19:01:42
| 2014-09-08T05:57:58
|
C
|
UTF-8
|
C
| false
| false
| 279
|
c
|
main-option_recovery_password.c
|
if( option_recovery_password != NULL )
{
if( mount_handle_set_recovery_password(
${mount_tool_name}_mount_handle,
option_recovery_password,
&error ) != 1 )
{
fprintf(
stderr,
"Unable to set recovery password.\n" );
goto on_error;
}
}
|
e4e154c2073f5cbb5ed8d3ef72127d8905be4394
|
52db6253baa4bf3d32cc7ce0e9e5694b48391e65
|
/tests/platform-independent-tests/tests/texture-image-generation/game.c
|
08a97bfe9ed68940041e23b6970b135d704f6478
|
[
"Unlicense"
] |
permissive
|
SasLuca/rayfork
|
02a8e185002b872a115318410e94abfc0a015bb0
|
0db32b2c80384e89555aa8f64d5be390bbb28573
|
refs/heads/rayfork-0.9
| 2021-09-11T06:30:40.597951
| 2020-12-03T10:59:55
| 2020-12-03T10:59:55
| 228,938,024
| 347
| 27
|
Unlicense
| 2022-08-22T06:09:44
| 2019-12-18T23:25:18
|
C
|
UTF-8
|
C
| false
| false
| 3,384
|
c
|
game.c
|
//Implementation of the texture image generation example from raylib using rayfork
#include "game.h"
#include "include/rayfork.h"
#include "glad.h"
#define NUM_TEXTURES 7 // Currently we have 7 generation algorithms
rf_context rf_ctx;
rf_default_render_batch rf_mem;
struct rf_default_font default_font_buffers;
rf_image vertical_gradient;
rf_image horizontal_gradient;
rf_image radial_gradient;
rf_image checked;
rf_image white_noise;
rf_image perlin_noise;
rf_image cellular;
rf_texture2d textures[NUM_TEXTURES] = { 0 };
int current_texture = 0;
void on_init(void)
{
//Load opengl with glad
gladLoadGL();
//Initialise rayfork and load the default font
rf_init(&rf_ctx, &rf_mem, SCREEN_WIDTH, SCREEN_HEIGHT, RF_DEFAULT_OPENGL_PROCS);
rf_load_default_font(&default_font_buffers);
vertical_gradient = rf_gen_image_gradient_v_ez(SCREEN_WIDTH, SCREEN_HEIGHT, RF_RED, RF_BLUE);
horizontal_gradient = rf_gen_image_gradient_h_ez(SCREEN_WIDTH, SCREEN_HEIGHT, RF_RED, RF_BLUE);
radial_gradient = rf_gen_image_gradient_radial_ez(SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, RF_WHITE, RF_BLACK);
checked = rf_gen_image_checked_ez(SCREEN_WIDTH, SCREEN_HEIGHT, 32, 32, RF_RED, RF_BLUE);
white_noise = rf_gen_image_white_noise_ez(SCREEN_WIDTH, SCREEN_HEIGHT, 0.5f);
perlin_noise = rf_gen_image_perlin_noise_ez(SCREEN_WIDTH, SCREEN_HEIGHT, 50, 50, 4.0f);
cellular = rf_gen_image_cellular_ez(SCREEN_WIDTH, SCREEN_HEIGHT, 32);
textures[0] = rf_load_texture_from_image(vertical_gradient);
textures[1] = rf_load_texture_from_image(horizontal_gradient);
textures[2] = rf_load_texture_from_image(radial_gradient);
textures[3] = rf_load_texture_from_image(checked);
textures[4] = rf_load_texture_from_image(white_noise);
textures[5] = rf_load_texture_from_image(perlin_noise);
textures[6] = rf_load_texture_from_image(cellular);
rf_unload_image_ez(vertical_gradient);
rf_unload_image_ez(horizontal_gradient);
rf_unload_image_ez(radial_gradient);
rf_unload_image_ez(checked);
rf_unload_image_ez(white_noise);
rf_unload_image_ez(perlin_noise);
rf_unload_image_ez(cellular);
}
void on_frame(const input_data input)
{
// Update
if (input.mouse_left_down || input.right_down)
{
current_texture = (current_texture + 1) % NUM_TEXTURES; // Cycle between the textures
}
// Draw
rf_begin();
rf_clear(RF_RAYWHITE);
rf_draw_texture(textures[current_texture], 0, 0, RF_WHITE);
rf_draw_rectangle(30, 400, 325, 30, rf_fade(RF_SKYBLUE, 0.5f));
rf_draw_rectangle_outline((rf_rec){ 30, 400, 325, 30 }, 1.0f, rf_fade(RF_WHITE, 0.5f));
rf_draw_text("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, RF_WHITE);
switch(current_texture)
{
case 0: rf_draw_text("VERTICAL GRADIENT", 560, 10, 20, RF_RAYWHITE); break;
case 1: rf_draw_text("HORIZONTAL GRADIENT", 540, 10, 20, RF_RAYWHITE); break;
case 2: rf_draw_text("RADIAL GRADIENT", 580, 10, 20, RF_LIGHTGRAY); break;
case 3: rf_draw_text("CHECKED", 680, 10, 20, RF_RAYWHITE); break;
case 4: rf_draw_text("WHITE NOISE", 640, 10, 20, RF_RED); break;
case 5: rf_draw_text("PERLIN NOISE", 630, 10, 20, RF_RAYWHITE); break;
case 6: rf_draw_text("CELLULAR", 670, 10, 20, RF_RAYWHITE); break;
default: break;
}
rf_end();
}
|
a348b8d3fdcac7327b05e4362090a1c2098b5dab
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/microchip/same54/bsp/include/instance/nvmctrl.h
|
bccd9fb614b408971684454f30759cb616098ec0
|
[
"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
| 4,691
|
h
|
nvmctrl.h
|
/**
* \file
*
* \brief Instance description for NVMCTRL
*
* Copyright (c) 2019 Microchip Technology Inc.
*
* \asf_license_start
*
* \page License
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 Licence 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.
*
* \asf_license_stop
*
*/
#ifndef _SAME54_NVMCTRL_INSTANCE_
#define _SAME54_NVMCTRL_INSTANCE_
/* ========== Register definition for NVMCTRL peripheral ========== */
#if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
#define REG_NVMCTRL_CTRLA (0x41004000) /**< \brief (NVMCTRL) Control A */
#define REG_NVMCTRL_CTRLB (0x41004004) /**< \brief (NVMCTRL) Control B */
#define REG_NVMCTRL_PARAM (0x41004008) /**< \brief (NVMCTRL) NVM Parameter */
#define REG_NVMCTRL_INTENCLR (0x4100400C) /**< \brief (NVMCTRL) Interrupt Enable Clear */
#define REG_NVMCTRL_INTENSET (0x4100400E) /**< \brief (NVMCTRL) Interrupt Enable Set */
#define REG_NVMCTRL_INTFLAG (0x41004010) /**< \brief (NVMCTRL) Interrupt Flag Status and Clear */
#define REG_NVMCTRL_STATUS (0x41004012) /**< \brief (NVMCTRL) Status */
#define REG_NVMCTRL_ADDR (0x41004014) /**< \brief (NVMCTRL) Address */
#define REG_NVMCTRL_RUNLOCK (0x41004018) /**< \brief (NVMCTRL) Lock Section */
#define REG_NVMCTRL_PBLDATA0 (0x4100401C) /**< \brief (NVMCTRL) Page Buffer Load Data x 0 */
#define REG_NVMCTRL_PBLDATA1 (0x41004020) /**< \brief (NVMCTRL) Page Buffer Load Data x 1 */
#define REG_NVMCTRL_ECCERR (0x41004024) /**< \brief (NVMCTRL) ECC Error Status Register */
#define REG_NVMCTRL_DBGCTRL (0x41004028) /**< \brief (NVMCTRL) Debug Control */
#define REG_NVMCTRL_SEECFG (0x4100402A) /**< \brief (NVMCTRL) SmartEEPROM Configuration Register */
#define REG_NVMCTRL_SEESTAT (0x4100402C) /**< \brief (NVMCTRL) SmartEEPROM Status Register */
#else
#define REG_NVMCTRL_CTRLA (*(RwReg16*)0x41004000UL) /**< \brief (NVMCTRL) Control A */
#define REG_NVMCTRL_CTRLB (*(WoReg16*)0x41004004UL) /**< \brief (NVMCTRL) Control B */
#define REG_NVMCTRL_PARAM (*(RoReg *)0x41004008UL) /**< \brief (NVMCTRL) NVM Parameter */
#define REG_NVMCTRL_INTENCLR (*(RwReg16*)0x4100400CUL) /**< \brief (NVMCTRL) Interrupt Enable Clear */
#define REG_NVMCTRL_INTENSET (*(RwReg16*)0x4100400EUL) /**< \brief (NVMCTRL) Interrupt Enable Set */
#define REG_NVMCTRL_INTFLAG (*(RwReg16*)0x41004010UL) /**< \brief (NVMCTRL) Interrupt Flag Status and Clear */
#define REG_NVMCTRL_STATUS (*(RoReg16*)0x41004012UL) /**< \brief (NVMCTRL) Status */
#define REG_NVMCTRL_ADDR (*(RwReg *)0x41004014UL) /**< \brief (NVMCTRL) Address */
#define REG_NVMCTRL_RUNLOCK (*(RoReg *)0x41004018UL) /**< \brief (NVMCTRL) Lock Section */
#define REG_NVMCTRL_PBLDATA0 (*(RoReg *)0x4100401CUL) /**< \brief (NVMCTRL) Page Buffer Load Data x 0 */
#define REG_NVMCTRL_PBLDATA1 (*(RoReg *)0x41004020UL) /**< \brief (NVMCTRL) Page Buffer Load Data x 1 */
#define REG_NVMCTRL_ECCERR (*(RoReg *)0x41004024UL) /**< \brief (NVMCTRL) ECC Error Status Register */
#define REG_NVMCTRL_DBGCTRL (*(RwReg8 *)0x41004028UL) /**< \brief (NVMCTRL) Debug Control */
#define REG_NVMCTRL_SEECFG (*(RwReg8 *)0x4100402AUL) /**< \brief (NVMCTRL) SmartEEPROM Configuration Register */
#define REG_NVMCTRL_SEESTAT (*(RoReg *)0x4100402CUL) /**< \brief (NVMCTRL) SmartEEPROM Status Register */
#endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* ========== Instance parameters for NVMCTRL peripheral ========== */
#define NVMCTRL_BLOCK_SIZE 8192 // Size Of Block (Bytes, Smallest Granularity for Erase Operation)
#define NVMCTRL_CLK_AHB_ID 6 // Index of AHB Clock in PM.AHBMASK register
#define NVMCTRL_CLK_AHB_ID_CACHE 23 // Index of AHB Clock in PM.AHBMASK register for NVMCTRL CACHE lines
#define NVMCTRL_CLK_AHB_ID_SMEEPROM 22 // Index of AHB Clock in PM.AHBMASK register for SMEE submodule
#define NVMCTRL_PAGE_SIZE 512 // Size Of Page (Bytes, Smallest Granularity for Write Operation In Main Array)
#endif /* _SAME54_NVMCTRL_INSTANCE_ */
|
643cbea4eea766683ccf92902f2f226f56c35746
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/u-boot_new/include/configs/smdk5420.h
|
606739b02e55ce46b68e66c8a11b8553b1a62765
|
[
"GPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 624
|
h
|
smdk5420.h
|
/*
* Copyright (C) 2013 Samsung Electronics
*
* Configuration settings for the SAMSUNG SMDK5420 board.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __CONFIG_SMDK5420_H
#define __CONFIG_SMDK5420_H
#include <configs/exynos5-dt.h>
#include <configs/exynos5420.h>
#define CONFIG_SMDK5420 /* which is in a SMDK5420 */
#undef CONFIG_DEFAULT_DEVICE_TREE
#define CONFIG_DEFAULT_DEVICE_TREE exynos5420-smdk5420
/* select serial console configuration */
#define CONFIG_SERIAL3 /* use SERIAL 3 */
#define CONFIG_SYS_PROMPT "SMDK5420 # "
#define CONFIG_IDENT_STRING " for SMDK5420"
#endif /* __CONFIG_SMDK5420_H */
|
3be6f5cb5958c645b7f91ddec9cb7a8d6ddb6bd9
|
fe22b7a0f9ab10170c513afb062d69cfba128ec2
|
/include/caliper/cali_definitions.h
|
fab5d79a85a56ee8420c3b5d14c043374490e3a8
|
[
"BSD-3-Clause"
] |
permissive
|
LLNL/Caliper
|
ef5e9a6f408610dab404b58d29b53ddff2ce9708
|
764e5b692b2569f3ba4405f8e75126a0c35c3fab
|
refs/heads/master
| 2023-09-04T00:11:12.741726
| 2023-08-30T14:10:20
| 2023-08-30T14:10:20
| 45,953,649
| 283
| 55
|
BSD-3-Clause
| 2023-09-14T01:34:46
| 2015-11-11T02:02:00
|
C++
|
UTF-8
|
C
| false
| false
| 959
|
h
|
cali_definitions.h
|
/* Copyright (c) 2015-2022, Lawrence Livermore National Security, LLC.
* See top-level LICENSE file for details.
*/
/**
* \file cali_definitions.h
* \brief Various type definitions for the %Caliper runtime system.
*/
#ifndef CALI_CALI_DEFINITIONS_H
#define CALI_CALI_DEFINITIONS_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
CALI_SCOPE_PROCESS = 1,
CALI_SCOPE_THREAD = 2,
CALI_SCOPE_TASK = 4,
CALI_SCOPE_CHANNEL = 8
} cali_context_scope_t;
/**
* Flush options
*/
typedef enum {
/** Clear trace and aggregation buffers after flush. */
CALI_FLUSH_CLEAR_BUFFERS = 1
} cali_flush_opt;
/**
* Channel creation options
*/
typedef enum {
/** Leave the channel inactive after it is created. */
CALI_CHANNEL_LEAVE_INACTIVE = 1,
/** Allow reading configuration entries from environment variables. */
CALI_CHANNEL_ALLOW_READ_ENV = 2
} cali_channel_opt;
#ifdef __cplusplus
} // extern "C"
#endif
#endif
|
f5271548eb8a11895e733b70b2f347fed7736f92
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/grpc/src/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h
|
7f464468a2182affc46a9b19c63d2651aded7e68
|
[
"BSD-3-Clause",
"MPL-2.0",
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later"
] |
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
| 97,624
|
h
|
tls.upb.h
|
/* This file was generated by upbc (the upb compiler) from the input
* file:
*
* envoy/extensions/transport_sockets/tls/v3/tls.proto
*
* Do not edit -- your changes will be discarded when the file is
* regenerated. */
#ifndef ENVOY_EXTENSIONS_TRANSPORT_SOCKETS_TLS_V3_TLS_PROTO_UPB_H_
#define ENVOY_EXTENSIONS_TRANSPORT_SOCKETS_TLS_V3_TLS_PROTO_UPB_H_
#include "upb/msg_internal.h"
#include "upb/decode.h"
#include "upb/decode_fast.h"
#include "upb/encode.h"
#include "upb/port_def.inc"
#ifdef __cplusplus
extern "C" {
#endif
struct envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext;
struct envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext;
struct envoy_extensions_transport_sockets_tls_v3_TlsKeyLog;
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext;
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider;
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance;
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext;
typedef struct envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext;
typedef struct envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext;
typedef struct envoy_extensions_transport_sockets_tls_v3_TlsKeyLog envoy_extensions_transport_sockets_tls_v3_TlsKeyLog;
typedef struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext envoy_extensions_transport_sockets_tls_v3_CommonTlsContext;
typedef struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider;
typedef struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance;
typedef struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_msginit;
struct envoy_config_core_v3_CidrRange;
struct envoy_config_core_v3_TypedExtensionConfig;
struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance;
struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext;
struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig;
struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate;
struct envoy_extensions_transport_sockets_tls_v3_TlsParameters;
struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys;
struct google_protobuf_BoolValue;
struct google_protobuf_Duration;
struct google_protobuf_UInt32Value;
extern const upb_MiniTable envoy_config_core_v3_CidrRange_msginit;
extern const upb_MiniTable envoy_config_core_v3_TypedExtensionConfig_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_TlsCertificate_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_TlsParameters_msginit;
extern const upb_MiniTable envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys_msginit;
extern const upb_MiniTable google_protobuf_BoolValue_msginit;
extern const upb_MiniTable google_protobuf_Duration_msginit;
extern const upb_MiniTable google_protobuf_UInt32Value_msginit;
typedef enum {
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_LENIENT_STAPLING = 0,
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_STRICT_STAPLING = 1,
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_MUST_STAPLE = 2
} envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_OcspStaplePolicy;
/* envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext */
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_new(upb_Arena* arena) {
return (envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_msginit, arena);
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse(const char* buf, size_t size, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* ret = envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse_ex(const char* buf, size_t size,
const upb_ExtensionRegistry* extreg,
int options, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* ret = envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_serialize(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg, upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_msginit, 0, arena, &ptr, len);
return ptr;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_serialize_ex(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg, int options,
upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_msginit, options, arena, &ptr, len);
return ptr;
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_has_common_tls_context(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
return _upb_hasbit(msg, 1);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_clear_common_tls_context(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), const upb_Message*) = NULL;
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_clear_sni(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(8, 16), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
}
UPB_INLINE upb_StringView envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_sni(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(8, 16), upb_StringView);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_clear_allow_renegotiation(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = 0;
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_allow_renegotiation(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_has_max_session_keys(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
return _upb_hasbit(msg, 2);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_clear_max_session_keys(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(16, 32), const upb_Message*) = NULL;
}
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_max_session_keys(const envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(16, 32), const struct google_protobuf_UInt32Value*);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_set_common_tls_context(envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* value) {
_upb_sethas(msg, 1);
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_mutable_common_tls_context(envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*)envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_set_common_tls_context(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_set_sni(envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext *msg, upb_StringView value) {
*UPB_PTR_AT(msg, UPB_SIZE(8, 16), upb_StringView) = value;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_set_allow_renegotiation(envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext *msg, bool value) {
*UPB_PTR_AT(msg, UPB_SIZE(1, 1), bool) = value;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_set_max_session_keys(envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext *msg, struct google_protobuf_UInt32Value* value) {
_upb_sethas(msg, 2);
*UPB_PTR_AT(msg, UPB_SIZE(16, 32), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_mutable_max_session_keys(envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext* msg, upb_Arena* arena) {
struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_max_session_keys(msg);
if (sub == NULL) {
sub = (struct google_protobuf_UInt32Value*)_upb_Message_New(&google_protobuf_UInt32Value_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_set_max_session_keys(msg, sub);
}
return sub;
}
/* envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext */
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_new(upb_Arena* arena) {
return (envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_msginit, arena);
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse(const char* buf, size_t size, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* ret = envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse_ex(const char* buf, size_t size,
const upb_ExtensionRegistry* extreg,
int options, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* ret = envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_serialize(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_msginit, 0, arena, &ptr, len);
return ptr;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_serialize_ex(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, int options,
upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_msginit, options, arena, &ptr, len);
return ptr;
}
typedef enum {
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_session_ticket_keys = 4,
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_session_ticket_keys_sds_secret_config = 5,
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_disable_stateless_session_resumption = 7,
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_NOT_SET = 0
} envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_oneofcases;
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_oneofcases envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_case(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return (envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_oneofcases)*UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_has_common_tls_context(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return _upb_hasbit(msg, 1);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_common_tls_context(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(12, 16), const upb_Message*) = NULL;
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(12, 16), const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_has_require_client_certificate(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return _upb_hasbit(msg, 2);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_require_client_certificate(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(16, 24), const upb_Message*) = NULL;
}
UPB_INLINE const struct google_protobuf_BoolValue* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(16, 24), const struct google_protobuf_BoolValue*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_has_require_sni(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return _upb_hasbit(msg, 3);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_require_sni(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(20, 32), const upb_Message*) = NULL;
}
UPB_INLINE const struct google_protobuf_BoolValue* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_sni(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(20, 32), const struct google_protobuf_BoolValue*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_has_session_ticket_keys(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(4, 4)) == 4;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_session_ticket_keys(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
UPB_WRITE_ONEOF(msg, struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys*, UPB_SIZE(32, 56), 0, UPB_SIZE(4, 4), envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_NOT_SET);
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return UPB_READ_ONEOF(msg, const struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys*, UPB_SIZE(32, 56), UPB_SIZE(4, 4), 4, NULL);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_has_session_ticket_keys_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(4, 4)) == 5;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_session_ticket_keys_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
UPB_WRITE_ONEOF(msg, struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*, UPB_SIZE(32, 56), 0, UPB_SIZE(4, 4), envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_NOT_SET);
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return UPB_READ_ONEOF(msg, const struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*, UPB_SIZE(32, 56), UPB_SIZE(4, 4), 5, NULL);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_has_session_timeout(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return _upb_hasbit(msg, 4);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_session_timeout(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(24, 40), const upb_Message*) = NULL;
}
UPB_INLINE const struct google_protobuf_Duration* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_timeout(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(24, 40), const struct google_protobuf_Duration*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_has_disable_stateless_session_resumption(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(4, 4)) == 7;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_disable_stateless_session_resumption(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
UPB_WRITE_ONEOF(msg, bool, UPB_SIZE(32, 56), 0, UPB_SIZE(4, 4), envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_type_NOT_SET);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_disable_stateless_session_resumption(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return UPB_READ_ONEOF(msg, bool, UPB_SIZE(32, 56), UPB_SIZE(4, 4), 7, false);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_ocsp_staple_policy(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = 0;
}
UPB_INLINE int32_t envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_ocsp_staple_policy(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_has_full_scan_certs_on_sni_mismatch(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return _upb_hasbit(msg, 5);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_clear_full_scan_certs_on_sni_mismatch(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(28, 48), const upb_Message*) = NULL;
}
UPB_INLINE const struct google_protobuf_BoolValue* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_full_scan_certs_on_sni_mismatch(const envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(28, 48), const struct google_protobuf_BoolValue*);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_common_tls_context(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* value) {
_upb_sethas(msg, 1);
*UPB_PTR_AT(msg, UPB_SIZE(12, 16), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_mutable_common_tls_context(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*)envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_common_tls_context(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_require_client_certificate(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, struct google_protobuf_BoolValue* value) {
_upb_sethas(msg, 2);
*UPB_PTR_AT(msg, UPB_SIZE(16, 24), struct google_protobuf_BoolValue*) = value;
}
UPB_INLINE struct google_protobuf_BoolValue* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_mutable_require_client_certificate(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, upb_Arena* arena) {
struct google_protobuf_BoolValue* sub = (struct google_protobuf_BoolValue*)envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate(msg);
if (sub == NULL) {
sub = (struct google_protobuf_BoolValue*)_upb_Message_New(&google_protobuf_BoolValue_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_require_client_certificate(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_require_sni(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, struct google_protobuf_BoolValue* value) {
_upb_sethas(msg, 3);
*UPB_PTR_AT(msg, UPB_SIZE(20, 32), struct google_protobuf_BoolValue*) = value;
}
UPB_INLINE struct google_protobuf_BoolValue* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_mutable_require_sni(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, upb_Arena* arena) {
struct google_protobuf_BoolValue* sub = (struct google_protobuf_BoolValue*)envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_sni(msg);
if (sub == NULL) {
sub = (struct google_protobuf_BoolValue*)_upb_Message_New(&google_protobuf_BoolValue_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_require_sni(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_session_ticket_keys(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys* value) {
UPB_WRITE_ONEOF(msg, struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys*, UPB_SIZE(32, 56), value, UPB_SIZE(4, 4), 4);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_mutable_session_ticket_keys(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys* sub = (struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys*)envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_TlsSessionTicketKeys_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_session_ticket_keys(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_session_ticket_keys_sds_secret_config(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* value) {
UPB_WRITE_ONEOF(msg, struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*, UPB_SIZE(32, 56), value, UPB_SIZE(4, 4), 5);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_mutable_session_ticket_keys_sds_secret_config(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* sub = (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*)envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_ticket_keys_sds_secret_config(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_session_ticket_keys_sds_secret_config(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_session_timeout(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, struct google_protobuf_Duration* value) {
_upb_sethas(msg, 4);
*UPB_PTR_AT(msg, UPB_SIZE(24, 40), struct google_protobuf_Duration*) = value;
}
UPB_INLINE struct google_protobuf_Duration* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_mutable_session_timeout(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, upb_Arena* arena) {
struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_session_timeout(msg);
if (sub == NULL) {
sub = (struct google_protobuf_Duration*)_upb_Message_New(&google_protobuf_Duration_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_session_timeout(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_disable_stateless_session_resumption(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, bool value) {
UPB_WRITE_ONEOF(msg, bool, UPB_SIZE(32, 56), value, UPB_SIZE(4, 4), 7);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_ocsp_staple_policy(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, int32_t value) {
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), int32_t) = value;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_full_scan_certs_on_sni_mismatch(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext *msg, struct google_protobuf_BoolValue* value) {
_upb_sethas(msg, 5);
*UPB_PTR_AT(msg, UPB_SIZE(28, 48), struct google_protobuf_BoolValue*) = value;
}
UPB_INLINE struct google_protobuf_BoolValue* envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_mutable_full_scan_certs_on_sni_mismatch(envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext* msg, upb_Arena* arena) {
struct google_protobuf_BoolValue* sub = (struct google_protobuf_BoolValue*)envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_full_scan_certs_on_sni_mismatch(msg);
if (sub == NULL) {
sub = (struct google_protobuf_BoolValue*)_upb_Message_New(&google_protobuf_BoolValue_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_set_full_scan_certs_on_sni_mismatch(msg, sub);
}
return sub;
}
/* envoy.extensions.transport_sockets.tls.v3.TlsKeyLog */
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_new(upb_Arena* arena) {
return (envoy_extensions_transport_sockets_tls_v3_TlsKeyLog*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_msginit, arena);
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_parse(const char* buf, size_t size, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* ret = envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_parse_ex(const char* buf, size_t size,
const upb_ExtensionRegistry* extreg,
int options, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* ret = envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_serialize(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_msginit, 0, arena, &ptr, len);
return ptr;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_serialize_ex(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, int options,
upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_msginit, options, arena, &ptr, len);
return ptr;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_clear_path(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(0, 0), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
}
UPB_INLINE upb_StringView envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_path(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(0, 0), upb_StringView);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_has_local_address_range(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg) {
return _upb_has_submsg_nohasbit(msg, UPB_SIZE(8, 16));
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_clear_local_address_range(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg) {
_upb_array_detach(msg, UPB_SIZE(8, 16));
}
UPB_INLINE const struct envoy_config_core_v3_CidrRange* const* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_local_address_range(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, size_t* len) {
return (const struct envoy_config_core_v3_CidrRange* const*)_upb_array_accessor(msg, UPB_SIZE(8, 16), len);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_has_remote_address_range(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg) {
return _upb_has_submsg_nohasbit(msg, UPB_SIZE(12, 24));
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_clear_remote_address_range(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg) {
_upb_array_detach(msg, UPB_SIZE(12, 24));
}
UPB_INLINE const struct envoy_config_core_v3_CidrRange* const* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_remote_address_range(const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, size_t* len) {
return (const struct envoy_config_core_v3_CidrRange* const*)_upb_array_accessor(msg, UPB_SIZE(12, 24), len);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_set_path(envoy_extensions_transport_sockets_tls_v3_TlsKeyLog *msg, upb_StringView value) {
*UPB_PTR_AT(msg, UPB_SIZE(0, 0), upb_StringView) = value;
}
UPB_INLINE struct envoy_config_core_v3_CidrRange** envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_mutable_local_address_range(envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, size_t* len) {
return (struct envoy_config_core_v3_CidrRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 16), len);
}
UPB_INLINE struct envoy_config_core_v3_CidrRange** envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_resize_local_address_range(envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, size_t len, upb_Arena* arena) {
return (struct envoy_config_core_v3_CidrRange**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(8, 16), len, UPB_SIZE(2, 3), arena);
}
UPB_INLINE struct envoy_config_core_v3_CidrRange* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_add_local_address_range(envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, upb_Arena* arena) {
struct envoy_config_core_v3_CidrRange* sub = (struct envoy_config_core_v3_CidrRange*)_upb_Message_New(&envoy_config_core_v3_CidrRange_msginit, arena);
bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(8, 16), UPB_SIZE(2, 3), &sub, arena);
if (!ok) return NULL;
return sub;
}
UPB_INLINE struct envoy_config_core_v3_CidrRange** envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_mutable_remote_address_range(envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, size_t* len) {
return (struct envoy_config_core_v3_CidrRange**)_upb_array_mutable_accessor(msg, UPB_SIZE(12, 24), len);
}
UPB_INLINE struct envoy_config_core_v3_CidrRange** envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_resize_remote_address_range(envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, size_t len, upb_Arena* arena) {
return (struct envoy_config_core_v3_CidrRange**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(12, 24), len, UPB_SIZE(2, 3), arena);
}
UPB_INLINE struct envoy_config_core_v3_CidrRange* envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_add_remote_address_range(envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* msg, upb_Arena* arena) {
struct envoy_config_core_v3_CidrRange* sub = (struct envoy_config_core_v3_CidrRange*)_upb_Message_New(&envoy_config_core_v3_CidrRange_msginit, arena);
bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(12, 24), UPB_SIZE(2, 3), &sub, arena);
if (!ok) return NULL;
return sub;
}
/* envoy.extensions.transport_sockets.tls.v3.CommonTlsContext */
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_new(upb_Arena* arena) {
return (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_msginit, arena);
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_parse(const char* buf, size_t size, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* ret = envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_parse_ex(const char* buf, size_t size,
const upb_ExtensionRegistry* extreg,
int options, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* ret = envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_serialize(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_msginit, 0, arena, &ptr, len);
return ptr;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_serialize_ex(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, int options,
upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_msginit, options, arena, &ptr, len);
return ptr;
}
typedef enum {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_validation_context = 3,
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_validation_context_sds_secret_config = 7,
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_combined_validation_context = 8,
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_validation_context_certificate_provider = 10,
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_validation_context_certificate_provider_instance = 12,
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_NOT_SET = 0
} envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_oneofcases;
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_oneofcases envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_case(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_oneofcases)*UPB_PTR_AT(msg, UPB_SIZE(4, 4), int32_t);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_params(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_hasbit(msg, 1);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_tls_params(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), const upb_Message*) = NULL;
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_TlsParameters* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_params(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(8, 8), const struct envoy_extensions_transport_sockets_tls_v3_TlsParameters*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificates(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_has_submsg_nohasbit(msg, UPB_SIZE(12, 16));
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_tls_certificates(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
_upb_array_detach(msg, UPB_SIZE(12, 16));
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate* const* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificates(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t* len) {
return (const struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate* const*)_upb_array_accessor(msg, UPB_SIZE(12, 16), len);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(4, 4)) == 3;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
UPB_WRITE_ONEOF(msg, struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*, UPB_SIZE(44, 80), 0, UPB_SIZE(4, 4), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_NOT_SET);
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return UPB_READ_ONEOF(msg, const struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*, UPB_SIZE(44, 80), UPB_SIZE(4, 4), 3, NULL);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_alpn_protocols(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
_upb_array_detach(msg, UPB_SIZE(16, 24));
}
UPB_INLINE upb_StringView const* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_alpn_protocols(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t* len) {
return (upb_StringView const*)_upb_array_accessor(msg, UPB_SIZE(16, 24), len);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificate_sds_secret_configs(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_has_submsg_nohasbit(msg, UPB_SIZE(20, 32));
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_tls_certificate_sds_secret_configs(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
_upb_array_detach(msg, UPB_SIZE(20, 32));
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* const* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_sds_secret_configs(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t* len) {
return (const struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(4, 4)) == 7;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_validation_context_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
UPB_WRITE_ONEOF(msg, struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*, UPB_SIZE(44, 80), 0, UPB_SIZE(4, 4), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_NOT_SET);
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return UPB_READ_ONEOF(msg, const struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*, UPB_SIZE(44, 80), UPB_SIZE(4, 4), 7, NULL);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_combined_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(4, 4)) == 8;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_combined_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
UPB_WRITE_ONEOF(msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext*, UPB_SIZE(44, 80), 0, UPB_SIZE(4, 4), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_NOT_SET);
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_combined_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return UPB_READ_ONEOF(msg, const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext*, UPB_SIZE(44, 80), UPB_SIZE(4, 4), 8, NULL);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificate_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_hasbit(msg, 2);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_tls_certificate_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(24, 40), const upb_Message*) = NULL;
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(24, 40), const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(4, 4)) == 10;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_validation_context_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
UPB_WRITE_ONEOF(msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*, UPB_SIZE(44, 80), 0, UPB_SIZE(4, 4), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_NOT_SET);
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return UPB_READ_ONEOF(msg, const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*, UPB_SIZE(44, 80), UPB_SIZE(4, 4), 10, NULL);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificate_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_hasbit(msg, 3);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_tls_certificate_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(28, 48), const upb_Message*) = NULL;
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(28, 48), const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(4, 4)) == 12;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_validation_context_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
UPB_WRITE_ONEOF(msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*, UPB_SIZE(44, 80), 0, UPB_SIZE(4, 4), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_type_NOT_SET);
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return UPB_READ_ONEOF(msg, const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*, UPB_SIZE(44, 80), UPB_SIZE(4, 4), 12, NULL);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_custom_handshaker(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_hasbit(msg, 4);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_custom_handshaker(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(32, 56), const upb_Message*) = NULL;
}
UPB_INLINE const struct envoy_config_core_v3_TypedExtensionConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_custom_handshaker(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(32, 56), const struct envoy_config_core_v3_TypedExtensionConfig*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_hasbit(msg, 5);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_tls_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(36, 64), const upb_Message*) = NULL;
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(36, 64), const struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_key_log(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return _upb_hasbit(msg, 6);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_clear_key_log(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(40, 72), const upb_Message*) = NULL;
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_key_log(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(40, 72), const envoy_extensions_transport_sockets_tls_v3_TlsKeyLog*);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_tls_params(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, struct envoy_extensions_transport_sockets_tls_v3_TlsParameters* value) {
_upb_sethas(msg, 1);
*UPB_PTR_AT(msg, UPB_SIZE(8, 8), struct envoy_extensions_transport_sockets_tls_v3_TlsParameters*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_TlsParameters* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_tls_params(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_TlsParameters* sub = (struct envoy_extensions_transport_sockets_tls_v3_TlsParameters*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_params(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_TlsParameters*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_TlsParameters_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_tls_params(msg, sub);
}
return sub;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate** envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_tls_certificates(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t* len) {
return (struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate**)_upb_array_mutable_accessor(msg, UPB_SIZE(12, 16), len);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate** envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_resize_tls_certificates(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t len, upb_Arena* arena) {
return (struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(12, 16), len, UPB_SIZE(2, 3), arena);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_add_tls_certificates(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate* sub = (struct envoy_extensions_transport_sockets_tls_v3_TlsCertificate*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_TlsCertificate_msginit, arena);
bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(12, 16), UPB_SIZE(2, 3), &sub, arena);
if (!ok) return NULL;
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_validation_context(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext* value) {
UPB_WRITE_ONEOF(msg, struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*, UPB_SIZE(44, 80), value, UPB_SIZE(4, 4), 3);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_validation_context(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext* sub = (struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_validation_context(msg, sub);
}
return sub;
}
UPB_INLINE upb_StringView* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_alpn_protocols(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t* len) {
return (upb_StringView*)_upb_array_mutable_accessor(msg, UPB_SIZE(16, 24), len);
}
UPB_INLINE upb_StringView* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_resize_alpn_protocols(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t len, upb_Arena* arena) {
return (upb_StringView*)_upb_Array_Resize_accessor2(msg, UPB_SIZE(16, 24), len, UPB_SIZE(3, 4), arena);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_add_alpn_protocols(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_StringView val, upb_Arena* arena) {
return _upb_Array_Append_accessor2(msg, UPB_SIZE(16, 24), UPB_SIZE(3, 4), &val, arena);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig** envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_tls_certificate_sds_secret_configs(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t* len) {
return (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig** envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_resize_tls_certificate_sds_secret_configs(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, size_t len, upb_Arena* arena) {
return (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig**)_upb_Array_Resize_accessor2(msg, UPB_SIZE(20, 32), len, UPB_SIZE(2, 3), arena);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_add_tls_certificate_sds_secret_configs(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* sub = (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig_msginit, arena);
bool ok = _upb_Array_Append_accessor2(msg, UPB_SIZE(20, 32), UPB_SIZE(2, 3), &sub, arena);
if (!ok) return NULL;
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_validation_context_sds_secret_config(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* value) {
UPB_WRITE_ONEOF(msg, struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*, UPB_SIZE(44, 80), value, UPB_SIZE(4, 4), 7);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_validation_context_sds_secret_config(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* sub = (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_sds_secret_config(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_validation_context_sds_secret_config(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_combined_validation_context(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* value) {
UPB_WRITE_ONEOF(msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext*, UPB_SIZE(44, 80), value, UPB_SIZE(4, 4), 8);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_combined_validation_context(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_combined_validation_context(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_combined_validation_context(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_tls_certificate_certificate_provider(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* value) {
_upb_sethas(msg, 2);
*UPB_PTR_AT(msg, UPB_SIZE(24, 40), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_tls_certificate_certificate_provider(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_tls_certificate_certificate_provider(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_validation_context_certificate_provider(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* value) {
UPB_WRITE_ONEOF(msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*, UPB_SIZE(44, 80), value, UPB_SIZE(4, 4), 10);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_validation_context_certificate_provider(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_certificate_provider(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_validation_context_certificate_provider(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_tls_certificate_certificate_provider_instance(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* value) {
_upb_sethas(msg, 3);
*UPB_PTR_AT(msg, UPB_SIZE(28, 48), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_tls_certificate_certificate_provider_instance(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_tls_certificate_certificate_provider_instance(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_validation_context_certificate_provider_instance(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* value) {
UPB_WRITE_ONEOF(msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*, UPB_SIZE(44, 80), value, UPB_SIZE(4, 4), 12);
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_validation_context_certificate_provider_instance(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context_certificate_provider_instance(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_validation_context_certificate_provider_instance(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_custom_handshaker(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, struct envoy_config_core_v3_TypedExtensionConfig* value) {
_upb_sethas(msg, 4);
*UPB_PTR_AT(msg, UPB_SIZE(32, 56), struct envoy_config_core_v3_TypedExtensionConfig*) = value;
}
UPB_INLINE struct envoy_config_core_v3_TypedExtensionConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_custom_handshaker(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_config_core_v3_TypedExtensionConfig* sub = (struct envoy_config_core_v3_TypedExtensionConfig*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_custom_handshaker(msg);
if (sub == NULL) {
sub = (struct envoy_config_core_v3_TypedExtensionConfig*)_upb_Message_New(&envoy_config_core_v3_TypedExtensionConfig_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_custom_handshaker(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_tls_certificate_provider_instance(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance* value) {
_upb_sethas(msg, 5);
*UPB_PTR_AT(msg, UPB_SIZE(36, 64), struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_tls_certificate_provider_instance(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance* sub = (struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_provider_instance(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_tls_certificate_provider_instance(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_key_log(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext *msg, envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* value) {
_upb_sethas(msg, 6);
*UPB_PTR_AT(msg, UPB_SIZE(40, 72), envoy_extensions_transport_sockets_tls_v3_TlsKeyLog*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_mutable_key_log(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_TlsKeyLog* sub = (struct envoy_extensions_transport_sockets_tls_v3_TlsKeyLog*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_key_log(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_TlsKeyLog*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_TlsKeyLog_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_set_key_log(msg, sub);
}
return sub;
}
/* envoy.extensions.transport_sockets.tls.v3.CommonTlsContext.CertificateProvider */
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_new(upb_Arena* arena) {
return (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit, arena);
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_parse(const char* buf, size_t size, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* ret = envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_parse_ex(const char* buf, size_t size,
const upb_ExtensionRegistry* extreg,
int options, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* ret = envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_serialize(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg, upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit, 0, arena, &ptr, len);
return ptr;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_serialize_ex(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg, int options,
upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit, options, arena, &ptr, len);
return ptr;
}
typedef enum {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_config_typed_config = 2,
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_config_NOT_SET = 0
} envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_config_oneofcases;
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_config_oneofcases envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_config_case(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg) {
return (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_config_oneofcases)*UPB_PTR_AT(msg, UPB_SIZE(0, 0), int32_t);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_clear_name(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
}
UPB_INLINE upb_StringView envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_name(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_has_typed_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg) {
return _upb_getoneofcase(msg, UPB_SIZE(0, 0)) == 2;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_clear_typed_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg) {
UPB_WRITE_ONEOF(msg, struct envoy_config_core_v3_TypedExtensionConfig*, UPB_SIZE(12, 24), 0, UPB_SIZE(0, 0), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_config_NOT_SET);
}
UPB_INLINE const struct envoy_config_core_v3_TypedExtensionConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_typed_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg) {
return UPB_READ_ONEOF(msg, const struct envoy_config_core_v3_TypedExtensionConfig*, UPB_SIZE(12, 24), UPB_SIZE(0, 0), 2, NULL);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_set_name(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider *msg, upb_StringView value) {
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), upb_StringView) = value;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_set_typed_config(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider *msg, struct envoy_config_core_v3_TypedExtensionConfig* value) {
UPB_WRITE_ONEOF(msg, struct envoy_config_core_v3_TypedExtensionConfig*, UPB_SIZE(12, 24), value, UPB_SIZE(0, 0), 2);
}
UPB_INLINE struct envoy_config_core_v3_TypedExtensionConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_mutable_typed_config(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* msg, upb_Arena* arena) {
struct envoy_config_core_v3_TypedExtensionConfig* sub = (struct envoy_config_core_v3_TypedExtensionConfig*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_typed_config(msg);
if (sub == NULL) {
sub = (struct envoy_config_core_v3_TypedExtensionConfig*)_upb_Message_New(&envoy_config_core_v3_TypedExtensionConfig_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_set_typed_config(msg, sub);
}
return sub;
}
/* envoy.extensions.transport_sockets.tls.v3.CommonTlsContext.CertificateProviderInstance */
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_new(upb_Arena* arena) {
return (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit, arena);
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_parse(const char* buf, size_t size, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* ret = envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_parse_ex(const char* buf, size_t size,
const upb_ExtensionRegistry* extreg,
int options, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* ret = envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_serialize(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* msg, upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit, 0, arena, &ptr, len);
return ptr;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_serialize_ex(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* msg, int options,
upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit, options, arena, &ptr, len);
return ptr;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_clear_instance_name(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(0, 0), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
}
UPB_INLINE upb_StringView envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(0, 0), upb_StringView);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_clear_certificate_name(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(8, 16), upb_StringView) = upb_StringView_FromDataAndSize(NULL, 0);
}
UPB_INLINE upb_StringView envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_certificate_name(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(8, 16), upb_StringView);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_set_instance_name(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance *msg, upb_StringView value) {
*UPB_PTR_AT(msg, UPB_SIZE(0, 0), upb_StringView) = value;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_set_certificate_name(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance *msg, upb_StringView value) {
*UPB_PTR_AT(msg, UPB_SIZE(8, 16), upb_StringView) = value;
}
/* envoy.extensions.transport_sockets.tls.v3.CommonTlsContext.CombinedCertificateValidationContext */
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_new(upb_Arena* arena) {
return (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_msginit, arena);
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_parse(const char* buf, size_t size, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* ret = envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_msginit, NULL, 0, arena) != kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_parse_ex(const char* buf, size_t size,
const upb_ExtensionRegistry* extreg,
int options, upb_Arena* arena) {
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* ret = envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_new(arena);
if (!ret) return NULL;
if (upb_Decode(buf, size, ret, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_msginit, extreg, options, arena) !=
kUpb_DecodeStatus_Ok) {
return NULL;
}
return ret;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_serialize(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg, upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_msginit, 0, arena, &ptr, len);
return ptr;
}
UPB_INLINE char* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_serialize_ex(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg, int options,
upb_Arena* arena, size_t* len) {
char* ptr;
(void)upb_Encode(msg, &envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_msginit, options, arena, &ptr, len);
return ptr;
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_has_default_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
return _upb_hasbit(msg, 1);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_clear_default_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), const upb_Message*) = NULL;
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_default_validation_context(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), const struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_has_validation_context_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
return _upb_hasbit(msg, 2);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_clear_validation_context_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(8, 16), const upb_Message*) = NULL;
}
UPB_INLINE const struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_sds_secret_config(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(8, 16), const struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_has_validation_context_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
return _upb_hasbit(msg, 3);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_clear_validation_context_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), const upb_Message*) = NULL;
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*);
}
UPB_INLINE bool envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_has_validation_context_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
return _upb_hasbit(msg, 4);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_clear_validation_context_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
*UPB_PTR_AT(msg, UPB_SIZE(16, 32), const upb_Message*) = NULL;
}
UPB_INLINE const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider_instance(const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg) {
return *UPB_PTR_AT(msg, UPB_SIZE(16, 32), const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*);
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_set_default_validation_context(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext *msg, struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext* value) {
_upb_sethas(msg, 1);
*UPB_PTR_AT(msg, UPB_SIZE(4, 8), struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_mutable_default_validation_context(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext* sub = (struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_default_validation_context(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_set_default_validation_context(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_set_validation_context_sds_secret_config(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext *msg, struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* value) {
_upb_sethas(msg, 2);
*UPB_PTR_AT(msg, UPB_SIZE(8, 16), struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_mutable_validation_context_sds_secret_config(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig* sub = (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_sds_secret_config(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_SdsSecretConfig_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_set_validation_context_sds_secret_config(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_set_validation_context_certificate_provider(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* value) {
_upb_sethas(msg, 3);
*UPB_PTR_AT(msg, UPB_SIZE(12, 24), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_mutable_validation_context_certificate_provider(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProvider_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_set_validation_context_certificate_provider(msg, sub);
}
return sub;
}
UPB_INLINE void envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_set_validation_context_certificate_provider_instance(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext *msg, envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* value) {
_upb_sethas(msg, 4);
*UPB_PTR_AT(msg, UPB_SIZE(16, 32), envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*) = value;
}
UPB_INLINE struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_mutable_validation_context_certificate_provider_instance(envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext* msg, upb_Arena* arena) {
struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance* sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*)envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider_instance(msg);
if (sub == NULL) {
sub = (struct envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*)_upb_Message_New(&envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_msginit, arena);
if (!sub) return NULL;
envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_set_validation_context_certificate_provider_instance(msg, sub);
}
return sub;
}
extern const upb_MiniTable_File envoy_extensions_transport_sockets_tls_v3_tls_proto_upb_file_layout;
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port_undef.inc"
#endif /* ENVOY_EXTENSIONS_TRANSPORT_SOCKETS_TLS_V3_TLS_PROTO_UPB_H_ */
|
d01252c475e11af77120f553c9e4d4610fb1e3cd
|
f7dc806f341ef5dbb0e11252a4693003a66853d5
|
/thirdparty/icu4c/common/uassert.h
|
52187528991c1c554e45e660b4f51bd5ec806d99
|
[
"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",
"ICU",
"NTP",
"NAIST-2003",
"GPL-2.0-or-later",
"LicenseRef-scancode-autoconf-simple-exception",
"Autoconf-exception-generic",
"JSON",
"Libpng"
] |
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
| 2,049
|
h
|
uassert.h
|
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
*
* Copyright (C) 2002-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
*
* File uassert.h
*
* Contains the U_ASSERT and UPRV_UNREACHABLE_* macros
*
******************************************************************************
*/
#ifndef U_ASSERT_H
#define U_ASSERT_H
/* utypes.h is included to get the proper define for uint8_t */
#include "unicode/utypes.h"
/* for abort */
#include <stdlib.h>
/**
* \def U_ASSERT
* By default, U_ASSERT just wraps the C library assert macro.
* By changing the definition here, the assert behavior for ICU can be changed
* without affecting other non - ICU uses of the C library assert().
*/
#if U_DEBUG
# include <assert.h>
# define U_ASSERT(exp) assert(exp)
#elif U_CPLUSPLUS_VERSION
# define U_ASSERT(exp) (void)0
#else
# define U_ASSERT(exp)
#endif
/**
* \def UPRV_UNREACHABLE_ASSERT
* This macro is used in places that we had believed were unreachable, but
* experience has shown otherwise (possibly due to memory corruption, etc).
* In this case we call assert() in debug versions as with U_ASSERT, instead
* of unconditionally calling abort(). However we also allow redefinition as
* with UPRV_UNREACHABLE_EXIT.
* @internal
*/
#if defined(UPRV_UNREACHABLE_ASSERT)
// Use the predefined value.
#elif U_DEBUG
# include <assert.h>
# define UPRV_UNREACHABLE_ASSERT assert(false)
#elif U_CPLUSPLUS_VERSION
# define UPRV_UNREACHABLE_ASSERT (void)0
#else
# define UPRV_UNREACHABLE_ASSERT
#endif
/**
* \def UPRV_UNREACHABLE_EXIT
* This macro is used to unconditionally abort if unreachable code is ever executed.
* @internal
*/
#if defined(UPRV_UNREACHABLE_EXIT)
// Use the predefined value.
#else
# define UPRV_UNREACHABLE_EXIT abort()
#endif
#endif
|
018c1ef85ad39b89753e97d919f24e51295f24c9
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/lib/mesa/src/freedreno/vulkan/tu_image.h
|
d877d0eb98632dae69aade0896038e31e78144c9
|
[] |
no_license
|
openbsd/xenocara
|
cb392d02ebba06f6ff7d826fd8a89aa3b8401779
|
a012b5de33ea0b977095d77316a521195b26cc6b
|
refs/heads/master
| 2023-08-25T12:16:58.862008
| 2023-08-12T16:16:25
| 2023-08-12T16:16:25
| 66,967,384
| 177
| 66
| null | 2023-07-22T18:12:37
| 2016-08-30T18:36:01
|
C
|
UTF-8
|
C
| false
| false
| 3,164
|
h
|
tu_image.h
|
/*
* Copyright © 2016 Red Hat.
* Copyright © 2016 Bas Nieuwenhuizen
* SPDX-License-Identifier: MIT
*
* based in part on anv driver which is:
* Copyright © 2015 Intel Corporation
*/
#ifndef TU_IMAGE_H
#define TU_IMAGE_H
#include "tu_common.h"
#define tu_image_view_stencil(iview, x) \
((iview->view.x & ~A6XX_##x##_COLOR_FORMAT__MASK) | A6XX_##x##_COLOR_FORMAT(FMT6_8_UINT))
#define tu_image_view_depth(iview, x) \
((iview->view.x & ~A6XX_##x##_COLOR_FORMAT__MASK) | A6XX_##x##_COLOR_FORMAT(FMT6_32_FLOAT))
struct tu_image
{
struct vk_image vk;
struct fdl_layout layout[3];
uint32_t total_size;
#ifdef ANDROID
/* For VK_ANDROID_native_buffer, the WSI image owns the memory, */
VkDeviceMemory owned_memory;
#endif
/* Set when bound */
struct tu_bo *bo;
uint64_t iova;
uint32_t lrz_height;
uint32_t lrz_pitch;
uint32_t lrz_offset;
uint32_t lrz_fc_offset;
uint32_t lrz_fc_size;
};
VK_DEFINE_NONDISP_HANDLE_CASTS(tu_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE)
struct tu_image_view
{
struct vk_image_view vk;
struct tu_image *image; /**< VkImageViewCreateInfo::image */
struct fdl6_view view;
/* for d32s8 separate depth */
uint64_t depth_base_addr;
uint32_t depth_layer_size;
uint32_t depth_PITCH;
/* for d32s8 separate stencil */
uint64_t stencil_base_addr;
uint32_t stencil_layer_size;
uint32_t stencil_PITCH;
};
VK_DEFINE_NONDISP_HANDLE_CASTS(tu_image_view, vk.base, VkImageView,
VK_OBJECT_TYPE_IMAGE_VIEW);
struct tu_buffer_view
{
struct vk_object_base base;
uint32_t descriptor[A6XX_TEX_CONST_DWORDS];
struct tu_buffer *buffer;
};
VK_DEFINE_NONDISP_HANDLE_CASTS(tu_buffer_view, base, VkBufferView,
VK_OBJECT_TYPE_BUFFER_VIEW)
uint32_t tu6_plane_count(VkFormat format);
enum pipe_format tu6_plane_format(VkFormat format, uint32_t plane);
uint32_t tu6_plane_index(VkFormat format, VkImageAspectFlags aspect_mask);
enum pipe_format tu_format_for_aspect(enum pipe_format format,
VkImageAspectFlags aspect_mask);
void
tu_cs_image_ref(struct tu_cs *cs, const struct fdl6_view *iview, uint32_t layer);
void
tu_cs_image_ref_2d(struct tu_cs *cs, const struct fdl6_view *iview, uint32_t layer, bool src);
void
tu_cs_image_flag_ref(struct tu_cs *cs, const struct fdl6_view *iview, uint32_t layer);
void
tu_cs_image_stencil_ref(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer);
void
tu_cs_image_depth_ref(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer);
bool
tiling_possible(VkFormat format);
bool
ubwc_possible(struct tu_device *device,
VkFormat format,
VkImageType type,
VkImageUsageFlags usage,
VkImageUsageFlags stencil_usage,
const struct fd_dev_info *info,
VkSampleCountFlagBits samples,
bool use_z24uint_s8uint);
void
tu_buffer_view_init(struct tu_buffer_view *view,
struct tu_device *device,
const VkBufferViewCreateInfo *pCreateInfo);
#endif /* TU_IMAGE_H */
|
07aaf82cc0d6c86c74ebe2f24648d2b7d6863307
|
3ca76f016adc234fd616ea989b5b09da02ad1898
|
/ACAeeprom.h
|
f2335e0c1afa0cb62702e063d1559ad172ea5f6b
|
[] |
no_license
|
stancecoke/BMSBattery_S_controllers_firmware
|
7d016b7ca55eb27b6311554d3ed92fdc77e934e2
|
442f9152ea632542cdaf9870063e05f79928cae2
|
refs/heads/Master
| 2023-08-10T17:54:52.398186
| 2022-01-11T20:56:25
| 2022-01-11T20:56:25
| 108,517,613
| 124
| 69
| null | 2023-07-18T08:21:53
| 2017-10-27T08:04:26
|
C
|
UTF-8
|
C
| false
| false
| 3,268
|
h
|
ACAeeprom.h
|
/*
* Copyright (c) 2018 Björn Schmidt
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* File: ACAeeprom.h
* Author: Björn Schmidt
*
* Created on August 30, 2018, 8:03 PM
*/
#ifndef BOEEPROM_H
#define BOEEPROM_H
#include "config.h"
extern uint8_t eeprom_magic_byte;
#define EEPROM_BASE_ADDRESS 0x4000
#define EEPROM_MAX_INIT_RANGE 0x2F // we should at least have 640 avail / 48 in use for now
typedef enum {
OFFSET_MOTOR_ANGLE = ((uint8_t) 0x01),
OFFSET_ASSIST_PERCENT_WANTED = ((uint8_t) 0x02),
OFFSET_ASSIST_LEVEL = ((uint8_t) 0x03),
OFFSET_THROTTLE_MIN_RANGE = ((uint8_t) 0x04),
OFFSET_THROTTLE_MAX_RANGE = ((uint8_t) 0x05),
OFFSET_RAMP_START = ((uint8_t) 0x06),
OFFSET_PAS_TRESHOLD = ((uint8_t) 0x07),
OFFSET_PID_GAIN_P = ((uint8_t) 0x08),
OFFSET_PID_GAIN_I = ((uint8_t) 0x09),
OFFSET_RAMP_END = ((uint8_t) 0x0A),
OFFSET_MAX_SPEED_DEFAULT = ((uint8_t) 0x0B),
OFFSET_MAX_SPEED_WITHOUT_PAS = ((uint8_t) 0x0C),
OFFSET_MAX_SPEED_WITH_THROTTLE_OVERRIDE = ((uint8_t) 0x0D),
OFFSET_BATTERY_CURRENT_MAX_VALUE_HIGH_BYTE = ((uint8_t) 0x0E),
OFFSET_BATTERY_CURRENT_MAX_VALUE = ((uint8_t) 0x0F),
OFFSET_REGEN_CURRENT_MAX_VALUE = ((uint8_t) 0x10),
OFFSET_CURRENT_CAL_A = ((uint8_t) 0x11),
OFFSET_ACA_FLAGS_HIGH_BYTE = ((uint8_t) 0x12),
OFFSET_ACA_FLAGS = ((uint8_t) 0x13),
OFFSET_TQ_CALIB = ((uint8_t) 0x14),
OFFSET_CORRECTION_AT_ANGLE = ((uint8_t) 0x15),
OFFSET_HALL_ANGLE_4_0 = ((uint8_t) 0x16),
OFFSET_HALL_ANGLE_6_60 = ((uint8_t) 0x17),
OFFSET_HALL_ANGLE_2_120 = ((uint8_t) 0x18),
OFFSET_HALL_ANGLE_3_180 = ((uint8_t) 0x19),
OFFSET_HALL_ANGLE_1_240 = ((uint8_t) 0x1A),
OFFSET_HALL_ANGLE_5_300 = ((uint8_t) 0x1B),
OFFSET_BATTERY_VOLTAGE_CALIB = ((uint8_t) 0x1C),
OFFSET_MOTOR_CONSTANT = ((uint8_t) 0x1D),
OFFSET_ACA_EXPERIMENTAL_FLAGS_HIGH_BYTE = ((uint8_t) 0x1E),
OFFSET_ACA_EXPERIMENTAL_FLAGS = ((uint8_t) 0x1F),
OFFSET_ASSIST_PERCENT_LEVEL_1 = ((uint8_t) 0x20),
OFFSET_ASSIST_PERCENT_LEVEL_2 = ((uint8_t) 0x21),
OFFSET_ASSIST_PERCENT_LEVEL_3 = ((uint8_t) 0x22),
OFFSET_ASSIST_PERCENT_LEVEL_4 = ((uint8_t) 0x23),
OFFSET_ASSIST_PERCENT_LEVEL_5 = ((uint8_t) 0x24),
OFFSET_BATTERY_VOLTAGE_MIN = ((uint8_t) 0x25),
OFFSET_BATTERY_VOLTAGE_MAX = ((uint8_t) 0x26),
OFFSET_PASSCODE_HIGH_BYTE = ((uint8_t) 0x27),
OFFSET_PASSCODE = ((uint8_t) 0x28),
OFFSET_GEAR_RATIO = ((uint8_t) 0x29)
} BO_EEPROM_OFFSETS;
void eeprom_init(void);
uint8_t eeprom_write(uint8_t adress_offset, uint8_t value);
uint8_t eeprom_read(uint8_t address_offset);
#endif /* BOEEPROM_H */
|
106cf4e1116e0acf151cf924975da78c635051b9
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/soc/allwinner/pm/pm_config-sun9iw1p1.h
|
8cd4fcbafe9e1d3fe56ba775ca76413ae8a04e69
|
[
"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
| 3,837
|
h
|
pm_config-sun9iw1p1.h
|
#ifndef _PM_CONFIG_SUN9IW1P1_H
#define _PM_CONFIG_SUN9IW1P1_H
/*
* Copyright (c) 2011-2015 yanggq.young@allwinnertech.com
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*/
#include "pm_def_i.h"
#include "mach/platform.h"
#include "mach/memory.h"
#include "asm-generic/sizes.h"
//#include <generated/autoconf.h>
#include "mach/irqs.h"
//debug reg
#define STANDBY_STATUS_REG_PA (SUNXI_R_PRCM_PBASE + 0x1f0)
#define STANDBY_STATUS_REG IO_ADDRESS((STANDBY_STATUS_REG_PA))
#define STANDBY_STATUS_REG_NUM (4) //reg1 - reg3 is available.
//module base reg
#define AW_LRADC01_BASE (SUNXI_LRADC01_PBASE)
#define AW_CCM_BASE (SUNXI_CCM_PLL_PBASE)
#define AW_CCM_MOD_BASE (SUNXI_CCM_MOD_PBASE)
#define AW_SPINLOCK_BASE (SUNXI_SPINLOCK_PBASE)
#define AW_CCU_UART_PA (0x06000400 + 0x194) //bit16: uart0;
#define AW_CCU_UART_RESET_PA (0x06000400 + 0x1b4) //bit16: uart0;
#define AW_CCM_PIO_BUS_GATE_REG_OFFSET (0x190)
//Notice: jtag&uart_ph use the same addr, on sun9i platform.
#define AW_JTAG_PH_GPIO_PA (0x06000800 + 0x100) //jtag0: PH8-PH11, bitmap: 0x2222
#define AW_UART_PF_GPIO_PA (0x06000800 + 0xB4) //uart0: PF2,PF4, bitmap: 0x04,0400;
#define AW_UART_PH_GPIO_PA (0x06000800 + 0x100) //uart0: PH12,PH13, bitmap: 0x22,0000
#define AW_JTAG_PF_GPIO_PA (0x06000800 + 0xB4) //jtag0: PF0,PF1,PF3,PF5 bitmap: 0x40,4044;
#define AW_JTAG_PH_CONFIG_VAL_MASK (0x0000ffff)
#define AW_JTAG_PH_CONFIG_VAL (0x00002222)
#define AW_JTAG_PF_CONFIG_VAL_MASK (0x00f0f0ff)
#define AW_JTAG_PF_CONFIG_VAL (0x00404044)
#define AW_UART_PH_CONFIG_VAL_MASK (0x00ff0000)
#define AW_UART_PH_CONFIG_VAL (0x00220000)
#define AW_UART_PF_CONFIG_VAL_MASK (0x000F0F00)
#define AW_UART_PF_CONFIG_VAL (0x00040400)
#define AW_JTAG_GPIO_PA (AW_JTAG_PF_GPIO_PA)
#define AW_UART_GPIO_PA (AW_UART_PF_GPIO_PA)
#define AW_JTAG_CONFIG_VAL_MASK AW_JTAG_PF_CONFIG_VAL_MASK
#define AW_JTAG_CONFIG_VAL AW_JTAG_PF_CONFIG_VAL
#define AW_RTC_BASE (AW_SRAM_A1_BASE) //notice: fake addr.
#define AW_SRAMCTRL_BASE (SUNXI_SYS_CTRL_PBASE)
#define GPIO_REG_LENGTH ((0x324+0x4)>>2)
#define CPUS_GPIO_REG_LENGTH ((0x304+0x4)>>2)
#define SRAM_REG_LENGTH ((0xF0+0x4)>>2)
#define CCU_REG_LENGTH ((0x184+0x4)>>2)
#define CCU_MOD_REG_LENGTH ((0x1B4+0x4)>>2)
#define CCU_MOD_CLK_AHB1_RESET_SPINLOCK (AW_CCM_MOD_BASE + 0x1a4)
#define CCU_CLK_NRESET (0x1<<22)
#define CCU_MOD_CLK_AHB1_GATING_SPINLOCK (AW_CCM_MOD_BASE + 0x184)
#define CCU_CLK_ON (0x1<<22)
/**start address for function run in sram*/
#define SRAM_FUNC_START (0xf0010000)
#define SRAM_FUNC_START_PA (0x00010000)
//for mem mapping
#define MEM_SW_VA_SRAM_BASE (0x00010000)
#define MEM_SW_PA_SRAM_BASE (0x00010000)
#define CPU_PLL_REST_DEFAULT_VAL (0x02001100)
#define CPU_CLK_REST_DEFAULT_VAL (0x00000000) //SRC is HOSC.
//interrupt src definition
#define AW_IRQ_TIMER1 (0)
#define AW_IRQ_TOUCHPANEL (0)
#define AW_IRQ_LRADC (0)
#define AW_IRQ_NMI (0)
#define AW_IRQ_MBOX (SUNXI_IRQ_MBOX )
#define AW_IRQ_ALARM (0)
#define AW_IRQ_IR0 (0)
#define AW_IRQ_IR1 (0)
#define AW_IRQ_USBOTG (SUNXI_IRQ_USB_OTG)
#define AW_IRQ_USBEHCI0 (SUNXI_IRQ_USB_EHCI0)
#define AW_IRQ_USBOHCI0 (SUNXI_IRQ_USB_OHCI0)
#define AW_IRQ_USBEHCI1 (SUNXI_IRQ_USB_EHCI1)
#define AW_IRQ_USBOHCI1 (SUNXI_IRQ_USB_OHCI1)
#define AW_IRQ_USBEHCI2 (SUNXI_IRQ_USB_EHCI2)
#define AW_IRQ_USBOHCI2 (SUNXI_IRQ_USB_OHCI2)
#define AW_IRQ_GPIOA (0)
#define AW_IRQ_GPIOB (SUNXI_IRQ_EINTB)
#define AW_IRQ_GPIOC (0)
#define AW_IRQ_GPIOD (0)
#define AW_IRQ_GPIOE (0)
#define AW_IRQ_GPIOF (0)
#define AW_IRQ_GPIOG (SUNXI_IRQ_EINTG)
#define AW_IRQ_GPIOH (0)
#define AW_IRQ_GPIOI (0)
#define AW_IRQ_GPIOJ (0)
#endif /*_PM_CONFIG_SUN9IW1P1_H*/
|
606b17267cf027b9ee49f836eb01f915f435012a
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/fs/logfs/gc.c
|
d4efb061bdc5d1dd62ecddcb7575cf891e3b792e
|
[
"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
| 20,638
|
c
|
gc.c
|
/*
* fs/logfs/gc.c - garbage collection code
*
* As should be obvious for Linux kernel code, license is GPLv2
*
* Copyright (c) 2005-2008 Joern Engel <joern@logfs.org>
*/
#include "logfs.h"
#include <linux/sched.h>
#include <linux/slab.h>
/*
* Wear leveling needs to kick in when the difference between low erase
* counts and high erase counts gets too big. A good value for "too big"
* may be somewhat below 10% of maximum erase count for the device.
* Why not 397, to pick a nice round number with no specific meaning? :)
*
* WL_RATELIMIT is the minimum time between two wear level events. A huge
* number of segments may fulfil the requirements for wear leveling at the
* same time. If that happens we don't want to cause a latency from hell,
* but just gently pick one segment every so often and minimize overhead.
*/
#define WL_DELTA 397
#define WL_RATELIMIT 100
#define MAX_OBJ_ALIASES 2600
#define SCAN_RATIO 512 /* number of scanned segments per gc'd segment */
#define LIST_SIZE 64 /* base size of candidate lists */
#define SCAN_ROUNDS 128 /* maximum number of complete medium scans */
#define SCAN_ROUNDS_HIGH 4 /* maximum number of higher-level scans */
static int no_free_segments(struct super_block *sb)
{
struct logfs_super *super = logfs_super(sb);
return super->s_free_list.count;
}
/* journal has distance -1, top-most ifile layer distance 0 */
static u8 root_distance(struct super_block *sb, gc_level_t __gc_level)
{
struct logfs_super *super = logfs_super(sb);
u8 gc_level = (__force u8)__gc_level;
switch (gc_level) {
case 0: /* fall through */
case 1: /* fall through */
case 2: /* fall through */
case 3:
/* file data or indirect blocks */
return super->s_ifile_levels + super->s_iblock_levels - gc_level;
case 6: /* fall through */
case 7: /* fall through */
case 8: /* fall through */
case 9:
/* inode file data or indirect blocks */
return super->s_ifile_levels - (gc_level - 6);
default:
printk(KERN_ERR"LOGFS: segment of unknown level %x found\n",
gc_level);
WARN_ON(1);
return super->s_ifile_levels + super->s_iblock_levels;
}
}
static int segment_is_reserved(struct super_block *sb, u32 segno)
{
struct logfs_super *super = logfs_super(sb);
struct logfs_area *area;
void *reserved;
int i;
/* Some segments are reserved. Just pretend they were all valid */
reserved = btree_lookup32(&super->s_reserved_segments, segno);
if (reserved)
return 1;
/* Currently open segments */
for_each_area(i) {
area = super->s_area[i];
if (area->a_is_open && area->a_segno == segno)
return 1;
}
return 0;
}
static void logfs_mark_segment_bad(struct super_block *sb, u32 segno)
{
BUG();
}
/*
* Returns the bytes consumed by valid objects in this segment. Object headers
* are counted, the segment header is not.
*/
static u32 logfs_valid_bytes(struct super_block *sb, u32 segno, u32 *ec,
gc_level_t *gc_level)
{
struct logfs_segment_entry se;
u32 ec_level;
logfs_get_segment_entry(sb, segno, &se);
if (se.ec_level == cpu_to_be32(BADSEG) ||
se.valid == cpu_to_be32(RESERVED))
return RESERVED;
ec_level = be32_to_cpu(se.ec_level);
*ec = ec_level >> 4;
*gc_level = GC_LEVEL(ec_level & 0xf);
return be32_to_cpu(se.valid);
}
static void logfs_cleanse_block(struct super_block *sb, u64 ofs, u64 ino,
u64 bix, gc_level_t gc_level)
{
struct inode *inode;
int err, cookie;
inode = logfs_safe_iget(sb, ino, &cookie);
err = logfs_rewrite_block(inode, bix, ofs, gc_level, 0);
BUG_ON(err);
logfs_safe_iput(inode, cookie);
}
static u32 logfs_gc_segment(struct super_block *sb, u32 segno)
{
struct logfs_super *super = logfs_super(sb);
struct logfs_segment_header sh;
struct logfs_object_header oh;
u64 ofs, ino, bix;
u32 seg_ofs, logical_segno, cleaned = 0;
int err, len, valid;
gc_level_t gc_level;
LOGFS_BUG_ON(segment_is_reserved(sb, segno), sb);
btree_insert32(&super->s_reserved_segments, segno, (void *)1, GFP_NOFS);
err = wbuf_read(sb, dev_ofs(sb, segno, 0), sizeof(sh), &sh);
BUG_ON(err);
gc_level = GC_LEVEL(sh.level);
logical_segno = be32_to_cpu(sh.segno);
if (sh.crc != logfs_crc32(&sh, sizeof(sh), 4)) {
logfs_mark_segment_bad(sb, segno);
cleaned = -1;
goto out;
}
for (seg_ofs = LOGFS_SEGMENT_HEADERSIZE;
seg_ofs + sizeof(oh) < super->s_segsize; ) {
ofs = dev_ofs(sb, logical_segno, seg_ofs);
err = wbuf_read(sb, dev_ofs(sb, segno, seg_ofs), sizeof(oh),
&oh);
BUG_ON(err);
if (!memchr_inv(&oh, 0xff, sizeof(oh)))
break;
if (oh.crc != logfs_crc32(&oh, sizeof(oh) - 4, 4)) {
logfs_mark_segment_bad(sb, segno);
cleaned = super->s_segsize - 1;
goto out;
}
ino = be64_to_cpu(oh.ino);
bix = be64_to_cpu(oh.bix);
len = sizeof(oh) + be16_to_cpu(oh.len);
valid = logfs_is_valid_block(sb, ofs, ino, bix, gc_level);
if (valid == 1) {
logfs_cleanse_block(sb, ofs, ino, bix, gc_level);
cleaned += len;
} else if (valid == 2) {
/* Will be invalid upon journal commit */
cleaned += len;
}
seg_ofs += len;
}
out:
btree_remove32(&super->s_reserved_segments, segno);
return cleaned;
}
static struct gc_candidate *add_list(struct gc_candidate *cand,
struct candidate_list *list)
{
struct rb_node **p = &list->rb_tree.rb_node;
struct rb_node *parent = NULL;
struct gc_candidate *cur;
int comp;
cand->list = list;
while (*p) {
parent = *p;
cur = rb_entry(parent, struct gc_candidate, rb_node);
if (list->sort_by_ec)
comp = cand->erase_count < cur->erase_count;
else
comp = cand->valid < cur->valid;
if (comp)
p = &parent->rb_left;
else
p = &parent->rb_right;
}
rb_link_node(&cand->rb_node, parent, p);
rb_insert_color(&cand->rb_node, &list->rb_tree);
if (list->count <= list->maxcount) {
list->count++;
return NULL;
}
cand = rb_entry(rb_last(&list->rb_tree), struct gc_candidate, rb_node);
rb_erase(&cand->rb_node, &list->rb_tree);
cand->list = NULL;
return cand;
}
static void remove_from_list(struct gc_candidate *cand)
{
struct candidate_list *list = cand->list;
rb_erase(&cand->rb_node, &list->rb_tree);
list->count--;
}
static void free_candidate(struct super_block *sb, struct gc_candidate *cand)
{
struct logfs_super *super = logfs_super(sb);
btree_remove32(&super->s_cand_tree, cand->segno);
kfree(cand);
}
u32 get_best_cand(struct super_block *sb, struct candidate_list *list, u32 *ec)
{
struct gc_candidate *cand;
u32 segno;
BUG_ON(list->count == 0);
cand = rb_entry(rb_first(&list->rb_tree), struct gc_candidate, rb_node);
remove_from_list(cand);
segno = cand->segno;
if (ec)
*ec = cand->erase_count;
free_candidate(sb, cand);
return segno;
}
/*
* We have several lists to manage segments with. The reserve_list is used to
* deal with bad blocks. We try to keep the best (lowest ec) segments on this
* list.
* The free_list contains free segments for normal usage. It usually gets the
* second pick after the reserve_list. But when the free_list is running short
* it is more important to keep the free_list full than to keep a reserve.
*
* Segments that are not free are put onto a per-level low_list. If we have
* to run garbage collection, we pick a candidate from there. All segments on
* those lists should have at least some free space so GC will make progress.
*
* And last we have the ec_list, which is used to pick segments for wear
* leveling.
*
* If all appropriate lists are full, we simply free the candidate and forget
* about that segment for a while. We have better candidates for each purpose.
*/
static void __add_candidate(struct super_block *sb, struct gc_candidate *cand)
{
struct logfs_super *super = logfs_super(sb);
u32 full = super->s_segsize - LOGFS_SEGMENT_RESERVE;
if (cand->valid == 0) {
/* 100% free segments */
log_gc_noisy("add reserve segment %x (ec %x) at %llx\n",
cand->segno, cand->erase_count,
dev_ofs(sb, cand->segno, 0));
cand = add_list(cand, &super->s_reserve_list);
if (cand) {
log_gc_noisy("add free segment %x (ec %x) at %llx\n",
cand->segno, cand->erase_count,
dev_ofs(sb, cand->segno, 0));
cand = add_list(cand, &super->s_free_list);
}
} else {
/* good candidates for Garbage Collection */
if (cand->valid < full)
cand = add_list(cand, &super->s_low_list[cand->dist]);
/* good candidates for wear leveling,
* segments that were recently written get ignored */
if (cand)
cand = add_list(cand, &super->s_ec_list);
}
if (cand)
free_candidate(sb, cand);
}
static int add_candidate(struct super_block *sb, u32 segno, u32 valid, u32 ec,
u8 dist)
{
struct logfs_super *super = logfs_super(sb);
struct gc_candidate *cand;
cand = kmalloc(sizeof(*cand), GFP_NOFS);
if (!cand)
return -ENOMEM;
cand->segno = segno;
cand->valid = valid;
cand->erase_count = ec;
cand->dist = dist;
btree_insert32(&super->s_cand_tree, segno, cand, GFP_NOFS);
__add_candidate(sb, cand);
return 0;
}
static void remove_segment_from_lists(struct super_block *sb, u32 segno)
{
struct logfs_super *super = logfs_super(sb);
struct gc_candidate *cand;
cand = btree_lookup32(&super->s_cand_tree, segno);
if (cand) {
remove_from_list(cand);
free_candidate(sb, cand);
}
}
static void scan_segment(struct super_block *sb, u32 segno)
{
u32 valid, ec = 0;
gc_level_t gc_level = 0;
u8 dist;
if (segment_is_reserved(sb, segno))
return;
remove_segment_from_lists(sb, segno);
valid = logfs_valid_bytes(sb, segno, &ec, &gc_level);
if (valid == RESERVED)
return;
dist = root_distance(sb, gc_level);
add_candidate(sb, segno, valid, ec, dist);
}
static struct gc_candidate *first_in_list(struct candidate_list *list)
{
if (list->count == 0)
return NULL;
return rb_entry(rb_first(&list->rb_tree), struct gc_candidate, rb_node);
}
/*
* Find the best segment for garbage collection. Main criterion is
* the segment requiring the least effort to clean. Secondary
* criterion is to GC on the lowest level available.
*
* So we search the least effort segment on the lowest level first,
* then move up and pick another segment iff is requires significantly
* less effort. Hence the LOGFS_MAX_OBJECTSIZE in the comparison.
*/
static struct gc_candidate *get_candidate(struct super_block *sb)
{
struct logfs_super *super = logfs_super(sb);
int i, max_dist;
struct gc_candidate *cand = NULL, *this;
max_dist = min(no_free_segments(sb), LOGFS_NO_AREAS - 1);
for (i = max_dist; i >= 0; i--) {
this = first_in_list(&super->s_low_list[i]);
if (!this)
continue;
if (!cand)
cand = this;
if (this->valid + LOGFS_MAX_OBJECTSIZE <= cand->valid)
cand = this;
}
return cand;
}
static int __logfs_gc_once(struct super_block *sb, struct gc_candidate *cand)
{
struct logfs_super *super = logfs_super(sb);
gc_level_t gc_level;
u32 cleaned, valid, segno, ec;
u8 dist;
if (!cand) {
log_gc("GC attempted, but no candidate found\n");
return 0;
}
segno = cand->segno;
dist = cand->dist;
valid = logfs_valid_bytes(sb, segno, &ec, &gc_level);
free_candidate(sb, cand);
log_gc("GC segment #%02x at %llx, %x required, %x free, %x valid, %llx free\n",
segno, (u64)segno << super->s_segshift,
dist, no_free_segments(sb), valid,
super->s_free_bytes);
cleaned = logfs_gc_segment(sb, segno);
log_gc("GC segment #%02x complete - now %x valid\n", segno,
valid - cleaned);
BUG_ON(cleaned != valid);
return 1;
}
static int logfs_gc_once(struct super_block *sb)
{
struct gc_candidate *cand;
cand = get_candidate(sb);
if (cand)
remove_from_list(cand);
return __logfs_gc_once(sb, cand);
}
/* returns 1 if a wrap occurs, 0 otherwise */
static int logfs_scan_some(struct super_block *sb)
{
struct logfs_super *super = logfs_super(sb);
u32 segno;
int i, ret = 0;
segno = super->s_sweeper;
for (i = SCAN_RATIO; i > 0; i--) {
segno++;
if (segno >= super->s_no_segs) {
segno = 0;
ret = 1;
/* Break out of the loop. We want to read a single
* block from the segment size on next invocation if
* SCAN_RATIO is set to match block size
*/
break;
}
scan_segment(sb, segno);
}
super->s_sweeper = segno;
return ret;
}
/*
* In principle, this function should loop forever, looking for GC candidates
* and moving data. LogFS is designed in such a way that this loop is
* guaranteed to terminate.
*
* Limiting the loop to some iterations serves purely to catch cases when
* these guarantees have failed. An actual endless loop is an obvious bug
* and should be reported as such.
*/
static void __logfs_gc_pass(struct super_block *sb, int target)
{
struct logfs_super *super = logfs_super(sb);
struct logfs_block *block;
int round, progress, last_progress = 0;
/*
* Doing too many changes to the segfile at once would result
* in a large number of aliases. Write the journal before
* things get out of hand.
*/
if (super->s_shadow_tree.no_shadowed_segments >= MAX_OBJ_ALIASES)
logfs_write_anchor(sb);
if (no_free_segments(sb) >= target &&
super->s_no_object_aliases < MAX_OBJ_ALIASES)
return;
log_gc("__logfs_gc_pass(%x)\n", target);
for (round = 0; round < SCAN_ROUNDS; ) {
if (no_free_segments(sb) >= target)
goto write_alias;
/* Sync in-memory state with on-medium state in case they
* diverged */
logfs_write_anchor(sb);
round += logfs_scan_some(sb);
if (no_free_segments(sb) >= target)
goto write_alias;
progress = logfs_gc_once(sb);
if (progress)
last_progress = round;
else if (round - last_progress > 2)
break;
continue;
/*
* The goto logic is nasty, I just don't know a better way to
* code it. GC is supposed to ensure two things:
* 1. Enough free segments are available.
* 2. The number of aliases is bounded.
* When 1. is achieved, we take a look at 2. and write back
* some alias-containing blocks, if necessary. However, after
* each such write we need to go back to 1., as writes can
* consume free segments.
*/
write_alias:
if (super->s_no_object_aliases < MAX_OBJ_ALIASES)
return;
if (list_empty(&super->s_object_alias)) {
/* All aliases are still in btree */
return;
}
log_gc("Write back one alias\n");
block = list_entry(super->s_object_alias.next,
struct logfs_block, alias_list);
block->ops->write_block(block);
/*
* To round off the nasty goto logic, we reset round here. It
* is a safety-net for GC not making any progress and limited
* to something reasonably small. If incremented it for every
* single alias, the loop could terminate rather quickly.
*/
round = 0;
}
LOGFS_BUG(sb);
}
static int wl_ratelimit(struct super_block *sb, u64 *next_event)
{
struct logfs_super *super = logfs_super(sb);
if (*next_event < super->s_gec) {
*next_event = super->s_gec + WL_RATELIMIT;
return 0;
}
return 1;
}
static void logfs_wl_pass(struct super_block *sb)
{
struct logfs_super *super = logfs_super(sb);
struct gc_candidate *wl_cand, *free_cand;
if (wl_ratelimit(sb, &super->s_wl_gec_ostore))
return;
wl_cand = first_in_list(&super->s_ec_list);
if (!wl_cand)
return;
free_cand = first_in_list(&super->s_free_list);
if (!free_cand)
return;
if (wl_cand->erase_count < free_cand->erase_count + WL_DELTA) {
remove_from_list(wl_cand);
__logfs_gc_once(sb, wl_cand);
}
}
/*
* The journal needs wear leveling as well. But moving the journal is an
* expensive operation so we try to avoid it as much as possible. And if we
* have to do it, we move the whole journal, not individual segments.
*
* Ratelimiting is not strictly necessary here, it mainly serves to avoid the
* calculations. First we check whether moving the journal would be a
* significant improvement. That means that a) the current journal segments
* have more wear than the future journal segments and b) the current journal
* segments have more wear than normal ostore segments.
* Rationale for b) is that we don't have to move the journal if it is aging
* less than the ostore, even if the reserve segments age even less (they are
* excluded from wear leveling, after all).
* Next we check that the superblocks have less wear than the journal. Since
* moving the journal requires writing the superblocks, we have to protect the
* superblocks even more than the journal.
*
* Also we double the acceptable wear difference, compared to ostore wear
* leveling. Journal data is read and rewritten rapidly, comparatively. So
* soft errors have much less time to accumulate and we allow the journal to
* be a bit worse than the ostore.
*/
static void logfs_journal_wl_pass(struct super_block *sb)
{
struct logfs_super *super = logfs_super(sb);
struct gc_candidate *cand;
u32 min_journal_ec = -1, max_reserve_ec = 0;
int i;
if (wl_ratelimit(sb, &super->s_wl_gec_journal))
return;
if (super->s_reserve_list.count < super->s_no_journal_segs) {
/* Reserve is not full enough to move complete journal */
return;
}
journal_for_each(i)
if (super->s_journal_seg[i])
min_journal_ec = min(min_journal_ec,
super->s_journal_ec[i]);
cand = rb_entry(rb_first(&super->s_free_list.rb_tree),
struct gc_candidate, rb_node);
max_reserve_ec = cand->erase_count;
for (i = 0; i < 2; i++) {
struct logfs_segment_entry se;
u32 segno = seg_no(sb, super->s_sb_ofs[i]);
u32 ec;
logfs_get_segment_entry(sb, segno, &se);
ec = be32_to_cpu(se.ec_level) >> 4;
max_reserve_ec = max(max_reserve_ec, ec);
}
if (min_journal_ec > max_reserve_ec + 2 * WL_DELTA) {
do_logfs_journal_wl_pass(sb);
}
}
void logfs_gc_pass(struct super_block *sb)
{
struct logfs_super *super = logfs_super(sb);
//BUG_ON(mutex_trylock(&logfs_super(sb)->s_w_mutex));
/* Write journal before free space is getting saturated with dirty
* objects.
*/
if (super->s_dirty_used_bytes + super->s_dirty_free_bytes
+ LOGFS_MAX_OBJECTSIZE >= super->s_free_bytes)
logfs_write_anchor(sb);
__logfs_gc_pass(sb, super->s_total_levels);
logfs_wl_pass(sb);
logfs_journal_wl_pass(sb);
}
static int check_area(struct super_block *sb, int i)
{
struct logfs_super *super = logfs_super(sb);
struct logfs_area *area = super->s_area[i];
gc_level_t gc_level;
u32 cleaned, valid, ec;
u32 segno = area->a_segno;
u64 ofs = dev_ofs(sb, area->a_segno, area->a_written_bytes);
if (!area->a_is_open)
return 0;
if (super->s_devops->can_write_buf(sb, ofs) == 0)
return 0;
printk(KERN_INFO"LogFS: Possibly incomplete write at %llx\n", ofs);
/*
* The device cannot write back the write buffer. Most likely the
* wbuf was already written out and the system crashed at some point
* before the journal commit happened. In that case we wouldn't have
* to do anything. But if the crash happened before the wbuf was
* written out correctly, we must GC this segment. So assume the
* worst and always do the GC run.
*/
area->a_is_open = 0;
valid = logfs_valid_bytes(sb, segno, &ec, &gc_level);
cleaned = logfs_gc_segment(sb, segno);
if (cleaned != valid)
return -EIO;
return 0;
}
int logfs_check_areas(struct super_block *sb)
{
int i, err;
for_each_area(i) {
err = check_area(sb, i);
if (err)
return err;
}
return 0;
}
static void logfs_init_candlist(struct candidate_list *list, int maxcount,
int sort_by_ec)
{
list->count = 0;
list->maxcount = maxcount;
list->sort_by_ec = sort_by_ec;
list->rb_tree = RB_ROOT;
}
int logfs_init_gc(struct super_block *sb)
{
struct logfs_super *super = logfs_super(sb);
int i;
btree_init_mempool32(&super->s_cand_tree, super->s_btree_pool);
logfs_init_candlist(&super->s_free_list, LIST_SIZE + SCAN_RATIO, 1);
logfs_init_candlist(&super->s_reserve_list,
super->s_bad_seg_reserve, 1);
for_each_area(i)
logfs_init_candlist(&super->s_low_list[i], LIST_SIZE, 0);
logfs_init_candlist(&super->s_ec_list, LIST_SIZE, 1);
return 0;
}
static void logfs_cleanup_list(struct super_block *sb,
struct candidate_list *list)
{
struct gc_candidate *cand;
while (list->count) {
cand = rb_entry(list->rb_tree.rb_node, struct gc_candidate,
rb_node);
remove_from_list(cand);
free_candidate(sb, cand);
}
BUG_ON(list->rb_tree.rb_node);
}
void logfs_cleanup_gc(struct super_block *sb)
{
struct logfs_super *super = logfs_super(sb);
int i;
if (!super->s_free_list.count)
return;
/*
* FIXME: The btree may still contain a single empty node. So we
* call the grim visitor to clean up that mess. Btree code should
* do it for us, really.
*/
btree_grim_visitor32(&super->s_cand_tree, 0, NULL);
logfs_cleanup_list(sb, &super->s_free_list);
logfs_cleanup_list(sb, &super->s_reserve_list);
for_each_area(i)
logfs_cleanup_list(sb, &super->s_low_list[i]);
logfs_cleanup_list(sb, &super->s_ec_list);
}
|
79bec2969418768c6191def2f24db7dde4b08cda
|
736bc705b28a4cb4288948b26b4253835acbfd1e
|
/ast-interpreter/test-cases/test1.c
|
eac1545d12833ff237f42b2faaf43cd9abd58ee3
|
[
"WTFPL"
] |
permissive
|
lijiansong/clang-llvm-tutorial
|
18aac7b5f7b3519f5c81e5a671c5ef20786c0161
|
91e7d8a7e967c44d54e21f5994260175dc1c7f8a
|
refs/heads/master
| 2022-05-11T05:06:20.398914
| 2022-04-16T01:57:24
| 2022-04-16T01:57:24
| 77,628,811
| 253
| 62
| null | null | null | null |
UTF-8
|
C
| false
| false
| 130
|
c
|
test1.c
|
extern int GET();
extern long MALLOC(int);
extern void FREE(long);
extern void PRINT(int);
int b=10;
int main() {
PRINT(b);
}
|
6f51fea0dcd5a31a2a183acc62d33b1e72095239
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/sysutils/syslinux/files/patch-mtools-syslinux.c
|
3b5ef2420b8096574ff702f6b75e6632fd5afce6
|
[
"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
| 3,914
|
c
|
patch-mtools-syslinux.c
|
--- mtools/syslinux.c.orig 2010-10-20 21:25:38.000000000 +0200
+++ mtools/syslinux.c 2010-11-16 14:59:55.668749526 +0100
@@ -20,12 +20,12 @@
*/
#define _GNU_SOURCE
-#include <alloca.h>
+//#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <inttypes.h>
-#include <mntent.h>
+//#include <mntent.h>
#include <paths.h>
#include <stdio.h>
#include <string.h>
@@ -42,6 +42,8 @@
#include "setadv.h"
#include "syslxopt.h"
+int verbose=0;
+
char *program; /* Name of program */
pid_t mypid;
@@ -124,6 +126,53 @@
return xpread(pp, buf, secsize, offset);
}
+/*
+ * load a file to be used as boot image
+ */
+static int load_boot_image(const char *name)
+{
+ int l, fd;
+ struct stat sb;
+ unsigned char *buf;
+
+ memset(&sb, 0, sizeof(sb));
+ fd = open(name, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "cannot open boot image %s\n", name);
+ return 1;
+ }
+ if (fstat(fd, &sb)) {
+ fprintf(stderr, "cannot stat boot image %s\n", name);
+ return 1;
+ }
+ if ( (sb.st_mode & S_IFREG) == 0) {
+ fprintf(stderr, "boot image %s is not a file 0x%x\n", name, sb.st_mode);
+ return 1;
+ }
+ if (sb.st_size < 1024 || sb.st_size > 0x8000) {
+ fprintf(stderr, "boot image %s bad size %lld\n", name, (long long int)sb.st_size);
+ return 1;
+ }
+ buf = calloc(1, sb.st_size);
+ if (buf == NULL) {
+ fprintf(stderr, "malloc failed for boot image %s\n", name);
+ return 1;
+ }
+ l = read(fd, buf, sb.st_size);
+ if (l != sb.st_size) {
+ fprintf(stderr, "read failed for boot image %s got %d\n", name, l);
+ return 1;
+ }
+ if (buf[0] != 0xeb || buf[0x200] != 0x0d) {
+ fprintf(stderr, "bad content for boot image %s\n", name);
+ return 1;
+ }
+ syslinux_bootsect = buf;
+ syslinux_ldlinux = buf + 512;
+ syslinux_ldlinux_len = sb.st_size - 512;
+ return 0;
+}
+
int main(int argc, char *argv[])
{
static unsigned char sectbuf[SECTOR_SIZE];
@@ -150,9 +199,15 @@
parse_options(argc, argv, MODE_SYSLINUX);
+ if (opt.verbose)
+ verbose = 1;
+
if (!opt.device)
usage(EX_USAGE, MODE_SYSLINUX);
+ if (opt.bimage != NULL)
+ load_boot_image(opt.bimage);
+
if (opt.sectors || opt.heads || opt.reset_adv || opt.set_once
|| (opt.update_only > 0) || opt.menu_save) {
fprintf(stderr,
@@ -216,11 +271,9 @@
/* These are needed for some flash memories */
"MTOOLS_SKIP_CHECK=1\n"
"MTOOLS_FAT_COMPATIBILITY=1\n"
- "drive s:\n"
- " file=\"/proc/%lu/fd/%d\"\n"
+ "drive s: file=\"%s\"\n"
" offset=%llu\n",
- (unsigned long)mypid,
- dev_fd, (unsigned long long)opt.offset);
+ opt.device, (unsigned long long)opt.offset);
if (ferror(mtc) || fclose(mtc))
die_err(mtools_conf);
@@ -239,9 +292,11 @@
syslinux_reset_adv(syslinux_adv);
/* This command may fail legitimately */
+ if (verbose) fprintf(stderr, "doing mattrib\n");
status = system("mattrib -h -r -s s:/ldlinux.sys 2>/dev/null");
(void)status; /* Keep _FORTIFY_SOURCE happy */
+ if (verbose) fprintf(stderr, "doing mcopy\n");
mtp = popen("mcopy -D o -D O -o - s:/ldlinux.sys", "w");
if (!mtp ||
fwrite(syslinux_ldlinux, 1, syslinux_ldlinux_len, mtp)
@@ -259,7 +314,9 @@
+ SECTOR_SIZE - 1) >> SECTOR_SHIFT;
sectors = calloc(ldlinux_sectors, sizeof *sectors);
fs = libfat_open(libfat_xpread, dev_fd);
+ if (verbose) fprintf(stderr, "libfat_open returns %p\n", fs);
ldlinux_cluster = libfat_searchdir(fs, 0, "LDLINUX SYS", NULL);
+ if (verbose) fprintf(stderr, "libfat_searchdir returns %d\n", ldlinux_cluster);
secp = sectors;
nsectors = 0;
s = libfat_clustertosector(fs, ldlinux_cluster);
@@ -267,6 +324,7 @@
*secp++ = s;
nsectors++;
s = libfat_nextsector(fs, s);
+ if (verbose) fprintf(stderr, "libfat_nextsector returns %d\n", (int)s);
}
libfat_close(fs);
|
e645ccaa3825f89c24fbea178f6390b0d7efea87
|
192f6a4c9d934be58bca0e610ec1a75e7777fcd1
|
/include/parrot/pmc_freeze.h
|
cf51159db81343cc00de81e56171de99e97180d2
|
[
"Artistic-2.0"
] |
permissive
|
parrot/parrot
|
39a74fbb015829cef901211d6d173b71eea475ea
|
f89a111c06ad0367817c52fda6ff5c24165c005b
|
refs/heads/master
| 2023-07-20T07:41:40.386067
| 2021-08-25T17:59:15
| 2021-08-25T17:59:15
| 1,071,734
| 450
| 134
| null | 2016-11-09T10:57:41
| 2010-11-11T15:14:10
|
C
|
UTF-8
|
C
| false
| false
| 8,115
|
h
|
pmc_freeze.h
|
/* pmc_freeze.h
* Copyright (C) 2001-2003, Parrot Foundation.
* Overview:
* PMC freeze and thaw interface
* Data Structure and Algorithms:
* History:
* Notes:
* References:
*/
#ifndef PARROT_PMC_FREEZE_H_GUARD
#define PARROT_PMC_FREEZE_H_GUARD
#include "parrot/packfile.h"
typedef enum {
VISIT_HOW_PMC_TO_VISITOR = 0x00, /* push to visitor */
VISIT_HOW_VISITOR_TO_PMC = 0x01, /* shift from visitor */
VISIT_HOW_PMC_TO_PMC = 0x02, /* push to visitor; then shift from visitor */
VISIT_HOW_VISITOR_TO_VISITOR = 0x03 /* shift from visitor; then push to visitor */
} visit_how_enum_t;
#define VISIT_HOW_MASK 0x03
typedef enum {
VISIT_WHAT_PMC = 0x04,
VISIT_WHAT_STRING = 0x08,
VISIT_WHAT_FLOATVAL = 0x10,
VISIT_WHAT_INTVAL = 0x20
} visit_what_enum_t;
#define VISIT_WHAT_MASK 0x3c
/* backwards-compat defns */
#define visit_enum_type INTVAL
#define VISIT_FREEZE_NORMAL (VISIT_HOW_PMC_TO_VISITOR | VISIT_WHAT_PMC)
#define VISIT_THAW_NORMAL (VISIT_HOW_VISITOR_TO_PMC | VISIT_WHAT_PMC)
#define VISIT_THAW_CONSTANTS VISIT_THAW_NORMAL
typedef enum {
EXTRA_IS_NULL,
EXTRA_IS_PROP_HASH
} extra_flags_enum;
#define VISIT_PMC(interp, visit, pmc) do {\
const INTVAL _visit_pmc_flags = VTABLE_get_integer((interp), (visit)); \
if (_visit_pmc_flags & VISIT_WHAT_PMC) { \
switch (_visit_pmc_flags & VISIT_HOW_MASK) { \
case VISIT_HOW_PMC_TO_VISITOR: \
VTABLE_push_pmc((interp), (visit), (pmc)); \
break; \
case VISIT_HOW_VISITOR_TO_PMC: \
(pmc) = VTABLE_shift_pmc((interp), (visit)); \
break; \
case VISIT_HOW_PMC_TO_PMC: \
VTABLE_push_pmc((interp), (visit), (pmc)); \
(pmc) = VTABLE_shift_pmc((interp), (visit)); \
break; \
case VISIT_HOW_VISITOR_TO_VISITOR: \
(pmc) = VTABLE_shift_pmc((interp), (visit)); \
VTABLE_push_pmc((interp), (visit), (pmc)); \
break; \
default: \
Parrot_x_panic_and_exit((interp), "Bad VISIT_HOW in VISIT_PMC", __FILE__, __LINE__); \
} \
} \
} while (0)
#define VISIT_PMC_ATTR(interp, visit, self, pmclass, attr_name) do {\
const INTVAL _visit_pmc_attr_flags = VTABLE_get_integer((interp), (visit)); \
if (_visit_pmc_attr_flags & VISIT_WHAT_PMC) { \
PMC *_visit_pmc_attr; \
switch (_visit_pmc_attr_flags & VISIT_HOW_MASK) { \
case VISIT_HOW_PMC_TO_VISITOR: \
GETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \
VTABLE_push_pmc((interp), (visit), _visit_pmc_attr); \
break; \
case VISIT_HOW_VISITOR_TO_PMC: \
_visit_pmc_attr = VTABLE_shift_pmc((interp), (visit)); \
SETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \
break; \
case VISIT_HOW_PMC_TO_PMC: \
GETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \
VTABLE_push_pmc((interp), (visit), _visit_pmc_attr); \
_visit_pmc_attr = VTABLE_shift_pmc((interp), (visit)); \
SETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \
break; \
case VISIT_HOW_VISITOR_TO_VISITOR: \
_visit_pmc_attr = VTABLE_shift_pmc((interp), (visit)); \
SETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \
GETATTR_ ## pmclass ## _ ## attr_name((interp), (self), _visit_pmc_attr); \
VTABLE_push_pmc((interp), (visit), _visit_pmc_attr); \
break; \
default: \
Parrot_x_panic_and_exit((interp), \
"Bad VISIT_HOW in VISIT_PMC_ATTR", __FILE__, __LINE__); \
} \
} \
} while (0)
/*
* public interfaces
*/
/* HEADERIZER BEGIN: src/packfile/object_serialization.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
PMC* Parrot_clone(PARROT_INTERP, ARGIN(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
STRING* Parrot_freeze(PARROT_INTERP, ARGIN(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
opcode_t * Parrot_freeze_pbc(PARROT_INTERP,
ARGIN(PMC *pmc),
ARGIN(const PackFile_ConstTable *pf),
ARGOUT(opcode_t *cursor),
ARGOUT(Hash **seen))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
__attribute__nonnull__(4)
__attribute__nonnull__(5)
FUNC_MODIFIES(*cursor)
FUNC_MODIFIES(*seen);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
UINTVAL Parrot_freeze_pbc_size(PARROT_INTERP,
ARGIN(PMC *pmc),
ARGIN(const PackFile_ConstTable *pf),
ARGOUT(Hash **seen))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
__attribute__nonnull__(4)
FUNC_MODIFIES(*seen);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC * Parrot_freeze_strings(PARROT_INTERP, ARGIN(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC * Parrot_thaw(PARROT_INTERP, ARGIN(STRING *image))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
PMC* Parrot_thaw_constants(PARROT_INTERP, ARGIN(STRING *image))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
PMC* Parrot_thaw_pbc(PARROT_INTERP,
ARGIN(PackFile_ConstTable *ct),
ARGMOD(const opcode_t **cursor))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(*cursor);
void Parrot_pf_verify_image_string(PARROT_INTERP, ARGIN(STRING *image))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
#define ASSERT_ARGS_Parrot_clone __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_Parrot_freeze __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_Parrot_freeze_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc) \
, PARROT_ASSERT_ARG(pf) \
, PARROT_ASSERT_ARG(cursor) \
, PARROT_ASSERT_ARG(seen))
#define ASSERT_ARGS_Parrot_freeze_pbc_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc) \
, PARROT_ASSERT_ARG(pf) \
, PARROT_ASSERT_ARG(seen))
#define ASSERT_ARGS_Parrot_freeze_strings __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_Parrot_thaw __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(image))
#define ASSERT_ARGS_Parrot_thaw_constants __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(image))
#define ASSERT_ARGS_Parrot_thaw_pbc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(ct) \
, PARROT_ASSERT_ARG(cursor))
#define ASSERT_ARGS_Parrot_pf_verify_image_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(image))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/packfile/object_serialization.c */
#endif /* PARROT_PMC_FREEZE_H_GUARD */
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
*/
|
7b6c8d5b5ad4a04860efc3c55042e2ab6d051df5
|
3afd7229cfff2da1b504cf33869f0397e7d72535
|
/src/wrapped/generated/wrappedatspitypes.h
|
3885e3924bbe99eefa8a9152ab0d21321247f87c
|
[
"MIT"
] |
permissive
|
ptitSeb/box64
|
ed62db37d8dd328316fef259be24ff95b9d785e7
|
7cba83231a0ca05a18bb6a07735ba8d5f0a216b6
|
refs/heads/main
| 2023-08-31T06:25:22.053788
| 2023-08-30T19:53:29
| 2023-08-30T19:53:29
| 317,493,442
| 2,317
| 197
|
MIT
| 2023-09-13T13:51:23
| 2020-12-01T09:42:50
|
C
|
UTF-8
|
C
| false
| false
| 577
|
h
|
wrappedatspitypes.h
|
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.2.0.18) *
*******************************************************************/
#ifndef __wrappedatspiTYPES_H_
#define __wrappedatspiTYPES_H_
#ifndef LIBNAME
#error You should only #include this file inside a wrapped*.c file
#endif
#ifndef ADDED_FUNCTIONS
#define ADDED_FUNCTIONS()
#endif
typedef void* (*pFppp_t)(void*, void*, void*);
#define SUPER() ADDED_FUNCTIONS() \
GO(atspi_event_listener_new, pFppp_t)
#endif // __wrappedatspiTYPES_H_
|
53e3642de2b8daea5073f7d084e9905035aacb18
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/lib/mesa/src/freedreno/ir3/ir3_nir_lower_tex_prefetch.c
|
ec987b79d2f096a51b39d2903869598a519ac0b9
|
[] |
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
| 7,663
|
c
|
ir3_nir_lower_tex_prefetch.c
|
/*
* Copyright © 2019 Igalia S.L.
*
* 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 (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 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 "ir3_nir.h"
/**
* A pass which detects tex instructions which are candidate to be executed
* prior to FS shader start, and change them to nir_texop_tex_prefetch.
*/
static int
coord_offset(nir_ssa_def *ssa)
{
nir_instr *parent_instr = ssa->parent_instr;
/* The coordinate of a texture sampling instruction eligible for
* pre-fetch is either going to be a load_interpolated_input/
* load_input, or a vec2 assembling non-swizzled components of
* a load_interpolated_input/load_input (due to varying packing)
*/
if (parent_instr->type == nir_instr_type_alu) {
nir_alu_instr *alu = nir_instr_as_alu(parent_instr);
if (alu->op != nir_op_vec2)
return -1;
if (!alu->src[0].src.is_ssa)
return -1;
int base_offset =
coord_offset(alu->src[0].src.ssa) + alu->src[0].swizzle[0];
/* NOTE it might be possible to support more than 2D? */
for (int i = 1; i < 2; i++) {
if (!alu->src[i].src.is_ssa)
return -1;
int nth_offset =
coord_offset(alu->src[i].src.ssa) + alu->src[i].swizzle[0];
if (nth_offset != (base_offset + i))
return -1;
}
return base_offset;
}
if (parent_instr->type != nir_instr_type_intrinsic)
return -1;
nir_intrinsic_instr *input = nir_instr_as_intrinsic(parent_instr);
if (input->intrinsic != nir_intrinsic_load_interpolated_input)
return -1;
/* limit to load_barycentric_pixel, other interpolation modes don't seem
* to be supported:
*/
if (!input->src[0].is_ssa)
return -1;
nir_intrinsic_instr *interp =
nir_instr_as_intrinsic(input->src[0].ssa->parent_instr);
if (interp->intrinsic != nir_intrinsic_load_barycentric_pixel)
return -1;
/* we also need a const input offset: */
if (!nir_src_is_const(input->src[1]))
return -1;
unsigned base = nir_src_as_uint(input->src[1]) + nir_intrinsic_base(input);
unsigned comp = nir_intrinsic_component(input);
return (4 * base) + comp;
}
int
ir3_nir_coord_offset(nir_ssa_def *ssa)
{
assert(ssa->num_components == 2);
return coord_offset(ssa);
}
static bool
has_src(nir_tex_instr *tex, nir_tex_src_type type)
{
return nir_tex_instr_src_index(tex, type) >= 0;
}
static bool
ok_bindless_src(nir_tex_instr *tex, nir_tex_src_type type)
{
int idx = nir_tex_instr_src_index(tex, type);
assert(idx >= 0);
nir_intrinsic_instr *bindless = ir3_bindless_resource(tex->src[idx].src);
/* TODO from SP_FS_BINDLESS_PREFETCH[n] it looks like this limit should
* be 1<<8 ?
*/
return nir_src_is_const(bindless->src[0]) &&
(nir_src_as_uint(bindless->src[0]) < (1 << 16));
}
/**
* Check that we will be able to encode the tex/samp parameters
* successfully. These limits are based on the layout of
* SP_FS_PREFETCH[n] and SP_FS_BINDLESS_PREFETCH[n], so at some
* point (if those regs changes) they may become generation
* specific.
*/
static bool
ok_tex_samp(nir_tex_instr *tex)
{
if (has_src(tex, nir_tex_src_texture_handle)) {
/* bindless case: */
assert(has_src(tex, nir_tex_src_sampler_handle));
return ok_bindless_src(tex, nir_tex_src_texture_handle) &&
ok_bindless_src(tex, nir_tex_src_sampler_handle);
} else {
assert(!has_src(tex, nir_tex_src_texture_offset));
assert(!has_src(tex, nir_tex_src_sampler_offset));
return (tex->texture_index <= 0x1f) && (tex->sampler_index <= 0xf);
}
}
static bool
lower_tex_prefetch_block(nir_block *block)
{
bool progress = false;
nir_foreach_instr_safe (instr, block) {
if (instr->type != nir_instr_type_tex)
continue;
nir_tex_instr *tex = nir_instr_as_tex(instr);
if (tex->op != nir_texop_tex)
continue;
if (has_src(tex, nir_tex_src_bias) || has_src(tex, nir_tex_src_lod) ||
has_src(tex, nir_tex_src_comparator) ||
has_src(tex, nir_tex_src_projector) ||
has_src(tex, nir_tex_src_offset) || has_src(tex, nir_tex_src_ddx) ||
has_src(tex, nir_tex_src_ddy) || has_src(tex, nir_tex_src_ms_index) ||
has_src(tex, nir_tex_src_texture_offset) ||
has_src(tex, nir_tex_src_sampler_offset))
continue;
/* only prefetch for simple 2d tex fetch case */
if (tex->sampler_dim != GLSL_SAMPLER_DIM_2D || tex->is_array)
continue;
if (!ok_tex_samp(tex))
continue;
int idx = nir_tex_instr_src_index(tex, nir_tex_src_coord);
/* First source should be the sampling coordinate. */
nir_tex_src *coord = &tex->src[idx];
assert(coord->src.is_ssa);
if (ir3_nir_coord_offset(coord->src.ssa) >= 0) {
tex->op = nir_texop_tex_prefetch;
progress |= true;
}
}
return progress;
}
static bool
lower_tex_prefetch_func(nir_function_impl *impl)
{
/* Only instructions in the the outer-most block are considered eligible for
* pre-dispatch, because they need to be move-able to the beginning of the
* shader to avoid locking down the register holding the pre-fetched result
* for too long. However if there is a preamble we should skip the preamble
* and only look in the first block after the preamble instead, because that
* corresponds to the first block in the original program and texture fetches
* in the preamble are never pre-dispatchable.
*/
nir_block *block = nir_start_block(impl);
nir_if *nif = nir_block_get_following_if(block);
if (nif) {
nir_instr *cond = nif->condition.ssa->parent_instr;
if (cond->type == nir_instr_type_intrinsic &&
nir_instr_as_intrinsic(cond)->intrinsic ==
nir_intrinsic_preamble_start_ir3) {
block = nir_cf_node_as_block(nir_cf_node_next(&nif->cf_node));
}
}
bool progress = lower_tex_prefetch_block(block);
if (progress) {
nir_metadata_preserve(impl,
nir_metadata_block_index | nir_metadata_dominance);
}
return progress;
}
bool
ir3_nir_lower_tex_prefetch(nir_shader *shader)
{
bool progress = false;
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
nir_foreach_function (function, shader) {
/* Only texture sampling instructions inside the main function
* are eligible for pre-dispatch.
*/
if (!function->impl || !function->is_entrypoint)
continue;
progress |= lower_tex_prefetch_func(function->impl);
}
return progress;
}
|
b5a31f84bae534e0f5ff8ba6e91aa9197d50bcf4
|
e1cddfd754d952134e72dfd03522c5ea4fb6008e
|
/src/plugins/rdma/test_api.c
|
e9d5fcaad98dda489c5142283a899834db5ce049
|
[
"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
| 6,878
|
c
|
test_api.c
|
/*
*------------------------------------------------------------------
* Copyright (c) 2019 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 <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlib/pci/pci.h>
#include <vnet/ethernet/ethernet.h>
#include <vat/vat.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vppinfra/error.h>
#include <rdma/rdma.h>
#define __plugin_msg_base rdma_test_main.msg_id_base
#include <vlibapi/vat_helper_macros.h>
/* declare message IDs */
#include <rdma/rdma.api_enum.h>
#include <rdma/rdma.api_types.h>
typedef struct
{
/* API message ID base */
u16 msg_id_base;
vat_main_t *vat_main;
} rdma_test_main_t;
rdma_test_main_t rdma_test_main;
static vl_api_rdma_mode_t
api_rdma_mode (rdma_mode_t mode)
{
switch (mode)
{
case RDMA_MODE_AUTO:
return RDMA_API_MODE_AUTO;
case RDMA_MODE_IBV:
return RDMA_API_MODE_IBV;
case RDMA_MODE_DV:
return RDMA_API_MODE_DV;
}
return ~0;
}
static vl_api_rdma_rss4_t
api_rdma_rss4 (rdma_rss4_t rss4)
{
switch (rss4)
{
case RDMA_RSS4_AUTO:
return RDMA_API_RSS4_AUTO;
case RDMA_RSS4_IP:
return RDMA_API_RSS4_IP;
case RDMA_RSS4_IP_UDP:
return RDMA_API_RSS4_IP_UDP;
case RDMA_RSS4_IP_TCP:
return RDMA_API_RSS4_IP_TCP;
}
return ~0;
}
static vl_api_rdma_rss6_t
api_rdma_rss6 (rdma_rss6_t rss6)
{
switch (rss6)
{
case RDMA_RSS6_AUTO:
return RDMA_API_RSS6_AUTO;
case RDMA_RSS6_IP:
return RDMA_API_RSS6_IP;
case RDMA_RSS6_IP_UDP:
return RDMA_API_RSS6_IP_UDP;
case RDMA_RSS6_IP_TCP:
return RDMA_API_RSS6_IP_TCP;
}
return ~0;
}
/* rdma create API */
static int
api_rdma_create (vat_main_t * vam)
{
vl_api_rdma_create_t *mp;
rdma_create_if_args_t args;
int ret;
if (!unformat_user (vam->input, unformat_rdma_create_if_args, &args))
{
clib_warning ("unknown input `%U'", format_unformat_error, vam->input);
return -99;
}
M (RDMA_CREATE, mp);
snprintf ((char *) mp->host_if, sizeof (mp->host_if), "%s", args.ifname);
snprintf ((char *) mp->name, sizeof (mp->name), "%s", args.name);
mp->rxq_num = clib_host_to_net_u16 (args.rxq_num);
mp->rxq_size = clib_host_to_net_u16 (args.rxq_size);
mp->txq_size = clib_host_to_net_u16 (args.txq_size);
mp->mode = api_rdma_mode (args.mode);
S (mp);
W (ret);
return ret;
}
static int
api_rdma_create_v2 (vat_main_t * vam)
{
vl_api_rdma_create_v2_t *mp;
rdma_create_if_args_t args;
int ret;
if (!unformat_user (vam->input, unformat_rdma_create_if_args, &args))
{
clib_warning ("unknown input `%U'", format_unformat_error, vam->input);
return -99;
}
M (RDMA_CREATE_V2, mp);
snprintf ((char *) mp->host_if, sizeof (mp->host_if), "%s", args.ifname);
if (args.name)
snprintf ((char *) mp->name, sizeof (mp->name), "%s", args.name);
else
mp->name[0] = 0;
mp->rxq_num = clib_host_to_net_u16 (args.rxq_num);
mp->rxq_size = clib_host_to_net_u16 (args.rxq_size);
mp->txq_size = clib_host_to_net_u16 (args.txq_size);
mp->mode = api_rdma_mode (args.mode);
mp->no_multi_seg = args.no_multi_seg;
mp->max_pktlen = clib_host_to_net_u16 (args.max_pktlen);
S (mp);
W (ret);
return ret;
}
static int
api_rdma_create_v3 (vat_main_t *vam)
{
vl_api_rdma_create_v3_t *mp;
rdma_create_if_args_t args;
int ret;
if (!unformat_user (vam->input, unformat_rdma_create_if_args, &args))
{
clib_warning ("unknown input `%U'", format_unformat_error, vam->input);
return -99;
}
M (RDMA_CREATE_V3, mp);
snprintf ((char *) mp->host_if, sizeof (mp->host_if), "%s", args.ifname);
if (args.name)
snprintf ((char *) mp->name, sizeof (mp->name), "%s", args.name);
else
mp->name[0] = 0;
mp->rxq_num = clib_host_to_net_u16 (args.rxq_num);
mp->rxq_size = clib_host_to_net_u16 (args.rxq_size);
mp->txq_size = clib_host_to_net_u16 (args.txq_size);
mp->mode = api_rdma_mode (args.mode);
mp->no_multi_seg = args.no_multi_seg;
mp->max_pktlen = clib_host_to_net_u16 (args.max_pktlen);
mp->rss4 = api_rdma_rss4 (args.rss4);
mp->rss6 = api_rdma_rss6 (args.rss6);
S (mp);
W (ret);
return ret;
}
/* rdma-create reply handler */
static void
vl_api_rdma_create_reply_t_handler (vl_api_rdma_create_reply_t * mp)
{
vat_main_t *vam = rdma_test_main.vat_main;
i32 retval = ntohl (mp->retval);
if (retval == 0)
{
fformat (vam->ofp, "created rdma with sw_if_index %d\n",
ntohl (mp->sw_if_index));
}
vam->retval = retval;
vam->result_ready = 1;
vam->regenerate_interface_table = 1;
}
/* rdma-create reply handler */
static void
vl_api_rdma_create_v2_reply_t_handler (vl_api_rdma_create_v2_reply_t * mp)
{
vat_main_t *vam = rdma_test_main.vat_main;
i32 retval = ntohl (mp->retval);
if (retval == 0)
{
fformat (vam->ofp, "created rdma with sw_if_index %d\n",
ntohl (mp->sw_if_index));
}
vam->retval = retval;
vam->result_ready = 1;
vam->regenerate_interface_table = 1;
}
/* rdma-create reply handler v3 */
static void
vl_api_rdma_create_v3_reply_t_handler (vl_api_rdma_create_v3_reply_t *mp)
{
vat_main_t *vam = rdma_test_main.vat_main;
i32 retval = ntohl (mp->retval);
if (retval == 0)
{
fformat (vam->ofp, "created rdma with sw_if_index %d\n",
ntohl (mp->sw_if_index));
}
vam->retval = retval;
vam->result_ready = 1;
vam->regenerate_interface_table = 1;
}
/* rdma delete API */
static int
api_rdma_delete (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
vl_api_rdma_delete_t *mp;
u32 sw_if_index = 0;
u8 index_defined = 0;
int ret;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "sw_if_index %u", &sw_if_index))
index_defined = 1;
else
{
clib_warning ("unknown input '%U'", format_unformat_error, i);
return -99;
}
}
if (!index_defined)
{
errmsg ("missing sw_if_index\n");
return -99;
}
M (RDMA_DELETE, mp);
mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
S (mp);
W (ret);
return ret;
}
#include <rdma/rdma.api_test.c>
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|
9f78e9e58ea65c1401d99b6a84721c141933b03d
|
3cd3872acbc8b1a79a70b89b2fd58a171e7adc82
|
/vpx_dsp/loongarch/quantize_lsx.c
|
77be0bb4fe68efb3b841434671be562df7d4e5b0
|
[] |
permissive
|
webmproject/libvpx
|
58ab97861063cb521ec0d00ef9cb222ca97873b1
|
6fd360c684736e351160b131827dfbb207841164
|
refs/heads/main
| 2023-04-09T15:32:34.688724
| 2023-04-07T22:19:18
| 2023-04-07T22:19:18
| 22,927,608
| 889
| 376
|
BSD-3-Clause
| 2023-03-24T13:37:34
| 2014-08-13T19:03:21
|
C
|
UTF-8
|
C
| false
| false
| 8,968
|
c
|
quantize_lsx.c
|
/*
* Copyright (c) 2022 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "./vpx_config.h"
#include "./vpx_dsp_rtcd.h"
#include "vpx_util/loongson_intrinsics.h"
static INLINE __m128i calculate_qcoeff(__m128i coeff, __m128i coeff_abs,
__m128i round, __m128i quant,
__m128i shift, __m128i cmp_mask) {
__m128i rounded, qcoeff;
rounded = __lsx_vsadd_h(coeff_abs, round);
qcoeff = __lsx_vmuh_h(rounded, quant);
qcoeff = __lsx_vadd_h(rounded, qcoeff);
qcoeff = __lsx_vmuh_h(qcoeff, shift);
qcoeff = __lsx_vsigncov_h(coeff, qcoeff);
qcoeff = __lsx_vand_v(qcoeff, cmp_mask);
return qcoeff;
}
static INLINE void calculate_dqcoeff_and_store(__m128i qcoeff, __m128i dequant,
int16_t *dqcoeff) {
__m128i dqcoeff16 = __lsx_vmul_h(qcoeff, dequant);
__lsx_vst(dqcoeff16, dqcoeff, 0);
}
static INLINE void calculate_dqcoeff_and_store_32x32(__m128i qcoeff,
__m128i dequant,
int16_t *dqcoeff) {
// Un-sign to bias rounding like C.
__m128i low, high, dqcoeff32_0, dqcoeff32_1, res;
__m128i zero = __lsx_vldi(0);
__m128i coeff = __lsx_vabsd_h(qcoeff, zero);
const __m128i sign_0 = __lsx_vilvl_h(qcoeff, zero);
const __m128i sign_1 = __lsx_vilvh_h(qcoeff, zero);
low = __lsx_vmul_h(coeff, dequant);
high = __lsx_vmuh_h(coeff, dequant);
dqcoeff32_0 = __lsx_vilvl_h(high, low);
dqcoeff32_1 = __lsx_vilvh_h(high, low);
// "Divide" by 2.
dqcoeff32_0 = __lsx_vsrai_w(dqcoeff32_0, 1);
dqcoeff32_1 = __lsx_vsrai_w(dqcoeff32_1, 1);
dqcoeff32_0 = __lsx_vsigncov_w(sign_0, dqcoeff32_0);
dqcoeff32_1 = __lsx_vsigncov_w(sign_1, dqcoeff32_1);
res = __lsx_vpickev_h(dqcoeff32_1, dqcoeff32_0);
__lsx_vst(res, dqcoeff, 0);
}
static INLINE __m128i scan_for_eob(__m128i coeff0, __m128i coeff1,
const int16_t *scan, int index,
__m128i zero) {
const __m128i zero_coeff0 = __lsx_vseq_h(coeff0, zero);
const __m128i zero_coeff1 = __lsx_vseq_h(coeff1, zero);
__m128i scan0 = __lsx_vld(scan + index, 0);
__m128i scan1 = __lsx_vld(scan + index + 8, 0);
__m128i eob0, eob1;
eob0 = __lsx_vandn_v(zero_coeff0, scan0);
eob1 = __lsx_vandn_v(zero_coeff1, scan1);
return __lsx_vmax_h(eob0, eob1);
}
static INLINE int16_t accumulate_eob(__m128i eob) {
__m128i eob_shuffled;
int16_t res_m;
eob_shuffled = __lsx_vshuf4i_w(eob, 0xe);
eob = __lsx_vmax_h(eob, eob_shuffled);
eob_shuffled = __lsx_vshuf4i_h(eob, 0xe);
eob = __lsx_vmax_h(eob, eob_shuffled);
eob_shuffled = __lsx_vshuf4i_h(eob, 0x1);
eob = __lsx_vmax_h(eob, eob_shuffled);
res_m = __lsx_vpickve2gr_h(eob, 1);
return res_m;
}
#if !CONFIG_VP9_HIGHBITDEPTH
void vpx_quantize_b_lsx(const int16_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, int16_t *qcoeff_ptr,
int16_t *dqcoeff_ptr, const int16_t *dequant_ptr,
uint16_t *eob_ptr, const int16_t *scan,
const int16_t *iscan) {
__m128i zero = __lsx_vldi(0);
int index = 16;
__m128i zbin, round, quant, dequant, quant_shift;
__m128i coeff0, coeff1;
__m128i qcoeff0, qcoeff1;
__m128i cmp_mask0, cmp_mask1;
__m128i eob, eob0;
(void)scan;
zbin = __lsx_vld(zbin_ptr, 0);
round = __lsx_vld(round_ptr, 0);
quant = __lsx_vld(quant_ptr, 0);
dequant = __lsx_vld(dequant_ptr, 0);
quant_shift = __lsx_vld(quant_shift_ptr, 0);
// Handle one DC and first 15 AC.
DUP2_ARG2(__lsx_vld, coeff_ptr, 0, coeff_ptr, 16, coeff0, coeff1);
qcoeff0 = __lsx_vabsd_h(coeff0, zero);
qcoeff1 = __lsx_vabsd_h(coeff1, zero);
cmp_mask0 = __lsx_vsle_h(zbin, qcoeff0);
zbin = __lsx_vilvh_d(zbin, zbin);
cmp_mask1 = __lsx_vsle_h(zbin, qcoeff1);
qcoeff0 =
calculate_qcoeff(coeff0, qcoeff0, round, quant, quant_shift, cmp_mask0);
round = __lsx_vilvh_d(round, round);
quant = __lsx_vilvh_d(quant, quant);
quant_shift = __lsx_vilvh_d(quant_shift, quant_shift);
qcoeff1 =
calculate_qcoeff(coeff1, qcoeff1, round, quant, quant_shift, cmp_mask1);
__lsx_vst(qcoeff0, qcoeff_ptr, 0);
__lsx_vst(qcoeff1, qcoeff_ptr, 16);
calculate_dqcoeff_and_store(qcoeff0, dequant, dqcoeff_ptr);
dequant = __lsx_vilvh_d(dequant, dequant);
calculate_dqcoeff_and_store(qcoeff1, dequant, dqcoeff_ptr + 8);
eob = scan_for_eob(qcoeff0, qcoeff1, iscan, 0, zero);
// AC only loop.
while (index < n_coeffs) {
coeff0 = __lsx_vld(coeff_ptr + index, 0);
coeff1 = __lsx_vld(coeff_ptr + index + 8, 0);
qcoeff0 = __lsx_vabsd_h(coeff0, zero);
qcoeff1 = __lsx_vabsd_h(coeff1, zero);
cmp_mask0 = __lsx_vsle_h(zbin, qcoeff0);
cmp_mask1 = __lsx_vsle_h(zbin, qcoeff1);
qcoeff0 =
calculate_qcoeff(coeff0, qcoeff0, round, quant, quant_shift, cmp_mask0);
qcoeff1 =
calculate_qcoeff(coeff1, qcoeff1, round, quant, quant_shift, cmp_mask1);
__lsx_vst(qcoeff0, qcoeff_ptr + index, 0);
__lsx_vst(qcoeff1, qcoeff_ptr + index + 8, 0);
calculate_dqcoeff_and_store(qcoeff0, dequant, dqcoeff_ptr + index);
calculate_dqcoeff_and_store(qcoeff1, dequant, dqcoeff_ptr + index + 8);
eob0 = scan_for_eob(qcoeff0, qcoeff1, iscan, index, zero);
eob = __lsx_vmax_h(eob, eob0);
index += 16;
}
*eob_ptr = accumulate_eob(eob);
}
void vpx_quantize_b_32x32_lsx(const int16_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
__m128i zero = __lsx_vldi(0);
int index;
__m128i zbin, round, quant, dequant, quant_shift;
__m128i coeff0, coeff1, qcoeff0, qcoeff1, cmp_mask0, cmp_mask1;
__m128i eob = zero, eob0;
(void)scan;
(void)n_coeffs;
zbin = __lsx_vld(zbin_ptr, 0);
zbin = __lsx_vsrari_h(zbin, 1);
round = __lsx_vld(round_ptr, 0);
round = __lsx_vsrari_h(round, 1);
quant = __lsx_vld(quant_ptr, 0);
dequant = __lsx_vld(dequant_ptr, 0);
quant_shift = __lsx_vld(quant_shift_ptr, 0);
quant_shift = __lsx_vslli_h(quant_shift, 1);
// Handle one DC and first 15 AC.
DUP2_ARG2(__lsx_vld, coeff_ptr, 0, coeff_ptr, 16, coeff0, coeff1);
qcoeff0 = __lsx_vabsd_h(coeff0, zero);
qcoeff1 = __lsx_vabsd_h(coeff1, zero);
cmp_mask0 = __lsx_vsle_h(zbin, qcoeff0);
// remove DC from zbin
zbin = __lsx_vilvh_d(zbin, zbin);
cmp_mask1 = __lsx_vsle_h(zbin, qcoeff1);
qcoeff0 =
calculate_qcoeff(coeff0, qcoeff0, round, quant, quant_shift, cmp_mask0);
// remove DC in quant_shift, quant, quant_shift
round = __lsx_vilvh_d(round, round);
quant = __lsx_vilvh_d(quant, quant);
quant_shift = __lsx_vilvh_d(quant_shift, quant_shift);
qcoeff1 =
calculate_qcoeff(coeff1, qcoeff1, round, quant, quant_shift, cmp_mask1);
__lsx_vst(qcoeff0, qcoeff_ptr, 0);
__lsx_vst(qcoeff1, qcoeff_ptr, 16);
calculate_dqcoeff_and_store_32x32(qcoeff0, dequant, dqcoeff_ptr);
dequant = __lsx_vilvh_d(dequant, dequant);
calculate_dqcoeff_and_store_32x32(qcoeff1, dequant, dqcoeff_ptr + 8);
eob = scan_for_eob(qcoeff0, qcoeff1, iscan, 0, zero);
// AC only loop.
for (index = 16; index < 32 * 32; index += 16) {
coeff0 = __lsx_vld(coeff_ptr + index, 0);
coeff1 = __lsx_vld(coeff_ptr + index + 8, 0);
qcoeff0 = __lsx_vabsd_h(coeff0, zero);
qcoeff1 = __lsx_vabsd_h(coeff1, zero);
cmp_mask0 = __lsx_vsle_h(zbin, qcoeff0);
cmp_mask1 = __lsx_vsle_h(zbin, qcoeff1);
qcoeff0 =
calculate_qcoeff(coeff0, qcoeff0, round, quant, quant_shift, cmp_mask0);
qcoeff1 =
calculate_qcoeff(coeff1, qcoeff1, round, quant, quant_shift, cmp_mask1);
__lsx_vst(qcoeff0, qcoeff_ptr + index, 0);
__lsx_vst(qcoeff1, qcoeff_ptr + index + 8, 0);
calculate_dqcoeff_and_store_32x32(qcoeff0, dequant, dqcoeff_ptr + index);
calculate_dqcoeff_and_store_32x32(qcoeff1, dequant,
dqcoeff_ptr + 8 + index);
eob0 = scan_for_eob(qcoeff0, qcoeff1, iscan, index, zero);
eob = __lsx_vmax_h(eob, eob0);
}
*eob_ptr = accumulate_eob(eob);
}
#endif
|
2f9ebc5029172e584d300801575faf7bf9d05b0e
|
de22e1e826e75096c32fd4685b377e2e750f94c8
|
/tests/thread-regions-test-files/pthread_exit.c
|
c8cad0609c2d67e4b5cfc3340039acb428dc160e
|
[
"MIT"
] |
permissive
|
mchalupa/dg
|
bb1430ebe5c9957d5f1b1278567674bdc03546ce
|
df6e4e23d2a0740ec9d9fa38e80032bd80556c95
|
refs/heads/master
| 2023-09-05T02:57:01.261394
| 2022-06-29T12:53:04
| 2022-12-19T10:12:03
| 31,018,102
| 458
| 146
|
MIT
| 2023-05-02T12:43:24
| 2015-02-19T14:12:47
|
C++
|
UTF-8
|
C
| false
| false
| 709
|
c
|
pthread_exit.c
|
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
void *func(void *ptr) {
int *x = (int *) ptr;
int *ret = (int *) malloc(sizeof(int));
int *ret1 = (int *) malloc(sizeof(int));
*ret1 = 100;
*x += 1;
if (*x == 1) {
*ret = 42;
pthread_exit(ret);
} else if (*x == 2) {
pthread_exit(ret1);
}
free(ret);
pthread_exit(NULL);
}
int (*ptr)(pthread_t *, const pthread_attr_t *, void *(*) (void *), void *);
int main() {
int x = 0;
int y = 0;
void *ret_val;
ptr = &pthread_create;
pthread_t thread_func;
ptr(&thread_func, NULL, func, &x);
pthread_join(thread_func, &ret_val);
free(ret_val);
return 0;
}
|
d4bc2729b9f38bea0d1e88b9fb5861e592b71511
|
07bbe7a0a829cfbc9789831d981aedf36e4e94d9
|
/source/lexbor/dom/collection.c
|
f9757542040448a97df016888dd9e3fb9c16b5c3
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
lexbor/lexbor
|
0bf3a22898d8e295fa20cc1391e31a68502c458a
|
31e3d9d7f9032cd475d5afa788999de2d4b891dd
|
refs/heads/master
| 2023-08-31T23:25:49.903737
| 2023-08-30T08:25:12
| 2023-08-30T08:25:12
| 122,375,902
| 758
| 95
|
Apache-2.0
| 2023-08-30T08:25:13
| 2018-02-21T18:28:52
|
C
|
UTF-8
|
C
| false
| false
| 1,975
|
c
|
collection.c
|
/*
* Copyright (C) 2018-2022 Alexander Borisov
*
* Author: Alexander Borisov <borisov@lexbor.com>
*/
#include "lexbor/dom/collection.h"
#include "lexbor/dom/interfaces/document.h"
lxb_dom_collection_t *
lxb_dom_collection_create(lxb_dom_document_t *document)
{
lxb_dom_collection_t *col;
col = lexbor_calloc(1, sizeof(lxb_dom_collection_t));
if (col == NULL) {
return NULL;
}
col->document = document;
return col;
}
lxb_status_t
lxb_dom_collection_init(lxb_dom_collection_t *col, size_t start_list_size)
{
if (col == NULL) {
return LXB_STATUS_ERROR_WRONG_ARGS;
}
if (col->document == NULL) {
return LXB_STATUS_ERROR_INCOMPLETE_OBJECT;
}
return lexbor_array_init(&col->array, start_list_size);
}
lxb_dom_collection_t *
lxb_dom_collection_destroy(lxb_dom_collection_t *col, bool self_destroy)
{
if (col == NULL) {
return NULL;
}
if (col->array.list != NULL) {
lexbor_array_destroy(&col->array, false);
col->array.list = NULL;
}
if (self_destroy) {
return lexbor_free(col);
}
return col;
}
/*
* No inline functions for ABI.
*/
lxb_dom_collection_t *
lxb_dom_collection_make_noi(lxb_dom_document_t *document, size_t start_list_size)
{
return lxb_dom_collection_make(document, start_list_size);
}
void
lxb_dom_collection_clean_noi(lxb_dom_collection_t *col)
{
lxb_dom_collection_clean(col);
}
lxb_status_t
lxb_dom_collection_append_noi(lxb_dom_collection_t *col, void *value)
{
return lxb_dom_collection_append(col, value);
}
lxb_dom_element_t *
lxb_dom_collection_element_noi(lxb_dom_collection_t *col, size_t idx)
{
return lxb_dom_collection_element(col, idx);
}
lxb_dom_node_t *
lxb_dom_collection_node_noi(lxb_dom_collection_t *col, size_t idx)
{
return lxb_dom_collection_node(col, idx);
}
size_t
lxb_dom_collection_length_noi(lxb_dom_collection_t *col)
{
return lxb_dom_collection_length(col);
}
|
f0b8feaaa2c50285e92e2933e1ef3c09201bd685
|
de21f9075f55640514c29ef0f1fe3f0690845764
|
/regression/ansi-c/goto_convert_switch_range_operands_count/main.c
|
7a55305218266cc6fa4517641eab4f5ff31f24ec
|
[
"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
| 109
|
c
|
main.c
|
int main()
{
int x;
switch(x)
{
case 0 ... 10 20:
break;
default:
break;
}
return 0;
}
|
65b193692ccbb66dd0ffbc8b257cf7577487c158
|
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
|
/src/coreclr/inc/optdefault.h
|
af504b660d3efcf32a5a971ade64819f713af142
|
[
"MIT"
] |
permissive
|
dotnet/runtime
|
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
|
47bb554d298e1e34c4e3895d7731e18ad1c47d02
|
refs/heads/main
| 2023-09-03T15:35:46.493337
| 2023-09-03T08:13:23
| 2023-09-03T08:13:23
| 210,716,005
| 13,765
| 5,179
|
MIT
| 2023-09-14T21:58:52
| 2019-09-24T23:36:39
|
C#
|
UTF-8
|
C
| false
| false
| 246
|
h
|
optdefault.h
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// Revert optimizations back to default
//
#undef FPO_ON
#ifdef _MSC_VER
#pragma optimize("",on)
#endif
|
8c2c5e10cc741655b3c81b968be124bf545cce91
|
19a9f2c19bcb81c4a14ba17831d3098de7731fb5
|
/ni/src/lib/nfp/gausW.c
|
9a523fdc2b7b22b1c5aa17af3e35604c269488bc
|
[
"Apache-2.0"
] |
permissive
|
NCAR/ncl
|
243c30eaefce642d53373aa583b73df72eb59f22
|
8a96101fe14d0cf0f5ed66a5e6b1733084bc69df
|
refs/heads/develop
| 2023-03-17T07:53:18.883458
| 2022-05-11T16:01:03
| 2022-05-11T16:01:03
| 67,087,395
| 254
| 68
|
NOASSERTION
| 2022-10-08T07:20:06
| 2016-09-01T01:34:28
|
C
|
UTF-8
|
C
| false
| false
| 3,364
|
c
|
gausW.c
|
#include <stdio.h>
#include "wrapper.h"
extern void NGCALLF(gauslobat,GAUSLOBAT)(double*,double*,int*);
extern void NGCALLF(findglw,FINDGLW)(double*,double*,int*);
NhlErrorTypes gaus_lobat_W( void )
{
/*
* Input array variables
*/
void *N;
ng_size_t *npts;
int inpts;
NclBasicDataTypes type_N;
/*
* Output array variables
*/
ng_size_t i, dsizes_output[2];
double *xgl, *wgt, *output;
int ret;
/*
* Retrieve arguments.
*/
N = (void*)NclGetArgValue(
0,
1,
NULL,
NULL,
NULL,
NULL,
&type_N,
DONT_CARE);
/*
* Check the input dimension size.
*/
npts = get_dimensions(N,1,type_N,"gaus_lobat");
if(npts == NULL)
return(NhlFATAL);
if( *npts < 1) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"gaus_lobat: npts must be at least 1");
return(NhlFATAL);
}
if( *npts > INT_MAX) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"gaus_lobat: npts is greater than INT_MAX");
return(NhlFATAL);
}
inpts = (int) *npts;
/*
* Allocate space for output array
*/
xgl = (double*)calloc(*npts,sizeof(double));
wgt = (double*)calloc(*npts,sizeof(double));
output = (double*)calloc(*npts*2,sizeof(double));
if( xgl == NULL || wgt == NULL || output == NULL) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"gaus_lobat: Unable to allocate memory for output array");
return(NhlFATAL);
}
/*
* Call the Fortran version of this routine.
*/
NGCALLF(gauslobat,GAUSLOBAT)(xgl,wgt,&inpts);
for( i = 0; i < *npts; i++ ) {
output[2*i] = xgl[i];
output[2*i+1] = wgt[i];
}
NclFree(xgl);
NclFree(wgt);
dsizes_output[0] = *npts;
dsizes_output[1] = 2;
ret = NclReturnValue((void*)output,2,dsizes_output,NULL,NCL_double,0);
NclFree(npts);
return(ret);
}
NhlErrorTypes gaus_lobat_wgt_W( void )
{
/*
* Input array variables
*/
void *lat;
double *tmp_lat;
ng_size_t dsizes_lat[1];
NclBasicDataTypes type_lat;
/*
* Output array variables
*/
double *wgt;
ng_size_t dsizes_wgt[1];
/*
* Declare various variables for random purposes.
*/
ng_size_t npts;
int inpts;
/*
* Retrieve arguments.
*/
lat = (void*)NclGetArgValue(
0,
1,
NULL,
dsizes_lat,
NULL,
NULL,
&type_lat,
DONT_CARE);
if( dsizes_lat[0] > INT_MAX) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"gaus_lobat_wgt: the length of lat is greater than INT_MAX");
return(NhlFATAL);
}
npts = dsizes_lat[0];
inpts = (int) npts;
/*
* Coerce data to double no matter what, since input array may get
* changed by Fortran routine.
*/
tmp_lat = (double*)calloc(npts,sizeof(double));
if( tmp_lat == NULL ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"gaus_lobat_wgt: Unable to allocate memory for making a copy of the input array");
return(NhlFATAL);
}
coerce_subset_input_double(lat,tmp_lat,0,type_lat,npts,0,NULL,NULL);
/*
* Allocate space for output array
*/
wgt = (double*)calloc(npts,sizeof(double));
if( wgt == NULL ) {
NhlPError(NhlFATAL,NhlEUNKNOWN,"gaus_lobat_wgt: Unable to allocate memory for output array");
return(NhlFATAL);
}
/*
* Call the Fortran version of this routine.
*/
NGCALLF(findglw,FINDGLW)(tmp_lat,wgt,&inpts);
/*
* Free memory.
*/
NclFree(tmp_lat);
dsizes_wgt[0] = npts;
return(NclReturnValue(wgt,1,dsizes_wgt,NULL,NCL_double,0));
}
|
901a9e827fe80a76c26d9ca56320448b4af45c47
|
1c90c9a656cf14fa877957c7504e67665d961733
|
/tests/feature_tests/bool.c
|
fc1563fb35c10a200f886f09a21cb9e8193801b2
|
[
"MIT"
] |
permissive
|
ShivamSarodia/ShivyC
|
dd5d1161d6da78491386c5f0a4ebcbca7ee506dd
|
6232136be38a29e8c18beae3d23e49ecfb7906fd
|
refs/heads/master
| 2023-05-25T01:38:55.008484
| 2023-05-23T06:44:15
| 2023-05-23T06:44:15
| 63,022,542
| 1,072
| 97
|
MIT
| 2023-05-23T06:44:16
| 2016-07-10T23:16:02
|
Python
|
UTF-8
|
C
| false
| false
| 743
|
c
|
bool.c
|
int main() {
if((3 && 4) != 1) return 1;
if((0 && 4) != 0) return 2;
if(0 && 4) return 3;
if((3 && 0) != 0) return 4;
if(3 && 0) return 5;
int a, *p = &a;
if((p && 0) != 0) return 6;
if(p && 0) return 7;
if((p && p) != 1) return 8;
if((3 || 4) != 1) return 9;
if((0 || 4) != 1) return 10;
if((2 || 0) != 1) return 11;
if((0 || 0) != 0) return 12;
if(0 || 0) return 13;
if((0 || 0) != 0) return 12;
if((p || 0) != 1) return 14;
if((p || p) != 1) return 15;
if(!p != 0) return 16;
if(!p) return 16;
if(!0 != 1) return 17;
int n = 0;
0 && (n = 1);
if(n == 1) return 18;
(n = 1) && 0;
if(n != 1) return 19;
1 || (n = 3);
if(n == 3) return 20;
(n = 3) || 1;
if(n != 3) return 21;
}
|
b47e60e980cce51b328aa51810fa10081fe220d9
|
da1500e0d3040497614d5327d2461a22e934b4d8
|
/net/third_party/quiche/src/http2/platform/api/http2_flags.h
|
08f95da687f171db4908d416eec811069f0e2292
|
[
"BSD-3-Clause"
] |
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
| 531
|
h
|
http2_flags.h
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef QUICHE_HTTP2_PLATFORM_API_HTTP2_FLAGS_H_
#define QUICHE_HTTP2_PLATFORM_API_HTTP2_FLAGS_H_
#include "net/http2/platform/impl/http2_flags_impl.h"
#define GetHttp2ReloadableFlag(flag) GetHttp2ReloadableFlagImpl(flag)
#define SetHttp2ReloadableFlag(flag, value) \
SetHttp2ReloadableFlagImpl(flag, value)
#endif // QUICHE_HTTP2_PLATFORM_API_HTTP2_FLAGS_H_
|
4350007158ebadf1c39416844cb8062f40cc9e72
|
2249ea163713b21f14fdf8784ba3ef3c0b540d1a
|
/lib/nauty/gtools.c
|
9b594168e7dfb74abacb20ab687fb580560174c9
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] |
permissive
|
lsils/mockturtle
|
58c106fc957f17206e062b5428055778c68b4a69
|
82fce07b7204b14fc4c53fd35c284b7ea68f05fd
|
refs/heads/master
| 2023-08-31T04:18:37.954364
| 2023-08-24T12:05:37
| 2023-08-24T12:05:37
| 131,001,448
| 159
| 80
|
MIT
| 2023-08-24T09:43:55
| 2018-04-25T12:15:49
|
C++
|
UTF-8
|
C
| false
| false
| 70,108
|
c
|
gtools.c
|
/* gtools.c : Common routines for gtools programs. */
/* Version 4.2, Oct 2017. */
/* Todo: size check if MAXN>0; option to free memory */
#include "gtools.h"
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif
TLS_ATTR size_t ogf_linelen;
TLS_ATTR boolean is_pipe;
#if HAVE_FSEEKO
#define FSEEK_VER fseeko
#define FTELL_VER ftello
#define OFF_T_VER off_t
#else
#if !FTELL_DEC
extern long ftell(FILE*);
extern int fseek(FILE*,long,int);
#endif
#define FSEEK_VER fseek
#define FTELL_VER ftell
#define OFF_T_VER long
#endif
#if !POPEN_DEC
extern FILE *popen(const char*,const char*);
#endif
/*
Version 1.1: Fixed sparse6 input for powers of 2. May 9, 1998
Version 1.2: Added "cmd: ..." option for opengraphfile().
Fixed readg() bug (could not be invisible). Oct 5, 1998
Version 1.3: Added "is_pipe". June 20, 2002
Version 1.4: Stuff for autoconf. August 30, 2002
Version 1.5: Unlocked stdio for efficiency. October 31, 2004
Also fwrite() in place of fputs() for writeline().
Version 1.6: i/o for sparsegraph; use of s6len; improve allocations
Version 1.7: Add stringcounts()
Add very long size code (see formats.txt)
Version 1.8: Add gtools_check()
Version 1.9: Add writepc_sg(), readpc_sg() and readpcle_sg()
Add planar_code options to opengraphfile()
Version 2.4: Add writeec_sg(), readec_sg() (MISSING!)
Add edge_code options to opengraphfile()
Version 2.5: Remove sortints(), not used
Version 2.6: Add sgtog6() and writeg6_sg()
Version 2.7: Add lots of explicit casts.
Fix planar code output for n > 255.
Version 3.0: Procedures for incremental sparse6 format.
Add checkgline()
Version 4.0: Procedures for digraph6 format.
Version 4.1: Made encodegraphsize() external.
Version 4.2: Fixes for null graphs; thanks to Kevin Ryde.
*/
#define B(i) (1 << ((i)-1))
#define M(i) ((1 << (i))-1)
/*********************************************************************
opengraphfile(filename,codetype,assumefixed,position)
opens and positions a file for reading graphs.
filename = the name of the file to open
(NULL means stdin, assumed already open)
If filename starts with "cmd:", the remainder is taken
to be a command to open a subshell for, using a pipe.
codetype = returns a code for the format.
This is a combination of SPARSE6, GRAPH6, PLANARCODE,
PLANARCODELE, PLANARCODEBE, EDGECODE, DIGRAPH6,
UNKNOWN_TYPE and HAS_HEADER.
If a header is present, that overrides the data.
If there is no header, the first graph is examined.
assumefixed = nonzero if files other than stdin or pipes should be
assumed to be seekable and have equal record sizes.
Ignored if there is a sparse6 header or the first
graph has sparse6 format.
position = the number of the record to position to
(the first is number 1; 0 and -NOLIMIT also mean
to position at start). planar_code files can only
be positioned at the start.
If the file starts with ">", there must be a header.
Otherwise opengraphfile() fails.
The value returned is a file pointer or NULL.
If assumedfixed is not zero and position > 1, the global variable
ogf_linelen is set to the length (including \n) of the length of the
first record. UPDATE
The global variable is_pipe is set to whether the input file is a pipe.
**********************************************************************/
FILE*
opengraphfile(char *filename, int *codetype, int assumefixed, long position)
{
FILE *f;
int c,bl,firstc;
long i,l;
OFF_T_VER pos,pos1,pos2;
boolean bad_header;
is_pipe = FALSE;
if (filename == NULL)
{
f = stdin;
assumefixed = FALSE;
}
else
{
if (filename[0] == 'c' && filename[1] == 'm'
&& filename[2] == 'd' && filename[3] == ':')
{
#if !HAVE_POPEN
gt_abort
(">E The \"cmd:\" option is not available in this version.\n");
#else
filename += 4;
while (*filename == ' ') ++filename;
f = popen(filename,"r");
#endif
assumefixed = FALSE;
is_pipe = TRUE;
}
else
f = fopen(filename,"r");
if (f == NULL)
{
fprintf(stderr,">E opengraphfile: can't open %s\n",filename);
return NULL;
}
}
FLOCKFILE(f);
firstc = c = GETC(f);
if (c == EOF)
{
*codetype = GRAPH6;
FUNLOCKFILE(f);
return f;
}
if (c != '>')
{
*codetype = firstc == ':' ? SPARSE6 : firstc == '&' ? DIGRAPH6 : GRAPH6;
ungetc(c,f);
}
else
{
bad_header = FALSE;
if ((c = GETC(f)) == EOF || c != '>')
bad_header = TRUE;
if (!bad_header && ((c = GETC(f)) == EOF ||
(c != 'g' && c != 's' && c != 'p')))
bad_header = TRUE;
if (!bad_header && c == 'g')
{
if ((c = GETC(f)) == EOF || c != 'r' ||
(c = GETC(f)) == EOF || c != 'a' ||
(c = GETC(f)) == EOF || c != 'p' ||
(c = GETC(f)) == EOF || c != 'h' ||
(c = GETC(f)) == EOF || c != '6' ||
(c = GETC(f)) == EOF || c != '<' ||
(c = GETC(f)) == EOF || c != '<')
bad_header = TRUE;
else
*codetype = GRAPH6 | HAS_HEADER;
}
else if (!bad_header && c == 'd')
{
if ((c = GETC(f)) == EOF || c != 'i' ||
(c = GETC(f)) == EOF || c != 'g' ||
(c = GETC(f)) == EOF || c != 'r' ||
(c = GETC(f)) == EOF || c != 'a' ||
(c = GETC(f)) == EOF || c != 'p' ||
(c = GETC(f)) == EOF || c != 'h' ||
(c = GETC(f)) == EOF || c != '6' ||
(c = GETC(f)) == EOF || c != '<' ||
(c = GETC(f)) == EOF || c != '<')
bad_header = TRUE;
else
*codetype = DIGRAPH6 | HAS_HEADER;
}
else if (!bad_header && c == 'e')
{
if ((c = GETC(f)) == EOF || c != 'd' ||
(c = GETC(f)) == EOF || c != 'g' ||
(c = GETC(f)) == EOF || c != 'e' ||
(c = GETC(f)) == EOF || c != '_' ||
(c = GETC(f)) == EOF || c != 'c' ||
(c = GETC(f)) == EOF || c != 'o' ||
(c = GETC(f)) == EOF || c != 'd' ||
(c = GETC(f)) == EOF || c != 'e' ||
(c = GETC(f)) == EOF || c != '<' ||
(c = GETC(f)) == EOF || c != '<')
bad_header = TRUE;
else
*codetype = EDGECODE | HAS_HEADER;
}
else if (!bad_header && c == 's')
{
if ((c = GETC(f)) == EOF || c != 'p' ||
(c = GETC(f)) == EOF || c != 'a' ||
(c = GETC(f)) == EOF || c != 'r' ||
(c = GETC(f)) == EOF || c != 's' ||
(c = GETC(f)) == EOF || c != 'e' ||
(c = GETC(f)) == EOF || c != '6' ||
(c = GETC(f)) == EOF || c != '<' ||
(c = GETC(f)) == EOF || c != '<')
bad_header = TRUE;
else
*codetype = SPARSE6 | HAS_HEADER;
}
else if (!bad_header && c == 'p')
{
if ((c = GETC(f)) == EOF || c != 'l' ||
(c = GETC(f)) == EOF || c != 'a' ||
(c = GETC(f)) == EOF || c != 'n' ||
(c = GETC(f)) == EOF || c != 'a' ||
(c = GETC(f)) == EOF || c != 'r' ||
(c = GETC(f)) == EOF || c != '_' ||
(c = GETC(f)) == EOF || c != 'c' ||
(c = GETC(f)) == EOF || c != 'o' ||
(c = GETC(f)) == EOF || c != 'd' ||
(c = GETC(f)) == EOF || c != 'e')
bad_header = TRUE;
else
{
if ((c = GETC(f)) == EOF)
bad_header = TRUE;
else if (c == ' ')
{
if ((bl = GETC(f)) == EOF || (bl != 'l' && bl != 'b') ||
(c = GETC(f)) == EOF || c != 'e' ||
(c = GETC(f)) == EOF || c != '<' ||
(c = GETC(f)) == EOF || c != '<')
bad_header = TRUE;
else if (bl == 'l')
*codetype = PLANARCODELE | HAS_HEADER;
else
*codetype = PLANARCODEBE | HAS_HEADER;
}
else if (c == '<')
{
if ((c = GETC(f)) == EOF || c != '<')
bad_header = TRUE;
else
*codetype = PLANARCODE | HAS_HEADER;
}
else
bad_header = TRUE;
}
}
if (bad_header)
{
fprintf(stderr,">E opengraphfile: illegal header in %s\n",
filename == NULL ? "stdin" : filename);
*codetype = UNKNOWN_TYPE | HAS_HEADER;
FUNLOCKFILE(f);
return NULL;
}
}
if (position <= 1) return f;
if (*codetype&PLANARCODEANY)
{
fprintf(stderr,
">E opengraphfile: planar_code files can only be opened at the start\n");
*codetype = UNKNOWN_TYPE | HAS_HEADER;
FUNLOCKFILE(f);
fclose(f);
return NULL;
}
if (*codetype&EDGECODE)
{
fprintf(stderr,
">E opengraphfile: edge_code files can only be opened at the start\n");
*codetype = UNKNOWN_TYPE | HAS_HEADER;
FUNLOCKFILE(f);
fclose(f);
return NULL;
}
if (!assumefixed || (*codetype&SPARSE6) || firstc == ':')
{
l = 1;
while ((c = GETC(f)) != EOF)
{
if (c == '\n')
{
++l;
if (l == position) break;
}
}
if (l == position) return f;
fprintf(stderr,
">E opengraphfile: can't find line %ld in %s\n",position,
filename == NULL ? "stdin" : filename);
return NULL;
}
else
{
pos1 = FTELL_VER(f);
if (pos1 < 0)
{
fprintf(stderr,">E opengraphfile: error on first ftell\n");
return NULL;
}
for (i = 1; (c = GETC(f)) != EOF && c != '\n'; ++i) {}
ogf_linelen = i;
if (c == EOF)
{
fprintf(stderr,
">E opengraphfile: required record no present\n");
FUNLOCKFILE(f);
return NULL;
}
pos2 = FTELL_VER(f);
if (pos2 < 0)
{
fprintf(stderr,">E opengraphfile: error on second ftell\n");
return NULL;
}
pos = pos1 + (position-1)*(pos2-pos1);
if (FSEEK_VER(f,pos,SEEK_SET) < 0)
{
fprintf(stderr,">E opengraphfile: seek failed\n");
return NULL;
}
}
FUNLOCKFILE(f);
return f;
}
/*********************************************************************/
void
writeline(FILE *f, char *s)
/* write a line with error checking */
/* \n is not appended automatically */
{
size_t slen;
slen = strlen(s);
if (fwrite(s,1,slen,f) != slen || ferror(f))
gt_abort(">E writeline : error on writing\n");
}
/*********************************************************************/
/* This function used to be called getline(), but this was changed due
to too much confusion with the GNU function of that name.
*/
char*
gtools_getline(FILE *f) /* read a line with error checking */
/* includes \n (if present) and \0. Immediate EOF causes NULL return. */
{
DYNALLSTAT(char,s,s_sz);
int c;
long i;
DYNALLOC1(char,s,s_sz,5000,"gtools_getline");
FLOCKFILE(f);
i = 0;
while ((c = GETC(f)) != EOF && c != '\n')
{
if (i == s_sz-3)
DYNREALLOC(char,s,s_sz,3*(s_sz/2)+10000,"gtools_getline");
s[i++] = (char)c;
}
FUNLOCKFILE(f);
if (i == 0 && c == EOF) return NULL;
if (c == '\n') s[i++] = '\n';
s[i] = '\0';
return s;
}
/****************************************************************************/
char*
getecline(FILE *f) /* read an edge_code line */
/* No trailing \n or \0 is added. Immediate EOF causes NULL return. */
{
size_t headsize,bodysize;
int sizesize,edgesize;
int c1,c,i;
DYNALLSTAT(unsigned char,s,s_sz);
FLOCKFILE(f);
if ((c1 = GETC(f)) == EOF) return NULL;
if (c1 > 0)
{
bodysize = c1;
edgesize = 1;
headsize = 1;
}
else
{
if ((c = GETC(f)) == EOF)
gt_abort(">E Incomplete edge_code line\n");
else
{
sizesize = c >> 4;
edgesize = c & 0xF;
bodysize = 0;
for (i = 0; i < sizesize; ++i)
{
if ((c = GETC(f)) == EOF)
gt_abort(">E Incomplete edge_code line\n");
else
bodysize = (bodysize << 8) + c;
}
headsize = 2 + sizesize;
}
}
DYNALLOC1(unsigned char,s,s_sz,headsize+bodysize,"getecline");
s[0] = (unsigned char)c1;
if (c1 == 0)
{
s[1] = (char)((sizesize << 4) + edgesize);
for (i = 0; i < sizesize; ++i)
s[headsize-1-i] = (bodysize >> 8*i) & 0xFF;
}
if (bodysize > 0 && fread(s+headsize,bodysize,1,f) != bodysize)
gt_abort(">E Incomplete edge_code line\n");
FUNLOCKFILE(f);
return (char*)s;
}
int
graphsize(char *s)
/* Get size of graph out of graph6, digraph6 or sparse6 string. */
{
char *p;
int n;
if (s[0] == ':' || s[0] == '&') p = s+1;
else p = s;
n = *p++ - BIAS6;
if (n > SMALLN)
{
n = *p++ - BIAS6;
if (n > SMALLN)
{
n = *p++ - BIAS6;
n = (n << 6) | (*p++ - BIAS6);
n = (n << 6) | (*p++ - BIAS6);
n = (n << 6) | (*p++ - BIAS6);
n = (n << 6) | (*p++ - BIAS6);
n = (n << 6) | (*p++ - BIAS6);
}
else
{
n = (n << 6) | (*p++ - BIAS6);
n = (n << 6) | (*p++ - BIAS6);
}
}
return n;
}
/****************************************************************************/
void
encodegraphsize(int n, char **pp)
/* Encode the size n in a string starting at **p, and reset **p
to point to the character after the size */
{
char *p;
p = *pp;
if (n <= SMALLN)
*p++ = (char)(BIAS6 + n);
else if (n <= SMALLISHN)
{
*p++ = MAXBYTE;
*p++ = (char)(BIAS6 + (n >> 12));
*p++ = (char)(BIAS6 + ((n >> 6) & C6MASK));
*p++ = (char)(BIAS6 + (n & C6MASK));
}
else
{
*p++ = MAXBYTE;
*p++ = MAXBYTE;
*p++ = (char)(BIAS6 + (n >> 30));
*p++ = (char)(BIAS6 + ((n >> 24) & C6MASK));
*p++ = (char)(BIAS6 + ((n >> 18) & C6MASK));
*p++ = (char)(BIAS6 + ((n >> 12) & C6MASK));
*p++ = (char)(BIAS6 + ((n >> 6) & C6MASK));
*p++ = (char)(BIAS6 + (n & C6MASK));
}
*pp = p;
}
/****************************************************************************/
void
stringcounts(char *s, int *pn, size_t *pe)
/* Determine number of edges of graph6, digraph6 or sparse6 string */
{
char *p;
int i,j,k,x,nb,v,n,need;
size_t count;
boolean done;
n = graphsize(s);
*pn = n;
p = s + (s[0] == ':' || s[0] == '&') + SIZELEN(n);
if (s[0] == ':') /* sparse6 */
{
count = 0;
for (i = n-1, nb = 0; i > 0 ; i >>= 1, ++nb) {}
k = 0;
v = 0;
done = FALSE;
while (!done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if ((x & B(k))) ++v;
--k;
need = nb;
j = 0;
while (need > 0 && !done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if (need >= k)
{
j = (j << k) | (x & M(k));
need -= k; k = 0;
}
else
{
k -= need;
j = (j << need) | ((x >> k) & M(need));
need = 0;
}
}
if (done) continue;
if (j > v)
v = j;
else if (v < n)
++count;
}
}
else /* graph6 or digraph6 */
{
count = 0;
for (; *p != '\n' && *p != '\0'; ++p)
count += bytecount[*p - BIAS6];
}
*pe = count;
}
/****************************************************************************/
void
stringtograph(char *s, graph *g, int m)
/* Convert string (graph6, digraph6 or sparse6 format) to graph. */
/* Assumes g is big enough to hold it. */
{
char *p;
int n,i,j,k,v,x,nb,need;
size_t ii;
set *gi,*gj;
boolean done;
n = graphsize(s);
if (n == 0) return;
p = s + (s[0] == ':' || s[0] == '&') + SIZELEN(n);
if (TIMESWORDSIZE(m) < n)
gt_abort(">E stringtograph: impossible m value\n");
for (ii = m*(size_t)n; --ii > 0;) g[ii] = 0;
g[0] = 0;
if (s[0] != ':' && s[0] != '&') /* graph6 format */
{
k = 1;
for (j = 1; j < n; ++j)
{
gj = GRAPHROW(g,j,m);
for (i = 0; i < j; ++i)
{
if (--k == 0)
{
k = 6;
x = *(p++) - BIAS6;
}
if ((x & TOPBIT6))
{
gi = GRAPHROW(g,i,m);
ADDELEMENT(gi,j);
ADDELEMENT(gj,i);
}
x <<= 1;
}
}
}
else if (s[0] == '&')
{
k = 1;
for (i = 0; i < n; ++i)
{
gi = GRAPHROW(g,i,m);
for (j = 0; j < n; ++j)
{
if (--k == 0)
{
k = 6;
x = *(p++) - BIAS6;
}
if ((x & TOPBIT6))
{
ADDELEMENT(gi,j);
}
x <<= 1;
}
}
}
else /* sparse6 format */
{
for (i = n-1, nb = 0; i > 0 ; i >>= 1, ++nb) {}
k = 0;
v = 0;
done = FALSE;
while (!done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if ((x & B(k))) ++v;
--k;
need = nb;
j = 0;
while (need > 0 && !done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if (need >= k)
{
j = (j << k) | (x & M(k));
need -= k; k = 0;
}
else
{
k -= need;
j = (j << need) | ((x >> k) & M(need));
need = 0;
}
}
if (done) continue;
if (j > v)
v = j;
else if (v < n)
{
ADDELEMENT(GRAPHROW(g,v,m),j);
ADDELEMENT(GRAPHROW(g,j,m),v);
}
}
}
}
/****************************************************************************/
void
stringtograph_inc(char *s, graph *g, int m,
graph *prevg, int prevn)
/* Convert string (graph6, digraph6 or sparse6 format) to graph,
allowing incremental sparse6 format with a prior graph assumed
to have matching m,n values.
If prevg != NULL and type is is6, use prevg as prior graph.
Assumes g is big enough to hold it.
*digraph is set according to the graph type.
*/
{
char *p;
int n,i,j,k,v,x,nb,need;
size_t ii;
set *gi,*gj;
boolean done;
if (s[0] == ';' && !prevg)
gt_abort(">E stringtograph_inc missing prior graph\n");
if (s[0] == ';')
{
n = prevn;
if (n == 0) return;
p = s + 1;
for (ii = m*(size_t)n; --ii > 0;) g[ii] = prevg[ii];
g[0] = prevg[0];
}
else
{
n = graphsize(s);
if (n == 0) return;
p = s + (s[0] == ':' || s[0] == '&') + SIZELEN(n);
for (ii = m*(size_t)n; --ii > 0;) g[ii] = 0;
g[0] = 0;
}
if (TIMESWORDSIZE(m) < n)
gt_abort(">E stringtograph_inc: impossible m value\n");
if (s[0] != ':' && s[0] != ';' && s[0] != '&') /* graph6 format */
{
k = 1;
for (j = 1; j < n; ++j)
{
gj = GRAPHROW(g,j,m);
for (i = 0; i < j; ++i)
{
if (--k == 0)
{
k = 6;
x = *(p++) - BIAS6;
}
if ((x & TOPBIT6))
{
gi = GRAPHROW(g,i,m);
FLIPELEMENT(gi,j);
if (i != j) FLIPELEMENT(gj,i);
}
x <<= 1;
}
}
}
else if (s[0] == '&') /* digraph6 format */
{
k = 1;
for (j = 0; j < n; ++j)
{
gj = GRAPHROW(g,j,m);
for (i = 0; i < n; ++i)
{
if (--k == 0)
{
k = 6;
x = *(p++) - BIAS6;
}
if ((x & TOPBIT6))
{
FLIPELEMENT(gj,i);
}
x <<= 1;
}
}
}
else /* sparse6 format */
{
for (i = n-1, nb = 0; i != 0 ; i >>= 1, ++nb) {}
k = 0;
v = 0;
done = FALSE;
while (!done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if ((x & B(k))) ++v;
--k;
need = nb;
j = 0;
while (need > 0 && !done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if (need >= k)
{
j = (j << k) | (x & M(k));
need -= k; k = 0;
}
else
{
k -= need;
j = (j << need) | ((x >> k) & M(need));
need = 0;
}
}
if (done) continue;
if (j > v)
v = j;
else if (v < n)
{
FLIPELEMENT(GRAPHROW(g,v,m),j);
if (j != v) FLIPELEMENT(GRAPHROW(g,j,m),v);
}
}
}
}
/***********************************************************************/
graph* /* read graph into nauty format */
readgg(FILE *f, graph *g, int reqm, int *pm, int *pn, boolean *digraph)
/* graph6, digraph6 and sparse6 formats are supported
f = an open file
g = place to put the answer (NULL for dynamic allocation)
reqm = the requested value of m (0 => compute from n)
*pm = the actual value of m
*pn = the value of n
*digraph = whether the input is a digraph
*/
{
char *s,*p;
int m,n;
if ((readg_line = gtools_getline(f)) == NULL) return NULL;
s = readg_line;
if (s[0] == ':')
{
readg_code = SPARSE6;
*digraph = FALSE;
p = s + 1;
}
else if (s[0] == '&')
{
readg_code = DIGRAPH6;
*digraph = TRUE;
p = s + 1;
}
else
{
readg_code = GRAPH6;
*digraph = FALSE;
p = s;
}
while (*p >= BIAS6 && *p <= MAXBYTE)
++p;
if (*p == '\0')
gt_abort(">E readgg: missing newline\n");
else if (*p != '\n')
gt_abort(">E readgg: illegal character\n");
n = graphsize(s);
if (readg_code == GRAPH6 && p - s != G6LEN(n))
gt_abort(">E readgg: truncated graph6 line\n");
if (readg_code == DIGRAPH6 && p - s != D6LEN(n))
gt_abort(">E readgg: truncated digraph6 line\n");
if (reqm > 0 && TIMESWORDSIZE(reqm) < n)
gt_abort(">E readgg: reqm too small\n");
else if (reqm > 0)
m = reqm;
else
m = (n + WORDSIZE - 1) / WORDSIZE;
if (g == NULL)
{
if ((g = (graph*)ALLOCS(n,m*sizeof(graph))) == NULL)
gt_abort(">E readgg: malloc failed\n");
}
*pn = n;
*pm = m;
stringtograph(s,g,m);
return g;
}
/***********************************************************************/
graph* /* read undirected graph into nauty format */
readg(FILE *f, graph *g, int reqm, int *pm, int *pn)
/* graph6 and sparse6 formats are supported
f = an open file
g = place to put the answer (NULL for dynamic allocation)
reqm = the requested value of m (0 => compute from n)
*pm = the actual value of m
*pn = the value of n
Only allows undirected graphs.
*/
{
boolean digraph;
graph *gg;
gg = readgg(f,g,reqm,pm,pn,&digraph);
if (!gg) return NULL;
if (digraph)
gt_abort(">E readg() doesn't all digraphs; use readgg()\n");
return gg;
}
/***********************************************************************/
int
checkgline(char *s)
/* Check if s[0..] appears to be a graph input line. A complete check
is not performed. Note that graph input lines must end with \n.
The value returned is 0 if no errors are found, otherwise:
1 = missing newline
2 = illegal character
3 = graph6 or digraph6 line with wrong length
*/
{
char *p;
int n,t;
if (s[0] == ':' || s[0] == ';')
{
t = SPARSE6;
p = s + 1;
}
else if (s[0] == '&')
{
t = DIGRAPH6;
p = s + 1;
}
else
{
t = GRAPH6;
p = s;
}
while (*p >= BIAS6 && *p <= MAXBYTE)
++p;
if (*p == '\0')
return 1;
else if (*p != '\n')
return 2;
if (t == GRAPH6)
{
n = graphsize(s);
if (p - s != G6LEN(n)) return 3;
}
if (t == DIGRAPH6)
{
n = graphsize(s);
if (p - s != D6LEN(n)) return 3;
}
return 0;
}
/***********************************************************************/
graph* /* read graph into nauty format */
readgg_inc(FILE *f, graph *g, int reqm, int *pm, int *pn,
graph *prevg, int prevm, int prevn, boolean *digraph)
/* graph6, digraph6 and sparse6 formats are supported
f = an open file
g = place to put the answer (NULL for dynamic allocation)
reqm = the requested value of m (0 => compute from n)
This is ignored for an incremental input.
*pm = the actual value of m
*pn = the value of n
*digraph = whether the input is a digraph
If prevg!=NULL, it is a prior graph for use in case the next
input is a sparse6 increment.
*/
{
char *s,*p;
int m,n;
if ((readg_line = gtools_getline(f)) == NULL) return NULL;
s = readg_line;
if (s[0] == ':')
{
readg_code = SPARSE6;
*digraph = FALSE;
p = s + 1;
}
else if (s[0] == ';')
{
readg_code = INCSPARSE6;
*digraph = FALSE;
p = s + 1;
}
else if (s[0] == '&')
{
readg_code = DIGRAPH6;
*digraph = TRUE;
p = s + 1;
}
else
{
readg_code = GRAPH6;
*digraph = FALSE;
p = s;
}
while (*p >= BIAS6 && *p <= MAXBYTE)
++p;
if (*p == '\0')
gt_abort(">E readg_inc: missing newline\n");
else if (*p != '\n')
gt_abort(">E readg_inc: illegal character\n");
if (readg_code == INCSPARSE6)
{
if (prevg == NULL) gt_abort(">E readg_inc: missing prior\n");
n = prevn;
m = prevm;
}
else
{
n = graphsize(s);
if (readg_code == GRAPH6 && p - s != G6LEN(n))
gt_abort(">E readg_inc: truncated graph6 line\n");
if (readg_code == DIGRAPH6 && p - s != D6LEN(n))
gt_abort(">E readg_inc: truncated digraph6 line\n");
if (reqm > 0 && TIMESWORDSIZE(reqm) < n)
gt_abort(">E readg_inc: reqm too small\n");
else if (reqm > 0)
m = reqm;
else
m = SETWORDSNEEDED(n);
}
if (g == NULL)
{
if ((g = (graph*)ALLOCS(n,m*sizeof(graph))) == NULL)
gt_abort(">E readg_inc: malloc failed\n");
}
*pn = n;
*pm = m;
stringtograph_inc(s,g,m,prevg,prevn);
return g;
}
/***********************************************************************/
graph* /* read undirected graph into nauty format */
readg_inc(FILE *f, graph *g, int reqm, int *pm, int *pn,
graph *prevg, int prevm, int prevn)
/* graph6 and sparse6 formats are supported
f = an open file
g = place to put the answer (NULL for dynamic allocation)
reqm = the requested value of m (0 => compute from n)
This is ignored for an incremental input.
*pm = the actual value of m
*pn = the value of n
*digraph = whether the input is a digraph
If prevg!=NULL, it is a prior graph for use in case the next
input is a sparse6 increment.
*/
{
boolean digraph;
graph *gg;
gg = readgg_inc(f,g,reqm,pm,pn,prevg,prevm,prevn,&digraph);
if (!gg) return NULL;
if (digraph)
gt_abort(">E readg_inc() doesn't all digraphs; use readgg_inc()\n");
return gg;
}
/****************************************************************************/
void
stringtosparsegraph(char *s, sparsegraph *sg, int *nloops)
/* Convert string (graph6, digraph6 or sparse6 format)
* to sparse graph.
* Assumes sg exists and is initialised
* Also returns the number of loops */
{
char *p,*q;
int n,nde,i,j,k,vv,x,nb,need;
int *d,*e;
size_t *v;
int loops;
boolean done;
n = graphsize(s);
q = s + (s[0] == ':' || s[0] == '&') + SIZELEN(n);
sg->nv = n;
DYNALLOC1(size_t,sg->v,sg->vlen,n,"stringtosparsegraph");
DYNALLOC1(int,sg->d,sg->dlen,n,"stringtosparsegraph");
v = sg->v;
d = sg->d;
for (i = 0; i < n; ++i) d[i] = 0;
if (s[0] != ':' && s[0] != '&') /* graph6 format */
{
p = q;
k = 1;
for (j = 1; j < n; ++j)
{
for (i = 0; i < j; ++i)
{
if (--k == 0)
{
k = 6;
x = *(p++) - BIAS6;
}
if ((x & TOPBIT6))
{
d[i]++;
d[j]++;
}
x <<= 1;
}
}
nde = 0;
for (i = 0; i < n; ++i)
{
v[i] = nde; nde += d[i]; d[i] = 0;
}
sg->nde = nde;
DYNALLOC1(int,sg->e,sg->elen,nde,"stringtosparsegraph");
e = sg->e;
p = q;
k = 1;
for (j = 1; j < n; ++j)
{
for (i = 0; i < j; ++i)
{
if (--k == 0)
{
k = 6;
x = *(p++) - BIAS6;
}
if ((x & TOPBIT6))
{
e[v[i]+d[i]++] = j;
e[v[j]+d[j]++] = i;
}
x <<= 1;
}
}
*nloops = 0;
}
else if (s[0] == '&') /* digraph6 */
{
p = q;
k = 1;
for (j = 0; j < n; ++j)
{
for (i = 0; i < n; ++i)
{
if (--k == 0)
{
k = 6;
x = *(p++) - BIAS6;
}
if ((x & TOPBIT6))
d[j]++;
x <<= 1;
}
}
nde = 0;
for (i = 0; i < n; ++i)
{
v[i] = nde; nde += d[i]; d[i] = 0;
}
sg->nde = nde;
DYNALLOC1(int,sg->e,sg->elen,nde,"stringtosparsegraph");
e = sg->e;
p = q;
k = 1;
*nloops = 0;
for (j = 0; j < n; ++j)
{
for (i = 0; i < n; ++i)
{
if (--k == 0)
{
k = 6;
x = *(p++) - BIAS6;
}
if ((x & TOPBIT6))
{
e[v[j]+d[j]++] = i;
if (i == j) ++*nloops;
}
x <<= 1;
}
}
}
else /* sparse6 format */
{
for (i = n-1, nb = 0; i > 0 ; i >>= 1, ++nb) {}
p = q;
k = 0;
vv = 0;
done = FALSE;
loops = 0;
while (!done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if ((x & B(k))) ++vv;
--k;
need = nb;
j = 0;
while (need > 0 && !done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if (need >= k)
{
j = (j << k) | (x & M(k));
need -= k; k = 0;
}
else
{
k -= need;
j = (j << need) | ((x >> k) & M(need));
need = 0;
}
}
if (done) continue;
if (j > vv)
vv = j;
else if (vv < n)
{
d[vv]++;
if (vv != j) d[j]++;
else ++loops;
}
}
nde = 0;
for (i = 0; i < n; ++i)
{
v[i] = nde; nde += d[i]; d[i] = 0;
}
sg->nde = nde;
DYNALLOC1(int,sg->e,sg->elen,nde,"stringtosparsegraph");
e = sg->e;
p = q;
k = 0;
vv = 0;
done = FALSE;
while (!done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if ((x & B(k))) ++vv;
--k;
need = nb;
j = 0;
while (need > 0 && !done)
{
if (k == 0)
{
x = *(p++);
if (x == '\n' || x == '\0')
{
done = TRUE; continue;
}
else
{
x -= BIAS6; k = 6;
}
}
if (need >= k)
{
j = (j << k) | (x & M(k));
need -= k; k = 0;
}
else
{
k -= need;
j = (j << need) | ((x >> k) & M(need));
need = 0;
}
}
if (done) continue;
if (j > vv)
vv = j;
else if (vv < n)
{
e[v[vv]+d[vv]++] = j;
if (vv != j) e[v[j]+d[j]++] = vv;
}
}
*nloops = loops;
}
}
/***********************************************************************/
sparsegraph* /* read graph into sparsegraph format */
read_sgg_loops(FILE *f, sparsegraph *sg, int *nloops, boolean *digraph)
/* graph6, digraph6 and sparse6 formats are supported
* f = an open file
* sg = place to put the answer (NULL for dynamic allocation)
* - must be initialised if not NULL
* nloops := number of loops (each loop in a sparse6 string
* gives one loop in the sparse representation)
*/
{
char *s,*p;
int n,loops;
if ((readg_line = gtools_getline(f)) == NULL) return NULL;
s = readg_line;
if (s[0] == ':')
{
readg_code = SPARSE6;
*digraph = FALSE;
p = s + 1;
}
else if (s[0] == '&')
{
readg_code = DIGRAPH6;
*digraph = TRUE;
p = s + 1;
}
else
{
readg_code = GRAPH6;
*digraph = FALSE;
p = s;
}
while (*p >= BIAS6 && *p <= MAXBYTE)
++p;
if (*p == '\0')
gt_abort(">E read_sg: missing newline\n");
else if (*p != '\n')
gt_abort(">E read_sg: illegal character\n");
n = graphsize(s);
if (readg_code == GRAPH6 && p - s != G6LEN(n))
gt_abort(">E read_sg: truncated graph6 line\n");
if (readg_code == DIGRAPH6 && p - s != D6LEN(n))
gt_abort(">E read_sg: truncated digraph6 line\n");
if (sg == NULL)
{
if ((sg = (sparsegraph*)ALLOCS(1,sizeof(sparsegraph))) == NULL)
gt_abort(">E read_sg: malloc failed\n");
SG_INIT(*sg);
}
stringtosparsegraph(s,sg,&loops);
*nloops = loops;
return sg;
}
/***********************************************************************/
sparsegraph* /* read undirected graph into sparsegraph format */
read_sg_loops(FILE *f, sparsegraph *sg, int *nloops)
/* graph6 and sparse6 formats are supported
* f = an open file
* sg = place to put the answer (NULL for dynamic allocation)
* - must be initialised if not NULL
* nloops := number of loops (each loop in a sparse6 string
* gives one loop in the sparse representation)
* digraph = whether input line was a digraph
*/
{
sparsegraph *sgg;
boolean digraph;
sgg = read_sgg_loops(f,sg,nloops,&digraph);
if (!sgg) return NULL;
if (digraph) gt_abort(">E read_sg_loops() can't handle digraphs,"
" use read_sgg_loops()\n");
return sgg;
}
/***********************************************************************/
sparsegraph* /* read graph into sparsegraph format */
read_sg(FILE *f, sparsegraph *sg)
/* graph6 and sparse6 formats are supported
* *f = an open file
* *sg = place to put the answer (NULL for dynamic allocation)
* - must be initialised if not NULL
*/
{
int loops;
sparsegraph *sgg;
boolean digraph;
sgg = read_sgg_loops(f,sg,&loops,&digraph);
if (!sgg) return NULL;
if (digraph) gt_abort(">E read_sg() can't handle digraphs,"
" use read_sgg_loops()\n");
return sgg;
}
/****************************************************************************/
DYNALLSTAT(char,gcode,gcode_sz); /* Used by ntog6, ntos6, ntod6 and sgtos6 */
TLS_ATTR size_t s6len;
TLS_ATTR int readg_code;
TLS_ATTR char *readg_line;
/****************************************************************************/
char*
ntod6(graph *g, int m, int n)
/* convert nauty graph to digraph6 string, including \n and \0 */
{
int i,j,k;
char *p,x;
set *gj;
size_t ii;
ii = D6LEN(n)+3;
DYNALLOC1(char,gcode,gcode_sz,ii,"ntod6");
p = gcode;
*p++ = '&';
encodegraphsize(n,&p);
k = 6;
x = 0;
for (j = 0; j < n; ++j)
{
gj = GRAPHROW(g,j,m);
for (i = 0; i < n; ++i)
{
x <<= 1;
if (ISELEMENT(gj,i)) x |= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
}
if (k != 6) *p++ = (char)(BIAS6 + (x << k));
*p++ = '\n';
*p = '\0';
return gcode;
}
/****************************************************************************/
char*
ntog6(graph *g, int m, int n)
/* convert nauty graph to graph6 string, including \n and \0 */
{
int i,j,k;
char *p,x;
set *gj;
size_t ii;
ii = G6LEN(n)+3;
DYNALLOC1(char,gcode,gcode_sz,ii,"ntog6");
p = gcode;
encodegraphsize(n,&p);
k = 6;
x = 0;
for (j = 1; j < n; ++j)
{
gj = GRAPHROW(g,j,m);
for (i = 0; i < j; ++i)
{
x <<= 1;
if (ISELEMENT(gj,i)) x |= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
}
if (k != 6) *p++ = (char)(BIAS6 + (x << k));
*p++ = '\n';
*p = '\0';
return gcode;
}
/****************************************************************************/
char*
ntos6(graph *g, int m, int n)
/* convert nauty graph to sparse6 string, including \n and \0 */
{
int i,j,k;
char *p,x;
set *gj;
size_t ii;
int r,rr,topbit,nb,lastj;
char *plim;
DYNALLOC1(char,gcode,gcode_sz,5000,"ntos6");
plim = gcode + gcode_sz - 20;
gcode[0] = ':';
p = gcode+1;
encodegraphsize(n,&p);
for (i = n-1, nb = 0; i > 0 ; i >>= 1, ++nb)
{}
topbit = 1 << (nb-1);
k = 6;
x = 0;
lastj = 0;
for (j = 0; j < n; ++j)
{
gj = GRAPHROW(g,j,m);
for (i = 0; i <= j; ++i)
{
if (ISELEMENT(gj,i))
{
if (p >= plim)
{
ii = p - gcode;
DYNREALLOC(char,gcode,gcode_sz,
3*(gcode_sz/2)+10000,"ntos6");
p = gcode + ii;
plim = gcode + gcode_sz - 20;
}
if (j == lastj)
{
x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
else
{
x = (x << 1) | (char)1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
if (j > lastj+1)
{
for (r = 0, rr = j; r < nb; ++r, rr <<= 1)
{
if ((rr & topbit)) x = (x << 1) | (char)1;
else x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
lastj = j;
}
for (r = 0, rr = i; r < nb; ++r, rr <<= 1)
{
if ((rr & topbit)) x = (x << 1) | (char)1;
else x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
}
}
}
if (k != 6)
{
if (k >= nb+1 && lastj == n-2 && n == (1<<nb))
*p++ = (char)(BIAS6 + ((x << k) | ((1 << (k-1)) - 1)));
else
*p++ = (char)(BIAS6 + ((x << k) | ((1 << k) - 1)));
}
*p++ = '\n';
*p = '\0';
s6len = p - gcode;
return gcode;
}
/****************************************************************************/
char*
ntois6(graph *g, graph *prevg, int m, int n)
/* convert nauty graph to incremental sparse6 string, including \n and \0.
prevg == NULL implies there is no prior graph */
{
int i,j,k;
char *p,x;
set *gj,*pgj;
setword gdiff;
size_t ii;
int r,rr,topbit,nb,lastj,iw,nwords;
char *plim;
if (!prevg) return ntos6(g,m,n);
DYNALLOC1(char,gcode,gcode_sz,5000,"ntois6");
plim = gcode + gcode_sz - 20;
gcode[0] = ';';
p = gcode+1;
for (i = n-1, nb = 0; i > 0 ; i >>= 1, ++nb)
{}
topbit = 1 << (nb-1);
k = 6;
x = 0;
lastj = 0;
for (j = 0; j < n; ++j)
{
gj = GRAPHROW(g,j,m);
pgj = GRAPHROW(prevg,j,m);
nwords = SETWORDSNEEDED(j+1);
for (iw = 0; iw < nwords; ++iw)
{
gdiff = gj[iw] ^ pgj[iw];
if (TIMESWORDSIZE(iw+1) > j+1) gdiff &= ALLMASK(SETBT(j+1));
while (gdiff)
{
TAKEBIT(i,gdiff);
i += TIMESWORDSIZE(iw);
if (p >= plim)
{
ii = p - gcode;
DYNREALLOC(char,gcode,gcode_sz,
3*(gcode_sz/2)+10000,"ntois6");
p = gcode + ii;
plim = gcode + gcode_sz - 20;
}
if (j == lastj)
{
x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
else
{
x = (x << 1) | (char)1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
if (j > lastj+1)
{
for (r = 0, rr = j; r < nb; ++r, rr <<= 1)
{
if ((rr & topbit)) x = (x << 1) | (char)1;
else x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
lastj = j;
}
for (r = 0, rr = i; r < nb; ++r, rr <<= 1)
{
if ((rr & topbit)) x = (x << 1) | (char)1;
else x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
}
}
}
if (k != 6)
{
if (k >= nb+1 && lastj == n-2 && n == (1<<nb))
*p++ = (char)(BIAS6 + ((x << k) | ((1 << (k-1)) - 1)));
else
*p++ = (char)(BIAS6 + ((x << k) | ((1 << k) - 1)));
}
*p++ = '\n';
*p = '\0';
s6len = p - gcode;
return gcode;
}
/*************************************************************************/
char*
sgtos6(sparsegraph *sg)
/* Convert undirected sparse graph to sparse6 string including '\n'.
It is null-terminated and its address (static memory) is returned.
The length, not including the null, is put in s6len. */
{
int *d,*e;
int i,j,n;
char *p,x,*plim;
int nb,topbit;
int dj,k,lastj;
int r,rr;
size_t ii,*v,vj,l;
SG_VDE(sg,v,d,e);
n = sg->nv;
for (i = n-1, nb = 0; i > 0 ; i >>= 1, ++nb) {}
ii = (size_t)(nb+1)*(n/6+sg->nde/3);
DYNALLOC1(char,gcode,gcode_sz,ii+1000,"sgtos6");
plim = gcode + gcode_sz - 20;
p = gcode;
*p++ = ':';
encodegraphsize(n,&p);
topbit = 1 << (nb-1);
k = 6;
x = 0;
lastj = 0;
for (j = 0; j < n; ++j)
{
vj = v[j];
dj = d[j];
for (l = 0; l < dj; ++l)
{
i = e[vj+l];
if (i <= j)
{
if (p >= plim)
{
ii = p - gcode;
DYNREALLOC(char,
gcode,gcode_sz,5*(gcode_sz/4)+1000,"sgtos6");
p = gcode + ii;
plim = gcode + gcode_sz - 20;
}
if (j == lastj)
{
x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
else
{
x = (x << 1) | (char)1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
if (j > lastj+1)
{
for (r = 0, rr = j; r < nb; ++r, rr <<= 1)
{
if ((rr & topbit)) x = (x << 1) | (char)1;
else x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
lastj = j;
}
for (r = 0, rr = i; r < nb; ++r, rr <<= 1)
{
if ((rr & topbit)) x = (x << 1) | (char)1;
else x <<= 1;
if (--k == 0)
{
*p++ = (char)(BIAS6 + x);
k = 6;
x = 0;
}
}
}
}
}
if (k != 6)
{
if (k >= nb+1 && lastj == n-2 && n == (1<<nb))
*p++ = (char)(BIAS6 + ((x << k) | ((1 << (k-1)) - 1)));
else
*p++ = (char)(BIAS6 + ((x << k) | ((1 << k) - 1)));
}
*p++ = '\n';
*p = '\0';
s6len = p - gcode;
return gcode;
}
/*************************************************************************/
char*
sgtog6(sparsegraph *sg)
/* Convert undirected sparse graph to graph6 string including '\n','\0'.
It is null-terminated and its address (static memory) is returned. */
{
int *d,*e,*ei;
int i,j,n;
char *p;
size_t ii,*v,bodylen,org;
static char g6bit[] = {32,16,8,4,2,1};
SG_VDE(sg,v,d,e);
n = sg->nv;
ii = G6LEN(n)+3;
DYNALLOC1(char,gcode,gcode_sz,ii,"sgtog6");
p = gcode;
encodegraphsize(n,&p);
bodylen = G6BODYLEN(n);
for (ii = 0; ii < bodylen; ++ii) p[ii] = 0;
p[bodylen] = '\n';
p[bodylen+1] = '\0';
for (i = 0, org = 0; i < n; org += i, ++i)
{
ei = e + v[i];
for (j = 0; j < d[i]; ++j)
if (ei[j] < i)
{
ii = ei[j] + org;
p[ii/6] |= g6bit[ii%6];
}
}
for (ii = 0; ii < bodylen; ++ii) p[ii] += BIAS6;
return gcode;
}
/*************************************************************************/
char*
sgtod6(sparsegraph *sg)
/* Convert undirected sparse graph to digraph6 string including '\n','\0'.
It is null-terminated and its address (static memory) is returned. */
{
int *d,*e,*ei;
int i,j,n;
char *p;
size_t ii,*v,bodylen,org;
static char g6bit[] = {32,16,8,4,2,1};
SG_VDE(sg,v,d,e);
n = sg->nv;
ii = D6LEN(n)+3;
DYNALLOC1(char,gcode,gcode_sz,ii,"sgtog6");
p = gcode;
*p++ = '&';
encodegraphsize(n,&p);
bodylen = D6BODYLEN(n);
for (ii = 0; ii < bodylen; ++ii) p[ii] = 0;
p[bodylen] = '\n';
p[bodylen+1] = '\0';
for (i = 0, org = 0; i < n; org += n, ++i)
{
ei = e + v[i];
for (j = 0; j < d[i]; ++j)
{
ii = ei[j] + org;
p[ii/6] |= g6bit[ii%6];
}
}
for (ii = 0; ii < bodylen; ++ii) p[ii] += BIAS6;
return gcode;
}
/**************************************************************************/
void
writeg6(FILE *f, graph *g, int m, int n)
/* write graph to file in graph6 format */
{
writeline(f,ntog6(g,m,n));
}
/**************************************************************************/
void
writed6(FILE *f, graph *g, int m, int n)
/* write graph to file in digraph6 format */
{
writeline(f,ntod6(g,m,n));
}
/**************************************************************************/
void
writes6(FILE *f, graph *g, int m, int n)
/* write graph to file in sparse6 format */
{
char *s;
s = ntos6(g,m,n);
if (fwrite(s,1,s6len,f) != s6len || ferror(f))
gt_abort(">E writes6 : error on writing\n");
}
/**************************************************************************/
void
writeis6(FILE *f, graph *g, graph *prevg, int m, int n)
/* write graph to file in incremental sparse6 format
prevg can be NULL if there is no previous graph */
{
char *s;
s = ntois6(g,prevg,m,n);
if (fwrite(s,1,s6len,f) != s6len || ferror(f))
gt_abort(">E writeis6 : error on writing\n");
}
/**************************************************************************/
void
writeg6_sg(FILE *f, sparsegraph *g)
/* write undirected sparse graph to file in sparse6 format */
{
writeline(f,sgtog6(g));
}
/**************************************************************************/
void
writed6_sg(FILE *f, sparsegraph *g)
/* write undirected sparse graph to file in sparse6 format */
{
writeline(f,sgtod6(g));
}
/**************************************************************************/
void
writes6_sg(FILE *f, sparsegraph *g)
/* write undirected sparse graph to file in sparse6 format */
{
char *s;
s = sgtos6(g);
if (fwrite(s,1,s6len,f) != s6len || ferror(f))
gt_abort(">E writes6 : error on writing\n");
}
/**************************************************************************/
DYNALLSTAT(unsigned char,buff,buff_sz);
void
writepc_sg(FILE *f, sparsegraph *sg)
/* write a sparse graph in planar_code format
*f = an open file
*sg = the graph to write
*/
{
int bytes;
size_t i,j,len,k,*v,vi;
unsigned int w;
int n,*d,*e,di;
#define BEPUT1(x) buff[j++]=(unsigned char)(x);
#define BEPUT2(x) w=(x); buff[j++]=(unsigned char)((w>>8)&0xFF); \
buff[j++]=(unsigned char)(w&0xff);
#define BEPUT4(x) w=(x); buff[j++]=(unsigned char)((w>>24)&0xFF); \
buff[j++]=(unsigned char)((w>>16)&0xff); \
buff[j++]=(unsigned char)((w>>8)&0xFF); \
buff[j++]=(unsigned char)(w&0xff);
n = sg->nv;
SG_VDE(sg,v,d,e);
if (n <= 255) bytes = 1;
else if (n <= 65535) bytes = 2;
else bytes = 4;
len = bytes * (1 + n + (size_t)(sg->nde));
if (bytes == 2) len += 1;
else if (bytes == 4) len += 3;
DYNALLOC1(unsigned char,buff,buff_sz,len,"writepc_sg");
if (bytes == 1)
{
j = 0;
BEPUT1(n);
for (i = 0; i < n; ++i)
{
vi = v[i];
di = d[i];
for (k = 0; k < di; ++k) { BEPUT1(e[vi+k]+1); }
BEPUT1(0);
}
}
else if (bytes == 2)
{
j = 0;
BEPUT1(n);
BEPUT2(n);
for (i = 0; i < n; ++i)
{
vi = v[i];
di = d[i];
for (k = 0; k < di; ++k) { BEPUT2(e[vi+k]+1); }
BEPUT2(0);
}
}
else /* bytes==4 */
{
j = 0;
BEPUT1(n);
BEPUT2(n);
BEPUT4(n);
for (i = 0; i < n; ++i)
{
vi = v[i];
di = d[i];
for (k = 0; k < di; ++k) { BEPUT4(e[vi+k]+1); }
BEPUT4(0);
}
}
if (fwrite((void*)buff,1,j,f) != j)
gt_abort(">E writepc_sg : error on writing\n");
}
/**************************************************************************/
sparsegraph*
readpc_sg(FILE *f,sparsegraph *sg)
/* read a planar_code graph into sparse graph format
*f = an open file
*sg = place to put the answer (NULL for dynamic allocation)
- must be initialised if not NULL
*/
{
#define BEGET1(x) { x = GETC(f); }
#define BEGET2(x) { w1=GETC(f); w2=GETC(f); if (w2==EOF) x = EOF; else \
x = (w1<<8) | w2; }
#define BEGET4(x) { w1=GETC(f); w2=GETC(f); w3=GETC(f); w4=GETC(f); \
if (w4==EOF) x = EOF; \
else x = (w1<<24) | (w2<<16) | (w3<<8) | w4; }
int w1,w2,w3,w4;
int bytes,n;
int i,j,*d,*e,di;
size_t *v,vi;
BEGET1(n);
if (n == EOF || n < 0) return NULL;
else if (n > 0)
bytes = 1;
else
{
BEGET2(n);
if (n == EOF || n < 0)
gt_abort(">E readpc_sg : error 1 on reading\n");
else if (n > 0)
bytes = 2;
else
{
BEGET4(n);
if (n == EOF || n < 0)
gt_abort(">E readpc_sg : error 2 on reading\n");
else if (n > 0)
bytes = 4;
else
gt_abort(">E readpc_sg : error 3 on reading\n");
}
}
if (sg == NULL)
{
if ((sg = (sparsegraph*)ALLOCS(1,sizeof(sparsegraph))) == NULL)
gt_abort(">E readpc_sg: malloc failed\n");
SG_INIT(*sg);
}
SG_ALLOC(*sg,n,2*(size_t)n,"readpc_sg");
SG_VDE(sg,v,d,e);
vi = 0;
for (i = 0; i < n; ++i)
{
v[i] = vi;
di = 0;
do
{
if (bytes == 1) BEGET1(j)
else if (bytes == 2) BEGET2(j)
else BEGET4(j);
if (j == EOF) gt_abort(">E readpc_sg : error 4 on reading\n");
if (j > 0)
{
if (vi == sg->elen)
{
DYNREALLOC(int,sg->e,sg->elen,2*sg->elen,"readpc_sg");
e = sg->e;
}
e[vi++] = j-1;
++di;
}
else if (j == 0)
d[i] = di;
else
gt_abort(">E readpc_sg : error 5 on reading\n");
} while (j != 0);
}
sg->nv = n;
sg->nde = vi;
return sg;
}
/**************************************************************************/
sparsegraph*
readpcle_sg(FILE *f,sparsegraph *sg)
/* read a planar_code graph into sparse graph format
*f = an open file
*sg = place to put the answer (NULL for dynamic allocation)
- must be initialised if not NULL
*/
{
#define LEGET1(x) { x = GETC(f); }
#define LEGET2(x) { w2=GETC(f); w1=GETC(f); if (w1==EOF) x = EOF; else \
x = (w1<<8) | w2; }
#define LEGET4(x) { w4=GETC(f); w3=GETC(f); w2=GETC(f); w1=GETC(f); \
if (w1==EOF) x = EOF; \
else x = (w1<<24) | (w2<<16) | (w3<<8) | w4; }
int w1,w2,w3,w4;
int bytes,n;
int i,j,*d,*e,di;
size_t *v,vi;
LEGET1(n);
if (n == EOF || n < 0) return NULL;
else if (n > 0)
bytes = 1;
else
{
LEGET2(n);
if (n == EOF || n < 0)
gt_abort(">E readpcle_sg : error 1 on reading\n");
else if (n > 0)
bytes = 2;
else
{
LEGET4(n);
if (n == EOF || n < 0)
gt_abort(">E readpcle_sg : error 2 on reading\n");
else if (n > 0)
bytes = 4;
else
gt_abort(">E readpcle_sg : error 3 on reading\n");
}
}
if (sg == NULL)
{
if ((sg = (sparsegraph*)ALLOCS(1,sizeof(sparsegraph))) == NULL)
gt_abort(">E readpcle_sg: malloc failed\n");
SG_INIT(*sg);
}
SG_ALLOC(*sg,n,2*(size_t)n,"readpcle_sg");
SG_VDE(sg,v,d,e);
vi = 0;
for (i = 0; i < n; ++i)
{
v[i] = vi;
di = 0;
do
{
if (bytes == 1) LEGET1(j)
else if (bytes == 2) LEGET2(j)
else LEGET4(j);
if (j == EOF) gt_abort(">E readpcle_sg : error 4 on reading\n");
if (j > 0)
{
if (vi == sg->elen)
{
DYNREALLOC(int,sg->e,sg->elen,2*sg->elen,"readpcle_sg");
e = sg->e;
}
e[vi++] = j-1;
++di;
}
else if (j == 0)
d[i] = di;
else
gt_abort(">E readpcle_sg : error 5 on reading\n");
} while (j != 0);
}
sg->nv = n;
sg->nde = vi;
return sg;
}
/**************************************************************************/
void
writelast(FILE *f)
/* write last graph read by readg() assuming no intervening gtools_getline() */
{
writeline(f,readg_line);
}
/**************************************************************************/
int
longvalue(char **ps, long *l)
{
boolean neg,pos;
long sofar,last;
char *s;
s = *ps;
pos = neg = FALSE;
if (*s == '-')
{
neg = TRUE;
++s;
}
else if (*s == '+')
{
pos = TRUE;
++s;
}
if (*s < '0' || *s > '9')
{
*ps = s;
return (pos || neg) ? ARG_ILLEGAL : ARG_MISSING;
}
sofar = 0;
for (; *s >= '0' && *s <= '9'; ++s)
{
last = sofar;
sofar = sofar * 10 + (*s - '0');
if (sofar < last || sofar > MAXARG)
{
*ps = s;
return ARG_TOOBIG;
}
}
*ps = s;
*l = neg ? -sofar : sofar;
return ARG_OK;
}
/**************************************************************************/
int
doublevalue(char **ps, double *l)
{
boolean neg,pos;
double sofar,weight;
char *s;
s = *ps;
pos = neg = FALSE;
if (*s == '-')
{
neg = TRUE;
++s;
}
else if (*s == '+')
{
pos = TRUE;
++s;
}
if ((*s < '0' || *s > '9') && *s != '.')
{
*ps = s;
return (pos || neg) ? ARG_ILLEGAL : ARG_MISSING;
}
sofar = 0.0;
for (; *s >= '0' && *s <= '9'; ++s)
sofar = sofar * 10 + (*s - '0');
if (*s == '.')
{
weight = 1.0;
for (++s; *s >= '0' && *s <= '9'; ++s)
{
weight /= 10.0;
sofar += weight * (*s - '0');
}
}
*ps = s;
*l = neg ? -sofar : sofar;
return ARG_OK;
}
/*************************************************************************/
void
arg_long(char **ps, long *val, char *id)
{
int code;
code = longvalue(ps,val);
if (code == ARG_MISSING || code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: missing argument value\n",id);
gt_abort(NULL);
}
else if (code == ARG_TOOBIG)
{
fprintf(stderr,">E %s: argument value too large\n",id);
gt_abort(NULL);
}
}
/*************************************************************************/
void
arg_int(char **ps, int *val, char *id)
{
int code;
long longval;
code = longvalue(ps,&longval);
*val = longval;
if (code == ARG_MISSING || code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: missing argument value\n",id);
gt_abort(NULL);
}
else if (code == ARG_TOOBIG || *val != longval)
{
fprintf(stderr,">E %s: argument value too large\n",id);
gt_abort(NULL);
}
}
/*************************************************************************/
void
arg_double(char **ps, double *val, char *id)
{
int code;
code = doublevalue(ps,val);
if (code == ARG_MISSING || code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: missing argument value\n",id);
gt_abort(NULL);
}
}
/************************************************************************/
boolean
strhaschar(char *s, int c)
/* Check if s contains c. Saves the bother of figuring out whether
strchr() is available, or index() or whatever. */
{
int i;
for (i = 0; s[i] != '\0'; ++i)
if (s[i] == c) return TRUE;
return FALSE;
}
/************************************************************************/
void
arg_range(char **ps, char *sep, long *val1, long *val2, char *id)
{
int code;
char *s;
s = *ps;
code = longvalue(&s,val1);
if (code != ARG_MISSING)
{
if (code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: bad range\n",id);
gt_abort(NULL);
}
else if (code == ARG_TOOBIG)
{
fprintf(stderr,">E %s: value too big\n",id);
gt_abort(NULL);
}
}
else if (*s == '\0' || !strhaschar(sep,*s))
{
fprintf(stderr,">E %s: missing value\n",id);
gt_abort(NULL);
}
else
*val1 = -NOLIMIT;
if (*s != '\0' && strhaschar(sep,*s))
{
++s;
code = longvalue(&s,val2);
if (code == ARG_MISSING)
*val2 = NOLIMIT;
else if (code == ARG_TOOBIG)
{
fprintf(stderr,">E %s: value too big\n",id);
gt_abort(NULL);
}
else if (code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: illegal range\n",id);
gt_abort(NULL);
}
}
else
*val2 = *val1;
*ps = s;
}
/************************************************************************/
void
arg_sequence(char **ps, char *sep,
long *val, int maxvals, int *numvals, char *id)
{
int code,ival;
char *s;
s = *ps;
for (ival = 0; ival < maxvals; ++ival)
{
code = longvalue(&s,&val[ival]);
if (code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: illegal value\n",id);
gt_abort(NULL);
}
else if (code == ARG_TOOBIG)
{
fprintf(stderr,">E %s: value too big\n",id);
gt_abort(NULL);
}
else if (code == ARG_MISSING)
{
fprintf(stderr,">E %s: value missing\n",id);
gt_abort(NULL);
}
if (*s == '\0' || !strhaschar(sep,*s))
{
*numvals = ival+1;
*ps = s;
return;
}
++s;
}
fprintf(stderr,">E %s: too many values\n",id);
gt_abort(NULL);
}
/************************************************************************/
void
arg_sequence_min(char **ps, char *sep,
long *val, int minvals, int maxvals, int *numvals, char *id)
{
int code,ival;
char *s;
s = *ps;
for (ival = 0; ival < maxvals; ++ival)
{
code = longvalue(&s,&val[ival]);
if (code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: illegal value\n",id);
gt_abort(NULL);
}
else if (code == ARG_TOOBIG)
{
fprintf(stderr,">E %s: value too big\n",id);
gt_abort(NULL);
}
else if (code == ARG_MISSING)
{
fprintf(stderr,">E %s: value missing\n",id);
gt_abort(NULL);
}
if (*s == '\0' || !strhaschar(sep,*s))
{
*numvals = ival+1;
*ps = s;
if (*numvals < minvals)
{
fprintf(stderr,">E %s: too few values\n",id);
gt_abort(NULL);
}
return;
}
++s;
}
fprintf(stderr,">E %s: too many values\n",id);
gt_abort(NULL);
}
/************************************************************************/
void
arg_doublerange(char **ps, char *sep, double *val1, double *val2, char *id)
{
int code;
char *s;
s = *ps;
code = doublevalue(&s,val1);
if (code != ARG_MISSING)
{
if (code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: bad range\n",id);
gt_abort(NULL);
}
}
else if (*s == '\0' || !strhaschar(sep,*s))
{
fprintf(stderr,">E %s: missing value\n",id);
gt_abort(NULL);
}
else
*val1 = -NOLIMIT;
if (*s != '\0' && strhaschar(sep,*s))
{
++s;
code = doublevalue(&s,val2);
if (code == ARG_MISSING)
*val2 = NOLIMIT;
else if (code == ARG_ILLEGAL)
{
fprintf(stderr,">E %s: illegal range\n",id);
gt_abort(NULL);
}
}
else
*val2 = *val1;
*ps = s;
}
/***********************************************************************/
void
writerange(FILE *f, int c, long lo, long hi) /* Write a range. */
{
if (c != '\0') fprintf(f,"%c",c);
if (lo != -NOLIMIT) fprintf(f,"%ld",lo);
if (lo != hi)
{
fprintf(stderr,":");
if (hi != NOLIMIT) fprintf(f,"%ld",hi);
}
}
/************************************************************************/
void
gt_abort(const char *msg) /* Write message and halt. */
{
if (msg) fprintf(stderr,"%s",msg);
ABORT(">E gtools");
}
/************************************************************************/
char*
stringcopy(char *s) /* duplicate string */
{
char *scopy;
size_t i,len;
for (len = 0; s[len] != '\0'; ++len)
{}
if ((scopy = (char*)ALLOCS(len+1,1)) == NULL)
gt_abort(">E stringcopy: malloc failed\n");
for (i = 0; i <= len; ++i)
scopy[i] = s[i];
return scopy;
}
/*****************************************************************************
* *
* gtools_check() checks that this file is compiled compatibly with the *
* given parameters. If not, call exit(1). *
* *
*****************************************************************************/
void
gtools_check(int wordsize, int m, int n, int version)
{
if (wordsize != WORDSIZE)
{
fprintf(ERRFILE,"Error: WORDSIZE mismatch in gtools.c\n");
exit(1);
}
#if MAXN
if (m > MAXM)
{
fprintf(ERRFILE,"Error: MAXM inadequate in gtools.c\n");
exit(1);
}
if (n > MAXN)
{
fprintf(ERRFILE,"Error: MAXN inadequate in gtools.c\n");
exit(1);
}
#endif
if (version < NAUTYREQUIRED)
{
fprintf(ERRFILE,"Error: gtools.c version mismatch\n");
exit(1);
}
}
|
01157be11025f8286d6b5c7b9eb06ccace840344
|
fbe68d84e97262d6d26dd65c704a7b50af2b3943
|
/third_party/virtualbox/src/VBox/HostServices/SharedClipboard/VBoxClipboard.h
|
e22de7be6aad5a35ccfcf53f5ba317df34040e82
|
[
"MIT",
"GPL-2.0-only",
"LicenseRef-scancode-unknown-license-reference",
"CDDL-1.0",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"GPL-2.0-or-later",
"MPL-1.0",
"LicenseRef-scancode-generic-exception",
"Apache-2.0",
"OpenSSL"
] |
permissive
|
thalium/icebox
|
c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb
|
6f78952d58da52ea4f0e55b2ab297f28e80c1160
|
refs/heads/master
| 2022-08-14T00:19:36.984579
| 2022-02-22T13:10:31
| 2022-02-22T13:10:31
| 190,019,914
| 585
| 109
|
MIT
| 2022-01-13T20:58:15
| 2019-06-03T14:18:12
|
C++
|
UTF-8
|
C
| false
| false
| 2,799
|
h
|
VBoxClipboard.h
|
/** @file
*
* Shared Clipboard
*/
/*
* Copyright (C) 2006-2017 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef __VBOXCLIPBOARD__H
#define __VBOXCLIPBOARD__H
#define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
#include <VBox/hgcmsvc.h>
#include <VBox/log.h>
struct _VBOXCLIPBOARDCONTEXT;
typedef struct _VBOXCLIPBOARDCONTEXT VBOXCLIPBOARDCONTEXT;
typedef struct _VBOXCLIPBOARDCLIENTDATA
{
struct _VBOXCLIPBOARDCLIENTDATA *pNext;
struct _VBOXCLIPBOARDCLIENTDATA *pPrev;
VBOXCLIPBOARDCONTEXT *pCtx;
uint32_t u32ClientID;
bool fAsync; /* Guest is waiting for a message. */
bool fReadPending; /* The guest is waiting for data from the host */
bool fMsgQuit;
bool fMsgReadData;
bool fMsgFormats;
struct {
VBOXHGCMCALLHANDLE callHandle;
VBOXHGCMSVCPARM *paParms;
} async;
struct {
VBOXHGCMCALLHANDLE callHandle;
VBOXHGCMSVCPARM *paParms;
} asyncRead;
struct {
void *pv;
uint32_t cb;
uint32_t u32Format;
} data;
uint32_t u32AvailableFormats;
uint32_t u32RequestedFormat;
} VBOXCLIPBOARDCLIENTDATA;
/*
* The service functions. Locking is between the service thread and the platform dependent windows thread.
*/
bool vboxSvcClipboardLock (void);
void vboxSvcClipboardUnlock (void);
void vboxSvcClipboardReportMsg (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Msg, uint32_t u32Formats);
void vboxSvcClipboardCompleteReadData(VBOXCLIPBOARDCLIENTDATA *pClient, int rc, uint32_t cbActual);
bool vboxSvcClipboardGetHeadless(void);
/*
* Platform dependent functions.
*/
int vboxClipboardInit (void);
void vboxClipboardDestroy (void);
int vboxClipboardConnect (VBOXCLIPBOARDCLIENTDATA *pClient, bool fHeadless);
void vboxClipboardDisconnect (VBOXCLIPBOARDCLIENTDATA *pClient);
void vboxClipboardFormatAnnounce (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Formats);
int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual);
void vboxClipboardWriteData (VBOXCLIPBOARDCLIENTDATA *pClient, void *pv, uint32_t cb, uint32_t u32Format);
int vboxClipboardSync (VBOXCLIPBOARDCLIENTDATA *pClient);
/* Host unit testing interface */
#ifdef UNIT_TEST
uint32_t TestClipSvcGetMode(void);
#endif
#endif /* __VBOXCLIPBOARD__H */
|
de933b81916ba3b3e9372930a57064b735ad925f
|
4ae9c81d181354a4b1353dfbc89b2dacfc79ee39
|
/src/common/io/chunkedRead.c
|
6368c387cd19436304be9ae5f4038caf18a45b26
|
[
"MIT"
] |
permissive
|
pgbackrest/pgbackrest
|
558521e97030d00335f4000ec5f5230a880b972e
|
7e5adc03594a3b7a975001e80902a51df3ddd577
|
refs/heads/main
| 2023-03-09T00:02:47.145795
| 2023-03-07T11:46:24
| 2023-03-07T11:46:24
| 14,313,288
| 1,826
| 211
|
NOASSERTION
| 2023-09-14T13:56:30
| 2013-11-11T21:08:39
|
C
|
UTF-8
|
C
| false
| false
| 6,300
|
c
|
chunkedRead.c
|
/***********************************************************************************************************************************
Read Chunked I/O
***********************************************************************************************************************************/
#include "build.auto.h"
#include "common/debug.h"
#include "common/io/bufferRead.h"
#include "common/io/read.h"
#include "common/log.h"
#include "common/type/object.h"
/***********************************************************************************************************************************
Object type
***********************************************************************************************************************************/
typedef struct IoChunkedRead
{
IoRead *read; // IoRead to read chunked data from
bool eof; // Has the end of the chunked data been reached?
size_t chunkLast; // Size of the last chunk
size_t chunkRemains; // Remaining data in the current chunk
} IoChunkedRead;
/***********************************************************************************************************************************
Macros for function logging
***********************************************************************************************************************************/
#define FUNCTION_LOG_IO_CHUNKED_READ_TYPE \
IoChunkedRead *
#define FUNCTION_LOG_IO_CHUNKED_READ_FORMAT(value, buffer, bufferSize) \
objNameToLog(value, "IoChunkedRead", buffer, bufferSize)
/***********************************************************************************************************************************
Read next chunk size
***********************************************************************************************************************************/
static bool
ioChunkedReadNext(THIS_VOID)
{
THIS(IoChunkedRead);
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(IO_CHUNKED_READ, this);
FUNCTION_TEST_END();
const uint64_t chunkDelta = ioReadVarIntU64(this->read);
// Stop when chunk delta is zero, which indicates the end of the chunk list
if (chunkDelta == 0)
{
this->eof = true;
FUNCTION_TEST_RETURN(BOOL, false);
}
// Calculate next chunk size from delta
if (this->chunkLast == 0)
this->chunkRemains = (size_t)chunkDelta;
else
this->chunkRemains = (size_t)(cvtInt64FromZigZag(chunkDelta - 1) + (int64_t)this->chunkLast);
this->chunkLast = this->chunkRemains;
FUNCTION_TEST_RETURN(BOOL, true);
}
/***********************************************************************************************************************************
Read first chunk size
***********************************************************************************************************************************/
static bool
ioChunkedReadOpen(THIS_VOID)
{
THIS(IoChunkedRead);
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(IO_CHUNKED_READ, this);
FUNCTION_LOG_END();
ASSERT(this != NULL);
ioChunkedReadNext(this);
FUNCTION_LOG_RETURN(BOOL, true);
}
/***********************************************************************************************************************************
Read next chunk or partial chunk
***********************************************************************************************************************************/
static size_t
ioChunkedRead(THIS_VOID, Buffer *const buffer, const bool block)
{
THIS(IoChunkedRead);
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(IO_CHUNKED_READ, this);
FUNCTION_LOG_PARAM(BUFFER, buffer);
FUNCTION_LOG_PARAM(BOOL, block);
FUNCTION_LOG_END();
ASSERT(this != NULL);
ASSERT(buffer != NULL);
size_t actualBytes = 0;
// Keep reading until the output buffer is full
while (!bufFull(buffer))
{
// If the entire chunk will fit in the output buffer
if (this->chunkRemains < bufRemains(buffer))
{
bufLimitSet(buffer, bufUsed(buffer) + this->chunkRemains);
ioRead(this->read, buffer);
actualBytes += this->chunkRemains;
this->chunkRemains = 0;
// Read the next chunk header
if (!ioChunkedReadNext(this))
break;
}
// Else only part of the chunk will fit in the output
else
{
actualBytes += bufRemains(buffer);
this->chunkRemains -= bufRemains(buffer);
ioRead(this->read, buffer);
}
}
FUNCTION_LOG_RETURN(SIZE, actualBytes);
}
/***********************************************************************************************************************************
Have all chunks been read?
***********************************************************************************************************************************/
static bool
ioChunkedReadEof(THIS_VOID)
{
THIS(IoChunkedRead);
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(IO_CHUNKED_READ, this);
FUNCTION_LOG_END();
ASSERT(this != NULL);
FUNCTION_LOG_RETURN(BOOL, this->eof);
}
/**********************************************************************************************************************************/
FN_EXTERN IoRead *
ioChunkedReadNew(IoRead *const read)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(IO_READ, read);
FUNCTION_LOG_END();
ASSERT(read != NULL);
IoRead *this = NULL;
OBJ_NEW_BEGIN(IoChunkedRead, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
{
IoChunkedRead *const driver = OBJ_NAME(OBJ_NEW_ALLOC(), IoRead::IoChunkedRead);
*driver = (IoChunkedRead)
{
.read = read,
};
this = ioReadNewP(driver, .eof = ioChunkedReadEof, .open = ioChunkedReadOpen, .read = ioChunkedRead);
}
OBJ_NEW_END();
FUNCTION_LOG_RETURN(IO_READ, this);
}
|
61c6b296c8e404c44b8aa6430c5aff5bc5f625cd
|
1c015973d4df0f85787c93c486ce7917c1f0af0d
|
/ext/agoo/queue.h
|
2a81e5972f7751ee9696da1858d2acf91e472e15
|
[
"MIT"
] |
permissive
|
ohler55/agoo
|
73d4a876d79a2cd075d88f02a9260bccb031d1dd
|
20b47d51c1ea4b2660031f7b4bf7b9ed88413b4f
|
refs/heads/develop
| 2023-08-31T23:12:22.615271
| 2023-07-10T19:21:33
| 2023-07-10T19:21:33
| 115,074,220
| 853
| 43
|
MIT
| 2023-09-04T05:38:49
| 2017-12-22T03:51:02
|
C
|
UTF-8
|
C
| false
| false
| 1,186
|
h
|
queue.h
|
// Copyright 2015, 2016, 2018 by Peter Ohler, All Rights Reserved
#ifndef AGOO_QUEUE_H
#define AGOO_QUEUE_H
#include <stdbool.h>
#include <stdlib.h>
#include "atomic.h"
#include "err.h"
typedef void *agooQItem;
typedef struct _agooQueue {
agooQItem *q;
agooQItem *end;
_Atomic(agooQItem*) head;
_Atomic(agooQItem*) tail;
bool multi_push;
bool multi_pop;
atomic_flag push_lock; // set to true when push in progress
atomic_flag pop_lock; // set to true when push in progress
atomic_int wait_state;
int rsock;
int wsock;
} *agooQueue;
extern int agoo_queue_init(agooErr err, agooQueue q, size_t qsize);
extern int agoo_queue_multi_init(agooErr err, agooQueue q, size_t qsize, bool multi_push, bool multi_pop);
extern void agoo_queue_cleanup(agooQueue q);
extern void agoo_queue_push(agooQueue q, agooQItem item);
extern agooQItem agoo_queue_pop(agooQueue q, double timeout);
extern bool agoo_queue_empty(agooQueue q);
extern int agoo_queue_listen(agooQueue q);
extern void agoo_queue_release(agooQueue q);
extern int agoo_queue_count(agooQueue q);
extern void agoo_queue_wakeup(agooQueue q);
#endif // AGOO_QUEUE_H
|
a7610282baa3057d0f5ca3b0b18eb37f101ea0bb
|
e8b04bef9aa1ac8e2c109dd315f133c8f4d28ae6
|
/projects/robots/gctronic/e-puck/transfer/library/motor_led/advance_one_timer/e_agenda.c
|
881667eca19ce7b116230dd89c8a6de99b4101b0
|
[
"Apache-2.0"
] |
permissive
|
cyberbotics/webots
|
f075dacf4067e8dcebbfd89e8690df8525f6d745
|
8aba6eaae76989facf3442305c8089d3cc366bcf
|
refs/heads/master
| 2023-08-31T09:41:13.205940
| 2023-08-18T10:48:30
| 2023-08-18T10:48:30
| 156,228,018
| 2,495
| 1,525
|
Apache-2.0
| 2023-08-28T16:30:33
| 2018-11-05T14:09:10
|
C++
|
UTF-8
|
C
| false
| false
| 6,950
|
c
|
e_agenda.c
|
/********************************************************************************
Advance agenda events of e-puck
December 2004: first version
Lucas Meier & Francesco Mondada
This file is part of the e-puck library license.
See http://www.e-puck.org/index.php?option=com_content&task=view&id=18&Itemid=45
(c) 2004-2007 Francesco Mondada, Lucas Meier
Robotics system laboratory http://lsro.epfl.ch
Laboratory of intelligent systems http://lis.epfl.ch
Swarm intelligent systems group http://swis.epfl.ch
EPFL Ecole polytechnique federale de Lausanne http://www.epfl.ch
**********************************************************************************/
/*! \file
* \ingroup motor_LED
* \brief Manage the agendas (timer2)
*
* This module manage the agendas with the timer2.
* \n \n An agenda is a structure made to work as chained list. It containts:
* the function you want to launch, the time setup between two launching events,
* a counter to measure the current time, a pointer to the next element of the list.
* \n \n Each times the timer2 has an interrupt, all the agenda chained list is
* scanned to look if an agenda has to be treated according to the cycle value
* and current counter value.
* \n \n If one (or more) agenda has to be treated, his callback function is launch.
* \author Code: Francesco Mondada, Lucas Meier \n Doc: Jonathan Besuchet
*/
#include "e_agenda.h"
#include "../e_epuck_ports.h"
#include <stdlib.h>
#define EXIT_OK 1
/*!pointer on the end of agenda chained list */
static Agenda *agenda_list = 0;
/*! \brief Start the agendas processing
*
* Start the agendas processing by starting the Timer2.
*/
void e_start_agendas_processing(void)
{
T2CON = 0; // reset Timer2 CONtrol register
T2CONbits.TCKPS = 0; // precsaler = 1
TMR2 = 0; // clear timer 2
PR2 = (int)(0.1*MILLISEC); // interrupt every 0.1 ms with 64 prescaler
IFS0bits.T2IF = 0; // clear interrupt flag
IEC0bits.T2IE = 1; // set interrupt enable bit
T2CONbits.TON = 1; // start Timer2
}
/*! \brief Stop all the agendas
*
* Stop all the agendas by disabling Timer2
* \warning the memory allocated for the agenda isn't freed,
* use \ref e_destroy_agenda(void (*func)(void)) for that.
* \sa e_destroy_agenda
*/
void e_end_agendas_processing(void)
{
T2CONbits.TON = 0; // disable Timer2
}
/*! \brief Activate an agenda
*
* Activate an agenda and allocate memory for him if there isn't already
* an agenda with the same callback function
* (the agenda is active but isn't processed if he
* has a null cycle value).
* \param func function called if the cycle value is reached by the counter
* \param cycle cycle value in millisec/10
* \return \ref EXIT_OK if the agenda has been created, exit the programme otherwise
*/
int e_activate_agenda(void (*func)(void), int cycle)
{
Agenda *current = agenda_list;
while (current)
{
if (current->function == func)
return(AG_ALREADY_CREATED);
else
current = current->next;
}
if(!(current = malloc(sizeof(Agenda))))
exit (EXIT_FAILURE);
current->cycle = cycle;
current->counter = 0;
current->activate = 1;
current->function = func;
current->next = agenda_list;
agenda_list = current;
return(EXIT_OK);
}
/*! \brief Destroy an agenda
*
* Destroy the agenda with a given callback function.
* \param func function to test
* \return \ref EXIT_OK if the agenda has been destroyed, \ref AG_NOT_FOUND otherwise
*/
int e_destroy_agenda(void (*func)(void))
{
Agenda *preceding = 0;
Agenda *current = agenda_list;
while (current)
{
if (current->function == func)
{
if (preceding)
preceding->next = current->next;
else
agenda_list = current->next;
free(current);
return(EXIT_OK);
}
else
{
preceding = current;
current = current->next;
}
}
return(AG_NOT_FOUND);
}
/*! \brief Change the cycle value of an agenda
*
* Change the cycle value of an agenda with a given callback function.
* \param func function to test
* \param cycle new cycle value in millisec/10
* \return \ref EXIT_OK if the cycle of the agenda has been modified,
* \ref AG_NOT_FOUND otherwise
*/
int e_set_agenda_cycle(void (*func)(void), int cycle)
{
Agenda *current = agenda_list;
while (current)
{
if (current->function == func)
{
current->cycle = cycle;
return(EXIT_OK);
}
else
current = current->next;
}
return(AG_NOT_FOUND);
}
/*! \brief Reset an agenda's counter
*
* Reset an agenda's counter with a given callback function.
* \param func function to reset
* \return \ref EXIT_OK if the cycle of the agenda has been reseted,
* \ref AG_NOT_FOUND otherwise
* \warning This function RESET the agenda, if you just want a pause tell
* \ref e_pause_agenda(void (*func)(void))
* \sa e_pause_agenda
*/
int e_reset_agenda(void (*func)(void))
{
Agenda *current = agenda_list;
while (current)
{
if (current->function == func)
{
current->counter = 0;
return(EXIT_OK);
}
else
current = current->next;
}
return(AG_NOT_FOUND);
}
/*! \brief Pause an agenda
*
* Pause an agenda but do not reset its information.
* \param func function to pause
* \return \ref EXIT_OK the agenda has been paused,
* \ref AG_NOT_FOUND otherwise
*/
int e_pause_agenda(void (*func)(void))
{
Agenda *current = agenda_list;
while (current)
{
if (current->function == func)
{
current->activate = 0;
return(EXIT_OK);
}
else
current = current->next;
}
return(AG_NOT_FOUND);
}
/*! \brief Restart an agenda previously paused
*
* Restart an agenda previously paused.
* \param func function to restart
* \return \ref EXIT_OK if he agenda has been restarted,
* \ref AG_NOT_FOUND otherwise
* \sa e_pause_agenda
*/
int e_restart_agenda(void (*func)(void))
{
Agenda *current = agenda_list;
while (current)
{
if (current->function == func)
{
current->activate = 1;
return(EXIT_OK);
}
else
current = current->next;
}
return(AG_NOT_FOUND);
}
/*! \brief Interrupt from timer2
*
* Parse the chained list of agenda.
* \n Increment counter only.
* \n Check if agenda has to be treated according to the cycle value
* and current counter value.
* \n Do it for number of cycle positive or null.
* \n Check if a service has to be activated.
*/
void __attribute__((interrupt, auto_psv))
_T2Interrupt(void)
{
Agenda *current = agenda_list;
IFS0bits.T2IF = 0;
while (current)
{
// agenda must be active with a positive non-null cycle value
if(current->activate == 1 && current->cycle > 0)
{
current->counter++;
// check if the agenda event must be triggered
if(current->counter > current->cycle-1) // a cycle value of 1 will be performed every interupt
{
current->function(); // trigger the associeted function
current->counter=0; // reset the counter
}
}
current = current->next;
}
return;
}
/* End of File : alarm.c */
|
dd61a8c20fccc37ea39dd1103c72b95320ff7d15
|
fd016aacb50a65dbda2f0e2b35cec38a63baf68d
|
/targets/TI_SimpleLink/_common/simplelink_sockets.h
|
89c8f5f79c50e9bc45501ecaf87f84b7f95b6c03
|
[
"MIT"
] |
permissive
|
nanoframework/nf-interpreter
|
4795563afe8b1d8e4819a4b4ebd700c9e36a4d80
|
2ebb0aeef2d9482a6233e4c78f562878ba726cf6
|
refs/heads/main
| 2023-08-29T11:30:31.384324
| 2023-08-29T10:55:46
| 2023-08-29T10:55:46
| 74,834,622
| 283
| 266
|
MIT
| 2023-09-14T00:22:43
| 2016-11-26T15:45:06
|
C
|
UTF-8
|
C
| false
| false
| 723
|
h
|
simplelink_sockets.h
|
//
// Copyright (c) .NET Foundation and Contributors
// Portions Copyright (c) Texas Instruments Incorporated. All rights reserved.
// See LICENSE file in the project root for full license information.
//
#ifndef SIMPLELINK_SOCKETS_H
#define SIMPLELINK_SOCKETS_H
#include <nanoHAL.h>
#include <nanoHAL_ConfigurationManager.h>
#define NATIVE_PROFILE_PAL_NETWORK()
#ifdef __cplusplus
extern "C" {
#endif
bool SimpleLink_SOCKETS_Initialize();
bool SimpleLink_SOCKETS_Uninitialize();
void Status_callback();
void Link_callback(bool linkUp);
// void PostAddressChanged(void* arg);
// void PostAvailabilityOn(void* arg);
// void PostAvailabilityOff(void* arg);
#ifdef __cplusplus
}
#endif
#endif // SIMPLELINK_SOCKETS_H
|
976d998cec13aed957e82fbd67729de2c02421b9
|
46f7a44ef70b1f4c26760bab0e02fc9d097dcfe1
|
/src/Detector/darknet/src/layer.c
|
032a24e0f2c4e9e534fb23c1e7c31cadd191d3f5
|
[
"Apache-2.0"
] |
permissive
|
Smorodov/Multitarget-tracker
|
d9bf865ee4d842dfd858247f8baf304655c41c75
|
27fb61d15155591cc0be7d39daf0cc1a5c68284d
|
refs/heads/master
| 2023-08-30T09:26:40.310522
| 2023-08-10T15:17:29
| 2023-08-10T15:17:29
| 11,808,499
| 2,137
| 660
|
Apache-2.0
| 2023-08-10T15:17:31
| 2013-08-01T05:09:47
|
C++
|
UTF-8
|
C
| false
| false
| 13,147
|
c
|
layer.c
|
#include "layer.h"
#include "dark_cuda.h"
#include <stdlib.h>
void free_sublayer(layer *l)
{
if (l) {
free_layer(*l);
free(l);
}
}
void free_layer(layer l)
{
free_layer_custom(l, 0);
}
void free_layer_custom(layer l, int keep_cudnn_desc)
{
if (l.share_layer != NULL) return; // don't free shared layers
if (l.antialiasing) {
free_sublayer(l.input_layer);
}
if (l.type == CONV_LSTM) {
if (l.peephole) {
free_sublayer(l.vf);
free_sublayer(l.vi);
free_sublayer(l.vo);
}
else {
free(l.vf);
free(l.vi);
free(l.vo);
}
free_sublayer(l.wf);
if (!l.bottleneck) {
free_sublayer(l.wi);
free_sublayer(l.wg);
free_sublayer(l.wo);
}
free_sublayer(l.uf);
free_sublayer(l.ui);
free_sublayer(l.ug);
free_sublayer(l.uo);
}
if (l.type == CRNN) {
free_sublayer(l.input_layer);
free_sublayer(l.self_layer);
free_sublayer(l.output_layer);
l.output = NULL;
l.delta = NULL;
#ifdef GPU
l.output_gpu = NULL;
l.delta_gpu = NULL;
#endif // GPU
}
if (l.type == DROPOUT) {
if (l.rand) free(l.rand);
#ifdef GPU
if (l.rand_gpu) cuda_free(l.rand_gpu);
if (l.drop_blocks_scale) cuda_free_host(l.drop_blocks_scale);
if (l.drop_blocks_scale_gpu) cuda_free(l.drop_blocks_scale_gpu);
#endif
return;
}
if (l.mask) free(l.mask);
if (l.classes_multipliers)free(l.classes_multipliers);
if (l.cweights) free(l.cweights);
if (l.indexes) free(l.indexes);
if (l.input_layers) free(l.input_layers);
if (l.input_sizes) free(l.input_sizes);
if (l.layers_output) free(l.layers_output);
if (l.layers_delta) free(l.layers_delta);
if (l.map) free(l.map);
if (l.rand) free(l.rand);
if (l.cost) free(l.cost);
if (l.labels && !l.detection) free(l.labels);
if (l.class_ids && !l.detection) free(l.class_ids);
if (l.cos_sim) free(l.cos_sim);
if (l.exp_cos_sim) free(l.exp_cos_sim);
if (l.p_constrastive) free(l.p_constrastive);
if (l.embedding_output) free(l.embedding_output);
if (l.state) free(l.state);
if (l.prev_state) free(l.prev_state);
if (l.forgot_state) free(l.forgot_state);
if (l.forgot_delta) free(l.forgot_delta);
if (l.state_delta) free(l.state_delta);
if (l.concat) free(l.concat);
if (l.concat_delta) free(l.concat_delta);
if (l.binary_weights) free(l.binary_weights);
if (l.biases) free(l.biases), l.biases = NULL;
if (l.bias_updates) free(l.bias_updates), l.bias_updates = NULL;
if (l.scales) free(l.scales), l.scales = NULL;
if (l.scale_updates) free(l.scale_updates), l.scale_updates = NULL;
if (l.biases_ema) free(l.biases_ema), l.biases = NULL;
if (l.scales_ema) free(l.scales_ema), l.scales = NULL;
if (l.weights_ema) free(l.weights_ema), l.weights = NULL;
if (l.weights) free(l.weights), l.weights = NULL;
if (l.weight_updates) free(l.weight_updates), l.weight_updates = NULL;
if (l.align_bit_weights) free(l.align_bit_weights);
if (l.mean_arr) free(l.mean_arr);
#ifdef GPU
if (l.delta && l.delta_pinned) {
cudaFreeHost(l.delta);
l.delta = NULL;
}
if (l.output && l.output_pinned) {
cudaFreeHost(l.output);
l.output = NULL;
}
#endif // GPU
if (l.delta) free(l.delta), l.delta = NULL;
if (l.output) free(l.output), l.output = NULL;
if (l.activation_input) free(l.activation_input), l.activation_input = NULL;
if (l.squared) free(l.squared);
if (l.norms) free(l.norms);
if (l.spatial_mean) free(l.spatial_mean);
if (l.mean) free(l.mean), l.mean = NULL;
if (l.variance) free(l.variance), l.variance = NULL;
if (l.mean_delta) free(l.mean_delta), l.mean_delta = NULL;
if (l.variance_delta) free(l.variance_delta), l.variance_delta = NULL;
if (l.rolling_mean) free(l.rolling_mean), l.rolling_mean = NULL;
if (l.rolling_variance) free(l.rolling_variance), l.rolling_variance = NULL;
if (l.x) free(l.x);
if (l.x_norm) free(l.x_norm);
if (l.m) free(l.m);
if (l.v) free(l.v);
if (l.z_cpu) free(l.z_cpu);
if (l.r_cpu) free(l.r_cpu);
if (l.binary_input) free(l.binary_input);
if (l.bin_re_packed_input) free(l.bin_re_packed_input);
if (l.t_bit_input) free(l.t_bit_input);
if (l.loss) free(l.loss);
// CONV-LSTM
if (l.f_cpu) free(l.f_cpu);
if (l.i_cpu) free(l.i_cpu);
if (l.g_cpu) free(l.g_cpu);
if (l.o_cpu) free(l.o_cpu);
if (l.c_cpu) free(l.c_cpu);
if (l.h_cpu) free(l.h_cpu);
if (l.temp_cpu) free(l.temp_cpu);
if (l.temp2_cpu) free(l.temp2_cpu);
if (l.temp3_cpu) free(l.temp3_cpu);
if (l.dc_cpu) free(l.dc_cpu);
if (l.dh_cpu) free(l.dh_cpu);
if (l.prev_state_cpu) free(l.prev_state_cpu);
if (l.prev_cell_cpu) free(l.prev_cell_cpu);
if (l.stored_c_cpu) free(l.stored_c_cpu);
if (l.stored_h_cpu) free(l.stored_h_cpu);
if (l.cell_cpu) free(l.cell_cpu);
#ifdef GPU
if (l.indexes_gpu) cuda_free((float *)l.indexes_gpu);
if (l.contrast_p_gpu) cuda_free((float *)l.contrast_p_gpu);
if (l.z_gpu) cuda_free(l.z_gpu);
if (l.r_gpu) cuda_free(l.r_gpu);
if (l.m_gpu) cuda_free(l.m_gpu);
if (l.v_gpu) cuda_free(l.v_gpu);
if (l.forgot_state_gpu) cuda_free(l.forgot_state_gpu);
if (l.forgot_delta_gpu) cuda_free(l.forgot_delta_gpu);
if (l.state_gpu) cuda_free(l.state_gpu);
if (l.state_delta_gpu) cuda_free(l.state_delta_gpu);
if (l.gate_gpu) cuda_free(l.gate_gpu);
if (l.gate_delta_gpu) cuda_free(l.gate_delta_gpu);
if (l.save_gpu) cuda_free(l.save_gpu);
if (l.save_delta_gpu) cuda_free(l.save_delta_gpu);
if (l.concat_gpu) cuda_free(l.concat_gpu);
if (l.concat_delta_gpu) cuda_free(l.concat_delta_gpu);
if (l.binary_input_gpu) cuda_free(l.binary_input_gpu);
if (l.binary_weights_gpu) cuda_free(l.binary_weights_gpu);
if (l.mean_gpu) cuda_free(l.mean_gpu), l.mean_gpu = NULL;
if (l.variance_gpu) cuda_free(l.variance_gpu), l.variance_gpu = NULL;
if (l.m_cbn_avg_gpu) cuda_free(l.m_cbn_avg_gpu), l.m_cbn_avg_gpu = NULL;
if (l.v_cbn_avg_gpu) cuda_free(l.v_cbn_avg_gpu), l.v_cbn_avg_gpu = NULL;
if (l.rolling_mean_gpu) cuda_free(l.rolling_mean_gpu), l.rolling_mean_gpu = NULL;
if (l.rolling_variance_gpu) cuda_free(l.rolling_variance_gpu), l.rolling_variance_gpu = NULL;
if (l.variance_delta_gpu) cuda_free(l.variance_delta_gpu), l.variance_delta_gpu = NULL;
if (l.mean_delta_gpu) cuda_free(l.mean_delta_gpu), l.mean_delta_gpu = NULL;
if (l.x_norm_gpu) cuda_free(l.x_norm_gpu);
// assisted excitation
if (l.gt_gpu) cuda_free(l.gt_gpu);
if (l.a_avg_gpu) cuda_free(l.a_avg_gpu);
if (l.align_bit_weights_gpu) cuda_free((float *)l.align_bit_weights_gpu);
if (l.mean_arr_gpu) cuda_free(l.mean_arr_gpu);
if (l.align_workspace_gpu) cuda_free(l.align_workspace_gpu);
if (l.transposed_align_workspace_gpu) cuda_free(l.transposed_align_workspace_gpu);
if (l.weights_gpu) cuda_free(l.weights_gpu), l.weights_gpu = NULL;
if (l.weight_updates_gpu) cuda_free(l.weight_updates_gpu), l.weight_updates_gpu = NULL;
if (l.weight_deform_gpu) cuda_free(l.weight_deform_gpu), l.weight_deform_gpu = NULL;
if (l.weights_gpu16) cuda_free(l.weights_gpu16), l.weights_gpu16 = NULL;
if (l.weight_updates_gpu16) cuda_free(l.weight_updates_gpu16), l.weight_updates_gpu16 = NULL;
if (l.biases_gpu) cuda_free(l.biases_gpu), l.biases_gpu = NULL;
if (l.bias_updates_gpu) cuda_free(l.bias_updates_gpu), l.bias_updates_gpu = NULL;
if (l.scales_gpu) cuda_free(l.scales_gpu), l.scales_gpu = NULL;
if (l.scale_updates_gpu) cuda_free(l.scale_updates_gpu), l.scale_updates_gpu = NULL;
if (l.input_antialiasing_gpu) cuda_free(l.input_antialiasing_gpu), l.input_antialiasing_gpu = NULL;
if (l.optimized_memory < 2) {
if (l.x_gpu) cuda_free(l.x_gpu), l.x_gpu = NULL;
if (l.output_gpu) cuda_free(l.output_gpu), l.output_gpu = NULL;
if (l.output_avg_gpu) cuda_free(l.output_avg_gpu), l.output_avg_gpu = NULL;
if (l.activation_input_gpu) cuda_free(l.activation_input_gpu), l.activation_input_gpu = NULL;
}
if (l.delta_gpu && (l.optimized_memory < 1 || l.keep_delta_gpu && l.optimized_memory < 3)) cuda_free(l.delta_gpu), l.delta_gpu = NULL;
if (l.cos_sim_gpu) cuda_free(l.cos_sim_gpu);
if (l.rand_gpu) cuda_free(l.rand_gpu);
if (l.squared_gpu) cuda_free(l.squared_gpu);
if (l.norms_gpu) cuda_free(l.norms_gpu);
if (l.input_sizes_gpu) cuda_free((float*)l.input_sizes_gpu);
if (l.layers_output_gpu) cuda_free((float*)l.layers_output_gpu);
if (l.layers_delta_gpu) cuda_free((float*)l.layers_delta_gpu);
// CONV-LSTM
if (l.f_gpu) cuda_free(l.f_gpu);
if (l.i_gpu) cuda_free(l.i_gpu);
if (l.g_gpu) cuda_free(l.g_gpu);
if (l.o_gpu) cuda_free(l.o_gpu);
if (l.c_gpu) cuda_free(l.c_gpu);
if (l.h_gpu) cuda_free(l.h_gpu);
if (l.bottelneck_hi_gpu) cuda_free(l.bottelneck_hi_gpu);
if (l.bottelneck_delta_gpu) cuda_free(l.bottelneck_delta_gpu);
if (l.temp_gpu) cuda_free(l.temp_gpu);
if (l.temp2_gpu) cuda_free(l.temp2_gpu);
if (l.temp3_gpu) cuda_free(l.temp3_gpu);
if (l.dc_gpu) cuda_free(l.dc_gpu);
if (l.dh_gpu) cuda_free(l.dh_gpu);
if (l.prev_state_gpu) cuda_free(l.prev_state_gpu);
if (l.prev_cell_gpu) cuda_free(l.prev_cell_gpu);
if (l.stored_c_gpu) cuda_free(l.stored_c_gpu);
if (l.stored_h_gpu) cuda_free(l.stored_h_gpu);
if (l.last_prev_state_gpu) cuda_free(l.last_prev_state_gpu);
if (l.last_prev_cell_gpu) cuda_free(l.last_prev_cell_gpu);
if (l.cell_gpu) cuda_free(l.cell_gpu);
#ifdef CUDNN // shouldn't be used for -map
if (!keep_cudnn_desc) {
if (l.srcTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.srcTensorDesc));
if (l.dstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dstTensorDesc));
if (l.srcTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.srcTensorDesc16));
if (l.dstTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dstTensorDesc16));
if (l.dsrcTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dsrcTensorDesc));
if (l.ddstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.ddstTensorDesc));
if (l.dsrcTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.dsrcTensorDesc16));
if (l.ddstTensorDesc16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.ddstTensorDesc16));
if (l.normTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normTensorDesc));
if (l.normDstTensorDesc) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normDstTensorDesc));
if (l.normDstTensorDescF16) CHECK_CUDNN(cudnnDestroyTensorDescriptor(l.normDstTensorDescF16));
if (l.weightDesc) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.weightDesc));
if (l.weightDesc16) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.weightDesc16));
if (l.dweightDesc) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.dweightDesc));
if (l.dweightDesc16) CHECK_CUDNN(cudnnDestroyFilterDescriptor(l.dweightDesc16));
if (l.convDesc) CHECK_CUDNN(cudnnDestroyConvolutionDescriptor(l.convDesc));
if (l.poolingDesc) CHECK_CUDNN(cudnnDestroyPoolingDescriptor(l.poolingDesc));
//cudnnConvolutionFwdAlgo_t fw_algo, fw_algo16;
//cudnnConvolutionBwdDataAlgo_t bd_algo, bd_algo16;
//cudnnConvolutionBwdFilterAlgo_t bf_algo, bf_algo16;
}
#endif // CUDNN
#endif // GPU
}
|
5095617c333f87d2ed49339fee6560374697f44b
|
7c857119fe1505b1d80d6e62969661c06dc1a2f4
|
/BaseTools/Source/C/GenFw/ElfConvert.c
|
0ffa9b16893e10eb843b56fe2017eeb5c7856bf0
|
[
"BSD-2-Clause"
] |
permissive
|
CloverHackyColor/CloverBootloader
|
7042ca7dd6b513d22be591a295e49071ae1482ee
|
2711170df4f60b2ae5aa20add3e00f35cf57b7e5
|
refs/heads/master
| 2023-08-30T22:14:34.590134
| 2023-08-27T19:14:02
| 2023-08-27T19:14:02
| 205,810,121
| 4,734
| 770
|
BSD-2-Clause
| 2023-09-03T12:41:33
| 2019-09-02T08:22:14
|
C
|
UTF-8
|
C
| false
| false
| 5,615
|
c
|
ElfConvert.c
|
/** @file
Elf convert solution
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "WinNtInclude.h"
#ifndef __GNUC__
#include <windows.h>
#include <io.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <assert.h>
#include <Common/UefiBaseTypes.h>
#include <IndustryStandard/PeImage.h>
#include "EfiUtilityMsgs.h"
#include "GenFw.h"
#include "ElfConvert.h"
#include "Elf32Convert.h"
#include "Elf64Convert.h"
//
// Result Coff file in memory.
//
UINT8 *mCoffFile = NULL;
//
// COFF relocation data
//
EFI_IMAGE_BASE_RELOCATION *mCoffBaseRel;
UINT16 *mCoffEntryRel;
//
// Current offset in coff file.
//
UINT32 mCoffOffset;
UINT32 mCoffOffsetMax;
//
// Offset in Coff file of headers and sections.
//
UINT32 mTableOffset;
//
//mFileBufferSize
//
UINT32 mFileBufferSize;
//
//*****************************************************************************
// Common ELF Functions
//*****************************************************************************
//
VOID
CoffAddFixupEntry(
UINT16 Val
)
{
*mCoffEntryRel = Val;
mCoffEntryRel++;
mCoffBaseRel->SizeOfBlock += 2;
mCoffOffset += 2;
}
VOID
CoffAddFixup(
UINT32 Offset,
UINT8 Type
)
{
if (mCoffBaseRel == NULL
|| mCoffBaseRel->VirtualAddress != (Offset & ~0xfff)) {
if (mCoffBaseRel != NULL) {
//
// Add a null entry (is it required ?)
//
CoffAddFixupEntry (0);
//
// Pad for alignment.
//
if (mCoffOffset % 4 != 0)
CoffAddFixupEntry (0);
}
mCoffFile = realloc (
mCoffFile,
mCoffOffset + sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT
);
if (mCoffFile == NULL) {
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
}
assert (mCoffFile != NULL);
memset (
mCoffFile + mCoffOffset, 0,
sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT
);
mCoffBaseRel = (EFI_IMAGE_BASE_RELOCATION*)(mCoffFile + mCoffOffset);
mCoffBaseRel->VirtualAddress = Offset & ~0xfff;
mCoffBaseRel->SizeOfBlock = sizeof(EFI_IMAGE_BASE_RELOCATION);
mCoffEntryRel = (UINT16 *)(mCoffBaseRel + 1);
mCoffOffset += sizeof(EFI_IMAGE_BASE_RELOCATION);
}
//
// Fill the entry.
//
CoffAddFixupEntry((UINT16) ((Type << 12) | (Offset & 0xfff)));
}
VOID
CreateSectionHeader (
const CHAR8 *Name,
UINT32 Offset,
UINT32 Size,
UINT32 Flags
)
{
EFI_IMAGE_SECTION_HEADER *Hdr;
Hdr = (EFI_IMAGE_SECTION_HEADER*)(mCoffFile + mTableOffset);
strcpy((char *)Hdr->Name, Name);
Hdr->Misc.VirtualSize = Size;
Hdr->VirtualAddress = Offset;
Hdr->SizeOfRawData = Size;
Hdr->PointerToRawData = Offset;
Hdr->PointerToRelocations = 0;
Hdr->PointerToLinenumbers = 0;
Hdr->NumberOfRelocations = 0;
Hdr->NumberOfLinenumbers = 0;
Hdr->Characteristics = Flags;
mTableOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
}
//
//*****************************************************************************
// Functions called from GenFw main code.
//*****************************************************************************
//
INTN
IsElfHeader (
UINT8 *FileBuffer
)
{
return (FileBuffer[EI_MAG0] == ELFMAG0 &&
FileBuffer[EI_MAG1] == ELFMAG1 &&
FileBuffer[EI_MAG2] == ELFMAG2 &&
FileBuffer[EI_MAG3] == ELFMAG3);
}
BOOLEAN
ConvertElf (
UINT8 **FileBuffer,
UINT32 *FileLength
)
{
ELF_FUNCTION_TABLE ElfFunctions;
UINT8 EiClass;
mFileBufferSize = *FileLength;
//
// Determine ELF type and set function table pointer correctly.
//
VerboseMsg ("Check Elf Image Header");
EiClass = (*FileBuffer)[EI_CLASS];
if (EiClass == ELFCLASS32) {
#ifndef JIEF_DEBUG
// Some globals have the same name and that confuses the debugger.
// So it's better not to link with Elf32Convert.o when debugging x64
if (!InitializeElf32 (*FileBuffer, &ElfFunctions)) {
return FALSE;
}
#endif
} else if (EiClass == ELFCLASS64) {
if (!InitializeElf64 (*FileBuffer, &ElfFunctions)) {
return FALSE;
}
} else {
Error (NULL, 0, 3000, "Unsupported", "ELF EI_CLASS not supported.");
return FALSE;
}
//
// Compute sections new address.
//
VerboseMsg ("Compute sections new address.");
ElfFunctions.ScanSections ();
//
// Write and relocate sections.
//
VerboseMsg ("Write and relocate sections.");
if (!ElfFunctions.WriteSections (SECTION_TEXT)) {
return FALSE;
}
if (!ElfFunctions.WriteSections (SECTION_DATA)) {
return FALSE;
}
if (!ElfFunctions.WriteSections (SECTION_HII)) {
return FALSE;
}
//
// Translate and write relocations.
//
VerboseMsg ("Translate and write relocations.");
ElfFunctions.WriteRelocations ();
//
// Write debug info.
//
VerboseMsg ("Write debug info.");
ElfFunctions.WriteDebug ();
//
// Make sure image size is correct before returning the new image.
//
VerboseMsg ("Set image size.");
ElfFunctions.SetImageSize ();
//
// Replace.
//
free (*FileBuffer);
*FileBuffer = mCoffFile;
*FileLength = mCoffOffset;
//
// Free resources used by ELF functions.
//
ElfFunctions.CleanUp ();
return TRUE;
}
|
fdb994a878e91108fb79d57d1bd48f9cbdcf0045
|
6f286be4a4e16867cc6e488080b8e3eced1dcd62
|
/src/tools-TEST/BedpeFilter_Test.h
|
ef179f785a155571a15703ca5024e36948315f22
|
[
"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
| 425
|
h
|
BedpeFilter_Test.h
|
#include "TestFramework.h"
#include "Settings.h"
#include "NGSD.h"
TEST_CLASS(BedpeFilter_Test)
{
Q_OBJECT
private slots:
void filter_roi()
{
//test
EXECUTE("BedpeFilter", "-in " + TESTDATA("data_in/BedpeFilter_in1.bedpe") + " -bed " + TESTDATA("data_in/BedpeFilter_in.bed")
+ " -out out/BedpeFilter_out1.bedpe");
COMPARE_FILES("out/BedpeFilter_out1.bedpe", TESTDATA("data_out/BedpeFilter_out1.bedpe"));
}
};
|
53bb083ae9cff0e32d69e9c8c0142bb4bb234135
|
3a4f120f3211a1482b8ba826f4922fa741c5586e
|
/ip/Pmods/PmodTC1_v1_0/drivers/PmodTC1_v1_0/examples/main.c
|
7b4808a0d613f0ba7f2769ddfc947c5456cf6cf2
|
[
"MIT"
] |
permissive
|
Digilent/vivado-library
|
7135129c7e4fec84d17e1fe037598bd2124085eb
|
cbfde215a27053004cb41d85535c4a1bd1673e14
|
refs/heads/master
| 2023-09-05T22:04:31.189589
| 2023-08-22T17:23:00
| 2023-08-22T17:23:46
| 46,139,497
| 512
| 327
|
MIT
| 2023-08-22T17:23:47
| 2015-11-13T18:23:02
|
C
|
UTF-8
|
C
| false
| false
| 3,263
|
c
|
main.c
|
/******************************************************************************/
/* */
/* main.c -- Definition for PmodTC1 demo */
/* */
/******************************************************************************/
/* Author: Arthur Brown */
/* Copyright 2017, Digilent Inc. */
/******************************************************************************/
/* File Description: */
/* */
/* This file defines a demonstration for the use of the Pmod Thermocouple IP */
/* core. Temperature data in Fahrenheit and Celsius is streamed out over UART */
/* to a serial terminal such as TeraTerm twice per second. */
/* */
/* UART TYPE BAUD RATE */
/* uartns550 9600 */
/* uartlite Configurable only in HW design */
/* ps7_uart 115200 (configured by bootrom/bsp) */
/* */
/******************************************************************************/
/* Revision History: */
/* */
/* 02/28/2017(ArtVVB): Validated */
/* 02/14/2018(atangzwj): Validated for Vivado 2017.4 */
/* */
/******************************************************************************/
#include <stdio.h>
#include "PmodTC1.h"
#include "sleep.h"
#include "xil_cache.h"
#include "xparameters.h"
void DemoInitialize();
void DemoRun();
void DemoCleanup();
void EnableCaches();
void DisableCaches();
PmodTC1 myDevice;
int main(void) {
DemoInitialize();
DemoRun();
DemoCleanup();
return 0;
}
void DemoInitialize() {
EnableCaches();
TC1_begin(&myDevice, XPAR_PMODTC1_0_AXI_LITE_SPI_BASEADDR);
}
void DemoRun() {
double celsius, fahrenheit;
printf("Starting Pmod TC1 Demo...\n\r");
while (1) {
celsius = TC1_getTemp(&myDevice);
fahrenheit = TC1_tempC2F(celsius);
printf("Temperature: %f deg F %f deg C\n\r", (fahrenheit), (celsius));
usleep(500000);
}
}
void DemoCleanup() {
TC1_end(&myDevice);
DisableCaches();
}
void EnableCaches() {
#ifdef __MICROBLAZE__
#ifdef XPAR_MICROBLAZE_USE_ICACHE
Xil_ICacheEnable();
#endif
#ifdef XPAR_MICROBLAZE_USE_DCACHE
Xil_DCacheEnable();
#endif
#endif
}
void DisableCaches() {
#ifdef __MICROBLAZE__
#ifdef XPAR_MICROBLAZE_USE_ICACHE
Xil_ICacheDisable();
#endif
#ifdef XPAR_MICROBLAZE_USE_DCACHE
Xil_DCacheDisable();
#endif
#endif
}
|
289efdfe9f237c249baf4cf6a07f679d18fe3859
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/ffmpeg/tests/checkasm/idctdsp.c
|
c06e607d99068fe00b8775ad3db41a9e456fd068
|
[
"LGPL-2.1-only",
"LGPL-3.0-only",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.1-or-later",
"GPL-3.0-or-later",
"LGPL-3.0-or-later",
"IJG",
"LicenseRef-scancode-other-permissive",
"MIT",
"GPL-2.0-or-later",
"Apache-2.0",
"GPL-3.0-only",
"BSD-3-Clause"
] |
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
| 3,329
|
c
|
idctdsp.c
|
/*
* Copyright (c) 2022 Ben Avison
*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 <string.h>
#include "checkasm.h"
#include "libavcodec/idctdsp.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
#define IDCTDSP_TEST(func) { #func, offsetof(IDCTDSPContext, func) },
typedef struct {
const char *name;
size_t offset;
} test;
#define RANDOMIZE_BUFFER16(name, size) \
do { \
int i; \
for (i = 0; i < size; ++i) { \
uint16_t r = rnd() % 0x201 - 0x100; \
AV_WN16A(name##0 + i, r); \
AV_WN16A(name##1 + i, r); \
} \
} while (0)
#define RANDOMIZE_BUFFER8(name, size) \
do { \
int i; \
for (i = 0; i < size; ++i) { \
uint8_t r = rnd(); \
name##0[i] = r; \
name##1[i] = r; \
} \
} while (0)
static void check_add_put_clamped(void)
{
/* Source buffers are only as big as needed, since any over-read won't affect results */
LOCAL_ALIGNED_16(int16_t, src0, [64]);
LOCAL_ALIGNED_16(int16_t, src1, [64]);
/* Destination buffers have borders of one row above/below and 8 columns left/right to catch overflows */
LOCAL_ALIGNED_8(uint8_t, dst0, [10 * 24]);
LOCAL_ALIGNED_8(uint8_t, dst1, [10 * 24]);
AVCodecContext avctx = { 0 };
IDCTDSPContext h;
const test tests[] = {
IDCTDSP_TEST(add_pixels_clamped)
IDCTDSP_TEST(put_pixels_clamped)
IDCTDSP_TEST(put_signed_pixels_clamped)
};
ff_idctdsp_init(&h, &avctx);
for (size_t t = 0; t < FF_ARRAY_ELEMS(tests); ++t) {
void (*func)(const int16_t *, uint8_t * ptrdiff_t) = *(void **)((intptr_t) &h + tests[t].offset);
if (check_func(func, "idctdsp.%s", tests[t].name)) {
declare_func(void, const int16_t *, uint8_t *, ptrdiff_t);
RANDOMIZE_BUFFER16(src, 64);
RANDOMIZE_BUFFER8(dst, 10 * 24);
call_ref(src0, dst0 + 24 + 8, 24);
call_new(src1, dst1 + 24 + 8, 24);
if (memcmp(dst0, dst1, 10 * 24))
fail();
bench_new(src1, dst1 + 24 + 8, 24);
}
}
}
void checkasm_check_idctdsp(void)
{
check_add_put_clamped();
report("idctdsp");
}
|
72db6f4bf36807c56bd8d9b0834e56a63aa89bb3
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/mingw/math/tgammal.c
|
1c7d4ea94593a8801a9ae012115eac2b5bd869cd
|
[
"MIT",
"SunPro",
"LGPL-2.0-or-later",
"ZPL-2.1",
"LicenseRef-scancode-public-domain"
] |
permissive
|
ziglang/zig
|
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
|
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
|
refs/heads/master
| 2023-08-31T13:16:45.980913
| 2023-08-31T05:50:29
| 2023-08-31T05:50:29
| 40,276,274
| 25,560
| 2,399
|
MIT
| 2023-09-14T21:09:50
| 2015-08-06T00:51:28
|
Zig
|
UTF-8
|
C
| false
| false
| 10,641
|
c
|
tgammal.c
|
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include "cephes_mconf.h"
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
double tgamma(double x);
long double tgammal(long double x)
{
return tgamma(x);
}
#else
/*
gamma(x+2) = gamma(x+2) P(x)/Q(x)
0 <= x <= 1
Relative error
n=7, d=8
Peak error = 1.83e-20
Relative error spread = 8.4e-23
*/
#if UNK
static const uLD P[8] = {
{ { 4.212760487471622013093E-5L } },
{ { 4.542931960608009155600E-4L } },
{ { 4.092666828394035500949E-3L } },
{ { 2.385363243461108252554E-2L } },
{ { 1.113062816019361559013E-1L } },
{ { 3.629515436640239168939E-1L } },
{ { 8.378004301573126728826E-1L } },
{ { 1.000000000000000000009E0L } }
};
static const uLD Q[9] = {
{ { -1.397148517476170440917E-5L } },
{ { 2.346584059160635244282E-4L } },
{ { -1.237799246653152231188E-3L } },
{ { -7.955933682494738320586E-4L } },
{ { 2.773706565840072979165E-2L } },
{ { -4.633887671244534213831E-2L } },
{ { -2.243510905670329164562E-1L } },
{ { 4.150160950588455434583E-1L } },
{ { 9.999999999999999999908E-1L } }
};
#endif
#if IBMPC
static const uLD P[8] = {
{ { 0x434a,0x3f22,0x2bda,0xb0b2,0x3ff0, 0x0, 0x0, 0x0 } },
{ { 0xf5aa,0xe82f,0x335b,0xee2e,0x3ff3, 0x0, 0x0, 0x0 } },
{ { 0xbe6c,0x3757,0xc717,0x861b,0x3ff7, 0x0, 0x0, 0x0 } },
{ { 0x7f43,0x5196,0xb166,0xc368,0x3ff9, 0x0, 0x0, 0x0 } },
{ { 0x9549,0x8eb5,0x8c3a,0xe3f4,0x3ffb, 0x0, 0x0, 0x0 } },
{ { 0x8d75,0x23af,0xc8e4,0xb9d4,0x3ffd, 0x0, 0x0, 0x0 } },
{ { 0x29cf,0x19b3,0x16c8,0xd67a,0x3ffe, 0x0, 0x0, 0x0 } },
{ { 0x0000,0x0000,0x0000,0x8000,0x3fff, 0x0, 0x0, 0x0 } }
};
static const uLD Q[9] = {
{ { 0x5473,0x2de8,0x1268,0xea67,0xbfee, 0x0, 0x0, 0x0 } },
{ { 0x334b,0xc2f0,0xa2dd,0xf60e,0x3ff2, 0x0, 0x0, 0x0 } },
{ { 0xbeed,0x1853,0xa691,0xa23d,0xbff5, 0x0, 0x0, 0x0 } },
{ { 0x296e,0x7cb1,0x5dfd,0xd08f,0xbff4, 0x0, 0x0, 0x0 } },
{ { 0x0417,0x7989,0xd7bc,0xe338,0x3ff9, 0x0, 0x0, 0x0 } },
{ { 0x3295,0x3698,0xd580,0xbdcd,0xbffa, 0x0, 0x0, 0x0 } },
{ { 0x75ef,0x3ab7,0x4ad3,0xe5bc,0xbffc, 0x0, 0x0, 0x0 } },
{ { 0xe458,0x2ec7,0xfd57,0xd47c,0x3ffd, 0x0, 0x0, 0x0 } },
{ { 0x0000,0x0000,0x0000,0x8000,0x3fff, 0x0, 0x0, 0x0 } }
};
#endif
#if MIEEE
static const uLD P[8] = {
{ { 0x3ff00000,0xb0b22bda,0x3f22434a, 0 } },
{ { 0x3ff30000,0xee2e335b,0xe82ff5aa, 0 } },
{ { 0x3ff70000,0x861bc717,0x3757be6c, 0 } },
{ { 0x3ff90000,0xc368b166,0x51967f43, 0 } },
{ { 0x3ffb0000,0xe3f48c3a,0x8eb59549, 0 } },
{ { 0x3ffd0000,0xb9d4c8e4,0x23af8d75, 0 } },
{ { 0x3ffe0000,0xd67a16c8,0x19b329cf, 0 } },
{ { 0x3fff0000,0x80000000,0x00000000, 0 } }
};
static const uLD Q[9] = {
{ { 0xbfee0000,0xea671268,0x2de85473, 0 } },
{ { 0x3ff20000,0xf60ea2dd,0xc2f0334b, 0 } },
{ { 0xbff50000,0xa23da691,0x1853beed, 0 } },
{ { 0xbff40000,0xd08f5dfd,0x7cb1296e, 0 } },
{ { 0x3ff90000,0xe338d7bc,0x79890417, 0 } },
{ { 0xbffa0000,0xbdcdd580,0x36983295, 0 } },
{ { 0xbffc0000,0xe5bc4ad3,0x3ab775ef, 0 } },
{ { 0x3ffd0000,0xd47cfd57,0x2ec7e458, 0 } },
{ { 0x3fff0000,0x80000000,0x00000000, 0 } }
};
#endif
#define MAXGAML 1755.455L
/*static const long double LOGPI = 1.14472988584940017414L;*/
/* Stirling's formula for the gamma function
gamma(x) = sqrt(2 pi) x^(x-.5) exp(-x) (1 + 1/x P(1/x))
z(x) = x
13 <= x <= 1024
Relative error
n=8, d=0
Peak error = 9.44e-21
Relative error spread = 8.8e-4
*/
#if UNK
static const uLD STIR[9] = {
{ { 7.147391378143610789273E-4L } },
{ { -2.363848809501759061727E-5L } },
{ { -5.950237554056330156018E-4L } },
{ { 6.989332260623193171870E-5L } },
{ { 7.840334842744753003862E-4L } },
{ { -2.294719747873185405699E-4L } },
{ { -2.681327161876304418288E-3L } },
{ { 3.472222222230075327854E-3L } },
{ { 8.333333333333331800504E-2L } }
};
#endif
#if IBMPC
static const uLD STIR[9] = {
{ { 0x6ede,0x69f7,0x54e3,0xbb5d,0x3ff4, 0, 0, 0 } },
{ { 0xc395,0x0295,0x4443,0xc64b,0xbfef, 0, 0, 0 } },
{ { 0xba6f,0x7c59,0x5e47,0x9bfb,0xbff4, 0, 0, 0 } },
{ { 0x5704,0x1a39,0xb11d,0x9293,0x3ff1, 0, 0, 0 } },
{ { 0x30b7,0x1a21,0x98b2,0xcd87,0x3ff4, 0, 0, 0 } },
{ { 0xbef3,0x7023,0x6a08,0xf09e,0xbff2, 0, 0, 0 } },
{ { 0x3a1c,0x5ac8,0x3478,0xafb9,0xbff6, 0, 0, 0 } },
{ { 0xc3c9,0x906e,0x38e3,0xe38e,0x3ff6, 0, 0, 0 } },
{ { 0xa1d5,0xaaaa,0xaaaa,0xaaaa,0x3ffb, 0, 0, 0 } }
};
#endif
#if MIEEE
static const uLD STIR[9] = {
{ { 0x3ff40000,0xbb5d54e3,0x69f76ede, 0 } },
{ { 0xbfef0000,0xc64b4443,0x0295c395, 0 } },
{ { 0xbff40000,0x9bfb5e47,0x7c59ba6f, 0 } },
{ { 0x3ff10000,0x9293b11d,0x1a395704, 0 } },
{ { 0x3ff40000,0xcd8798b2,0x1a2130b7, 0 } },
{ { 0xbff20000,0xf09e6a08,0x7023bef3, 0 } },
{ { 0xbff60000,0xafb93478,0x5ac83a1c, 0 } },
{ { 0x3ff60000,0xe38e38e3,0x906ec3c9, 0 } },
{ { 0x3ffb0000,0xaaaaaaaa,0xaaaaa1d5, 0 } }
};
#endif
#define MAXSTIR 1024.0L
static const long double SQTPI = 2.50662827463100050242E0L;
/* 1/gamma(x) = z P(z)
* z(x) = 1/x
* 0 < x < 0.03125
* Peak relative error 4.2e-23
*/
#if UNK
static const uLD S[9] = {
{ { -1.193945051381510095614E-3L } },
{ { 7.220599478036909672331E-3L } },
{ { -9.622023360406271645744E-3L } },
{ { -4.219773360705915470089E-2L } },
{ { 1.665386113720805206758E-1L } },
{ { -4.200263503403344054473E-2L } },
{ { -6.558780715202540684668E-1L } },
{ { 5.772156649015328608253E-1L } },
{ { 1.000000000000000000000E0L } }
};
#endif
#if IBMPC
static const uLD S[9] = {
{ { 0xbaeb,0xd6d3,0x25e5,0x9c7e,0xbff5, 0, 0, 0 } },
{ { 0xfe9a,0xceb4,0xc74e,0xec9a,0x3ff7, 0, 0, 0 } },
{ { 0x9225,0xdfef,0xb0e9,0x9da5,0xbff8, 0, 0, 0 } },
{ { 0x10b0,0xec17,0x87dc,0xacd7,0xbffa, 0, 0, 0 } },
{ { 0x6b8d,0x7515,0x1905,0xaa89,0x3ffc, 0, 0, 0 } },
{ { 0xf183,0x126b,0xf47d,0xac0a,0xbffa, 0, 0, 0 } },
{ { 0x7bf6,0x57d1,0xa013,0xa7e7,0xbffe, 0, 0, 0 } },
{ { 0xc7a9,0x7db0,0x67e3,0x93c4,0x3ffe, 0, 0, 0 } },
{ { 0x0000,0x0000,0x0000,0x8000,0x3fff, 0, 0, 0 } }
};
#endif
#if MIEEE
static const long S[9] = {
{ { 0xbff50000,0x9c7e25e5,0xd6d3baeb, 0 } },
{ { 0x3ff70000,0xec9ac74e,0xceb4fe9a, 0 } },
{ { 0xbff80000,0x9da5b0e9,0xdfef9225, 0 } },
{ { 0xbffa0000,0xacd787dc,0xec1710b0, 0 } },
{ { 0x3ffc0000,0xaa891905,0x75156b8d, 0 } },
{ { 0xbffa0000,0xac0af47d,0x126bf183, 0 } },
{ { 0xbffe0000,0xa7e7a013,0x57d17bf6, 0 } },
{ { 0x3ffe0000,0x93c467e3,0x7db0c7a9, 0 } },
{ { 0x3fff0000,0x80000000,0x00000000, 0 } }
};
#endif
/* 1/gamma(-x) = z P(z)
* z(x) = 1/x
* 0 < x < 0.03125
* Peak relative error 5.16e-23
* Relative error spread = 2.5e-24
*/
#if UNK
static const uLD SN[9] = {
{ { 1.133374167243894382010E-3L } },
{ { 7.220837261893170325704E-3L } },
{ { 9.621911155035976733706E-3L } },
{ { -4.219773343731191721664E-2L } },
{ { -1.665386113944413519335E-1L } },
{ { -4.200263503402112910504E-2L } },
{ { 6.558780715202536547116E-1L } },
{ { 5.772156649015328608727E-1L } },
{ { -1.000000000000000000000E0L } }
};
#endif
#if IBMPC
static const uLD SN[9] = {
{ { 0x5dd1,0x02de,0xb9f7,0x948d,0x3ff5, 0, 0, 0 } },
{ { 0x989b,0xdd68,0xc5f1,0xec9c,0x3ff7, 0, 0, 0 } },
{ { 0x2ca1,0x18f0,0x386f,0x9da5,0x3ff8, 0, 0, 0 } },
{ { 0x783f,0x41dd,0x87d1,0xacd7,0xbffa, 0, 0, 0 } },
{ { 0x7a5b,0xd76d,0x1905,0xaa89,0xbffc, 0, 0, 0 } },
{ { 0x7f64,0x1234,0xf47d,0xac0a,0xbffa, 0, 0, 0 } },
{ { 0x5e26,0x57d1,0xa013,0xa7e7,0x3ffe, 0, 0, 0 } },
{ { 0xc7aa,0x7db0,0x67e3,0x93c4,0x3ffe, 0, 0, 0 } },
{ { 0x0000,0x0000,0x0000,0x8000,0xbfff, 0, 0, 0 } }
};
#endif
#if MIEEE
static const uLD SN[9] = {
{ { 0x3ff50000,0x948db9f7,0x02de5dd1, 0 } },
{ { 0x3ff70000,0xec9cc5f1,0xdd68989b, 0 } },
{ { 0x3ff80000,0x9da5386f,0x18f02ca1, 0 } },
{ { 0xbffa0000,0xacd787d1,0x41dd783f, 0 } },
{ { 0xbffc0000,0xaa891905,0xd76d7a5b, 0 } },
{ { 0xbffa0000,0xac0af47d,0x12347f64, 0 } },
{ { 0x3ffe0000,0xa7e7a013,0x57d15e26, 0 } },
{ { 0x3ffe0000,0x93c467e3,0x7db0c7aa, 0 } },
{ { 0xbfff0000,0x80000000,0x00000000, 0 } }
};
#endif
static long double stirf (long double);
/* Gamma function computed by Stirling's formula. */
static long double stirf(long double x)
{
long double y, w, v;
w = 1.0L/x;
/* For large x, use rational coefficients from the analytical expansion. */
if (x > 1024.0L)
w = (((((6.97281375836585777429E-5L * w
+ 7.84039221720066627474E-4L) * w
- 2.29472093621399176955E-4L) * w
- 2.68132716049382716049E-3L) * w
+ 3.47222222222222222222E-3L) * w
+ 8.33333333333333333333E-2L) * w
+ 1.0L;
else
w = 1.0L + w * polevll( w, STIR, 8 );
y = expl(x);
if (x > MAXSTIR)
{ /* Avoid overflow in pow() */
v = powl(x, 0.5L * x - 0.25L);
y = v * (v / y);
}
else
{
y = powl(x, x - 0.5L) / y;
}
y = SQTPI * y * w;
return (y);
}
long double __tgammal_r(long double, int *);
long double __tgammal_r(long double x, int* sgngaml)
{
long double p, q, z;
int i;
*sgngaml = 1;
#ifdef NANS
if (isnanl(x))
return x;
#endif
#ifdef INFINITIES
#ifdef NANS
if (x == INFINITYL)
return (x);
if (x == -INFINITYL)
return (NANL);
#else
if (!isfinite(x))
return (x);
#endif
#endif
if (x == 0.0L)
return copysignl(HUGE_VALL, x);
q = fabsl(x);
if (q > 13.0L)
{
if (q > MAXGAML)
goto goverf;
if (x < 0.0L)
{
p = floorl(q);
if (p == q)
{
gsing:
_SET_ERRNO(EDOM);
mtherr("tgammal", SING);
#ifdef NANS
return (NAN);
#else
return (*sgngaml * MAXNUML);
#endif
}
i = p;
if ((i & 1) == 0)
*sgngaml = -1;
z = q - p;
if (z > 0.5L)
{
p += 1.0L;
z = q - p;
}
z = q * sinl(PIL * z);
z = fabsl(z) * stirf(q);
if (z <= PIL/MAXNUML)
{
goverf:
_SET_ERRNO(ERANGE);
mtherr("tgammal", OVERFLOW);
#ifdef INFINITIES
return(*sgngaml * INFINITYL);
#else
return(*sgngaml * MAXNUML);
#endif
}
z = PIL/z;
}
else
{
z = stirf(x);
}
return (*sgngaml * z);
}
z = 1.0L;
while (x >= 3.0L)
{
x -= 1.0L;
z *= x;
}
while (x < -0.03125L)
{
z /= x;
x += 1.0L;
}
if (x <= 0.03125L)
goto Small;
while (x < 2.0L)
{
z /= x;
x += 1.0L;
}
if (x == 2.0L)
return (z);
x -= 2.0L;
p = polevll( x, P, 7 );
q = polevll( x, Q, 8 );
return (z * p / q);
Small:
if (x == 0.0L)
{
goto gsing;
}
else
{
if (x < 0.0L)
{
x = -x;
q = z / (x * polevll(x, SN, 8));
}
else
q = z / (x * polevll(x, S, 8));
}
return q;
}
/* This is the C99 version. */
long double tgammal(long double x)
{
int local_sgngaml = 0;
return (__tgammal_r(x, &local_sgngaml));
}
#endif
|
c44260cf83f1d851cbf83f289c0ded4a835fb8aa
|
9746c6821b6c13e9089f1eeee1b53efcafb4a84f
|
/src/private.h
|
bc5c7032c0ed02229a7d763bdd4bf0848ff639da
|
[
"MIT"
] |
permissive
|
intel/kernel-fuzzer-for-xen-project
|
3c953d3e2ff8d497435b3eddd2b3bcce570f705c
|
3458cf6ecdddf4aa3d85484915eb4fa7d2f378e4
|
refs/heads/master
| 2023-08-20T22:14:24.086023
| 2023-05-26T18:56:48
| 2023-05-26T18:56:48
| 261,611,628
| 457
| 80
|
MIT
| 2023-05-26T18:56:49
| 2020-05-06T00:14:07
|
C
|
UTF-8
|
C
| false
| false
| 1,529
|
h
|
private.h
|
/*
* Copyright (C) 2020 Intel Corporation
* SPDX-License-Identifier: MIT
*/
#ifndef PRIVATE_H
#define PRIVATE_H
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <glib.h>
#include <capstone.h>
#include "config.h"
#include "signal.h"
#include "vmi.h"
#include "afl.h"
#include "setup.h"
#include "tracer.h"
#include "forkvm.h"
#include "ptcov.h"
#include "sink.h"
extern char *domain;
extern char *json;
extern FILE *input_file;
extern char *input_path;
extern size_t input_size;
extern size_t input_limit;
extern unsigned char *input;
extern uint32_t domid, sinkdomid, fuzzdomid;
extern char* fork_sig;
extern bool afl;
extern bool parent_ready;
extern bool crash;
extern bool setup;
extern bool debug;
extern bool loopmode;
extern bool nocov;
extern bool ptcov;
extern addr_t address;
extern unsigned long limit;
extern const char* record_codecov;
extern const char* record_memaccess;
extern GHashTable *codecov;
extern GHashTable *memaccess;
extern xc_interface *xc;
extern libxl_ctx *xl;
extern vmi_instance_t vmi;
extern os_t os;
extern addr_t target_pagetable;
extern addr_t start_rip;
extern page_mode_t pm;
extern int interrupted;
extern int vcpus;
extern GSList* doublefetch;
extern bool harness_cpuid;
extern bool extended_mark;
extern unsigned int magic_mark;
extern uint8_t start_byte;
extern csh cs_handle;
extern bool builtin_list;
extern GSList *sink_list;
#endif
|
8a6316baeb094ee0dcd18543563d92685abe8060
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/nuvoton/libraries/nu_packages/Demo/usbd_cdc_vcom_echo.c
|
252a52b1abf245e95e82c1c1587c3924559f19fe
|
[
"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
| 2,327
|
c
|
usbd_cdc_vcom_echo.c
|
/**************************************************************************//**
*
* @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-1-10 Wayne First version
*
******************************************************************************/
#include <rtthread.h>
#if defined(RT_USB_DEVICE_CDC) && (defined(BSP_USING_USBD) || defined(BSP_USING_HSUSBD))
static struct rt_semaphore rx_sem;
static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
{
rt_err_t result = 0;
result = rt_sem_release(&rx_sem);
RT_ASSERT(result == RT_EOK);
return RT_EOK;
}
static void serial_thread_entry(void *parameter)
{
rt_device_t serial = (rt_device_t)parameter;
char ch;
char szStr[64];
while (1)
{
while (rt_device_read(serial, -1, &ch, 1) != 1)
{
if (rt_sem_take(&rx_sem, 3 * RT_TICK_PER_SECOND) == -RT_ETIMEOUT)
{
/* output current tick */
rt_snprintf(szStr, sizeof(szStr), "%d\n", rt_tick_get());
rt_device_write(serial, 0, &szStr[0], rt_strlen(szStr));
continue;
}
}
rt_device_write(serial, 0, &ch, 1);
}
}
static int vcom_echo_init(void)
{
rt_err_t result = 0;
rt_thread_t thread;
rt_device_t serial;
serial = rt_device_find("vcom");
if (!serial)
{
rt_kprintf("find failed!\n");
return -RT_ERROR;
}
result = rt_device_init(serial);
if (result)
{
rt_kprintf("init failed!\n");
return -1;
}
result = rt_device_open(serial, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX/* | RT_DEVICE_FLAG_DMA_TX */);
if (result)
{
rt_kprintf("open failed!\n");
return -1;
}
result = rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK);
result = rt_device_set_rx_indicate(serial, uart_input);
RT_ASSERT(result == RT_EOK);
thread = rt_thread_create("serial", serial_thread_entry, (void *)serial, 1024, 25, 10);
if (thread != RT_NULL)
{
result = rt_thread_startup(thread);
RT_ASSERT(result == RT_EOK);
}
return 0;
}
INIT_APP_EXPORT(vcom_echo_init);
#endif
|
3b9a9e3e68e6451ec1d606eba255a6ff5ccb6b25
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/Infineon/libraries/IFX_PSOC6_HAL/mtb-pdl-cat1/drivers/include/cy_lpcomp.h
|
10a04427094650788c0b7e2e03a6ea8960009a21
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later"
] |
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
| 35,763
|
h
|
cy_lpcomp.h
|
/***************************************************************************//**
* \file cy_lpcomp.h
* \version 1.50
*
* This file provides constants and parameter values for the Low Power Comparator driver.
*
********************************************************************************
* \copyright
* (c) (2016-2022), Cypress Semiconductor Corporation (an Infineon company) or
* an affiliate of Cypress Semiconductor Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*******************************************************************************/
/**
* \addtogroup group_lpcomp
* \{
* Provides access to low-power comparators implemented using the fixed-function,
* LP comparator block that is present in the CAT1A and CAT1D devices.
*
* The functions and other declarations used in this driver are in the cy_lpcomp.h file.
* You can include the cy_pdl.h to get access to all functions
* and declarations in the PDL.
*
* Such comparators can perform a fast analog signal comparison of internal
* and external analog signals in all system power modes. The low-power comparator
* output can be inspected by the CPU, used as an interrupt/wakeup source to the
* CPU in Low-power mode (Sleep, Low-power Sleep or Deep-Sleep), used as
* a wakeup source to system resources in Hibernate mode, or fed to DSI as
* an asynchronous or synchronous signal (level or pulse).
*
* \section group_lpcomp_section_Configuration_Considerations Configuration Considerations
* To set up a low-power comparator, the inputs, output, mode, interrupts and
* the other configuration parameters are configured. Power the low-power comparator
* to start it operate.
*
* The sequence recommended for the low-power comparator operation:
*
* 1) To initialize the driver, call the Cy_LPComp_Init_Ext() function providing
* the filled cy_stc_lpcomp_config_t structure, the low-power comparator
* channel number and the low-power comparator registers structure pointer.
*
* 2) Optionally, configure the interrupt requests if the interrupt event
* triggering is needed. Use the Cy_LPComp_SetInterruptMask() function with
* the parameter for the mask available in the configuration file.
* Additionally, enable the Global interrupts and initialize the referenced
* interrupt by setting the priority and the interrupt vector using
* the \ref Cy_SysInt_Init() function of the sysint driver.
*
* 3) Configure the inputs and the output using the \ref Cy_GPIO_Pin_Init()
* functions of the GPIO driver.
* High Impedance Analog drive mode is for the inputs and
* Strong drive mode - for the output.
* Use the Cy_LPComp_SetInputs() function to connect the comparator inputs
* to the dedicated IO pins, AMUXBUSA/AMUXBUSB or Vref:
* \image html lpcomp_inputs.png
*
* 4) Power on the comparator using the Cy_LPComp_Enable_Ext() function.
*
* 5) The comparator output can be monitored using
* the Cy_LPComp_GetCompare() function or using the low-power comparator
* interrupt (if the interrupt is enabled).
*
* \note The interrupt is not cleared automatically.
* It is the user's responsibility to do that.
* The interrupt is cleared by writing "1" in the corresponding interrupt
* register bit position. The preferred way to clear interrupt sources
* is using the Cy_LPComp_ClearInterrupt() function.
*
* \note Individual comparator interrupt outputs are ORed together
* as a single asynchronous interrupt source before it is sent out and
* used to wake up the system in the low-power mode.
* For CAT1A, CAT1D devices, the individual comparator interrupt is masked
* by the INTR_MASK register. The masked result is captured in
* the INTR_MASKED register.
* Writing "1" to the INTR register bit will clear the interrupt.
*
* \section group_lpcomp_lp Low Power Support
* The low-power comparator provides callback functions to facilitate
* the low-power mode transition.
* Call \ref Cy_LPComp_DeepSleepCallback during execution of
* \ref Cy_SysPm_CpuEnterDeepSleep.
* Call \ref Cy_LPComp_HibernateCallback during execution of
* \ref Cy_SysPm_SystemEnterHibernate.
* To trigger callback execution, register the callback before calling
* the mode transition function.
* Refer to \ref group_syspm driver for more
* information about low-power mode transition.
*
* The example below shows the entering Hibernate mode.
* The positive low-power comparator input connects to the dedicated GPIO pin
* and the negative low-power comparator input connects to the local reference.
* The LED blinks twice after a device reset and goes into Hibernate mode.
* When the voltage on the positive input is greater than the local reference
* voltage (0.45V - 0.75V), the device wakes up and the LED starts blinking. \n
* Section of declarations:
* \snippet lpcomp/snippet/main.c LP_COMP_CFG_HIBERNATE
* Section of application code:
* \snippet lpcomp/snippet/main.c LP_COMP_FUNC_HIBERNATE
* \section group_lpcomp_more_information More Information
*
* For a detailed description of the registers, refer to
* the appropriate device technical reference manual (TRM).
*
* \section group_lpcomp_Changelog Changelog
* <table class="doxtable">
* <tr><th>Version</th><th>Changes</th><th>Reason for Change</th></tr>
* <tr>
* <td>1.50</td>
* <td> * Minor improvement in implementation of disabling functionality for the comparator.
* * Documented MISRA C-2012 violation of the Rule 10.3.
* </td>
* <td>
* * Power drive mode for the comparator is restored to the level before disabling,
* instead of initial level.
* * MISRA C-2012 compliance.
* </td>
* </tr>
* <tr>
* <td>1.40</td>
* <td>Introduced an extended versions of the existing functions with
* a pointer to the context structure allocated by the user:
* * \ref Cy_LPComp_Init_Ext(),
* * \ref Cy_LPComp_Enable_Ext(),
* * \ref Cy_LPComp_Disable_Ext(),
* * \ref Cy_LPComp_SetInterruptTriggerMode_Ext(),
* * \ref Cy_LPComp_SetPower_Ext()
* </td>
* <td>
* * Improved returning of the comparator from disabled to operational state
* with restoring power drive and interrupt edge-detect modes, configured before disable.
* * Improved thread safe implementation of the PDL.
* </td>
* </tr>
* <tr>
* <td>1.30</td>
* <td>Fixed/documented MISRA 2012 violations.</td>
* <td>MISRA 2012 compliance.</td>
* </tr>
* <tr>
* <td>1.20.1</td>
* <td>Minor documentation updates.</td>
* <td>Documentation enhancement.</td>
* </tr>
* <tr>
* <td rowspan="2">1.20</td>
* <td>Flattened the organization of the driver source code into the single
* source directory and the single include directory.
* </td>
* <td>Driver library directory-structure simplification.</td>
* </tr>
* <tr>
* <td>Added register access layer. Use register access macros instead
* of direct register access using de-referenced pointers.</td>
* <td>Makes register access device-independent, so that the PDL does
* not need to be recompiled for each supported part number.</td>
* </tr>
* <tr>
* <td>1.10.1</td>
* <td>Added Low Power Callback section</td>
* <td>Documentation update and clarification</td>
* </tr>
* <tr>
* <td>1.10</td>
* <td>The CY_WEAK keyword is removed from Cy_LPComp_DeepSleepCallback()
* and Cy_LPComp_HibernateCallback() functions<br>
* Added input parameter validation to the API functions.</td>
* <td></td>
* </tr>
* <tr>
* <td>1.0</td>
* <td>Initial version</td>
* <td></td>
* </tr>
* </table>
*
* \defgroup group_lpcomp_macros Macros
* \defgroup group_lpcomp_functions Functions
* \{
* \defgroup group_lpcomp_functions_syspm_callback Low Power Callback
* \}
* \defgroup group_lpcomp_data_structures Data Structures
* \defgroup group_lpcomp_enums Enumerated Types
*/
#ifndef CY_LPCOMP_PDL_H
#define CY_LPCOMP_PDL_H
/******************************************************************************/
/* Include files */
/******************************************************************************/
#include "cy_device.h"
#if defined (CY_IP_MXLPCOMP) || defined (CY_IP_MXS22LPCOMP)
#include <stdbool.h>
#include <stddef.h>
#include "cy_syslib.h"
#include "cy_syspm.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**
* \addtogroup group_lpcomp_macros
* \{
*/
/** Driver major version. */
#define CY_LPCOMP_DRV_VERSION_MAJOR 1
/** Driver minor version. */
#define CY_LPCOMP_DRV_VERSION_MINOR 50
/******************************************************************************
* API Constants
******************************************************************************/
/** The low-power comparator PDL ID. */
#define CY_LPCOMP_ID CY_PDL_DRV_ID(0x23u)
/** The low-power comparator number of channels. */
#define CY_LPCOMP_MAX_CHANNEL_NUM (2u)
/** The low-power comparator comparator 1 interrupt mask. */
#define CY_LPCOMP_COMP0 (LPCOMP_INTR_COMP0_Msk)
/** The low-power comparator comparator 2 interrupt mask. */
#define CY_LPCOMP_COMP1 (LPCOMP_INTR_COMP1_Msk)
/** \cond INTERNAL_MACROS */
/******************************************************************************
* Registers Constants
******************************************************************************/
#define CY_LPCOMP_MODE_ULP_Pos (0x0uL)
#define CY_LPCOMP_MODE_ULP_Msk (0x1uL)
#define CY_LPCOMP_INTR_Pos (LPCOMP_INTR_COMP0_Pos)
#define CY_LPCOMP_INTR_Msk (LPCOMP_INTR_COMP0_Msk | LPCOMP_INTR_COMP1_Msk)
#define CY_LPCOMP_CMP0_SW_POS_Msk (LPCOMP_CMP0_SW_CMP0_IP0_Msk | \
LPCOMP_CMP0_SW_CMP0_AP0_Msk | \
LPCOMP_CMP0_SW_CMP0_BP0_Msk)
#define CY_LPCOMP_CMP0_SW_NEG_Msk (LPCOMP_CMP0_SW_CMP0_IN0_Msk | \
LPCOMP_CMP0_SW_CMP0_AN0_Msk | \
LPCOMP_CMP0_SW_CMP0_BN0_Msk | \
LPCOMP_CMP0_SW_CMP0_VN0_Msk)
#define CY_LPCOMP_CMP1_SW_POS_Msk (LPCOMP_CMP1_SW_CMP1_IP1_Msk | \
LPCOMP_CMP1_SW_CMP1_AP1_Msk | \
LPCOMP_CMP1_SW_CMP1_BP1_Msk)
#define CY_LPCOMP_CMP1_SW_NEG_Msk (LPCOMP_CMP1_SW_CMP1_IN1_Msk | \
LPCOMP_CMP1_SW_CMP1_AN1_Msk | \
LPCOMP_CMP1_SW_CMP1_BN1_Msk | \
LPCOMP_CMP1_SW_CMP1_VN1_Msk)
#define CY_LPCOMP_CMP0_OUTPUT_CONFIG_Pos LPCOMP_CMP0_CTRL_DSI_BYPASS0_Pos
#define CY_LPCOMP_CMP1_OUTPUT_CONFIG_Pos LPCOMP_CMP1_CTRL_DSI_BYPASS1_Pos
#define CY_LPCOMP_CMP0_OUTPUT_CONFIG_Msk (LPCOMP_CMP0_CTRL_DSI_BYPASS0_Msk | \
LPCOMP_CMP0_CTRL_DSI_LEVEL0_Msk)
#define CY_LPCOMP_CMP1_OUTPUT_CONFIG_Msk (LPCOMP_CMP1_CTRL_DSI_BYPASS1_Msk | \
LPCOMP_CMP1_CTRL_DSI_LEVEL1_Msk)
#define CY_HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SL_SR_Pos HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SL_Pos
#define CY_HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SL_SR_Msk (HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SL_Msk | \
HSIOM_AMUX_SPLIT_CTL_SWITCH_AA_SR_Msk)
#define CY_HSIOM_AMUX_SPLIT_CTL_SWITCH_BB_SL_SR_Pos HSIOM_AMUX_SPLIT_CTL_SWITCH_BB_SL_Pos
#define CY_HSIOM_AMUX_SPLIT_CTL_SWITCH_BB_SL_SR_Msk (HSIOM_AMUX_SPLIT_CTL_SWITCH_BB_SL_Msk | \
HSIOM_AMUX_SPLIT_CTL_SWITCH_BB_SR_Msk)
#define CY_LPCOMP_REF_CONNECTED (1u)
#define CY_LPCOMP_WAKEUP_PIN0_Msk CY_SYSPM_WAKEUP_LPCOMP0
#define CY_LPCOMP_WAKEUP_PIN1_Msk CY_SYSPM_WAKEUP_LPCOMP1
/* Internal constants for Cy_LPComp_Enable() */
#define CY_LPCOMP_NORMAL_POWER_DELAY (3u)
#define CY_LPCOMP_LP_POWER_DELAY (6u)
#define CY_LPCOMP_ULP_POWER_DELAY (50u)
/** \endcond */
/** \} group_lpcomp_macros */
/**
* \addtogroup group_lpcomp_enums
* \{
*/
/******************************************************************************
* Enumerations
*****************************************************************************/
/** The low-power comparator output modes. */
typedef enum
{
CY_LPCOMP_OUT_PULSE = 0u, /**< The low-power comparator DSI output with the pulse option, no bypass. */
CY_LPCOMP_OUT_DIRECT = 1u, /**< The low-power comparator Bypass mode, the direct output of a comparator. */
CY_LPCOMP_OUT_SYNC = 2u /**< The low-power comparator DSI output with the level option, it is similar
to Bypass mode but it is 1 cycle slower. */
} cy_en_lpcomp_out_t;
/** The low-power comparator hysteresis modes. */
typedef enum
{
CY_LPCOMP_HYST_ENABLE = 1u, /**< The low-power comparator enable hysteresis. */
CY_LPCOMP_HYST_DISABLE = 0u /**< The low-power comparator disable hysteresis. */
} cy_en_lpcomp_hyst_t;
/** The low-power comparator channel number. */
typedef enum
{
CY_LPCOMP_CHANNEL_0 = 0x1u, /**< The low-power comparator 0. */
CY_LPCOMP_CHANNEL_1 = 0x2u /**< The low-power comparator 1. */
} cy_en_lpcomp_channel_t;
/** The low-power comparator interrupt modes. */
typedef enum
{
CY_LPCOMP_INTR_DISABLE = 0u, /**< The low-power comparator interrupt is disabled, no interrupt will be detected. */
CY_LPCOMP_INTR_RISING = 1u, /**< The low-power comparator interrupt on the rising edge. */
CY_LPCOMP_INTR_FALLING = 2u, /**< The low-power comparator interrupt on the falling edge. */
CY_LPCOMP_INTR_BOTH = 3u /**< The low-power comparator interrupt on both rising and falling edges. */
} cy_en_lpcomp_int_t;
/** The low-power comparator power-mode selection. */
typedef enum
{
CY_LPCOMP_MODE_OFF = 0u, /**< The low-power comparator channel power-off. */
CY_LPCOMP_MODE_ULP = 1u, /**< The low-power comparator channel ULP mode. */
CY_LPCOMP_MODE_LP = 2u, /**< The low-power comparator channel LP mode. */
CY_LPCOMP_MODE_NORMAL = 3u /**< The low-power comparator channel normal mode. */
} cy_en_lpcomp_pwr_t;
/** The low-power comparator inputs. */
typedef enum
{
CY_LPCOMP_SW_GPIO = 0x01u, /**< The low-power comparator input connects to GPIO pin. */
CY_LPCOMP_SW_AMUXBUSA = 0x02u, /**< The low-power comparator input connects to AMUXBUSA. */
CY_LPCOMP_SW_AMUXBUSB = 0x04u, /**< The low-power comparator input connects to AMUXBUSB. */
CY_LPCOMP_SW_LOCAL_VREF = 0x08u /**< The low-power comparator input connects to local VREF. */
} cy_en_lpcomp_inputs_t;
/** The low-power comparator error codes. */
typedef enum
{
CY_LPCOMP_SUCCESS = 0x00u, /**< Successful */
CY_LPCOMP_BAD_PARAM = CY_LPCOMP_ID | CY_PDL_STATUS_ERROR | 0x01u, /**< One or more invalid parameters */
} cy_en_lpcomp_status_t;
#if defined (CY_IP_MXS22LPCOMP)
/** The low-power comparator trim polarity. */
typedef enum
{
CY_LPCOMP_TRIM_NEGATIVE = 0x00UL, /**< The low-power comparator trim is negative. */
CY_LPCOMP_TRIM_POSITIVE = 0x01UL, /**< The low-power comparator trim is positive. */
} cy_en_lpcomp_trim_polarity_t;
/** The low-power comparator trim magnitude. */
typedef enum
{
CY_LPCOMP_TRIM_0mV = 0x00UL, /**< The low-power comparator trim value 0mV. */
CY_LPCOMP_TRIM_1mV = 0x01UL, /**< The low-power comparator trim value 1mV. */
CY_LPCOMP_TRIM_2mV = 0x02UL, /**< The low-power comparator trim value 2mV. */
CY_LPCOMP_TRIM_3mV = 0x03UL, /**< The low-power comparator trim value 3mV. */
CY_LPCOMP_TRIM_4mV = 0x04UL, /**< The low-power comparator trim value 4mV. */
CY_LPCOMP_TRIM_5mV = 0x05UL, /**< The low-power comparator trim value 5mV. */
CY_LPCOMP_TRIM_6mV = 0x06UL, /**< The low-power comparator trim value 6mV. */
CY_LPCOMP_TRIM_7mV = 0x07UL, /**< The low-power comparator trim value 7mV. */
CY_LPCOMP_TRIM_8mV = 0x08UL, /**< The low-power comparator trim value 8mV. */
CY_LPCOMP_TRIM_9mV = 0x09UL, /**< The low-power comparator trim value 9mV. */
CY_LPCOMP_TRIM_10mV = 0x0AUL, /**< The low-power comparator trim value 10mV. */
CY_LPCOMP_TRIM_11mV = 0x0BUL, /**< The low-power comparator trim value 11mV. */
CY_LPCOMP_TRIM_12mV = 0x0CUL, /**< The low-power comparator trim value 12mV. */
CY_LPCOMP_TRIM_13mV = 0x0DUL, /**< The low-power comparator trim value 13mV. */
CY_LPCOMP_TRIM_14mV = 0x0EUL, /**< The low-power comparator trim value 14mV. */
CY_LPCOMP_TRIM_15mV = 0x0FUL /**< The low-power comparator trim value 15mV. */
} cy_en_lpcomp_trim_magnitude_t;
#endif
/** \} group_lpcomp_enums */
/**
* \addtogroup group_lpcomp_data_structures
* \{
*/
/******************************************************************************
* Structures
*****************************************************************************/
/** The low-power comparator configuration structure. */
typedef struct {
cy_en_lpcomp_out_t outputMode; /**< The low-power comparator outputMode: Direct output,
Synchronized output or Pulse output */
cy_en_lpcomp_hyst_t hysteresis; /**< Enables or disables the low-power comparator hysteresis */
cy_en_lpcomp_pwr_t power; /**< Sets the low-power comparator power mode */
cy_en_lpcomp_int_t intType; /**< Sets the low-power comparator interrupt mode */
} cy_stc_lpcomp_config_t;
#if defined (CY_IP_MXS22LPCOMP)
/** The low-power comparator trim structure. */
typedef struct
{
bool enable; /**< Enables or disables the low-power comparator trim */
cy_en_lpcomp_trim_polarity_t polarity; /**< Defines the low-power comparator trim polarity */
cy_en_lpcomp_trim_magnitude_t magnitude; /**< Defines the low-power comparator trim magnitude */
} cy_en_lpcomp_trim_t;
#endif
/** The low-power comparator context structure, used to improve thread-safe implementation of the PDL.
* It is applicable for the following functions:
* * \ref Cy_LPComp_Init_Ext(),
* * \ref Cy_LPComp_Enable_Ext(),
* * \ref Cy_LPComp_Disable_Ext(),
* * \ref Cy_LPComp_SetInterruptTriggerMode_Ext(),
* * \ref Cy_LPComp_SetPower_Ext()
*/
typedef struct {
/** \cond CONTEXT_STRUCTURE */
cy_en_lpcomp_int_t intType[CY_LPCOMP_MAX_CHANNEL_NUM];
cy_en_lpcomp_pwr_t power[CY_LPCOMP_MAX_CHANNEL_NUM];
/** \endcond */
} cy_stc_lpcomp_context_t;
/** \} group_lpcomp_data_structures */
/** \cond INTERNAL_MACROS */
/******************************************************************************
* Macros
*****************************************************************************/
#define CY_LPCOMP_IS_CHANNEL_VALID(channel) (((channel) == CY_LPCOMP_CHANNEL_0) || \
((channel) == CY_LPCOMP_CHANNEL_1))
#define CY_LPCOMP_IS_OUT_MODE_VALID(mode) (((mode) == CY_LPCOMP_OUT_PULSE) || \
((mode) == CY_LPCOMP_OUT_DIRECT) || \
((mode) == CY_LPCOMP_OUT_SYNC))
#define CY_LPCOMP_IS_HYSTERESIS_VALID(hyst) (((hyst) == CY_LPCOMP_HYST_ENABLE) || \
((hyst) == CY_LPCOMP_HYST_DISABLE))
#define CY_LPCOMP_IS_INTR_MODE_VALID(intr) (((intr) == CY_LPCOMP_INTR_DISABLE) || \
((intr) == CY_LPCOMP_INTR_RISING) || \
((intr) == CY_LPCOMP_INTR_FALLING) || \
((intr) == CY_LPCOMP_INTR_BOTH))
#define CY_LPCOMP_IS_POWER_VALID(power) (((power) == CY_LPCOMP_MODE_OFF) || \
((power) == CY_LPCOMP_MODE_ULP) || \
((power) == CY_LPCOMP_MODE_LP) || \
((power) == CY_LPCOMP_MODE_NORMAL))
#define CY_LPCOMP_IS_INTR_VALID(intr) (((intr) == CY_LPCOMP_COMP0) || \
((intr) == CY_LPCOMP_COMP1) || \
((intr) == (CY_LPCOMP_COMP0 | CY_LPCOMP_COMP1)))
#define CY_LPCOMP_IS_INPUT_P_VALID(input) (((input) == CY_LPCOMP_SW_GPIO) || \
((input) == CY_LPCOMP_SW_AMUXBUSA) || \
((input) == CY_LPCOMP_SW_AMUXBUSB))
#define CY_LPCOMP_IS_INPUT_N_VALID(input) (((input) == CY_LPCOMP_SW_GPIO) || \
((input) == CY_LPCOMP_SW_AMUXBUSA) || \
((input) == CY_LPCOMP_SW_AMUXBUSB) || \
((input) == CY_LPCOMP_SW_LOCAL_VREF))
#if defined (CY_IP_MXS22LPCOMP)
#define CY_LPCOMP_IS_TRIM_VALID(trim) (((((trim)->polarity) == CY_LPCOMP_TRIM_NEGATIVE) || \
(((trim)->polarity) == CY_LPCOMP_TRIM_POSITIVE)) && \
((((trim)->magnitude) >= CY_LPCOMP_TRIM_0mV) && \
(((trim)->magnitude) <= CY_LPCOMP_TRIM_15mV)))
#endif
/** \endcond */
/**
* \addtogroup group_lpcomp_functions
* \{
*/
/******************************************************************************
* Functions
*******************************************************************************/
cy_en_lpcomp_status_t Cy_LPComp_Init_Ext(LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, const cy_stc_lpcomp_config_t *config,
cy_stc_lpcomp_context_t *context);
void Cy_LPComp_Enable_Ext(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_stc_lpcomp_context_t *context);
void Cy_LPComp_Disable_Ext(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_stc_lpcomp_context_t *context);
#if defined (CY_IP_MXLPCOMP)
cy_en_lpcomp_status_t Cy_LPComp_Init(LPCOMP_Type *base, cy_en_lpcomp_channel_t channel, const cy_stc_lpcomp_config_t *config);
void Cy_LPComp_Enable(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel);
void Cy_LPComp_Disable(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel);
#endif
__STATIC_INLINE void Cy_LPComp_GlobalEnable(LPCOMP_Type *base);
__STATIC_INLINE void Cy_LPComp_GlobalDisable(LPCOMP_Type *base);
__STATIC_INLINE void Cy_LPComp_UlpReferenceEnable(LPCOMP_Type *base);
__STATIC_INLINE void Cy_LPComp_UlpReferenceDisable(LPCOMP_Type *base);
__STATIC_INLINE uint32_t Cy_LPComp_GetCompare(LPCOMP_Type const * base, cy_en_lpcomp_channel_t channel);
void Cy_LPComp_SetPower_Ext(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_pwr_t power,
cy_stc_lpcomp_context_t *context);
#if defined (CY_IP_MXLPCOMP)
void Cy_LPComp_SetPower(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_pwr_t power);
#endif
void Cy_LPComp_SetHysteresis(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_hyst_t hysteresis);
void Cy_LPComp_SetInputs(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_inputs_t inputP, cy_en_lpcomp_inputs_t inputN);
void Cy_LPComp_SetOutputMode(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_out_t outType);
void Cy_LPComp_SetInterruptTriggerMode_Ext(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_int_t intType,
cy_stc_lpcomp_context_t *context);
#if defined (CY_IP_MXLPCOMP)
void Cy_LPComp_SetInterruptTriggerMode(LPCOMP_Type* base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_int_t intType);
#endif
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatus(LPCOMP_Type const * base);
__STATIC_INLINE void Cy_LPComp_ClearInterrupt(LPCOMP_Type* base, uint32_t interrupt);
__STATIC_INLINE void Cy_LPComp_SetInterrupt(LPCOMP_Type* base, uint32_t interrupt);
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptMask(LPCOMP_Type const * base);
__STATIC_INLINE void Cy_LPComp_SetInterruptMask(LPCOMP_Type* base, uint32_t interrupt);
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatusMasked(LPCOMP_Type const * base);
__STATIC_INLINE void Cy_LPComp_ConnectULPReference(LPCOMP_Type *base, cy_en_lpcomp_channel_t channel);
#if defined (CY_IP_MXS22LPCOMP)
void Cy_LPComp_GetTrim(LPCOMP_Type const * base, cy_en_lpcomp_channel_t channel, cy_en_lpcomp_trim_t * trim);
void Cy_LPComp_SetTrim(LPCOMP_Type * base, cy_en_lpcomp_channel_t channel, const cy_en_lpcomp_trim_t * trim);
#endif
/** \addtogroup group_lpcomp_functions_syspm_callback
* The driver supports the SysPm callback for Deep Sleep and Hibernate transition.
* \{
*/
cy_en_syspm_status_t Cy_LPComp_DeepSleepCallback(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode);
cy_en_syspm_status_t Cy_LPComp_HibernateCallback(cy_stc_syspm_callback_params_t *callbackParams, cy_en_syspm_callback_mode_t mode);
/** \} */
/*******************************************************************************
* Function Name: Cy_LPComp_GlobalEnable
****************************************************************************//**
*
* Activates the IP of the low-power comparator hardware block.
* Call this function before operating any comparator channel.
* \note Interrupts can be enabled after the block is enabled and appropriate
* start-up time has elapsed:
* * 3 us for normal power mode;
* * 6 us for LP mode;
* * 50 us for ULP mode.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \return None.
*
*******************************************************************************/
__STATIC_INLINE void Cy_LPComp_GlobalEnable(LPCOMP_Type* base)
{
LPCOMP_CONFIG(base) |= LPCOMP_CONFIG_ENABLED_Msk;
}
/*******************************************************************************
* Function Name: Cy_LPComp_GlobalDisable
****************************************************************************//**
*
* Deactivates the IP of the low-power comparator hardware block.
* (Analog is in power down, open all switches, all clocks are off).
*
* \param *base
* The low-power comparator register structure pointer.
*
* \return None.
*
*******************************************************************************/
__STATIC_INLINE void Cy_LPComp_GlobalDisable(LPCOMP_Type *base)
{
LPCOMP_CONFIG(base) &= (uint32_t) ~LPCOMP_CONFIG_ENABLED_Msk;
}
/*******************************************************************************
* Function Name: Cy_LPComp_UlpReferenceEnable
****************************************************************************//**
*
* Enables the local reference-generator circuit.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \return None.
*
*******************************************************************************/
__STATIC_INLINE void Cy_LPComp_UlpReferenceEnable(LPCOMP_Type *base)
{
LPCOMP_CONFIG(base) |= LPCOMP_CONFIG_LPREF_EN_Msk;
}
/*******************************************************************************
* Function Name: Cy_LPComp_UlpReferenceDisable
****************************************************************************//**
*
* Disables the local reference-generator circuit.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \return None.
*
*******************************************************************************/
__STATIC_INLINE void Cy_LPComp_UlpReferenceDisable(LPCOMP_Type *base)
{
LPCOMP_CONFIG(base) &= (uint32_t) ~LPCOMP_CONFIG_LPREF_EN_Msk;
}
/*******************************************************************************
* Function Name: Cy_LPComp_GetCompare
****************************************************************************//**
*
* This function returns a non-zero value when the voltage connected to the
* positive input is greater than the negative input voltage.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \param channel
* The low-power comparator channel index.
*
* \return The low-power comparator compare result.
* The value is a non-zero when the voltage connected to the positive
* input is greater than the negative input voltage.
*
*******************************************************************************/
__STATIC_INLINE uint32_t Cy_LPComp_GetCompare(LPCOMP_Type const * base, cy_en_lpcomp_channel_t channel)
{
uint32_t result;
CY_ASSERT_L3(CY_LPCOMP_IS_CHANNEL_VALID(channel));
if (CY_LPCOMP_CHANNEL_0 == channel)
{
result = _FLD2VAL(LPCOMP_STATUS_OUT0, LPCOMP_STATUS(base));
}
else
{
result = _FLD2VAL(LPCOMP_STATUS_OUT1, LPCOMP_STATUS(base));
}
return (result);
}
/*******************************************************************************
* Function Name: Cy_LPComp_SetInterruptMask
****************************************************************************//**
*
* Configures which bits of the interrupt request register will trigger an
* interrupt event.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \param interrupt
* uint32_t interruptMask: Bit Mask of interrupts to set.
* * Bit 0: COMP0 interrupt mask
* * Bit 1: COMP1 interrupt mask
*
* \return None.
*
*******************************************************************************/
__STATIC_INLINE void Cy_LPComp_SetInterruptMask(LPCOMP_Type* base, uint32_t interrupt)
{
CY_ASSERT_L2(CY_LPCOMP_IS_INTR_VALID(interrupt));
LPCOMP_INTR_MASK(base) |= interrupt;
}
/*******************************************************************************
* Function Name: Cy_LPComp_GetInterruptMask
****************************************************************************//**
*
* Returns an interrupt mask.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \return bit mapping information:
* * Bit 0: COMP0 interrupt mask
* * Bit 1: COMP1 interrupt mask
*
*******************************************************************************/
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptMask(LPCOMP_Type const * base)
{
return (LPCOMP_INTR_MASK(base));
}
/*******************************************************************************
* Function Name: Cy_LPComp_GetInterruptStatusMasked
****************************************************************************//**
*
* Returns an interrupt request register masked by an interrupt mask.
* Returns the result of the bitwise AND operation between the corresponding
* interrupt request and mask bits.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \return bit mapping information:
* * Bit 0: COMP0 interrupt masked
* * Bit 1: COMP1 interrupt masked
*
*******************************************************************************/
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatusMasked(LPCOMP_Type const * base)
{
return (LPCOMP_INTR_MASKED(base));
}
/*******************************************************************************
* Function Name: Cy_LPComp_GetInterruptStatus
****************************************************************************//**
*
* Returns the status of two different low-power comparator interrupt requests.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \return bit mapping information:
* * Bit 0: COMP0 interrupt status
* * Bit 1: COMP1 interrupt status
*
*******************************************************************************/
__STATIC_INLINE uint32_t Cy_LPComp_GetInterruptStatus(LPCOMP_Type const * base)
{
return (_FLD2VAL(CY_LPCOMP_INTR, LPCOMP_INTR(base)));
}
/*******************************************************************************
* Function Name: Cy_LPComp_ClearInterrupt
****************************************************************************//**
*
* Clears low-power comparator interrupts by setting each bit.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \param interrupt
* * Bit 0: COMP0 interrupt status
* * Bit 1: COMP1 interrupt status
*
* \return None.
*
*******************************************************************************/
__STATIC_INLINE void Cy_LPComp_ClearInterrupt(LPCOMP_Type* base, uint32_t interrupt)
{
CY_ASSERT_L2(CY_LPCOMP_IS_INTR_VALID(interrupt));
LPCOMP_INTR(base) |= interrupt;
(void) LPCOMP_INTR(base);
}
/*******************************************************************************
* Function Name: Cy_LPComp_SetInterrupt
****************************************************************************//**
*
* Sets a software interrupt request.
* This function is used in the case of combined interrupt signal from the global
* signal reference. This function from either component instance can be used
* to trigger either or both software interrupts. The function sets the INTR_SET interrupt mask.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \param interrupt
* * Bit 0: COMP0 interrupt status
* * Bit 1: COMP1 interrupt status
*
* \return None.
*
*******************************************************************************/
__STATIC_INLINE void Cy_LPComp_SetInterrupt(LPCOMP_Type* base, uint32_t interrupt)
{
CY_ASSERT_L2(CY_LPCOMP_IS_INTR_VALID(interrupt));
LPCOMP_INTR_SET(base) = interrupt;
}
/*******************************************************************************
* Function Name: Cy_LPComp_ConnectULPReference
****************************************************************************//**
*
* Connects the local reference generator output to the comparator negative input.
*
* \param *base
* The low-power comparator register structure pointer.
*
* \param channel
* The low-power comparator channel index.
*
* \return None.
*
*******************************************************************************/
__STATIC_INLINE void Cy_LPComp_ConnectULPReference(LPCOMP_Type *base, cy_en_lpcomp_channel_t channel)
{
CY_ASSERT_L3(CY_LPCOMP_IS_CHANNEL_VALID(channel));
if (CY_LPCOMP_CHANNEL_0 == channel)
{
LPCOMP_CMP0_SW_CLEAR(base) = CY_LPCOMP_CMP0_SW_NEG_Msk;
LPCOMP_CMP0_SW(base) = _CLR_SET_FLD32U(LPCOMP_CMP0_SW(base), LPCOMP_CMP0_SW_CMP0_VN0, CY_LPCOMP_REF_CONNECTED);
}
else
{
LPCOMP_CMP1_SW_CLEAR(base) = CY_LPCOMP_CMP1_SW_NEG_Msk;
LPCOMP_CMP1_SW(base) = _CLR_SET_FLD32U(LPCOMP_CMP1_SW(base), LPCOMP_CMP1_SW_CMP1_VN1, CY_LPCOMP_REF_CONNECTED);
}
}
/** \} group_lpcomp_functions */
#ifdef __cplusplus
}
#endif
#endif /* CY_IP_MXLPCOMP and CY_IP_MXS22LPCOMP */
#endif /* CY_LPCOMP_PDL_H */
/** \} group_lpcomp */
/* [] END OF FILE */
|
f783c266d63085a4b689c999ff490d9bffffda51
|
010279e2ba272d09e9d2c4e903722e5faba2cf7a
|
/contrib/libs/cxxsupp/openmp/ompt-event-specific.h
|
f6c7022c8f66474b168829ef0f51417e9b321f4e
|
[
"MIT",
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LicenseRef-scancode-arm-llvm-sga",
"LicenseRef-scancode-generic-cla"
] |
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
| 4,829
|
h
|
ompt-event-specific.h
|
/******************************************************************************
* File: ompt-event-specific.h
*
* Description:
*
* specify which of the OMPT events are implemented by this runtime system
* and the level of their implementation by a runtime system.
*****************************************************************************/
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef __OMPT_EVENT_SPECIFIC_H__
#define __OMPT_EVENT_SPECIFIC_H__
#define _ompt_tokenpaste_helper(x, y) x##y
#define _ompt_tokenpaste(x, y) _ompt_tokenpaste_helper(x, y)
#define ompt_event_implementation_status(e) _ompt_tokenpaste(e, _implemented)
/*----------------------------------------------------------------------------
| Specify whether an event may occur or not, and whether event callbacks
| never, sometimes, or always occur.
|
| The values for these constants are defined in section 6.1.2 of
| the OMPT TR. They are exposed to tools through ompt_set_callback.
+--------------------------------------------------------------------------*/
#define ompt_event_UNIMPLEMENTED ompt_set_never
#define ompt_event_MAY_CONVENIENT ompt_set_sometimes
#define ompt_event_MAY_ALWAYS ompt_set_always
#if OMPT_OPTIONAL
#define ompt_event_MAY_ALWAYS_OPTIONAL ompt_event_MAY_ALWAYS
#else
#define ompt_event_MAY_ALWAYS_OPTIONAL ompt_event_UNIMPLEMENTED
#endif
/*----------------------------------------------------------------------------
| Mandatory Events
+--------------------------------------------------------------------------*/
#define ompt_callback_thread_begin_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_thread_end_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_parallel_begin_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_parallel_end_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_task_create_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_task_schedule_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_implicit_task_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_target_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_emi_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_data_op_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_data_op_emi_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_submit_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_submit_emi_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_control_tool_implemented ompt_event_MAY_ALWAYS
#define ompt_callback_device_initialize_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_device_finalize_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_device_load_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_device_unload_implemented ompt_event_UNIMPLEMENTED
/*----------------------------------------------------------------------------
| Optional Events
+--------------------------------------------------------------------------*/
#define ompt_callback_sync_region_wait_implemented \
ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_mutex_released_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_dependences_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_task_dependence_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_work_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_masked_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_target_map_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_target_map_emi_implemented ompt_event_UNIMPLEMENTED
#define ompt_callback_sync_region_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_lock_init_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_lock_destroy_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_mutex_acquire_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_mutex_acquired_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_nest_lock_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_flush_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_cancel_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_reduction_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_dispatch_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#define ompt_callback_error_implemented ompt_event_MAY_ALWAYS_OPTIONAL
#endif
|
c27ca70557df8faa9071027c2a991304f5aacafb
|
f79dec3c4033ca3cbb55d8a51a748cc7b8b6fbab
|
/sysutils/xentools48/patches/patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h
|
891172384a2eff3de83b6611775ba7fcdc56f90b
|
[] |
no_license
|
jsonn/pkgsrc
|
fb34c4a6a2d350e8e415f3c4955d4989fcd86881
|
c1514b5f4a3726d90e30aa16b0c209adbc276d17
|
refs/heads/trunk
| 2021-01-24T09:10:01.038867
| 2017-07-07T15:49:43
| 2017-07-07T15:49:43
| 2,095,004
| 106
| 47
| null | 2016-09-19T09:26:01
| 2011-07-23T23:49:04
|
Makefile
|
UTF-8
|
C
| false
| false
| 516
|
h
|
patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h
|
$NetBSD: patch-.._newlib-1.16.0_newlib_libc_include_sys__types.h,v 1.1 2017/03/30 09:15:10 bouyer Exp $
--- ../newlib-1.16.0/newlib/libc/include/sys/_types.h.orig 2017-03-28 15:10:39.000000000 +0200
+++ ../newlib-1.16.0/newlib/libc/include/sys/_types.h 2017-03-28 15:10:56.000000000 +0200
@@ -52,12 +52,8 @@
#endif
#ifndef __ssize_t_defined
-#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
-typedef int _ssize_t;
-#else
typedef long _ssize_t;
#endif
-#endif
#define __need_wint_t
#include <stddef.h>
|
f4a96dca843dd1d17e524b178ea2e6d98b05dd4f
|
c72e8e7a91acfc92d6cbd02dfbbcc20f00aab63f
|
/test/src/common/harnessPq.c
|
060366bb590a5533ab80cc5b2e7a085aeb3bdabd
|
[
"MIT"
] |
permissive
|
pgbackrest/pgbackrest
|
83b3760b0faaaf7a0da4a54caeaa2231d6144704
|
e3fcd8cd9e0be42a32fc4cbd2ae3db2c072eabcd
|
refs/heads/main
| 2023-09-03T22:27:01.317021
| 2023-08-31T20:36:52
| 2023-08-31T20:36:52
| 14,313,288
| 1,826
| 211
|
NOASSERTION
| 2023-09-14T13:56:30
| 2013-11-11T21:08:39
|
C
|
UTF-8
|
C
| false
| false
| 15,716
|
c
|
harnessPq.c
|
/***********************************************************************************************************************************
Pq Test Harness
***********************************************************************************************************************************/
#ifndef HARNESS_PQ_REAL
#include "build.auto.h"
#include <string.h>
#include <libpq-fe.h>
#include "common/type/json.h"
#include "common/type/string.h"
#include "common/type/variantList.h"
#include "common/harnessPq.h"
#include "common/harnessTest.h"
/***********************************************************************************************************************************
Pq shim error prefix
***********************************************************************************************************************************/
#define PQ_ERROR_PREFIX "PQ SHIM ERROR"
/***********************************************************************************************************************************
Script that defines how shim functions operate
***********************************************************************************************************************************/
HarnessPq harnessPqScript[1024];
bool harnessPqScriptDone = true;
unsigned int harnessPqScriptIdx;
// Is PQfinish scripting required?
bool harnessPqStrict = false;
// If there is a script failure change the behavior of cleanup functions to return immediately so the real error will be reported
// rather than a bogus scripting error during cleanup
bool harnessPqScriptFail;
char harnessPqScriptError[4096];
/***********************************************************************************************************************************
Set pq script
***********************************************************************************************************************************/
void
harnessPqScriptSet(HarnessPq *harnessPqScriptParam)
{
if (!harnessPqScriptDone)
THROW(AssertError, "previous pq script has not yet completed");
if (harnessPqScriptParam[0].function == NULL)
THROW(AssertError, "pq script must have entries");
// Copy records into local storage
unsigned int copyIdx = 0;
while (harnessPqScriptParam[copyIdx].function != NULL)
{
harnessPqScript[copyIdx] = harnessPqScriptParam[copyIdx];
copyIdx++;
}
harnessPqScript[copyIdx].function = NULL;
harnessPqScriptDone = false;
harnessPqScriptIdx = 0;
}
/**********************************************************************************************************************************/
void
harnessPqScriptStrictSet(bool strict)
{
harnessPqStrict = strict;
}
/***********************************************************************************************************************************
Run pq script
***********************************************************************************************************************************/
static HarnessPq *
harnessPqScriptRun(const char *const function, const VariantList *const param, const HarnessPq *const parent)
{
// If an error has already been thrown then throw the same error again
if (harnessPqScriptFail)
THROW(AssertError, harnessPqScriptError);
// Convert params to json for comparison and reporting
String *paramStr = NULL;
if (param)
{
Variant *const varList = varNewVarLst(param);
paramStr = jsonFromVar(varList);
varFree(varList);
}
else
paramStr = strNew();
// Ensure script has not ended
if (harnessPqScriptDone)
{
snprintf(harnessPqScriptError, sizeof(harnessPqScriptError), "pq script ended before %s (%s)", function, strZ(paramStr));
TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError);
harnessPqScriptFail = true;
THROW(AssertError, harnessPqScriptError);
}
// Get current script item
HarnessPq *result = &harnessPqScript[harnessPqScriptIdx];
// Check that expected function was called
if (strcmp(result->function, function) != 0)
{
snprintf(
harnessPqScriptError, sizeof(harnessPqScriptError), "pq script [%u] expected function %s (%s) but got %s (%s)",
harnessPqScriptIdx, result->function, result->param == NULL ? "" : result->param, function, strZ(paramStr));
TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError);
harnessPqScriptFail = true;
// Return without error if closing the connection and an error is currently being thrown. Errors outside of the pq shim can
// cause the connection to be cleaned up and we don't want to mask those errors. However, the failure is still logged and
// any subsequent call to the pq shim will result in an error.
if (strcmp(function, HRNPQ_FINISH) == 0 && errorType() != NULL)
return NULL;
THROW(AssertError, harnessPqScriptError);
}
// Check that parameters match
if ((param != NULL && result->param == NULL) || (param == NULL && result->param != NULL) ||
(param != NULL && result->param != NULL && !strEqZ(paramStr, result->param)))
{
snprintf(
harnessPqScriptError, sizeof(harnessPqScriptError), "pq script [%u] function '%s', expects param '%s' but got '%s'",
harnessPqScriptIdx, result->function, result->param ? result->param : "NULL", param ? strZ(paramStr) : "NULL");
TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError);
harnessPqScriptFail = true;
THROW(AssertError, harnessPqScriptError);
}
// Make sure the session matches with the parent as a sanity check
if (parent != NULL && result->session != parent->session)
{
snprintf(
harnessPqScriptError, sizeof(harnessPqScriptError), "pq script [%u] function '%s', expects session '%u' but got '%u'",
harnessPqScriptIdx, result->function, result->session, parent->session);
TEST_LOG_FMT(PQ_ERROR_PREFIX ": %s", harnessPqScriptError);
harnessPqScriptFail = true;
THROW(AssertError, harnessPqScriptError);
}
// Sleep if requested
if (result->sleep > 0)
sleepMSec(result->sleep);
harnessPqScriptIdx++;
if (harnessPqScript[harnessPqScriptIdx].function == NULL)
harnessPqScriptDone = true;
strFree(paramStr);
return result;
}
/***********************************************************************************************************************************
Shim for PQconnectdb()
***********************************************************************************************************************************/
PGconn *
PQconnectdb(const char *conninfo)
{
return (PGconn *)harnessPqScriptRun(HRNPQ_CONNECTDB, varLstAdd(varLstNew(), varNewStrZ(conninfo)), NULL);
}
/***********************************************************************************************************************************
Shim for PQstatus()
***********************************************************************************************************************************/
ConnStatusType
PQstatus(const PGconn *conn)
{
return (ConnStatusType)harnessPqScriptRun(HRNPQ_STATUS, NULL, (HarnessPq *)conn)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQerrorMessage()
***********************************************************************************************************************************/
char *
PQerrorMessage(const PGconn *conn)
{
return (char *)harnessPqScriptRun(HRNPQ_ERRORMESSAGE, NULL, (HarnessPq *)conn)->resultZ;
}
/***********************************************************************************************************************************
Shim for PQsetNoticeProcessor()
***********************************************************************************************************************************/
PQnoticeProcessor
PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
{
(void)conn;
// Call the processor that was passed so we have coverage
proc(arg, "test notice");
return NULL;
}
/***********************************************************************************************************************************
Shim for PQsendQuery()
***********************************************************************************************************************************/
int
PQsendQuery(PGconn *conn, const char *query)
{
return harnessPqScriptRun(HRNPQ_SENDQUERY, varLstAdd(varLstNew(), varNewStrZ(query)), (HarnessPq *)conn)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQconsumeInput()
***********************************************************************************************************************************/
int
PQconsumeInput(PGconn *conn)
{
return harnessPqScriptRun(HRNPQ_CONSUMEINPUT, NULL, (HarnessPq *)conn)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQisBusy()
***********************************************************************************************************************************/
int
PQisBusy(PGconn *conn)
{
return harnessPqScriptRun(HRNPQ_ISBUSY, NULL, (HarnessPq *)conn)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQgetCancel()
***********************************************************************************************************************************/
PGcancel *
PQgetCancel(PGconn *conn)
{
HarnessPq *harnessPq = harnessPqScriptRun(HRNPQ_GETCANCEL, NULL, (HarnessPq *)conn);
return harnessPq->resultNull ? NULL : (PGcancel *)harnessPq;
}
/***********************************************************************************************************************************
Shim for PQcancel()
***********************************************************************************************************************************/
int
PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
{
HarnessPq *harnessPq = harnessPqScriptRun(HRNPQ_CANCEL, NULL, (HarnessPq *)cancel);
if (!harnessPq->resultInt)
{
strncpy(errbuf, harnessPq->resultZ, (size_t)errbufsize);
errbuf[errbufsize - 1] = '\0';
}
return harnessPq->resultInt;
}
/***********************************************************************************************************************************
Shim for PQfreeCancel()
***********************************************************************************************************************************/
void
PQfreeCancel(PGcancel *cancel)
{
harnessPqScriptRun(HRNPQ_FREECANCEL, NULL, (HarnessPq *)cancel);
}
/***********************************************************************************************************************************
Shim for PQgetResult()
***********************************************************************************************************************************/
PGresult *
PQgetResult(PGconn *conn)
{
if (!harnessPqScriptFail)
{
HarnessPq *harnessPq = harnessPqScriptRun(HRNPQ_GETRESULT, NULL, (HarnessPq *)conn);
return harnessPq->resultNull ? NULL : (PGresult *)harnessPq;
}
return NULL;
}
/***********************************************************************************************************************************
Shim for PQresultStatus()
***********************************************************************************************************************************/
ExecStatusType
PQresultStatus(const PGresult *res)
{
return (ExecStatusType)harnessPqScriptRun(HRNPQ_RESULTSTATUS, NULL, (HarnessPq *)res)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQresultErrorMessage()
***********************************************************************************************************************************/
char *
PQresultErrorMessage(const PGresult *res)
{
return (char *)harnessPqScriptRun(HRNPQ_RESULTERRORMESSAGE, NULL, (HarnessPq *)res)->resultZ;
}
/***********************************************************************************************************************************
Shim for PQntuples()
***********************************************************************************************************************************/
int
PQntuples(const PGresult *res)
{
return harnessPqScriptRun(HRNPQ_NTUPLES, NULL, (HarnessPq *)res)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQnfields()
***********************************************************************************************************************************/
int
PQnfields(const PGresult *res)
{
return harnessPqScriptRun(HRNPQ_NFIELDS, NULL, (HarnessPq *)res)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQgetisnull()
***********************************************************************************************************************************/
int
PQgetisnull(const PGresult *res, int tup_num, int field_num)
{
return harnessPqScriptRun(
HRNPQ_GETISNULL, varLstAdd(varLstAdd(varLstNew(), varNewInt(tup_num)), varNewInt(field_num)), (HarnessPq *)res)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQftype()
***********************************************************************************************************************************/
Oid
PQftype(const PGresult *res, int field_num)
{
return (Oid)harnessPqScriptRun(HRNPQ_FTYPE, varLstAdd(varLstNew(), varNewInt(field_num)), (HarnessPq *)res)->resultInt;
}
/***********************************************************************************************************************************
Shim for PQgetvalue()
***********************************************************************************************************************************/
char *
PQgetvalue(const PGresult *res, int tup_num, int field_num)
{
return (char *)harnessPqScriptRun(
HRNPQ_GETVALUE, varLstAdd(varLstAdd(varLstNew(), varNewInt(tup_num)), varNewInt(field_num)), (HarnessPq *)res)->resultZ;
}
/***********************************************************************************************************************************
Shim for PQclear()
***********************************************************************************************************************************/
void
PQclear(PGresult *res)
{
if (!harnessPqScriptFail)
harnessPqScriptRun(HRNPQ_CLEAR, NULL, (HarnessPq *)res);
}
/***********************************************************************************************************************************
Shim for PQfinish()
***********************************************************************************************************************************/
void
PQfinish(PGconn *conn)
{
if (harnessPqStrict && !harnessPqScriptFail)
harnessPqScriptRun(HRNPQ_FINISH, NULL, (HarnessPq *)conn);
}
#endif // HARNESS_PQ_REAL
|
7dfe3d6e8feeadd75868a1c6c465c6c346b56cd9
|
3cd3872acbc8b1a79a70b89b2fd58a171e7adc82
|
/vpx_dsp/arm/sum_squares_neon.c
|
074afe32583b53ade87566261bd936f67f1c1928
|
[] |
permissive
|
webmproject/libvpx
|
58ab97861063cb521ec0d00ef9cb222ca97873b1
|
6fd360c684736e351160b131827dfbb207841164
|
refs/heads/main
| 2023-04-09T15:32:34.688724
| 2023-04-07T22:19:18
| 2023-04-07T22:19:18
| 22,927,608
| 889
| 376
|
BSD-3-Clause
| 2023-03-24T13:37:34
| 2014-08-13T19:03:21
|
C
|
UTF-8
|
C
| false
| false
| 3,575
|
c
|
sum_squares_neon.c
|
/*
* Copyright (c) 2018 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <arm_neon.h>
#include <assert.h>
#include "./vpx_dsp_rtcd.h"
#include "vpx_dsp/arm/sum_neon.h"
uint64_t vpx_sum_squares_2d_i16_neon(const int16_t *src, int stride, int size) {
if (size == 4) {
int16x4_t s[4];
int32x4_t sum_s32;
s[0] = vld1_s16(src + 0 * stride);
s[1] = vld1_s16(src + 1 * stride);
s[2] = vld1_s16(src + 2 * stride);
s[3] = vld1_s16(src + 3 * stride);
sum_s32 = vmull_s16(s[0], s[0]);
sum_s32 = vmlal_s16(sum_s32, s[1], s[1]);
sum_s32 = vmlal_s16(sum_s32, s[2], s[2]);
sum_s32 = vmlal_s16(sum_s32, s[3], s[3]);
return horizontal_long_add_uint32x4(vreinterpretq_u32_s32(sum_s32));
} else {
uint64x2_t sum_u64 = vdupq_n_u64(0);
int rows = size;
do {
const int16_t *src_ptr = src;
int32x4_t sum_s32[2] = { vdupq_n_s32(0), vdupq_n_s32(0) };
int cols = size;
do {
int16x8_t s[8];
s[0] = vld1q_s16(src_ptr + 0 * stride);
s[1] = vld1q_s16(src_ptr + 1 * stride);
s[2] = vld1q_s16(src_ptr + 2 * stride);
s[3] = vld1q_s16(src_ptr + 3 * stride);
s[4] = vld1q_s16(src_ptr + 4 * stride);
s[5] = vld1q_s16(src_ptr + 5 * stride);
s[6] = vld1q_s16(src_ptr + 6 * stride);
s[7] = vld1q_s16(src_ptr + 7 * stride);
sum_s32[0] =
vmlal_s16(sum_s32[0], vget_low_s16(s[0]), vget_low_s16(s[0]));
sum_s32[0] =
vmlal_s16(sum_s32[0], vget_low_s16(s[1]), vget_low_s16(s[1]));
sum_s32[0] =
vmlal_s16(sum_s32[0], vget_low_s16(s[2]), vget_low_s16(s[2]));
sum_s32[0] =
vmlal_s16(sum_s32[0], vget_low_s16(s[3]), vget_low_s16(s[3]));
sum_s32[0] =
vmlal_s16(sum_s32[0], vget_low_s16(s[4]), vget_low_s16(s[4]));
sum_s32[0] =
vmlal_s16(sum_s32[0], vget_low_s16(s[5]), vget_low_s16(s[5]));
sum_s32[0] =
vmlal_s16(sum_s32[0], vget_low_s16(s[6]), vget_low_s16(s[6]));
sum_s32[0] =
vmlal_s16(sum_s32[0], vget_low_s16(s[7]), vget_low_s16(s[7]));
sum_s32[1] =
vmlal_s16(sum_s32[1], vget_high_s16(s[0]), vget_high_s16(s[0]));
sum_s32[1] =
vmlal_s16(sum_s32[1], vget_high_s16(s[1]), vget_high_s16(s[1]));
sum_s32[1] =
vmlal_s16(sum_s32[1], vget_high_s16(s[2]), vget_high_s16(s[2]));
sum_s32[1] =
vmlal_s16(sum_s32[1], vget_high_s16(s[3]), vget_high_s16(s[3]));
sum_s32[1] =
vmlal_s16(sum_s32[1], vget_high_s16(s[4]), vget_high_s16(s[4]));
sum_s32[1] =
vmlal_s16(sum_s32[1], vget_high_s16(s[5]), vget_high_s16(s[5]));
sum_s32[1] =
vmlal_s16(sum_s32[1], vget_high_s16(s[6]), vget_high_s16(s[6]));
sum_s32[1] =
vmlal_s16(sum_s32[1], vget_high_s16(s[7]), vget_high_s16(s[7]));
src_ptr += 8;
cols -= 8;
} while (cols);
sum_u64 = vpadalq_u32(sum_u64, vreinterpretq_u32_s32(sum_s32[0]));
sum_u64 = vpadalq_u32(sum_u64, vreinterpretq_u32_s32(sum_s32[1]));
src += 8 * stride;
rows -= 8;
} while (rows);
return horizontal_add_uint64x2(sum_u64);
}
}
|
353840ef6bb649b0825adbe3bf04acfb7fedb043
|
6186edb27443f74139dd22d5e3ea42f5a99bf568
|
/MemoryModule/MmpDotNet.h
|
14253e58313f1b2e13b655d089823863db177c15
|
[
"MIT"
] |
permissive
|
bb107/MemoryModulePP
|
a129d46775ebac8b8ff5ca4d1773dee05078a451
|
5fb7f591d271fda24f11753ca2c555c6d0c8d5f6
|
refs/heads/master
| 2023-05-11T18:16:17.904532
| 2023-05-03T02:52:22
| 2023-05-03T02:52:22
| 237,896,459
| 269
| 85
|
MIT
| 2022-10-07T01:16:04
| 2020-02-03T06:03:41
|
C++
|
UTF-8
|
C
| false
| false
| 239
|
h
|
MmpDotNet.h
|
#pragma once
typedef HRESULT(WINAPI* GetFileVersion_T)(
LPCWSTR szFilename,
LPWSTR szBuffer,
DWORD cchBuffer,
DWORD* dwLength
);
BOOL WINAPI MmpPreInitializeHooksForDotNet();
BOOL WINAPI MmpInitializeHooksForDotNet();
|
fd1b9848b50079cfd13abda2659e96a9483e4009
|
2c73a693c2b3c162eae2ab94f649d8c4494878ba
|
/luat/include/luat_log.h
|
59e630f6a796df9114b20172e1fbf756ecf8a98c
|
[
"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
| 2,001
|
h
|
luat_log.h
|
#ifndef LUAT_LOG_H
#define LUAT_LOG_H
#include "luat_base.h"
#define LUAT_LOG_DEBUG 1
#define LUAT_LOG_INFO 2
#define LUAT_LOG_WARN 3
#define LUAT_LOG_ERROR 4
#define LUAT_LOG_CLOSE 7
// void luat_print(const char* _str);
void luat_nprint(char *s, size_t l);
void luat_log_write(char *s, size_t l);
// #define luat_nprint luat_log_write
void luat_log_set_uart_port(int port);
uint8_t luat_log_get_uart_port(void);
void luat_log_set_level(int level);
int luat_log_get_level(void);
#ifdef LUAT_USE_LOG2
#define LLOGE(format, ...) luat_log_printf(LUAT_LOG_ERROR, "E/" LUAT_LOG_TAG " " format "\n", ##__VA_ARGS__)
#define LLOGW(format, ...) luat_log_printf(LUAT_LOG_WARN, "W/" LUAT_LOG_TAG " " format "\n", ##__VA_ARGS__)
#define LLOGI(format, ...) luat_log_printf(LUAT_LOG_INFO, "I/" LUAT_LOG_TAG " " format "\n", ##__VA_ARGS__)
#define LLOGD(format, ...) luat_log_printf(LUAT_LOG_DEBUG, "D/" LUAT_LOG_TAG " " format "\n", ##__VA_ARGS__)
void luat_log_printf(int level, const char* _fmt, ...);
#else
void luat_log_log(int level, const char* tag, const char* _fmt, ...);
#define LLOGE(format, ...) luat_log_log(LUAT_LOG_ERROR, LUAT_LOG_TAG, format, ##__VA_ARGS__)
#define LLOGW(format, ...) luat_log_log(LUAT_LOG_WARN, LUAT_LOG_TAG, format, ##__VA_ARGS__)
#define LLOGI(format, ...) luat_log_log(LUAT_LOG_INFO, LUAT_LOG_TAG, format, ##__VA_ARGS__)
#define LLOGD(format, ...) luat_log_log(LUAT_LOG_DEBUG, LUAT_LOG_TAG, format, ##__VA_ARGS__)
#define luat_log_error(XTAG, format, ...) luat_log_log(LUAT_LOG_ERROR, XTAG, format, ##__VA_ARGS__)
#define luat_log_warn(XTAG, format, ...) luat_log_log(LUAT_LOG_WARN, XTAG, format, ##__VA_ARGS__)
#define luat_log_info(XTAG, format, ...) luat_log_log(LUAT_LOG_INFO, XTAG, format, ##__VA_ARGS__)
#define luat_log_debug(XTAG, format, ...) luat_log_log(LUAT_LOG_DEBUG, XTAG, format, ##__VA_ARGS__)
void luat_log_dump(const char* tag, void* ptr, size_t len);
#define LLOGDUMP(ptr,len) luat_log_dump(LUAT_LOG_TAG, ptr, len)
#endif
#endif
|
95ed7f6aa3409b78a1c7905bdc026b1a60cf1bb8
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/wayland-protocols/gtk/gtk/gtkcsswidgetnode.c
|
fcc7682832c0059029dc26d5b2b3c31a1cdb8612
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"LGPL-2.0-only",
"LGPL-2.1-only",
"BSD-3-Clause"
] |
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
| 5,755
|
c
|
gtkcsswidgetnode.c
|
/* GTK - The GIMP Toolkit
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcsswidgetnodeprivate.h"
#include "gtkcssanimatedstyleprivate.h"
#include "gtkprivate.h"
#include "gtksettingsprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
G_DEFINE_TYPE (GtkCssWidgetNode, gtk_css_widget_node, GTK_TYPE_CSS_NODE)
static void
gtk_css_widget_node_finalize (GObject *object)
{
GtkCssWidgetNode *node = GTK_CSS_WIDGET_NODE (object);
g_object_unref (node->last_updated_style);
G_OBJECT_CLASS (gtk_css_widget_node_parent_class)->finalize (object);
}
static gboolean
gtk_css_widget_node_queue_callback (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
GtkCssNode *node = user_data;
gtk_css_node_invalidate_frame_clock (node, TRUE);
gtk_root_queue_restyle (GTK_ROOT (widget));
return G_SOURCE_CONTINUE;
}
static void
gtk_css_widget_node_queue_validate (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
if (GTK_IS_ROOT (widget_node->widget))
widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget,
gtk_css_widget_node_queue_callback,
node,
NULL);
}
static void
gtk_css_widget_node_dequeue_validate (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
if (widget_node->widget && GTK_IS_ROOT (widget_node->widget))
gtk_widget_remove_tick_callback (widget_node->widget,
widget_node->validate_cb_id);
}
static void
gtk_css_widget_node_validate (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
GtkCssStyleChange change;
GtkCssStyle *style;
if (widget_node->widget == NULL)
return;
if (node->style == widget_node->last_updated_style)
return;
style = gtk_css_node_get_style (node);
gtk_css_style_change_init (&change, widget_node->last_updated_style, style);
if (gtk_css_style_change_has_change (&change))
{
gtk_widget_css_changed (widget_node->widget, &change);
g_set_object (&widget_node->last_updated_style, style);
}
gtk_css_style_change_finish (&change);
}
static GtkStyleProvider *
gtk_css_widget_node_get_style_provider (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
GtkStyleContext *context;
GtkStyleCascade *cascade;
if (widget_node->widget == NULL)
return NULL;
context = _gtk_widget_peek_style_context (widget_node->widget);
if (context)
return gtk_style_context_get_style_provider (context);
cascade = _gtk_settings_get_style_cascade (gtk_widget_get_settings (widget_node->widget),
gtk_widget_get_scale_factor (widget_node->widget));
return GTK_STYLE_PROVIDER (cascade);
}
static GdkFrameClock *
gtk_css_widget_node_get_frame_clock (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
if (widget_node->widget == NULL)
return NULL;
if (!gtk_settings_get_enable_animations (gtk_widget_get_settings (widget_node->widget)))
return NULL;
return gtk_widget_get_frame_clock (widget_node->widget);
}
static void
gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
{
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_css_widget_node_finalize;
node_class->validate = gtk_css_widget_node_validate;
node_class->queue_validate = gtk_css_widget_node_queue_validate;
node_class->dequeue_validate = gtk_css_widget_node_dequeue_validate;
node_class->get_style_provider = gtk_css_widget_node_get_style_provider;
node_class->get_frame_clock = gtk_css_widget_node_get_frame_clock;
}
static void
gtk_css_widget_node_init (GtkCssWidgetNode *node)
{
node->last_updated_style = g_object_ref (gtk_css_static_style_get_default ());
}
GtkCssNode *
gtk_css_widget_node_new (GtkWidget *widget)
{
GtkCssWidgetNode *result;
gtk_internal_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
result = g_object_new (GTK_TYPE_CSS_WIDGET_NODE, NULL);
result->widget = widget;
gtk_css_node_set_visible (GTK_CSS_NODE (result),
_gtk_widget_get_visible (widget));
return GTK_CSS_NODE (result);
}
void
gtk_css_widget_node_widget_destroyed (GtkCssWidgetNode *node)
{
gtk_internal_return_if_fail (GTK_IS_CSS_WIDGET_NODE (node));
gtk_internal_return_if_fail (node->widget != NULL);
node->widget = NULL;
/* Contents of this node are now undefined.
* So we don't clear the style or anything.
*/
}
GtkWidget *
gtk_css_widget_node_get_widget (GtkCssWidgetNode *node)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_WIDGET_NODE (node), NULL);
return node->widget;
}
|
d1d1f96da4a9265aaad6efaa4d7efe99e814bdff
|
321d11eaee885ceb3a74db0a062f9bbdf282148c
|
/crypto/ec/curve448/arch_32/f_impl32.c
|
8a7a1fdbdeae542902a82ec4485ce0adaf347730
|
[
"Apache-2.0",
"OpenSSL",
"LicenseRef-scancode-proprietary-license"
] |
permissive
|
openssl/openssl
|
75691ebaae957793f2ff0673f77545277dfb3988
|
5318c012885a5382eadbf95aa9c1d35664bca819
|
refs/heads/master
| 2023-09-03T15:22:52.727123
| 2023-09-01T07:10:49
| 2023-09-02T14:30:01
| 7,634,677
| 24,148
| 11,569
|
Apache-2.0
| 2023-09-14T19:48:11
| 2013-01-15T22:34:48
|
C
|
UTF-8
|
C
| false
| false
| 2,811
|
c
|
f_impl32.c
|
/*
* Copyright 2017-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2014 Cryptography Research, Inc.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*
* Originally written by Mike Hamburg
*/
#include "internal/e_os.h"
#include <openssl/macros.h>
#include "internal/numbers.h"
#ifdef UINT128_MAX
/* We have support for 128 bit ints, so do nothing here */
NON_EMPTY_TRANSLATION_UNIT
#else
# include "../field.h"
void ossl_gf_mul(gf_s * RESTRICT cs, const gf as, const gf bs)
{
const uint32_t *a = as->limb, *b = bs->limb;
uint32_t *c = cs->limb;
uint64_t accum0 = 0, accum1 = 0, accum2 = 0;
uint32_t mask = (1 << 28) - 1;
uint32_t aa[8], bb[8];
int i, j;
for (i = 0; i < 8; i++) {
aa[i] = a[i] + a[i + 8];
bb[i] = b[i] + b[i + 8];
}
for (j = 0; j < 8; j++) {
accum2 = 0;
for (i = 0; i < j + 1; i++) {
accum2 += widemul(a[j - i], b[i]);
accum1 += widemul(aa[j - i], bb[i]);
accum0 += widemul(a[8 + j - i], b[8 + i]);
}
accum1 -= accum2;
accum0 += accum2;
accum2 = 0;
for (i = j + 1; i < 8; i++) {
accum0 -= widemul(a[8 + j - i], b[i]);
accum2 += widemul(aa[8 + j - i], bb[i]);
accum1 += widemul(a[16 + j - i], b[8 + i]);
}
accum1 += accum2;
accum0 += accum2;
c[j] = ((uint32_t)(accum0)) & mask;
c[j + 8] = ((uint32_t)(accum1)) & mask;
accum0 >>= 28;
accum1 >>= 28;
}
accum0 += accum1;
accum0 += c[8];
accum1 += c[0];
c[8] = ((uint32_t)(accum0)) & mask;
c[0] = ((uint32_t)(accum1)) & mask;
accum0 >>= 28;
accum1 >>= 28;
c[9] += ((uint32_t)(accum0));
c[1] += ((uint32_t)(accum1));
}
void ossl_gf_mulw_unsigned(gf_s * RESTRICT cs, const gf as, uint32_t b)
{
const uint32_t *a = as->limb;
uint32_t *c = cs->limb;
uint64_t accum0 = 0, accum8 = 0;
uint32_t mask = (1 << 28) - 1;
int i;
assert(b <= mask);
for (i = 0; i < 8; i++) {
accum0 += widemul(b, a[i]);
accum8 += widemul(b, a[i + 8]);
c[i] = accum0 & mask;
accum0 >>= 28;
c[i + 8] = accum8 & mask;
accum8 >>= 28;
}
accum0 += accum8 + c[8];
c[8] = ((uint32_t)accum0) & mask;
c[9] += (uint32_t)(accum0 >> 28);
accum8 += c[0];
c[0] = ((uint32_t)accum8) & mask;
c[1] += (uint32_t)(accum8 >> 28);
}
void ossl_gf_sqr(gf_s * RESTRICT cs, const gf as)
{
ossl_gf_mul(cs, as, as); /* Performs better with a dedicated square */
}
#endif
|
45f3b7225ea19e0a706f4a19bb441b45fec77afe
|
a3d6556180e74af7b555f8d47d3fea55b94bcbda
|
/third_party/blink/web_tests/compositing/invisible-subtree-compositing-and-preserves-3d-expected.html
|
79c6538829d58fc74c48d46c6e31fb68e85fdc4b
|
[
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause",
"MIT",
"Apache-2.0"
] |
permissive
|
chromium/chromium
|
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
|
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
|
refs/heads/main
| 2023-08-24T00:35:12.585945
| 2023-08-23T22:01:11
| 2023-08-23T22:01:11
| 120,360,765
| 17,408
| 7,102
|
BSD-3-Clause
| 2023-09-10T23:44:27
| 2018-02-05T20:55:32
| null |
UTF-8
|
C
| false
| false
| 191
|
html
|
invisible-subtree-compositing-and-preserves-3d-expected.html
|
<!doctype HTML>
<div style="transform: translateX(300px); width: 300px; height: 300px; background: lightblue">
<div style="width: 200px; height: 200px; background: lightgray"></div>
</div>
|
488c2d3be3934175bbada1b3f1e6f2e32194a947
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/net/wireless/p54/p54usb.c
|
f42dc3ccd496c33b9350f94b86e4bdf2411267a7
|
[
"GPL-1.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"Linux-syscall-note",
"GPL-2.0-only"
] |
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
| 29,835
|
c
|
p54usb.c
|
/*
* Linux device driver for USB based Prism54
*
* Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
*
* Based on the islsm (softmac prism54) driver, which is:
* Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/init.h>
#include <linux/usb.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/firmware.h>
#include <linux/etherdevice.h>
#include <linux/delay.h>
#include <linux/crc32.h>
#include <linux/module.h>
#include <net/mac80211.h>
#include "p54.h"
#include "lmac.h"
#include "p54usb.h"
MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>");
MODULE_DESCRIPTION("Prism54 USB wireless driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("prism54usb");
MODULE_FIRMWARE("isl3886usb");
MODULE_FIRMWARE("isl3887usb");
/*
* Note:
*
* Always update our wiki's device list (located at:
* http://wireless.kernel.org/en/users/Drivers/p54/devices ),
* whenever you add a new device.
*/
static struct usb_device_id p54u_table[] = {
/* Version 1 devices (pci chip + net2280) */
{USB_DEVICE(0x0411, 0x0050)}, /* Buffalo WLI2-USB2-G54 */
{USB_DEVICE(0x045e, 0x00c2)}, /* Microsoft MN-710 */
{USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */
{USB_DEVICE(0x0675, 0x0530)}, /* DrayTek Vigor 530 */
{USB_DEVICE(0x06b9, 0x0120)}, /* Thomson SpeedTouch 120g */
{USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */
{USB_DEVICE(0x07aa, 0x001c)}, /* Corega CG-WLUSB2GT */
{USB_DEVICE(0x083a, 0x4501)}, /* Accton 802.11g WN4501 USB */
{USB_DEVICE(0x083a, 0x4502)}, /* Siemens Gigaset USB Adapter */
{USB_DEVICE(0x083a, 0x5501)}, /* Phillips CPWUA054 */
{USB_DEVICE(0x0846, 0x4200)}, /* Netgear WG121 */
{USB_DEVICE(0x0846, 0x4210)}, /* Netgear WG121 the second ? */
{USB_DEVICE(0x0846, 0x4220)}, /* Netgear WG111 */
{USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */
{USB_DEVICE(0x0bf8, 0x1007)}, /* Fujitsu E-5400 USB */
{USB_DEVICE(0x0cde, 0x0006)}, /* Medion 40900, Roper Europe */
{USB_DEVICE(0x0db0, 0x6826)}, /* MSI UB54G (MS-6826) */
{USB_DEVICE(0x107b, 0x55f2)}, /* Gateway WGU-210 (Gemtek) */
{USB_DEVICE(0x124a, 0x4023)}, /* Shuttle PN15, Airvast WM168g, IOGear GWU513 */
{USB_DEVICE(0x1435, 0x0210)}, /* Inventel UR054G */
{USB_DEVICE(0x15a9, 0x0002)}, /* Gemtek WUBI-100GW 802.11g */
{USB_DEVICE(0x1630, 0x0005)}, /* 2Wire 802.11g USB (v1) / Z-Com */
{USB_DEVICE(0x182d, 0x096b)}, /* Sitecom WL-107 */
{USB_DEVICE(0x1915, 0x2234)}, /* Linksys WUSB54G OEM */
{USB_DEVICE(0x1915, 0x2235)}, /* Linksys WUSB54G Portable OEM */
{USB_DEVICE(0x2001, 0x3701)}, /* DLink DWL-G120 Spinnaker */
{USB_DEVICE(0x2001, 0x3703)}, /* DLink DWL-G122 */
{USB_DEVICE(0x2001, 0x3762)}, /* Conceptronic C54U */
{USB_DEVICE(0x5041, 0x2234)}, /* Linksys WUSB54G */
{USB_DEVICE(0x5041, 0x2235)}, /* Linksys WUSB54G Portable */
/* Version 2 devices (3887) */
{USB_DEVICE(0x0471, 0x1230)}, /* Philips CPWUA054/00 */
{USB_DEVICE(0x050d, 0x7050)}, /* Belkin F5D7050 ver 1000 */
{USB_DEVICE(0x0572, 0x2000)}, /* Cohiba Proto board */
{USB_DEVICE(0x0572, 0x2002)}, /* Cohiba Proto board */
{USB_DEVICE(0x06a9, 0x000e)}, /* Westell 802.11g USB (A90-211WG-01) */
{USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
{USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
{USB_DEVICE(0x07aa, 0x0020)}, /* Corega WLUSB2GTST USB */
{USB_DEVICE(0x0803, 0x4310)}, /* Zoom 4410a */
{USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
{USB_DEVICE(0x083a, 0x4531)}, /* T-Com Sinus 154 data II */
{USB_DEVICE(0x083a, 0xc501)}, /* Zoom Wireless-G 4410 */
{USB_DEVICE(0x083a, 0xf503)}, /* Accton FD7050E ver 1010ec */
{USB_DEVICE(0x0846, 0x4240)}, /* Netgear WG111 (v2) */
{USB_DEVICE(0x0915, 0x2000)}, /* Cohiba Proto board */
{USB_DEVICE(0x0915, 0x2002)}, /* Cohiba Proto board */
{USB_DEVICE(0x0baf, 0x0118)}, /* U.S. Robotics U5 802.11g Adapter*/
{USB_DEVICE(0x0bf8, 0x1009)}, /* FUJITSU E-5400 USB D1700*/
/* {USB_DEVICE(0x0cde, 0x0006)}, * Medion MD40900 already listed above,
* just noting it here for clarity */
{USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */
{USB_DEVICE(0x0cde, 0x0015)}, /* Zcomax XG-705A */
{USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */
{USB_DEVICE(0x124a, 0x4025)}, /* IOGear GWU513 (GW3887IK chip) */
{USB_DEVICE(0x1260, 0xee22)}, /* SMC 2862W-G version 2 */
{USB_DEVICE(0x13b1, 0x000a)}, /* Linksys WUSB54G ver 2 */
{USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */
{USB_DEVICE(0x1413, 0x5400)}, /* Telsey 802.11g USB2.0 Adapter */
{USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */
/* {USB_DEVICE(0x15a9, 0x0002)}, * Also SparkLAN WL-682 with 3887 */
{USB_DEVICE(0x1668, 0x1050)}, /* Actiontec 802UIG-1 */
{USB_DEVICE(0x1740, 0x1000)}, /* Senao NUB-350 */
{USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */
{USB_DEVICE(0x2001, 0x3705)}, /* D-Link DWL-G120 rev C1 */
{USB_DEVICE(0x413c, 0x5513)}, /* Dell WLA3310 USB Wireless Adapter */
{USB_DEVICE(0x413c, 0x8102)}, /* Spinnaker DUT */
{USB_DEVICE(0x413c, 0x8104)}, /* Cohiba Proto board */
{}
};
MODULE_DEVICE_TABLE(usb, p54u_table);
static const struct {
u32 intf;
enum p54u_hw_type type;
const char *fw;
char hw[20];
} p54u_fwlist[__NUM_P54U_HWTYPES] = {
{
.type = P54U_NET2280,
.intf = FW_LM86,
.fw = "isl3886usb",
.hw = "ISL3886 + net2280",
},
{
.type = P54U_3887,
.intf = FW_LM87,
.fw = "isl3887usb",
.hw = "ISL3887",
},
};
static void p54u_rx_cb(struct urb *urb)
{
struct sk_buff *skb = (struct sk_buff *) urb->context;
struct p54u_rx_info *info = (struct p54u_rx_info *)skb->cb;
struct ieee80211_hw *dev = info->dev;
struct p54u_priv *priv = dev->priv;
skb_unlink(skb, &priv->rx_queue);
if (unlikely(urb->status)) {
dev_kfree_skb_irq(skb);
return;
}
skb_put(skb, urb->actual_length);
if (priv->hw_type == P54U_NET2280)
skb_pull(skb, priv->common.tx_hdr_len);
if (priv->common.fw_interface == FW_LM87) {
skb_pull(skb, 4);
skb_put(skb, 4);
}
if (p54_rx(dev, skb)) {
skb = dev_alloc_skb(priv->common.rx_mtu + 32);
if (unlikely(!skb)) {
/* TODO check rx queue length and refill *somewhere* */
return;
}
info = (struct p54u_rx_info *) skb->cb;
info->urb = urb;
info->dev = dev;
urb->transfer_buffer = skb_tail_pointer(skb);
urb->context = skb;
} else {
if (priv->hw_type == P54U_NET2280)
skb_push(skb, priv->common.tx_hdr_len);
if (priv->common.fw_interface == FW_LM87) {
skb_push(skb, 4);
skb_put(skb, 4);
}
skb_reset_tail_pointer(skb);
skb_trim(skb, 0);
urb->transfer_buffer = skb_tail_pointer(skb);
}
skb_queue_tail(&priv->rx_queue, skb);
usb_anchor_urb(urb, &priv->submitted);
if (usb_submit_urb(urb, GFP_ATOMIC)) {
skb_unlink(skb, &priv->rx_queue);
usb_unanchor_urb(urb);
dev_kfree_skb_irq(skb);
}
}
static void p54u_tx_cb(struct urb *urb)
{
struct sk_buff *skb = urb->context;
struct ieee80211_hw *dev =
usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
p54_free_skb(dev, skb);
}
static void p54u_tx_dummy_cb(struct urb *urb) { }
static void p54u_free_urbs(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
usb_kill_anchored_urbs(&priv->submitted);
}
static void p54u_stop(struct ieee80211_hw *dev)
{
/*
* TODO: figure out how to reliably stop the 3887 and net2280 so
* the hardware is still usable next time we want to start it.
* until then, we just stop listening to the hardware..
*/
p54u_free_urbs(dev);
}
static int p54u_init_urbs(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
struct urb *entry = NULL;
struct sk_buff *skb;
struct p54u_rx_info *info;
int ret = 0;
while (skb_queue_len(&priv->rx_queue) < 32) {
skb = __dev_alloc_skb(priv->common.rx_mtu + 32, GFP_KERNEL);
if (!skb) {
ret = -ENOMEM;
goto err;
}
entry = usb_alloc_urb(0, GFP_KERNEL);
if (!entry) {
ret = -ENOMEM;
goto err;
}
usb_fill_bulk_urb(entry, priv->udev,
usb_rcvbulkpipe(priv->udev, P54U_PIPE_DATA),
skb_tail_pointer(skb),
priv->common.rx_mtu + 32, p54u_rx_cb, skb);
info = (struct p54u_rx_info *) skb->cb;
info->urb = entry;
info->dev = dev;
skb_queue_tail(&priv->rx_queue, skb);
usb_anchor_urb(entry, &priv->submitted);
ret = usb_submit_urb(entry, GFP_KERNEL);
if (ret) {
skb_unlink(skb, &priv->rx_queue);
usb_unanchor_urb(entry);
goto err;
}
usb_free_urb(entry);
entry = NULL;
}
return 0;
err:
usb_free_urb(entry);
kfree_skb(skb);
p54u_free_urbs(dev);
return ret;
}
static int p54u_open(struct ieee80211_hw *dev)
{
/*
* TODO: Because we don't know how to reliably stop the 3887 and
* the isl3886+net2280, other than brutally cut off all
* communications. We have to reinitialize the urbs on every start.
*/
return p54u_init_urbs(dev);
}
static __le32 p54u_lm87_chksum(const __le32 *data, size_t length)
{
u32 chk = 0;
length >>= 2;
while (length--) {
chk ^= le32_to_cpu(*data++);
chk = (chk >> 5) ^ (chk << 3);
}
return cpu_to_le32(chk);
}
static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb)
{
struct p54u_priv *priv = dev->priv;
struct urb *data_urb;
struct lm87_tx_hdr *hdr = (void *)skb->data - sizeof(*hdr);
data_urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!data_urb) {
p54_free_skb(dev, skb);
return;
}
hdr->chksum = p54u_lm87_chksum((__le32 *)skb->data, skb->len);
hdr->device_addr = ((struct p54_hdr *)skb->data)->req_id;
usb_fill_bulk_urb(data_urb, priv->udev,
usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
hdr, skb->len + sizeof(*hdr), FREE_AFTER_TX(skb) ?
p54u_tx_cb : p54u_tx_dummy_cb, skb);
data_urb->transfer_flags |= URB_ZERO_PACKET;
usb_anchor_urb(data_urb, &priv->submitted);
if (usb_submit_urb(data_urb, GFP_ATOMIC)) {
usb_unanchor_urb(data_urb);
p54_free_skb(dev, skb);
}
usb_free_urb(data_urb);
}
static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb)
{
struct p54u_priv *priv = dev->priv;
struct urb *int_urb = NULL, *data_urb = NULL;
struct net2280_tx_hdr *hdr = (void *)skb->data - sizeof(*hdr);
struct net2280_reg_write *reg = NULL;
int err = -ENOMEM;
reg = kmalloc(sizeof(*reg), GFP_ATOMIC);
if (!reg)
goto out;
int_urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!int_urb)
goto out;
data_urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!data_urb)
goto out;
reg->port = cpu_to_le16(NET2280_DEV_U32);
reg->addr = cpu_to_le32(P54U_DEV_BASE);
reg->val = cpu_to_le32(ISL38XX_DEV_INT_DATA);
memset(hdr, 0, sizeof(*hdr));
hdr->len = cpu_to_le16(skb->len);
hdr->device_addr = ((struct p54_hdr *) skb->data)->req_id;
usb_fill_bulk_urb(int_urb, priv->udev,
usb_sndbulkpipe(priv->udev, P54U_PIPE_DEV), reg, sizeof(*reg),
p54u_tx_dummy_cb, dev);
/*
* URB_FREE_BUFFER triggers a code path in the USB subsystem that will
* free what is inside the transfer_buffer after the last reference to
* the int_urb is dropped.
*/
int_urb->transfer_flags |= URB_FREE_BUFFER | URB_ZERO_PACKET;
reg = NULL;
usb_fill_bulk_urb(data_urb, priv->udev,
usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
hdr, skb->len + sizeof(*hdr), FREE_AFTER_TX(skb) ?
p54u_tx_cb : p54u_tx_dummy_cb, skb);
data_urb->transfer_flags |= URB_ZERO_PACKET;
usb_anchor_urb(int_urb, &priv->submitted);
err = usb_submit_urb(int_urb, GFP_ATOMIC);
if (err) {
usb_unanchor_urb(int_urb);
goto out;
}
usb_anchor_urb(data_urb, &priv->submitted);
err = usb_submit_urb(data_urb, GFP_ATOMIC);
if (err) {
usb_unanchor_urb(data_urb);
goto out;
}
out:
usb_free_urb(int_urb);
usb_free_urb(data_urb);
if (err) {
kfree(reg);
p54_free_skb(dev, skb);
}
}
static int p54u_write(struct p54u_priv *priv,
struct net2280_reg_write *buf,
enum net2280_op_type type,
__le32 addr, __le32 val)
{
unsigned int ep;
int alen;
if (type & 0x0800)
ep = usb_sndbulkpipe(priv->udev, P54U_PIPE_DEV);
else
ep = usb_sndbulkpipe(priv->udev, P54U_PIPE_BRG);
buf->port = cpu_to_le16(type);
buf->addr = addr;
buf->val = val;
return usb_bulk_msg(priv->udev, ep, buf, sizeof(*buf), &alen, 1000);
}
static int p54u_read(struct p54u_priv *priv, void *buf,
enum net2280_op_type type,
__le32 addr, __le32 *val)
{
struct net2280_reg_read *read = buf;
__le32 *reg = buf;
unsigned int ep;
int alen, err;
if (type & 0x0800)
ep = P54U_PIPE_DEV;
else
ep = P54U_PIPE_BRG;
read->port = cpu_to_le16(type);
read->addr = addr;
err = usb_bulk_msg(priv->udev, usb_sndbulkpipe(priv->udev, ep),
read, sizeof(*read), &alen, 1000);
if (err)
return err;
err = usb_bulk_msg(priv->udev, usb_rcvbulkpipe(priv->udev, ep),
reg, sizeof(*reg), &alen, 1000);
if (err)
return err;
*val = *reg;
return 0;
}
static int p54u_bulk_msg(struct p54u_priv *priv, unsigned int ep,
void *data, size_t len)
{
int alen;
return usb_bulk_msg(priv->udev, usb_sndbulkpipe(priv->udev, ep),
data, len, &alen, 2000);
}
static int p54u_device_reset(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
int ret, lock = (priv->intf->condition != USB_INTERFACE_BINDING);
if (lock) {
ret = usb_lock_device_for_reset(priv->udev, priv->intf);
if (ret < 0) {
dev_err(&priv->udev->dev, "(p54usb) unable to lock "
"device for reset (%d)!\n", ret);
return ret;
}
}
ret = usb_reset_device(priv->udev);
if (lock)
usb_unlock_device(priv->udev);
if (ret)
dev_err(&priv->udev->dev, "(p54usb) unable to reset "
"device (%d)!\n", ret);
return ret;
}
static const char p54u_romboot_3887[] = "~~~~";
static int p54u_firmware_reset_3887(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
u8 *buf;
int ret;
buf = kmemdup(p54u_romboot_3887, 4, GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = p54u_bulk_msg(priv, P54U_PIPE_DATA,
buf, 4);
kfree(buf);
if (ret)
dev_err(&priv->udev->dev, "(p54usb) unable to jump to "
"boot ROM (%d)!\n", ret);
return ret;
}
static const char p54u_firmware_upload_3887[] = "<\r";
static int p54u_upload_firmware_3887(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
int err, alen;
u8 carry = 0;
u8 *buf, *tmp;
const u8 *data;
unsigned int left, remains, block_size;
struct x2_header *hdr;
unsigned long timeout;
err = p54u_firmware_reset_3887(dev);
if (err)
return err;
tmp = buf = kmalloc(P54U_FW_BLOCK, GFP_KERNEL);
if (!buf)
return -ENOMEM;
left = block_size = min((size_t)P54U_FW_BLOCK, priv->fw->size);
strcpy(buf, p54u_firmware_upload_3887);
left -= strlen(p54u_firmware_upload_3887);
tmp += strlen(p54u_firmware_upload_3887);
data = priv->fw->data;
remains = priv->fw->size;
hdr = (struct x2_header *)(buf + strlen(p54u_firmware_upload_3887));
memcpy(hdr->signature, X2_SIGNATURE, X2_SIGNATURE_SIZE);
hdr->fw_load_addr = cpu_to_le32(ISL38XX_DEV_FIRMWARE_ADDR);
hdr->fw_length = cpu_to_le32(priv->fw->size);
hdr->crc = cpu_to_le32(~crc32_le(~0, (void *)&hdr->fw_load_addr,
sizeof(u32)*2));
left -= sizeof(*hdr);
tmp += sizeof(*hdr);
while (remains) {
while (left--) {
if (carry) {
*tmp++ = carry;
carry = 0;
remains--;
continue;
}
switch (*data) {
case '~':
*tmp++ = '}';
carry = '^';
break;
case '}':
*tmp++ = '}';
carry = ']';
break;
default:
*tmp++ = *data;
remains--;
break;
}
data++;
}
err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, block_size);
if (err) {
dev_err(&priv->udev->dev, "(p54usb) firmware "
"upload failed!\n");
goto err_upload_failed;
}
tmp = buf;
left = block_size = min((unsigned int)P54U_FW_BLOCK, remains);
}
*((__le32 *)buf) = cpu_to_le32(~crc32_le(~0, priv->fw->data,
priv->fw->size));
err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, sizeof(u32));
if (err) {
dev_err(&priv->udev->dev, "(p54usb) firmware upload failed!\n");
goto err_upload_failed;
}
timeout = jiffies + msecs_to_jiffies(1000);
while (!(err = usb_bulk_msg(priv->udev,
usb_rcvbulkpipe(priv->udev, P54U_PIPE_DATA), buf, 128, &alen, 1000))) {
if (alen > 2 && !memcmp(buf, "OK", 2))
break;
if (alen > 5 && !memcmp(buf, "ERROR", 5)) {
err = -EINVAL;
break;
}
if (time_after(jiffies, timeout)) {
dev_err(&priv->udev->dev, "(p54usb) firmware boot "
"timed out!\n");
err = -ETIMEDOUT;
break;
}
}
if (err) {
dev_err(&priv->udev->dev, "(p54usb) firmware upload failed!\n");
goto err_upload_failed;
}
buf[0] = 'g';
buf[1] = '\r';
err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, 2);
if (err) {
dev_err(&priv->udev->dev, "(p54usb) firmware boot failed!\n");
goto err_upload_failed;
}
timeout = jiffies + msecs_to_jiffies(1000);
while (!(err = usb_bulk_msg(priv->udev,
usb_rcvbulkpipe(priv->udev, P54U_PIPE_DATA), buf, 128, &alen, 1000))) {
if (alen > 0 && buf[0] == 'g')
break;
if (time_after(jiffies, timeout)) {
err = -ETIMEDOUT;
break;
}
}
if (err)
goto err_upload_failed;
err_upload_failed:
kfree(buf);
return err;
}
static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev)
{
struct p54u_priv *priv = dev->priv;
const struct p54p_csr *devreg = (const struct p54p_csr *) P54U_DEV_BASE;
int err, alen;
void *buf;
__le32 reg;
unsigned int remains, offset;
const u8 *data;
buf = kmalloc(512, GFP_KERNEL);
if (!buf)
return -ENOMEM;
#define P54U_WRITE(type, addr, data) \
do {\
err = p54u_write(priv, buf, type,\
cpu_to_le32((u32)(unsigned long)addr), data);\
if (err) \
goto fail;\
} while (0)
#define P54U_READ(type, addr) \
do {\
err = p54u_read(priv, buf, type,\
cpu_to_le32((u32)(unsigned long)addr), ®);\
if (err)\
goto fail;\
} while (0)
/* power down net2280 bridge */
P54U_READ(NET2280_BRG_U32, NET2280_GPIOCTL);
reg |= cpu_to_le32(P54U_BRG_POWER_DOWN);
reg &= cpu_to_le32(~P54U_BRG_POWER_UP);
P54U_WRITE(NET2280_BRG_U32, NET2280_GPIOCTL, reg);
mdelay(100);
/* power up bridge */
reg |= cpu_to_le32(P54U_BRG_POWER_UP);
reg &= cpu_to_le32(~P54U_BRG_POWER_DOWN);
P54U_WRITE(NET2280_BRG_U32, NET2280_GPIOCTL, reg);
mdelay(100);
P54U_WRITE(NET2280_BRG_U32, NET2280_DEVINIT,
cpu_to_le32(NET2280_CLK_30Mhz |
NET2280_PCI_ENABLE |
NET2280_PCI_SOFT_RESET));
mdelay(20);
P54U_WRITE(NET2280_BRG_CFG_U16, PCI_COMMAND,
cpu_to_le32(PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER));
P54U_WRITE(NET2280_BRG_CFG_U32, PCI_BASE_ADDRESS_0,
cpu_to_le32(NET2280_BASE));
P54U_READ(NET2280_BRG_CFG_U16, PCI_STATUS);
reg |= cpu_to_le32(PCI_STATUS_REC_MASTER_ABORT);
P54U_WRITE(NET2280_BRG_CFG_U16, PCI_STATUS, reg);
// TODO: we really need this?
P54U_READ(NET2280_BRG_U32, NET2280_RELNUM);
P54U_WRITE(NET2280_BRG_U32, NET2280_EPA_RSP,
cpu_to_le32(NET2280_CLEAR_NAK_OUT_PACKETS_MODE));
P54U_WRITE(NET2280_BRG_U32, NET2280_EPC_RSP,
cpu_to_le32(NET2280_CLEAR_NAK_OUT_PACKETS_MODE));
P54U_WRITE(NET2280_BRG_CFG_U32, PCI_BASE_ADDRESS_2,
cpu_to_le32(NET2280_BASE2));
/* finally done setting up the bridge */
P54U_WRITE(NET2280_DEV_CFG_U16, 0x10000 | PCI_COMMAND,
cpu_to_le32(PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER));
P54U_WRITE(NET2280_DEV_CFG_U16, 0x10000 | 0x40 /* TRDY timeout */, 0);
P54U_WRITE(NET2280_DEV_CFG_U32, 0x10000 | PCI_BASE_ADDRESS_0,
cpu_to_le32(P54U_DEV_BASE));
P54U_WRITE(NET2280_BRG_U32, NET2280_USBIRQENB1, 0);
P54U_WRITE(NET2280_BRG_U32, NET2280_IRQSTAT1,
cpu_to_le32(NET2280_PCI_INTA_INTERRUPT));
/* do romboot */
P54U_WRITE(NET2280_DEV_U32, &devreg->int_enable, 0);
P54U_READ(NET2280_DEV_U32, &devreg->ctrl_stat);
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RAMBOOT);
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_CLKRUN);
P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);
mdelay(20);
reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);
P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);
mdelay(20);
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);
mdelay(100);
P54U_READ(NET2280_DEV_U32, &devreg->int_ident);
P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);
/* finally, we can upload firmware now! */
remains = priv->fw->size;
data = priv->fw->data;
offset = ISL38XX_DEV_FIRMWARE_ADDR;
while (remains) {
unsigned int block_len = min(remains, (unsigned int)512);
memcpy(buf, data, block_len);
err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, block_len);
if (err) {
dev_err(&priv->udev->dev, "(p54usb) firmware block "
"upload failed\n");
goto fail;
}
P54U_WRITE(NET2280_DEV_U32, &devreg->direct_mem_base,
cpu_to_le32(0xc0000f00));
P54U_WRITE(NET2280_DEV_U32,
0x0020 | (unsigned long)&devreg->direct_mem_win, 0);
P54U_WRITE(NET2280_DEV_U32,
0x0020 | (unsigned long)&devreg->direct_mem_win,
cpu_to_le32(1));
P54U_WRITE(NET2280_DEV_U32,
0x0024 | (unsigned long)&devreg->direct_mem_win,
cpu_to_le32(block_len));
P54U_WRITE(NET2280_DEV_U32,
0x0028 | (unsigned long)&devreg->direct_mem_win,
cpu_to_le32(offset));
P54U_WRITE(NET2280_DEV_U32, &devreg->dma_addr,
cpu_to_le32(NET2280_EPA_FIFO_PCI_ADDR));
P54U_WRITE(NET2280_DEV_U32, &devreg->dma_len,
cpu_to_le32(block_len >> 2));
P54U_WRITE(NET2280_DEV_U32, &devreg->dma_ctrl,
cpu_to_le32(ISL38XX_DMA_MASTER_CONTROL_TRIGGER));
mdelay(10);
P54U_READ(NET2280_DEV_U32,
0x002C | (unsigned long)&devreg->direct_mem_win);
if (!(reg & cpu_to_le32(ISL38XX_DMA_STATUS_DONE)) ||
!(reg & cpu_to_le32(ISL38XX_DMA_STATUS_READY))) {
dev_err(&priv->udev->dev, "(p54usb) firmware DMA "
"transfer failed\n");
goto fail;
}
P54U_WRITE(NET2280_BRG_U32, NET2280_EPA_STAT,
cpu_to_le32(NET2280_FIFO_FLUSH));
remains -= block_len;
data += block_len;
offset += block_len;
}
/* do ramboot */
P54U_READ(NET2280_DEV_U32, &devreg->ctrl_stat);
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_CLKRUN);
reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RAMBOOT);
P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);
mdelay(20);
reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);
P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);
mdelay(100);
P54U_READ(NET2280_DEV_U32, &devreg->int_ident);
P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);
/* start up the firmware */
P54U_WRITE(NET2280_DEV_U32, &devreg->int_enable,
cpu_to_le32(ISL38XX_INT_IDENT_INIT));
P54U_WRITE(NET2280_BRG_U32, NET2280_IRQSTAT1,
cpu_to_le32(NET2280_PCI_INTA_INTERRUPT));
P54U_WRITE(NET2280_BRG_U32, NET2280_USBIRQENB1,
cpu_to_le32(NET2280_PCI_INTA_INTERRUPT_ENABLE |
NET2280_USB_INTERRUPT_ENABLE));
P54U_WRITE(NET2280_DEV_U32, &devreg->dev_int,
cpu_to_le32(ISL38XX_DEV_INT_RESET));
err = usb_interrupt_msg(priv->udev,
usb_rcvbulkpipe(priv->udev, P54U_PIPE_INT),
buf, sizeof(__le32), &alen, 1000);
if (err || alen != sizeof(__le32))
goto fail;
P54U_READ(NET2280_DEV_U32, &devreg->int_ident);
P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);
if (!(reg & cpu_to_le32(ISL38XX_INT_IDENT_INIT)))
err = -EINVAL;
P54U_WRITE(NET2280_BRG_U32, NET2280_USBIRQENB1, 0);
P54U_WRITE(NET2280_BRG_U32, NET2280_IRQSTAT1,
cpu_to_le32(NET2280_PCI_INTA_INTERRUPT));
#undef P54U_WRITE
#undef P54U_READ
fail:
kfree(buf);
return err;
}
static int p54_find_type(struct p54u_priv *priv)
{
int i;
for (i = 0; i < __NUM_P54U_HWTYPES; i++)
if (p54u_fwlist[i].type == priv->hw_type)
break;
if (i == __NUM_P54U_HWTYPES)
return -EOPNOTSUPP;
return i;
}
static int p54u_start_ops(struct p54u_priv *priv)
{
struct ieee80211_hw *dev = priv->common.hw;
int ret;
ret = p54_parse_firmware(dev, priv->fw);
if (ret)
goto err_out;
ret = p54_find_type(priv);
if (ret < 0)
goto err_out;
if (priv->common.fw_interface != p54u_fwlist[ret].intf) {
dev_err(&priv->udev->dev, "wrong firmware, please get "
"a firmware for \"%s\" and try again.\n",
p54u_fwlist[ret].hw);
ret = -ENODEV;
goto err_out;
}
ret = priv->upload_fw(dev);
if (ret)
goto err_out;
ret = p54u_open(dev);
if (ret)
goto err_out;
ret = p54_read_eeprom(dev);
if (ret)
goto err_stop;
p54u_stop(dev);
ret = p54_register_common(dev, &priv->udev->dev);
if (ret)
goto err_stop;
return 0;
err_stop:
p54u_stop(dev);
err_out:
/*
* p54u_disconnect will do the rest of the
* cleanup
*/
return ret;
}
static void p54u_load_firmware_cb(const struct firmware *firmware,
void *context)
{
struct p54u_priv *priv = context;
struct usb_device *udev = priv->udev;
int err;
complete(&priv->fw_wait_load);
if (firmware) {
priv->fw = firmware;
err = p54u_start_ops(priv);
} else {
err = -ENOENT;
dev_err(&udev->dev, "Firmware not found.\n");
}
if (err) {
struct device *parent = priv->udev->dev.parent;
dev_err(&udev->dev, "failed to initialize device (%d)\n", err);
if (parent)
device_lock(parent);
device_release_driver(&udev->dev);
/*
* At this point p54u_disconnect has already freed
* the "priv" context. Do not use it anymore!
*/
priv = NULL;
if (parent)
device_unlock(parent);
}
usb_put_dev(udev);
}
static int p54u_load_firmware(struct ieee80211_hw *dev,
struct usb_interface *intf)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct p54u_priv *priv = dev->priv;
struct device *device = &udev->dev;
int err, i;
BUILD_BUG_ON(ARRAY_SIZE(p54u_fwlist) != __NUM_P54U_HWTYPES);
init_completion(&priv->fw_wait_load);
i = p54_find_type(priv);
if (i < 0)
return i;
dev_info(&priv->udev->dev, "Loading firmware file %s\n",
p54u_fwlist[i].fw);
usb_get_dev(udev);
err = request_firmware_nowait(THIS_MODULE, 1, p54u_fwlist[i].fw,
device, GFP_KERNEL, priv,
p54u_load_firmware_cb);
if (err) {
dev_err(&priv->udev->dev, "(p54usb) cannot load firmware %s "
"(%d)!\n", p54u_fwlist[i].fw, err);
}
return err;
}
static int p54u_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct ieee80211_hw *dev;
struct p54u_priv *priv;
int err;
unsigned int i, recognized_pipes;
dev = p54_init_common(sizeof(*priv));
if (!dev) {
dev_err(&udev->dev, "(p54usb) ieee80211 alloc failed\n");
return -ENOMEM;
}
priv = dev->priv;
priv->hw_type = P54U_INVALID_HW;
SET_IEEE80211_DEV(dev, &intf->dev);
usb_set_intfdata(intf, dev);
priv->udev = udev;
priv->intf = intf;
skb_queue_head_init(&priv->rx_queue);
init_usb_anchor(&priv->submitted);
usb_get_dev(udev);
/* really lazy and simple way of figuring out if we're a 3887 */
/* TODO: should just stick the identification in the device table */
i = intf->altsetting->desc.bNumEndpoints;
recognized_pipes = 0;
while (i--) {
switch (intf->altsetting->endpoint[i].desc.bEndpointAddress) {
case P54U_PIPE_DATA:
case P54U_PIPE_MGMT:
case P54U_PIPE_BRG:
case P54U_PIPE_DEV:
case P54U_PIPE_DATA | USB_DIR_IN:
case P54U_PIPE_MGMT | USB_DIR_IN:
case P54U_PIPE_BRG | USB_DIR_IN:
case P54U_PIPE_DEV | USB_DIR_IN:
case P54U_PIPE_INT | USB_DIR_IN:
recognized_pipes++;
}
}
priv->common.open = p54u_open;
priv->common.stop = p54u_stop;
if (recognized_pipes < P54U_PIPE_NUMBER) {
#ifdef CONFIG_PM
/* ISL3887 needs a full reset on resume */
udev->reset_resume = 1;
#endif /* CONFIG_PM */
err = p54u_device_reset(dev);
priv->hw_type = P54U_3887;
dev->extra_tx_headroom += sizeof(struct lm87_tx_hdr);
priv->common.tx_hdr_len = sizeof(struct lm87_tx_hdr);
priv->common.tx = p54u_tx_lm87;
priv->upload_fw = p54u_upload_firmware_3887;
} else {
priv->hw_type = P54U_NET2280;
dev->extra_tx_headroom += sizeof(struct net2280_tx_hdr);
priv->common.tx_hdr_len = sizeof(struct net2280_tx_hdr);
priv->common.tx = p54u_tx_net2280;
priv->upload_fw = p54u_upload_firmware_net2280;
}
err = p54u_load_firmware(dev, intf);
return err;
}
static void p54u_disconnect(struct usb_interface *intf)
{
struct ieee80211_hw *dev = usb_get_intfdata(intf);
struct p54u_priv *priv;
if (!dev)
return;
priv = dev->priv;
wait_for_completion(&priv->fw_wait_load);
p54_unregister_common(dev);
usb_put_dev(interface_to_usbdev(intf));
release_firmware(priv->fw);
p54_free_common(dev);
}
static int p54u_pre_reset(struct usb_interface *intf)
{
struct ieee80211_hw *dev = usb_get_intfdata(intf);
if (!dev)
return -ENODEV;
p54u_stop(dev);
return 0;
}
static int p54u_resume(struct usb_interface *intf)
{
struct ieee80211_hw *dev = usb_get_intfdata(intf);
struct p54u_priv *priv;
if (!dev)
return -ENODEV;
priv = dev->priv;
if (unlikely(!(priv->upload_fw && priv->fw)))
return 0;
return priv->upload_fw(dev);
}
static int p54u_post_reset(struct usb_interface *intf)
{
struct ieee80211_hw *dev = usb_get_intfdata(intf);
struct p54u_priv *priv;
int err;
err = p54u_resume(intf);
if (err)
return err;
/* reinitialize old device state */
priv = dev->priv;
if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED)
ieee80211_restart_hw(dev);
return 0;
}
#ifdef CONFIG_PM
static int p54u_suspend(struct usb_interface *intf, pm_message_t message)
{
return p54u_pre_reset(intf);
}
#endif /* CONFIG_PM */
static struct usb_driver p54u_driver = {
.name = "p54usb",
.id_table = p54u_table,
.probe = p54u_probe,
.disconnect = p54u_disconnect,
.pre_reset = p54u_pre_reset,
.post_reset = p54u_post_reset,
#ifdef CONFIG_PM
.suspend = p54u_suspend,
.resume = p54u_resume,
.reset_resume = p54u_resume,
#endif /* CONFIG_PM */
.soft_unbind = 1,
.disable_hub_initiated_lpm = 1,
};
module_usb_driver(p54u_driver);
|
83699da5b1bbf7fb5b11f498aeefabf3cbcceed6
|
aed47b5a4ea3af5cbacfc034c1565bd800e9461a
|
/src/CControl/Sources/Statistics/center.c
|
64a1bf3108fd119212d8d6a114fc855ab8751186
|
[
"MIT"
] |
permissive
|
DanielMartensson/CControl
|
a4dcfc13af8ef8266ac83f9ec0690848f5afd1b2
|
25ce62ef3a0d87a55459fc9e7d4e1ee895d89ed9
|
refs/heads/master
| 2023-08-30T23:53:16.167470
| 2023-08-28T21:30:11
| 2023-08-28T21:30:11
| 214,724,629
| 169
| 53
|
MIT
| 2023-03-02T21:35:56
| 2019-10-12T22:33:21
|
C
|
ISO-8859-15
|
C
| false
| false
| 696
|
c
|
center.c
|
/*
* center.c
*
* Created on: 23 Juli. 2023
* Author: Daniel Mårtensson
*/
#include "../../Headers/functions.h"
/*
* Center the data matrix X by using X = X - mean(X)
* X[m*n]
* mu[n]
*/
void center(float X[], float mu[], size_t row, size_t column) {
size_t i, j;
float* X0 = X;
float average;
/* Column-Major */
tran(X, row, column);
for (i = 0; i < column; i++) {
/* Average data mu[i] = mean(X) */
average = mean(X, row);
/* Center the data X = X - mu */
for (j = 0; j < row; j++) {
X[j] -= average;
}
/* Save the average */
mu[i] = average;
/* Jump to next row */
X += row;
}
X = X0;
/* Turn it back to Row-Major */
tran(X, column, row);
}
|
98f2c21d16c9ec97d78d63c5d0536fc55df4e177
|
1577e1cf4e89584a125cffb855ca50a9654c6d55
|
/Security/tests/TrustTests/EvaluationTests/KeySizeTests_data.h
|
e749eac087a5834434ad7f9f1ca46fda86bf3986
|
[] |
no_license
|
apple-open-source/macos
|
a4188b5c2ef113d90281d03cd1b14e5ee52ebffb
|
2d2b15f13487673de33297e49f00ef94af743a9a
|
refs/heads/master
| 2023-08-01T11:03:26.870408
| 2023-03-27T00:00:00
| 2023-03-27T00:00:00
| 180,595,052
| 124
| 24
| null | 2022-12-27T14:54:09
| 2019-04-10T14:06:23
| null |
UTF-8
|
C
| false
| false
| 110,571
|
h
|
KeySizeTests_data.h
|
/*
* Copyright (c) 2018 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
#ifndef _TRUSTTESTS_EVALUATION_KEY_SIZE_TESTS_H_
#define _TRUSTTESTS_EVALUATION_KEY_SIZE_TESTS_H_
const uint8_t prt_forest_fi_certificate[1797] = {
0x30,0x82,0x07,0x01,0x30,0x82,0x05,0xe9,0xa0,0x03,0x02,0x01,0x02,0x02,0x11,0x00,0xfa,0x69,0x1a,0xa7,
0xbf,0x1b,0x93,0xbe,0x97,0x11,0xb0,0xfe,0xfc,0xa8,0x8d,0x8c,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,
0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x39,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,
0x46,0x49,0x31,0x0f,0x30,0x0d,0x06,0x03,0x55,0x04,0x0a,0x13,0x06,0x53,0x6f,0x6e,0x65,0x72,0x61,0x31,
0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x03,0x13,0x10,0x53,0x6f,0x6e,0x65,0x72,0x61,0x20,0x43,0x6c,0x61,
0x73,0x73,0x32,0x20,0x43,0x41,0x30,0x1e,0x17,0x0d,0x31,0x30,0x31,0x32,0x30,0x31,0x30,0x39,0x33,0x39,
0x33,0x33,0x5a,0x17,0x0d,0x31,0x33,0x31,0x31,0x33,0x30,0x30,0x39,0x33,0x39,0x33,0x33,0x5a,0x30,0x57,
0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x46,0x49,0x31,0x16,0x30,0x14,0x06,0x03,0x55,
0x04,0x0a,0x0c,0x0d,0x50,0x52,0x54,0x2d,0x46,0x6f,0x72,0x65,0x73,0x74,0x20,0x4f,0x79,0x31,0x16,0x30,
0x14,0x06,0x03,0x55,0x04,0x0b,0x0c,0x0d,0x54,0x69,0x65,0x74,0x6f,0x68,0x61,0x6c,0x6c,0x69,0x6e,0x74,
0x6f,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x03,0x0c,0x0f,0x2a,0x2e,0x70,0x72,0x74,0x2d,0x66,0x6f,
0x72,0x65,0x73,0x74,0x2e,0x66,0x69,0x30,0x82,0x04,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x04,0x0f,0x00,0x30,0x82,0x04,0x0a,0x02,0x82,0x04,0x01,0x00,
0xbc,0x62,0x25,0x57,0xbc,0x71,0xb8,0xa9,0x5b,0x0e,0x04,0xbc,0xc4,0x0e,0xf1,0x0e,0x1f,0x20,0xd2,0xf4,
0x4f,0x23,0xfe,0x14,0x54,0x34,0x81,0xd3,0x5b,0xdd,0x74,0xed,0xa1,0xbe,0x91,0x99,0x9d,0x02,0xb9,0x36,
0x70,0x43,0x5d,0x73,0xa6,0xe5,0x70,0x7b,0x0e,0x0c,0x3f,0x33,0xbb,0x71,0xd6,0xd4,0x22,0xb0,0xeb,0xf5,
0x6e,0x07,0x7c,0xe7,0xc7,0xd1,0x20,0x64,0x72,0x4e,0xae,0x5e,0xae,0xaf,0x08,0xfb,0x7d,0x6d,0xdb,0x69,
0x5a,0x31,0x73,0x7d,0xbd,0x53,0xcb,0x04,0x69,0x6d,0x74,0x56,0x6c,0xbc,0x84,0xa6,0x01,0x39,0x37,0x0c,
0xb9,0x5c,0x2e,0x78,0x50,0x3a,0x8d,0x1f,0xa2,0x33,0xf1,0xd2,0xc2,0x87,0x51,0xf4,0x92,0xc3,0xa7,0xaa,
0xc8,0x36,0x51,0x1c,0xfb,0x77,0xbf,0xcf,0x24,0x11,0xfe,0xf4,0x11,0x2f,0x5c,0xdf,0x26,0xf6,0xb9,0x15,
0xc1,0x46,0x75,0x83,0x40,0x77,0xa4,0x83,0x74,0xce,0xc0,0x29,0x31,0xd3,0xd8,0x68,0xfa,0x2e,0xcc,0x15,
0x2c,0x59,0x5c,0xa7,0x96,0x65,0x8f,0x34,0x87,0x29,0x22,0x1d,0xde,0x65,0xc7,0x1c,0x5c,0xd8,0x33,0x22,
0xf7,0x93,0xd9,0xcd,0x96,0x76,0x22,0xab,0x75,0x18,0x04,0xe7,0x65,0x2a,0xeb,0x42,0x75,0x17,0x13,0x12,
0x00,0xe3,0xf4,0xd9,0xde,0xd1,0x9f,0x1c,0x61,0xee,0xf6,0xb9,0xf9,0x50,0xb3,0x1b,0x79,0x77,0x38,0x3c,
0x6a,0xcc,0xa0,0x1d,0xe4,0xd7,0x43,0xca,0x8b,0x22,0xbf,0x77,0x33,0xea,0xaa,0x01,0xcf,0x1e,0xd0,0x0d,
0x04,0x2b,0xec,0x42,0x7b,0xec,0x53,0xed,0xc7,0x4f,0x0c,0xac,0x29,0xb7,0x8b,0x92,0x14,0x3f,0x9b,0xc6,
0xd8,0xa1,0x30,0x4d,0x5a,0x07,0x0e,0x1e,0x80,0x5f,0x38,0x66,0x4d,0xc1,0xad,0x2f,0xee,0xae,0x94,0x50,
0x8e,0x38,0x2a,0x00,0x80,0xe2,0xc4,0x43,0x2e,0xd5,0xcd,0xca,0x3f,0x3d,0xcb,0x35,0x13,0x96,0xd2,0xdc,
0x0e,0xe7,0x45,0x57,0x4b,0x8f,0xee,0xa1,0xce,0xe6,0x57,0x52,0xcd,0xd0,0x82,0xca,0x3b,0x87,0xf4,0x22,
0xff,0x81,0x4b,0xf5,0xa3,0xda,0xc5,0xb6,0x67,0xb8,0xf4,0xaf,0xff,0x8d,0x4e,0x80,0xb5,0x22,0x80,0x3c,
0x70,0xe4,0xa0,0xae,0xdc,0xcf,0x44,0xff,0x00,0x98,0x3f,0x19,0x7b,0x4c,0x3d,0xd8,0xa5,0xd8,0xe0,0x05,
0x73,0x54,0x06,0x0c,0x4d,0x50,0xf8,0xd8,0x85,0x0b,0xa8,0x49,0xaa,0x97,0x87,0x3b,0x32,0xe8,0x58,0x22,
0xee,0x34,0x1c,0x9f,0xe3,0x18,0xba,0x93,0x43,0xea,0xb7,0x78,0x35,0xa2,0xb5,0x1e,0x19,0x16,0x3b,0xb3,
0xf5,0x12,0xe8,0x26,0x62,0x2d,0xd7,0x45,0xc3,0xa4,0x4b,0xda,0x38,0x48,0x00,0x3f,0x68,0x62,0xa2,0x83,
0x9d,0x32,0x76,0x27,0x40,0x5d,0x0e,0x75,0xb1,0x08,0xdb,0x58,0xfa,0x20,0x62,0xf1,0x3f,0xbd,0x86,0x2f,
0x7c,0x07,0x01,0x14,0x1d,0x19,0x61,0xee,0x0a,0x85,0xbf,0xc7,0x4f,0x4a,0x06,0xc0,0xaf,0x44,0x5d,0x6f,
0xc3,0x53,0x23,0xcb,0xdf,0x40,0x7a,0x18,0xa1,0x34,0x80,0x18,0x86,0xfe,0xe3,0x87,0xce,0x30,0x53,0x33,
0x1c,0x45,0x4a,0xb4,0xe1,0x8c,0x9b,0x4b,0xf5,0x2c,0x7c,0x13,0x56,0x37,0x8a,0x94,0x24,0xdb,0x3a,0x4b,
0x80,0xb1,0x26,0x57,0x5a,0x75,0x1c,0x44,0xc5,0xf7,0x67,0xb4,0x61,0x87,0xe8,0x2e,0xd9,0xe1,0xb9,0x45,
0xcc,0xdc,0xdf,0x3b,0x8c,0xce,0xd0,0x46,0x6b,0x87,0xb5,0xa9,0xfe,0x35,0x87,0xe0,0xca,0xc6,0x7d,0xc8,
0x86,0xc2,0xfe,0x89,0xec,0xa9,0x86,0x33,0x81,0xdc,0x41,0xb3,0xe7,0xc4,0x82,0x3a,0x81,0x05,0xbd,0x8b,
0x92,0xb2,0x6a,0x2c,0x3c,0xca,0xd0,0x22,0xff,0xc8,0x8f,0xf0,0x5f,0x0e,0xfb,0x0b,0x36,0x64,0x6a,0x12,
0x77,0x2d,0x8a,0x38,0xde,0x7d,0xed,0xc9,0xa7,0xc1,0x85,0x41,0xa2,0x7b,0xa5,0xdc,0x30,0x96,0xda,0xf8,
0xb3,0xc8,0x21,0x56,0x3c,0xdb,0xe4,0x8c,0xb0,0xfb,0xec,0x0e,0x58,0x49,0x3c,0x75,0x3c,0xc2,0x41,0xbd,
0xc0,0x81,0x37,0xc7,0x69,0x5a,0x41,0x86,0x18,0xe9,0x41,0x7f,0xba,0xff,0xc3,0x52,0x56,0xf9,0x7c,0x60,
0x14,0xf9,0x66,0x4c,0x60,0xb6,0x3e,0x23,0xcd,0xd1,0x2d,0x4f,0x43,0x97,0xea,0xa3,0x37,0xa4,0x2a,0xa7,
0x81,0x49,0x90,0xe3,0xb6,0x12,0x1b,0xac,0x78,0x57,0x20,0x51,0xb4,0x16,0x5e,0x58,0x61,0x0f,0x1e,0x35,
0xbc,0x3f,0x44,0xc2,0x85,0xa5,0x61,0x8a,0x0a,0x7c,0x2e,0xb0,0x11,0x12,0xc6,0xc0,0xc8,0xcb,0xd8,0x13,
0xc3,0x58,0xf1,0xcd,0x06,0x5f,0x90,0xa5,0xd7,0x74,0xbc,0x1a,0x9c,0xdc,0xab,0xde,0xea,0x36,0x67,0x41,
0x4f,0x62,0x86,0xc6,0xfe,0x63,0x14,0x83,0x11,0xab,0xfb,0x61,0x38,0x11,0xce,0x01,0xe8,0xee,0x3a,0x21,
0xbc,0xaa,0x4b,0xb0,0x8f,0x2f,0xcf,0x58,0xe6,0x55,0x61,0x38,0xa7,0xc3,0xaa,0x3b,0xb0,0x8c,0xf4,0x82,
0xa0,0x96,0xc4,0x13,0x4a,0xc0,0xc8,0x93,0xb7,0x3d,0x28,0x05,0xb9,0xc8,0x4c,0xe8,0x57,0xda,0x56,0x8b,
0xda,0x27,0xab,0xbf,0x7e,0x66,0x43,0xdc,0x57,0x09,0xdc,0x88,0x8e,0xfb,0xa7,0x63,0x41,0xfb,0xf1,0x67,
0xb5,0xe1,0x84,0x5d,0x1d,0xe3,0xb4,0xc6,0x40,0x97,0xf8,0x4d,0xfc,0x00,0xcd,0x56,0xc2,0xab,0xff,0x49,
0x93,0xff,0x46,0x56,0x9b,0xee,0x6d,0xa0,0x5d,0xf4,0x78,0x36,0x0e,0xf6,0xc9,0x9c,0x79,0x89,0xf9,0x9c,
0xa7,0x3e,0xa0,0x8d,0x62,0x7c,0xdc,0x83,0x0a,0xfc,0x46,0x96,0x31,0xd3,0x56,0xc6,0xea,0x7f,0x1d,0xaa,
0x49,0xd1,0x8b,0x54,0xa2,0x6e,0x59,0x8c,0x2a,0xec,0x3a,0xd7,0xda,0xd2,0xc1,0xfc,0x1d,0x78,0x55,0xce,
0xd8,0x0c,0x1d,0x7e,0x99,0xf8,0x5e,0x3c,0x2d,0xec,0x63,0xe2,0xda,0xa1,0x68,0x6f,0x28,0x2e,0xb4,0xef,
0x07,0xc4,0xa8,0x65,0xc7,0xfd,0x6b,0x0f,0x83,0x23,0xf8,0xc2,0xc9,0x55,0xfa,0xa4,0xa8,0x6a,0xab,0x12,
0xf4,0x89,0x42,0x26,0x72,0xd1,0x82,0x2f,0x62,0x14,0xb6,0x04,0x23,0x20,0xb6,0xd4,0xef,0x59,0x8a,0x40,
0x43,0xd7,0x72,0xe0,0x5b,0x0c,0xb0,0x73,0x6f,0x6a,0x87,0xc1,0x82,0x50,0x20,0xdb,0xaa,0xf8,0x8d,0x70,
0xb6,0x39,0x46,0xe0,0x68,0xc4,0xab,0xea,0xd1,0x31,0xad,0xf7,0x05,0xfb,0x3a,0x3c,0x2e,0x66,0x4f,0xc6,
0x0d,0xf9,0xb8,0x29,0xec,0xdc,0xfc,0x81,0x56,0x2b,0xb0,0xad,0xd2,0x12,0x8f,0x69,0x70,0x18,0x27,0x16,
0xf9,0xf0,0x40,0x93,0xef,0x6b,0x95,0x96,0xcd,0x5f,0xe9,0x5a,0x7b,0xad,0x7f,0x98,0xa7,0x6a,0xe5,0x17,
0xeb,0xc3,0xdd,0xc9,0x02,0x03,0x01,0x00,0x01,0xa3,0x81,0xe5,0x30,0x81,0xe2,0x30,0x13,0x06,0x03,0x55,
0x1d,0x23,0x04,0x0c,0x30,0x0a,0x80,0x08,0x4a,0xa0,0xaa,0x58,0x84,0xd3,0x5e,0x3c,0x30,0x19,0x06,0x03,
0x55,0x1d,0x20,0x04,0x12,0x30,0x10,0x30,0x0e,0x06,0x0c,0x2b,0x06,0x01,0x04,0x01,0x82,0x0f,0x02,0x03,
0x01,0x01,0x02,0x30,0x72,0x06,0x03,0x55,0x1d,0x1f,0x04,0x6b,0x30,0x69,0x30,0x67,0xa0,0x65,0xa0,0x63,
0x86,0x61,0x6c,0x64,0x61,0x70,0x3a,0x2f,0x2f,0x31,0x39,0x34,0x2e,0x32,0x35,0x32,0x2e,0x31,0x32,0x34,
0x2e,0x32,0x34,0x31,0x3a,0x33,0x38,0x39,0x2f,0x63,0x6e,0x3d,0x53,0x6f,0x6e,0x65,0x72,0x61,0x25,0x32,
0x30,0x43,0x6c,0x61,0x73,0x73,0x32,0x25,0x32,0x30,0x43,0x41,0x2c,0x6f,0x3d,0x53,0x6f,0x6e,0x65,0x72,
0x61,0x2c,0x63,0x3d,0x46,0x49,0x3f,0x63,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x72,0x65,
0x76,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x6c,0x69,0x73,0x74,0x3b,0x62,0x69,0x6e,0x61,0x72,0x79,0x30,
0x1d,0x06,0x03,0x55,0x1d,0x25,0x04,0x16,0x30,0x14,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x01,
0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x1d,0x06,0x03,0x55,0x1d,0x0e,0x04,0x16,0x04,
0x14,0x85,0xc2,0x31,0x35,0x4f,0x93,0x92,0x9d,0x8a,0xbc,0x32,0x7d,0x1b,0xf0,0xaa,0x96,0xb1,0x03,0x86,
0x71,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,
0x00,0x00,0x9e,0x75,0x2b,0x95,0x6a,0x96,0x12,0x24,0xd5,0x04,0x6c,0x34,0x0a,0x58,0x5a,0x7d,0x59,0xb9,
0x03,0x23,0x13,0xc3,0xf5,0x24,0x57,0x33,0x8d,0xca,0x5f,0xd8,0x26,0xff,0x64,0x46,0x13,0x40,0xe5,0x04,
0xb2,0xba,0x92,0xa5,0xa6,0xa3,0xd9,0x2b,0xff,0x05,0xef,0xce,0x3c,0x28,0xe8,0x1b,0xa3,0x10,0x8a,0xdd,
0x3d,0x3a,0x0a,0xe1,0x07,0x3c,0xb4,0xf6,0xbb,0xeb,0xb5,0xf2,0x05,0xe8,0xd7,0x16,0x3e,0xe5,0x15,0x49,
0xdf,0x8d,0x34,0xb8,0x1b,0xd4,0xf2,0x65,0xa0,0x70,0x80,0xd0,0xbf,0xa5,0x74,0x5d,0xfb,0xd4,0x52,0x3b,
0x54,0xca,0x32,0xba,0xf7,0xe3,0x90,0xa5,0xa8,0xad,0xd0,0xe5,0x5d,0x18,0x18,0x87,0x60,0xb0,0xf3,0xf9,
0x62,0x20,0x77,0xaa,0x0f,0xdd,0x16,0x4c,0x01,0x3a,0xb1,0x1f,0x85,0x7e,0x01,0x04,0x5f,0xf1,0x37,0x36,
0xe3,0x3a,0xc1,0xa3,0x7c,0x33,0xca,0xce,0x0b,0xb9,0x34,0xe2,0xe1,0xe6,0xed,0x24,0xc1,0xc3,0xc7,0x74,
0x8f,0x22,0x2c,0x6e,0xcb,0x5c,0x7a,0x61,0x99,0xde,0xea,0x13,0xe1,0xa8,0xa1,0x94,0xd0,0x85,0x65,0x65,
0xed,0x97,0x14,0x6e,0x97,0xc9,0xcf,0x34,0x7c,0xf2,0x68,0xeb,0xc2,0x7d,0x03,0x53,0xf5,0xdb,0xa1,0x11,
0x8d,0xda,0xcc,0x26,0x13,0xaa,0x43,0x76,0x04,0x9b,0x85,0x89,0xc3,0x29,0xd8,0xb5,0x54,0x81,0x09,0xf5,
0x18,0x52,0xa5,0x38,0x4a,0x00,0xc6,0x1d,0x4d,0x5a,0x15,0xa0,0xfd,0xf7,0x58,0x27,0xcd,0x6b,0x56,0x6b,
0xee,0x7d,0x73,0xd3,0xfd,0x6c,0xb6,0xb1,0x3b,0xbd,0xbf,0x5b,0x4a,0x6c,0xd3,0x1c,0x47
};
// MARK: RSA Key Size Test Certs
/* RSA Key Size Test Cert Chains
* _root512 -> _int2048A -> _leaf2048A
* _root2048 -> _int512 -> _leaf2048B
* _root2048 -> _int2048B -> _leaf512
* _root2048 -> _int2048B -> _leaf1024
* _root2048 -> _int2048B -> _leaf2048C
*/
/* subject:/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=512-bit Test Root CA */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=512-bit Test Root CA */
unsigned char _root512[600]={
0x30,0x82,0x02,0x54,0x30,0x82,0x01,0xFE,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0xAF,0x64,0x99,0x71,0x1A,0x67,0x40,0xD8,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x81,0x8A,0x31,0x0B,0x30,0x09,0x06,0x03,
0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,
0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,
0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,
0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,
0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,
0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,
0x65,0x72,0x69,0x6E,0x67,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x03,0x0C,0x14,
0x35,0x31,0x32,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,0x6F,
0x74,0x20,0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,
0x30,0x33,0x32,0x34,0x5A,0x17,0x0D,0x32,0x35,0x31,0x32,0x31,0x35,0x32,0x33,0x30,
0x33,0x32,0x34,0x5A,0x30,0x81,0x8A,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,
0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,
0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x14,0x30,
0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,
0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,
0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,
0x6E,0x67,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x03,0x0C,0x14,0x35,0x31,0x32,
0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,0x20,0x43,
0x41,0x30,0x5C,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,
0x05,0x00,0x03,0x4B,0x00,0x30,0x48,0x02,0x41,0x00,0xBE,0x86,0xC0,0x0C,0x4A,0x75,
0xC7,0xEC,0x8D,0xBF,0x1E,0xFC,0x70,0x58,0x23,0x5E,0xF0,0x61,0x1E,0x59,0x74,0x41,
0x88,0x19,0x87,0x20,0x87,0x77,0xE3,0x08,0x8A,0x68,0x80,0xE4,0xED,0x35,0xE7,0x85,
0x52,0x30,0xF7,0xF1,0xC4,0x16,0xED,0x59,0xE8,0xF3,0x40,0x23,0x8E,0x30,0x72,0x40,
0x22,0x26,0x15,0x9F,0xE4,0x97,0xEB,0x56,0xE8,0xAF,0x02,0x03,0x01,0x00,0x01,0xA3,
0x45,0x30,0x43,0x30,0x12,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x08,0x30,
0x06,0x01,0x01,0xFF,0x02,0x01,0x03,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,
0xFF,0x04,0x04,0x03,0x02,0x01,0x06,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,
0x04,0x14,0x14,0xE9,0x8B,0x3E,0x9D,0x8A,0xA7,0xCA,0x70,0x97,0x2B,0x9A,0x2C,0x31,
0xC7,0xF9,0xA2,0x5A,0x4B,0x72,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,
0x01,0x01,0x0B,0x05,0x00,0x03,0x41,0x00,0x6E,0x14,0x08,0x64,0xCD,0x84,0xDB,0xBF,
0xA4,0x2B,0x5F,0x51,0x5F,0x2D,0x00,0x46,0xA5,0x20,0x28,0x53,0x74,0x90,0x6D,0x24,
0xD4,0xB9,0x7E,0x0D,0xFD,0x5E,0x65,0x7F,0xB5,0x88,0x96,0xD8,0x54,0xBA,0xBD,0x09,
0x1C,0x89,0x91,0x5B,0xC4,0x4B,0xD4,0x6B,0xE4,0x4B,0x7A,0xBF,0x62,0x36,0x97,0xF7,
0x58,0xAC,0xCD,0x9C,0xAF,0x9B,0x02,0x68,
};
/* subject:/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test Root CA */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test Root CA */
unsigned char _root2048[996]={
0x30,0x82,0x03,0xE0,0x30,0x82,0x02,0xC8,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0xD2,0xA0,0x17,0x6E,0xF4,0xB7,0xF3,0x96,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x81,0x8B,0x31,0x0B,0x30,0x09,0x06,0x03,
0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,
0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,
0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,
0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,
0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,
0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,
0x65,0x72,0x69,0x6E,0x67,0x31,0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,
0x32,0x30,0x34,0x38,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,
0x6F,0x74,0x20,0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x32,
0x33,0x30,0x34,0x31,0x30,0x5A,0x17,0x0D,0x32,0x35,0x31,0x32,0x31,0x35,0x32,0x33,
0x30,0x34,0x31,0x30,0x5A,0x30,0x81,0x8B,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,
0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,
0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,0x03,
0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x14,
0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,
0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,
0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,
0x69,0x6E,0x67,0x31,0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,0x32,0x30,
0x34,0x38,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,
0x20,0x43,0x41,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,
0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,
0x82,0x01,0x01,0x00,0xEE,0x68,0xB9,0x94,0x15,0x11,0x2F,0x35,0x36,0xBC,0x9D,0x63,
0x25,0x8E,0x55,0xE4,0x17,0xE0,0x60,0x9C,0x6D,0x71,0x4C,0x30,0x7B,0xB7,0xEE,0x42,
0x2D,0xE9,0x05,0x4C,0x41,0x3A,0x19,0x97,0x77,0xCC,0x4C,0xFF,0x81,0x52,0xE8,0xDF,
0xB7,0x1A,0x75,0x1F,0xD1,0xD7,0x4D,0x21,0x5E,0x79,0xDF,0x7E,0xCF,0x45,0x47,0xF5,
0x4D,0x05,0xD6,0xB1,0xF3,0xEA,0xF8,0x28,0xD8,0xAC,0x2C,0xCE,0x83,0xBF,0xA5,0x70,
0x6F,0x5B,0x46,0x39,0xF6,0xC1,0x78,0x56,0x31,0x24,0x7E,0x15,0xCE,0x04,0x50,0x99,
0x30,0xDA,0xF0,0xAE,0x23,0xDD,0x86,0x54,0xAD,0xBC,0x55,0x45,0x93,0xCC,0xC8,0xE7,
0x16,0x46,0x00,0x34,0x2C,0x8C,0x8F,0x31,0xED,0x08,0x3F,0xD9,0xA6,0x90,0x32,0x37,
0x1B,0xCD,0xD4,0x16,0x83,0xEE,0xF9,0x52,0x80,0x3E,0x27,0x26,0xEF,0xEF,0xF9,0xFD,
0xA6,0xD5,0x38,0x83,0xD9,0x8F,0xB6,0xF0,0xA1,0x0D,0x4F,0x89,0x8D,0x7C,0x14,0x7D,
0x8F,0x7A,0x84,0xF9,0xCB,0x8C,0x68,0x9E,0xF3,0x0E,0x2C,0x68,0xBF,0x37,0x69,0x2A,
0x67,0x90,0x7D,0xAF,0xF0,0x7B,0x38,0xBC,0xB3,0x77,0xD1,0xDD,0xF4,0x5E,0x3F,0xA0,
0x48,0xE8,0xBA,0x59,0xD8,0xB6,0xFF,0x51,0x7C,0xB8,0xCE,0xAE,0x02,0x5A,0x71,0x1E,
0xD6,0x5A,0x0A,0x55,0x27,0x29,0x9C,0xC2,0xF6,0x8B,0x0E,0x0D,0xFA,0xF3,0x3F,0x60,
0x17,0xE8,0xFA,0x98,0xC0,0x92,0xD7,0x14,0x9B,0xD1,0x3E,0x03,0xE4,0x8D,0x58,0xFF,
0x4C,0x01,0x77,0x74,0x83,0x01,0xA6,0xB1,0x81,0x34,0x26,0x0D,0xF8,0xAA,0x08,0xF2,
0xDC,0xEA,0x32,0x11,0x02,0x03,0x01,0x00,0x01,0xA3,0x45,0x30,0x43,0x30,0x12,0x06,
0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x08,0x30,0x06,0x01,0x01,0xFF,0x02,0x01,
0x03,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x01,
0x06,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0xCA,0x4D,0x8B,0xBD,
0x98,0x36,0x22,0xF8,0xA9,0x21,0x8E,0xEA,0xFC,0xE6,0xD7,0x17,0x81,0xA7,0xE2,0x12,
0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,
0x82,0x01,0x01,0x00,0x99,0x99,0xDB,0x59,0xEE,0x32,0x98,0x1C,0xE4,0x62,0xE4,0xF9,
0xA5,0xE9,0xA4,0x3F,0x49,0x57,0x37,0x71,0x34,0x3E,0x68,0xAE,0x27,0xB4,0xAF,0xCB,
0x96,0xFD,0xA8,0x0A,0xE7,0x0A,0x22,0x7C,0x5E,0x78,0x95,0xA9,0x67,0xAF,0xB4,0xDD,
0x09,0xD1,0xE5,0x0C,0x6B,0xC6,0xD8,0x1A,0xE3,0x91,0x5F,0xBD,0xD0,0xB9,0x0F,0x1D,
0xB9,0xB7,0xF1,0xC7,0x64,0xCA,0xAB,0x69,0x6E,0xD0,0x61,0xB3,0x9F,0x27,0x1E,0x06,
0xB6,0x42,0x84,0xAB,0x6F,0xE7,0x2B,0xBC,0x04,0x28,0x64,0xC2,0xC0,0x1D,0x43,0xFF,
0x2A,0x1D,0x3F,0x92,0xA1,0xD7,0xD5,0xFB,0x04,0xF9,0x57,0x9F,0x78,0x87,0x8C,0xDB,
0xB3,0x3F,0x41,0x96,0x8E,0x65,0x50,0x39,0xE7,0xD0,0x8A,0x39,0x29,0x68,0x12,0x11,
0x44,0xDD,0x7B,0x86,0x59,0xAF,0x40,0xEA,0x78,0xD9,0xDD,0xB5,0xDB,0xA7,0x7F,0xD4,
0xBA,0x94,0x8D,0x7D,0xA5,0xD0,0xAA,0x48,0x42,0x1E,0x6C,0x71,0x33,0x49,0xCA,0x0D,
0xF5,0x8D,0x10,0xD0,0x3E,0xF8,0xD3,0x35,0xAE,0x83,0xCA,0x02,0x23,0xC2,0xCD,0x21,
0x75,0x9B,0x2C,0xE0,0xF7,0x23,0x26,0x04,0xED,0x78,0xE8,0x29,0x33,0x87,0x65,0x98,
0x4C,0x7E,0xC3,0x61,0xB5,0xDB,0x66,0xBD,0x9D,0x3D,0xC9,0x02,0x7A,0xB8,0xA2,0x7C,
0x81,0x8B,0x10,0xB5,0x97,0x63,0x85,0x2B,0x19,0x94,0xB3,0x4C,0x8D,0xED,0x76,0xCE,
0x31,0x49,0xCC,0x22,0x67,0xFB,0xDA,0x6A,0x0A,0xE2,0x56,0xCD,0x51,0x6A,0x6E,0x54,
0xDF,0x04,0x1A,0xBE,0x77,0xB9,0x28,0x2F,0xCA,0xA5,0xA5,0xF4,0xF1,0xE5,0x12,0x1B,
0x2D,0x60,0xB7,0xA7,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test SubCA 1 */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=512-bit Test Root CA */
unsigned char _int2048A[809]={
0x30,0x82,0x03,0x25,0x30,0x82,0x02,0xCF,0xA0,0x03,0x02,0x01,0x02,0x02,0x08,0x76,
0xCD,0xF6,0x90,0x52,0xAA,0x72,0x81,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,
0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x81,0x8A,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,
0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,
0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,
0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,
0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,
0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,
0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,
0x72,0x69,0x6E,0x67,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x03,0x0C,0x14,0x35,
0x31,0x32,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,
0x20,0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x30,0x32,0x30,
0x38,0x34,0x31,0x5A,0x17,0x0D,0x31,0x36,0x31,0x32,0x31,0x36,0x30,0x32,0x30,0x38,
0x34,0x31,0x5A,0x30,0x77,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,
0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,
0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,
0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,
0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,
0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1E,0x30,0x1C,
0x06,0x03,0x55,0x04,0x03,0x0C,0x15,0x32,0x30,0x34,0x38,0x2D,0x62,0x69,0x74,0x20,
0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x31,0x30,0x82,0x01,0x22,
0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,
0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xAD,0xF2,0x04,
0x31,0xBD,0x86,0x8D,0x5A,0x0C,0xF1,0xDF,0x48,0xBE,0xD3,0x98,0x61,0x50,0x75,0x95,
0xCB,0x1D,0xE3,0x0D,0x17,0x3F,0xEC,0xD6,0xEA,0x5C,0xB7,0x75,0xEB,0x3B,0x73,0x09,
0x69,0x35,0xD2,0x82,0xF8,0x08,0xAE,0xF0,0xF5,0xC1,0xCA,0xFB,0x84,0x3E,0x36,0xAE,
0xCB,0xF9,0x59,0x61,0xE2,0x18,0xED,0x77,0xF8,0xCC,0x75,0x3E,0x4B,0x98,0x81,0x2B,
0x04,0x04,0xEE,0xC5,0x79,0x64,0xBB,0x77,0xED,0xA1,0xC3,0x6C,0x80,0xD7,0xFE,0xAE,
0x05,0x58,0xBD,0x42,0x26,0xD5,0xC4,0xE5,0x4E,0x26,0x09,0x74,0x0A,0xAE,0x49,0x31,
0x80,0x4E,0x25,0xD8,0x2C,0x87,0x32,0xEB,0xD9,0x3D,0xFB,0x5F,0x21,0x6B,0x0E,0xC7,
0x83,0x4A,0x6C,0x2C,0xB1,0x82,0xEC,0xDF,0xD2,0x65,0x92,0x32,0x5C,0x30,0xEA,0x48,
0xC7,0x13,0x39,0xB7,0x4D,0x81,0x79,0x1C,0x17,0x31,0xC1,0x83,0x42,0xFB,0xC3,0x1B,
0xF0,0xA0,0x45,0xED,0xAA,0xDC,0x02,0x73,0x4B,0x48,0x76,0xAE,0x68,0x80,0x93,0x51,
0x3D,0x79,0x7F,0x9E,0x53,0xD3,0x60,0x5A,0x4F,0x5B,0x2E,0xB8,0x13,0x6A,0x5F,0x27,
0x7E,0x09,0x80,0x61,0xCF,0x41,0xDE,0xD1,0x9F,0xFA,0xEF,0x42,0xD0,0xB1,0x81,0x69,
0x03,0x91,0x1A,0xD9,0xE2,0x33,0x34,0x78,0xFE,0x45,0xB1,0x23,0x39,0x20,0xBC,0x2D,
0xA5,0x8A,0xB2,0x84,0xEF,0x2A,0xF4,0x6C,0x2E,0xD1,0xEE,0x61,0x38,0x8F,0xA0,0xB0,
0x0D,0xC4,0x0A,0x3D,0xB9,0x2C,0x6D,0x77,0xB5,0xE3,0x06,0x8B,0xB4,0x0D,0xA7,0x71,
0xFD,0x38,0x0B,0x1F,0x5C,0x1C,0x9F,0x2F,0x2E,0xA4,0xD4,0xE8,0x6F,0x02,0x03,0x01,
0x00,0x01,0xA3,0x63,0x30,0x61,0x30,0x0F,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,
0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,
0xFF,0x04,0x04,0x03,0x02,0x02,0x04,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,
0x04,0x14,0x03,0x99,0x06,0x5B,0xDA,0x2C,0xBA,0x9B,0x66,0x0A,0x5A,0x7B,0xAB,0x99,
0xA5,0x7F,0x72,0xA9,0xD4,0xF7,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,
0x16,0x80,0x14,0x14,0xE9,0x8B,0x3E,0x9D,0x8A,0xA7,0xCA,0x70,0x97,0x2B,0x9A,0x2C,
0x31,0xC7,0xF9,0xA2,0x5A,0x4B,0x72,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,
0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x41,0x00,0xAE,0x2A,0xA7,0x7F,0xE7,0xC9,0xE4,
0xAA,0x2C,0x7F,0x04,0x5D,0x9B,0x0E,0x01,0x47,0x1E,0xB1,0x0E,0x35,0xD7,0x1F,0xAC,
0x8E,0xA7,0xCC,0xAD,0x16,0xAC,0x47,0xDC,0x5E,0x13,0x1C,0x15,0x05,0x89,0x56,0xC0,
0x76,0x55,0x96,0xA0,0x8B,0xBD,0x3B,0xD7,0x93,0x08,0xBA,0xD0,0x7E,0x64,0x7A,0xB1,
0x74,0xE0,0x82,0x2B,0xE4,0x12,0xA3,0x4D,0x0B,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=512-bit Test SubCA */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test Root CA */
unsigned char _int512[802]={
0x30,0x82,0x03,0x1E,0x30,0x82,0x02,0x06,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0xBE,0x29,0xEC,0x6D,0x40,0x7E,0x44,0x98,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x81,0x8B,0x31,0x0B,0x30,0x09,0x06,0x03,
0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,
0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,
0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,
0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,
0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,
0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,
0x65,0x72,0x69,0x6E,0x67,0x31,0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,
0x32,0x30,0x34,0x38,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,
0x6F,0x74,0x20,0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x30,
0x32,0x30,0x39,0x32,0x32,0x5A,0x17,0x0D,0x31,0x36,0x31,0x32,0x31,0x36,0x30,0x32,
0x30,0x39,0x32,0x32,0x5A,0x30,0x74,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,
0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,
0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,
0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,
0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1B,
0x30,0x19,0x06,0x03,0x55,0x04,0x03,0x0C,0x12,0x35,0x31,0x32,0x2D,0x62,0x69,0x74,
0x20,0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x30,0x5C,0x30,0x0D,0x06,
0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x4B,0x00,0x30,
0x48,0x02,0x41,0x00,0xF2,0xD1,0x57,0xDD,0xA6,0xBC,0x2B,0xBC,0x22,0x7B,0x5D,0xC5,
0x3A,0x73,0xCE,0x80,0x88,0xD7,0xDF,0x45,0xBE,0x01,0x22,0xA7,0xC2,0x7E,0x35,0x1F,
0x74,0x02,0xA4,0xE3,0xD9,0xF3,0xE4,0x35,0xE9,0xB0,0xBD,0x71,0xC7,0x19,0x80,0xA8,
0x9F,0xD7,0x62,0xFC,0x46,0xA6,0x84,0xF2,0xB0,0x9F,0xF5,0x1C,0xF1,0xA5,0x18,0x58,
0x76,0x49,0x3F,0xF9,0x02,0x03,0x01,0x00,0x01,0xA3,0x63,0x30,0x61,0x30,0x0F,0x06,
0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,0x0E,
0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x02,0x04,0x30,0x1D,
0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x9E,0x85,0x9A,0xA5,0x88,0x09,0xB0,
0x93,0x9B,0xB4,0xE5,0xCE,0x68,0x99,0x93,0xE9,0x79,0xE9,0x7C,0x98,0x30,0x1F,0x06,
0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0xCA,0x4D,0x8B,0xBD,0x98,0x36,
0x22,0xF8,0xA9,0x21,0x8E,0xEA,0xFC,0xE6,0xD7,0x17,0x81,0xA7,0xE2,0x12,0x30,0x0D,
0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,
0x01,0x00,0xD7,0x94,0x1E,0x53,0x9B,0xB5,0xC6,0x02,0x26,0xC2,0x7F,0xB2,0xD1,0x36,
0x63,0xD5,0xEE,0x35,0x66,0x92,0x48,0xEF,0xD1,0xB4,0xDD,0xD7,0xE1,0xDF,0x05,0xF2,
0x76,0x74,0x28,0x75,0xC1,0x51,0x66,0x6E,0x2C,0x2A,0x8C,0x82,0x34,0xD3,0x43,0x0F,
0x22,0x12,0x01,0xD6,0x7D,0xFA,0x0E,0xF0,0x52,0xB0,0x20,0x1E,0x25,0x2B,0x39,0xA5,
0x2C,0xD5,0x9F,0x89,0x87,0x42,0xAC,0xCB,0xEA,0x56,0xB6,0x8A,0x65,0x40,0xD9,0x19,
0x84,0xF3,0x37,0x71,0x1C,0x0A,0x5E,0x2C,0xBB,0xB1,0xB4,0xA0,0x99,0x35,0x5A,0x0F,
0x62,0xE0,0x7A,0x91,0x2A,0x14,0x47,0xF9,0x2E,0x3D,0x7C,0x53,0x98,0x23,0x63,0x3D,
0x47,0x46,0x9E,0x7C,0x49,0x09,0x50,0xEA,0xCE,0xB4,0x1A,0x17,0x4E,0x6E,0x6D,0x0A,
0x99,0xF5,0xAD,0x6E,0x88,0xF1,0xCE,0xF0,0xD7,0xB4,0x3A,0x6E,0xE7,0x97,0x4C,0x53,
0x04,0x1D,0xB3,0x08,0x49,0x63,0x14,0x25,0x99,0xA7,0xCD,0x82,0xD5,0xF9,0xB9,0xCB,
0x89,0x83,0xCD,0xD5,0x9E,0x57,0xBA,0x90,0x83,0x5F,0x31,0xB4,0x3C,0x3C,0x46,0xD0,
0xA1,0xA7,0x7F,0x7A,0xF8,0x18,0x4B,0xC0,0xA9,0x0E,0x47,0x9A,0xE4,0x9B,0x6F,0x1B,
0xAB,0x8F,0x71,0x54,0x8E,0xA6,0x0B,0xCC,0x16,0xE2,0xCD,0x38,0xA8,0xC2,0x0E,0x20,
0xB0,0x6E,0x9C,0x8B,0x02,0xDF,0xC3,0xCE,0xB8,0xBB,0x92,0x50,0x27,0xB2,0x81,0xC5,
0x48,0x16,0x82,0xC4,0xB1,0x5E,0x5F,0x43,0x47,0xF9,0x6F,0x8A,0x81,0x95,0x93,0xB2,
0x78,0x24,0x67,0xEB,0xCB,0xC1,0xA4,0x4F,0x23,0x11,0xDF,0x33,0xD0,0x5F,0x79,0x26,
0x1F,0x81,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test SubCA 2 */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test Root CA */
unsigned char _int2048B[1005]={
0x30,0x82,0x03,0xE9,0x30,0x82,0x02,0xD1,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0xBE,0x29,0xEC,0x6D,0x40,0x7E,0x44,0x99,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x81,0x8B,0x31,0x0B,0x30,0x09,0x06,0x03,
0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,
0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,
0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,
0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,
0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,
0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,
0x65,0x72,0x69,0x6E,0x67,0x31,0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,
0x32,0x30,0x34,0x38,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,
0x6F,0x74,0x20,0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x30,
0x32,0x30,0x39,0x33,0x39,0x5A,0x17,0x0D,0x31,0x36,0x31,0x32,0x31,0x36,0x30,0x32,
0x30,0x39,0x33,0x39,0x5A,0x30,0x77,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,
0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,
0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,
0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,
0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,
0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1E,
0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,0x32,0x30,0x34,0x38,0x2D,0x62,0x69,
0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x32,0x30,0x82,
0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,
0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xBA,
0x74,0x33,0x7D,0x7B,0x48,0x2C,0x25,0x5F,0x73,0x9C,0x09,0xCC,0xBC,0x90,0x38,0xDF,
0x41,0x06,0xD2,0x1F,0x92,0xD3,0xF0,0x94,0xBC,0x97,0x39,0x17,0x68,0x76,0xE0,0x9C,
0x68,0x78,0xD3,0xE7,0xC7,0xBE,0xC8,0xD8,0xBE,0x2F,0x94,0x93,0x3E,0xCF,0x24,0x4D,
0xB3,0xCF,0xA8,0xC1,0xDF,0xF3,0xC5,0x6A,0x23,0xFC,0x7C,0xAC,0x20,0xC1,0x28,0x7D,
0x61,0x50,0xEB,0x1D,0xD1,0xAE,0xD3,0xCC,0xEC,0x67,0x95,0x0B,0x6C,0x06,0xFE,0x6C,
0xC5,0xBC,0xBA,0xCB,0xDF,0x2D,0x0E,0xBD,0x1E,0x67,0xF9,0xD0,0xF0,0x71,0x91,0x96,
0xD4,0x2E,0x4C,0x1A,0xC0,0xEA,0xD7,0x8B,0x09,0xDF,0xC2,0x89,0x30,0xAD,0x48,0xC4,
0xEE,0x22,0x7A,0x8A,0xD9,0x8E,0x71,0xD1,0xE8,0x3B,0x4D,0x2A,0xB6,0x41,0x32,0x04,
0x66,0x5B,0x5C,0x5C,0x8D,0x0E,0xFC,0x80,0x2A,0x26,0x23,0xF8,0xEA,0x77,0xA1,0xEC,
0xF1,0x2F,0x63,0xB0,0xB3,0xA0,0x8F,0x53,0xDB,0xF2,0x7E,0x9E,0xF8,0x8F,0x9B,0x4B,
0xA2,0x57,0xB5,0xE9,0x47,0xEF,0x86,0xEE,0xAE,0x88,0xB5,0xF7,0x6E,0x42,0x79,0x99,
0x84,0xB8,0x7F,0x48,0x47,0x25,0x52,0x88,0x9C,0x1F,0xAB,0x7D,0xCE,0x8B,0x21,0x39,
0x7B,0xF6,0xD1,0xB8,0x2B,0xCE,0xDA,0x21,0x15,0x3A,0xF0,0x0D,0xD1,0x59,0x0F,0xF4,
0xFF,0x6B,0xCF,0x71,0x5D,0xE9,0x8F,0xE7,0xC1,0x4F,0xF7,0xEA,0xB8,0xE5,0x9F,0x16,
0xB7,0x17,0x5A,0x27,0x35,0x2C,0xDE,0x18,0xF6,0x55,0xDC,0x05,0x18,0xD2,0x12,0x0C,
0x35,0x44,0x88,0xFC,0xEC,0x5E,0x46,0x17,0xDA,0x48,0xD5,0x73,0xD2,0x73,0xEB,0x02,
0x03,0x01,0x00,0x01,0xA3,0x63,0x30,0x61,0x30,0x0F,0x06,0x03,0x55,0x1D,0x13,0x01,
0x01,0xFF,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,
0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x02,0x04,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,
0x04,0x16,0x04,0x14,0x0C,0x3F,0x97,0x58,0x60,0x67,0x21,0xC9,0xDB,0xD4,0x23,0x58,
0x60,0x8E,0xC1,0x3F,0x99,0x9F,0x12,0x78,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,
0x18,0x30,0x16,0x80,0x14,0xCA,0x4D,0x8B,0xBD,0x98,0x36,0x22,0xF8,0xA9,0x21,0x8E,
0xEA,0xFC,0xE6,0xD7,0x17,0x81,0xA7,0xE2,0x12,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,
0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x62,0x5B,0x7A,
0xEA,0x51,0xBC,0x4B,0xE2,0xA6,0x3F,0xC9,0x71,0x1F,0x03,0x64,0x83,0x96,0x69,0x09,
0x36,0x14,0xA3,0xCF,0xFB,0x7D,0x67,0xB5,0x24,0x12,0x10,0xCF,0xA2,0x38,0x41,0x60,
0x73,0xDD,0x9F,0x78,0x3A,0xE2,0x57,0xBF,0x64,0x0A,0xE4,0xB5,0x97,0x64,0x38,0x6E,
0x36,0xCE,0x49,0x5E,0x21,0x53,0x4E,0x77,0x20,0x1E,0xBE,0xE0,0x33,0xDB,0x99,0xF1,
0xC9,0xE8,0xA8,0x29,0x0A,0x23,0xE9,0x8D,0x91,0xE3,0x65,0x03,0xCB,0x97,0xA5,0x3F,
0xF1,0xBF,0x28,0x4D,0x6C,0x2E,0xA7,0xFE,0x65,0x57,0xBE,0x1B,0x64,0xCE,0xFB,0x4B,
0x33,0x7C,0x79,0x9B,0xCE,0x57,0xBE,0xB3,0x11,0x44,0xC1,0xD8,0x83,0x88,0x01,0x02,
0x7C,0x51,0x32,0x31,0xA5,0xE7,0xE2,0xD2,0x91,0xAB,0x4F,0x37,0xE7,0x8D,0xBC,0x44,
0x93,0xC8,0x29,0x0D,0x68,0x30,0xDB,0x54,0x1A,0x42,0x92,0x54,0xC2,0x0D,0xBF,0x28,
0x69,0x94,0x95,0x77,0xCA,0xDA,0x68,0xFA,0x12,0xF4,0x19,0xEE,0x81,0x8F,0x9C,0x22,
0x04,0x89,0xDD,0x2F,0x0A,0x17,0xC5,0xB5,0x1C,0x3A,0x3F,0x13,0x77,0x21,0x49,0xFC,
0xBF,0xB7,0x82,0x9A,0x37,0x8A,0x6D,0x10,0xF6,0x44,0xF2,0xD5,0xFB,0xBC,0xB6,0xC5,
0x50,0xD7,0x9B,0x4D,0x6D,0x18,0x85,0xB7,0xE6,0x90,0xE1,0xD4,0x3F,0x16,0x8A,0x74,
0x97,0x32,0x29,0x3C,0xCA,0xE2,0x9E,0xC6,0xEB,0xBA,0x7A,0x9B,0xF9,0xE8,0xC7,0xA5,
0x01,0x29,0x38,0x5B,0x6D,0x13,0xFC,0x2D,0x6A,0xE9,0x99,0xEC,0x62,0x10,0xEA,0x07,
0x31,0x7F,0xF6,0x2C,0xE3,0x85,0x8C,0x0C,0x20,0x99,0x69,0x60,0x53,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test Leaf 1 */
/* issuer :/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test SubCA 1 */
unsigned char _leaf2048A[1000]={
0x30,0x82,0x03,0xE4,0x30,0x82,0x02,0xCC,0xA0,0x03,0x02,0x01,0x02,0x02,0x08,0x7E,
0x98,0x75,0xB3,0x73,0xE3,0x76,0xC7,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,
0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x77,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,
0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,
0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,
0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,
0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,
0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,
0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,0x32,0x30,0x34,0x38,0x2D,0x62,
0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x31,0x30,
0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,0x31,0x38,0x35,0x36,0x5A,
0x17,0x0D,0x31,0x36,0x31,0x32,0x31,0x36,0x32,0x33,0x31,0x38,0x35,0x36,0x5A,0x30,
0x76,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,
0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,
0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,
0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,
0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,
0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,
0x03,0x0C,0x14,0x32,0x30,0x34,0x38,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,
0x20,0x4C,0x65,0x61,0x66,0x20,0x31,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,
0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,
0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xB3,0xA5,0x19,0x09,0x20,0x84,0xCE,0x67,
0x24,0x88,0xCD,0xEB,0x25,0x9C,0xE7,0xD3,0x52,0xC5,0xC0,0x0F,0xA2,0x39,0x6C,0xF2,
0x1D,0x6D,0x8F,0x29,0x45,0x09,0xD8,0x34,0xE8,0xD7,0xE0,0xD4,0xE6,0x96,0x20,0x33,
0xDC,0x4A,0x99,0x3F,0x39,0x20,0x52,0x72,0x4A,0x12,0x5F,0x31,0xF3,0xB0,0x2B,0x17,
0x6E,0x6B,0x80,0x8F,0xFD,0xC7,0x48,0x8D,0x42,0xBB,0xFA,0x2E,0xBD,0x98,0xA4,0x14,
0x6B,0x6B,0xD0,0x98,0x3D,0x33,0x13,0x99,0x00,0x3A,0x69,0xAD,0x76,0xD5,0x2A,0x01,
0x7B,0x32,0x68,0x2D,0x7F,0xA2,0x48,0x25,0x2C,0x0F,0x6F,0xA1,0xD9,0xA7,0xB7,0x75,
0xE1,0x1D,0xAD,0xCA,0xBB,0x3A,0xBF,0xA8,0x4D,0x93,0x8E,0xC3,0xF3,0x51,0x65,0xDC,
0xD8,0x2D,0x6B,0x4C,0x10,0x77,0x6B,0xEC,0x4F,0x07,0x8C,0x5B,0x8B,0x9A,0x53,0xDC,
0xF3,0x1C,0x17,0x10,0x42,0x42,0x29,0x14,0x0A,0xE7,0x4C,0xEF,0x04,0x95,0xA0,0x84,
0x47,0xD2,0x2C,0x81,0xB4,0x37,0x53,0xD2,0x76,0x31,0x97,0xE1,0x11,0xB1,0xDE,0x83,
0xE0,0xFC,0xA5,0x12,0x34,0x0C,0xBD,0x81,0x31,0xA9,0x6D,0xDC,0x7C,0xE6,0x79,0xC2,
0x42,0xED,0x91,0xCA,0x26,0xD5,0x4C,0x30,0xA8,0x49,0x70,0x69,0xD5,0x4C,0x34,0x92,
0xCB,0xC3,0xA4,0x52,0x70,0x2D,0xDD,0x5A,0xFB,0x22,0x00,0xD7,0x2D,0xA3,0x75,0xC1,
0xED,0xE4,0x2A,0x3E,0x23,0xE6,0xBD,0x84,0xC4,0xCC,0xE8,0x49,0xE0,0xAE,0xCA,0x81,
0x75,0xDB,0x87,0xEF,0xE9,0xE9,0x1E,0xA9,0xBE,0x40,0x0B,0x64,0x86,0x22,0xBA,0xAE,
0x64,0x27,0xA9,0xFE,0x07,0xE5,0x69,0x8F,0x02,0x03,0x01,0x00,0x01,0xA3,0x75,0x30,
0x73,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,0x30,
0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,
0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,
0x05,0x07,0x03,0x02,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x5D,
0xA6,0xDA,0xDF,0xA5,0x29,0x94,0xF6,0x34,0xA9,0xC5,0x46,0xA3,0xBB,0xBD,0x0A,0x00,
0x0E,0xD4,0xFC,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,
0x03,0x99,0x06,0x5B,0xDA,0x2C,0xBA,0x9B,0x66,0x0A,0x5A,0x7B,0xAB,0x99,0xA5,0x7F,
0x72,0xA9,0xD4,0xF7,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,
0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x0D,0xCB,0x71,0x05,0x25,0x22,0xD7,0x9A,
0xE9,0x74,0x9E,0x16,0x91,0x73,0x90,0x95,0x1D,0x52,0xA7,0xAB,0xDA,0xDF,0x40,0x7B,
0x57,0x7D,0x0A,0x9A,0xE9,0x65,0x18,0xF7,0x94,0x2B,0x9E,0x88,0x30,0xD3,0x8E,0x2A,
0xE6,0xC6,0x7E,0xF7,0xF7,0x1A,0xE0,0x9F,0x91,0xB5,0xD0,0x62,0xA1,0x5D,0xB7,0x6B,
0x0E,0xC7,0x4E,0x44,0xCC,0x79,0x39,0x56,0xA0,0x2D,0x9E,0x43,0xC3,0xF7,0x26,0x8B,
0x99,0xC8,0x0E,0x68,0x5D,0xBD,0x02,0xB5,0xB1,0x59,0xB5,0x0F,0xF0,0x58,0xF6,0x32,
0x57,0x7D,0xD3,0xB6,0x4C,0x89,0x64,0x21,0xBB,0xB3,0x13,0x15,0xC0,0xDD,0xF7,0xB5,
0x1C,0xD1,0x1F,0xF9,0xE0,0xE9,0xB6,0x7F,0x1D,0x60,0xDC,0x9F,0x07,0xE9,0x5C,0x42,
0x02,0x9B,0x64,0x13,0x5D,0x75,0xB5,0x77,0x01,0xF6,0xF6,0x2D,0x02,0xA8,0x18,0x59,
0x9C,0x38,0x35,0xBC,0x75,0x11,0xCC,0x56,0xF5,0x5A,0x01,0x73,0xA9,0x06,0x31,0xAC,
0x12,0x0C,0x03,0xC2,0xF3,0x67,0x26,0xA4,0xB3,0x2D,0xA2,0x7A,0xE5,0x44,0xE2,0x4F,
0x28,0x25,0x6C,0xB8,0xF2,0x52,0xAF,0xCE,0x72,0x47,0xE9,0xD6,0xD1,0xFD,0x6B,0xFB,
0x94,0x28,0xA8,0x82,0x85,0x49,0x8B,0xBC,0xB5,0x7B,0x93,0xCF,0x2D,0x29,0xE1,0x0C,
0x5B,0xAF,0x3C,0xEC,0xED,0x78,0xDC,0x24,0x56,0x5C,0xC8,0xF4,0x47,0xBC,0x63,0xA3,
0x37,0xF9,0x9C,0x92,0xF5,0xD3,0xAD,0x71,0xEC,0x43,0xE9,0x0B,0xDC,0xB5,0x9F,0x03,
0x44,0x55,0x12,0x1D,0x39,0xF3,0x8C,0xAE,0x59,0x15,0xC1,0x12,0xAF,0xC1,0x02,0x95,
0x62,0x7D,0x56,0xF0,0x93,0x47,0x5A,0x50,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test Leaf 2 */
/* issuer :/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=512-bit Test SubCA */
unsigned char _leaf2048B[803]={
0x30,0x82,0x03,0x1F,0x30,0x82,0x02,0xC9,0xA0,0x03,0x02,0x01,0x02,0x02,0x08,0x4E,
0xBF,0xB9,0x68,0xC8,0x8C,0x3A,0xE1,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,
0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x74,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,
0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,
0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,
0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,
0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,
0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,
0x1B,0x30,0x19,0x06,0x03,0x55,0x04,0x03,0x0C,0x12,0x35,0x31,0x32,0x2D,0x62,0x69,
0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x30,0x1E,0x17,0x0D,
0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,0x31,0x39,0x33,0x34,0x5A,0x17,0x0D,0x31,
0x36,0x31,0x32,0x31,0x36,0x32,0x33,0x31,0x39,0x33,0x34,0x5A,0x30,0x76,0x31,0x0B,
0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,
0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,
0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,
0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,
0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,
0x65,0x72,0x69,0x6E,0x67,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x03,0x0C,0x14,
0x32,0x30,0x34,0x38,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x4C,0x65,
0x61,0x66,0x20,0x32,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,
0x02,0x82,0x01,0x01,0x00,0xD3,0x79,0xB9,0x77,0x2A,0x76,0x17,0xEE,0xD1,0x4E,0x6D,
0x6B,0x9F,0x42,0xAA,0xDE,0x81,0x47,0xC5,0x2B,0x43,0x3A,0x4F,0xB9,0x42,0x5E,0x5A,
0x35,0xDE,0xF5,0x86,0x8C,0x0E,0xD1,0xC3,0x7B,0xA2,0x82,0x52,0x33,0xA0,0x2B,0x8C,
0x58,0x04,0x75,0x8E,0xFB,0x08,0x9B,0xA7,0xEA,0x66,0x86,0xFA,0x5E,0xC2,0xCC,0x21,
0x6C,0x17,0xC3,0x6B,0x05,0xFE,0x33,0x21,0x51,0x18,0xA1,0x0A,0xDD,0x5F,0xCE,0xF2,
0xF6,0xB6,0x82,0x6C,0xBB,0x26,0x68,0x76,0xC3,0x16,0xEB,0x35,0x78,0x79,0x03,0xB0,
0x36,0xC5,0x7D,0xDF,0x5C,0x38,0xB6,0xF0,0xD1,0xE0,0x9D,0x71,0xFB,0xA8,0x1B,0x83,
0x9D,0x30,0xBC,0x2D,0x09,0x4D,0x9F,0xF4,0x69,0x33,0x99,0xE5,0xE9,0x76,0x6B,0x78,
0x71,0xA7,0x13,0xF4,0xFB,0x2A,0x24,0x4D,0xD0,0x54,0x6E,0xAE,0x19,0xEE,0xCB,0x43,
0x8C,0x3F,0x90,0x0F,0xDC,0xFE,0xA4,0xFF,0x8A,0xAD,0x22,0x21,0x61,0x51,0xAA,0x76,
0x66,0x43,0xC0,0xE5,0x42,0x94,0x0F,0xBE,0x3C,0x89,0x45,0x50,0x0D,0x4F,0xDC,0x19,
0xEF,0xF8,0x19,0xB6,0x7E,0x42,0xBD,0x88,0xA3,0x65,0x59,0xE8,0x7A,0xC1,0x7F,0x32,
0x15,0x38,0xA3,0x58,0xC4,0x25,0x74,0xFC,0x02,0x8C,0xFC,0x31,0x28,0x20,0x05,0xAD,
0x9B,0x27,0xE5,0x25,0x81,0x63,0x92,0xE1,0x49,0x55,0x5B,0xD7,0x36,0x3E,0xC4,0x2F,
0x98,0x23,0xAA,0x62,0x85,0x68,0x4C,0x2D,0xEA,0x46,0xD6,0x99,0xCE,0x61,0x7C,0xE7,
0x18,0x0B,0x72,0x5E,0xA0,0x06,0x49,0x6E,0x1C,0x31,0x0F,0x61,0x3F,0x62,0x68,0xC0,
0x89,0xC8,0x91,0x45,0xAD,0x02,0x03,0x01,0x00,0x01,0xA3,0x75,0x30,0x73,0x30,0x0C,
0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,0x30,0x0E,0x06,0x03,
0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,0x13,0x06,0x03,
0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,
0x02,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x81,0x88,0xF3,0xCE,
0xC9,0x31,0x5E,0x77,0x3C,0x27,0x4E,0x5E,0x4A,0xE6,0xEA,0x06,0x7A,0xEA,0x32,0x43,
0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x9E,0x85,0x9A,
0xA5,0x88,0x09,0xB0,0x93,0x9B,0xB4,0xE5,0xCE,0x68,0x99,0x93,0xE9,0x79,0xE9,0x7C,
0x98,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,
0x03,0x41,0x00,0x39,0x1A,0x27,0x7C,0xDB,0x9C,0xE7,0x83,0x5F,0x57,0x69,0x4D,0xAD,
0xD5,0x98,0xBA,0xA8,0x56,0x54,0x8D,0x84,0x18,0xB0,0xAF,0xEA,0x4B,0x74,0xB7,0x87,
0xDC,0xD8,0x1E,0x10,0x10,0xE3,0x73,0xC1,0x90,0x83,0x9F,0xB8,0xF4,0x41,0x03,0x02,
0x49,0xF7,0x57,0x5C,0x7D,0x03,0xE9,0x9E,0x57,0xF4,0xBC,0x74,0x3A,0xC0,0x9B,0xFF,
0x20,0x73,0xC7,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=512-bit Test Leaf */
/* issuer :/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test SubCA 2 */
unsigned char _leaf512[798]={
0x30,0x82,0x03,0x1A,0x30,0x82,0x02,0x02,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0x81,0x94,0x54,0x10,0xDC,0xA5,0x98,0x14,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x77,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,
0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,
0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,
0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,
0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,
0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,
0x31,0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,0x32,0x30,0x34,0x38,0x2D,
0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x32,
0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,0x32,0x30,0x30,0x38,
0x5A,0x17,0x0D,0x31,0x36,0x31,0x32,0x31,0x36,0x32,0x33,0x32,0x30,0x30,0x38,0x5A,
0x30,0x73,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,
0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,
0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,
0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,
0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,
0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1A,0x30,0x18,0x06,0x03,0x55,
0x04,0x03,0x0C,0x11,0x35,0x31,0x32,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,
0x20,0x4C,0x65,0x61,0x66,0x30,0x5C,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,
0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x4B,0x00,0x30,0x48,0x02,0x41,0x00,0xEB,0x34,
0xD8,0x83,0x6D,0xFE,0xDD,0x09,0x27,0xC1,0xA1,0xA7,0x1F,0x9D,0xA8,0xDF,0x55,0xDE,
0x54,0x03,0x3D,0x42,0x54,0x24,0x3D,0x92,0x8B,0x21,0x4B,0xEE,0x8C,0x2B,0x9C,0x3F,
0x34,0xD1,0x6B,0xDE,0xC0,0xC2,0x20,0x06,0x87,0x9B,0x11,0x96,0x8C,0xB5,0x24,0xDD,
0x93,0xE6,0x1B,0x77,0xC1,0x7A,0xD0,0x1F,0xD2,0x09,0x3D,0x21,0x8A,0x15,0x02,0x03,
0x01,0x00,0x01,0xA3,0x75,0x30,0x73,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,
0xFF,0x04,0x02,0x30,0x00,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,
0x04,0x03,0x02,0x05,0xA0,0x30,0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,
0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x1D,0x06,0x03,0x55,0x1D,
0x0E,0x04,0x16,0x04,0x14,0xAE,0x83,0x56,0x29,0x05,0x75,0x48,0xB2,0x2F,0x0D,0x92,
0x26,0x21,0xC2,0x7C,0x34,0x48,0xF7,0xAC,0xAF,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,
0x04,0x18,0x30,0x16,0x80,0x14,0x0C,0x3F,0x97,0x58,0x60,0x67,0x21,0xC9,0xDB,0xD4,
0x23,0x58,0x60,0x8E,0xC1,0x3F,0x99,0x9F,0x12,0x78,0x30,0x0D,0x06,0x09,0x2A,0x86,
0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x85,0xEC,
0xC6,0xA7,0x1B,0x36,0x62,0x3A,0x04,0xBB,0xE8,0x8F,0xE2,0x66,0x8E,0xD4,0x02,0x97,
0x6C,0x29,0x27,0xFF,0xC8,0xC6,0xBC,0xFE,0x9D,0xBC,0x09,0x8C,0x6B,0x0B,0x1E,0x48,
0x82,0x46,0xBD,0xCF,0x02,0xB7,0x59,0x6E,0x7A,0xFC,0x8C,0x58,0x03,0x6A,0x92,0x4A,
0xB0,0x1F,0x2E,0x6F,0x78,0x84,0x10,0x54,0xA9,0x70,0x65,0xDD,0xA2,0xAA,0xAA,0xFA,
0x59,0x98,0xD7,0x42,0x60,0x42,0x15,0x2C,0x11,0x48,0xDE,0xF6,0x76,0x91,0x5C,0x2B,
0x0B,0xEF,0x5F,0x23,0x61,0x8A,0x4E,0x81,0x82,0x3F,0xDA,0x9E,0x02,0xAF,0x82,0xDD,
0x43,0x94,0x08,0xD1,0xA0,0x31,0x98,0x14,0x4C,0xBD,0x5E,0xFA,0x73,0xDC,0x0A,0x72,
0xA4,0xB0,0x78,0x8A,0xC6,0xFE,0xBB,0x5A,0xBF,0x78,0x32,0x8D,0x26,0x7B,0xA3,0xBD,
0x06,0x45,0x93,0xC6,0x96,0x99,0x14,0x8C,0x69,0xD1,0x52,0xDC,0xD4,0x1C,0x3E,0xCB,
0x91,0x46,0x92,0x1B,0xBE,0x21,0xEC,0x21,0xE2,0xB9,0x23,0xD5,0xB0,0xAD,0x42,0xFA,
0x9A,0x91,0xA4,0xA1,0x48,0x4D,0x94,0xB5,0xCF,0x14,0x21,0xA4,0x8E,0x18,0x2E,0x78,
0x93,0xA0,0xED,0x43,0x15,0x92,0x68,0x57,0x78,0x52,0x28,0xEB,0x4A,0x48,0x79,0xEF,
0x17,0xD3,0xD5,0xAD,0x2F,0x8A,0xF4,0xD2,0x21,0x79,0x08,0x08,0x66,0xE1,0x54,0x7F,
0xFC,0x3D,0x5D,0x81,0xD8,0xA8,0x47,0xC3,0x3B,0xE9,0x52,0x77,0x05,0xF2,0x42,0xDE,
0x23,0x24,0x99,0x7A,0x20,0x49,0x86,0x49,0x04,0x60,0x77,0xBD,0xD5,0x33,0xBB,0x49,
0x61,0x8B,0x1C,0xBB,0x8E,0xE8,0x1D,0xA4,0x1E,0xA4,0x21,0x77,0x59,0xBD,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=1024-bit Test Leaf */
/* issuer :/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test SubCA 2 */
unsigned char _leaf1024[867]={
0x30,0x82,0x03,0x5F,0x30,0x82,0x02,0x47,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0x81,0x94,0x54,0x10,0xDC,0xA5,0x98,0x15,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x77,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,
0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,
0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,
0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,
0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,
0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,
0x31,0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,0x32,0x30,0x34,0x38,0x2D,
0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x32,
0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,0x32,0x30,0x32,0x32,
0x5A,0x17,0x0D,0x31,0x36,0x31,0x32,0x31,0x36,0x32,0x33,0x32,0x30,0x32,0x32,0x5A,
0x30,0x74,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,
0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,
0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,
0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,
0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,
0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1B,0x30,0x19,0x06,0x03,0x55,
0x04,0x03,0x0C,0x12,0x31,0x30,0x32,0x34,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,
0x74,0x20,0x4C,0x65,0x61,0x66,0x30,0x81,0x9F,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,
0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8D,0x00,0x30,0x81,0x89,0x02,
0x81,0x81,0x00,0xCA,0xCD,0xBD,0x1E,0xA5,0xF1,0xDC,0x50,0x7F,0xF6,0x52,0x96,0x56,
0x1F,0xD9,0x9A,0x3F,0x32,0xED,0x45,0x29,0xCE,0x2C,0x18,0xA4,0x3E,0xA6,0x92,0xDF,
0x8E,0x33,0x76,0x4D,0xCB,0xDB,0xD9,0x5E,0x83,0x32,0x96,0x19,0x8B,0x62,0xFE,0x67,
0xBB,0xE6,0xC0,0x3D,0x1A,0xEF,0xE4,0x19,0x40,0x8B,0x26,0x80,0xD9,0x22,0x8A,0x1E,
0xDF,0xC6,0x79,0x2C,0x07,0x7C,0xD7,0x10,0x91,0x7E,0x0F,0xC5,0x5E,0x69,0xC3,0xEB,
0x1F,0x34,0x50,0x4D,0xA5,0xE1,0xF6,0x3A,0x6C,0xF0,0xD4,0x21,0x20,0x5C,0x0A,0x68,
0xC1,0x26,0x4B,0x4A,0x79,0x08,0x64,0x67,0xDE,0x1E,0x17,0xC5,0xE4,0xEE,0xA6,0xE3,
0xC4,0x54,0x34,0x7C,0xFE,0x82,0x5B,0xE4,0xAB,0xAF,0x97,0x2C,0x6B,0xAC,0x02,0x11,
0xF3,0xD9,0x67,0x02,0x03,0x01,0x00,0x01,0xA3,0x75,0x30,0x73,0x30,0x0C,0x06,0x03,
0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,0x30,0x0E,0x06,0x03,0x55,0x1D,
0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,0x13,0x06,0x03,0x55,0x1D,
0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,
0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0xB9,0xC9,0xD8,0x19,0xA6,0x69,
0x3A,0x16,0x2E,0x32,0x2B,0x9A,0x10,0xB6,0xFA,0x20,0x93,0x16,0x7E,0xBC,0x30,0x1F,
0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x0C,0x3F,0x97,0x58,0x60,
0x67,0x21,0xC9,0xDB,0xD4,0x23,0x58,0x60,0x8E,0xC1,0x3F,0x99,0x9F,0x12,0x78,0x30,
0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,
0x01,0x01,0x00,0xA6,0x0A,0xB5,0x39,0x4B,0xA9,0xED,0x9B,0x8C,0xC5,0x5D,0xF1,0xAA,
0x9D,0x57,0x55,0x5C,0xF2,0x10,0x29,0xBD,0x56,0x36,0xEF,0x52,0xDC,0xEA,0x27,0xF9,
0xA2,0x79,0xBB,0xE6,0x16,0x29,0xA4,0x90,0x31,0x26,0x24,0x8A,0x79,0xBE,0x36,0xFC,
0xA9,0xEF,0x77,0x13,0x16,0xA3,0x55,0xEB,0xD1,0x1A,0xD8,0xE2,0x16,0x72,0x5F,0x7D,
0x10,0x76,0x3B,0x9A,0x00,0x51,0xAC,0x5A,0x4E,0x05,0xA3,0x82,0x1D,0xAB,0xC1,0x5E,
0x44,0xD8,0xA0,0x95,0xD1,0xB5,0x75,0xE6,0x3B,0xB2,0x20,0xFB,0xBB,0xB9,0x88,0xD5,
0x27,0x3B,0x90,0xA6,0xF0,0x6D,0x80,0xC8,0xA3,0x3A,0x3D,0x33,0x8F,0x14,0x09,0x5D,
0xBB,0xA0,0xD7,0x3D,0x10,0xE9,0x8D,0x0E,0xB4,0x51,0x42,0xD3,0xB3,0xEF,0xC2,0xF2,
0x0B,0x35,0x35,0x5D,0x7B,0xE1,0x47,0x9E,0x90,0xF9,0x14,0xDD,0xDD,0x1E,0x5F,0xDC,
0xAB,0x04,0x08,0x8A,0x6B,0x82,0x2F,0xCA,0xA6,0x37,0x07,0x4C,0x94,0xD5,0x4F,0x83,
0x67,0xEF,0xE2,0x12,0xDB,0x71,0x69,0x5A,0x33,0x8E,0x32,0x90,0xDE,0xE7,0x8C,0x6E,
0x64,0xFD,0x8E,0x09,0xDA,0xBD,0x08,0xBE,0xC1,0x6F,0xD0,0x30,0xDD,0x18,0xDB,0xD1,
0x34,0x7D,0x86,0x69,0xD7,0x57,0xE4,0x70,0x7F,0xF8,0x49,0xC0,0x4B,0xE4,0x73,0xE1,
0x29,0x26,0x5E,0x04,0xDC,0xC6,0x69,0x17,0xDF,0x62,0x20,0xE1,0x15,0xAB,0xDD,0x1B,
0x0C,0xD7,0xA6,0x1C,0x2C,0x7B,0xD9,0x2D,0xDE,0x46,0x43,0x81,0xFA,0xD9,0x11,0xDD,
0xE8,0x4B,0x6A,0x31,0x85,0x24,0x0A,0xFD,0xAD,0x93,0xF6,0x50,0x2B,0x36,0xE5,0xE5,
0x9E,0x8D,0x85,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test Leaf 3 */
/* issuer :/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=2048-bit Test SubCA 2 */
unsigned char _leaf2048C[1001]={
0x30,0x82,0x03,0xE5,0x30,0x82,0x02,0xCD,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0x81,0x94,0x54,0x10,0xDC,0xA5,0x98,0x16,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x77,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,
0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,
0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,
0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,
0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,
0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,
0x31,0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,0x32,0x30,0x34,0x38,0x2D,
0x62,0x69,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x32,
0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,0x32,0x30,0x33,0x33,
0x5A,0x17,0x0D,0x31,0x36,0x31,0x32,0x31,0x36,0x32,0x33,0x32,0x30,0x33,0x33,0x5A,
0x30,0x76,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,
0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,
0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,
0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,
0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,
0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,
0x04,0x03,0x0C,0x14,0x32,0x30,0x34,0x38,0x2D,0x62,0x69,0x74,0x20,0x54,0x65,0x73,
0x74,0x20,0x4C,0x65,0x61,0x66,0x20,0x33,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,
0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xC4,0xFE,0xE0,0xE5,0xC7,0x13,0x95,
0x56,0x9E,0xA2,0x32,0xF5,0x52,0xD8,0xAA,0x06,0xF0,0x0F,0x2A,0x76,0xA8,0xCB,0xF3,
0x39,0x5D,0x6E,0xEA,0x9C,0x4F,0x80,0xA1,0x9F,0xAC,0x8F,0x7D,0x34,0xDD,0x5D,0xD1,
0x69,0xD9,0x2C,0x5D,0x49,0x2D,0x31,0x81,0x0D,0x2E,0x25,0xB7,0xA2,0x63,0x77,0xA1,
0x58,0x8C,0x8D,0x2A,0x73,0x86,0xD8,0x15,0xFF,0xA9,0xED,0xF1,0xE6,0x08,0x7F,0x15,
0x7B,0xFE,0xCC,0x07,0x7F,0xB7,0x63,0xA0,0x00,0x98,0xF0,0xBA,0x74,0x0C,0x34,0x2B,
0xC4,0xE6,0xD6,0x2A,0xEE,0x7E,0x9D,0xBE,0xFD,0x34,0x70,0xCC,0x22,0x2C,0x2E,0x4F,
0x81,0xC1,0xDA,0xB8,0x0B,0xC4,0xF9,0xFE,0xFD,0x74,0x47,0xE4,0xA9,0xA4,0x65,0x85,
0x10,0x86,0x29,0x72,0x35,0x38,0x4B,0xD7,0xDA,0x3A,0x59,0xE7,0x8A,0x6D,0xC5,0x71,
0x59,0x89,0xA5,0xC4,0xA3,0x9E,0xFC,0x81,0x18,0xD3,0x97,0x48,0xB2,0xDD,0xFE,0xB3,
0xB3,0x78,0x71,0x35,0x3C,0x66,0x0F,0xD6,0xAA,0x84,0xF8,0xCB,0x87,0xB8,0xB4,0xFD,
0x19,0x18,0x31,0xCC,0x53,0xB7,0x1B,0xB6,0x7D,0x99,0x9C,0x14,0x19,0xDA,0x84,0x72,
0x88,0x21,0x9A,0x87,0x60,0x69,0xC3,0x8E,0x1F,0x34,0x3B,0xA3,0x56,0xA5,0x21,0xF0,
0xDB,0xC1,0x54,0xEA,0x41,0x69,0x19,0x45,0x5E,0x52,0xB3,0x3A,0xBD,0x1A,0x8A,0x64,
0x7B,0xA9,0xD4,0xF1,0x2B,0x58,0xCF,0x0D,0x7F,0x3C,0x86,0xDA,0x9A,0x94,0x42,0x36,
0x6B,0x9F,0xD8,0xF4,0x64,0x18,0x66,0x6F,0xF7,0xB5,0x80,0xCE,0x43,0x8D,0x84,0x7A,
0x99,0xE3,0x3D,0x03,0xB5,0x94,0x86,0xBD,0xEB,0x02,0x03,0x01,0x00,0x01,0xA3,0x75,
0x30,0x73,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,
0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,
0x30,0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,
0x05,0x05,0x07,0x03,0x02,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,
0x50,0x25,0x7E,0xA7,0xF5,0x2B,0xA3,0x3A,0x35,0x31,0x82,0x4C,0xD6,0xA6,0x5F,0x04,
0xC1,0x3A,0xAC,0x63,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,
0x14,0x0C,0x3F,0x97,0x58,0x60,0x67,0x21,0xC9,0xDB,0xD4,0x23,0x58,0x60,0x8E,0xC1,
0x3F,0x99,0x9F,0x12,0x78,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,
0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x7E,0xF7,0x12,0xE6,0x05,0x3B,0x13,
0x4B,0x35,0xAD,0x63,0xCF,0x39,0xC7,0x9B,0x62,0x83,0xF6,0x52,0xCC,0x54,0x14,0x13,
0x5D,0xD8,0xE3,0x1E,0x33,0x37,0x6F,0x3B,0x13,0x9F,0x23,0xBC,0xA0,0xAC,0xF3,0xA1,
0x94,0x0C,0xE0,0x51,0xDE,0x08,0x56,0x8B,0x90,0x2E,0x4B,0xB1,0xCD,0x9B,0x1A,0x44,
0x8E,0xB9,0x0B,0xA7,0x0B,0x5B,0xAC,0x7A,0x37,0xF7,0x71,0x27,0x4E,0xB8,0x15,0x09,
0x70,0x10,0xAA,0x3C,0x61,0xC8,0x76,0x2A,0x2E,0x13,0x76,0xC9,0x2E,0xEE,0x98,0x75,
0xF7,0x61,0x7D,0x8E,0x3C,0xFC,0x19,0xDE,0xAB,0xE5,0xDA,0xFE,0x30,0x00,0x45,0x13,
0xE2,0x82,0x96,0x59,0xEE,0x02,0x5A,0x9B,0xFA,0x1B,0x4E,0x65,0xE0,0x75,0x8F,0x99,
0x82,0xBD,0x2A,0x16,0x10,0xC2,0xA5,0xA2,0x1A,0xC0,0xF6,0x4A,0x42,0x46,0xBA,0x12,
0xE0,0x64,0x7B,0x10,0x57,0xB6,0xFE,0xC3,0x46,0xCC,0x43,0xDC,0x69,0xF0,0x72,0x69,
0x62,0xDB,0x0C,0x6E,0x21,0xF9,0xB4,0x59,0xD7,0xA3,0xFC,0x82,0x98,0x60,0x60,0x57,
0x7F,0xDD,0x25,0x65,0xB7,0x04,0x3E,0xDA,0xA3,0x07,0x7C,0x69,0xAF,0x81,0xA9,0x49,
0x81,0x09,0x62,0x71,0x51,0x4F,0x40,0x8F,0xE4,0x01,0x4C,0xAE,0xF4,0x9D,0xE0,0x38,
0xB1,0x20,0xF0,0x5D,0x1C,0xA0,0xB4,0x31,0xBF,0xE7,0xC7,0xFE,0xFF,0xA5,0x81,0xFB,
0x8E,0xEE,0x19,0xB1,0xF1,0x64,0x44,0x3D,0xDA,0x71,0xE3,0x80,0x58,0xFB,0x23,0x6E,
0xAE,0x3B,0x69,0x64,0x37,0x82,0x54,0xD6,0xEA,0xD4,0x02,0xD9,0x27,0x1A,0x9F,0xCE,
0x0D,0x44,0xA9,0x29,0x07,0x8C,0x76,0x0A,0xCB,
};
// MARK: EC Key Size Test Certs
/* EC Key Size Test Cert Chains
* _root384 -> _int384B -> _leaf128
* _root384 -> _int384B -> _leaf192
* _root384 -> _int384B -> _leaf384C
*/
/* subject:/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=secp384r1 Test Root CA */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=secp384r1 Test Root CA */
unsigned char _root384[662]={
0x30,0x82,0x02,0x92,0x30,0x82,0x02,0x18,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0x9B,0x8A,0xBF,0x1F,0x3B,0x4D,0xCC,0x76,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,
0x3D,0x04,0x01,0x30,0x81,0x8C,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,
0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,
0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,
0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x14,0x30,0x12,
0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,
0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,
0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,
0x67,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x0C,0x16,0x73,0x65,0x63,0x70,
0x33,0x38,0x34,0x72,0x31,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,0x20,
0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x30,0x33,0x30,0x34,
0x32,0x35,0x5A,0x17,0x0D,0x32,0x35,0x31,0x32,0x31,0x35,0x30,0x33,0x30,0x34,0x32,
0x35,0x5A,0x30,0x81,0x8C,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,
0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,
0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,
0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x14,0x30,0x12,0x06,
0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,
0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,
0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,
0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x0C,0x16,0x73,0x65,0x63,0x70,0x33,
0x38,0x34,0x72,0x31,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,0x20,0x43,
0x41,0x30,0x76,0x30,0x10,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,0x02,0x01,0x06,0x05,
0x2B,0x81,0x04,0x00,0x22,0x03,0x62,0x00,0x04,0xFE,0xE3,0x68,0x79,0x40,0x81,0x4D,
0xC3,0xAA,0x9F,0x1D,0x9D,0x03,0x33,0x5F,0x39,0x4D,0xFD,0x4E,0x7E,0xC3,0xC2,0x9D,
0xB4,0x61,0x98,0x8D,0x02,0xA9,0xA0,0xA7,0x4E,0x49,0xE8,0xFE,0xAD,0x1D,0x6B,0x7D,
0xAF,0xDA,0x55,0xF5,0xD2,0x8E,0x5F,0x2F,0x0E,0x55,0x50,0x61,0x07,0x81,0xE6,0xDF,
0xD5,0xD1,0xA5,0x21,0xA9,0x78,0x38,0xC5,0x75,0x76,0x06,0x54,0x67,0xC7,0xD1,0x00,
0x37,0xD2,0x65,0x52,0xB6,0x28,0xA0,0x5D,0x76,0x32,0xF0,0x48,0xAC,0x86,0x8B,0x5B,
0x90,0x08,0xE4,0xD3,0xCA,0xF0,0xE8,0x0E,0x45,0xA3,0x45,0x30,0x43,0x30,0x12,0x06,
0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x08,0x30,0x06,0x01,0x01,0xFF,0x02,0x01,
0x03,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x01,
0x06,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x86,0xC8,0x90,0xD5,
0xD7,0x5C,0x3A,0xE1,0x29,0xF4,0x13,0x54,0xD0,0x06,0x90,0xAA,0xEC,0xF8,0x97,0xF7,
0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,0x04,0x01,0x03,0x69,0x00,0x30,0x66,
0x02,0x31,0x00,0xE3,0xE1,0x9C,0xB4,0xEE,0x40,0x25,0x9A,0x82,0x3F,0x0A,0x03,0x55,
0xDC,0x52,0x7D,0x3B,0xFC,0xC2,0x1A,0x05,0x97,0xEF,0x3F,0xA0,0x63,0x49,0x8A,0x00,
0x38,0x72,0x05,0xDB,0x74,0x9C,0xED,0x68,0x8E,0x03,0xB8,0x6B,0x36,0x11,0x2C,0x77,
0xA3,0xB8,0x7C,0x02,0x31,0x00,0xA9,0xB5,0x88,0xB6,0x3A,0x85,0x55,0x2E,0x69,0x56,
0x8D,0xC4,0x5B,0x24,0xD2,0x8A,0x0E,0x01,0xA9,0x0E,0xC1,0x4D,0xDB,0x39,0xE9,0x9C,
0x16,0x49,0xEE,0xD8,0x50,0xC0,0x1E,0x02,0xD4,0x5C,0x8B,0x07,0xD1,0xA5,0x74,0xE3,
0x6F,0x62,0xC8,0x32,0x40,0x1D,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=secp384r1 Test SubCA 2 */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple, Inc./OU=Security Engineering/CN=secp384r1 Test Root CA */
unsigned char _int384B[671]={
0x30,0x82,0x02,0x9B,0x30,0x82,0x02,0x21,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0xFE,0xE6,0x21,0x31,0x73,0x83,0x11,0xBA,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,
0x3D,0x04,0x01,0x30,0x81,0x8C,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,
0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,
0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,
0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x14,0x30,0x12,
0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,
0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,
0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,
0x67,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x0C,0x16,0x73,0x65,0x63,0x70,
0x33,0x38,0x34,0x72,0x31,0x20,0x54,0x65,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,0x20,
0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x32,0x31,0x32,
0x31,0x38,0x5A,0x17,0x0D,0x31,0x36,0x31,0x32,0x31,0x36,0x32,0x32,0x31,0x32,0x31,
0x38,0x5A,0x30,0x78,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,
0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,
0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,
0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,
0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,
0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1F,0x30,0x1D,0x06,
0x03,0x55,0x04,0x03,0x0C,0x16,0x73,0x65,0x63,0x70,0x33,0x38,0x34,0x72,0x31,0x20,
0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x32,0x30,0x76,0x30,0x10,
0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,0x02,0x01,0x06,0x05,0x2B,0x81,0x04,0x00,0x22,
0x03,0x62,0x00,0x04,0x08,0xAE,0xF2,0x28,0x6E,0x8C,0xE8,0x16,0x01,0x86,0x37,0xFE,
0xFD,0x17,0xA5,0x37,0x30,0xD2,0x55,0xDB,0x4C,0x6D,0xE5,0xAF,0x63,0xBD,0x5F,0xB5,
0x6E,0xDB,0x66,0xB3,0x2C,0xA0,0xD1,0x6B,0xC2,0x82,0x28,0xBB,0xEF,0xD7,0xFE,0xA1,
0x3D,0x5A,0x00,0x56,0xFD,0xD2,0x28,0x36,0x8D,0xEE,0xFC,0x3F,0x58,0xFE,0x5D,0x0C,
0x82,0xE8,0x7F,0x0D,0x89,0xEE,0x4A,0xC1,0xF7,0xF3,0xB3,0x64,0xF7,0xB9,0x58,0xD6,
0x76,0x62,0x67,0x52,0x9B,0xDA,0x19,0xDA,0xD3,0xCA,0x55,0xF9,0xBD,0xBD,0x38,0x4E,
0x23,0xA5,0xF8,0xA9,0xA3,0x63,0x30,0x61,0x30,0x0F,0x06,0x03,0x55,0x1D,0x13,0x01,
0x01,0xFF,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,
0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x02,0x04,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,
0x04,0x16,0x04,0x14,0xD8,0xEA,0x0F,0xE6,0x82,0x91,0x5F,0xC4,0xA1,0x59,0x2B,0xBC,
0xB4,0x63,0x42,0xAF,0x57,0xCC,0xBC,0x79,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,
0x18,0x30,0x16,0x80,0x14,0x86,0xC8,0x90,0xD5,0xD7,0x5C,0x3A,0xE1,0x29,0xF4,0x13,
0x54,0xD0,0x06,0x90,0xAA,0xEC,0xF8,0x97,0xF7,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,
0xCE,0x3D,0x04,0x01,0x03,0x69,0x00,0x30,0x66,0x02,0x31,0x00,0xBD,0x7D,0x2C,0x3A,
0xC6,0xE6,0xA7,0xDB,0x73,0xA2,0x36,0x13,0x38,0xC4,0x17,0x71,0x35,0x41,0x23,0xC7,
0xCC,0xF1,0x9E,0x89,0x97,0x1F,0xD7,0xFC,0x58,0x9D,0x50,0x2D,0x0B,0xD9,0x33,0xD5,
0x7E,0xB4,0xD8,0x43,0xCF,0xDB,0x0A,0xBE,0xBE,0x44,0xDF,0x10,0x02,0x31,0x00,0xFD,
0xE3,0x32,0x58,0x06,0x7D,0xA1,0x7B,0x1F,0x22,0x85,0x82,0x54,0xD9,0xB0,0x36,0x4A,
0x2E,0x0B,0x24,0xA6,0x9B,0xBD,0x15,0x76,0xDB,0xAC,0xD4,0x97,0x91,0x64,0x11,0xFE,
0x47,0x11,0x59,0xBC,0xAF,0x1C,0x5A,0x16,0xF8,0x2E,0x0B,0x46,0x2C,0xD7,0x6E,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=secp128r1 Test Leaf */
/* issuer :/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=secp384r1 Test SubCA 2 */
unsigned char _leaf128[599]={
0x30,0x82,0x02,0x53,0x30,0x82,0x01,0xDA,0xA0,0x03,0x02,0x01,0x02,0x02,0x08,0x49,
0xF9,0xF0,0x5F,0xA0,0x17,0xBD,0x2F,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,
0x04,0x01,0x30,0x78,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,
0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,
0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,
0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,
0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,
0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1F,0x30,0x1D,0x06,
0x03,0x55,0x04,0x03,0x0C,0x16,0x73,0x65,0x63,0x70,0x33,0x38,0x34,0x72,0x31,0x20,
0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x32,0x30,0x1E,0x17,0x0D,
0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,0x32,0x32,0x33,0x34,0x5A,0x17,0x0D,0x31,
0x36,0x31,0x32,0x31,0x36,0x32,0x33,0x32,0x32,0x33,0x34,0x5A,0x30,0x75,0x31,0x0B,
0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,
0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,
0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,
0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,
0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,
0x65,0x72,0x69,0x6E,0x67,0x31,0x1C,0x30,0x1A,0x06,0x03,0x55,0x04,0x03,0x0C,0x13,
0x73,0x65,0x63,0x70,0x31,0x32,0x38,0x72,0x31,0x20,0x54,0x65,0x73,0x74,0x20,0x4C,
0x65,0x61,0x66,0x30,0x36,0x30,0x10,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,0x02,0x01,
0x06,0x05,0x2B,0x81,0x04,0x00,0x1C,0x03,0x22,0x00,0x04,0xB1,0x4F,0xBB,0xCA,0x19,
0xDD,0x23,0xF4,0x58,0xC2,0xDF,0x70,0x7A,0x46,0xB4,0xC9,0x22,0x71,0xF6,0x4D,0x1D,
0xDA,0x4C,0x0F,0x62,0x68,0x14,0x42,0xA7,0x77,0x8F,0xC6,0xA3,0x75,0x30,0x73,0x30,
0x0C,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,0x30,0x0E,0x06,
0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,0x13,0x06,
0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,
0x03,0x02,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x56,0x3C,0xD0,
0xEF,0xEF,0x08,0x74,0x41,0xD8,0xAB,0x26,0x21,0xD7,0xD9,0x6A,0xED,0xE1,0x1B,0x54,
0xF2,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0xD8,0xEA,
0x0F,0xE6,0x82,0x91,0x5F,0xC4,0xA1,0x59,0x2B,0xBC,0xB4,0x63,0x42,0xAF,0x57,0xCC,
0xBC,0x79,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,0x04,0x01,0x03,0x68,0x00,
0x30,0x65,0x02,0x31,0x00,0xFD,0x13,0x19,0x07,0xFB,0xD1,0x1B,0x3A,0xB1,0x82,0x2D,
0xA0,0x16,0xEE,0xAD,0x0B,0xCF,0x19,0x65,0x49,0x64,0xCE,0x03,0x04,0x32,0xD9,0x1F,
0xD2,0xC7,0x0A,0x43,0xD8,0xB9,0x9B,0x74,0x41,0x1A,0x20,0xAA,0xB3,0x2A,0xA8,0x71,
0xAC,0x65,0x73,0xBE,0xD1,0x02,0x30,0x2D,0x0D,0xFC,0x08,0x2E,0x9A,0x61,0xA3,0xB6,
0x55,0x72,0x4A,0x26,0x73,0xE3,0xA2,0x1A,0xE4,0x64,0x1C,0x44,0x93,0x5B,0xF8,0x93,
0xBB,0x42,0x2E,0x01,0xC9,0xAF,0xE1,0x98,0x04,0x8B,0x8C,0xC1,0x9F,0x2B,0x37,0x54,
0x4B,0x55,0xC9,0xF2,0x3F,0x6F,0x5E,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=prime192v1 Test Leaf */
/* issuer :/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=secp384r1 Test SubCA 2 */
unsigned char _leaf192[619]={
0x30,0x82,0x02,0x67,0x30,0x82,0x01,0xEE,0xA0,0x03,0x02,0x01,0x02,0x02,0x08,0x49,
0xF9,0xF0,0x5F,0xA0,0x17,0xBD,0x30,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,
0x04,0x01,0x30,0x78,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,
0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,
0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,
0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,
0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,
0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1F,0x30,0x1D,0x06,
0x03,0x55,0x04,0x03,0x0C,0x16,0x73,0x65,0x63,0x70,0x33,0x38,0x34,0x72,0x31,0x20,
0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x32,0x30,0x1E,0x17,0x0D,
0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,0x32,0x32,0x34,0x33,0x5A,0x17,0x0D,0x31,
0x36,0x31,0x32,0x31,0x36,0x32,0x33,0x32,0x32,0x34,0x33,0x5A,0x30,0x76,0x31,0x0B,
0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,
0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,
0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,
0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,
0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,
0x65,0x72,0x69,0x6E,0x67,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x03,0x0C,0x14,
0x70,0x72,0x69,0x6D,0x65,0x31,0x39,0x32,0x76,0x31,0x20,0x54,0x65,0x73,0x74,0x20,
0x4C,0x65,0x61,0x66,0x30,0x49,0x30,0x13,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,0x02,
0x01,0x06,0x08,0x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x01,0x03,0x32,0x00,0x04,0x29,
0x68,0x3F,0x3A,0xC9,0x63,0xDD,0x0F,0xC9,0x1A,0x4B,0x94,0x5C,0xEE,0x2C,0x41,0x42,
0xE0,0x35,0x9B,0xA9,0x93,0x03,0x8C,0xB7,0x2A,0xC5,0x96,0x8D,0x33,0x94,0x90,0x58,
0x78,0x5F,0xA4,0xFE,0x93,0x96,0x89,0x4D,0x50,0xB6,0xB8,0x78,0x40,0xC5,0xBA,0xA3,
0x75,0x30,0x73,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,
0x00,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,
0xA0,0x30,0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,
0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,
0x14,0x69,0x6E,0x52,0x27,0xD9,0x64,0x18,0x47,0x7F,0x23,0xF7,0xFB,0xF6,0x07,0x48,
0xDD,0x0E,0x48,0x0D,0xC3,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,
0x80,0x14,0xD8,0xEA,0x0F,0xE6,0x82,0x91,0x5F,0xC4,0xA1,0x59,0x2B,0xBC,0xB4,0x63,
0x42,0xAF,0x57,0xCC,0xBC,0x79,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,0x04,
0x01,0x03,0x68,0x00,0x30,0x65,0x02,0x31,0x00,0xC3,0x36,0x26,0x00,0x44,0x7B,0xEE,
0xAA,0x4A,0x13,0xA5,0x64,0x8A,0x6B,0x40,0x91,0x43,0x3A,0x4E,0x3C,0xDF,0x28,0x59,
0x12,0x86,0xB1,0x45,0x34,0x23,0xAE,0x8B,0x6D,0x91,0x7D,0xFB,0x0E,0x15,0xF9,0xC9,
0xFB,0x52,0x96,0xBA,0x0B,0xBE,0x84,0xAC,0x58,0x02,0x30,0x5C,0x21,0x90,0x17,0x18,
0x38,0xA3,0x40,0xAF,0x53,0x76,0x88,0x4B,0x22,0x97,0x5E,0x54,0xF2,0x98,0x0F,0xB5,
0x61,0x4C,0x10,0x44,0x53,0xFC,0xB6,0x6E,0xF3,0x9E,0x2C,0x4B,0x3B,0xAC,0xC8,0x90,
0xBF,0xAE,0xEC,0xC7,0x62,0xFE,0x2F,0xAF,0x1A,0x90,0x35,
};
/* subject:/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=secp384r1 Test Leaf 3 */
/* issuer :/C=US/ST=California/O=Apple, Inc./OU=Security Engineering/CN=secp384r1 Test SubCA 2 */
unsigned char _leaf384C[665]={
0x30,0x82,0x02,0x95,0x30,0x82,0x02,0x1C,0xA0,0x03,0x02,0x01,0x02,0x02,0x08,0x49,
0xF9,0xF0,0x5F,0xA0,0x17,0xBD,0x31,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,
0x04,0x01,0x30,0x78,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,
0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,
0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,
0x0B,0x41,0x70,0x70,0x6C,0x65,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,
0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,
0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1F,0x30,0x1D,0x06,
0x03,0x55,0x04,0x03,0x0C,0x16,0x73,0x65,0x63,0x70,0x33,0x38,0x34,0x72,0x31,0x20,
0x54,0x65,0x73,0x74,0x20,0x53,0x75,0x62,0x43,0x41,0x20,0x32,0x30,0x1E,0x17,0x0D,
0x31,0x35,0x31,0x32,0x31,0x37,0x32,0x33,0x32,0x32,0x35,0x35,0x5A,0x17,0x0D,0x31,
0x36,0x31,0x32,0x31,0x36,0x32,0x33,0x32,0x32,0x35,0x35,0x5A,0x30,0x77,0x31,0x0B,
0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,
0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,
0x31,0x14,0x30,0x12,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0B,0x41,0x70,0x70,0x6C,0x65,
0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,
0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,
0x65,0x72,0x69,0x6E,0x67,0x31,0x1E,0x30,0x1C,0x06,0x03,0x55,0x04,0x03,0x0C,0x15,
0x73,0x65,0x63,0x70,0x33,0x38,0x34,0x72,0x31,0x20,0x54,0x65,0x73,0x74,0x20,0x4C,
0x65,0x61,0x66,0x20,0x33,0x30,0x76,0x30,0x10,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,
0x02,0x01,0x06,0x05,0x2B,0x81,0x04,0x00,0x22,0x03,0x62,0x00,0x04,0x1F,0x62,0x07,
0xBA,0x5D,0x2A,0x56,0xED,0x5D,0xE7,0x0B,0x18,0xDE,0x65,0x13,0xA4,0x31,0x53,0xFC,
0x86,0x86,0xB4,0xC4,0x27,0x39,0x4D,0xD1,0x22,0xC2,0xFF,0x07,0x62,0xAB,0x64,0xDD,
0xCC,0xEB,0x7F,0x08,0x12,0x78,0x20,0x90,0x40,0xD3,0xCF,0x45,0x71,0x98,0x6E,0x4E,
0x93,0xC5,0x66,0x40,0x76,0xB0,0xAD,0xDB,0xD6,0xFA,0x9C,0x7F,0x46,0xF9,0xC9,0xDE,
0xF5,0x41,0xA3,0x0C,0x7F,0x73,0xF3,0x0C,0x91,0xE1,0x0B,0xAD,0xBC,0xD5,0xD2,0xB1,
0x6F,0xC3,0x1F,0x43,0x94,0x9C,0x18,0x5B,0xD9,0xE1,0x5A,0x84,0x2F,0xA3,0x75,0x30,
0x73,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,0x30,
0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,
0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,
0x05,0x07,0x03,0x02,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0xB3,
0xB5,0xC9,0x62,0x46,0xDD,0x1C,0x89,0x93,0xE3,0xAA,0x7C,0xEA,0x61,0x22,0x8B,0xF2,
0x04,0x31,0x74,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,
0xD8,0xEA,0x0F,0xE6,0x82,0x91,0x5F,0xC4,0xA1,0x59,0x2B,0xBC,0xB4,0x63,0x42,0xAF,
0x57,0xCC,0xBC,0x79,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x3D,0x04,0x01,0x03,
0x68,0x00,0x30,0x65,0x02,0x30,0x33,0xE4,0xE8,0x8E,0x00,0x57,0xE4,0x53,0xCC,0xD4,
0x04,0xF2,0xB6,0x7D,0xD5,0x14,0x5B,0xB2,0xBE,0x28,0xF8,0x5D,0x55,0x7A,0xB3,0x06,
0x17,0x87,0xA9,0xAA,0x23,0xCE,0xAF,0x15,0xF3,0xE1,0xA8,0x9B,0xCF,0x06,0xC9,0x06,
0x75,0x0C,0x13,0x12,0x40,0x32,0x02,0x31,0x00,0xE2,0x28,0x4A,0x28,0xA6,0x94,0x2C,
0x8E,0x5A,0x13,0xCF,0x33,0xBB,0x6A,0x11,0x74,0x3A,0xED,0x3A,0x61,0x07,0x6D,0x49,
0x84,0xBF,0xE2,0x1F,0xED,0x08,0x70,0x0F,0xCA,0x45,0xBA,0x68,0x1C,0xF3,0x15,0x7E,
0xAB,0x41,0x0E,0xAB,0x84,0x29,0x33,0x87,0x3A,
};
/* subject:/C=US/ST=California/L=Cupertino/O=Apple Inc./OU=Security Engineering/CN=Weak Crypto Test CA */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple Inc./OU=Security Engineering/CN=Weak Crypto Test CA */
uint8_t _rootSSL[] = {
0x30,0x82,0x03,0xDA,0x30,0x82,0x02,0xC2,0xA0,0x03,0x02,0x01,0x02,0x02,0x09,0x00,
0xCE,0xB0,0xBF,0x61,0x75,0x93,0xF9,0x53,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x30,0x81,0x88,0x31,0x0B,0x30,0x09,0x06,0x03,
0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,
0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,
0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,
0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,
0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,
0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,
0x72,0x69,0x6E,0x67,0x31,0x1C,0x30,0x1A,0x06,0x03,0x55,0x04,0x03,0x0C,0x13,0x57,
0x65,0x61,0x6B,0x20,0x43,0x72,0x79,0x70,0x74,0x6F,0x20,0x54,0x65,0x73,0x74,0x20,
0x43,0x41,0x30,0x1E,0x17,0x0D,0x31,0x39,0x30,0x34,0x31,0x39,0x32,0x32,0x33,0x33,
0x34,0x38,0x5A,0x17,0x0D,0x32,0x30,0x30,0x34,0x31,0x38,0x32,0x32,0x33,0x33,0x34,
0x38,0x5A,0x30,0x81,0x88,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,
0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,
0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,
0x0C,0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x13,0x30,0x11,0x06,
0x03,0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,
0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,
0x69,0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,
0x1C,0x30,0x1A,0x06,0x03,0x55,0x04,0x03,0x0C,0x13,0x57,0x65,0x61,0x6B,0x20,0x43,
0x72,0x79,0x70,0x74,0x6F,0x20,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x30,0x82,0x01,
0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,
0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xC8,0xC5,
0x06,0x13,0xEB,0x60,0xE1,0x07,0xE3,0x47,0x50,0x42,0xC3,0x5B,0xAE,0xF4,0x5A,0x65,
0x6A,0x74,0xAC,0xF2,0xF6,0x1C,0xFC,0x45,0x21,0x8D,0x0E,0x08,0x78,0x83,0x28,0xDD,
0xBB,0xDD,0x65,0xD4,0x2F,0x05,0x56,0x06,0x21,0xEF,0xE2,0xE9,0x2C,0x78,0x61,0x56,
0x1F,0x87,0x4D,0x99,0xD0,0x2B,0x47,0x30,0xFF,0xAE,0x29,0x1F,0x63,0xF3,0xFC,0x26,
0xEC,0xDF,0xCD,0x34,0xD1,0x4B,0xDE,0x5A,0x52,0xFA,0x90,0x1F,0x6B,0xDE,0x74,0x79,
0xDD,0x3E,0x53,0x62,0x20,0xD3,0x5B,0x18,0x0A,0xE8,0xBE,0xEB,0xBD,0x52,0x81,0xAD,
0x1A,0x24,0x3C,0x9C,0xAD,0xC4,0x72,0xA9,0x9D,0xC1,0xC0,0x7F,0x42,0x32,0x02,0x5B,
0x4F,0xFF,0x5E,0x7F,0xA5,0xD0,0x26,0xF9,0xF7,0x80,0xF9,0xEC,0x86,0x0F,0xA9,0x0B,
0x12,0x6E,0x95,0x1D,0x18,0xC9,0x0D,0x7B,0x52,0xD2,0x37,0xF1,0x68,0x45,0x9C,0x58,
0x6F,0x88,0xC7,0x71,0x9F,0x02,0xEA,0x44,0x13,0xF2,0x5D,0xAC,0x81,0xD7,0x59,0x98,
0x19,0xA2,0xB8,0x56,0xA3,0x89,0xC7,0xD9,0x5E,0xA2,0xA8,0xBA,0xC2,0x97,0x94,0x09,
0xBB,0x81,0xDE,0xE8,0x9A,0x06,0x92,0xAA,0x14,0xDA,0x4D,0xFB,0xD6,0xD4,0xC6,0x0F,
0x1E,0x25,0xAA,0x42,0xDB,0x3F,0x59,0xD2,0x90,0x93,0x4C,0xB4,0xF8,0x39,0x8B,0xA1,
0x54,0x7B,0x83,0x29,0xCF,0xA2,0x53,0xD7,0x14,0x9A,0x57,0xB8,0x13,0x0F,0x48,0x1F,
0x56,0x13,0xE3,0xBB,0x9A,0x11,0x62,0x37,0x25,0xA4,0x8A,0xA2,0x03,0x9E,0x9F,0xD0,
0x08,0x52,0xF7,0x58,0x79,0xD6,0xBD,0xD7,0xCA,0x00,0x3C,0xE7,0xFB,0xDB,0x02,0x03,
0x01,0x00,0x01,0xA3,0x45,0x30,0x43,0x30,0x12,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,
0xFF,0x04,0x08,0x30,0x06,0x01,0x01,0xFF,0x02,0x01,0x00,0x30,0x0E,0x06,0x03,0x55,
0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x01,0x06,0x30,0x1D,0x06,0x03,0x55,
0x1D,0x0E,0x04,0x16,0x04,0x14,0xF1,0x0F,0x83,0xE3,0x07,0x66,0xE9,0x79,0xEE,0x31,
0x1A,0x6A,0x30,0x9B,0xDA,0x97,0x15,0xF7,0xB9,0xB4,0x30,0x0D,0x06,0x09,0x2A,0x86,
0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x9D,0xC9,
0xCD,0xFB,0x8F,0x40,0xC2,0xFD,0xF0,0x7D,0x8D,0x36,0x43,0x57,0x98,0x91,0x11,0x0A,
0x3A,0x70,0x28,0x5D,0xCC,0xF6,0xB7,0xF9,0x51,0xB3,0xCA,0x80,0x67,0x5A,0xF4,0x6D,
0xB4,0x4A,0x50,0x11,0xC5,0x25,0xA3,0x5B,0xBF,0x03,0xB4,0xA2,0x37,0x80,0x08,0x7B,
0x5D,0xDB,0x39,0x2B,0x06,0xA0,0x6C,0x5B,0x1D,0x1E,0x21,0x79,0x5B,0x34,0x78,0x03,
0xA2,0xBF,0x2F,0x68,0x90,0xF7,0xA9,0x55,0x35,0xAF,0x27,0x58,0xF5,0x96,0x93,0x64,
0x9E,0xC0,0x4E,0x76,0x9E,0xEA,0x18,0x1B,0x97,0x7B,0xFB,0x71,0x4D,0x30,0x5C,0x5D,
0x4C,0xDF,0xB4,0x41,0x0C,0x15,0xC0,0x94,0xAA,0x85,0xB8,0x55,0x39,0x49,0xA4,0x5F,
0x33,0xA1,0x57,0x2C,0xF1,0x16,0xC6,0x0B,0xCC,0x33,0x4B,0xA5,0xA3,0x44,0x63,0xA3,
0xCB,0x9F,0xC9,0xF8,0x99,0x51,0x63,0x28,0x8D,0xC7,0xE3,0x45,0x6F,0x4E,0x26,0x8C,
0xEA,0xDA,0xAE,0x74,0xFC,0x81,0xBC,0x5E,0xF1,0x64,0xD5,0xE5,0x63,0x74,0x34,0x9B,
0x72,0x54,0xF9,0xE1,0x5A,0xE6,0x2C,0xCF,0x2B,0xD9,0x0B,0xD1,0xF4,0xB8,0x51,0x9D,
0x9D,0x70,0xC2,0x2B,0xC4,0x07,0x6B,0xA2,0x70,0xC7,0x1B,0x33,0xC3,0x50,0x65,0xB6,
0x13,0x18,0x64,0xFF,0x27,0xA8,0x7B,0xD8,0xCB,0x45,0xC9,0xD2,0x57,0x2A,0x15,0xB6,
0x6E,0xD9,0x06,0xEB,0x38,0xC6,0x19,0x97,0x4E,0x3D,0x31,0x45,0x90,0x6A,0xD9,0x55,
0x60,0x43,0xF4,0x04,0x62,0x39,0xE0,0x8A,0xAB,0x55,0xA4,0xA2,0xF8,0x5E,0xA9,0x3E,
0xCB,0x08,0x9B,0x35,0x66,0x5D,0xFA,0x6A,0xC2,0x93,0x12,0x74,0x63,0x20,
};
/* subject:/C=US/ST=California/L=Cupertino/O=Apple Inc./OU=Security Engineering/CN=Weak Key Leaf */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple Inc./OU=Security Engineering/CN=Weak Crypto Test CA */
unsigned char _leaf1024SSL[] = {
0x30,0x82,0x03,0xAE,0x30,0x82,0x02,0x96,0xA0,0x03,0x02,0x01,0x02,0x02,0x13,0x7A,
0x22,0xA1,0x88,0x18,0x9E,0x75,0x77,0xE6,0xEF,0x7E,0xC0,0x33,0x8E,0xE8,0x90,0xE8,
0x7B,0xC7,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,
0x00,0x30,0x81,0x88,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,
0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,
0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,
0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x13,0x30,0x11,0x06,0x03,
0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,
0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,
0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1C,
0x30,0x1A,0x06,0x03,0x55,0x04,0x03,0x0C,0x13,0x57,0x65,0x61,0x6B,0x20,0x43,0x72,
0x79,0x70,0x74,0x6F,0x20,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x30,0x1E,0x17,0x0D,
0x31,0x39,0x30,0x34,0x31,0x39,0x32,0x32,0x34,0x31,0x32,0x38,0x5A,0x17,0x0D,0x32,
0x30,0x30,0x34,0x31,0x38,0x32,0x32,0x34,0x31,0x32,0x38,0x5A,0x30,0x81,0x82,0x31,
0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,
0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,
0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,
0x72,0x74,0x69,0x6E,0x6F,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0A,
0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,
0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,
0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x16,0x30,0x14,0x06,0x03,0x55,
0x04,0x03,0x0C,0x0D,0x57,0x65,0x61,0x6B,0x20,0x4B,0x65,0x79,0x20,0x4C,0x65,0x61,
0x66,0x30,0x81,0x9F,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,
0x01,0x05,0x00,0x03,0x81,0x8D,0x00,0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xC9,0x5D,
0xD1,0xA8,0xEE,0x6A,0x6C,0x0A,0xA5,0x1A,0x7D,0xA8,0xCA,0xA3,0xDC,0x7D,0xC3,0x47,
0xF8,0x49,0x0C,0xA5,0xDF,0x4A,0xCA,0x80,0xBC,0x73,0x0D,0xFD,0x36,0x21,0x93,0x46,
0x03,0xF4,0x8C,0x4E,0xD9,0x2F,0x4F,0x7D,0x23,0x15,0xE6,0xCB,0x51,0x8F,0xE3,0xA2,
0x97,0x87,0xC7,0x25,0x25,0x0D,0x7F,0xDA,0x21,0x8B,0xC4,0x01,0xE1,0xDC,0x08,0x6F,
0xAE,0xCF,0x89,0xDA,0x45,0xA3,0x12,0xE1,0xC3,0xE9,0xBF,0x3A,0x12,0x0C,0xDD,0x25,
0x9B,0xDE,0x96,0x35,0x2C,0x3F,0xA2,0xCD,0x00,0xFF,0xA1,0x8E,0x02,0xEF,0x31,0xC6,
0x30,0x45,0x69,0x4D,0x9A,0xF1,0x05,0xB4,0x52,0x65,0xA7,0x85,0xE9,0x37,0xBA,0xA0,
0xB9,0x96,0x88,0x5D,0xB5,0xAF,0xDA,0xE2,0xDD,0x68,0x62,0x95,0xCC,0x33,0x02,0x03,
0x01,0x00,0x01,0xA3,0x81,0x98,0x30,0x81,0x95,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,
0x01,0x01,0xFF,0x04,0x02,0x30,0x00,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,
0xFF,0x04,0x04,0x03,0x02,0x07,0x80,0x30,0x1D,0x06,0x03,0x55,0x1D,0x25,0x04,0x16,
0x30,0x14,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01,0x06,0x08,0x2B,0x06,
0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x16,0x06,0x03,0x55,0x1D,0x11,0x04,0x0F,0x30,
0x0D,0x82,0x0B,0x65,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x1D,
0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x84,0x25,0x19,0x83,0x30,0xFF,0x03,
0x58,0xCE,0x52,0x74,0x0E,0x20,0xC4,0x42,0x5A,0x9A,0x58,0xE2,0xFD,0x30,0x1F,0x06,
0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0xF1,0x0F,0x83,0xE3,0x07,0x66,
0xE9,0x79,0xEE,0x31,0x1A,0x6A,0x30,0x9B,0xDA,0x97,0x15,0xF7,0xB9,0xB4,0x30,0x0D,
0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,
0x01,0x00,0x4D,0xA0,0x2F,0xE7,0xE4,0xE0,0x08,0x75,0x79,0x13,0x1C,0x52,0xF1,0xC8,
0x24,0xB5,0x21,0x54,0x0D,0x20,0xEB,0x09,0xEC,0x1B,0x89,0xBD,0xA6,0x47,0x1E,0x43,
0x4F,0x01,0x32,0x83,0x41,0xC3,0xD0,0x2A,0xB6,0xDB,0x5B,0x9F,0x97,0x2A,0xD6,0xB3,
0x38,0xD5,0x55,0x32,0xB4,0x79,0x1E,0x48,0x1C,0xA5,0x02,0xDE,0xC3,0x2E,0xAD,0xCA,
0xAC,0x57,0xA0,0xCD,0xEE,0x0D,0x21,0xF7,0xBF,0xF4,0xB7,0x3C,0x5A,0x35,0xFD,0x1F,
0x47,0x4C,0xB2,0xC4,0x22,0x4E,0xA6,0x5F,0xA7,0x09,0x9A,0x26,0x4E,0x8A,0x4C,0x0B,
0x1A,0xAF,0x6B,0xF7,0x5F,0x56,0x12,0xD9,0xC1,0x26,0x21,0xE2,0xA5,0xCE,0x45,0x00,
0xB9,0xB6,0x88,0xC8,0xD2,0xC9,0x66,0xB4,0x9E,0xD2,0x34,0x19,0xA2,0x0B,0x30,0x9E,
0xC8,0x85,0x30,0x71,0x95,0x3D,0x3D,0x61,0xD2,0x4E,0x4D,0xB1,0xF8,0xC2,0x92,0x1B,
0x21,0x67,0x7A,0x97,0x02,0xF0,0xE3,0x47,0x1C,0xF5,0x08,0xA9,0xA3,0x08,0xF5,0xED,
0x4C,0x55,0x7C,0x62,0xF3,0xD3,0xD4,0xB9,0xAD,0xBF,0xFC,0x66,0x95,0xAF,0x7E,0xD9,
0x5E,0xDD,0x68,0xCF,0x78,0x25,0xEF,0x90,0x44,0x1F,0xFC,0xB3,0x35,0x81,0x1D,0x1B,
0x27,0xAC,0x28,0xB8,0x58,0xAB,0x6D,0xFE,0x71,0xC0,0x4F,0xBE,0x37,0x35,0xA0,0x62,
0x93,0xA8,0x91,0x73,0x43,0x39,0x0A,0xAD,0x5E,0xE8,0x1E,0x90,0xF0,0x50,0xC7,0x7C,
0xED,0x29,0xE5,0xD2,0x42,0x55,0x89,0x9C,0xD7,0x51,0xA9,0xB6,0xF0,0xC5,0x39,0x34,
0xE4,0xA0,0x6D,0xAD,0x1A,0x51,0xCC,0xA0,0xDA,0x0D,0xA7,0xB9,0x7F,0x06,0xDE,0x96,
0xD6,0x0F,
};
/* subject:/C=US/ST=California/L=Cupertino/O=Apple Inc./OU=Security Engineering/CN=Strong Crypto Leaf */
/* issuer :/C=US/ST=California/L=Cupertino/O=Apple Inc./OU=Security Engineering/CN=Weak Crypto Test CA */
uint8_t _leaf2048SSL[] = {
0x30,0x82,0x04,0x37,0x30,0x82,0x03,0x1F,0xA0,0x03,0x02,0x01,0x02,0x02,0x13,0x7A,
0x22,0xA1,0x88,0x18,0x9E,0x75,0x77,0xE6,0xEF,0x7E,0xC0,0x33,0x8E,0xE8,0x90,0xE8,
0x7B,0xC6,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,
0x00,0x30,0x81,0x88,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,
0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,
0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,
0x09,0x43,0x75,0x70,0x65,0x72,0x74,0x69,0x6E,0x6F,0x31,0x13,0x30,0x11,0x06,0x03,
0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,
0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,
0x74,0x79,0x20,0x45,0x6E,0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1C,
0x30,0x1A,0x06,0x03,0x55,0x04,0x03,0x0C,0x13,0x57,0x65,0x61,0x6B,0x20,0x43,0x72,
0x79,0x70,0x74,0x6F,0x20,0x54,0x65,0x73,0x74,0x20,0x43,0x41,0x30,0x1E,0x17,0x0D,
0x31,0x39,0x30,0x34,0x31,0x39,0x32,0x32,0x33,0x38,0x31,0x34,0x5A,0x17,0x0D,0x32,
0x30,0x30,0x34,0x31,0x38,0x32,0x32,0x33,0x38,0x31,0x34,0x5A,0x30,0x81,0x87,0x31,
0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,
0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,
0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,
0x72,0x74,0x69,0x6E,0x6F,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0A,
0x41,0x70,0x70,0x6C,0x65,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1D,0x30,0x1B,0x06,0x03,
0x55,0x04,0x0B,0x0C,0x14,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x45,0x6E,
0x67,0x69,0x6E,0x65,0x65,0x72,0x69,0x6E,0x67,0x31,0x1B,0x30,0x19,0x06,0x03,0x55,
0x04,0x03,0x0C,0x12,0x53,0x74,0x72,0x6F,0x6E,0x67,0x20,0x43,0x72,0x79,0x70,0x74,
0x6F,0x20,0x4C,0x65,0x61,0x66,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,
0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,
0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xAF,0x01,0x48,0x09,0xB9,0xA1,0xB5,0x29,0x07,
0x36,0x35,0xA6,0x5D,0x97,0x38,0x1F,0x0A,0xD1,0xD8,0x0B,0xD1,0xC5,0xDD,0x07,0x39,
0x96,0xBA,0xDD,0xFF,0xC0,0x42,0x8D,0x19,0xDD,0xA9,0x44,0x0A,0xD6,0xD7,0xBA,0x74,
0x1F,0xDA,0x75,0x15,0x02,0x50,0xC9,0x78,0x46,0x76,0xDB,0xAA,0xCF,0xE0,0x5A,0xA1,
0xDE,0x81,0xFB,0x73,0xB9,0x85,0x7F,0xA4,0xD7,0x52,0xE6,0x96,0xD7,0x67,0x42,0x78,
0x89,0x8D,0xFF,0xD6,0xF4,0x3D,0x02,0x68,0x14,0xA2,0x5E,0x48,0xD9,0x2C,0x9B,0x09,
0x09,0xEA,0x00,0x00,0xB1,0x8B,0x32,0xB8,0x1E,0x92,0x05,0xFF,0xCB,0x72,0x7A,0x6F,
0x8F,0xCC,0xFB,0x04,0xCD,0x11,0xC0,0x12,0xBA,0x62,0x6E,0x02,0xBA,0x8C,0xE7,0x61,
0xE7,0xC4,0x52,0xA5,0xA6,0xF3,0x86,0x34,0xA8,0xCC,0x15,0x59,0x48,0x18,0xF3,0xCC,
0x13,0xE4,0x8A,0x3F,0xF1,0xF8,0xED,0xD8,0x74,0x5D,0x86,0x6E,0x07,0x6A,0xA1,0xA9,
0xCF,0x46,0xE0,0x76,0x38,0xC8,0xEC,0x33,0x7A,0x40,0x5E,0x0E,0x6E,0xB0,0x11,0x53,
0xD0,0xA3,0xEB,0x7E,0x73,0x6D,0xFD,0xAB,0xAE,0x24,0x31,0x2E,0x1D,0xC8,0x3D,0xF7,
0xBE,0xA4,0xB1,0x6A,0x69,0x09,0xDF,0xBE,0x20,0x43,0x55,0x55,0x49,0x26,0x36,0xF5,
0x3F,0x8F,0x25,0xDA,0x34,0x1A,0xD4,0x2B,0xCC,0x88,0x5C,0xDA,0x03,0x85,0xE3,0xCF,
0xD4,0xA7,0x8E,0x49,0x30,0x74,0x8A,0xB0,0x11,0xCF,0xA0,0x81,0xA6,0x99,0x5E,0xE2,
0xEE,0x47,0x03,0x13,0x04,0x07,0xAB,0x74,0x30,0x4D,0xA7,0xFF,0xD7,0x7A,0x9B,0xBA,
0x38,0x94,0x35,0xC3,0xDD,0x93,0xBB,0x02,0x03,0x01,0x00,0x01,0xA3,0x81,0x98,0x30,
0x81,0x95,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,
0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x07,0x80,
0x30,0x1D,0x06,0x03,0x55,0x1D,0x25,0x04,0x16,0x30,0x14,0x06,0x08,0x2B,0x06,0x01,
0x05,0x05,0x07,0x03,0x01,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,
0x16,0x06,0x03,0x55,0x1D,0x11,0x04,0x0F,0x30,0x0D,0x82,0x0B,0x65,0x78,0x61,0x6D,
0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,
0x04,0x14,0x77,0xD2,0xF8,0xFB,0x2A,0x51,0x1C,0xD0,0x26,0x13,0x7B,0x36,0xFB,0x3D,
0xC9,0x04,0xFD,0x75,0x22,0xFE,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,
0x16,0x80,0x14,0xF1,0x0F,0x83,0xE3,0x07,0x66,0xE9,0x79,0xEE,0x31,0x1A,0x6A,0x30,
0x9B,0xDA,0x97,0x15,0xF7,0xB9,0xB4,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,
0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x2B,0x72,0x9E,0x87,0xFA,
0x4D,0x05,0x78,0x93,0x49,0x7F,0x58,0x3D,0x49,0xD8,0x3D,0x5A,0x69,0x29,0x58,0x41,
0x74,0xAA,0x29,0xEF,0x4E,0x04,0x5F,0x7D,0xA8,0x54,0x8D,0x59,0x90,0x28,0x93,0x90,
0x45,0x82,0x31,0xE2,0xC5,0xE8,0xFC,0xFB,0x91,0x07,0xD0,0x89,0x60,0x69,0xAB,0x4A,
0xB1,0x63,0x39,0xF9,0xD9,0xED,0xFC,0x81,0xB9,0x28,0x0B,0xBA,0x53,0xC1,0xF7,0x94,
0xE4,0x1A,0x02,0xAE,0xD9,0x02,0x42,0x43,0xAE,0xFC,0x26,0x4C,0x75,0x6C,0x51,0xAD,
0x11,0xB9,0xBA,0x65,0xD1,0x5D,0x51,0x15,0x0D,0xDA,0xAC,0x26,0x53,0x77,0xFE,0x68,
0xFD,0x83,0xD3,0xB0,0x29,0x26,0xC5,0x2F,0x2F,0x2B,0x76,0x4A,0x62,0x7C,0x41,0xBB,
0x2A,0xF7,0xE4,0x51,0x28,0x1D,0x34,0xB1,0x46,0x44,0x58,0x04,0x8F,0x64,0x20,0xBE,
0x26,0x5C,0x36,0x07,0xD1,0x7C,0xAB,0x3D,0x12,0x02,0xD5,0xC1,0xB6,0xBF,0x12,0x3A,
0xC4,0x8A,0x61,0x8E,0x16,0x55,0x61,0x88,0xA5,0xBE,0xA8,0xAC,0x3B,0xD3,0xEB,0xAC,
0xB8,0xEF,0x54,0xA7,0x78,0x99,0xA1,0x04,0x20,0x20,0x28,0x37,0xC5,0x47,0x63,0xB3,
0x7D,0x0D,0xBB,0x8A,0x6A,0x5B,0x11,0x9C,0x08,0x09,0xCD,0xFB,0x8E,0x68,0xDF,0xE8,
0x8C,0x7B,0x27,0x38,0xCC,0x6C,0x0B,0xCE,0x62,0xD1,0x87,0x91,0xC7,0x8B,0xD5,0xE7,
0xA2,0xF2,0x8F,0x4F,0x32,0xB8,0xE6,0xE6,0xE1,0x20,0x82,0x9D,0xED,0x56,0xBA,0x88,
0x2D,0xB0,0xCD,0x72,0x20,0x13,0x71,0x34,0x9C,0x02,0x0B,0x72,0x9C,0x27,0x67,0x5F,
0x2A,0x77,0x4E,0x43,0xE5,0x71,0x96,0x36,0x11,0x0F,0x35,
};
/* subject:/OU=Domain Control Validated/OU=PositiveSSL Wildcard/CN=*.badssl.com */
/* issuer :/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA */
uint8_t _leaf2048SystemTrust[] = {
0x30,0x82,0x05,0x4B,0x30,0x82,0x04,0x33,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x4C,
0x8E,0x18,0x71,0x4B,0x34,0xE7,0x5E,0x8D,0xAE,0xFB,0xE8,0xF6,0x4C,0x3A,0x82,0x30,
0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x81,
0x90,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x47,0x42,0x31,0x1B,
0x30,0x19,0x06,0x03,0x55,0x04,0x08,0x13,0x12,0x47,0x72,0x65,0x61,0x74,0x65,0x72,
0x20,0x4D,0x61,0x6E,0x63,0x68,0x65,0x73,0x74,0x65,0x72,0x31,0x10,0x30,0x0E,0x06,
0x03,0x55,0x04,0x07,0x13,0x07,0x53,0x61,0x6C,0x66,0x6F,0x72,0x64,0x31,0x1A,0x30,
0x18,0x06,0x03,0x55,0x04,0x0A,0x13,0x11,0x43,0x4F,0x4D,0x4F,0x44,0x4F,0x20,0x43,
0x41,0x20,0x4C,0x69,0x6D,0x69,0x74,0x65,0x64,0x31,0x36,0x30,0x34,0x06,0x03,0x55,
0x04,0x03,0x13,0x2D,0x43,0x4F,0x4D,0x4F,0x44,0x4F,0x20,0x52,0x53,0x41,0x20,0x44,
0x6F,0x6D,0x61,0x69,0x6E,0x20,0x56,0x61,0x6C,0x69,0x64,0x61,0x74,0x69,0x6F,0x6E,
0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,
0x41,0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x37,0x30,0x37,0x30,0x30,0x30,0x30,0x30,
0x30,0x5A,0x17,0x0D,0x31,0x37,0x30,0x39,0x30,0x35,0x32,0x33,0x35,0x39,0x35,0x39,
0x5A,0x30,0x59,0x31,0x21,0x30,0x1F,0x06,0x03,0x55,0x04,0x0B,0x13,0x18,0x44,0x6F,
0x6D,0x61,0x69,0x6E,0x20,0x43,0x6F,0x6E,0x74,0x72,0x6F,0x6C,0x20,0x56,0x61,0x6C,
0x69,0x64,0x61,0x74,0x65,0x64,0x31,0x1D,0x30,0x1B,0x06,0x03,0x55,0x04,0x0B,0x13,
0x14,0x50,0x6F,0x73,0x69,0x74,0x69,0x76,0x65,0x53,0x53,0x4C,0x20,0x57,0x69,0x6C,
0x64,0x63,0x61,0x72,0x64,0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x0C,0x0C,
0x2A,0x2E,0x62,0x61,0x64,0x73,0x73,0x6C,0x2E,0x63,0x6F,0x6D,0x30,0x82,0x01,0x22,
0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,
0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xC2,0x04,0xEC,
0xF8,0x8C,0xEE,0x04,0xC2,0xB3,0xD8,0x50,0xD5,0x70,0x58,0xCC,0x93,0x18,0xEB,0x5C,
0xA8,0x68,0x49,0xB0,0x22,0xB5,0xF9,0x95,0x9E,0xB1,0x2B,0x2C,0x76,0x3E,0x6C,0xC0,
0x4B,0x60,0x4C,0x4C,0xEA,0xB2,0xB4,0xC0,0x0F,0x80,0xB6,0xB0,0xF9,0x72,0xC9,0x86,
0x02,0xF9,0x5C,0x41,0x5D,0x13,0x2B,0x7F,0x71,0xC4,0x4B,0xBC,0xE9,0x94,0x2E,0x50,
0x37,0xA6,0x67,0x1C,0x61,0x8C,0xF6,0x41,0x42,0xC5,0x46,0xD3,0x16,0x87,0x27,0x9F,
0x74,0xEB,0x0A,0x9D,0x11,0x52,0x26,0x21,0x73,0x6C,0x84,0x4C,0x79,0x55,0xE4,0xD1,
0x6B,0xE8,0x06,0x3D,0x48,0x15,0x52,0xAD,0xB3,0x28,0xDB,0xAA,0xFF,0x6E,0xFF,0x60,
0x95,0x4A,0x77,0x6B,0x39,0xF1,0x24,0xD1,0x31,0xB6,0xDD,0x4D,0xC0,0xC4,0xFC,0x53,
0xB9,0x6D,0x42,0xAD,0xB5,0x7C,0xFE,0xAE,0xF5,0x15,0xD2,0x33,0x48,0xE7,0x22,0x71,
0xC7,0xC2,0x14,0x7A,0x6C,0x28,0xEA,0x37,0x4A,0xDF,0xEA,0x6C,0xB5,0x72,0xB4,0x7E,
0x5A,0xA2,0x16,0xDC,0x69,0xB1,0x57,0x44,0xDB,0x0A,0x12,0xAB,0xDE,0xC3,0x0F,0x47,
0x74,0x5C,0x41,0x22,0xE1,0x9A,0xF9,0x1B,0x93,0xE6,0xAD,0x22,0x06,0x29,0x2E,0xB1,
0xBA,0x49,0x1C,0x0C,0x27,0x9E,0xA3,0xFB,0x8B,0xF7,0x40,0x72,0x00,0xAC,0x92,0x08,
0xD9,0x8C,0x57,0x84,0x53,0x81,0x05,0xCB,0xE6,0xFE,0x6B,0x54,0x98,0x40,0x27,0x85,
0xC7,0x10,0xBB,0x73,0x70,0xEF,0x69,0x18,0x41,0x07,0x45,0x55,0x7C,0xF9,0x64,0x3F,
0x3D,0x2C,0xC3,0xA9,0x7C,0xEB,0x93,0x1A,0x4C,0x86,0xD1,0xCA,0x85,0x02,0x03,0x01,
0x00,0x01,0xA3,0x82,0x01,0xD5,0x30,0x82,0x01,0xD1,0x30,0x1F,0x06,0x03,0x55,0x1D,
0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x90,0xAF,0x6A,0x3A,0x94,0x5A,0x0B,0xD8,0x90,
0xEA,0x12,0x56,0x73,0xDF,0x43,0xB4,0x3A,0x28,0xDA,0xE7,0x30,0x1D,0x06,0x03,0x55,
0x1D,0x0E,0x04,0x16,0x04,0x14,0x9D,0xEE,0xC1,0x7B,0x81,0x0B,0x3A,0x47,0x69,0x71,
0x18,0x7D,0x11,0x37,0x93,0xBC,0xA5,0x1B,0x3F,0xFB,0x30,0x0E,0x06,0x03,0x55,0x1D,
0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,0x0C,0x06,0x03,0x55,0x1D,
0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,0x30,0x1D,0x06,0x03,0x55,0x1D,0x25,0x04,
0x16,0x30,0x14,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01,0x06,0x08,0x2B,
0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x4F,0x06,0x03,0x55,0x1D,0x20,0x04,0x48,
0x30,0x46,0x30,0x3A,0x06,0x0B,0x2B,0x06,0x01,0x04,0x01,0xB2,0x31,0x01,0x02,0x02,
0x07,0x30,0x2B,0x30,0x29,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x01,0x16,
0x1D,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x73,0x65,0x63,0x75,0x72,0x65,0x2E,
0x63,0x6F,0x6D,0x6F,0x64,0x6F,0x2E,0x63,0x6F,0x6D,0x2F,0x43,0x50,0x53,0x30,0x08,
0x06,0x06,0x67,0x81,0x0C,0x01,0x02,0x01,0x30,0x54,0x06,0x03,0x55,0x1D,0x1F,0x04,
0x4D,0x30,0x4B,0x30,0x49,0xA0,0x47,0xA0,0x45,0x86,0x43,0x68,0x74,0x74,0x70,0x3A,
0x2F,0x2F,0x63,0x72,0x6C,0x2E,0x63,0x6F,0x6D,0x6F,0x64,0x6F,0x63,0x61,0x2E,0x63,
0x6F,0x6D,0x2F,0x43,0x4F,0x4D,0x4F,0x44,0x4F,0x52,0x53,0x41,0x44,0x6F,0x6D,0x61,
0x69,0x6E,0x56,0x61,0x6C,0x69,0x64,0x61,0x74,0x69,0x6F,0x6E,0x53,0x65,0x63,0x75,
0x72,0x65,0x53,0x65,0x72,0x76,0x65,0x72,0x43,0x41,0x2E,0x63,0x72,0x6C,0x30,0x81,
0x85,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x01,0x04,0x79,0x30,0x77,0x30,
0x4F,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x02,0x86,0x43,0x68,0x74,0x74,
0x70,0x3A,0x2F,0x2F,0x63,0x72,0x74,0x2E,0x63,0x6F,0x6D,0x6F,0x64,0x6F,0x63,0x61,
0x2E,0x63,0x6F,0x6D,0x2F,0x43,0x4F,0x4D,0x4F,0x44,0x4F,0x52,0x53,0x41,0x44,0x6F,
0x6D,0x61,0x69,0x6E,0x56,0x61,0x6C,0x69,0x64,0x61,0x74,0x69,0x6F,0x6E,0x53,0x65,
0x63,0x75,0x72,0x65,0x53,0x65,0x72,0x76,0x65,0x72,0x43,0x41,0x2E,0x63,0x72,0x74,
0x30,0x24,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x86,0x18,0x68,0x74,
0x74,0x70,0x3A,0x2F,0x2F,0x6F,0x63,0x73,0x70,0x2E,0x63,0x6F,0x6D,0x6F,0x64,0x6F,
0x63,0x61,0x2E,0x63,0x6F,0x6D,0x30,0x23,0x06,0x03,0x55,0x1D,0x11,0x04,0x1C,0x30,
0x1A,0x82,0x0C,0x2A,0x2E,0x62,0x61,0x64,0x73,0x73,0x6C,0x2E,0x63,0x6F,0x6D,0x82,
0x0A,0x62,0x61,0x64,0x73,0x73,0x6C,0x2E,0x63,0x6F,0x6D,0x30,0x0D,0x06,0x09,0x2A,
0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x75,
0x48,0x83,0x88,0x9C,0x55,0x24,0x37,0x30,0x07,0xEB,0x26,0x68,0xC8,0x79,0x1C,0x5C,
0xAE,0x9A,0x02,0x9A,0xB5,0x52,0x75,0x44,0xAC,0xA9,0xED,0x59,0x65,0xD0,0xC6,0x47,
0x26,0x04,0x8D,0x57,0x89,0x16,0x2E,0x71,0x18,0x48,0x98,0x68,0x1C,0xF6,0x31,0xF5,
0x26,0x4B,0xE8,0x81,0x44,0xB1,0xFF,0x5C,0x65,0x3D,0x78,0x54,0x94,0xC3,0x86,0x9D,
0x48,0x96,0xE8,0x32,0xAF,0xE1,0x8F,0x94,0x47,0xBE,0x37,0x8C,0xC3,0xED,0x4D,0x97,
0xBB,0xC6,0x2A,0x37,0x72,0x01,0x3A,0x8F,0x82,0xA4,0x34,0x44,0xC4,0xC4,0xF8,0x50,
0x24,0x48,0x9E,0x19,0xF0,0xEC,0xE1,0xC6,0x13,0x44,0x26,0xB6,0x65,0xE1,0x62,0x49,
0x87,0xA4,0xF4,0xD8,0xC4,0x39,0x3C,0x7D,0x42,0xC8,0xA4,0x2A,0x54,0x05,0xA0,0xDC,
0x0A,0xF8,0x2B,0x22,0x94,0x93,0x78,0x4E,0x6A,0x36,0x1B,0xD2,0xE7,0xE9,0xAE,0x84,
0xED,0x13,0x1D,0xA1,0xF7,0xA2,0x83,0x81,0x03,0x4C,0x9E,0x21,0xFB,0xBF,0xA8,0x30,
0xFE,0xEB,0x00,0x68,0xB1,0x7F,0xBA,0x5D,0xE2,0x5D,0xFF,0x41,0x1F,0xD6,0xF5,0xA6,
0x5C,0x8A,0xEF,0x81,0x80,0xC8,0xF1,0x52,0x00,0x17,0x9D,0xD1,0x96,0x1A,0x7D,0x5E,
0xD2,0x83,0xB3,0x82,0xC2,0x3D,0x46,0x83,0xA5,0x1E,0xB4,0x36,0x35,0x38,0xC4,0x7A,
0x2E,0xDF,0x0B,0xA1,0x98,0x63,0x58,0x0B,0x1E,0xD0,0x6D,0x83,0x1F,0xF1,0x72,0x4D,
0x09,0xAC,0x96,0x1A,0x0B,0xE5,0xF6,0x34,0x4C,0xAB,0xBC,0xBC,0x99,0x5B,0x82,0x59,
0xE6,0x6C,0xD3,0xDB,0x98,0xE0,0xCE,0x95,0x3B,0xCF,0x4E,0x17,0xC3,0xEE,0x3A,
};
/* subject:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA */
/* issuer :/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Certification Authority */
uint8_t _int2048SystemTrust[] = {
0x30,0x82,0x06,0x08,0x30,0x82,0x03,0xF0,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x2B,
0x2E,0x6E,0xEA,0xD9,0x75,0x36,0x6C,0x14,0x8A,0x6E,0xDB,0xA3,0x7C,0x8C,0x07,0x30,
0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0C,0x05,0x00,0x30,0x81,
0x85,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x47,0x42,0x31,0x1B,
0x30,0x19,0x06,0x03,0x55,0x04,0x08,0x13,0x12,0x47,0x72,0x65,0x61,0x74,0x65,0x72,
0x20,0x4D,0x61,0x6E,0x63,0x68,0x65,0x73,0x74,0x65,0x72,0x31,0x10,0x30,0x0E,0x06,
0x03,0x55,0x04,0x07,0x13,0x07,0x53,0x61,0x6C,0x66,0x6F,0x72,0x64,0x31,0x1A,0x30,
0x18,0x06,0x03,0x55,0x04,0x0A,0x13,0x11,0x43,0x4F,0x4D,0x4F,0x44,0x4F,0x20,0x43,
0x41,0x20,0x4C,0x69,0x6D,0x69,0x74,0x65,0x64,0x31,0x2B,0x30,0x29,0x06,0x03,0x55,
0x04,0x03,0x13,0x22,0x43,0x4F,0x4D,0x4F,0x44,0x4F,0x20,0x52,0x53,0x41,0x20,0x43,
0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,
0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x1E,0x17,0x0D,0x31,0x34,0x30,0x32,0x31,0x32,
0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x32,0x39,0x30,0x32,0x31,0x31,0x32,
0x33,0x35,0x39,0x35,0x39,0x5A,0x30,0x81,0x90,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,
0x04,0x06,0x13,0x02,0x47,0x42,0x31,0x1B,0x30,0x19,0x06,0x03,0x55,0x04,0x08,0x13,
0x12,0x47,0x72,0x65,0x61,0x74,0x65,0x72,0x20,0x4D,0x61,0x6E,0x63,0x68,0x65,0x73,
0x74,0x65,0x72,0x31,0x10,0x30,0x0E,0x06,0x03,0x55,0x04,0x07,0x13,0x07,0x53,0x61,
0x6C,0x66,0x6F,0x72,0x64,0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x0A,0x13,0x11,
0x43,0x4F,0x4D,0x4F,0x44,0x4F,0x20,0x43,0x41,0x20,0x4C,0x69,0x6D,0x69,0x74,0x65,
0x64,0x31,0x36,0x30,0x34,0x06,0x03,0x55,0x04,0x03,0x13,0x2D,0x43,0x4F,0x4D,0x4F,
0x44,0x4F,0x20,0x52,0x53,0x41,0x20,0x44,0x6F,0x6D,0x61,0x69,0x6E,0x20,0x56,0x61,
0x6C,0x69,0x64,0x61,0x74,0x69,0x6F,0x6E,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,
0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x41,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,
0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,
0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0x8E,0xC2,0x02,0x19,0xE1,0xA0,
0x59,0xA4,0xEB,0x38,0x35,0x8D,0x2C,0xFD,0x01,0xD0,0xD3,0x49,0xC0,0x64,0xC7,0x0B,
0x62,0x05,0x45,0x16,0x3A,0xA8,0xA0,0xC0,0x0C,0x02,0x7F,0x1D,0xCC,0xDB,0xC4,0xA1,
0x6D,0x77,0x03,0xA3,0x0F,0x86,0xF9,0xE3,0x06,0x9C,0x3E,0x0B,0x81,0x8A,0x9B,0x49,
0x1B,0xAD,0x03,0xBE,0xFA,0x4B,0xDB,0x8C,0x20,0xED,0xD5,0xCE,0x5E,0x65,0x8E,0x3E,
0x0D,0xAF,0x4C,0xC2,0xB0,0xB7,0x45,0x5E,0x52,0x2F,0x34,0xDE,0x48,0x24,0x64,0xB4,
0x41,0xAE,0x00,0x97,0xF7,0xBE,0x67,0xDE,0x9E,0xD0,0x7A,0xA7,0x53,0x80,0x3B,0x7C,
0xAD,0xF5,0x96,0x55,0x6F,0x97,0x47,0x0A,0x7C,0x85,0x8B,0x22,0x97,0x8D,0xB3,0x84,
0xE0,0x96,0x57,0xD0,0x70,0x18,0x60,0x96,0x8F,0xEE,0x2D,0x07,0x93,0x9D,0xA1,0xBA,
0xCA,0xD1,0xCD,0x7B,0xE9,0xC4,0x2A,0x9A,0x28,0x21,0x91,0x4D,0x6F,0x92,0x4F,0x25,
0xA5,0xF2,0x7A,0x35,0xDD,0x26,0xDC,0x46,0xA5,0xD0,0xAC,0x59,0x35,0x8C,0xFF,0x4E,
0x91,0x43,0x50,0x3F,0x59,0x93,0x1E,0x6C,0x51,0x21,0xEE,0x58,0x14,0xAB,0xFE,0x75,
0x50,0x78,0x3E,0x4C,0xB0,0x1C,0x86,0x13,0xFA,0x6B,0x98,0xBC,0xE0,0x3B,0x94,0x1E,
0x85,0x52,0xDC,0x03,0x93,0x24,0x18,0x6E,0xCB,0x27,0x51,0x45,0xE6,0x70,0xDE,0x25,
0x43,0xA4,0x0D,0xE1,0x4A,0xA5,0xED,0xB6,0x7E,0xC8,0xCD,0x6D,0xEE,0x2E,0x1D,0x27,
0x73,0x5D,0xDC,0x45,0x30,0x80,0xAA,0xE3,0xB2,0x41,0x0B,0xAF,0xBD,0x44,0x87,0xDA,
0xB9,0xE5,0x1B,0x9D,0x7F,0xAE,0xE5,0x85,0x82,0xA5,0x02,0x03,0x01,0x00,0x01,0xA3,
0x82,0x01,0x65,0x30,0x82,0x01,0x61,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,
0x30,0x16,0x80,0x14,0xBB,0xAF,0x7E,0x02,0x3D,0xFA,0xA6,0xF1,0x3C,0x84,0x8E,0xAD,
0xEE,0x38,0x98,0xEC,0xD9,0x32,0x32,0xD4,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,
0x16,0x04,0x14,0x90,0xAF,0x6A,0x3A,0x94,0x5A,0x0B,0xD8,0x90,0xEA,0x12,0x56,0x73,
0xDF,0x43,0xB4,0x3A,0x28,0xDA,0xE7,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,
0xFF,0x04,0x04,0x03,0x02,0x01,0x86,0x30,0x12,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,
0xFF,0x04,0x08,0x30,0x06,0x01,0x01,0xFF,0x02,0x01,0x00,0x30,0x1D,0x06,0x03,0x55,
0x1D,0x25,0x04,0x16,0x30,0x14,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01,
0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x1B,0x06,0x03,0x55,0x1D,
0x20,0x04,0x14,0x30,0x12,0x30,0x06,0x06,0x04,0x55,0x1D,0x20,0x00,0x30,0x08,0x06,
0x06,0x67,0x81,0x0C,0x01,0x02,0x01,0x30,0x4C,0x06,0x03,0x55,0x1D,0x1F,0x04,0x45,
0x30,0x43,0x30,0x41,0xA0,0x3F,0xA0,0x3D,0x86,0x3B,0x68,0x74,0x74,0x70,0x3A,0x2F,
0x2F,0x63,0x72,0x6C,0x2E,0x63,0x6F,0x6D,0x6F,0x64,0x6F,0x63,0x61,0x2E,0x63,0x6F,
0x6D,0x2F,0x43,0x4F,0x4D,0x4F,0x44,0x4F,0x52,0x53,0x41,0x43,0x65,0x72,0x74,0x69,
0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,
0x79,0x2E,0x63,0x72,0x6C,0x30,0x71,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x01,
0x01,0x04,0x65,0x30,0x63,0x30,0x3B,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x30,
0x02,0x86,0x2F,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x63,0x72,0x74,0x2E,0x63,0x6F,
0x6D,0x6F,0x64,0x6F,0x63,0x61,0x2E,0x63,0x6F,0x6D,0x2F,0x43,0x4F,0x4D,0x4F,0x44,
0x4F,0x52,0x53,0x41,0x41,0x64,0x64,0x54,0x72,0x75,0x73,0x74,0x43,0x41,0x2E,0x63,
0x72,0x74,0x30,0x24,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x86,0x18,
0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x6F,0x63,0x73,0x70,0x2E,0x63,0x6F,0x6D,0x6F,
0x64,0x6F,0x63,0x61,0x2E,0x63,0x6F,0x6D,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
0xF7,0x0D,0x01,0x01,0x0C,0x05,0x00,0x03,0x82,0x02,0x01,0x00,0x4E,0x2B,0x76,0x4F,
0x92,0x1C,0x62,0x36,0x89,0xBA,0x77,0xC1,0x27,0x05,0xF4,0x1C,0xD6,0x44,0x9D,0xA9,
0x9A,0x3E,0xAA,0xD5,0x66,0x66,0x01,0x3E,0xEA,0x49,0xE6,0xA2,0x35,0xBC,0xFA,0xF6,
0xDD,0x95,0x8E,0x99,0x35,0x98,0x0E,0x36,0x18,0x75,0xB1,0xDD,0xDD,0x50,0x72,0x7C,
0xAE,0xDC,0x77,0x88,0xCE,0x0F,0xF7,0x90,0x20,0xCA,0xA3,0x67,0x2E,0x1F,0x56,0x7F,
0x7B,0xE1,0x44,0xEA,0x42,0x95,0xC4,0x5D,0x0D,0x01,0x50,0x46,0x15,0xF2,0x81,0x89,
0x59,0x6C,0x8A,0xDD,0x8C,0xF1,0x12,0xA1,0x8D,0x3A,0x42,0x8A,0x98,0xF8,0x4B,0x34,
0x7B,0x27,0x3B,0x08,0xB4,0x6F,0x24,0x3B,0x72,0x9D,0x63,0x74,0x58,0x3C,0x1A,0x6C,
0x3F,0x4F,0xC7,0x11,0x9A,0xC8,0xA8,0xF5,0xB5,0x37,0xEF,0x10,0x45,0xC6,0x6C,0xD9,
0xE0,0x5E,0x95,0x26,0xB3,0xEB,0xAD,0xA3,0xB9,0xEE,0x7F,0x0C,0x9A,0x66,0x35,0x73,
0x32,0x60,0x4E,0xE5,0xDD,0x8A,0x61,0x2C,0x6E,0x52,0x11,0x77,0x68,0x96,0xD3,0x18,
0x75,0x51,0x15,0x00,0x1B,0x74,0x88,0xDD,0xE1,0xC7,0x38,0x04,0x43,0x28,0xE9,0x16,
0xFD,0xD9,0x05,0xD4,0x5D,0x47,0x27,0x60,0xD6,0xFB,0x38,0x3B,0x6C,0x72,0xA2,0x94,
0xF8,0x42,0x1A,0xDF,0xED,0x6F,0x06,0x8C,0x45,0xC2,0x06,0x00,0xAA,0xE4,0xE8,0xDC,
0xD9,0xB5,0xE1,0x73,0x78,0xEC,0xF6,0x23,0xDC,0xD1,0xDD,0x6C,0x8E,0x1A,0x8F,0xA5,
0xEA,0x54,0x7C,0x96,0xB7,0xC3,0xFE,0x55,0x8E,0x8D,0x49,0x5E,0xFC,0x64,0xBB,0xCF,
0x3E,0xBD,0x96,0xEB,0x69,0xCD,0xBF,0xE0,0x48,0xF1,0x62,0x82,0x10,0xE5,0x0C,0x46,
0x57,0xF2,0x33,0xDA,0xD0,0xC8,0x63,0xED,0xC6,0x1F,0x94,0x05,0x96,0x4A,0x1A,0x91,
0xD1,0xF7,0xEB,0xCF,0x8F,0x52,0xAE,0x0D,0x08,0xD9,0x3E,0xA8,0xA0,0x51,0xE9,0xC1,
0x87,0x74,0xD5,0xC9,0xF7,0x74,0xAB,0x2E,0x53,0xFB,0xBB,0x7A,0xFB,0x97,0xE2,0xF8,
0x1F,0x26,0x8F,0xB3,0xD2,0xA0,0xE0,0x37,0x5B,0x28,0x3B,0x31,0xE5,0x0E,0x57,0x2D,
0x5A,0xB8,0xAD,0x79,0xAC,0x5E,0x20,0x66,0x1A,0xA5,0xB9,0xA6,0xB5,0x39,0xC1,0xF5,
0x98,0x43,0xFF,0xEE,0xF9,0xA7,0xA7,0xFD,0xEE,0xCA,0x24,0x3D,0x80,0x16,0xC4,0x17,
0x8F,0x8A,0xC1,0x60,0xA1,0x0C,0xAE,0x5B,0x43,0x47,0x91,0x4B,0xD5,0x9A,0x17,0x5F,
0xF9,0xD4,0x87,0xC1,0xC2,0x8C,0xB7,0xE7,0xE2,0x0F,0x30,0x19,0x37,0x86,0xAC,0xE0,
0xDC,0x42,0x03,0xE6,0x94,0xA8,0x9D,0xAE,0xFD,0x0F,0x24,0x51,0x94,0xCE,0x92,0x08,
0xD1,0xFC,0x50,0xF0,0x03,0x40,0x7B,0x88,0x59,0xED,0x0E,0xDD,0xAC,0xD2,0x77,0x82,
0x34,0xDC,0x06,0x95,0x02,0xD8,0x90,0xF9,0x2D,0xEA,0x37,0xD5,0x1A,0x60,0xD0,0x67,
0x20,0xD7,0xD8,0x42,0x0B,0x45,0xAF,0x82,0x68,0xDE,0xDD,0x66,0x24,0x37,0x90,0x29,
0x94,0x19,0x46,0x19,0x25,0xB8,0x80,0xD7,0xCB,0xD4,0x86,0x28,0x6A,0x44,0x70,0x26,
0x23,0x62,0xA9,0x9F,0x86,0x6F,0xBF,0xBA,0x90,0x70,0xD2,0x56,0x77,0x85,0x78,0xEF,
0xEA,0x25,0xA9,0x17,0xCE,0x50,0x72,0x8C,0x00,0x3A,0xAA,0xE3,0xDB,0x63,0x34,0x9F,
0xF8,0x06,0x71,0x01,0xE2,0x82,0x20,0xD4,0xFE,0x6F,0xBD,0xB1,
};
#endif /* _TRUSTTESTS_EVALUATION_KEY_SIZE_TESTS_H_ */
|
2ef5ee320036d15dc6718f11f8e2aee2ddd965e9
|
ca414d0345d2d1486da1126960a164a655965968
|
/src/sys/cpu_index.c
|
40db9ce642dc68f15ca592df5728d214279c679e
|
[] |
permissive
|
Menotdan/DripOS
|
6d2ee8fbd87145d789fbe5781e2f6ae825a5aba6
|
2a3110338e84a8a14f1e9217cea2082de888189c
|
refs/heads/dev
| 2023-07-20T01:50:26.166067
| 2023-05-26T02:59:52
| 2023-05-26T02:59:52
| 149,795,128
| 119
| 15
|
MIT
| 2020-03-26T20:43:19
| 2018-09-21T17:21:05
|
C
|
UTF-8
|
C
| false
| false
| 104
|
c
|
cpu_index.c
|
#include "cpu_index.h"
#include "smp.h"
int get_cpu_index() {
return get_cpu_locals()->cpu_index;
}
|
4dc475209d63ad21d9dbfb3074ca8636ae56eea9
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/usr.sbin/tcpdump/print-pflog.c
|
d8c0b824334caee1f0f8b9a775f6a0998f7fef6c
|
[] |
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,722
|
c
|
print-pflog.c
|
/* $OpenBSD: print-pflog.c,v 1.35 2022/02/22 17:35:01 deraadt Exp $ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 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.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
#ifndef NO_PID
#define NO_PID (99999+1)
#endif
#include <netinet/in.h>
#include <netinet/ip.h>
#include <net/if.h>
#include <net/pfvar.h>
#include <net/if_pflog.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
char *pf_reasons[PFRES_MAX+2] = PFRES_NAMES;
void
pflog_if_print(u_char *user, const struct pcap_pkthdr *h,
const u_char *p)
{
u_int length = h->len;
u_int hdrlen;
u_int caplen = h->caplen;
const struct ip *ip;
const struct ip6_hdr *ip6;
const struct pfloghdr *hdr;
ts_print(&h->ts);
/* check length */
if (caplen < sizeof(u_int8_t)) {
printf("[|pflog]");
goto out;
}
#define MIN_PFLOG_HDRLEN 45
hdr = (struct pfloghdr *)p;
if (hdr->length < MIN_PFLOG_HDRLEN) {
printf("[pflog: invalid header length!]");
goto out;
}
hdrlen = (hdr->length + 3) & 0xfc;
if (caplen < hdrlen) {
printf("[|pflog]");
goto out;
}
/*
* Some printers want to get back at the link level addresses,
* and/or check that they're not walking off the end of the packet.
* Rather than pass them all the way down, we set these globals.
*/
packetp = p;
snapend = p + caplen;
hdr = (struct pfloghdr *)p;
if (eflag) {
printf("rule ");
if (ntohl(hdr->rulenr) == (u_int32_t) -1)
printf("def");
else {
printf("%u", ntohl(hdr->rulenr));
if (hdr->ruleset[0]) {
printf(".%s", hdr->ruleset);
if (ntohl(hdr->subrulenr) == (u_int32_t) -1)
printf(".def");
else
printf(".%u", ntohl(hdr->subrulenr));
}
}
if (hdr->reason < PFRES_MAX)
printf("/(%s) ", pf_reasons[hdr->reason]);
else
printf("/(unkn %u) ", (unsigned)hdr->reason);
if (vflag)
printf("[uid %u, pid %u] ", (unsigned)hdr->rule_uid,
(unsigned)hdr->rule_pid);
switch (hdr->action) {
case PF_MATCH:
printf("match");
break;
case PF_SCRUB:
printf("scrub");
break;
case PF_PASS:
printf("pass");
break;
case PF_DROP:
printf("block");
break;
case PF_NAT:
case PF_NONAT:
printf("nat");
break;
case PF_BINAT:
case PF_NOBINAT:
printf("binat");
break;
case PF_RDR:
case PF_NORDR:
printf("rdr");
break;
}
printf(" %s on %s: ",
hdr->dir == PF_OUT ? "out" : "in",
hdr->ifname);
if (vflag && hdr->pid != NO_PID)
printf("[uid %u, pid %u] ", (unsigned)hdr->uid,
(unsigned)hdr->pid);
if (vflag && hdr->rewritten) {
char buf[48];
printf("[rewritten: ");
if (inet_ntop(hdr->naf, &hdr->saddr, buf,
sizeof(buf)) == NULL)
printf("src ?");
else
printf("src %s:%u", buf, ntohs(hdr->sport));
printf(", ");
if (inet_ntop(hdr->naf, &hdr->daddr, buf,
sizeof(buf)) == NULL)
printf("dst ?");
else
printf("dst %s:%u", buf, ntohs(hdr->dport));
printf("] ");
}
}
length -= hdrlen;
switch(hdr->af) {
case AF_INET:
ip = (struct ip *)(p + hdrlen);
ip_print((const u_char *)ip, length);
if (xflag)
default_print((const u_char *)ip,
caplen - hdrlen);
break;
case AF_INET6:
ip6 = (struct ip6_hdr *)(p + hdrlen);
ip6_print((const u_char *)ip6, length);
if (xflag)
default_print((const u_char *)ip6,
caplen - hdrlen);
break;
default:
printf("unknown-af %d", hdr->af);
break;
}
out:
putchar('\n');
}
|
6310be1356d47bfdee69ce89d7034670e2fbf415
|
bf29e10264b10d4b1846f6eb2505f4980bb6c69e
|
/edk2-rockchip/Silicon/Rockchip/Rk356x/Drivers/DisplayDxe/Vop2.c
|
c8a94a65a746e08ea1f7bd9adf7a091df959baa8
|
[] |
no_license
|
jaredmcneill/quartz64_uefi
|
580527186654bb81e0d831234a716c18988ac46a
|
b6eb13d46bf9b9c5cf2d98f153cf27da50355363
|
refs/heads/main
| 2023-07-07T23:11:08.530886
| 2023-06-02T08:55:32
| 2023-06-02T08:55:32
| 432,544,722
| 110
| 53
| null | 2023-09-03T10:48:27
| 2021-11-27T19:07:03
|
C
|
UTF-8
|
C
| false
| false
| 6,374
|
c
|
Vop2.c
|
/** @file
*
* Copyright (c) 2021, Jared McNeill <jmcneill@invisible.ca>
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/
#include <Base.h>
#include "DisplayDxe.h"
#include <IndustryStandard/Rk356x.h>
#include <IndustryStandard/Rk356xVop2.h>
#include <Library/CruLib.h>
#include "Vop2.h"
#include "DwHdmi.h"
STATIC BOOLEAN mVop2Initialized = FALSE;
STATIC HDMI_DISPLAY_TIMING *mCurrentTimings;
STATIC
VOID
Vop2DebugDumpFrame (
const char *Name,
UINTN Start,
UINTN End
)
{
UINTN Reg;
DEBUG ((DEBUG_INFO, " --- %a: ---\n", Name));
for (Reg = Start; Reg < End; Reg += (4 * 8)) {
DEBUG ((DEBUG_INFO, " %08X: %08X %08X %08X %08X %08X %08X %08X %08X\n",
Reg,
MmioRead32 (Reg + 0), MmioRead32 (Reg + 4), MmioRead32 (Reg + 8), MmioRead32 (Reg + 12),
MmioRead32 (Reg + 16), MmioRead32 (Reg + 20), MmioRead32 (Reg + 24), MmioRead32 (Reg + 28)
));
}
}
STATIC
VOID
Vop2DebugDump (
VOID
)
{
Vop2DebugDumpFrame ("SYSREG ", VOP2_SYSREG_BASE, VOP2_SYSREG_BASE + 0x100);
Vop2DebugDumpFrame ("OVERLAY", VOP2_OVERLAY_BASE, VOP2_OVERLAY_BASE + 0x100);
Vop2DebugDumpFrame ("POST0", VOP2_POSTn_BASE (0), VOP2_POSTn_BASE (0) + 0x100);
Vop2DebugDumpFrame ("ESMART0", VOP2_ESMARTn_BASE (0), VOP2_ESMARTn_BASE (0) + 0x100);
}
STATIC
VOID
Vop2Initialize (
VOID
)
{
DEBUG ((DEBUG_INFO, "Vop2Initialize() called\n"));
MmioOr32 (VOP2_SYS_OTP_WIN_EN_IMD, VOP2_SYS_OTP_WIN_EN_IMD_OTP_EN);
MmioOr32 (VOP2_OVERLAY_CTRL, VOP2_OVERLAY_CTRL_LAYER_SEL_REGDONE_IMD);
MmioOr32 (VOP2_SYS_DSP_INFACE_POL, VOP2_SYS_DSP_INFACE_POL_REGDONE_IMD_EN);
#if 0
MmioWrite32 (VOP2_LAYER_SEL, 0x00000002); /* layer0_sel = esmart0 */
MmioAndThenOr32 (VOP2_PORT_SEL, ~0xFFF, 0x80); /* port_mux = 1 layer */
#else
MmioWrite32 (VOP2_LAYER_SEL, 0x00107632);
MmioAndThenOr32 (VOP2_PORT_SEL, ~0xFFF, 0x085);
#endif
MmioWrite32 (VOP2_SYS_AUTO_GATING_CTRL_IMD, 0);
}
VOID
Vop2SetMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode
)
{
UINT32 Val;
UINT32 HSyncLen, HActSt, HActEnd, HBackPorch;
UINT32 VSyncLen, VActSt, VActEnd, VBackPorch;
UINTN Rate;
mCurrentTimings = &mPreferredTimings;
ASSERT (mCurrentTimings != NULL);
ASSERT (Mode->Info->HorizontalResolution == mCurrentTimings->HDisplay);
ASSERT (Mode->Info->VerticalResolution == mCurrentTimings->VDisplay);
ASSERT (Mode->FrameBufferBase != 0 && Mode->FrameBufferBase < SIZE_4GB);
if (!mVop2Initialized) {
Vop2Initialize ();
mVop2Initialized = TRUE;
}
CruSetHdmiClockRate (mCurrentTimings->FrequencyKHz * 1000);
gBS->Stall (100000); // XXX wait for lock
Rate = CruGetHdmiClockRate ();
DEBUG ((DEBUG_INFO, "Vop2SetMode(): HPLL rate %u Hz\n", Rate));
/* Enable HDMI interface */
MmioOr32 (VOP2_SYS_DSP_INFACE_EN, VOP2_SYS_DSP_INFACE_EN_HDMI_OUT_EN);
Val = MmioRead32 (VOP2_SYS_DSP_INFACE_POL);
Val |= VOP2_SYS_DSP_INFACE_POL_REGDONE_IMD_EN;
Val |= VOP2_SYS_DSP_INFACE_POL_HDMI_DCLK_POL;
Val &= ~(VOP2_SYS_DSP_INFACE_POL_HDMI_VSYNC_POL|VOP2_SYS_DSP_INFACE_POL_HDMI_HSYNC_POL|VOP2_SYS_DSP_INFACE_POL_HDMI_DEN_POL);
if (mCurrentTimings->VSyncPol) {
Val |= VOP2_SYS_DSP_INFACE_POL_HDMI_VSYNC_POL;
}
if (mCurrentTimings->HSyncPol) {
Val |= VOP2_SYS_DSP_INFACE_POL_HDMI_HSYNC_POL;
}
MmioWrite32 (VOP2_SYS_DSP_INFACE_POL, Val);
/* Setup post-process timings */
HSyncLen = mCurrentTimings->HSyncEnd - mCurrentTimings->HSyncStart;
HBackPorch = mCurrentTimings->HTotal - mCurrentTimings->HSyncEnd;
HActSt = mCurrentTimings->HTotal - mCurrentTimings->HSyncStart;
HActEnd = HActSt + mCurrentTimings->HDisplay;
VSyncLen = mCurrentTimings->VSyncEnd - mCurrentTimings->VSyncStart;
VBackPorch = mCurrentTimings->VTotal - mCurrentTimings->VSyncEnd;
VActSt = mCurrentTimings->VTotal - mCurrentTimings->VSyncStart;
VActEnd = VActSt + mCurrentTimings->VDisplay;
MmioWrite32 (VOP2_POSTn_DSP_BG (0), 0x1FF);
MmioWrite32 (VOP2_POSTn_PRE_SCAN_HTIMING (0), ((42 + (mCurrentTimings->HDisplay >> 1) - 1) << 16) | HSyncLen);
MmioWrite32 (VOP2_POSTn_DSP_HACT_INFO (0), (HActSt << 16) | HActEnd);
MmioWrite32 (VOP2_POSTn_DSP_VACT_INFO (0), (VActSt << 16) | VActEnd);
MmioWrite32 (VOP2_POSTn_SCL_FACTOR_YRGB (0), 0x10001000); /* No scaling */
MmioWrite32 (VOP2_POSTn_DSP_HTOTAL_HS_END (0), (mCurrentTimings->HTotal << 16) | HSyncLen);
MmioWrite32 (VOP2_POSTn_DSP_HACT_ST_END (0), (HActSt << 16) | HActEnd);
MmioWrite32 (VOP2_POSTn_DSP_VTOTAL_VS_END (0), (mCurrentTimings->VTotal << 16) | VSyncLen);
MmioWrite32 (VOP2_POSTn_DSP_VACT_ST_END (0), (VActSt << 16) | VActEnd);
MmioAndThenOr32 (VOP2_DPn_BG_MIX_CTRL (0),
~VOP2_DPn_BG_MIX_CTRL_DP_BG_DLY_NUM_MASK,
42 << VOP2_DPn_BG_MIX_CTRL_DP_BG_DLY_NUM_SHIFT);
/* Setup layer */
MmioWrite32 (VOP2_ESMART_CTRL0 (0), BIT0);
MmioWrite32 (VOP2_ESMART_REGION0_VIR (0), Mode->Info->HorizontalResolution);
MmioWrite32 (VOP2_ESMART_REGION0_MST_YRGB (0), (UINT32)Mode->FrameBufferBase);
MmioWrite32 (VOP2_ESMART_REGION0_ACT_INFO (0), ((mCurrentTimings->VDisplay - 1) << 16) | (mCurrentTimings->HDisplay - 1));
MmioWrite32 (VOP2_ESMART_REGION0_DSP_INFO (0), ((mCurrentTimings->VDisplay - 1) << 16) | (mCurrentTimings->HDisplay - 1));
MmioWrite32 (VOP2_ESMART_REGION0_DSP_OFFSET (0), 0);
MmioAndThenOr32 (VOP2_ESMART_REGION0_MST_CTL (0),
~VOP2_ESMART_REGION0_MST_CTL_DATA_FMT_MASK,
VOP2_ESMART_REGION0_MST_CTL_DATA_FMT_ARGB8888 | VOP2_ESMART_REGION0_MST_CTL_MST_ENABLE);
/* Set output mode and enable */
Val = MmioRead32 (VOP2_POSTn_DSP_CTRL (0));
Val &= ~VOP2_POSTn_DSP_CTRL_DSP_OUT_MODE;
Val |= VOP2_POSTn_DSP_CTRL_DSP_OUT_MODE_30BIT;
// Val |= VOP2_POSTn_DSP_CTRL_DSP_OUT_MODE_24BIT;
Val &= ~VOP2_POSTn_DSP_CTRL_VOP_STANDBY_EN_IMD;
MmioWrite32 (VOP2_POSTn_DSP_CTRL (0), Val);
/* XXX color bars */
// MmioWrite32 (VOP2_POSTn_COLOR_CTRL (0), 1);
/* Commit settings */
MmioWrite32 (VOP2_SYS_REG_CFG_DONE,
VOP2_SYS_REG_CFG_DONE_SW_GLOBAL_REGDONE_EN |
VOP2_SYS_REG_CFG_DONE_REG_LOAD_GLOBAL0_EN);
/* Dump registers */
Vop2DebugDump ();
}
|
28314c05e2df1610eda8b9f15d171efd7cb20409
|
f9e7d65cb784c01a0200145ba8d289afe41d4a56
|
/board/karma/board.c
|
7bac35bd64bce5aa2ac40b9db8f3d78e9aff309c
|
[
"BSD-3-Clause"
] |
permissive
|
FrameworkComputer/EmbeddedController
|
ad7086769e87d0a4179eae96a7c9ff5e383ff54e
|
f6d6b927eed71550d3475411cfc3e59abe5cef2a
|
refs/heads/hx20-hx30
| 2023-08-08T20:45:10.621169
| 2023-05-26T07:03:59
| 2023-05-26T07:03:59
| 447,021,040
| 846
| 48
|
BSD-3-Clause
| 2023-05-26T07:04:59
| 2022-01-12T00:11:14
|
C
|
UTF-8
|
C
| false
| false
| 1,065
|
c
|
board.c
|
/* Copyright 2019 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "console.h"
#include "gpio.h"
#include "oz554.h"
#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args)
__override void oz554_board_init(void)
{
int pin_status = 0;
pin_status |= gpio_get_level(GPIO_PANEL_ID_0) << 0;
pin_status |= gpio_get_level(GPIO_PANEL_ID_1) << 1;
pin_status |= gpio_get_level(GPIO_PANEL_ID_2) << 2;
switch (pin_status) {
case 0x04:
CPRINTS("PANEL_LM_SSE2");
break;
case 0x05:
CPRINTS("PANEL_LM_SSK1");
/* Reigster 0x02: Setting LED current: 55(mA) */
if (oz554_set_config(2, 0x55))
CPRINTS("oz554 config failed");
break;
case 0x06:
CPRINTS("PANEL_LM_SSM1");
if (oz554_set_config(2, 0x46))
CPRINTS("oz554 config failed");
if (oz554_set_config(5, 0x87))
CPRINTS("oz554 config failed");
break;
default:
CPRINTS("PANEL_UNKNOWN");
break;
}
}
|
abf37ce393eec71ea3f014abfbc054fa5f1c951e
|
14ed2724b7c610543959f23d401e7b90283e63c4
|
/Source/dprocess.h
|
a16158290070d0909259a58e6ab45567a45d1cca
|
[
"MIT"
] |
permissive
|
powervr-graphics/PowerVR-Series1
|
d0ec36623d257e05c078e5d3f4bdfcd786ba46a4
|
c8c11cbe29c5b758ed1ef9600fc8614fc8da618e
|
refs/heads/main
| 2023-08-14T18:42:40.609670
| 2022-03-23T10:29:37
| 2022-03-23T10:29:37
| 467,444,934
| 260
| 17
| null | null | null | null |
UTF-8
|
C
| false
| false
| 35,921
|
h
|
dprocess.h
|
/******************************************************************************
* Name : dprocess.h
* Title : Low level API top level code for PowerVR
* Author : Graham Connor
* Created : 13/8/1997
*
* Copyright : 1995-2022 Imagination Technologies (c)
* License : MIT
*
* Description :
*
* Platform : ANSI
*
* Modifications:
* $Log: dprocess.h,v $
* Revision 1.14 1997/11/11 10:21:18 gdc
* made gouraud highlight white and changed its sape a bit
*
* Revision 1.13 1997/08/29 11:42:28 gdc
* fixed bug where wrong translucency level was being set
* and trans bits were overwriting the texture exponent
*
* Revision 1.12 1997/08/29 09:57:21 gdc
* removed ^M's and made sure vfog and smooth highlight indices are
* zeroed if not in use (and on or other feature is on)
*
* Revision 1.11 1997/08/27 15:48:43 ls
* Renamed IMPLEMENT_VERTEX_TRANS IMPLEMENT_AVG_VERTEX TRANS
* renamed IMPLEMENT_VERTEX_GLOBAL_TRANS IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
* introduced non-averaging vertex Alpha: uses 1st vertex Alpha only
* Any Process which uses Smooth or Flatten/Fltn uses the average vertex alpha
* otherwise use 1st vertex alpha
*
* Revision 1.10 1997/08/27 08:48:02 sks
* Added new functions for smooth specular highlights.
*
* Revision 1.9 1997/08/26 14:14:30 sks
* Removed stuff from FakeHighlight().
*
* Revision 1.8 1997/08/26 12:40:23 sks
* More work on FakeHighlight function
*
* Revision 1.7 1997/08/22 16:36:10 sks
* Started work on smooth highlights function: FakeHighlight().
*
* Revision 1.6 1997/08/22 10:36:39 gdc
* added other vertex fog routines for flat and avg flat, and a non functional
* stub for smooth highlights
*
* Revision 1.5 1997/08/19 14:38:32 gdc
* added average colour with veretx fog functions
*
* Revision 1.4 1997/08/19 11:50:41 gdc
* got sense of fog index right way around
*
* Revision 1.3 1997/08/18 16:26:31 gdc
* dummied up routines to test vertex fog
*
* Revision 1.2 1997/08/13 16:19:58 gdc
* added process functions for per vertex fogging
*
* Revision 1.1 1997/08/13 10:29:54 gdc
* Initial revision
*
*
*****************************************************************************/
/**********************************************************************/
/* these defines are ripped off from dshade.c */
#define READ_RBGS_VIA_BYTE_PTRS (HAS_FAST_BYTE_LOAD)
#if READ_RBGS_VIA_BYTE_PTRS
#if BIG_ENDIAN
#define R_BYTE_OFFSET 3
#define G_BYTE_OFFSET 2
#define B_BYTE_OFFSET 1
#else
#define R_BYTE_OFFSET 0
#define G_BYTE_OFFSET 1
#define B_BYTE_OFFSET 2
#endif
#define GET_R(UINT32_LOCATION) (((const sgl_uint8 *) & UINT32_LOCATION) [R_BYTE_OFFSET])
#define GET_G(UINT32_LOCATION) (((const sgl_uint8 *) & UINT32_LOCATION) [G_BYTE_OFFSET])
#define GET_B(UINT32_LOCATION) (((const sgl_uint8 *) & UINT32_LOCATION) [B_BYTE_OFFSET])
#else
#define GET_R(x) (((x) >> 16) & 0x000000FF)
#define GET_G(x) (((x) >> 8) & 0x000000FF)
#define GET_B(x) ((x) & 0x000000FF)
#endif
#define fIntensityScale (15.0f / (3.0f * 255.0f))
static int LookUp[16] = { 0x0, 0x0, 0x0, 0x0,
0x0, 0x1, 0x3, 0x5, 0x7, 0x9, 0xb, 0xd,
0xf, 0xf, 0xf, 0xf };
static sgl_uint32 FakeHighlight (PROCESSDATACONTEXT pPDC, sgl_uint32 *SpecularHighlightBaseColour)
{
sgl_uint32 RTotal, GTotal, BTotal;
sgl_uint V0Int, V1Int, V2Int;
sgl_uint nTmp;
float fLargest;
float fColourScale;
sgl_uint32 FinalColour;
sgl_uint32 Colour;
sgl_uint32 Index;
/*
// Extract each of the red green and blue components from each of the
// three vertex colours, and sum up the totals of the R,G,Bs PLUS the
// total of each component for the three verts, which will be used to
// compute an "intensity"
*/
#if READ_RBGS_VIA_BYTE_PTRS
/* Vertex 0 */
RTotal = GET_R(pPDC.pV0->u32Specular);
GTotal = GET_G(pPDC.pV0->u32Specular);
BTotal = GET_B(pPDC.pV0->u32Specular);
V0Int = RTotal + GTotal + BTotal;
/* Vertex 1 */
V1Int = GET_R(pPDC.pV1->u32Specular);
RTotal+= V1Int;
nTmp = GET_G(pPDC.pV1->u32Specular);
GTotal+= nTmp;
V1Int += nTmp;
nTmp = GET_B(pPDC.pV1->u32Specular);
BTotal+= nTmp;
V1Int += nTmp;
/* Vertex 2 */
V2Int = GET_R(pPDC.pV2->u32Specular);
RTotal+= V2Int;
nTmp = GET_G(pPDC.pV2->u32Specular);
GTotal+= nTmp;
V2Int += nTmp;
nTmp = GET_B(pPDC.pV2->u32Specular);
BTotal+= nTmp;
V2Int += nTmp;
#else
/* Vertex 0 */
Colour = pPDC.pV0->u32Specular;
RTotal = GET_R(Colour);
GTotal = GET_G(Colour);
BTotal = GET_B(Colour);
V0Int = RTotal + GTotal + BTotal;
/* Vertex 1 */
Colour = pPDC.pV1->u32Specular;
V1Int = GET_R(Colour);
RTotal+= V1Int;
nTmp = GET_G(Colour);
GTotal+= nTmp;
V1Int += nTmp;
nTmp = GET_B(Colour);
BTotal+= nTmp;
V1Int += nTmp;
/* Vertex 2 */
Colour = pPDC.pV2->u32Specular;
V2Int = GET_R(Colour);
RTotal+= V2Int;
nTmp = GET_G(Colour);
GTotal+= nTmp;
V2Int += nTmp;
nTmp = GET_B(Colour);
BTotal+= nTmp;
V2Int += nTmp;
#endif
#define COLOUR_HIGHLIGHT 0
#if COLOUR_HIGHLIGHT
if(RTotal > GTotal)
{
if(RTotal > BTotal)
{
fLargest = (float) RTotal;
}
else
{
fLargest = (float) BTotal;
}
}
else if(GTotal > BTotal)
{
fLargest = (float) GTotal;
}
else if(BTotal > 0)
{
fLargest = (float) BTotal;
}
/*
// Else the whole thing is black. Exit out now
*/
else
{
*SpecularHighlightBaseColour = 0;
return 0;
}
/* Calculate the base colour */
fColourScale = ((3.0f * 255.0f) / (fLargest));
RTotal = (sgl_uint32)( (float)(RTotal) * fColourScale );
GTotal = (sgl_uint32)( (float)(GTotal) * fColourScale );
BTotal = (sgl_uint32)( (float)(BTotal) * fColourScale );
FinalColour = ((RTotal & 0xff)<<16) | ((GTotal & 0xff)<<8) | (BTotal & 0xff);
*SpecularHighlightBaseColour = FinalColour;
#else
*SpecularHighlightBaseColour = 0x00ffffff;
#endif
/*
// Calculate the texture coordinates
*/
V0Int = (sgl_uint)( (float)(V0Int) * fIntensityScale );
V1Int = (sgl_uint)( (float)(V1Int) * fIntensityScale );
V2Int = (sgl_uint)( (float)(V2Int) * fIntensityScale );
Index = (LookUp[(V0Int & 0xf)] << 8) | (LookUp[(V1Int & 0xf)] << 4) |
LookUp[(V2Int & 0xf)] ;
return (Index);
}
/*
// ============================================================================
// PER POLYGON INTERMEDIATE ROUTINE MACROS AND GLOBALS
// ============================================================================
*/
/*
// Average flat shading parameters
//
// This is for when smooth shading is knocked of by translucency
// average the smooth colour into the base colour
//
// instead of doing the 1/3 in fp land, do it in integer
// land. 85/256 = 0.332. Save some shifts and go straight
// to the correct bit range.
*/
/*
// New Implementation:
// Leave all the numbers in the same place: Note we have
// JUST enough head room for Red as worst case is
// (0xFF * 3) * 85 = 0xFE01
//
// By the same idea, we can keep R & B in the SAME variable!
// since they are separated by enough space.
//
// Furthermore we can add ALL the RBG values together, and then
// at the end get just the RB by subtracting out G's total.
//
// Since we can't guarantee the content of very top 8 bits
// of each input colour, accumulate these in the G as well.
//
// Saves loads of instructions - Sometimes I amaze even myself ;)
// Who needs MMX!
// Simon
*/
#define IMPLEMENT_AVG_FLAT(Result, Src) \
{ \
sgl_uint32 RedNBlue, GreenNTop; \
RedNBlue = Src.pV0->u32Colour; \
GreenNTop = Src.pV0->u32Colour & 0xFF00FF00; \
RedNBlue += Src.pV1->u32Colour; \
GreenNTop += Src.pV1->u32Colour & 0xFF00FF00; \
RedNBlue += Src.pV2->u32Colour; \
GreenNTop += Src.pV2->u32Colour & 0xFF00FF00; \
RedNBlue -= GreenNTop; \
GreenNTop *= 85; \
RedNBlue *= 85; \
GreenNTop >>= 8; \
RedNBlue >>= 8; \
Result= (RedNBlue & 0x00FF0000) \
| (GreenNTop & 0x0000FF00) \
| (RedNBlue & 0x000000FF); \
}
/*********************************/
/*
// Ok the rest have had the same treatment
*/
/*
// For the highlight we are going down to just 5 bits
//
// Target positions:
// Red:30-26, Green:25-21, Blue:20-16
//
// After the multiply by 85, we end up with
// R&B: Red:31-16 Blue:15-0
// and
// G: Green:23-8
//
// Now the shift for Green is UP two places (since the
// most sig bit moves from 23 to 25). Since the last thing
// we did was a multiply we can combine the two to give a
// multiply by (85*4) instead!
//
// Red must go down one spot and Blue up lots. Rather than
// do a multiply by 85 and then an effective shift down, may
// as well only multiply by 42. Since we are only going to
// 5 bits in the end, it comes out with the same accuracy.
// Thus we really have R&B in the positions
// R&B: Red:30-15 Blue:14-0
//
*/
#define IMPLEMENT_AVG_HIGHLIGHT(Result, Src) \
AVERAGE_RBG_TO_555_TOP(Result, Src.pV0->u32Specular,\
Src.pV1->u32Specular,\
Src.pV2->u32Specular)
/*********************************/
#define IMPLEMENT_HIGHLIGHT \
{ \
sgl_uint32 H = gPDC.pV0->u32Specular; \
pMat->Shading.u.Highlight = ((H << 07) & 0x7C000000) | \
((H << 10) & 0x03E00000) | \
((H << 13) & 0x001F0000); \
}
/*********************************/
#define IMPLEMENT_SMOOTH \
pMat->Shading.u.Smooth.Col0 = gPDC.pV0->u32Colour; \
pMat->Shading.u.Smooth.Col1 = gPDC.pV1->u32Colour; \
pMat->Shading.u.Smooth.Col2 = gPDC.pV2->u32Colour; \
pMat->Shading.u.Smooth.nX = (int) gPDC.pV0->fX; \
pMat->Shading.u.Smooth.nY = (int) gPDC.pV0->fY;
#if 0
#define IMPLEMENT_NATIVE_SMOOTH \
pMat->Shading.u.NativeSmooth.fIntensity[0] = gPDC.pV0->fIntensity; \
pMat->Shading.u.NativeSmooth.fIntensity[1] = gPDC.pV1->fIntensity; \
pMat->Shading.u.NativeSmooth.fIntensity[2] = gPDC.pV2->fIntensity; \
pMat->Shading.u.NativeSmooth.nX = (int) gPDC.pV0->fX; \
pMat->Shading.u.NativeSmooth.nY = (int) gPDC.pV0->fY;
#else
#define IMPLEMENT_NATIVE_SMOOTH \
pMat->Shading.u.Smooth.Col0 = gPDC.pV0->u32Colour; \
pMat->Shading.u.Smooth.Col1 = gPDC.pV1->u32Colour; \
pMat->Shading.u.Smooth.Col2 = gPDC.pV2->u32Colour; \
pMat->Shading.u.Smooth.nX = (int) gPDC.pV0->fX; \
pMat->Shading.u.Smooth.nY = (int) gPDC.pV0->fY;
#endif
/*****************************************************************/
#define IMPLEMENT_VERTEX_TRANS \
{ \
sgl_uint32 Alpha; \
Alpha = gPDC.pV0->u32Colour >> 28; \
pTri->TSPControlWord |= (0xF - Alpha) << 13; \
}
/*
// We want to get the average of three 8 bit integer Alpha values,
// which are stored in the top bits of the colours, get only
// the top 4 bits of the average, reverse the meaning of alpha
// (ie by subtracting the 4 bit value from 0xF) and then store
// the 4 bit result back in bits 16..13 (inclusive and counting
// from bit 0) of the TSP control word.
//
// First get the top 8 bits only by shifting down by 24, and add
// them. Now if we were to multiply this by 85 (which effectively
// is a division by 3 if you shift down by 8), we get the most
// sig bit in bit 15.
//
// Since we want the most sig bit in bit 16 we instead multiply
// by (2*85).
//
// We then mask to get just the 4 most sig bits, and subtract
// this from "F" in the correct pos to reverse the sense of alpha
// from D3D style to PCX1 style.
*/
#define IMPLEMENT_AVG_VERTEX_TRANS \
{ \
sgl_uint32 Alpha; \
Alpha = (gPDC.pV0->u32Colour >> 24) + \
(gPDC.pV1->u32Colour >> 24) + \
(gPDC.pV2->u32Colour >> 24); \
Alpha *= (2*85); \
Alpha &= (0xF << 13); \
Alpha = (0xF << 13) - Alpha; \
pTri->TSPControlWord |= Alpha; \
}
/****************************************************************/
/*
// This macro is similar to the previous EXCEPT we must scale
// everything by the global alpha value. This is an 8 bit value,
// so after multiplying by it, everything is shifted up by a
// further 8 bits.
//
// Thus after we multiply by (85 * gPDC.Context.u32GlobalTrans)
// the most sig bit of the Alpha is in bit 23 (i.e. 15+8). To move
// it into bit 16 (where we want it), shift down by 7.
//
// To eliminate the shift by 7 and 85 * gPDC.Context.u32GlobalTrans
// these have been precalculated in gPDC.u32GlobalTransBy85div128
// This does introduce some errors, but having checked it on a
// spreadsheet and noting that we only want 4 bits as a final
// result, the error is insignificant.
*/
#define IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS \
{ \
sgl_uint32 Alpha; \
Alpha = (gPDC.pV0->u32Colour >> 24) + \
(gPDC.pV1->u32Colour >> 24) + \
(gPDC.pV2->u32Colour >> 24); \
Alpha *= gPDC.u32GlobalTransBy85div128; \
Alpha &= (0xF << 13); \
Alpha = (0xF << 13) - Alpha; \
pTri->TSPControlWord |= Alpha; \
}
#define IMPLEMENT_VERTEX_GLOBAL_TRANS \
{ \
sgl_uint32 Alpha; \
Alpha = gPDC.pV0->u32Colour >> 24; \
Alpha += (Alpha + Alpha); \
Alpha *= gPDC.u32GlobalTransBy85div128; \
Alpha &= (0xF << 13); \
Alpha = (0xF << 13) - Alpha; \
pTri->TSPControlWord |= Alpha; \
}
/*********************************/
#define IMPLEMENT_SHADOW_LIGHTVOL \
pMat->v.LightVolCol = gPDC.Context.u.u32LightVolColour;
/*********************************/
/*
// To implement vertex fogging we add an extra plane in a special
// fog pass, this plane uses a special fog texture a la NTTrans
// but this must have texture coords to map a texture with linear
// alpha variation in the U direction to an appropriate bit of
// fog - this is done via a look up, the index of which is calculated
// below
*/
#define IMPLEMENT_VERTEX_FOG \
{ \
sgl_uint32 nFogIndex; \
nFogIndex = (((gPDC.pV0->u32Specular & 0xF0000000) >> 20) | \
((gPDC.pV1->u32Specular & 0xF0000000)>> 24) | \
((gPDC.pV2->u32Specular & 0xF0000000)>> 28)); \
pMat->nFogIndex = (~nFogIndex)&0xfffUL; \
pMat->nSmoothSpecularIndex = 0; \
}
/*
// As above but in flat shading mode the fog is flat
// Only use the first vertex for the properties
*/
#define IMPLEMENT_FLAT_VERTEX_FOG \
{ \
sgl_uint32 nFogIndex; \
sgl_uint32 nFogTmp; \
nFogTmp = ((gPDC.pV0->u32Specular) >> 28); \
nFogIndex = nFogTmp | nFogTmp << 4 | nFogTmp << 8; \
pMat->nFogIndex = (~nFogIndex); \
pMat->nSmoothSpecularIndex = 0; \
}
/*
// As above but in average colour flat shading mode the fog is flat
// But uses average of the all vertices for the properties
*/
#define IMPLEMENT_AVG_VERTEX_FOG \
{ \
sgl_uint32 nFogIndex; \
sgl_uint32 nFogTmp; \
nFogTmp = (gPDC.pV0->u32Specular >> 28)+ \
(gPDC.pV1->u32Specular >> 28)+ \
(gPDC.pV2->u32Specular >> 28); \
nFogTmp = (nFogTmp * 85)>> 8; \
nFogIndex = nFogTmp | nFogTmp << 4 | nFogTmp << 8; \
pMat->nFogIndex = (~nFogIndex)&0xfffUL; \
pMat->nSmoothSpecularIndex = 0; \
}
/*
// ============================================================================
// PER POLYGON INTERMEDIATE ROUTINES (PPIRs)
// ============================================================================
*/
static void ProcessFlatten( PITRI pTri)
{
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
}
static void ProcessFlatHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
}
static void ProcessFlattenHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
}
static void ProcessFlattenTex (PITRI pTri)
{
/* No gpMatCurrent increment*/
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlatTexHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlattenTexHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessSmooth (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
}
static void ProcessSmoothHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH;
pMat->nFogIndex = 0;
pMat->nSmoothSpecularIndex= FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessSmoothTexHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH;
pMat->nFogIndex = 0;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessSmoothTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_SMOOTH
}
static void ProcessSmoothTransHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_SMOOTH
pMat->nFogIndex = 0;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessSmoothGTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_SMOOTH
}
static void ProcessSmoothGTransHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_SMOOTH
pMat->nFogIndex = 0;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessSmoothTex (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessSmoothTexTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_SMOOTH
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessSmoothTexTransHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_SMOOTH
pMat->nFogIndex = 0;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessSmoothTexGTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_SMOOTH
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessSmoothTexGTransHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_SMOOTH
pMat->nFogIndex = 0;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
/* ProcessFlatTexFn( pTri ); */
}
/*
// ============================================================================
// PER TRIANGLE VERTEX FOG PROCESS ROUTINES
// ============================================================================
*/
static void ProcessFlatVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessSmoothVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_VERTEX_FOG;
IMPLEMENT_SMOOTH
}
static void ProcessSmoothVFogHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_VERTEX_FOG;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessFlatTexVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessSmoothTexVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_VERTEX_FOG;
IMPLEMENT_SMOOTH
}
static void ProcessSmoothTexVFogHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_VERTEX_FOG;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessFlatHighlightVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessFlatTexHighlightVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_FLAT_VERTEX_FOG;
}
/*
// ========================================
// PER TRIANGLE VERTEX FOG PROCESS ROUTINES
// WITH AVERAGE COLOUR
// ========================================
*/
static void ProcessFlattenVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessFlattenHighlightVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessFlattenTexVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessFlattenTexHighlightVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_FOG;
}
/*
// ========================================
// PER TRIANGLE VERTEX FOG PROCESS ROUTINES
// WITH VERTEX TRANSLUCENCY
// ========================================
*/
static void ProcessFlatTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_VERTEX_TRANS
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessSmoothTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_VERTEX_FOG;
}
static void ProcessSmoothTransVFogHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_VERTEX_FOG;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessFlatTexTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_VERTEX_TRANS
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessSmoothTexTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_VERTEX_FOG;
}
static void ProcessSmoothTexTransVFogHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_VERTEX_FOG;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessHighTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_TRANS
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessHighTexTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_TRANS
IMPLEMENT_FLAT_VERTEX_FOG;
}
/*
// ========================================
// PER TRIANGLE VERTEX FOG PROCESS ROUTINES
// WITH VERTEX TRANSLUCENCY
// AND AVERAGE COLOUR
// ========================================
*/
static void ProcessFlattenTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessHighFltnTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessHighFltnTexTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessFlattenTexTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_AVG_VERTEX_FOG;
}
/*
// ========================================
// PER TRIANGLE VERTEX FOG PROCESS ROUTINES
// WITH VERTEX & GLOBAL TRANSLUCENCY
// ========================================
*/
static void ProcessFlatGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessSmoothGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_VERTEX_FOG;
}
static void ProcessSmoothGTransVFogHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_VERTEX_FOG;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessFlatTexGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_VERTEX_GLOBAL_TRANS
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessSmoothTexGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_VERTEX_FOG;
}
static void ProcessSmoothTexGTransVFogHighlight (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_VERTEX_FOG;
pMat->nSmoothSpecularIndex = FakeHighlight(gPDC, &pMat->nSmoothSpecularColour);
}
static void ProcessHighGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_GLOBAL_TRANS
IMPLEMENT_FLAT_VERTEX_FOG;
}
static void ProcessHighTexGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_GLOBAL_TRANS
IMPLEMENT_FLAT_VERTEX_FOG;
}
/*
// ========================================
// PER TRIANGLE VERTEX FOG PROCESS ROUTINES
// WITH VERTEX & GLOBAL TRANSLUCENCY
// AND AVERAGE COLOUR
// ========================================
*/
static void ProcessFlattenGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessFlattenTexGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessHighFltnGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_AVG_VERTEX_FOG;
}
static void ProcessHighFltnTexGTransVFog (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_AVG_VERTEX_FOG;
}
/*
// ============================================================================
// NATIVE SMOOTH SHADING:
// ============================================================================
*/
static void ProcessNativeSmooth (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_NATIVE_SMOOTH
}
static void ProcessNativeSmoothTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_NATIVE_SMOOTH
}
static void ProcessNativeSmoothGTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_NATIVE_SMOOTH
}
static void ProcessNativeSmoothTex (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_NATIVE_SMOOTH
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessNativeSmoothTexTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_NATIVE_SMOOTH
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessNativeSmoothTexGTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_NATIVE_SMOOTH
/* ProcessFlatTexFn( pTri ); */
}
/*
// ============================================================================
// PER POLYGON INTERMEDIATE ROUTINES WITH SHADOWS OR L-Vs (PPIRs)
// ============================================================================
*/
static void ProcessFlatShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessFlattenShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessFlatHighlightShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessFlattenHighlightShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessFlatTexShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlattenTexShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlatTexHighlightShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlattenTexHighlightShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessSmoothShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessSmoothTexShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_SMOOTH
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
/**********************************************************************/
/* PROCESS FUNCTIONS FOR PER VERTEX TRANSLUCENT TRIS (NON-TEXTURED) */
/**********************************************************************/
static void ProcessFlatTrans (PITRI pTri)
{
IMPLEMENT_VERTEX_TRANS
}
static void ProcessFlattenTrans (PITRI pTri)
{
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
}
static void ProcessHighTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_TRANS
}
static void ProcessHighFltnTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
}
static void ProcessFlatGTrans (PITRI pTri)
{
IMPLEMENT_VERTEX_GLOBAL_TRANS
}
static void ProcessFlattenGTrans (PITRI pTri)
{
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
}
static void ProcessHighGTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_GLOBAL_TRANS
}
static void ProcessHighFltnGTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
}
static void ProcessFlatTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_VERTEX_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessFlattenTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessHighTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessHighFltnTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessFlatGTransShadOrLiVol (PITRI pTri)
{
IMPLEMENT_VERTEX_GLOBAL_TRANS
}
static void ProcessFlattenGTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessHighGTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_GLOBAL_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
}
static void ProcessHighFltnGTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
}
/**********************************************************************/
/* PROCESS FUNCTIONS FOR PER VERTEX TRANSLUCENT TRIS (TEXTURED) */
/**********************************************************************/
static void ProcessFlatTexTrans (PITRI pTri)
{
IMPLEMENT_VERTEX_TRANS
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlattenTexTrans (PITRI pTri)
{
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessHighTexTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_TRANS
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessHighFltnTexTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlatTexGTrans (PITRI pTri)
{
IMPLEMENT_VERTEX_GLOBAL_TRANS
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlattenTexGTrans (PITRI pTri)
{
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessHighTexGTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_GLOBAL_TRANS
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessHighFltnTexGTrans (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlatTexTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_VERTEX_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlattenTexTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessHighTexTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessHighFltnTexTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlatTexGTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_VERTEX_GLOBAL_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessFlattenTexGTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessHighTexGTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_HIGHLIGHT
IMPLEMENT_VERTEX_GLOBAL_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
static void ProcessHighFltnTexGTransShadOrLiVol (PITRI pTri)
{
PIMATERIAL pMat = gpMatCurrent;
IMPLEMENT_AVG_FLAT(pTri->BaseColour, gPDC);
IMPLEMENT_AVG_HIGHLIGHT(pMat->Shading.u.Highlight, gPDC);
IMPLEMENT_AVG_VERTEX_GLOBAL_TRANS
IMPLEMENT_SHADOW_LIGHTVOL
/* ProcessFlatTexFn( pTri ); */
}
|
926852a84531e7abf7009a7270426f48cf6b213c
|
8838eb997879add5759b6dfb23f9a646464e53ca
|
/src/drivers/pci/msi/pci_msi.h
|
4919a2f3d6ea1fac09cc4bea3a50ffc6b5facd0a
|
[
"BSD-2-Clause"
] |
permissive
|
embox/embox
|
d6aacec876978522f01cdc4b8de37a668c6f4c80
|
98e3c06e33f3fdac10a29c069c20775568e0a6d1
|
refs/heads/master
| 2023-09-04T03:02:20.165042
| 2023-09-02T14:55:31
| 2023-09-02T14:55:31
| 33,078,138
| 1,087
| 325
|
BSD-2-Clause
| 2023-09-14T16:58:34
| 2015-03-29T15:27:48
|
C
|
UTF-8
|
C
| false
| false
| 1,406
|
h
|
pci_msi.h
|
/**
* @file
*
* @date Feb 10, 2022
* @author Anton Bondarev
*/
#ifndef SRC_DRIVERS_PCI_MSI_PCI_MSI_H_
#define SRC_DRIVERS_PCI_MSI_PCI_MSI_H_
#include <stdint.h>
#include <drivers/pci/pci.h>
#include <drivers/pci/pci_regs.h>
static inline void pci_msi_set_enable(struct pci_slot_dev *dev, int enable) {
#if 0
/* x86 version */
uint16_t control;
pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
control &= ~PCI_MSI_FLAGS_ENABLE;
if (enable) {
control |= PCI_MSI_FLAGS_ENABLE;
}
pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
#else
/* e2k version */
uint32_t control;
pci_read_config_dword(dev, dev->msi_cap, &control);
control &= ~(PCI_MSI_FLAGS_ENABLE << 16);
if (enable) {
control |= (PCI_MSI_FLAGS_ENABLE << 16);
}
pci_write_config_dword(dev, dev->msi_cap, control);
#endif
}
static inline void pci_msix_clear_and_set_ctrl(struct pci_slot_dev *dev,
uint16_t clear, uint16_t set) {
#if 0 /* x86 version */
uint16_t ctrl;
pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &ctrl);
ctrl &= ~clear;
ctrl |= set;
pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, ctrl);
#else
/* e2k version */
uint32_t ctrl;
pci_read_config_dword(dev, dev->msix_cap, &ctrl);
ctrl &= ~clear;
ctrl |= ((uint32_t)set << 16);
pci_write_config_dword(dev, dev->msix_cap, ctrl);
}
#endif
#endif /* SRC_DRIVERS_PCI_MSI_PCI_MSI_H_ */
|
ee9e802684eced0b90b3fcefc0310a29377e2bec
|
4b15f318ba3332ee946cb0b2838c93e7935b9b89
|
/src/promotion/nhit/nhit.h
|
567bc49dcd589109abb2207d6a7c85145e5abe8d
|
[
"BSD-3-Clause"
] |
permissive
|
Open-CAS/ocf
|
c4f8a5c9c1b254a905fda75be2c19bd7c8ebd450
|
016d7a8ee2822d672c308264e79bae4081e7930e
|
refs/heads/master
| 2023-05-28T08:40:51.328181
| 2023-05-11T08:11:57
| 2023-05-11T08:11:57
| 152,160,836
| 168
| 94
|
BSD-3-Clause
| 2023-09-14T08:01:50
| 2018-10-08T23:46:10
|
C
|
UTF-8
|
C
| false
| false
| 783
|
h
|
nhit.h
|
/*
* Copyright(c) 2019-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef NHIT_PROMOTION_POLICY_H_
#define NHIT_PROMOTION_POLICY_H_
#include "ocf/ocf.h"
#include "../../ocf_request.h"
#include "../promotion.h"
#include "nhit_structs.h"
void nhit_setup(ocf_cache_t cache);
ocf_error_t nhit_init(ocf_cache_t cache);
void nhit_deinit(ocf_promotion_policy_t policy);
ocf_error_t nhit_set_param(ocf_cache_t cache, uint8_t param_id,
uint32_t param_value);
ocf_error_t nhit_get_param(ocf_cache_t cache, uint8_t param_id,
uint32_t *param_value);
void nhit_req_purge(ocf_promotion_policy_t policy,
struct ocf_request *req);
bool nhit_req_should_promote(ocf_promotion_policy_t policy,
struct ocf_request *req);
#endif /* NHIT_PROMOTION_POLICY_H_ */
|
b66ec18c439ab1cdeaa4c2d2e019977edd8a2f82
|
e8c76797b194bce6702adf9721a96c2b440efd5c
|
/modules/filters/mod_ext_filter.c
|
0d2ae72b57fd9b1118220123364ef738b0147835
|
[
"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
| 32,389
|
c
|
mod_ext_filter.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.
*/
/*
* mod_ext_filter allows Unix-style filters to filter http content.
*/
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "http_protocol.h"
#include "http_core.h"
#include "apr_buckets.h"
#include "util_filter.h"
#include "util_script.h"
#include "util_time.h"
#include "apr_strings.h"
#include "apr_hash.h"
#include "apr_lib.h"
#include "apr_poll.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
typedef struct ef_server_t {
apr_pool_t *p;
apr_hash_t *h;
} ef_server_t;
typedef struct ef_filter_t {
const char *name;
enum {INPUT_FILTER=1, OUTPUT_FILTER} mode;
ap_filter_type ftype;
const char *command;
const char *enable_env;
const char *disable_env;
char **args;
const char *intype; /* list of IMTs we process (well, just one for now) */
#define INTYPE_ALL (char *)1
const char *outtype; /* IMT of filtered output */
#define OUTTYPE_UNCHANGED (char *)1
int preserves_content_length;
} ef_filter_t;
typedef struct ef_dir_t {
int log_stderr;
int onfail;
} ef_dir_t;
typedef struct ef_ctx_t {
apr_pool_t *p;
apr_proc_t *proc;
apr_procattr_t *procattr;
ef_dir_t *dc;
ef_filter_t *filter;
int noop, hit_eos;
#if APR_FILES_AS_SOCKETS
apr_pollset_t *pollset;
#endif
} ef_ctx_t;
module AP_MODULE_DECLARE_DATA ext_filter_module;
static const server_rec *main_server;
static apr_status_t ef_output_filter(ap_filter_t *, apr_bucket_brigade *);
static apr_status_t ef_input_filter(ap_filter_t *, apr_bucket_brigade *,
ap_input_mode_t, apr_read_type_e,
apr_off_t);
#define ERRFN_USERDATA_KEY "EXTFILTCHILDERRFN"
static void *create_ef_dir_conf(apr_pool_t *p, char *dummy)
{
ef_dir_t *dc = (ef_dir_t *)apr_pcalloc(p, sizeof(ef_dir_t));
dc->log_stderr = -1;
dc->onfail = -1;
return dc;
}
static void *create_ef_server_conf(apr_pool_t *p, server_rec *s)
{
ef_server_t *conf;
conf = (ef_server_t *)apr_pcalloc(p, sizeof(ef_server_t));
conf->p = p;
conf->h = apr_hash_make(conf->p);
return conf;
}
static void *merge_ef_dir_conf(apr_pool_t *p, void *basev, void *overridesv)
{
ef_dir_t *a = (ef_dir_t *)apr_pcalloc (p, sizeof(ef_dir_t));
ef_dir_t *base = (ef_dir_t *)basev, *over = (ef_dir_t *)overridesv;
if (over->log_stderr != -1) { /* if admin coded something... */
a->log_stderr = over->log_stderr;
}
else {
a->log_stderr = base->log_stderr;
}
if (over->onfail != -1) { /* if admin coded something... */
a->onfail = over->onfail;
}
else {
a->onfail = base->onfail;
}
return a;
}
static const char *add_options(cmd_parms *cmd, void *in_dc,
const char *arg)
{
ef_dir_t *dc = in_dc;
if (!strcasecmp(arg, "LogStderr")) {
dc->log_stderr = 1;
}
else if (!strcasecmp(arg, "NoLogStderr")) {
dc->log_stderr = 0;
}
else if (!strcasecmp(arg, "Onfail=remove")) {
dc->onfail = 1;
}
else if (!strcasecmp(arg, "Onfail=abort")) {
dc->onfail = 0;
}
else {
return apr_pstrcat(cmd->temp_pool,
"Invalid ExtFilterOptions option: ",
arg,
NULL);
}
return NULL;
}
static const char *parse_cmd(apr_pool_t *p, const char **args, ef_filter_t *filter)
{
if (**args == '"') {
const char *start = *args + 1;
char *parms;
int escaping = 0;
apr_status_t rv;
++*args; /* move past leading " */
/* find true end of args string (accounting for escaped quotes) */
while (**args && (**args != '"' || escaping)) {
if (escaping) {
escaping = 0;
}
else if (**args == '\\') {
escaping = 1;
}
++*args;
}
if (**args != '"') {
return "Expected cmd= delimiter";
}
/* copy *just* the arg string for parsing, */
parms = apr_pstrndup(p, start, *args - start);
++*args; /* move past trailing " */
/* parse and tokenize the args. */
rv = apr_tokenize_to_argv(parms, &(filter->args), p);
if (rv != APR_SUCCESS) {
return "cmd= parse error";
}
}
else
{
/* simple path */
/* Allocate space for two argv pointers and parse the args. */
filter->args = (char **)apr_palloc(p, 2 * sizeof(char *));
filter->args[0] = ap_getword_white(p, args);
filter->args[1] = NULL; /* end of args */
}
if (!filter->args[0]) {
return "Invalid cmd= parameter";
}
filter->command = filter->args[0];
return NULL;
}
static const char *define_filter(cmd_parms *cmd, void *dummy, const char *args)
{
ef_server_t *conf = ap_get_module_config(cmd->server->module_config,
&ext_filter_module);
const char *token;
const char *name;
char *normalized_name;
ef_filter_t *filter;
name = ap_getword_white(cmd->pool, &args);
if (!name) {
return "Filter name not found";
}
/* During request processing, we find information about the filter
* by looking up the filter name provided by core server in our
* hash table. But the core server has normalized the filter
* name by converting it to lower case. Thus, when adding the
* filter to our hash table we have to use lower case as well.
*/
normalized_name = apr_pstrdup(cmd->pool, name);
ap_str_tolower(normalized_name);
if (apr_hash_get(conf->h, normalized_name, APR_HASH_KEY_STRING)) {
return apr_psprintf(cmd->pool, "ExtFilter %s is already defined",
name);
}
filter = (ef_filter_t *)apr_pcalloc(conf->p, sizeof(ef_filter_t));
filter->name = name;
filter->mode = OUTPUT_FILTER;
filter->ftype = AP_FTYPE_RESOURCE;
apr_hash_set(conf->h, normalized_name, APR_HASH_KEY_STRING, filter);
while (*args) {
while (apr_isspace(*args)) {
++args;
}
/* Nasty parsing... I wish I could simply use ap_getword_white()
* here and then look at the token, but ap_getword_white() doesn't
* do the right thing when we have cmd="word word word"
*/
if (!strncasecmp(args, "preservescontentlength", 22)) {
token = ap_getword_white(cmd->pool, &args);
if (!strcasecmp(token, "preservescontentlength")) {
filter->preserves_content_length = 1;
}
else {
return apr_psprintf(cmd->pool,
"mangled argument `%s'",
token);
}
continue;
}
if (!strncasecmp(args, "mode=", 5)) {
args += 5;
token = ap_getword_white(cmd->pool, &args);
if (!strcasecmp(token, "output")) {
filter->mode = OUTPUT_FILTER;
}
else if (!strcasecmp(token, "input")) {
filter->mode = INPUT_FILTER;
}
else {
return apr_psprintf(cmd->pool, "Invalid mode: `%s'",
token);
}
continue;
}
if (!strncasecmp(args, "ftype=", 6)) {
args += 6;
token = ap_getword_white(cmd->pool, &args);
filter->ftype = atoi(token);
continue;
}
if (!strncasecmp(args, "enableenv=", 10)) {
args += 10;
token = ap_getword_white(cmd->pool, &args);
filter->enable_env = token;
continue;
}
if (!strncasecmp(args, "disableenv=", 11)) {
args += 11;
token = ap_getword_white(cmd->pool, &args);
filter->disable_env = token;
continue;
}
if (!strncasecmp(args, "intype=", 7)) {
args += 7;
filter->intype = ap_getword_white(cmd->pool, &args);
continue;
}
if (!strncasecmp(args, "outtype=", 8)) {
args += 8;
filter->outtype = ap_getword_white(cmd->pool, &args);
continue;
}
if (!strncasecmp(args, "cmd=", 4)) {
args += 4;
if ((token = parse_cmd(cmd->pool, &args, filter))) {
return token;
}
continue;
}
return apr_psprintf(cmd->pool, "Unexpected parameter: `%s'",
args);
}
/* parsing is done... register the filter
*/
if (filter->mode == OUTPUT_FILTER) {
/* XXX need a way to ensure uniqueness among all filters */
ap_register_output_filter(filter->name, ef_output_filter, NULL, filter->ftype);
}
else if (filter->mode == INPUT_FILTER) {
/* XXX need a way to ensure uniqueness among all filters */
ap_register_input_filter(filter->name, ef_input_filter, NULL, filter->ftype);
}
else {
ap_assert(1 != 1); /* we set the field wrong somehow */
}
return NULL;
}
static const command_rec cmds[] =
{
AP_INIT_ITERATE("ExtFilterOptions",
add_options,
NULL,
ACCESS_CONF, /* same as SetInputFilter/SetOutputFilter */
"valid options: LogStderr, NoLogStderr"),
AP_INIT_RAW_ARGS("ExtFilterDefine",
define_filter,
NULL,
RSRC_CONF,
"Define an external filter"),
{NULL}
};
static int ef_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *main_s)
{
main_server = main_s;
return OK;
}
static void register_hooks(apr_pool_t *p)
{
ap_hook_post_config(ef_init, NULL, NULL, APR_HOOK_MIDDLE);
}
static apr_status_t set_resource_limits(request_rec *r,
apr_procattr_t *procattr)
{
#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \
defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
core_dir_config *conf =
(core_dir_config *)ap_get_core_module_config(r->per_dir_config);
apr_status_t rv;
#ifdef RLIMIT_CPU
rv = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, conf->limit_cpu);
ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
#endif
#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
rv = apr_procattr_limit_set(procattr, APR_LIMIT_MEM, conf->limit_mem);
ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
#endif
#ifdef RLIMIT_NPROC
rv = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, conf->limit_nproc);
ap_assert(rv == APR_SUCCESS); /* otherwise, we're out of sync with APR */
#endif
#endif /* if at least one limit defined */
return APR_SUCCESS;
}
static apr_status_t ef_close_file(void *vfile)
{
return apr_file_close(vfile);
}
static void child_errfn(apr_pool_t *pool, apr_status_t err, const char *description)
{
request_rec *r;
void *vr;
apr_file_t *stderr_log;
char time_str[APR_CTIME_LEN];
apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, pool);
r = vr;
apr_file_open_stderr(&stderr_log, pool);
ap_recent_ctime(time_str, apr_time_now());
apr_file_printf(stderr_log,
"[%s] [client %s] mod_ext_filter (%d)%pm: %s\n",
time_str,
r->useragent_ip,
err,
&err,
description);
}
/* init_ext_filter_process: get the external filter process going
* This is per-filter-instance (i.e., per-request) initialization.
*/
static apr_status_t init_ext_filter_process(ap_filter_t *f)
{
ef_ctx_t *ctx = f->ctx;
apr_status_t rc;
ef_dir_t *dc = ctx->dc;
const char * const *env;
ctx->proc = apr_pcalloc(ctx->p, sizeof(*ctx->proc));
rc = apr_procattr_create(&ctx->procattr, ctx->p);
ap_assert(rc == APR_SUCCESS);
rc = apr_procattr_io_set(ctx->procattr,
APR_CHILD_BLOCK,
APR_CHILD_BLOCK,
APR_CHILD_BLOCK);
ap_assert(rc == APR_SUCCESS);
rc = set_resource_limits(f->r, ctx->procattr);
ap_assert(rc == APR_SUCCESS);
if (dc->log_stderr > 0) {
rc = apr_procattr_child_err_set(ctx->procattr,
f->r->server->error_log, /* stderr in child */
NULL);
ap_assert(rc == APR_SUCCESS);
}
rc = apr_procattr_child_errfn_set(ctx->procattr, child_errfn);
ap_assert(rc == APR_SUCCESS);
apr_pool_userdata_set(f->r, ERRFN_USERDATA_KEY, apr_pool_cleanup_null, ctx->p);
rc = apr_procattr_error_check_set(ctx->procattr, 1);
if (rc != APR_SUCCESS) {
return rc;
}
/* add standard CGI variables as well as DOCUMENT_URI, DOCUMENT_PATH_INFO,
* and QUERY_STRING_UNESCAPED
*/
ap_add_cgi_vars(f->r);
ap_add_common_vars(f->r);
apr_table_setn(f->r->subprocess_env, "DOCUMENT_URI", f->r->uri);
apr_table_setn(f->r->subprocess_env, "DOCUMENT_PATH_INFO", f->r->path_info);
if (f->r->args) {
/* QUERY_STRING is added by ap_add_cgi_vars */
char *arg_copy = apr_pstrdup(f->r->pool, f->r->args);
ap_unescape_url(arg_copy);
apr_table_setn(f->r->subprocess_env, "QUERY_STRING_UNESCAPED",
ap_escape_shell_cmd(f->r->pool, arg_copy));
}
env = (const char * const *) ap_create_environment(ctx->p,
f->r->subprocess_env);
rc = apr_proc_create(ctx->proc,
ctx->filter->command,
(const char * const *)ctx->filter->args,
env, /* environment */
ctx->procattr,
ctx->p);
if (rc != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, f->r, APLOGNO(01458)
"couldn't create child process to run `%s'",
ctx->filter->command);
return rc;
}
apr_pool_note_subprocess(ctx->p, ctx->proc, APR_KILL_AFTER_TIMEOUT);
/* We don't want the handle to the child's stdin inherited by any
* other processes created by httpd. Otherwise, when we close our
* handle, the child won't see EOF because another handle will still
* be open.
*/
apr_pool_cleanup_register(ctx->p, ctx->proc->in,
apr_pool_cleanup_null, /* other mechanism */
ef_close_file);
#if APR_FILES_AS_SOCKETS
{
apr_pollfd_t pfd = { 0 };
rc = apr_pollset_create(&ctx->pollset, 2, ctx->p, 0);
ap_assert(rc == APR_SUCCESS);
pfd.p = ctx->p;
pfd.desc_type = APR_POLL_FILE;
pfd.reqevents = APR_POLLOUT;
pfd.desc.f = ctx->proc->in;
rc = apr_pollset_add(ctx->pollset, &pfd);
ap_assert(rc == APR_SUCCESS);
pfd.reqevents = APR_POLLIN;
pfd.desc.f = ctx->proc->out;
rc = apr_pollset_add(ctx->pollset, &pfd);
ap_assert(rc == APR_SUCCESS);
}
#endif
return APR_SUCCESS;
}
static const char *get_cfg_string(ef_dir_t *dc, ef_filter_t *filter, apr_pool_t *p)
{
const char *log_stderr_str = dc->log_stderr < 1 ?
"NoLogStderr" : "LogStderr";
const char *preserve_content_length_str = filter->preserves_content_length ?
"PreservesContentLength" : "!PreserveContentLength";
const char *intype_str = !filter->intype ?
"*/*" : filter->intype;
const char *outtype_str = !filter->outtype ?
"(unchanged)" : filter->outtype;
return apr_psprintf(p,
"ExtFilterOptions %s %s ExtFilterInType %s "
"ExtFilterOuttype %s",
log_stderr_str, preserve_content_length_str,
intype_str, outtype_str);
}
static ef_filter_t *find_filter_def(const server_rec *s, const char *fname)
{
ef_server_t *sc;
ef_filter_t *f;
sc = ap_get_module_config(s->module_config, &ext_filter_module);
f = apr_hash_get(sc->h, fname, APR_HASH_KEY_STRING);
if (!f && s != main_server) {
s = main_server;
sc = ap_get_module_config(s->module_config, &ext_filter_module);
f = apr_hash_get(sc->h, fname, APR_HASH_KEY_STRING);
}
return f;
}
static apr_status_t init_filter_instance(ap_filter_t *f)
{
ef_ctx_t *ctx;
ef_dir_t *dc;
apr_status_t rv;
f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(ef_ctx_t));
dc = ap_get_module_config(f->r->per_dir_config,
&ext_filter_module);
ctx->dc = dc;
/* look for the user-defined filter */
ctx->filter = find_filter_def(f->r->server, f->frec->name);
if (!ctx->filter) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, f->r, APLOGNO(01459)
"couldn't find definition of filter '%s'",
f->frec->name);
return APR_EINVAL;
}
ctx->p = f->r->pool;
if (ctx->filter->intype &&
ctx->filter->intype != INTYPE_ALL) {
const char *ctypes;
if (ctx->filter->mode == INPUT_FILTER) {
ctypes = apr_table_get(f->r->headers_in, "Content-Type");
}
else {
ctypes = f->r->content_type;
}
if (ctypes) {
const char *ctype = ap_getword(f->r->pool, &ctypes, ';');
if (strcasecmp(ctx->filter->intype, ctype)) {
/* wrong IMT for us; don't mess with the output */
ctx->noop = 1;
}
}
else {
ctx->noop = 1;
}
}
if (ctx->filter->enable_env &&
!apr_table_get(f->r->subprocess_env, ctx->filter->enable_env)) {
/* an environment variable that enables the filter isn't set; bail */
ctx->noop = 1;
}
if (ctx->filter->disable_env &&
apr_table_get(f->r->subprocess_env, ctx->filter->disable_env)) {
/* an environment variable that disables the filter is set; bail */
ctx->noop = 1;
}
if (!ctx->noop) {
rv = init_ext_filter_process(f);
if (rv != APR_SUCCESS) {
return rv;
}
if (ctx->filter->outtype &&
ctx->filter->outtype != OUTTYPE_UNCHANGED) {
ap_set_content_type(f->r, ctx->filter->outtype);
}
if (ctx->filter->preserves_content_length != 1) {
/* nasty, but needed to avoid confusing the browser
*/
apr_table_unset(f->r->headers_out, "Content-Length");
}
}
if (APLOGrtrace1(f->r)) {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, f->r,
"%sfiltering `%s' of type `%s' through `%s', cfg %s",
ctx->noop ? "NOT " : "",
f->r->uri ? f->r->uri : f->r->filename,
f->r->content_type ? f->r->content_type : "(unspecified)",
ctx->filter->command,
get_cfg_string(dc, ctx->filter, f->r->pool));
}
return APR_SUCCESS;
}
/* drain_available_output():
*
* if any data is available from the filter, read it and append it
* to the bucket brigade
*/
static apr_status_t drain_available_output(ap_filter_t *f,
apr_bucket_brigade *bb)
{
request_rec *r = f->r;
conn_rec *c = r->connection;
ef_ctx_t *ctx = f->ctx;
apr_size_t len;
char buf[4096];
apr_status_t rv;
apr_bucket *b;
while (1) {
int lvl = APLOG_TRACE5;
len = sizeof(buf);
rv = apr_file_read(ctx->proc->out, buf, &len);
if (rv && !APR_STATUS_IS_EAGAIN(rv))
lvl = APLOG_DEBUG;
ap_log_rerror(APLOG_MARK, lvl, rv, r, APLOGNO(01460)
"apr_file_read(child output), len %" APR_SIZE_T_FMT, len);
if (rv != APR_SUCCESS) {
return rv;
}
b = apr_bucket_heap_create(buf, len, NULL, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
return APR_SUCCESS;
}
/* we should never get here; if we do, a bogus error message would be
* the least of our problems
*/
return APR_ANONYMOUS;
}
static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data,
apr_size_t len, apr_bucket_brigade *bb)
{
ef_ctx_t *ctx = f->ctx;
apr_status_t rv;
apr_size_t bytes_written = 0;
apr_size_t tmplen;
do {
tmplen = len - bytes_written;
rv = apr_file_write_full(ctx->proc->in,
(const char *)data + bytes_written,
tmplen, &tmplen);
bytes_written += tmplen;
if (rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, APLOGNO(01461)
"apr_file_write(child input), len %" APR_SIZE_T_FMT,
tmplen);
return rv;
}
if (APR_STATUS_IS_EAGAIN(rv)) {
/* XXX handle blocking conditions here... if we block, we need
* to read data from the child process and pass it down to the
* next filter!
*/
rv = drain_available_output(f, bb);
if (APR_STATUS_IS_EAGAIN(rv)) {
#if APR_FILES_AS_SOCKETS
int num_events;
const apr_pollfd_t *pdesc;
rv = apr_pollset_poll(ctx->pollset, f->r->server->timeout,
&num_events, &pdesc);
if (rv != APR_SUCCESS && !APR_STATUS_IS_EINTR(rv)) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, f->r, APLOGNO(01462)
"apr_pollset_poll()");
/* some error such as APR_TIMEUP */
return rv;
}
ap_log_rerror(APLOG_MARK, APLOG_TRACE6, rv, f->r,
"apr_pollset_poll()");
#else /* APR_FILES_AS_SOCKETS */
/* Yuck... I'd really like to wait until I can read
* or write, but instead I have to sleep and try again
*/
apr_sleep(apr_time_from_msec(100));
ap_log_rerror(APLOG_MARK, APLOG_TRACE6, 0, f->r, "apr_sleep()");
#endif /* APR_FILES_AS_SOCKETS */
}
else if (rv != APR_SUCCESS) {
return rv;
}
}
} while (bytes_written < len);
return rv;
}
/* check_filter_process_on_eos():
*
* if we hit end-of-stream, check the exit status of the filter process, and log
* an appropriate message if it failed
*/
static apr_status_t check_filter_process_on_eos(ef_ctx_t *ctx, request_rec *r)
{
if (ctx->hit_eos) {
int exitcode;
apr_exit_why_e exitwhy;
apr_status_t waitret = apr_proc_wait(ctx->proc, &exitcode, &exitwhy,
APR_WAIT);
if (waitret != APR_CHILD_DONE) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, waitret, r, APLOGNO(10451)
"apr_proc_wait() failed, uri=%s", r->uri);
return waitret;
}
else if (exitwhy != APR_PROC_EXIT) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, APLOGNO(10452)
"child process %s killed by signal %d, uri=%s",
ctx->filter->command, exitcode, r->uri);
return APR_EGENERAL;
}
else if (exitcode != 0) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, APLOGNO(10453)
"child process %s exited with non-zero status %d, "
"uri=%s", ctx->filter->command, exitcode, r->uri);
return APR_EGENERAL;
}
}
return APR_SUCCESS;
}
/* ef_unified_filter:
*
* runs the bucket brigade bb through the filter and puts the result into
* bb, dropping the previous content of bb (the input)
*/
static apr_status_t ef_unified_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
request_rec *r = f->r;
conn_rec *c = r->connection;
ef_ctx_t *ctx = f->ctx;
apr_bucket *b;
apr_size_t len;
const char *data;
apr_status_t rv;
char buf[4096];
apr_bucket *eos = NULL;
apr_bucket_brigade *bb_tmp;
bb_tmp = apr_brigade_create(r->pool, c->bucket_alloc);
for (b = APR_BRIGADE_FIRST(bb);
b != APR_BRIGADE_SENTINEL(bb);
b = APR_BUCKET_NEXT(b))
{
if (APR_BUCKET_IS_EOS(b)) {
eos = b;
break;
}
if (AP_BUCKET_IS_ERROR(b)) {
apr_bucket *cpy;
apr_bucket_copy(b, &cpy);
APR_BRIGADE_INSERT_TAIL(bb_tmp, cpy);
break;
}
rv = apr_bucket_read(b, &data, &len, APR_BLOCK_READ);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01463) "apr_bucket_read()");
return rv;
}
/* Good cast, we just tested len isn't negative */
if (len > 0 &&
(rv = pass_data_to_filter(f, data, (apr_size_t)len, bb_tmp))
!= APR_SUCCESS) {
return rv;
}
}
apr_brigade_cleanup(bb);
APR_BRIGADE_CONCAT(bb, bb_tmp);
apr_brigade_destroy(bb_tmp);
if (eos) {
/* close the child's stdin to signal that no more data is coming;
* that will cause the child to finish generating output
*/
if ((rv = apr_file_close(ctx->proc->in)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01464)
"apr_file_close(child input)");
return rv;
}
/* since we've seen eos and closed the child's stdin, set the proper pipe
* timeout; we don't care if we don't return from apr_file_read() for a while...
*/
rv = apr_file_pipe_timeout_set(ctx->proc->out,
r->server->timeout);
if (rv) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01465)
"apr_file_pipe_timeout_set(child output)");
return rv;
}
}
do {
int lvl = APLOG_TRACE6;
len = sizeof(buf);
rv = apr_file_read(ctx->proc->out, buf, &len);
if (rv && !APR_STATUS_IS_EOF(rv) && !APR_STATUS_IS_EAGAIN(rv))
lvl = APLOG_ERR;
ap_log_rerror(APLOG_MARK, lvl, rv, r, APLOGNO(01466)
"apr_file_read(child output), len %" APR_SIZE_T_FMT, len);
if (APR_STATUS_IS_EAGAIN(rv)) {
if (eos) {
/* should not occur, because we have an APR timeout in place */
AP_DEBUG_ASSERT(1 != 1);
}
return APR_SUCCESS;
}
if (rv == APR_SUCCESS) {
b = apr_bucket_heap_create(buf, len, NULL, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
}
} while (rv == APR_SUCCESS);
if (!APR_STATUS_IS_EOF(rv)) {
return rv;
}
if (eos) {
b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
ctx->hit_eos = 1;
}
return APR_SUCCESS;
}
static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
request_rec *r = f->r;
ef_ctx_t *ctx = f->ctx;
apr_status_t rv;
if (!ctx) {
if ((rv = init_filter_instance(f)) != APR_SUCCESS) {
ctx = f->ctx;
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01467)
"can't initialise output filter %s: %s",
f->frec->name,
(ctx->dc->onfail == 1) ? "removing" : "aborting");
ap_remove_output_filter(f);
if (ctx->dc->onfail == 1) {
return ap_pass_brigade(f->next, bb);
}
else {
apr_bucket *e;
f->r->status_line = "500 Internal Server Error";
apr_brigade_cleanup(bb);
e = ap_bucket_error_create(HTTP_INTERNAL_SERVER_ERROR,
NULL, r->pool,
f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
e = apr_bucket_eos_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
ap_pass_brigade(f->next, bb);
return AP_FILTER_ERROR;
}
}
ctx = f->ctx;
}
if (ctx->noop) {
ap_remove_output_filter(f);
return ap_pass_brigade(f->next, bb);
}
rv = ef_unified_filter(f, bb);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01468)
"ef_unified_filter() failed");
return rv;
}
if ((rv = check_filter_process_on_eos(ctx, r)) != APR_SUCCESS) {
return rv;
}
if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, APLOGNO(01469)
"ap_pass_brigade() failed");
}
return rv;
}
static apr_status_t ef_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
ap_input_mode_t mode, apr_read_type_e block,
apr_off_t readbytes)
{
ef_ctx_t *ctx = f->ctx;
apr_status_t rv;
/* just get out of the way of things we don't want. */
if (mode != AP_MODE_READBYTES) {
return ap_get_brigade(f->next, bb, mode, block, readbytes);
}
if (!ctx) {
if ((rv = init_filter_instance(f)) != APR_SUCCESS) {
ctx = f->ctx;
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, APLOGNO(01470)
"can't initialise input filter %s: %s",
f->frec->name,
(ctx->dc->onfail == 1) ? "removing" : "aborting");
ap_remove_input_filter(f);
if (ctx->dc->onfail == 1) {
return ap_get_brigade(f->next, bb, mode, block, readbytes);
}
else {
f->r->status = HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
}
}
ctx = f->ctx;
}
if (ctx->hit_eos) {
/* Match behaviour of HTTP_IN if filter is re-invoked after
* hitting EOS: give back another EOS. */
apr_bucket *e = apr_bucket_eos_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
return APR_SUCCESS;
}
if (ctx->noop) {
ap_remove_input_filter(f);
return ap_get_brigade(f->next, bb, mode, block, readbytes);
}
rv = ap_get_brigade(f->next, bb, mode, block, readbytes);
if (rv != APR_SUCCESS) {
return rv;
}
rv = ef_unified_filter(f, bb);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, APLOGNO(10454)
"ef_unified_filter() failed");
return rv;
}
return check_filter_process_on_eos(ctx, f->r);
}
AP_DECLARE_MODULE(ext_filter) =
{
STANDARD20_MODULE_STUFF,
create_ef_dir_conf,
merge_ef_dir_conf,
create_ef_server_conf,
NULL,
cmds,
register_hooks
};
|
b8ef6af270eb61bee212ba19b411f5f72bf26c6b
|
eecd5e4c50d8b78a769bcc2675250576bed34066
|
/include/petsc/private/kernels/petscaxpy.h
|
5b9096aaec9c0b3fb5b69dd8ea6eba1e104d0efb
|
[
"BSD-2-Clause"
] |
permissive
|
petsc/petsc
|
3b1a04fea71858e0292f9fd4d04ea11618c50969
|
9c5460f9064ca60dd71a234a1f6faf93e7a6b0c9
|
refs/heads/main
| 2023-08-17T20:51:16.507070
| 2023-08-17T16:08:06
| 2023-08-17T16:08:06
| 8,691,401
| 341
| 169
|
NOASSERTION
| 2023-03-29T11:02:58
| 2013-03-10T20:55:21
|
C
|
UTF-8
|
C
| false
| false
| 8,300
|
h
|
petscaxpy.h
|
/*
PetscKernelAXPY - X = X + alpha * Y
Input Parameters:
+ X, Y - arrays
. alpha - scalar
- n - length of arrays
Also PetscKernelAXPY2(), PetscKernelAXPY3(), PetscKernelAXPY4()
*/
#ifndef PETSC_KERNELS_PETSCAXPY_H
#define PETSC_KERNELS_PETSCAXPY_H
#if defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
#if defined(PETSC_HAVE_FORTRAN_CAPS)
#define fortranmaxpy4_ FORTRANMAXPY4
#define fortranmaxpy3_ FORTRANMAXPY3
#define fortranmaxpy2_ FORTRANMAXPY2
#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
#define fortranmaxpy4_ fortranmaxpy4
#define fortranmaxpy3_ fortranmaxpy3
#define fortranmaxpy2_ fortranmaxpy2
#endif
PETSC_EXTERN void fortranmaxpy4_(void *, const void *, const void *, const void *, const void *, const void *, const void *, const void *, const void *, const PetscInt *);
PETSC_EXTERN void fortranmaxpy3_(void *, const void *, const void *, const void *, const void *, const void *, const void *, const PetscInt *);
PETSC_EXTERN void fortranmaxpy2_(void *, const void *, const void *, const void *, const void *, const PetscInt *);
#endif
#include <petscblaslapack.h>
#if defined(PETSC_USE_FORTRAN_KERNEL_MAXPY)
#define PetscKernelAXPY(U, a1, p1, n) \
{ \
PetscBLASInt one = 1; \
PetscBLASInt nn = (PetscBLASInt)n; \
PetscCallBLAS("BLASaxpy", BLASaxpy_(&nn, &a1, p1, &one, U, &one)); \
}
#define PetscKernelAXPY2(U, a1, a2, p1, p2, n) \
{ \
fortranmaxpy2_(U, &a1, &a2, p1, p2, &n); \
}
#define PetscKernelAXPY3(U, a1, a2, a3, p1, p2, p3, n) \
{ \
fortranmaxpy3_(U, &a1, &a2, &a3, p1, p2, p3, &n); \
}
#define PetscKernelAXPY4(U, a1, a2, a3, a4, p1, p2, p3, p4, n) \
{ \
fortranmaxpy4_(U, &a1, &a2, &a3, &a4, p1, p2, p3, p4, &n); \
}
#elif defined(PETSC_USE_UNROLL_KERNELS)
#define PetscKernelAXPY(U, Alpha, P, n) \
{ \
switch (n & 0x3) { \
case 3: \
*U++ += Alpha * *P++; \
case 2: \
*U++ += Alpha * *P++; \
case 1: \
*U++ += Alpha * *P++; \
n -= 4; \
case 0: \
break; \
} \
while (n > 0) { \
U[0] += Alpha * P[0]; \
U[1] += Alpha * P[1]; \
U[2] += Alpha * P[2]; \
U[3] += Alpha * P[3]; \
U += 4; \
P += 4; \
n -= 4; \
} \
}
#define PetscKernelAXPY2(U, a1, a2, p1, p2, n) \
{ \
switch (n & 0x3) { \
case 3: \
*U++ += a1 * *p1++ + a2 * *p2++; \
case 2: \
*U++ += a1 * *p1++ + a2 * *p2++; \
case 1: \
*U++ += a1 * *p1++ + a2 * *p2++; \
n -= 4; \
case 0: \
break; \
} \
while (n > 0) { \
U[0] += a1 * p1[0] + a2 * p2[0]; \
U[1] += a1 * p1[1] + a2 * p2[1]; \
U[2] += a1 * p1[2] + a2 * p2[2]; \
U[3] += a1 * p1[3] + a2 * p2[3]; \
U += 4; \
p1 += 4; \
p2 += 4; \
n -= 4; \
} \
}
#define PetscKernelAXPY3(U, a1, a2, a3, p1, p2, p3, n) \
{ \
switch (n & 0x3) { \
case 3: \
*U++ += a1 * *p1++ + a2 * *p2++ + a3 * *p3++; \
case 2: \
*U++ += a1 * *p1++ + a2 * *p2++ + a3 * *p3++; \
case 1: \
*U++ += a1 * *p1++ + a2 * *p2++ + a3 * *p3++; \
n -= 4; \
case 0: \
break; \
} \
while (n > 0) { \
U[0] += a1 * p1[0] + a2 * p2[0] + a3 * p3[0]; \
U[1] += a1 * p1[1] + a2 * p2[1] + a3 * p3[1]; \
U[2] += a1 * p1[2] + a2 * p2[2] + a3 * p3[2]; \
U[3] += a1 * p1[3] + a2 * p2[3] + a3 * p3[3]; \
U += 4; \
p1 += 4; \
p2 += 4; \
p3 += 4; \
n -= 4; \
} \
}
#define PetscKernelAXPY4(U, a1, a2, a3, a4, p1, p2, p3, p4, n) \
{ \
switch (n & 0x3) { \
case 3: \
*U++ += a1 * *p1++ + a2 * *p2++ + a3 * *p3++ + a4 * *p4++; \
case 2: \
*U++ += a1 * *p1++ + a2 * *p2++ + a3 * *p3++ + a4 * *p4++; \
case 1: \
*U++ += a1 * *p1++ + a2 * *p2++ + a3 * *p3++ + a4 * *p4++; \
n -= 4; \
case 0: \
break; \
} \
while (n > 0) { \
U[0] += a1 * p1[0] + a2 * p2[0] + a3 * p3[0] + a4 * p4[0]; \
U[1] += a1 * p1[1] + a2 * p2[1] + a3 * p3[1] + a4 * p4[1]; \
U[2] += a1 * p1[2] + a2 * p2[2] + a3 * p3[2] + a4 * p4[2]; \
U[3] += a1 * p1[3] + a2 * p2[3] + a3 * p3[3] + a4 * p4[3]; \
U += 4; \
p1 += 4; \
p2 += 4; \
p3 += 4; \
p4 += 4; \
n -= 4; \
} \
}
#elif defined(PETSC_USE_WHILE_KERNELS)
#define PetscKernelAXPY(U, a1, p1, n) \
{ \
while (n--) *U++ += a1 * *p1++; \
}
#define PetscKernelAXPY2(U, a1, a2, p1, p2, n) \
{ \
while (n--) *U++ += a1 * *p1++ + a2 * *p2++; \
}
#define PetscKernelAXPY3(U, a1, a2, a3, p1, p2, p3, n) \
{ \
while (n--) *U++ += a1 * *p1++ + a2 * *p2++ + a3 * *p3++; \
}
#define PetscKernelAXPY4(U, a1, a2, a3, a4, p1, p2, p3, p4, n) \
{ \
while (n--) *U++ += a1 * *p1++ + a2 * *p2++ + a3 * *p3++ + a4 * *p4++; \
}
#elif defined(PETSC_USE_BLAS_KERNELS)
#define PetscKernelAXPY(U, a1, p1, n) \
{ \
PetscBLASInt one = 1; \
PetscBLASInt nn = (PetscBLASInt)n; \
PetscCallBLAS("BLASaxpy", BLASaxpy_(&nn, &a1, p1, &one, U, &one)); \
}
#define PetscKernelAXPY2(U, a1, a2, p1, p2, n) \
{ \
PetscKernelAXPY(U, a1, p1, n); \
PetscKernelAXPY(U, a2, p2, n); \
}
#define PetscKernelAXPY3(U, a1, a2, a3, p1, p2, p3, n) \
{ \
PetscKernelAXPY2(U, a1, a2, p1, p2, n); \
PetscKernelAXPY(U, a3, p3, n); \
}
#define PetscKernelAXPY4(U, a1, a2, a3, a4, p1, p2, p3, p4, n) \
{ \
PetscKernelAXPY2(U, a1, a2, p1, p2, n); \
PetscKernelAXPY2(U, a3, a4, p3, p4, n); \
}
#else
#define PetscKernelAXPY(U, a1, p1, n) \
do { \
const PetscInt _n = n; \
const PetscScalar _a1 = a1; \
const PetscScalar *PETSC_RESTRICT _p1 = p1; \
PetscScalar *PETSC_RESTRICT _U = U; \
PetscInt __i = 0; \
for (; __i < _n - 1; __i += 2) { \
PetscScalar __s1 = _a1 * _p1[__i]; \
PetscScalar __s2 = _a1 * _p1[__i + 1]; \
__s1 += _U[__i]; \
__s2 += _U[__i + 1]; \
_U[__i] = __s1; \
_U[__i + 1] = __s2; \
} \
if (_n & 0x1) _U[__i] += _a1 * _p1[__i]; \
} while (0)
#define PetscKernelAXPY2(U, a1, a2, p1, p2, n) \
do { \
const PetscInt _n = n; \
const PetscScalar _a1 = a1; \
const PetscScalar _a2 = a2; \
const PetscScalar *PETSC_RESTRICT _p1 = p1; \
const PetscScalar *PETSC_RESTRICT _p2 = p2; \
PetscScalar *PETSC_RESTRICT _U = U; \
for (PetscInt __i = 0; __i < _n; __i++) _U[__i] += _a1 * _p1[__i] + _a2 * _p2[__i]; \
} while (0)
#define PetscKernelAXPY3(U, a1, a2, a3, p1, p2, p3, n) \
do { \
const PetscInt _n = n; \
const PetscScalar _a1 = a1; \
const PetscScalar _a2 = a2; \
const PetscScalar _a3 = a3; \
const PetscScalar *PETSC_RESTRICT _p1 = p1; \
const PetscScalar *PETSC_RESTRICT _p2 = p2; \
const PetscScalar *PETSC_RESTRICT _p3 = p3; \
PetscScalar *PETSC_RESTRICT _U = U; \
for (PetscInt __i = 0; __i < _n; __i++) _U[__i] += _a1 * _p1[__i] + _a2 * _p2[__i] + _a3 * _p3[__i]; \
} while (0)
#define PetscKernelAXPY4(U, a1, a2, a3, a4, p1, p2, p3, p4, n) \
do { \
const PetscInt _n = n; \
const PetscScalar _a1 = a1; \
const PetscScalar _a2 = a2; \
const PetscScalar _a3 = a3; \
const PetscScalar _a4 = a4; \
const PetscScalar *PETSC_RESTRICT _p1 = p1; \
const PetscScalar *PETSC_RESTRICT _p2 = p2; \
const PetscScalar *PETSC_RESTRICT _p3 = p3; \
const PetscScalar *PETSC_RESTRICT _p4 = p4; \
PetscScalar *PETSC_RESTRICT _U = U; \
for (PetscInt __i = 0; __i < _n; __i++) _U[__i] += _a1 * _p1[__i] + _a2 * _p2[__i] + _a3 * _p3[__i] + _a4 * _p4[__i]; \
} while (0)
#endif
#endif // PETSC_KERNELS_PETSCAXPY_H
|
cdd3caa547f34b413ad88d0b55ecf36fb8f99d0a
|
ecce427678ecff2a93a47f3b1b664202c7d27617
|
/assets/anims/anim_16.inc.c
|
981914478a374c9f8d69037b0f41c0af00e9f778
|
[] |
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
| 20,275
|
c
|
anim_16.inc.c
|
static const struct Animation anim_16[] = {
0,
189,
0,
0,
0x64,
ANIMINDEX_NUMPARTS(anim_16_indices),
anim_16_values,
anim_16_indices,
0,
};
static const u16 anim_16_indices[] = {
0x0001, 0x0000, 0x0064, 0x0001, 0x0001, 0x0065, 0x0001, 0x0000, 0x0001, 0x0066, 0x0001, 0x0000,
0x0064, 0x084D, 0x0001, 0x0000, 0x0001, 0x08B1,
0x0064, 0x0721, 0x0064, 0x0785, 0x0064, 0x07E9,
0x0064, 0x05F5, 0x0064, 0x0659, 0x0064, 0x06BD,
0x0001, 0x05F1, 0x0001, 0x05F2, 0x0001, 0x05F3,
0x0001, 0x006B, 0x0001, 0x006C, 0x0001, 0x006D,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x006A,
0x0001, 0x0067, 0x0001, 0x0068, 0x0001, 0x0069,
0x0001, 0x05ED, 0x0001, 0x05EE, 0x0001, 0x05EF,
0x0001, 0x0072, 0x0001, 0x0073, 0x0001, 0x0074,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0071,
0x0001, 0x006E, 0x0001, 0x006F, 0x0001, 0x0070,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x05F0,
0x0064, 0x04C1, 0x0064, 0x0525, 0x0064, 0x0589,
0x0001, 0x0000, 0x0001, 0x0000, 0x0064, 0x045D,
0x0064, 0x0331, 0x0064, 0x0395, 0x0064, 0x03F9,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x05F4,
0x0064, 0x0205, 0x0064, 0x0269, 0x0064, 0x02CD,
0x0001, 0x0000, 0x0001, 0x0000, 0x0064, 0x01A1,
0x0064, 0x0075, 0x0064, 0x00D9, 0x0064, 0x013D,
};
static const s16 anim_16_values[] = {
0x0000, 0x00B3, 0x00B3, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B8,
0x00B9, 0x00BB, 0x00BC, 0x00BE, 0x00C0, 0x00C1, 0x00C3, 0x00C4,
0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C8, 0x00C8, 0x00C7, 0x00C6,
0x00C5, 0x00C4, 0x00C2, 0x00C1, 0x00BF, 0x00BD, 0x00BC, 0x00BA,
0x00B8, 0x00B6, 0x00B5, 0x00B4, 0x00B3, 0x00B2, 0x00B3, 0x00B3,
0x00B4, 0x00B3, 0x00B2, 0x00B1, 0x00B1, 0x00B2, 0x00B4, 0x00B6,
0x00B8, 0x00BA, 0x00BD, 0x00BF, 0x00C1, 0x00C3, 0x00C5, 0x00C7,
0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CB,
0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C8, 0x00C6, 0x00C5, 0x00C4,
0x00C3, 0x00C1, 0x00C0, 0x00BF, 0x00BD, 0x00BC, 0x00BA, 0x00B9,
0x00B8, 0x00B7, 0x00B5, 0x00B4, 0x00B3, 0x00B2, 0x00B1, 0x00B0,
0x00B0, 0x00AF, 0x00AF, 0x00AF, 0x00AF, 0x00B0, 0x00B0, 0x00B1,
0x00B1, 0x00B2, 0x00B2, 0x00B3, 0x00B3, 0xFFFF, 0x3FFF, 0xE7CE,
0xF984, 0xE96B, 0xF446, 0x0FB9, 0xF4A2, 0x94B9, 0x0ACF, 0x020D,
0xEDD2, 0xE463, 0xF6CC, 0x0FE6, 0x99E5, 0x0406, 0x040E, 0x0423,
0x0444, 0x0470, 0x04A6, 0x04E5, 0x052A, 0x0575, 0x05C4, 0x0617,
0x066A, 0x06BE, 0x0711, 0x0761, 0x07AE, 0x07F5, 0x0835, 0x086E,
0x089E, 0x08C2, 0x08DB, 0x08E7, 0x08E4, 0x0231, 0x0171, 0x00C9,
0x0038, 0xFFBC, 0xFF52, 0xFEFA, 0xFEB0, 0xFE74, 0xFE44, 0xFE1E,
0xFE00, 0xFE09, 0xFE4E, 0xFEBE, 0xFF46, 0xFFD5, 0x0057, 0x00BC,
0x00F2, 0x0108, 0x011A, 0x0128, 0x0132, 0x013A, 0x013E, 0x0141,
0x0140, 0x013E, 0x013A, 0x0135, 0x012F, 0x0128, 0x0121, 0x0119,
0x0112, 0x010B, 0x0104, 0x00FF, 0x00FB, 0x00F9, 0x00F8, 0x00FA,
0x00FE, 0x0102, 0x0103, 0x0101, 0x00FE, 0x00FA, 0x00F5, 0x00F0,
0x00ED, 0x00EA, 0x00EA, 0x00ED, 0x00F2, 0x00FC, 0x010B, 0x011F,
0x0138, 0x0158, 0x0180, 0x01AF, 0x01E7, 0x024E, 0x02FC, 0x03D8,
0x04CA, 0x05BA, 0x0691, 0x0736, 0x0790, 0x071C, 0x05E2, 0x049C,
0x0406, 0x017C, 0x017C, 0x017B, 0x017A, 0x0179, 0x0177, 0x0175,
0x0173, 0x0171, 0x016E, 0x016C, 0x0169, 0x0166, 0x0164, 0x0161,
0x015F, 0x015D, 0x015B, 0x0159, 0x0158, 0x0156, 0x0156, 0x0155,
0x0156, 0x0188, 0x0189, 0x018A, 0x018A, 0x018A, 0x0189, 0x0187,
0x0185, 0x0182, 0x017F, 0x017B, 0x0177, 0x0171, 0x0169, 0x015E,
0x0153, 0x0148, 0x013F, 0x0137, 0x0133, 0x0131, 0x012F, 0x012D,
0x012B, 0x012A, 0x0129, 0x0128, 0x0127, 0x0126, 0x0126, 0x0126,
0x0125, 0x0125, 0x0125, 0x0125, 0x0126, 0x0126, 0x0126, 0x0127,
0x0127, 0x0128, 0x0128, 0x0129, 0x0129, 0x0128, 0x0125, 0x0121,
0x011B, 0x0114, 0x010D, 0x0105, 0x00FE, 0x00F7, 0x00F1, 0x00ED,
0x00EB, 0x00EA, 0x00ED, 0x00F2, 0x00FA, 0x0107, 0x0117, 0x012C,
0x0146, 0x017D, 0x01DD, 0x0258, 0x02DF, 0x0363, 0x03D5, 0x0426,
0x0448, 0x03DA, 0x02E4, 0x01ED, 0x017C, 0xB647, 0xB653, 0xB677,
0xB6B0, 0xB6FC, 0xB75A, 0xB7C8, 0xB844, 0xB8CB, 0xB95C, 0xB9F6,
0xBA96, 0xBB3A, 0xBBE1, 0xBC88, 0xBD2E, 0xBDD0, 0xBE6E, 0xBF04,
0xBF92, 0xC014, 0xC08A, 0xC0F2, 0xC149, 0xBC8C, 0xBBC9, 0xBB07,
0xBA4D, 0xB9A1, 0xB90A, 0xB88D, 0xB832, 0xB7FE, 0xB7F7, 0xB824,
0xB88C, 0xB98C, 0xBB53, 0xBD9E, 0xC02C, 0xC2BA, 0xC506, 0xC6CD,
0xC7CE, 0xC84A, 0xC8B2, 0xC907, 0xC94A, 0xC97D, 0xC9A2, 0xC9BA,
0xC9C7, 0xC9CA, 0xC9C5, 0xC9B8, 0xC9A7, 0xC992, 0xC97B, 0xC963,
0xC94C, 0xC938, 0xC928, 0xC91D, 0xC919, 0xC91E, 0xC92D, 0xC947,
0xC96F, 0xC9AA, 0xC9F9, 0xCA5B, 0xCACB, 0xCB47, 0xCBCC, 0xCC57,
0xCCE4, 0xCD70, 0xCDF9, 0xCE7B, 0xCEF3, 0xCF5E, 0xCFBA, 0xD002,
0xD033, 0xD04C, 0xD048, 0xD025, 0xCFDF, 0xCF27, 0xCDC6, 0xCBE2,
0xC99F, 0xC723, 0xC494, 0xC214, 0xBFCB, 0xBD1B, 0xB9F8, 0xB75D,
0xB647, 0x2A1A, 0x2A11, 0x29F6, 0x29CD, 0x2998, 0x295A, 0x2914,
0x28CA, 0x287E, 0x2833, 0x27EB, 0x27A8, 0x276D, 0x273D, 0x271B,
0x2708, 0x2707, 0x271B, 0x2746, 0x278B, 0x27EC, 0x286C, 0x290E,
0x29D3, 0x2B07, 0x2CDD, 0x2F38, 0x31F7, 0x34FC, 0x3828, 0x3B5D,
0x3E7B, 0x4163, 0x43F7, 0x4617, 0x47A4, 0x488C, 0x48DC, 0x48A7,
0x47FF, 0x46F7, 0x45A3, 0x4414, 0x425E, 0x4087, 0x3E8C, 0x3C71,
0x3A39, 0x37E9, 0x3585, 0x3311, 0x3092, 0x2E0A, 0x2B7E, 0x28F3,
0x266C, 0x23EE, 0x217C, 0x1F1B, 0x1CCE, 0x1A9A, 0x1883, 0x168C,
0x14BB, 0x1312, 0x1196, 0x104C, 0x0F36, 0x0E5D, 0x0DC0, 0x0D5C,
0x0D2C, 0x0D2B, 0x0D55, 0x0DA6, 0x0E19, 0x0EA9, 0x0F53, 0x1011,
0x10DF, 0x11B9, 0x129A, 0x137E, 0x1460, 0x153C, 0x160D, 0x16CF,
0x177E, 0x1839, 0x1920, 0x1A2D, 0x1B5D, 0x1CAA, 0x1E10, 0x1F89,
0x2110, 0x2359, 0x265C, 0x28FB, 0x2A1A, 0x14B9, 0x14B7, 0x14B1,
0x14A7, 0x1499, 0x1486, 0x146E, 0x1452, 0x1431, 0x140C, 0x13E1,
0x13B1, 0x137C, 0x1342, 0x1302, 0x12BD, 0x1272, 0x1221, 0x11CA,
0x116D, 0x110A, 0x10A1, 0x1031, 0x0FBB, 0x0F2D, 0x0E7A, 0x0DA8,
0x0CBB, 0x0BB8, 0x0AA7, 0x098B, 0x0869, 0x0749, 0x062D, 0x051D,
0x041D, 0x030B, 0x01D2, 0x0089, 0xFF4A, 0xFE2B, 0xFD45, 0xFCB0,
0xFC86, 0xFCA0, 0xFCCA, 0xFD03, 0xFD49, 0xFD9B, 0xFDF9, 0xFE5F,
0xFECF, 0xFF45, 0xFFC2, 0x0042, 0x00C7, 0x014F, 0x01D7, 0x0260,
0x02E7, 0x036C, 0x03ED, 0x0469, 0x04DF, 0x054E, 0x05B4, 0x0611,
0x0662, 0x06A8, 0x06E3, 0x0714, 0x073D, 0x075E, 0x077A, 0x0792,
0x07A6, 0x07B9, 0x07CB, 0x07DE, 0x07F3, 0x080C, 0x0829, 0x084C,
0x0876, 0x08A9, 0x08E6, 0x092E, 0x0983, 0x09FA, 0x0AA2, 0x0B71,
0x0C5D, 0x0D5B, 0x0E62, 0x0F67, 0x105F, 0x1194, 0x1304, 0x1438,
0x14B9, 0x0963, 0x096A, 0x097E, 0x099F, 0x09CA, 0x09FE, 0x0A3C,
0x0A80, 0x0ACA, 0x0B19, 0x0B6B, 0x0BC0, 0x0C16, 0x0C6B, 0x0CBF,
0x0D11, 0x0D5E, 0x0DA7, 0x0DE9, 0x0E24, 0x0E56, 0x0E7E, 0x0E9B,
0x0EAC, 0x0EA6, 0x0E83, 0x0E47, 0x0DF8, 0x0D99, 0x0D2F, 0x0CBE,
0x0C4B, 0x0BDA, 0x0B6F, 0x0B0F, 0x0ABF, 0x0A7B, 0x0A3D, 0x0A04,
0x09CF, 0x099E, 0x0970, 0x0943, 0x0918, 0x08EB, 0x08BC, 0x088B,
0x0859, 0x0826, 0x07F1, 0x07BD, 0x0788, 0x0753, 0x071F, 0x06EC,
0x06BB, 0x068B, 0x065D, 0x0631, 0x0609, 0x05E3, 0x05C1, 0x05A3,
0x0588, 0x0573, 0x0562, 0x0557, 0x0551, 0x0552, 0x0559, 0x0568,
0x057C, 0x0596, 0x05B6, 0x05DA, 0x0602, 0x062F, 0x065F, 0x0691,
0x06C7, 0x06FE, 0x0737, 0x0772, 0x07AD, 0x07E8, 0x0824, 0x085E,
0x0898, 0x08E2, 0x0948, 0x09BE, 0x0A3A, 0x0AB0, 0x0B18, 0x0B64,
0x0B8B, 0x0B3E, 0x0A80, 0x09BC, 0x0963, 0xC2A4, 0xC2B6, 0xC2E9,
0xC339, 0xC3A3, 0xC424, 0xC4B8, 0xC55A, 0xC609, 0xC6BF, 0xC77A,
0xC836, 0xC8EF, 0xC9A2, 0xCA4C, 0xCAE7, 0xCB72, 0xCBE9, 0xCC47,
0xCC89, 0xCCAD, 0xCCAD, 0xCC87, 0xCC37, 0xCB97, 0xCA8C, 0xC924,
0xC76C, 0xC571, 0xC341, 0xC0E9, 0xBE76, 0xBBF6, 0xB976, 0xB704,
0xB4AC, 0xB209, 0xAED6, 0xAB59, 0xA7D5, 0xA48D, 0xA1C5, 0x9FC0,
0x9EC4, 0x9E72, 0x9E3F, 0x9E2A, 0x9E2F, 0x9E4E, 0x9E83, 0x9ECE,
0x9F2B, 0x9F99, 0xA015, 0xA09F, 0xA132, 0xA1CF, 0xA271, 0xA318,
0xA3C1, 0xA46B, 0xA512, 0xA5B5, 0xA653, 0xA6E8, 0xA773, 0xA7F2,
0xA863, 0xA8C9, 0xA92B, 0xA98B, 0xA9E7, 0xAA42, 0xAA9C, 0xAAF6,
0xAB50, 0xABAC, 0xAC09, 0xAC69, 0xACCD, 0xAD35, 0xADA1, 0xAE14,
0xAE8D, 0xAF0D, 0xAF95, 0xB025, 0xB0C0, 0xB173, 0xB24D, 0xB349,
0xB465, 0xB59D, 0xB6ED, 0xB852, 0xB9C8, 0xBC01, 0xBEF5, 0xC189,
0xC2A4, 0xFEC6, 0xFEC3, 0xFEBC, 0xFEB0, 0xFEA2, 0xFE92, 0xFE80,
0xFE6E, 0xFE5C, 0xFE4B, 0xFE3C, 0xFE30, 0xFE28, 0xFE24, 0xFE25,
0xFE2D, 0xFE3C, 0xFE52, 0xFE71, 0xFE99, 0xFED1, 0xFF1B, 0xFF76,
0xFFDD, 0x004E, 0x00C8, 0x0148, 0x01CA, 0x024C, 0x02CB, 0x0346,
0x03B8, 0x0420, 0x047A, 0x04C5, 0x04FD, 0x01F6, 0x0315, 0x0440,
0x04DE, 0x04AA, 0x03FE, 0x0335, 0x02A7, 0x025B, 0x0219, 0x01DF,
0x01AD, 0x017F, 0x0155, 0x012C, 0x0104, 0x00DA, 0x00AF, 0x0084,
0x0059, 0x002E, 0x0003, 0xFFDB, 0xFFB2, 0xFF8C, 0xFF67, 0xFF44,
0xFF24, 0xFF07, 0xFEEE, 0xFED8, 0xFEC6, 0xFEB7, 0xFEAB, 0xFEA3,
0xFE9C, 0xFE98, 0xFE96, 0xFE95, 0xFE96, 0xFE99, 0xFE9C, 0xFEA0,
0xFEA5, 0xFEAA, 0xFEAF, 0xFEB4, 0xFEB9, 0xFEBD, 0xFEC0, 0xFEC2,
0xFEC3, 0xFEC4, 0xFEC5, 0xFEC6, 0xFEC7, 0xFEC7, 0xFEC7, 0xFEC7,
0xFEC6, 0xFEC6, 0xFEC6, 0xFEC6, 0xFEC6, 0x0008, 0x0009, 0x000C,
0x0011, 0x0017, 0x001E, 0x0026, 0x002F, 0x0038, 0x0041, 0x004A,
0x0052, 0x0059, 0x0060, 0x0065, 0x0068, 0x0069, 0x0068, 0x0065,
0x005E, 0x0055, 0x0048, 0x0039, 0x0027, 0x0012, 0xFFFD, 0xFFE5,
0xFFCC, 0xFFB2, 0xFF97, 0xFF7C, 0xFF61, 0xFF46, 0xFF2B, 0xFF12,
0xFEF9, 0xFEC5, 0xFEAB, 0xFE92, 0xFE78, 0xFE57, 0xFE32, 0xFE14,
0xFE08, 0xFE0C, 0xFE16, 0xFE24, 0xFE35, 0xFE48, 0xFE5D, 0xFE73,
0xFE88, 0xFE9E, 0xFEB6, 0xFED0, 0xFEEA, 0xFF06, 0xFF22, 0xFF3E,
0xFF5A, 0xFF75, 0xFF8E, 0xFFA6, 0xFFBC, 0xFFD0, 0xFFE1, 0xFFEF,
0xFFF9, 0x0000, 0x0003, 0x0005, 0x0004, 0x0002, 0xFFFF, 0xFFFA,
0xFFF3, 0xFFEC, 0xFFE4, 0xFFDC, 0xFFD4, 0xFFCC, 0xFFC4, 0xFFBE,
0xFFB8, 0xFFB3, 0xFFB0, 0xFFAE, 0xFFAF, 0xFFC0, 0xFFE4, 0x0008,
0x001E, 0x0022, 0x0023, 0x0020, 0x001A, 0x0014, 0x000E, 0x0009,
0x0008, 0xC07B, 0xC08A, 0xC0B6, 0xC0FB, 0xC157, 0xC1C5, 0xC243,
0xC2CD, 0xC361, 0xC3FA, 0xC497, 0xC532, 0xC5CB, 0xC65C, 0xC6E3,
0xC75C, 0xC7C5, 0xC81A, 0xC858, 0xC87C, 0xC886, 0xC87A, 0xC85A,
0xC827, 0xC7E6, 0xC797, 0xC73C, 0xC6D8, 0xC66D, 0xC5FD, 0xC58A,
0xC517, 0xC4A5, 0xC437, 0xC3CE, 0xC36E, 0xC128, 0xBFB6, 0xBE43,
0xBCAC, 0xBA92, 0xB822, 0xB615, 0xB524, 0xB539, 0xB5B6, 0xB67D,
0xB772, 0xB879, 0xB974, 0xBA47, 0xBAD6, 0xBB3A, 0xBB9E, 0xBC01,
0xBC62, 0xBCBF, 0xBD17, 0xBD6A, 0xBDB5, 0xBDF7, 0xBE30, 0xBE5E,
0xBE7F, 0xBE93, 0xBE99, 0xBE8E, 0xBE72, 0xBE3A, 0xBDE2, 0xBD6D,
0xBCE1, 0xBC42, 0xBB95, 0xBADF, 0xBA24, 0xB969, 0xB8B2, 0xB806,
0xB767, 0xB6DC, 0xB668, 0xB611, 0xB5DB, 0xB5CB, 0xB5E6, 0xB5F3,
0xB5D0, 0xB59C, 0xB578, 0xB586, 0xB5E6, 0xB6E2, 0xB87A, 0xBA63,
0xBC4D, 0xBDEB, 0xBEF1, 0xBF10, 0xBDFC, 0x378C, 0x3745, 0x3678,
0x3534, 0x3389, 0x3183, 0x2F33, 0x2CA6, 0x29EB, 0x2710, 0x2424,
0x2136, 0x1E55, 0x1B8D, 0x18EF, 0x1689, 0x1469, 0x129E, 0x1137,
0x1041, 0x0FBD, 0x0F99, 0x0FCB, 0x1049, 0x1108, 0x11FE, 0x1320,
0x1464, 0x15BF, 0x1728, 0x1893, 0x19F7, 0x1B49, 0x1C7E, 0x1D8D,
0x1E6A, 0x1F2A, 0x1FE4, 0x2092, 0x212D, 0x21AF, 0x2211, 0x224D,
0x225D, 0x2224, 0x219F, 0x20E6, 0x2014, 0x1F43, 0x1E8D, 0x1E0D,
0x1DDD, 0x1DDE, 0x1DE3, 0x1DED, 0x1DFD, 0x1E14, 0x1E34, 0x1E5E,
0x1E93, 0x1ED4, 0x1F23, 0x1F80, 0x1FEE, 0x206C, 0x20FE, 0x21A3,
0x225D, 0x2334, 0x242D, 0x2545, 0x2676, 0x27BF, 0x291A, 0x2A83,
0x2BF8, 0x2D73, 0x2EF2, 0x306F, 0x31E8, 0x3358, 0x34BC, 0x3610,
0x374F, 0x3876, 0x3981, 0x3A6C, 0x3B33, 0x3BD3, 0x3C47, 0x3C8C,
0x3C9D, 0x3C77, 0x3C1B, 0x3B94, 0x3AE9, 0x3A24, 0x394D, 0x386D,
0x378C, 0xF629, 0xF62A, 0xF62F, 0xF635, 0xF63D, 0xF646, 0xF64F,
0xF658, 0xF65F, 0xF665, 0xF669, 0xF66A, 0xF667, 0xF661, 0xF655,
0xF644, 0xF62D, 0xF610, 0xF5EB, 0xF5BE, 0xF589, 0xF54B, 0xF506,
0xF4B9, 0xF465, 0xF40A, 0xF3AA, 0xF343, 0xF2D8, 0xF267, 0xF1F2,
0xF17A, 0xF0FE, 0xF07F, 0xEFFD, 0xEF79, 0xEED8, 0xEE0A, 0xED20,
0xEC2C, 0xEB3F, 0xEA6A, 0xE9BE, 0xE94D, 0xE916, 0xE90A, 0xE921,
0xE953, 0xE999, 0xE9EB, 0xEA42, 0xEA96, 0xEAE8, 0xEB3F, 0xEB9A,
0xEBF9, 0xEC5B, 0xECBF, 0xED25, 0xED8E, 0xEDF7, 0xEE60, 0xEECA,
0xEF33, 0xEF9C, 0xF003, 0xF068, 0xF0CA, 0xF12D, 0xF191, 0xF1F7,
0xF25E, 0xF2C6, 0xF32E, 0xF394, 0xF3FA, 0xF45E, 0xF4C0, 0xF51E,
0xF57A, 0xF5D1, 0xF624, 0xF672, 0xF6BA, 0xF6F6, 0xF721, 0xF73D,
0xF74D, 0xF754, 0xF753, 0xF74D, 0xF745, 0xF732, 0xF70E, 0xF6E0,
0xF6AE, 0xF67C, 0xF652, 0xF634, 0xF629, 0xF79A, 0xF7A2, 0xF7B9,
0xF7DF, 0xF810, 0xF84D, 0xF893, 0xF8E1, 0xF935, 0xF98E, 0xF9EA,
0xFA48, 0xFAA6, 0xFB03, 0xFB5E, 0xFBB4, 0xFC05, 0xFC4E, 0xFC8F,
0xFCC6, 0xFCF3, 0xFD1B, 0xFD3E, 0xFD5C, 0xFD76, 0xFD8D, 0xFDA1,
0xFDB3, 0xFDC4, 0xFDD4, 0xFDE4, 0xFDF5, 0xFE07, 0xFE1C, 0xFE33,
0xFE4D, 0xFE6C, 0xFE91, 0xFEB9, 0xFEE2, 0xFF0A, 0xFF2E, 0xFF4E,
0xFF67, 0xFF80, 0xFF9F, 0xFFBF, 0xFFD8, 0xFFE6, 0xFFE3, 0xFFC7,
0xFF8E, 0xFF3E, 0xFEE1, 0xFE7B, 0xFE0C, 0xFD95, 0xFD1A, 0xFC9A,
0xFC18, 0xFB96, 0xFB14, 0xFA95, 0xFA1A, 0xF9A5, 0xF937, 0xF8D2,
0xF878, 0xF827, 0xF7DE, 0xF79C, 0xF75F, 0xF728, 0xF6F4, 0xF6C3,
0xF694, 0xF666, 0xF639, 0xF60B, 0xF5DC, 0xF5AA, 0xF574, 0xF53A,
0xF4FB, 0xF4A7, 0xF436, 0xF3B7, 0xF338, 0xF2C6, 0xF270, 0xF242,
0xF24C, 0xF2A6, 0xF34F, 0xF42B, 0xF51D, 0xF60A, 0xF6D5, 0xF764,
0xF79A, 0xAAEC, 0xAAE3, 0xAAC8, 0xAAA0, 0xAA6B, 0xAA2C, 0xA9E7,
0xA99D, 0xA950, 0xA904, 0xA8BB, 0xA878, 0xA83C, 0xA80A, 0xA7E6,
0xA7D0, 0xA7CD, 0xA7DD, 0xA804, 0xA845, 0xA8A2, 0xA91B, 0xA9AD,
0xAA56, 0xAB14, 0xABE3, 0xACC1, 0xADAC, 0xAEA1, 0xAF9D, 0xB09F,
0xB1A2, 0xB2A6, 0xB3A6, 0xB4A1, 0xB595, 0xB68E, 0xB79B, 0xB8B7,
0xB9DE, 0xBB0D, 0xBC3F, 0xBD70, 0xBE9D, 0xBFD7, 0xC12B, 0xC28B,
0xC3E8, 0xC534, 0xC660, 0xC760, 0xC824, 0xC8C3, 0xC95E, 0xC9F3,
0xCA82, 0xCB0A, 0xCB88, 0xCBFE, 0xCC68, 0xCCC6, 0xCD18, 0xCD5C,
0xCD91, 0xCDB6, 0xCDCA, 0xCDCD, 0xCDBC, 0xCD9A, 0xCD69, 0xCD2B,
0xCCDE, 0xCC82, 0xCC18, 0xCBA0, 0xCB18, 0xCA82, 0xC9DE, 0xC92A,
0xC868, 0xC796, 0xC6B6, 0xC5C7, 0xC4C8, 0xC390, 0xC201, 0xC02F,
0xBE2E, 0xBC12, 0xB9EF, 0xB7D9, 0xB5E5, 0xB426, 0xB273, 0xB0AB,
0xAEEF, 0xAD5E, 0xAC17, 0xAB3C, 0xAAEC, 0x8001, 0x8001, 0x4171,
0xBF5F, 0x8001, 0x8001, 0x4171, 0xBF5F, 0xFBEE, 0xFBF0, 0xFBF9,
0xFC06, 0xFC19, 0xFC30, 0xFC4C, 0xFC6B, 0xFC8F, 0xFCB6, 0xFCE0,
0xFD0D, 0xFD3D, 0xFD6F, 0xFDA4, 0xFDDA, 0xFE12, 0xFE4B, 0xFE85,
0xFEBF, 0xFEFB, 0xFF36, 0xFF71, 0xFFAC, 0xFFE6, 0x001E, 0x0056,
0x008C, 0x00C0, 0x00F3, 0x0122, 0x0150, 0x017A, 0x01A1, 0x01C4,
0x01E4, 0x01FF, 0x0216, 0x0229, 0x0236, 0x023F, 0x0243, 0x0242,
0x023D, 0x0234, 0x0227, 0x0217, 0x0204, 0x01ED, 0x01D4, 0x01B8,
0x019A, 0x017A, 0x0158, 0x0134, 0x010F, 0x00E9, 0x00C3, 0x009B,
0x0073, 0x004B, 0x0024, 0xFFFD, 0xFFD7, 0xFFB1, 0xFF8C, 0xFF68,
0xFF47, 0xFF27, 0xFF09, 0xFEED, 0xFED3, 0xFEB9, 0xFE9F, 0xFE85,
0xFE6C, 0xFE52, 0xFE39, 0xFE20, 0xFE07, 0xFDEE, 0xFDD5, 0xFDBC,
0xFDA3, 0xFD8B, 0xFD72, 0xFD59, 0xFD40, 0xFD26, 0xFD0D, 0xFCF4,
0xFCDA, 0xFCC1, 0xFCA7, 0xFC8D, 0xFC72, 0xFC4F, 0xFC23, 0xFBFD,
0xFBEE, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFE, 0xFFFD, 0xFFFC,
0xFFFB, 0xFFF9, 0xFFF7, 0xFFF5, 0xFFF3, 0xFFF1, 0xFFEF, 0xFFEC,
0xFFEA, 0xFFE7, 0xFFE5, 0xFFE2, 0xFFDF, 0xFFDD, 0xFFDA, 0xFFD8,
0xFFD5, 0xFFD2, 0xFFD0, 0xFFCE, 0xFFCB, 0xFFC9, 0xFFC7, 0xFFC5,
0xFFC3, 0xFFC2, 0xFFC0, 0xFFBF, 0xFFBE, 0xFFBD, 0xFFBC, 0xFFBC,
0xFFBC, 0xFFBC, 0xFFBC, 0xFFBD, 0xFFBE, 0xFFBF, 0xFFC1, 0xFFC2,
0xFFC4, 0xFFC6, 0xFFC8, 0xFFCA, 0xFFCD, 0xFFCF, 0xFFD2, 0xFFD4,
0xFFD7, 0xFFDA, 0xFFDD, 0xFFE0, 0xFFE3, 0xFFE6, 0xFFE8, 0xFFEB,
0xFFEE, 0xFFF1, 0xFFF3, 0xFFF6, 0xFFF8, 0xFFFB, 0xFFFD, 0xFFFF,
0x0000, 0x0001, 0x0003, 0x0005, 0x0006, 0x0008, 0x000A, 0x000B,
0x000D, 0x000F, 0x0010, 0x0012, 0x0013, 0x0014, 0x0016, 0x0017,
0x0018, 0x0019, 0x001A, 0x001A, 0x001B, 0x001C, 0x001C, 0x001C,
0x001C, 0x0018, 0x000E, 0x0004, 0x0000, 0x109A, 0x109B, 0x109F,
0x10A4, 0x10AC, 0x10B6, 0x10C2, 0x10CF, 0x10DE, 0x10EE, 0x1100,
0x1113, 0x1126, 0x113B, 0x1151, 0x1167, 0x117E, 0x1196, 0x11AD,
0x11C5, 0x11DD, 0x11F5, 0x120C, 0x1224, 0x123B, 0x1251, 0x1267,
0x127C, 0x128F, 0x12A2, 0x12B4, 0x12C4, 0x12D3, 0x12E0, 0x12EC,
0x12F6, 0x12FE, 0x1303, 0x1307, 0x1308, 0x1306, 0x1302, 0x12FA,
0x12F0, 0x12E3, 0x12D4, 0x12C3, 0x12AF, 0x129B, 0x1284, 0x126C,
0x1253, 0x123A, 0x121F, 0x1204, 0x11E8, 0x11CC, 0x11B1, 0x1195,
0x117A, 0x115F, 0x1146, 0x112D, 0x1115, 0x10FF, 0x10EA, 0x10D7,
0x10C6, 0x10B8, 0x10AB, 0x10A1, 0x109A, 0x1096, 0x1096, 0x109A,
0x10A0, 0x10A9, 0x10B5, 0x10C3, 0x10D3, 0x10E4, 0x10F7, 0x110A,
0x111E, 0x1132, 0x1147, 0x115A, 0x116D, 0x117F, 0x1190, 0x119F,
0x11AC, 0x11B6, 0x11BE, 0x11C3, 0x11C5, 0x1196, 0x1130, 0x10C9,
0x109A, 0xFFE7, 0xFFE7, 0xFFE5, 0xFFE1, 0xFFDD, 0xFFD8, 0xFFD2,
0xFFCB, 0xFFC3, 0xFFBB, 0xFFB2, 0xFFA9, 0xFFA0, 0xFF96, 0xFF8D,
0xFF84, 0xFF7B, 0xFF72, 0xFF6A, 0xFF62, 0xFF5B, 0xFF55, 0xFF50,
0xFF4B, 0xFF48, 0xFF45, 0xFF43, 0xFF41, 0xFF40, 0xFF3F, 0xFF3F,
0xFF3F, 0xFF3F, 0xFF3F, 0xFF40, 0xFF40, 0xFF41, 0xFF42, 0xFF43,
0xFF44, 0xFF44, 0xFF45, 0xFF45, 0xFF46, 0xFF45, 0xFF45, 0xFF44,
0xFF44, 0xFF43, 0xFF42, 0xFF41, 0xFF40, 0xFF3F, 0xFF3D, 0xFF3D,
0xFF3C, 0xFF3B, 0xFF3B, 0xFF3B, 0xFF3B, 0xFF3B, 0xFF3C, 0xFF3D,
0xFF3F, 0xFF41, 0xFF44, 0xFF47, 0xFF4B, 0xFF50, 0xFF55, 0xFF5B,
0xFF62, 0xFF6A, 0xFF72, 0xFF7A, 0xFF83, 0xFF8C, 0xFF96, 0xFF9F,
0xFFA9, 0xFFB3, 0xFFBD, 0xFFC6, 0xFFD0, 0xFFD9, 0xFFE2, 0xFFEA,
0xFFF2, 0xFFFA, 0x0000, 0x0006, 0x000B, 0x000D, 0x000B, 0x0005,
0xFFFF, 0xFFF6, 0xFFEF, 0xFFEA, 0xFFE7, 0xFF0A, 0xFF07, 0xFEFD,
0xFEED, 0xFED8, 0xFEBF, 0xFEA2, 0xFE82, 0xFE5F, 0xFE3B, 0xFE15,
0xFDEF, 0xFDC8, 0xFDA3, 0xFD7E, 0xFD5C, 0xFD3C, 0xFD20, 0xFD07,
0xFCF3, 0xFCE5, 0xFCDC, 0xFCDA, 0xFCDF, 0xFCEB, 0xFCFF, 0xFD1B,
0xFD3C, 0xFD63, 0xFD8F, 0xFDBF, 0xFDF3, 0xFE29, 0xFE62, 0xFE9C,
0xFED8, 0xFF13, 0xFF4E, 0xFF87, 0xFFBF, 0xFFF4, 0x0025, 0x0053,
0x007D, 0x00A5, 0x00CE, 0x00F9, 0x0124, 0x0150, 0x017C, 0x01A8,
0x01D4, 0x0200, 0x022A, 0x0254, 0x027C, 0x02A3, 0x02C8, 0x02EB,
0x030B, 0x0329, 0x0343, 0x035B, 0x036F, 0x037F, 0x038B, 0x0393,
0x0396, 0x0394, 0x038D, 0x0383, 0x0374, 0x0361, 0x034A, 0x0331,
0x0314, 0x02F5, 0x02D3, 0x02AF, 0x0289, 0x0262, 0x0239, 0x0210,
0x01E6, 0x01BB, 0x0190, 0x0166, 0x013C, 0x0113, 0x00EA, 0x00C3,
0x009E, 0x0071, 0x0036, 0xFFF4, 0xFFB0, 0xFF71, 0xFF3C, 0xFF17,
0xFF0A, 0xF261, 0xF265, 0xF271, 0xF284, 0xF29E, 0xF2BE, 0xF2E3,
0xF30D, 0xF33C, 0xF36E, 0xF3A3, 0xF3DB, 0xF415, 0xF450, 0xF48C,
0xF4C8, 0xF504, 0xF53F, 0xF578, 0xF5AF, 0xF5E3, 0xF614, 0xF642,
0xF66A, 0xF691, 0xF6BA, 0xF6E3, 0xF70E, 0xF739, 0xF764, 0xF790,
0xF7BB, 0xF7E6, 0xF80F, 0xF838, 0xF85F, 0xF885, 0xF8A9, 0xF8CA,
0xF8EA, 0xF906, 0xF91F, 0xF935, 0xF947, 0xF956, 0xF960, 0xF966,
0xF967, 0xF962, 0xF953, 0xF93E, 0xF921, 0xF8FE, 0xF8D6, 0xF8AA,
0xF87A, 0xF847, 0xF811, 0xF7DB, 0xF7A3, 0xF76C, 0xF736, 0xF702,
0xF6D0, 0xF6A2, 0xF677, 0xF652, 0xF632, 0xF617, 0xF5FE, 0xF5E8,
0xF5D3, 0xF5C1, 0xF5B0, 0xF5A0, 0xF591, 0xF583, 0xF576, 0xF569,
0xF55D, 0xF550, 0xF543, 0xF535, 0xF527, 0xF518, 0xF507, 0xF4F5,
0xF4E1, 0xF4CB, 0xF4B3, 0xF499, 0xF47C, 0xF44D, 0xF405, 0xF3AE,
0xF350, 0xF2F6, 0xF2AA, 0xF275, 0xF261, 0x03C4, 0x03C1, 0x03B9,
0x03AC, 0x039A, 0x0383, 0x0367, 0x0347, 0x0324, 0x02FC, 0x02D1,
0x02A2, 0x0270, 0x023B, 0x0204, 0x01C9, 0x018D, 0x014E, 0x010E,
0x00CC, 0x0089, 0x0044, 0xFFFF, 0xFFB9, 0xFF72, 0xFF2B, 0xFEE3,
0xFE9C, 0xFE55, 0xFE0E, 0xFDC9, 0xFD84, 0xFD41, 0xFCFF, 0xFCBE,
0xFC80, 0xFC43, 0xFC09, 0xFBD2, 0xFB9D, 0xFB6B, 0xFB3C, 0xFB11,
0xFAE9, 0xFAC5, 0xFAA6, 0xFA8A, 0xFA73, 0xFA61, 0xFA54, 0xFA4C,
0xFA49, 0xFA4C, 0xFA55, 0xFA64, 0xFA79, 0xFA92, 0xFAB1, 0xFAD5,
0xFAFD, 0xFB29, 0xFB59, 0xFB8D, 0xFBC4, 0xFBFE, 0xFC3C, 0xFC7C,
0xFCBE, 0xFD02, 0xFD49, 0xFD90, 0xFDDA, 0xFE24, 0xFE6F, 0xFEBA,
0xFF06, 0xFF52, 0xFF9E, 0xFFE9, 0x0032, 0x007B, 0x00C3, 0x0109,
0x014E, 0x0190, 0x01D0, 0x020D, 0x0248, 0x027F, 0x02B3, 0x02E3,
0x0310, 0x0338, 0x035B, 0x037A, 0x0394, 0x03A8, 0x03B8, 0x03C1,
0x03C4, 0x388D,
};
|
322a3ddb4be0dfdf6b1a95a6edf3573523e1d296
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/atari/atari/pmap_bootstrap.c
|
db01072062049963a6ad7daf6e9b0124db710675
|
[] |
no_license
|
NetBSD/src
|
1a9cbc22ed778be638b37869ed4fb5c8dd616166
|
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
|
refs/heads/trunk
| 2023-08-31T13:24:58.105962
| 2023-08-27T15:50:47
| 2023-08-27T15:50:47
| 88,439,547
| 656
| 348
| null | 2023-07-20T20:07:24
| 2017-04-16T20:03:43
| null |
UTF-8
|
C
| false
| false
| 5,384
|
c
|
pmap_bootstrap.c
|
/* $NetBSD: pmap_bootstrap.c,v 1.10 2023/01/06 10:28:27 tsutsui Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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.
*/
/*
* Copyright (c) 1991 Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* 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.
*
* @(#)pmap.c 7.5 (Berkeley) 5/10/91
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/malloc.h>
#include <uvm/uvm.h>
#include <machine/pte.h>
#include <machine/cpu.h>
#include <machine/vmparam.h>
#include <m68k/cacheops.h>
struct memseg boot_segs[NMEM_SEGS];
struct memseg usable_segs[NMEM_SEGS];
extern paddr_t avail_start;
extern paddr_t avail_end;
extern paddr_t msgbufpa;
/*
* All those kernel PT submaps that BSD is so fond of
*/
void *CADDR1, *CADDR2;
char *vmmap;
/*
* Bootstrap the system enough to run with virtual memory.
*
* This is called after mapping has already been enabled
* and just syncs the pmap module with what has already been done.
*/
void
pmap_bootstrap(vaddr_t vstart)
{
vaddr_t va;
int i;
/*
* Announce page-size to the VM-system
*/
uvmexp.pagesize = NBPG;
uvm_md_init();
/*
* Setup physical address ranges
*/
for (i = 0; i < NMEM_SEGS && usable_segs[i].start; i++)
continue;
/* XXX: allow for msgbuf */
usable_segs[i - 1].end -= m68k_round_page(MSGBUFSIZE);
msgbufpa = usable_segs[i - 1].end;
/*
* Count physical memory
*/
mem_size = 0;
for (i = 0; i < NMEM_SEGS; i++) {
if (boot_segs[i].start == boot_segs[i].end)
break;
mem_size += boot_segs[i].end - boot_segs[i].start;
}
/*
* Announce available memory to the VM-system
*/
for (i = 0; i < NMEM_SEGS && usable_segs[i].start; i++)
uvm_page_physload(atop(usable_segs[i].start),
atop(usable_segs[i].end),
atop(usable_segs[i].start),
atop(usable_segs[i].end),
usable_segs[i].free_list);
avail_start = usable_segs[0].start;
avail_end = usable_segs[i - 1].end;
virtual_avail = vstart;
virtual_end = VM_MAX_KERNEL_ADDRESS;
/*
* Allocate all the submaps we need
*/
#define SYSMAP(c, v, n) \
v = (c)va; va += ((n)*PAGE_SIZE);
va = virtual_avail;
SYSMAP(void * ,CADDR1 ,1 )
SYSMAP(void * ,CADDR2 ,1 )
SYSMAP(void * ,vmmap ,1 )
SYSMAP(void * ,msgbufaddr ,btoc(MSGBUFSIZE) )
DCIS();
virtual_avail = reserve_dumppages(va);
}
|
25fcb86d4be243eb05a2e13e71642449ff1dbedc
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/audio/timidity/files/patch-playmidi.c
|
5e2f993dd1438f4f60e4a5f886743358634c88dc
|
[
"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
| 271
|
c
|
patch-playmidi.c
|
--- playmidi.c.orig 1996-05-20 13:09:46 UTC
+++ playmidi.c
@@ -27,7 +27,7 @@
#endif
#include <stdlib.h>
-#if defined(SOLARIS) || defined(__WIN32__)
+#if defined(SOLARIS) || defined(__WIN32__) || defined(__FreeBSD__)
# include <string.h>
#else
#include <strings.h>
|
91e107a767d32d54ac56d3809973e72ed5ba7da5
|
89ac799bd004042f913c9205abd22feaf847f5be
|
/src/map/Map_ScriptLoadMapBlocks_800312D0.c
|
87880f4561039ea5c1f804bf2ca8cb38bc74141a
|
[] |
no_license
|
FoxdieTeam/mgs_reversing
|
de0b501e9a6318bf817e0d0f03af34c836a2f0b6
|
d057e3eb8bebeb645ca23db6ce690577268f59d5
|
refs/heads/master
| 2023-07-21T02:31:57.827478
| 2023-07-17T10:50:39
| 2023-07-17T10:50:39
| 223,033,157
| 270
| 35
| null | 2023-09-14T21:49:31
| 2019-11-20T21:44:13
|
C
|
UTF-8
|
C
| false
| false
| 473
|
c
|
Map_ScriptLoadMapBlocks_800312D0.c
|
#include "linker.h"
#include "libgcl/libgcl.h"
#include "map.h"
extern struct map_record gMapRecs_800B7910[16];
struct map_record *Map_ScriptLoadMapBlocks_800312D0()
{
int nameHashed; // $v0
int mapNum; // $s0
while (GCL_Get_Param_Result_80020AA4())
{
mapNum = GCL_GetNextParamValue_80020AD4();
nameHashed = GCL_GetNextParamValue_80020AD4();
Map_LoadMapData_80031244(mapNum, nameHashed);
}
return gMapRecs_800B7910;
}
|
08c3f939c44d40949671d4fcb130c1ba51dde0f7
|
3c883e1084f0a61e558c2d210bb1b4ae8a5e6a06
|
/third_party/nvxs-1.0.2/CLAPACK/TESTING/LIN/dqrt17.c
|
e807835b30289c93731d24d2902b889810345357
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"Python-2.0",
"BSD-3-Clause"
] |
permissive
|
nya3jp/python-animeface
|
7e48aa333c9f365a80acdf43e5d516edc8d0b189
|
15caf8b1ca29847f0dceb54e4b91c77726c4111c
|
refs/heads/main
| 2022-04-29T20:17:01.198810
| 2022-04-04T10:17:59
| 2022-04-04T10:17:59
| 10,998,381
| 150
| 14
|
Apache-2.0
| 2022-04-03T07:18:40
| 2013-06-27T14:06:08
|
C
|
UTF-8
|
C
| false
| false
| 6,596
|
c
|
dqrt17.c
|
#include "f2c.h"
#include "blaswrap.h"
/* Table of constant values */
static integer c__1 = 1;
static integer c__13 = 13;
static doublereal c_b13 = -1.;
static doublereal c_b14 = 1.;
static integer c__0 = 0;
static doublereal c_b22 = 0.;
doublereal dqrt17_(char *trans, integer *iresid, integer *m, integer *n,
integer *nrhs, doublereal *a, integer *lda, doublereal *x, integer *
ldx, doublereal *b, integer *ldb, doublereal *c__, doublereal *work,
integer *lwork)
{
/* System generated locals */
integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, x_dim1,
x_offset, i__1;
doublereal ret_val;
/* Local variables */
doublereal err;
integer iscl, info;
extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *,
integer *, doublereal *, doublereal *, integer *, doublereal *,
integer *, doublereal *, doublereal *, integer *);
extern logical lsame_(char *, char *);
doublereal norma, normb;
integer ncols;
doublereal normx, rwork[1];
integer nrows;
extern doublereal dlamch_(char *), dlange_(char *, integer *,
integer *, doublereal *, integer *, doublereal *);
extern /* Subroutine */ int dlascl_(char *, integer *, integer *,
doublereal *, doublereal *, integer *, integer *, doublereal *,
integer *, integer *), dlacpy_(char *, integer *, integer
*, doublereal *, integer *, doublereal *, integer *),
xerbla_(char *, integer *);
doublereal bignum, smlnum, normrs;
/* -- LAPACK test routine (version 3.1) -- */
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
/* November 2006 */
/* .. Scalar Arguments .. */
/* .. */
/* .. Array Arguments .. */
/* .. */
/* Purpose */
/* ======= */
/* DQRT17 computes the ratio */
/* || R'*op(A) ||/(||A||*alpha*max(M,N,NRHS)*eps) */
/* where R = op(A)*X - B, op(A) is A or A', and */
/* alpha = ||B|| if IRESID = 1 (zero-residual problem) */
/* alpha = ||R|| if IRESID = 2 (otherwise). */
/* Arguments */
/* ========= */
/* TRANS (input) CHARACTER*1 */
/* Specifies whether or not the transpose of A is used. */
/* = 'N': No transpose, op(A) = A. */
/* = 'T': Transpose, op(A) = A'. */
/* IRESID (input) INTEGER */
/* IRESID = 1 indicates zero-residual problem. */
/* IRESID = 2 indicates non-zero residual. */
/* M (input) INTEGER */
/* The number of rows of the matrix A. */
/* If TRANS = 'N', the number of rows of the matrix B. */
/* If TRANS = 'T', the number of rows of the matrix X. */
/* N (input) INTEGER */
/* The number of columns of the matrix A. */
/* If TRANS = 'N', the number of rows of the matrix X. */
/* If TRANS = 'T', the number of rows of the matrix B. */
/* NRHS (input) INTEGER */
/* The number of columns of the matrices X and B. */
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
/* The m-by-n matrix A. */
/* LDA (input) INTEGER */
/* The leading dimension of the array A. LDA >= M. */
/* X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
/* If TRANS = 'N', the n-by-nrhs matrix X. */
/* If TRANS = 'T', the m-by-nrhs matrix X. */
/* LDX (input) INTEGER */
/* The leading dimension of the array X. */
/* If TRANS = 'N', LDX >= N. */
/* If TRANS = 'T', LDX >= M. */
/* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */
/* If TRANS = 'N', the m-by-nrhs matrix B. */
/* If TRANS = 'T', the n-by-nrhs matrix B. */
/* LDB (input) INTEGER */
/* The leading dimension of the array B. */
/* If TRANS = 'N', LDB >= M. */
/* If TRANS = 'T', LDB >= N. */
/* C (workspace) DOUBLE PRECISION array, dimension (LDB,NRHS) */
/* WORK (workspace) DOUBLE PRECISION array, dimension (LWORK) */
/* LWORK (input) INTEGER */
/* The length of the array WORK. LWORK >= NRHS*(M+N). */
/* ===================================================================== */
/* .. Parameters .. */
/* .. */
/* .. Local Scalars .. */
/* .. */
/* .. Local Arrays .. */
/* .. */
/* .. External Functions .. */
/* .. */
/* .. External Subroutines .. */
/* .. */
/* .. Intrinsic Functions .. */
/* .. */
/* .. Executable Statements .. */
/* Parameter adjustments */
a_dim1 = *lda;
a_offset = 1 + a_dim1;
a -= a_offset;
x_dim1 = *ldx;
x_offset = 1 + x_dim1;
x -= x_offset;
c_dim1 = *ldb;
c_offset = 1 + c_dim1;
c__ -= c_offset;
b_dim1 = *ldb;
b_offset = 1 + b_dim1;
b -= b_offset;
--work;
/* Function Body */
ret_val = 0.;
if (lsame_(trans, "N")) {
nrows = *m;
ncols = *n;
} else if (lsame_(trans, "T")) {
nrows = *n;
ncols = *m;
} else {
xerbla_("DQRT17", &c__1);
return ret_val;
}
if (*lwork < ncols * *nrhs) {
xerbla_("DQRT17", &c__13);
return ret_val;
}
if (*m <= 0 || *n <= 0 || *nrhs <= 0) {
return ret_val;
}
norma = dlange_("One-norm", m, n, &a[a_offset], lda, rwork);
smlnum = dlamch_("Safe minimum") / dlamch_("Precision");
bignum = 1. / smlnum;
iscl = 0;
/* compute residual and scale it */
dlacpy_("All", &nrows, nrhs, &b[b_offset], ldb, &c__[c_offset], ldb);
dgemm_(trans, "No transpose", &nrows, nrhs, &ncols, &c_b13, &a[a_offset],
lda, &x[x_offset], ldx, &c_b14, &c__[c_offset], ldb);
normrs = dlange_("Max", &nrows, nrhs, &c__[c_offset], ldb, rwork);
if (normrs > smlnum) {
iscl = 1;
dlascl_("General", &c__0, &c__0, &normrs, &c_b14, &nrows, nrhs, &c__[
c_offset], ldb, &info);
}
/* compute R'*A */
dgemm_("Transpose", trans, nrhs, &ncols, &nrows, &c_b14, &c__[c_offset],
ldb, &a[a_offset], lda, &c_b22, &work[1], nrhs);
/* compute and properly scale error */
err = dlange_("One-norm", nrhs, &ncols, &work[1], nrhs, rwork);
if (norma != 0.) {
err /= norma;
}
if (iscl == 1) {
err *= normrs;
}
if (*iresid == 1) {
normb = dlange_("One-norm", &nrows, nrhs, &b[b_offset], ldb, rwork);
if (normb != 0.) {
err /= normb;
}
} else {
normx = dlange_("One-norm", &ncols, nrhs, &x[x_offset], ldx, rwork);
if (normx != 0.) {
err /= normx;
}
}
/* Computing MAX */
i__1 = max(*m,*n);
ret_val = err / (dlamch_("Epsilon") * (doublereal) max(i__1,*
nrhs));
return ret_val;
/* End of DQRT17 */
} /* dqrt17_ */
|
8046b43edda7b997497168de371c27f132c4833d
|
8551168c7b71c31eebad0f9b0c71eebbcc743000
|
/src/lib/ultra/io/visetyscale.c
|
6b9603e20b2927257031768d69d73b271d54f2e8
|
[
"MIT"
] |
permissive
|
n64decomp/perfect_dark
|
0db80e8ecba74741b959962e55c835a91c920f44
|
0235a971d6fb1a0d4421856d5a65aa8067bd4658
|
refs/heads/master
| 2023-08-31T04:27:53.864767
| 2023-08-29T11:36:58
| 2023-08-29T11:36:58
| 241,214,589
| 452
| 47
|
MIT
| 2023-08-21T08:53:40
| 2020-02-17T21:46:45
|
C
|
UTF-8
|
C
| false
| false
| 229
|
c
|
visetyscale.c
|
#include <os_internal.h>
#include "viint.h"
void osViSetYScale(f32 value)
{
register u32 saveMask = __osDisableInt();
__osViNext->y.factor = value;
__osViNext->state |= VI_STATE_YSCALE_UPDATED;
__osRestoreInt(saveMask);
}
|
aeaad9ac956cc894ccef82c6e2eb09ab681c84f4
|
fc89df5d65edcfada41a5bcc3b5c52d7b00d9d13
|
/components/spotify/cspot/bell/main/platform/win32/win32shim.h
|
f06bebf3932f7959c3516669bd80134c6da4992c
|
[] |
no_license
|
sle118/squeezelite-esp32
|
b83f580b4de4a517be87ca1db8fead2223694068
|
149c9d8142d7a3f8679efc73985609eb6dee73a5
|
refs/heads/master-v4.3
| 2023-08-23T05:06:18.461579
| 2023-08-22T23:30:18
| 2023-08-22T23:30:18
| 187,874,998
| 698
| 84
| null | 2023-09-09T22:58:50
| 2019-05-21T16:25:56
|
C
|
UTF-8
|
C
| false
| false
| 394
|
h
|
win32shim.h
|
#pragma once
#include <winsock2.h>
#define SHUT_RDWR SD_BOTH
#define ssize_t SSIZE_T
#define strcasecmp stricmp
#define strncasecmp _strnicmp
#define bzero(p, n) memset(p, 0, n)
#define usleep(x) Sleep((x) / 1000)
inline size_t read(int sock, char* buf, size_t n) {
return recv(sock, buf, n, 0);
}
inline int write(int sock, const char* buf, size_t n) {
return send(sock, buf, n, 0);
}
|
81e423ed900bcc4515984996aa79010c1cf4bc3d
|
54c67306d63bb69a5cf381d12108d3dc98ae0f5d
|
/third-party/cubeb/cubeb/src/cubeb_strings.h
|
cfffbbc68aca4ac87e480b71f3de08f68a094928
|
[
"ISC",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
open-goal/jak-project
|
adf30a3459c24afda5b180e3abe1583c93458a37
|
d96dce27149fbf58586160cfecb634614f055943
|
refs/heads/master
| 2023-09-01T21:51:16.736237
| 2023-09-01T16:10:59
| 2023-09-01T16:10:59
| 289,585,720
| 1,826
| 131
|
ISC
| 2023-09-14T13:27:47
| 2020-08-22T23:55:21
|
Common Lisp
|
UTF-8
|
C
| false
| false
| 1,271
|
h
|
cubeb_strings.h
|
/*
* Copyright © 2011 Mozilla Foundation
*
* This program is made available under an ISC-style license. See the
* accompanying file LICENSE for details.
*/
#ifndef CUBEB_STRINGS_H
#define CUBEB_STRINGS_H
#include "cubeb/cubeb.h"
#if defined(__cplusplus)
extern "C" {
#endif
/** Opaque handle referencing interned string storage. */
typedef struct cubeb_strings cubeb_strings;
/** Initialize an interned string structure.
@param strings An out param where an opaque pointer to the
interned string storage will be returned.
@retval CUBEB_OK in case of success.
@retval CUBEB_ERROR in case of error. */
CUBEB_EXPORT int
cubeb_strings_init(cubeb_strings ** strings);
/** Destroy an interned string structure freeing all associated memory.
@param strings An opaque pointer to the interned string storage to
destroy. */
CUBEB_EXPORT void
cubeb_strings_destroy(cubeb_strings * strings);
/** Add string to internal storage.
@param strings Opaque pointer to interned string storage.
@param s String to add to storage.
@retval CUBEB_OK
@retval CUBEB_ERROR
*/
CUBEB_EXPORT char const *
cubeb_strings_intern(cubeb_strings * strings, char const * s);
#if defined(__cplusplus)
}
#endif
#endif // !CUBEB_STRINGS_H
|
8d20726a3dc126abe4102084403cf820df3856ce
|
7d232f51e2330a4f537c50ede9c6bc023d656fd4
|
/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.h
|
49fd3223f14480c91034cf1fe347d605db971faa
|
[
"BSD-3-Clause",
"MPL-2.0",
"Apache-2.0"
] |
permissive
|
grpc/grpc
|
6975af3ba6f07a6fe965b875a0c09abf18999a52
|
e4d598ab64aa54f1da78c6ed6133b741742d11d4
|
refs/heads/master
| 2023-08-31T01:10:22.666618
| 2023-08-30T22:35:17
| 2023-08-30T22:35:17
| 27,729,880
| 42,330
| 13,022
|
Apache-2.0
| 2023-09-14T21:54:19
| 2014-12-08T18:58:53
|
C++
|
UTF-8
|
C
| false
| false
| 1,254
|
h
|
collection_entry.upbdefs.h
|
/* This file was generated by upbc (the upb compiler) from the input
* file:
*
* xds/core/v3/collection_entry.proto
*
* Do not edit -- your changes will be discarded when the file is
* regenerated. */
#ifndef XDS_CORE_V3_COLLECTION_ENTRY_PROTO_UPBDEFS_H_
#define XDS_CORE_V3_COLLECTION_ENTRY_PROTO_UPBDEFS_H_
#include "upb/reflection/def.h"
#include "upb/reflection/def_pool_internal.h"
#include "upb/port/def.inc"
#ifdef __cplusplus
extern "C" {
#endif
#include "upb/reflection/def.h"
#include "upb/port/def.inc"
extern _upb_DefPool_Init xds_core_v3_collection_entry_proto_upbdefinit;
UPB_INLINE const upb_MessageDef *xds_core_v3_CollectionEntry_getmsgdef(upb_DefPool *s) {
_upb_DefPool_LoadDefInit(s, &xds_core_v3_collection_entry_proto_upbdefinit);
return upb_DefPool_FindMessageByName(s, "xds.core.v3.CollectionEntry");
}
UPB_INLINE const upb_MessageDef *xds_core_v3_CollectionEntry_InlineEntry_getmsgdef(upb_DefPool *s) {
_upb_DefPool_LoadDefInit(s, &xds_core_v3_collection_entry_proto_upbdefinit);
return upb_DefPool_FindMessageByName(s, "xds.core.v3.CollectionEntry.InlineEntry");
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "upb/port/undef.inc"
#endif /* XDS_CORE_V3_COLLECTION_ENTRY_PROTO_UPBDEFS_H_ */
|
d494de224b16dd6a93377597b410817fceb030e2
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/sys/arch/hppa/hppa/vm_machdep.c
|
17a864cc75cac27cc674faeafd6e31c98365bcd2
|
[] |
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
| 5,807
|
c
|
vm_machdep.c
|
/* $OpenBSD: vm_machdep.c,v 1.85 2022/10/25 15:15:38 guenther Exp $ */
/*
* Copyright (c) 1999-2004 Michael Shalayeff
* 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 AUTHOR ``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 AUTHOR OR HIS RELATIVES 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 MIND, 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/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/user.h>
#include <sys/ptrace.h>
#include <sys/exec.h>
#include <sys/pool.h>
#include <uvm/uvm_extern.h>
#include <machine/cpufunc.h>
#include <machine/fpu.h>
#include <machine/pmap.h>
#include <machine/pcb.h>
extern struct pool hppa_fppl;
void
cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb,
void (*func)(void *), void *arg)
{
struct pcb *pcbp;
struct trapframe *tf;
register_t sp;
#ifdef DIAGNOSTIC
if (round_page(sizeof(struct user)) > NBPG)
panic("USPACE too small for user");
#endif
fpu_proc_save(p1);
pcbp = &p2->p_addr->u_pcb;
bcopy(&p1->p_addr->u_pcb, pcbp, sizeof(*pcbp));
/* space is cached for the copy{in,out}'s pleasure */
pcbp->pcb_space = p2->p_vmspace->vm_map.pmap->pm_space;
pcbp->pcb_fpstate = pool_get(&hppa_fppl, PR_WAITOK);
*pcbp->pcb_fpstate = *p1->p_addr->u_pcb.pcb_fpstate;
/* reset any of the pending FPU exceptions from parent */
pcbp->pcb_fpstate->hfp_regs.fpr_regs[0] =
HPPA_FPU_FORK(pcbp->pcb_fpstate->hfp_regs.fpr_regs[0]);
pcbp->pcb_fpstate->hfp_regs.fpr_regs[1] = 0;
pcbp->pcb_fpstate->hfp_regs.fpr_regs[2] = 0;
pcbp->pcb_fpstate->hfp_regs.fpr_regs[3] = 0;
p2->p_md.md_bpva = p1->p_md.md_bpva;
p2->p_md.md_bpsave[0] = p1->p_md.md_bpsave[0];
p2->p_md.md_bpsave[1] = p1->p_md.md_bpsave[1];
sp = (register_t)p2->p_addr + NBPG;
p2->p_md.md_regs = tf = (struct trapframe *)sp;
sp += sizeof(struct trapframe);
bcopy(p1->p_md.md_regs, tf, sizeof(*tf));
tf->tf_cr30 = (paddr_t)pcbp->pcb_fpstate;
tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr2 = tf->tf_sr3 =
tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 =
tf->tf_iisq_head = tf->tf_iisq_tail =
p2->p_vmspace->vm_map.pmap->pm_space;
tf->tf_pidr1 = tf->tf_pidr2 = pmap_sid2pid(tf->tf_sr0);
/*
* theoretically these could be inherited from the father,
* but just in case.
*/
tf->tf_sr7 = HPPA_SID_KERNEL;
mfctl(CR_EIEM, tf->tf_eiem);
tf->tf_ipsw = PSL_C | PSL_Q | PSL_P | PSL_D | PSL_I /* | PSL_L */ |
(curcpu()->ci_psw & PSL_O);
/*
* If specified, give the child a different stack and/or TCB
*/
if (stack != NULL)
setstack(tf, (u_long)stack, 0); /* XXX ignore error? */
if (tcb != NULL)
tf->tf_cr27 = (u_long)tcb;
/*
* Build stack frames for the cpu_switchto & co.
*/
sp += HPPA_FRAME_SIZE;
*(register_t*)(sp - HPPA_FRAME_SIZE) = 0;
*(register_t*)(sp + HPPA_FRAME_CRP) = (register_t)&proc_trampoline;
*(register_t*)(sp) = (sp - HPPA_FRAME_SIZE);
sp += HPPA_FRAME_SIZE + 16*4; /* frame + callee-saved registers */
*HPPA_FRAME_CARG(0, sp) = (register_t)arg;
*HPPA_FRAME_CARG(1, sp) = KERNMODE(func);
pcbp->pcb_ksp = sp;
}
void
cpu_exit(struct proc *p)
{
struct pcb *pcb = &p->p_addr->u_pcb;
fpu_proc_flush(p);
pool_put(&hppa_fppl, pcb->pcb_fpstate);
pmap_deactivate(p);
sched_exit(p);
}
struct kmem_va_mode kv_physwait = {
.kv_map = &phys_map,
.kv_wait = 1,
};
/*
* Map an IO request into kernel virtual address space.
*/
void
vmapbuf(struct buf *bp, vsize_t len)
{
struct kmem_dyn_mode kd_prefer = { .kd_waitok = 1 };
struct pmap *pm = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map);
vaddr_t kva, uva;
vsize_t size, off;
#ifdef DIAGNOSTIC
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
#endif
bp->b_saveaddr = bp->b_data;
uva = trunc_page((vaddr_t)bp->b_data);
off = (vaddr_t)bp->b_data - uva;
size = round_page(off + len);
kd_prefer.kd_prefer = uva;
kva = (vaddr_t)km_alloc(size, &kv_physwait, &kp_none, &kd_prefer);
bp->b_data = (caddr_t)(kva + off);
while (size > 0) {
paddr_t pa;
if (pmap_extract(pm, uva, &pa) == FALSE)
panic("vmapbuf: null page frame");
else
pmap_kenter_pa(kva, pa, PROT_READ | PROT_WRITE);
uva += PAGE_SIZE;
kva += PAGE_SIZE;
size -= PAGE_SIZE;
}
pmap_update(pmap_kernel());
}
/*
* Unmap IO request from the kernel virtual address space.
*/
void
vunmapbuf(struct buf *bp, vsize_t len)
{
vaddr_t addr, off;
#ifdef DIAGNOSTIC
if ((bp->b_flags & B_PHYS) == 0)
panic("vunmapbuf");
#endif
addr = trunc_page((vaddr_t)bp->b_data);
off = (vaddr_t)bp->b_data - addr;
len = round_page(off + len);
pmap_kremove(addr, len);
pmap_update(pmap_kernel());
km_free((void *)addr, len, &kv_physwait, &kp_none);
bp->b_data = bp->b_saveaddr;
bp->b_saveaddr = NULL;
}
|
bcb79928cc2db3a07edace79281cf3e30f37430e
|
94a1ae89fa4fac16b3d2a6c56ca678d6c8af668a
|
/include/ircd/simt/samax.h
|
d13511b3d62188b28b3f1467d8063065349d9531
|
[
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
matrix-construct/construct
|
99d677d0c2254cac2176d80690bbfd02b18a8658
|
0624b69246878da592d3f5c2c3737ad0b5ff6277
|
refs/heads/master
| 2023-05-28T12:16:23.661446
| 2023-04-28T05:33:46
| 2023-05-01T19:45:37
| 147,328,703
| 356
| 41
|
NOASSERTION
| 2022-07-22T03:45:21
| 2018-09-04T10:26:23
|
C++
|
UTF-8
|
C
| false
| false
| 754
|
h
|
samax.h
|
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2021 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_SIMT_SAMAX_H
/// Softargmax state.
///
/// In FP32 environments, naively implementing softmax as expressed in
/// literature will overflow. Researchers have mitigated this at the cost
/// of some extra state and passes.
struct ircd_math_samax
{
float
mu,
sum,
lambda;
};
|
10ab20971b9a2079a7e778502c3c5a6d280a1d53
|
476fde4234ce92fb50e5cfc4df9789d40c497698
|
/src/execline/forbacktickx.c
|
b25095e366a31fb89fc48fa552399d91562e3267
|
[
"ISC"
] |
permissive
|
skarnet/execline
|
47c0b12ce14f001684a245897aacff5e0bff4e07
|
7d790daa90f49e153251d0f41bcb208d8bea588c
|
refs/heads/master
| 2023-07-09T08:22:55.484648
| 2023-06-27T08:29:16
| 2023-06-27T08:29:16
| 31,461,279
| 138
| 22
| null | 2015-05-23T11:55:38
| 2015-02-28T11:57:30
|
C
|
UTF-8
|
C
| false
| false
| 3,375
|
c
|
forbacktickx.c
|
/* ISC license. */
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr.h>
#include <skalibs/exec.h>
#include <execline/config.h>
#include <execline/execline.h>
#define USAGE "forbacktickx [ -p | -o okcode,okcode,... | -x breakcode,breakcode,... ] [ -E | -e ] [ -N | -n ] [ -C | -c ] [ -0 | -d delim ] var { backtickcmd... } command..."
#define dieusage() strerr_dieusage(100, USAGE)
int main (int argc, char const *const *argv)
{
char const *delim = "\n" ;
char const *codes = 0 ;
int crunch = 0, chomp = 1, not = 1, par = 0, doimport = 0 ;
PROG = "forbacktickx" ;
{
subgetopt l = SUBGETOPT_ZERO ;
for (;;)
{
int opt = subgetopt_r(argc, argv, "pNnCc0d:o:x:Ee", &l) ;
if (opt == -1) break ;
switch (opt)
{
case 'p' : par = 1 ; break ;
case 'N' : chomp = 0 ; break ;
case 'n' : chomp = 1 ; break ;
case 'C' : crunch = 1 ; break ;
case 'c' : crunch = 0 ; break ;
case '0' : delim = 0 ; break ;
case 'd' : delim = l.arg ; break ;
case 'o' :
{
unsigned short okcodes[256] ;
size_t nbc ;
if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ;
codes = l.arg ;
not = 0 ;
break ;
}
case 'x' :
{
unsigned short okcodes[256] ;
size_t nbc ;
if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ;
codes = l.arg ;
not = 1 ;
break ;
}
case 'E' : doimport = 1 ; break ;
case 'e' : doimport = 0 ; break ;
default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
}
if (argc < 2) dieusage() ;
if (!argv[0][0]) dieusage() ;
if (!argv[1][0]) strerr_dief1x(100, "empty block") ;
{
unsigned int m = 0, i = 1 ;
int fd = dup(0) ;
char const *newargv[argc + 19] ;
char fmt[UINT_FMT] ;
if (fd < 0)
{
if (errno != EBADF) strerr_diefu1sys(111, "dup stdin") ;
}
else fmt[uint_fmt(fmt, (unsigned int)fd)] = 0 ;
newargv[m++] = EXECLINE_BINPREFIX "pipeline" ;
newargv[m++] = "--" ;
while (argv[i] && argv[i][0] != EXECLINE_BLOCK_END_CHAR && (!EXECLINE_BLOCK_END_CHAR || (argv[i][0] && argv[i][1])))
newargv[m++] = argv[i++] ;
if (!argv[i]) strerr_dief1x(100, "unterminated block") ;
newargv[m++] = "" ; i++ ;
newargv[m++] = EXECLINE_BINPREFIX "unexport" ;
newargv[m++] = "!" ;
newargv[m++] = EXECLINE_BINPREFIX "forstdin" ;
newargv[m++] = doimport ? "-E" : "-e" ;
if (par) newargv[m++] = "-p" ;
newargv[m++] = chomp ? "-n" : "-N" ;
if (crunch) newargv[m++] = "-C" ;
if (!delim) newargv[m++] = "-0" ;
else if (strcmp(delim, "\n"))
{
newargv[m++] = "-d" ;
newargv[m++] = delim ;
}
if (codes)
{
newargv[m++] = not ? "-x" : "-o" ;
newargv[m++] = codes ;
}
newargv[m++] = "--" ;
newargv[m++] = argv[0] ;
if (fd < 0)
{
newargv[m++] = EXECLINE_BINPREFIX "fdclose" ;
newargv[m++] = "0" ;
}
else
{
newargv[m++] = EXECLINE_BINPREFIX "fdmove" ;
newargv[m++] = "0" ;
newargv[m++] = fmt ;
}
while (argv[i]) newargv[m++] = argv[i++] ;
newargv[m++] = 0 ;
xexec(newargv) ;
}
}
|
e790819ed265dbe083e613ba6876dcddd8c54822
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/cris/kernel/process.c
|
b78498eb079b14e2930208d963c5e9dd87f57a1f
|
[
"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
| 1,580
|
c
|
process.c
|
/*
* linux/arch/cris/kernel/process.c
*
* Copyright (C) 1995 Linus Torvalds
* Copyright (C) 2000-2002 Axis Communications AB
*
* Authors: Bjorn Wesen (bjornw@axis.com)
*
*/
/*
* This file handles the architecture-dependent parts of process handling..
*/
#include <linux/atomic.h>
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/init_task.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/user.h>
#include <linux/elfcore.h>
#include <linux/mqueue.h>
#include <linux/reboot.h>
#include <linux/rcupdate.h>
//#define DEBUG
extern void default_idle(void);
void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);
void arch_cpu_idle(void)
{
default_idle();
}
void hard_reset_now (void);
void machine_restart(char *cmd)
{
hard_reset_now();
}
/*
* Similar to machine_power_off, but don't shut off power. Add code
* here to freeze the system for e.g. post-mortem debug purpose when
* possible. This halt has nothing to do with the idle halt.
*/
void machine_halt(void)
{
}
/* If or when software power-off is implemented, add code here. */
void machine_power_off(void)
{
}
/*
* When a process does an "exec", machine state like FPU and debug
* registers need to be reset. This is a hook function for that.
* Currently we don't have any such state to reset, so this is empty.
*/
void flush_thread(void)
{
}
/* Fill in the fpu structure for a core dump. */
int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
{
return 0;
}
|
1bed4e57f6b8be3d32f3b5a9a70b8c60fef60416
|
4bcc9806152542ab43fc2cf47c499424f200896c
|
/tensorflow/c/tf_tstring.h
|
876fd5f384f46cd667728e04bcf5296766be9ba3
|
[
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"BSD-2-Clause"
] |
permissive
|
tensorflow/tensorflow
|
906276dbafcc70a941026aa5dc50425ef71ee282
|
a7f3934a67900720af3d3b15389551483bee50b8
|
refs/heads/master
| 2023-08-25T04:24:41.611870
| 2023-08-25T04:06:24
| 2023-08-25T04:14:08
| 45,717,250
| 208,740
| 109,943
|
Apache-2.0
| 2023-09-14T20:55:50
| 2015-11-07T01:19:20
|
C++
|
UTF-8
|
C
| false
| false
| 1,703
|
h
|
tf_tstring.h
|
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_C_TF_TSTRING_H_
#define TENSORFLOW_C_TF_TSTRING_H_
#include "tensorflow/c/c_api_macros.h"
#include "tensorflow/c/tf_tensor.h"
#include "tensorflow/core/platform/ctstring.h"
#ifdef __cplusplus
extern "C" {
#endif
TF_CAPI_EXPORT extern void TF_StringInit(TF_TString *t);
TF_CAPI_EXPORT extern void TF_StringCopy(TF_TString *dst, const char *src,
size_t size);
TF_CAPI_EXPORT extern void TF_StringAssignView(TF_TString *dst, const char *src,
size_t size);
TF_CAPI_EXPORT extern const char *TF_StringGetDataPointer(
const TF_TString *tstr);
TF_CAPI_EXPORT extern TF_TString_Type TF_StringGetType(const TF_TString *str);
TF_CAPI_EXPORT extern size_t TF_StringGetSize(const TF_TString *tstr);
TF_CAPI_EXPORT extern size_t TF_StringGetCapacity(const TF_TString *str);
TF_CAPI_EXPORT extern void TF_StringDealloc(TF_TString *tstr);
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif // TENSORFLOW_C_TF_TSTRING_H_
|
9d0bb995323b2f9bedbc59ba48a3d1f8b7a126f0
|
cf56b5fcf51fddb219c47f5f006d8595a4483c57
|
/src/components/cl/hier/alltoallv/alltoallv.c
|
c60bdf84fe014fd6a08033e9fd561eadc059bc8d
|
[
"BSD-3-Clause"
] |
permissive
|
openucx/ucc
|
3b39fbd849a7850c559b60eaec7882292f8a5eca
|
f89cd7557e6ebb19b4c6ebd529647d8b42c30657
|
refs/heads/master
| 2023-08-18T03:18:54.072899
| 2023-08-17T18:05:44
| 2023-08-17T18:05:44
| 282,490,868
| 150
| 57
|
BSD-3-Clause
| 2023-09-12T09:49:18
| 2020-07-25T17:18:51
|
C
|
UTF-8
|
C
| false
| false
| 12,939
|
c
|
alltoallv.c
|
/**
* Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* Copyright (c) Meta Platforms, Inc. and affiliates. 2022.
*
* See file LICENSE for terms.
*/
#include "alltoallv.h"
#include "../cl_hier_coll.h"
#include "core/ucc_team.h"
ucc_base_coll_alg_info_t
ucc_cl_hier_alltoallv_algs[UCC_CL_HIER_ALLTOALLV_ALG_LAST + 1] = {
[UCC_CL_HIER_ALLTOALLV_ALG_NODE_SPLIT] =
{.id = UCC_CL_HIER_ALLTOALLV_ALG_NODE_SPLIT,
.name = "node_split",
.desc = "splitting alltoallv into two concurrent a2av calls"
" withing the node and outside of it"},
[UCC_CL_HIER_ALLTOALLV_ALG_LAST] = {
.id = 0, .name = NULL, .desc = NULL}};
static ucc_status_t ucc_cl_hier_alltoallv_start(ucc_coll_task_t *task)
{
UCC_CL_HIER_PROFILE_REQUEST_EVENT(task, "cl_hier_alltoallv_start", 0);
return ucc_schedule_start(task);
}
static ucc_status_t ucc_cl_hier_alltoallv_finalize(ucc_coll_task_t *task)
{
ucc_cl_hier_schedule_t *schedule =
ucc_derived_of(task, ucc_cl_hier_schedule_t);
ucc_status_t status;
UCC_CL_HIER_PROFILE_REQUEST_EVENT(task, "cl_hier_alltoallv_finalize", 0);
ucc_assert(schedule->super.super.n_tasks == 1 ||
schedule->super.super.n_tasks == 2);
if (schedule->scratch) {
ucc_mc_free(schedule->scratch);
}
status = ucc_schedule_finalize(task);
ucc_cl_hier_put_schedule(&schedule->super.super);
return status;
}
#define SET_FULL_COUNTS(_type, _sbgp, _coll_args, _team, _node_thresh, \
_sdt_size, _rdt_size, _sc_full, _sd_full, _rc_full, \
_rd_full) \
do { \
int _i, _is_local; \
_type _scount, _rcount; \
\
for (_i = 0; _i < (_sbgp)->group_size; _i++) { \
_scount = ((_type *)(_coll_args)->args.src.info_v.counts)[_i]; \
_rcount = ((_type *)(_coll_args)->args.dst.info_v.counts)[_i]; \
_is_local = \
ucc_rank_on_local_node(_i, (_team)->params.team->topo); \
if ((_scount * _sdt_size > (_node_thresh)) && _is_local) { \
((_type *)_sc_full)[_i] = 0; \
} else { \
((_type *)_sc_full)[_i] = _scount; \
((_type *)_sd_full)[_i] = \
((_type *)(_coll_args) \
->args.src.info_v.displacements)[_i]; \
} \
if ((_rcount * _rdt_size > (_node_thresh)) && _is_local) { \
((_type *)_rc_full)[_i] = 0; \
} else { \
((_type *)_rc_full)[_i] = _rcount; \
((_type *)_rd_full)[_i] = \
((_type *)(_coll_args) \
->args.dst.info_v.displacements)[_i]; \
} \
} \
} while (0)
#define SET_NODE_COUNTS(_type, _sbgp, _coll_args, _node_thresh, _sdt_size, \
_rdt_size, _sc_node, _sd_node, _rc_node, _rd_node) \
do { \
int _i; \
_type _scount, _rcount; \
\
for (_i = 0; _i < (_sbgp)->group_size; _i++) { \
ucc_rank_t r = ucc_ep_map_eval((_sbgp)->map, _i); \
_scount = ((_type *)(_coll_args)->args.src.info_v.counts)[r]; \
_rcount = ((_type *)(_coll_args)->args.dst.info_v.counts)[r]; \
if (_scount * _sdt_size <= (_node_thresh)) { \
((_type *)_sc_node)[_i] = 0; \
} else { \
((_type *)_sc_node)[_i] = _scount; \
((_type *)_sd_node)[_i] = \
((_type *)(_coll_args)->args.src.info_v.displacements)[r]; \
} \
if (_rcount * _rdt_size <= (_node_thresh)) { \
((_type *)_rc_node)[_i] = 0; \
} else { \
((_type *)_rc_node)[_i] = _rcount; \
((_type *)_rd_node)[_i] = \
((_type *)(_coll_args)->args.dst.info_v.displacements)[r]; \
} \
} \
} while (0)
ucc_status_t ucc_cl_hier_alltoallv_triggered_post_setup(ucc_coll_task_t *task)
{
ucc_cl_hier_schedule_t *schedule =
ucc_derived_of(task, ucc_cl_hier_schedule_t);
ucc_status_t status = UCC_OK;
int n_tasks = schedule->super.super.n_tasks;
int i = 0;
for (i = 0; i < n_tasks; ++i) {
ucc_coll_task_t *sub_task = schedule->super.super.tasks[i];
if (sub_task->triggered_post_setup != NULL) {
sub_task->ee = task->ee;
sub_task->triggered_post_setup(sub_task);
}
}
return status;
}
UCC_CL_HIER_PROFILE_FUNC(ucc_status_t, ucc_cl_hier_alltoallv_init,
(coll_args, team, task),
ucc_base_coll_args_t *coll_args, ucc_base_team_t *team,
ucc_coll_task_t **task)
{
ucc_cl_hier_team_t *cl_team = ucc_derived_of(team, ucc_cl_hier_team_t);
ucc_cl_hier_lib_t *cl_lib = UCC_CL_HIER_TEAM_LIB(cl_team);
int full_only = 0;
ucc_cl_hier_schedule_t *cl_schedule;
ucc_schedule_t *schedule;
ucc_status_t status;
ucc_base_coll_args_t args;
ucc_coll_task_t *task_node, *task_full;
int c64, d64;
void *sc_full, *sd_full, *rc_full, *rd_full;
void *sc_node, *sd_node, *rc_node, *rd_node;
ucc_rank_t full_size, node_size;
size_t sdt_size, rdt_size;
ucc_sbgp_t *sbgp;
size_t elem_size;
if (UCC_IS_INPLACE(coll_args->args)) {
cl_debug(team->context->lib, "inplace alltoallv is not supported");
return UCC_ERR_NOT_SUPPORTED;
}
if (!SBGP_ENABLED(cl_team, FULL)) {
cl_debug(team->context->lib, "alltoallv requires FULL sbgp");
return UCC_ERR_NOT_SUPPORTED;
}
c64 = UCC_COLL_ARGS_COUNT64(&coll_args->args);
d64 = UCC_COLL_ARGS_DISPL64(&coll_args->args);
if (c64 ^ d64) {
cl_debug(team->context->lib,
"mixed 64 bit count/displ mode is not supported");
return UCC_ERR_NOT_SUPPORTED;
}
cl_schedule = ucc_cl_hier_get_schedule(cl_team);
if (ucc_unlikely(!cl_schedule)) {
return UCC_ERR_NO_MEMORY;
}
schedule = &cl_schedule->super.super;
memcpy(&args, coll_args, sizeof(args));
UCC_CHECK_GOTO(ucc_schedule_init(schedule, &args, team), error, status);
full_size = cl_team->sbgps[UCC_HIER_SBGP_FULL].sbgp->group_size;
node_size = cl_team->sbgps[UCC_HIER_SBGP_NODE].sbgp->group_size;
elem_size = c64 ? 8 : 4;
if (!SBGP_ENABLED(cl_team, NODE)) {
full_only = 1;
UCC_CHECK_GOTO(ucc_coll_init(
cl_team->sbgps[UCC_HIER_SBGP_FULL].score_map,
&args, &task_full),
error, status);
goto full;
}
status = ucc_mc_alloc(&cl_schedule->scratch,
elem_size * (full_size + node_size) * 4,
UCC_MEMORY_TYPE_HOST);
if (ucc_unlikely(UCC_OK != status)) {
cl_error(team->context->lib,
"failed to allocate %zd bytes for full counts",
elem_size * (full_size + node_size) * 4);
goto error;
}
sc_full = cl_schedule->scratch->addr;
sd_full = PTR_OFFSET(sc_full, full_size * elem_size);
rc_full = PTR_OFFSET(sc_full, full_size * elem_size * 2);
rd_full = PTR_OFFSET(sc_full, full_size * elem_size * 3);
sc_node = PTR_OFFSET(sc_full, full_size * elem_size * 4);
sd_node = PTR_OFFSET(sc_node, node_size * elem_size);
rc_node = PTR_OFFSET(sc_node, node_size * elem_size * 2);
rd_node = PTR_OFFSET(sc_node, node_size * elem_size * 3);
/* Duplicate FULL a2av info and alloc task */
sbgp = cl_team->sbgps[UCC_HIER_SBGP_FULL].sbgp;
ucc_assert(sbgp->group_size == team->params.size);
sdt_size = ucc_dt_size(coll_args->args.src.info_v.datatype);
rdt_size = ucc_dt_size(coll_args->args.dst.info_v.datatype);
if (c64) {
SET_FULL_COUNTS(uint64_t, sbgp, coll_args, team,
cl_lib->cfg.a2av_node_thresh, sdt_size, rdt_size,
sc_full, sd_full, rc_full, rd_full);
} else {
SET_FULL_COUNTS(uint32_t, sbgp, coll_args, team,
cl_lib->cfg.a2av_node_thresh, sdt_size, rdt_size,
sc_full, sd_full, rc_full, rd_full);
}
args.args.src.info_v.counts = (ucc_count_t *)sc_full;
args.args.dst.info_v.counts = (ucc_count_t *)rc_full;
args.args.src.info_v.displacements = (ucc_aint_t *)sd_full;
args.args.dst.info_v.displacements = (ucc_aint_t *)rd_full;
UCC_CHECK_GOTO(ucc_coll_init(cl_team->sbgps[UCC_HIER_SBGP_FULL].score_map,
&args, &task_full),
err_init_1, status);
/* Setup NODE a2av */
sbgp = cl_team->sbgps[UCC_HIER_SBGP_NODE].sbgp;
if (c64) {
SET_NODE_COUNTS(uint64_t, sbgp, coll_args,
cl_lib->cfg.a2av_node_thresh, sdt_size, rdt_size,
sc_node, sd_node, rc_node, rd_node);
} else {
SET_NODE_COUNTS(uint32_t, sbgp, coll_args,
cl_lib->cfg.a2av_node_thresh, sdt_size, rdt_size,
sc_node, sd_node, rc_node, rd_node);
}
args.args.src.info_v.counts = (ucc_count_t *)sc_node;
args.args.dst.info_v.counts = (ucc_count_t *)rc_node;
args.args.src.info_v.displacements = (ucc_aint_t *)sd_node;
args.args.dst.info_v.displacements = (ucc_aint_t *)rd_node;
UCC_CHECK_GOTO(ucc_coll_init(cl_team->sbgps[UCC_HIER_SBGP_NODE].score_map,
&args, &task_node),
err_init_2, status);
UCC_CHECK_GOTO(ucc_schedule_add_task(schedule, task_node), err_init_3,
status);
UCC_CHECK_GOTO(ucc_task_subscribe_dep(&schedule->super, task_node,
UCC_EVENT_SCHEDULE_STARTED),
err_init_3, status);
full:
UCC_CHECK_GOTO(ucc_schedule_add_task(schedule, task_full), err_init_3,
status);
UCC_CHECK_GOTO(ucc_task_subscribe_dep(&schedule->super, task_full,
UCC_EVENT_SCHEDULE_STARTED),
err_init_3, status);
schedule->super.post = ucc_cl_hier_alltoallv_start;
schedule->super.progress = NULL;
schedule->super.finalize = ucc_cl_hier_alltoallv_finalize;
schedule->super.triggered_post_setup =
ucc_cl_hier_alltoallv_triggered_post_setup;
*task = &schedule->super;
return UCC_OK;
err_init_3:
if (!full_only) {
ucc_collective_finalize(&task_node->super);
}
err_init_2:
ucc_collective_finalize(&task_full->super);
err_init_1:
if (!full_only) {
ucc_mc_free(cl_schedule->scratch);
}
error:
ucc_cl_hier_put_schedule(schedule);
return status;
}
|
13ca8284bffd3a7b1f421943278eb0d9a5bca8fe
|
1231379e557a3094413045721b4c65ce9bae568b
|
/src/inc/msquichelper.h
|
232ea616ab058e6a1fd3f889b7e125c99382de0a
|
[
"MIT"
] |
permissive
|
microsoft/msquic
|
a63982f1b7d017fb0497e2dce56f1ef527bd6eaa
|
f91ccc2f975225a278bc68238555ed0923e676ba
|
refs/heads/main
| 2023-09-04T01:25:39.133074
| 2023-08-28T18:04:51
| 2023-08-28T18:04:51
| 217,654,199
| 3,641
| 521
|
MIT
| 2023-09-14T14:36:09
| 2019-10-26T04:10:24
|
C
|
UTF-8
|
C
| false
| false
| 19,303
|
h
|
msquichelper.h
|
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
Abstract:
This file contains helpers for using MsQuic.
Environment:
user mode or kernel mode
--*/
#pragma once
#include "quic_platform.h"
#include "msquic.h"
#include "msquicp.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <share.h>
#endif // _WIN32
typedef struct QUIC_CREDENTIAL_CONFIG_HELPER {
QUIC_CREDENTIAL_CONFIG CredConfig;
union {
QUIC_CERTIFICATE_HASH CertHash;
QUIC_CERTIFICATE_HASH_STORE CertHashStore;
QUIC_CERTIFICATE_FILE CertFile;
};
} QUIC_CREDENTIAL_CONFIG_HELPER;
//
// Converts the QUIC Status Code to a string for console output.
//
inline
_Null_terminated_
const char*
QuicStatusToString(
_In_ QUIC_STATUS Status
)
{
switch (Status) {
case QUIC_STATUS_SUCCESS: return "SUCCESS";
case QUIC_STATUS_PENDING: return "PENDING";
case QUIC_STATUS_OUT_OF_MEMORY: return "OUT_OF_MEMORY";
case QUIC_STATUS_INVALID_PARAMETER: return "INVALID_PARAMETER";
case QUIC_STATUS_INVALID_STATE: return "INVALID_STATE";
case QUIC_STATUS_NOT_SUPPORTED: return "NOT_SUPPORTED";
case QUIC_STATUS_NOT_FOUND: return "NOT_FOUND";
case QUIC_STATUS_BUFFER_TOO_SMALL: return "BUFFER_TOO_SMALL";
case QUIC_STATUS_HANDSHAKE_FAILURE: return "HANDSHAKE_FAILURE";
case QUIC_STATUS_ABORTED: return "ABORTED";
case QUIC_STATUS_ADDRESS_IN_USE: return "ADDRESS_IN_USE";
case QUIC_STATUS_CONNECTION_TIMEOUT: return "CONNECTION_TIMEOUT";
case QUIC_STATUS_CONNECTION_IDLE: return "CONNECTION_IDLE";
case QUIC_STATUS_UNREACHABLE: return "UNREACHABLE";
case QUIC_STATUS_INTERNAL_ERROR: return "INTERNAL_ERROR";
case QUIC_STATUS_CONNECTION_REFUSED: return "CONNECTION_REFUSED";
case QUIC_STATUS_PROTOCOL_ERROR: return "PROTOCOL_ERROR";
case QUIC_STATUS_VER_NEG_ERROR: return "VER_NEG_ERROR";
case QUIC_STATUS_USER_CANCELED: return "USER_CANCELED";
case QUIC_STATUS_ALPN_NEG_FAILURE: return "ALPN_NEG_FAILURE";
case QUIC_STATUS_STREAM_LIMIT_REACHED: return "STREAM_LIMIT_REACHED";
}
return "UNKNOWN";
}
//
// Helper function to get the RTT (in microseconds) from a MsQuic Connection or Stream handle.
//
inline
uint32_t
GetConnRtt(
_In_ const QUIC_API_TABLE* MsQuicTable,
_In_ HQUIC Handle
)
{
QUIC_STATISTICS Value;
uint32_t ValueSize = sizeof(Value);
MsQuicTable->GetParam(
Handle,
QUIC_PARAM_CONN_STATISTICS,
&ValueSize,
&Value);
return Value.Rtt;
}
//
// Helper function to get the Stream ID from a MsQuic Stream handle.
//
inline
uint64_t
GetStreamID(
_In_ const QUIC_API_TABLE* MsQuicTable,
_In_ HQUIC Handle
)
{
uint64_t ID = (uint32_t)(-1);
uint32_t IDLen = sizeof(ID);
MsQuicTable->GetParam(
Handle,
QUIC_PARAM_STREAM_ID,
&IDLen,
&ID);
return ID;
}
//
// Helper function to get the remote IP address (as a string) from a MsQuic
// Connection or Stream handle.
//
inline
QUIC_ADDR_STR
GetRemoteAddr(
_In_ const QUIC_API_TABLE* MsQuicTable,
_In_ HQUIC Handle
)
{
QUIC_ADDR addr;
uint32_t addrLen = sizeof(addr);
QUIC_ADDR_STR addrStr = { 0 };
QUIC_STATUS status =
MsQuicTable->GetParam(
Handle,
QUIC_PARAM_CONN_REMOTE_ADDRESS,
&addrLen,
&addr);
if (QUIC_SUCCEEDED(status)) {
QuicAddrToString(&addr, &addrStr);
}
return addrStr;
}
inline
QUIC_STATUS
QuicForceRetry(
_In_ const QUIC_API_TABLE* MsQuicTable,
_In_ BOOLEAN Enabled
)
{
uint16_t value = Enabled ? 0 : 65;
return
MsQuicTable->SetParam(
NULL,
QUIC_PARAM_GLOBAL_RETRY_MEMORY_PERCENT,
sizeof(value),
&value);
}
inline
void
DumpMsQuicPerfCounters(
_In_ const QUIC_API_TABLE* MsQuicTable
)
{
uint64_t Counters[QUIC_PERF_COUNTER_MAX] = {0};
uint32_t Lenth = sizeof(Counters);
MsQuicTable->GetParam(
NULL,
QUIC_PARAM_GLOBAL_PERF_COUNTERS,
&Lenth,
&Counters);
printf("Perf Counters:\n");
printf(" CONN_CREATED: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_CREATED]);
printf(" CONN_HANDSHAKE_FAIL: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_HANDSHAKE_FAIL]);
printf(" CONN_APP_REJECT: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_APP_REJECT]);
printf(" CONN_ACTIVE: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_ACTIVE]);
printf(" CONN_CONNECTED: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_CONNECTED]);
printf(" CONN_PROTOCOL_ERRORS: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_PROTOCOL_ERRORS]);
printf(" CONN_NO_ALPN: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_NO_ALPN]);
printf(" STRM_ACTIVE: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_STRM_ACTIVE]);
printf(" PKTS_SUSPECTED_LOST: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_PKTS_SUSPECTED_LOST]);
printf(" PKTS_DROPPED: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_PKTS_DROPPED]);
printf(" PKTS_DECRYPTION_FAIL: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_PKTS_DECRYPTION_FAIL]);
printf(" UDP_RECV: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_UDP_RECV]);
printf(" UDP_SEND: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_UDP_SEND]);
printf(" UDP_RECV_BYTES: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_UDP_RECV_BYTES]);
printf(" UDP_SEND_BYTES: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_UDP_SEND_BYTES]);
printf(" UDP_RECV_EVENTS: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_UDP_RECV_EVENTS]);
printf(" UDP_SEND_CALLS: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_UDP_SEND_CALLS]);
printf(" APP_SEND_BYTES: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_APP_SEND_BYTES]);
printf(" APP_RECV_BYTES: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_APP_RECV_BYTES]);
printf(" CONN_QUEUE_DEPTH: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_QUEUE_DEPTH]);
printf(" CONN_OPER_QUEUE_DEPTH: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_OPER_QUEUE_DEPTH]);
printf(" CONN_OPER_QUEUED: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_OPER_QUEUED]);
printf(" CONN_OPER_COMPLETED: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_CONN_OPER_COMPLETED]);
printf(" WORK_OPER_QUEUE_DEPTH: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_WORK_OPER_QUEUE_DEPTH]);
printf(" WORK_OPER_QUEUED: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_WORK_OPER_QUEUED]);
printf(" WORK_OPER_COMPLETED: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_WORK_OPER_COMPLETED]);
printf(" PATH_VALIDATED: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_PATH_VALIDATED]);
printf(" PATH_FAILURE: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_PATH_FAILURE]);
printf(" SEND_STATELESS_RESET: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_SEND_STATELESS_RESET]);
printf(" SEND_STATELESS_RETRY: %llu\n", (unsigned long long)Counters[QUIC_PERF_COUNTER_SEND_STATELESS_RETRY]);
}
//
// Converts an input command line arg string and port to a socket address.
// Supports IPv4, IPv6 or '*' input strings.
//
inline
BOOLEAN
ConvertArgToAddress(
_In_z_ const char* Arg,
_In_ uint16_t Port, // Host Byte Order
_Out_ QUIC_ADDR* Address
)
{
if (strcmp("*", Arg) == 0) {
//
// Explicitly zero, otherwise kernel mode errors
//
CxPlatZeroMemory(Address, sizeof(*Address));
QuicAddrSetFamily(Address, QUIC_ADDRESS_FAMILY_UNSPEC);
QuicAddrSetPort(Address, Port);
return TRUE;
}
return QuicAddrFromString(Arg, Port, Address);
}
inline uint8_t DecodeHexChar(char c)
{
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'A' && c <= 'F') return 10 + c - 'A';
if (c >= 'a' && c <= 'f') return 10 + c - 'a';
return 0;
}
inline
uint32_t
DecodeHexBuffer(
_In_z_ const char* HexBuffer,
_In_ uint32_t OutBufferLen,
_Out_writes_to_(OutBufferLen, return)
uint8_t* OutBuffer
)
{
uint32_t HexBufferLen = (uint32_t)strlen(HexBuffer) / 2;
if (HexBufferLen > OutBufferLen) {
return 0;
}
for (uint32_t i = 0; i < HexBufferLen; i++) {
OutBuffer[i] =
(DecodeHexChar(HexBuffer[i * 2]) << 4) |
DecodeHexChar(HexBuffer[i * 2 + 1]);
}
return HexBufferLen;
}
inline
void
EncodeHexBuffer(
_In_reads_(BufferLen) uint8_t* Buffer,
_In_ uint8_t BufferLen,
_Out_writes_bytes_(2*BufferLen) char* HexString
)
{
#define HEX_TO_CHAR(x) ((x) > 9 ? ('a' + ((x) - 10)) : '0' + (x))
for (uint8_t i = 0; i < BufferLen; i++) {
HexString[i*2] = HEX_TO_CHAR(Buffer[i] >> 4);
HexString[i*2 + 1] = HEX_TO_CHAR(Buffer[i] & 0xf);
}
}
#if defined(__cplusplus)
//
// Arg Value Parsers
//
inline
bool
IsArg(
_In_z_ const char* Arg,
_In_z_ const char* toTestAgainst
)
{
return Arg[0] && (_strnicmp(Arg + 1, toTestAgainst, strlen(toTestAgainst)) == 0);
}
inline
bool
IsValue(
_In_z_ const char* name,
_In_z_ const char* toTestAgainst
)
{
return _strnicmp(name, toTestAgainst, CXPLAT_MIN(strlen(name), strlen(toTestAgainst))) == 0;
}
inline
bool
GetFlag(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_z_ const char* name
)
{
const size_t nameLen = strlen(name);
for (int i = 0; i < argc; i++) {
if (_strnicmp(argv[i] + 1, name, nameLen) == 0
&& strlen(argv[i]) == nameLen + 1) {
return true;
}
}
return false;
}
//
// Helper function that searches the list of args for a given
// parameter name, insensitive to case.
//
inline
_Ret_maybenull_ _Null_terminated_ const char*
GetValue(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_z_ const char* name
)
{
const size_t nameLen = strlen(name);
for (int i = 0; i < argc; i++) {
if (_strnicmp(argv[i] + 1, name, nameLen) == 0
&& strlen(argv[i]) > 1 + nameLen + 1
&& *(argv[i] + 1 + nameLen) == ':') {
return argv[i] + 1 + nameLen + 1;
}
}
return nullptr;
}
inline
_Success_(return != false)
bool
TryGetValue(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_z_ const char* name,
_Out_ _Null_terminated_ const char** pValue
)
{
auto value = GetValue(argc, argv, name);
if (!value) return false;
*pValue = value;
return true;
}
inline
_Success_(return != false)
bool
TryGetValue(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_z_ const char* name,
_Out_ uint8_t* pValue
)
{
auto value = GetValue(argc, argv, name);
if (!value) return false;
*pValue = (uint8_t)atoi(value);
return true;
}
inline
_Success_(return != false)
bool
TryGetValue(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_z_ const char* name,
_Out_ uint16_t* pValue
)
{
auto value = GetValue(argc, argv, name);
if (!value) return false;
*pValue = (uint16_t)atoi(value);
return true;
}
inline
_Success_(return != false)
bool
TryGetValue(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_z_ const char* name,
_Out_ uint32_t* pValue
)
{
auto value = GetValue(argc, argv, name);
if (!value) return false;
char* End;
#ifdef _WIN32
*pValue = (uint32_t)_strtoui64(value, &End, 10);
#else
*pValue = (uint32_t)strtoull(value, &End, 10);
#endif
return true;
}
inline
_Success_(return != false)
bool
TryGetValue(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_z_ const char* name,
_Out_ int32_t* pValue
)
{
auto value = GetValue(argc, argv, name);
if (!value) return false;
*pValue = (int32_t)atoi(value);
return true;
}
inline
_Success_(return != false)
bool
TryGetValue(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_z_ const char* name,
_Out_ uint64_t* pValue
)
{
auto value = GetValue(argc, argv, name);
if (!value) return false;
char* End;
#ifdef _WIN32
*pValue = _strtoui64(value, &End, 10);
#else
*pValue = strtoull(value, &End, 10);
#endif
return true;
}
inline
_Success_(return != false)
HQUIC
GetServerConfigurationFromArgs(
_In_ int argc,
_In_reads_(argc) _Null_terminated_ char* argv[],
_In_ const QUIC_API_TABLE* MsQuicTable,
_In_ HQUIC Registration,
_In_reads_(AlpnBufferCount) _Pre_defensive_
const QUIC_BUFFER* const AlpnBuffers,
_In_range_(>, 0) uint32_t AlpnBufferCount,
_In_reads_bytes_opt_(SettingsSize)
const QUIC_SETTINGS* Settings,
_In_ uint32_t SettingsSize
)
{
QUIC_CREDENTIAL_CONFIG_HELPER Helper;
CxPlatZeroMemory(&Helper, sizeof(Helper));
const QUIC_CREDENTIAL_CONFIG* Config = &Helper.CredConfig;
Helper.CredConfig.Flags = QUIC_CREDENTIAL_FLAG_NONE;
const char* Cert;
const char* KeyFile;
if (((Cert = GetValue(argc, argv, "thumbprint")) != nullptr) ||
((Cert = GetValue(argc, argv, "cert_hash")) != nullptr) ||
((Cert = GetValue(argc, argv, "hash")) != nullptr)) {
uint32_t CertHashLen =
DecodeHexBuffer(
Cert,
sizeof(Helper.CertHashStore.ShaHash),
Helper.CertHashStore.ShaHash);
if (CertHashLen != sizeof(Helper.CertHashStore.ShaHash)) {
return nullptr;
}
Helper.CredConfig.Type = QUIC_CREDENTIAL_TYPE_CERTIFICATE_HASH_STORE;
Helper.CredConfig.CertificateHashStore = &Helper.CertHashStore;
memcpy(Helper.CertHashStore.StoreName, "My", sizeof("My"));
Helper.CertHashStore.Flags =
GetValue(argc, argv, "machine") ?
QUIC_CERTIFICATE_HASH_STORE_FLAG_MACHINE_STORE :
QUIC_CERTIFICATE_HASH_STORE_FLAG_NONE;
} else if (
(((Cert = GetValue(argc, argv, "file")) != nullptr) &&
((KeyFile = GetValue(argc, argv, "key")) != nullptr)) ||
(((Cert = GetValue(argc, argv, "cert_file")) != nullptr) &&
((KeyFile = GetValue(argc, argv, "cert_key")) != nullptr))) {
Helper.CertFile.CertificateFile = (char*)Cert;
Helper.CertFile.PrivateKeyFile = (char*)KeyFile;
Helper.CredConfig.Type = QUIC_CREDENTIAL_TYPE_CERTIFICATE_FILE;
Helper.CredConfig.CertificateFile = &Helper.CertFile;
#ifdef QUIC_TEST_APIS
} else if (GetValue(argc, argv, "selfsign")) {
Config = CxPlatGetSelfSignedCert(CXPLAT_SELF_SIGN_CERT_USER, FALSE, NULL);
if (!Config) {
return nullptr;
}
#endif
} else {
return nullptr;
}
#ifdef QUIC_TEST_APIS
void* Context = (Config != &Helper.CredConfig) ? (void*)Config : nullptr;
#else
void* Context = nullptr;
#endif
HQUIC Configuration = nullptr;
if (QUIC_SUCCEEDED(
MsQuicTable->ConfigurationOpen(
Registration,
AlpnBuffers,
AlpnBufferCount,
Settings,
SettingsSize,
Context,
&Configuration)) &&
QUIC_FAILED(
MsQuicTable->ConfigurationLoadCredential(
Configuration,
Config))) {
MsQuicTable->ConfigurationClose(Configuration);
Configuration = nullptr;
}
#ifdef QUIC_TEST_APIS
if (!Configuration && Config != &Helper.CredConfig) {
CxPlatFreeSelfSignedCert(Config);
}
#endif
return Configuration;
}
inline
void
FreeServerConfiguration(
_In_ const QUIC_API_TABLE* MsQuicTable,
_In_ HQUIC Configuration
)
{
#ifdef QUIC_TEST_APIS
auto SelfSignedConfig = (const QUIC_CREDENTIAL_CONFIG*)MsQuicTable->GetContext(Configuration);
if (SelfSignedConfig) {
CxPlatFreeSelfSignedCert(SelfSignedConfig);
}
#endif
MsQuicTable->ConfigurationClose(Configuration);
}
inline
void
WriteSslKeyLogFile(
_In_z_ const char* FileName,
_In_ QUIC_TLS_SECRETS& TlsSecrets
)
{
FILE* File = nullptr;
#ifdef _WIN32
File = _fsopen(FileName, "ab", _SH_DENYNO);
#else
File = fopen(FileName, "ab");
#endif
if (File == nullptr) {
printf("Failed to open sslkeylogfile %s\n", FileName);
return;
}
if (fseek(File, 0, SEEK_END) == 0 && ftell(File) == 0) {
fprintf(File, "# TLS 1.3 secrets log file, generated by quicinterop\n");
}
char ClientRandomBuffer[(2 * sizeof(QUIC_TLS_SECRETS::ClientRandom)) + 1] = {0};
char TempHexBuffer[(2 * QUIC_TLS_SECRETS_MAX_SECRET_LEN) + 1] = {0};
if (TlsSecrets.IsSet.ClientRandom) {
EncodeHexBuffer(
TlsSecrets.ClientRandom,
(uint8_t)sizeof(TlsSecrets.ClientRandom),
ClientRandomBuffer);
}
if (TlsSecrets.IsSet.ClientEarlyTrafficSecret) {
EncodeHexBuffer(
TlsSecrets.ClientEarlyTrafficSecret,
TlsSecrets.SecretLength,
TempHexBuffer);
fprintf(
File,
"CLIENT_EARLY_TRAFFIC_SECRET %s %s\n",
ClientRandomBuffer,
TempHexBuffer);
}
if (TlsSecrets.IsSet.ClientHandshakeTrafficSecret) {
EncodeHexBuffer(
TlsSecrets.ClientHandshakeTrafficSecret,
TlsSecrets.SecretLength,
TempHexBuffer);
fprintf(
File,
"CLIENT_HANDSHAKE_TRAFFIC_SECRET %s %s\n",
ClientRandomBuffer,
TempHexBuffer);
}
if (TlsSecrets.IsSet.ServerHandshakeTrafficSecret) {
EncodeHexBuffer(
TlsSecrets.ServerHandshakeTrafficSecret,
TlsSecrets.SecretLength,
TempHexBuffer);
fprintf(
File,
"SERVER_HANDSHAKE_TRAFFIC_SECRET %s %s\n",
ClientRandomBuffer,
TempHexBuffer);
}
if (TlsSecrets.IsSet.ClientTrafficSecret0) {
EncodeHexBuffer(
TlsSecrets.ClientTrafficSecret0,
TlsSecrets.SecretLength,
TempHexBuffer);
fprintf(
File,
"CLIENT_TRAFFIC_SECRET_0 %s %s\n",
ClientRandomBuffer,
TempHexBuffer);
}
if (TlsSecrets.IsSet.ServerTrafficSecret0) {
EncodeHexBuffer(
TlsSecrets.ServerTrafficSecret0,
TlsSecrets.SecretLength,
TempHexBuffer);
fprintf(
File,
"SERVER_TRAFFIC_SECRET_0 %s %s\n",
ClientRandomBuffer,
TempHexBuffer);
}
fflush(File);
fclose(File);
}
#endif // defined(__cplusplus)
|
e09c985d01f8d4daf337e8044131be934e58954a
|
281e2f72eeefb4ca211e07154e393090d10c5a74
|
/patch/st_embedder_x.h
|
6910fb9eb293d7489dabfd3180214a156e629c34
|
[
"MIT"
] |
permissive
|
bakkeby/st-flexipatch
|
b7516375372476aa5dd37aba8a48150eb108aa40
|
f097dbd0798d36f817b29f9881e1989f8864843d
|
refs/heads/master
| 2023-08-05T04:58:26.636960
| 2023-07-05T09:15:27
| 2023-07-05T09:15:27
| 209,058,985
| 321
| 129
|
MIT
| 2023-07-20T00:42:22
| 2019-09-17T13:17:33
|
C
|
UTF-8
|
C
| false
| false
| 239
|
h
|
st_embedder_x.h
|
#define XEMBED_EMBEDDED_NOTIFY 0
#define XEMBED_WINDOW_ACTIVATE 1
#define XEMBED_FOCUS_CURRENT 0
static void createnotify(XEvent *e);
static void destroynotify(XEvent *e);
static void sendxembed(long msg, long detail, long d1, long d2);
|
3a24e1a781af33b8acbc0cde4b6e236f5177aa7b
|
f8c0a188d1cf8ae5221c4cd11552c221a86e259a
|
/Firmware/WeighAX/Firmware/Common/Scales.h
|
39fd15c3c7133e8b0c6587a2a0da3651a02a64b3
|
[
"CC-BY-3.0",
"BSD-2-Clause"
] |
permissive
|
digitalinteraction/openmovement
|
6310abf35b379655073485e84719cc2521733c0e
|
9c2ee2eeb5eae457673e60699b2842c6df82abb1
|
refs/heads/master
| 2023-08-03T23:48:42.973605
| 2023-07-26T17:52:37
| 2023-07-26T17:52:37
| 27,082,024
| 135
| 86
| null | 2018-06-21T23:32:43
| 2014-11-24T15:38:43
|
C
|
UTF-8
|
C
| false
| false
| 2,417
|
h
|
Scales.h
|
/*
* Copyright (c) 2012-2013, Newcastle University, UK.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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.
*/
#ifndef SCALES_H
#define SCALES_H
// Include
// Types
typedef struct
{
unsigned char syncCode; // @0 0x55
unsigned char weightMSB; // @1 High byte of weight short
unsigned char weightLSB; // @2 Low byte of weight short
unsigned char units; // @3 0-kg,1-lbs,2St:lbs.d
unsigned char checksum; // @4 Unknown format
// USER SET BYTES
unsigned short weight; // Weight, native
unsigned long time; // Time of measurement
} scaleData_t;
// Globals
extern volatile scaleData_t gScaleData;
extern unsigned char scales_buffer[];
extern unsigned short scales_buffer_tail;
extern unsigned short scales_buffer_head;
extern volatile unsigned char gScalesDataReady;
// Prototypes
void ScalesCommInit(void);
void ScalesCommOff(void);
void ScalesCommWait(void);
void ScalesCommClear(void);
unsigned char ScalesDataReady(void);
unsigned char ScalesDataWaiting(void);
unsigned char ScalesParseData(void);
#endif
|
021e9937ff27a0698a5bc494c4293f680f437512
|
e1cddfd754d952134e72dfd03522c5ea4fb6008e
|
/src/vnet/interface_cli.c
|
74ac32522d71507eb18547c105880e915f848944
|
[
"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
| 82,989
|
c
|
interface_cli.c
|
/*
* Copyright (c) 2015 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.
*/
/*
* interface_cli.c: interface CLI
*
* Copyright (c) 2008 Eliot Dresselhaus
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file
* @brief Interface CLI.
*
* Source code for several CLI interface commands.
*
*/
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
#include <vppinfra/bitmap.h>
#include <vnet/fib/ip4_fib.h>
#include <vnet/fib/ip6_fib.h>
#include <vnet/l2/l2_output.h>
#include <vnet/l2/l2_input.h>
#include <vnet/classify/vnet_classify.h>
#include <vnet/interface/rx_queue_funcs.h>
#include <vnet/interface/tx_queue_funcs.h>
#include <vnet/hash/hash.h>
static int
compare_interface_names (void *a1, void *a2)
{
u32 *hi1 = a1;
u32 *hi2 = a2;
return vnet_hw_interface_compare (vnet_get_main (), *hi1, *hi2);
}
static clib_error_t *
show_or_clear_hw_interfaces (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd, int is_show)
{
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnm->interface_main;
vnet_hw_interface_t *hi;
u32 hw_if_index, *hw_if_indices = 0;
int i, verbose = -1, show_bond = 0;
if (!unformat_user (input, unformat_line_input, line_input))
goto skip_unformat;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
/* See if user wants to show a specific interface. */
if (unformat (line_input, "%U", unformat_vnet_hw_interface, vnm,
&hw_if_index))
vec_add1 (hw_if_indices, hw_if_index);
/* See if user wants to show an interface with a specific hw_if_index. */
else if (unformat (line_input, "%u", &hw_if_index))
vec_add1 (hw_if_indices, hw_if_index);
else if (unformat (line_input, "verbose"))
verbose = 1; /* this is also the default */
else if (unformat (line_input, "detail"))
verbose = 2;
else if (unformat (line_input, "brief"))
verbose = 0;
else if (unformat (line_input, "bond"))
{
show_bond = 1;
if (verbose < 0)
verbose = 0; /* default to brief for link bonding */
}
else
{
error = clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
unformat_free (line_input);
goto done;
}
}
unformat_free (line_input);
skip_unformat:
/* Gather interfaces. */
if (vec_len (hw_if_indices) == 0)
pool_foreach (hi, im->hw_interfaces)
vec_add1 (hw_if_indices, hi - im->hw_interfaces);
if (verbose < 0)
verbose = 1; /* default to verbose (except bond) */
if (is_show)
{
/* Sort by name. */
vec_sort_with_function (hw_if_indices, compare_interface_names);
vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm, 0, verbose);
for (i = 0; i < vec_len (hw_if_indices); i++)
{
hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
if (show_bond == 0) /* show all interfaces */
vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
hi, verbose);
else if ((hi->bond_info) &&
(hi->bond_info != VNET_HW_INTERFACE_BOND_INFO_SLAVE))
{ /* show only bonded interface and all its slave interfaces */
int hw_idx;
vnet_hw_interface_t *shi;
vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
hi, verbose);
/* *INDENT-OFF* */
clib_bitmap_foreach (hw_idx, hi->bond_info)
{
shi = vnet_get_hw_interface(vnm, hw_idx);
vlib_cli_output (vm, "%U\n",
format_vnet_hw_interface, vnm, shi, verbose);
}
/* *INDENT-ON* */
}
}
}
else
{
for (i = 0; i < vec_len (hw_if_indices); i++)
{
vnet_device_class_t *dc;
hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
dc = vec_elt_at_index (im->device_classes, hi->dev_class_index);
if (dc->clear_counters)
dc->clear_counters (hi->dev_instance);
}
}
done:
vec_free (hw_if_indices);
return error;
}
static clib_error_t *
show_hw_interfaces (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
return show_or_clear_hw_interfaces (vm, input, cmd, 1 /* is_show */ );
}
static clib_error_t *
clear_hw_interfaces (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
return show_or_clear_hw_interfaces (vm, input, cmd, 0 /* is_show */ );
}
/*?
* Display more detailed information about all or a list of given interfaces.
* The verboseness of the output can be controlled by the following optional
* parameters:
* - brief: Only show name, index and state (default for bonded interfaces).
* - verbose: Also display additional attributes (default for all other interfaces).
* - detail: Also display all remaining attributes and extended statistics.
*
* To limit the output of the command to bonded interfaces and their slave
* interfaces, use the '<em>bond</em>' optional parameter.
*
* @cliexpar
* Example of how to display default data for all interfaces:
* @cliexstart{show hardware-interfaces}
* Name Idx Link Hardware
* GigabitEthernet7/0/0 1 up GigabitEthernet7/0/0
* Ethernet address ec:f4:bb:c0:bc:fc
* Intel e1000
* carrier up full duplex speed 1000 mtu 9216
* rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
* cpu socket 0
* GigabitEthernet7/0/1 2 up GigabitEthernet7/0/1
* Ethernet address ec:f4:bb:c0:bc:fd
* Intel e1000
* carrier up full duplex speed 1000 mtu 9216
* rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
* cpu socket 0
* VirtualEthernet0/0/0 3 up VirtualEthernet0/0/0
* Ethernet address 02:fe:a5:a9:8b:8e
* VirtualEthernet0/0/1 4 up VirtualEthernet0/0/1
* Ethernet address 02:fe:c0:4e:3b:b0
* VirtualEthernet0/0/2 5 up VirtualEthernet0/0/2
* Ethernet address 02:fe:1f:73:92:81
* VirtualEthernet0/0/3 6 up VirtualEthernet0/0/3
* Ethernet address 02:fe:f2:25:c4:68
* local0 0 down local0
* local
* @cliexend
* Example of how to display '<em>verbose</em>' data for an interface by name and
* software index (where 2 is the software index):
* @cliexstart{show hardware-interfaces GigabitEthernet7/0/0 2 verbose}
* Name Idx Link Hardware
* GigabitEthernet7/0/0 1 up GigabitEthernet7/0/0
* Ethernet address ec:f4:bb:c0:bc:fc
* Intel e1000
* carrier up full duplex speed 1000 mtu 9216
* rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
* cpu socket 0
* GigabitEthernet7/0/1 2 down GigabitEthernet7/0/1
* Ethernet address ec:f4:bb:c0:bc:fd
* Intel e1000
* carrier up full duplex speed 1000 mtu 9216
* rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
* cpu socket 0
* @cliexend
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_hw_interfaces_command, static) = {
.path = "show hardware-interfaces",
.short_help = "show hardware-interfaces [brief|verbose|detail] [bond] "
"[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
.function = show_hw_interfaces,
};
/* *INDENT-ON* */
/*?
* Clear the extended statistics for all or a list of given interfaces
* (statistics associated with the '<em>show hardware-interfaces</em>' command).
*
* @cliexpar
* Example of how to clear the extended statistics for all interfaces:
* @cliexcmd{clear hardware-interfaces}
* Example of how to clear the extended statistics for an interface by
* name and software index (where 2 is the software index):
* @cliexcmd{clear hardware-interfaces GigabitEthernet7/0/0 2}
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (clear_hw_interface_counters_command, static) = {
.path = "clear hardware-interfaces",
.short_help = "clear hardware-interfaces "
"[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
.function = clear_hw_interfaces,
};
/* *INDENT-ON* */
static int
sw_interface_name_compare (void *a1, void *a2)
{
vnet_sw_interface_t *si1 = a1;
vnet_sw_interface_t *si2 = a2;
return vnet_sw_interface_compare (vnet_get_main (),
si1->sw_if_index, si2->sw_if_index);
}
static clib_error_t *
show_sw_interfaces (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
clib_error_t *error = 0;
vnet_main_t *vnm = vnet_get_main ();
unformat_input_t _linput, *linput = &_linput;
vnet_interface_main_t *im = &vnm->interface_main;
vnet_sw_interface_t *si, *sorted_sis = 0;
u32 sw_if_index = ~(u32) 0;
u8 show_addresses = 0;
u8 show_features = 0;
u8 show_tag = 0;
u8 show_vtr = 0;
int verbose = 0;
/*
* Get a line of input. Won't work if the user typed
* "show interface" and nothing more.
*/
if (unformat_user (input, unformat_line_input, linput))
{
while (unformat_check_input (linput) != UNFORMAT_END_OF_INPUT)
{
/* See if user wants to show specific interface */
if (unformat
(linput, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
{
si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
vec_add1 (sorted_sis, si[0]);
}
else if (unformat (linput, "address") || unformat (linput, "addr"))
show_addresses = 1;
else if (unformat (linput, "features") || unformat (linput, "feat"))
show_features = 1;
else if (unformat (linput, "tag"))
show_tag = 1;
else if (unformat (linput, "vtr"))
show_vtr = 1;
else if (unformat (linput, "verbose"))
verbose = 1;
else if (unformat (linput, "%d", &sw_if_index))
{
if (!pool_is_free_index (im->sw_interfaces, sw_if_index))
{
si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
vec_add1 (sorted_sis, si[0]);
}
else
{
vec_free (sorted_sis);
error = clib_error_return (0, "unknown interface index `%d'",
sw_if_index);
goto done;
}
}
else
{
vec_free (sorted_sis);
error = clib_error_return (0, "unknown input `%U'",
format_unformat_error, linput);
goto done;
}
}
unformat_free (linput);
}
if (show_features || show_tag || show_vtr)
{
if (sw_if_index == ~(u32) 0)
{
vec_free (sorted_sis);
return clib_error_return (0, "Interface not specified...");
}
}
if (show_features)
{
vnet_interface_features_show (vm, sw_if_index, verbose);
vlib_cli_output (vm, "%U", format_l2_input_features, sw_if_index, 1);
l2_output_config_t *l2_output = l2output_intf_config (sw_if_index);
vlib_cli_output (vm, "\nl2-output:");
if (l2_output->out_vtr_flag)
vlib_cli_output (vm, "%10s (%s)", "VTR", "--internal--");
vlib_cli_output (vm, "%U", format_l2_output_features,
l2_output->feature_bitmap, 1);
vec_free (sorted_sis);
return 0;
}
if (show_tag)
{
u8 *tag;
tag = vnet_get_sw_interface_tag (vnm, sw_if_index);
vlib_cli_output (vm, "%U: %s",
format_vnet_sw_if_index_name, vnm, sw_if_index,
tag ? (char *) tag : "(none)");
vec_free (sorted_sis);
return 0;
}
/*
* Show vlan tag rewrite data for one interface.
*/
if (show_vtr)
{
u32 vtr_op = L2_VTR_DISABLED;
u32 push_dot1q = 0, tag1 = 0, tag2 = 0;
if (l2vtr_get (vm, vnm, sw_if_index,
&vtr_op, &push_dot1q, &tag1, &tag2) != 0)
{
vlib_cli_output (vm, "%U: Problem getting vlan tag-rewrite data",
format_vnet_sw_if_index_name, vnm, sw_if_index);
return 0;
}
vlib_cli_output (vm, "%U: VTR %0U",
format_vnet_sw_if_index_name, vnm, sw_if_index,
format_vtr, vtr_op, push_dot1q, tag1, tag2);
return 0;
}
if (!show_addresses)
vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, 0);
if (vec_len (sorted_sis) == 0) /* Get all interfaces */
{
/* Gather interfaces. */
sorted_sis =
vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
vec_set_len (sorted_sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces)
{
int visible = vnet_swif_is_api_visible (si);
if (visible)
vec_add1 (sorted_sis, si[0]);
}
/* *INDENT-ON* */
/* Sort by name. */
vec_sort_with_function (sorted_sis, sw_interface_name_compare);
}
if (show_addresses)
{
vec_foreach (si, sorted_sis)
{
ip4_main_t *im4 = &ip4_main;
ip6_main_t *im6 = &ip6_main;
ip_lookup_main_t *lm4 = &im4->lookup_main;
ip_lookup_main_t *lm6 = &im6->lookup_main;
ip_interface_address_t *ia = 0;
u32 fib_index4 = 0, fib_index6 = 0;
if (vec_len (im4->fib_index_by_sw_if_index) > si->sw_if_index)
fib_index4 = vec_elt (im4->fib_index_by_sw_if_index,
si->sw_if_index);
if (vec_len (im6->fib_index_by_sw_if_index) > si->sw_if_index)
fib_index6 = vec_elt (im6->fib_index_by_sw_if_index,
si->sw_if_index);
ip4_fib_t *fib4 = ip4_fib_get (fib_index4);
ip6_fib_t *fib6 = ip6_fib_get (fib_index6);
if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
vlib_cli_output
(vm, "%U (%s): \n unnumbered, use %U",
format_vnet_sw_if_index_name, vnm, si->sw_if_index,
(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn",
format_vnet_sw_if_index_name, vnm, si->unnumbered_sw_if_index);
else
vlib_cli_output
(vm, "%U (%s):",
format_vnet_sw_if_index_name, vnm, si->sw_if_index,
(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn");
/* Display any L2 info */
vlib_cli_output (vm, "%U", format_l2_input, si->sw_if_index);
/* *INDENT-OFF* */
/* Display any IP4 addressing info */
foreach_ip_interface_address (lm4, ia, si->sw_if_index,
1 /* honor unnumbered */,
({
ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia);
if (fib4->hash.table_id)
vlib_cli_output (
vm, " L3 %U/%d ip4 table-id %d fib-idx %d", format_ip4_address,
r4, ia->address_length, fib4->hash.table_id,
ip4_fib_index_from_table_id (fib4->hash.table_id));
else
vlib_cli_output (vm, " L3 %U/%d",
format_ip4_address, r4, ia->address_length);
}));
/* *INDENT-ON* */
/* *INDENT-OFF* */
/* Display any IP6 addressing info */
foreach_ip_interface_address (lm6, ia, si->sw_if_index,
1 /* honor unnumbered */,
({
ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia);
if (fib6->table_id)
vlib_cli_output (vm, " L3 %U/%d ip6 table-id %d fib-idx %d",
format_ip6_address, r6, ia->address_length,
fib6->table_id,
ip6_fib_index_from_table_id (fib6->table_id));
else
vlib_cli_output (vm, " L3 %U/%d",
format_ip6_address, r6, ia->address_length);
}));
/* *INDENT-ON* */
}
}
else
{
vec_foreach (si, sorted_sis)
{
vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, si);
}
}
done:
vec_free (sorted_sis);
return error;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_sw_interfaces_command, static) = {
.path = "show interface",
.short_help = "show interface [address|addr|features|feat|vtr|tag] "
"[<interface> [<interface> [..]]] [verbose]",
.function = show_sw_interfaces,
.is_mp_safe = 1,
};
/* *INDENT-ON* */
/* Root of all interface commands. */
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (vnet_cli_interface_command, static) = {
.path = "interface",
.short_help = "Interface commands",
};
/* *INDENT-ON* */
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (vnet_cli_set_interface_command, static) = {
.path = "set interface",
.short_help = "Interface commands",
};
/* *INDENT-ON* */
static clib_error_t *
clear_interface_counters (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnm->interface_main;
vlib_simple_counter_main_t *sm;
vlib_combined_counter_main_t *cm;
int j, n_counters;
n_counters = vec_len (im->combined_sw_if_counters);
for (j = 0; j < n_counters; j++)
{
im = &vnm->interface_main;
cm = im->combined_sw_if_counters + j;
vlib_clear_combined_counters (cm);
}
n_counters = vec_len (im->sw_if_counters);
for (j = 0; j < n_counters; j++)
{
im = &vnm->interface_main;
sm = im->sw_if_counters + j;
vlib_clear_simple_counters (sm);
}
return 0;
}
/*?
* Clear the statistics for all interfaces (statistics associated with the
* '<em>show interface</em>' command).
*
* @cliexpar
* Example of how to clear the statistics for all interfaces:
* @cliexcmd{clear interfaces}
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (clear_interface_counters_command, static) = {
.path = "clear interfaces",
.short_help = "clear interfaces",
.function = clear_interface_counters,
};
/* *INDENT-ON* */
/**
* Parse subinterface names.
*
* The following subinterface syntax is supported. The first two are for
* backwards compatability:
*
* <intf-name> <id>
* - a subinterface with the name <intf-name>.<id>. The subinterface
* is a single dot1q vlan with vlan id <id> and exact-match semantics.
*
* <intf-name> <min_id>-<max_id>
* - a set of the above subinterfaces, repeating for each id
* in the range <min_id> to <max_id>
*
* In the following, exact-match semantics (i.e. the number of vlan tags on the
* packet must match the number of tags in the configuration) are used only if
* the keyword exact-match is present. Non-exact match is the default.
*
* <intf-name> <id> dot1q <outer_id> [exact-match]
* - a subinterface with the name <intf-name>.<id>. The subinterface
* is a single dot1q vlan with vlan id <outer_id>.
*
* <intf-name> <id> dot1q any [exact-match]
* - a subinterface with the name <intf-name>.<id>. The subinterface
* is a single dot1q vlan with any vlan id.
*
* <intf-name> <id> dot1q <outer_id> inner-dot1q <inner_id> [exact-match]
* - a subinterface with the name <intf-name>.<id>. The subinterface
* is a double dot1q vlan with outer vlan id <outer_id> and inner vlan id
* <inner_id>.
*
* <intf-name> <id> dot1q <outer_id> inner-dot1q any [exact-match]
* - a subinterface with the name <intf-name>.<id>. The subinterface
* is a double dot1q vlan with outer vlan id <id> and any inner vlan id.
*
* <intf-name> <id> dot1q any inner-dot1q any [exact-match]
*
* - a subinterface with the name <intf-name>.<id>. The subinterface
* is a double dot1q vlan with any outer vlan id and any inner vlan id.
*
* For each of the above CLI, there is a duplicate that uses the keyword
* "dot1ad" in place of the first "dot1q". These interfaces use ethertype
* 0x88ad in place of 0x8100 for the outer ethertype. Note that for double-
* tagged packets the inner ethertype is always 0x8100. Also note that
* the dot1q and dot1ad naming spaces are independent, so it is legal to
* have both "Gig3/0/0.1 dot1q 100" and "Gig3/0/0.2 dot1ad 100". For example:
*
* <intf-name> <id> dot1ad <outer_id> inner-dot1q <inner_id> [exact-match]
* - a subinterface with the name <intf-name>.<id>. The subinterface
* is a double dot1ad vlan with outer vlan id <outer_id> and inner vlan
* id <inner_id>.
*
* <intf-name> <id> untagged
* - a subinterface with the name <intf-name>.<id>. The subinterface
* has no vlan tags. Only one can be specified per interface.
*
* <intf-name> <id> default
* - a subinterface with the name <intf-name>.<id>. This is associated
* with a packet that did not match any other configured subinterface
* on this interface. Only one can be specified per interface.
*/
static clib_error_t *
parse_vlan_sub_interfaces (unformat_input_t * input,
vnet_sw_interface_t * template)
{
clib_error_t *error = 0;
u32 inner_vlan, outer_vlan;
if (unformat (input, "any inner-dot1q any"))
{
template->sub.eth.flags.two_tags = 1;
template->sub.eth.flags.outer_vlan_id_any = 1;
template->sub.eth.flags.inner_vlan_id_any = 1;
}
else if (unformat (input, "any"))
{
template->sub.eth.flags.one_tag = 1;
template->sub.eth.flags.outer_vlan_id_any = 1;
}
else if (unformat (input, "%d inner-dot1q any", &outer_vlan))
{
template->sub.eth.flags.two_tags = 1;
template->sub.eth.flags.inner_vlan_id_any = 1;
template->sub.eth.outer_vlan_id = outer_vlan;
}
else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan))
{
template->sub.eth.flags.two_tags = 1;
template->sub.eth.outer_vlan_id = outer_vlan;
template->sub.eth.inner_vlan_id = inner_vlan;
}
else if (unformat (input, "%d", &outer_vlan))
{
template->sub.eth.flags.one_tag = 1;
template->sub.eth.outer_vlan_id = outer_vlan;
}
else
{
error = clib_error_return (0, "expected dot1q config, got `%U'",
format_unformat_error, input);
goto done;
}
if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "exact-match"))
{
template->sub.eth.flags.exact_match = 1;
}
}
done:
return error;
}
static clib_error_t *
create_sub_interfaces (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
clib_error_t *error = 0;
u32 hw_if_index, sw_if_index;
vnet_hw_interface_t *hi;
u32 id, id_min, id_max;
vnet_sw_interface_t template;
hw_if_index = ~0;
if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
{
error = clib_error_return (0, "unknown interface `%U'",
format_unformat_error, input);
goto done;
}
clib_memset (&template, 0, sizeof (template));
template.sub.eth.raw_flags = 0;
if (unformat (input, "%d default", &id_min))
{
id_max = id_min;
template.sub.eth.flags.default_sub = 1;
}
else if (unformat (input, "%d untagged", &id_min))
{
id_max = id_min;
template.sub.eth.flags.no_tags = 1;
template.sub.eth.flags.exact_match = 1;
}
else if (unformat (input, "%d dot1q", &id_min))
{
/* parse dot1q config */
id_max = id_min;
error = parse_vlan_sub_interfaces (input, &template);
if (error)
goto done;
}
else if (unformat (input, "%d dot1ad", &id_min))
{
/* parse dot1ad config */
id_max = id_min;
template.sub.eth.flags.dot1ad = 1;
error = parse_vlan_sub_interfaces (input, &template);
if (error)
goto done;
}
else if (unformat (input, "%d-%d", &id_min, &id_max))
{
template.sub.eth.flags.one_tag = 1;
template.sub.eth.flags.exact_match = 1;
if (id_min > id_max)
goto id_error;
}
else if (unformat (input, "%d", &id_min))
{
id_max = id_min;
template.sub.eth.flags.one_tag = 1;
template.sub.eth.outer_vlan_id = id_min;
template.sub.eth.flags.exact_match = 1;
}
else
{
id_error:
error = clib_error_return (0, "expected ID or ID MIN-MAX, got `%U'",
format_unformat_error, input);
goto done;
}
hi = vnet_get_hw_interface (vnm, hw_if_index);
if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
{
error =
clib_error_return (0,
"not allowed as %v belong to a BondEthernet interface",
hi->name);
goto done;
}
for (id = id_min; id <= id_max; id++)
{
uword *p;
vnet_interface_main_t *im = &vnm->interface_main;
u64 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
u64 *kp;
p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
if (p)
{
if (CLIB_DEBUG > 0)
clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
hi->sw_if_index, id);
continue;
}
template.type = VNET_SW_INTERFACE_TYPE_SUB;
template.flood_class = VNET_FLOOD_CLASS_NORMAL;
template.sup_sw_if_index = hi->sw_if_index;
template.sub.id = id;
if (id_min < id_max)
template.sub.eth.outer_vlan_id = id;
error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
if (error)
goto done;
kp = clib_mem_alloc (sizeof (*kp));
*kp = sup_and_sub_key;
hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name,
vnet_get_main (), sw_if_index);
}
done:
return error;
}
/*?
* This command is used to add VLAN IDs to interfaces, also known as subinterfaces.
* The primary input to this command is the '<em>interface</em>' and '<em>subId</em>'
* (subinterface Id) parameters. If no additional VLAN ID is provide, the VLAN ID is
* assumed to be the '<em>subId</em>'. The VLAN ID and '<em>subId</em>' can be different,
* but this is not recommended.
*
* This command has several variations:
* - <b>create sub-interfaces <interface> <subId></b> - Create a subinterface to
* process packets with a given 802.1q VLAN ID (same value as the '<em>subId</em>').
*
* - <b>create sub-interfaces <interface> <subId> default</b> - Adding the
* '<em>default</em>' parameter indicates that packets with VLAN IDs that do not
* match any other subinterfaces should be sent to this subinterface.
*
* - <b>create sub-interfaces <interface> <subId> untagged</b> - Adding the
* '<em>untagged</em>' parameter indicates that packets no VLAN IDs should be sent
* to this subinterface.
*
* - <b>create sub-interfaces <interface> <subId>-<subId></b> - Create a range of
* subinterfaces to handle a range of VLAN IDs.
*
* - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any [exact-match]</b> -
* Use this command to specify the outer VLAN ID, to either be explicit or to make the
* VLAN ID different from the '<em>subId</em>'.
*
* - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any inner-dot1q
* <vlanId>|any [exact-match]</b> - Use this command to specify the outer VLAN ID and
* the inner VLAN ID.
*
* When '<em>dot1q</em>' or '<em>dot1ad</em>' is explicitly entered, subinterfaces
* can be configured as either exact-match or non-exact match. Non-exact match is the CLI
* default. If '<em>exact-match</em>' is specified, packets must have the same number of
* VLAN tags as the configuration. For non-exact-match, packets must at least that number
* of tags. L3 (routed) interfaces must be configured as exact-match. L2 interfaces are
* typically configured as non-exact-match. If '<em>dot1q</em>' or '<em>dot1ad</em>' is NOT
* entered, then the default behavior is exact-match.
*
* Use the '<em>show interface</em>' command to display all subinterfaces.
*
* @cliexpar
* @parblock
* Example of how to create a VLAN subinterface 11 to process packets on 802.1q VLAN ID 11:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11}
*
* The previous example is shorthand and is equivalent to:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 11 exact-match}
*
*
* Example of how to create a subinterface number that is different from the VLAN ID:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100}
*
*
* Examples of how to create q-in-q and q-in-any subinterfaces:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100 inner-dot1q 200}
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1q 100 inner-dot1q any}
*
* Examples of how to create dot1ad interfaces:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1ad 11}
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1ad 100 inner-dot1q 200}
*
*
* Examples of '<em>exact-match</em>' versus non-exact match. A packet with
* outer VLAN 100 and inner VLAN 200 would match this interface, because the default
* is non-exact match:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100}
*
* However, the same packet would NOT match this interface because '<em>exact-match</em>'
* is specified and only one VLAN is configured, but packet contains two VLANs:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100 exact-match}
*
*
* Example of how to created a subinterface to process untagged packets:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 untagged}
*
* Example of how to created a subinterface to process any packet with a VLAN ID that
* does not match any other subinterface:
* @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 7 default}
*
* When subinterfaces are created, they are in the down state. Example of how to
* enable a newly created subinterface:
* @cliexcmd{set interface GigabitEthernet2/0/0.7 up}
* @endparblock
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (create_sub_interfaces_command, static) = {
.path = "create sub-interfaces",
.short_help = "create sub-interfaces <interface> "
"{<subId> [default|untagged]} | "
"{<subId>-<subId>} | "
"{<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}",
.function = create_sub_interfaces,
};
/* *INDENT-ON* */
static clib_error_t *
set_state (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
clib_error_t *error;
u32 sw_if_index, flags;
sw_if_index = ~0;
if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
{
error = clib_error_return (0, "unknown interface `%U'",
format_unformat_error, input);
goto done;
}
if (!unformat (input, "%U", unformat_vnet_sw_interface_flags, &flags))
{
error = clib_error_return (0, "unknown flags `%U'",
format_unformat_error, input);
goto done;
}
error = vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
if (error)
goto done;
done:
return error;
}
/*?
* This command is used to change the admin state (up/down) of an interface.
*
* If an interface is down, the optional '<em>punt</em>' flag can also be set.
* The '<em>punt</em>' flag implies the interface is disabled for forwarding
* but punt all traffic to slow-path. Use the '<em>enable</em>' flag to clear
* '<em>punt</em>' flag (interface is still down).
*
* @cliexpar
* Example of how to configure the admin state of an interface to
'<em>up</em>':
* @cliexcmd{set interface state GigabitEthernet2/0/0 up}
* Example of how to configure the admin state of an interface to
'<em>down</em>':
* @cliexcmd{set interface state GigabitEthernet2/0/0 down}
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_state_command, static) = {
.path = "set interface state",
.short_help = "set interface state <interface> [up|down|punt|enable]",
.function = set_state,
};
/* *INDENT-ON* */
static clib_error_t *
set_unnumbered (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
u32 unnumbered_sw_if_index = ~0;
u32 inherit_from_sw_if_index = ~0;
int enable = 1;
if (unformat (input, "%U use %U",
unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
unformat_vnet_sw_interface, vnm, &inherit_from_sw_if_index))
enable = 1;
else if (unformat (input, "del %U",
unformat_vnet_sw_interface, vnm,
&unnumbered_sw_if_index))
enable = 0;
else
return clib_error_return (0, "parse error '%U'",
format_unformat_error, input);
if (~0 == unnumbered_sw_if_index)
return clib_error_return (0, "Specify the unnumbered interface");
if (enable && ~0 == inherit_from_sw_if_index)
return clib_error_return (0, "When enabling unnumbered specify the"
" IP enabled interface that it uses");
int rv = vnet_sw_interface_update_unnumbered (
unnumbered_sw_if_index, inherit_from_sw_if_index, enable);
switch (rv)
{
case 0:
break;
case VNET_API_ERROR_UNEXPECTED_INTF_STATE:
return clib_error_return (
0,
"When enabling unnumbered both interfaces must be in the same tables");
default:
return clib_error_return (
0, "vnet_sw_interface_update_unnumbered returned %d", rv);
}
return (NULL);
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_unnumbered_command, static) = {
.path = "set interface unnumbered",
.short_help = "set interface unnumbered [<interface> use <interface> | del <interface>]",
.function = set_unnumbered,
};
/* *INDENT-ON* */
static clib_error_t *
set_hw_class (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnm->interface_main;
clib_error_t *error;
u32 hw_if_index, hw_class_index;
hw_if_index = ~0;
if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
{
error = clib_error_return (0, "unknown hardware interface `%U'",
format_unformat_error, input);
goto done;
}
if (!unformat_user (input, unformat_hash_string,
im->hw_interface_class_by_name, &hw_class_index))
{
error = clib_error_return (0, "unknown hardware class `%U'",
format_unformat_error, input);
goto done;
}
error = vnet_hw_interface_set_class (vnm, hw_if_index, hw_class_index);
if (error)
goto done;
done:
return error;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_hw_class_command, static) = {
.path = "set interface hw-class",
.short_help = "Set interface hardware class",
.function = set_hw_class,
};
/* *INDENT-ON* */
static clib_error_t *
vnet_interface_cli_init (vlib_main_t * vm)
{
return 0;
}
VLIB_INIT_FUNCTION (vnet_interface_cli_init);
static clib_error_t *
renumber_interface_command_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
u32 hw_if_index;
u32 new_dev_instance;
vnet_main_t *vnm = vnet_get_main ();
int rv;
if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
return clib_error_return (0, "unknown hardware interface `%U'",
format_unformat_error, input);
if (!unformat (input, "%d", &new_dev_instance))
return clib_error_return (0, "new dev instance missing");
rv = vnet_interface_name_renumber (hw_if_index, new_dev_instance);
switch (rv)
{
case 0:
break;
default:
return clib_error_return (0, "vnet_interface_name_renumber returned %d",
rv);
}
return 0;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (renumber_interface_command, static) = {
.path = "renumber interface",
.short_help = "renumber interface <interface> <new-dev-instance>",
.function = renumber_interface_command_fn,
};
/* *INDENT-ON* */
static clib_error_t *
promiscuous_cmd (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index;
u32 flags = ETHERNET_INTERFACE_FLAG_ACCEPT_ALL;
ethernet_main_t *em = ðernet_main;
ethernet_interface_t *eif;
if (unformat (input, "on %U",
unformat_vnet_hw_interface, vnm, &hw_if_index))
;
else if (unformat (input, "off %U",
unformat_ethernet_interface, vnm, &hw_if_index))
flags = 0;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
eif = ethernet_get_interface (em, hw_if_index);
if (!eif)
return clib_error_return (0, "not supported");
ethernet_set_flags (vnm, hw_if_index, flags);
return 0;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_promiscuous_cmd, static) = {
.path = "set interface promiscuous",
.short_help = "set interface promiscuous [on|off] <interface>",
.function = promiscuous_cmd,
};
/* *INDENT-ON* */
static clib_error_t *
mtu_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index, sw_if_index, mtu;
ethernet_main_t *em = ðernet_main;
u32 mtus[VNET_N_MTU] = { 0, 0, 0, 0 };
clib_error_t *err;
if (unformat (input, "%d %U", &mtu,
unformat_vnet_hw_interface, vnm, &hw_if_index))
{
/*
* Change physical MTU on interface. Only supported for Ethernet
* interfaces
*/
ethernet_interface_t *eif = ethernet_get_interface (em, hw_if_index);
if (!eif)
return clib_error_return (0, "not supported");
err = vnet_hw_interface_set_mtu (vnm, hw_if_index, mtu);
if (err)
return err;
goto done;
}
else if (unformat (input, "packet %d %U", &mtu,
unformat_vnet_sw_interface, vnm, &sw_if_index))
/* Set default packet MTU (including L3 header */
mtus[VNET_MTU_L3] = mtu;
else if (unformat (input, "ip4 %d %U", &mtu,
unformat_vnet_sw_interface, vnm, &sw_if_index))
mtus[VNET_MTU_IP4] = mtu;
else if (unformat (input, "ip6 %d %U", &mtu,
unformat_vnet_sw_interface, vnm, &sw_if_index))
mtus[VNET_MTU_IP6] = mtu;
else if (unformat (input, "mpls %d %U", &mtu,
unformat_vnet_sw_interface, vnm, &sw_if_index))
mtus[VNET_MTU_MPLS] = mtu;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
vnet_sw_interface_set_protocol_mtu (vnm, sw_if_index, mtus);
done:
return 0;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_mtu_cmd, static) = {
.path = "set interface mtu",
.short_help = "set interface mtu [packet|ip4|ip6|mpls] <value> <interface>",
.function = mtu_cmd,
};
/* *INDENT-ON* */
static clib_error_t *
show_interface_sec_mac_addr_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnm->interface_main;
ethernet_main_t *em = ðernet_main;
u32 sw_if_index = ~0;
vnet_sw_interface_t *si, *sorted_sis = 0;
if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
{
si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
vec_add1 (sorted_sis, si[0]);
}
/* if an interface name was not passed, get all interfaces */
if (vec_len (sorted_sis) == 0)
{
sorted_sis =
vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
vec_set_len (sorted_sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces)
{
int visible = vnet_swif_is_api_visible (si);
if (visible)
vec_add1 (sorted_sis, si[0]);
}
/* *INDENT-ON* */
/* Sort by name. */
vec_sort_with_function (sorted_sis, sw_interface_name_compare);
}
vec_foreach (si, sorted_sis)
{
vnet_sw_interface_t *sup_si;
ethernet_interface_t *ei;
sup_si = vnet_get_sup_sw_interface (vnm, si->sw_if_index);
ei = ethernet_get_interface (em, sup_si->hw_if_index);
vlib_cli_output (vm, "%U (%s):",
format_vnet_sw_if_index_name, vnm, si->sw_if_index,
(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ?
"up" : "dn");
if (ei && ei->secondary_addrs)
{
ethernet_interface_address_t *sec_addr;
vec_foreach (sec_addr, ei->secondary_addrs)
{
vlib_cli_output (vm, " %U", format_mac_address_t, &sec_addr->mac);
}
}
}
vec_free (sorted_sis);
return 0;
}
/*?
* This command is used to display interface secondary mac addresses.
*
* @cliexpar
* Example of how to display interface secondary mac addresses:
* @cliexstart{show interface secondary-mac-address}
* @cliexend
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_interface_sec_mac_addr, static) = {
.path = "show interface secondary-mac-address",
.short_help = "show interface secondary-mac-address [<interface>]",
.function = show_interface_sec_mac_addr_fn,
};
/* *INDENT-ON* */
static clib_error_t *
interface_add_del_mac_address (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_sw_interface_t *si = NULL;
clib_error_t *error = 0;
u32 sw_if_index = ~0;
u8 mac[6] = { 0 };
u8 is_add, is_del;
is_add = is_del = 0;
if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
{
error = clib_error_return (0, "unknown interface `%U'",
format_unformat_error, input);
goto done;
}
if (!unformat_user (input, unformat_ethernet_address, mac))
{
error = clib_error_return (0, "expected mac address `%U'",
format_unformat_error, input);
goto done;
}
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "add"))
is_add = 1;
else if (unformat (input, "del"))
is_del = 1;
else
break;
}
if (is_add == is_del)
{
error = clib_error_return (0, "must choose one of add or del");
goto done;
}
si = vnet_get_sw_interface (vnm, sw_if_index);
error =
vnet_hw_interface_add_del_mac_address (vnm, si->hw_if_index, mac, is_add);
done:
return error;
}
/*?
* The '<em>set interface secondary-mac-address </em>' command allows adding
* or deleting extra MAC addresses on a given interface without changing the
* default MAC address. This could allow packets sent to these MAC addresses
* to be received without setting the interface to promiscuous mode.
* Not all interfaces support this operation. The ones that do are mostly
* hardware NICs, though virtio does also.
*
* @cliexpar
* @parblock
* Example of how to add a secondary MAC Address on an interface:
* @cliexcmd{set interface secondary-mac-address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01 add}
* Example of how to delete a secondary MAC address from an interface:
* @cliexcmd{set interface secondary-mac-address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01 del}
* @endparblock
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (interface_add_del_mac_address_cmd, static) = {
.path = "set interface secondary-mac-address",
.short_help = "set interface secondary-mac-address <interface> <mac-address> [(add|del)]",
.function = interface_add_del_mac_address,
};
/* *INDENT-ON* */
static clib_error_t *
set_interface_mac_address (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_sw_interface_t *si = NULL;
clib_error_t *error = 0;
u32 sw_if_index = ~0;
u8 mac[6] = { 0 };
if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
{
error = clib_error_return (0, "unknown interface `%U'",
format_unformat_error, input);
goto done;
}
if (!unformat_user (input, unformat_ethernet_address, mac))
{
error = clib_error_return (0, "expected mac address `%U'",
format_unformat_error, input);
goto done;
}
si = vnet_get_sw_interface (vnm, sw_if_index);
error = vnet_hw_interface_change_mac_address (vnm, si->hw_if_index, mac);
done:
return error;
}
/*?
* The '<em>set interface mac address </em>' command allows to set MAC address of given interface.
* In case of NIC interfaces the one has to support MAC address change. A side effect of MAC address
* change are changes of MAC addresses in FIB tables (ipv4 and ipv6).
*
* @cliexpar
* @parblock
* Example of how to change MAC Address of interface:
* @cliexcmd{set interface mac address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01}
* @cliexcmd{set interface mac address host-vpp0 aa:bb:cc:dd:ee:02}
* @cliexcmd{set interface mac address tap-0 aa:bb:cc:dd:ee:03}
* @cliexcmd{set interface mac address pg0 aa:bb:cc:dd:ee:04}
* @endparblock
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_mac_address_cmd, static) = {
.path = "set interface mac address",
.short_help = "set interface mac address <interface> <mac-address>",
.function = set_interface_mac_address,
};
/* *INDENT-ON* */
static clib_error_t *
set_tag (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
u32 sw_if_index = ~0;
u8 *tag = 0;
if (!unformat (input, "%U %s", unformat_vnet_sw_interface,
vnm, &sw_if_index, &tag))
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
return 0;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_tag_command, static) = {
.path = "set interface tag",
.short_help = "set interface tag <interface> <tag>",
.function = set_tag,
};
/* *INDENT-ON* */
static clib_error_t *
clear_tag (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
u32 sw_if_index = ~0;
if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
vnet_clear_sw_interface_tag (vnm, sw_if_index);
return 0;
}
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (clear_tag_command, static) = {
.path = "clear interface tag",
.short_help = "clear interface tag <interface>",
.function = clear_tag,
};
/* *INDENT-ON* */
static clib_error_t *
set_ip_directed_broadcast (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
u32 sw_if_index = ~0;
u8 enable = 0;
if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
else if (unformat (input, "enable"))
enable = 1;
else if (unformat (input, "disable"))
enable = 0;
else
return clib_error_return (0, "unknown input: `%U'",
format_unformat_error, input);
if (~0 == sw_if_index)
return clib_error_return (0, "specify an interface: `%U'",
format_unformat_error, input);
vnet_sw_interface_ip_directed_broadcast (vnm, sw_if_index, enable);
return 0;
}
/*?
* This command is used to enable/disable IP directed broadcast
* If directed broadcast is enabled a packet sent to the interface's
* subnet broadcast address will be sent L2 broadcast on the interface,
* otherwise it is dropped.
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_ip_directed_broadcast_command, static) = {
.path = "set interface ip directed-broadcast",
.short_help = "set interface enable <interface> <enable|disable>",
.function = set_ip_directed_broadcast,
};
/* *INDENT-ON* */
clib_error_t *
set_hw_interface_change_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
u8 queue_id_valid, u32 queue_id,
vnet_hw_if_rx_mode mode)
{
clib_error_t *error = 0;
vnet_hw_interface_t *hw;
u32 *queue_indices = 0;
hw = vnet_get_hw_interface (vnm, hw_if_index);
if (queue_id_valid)
{
u32 queue_index;
queue_index =
vnet_hw_if_get_rx_queue_index_by_id (vnm, hw_if_index, queue_id);
if (queue_index == ~0)
return clib_error_return (0, "unknown queue %u on interface %s",
queue_id, hw->name);
vec_add1 (queue_indices, queue_index);
}
else
queue_indices = hw->rx_queue_indices;
for (int i = 0; i < vec_len (queue_indices); i++)
{
int rv = vnet_hw_if_set_rx_queue_mode (vnm, queue_indices[i], mode);
if (rv)
{
error = clib_error_return (
0, "unable to set rx-mode on interface %v queue-id %u.\n",
hw->name, queue_id);
goto done;
}
}
done:
if (queue_indices != hw->rx_queue_indices)
vec_free (queue_indices);
vnet_hw_if_update_runtime_data (vnm, hw_if_index);
return error;
}
static clib_error_t *
set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index = (u32) ~ 0;
u32 queue_id = (u32) ~ 0;
vnet_hw_if_rx_mode mode = VNET_HW_IF_RX_MODE_UNKNOWN;
u8 queue_id_valid = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat
(line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
;
else if (unformat (line_input, "queue %d", &queue_id))
queue_id_valid = 1;
else if (unformat (line_input, "polling"))
mode = VNET_HW_IF_RX_MODE_POLLING;
else if (unformat (line_input, "interrupt"))
mode = VNET_HW_IF_RX_MODE_INTERRUPT;
else if (unformat (line_input, "adaptive"))
mode = VNET_HW_IF_RX_MODE_ADAPTIVE;
else
{
error = clib_error_return (0, "parse error: '%U'",
format_unformat_error, line_input);
unformat_free (line_input);
return error;
}
}
unformat_free (line_input);
if (hw_if_index == (u32) ~ 0)
return clib_error_return (0, "please specify valid interface name");
if (mode == VNET_HW_IF_RX_MODE_UNKNOWN)
return clib_error_return (0, "please specify valid rx-mode");
error = set_hw_interface_change_rx_mode (vnm, hw_if_index, queue_id_valid,
queue_id, mode);
return (error);
}
/*?
* This command is used to assign the RX packet processing mode (polling,
* interrupt, adaptive) of the a given interface, and optionally a
* given queue. If the '<em>queue</em>' is not provided, the '<em>mode</em>'
* is applied to all queues of the interface. Not all interfaces support
* all modes. To display the current rx-mode use the command
* '<em>show interface rx-placement</em>'.
*
* @cliexpar
* Example of how to assign rx-mode to all queues on an interface:
* @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 polling}
* Example of how to assign rx-mode to one queue of an interface:
* @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 queue 0 interrupt}
* Example of how to display the rx-mode of all interfaces:
* @cliexstart{show interface rx-placement}
* Thread 1 (vpp_wk_0):
* node dpdk-input:
* GigabitEthernet7/0/0 queue 0 (polling)
* node vhost-user-input:
* VirtualEthernet0/0/12 queue 0 (interrupt)
* VirtualEthernet0/0/12 queue 2 (polling)
* VirtualEthernet0/0/13 queue 0 (polling)
* VirtualEthernet0/0/13 queue 2 (polling)
* Thread 2 (vpp_wk_1):
* node dpdk-input:
* GigabitEthernet7/0/1 queue 0 (polling)
* node vhost-user-input:
* VirtualEthernet0/0/12 queue 1 (polling)
* VirtualEthernet0/0/12 queue 3 (polling)
* VirtualEthernet0/0/13 queue 1 (polling)
* VirtualEthernet0/0/13 queue 3 (polling)
* @cliexend
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (cmd_set_if_rx_mode,static) = {
.path = "set interface rx-mode",
.short_help = "set interface rx-mode <interface> [queue <n>] [polling | interrupt | adaptive]",
.function = set_interface_rx_mode,
};
/* *INDENT-ON* */
static clib_error_t *
show_interface_rx_placement_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
u8 *s = 0;
vnet_main_t *vnm = vnet_get_main ();
vnet_hw_if_rx_queue_t **all_queues = 0;
vnet_hw_if_rx_queue_t **qptr;
vnet_hw_if_rx_queue_t *q;
pool_foreach (q, vnm->interface_main.hw_if_rx_queues)
vec_add1 (all_queues, q);
vec_sort_with_function (all_queues, vnet_hw_if_rxq_cmp_cli_api);
u32 prev_node = ~0;
vec_foreach (qptr, all_queues)
{
u32 current_thread = qptr[0]->thread_index;
u32 hw_if_index = qptr[0]->hw_if_index;
vnet_hw_interface_t *hw_if = vnet_get_hw_interface (vnm, hw_if_index);
u32 current_node = hw_if->input_node_index;
if (current_node != prev_node)
s = format (s, " node %U:\n", format_vlib_node_name, vm, current_node);
s = format (s, " %U queue %u (%U)\n", format_vnet_sw_if_index_name,
vnm, hw_if->sw_if_index, qptr[0]->queue_id,
format_vnet_hw_if_rx_mode, qptr[0]->mode);
if (qptr == all_queues + vec_len (all_queues) - 1 ||
current_thread != qptr[1]->thread_index)
{
vlib_cli_output (vm, "Thread %u (%s):\n%v", current_thread,
vlib_worker_threads[current_thread].name, s);
vec_reset_length (s);
}
prev_node = current_node;
}
vec_free (s);
vec_free (all_queues);
return 0;
}
/*?
* This command is used to display the interface and queue worker
* thread placement.
*
* @cliexpar
* Example of how to display the interface placement:
* @cliexstart{show interface rx-placement}
* Thread 1 (vpp_wk_0):
* node dpdk-input:
* GigabitEthernet7/0/0 queue 0 (polling)
* node vhost-user-input:
* VirtualEthernet0/0/12 queue 0 (polling)
* VirtualEthernet0/0/12 queue 2 (polling)
* VirtualEthernet0/0/13 queue 0 (polling)
* VirtualEthernet0/0/13 queue 2 (polling)
* Thread 2 (vpp_wk_1):
* node dpdk-input:
* GigabitEthernet7/0/1 queue 0 (polling)
* node vhost-user-input:
* VirtualEthernet0/0/12 queue 1 (polling)
* VirtualEthernet0/0/12 queue 3 (polling)
* VirtualEthernet0/0/13 queue 1 (polling)
* VirtualEthernet0/0/13 queue 3 (polling)
* @cliexend
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_interface_rx_placement, static) = {
.path = "show interface rx-placement",
.short_help = "show interface rx-placement",
.function = show_interface_rx_placement_fn,
};
/* *INDENT-ON* */
clib_error_t *
set_hw_interface_rx_placement (u32 hw_if_index, u32 queue_id,
u32 thread_index, u8 is_main)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_device_main_t *vdm = &vnet_device_main;
vnet_hw_interface_t *hw;
u32 queue_index;
if (is_main)
thread_index = 0;
else
thread_index += vdm->first_worker_thread_index;
if (thread_index > vdm->last_worker_thread_index)
return clib_error_return (0,
"please specify valid worker thread or main");
hw = vnet_get_hw_interface (vnm, hw_if_index);
queue_index =
vnet_hw_if_get_rx_queue_index_by_id (vnm, hw_if_index, queue_id);
if (queue_index == ~0)
return clib_error_return (0, "unknown queue %u on interface %s", queue_id,
hw->name);
vnet_hw_if_set_rx_queue_thread_index (vnm, queue_index, thread_index);
vnet_hw_if_update_runtime_data (vnm, hw_if_index);
return 0;
}
static clib_error_t *
set_interface_rx_placement (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index = (u32) ~ 0;
u32 queue_id = (u32) 0;
u32 thread_index = (u32) ~ 0;
u8 is_main = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat
(line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
;
else if (unformat (line_input, "queue %d", &queue_id))
;
else if (unformat (line_input, "main", &thread_index))
is_main = 1;
else if (unformat (line_input, "worker %d", &thread_index))
;
else
{
error = clib_error_return (0, "parse error: '%U'",
format_unformat_error, line_input);
unformat_free (line_input);
return error;
}
}
unformat_free (line_input);
if (hw_if_index == (u32) ~ 0)
return clib_error_return (0, "please specify valid interface name");
error = set_hw_interface_rx_placement (hw_if_index, queue_id, thread_index,
is_main);
return (error);
}
/*?
* This command is used to assign a given interface, and optionally a
* given queue, to a different thread. If the '<em>queue</em>' is not provided,
* it defaults to 0. The '<em>worker</em>' parameter is zero based and the index
* in the thread name, for example, 0 in the thread name '<em>vpp_wk_0</em>'.
*
* @cliexpar
* Example of how to display the interface placement:
* @cliexstart{show interface rx-placement}
* Thread 1 (vpp_wk_0):
* node dpdk-input:
* GigabitEthernet7/0/0 queue 0 (polling)
* node vhost-user-input:
* VirtualEthernet0/0/12 queue 0 (polling)
* VirtualEthernet0/0/12 queue 2 (polling)
* VirtualEthernet0/0/13 queue 0 (polling)
* VirtualEthernet0/0/13 queue 2 (polling)
* Thread 2 (vpp_wk_1):
* node dpdk-input:
* GigabitEthernet7/0/1 queue 0 (polling)
* node vhost-user-input:
* VirtualEthernet0/0/12 queue 1 (polling)
* VirtualEthernet0/0/12 queue 3 (polling)
* VirtualEthernet0/0/13 queue 1 (polling)
* VirtualEthernet0/0/13 queue 3 (polling)
* @cliexend
* Example of how to assign a interface and queue to a worker thread:
* @cliexcmd{set interface rx-placement VirtualEthernet0/0/12 queue 1 worker 0}
* Example of how to display the interface placement:
* @cliexstart{show interface rx-placement}
* Thread 1 (vpp_wk_0):
* node dpdk-input:
* GigabitEthernet7/0/0 queue 0 (polling)
* node vhost-user-input:
* VirtualEthernet0/0/12 queue 0 (polling)
* VirtualEthernet0/0/12 queue 1 (polling)
* VirtualEthernet0/0/12 queue 2 (polling)
* VirtualEthernet0/0/13 queue 0 (polling)
* VirtualEthernet0/0/13 queue 2 (polling)
* Thread 2 (vpp_wk_1):
* node dpdk-input:
* GigabitEthernet7/0/1 queue 0 (polling)
* node vhost-user-input:
* VirtualEthernet0/0/12 queue 3 (polling)
* VirtualEthernet0/0/13 queue 1 (polling)
* VirtualEthernet0/0/13 queue 3 (polling)
* @cliexend
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (cmd_set_if_rx_placement,static) = {
.path = "set interface rx-placement",
.short_help = "set interface rx-placement <interface> [queue <n>] "
"[worker <n> | main]",
.function = set_interface_rx_placement,
.is_mp_safe = 1,
};
/* *INDENT-ON* */
int
set_hw_interface_tx_queue (u32 hw_if_index, u32 queue_id, uword *bitmap)
{
vnet_main_t *vnm = vnet_get_main ();
vlib_thread_main_t *vtm = vlib_get_thread_main ();
vnet_hw_if_tx_queue_t *txq;
u32 queue_index;
u32 thread_index;
/* highest set bit in bitmap should not exceed last worker thread index */
thread_index = clib_bitmap_last_set (bitmap);
if ((thread_index != ~0) && (thread_index >= vtm->n_vlib_mains))
return VNET_API_ERROR_INVALID_VALUE;
queue_index =
vnet_hw_if_get_tx_queue_index_by_id (vnm, hw_if_index, queue_id);
if (queue_index == ~0)
return VNET_API_ERROR_INVALID_QUEUE;
txq = vnet_hw_if_get_tx_queue (vnm, queue_index);
// free the existing bitmap
if (clib_bitmap_count_set_bits (txq->threads))
{
txq->shared_queue = 0;
clib_bitmap_free (txq->threads);
}
clib_bitmap_foreach (thread_index, bitmap)
vnet_hw_if_tx_queue_assign_thread (vnm, queue_index, thread_index);
vnet_hw_if_update_runtime_data (vnm, hw_if_index);
return 0;
}
static clib_error_t *
set_interface_tx_queue (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index = (u32) ~0;
u32 queue_id = (u32) 0;
uword *bitmap = 0;
int rv = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "%U", unformat_vnet_hw_interface, vnm,
&hw_if_index))
;
else if (unformat (line_input, "queue %d", &queue_id))
;
else if (unformat (line_input, "threads %U", unformat_bitmap_list,
&bitmap))
;
else
{
error = clib_error_return (0, "parse error: '%U'",
format_unformat_error, line_input);
unformat_free (line_input);
return error;
}
}
unformat_free (line_input);
if (hw_if_index == (u32) ~0)
{
error = clib_error_return (0, "please specify valid interface name");
goto error;
}
rv = set_hw_interface_tx_queue (hw_if_index, queue_id, bitmap);
switch (rv)
{
case VNET_API_ERROR_INVALID_VALUE:
error = clib_error_return (
0, "please specify valid thread(s) - last thread index %u",
clib_bitmap_last_set (bitmap));
break;
case VNET_API_ERROR_INVALID_QUEUE:
error = clib_error_return (
0, "unknown queue %u on interface %s", queue_id,
vnet_get_hw_interface (vnet_get_main (), hw_if_index)->name);
break;
default:
break;
}
error:
clib_bitmap_free (bitmap);
return (error);
}
VLIB_CLI_COMMAND (cmd_set_if_tx_queue, static) = {
.path = "set interface tx-queue",
.short_help = "set interface tx-queue <interface> queue <n> "
"[threads <list>]",
.function = set_interface_tx_queue,
.is_mp_safe = 1,
};
clib_error_t *
set_interface_rss_queues (vlib_main_t * vm, u32 hw_if_index,
clib_bitmap_t * bitmap)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
return vnet_hw_interface_set_rss_queues (vnm, hi, bitmap);
}
static clib_error_t *
set_interface_rss_queues_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index = (u32) ~ 0;
clib_bitmap_t *bitmap = NULL;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat
(line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
;
else
if (unformat (line_input, "list %U", unformat_bitmap_list, &bitmap))
;
else
{
error = clib_error_return (0, "parse error: '%U'",
format_unformat_error, line_input);
unformat_free (line_input);
goto done;
}
}
unformat_free (line_input);
if (hw_if_index == (u32) ~ 0)
{
error = clib_error_return (0, "please specify valid interface name");
goto done;
}
if (bitmap == NULL)
{
error = clib_error_return (0, "please specify the valid rss queues");
goto done;
}
error = set_interface_rss_queues (vm, hw_if_index, bitmap);
done:
if (bitmap)
clib_bitmap_free (bitmap);
return (error);
}
/*?
* This command is used to set the rss queues of a given interface
* Not all the interfaces support this operation.
* To display the current rss queues, use the command
* '<em>show hardware-interfaces</em>'.
*
* @cliexpar
* Example of how to set the rss queues to 0,2-5,7 of an interface:
* @cliexstart{set interface rss queues VirtualFunctionEthernet18/1/0 list 0,2-5,7}
* @cliexend
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (cmd_set_interface_rss_queues,static) = {
.path = "set interface rss queues",
.short_help = "set interface rss queues <interface> <list <queue-list>>",
.function = set_interface_rss_queues_fn,
};
/* *INDENT-ON* */
static u8 *
format_vnet_pcap (u8 * s, va_list * args)
{
vnet_pcap_t *pp = va_arg (*args, vnet_pcap_t *);
int type = va_arg (*args, int);
int printed = 0;
if (type == 0)
{
if (pp->pcap_rx_enable)
{
s = format (s, "rx");
printed = 1;
}
if (pp->pcap_tx_enable)
{
if (printed)
s = format (s, " and ");
s = format (s, "tx");
printed = 1;
}
if (pp->pcap_drop_enable)
{
if (printed)
s = format (s, " and ");
s = format (s, "drop");
printed = 1;
}
return s;
}
s = format (s, "unknown type %d!", type);
return s;
}
int
vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a)
{
vlib_main_t *vm = vlib_get_main ();
vnet_main_t *vnm = vnet_get_main ();
vnet_pcap_t *pp = &vnm->pcap;
pcap_main_t *pm = &pp->pcap_main;
vnet_classify_main_t *cm = &vnet_classify_main;
if (a->status)
{
if (pp->pcap_rx_enable || pp->pcap_tx_enable || pp->pcap_drop_enable)
{
vlib_cli_output
(vm, "pcap %U dispatch capture enabled: %d of %d pkts...",
format_vnet_pcap, pp, 0 /* print type */ ,
pm->n_packets_captured, pm->n_packets_to_capture);
vlib_cli_output (vm, "capture to file %s", pm->file_name);
}
else
vlib_cli_output (vm, "pcap dispatch capture disabled");
return 0;
}
/* Consistency checks */
/* Enable w/ capture already enabled not allowed */
if ((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable)
&& (a->rx_enable + a->tx_enable + a->drop_enable))
return VNET_API_ERROR_INVALID_VALUE;
/* Disable capture with capture already disabled, not interesting */
if (((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable) ==
0) &&
((a->rx_enable + a->tx_enable + a->drop_enable == 0)))
return VNET_API_ERROR_VALUE_EXIST;
/* Change number of packets to capture while capturing */
if ((pp->pcap_rx_enable + pp->pcap_tx_enable + pp->pcap_drop_enable)
&& (a->rx_enable + a->tx_enable + a->drop_enable)
&& (pm->n_packets_to_capture != a->packets_to_capture))
return VNET_API_ERROR_INVALID_VALUE_2;
/* Classify filter specified, but no classify filter configured */
if ((a->rx_enable + a->tx_enable + a->drop_enable) && a->filter &&
(!cm->classify_table_index_by_sw_if_index ||
cm->classify_table_index_by_sw_if_index[0] == ~0))
return VNET_API_ERROR_NO_SUCH_LABEL;
if (a->rx_enable + a->tx_enable + a->drop_enable)
{
void *save_pcap_data;
/* Sanity check max bytes per pkt */
if (a->max_bytes_per_pkt < 32 || a->max_bytes_per_pkt > 9000)
return VNET_API_ERROR_INVALID_MEMORY_SIZE;
/* Clean up from previous run, if any */
vec_reset_length (pm->pcap_data);
/* Throw away the data buffer? */
if (a->free_data)
vec_free (pm->pcap_data);
save_pcap_data = pm->pcap_data;
memset (pm, 0, sizeof (*pm));
pm->pcap_data = save_pcap_data;
vec_validate_aligned (vnet_trace_placeholder, 2048,
CLIB_CACHE_LINE_BYTES);
if (pm->lock == 0)
clib_spinlock_init (&(pm->lock));
if (a->filename == 0)
{
u8 *stem = 0;
if (a->rx_enable)
stem = format (stem, "rx");
if (a->tx_enable)
stem = format (stem, "tx");
if (a->drop_enable)
stem = format (stem, "drop");
a->filename = format (0, "/tmp/%v.pcap%c", stem, 0);
vec_free (stem);
}
pm->file_name = (char *) a->filename;
pm->n_packets_captured = 0;
pm->packet_type = PCAP_PACKET_TYPE_ethernet;
/* Preallocate the data vector? */
if (a->preallocate_data)
{
vec_validate
(pm->pcap_data, a->packets_to_capture
* ((sizeof (pcap_packet_header_t) + a->max_bytes_per_pkt)));
vec_reset_length (pm->pcap_data);
}
pm->n_packets_to_capture = a->packets_to_capture;
pp->pcap_sw_if_index = a->sw_if_index;
if (a->filter)
pp->filter_classify_table_index =
cm->classify_table_index_by_sw_if_index[0];
else
pp->filter_classify_table_index = ~0;
pp->pcap_error_index = a->drop_err;
pp->pcap_rx_enable = a->rx_enable;
pp->pcap_tx_enable = a->tx_enable;
pp->pcap_drop_enable = a->drop_enable;
pp->max_bytes_per_pkt = a->max_bytes_per_pkt;
}
else
{
pp->pcap_rx_enable = 0;
pp->pcap_tx_enable = 0;
pp->pcap_drop_enable = 0;
pp->filter_classify_table_index = ~0;
pp->pcap_error_index = ~0;
if (pm->n_packets_captured)
{
clib_error_t *error;
pm->n_packets_to_capture = pm->n_packets_captured;
vlib_cli_output (vm, "Write %d packets to %s, and stop capture...",
pm->n_packets_captured, pm->file_name);
error = pcap_write (pm);
if (pm->flags & PCAP_MAIN_INIT_DONE)
pcap_close (pm);
/* Report I/O errors... */
if (error)
{
clib_error_report (error);
return VNET_API_ERROR_SYSCALL_ERROR_1;
}
vec_free (pm->file_name);
if (a->free_data)
vec_free (pm->pcap_data);
return 0;
}
else
return VNET_API_ERROR_NO_SUCH_ENTRY;
}
return 0;
}
static clib_error_t *
pcap_trace_command_fn (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
vnet_pcap_dispatch_trace_args_t _a, *a = &_a;
vnet_main_t *vnm = vnet_get_main ();
u8 *filename = 0;
u32 max = 1000;
u32 max_bytes_per_pkt = 512;
int rv;
int rx_enable = 0;
int tx_enable = 0;
int preallocate_data = 0;
int drop_enable = 0;
int status = 0;
int filter = 0;
int free_data = 0;
u32 sw_if_index = 0; /* default: any interface */
vlib_error_t drop_err = ~0; /* default: any error */
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "rx"))
rx_enable = 1;
else if (unformat (line_input, "tx"))
tx_enable = 1;
else if (unformat (line_input, "drop"))
drop_enable = 1;
else if (unformat (line_input, "off"))
rx_enable = tx_enable = drop_enable = 0;
else if (unformat (line_input, "max-bytes-per-pkt %u",
&max_bytes_per_pkt))
;
else if (unformat (line_input, "max %d", &max))
;
else if (unformat (line_input, "packets-to-capture %d", &max))
;
else if (unformat (line_input, "file %U", unformat_vlib_tmpfile,
&filename))
;
else if (unformat (line_input, "status %=", &status, 1))
;
else if (unformat (line_input, "intfc %U",
unformat_vnet_sw_interface, vnm, &sw_if_index))
;
else if (unformat (line_input, "interface %U",
unformat_vnet_sw_interface, vnm, &sw_if_index))
;
else if (unformat (line_input, "error %U", unformat_vlib_error, vm,
&drop_err))
;
else if (unformat (line_input, "preallocate-data %=",
&preallocate_data, 1))
;
else if (unformat (line_input, "free-data %=", &free_data, 1))
;
else if (unformat (line_input, "intfc any")
|| unformat (line_input, "interface any"))
sw_if_index = 0;
else if (unformat (line_input, "filter"))
filter = 1;
else
{
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
}
}
unformat_free (line_input);
/* no need for memset (a, 0, sizeof (*a)), set all fields here. */
a->filename = filename;
a->rx_enable = rx_enable;
a->tx_enable = tx_enable;
a->preallocate_data = preallocate_data;
a->free_data = free_data;
a->drop_enable = drop_enable;
a->status = status;
a->packets_to_capture = max;
a->sw_if_index = sw_if_index;
a->filter = filter;
a->max_bytes_per_pkt = max_bytes_per_pkt;
a->drop_err = drop_err;
rv = vnet_pcap_dispatch_trace_configure (a);
switch (rv)
{
case 0:
break;
case VNET_API_ERROR_INVALID_VALUE:
return clib_error_return (0, "dispatch trace already enabled...");
case VNET_API_ERROR_VALUE_EXIST:
return clib_error_return (0, "dispatch trace already disabled...");
case VNET_API_ERROR_INVALID_VALUE_2:
return clib_error_return
(0, "can't change number of records to capture while tracing...");
case VNET_API_ERROR_SYSCALL_ERROR_1:
return clib_error_return (0, "I/O writing trace capture...");
case VNET_API_ERROR_NO_SUCH_ENTRY:
return clib_error_return (0, "No packets captured...");
case VNET_API_ERROR_INVALID_MEMORY_SIZE:
return clib_error_return (0,
"Max bytes per pkt must be > 32, < 9000...");
case VNET_API_ERROR_NO_SUCH_LABEL:
return clib_error_return
(0, "No classify filter configured, see 'classify filter...'");
default:
vlib_cli_output (vm, "WARNING: trace configure returned %d", rv);
break;
}
return 0;
}
/*?
* This command is used to start or stop a packet capture, or show
* the status of packet capture.
*
* This command has the following optional parameters:
*
*
* - <b>rx</b> - Capture received packets
*
* - <b>tx</b> - Capture transmitted packets
*
* - <b>drop</b> - Capture dropped packets
*
* - <b>off</b> - Stop capturing packets, write results to the specified file
*
* - <b>max <nn></b> - Depth of local buffer. Once '<em>nn</em>' number
* of packets have been received, buffer is flushed to file. Once another
* '<em>nn</em>' number of packets have been received, buffer is flushed
* to file, overwriting previous write. If not entered, value defaults
* to 100. Can only be updated if packet capture is off.
*
* - <b>max-bytes-per-pkt <nnnn></b> - Maximum number of bytes to capture
* for each packet. Must be >= 32, <= 9000.
*
* - <b>preallocate-data</b> - Preallocate the data buffer, to avoid
* vector expansion delays during pcap capture
*
* - <b>free-data</b> - Free the data buffer. Ordinarily it's a feature
* to retain the data buffer so this option is seldom used.
*
* - <b>intfc <interface-name>|any</b> - Used to specify a given interface,
* or use '<em>any</em>' to run packet capture on all interfaces.
* '<em>any</em>' is the default if not provided. Settings from a previous
* packet capture are preserved, so '<em>any</em>' can be used to reset
* the interface setting.
*
* - <b>filter</b> - Use the pcap trace rx / tx / drop filter, which
* must be configured. Use <b>classify filter pcap...</b> to configure the
* filter. The filter will only be executed if the per-interface or
* any-interface tests fail.
*
* - <b>error <node>.<error></b> - filter packets based on a specific error.
* For example: error {ip4-udp-lookup}.{no_listener}
*
* - <b>file <name></b> - Used to specify the output filename. The file will
* be placed in the '<em>/tmp</em>' directory, so only the filename is
* supported. Directory should not be entered. If file already exists, file
* will be overwritten. If no filename is provided, the file will be
* named "/tmp/rx.pcap", "/tmp/tx.pcap", "/tmp/rxandtx.pcap", etc.
* Can only be updated if packet capture is off.
*
* - <b>status</b> - Displays the current status and configured attributes
* associated with a packet capture. If packet capture is in progress,
* '<em>status</em>' also will return the number of packets currently in
* the local buffer. All additional attributes entered on command line
* with '<em>status</em>' will be ignored and not applied.
*
* @cliexpar
* Example of how to display the status of a tx packet capture when off:
* @cliexstart{pcap trace status}
* max is 100, for any interface to file /tmp/vpe.pcap
* pcap tx capture is off...
* @cliexend
* Example of how to start a tx packet capture:
* @cliexstart{pcap trace tx max 35 intfc GigabitEthernet0/8/0 file
* vppTest.pcap}
* @cliexend
* Example of how to display the status of a tx packet capture in progress:
* @cliexstart{pcap trace status}
* max is 35, for interface GigabitEthernet0/8/0 to file /tmp/vppTest.pcap
* pcap tx capture is on: 20 of 35 pkts...
* @cliexend
* Example of how to stop a tx packet capture:
* @cliexstart{pcap trace off}
* captured 21 pkts...
* saved to /tmp/vppTest.pcap...
* @cliexend
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (pcap_tx_trace_command, static) = {
.path = "pcap trace",
.short_help =
"pcap trace [rx] [tx] [drop] [off] [max <nn>] [intfc <interface>|any]\n"
" [file <name>] [status] [max-bytes-per-pkt <nnnn>][filter]\n"
" [preallocate-data][free-data]",
.function = pcap_trace_command_fn,
};
/* *INDENT-ON* */
static clib_error_t *
set_pcap_filter_function (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
vnet_pcap_t *pp = &vnet_get_main ()->pcap;
unformat_input_t _line_input, *line_input = &_line_input;
vlib_is_packet_traced_fn_t *res = 0;
clib_error_t *error = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != (uword) UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "%U", unformat_vlib_trace_filter_function,
&res))
;
else
{
error = clib_error_create (
"expected valid trace filter function, got `%U'",
format_unformat_error, line_input);
goto done;
}
}
pp->current_filter_function = res;
done:
unformat_free (line_input);
return error;
}
VLIB_CLI_COMMAND (set_pcap_filter_function_cli, static) = {
.path = "set pcap filter function",
.short_help = "set pcap filter function <func_name>",
.function = set_pcap_filter_function,
};
static clib_error_t *
show_pcap_filter_function (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
vnet_pcap_t *pp = &vnet_get_main ()->pcap;
vlib_trace_filter_main_t *tfm = &vlib_trace_filter_main;
vlib_is_packet_traced_fn_t *current_trace_filter_fn =
pp->current_filter_function;
vlib_trace_filter_function_registration_t *reg =
tfm->trace_filter_registration;
while (reg)
{
vlib_cli_output (vm, "%sname:%s description: %s priority: %u",
reg->function == current_trace_filter_fn ? "(*) " : "",
reg->name, reg->description, reg->priority);
reg = reg->next;
}
return 0;
}
VLIB_CLI_COMMAND (show_pcap_filter_function_cli, static) = {
.path = "show pcap filter function",
.short_help = "show pcap filter function",
.function = show_pcap_filter_function,
};
static clib_error_t *
set_interface_name (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
u32 hw_if_index = ~0;
char *name = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "%U %s", unformat_vnet_hw_interface, vnm,
&hw_if_index, &name))
;
else
{
error = clib_error_return (0, "parse error: '%U'",
format_unformat_error, line_input);
unformat_free (line_input);
vec_free (name);
return error;
}
}
unformat_free (line_input);
if (hw_if_index == (u32) ~0 || name == 0)
{
vec_free (name);
error = clib_error_return (0, "please specify valid interface name");
return error;
}
error = vnet_rename_interface (vnm, hw_if_index, name);
vec_free (name);
return (error);
}
VLIB_CLI_COMMAND (cmd_set_if_name, static) = {
.path = "set interface name",
.short_help = "set interface name <interface-name> <new-interface-name>",
.function = set_interface_name,
.is_mp_safe = 1,
};
static clib_error_t *
set_interface_tx_hash_cmd (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hi;
u8 *hash_name = 0;
u32 hw_if_index = (u32) ~0;
vnet_hash_fn_t hf;
vnet_hash_fn_type_t ftype;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "%U", unformat_vnet_hw_interface, vnm,
&hw_if_index))
;
else if (unformat (line_input, "hash-name %s", &hash_name))
;
else
{
error = clib_error_return (0, "parse error: '%U'",
format_unformat_error, line_input);
unformat_free (line_input);
return error;
}
}
unformat_free (line_input);
if (hw_if_index == (u32) ~0)
{
error = clib_error_return (0, "please specify valid interface name");
goto error;
}
if (hash_name == 0)
{
error = clib_error_return (0, "hash-name is required");
goto error;
}
hi = vnet_get_hw_interface (vnm, hw_if_index);
ftype =
vnet_get_hw_interface_class (vnm, hi->hw_class_index)->tx_hash_fn_type;
hf = vnet_hash_function_from_name ((const char *) hash_name, ftype);
if (!hf)
{
error = clib_error_return (0, "please specify valid hash name");
goto error;
}
hi->hf = hf;
error:
vec_free (hash_name);
return (error);
}
VLIB_CLI_COMMAND (cmd_set_if_tx_hash, static) = {
.path = "set interface tx-hash",
.short_help = "set interface tx-hash <interface> hash-name <hash-name>",
.function = set_interface_tx_hash_cmd,
};
static clib_error_t *
show_tx_hash (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hi;
vnet_hash_function_registration_t *hash;
u32 hw_if_index = (u32) ~0;
vnet_hash_fn_type_t ftype;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "%U", unformat_vnet_hw_interface, vnm,
&hw_if_index))
;
else
{
error = clib_error_return (0, "parse error: '%U'",
format_unformat_error, line_input);
unformat_free (line_input);
goto error;
}
}
unformat_free (line_input);
if (hw_if_index == (u32) ~0)
{
error = clib_error_return (0, "please specify valid interface name");
goto error;
}
hi = vnet_get_hw_interface (vnm, hw_if_index);
ftype =
vnet_get_hw_interface_class (vnm, hi->hw_class_index)->tx_hash_fn_type;
if (hi->hf)
{
hash = vnet_hash_function_from_func (hi->hf, ftype);
if (hash)
vlib_cli_output (vm, "%U", format_vnet_hash, hash);
else
vlib_cli_output (vm, "no matching hash function found");
}
else
vlib_cli_output (vm, "no hashing function set");
error:
return (error);
}
VLIB_CLI_COMMAND (cmd_show_tx_hash, static) = {
.path = "show interface tx-hash",
.short_help = "show interface tx-hash [interface]",
.function = show_tx_hash,
};
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|
5ffaecc73bba297415cf7852bb2894d51ea967dc
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/regress/sys/net/pf_trans/iocmd-limit.c
|
f847abd2a87809512fa32ab2034c4b63d5fc6278
|
[] |
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,672
|
c
|
iocmd-limit.c
|
/* $OpenBSD: iocmd-limit.c,v 1.2 2023/07/10 17:45:17 anton Exp $ */
/*
* Copyright (c) 2023 Alexandr Nedvedicky <sashan@openbsd.org>
*
* 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.
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <net/if.h>
#include <netinet/in.h>
#include <net/pfvar.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define REGRESS_ANCHOR "regress"
static void
usage(const char *progname)
{
fprintf(stderr,
"%s -c iocmd [-i iterations ]\n"
"\t-c iocmd to test, currently DIOCGETRULES "
"and DIOCXEND are supported\n"
"\t-i number of iterations is 1 by default\n", progname);
exit(1);
}
static int
do_DIOCGETRULES_test(int dev)
{
struct pfioc_rule pr;
int rv;
memset(&pr, 0, sizeof(pr));
memcpy(pr.anchor, REGRESS_ANCHOR, sizeof(REGRESS_ANCHOR));
pr.rule.action = PF_PASS;
if ((rv = ioctl(dev, DIOCGETRULES, &pr)) == -1) {
/*
* we expect to see EBUSY anything else is odd and we should
* exit right away.
*/
if (errno != EBUSY)
err(1, "%s DIOCGETRULES", __func__);
}
return (rv);
}
static int
result_DIOCGETRULES(unsigned int iterations, unsigned int limit)
{
int rv;
/*
* DIOCGETRULES must see EBUSY before iterations reach limit
* to conclude test is successful.
*/
rv = (iterations < limit) ? 0 : 1;
if (rv)
printf(
"DIOCGETRULES could obtain %u tickets, reaching the limit "
"of %u tickets\n",
iterations, limit);
return (rv);
}
static int
do_DIOCXEND_test(int dev)
{
struct pfioc_rule pr;
int rv;
memset(&pr, 0, sizeof(pr));
memcpy(pr.anchor, REGRESS_ANCHOR, sizeof(REGRESS_ANCHOR));
pr.rule.action = PF_PASS;
if ((rv = ioctl(dev, DIOCGETRULES, &pr)) == -1)
warn("%s DIOCGETRULES", __func__);
else if ((rv = ioctl(dev, DIOCXEND, &pr.ticket)) == -1)
warn("%s DIOCXEND", __func__);
return (rv);
}
static int
result_DIOCXEND(unsigned int iterations, unsigned int limit)
{
int rv;
/*
* failing to reach limit when also closing tickets
* using DIOXXEND is an error.
*/
rv = (iterations < limit) ? 1 : 0;
if (rv)
printf(
"Although test is is using DIOCXEND it still"
"hits limit (%u)\n", iterations);
return (rv);
}
static struct iocmd_test {
const char *iocmd_name;
int (*iocmd_test)(int);
int (*iocmd_result)(unsigned int, unsigned int);
} iocmd_test_tab[] = {
{ "DIOCGETRULES", do_DIOCGETRULES_test, result_DIOCGETRULES },
{ "DIOCXEND", do_DIOCXEND_test, result_DIOCXEND },
{ NULL, NULL }
};
static struct iocmd_test *
parse_iocmd_name(const char *iocmd_name)
{
int i = 0;
while (iocmd_test_tab[i].iocmd_name != NULL) {
if (strcasecmp(iocmd_test_tab[i].iocmd_name, iocmd_name) == 0)
break;
i++;
}
return ((iocmd_test_tab[i].iocmd_name == NULL) ?
NULL : &iocmd_test_tab[i]);
}
int
main(int argc, char *const argv[])
{
const char *errstr = NULL;
unsigned int iterations = 1;
unsigned int i = 0;
int dev;
int c;
struct iocmd_test *test_iocmd = NULL;
while ((c = getopt(argc, argv, "i:c:")) != -1) {
switch (c) {
case 'i':
iterations = strtonum(optarg, 1, UINT32_MAX, &errstr);
if (errstr != NULL) {
fprintf(stderr,
"%s: number of iteration (-i %s) "
"is invalid: %s\n",
argv[0], optarg, errstr);
usage(argv[0]);
}
break;
case 'c':
test_iocmd = parse_iocmd_name(optarg);
if (test_iocmd == NULL) {
fprintf(stderr, "%s invalid iocmd: %s\n",
argv[0], optarg);
usage(argv[0]);
}
break;
default:
usage(argv[0]);
}
}
if (test_iocmd == NULL) {
fprintf(stderr, "%s -c option is required\n", argv[0]);
usage(argv[0]);
}
dev = open("/dev/pf", O_RDONLY);
if (dev < 0)
err(1, "open(\"dev/pf\")");
while (i < iterations) {
if (test_iocmd->iocmd_test(dev) != 0)
break;
i++;
}
return (test_iocmd->iocmd_result(i, iterations));
}
|
39dc5adad7f61b104677a16bfdf6015d24ad1cd7
|
61da6274995cf914291af51bd02e60f408fdfedd
|
/src/moba/model_T1.c
|
046da7a9b7f08cc89553ccc1f27238fdb1c36758
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] |
permissive
|
mrirecon/bart
|
360d518b4c79836d506803aa4a77e8e252ab820b
|
a3c9dc313f79c4c52f1ba3e617d5831ef088ddf7
|
refs/heads/master
| 2023-08-31T11:01:08.932824
| 2023-08-30T12:15:35
| 2023-08-30T13:51:18
| 23,212,230
| 264
| 185
|
BSD-3-Clause
| 2023-08-03T18:43:36
| 2014-08-22T03:57:09
|
C
|
UTF-8
|
C
| false
| false
| 5,197
|
c
|
model_T1.c
|
/* Copyright 2019. Uecker Lab, University Medical Center Goettingen.
* All rights reserved. Use of this source code is governed by
* a BSD-style license which can be found in the LICENSE file.
*
* Authors: Xiaoqing Wang, Martin Uecker
*/
#include <stdlib.h>
#include <complex.h>
#include <math.h>
#include <stdbool.h>
#include <assert.h>
#include "misc/misc.h"
#include "misc/mri.h"
#include "misc/mmio.h"
#include "misc/debug.h"
#include "linops/someops.h"
#include "nlops/nlop.h"
#include "nlops/chain.h"
#include "nlops/cast.h"
#include "nlops/stack.h"
#include "num/multind.h"
#include "num/flpmath.h"
#include "num/iovec.h"
#include "noir/model.h"
#include "moba/T1fun.h"
#include "model_T1.h"
static struct mobamod T1_create_internal(const long dims[DIMS], const complex float* mask, const complex float* TI, const complex float* psf,
float scaling_M0, float scaling_R1s, const struct noir_model_conf_s* conf, float fov)
{
long data_dims[DIMS];
md_select_dims(DIMS, ~COEFF_FLAG, data_dims, dims);
struct noir_s nlinv = noir_create(data_dims, mask, psf, conf);
struct mobamod ret;
long map_dims[DIMS];
long out_dims[DIMS];
long in_dims[DIMS];
long TI_dims[DIMS];
md_select_dims(DIMS, conf->fft_flags|TIME_FLAG|TIME2_FLAG, map_dims, dims);
md_select_dims(DIMS, conf->fft_flags|TE_FLAG|TIME_FLAG|TIME2_FLAG, out_dims, dims);
md_select_dims(DIMS, conf->fft_flags|COEFF_FLAG|TIME_FLAG|TIME2_FLAG, in_dims, dims);
md_select_dims(DIMS, TE_FLAG|TIME_FLAG|TIME2_FLAG, TI_dims, dims);
#if 1
// chain T1 model
struct nlop_s* T1 = NULL;
if(conf->noncart) { // overgridding with factor two
long map_dims2[DIMS];
long out_dims2[DIMS];
long in_dims2[DIMS];
md_copy_dims(DIMS, map_dims2, map_dims);
md_copy_dims(DIMS, out_dims2, out_dims);
md_copy_dims(DIMS, in_dims2, in_dims);
long red_fov[3];
for (int i = 0; i < 3; i++)
red_fov[i] = (1 == map_dims[i]) ? 1 : (map_dims[i] * fov);
if (1. != fov) {
md_copy_dims(3, map_dims2, red_fov);
md_copy_dims(3, out_dims2, red_fov);
md_copy_dims(3, in_dims2, red_fov);
}
T1 = nlop_T1_create(DIMS, map_dims2, out_dims2, in_dims2, TI_dims, TI, scaling_M0, scaling_R1s);
T1 = nlop_chain_FF(T1, nlop_from_linop_F(linop_resize_center_create(DIMS, out_dims, out_dims2)));
T1 = nlop_chain_FF(nlop_from_linop_F(linop_resize_center_create(DIMS, in_dims2, in_dims)), T1);
} else
T1 = nlop_T1_create(DIMS, map_dims, out_dims, in_dims, TI_dims, TI, scaling_M0, scaling_R1s);
debug_printf(DP_INFO, "T1 Model created:\n Model ");
nlop_debug(DP_INFO, T1);
debug_printf(DP_INFO, "NLINV ");
nlop_debug(DP_INFO, nlinv.nlop);
const struct nlop_s* b = nlinv.nlop;
const struct nlop_s* c = nlop_chain2_FF(T1, 0, b, 0);
nlinv.nlop = nlop_permute_inputs_F(c, 2, (const int[2]){ 1, 0 });
#endif
ret.nlop = nlinv.nlop;
ret.linop = nlinv.linop;
return ret;
}
struct mobamod T1_create(const long dims[DIMS], const complex float* mask, const complex float* TI, const complex float* psf,
float scaling_M0, float scaling_R1s, const struct noir_model_conf_s* conf, float fov)
{
unsigned long bat_flags = TIME_FLAG | TIME2_FLAG;
int bat_idx = TIME_DIM;
if(1 < dims[TIME2_DIM]) {
if ( ((0 == MD_IS_SET(conf->ptrn_flags, TIME_DIM)) != (0 == MD_IS_SET(conf->ptrn_flags, TIME2_DIM)))
|| ((0 == MD_IS_SET(conf->cnstcoil_flags, TIME_DIM)) != (0 == MD_IS_SET(conf->cnstcoil_flags, TIME2_DIM))) ) {
bat_flags = MD_CLEAR(bat_flags, TIME_DIM);
bat_idx = TIME2_DIM;
}
}
long bat_dims[DIMS];
long dims_slc[DIMS];
md_select_dims(DIMS, bat_flags, bat_dims, dims);
md_select_dims(DIMS, ~bat_flags, dims_slc, dims);
long psf_dims[DIMS];
md_select_dims(DIMS, conf->ptrn_flags & ~COEFF_FLAG, psf_dims, dims);
long psf_dims_slc[DIMS];
md_select_dims(DIMS, ~bat_flags, psf_dims_slc, psf_dims);
long TI_dims[DIMS];
md_select_dims(DIMS, TE_FLAG|TIME_FLAG|TIME2_FLAG, TI_dims, dims);
long TI_dims_slc[DIMS];
md_select_dims(DIMS, ~bat_flags, TI_dims_slc, TI_dims);
int N = md_calc_size(DIMS, bat_dims);
const struct linop_s* lop = NULL;
const struct nlop_s* nlops[N];
long pos[DIMS];
md_singleton_strides(DIMS, pos);
int i = 0;
do {
complex float* psf_tmp = md_alloc(DIMS, psf_dims_slc, CFL_SIZE);
md_slice(DIMS, bat_flags, pos, psf_dims, psf_tmp, psf, CFL_SIZE);
complex float* TI_tmp = md_alloc(DIMS, psf_dims_slc, CFL_SIZE);
md_slice(DIMS, bat_flags, pos, TI_dims, TI_tmp, TI, CFL_SIZE);
struct mobamod T1 = T1_create_internal(dims_slc, mask, TI_tmp, psf_tmp, scaling_M0, scaling_R1s, conf, fov);
nlops[i++] = T1.nlop;
if (NULL == lop)
lop = linop_clone(T1.linop);
else {
if (!MD_IS_SET(conf->cnstcoil_flags, bat_idx))
lop = linop_stack_FF(bat_idx, bat_idx, lop, linop_clone(T1.linop));
}
md_free(TI_tmp);
md_free(psf_tmp);
} while (md_next(DIMS, bat_dims, bat_flags, pos));
struct mobamod result = {
.nlop = (1 == N) ? (struct nlop_s*)nlops[0] : (struct nlop_s*)nlop_stack_container_create_F(N, nlops, 2, (int [2]){ bat_idx, (MD_IS_SET(conf->cnstcoil_flags, bat_idx) ? -1 : bat_idx) }, 1, (int[1]){ bat_idx }),
.linop = lop,
};
result.nlop = nlop_flatten_F(result.nlop);
return result;
}
|
bfa009cfb19f81883c829d4e3dbe2da9feb0fbd0
|
7f6c235b0598353549959c18f69eefd20b766907
|
/include/arch/test.h
|
d92444e2e81938ce9e244cddddcba65ac9c8df16
|
[
"ClArtistic"
] |
permissive
|
z88dk/z88dk
|
46dfd4905f36d99333173cadd0a660839befc9f0
|
8b07f37cc43c5d9ffe69b563c80763491d8faff7
|
refs/heads/master
| 2023-09-04T19:29:49.254958
| 2023-09-03T20:51:24
| 2023-09-03T20:51:24
| 54,035,569
| 820
| 263
|
NOASSERTION
| 2023-09-05T11:09:04
| 2016-03-16T13:48:16
|
Assembly
|
UTF-8
|
C
| false
| false
| 4,296
|
h
|
test.h
|
#ifndef ARCH_TEST_H
#define ARCH_TEST_H
#include <sys/compiler.h>
#define REG_MMU0 0x50
#define REG_MMU1 0x51
#define REG_MMU2 0x52
#define REG_MMU3 0x53
#define REG_MMU4 0x54
#define REG_MMU5 0x55
#define REG_MMU6 0x56
#define REG_MMU7 0x57
// This function doesn't exist and is handled entirely by the preprocessor
// and peep hole optimiser
//
// The optimiser has rules for sdcc and sccz80, so we have to make the call to
// this resemble those used in newlib
//
// As a result, the sdcc variant needs to be __stdc so that the two parameters
// are packed into a single word.
#ifdef __SDCC
extern void ZXN_WRITE_REG(unsigned char reg,unsigned char data) __preserves_regs(a,d,e,iyl,iyh);
extern void ZXN_WRITE_REG_callee(unsigned char reg,unsigned char val) __z88dk_callee __preserves_regs(a,d,e,iyl,iyh);
#else
extern void __LIB__ ZXN_WRITE_REG(unsigned char reg,unsigned char data) __smallc;
extern void __LIB__ ZXN_WRITE_REG_callee(unsigned char reg,unsigned char val) __smallc __z88dk_callee;
#endif
#define ZXN_WRITE_REG(a,b) ZXN_WRITE_REG_callee(a,b)
#ifndef __SDCC
extern void __LIB__ ZXN_WRITE_MMU0(unsigned char page) __smallc __z88dk_fastcall;
extern void __LIB__ ZXN_WRITE_MMU1(unsigned char page) __smallc __z88dk_fastcall;
extern void __LIB__ ZXN_WRITE_MMU2(unsigned char page) __smallc __z88dk_fastcall;
extern void __LIB__ ZXN_WRITE_MMU3(unsigned char page) __smallc __z88dk_fastcall;
extern void __LIB__ ZXN_WRITE_MMU4(unsigned char page) __smallc __z88dk_fastcall;
extern void __LIB__ ZXN_WRITE_MMU5(unsigned char page) __smallc __z88dk_fastcall;
extern void __LIB__ ZXN_WRITE_MMU6(unsigned char page) __smallc __z88dk_fastcall;
extern void __LIB__ ZXN_WRITE_MMU7(unsigned char page) __smallc __z88dk_fastcall;
#else
extern unsigned char ZXN_READ_MMU0(void) __preserves_regs(d,e,h,iyl,iyh);
extern unsigned char ZXN_READ_MMU1(void) __preserves_regs(d,e,h,iyl,iyh);
extern unsigned char ZXN_READ_MMU2(void) __preserves_regs(d,e,h,iyl,iyh);
extern unsigned char ZXN_READ_MMU3(void) __preserves_regs(d,e,h,iyl,iyh);
extern unsigned char ZXN_READ_MMU4(void) __preserves_regs(d,e,h,iyl,iyh);
extern unsigned char ZXN_READ_MMU5(void) __preserves_regs(d,e,h,iyl,iyh);
extern unsigned char ZXN_READ_MMU6(void) __preserves_regs(d,e,h,iyl,iyh);
extern unsigned char ZXN_READ_MMU7(void) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU0(unsigned char page) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU0_fastcall(unsigned char page) __preserves_regs(d,e,h,iyl,iyh) __z88dk_fastcall;
#define ZXN_WRITE_MMU0(a) ZXN_WRITE_MMU0_fastcall(a)
extern void ZXN_WRITE_MMU1(unsigned char page) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU1_fastcall(unsigned char page) __preserves_regs(d,e,h,iyl,iyh) __z88dk_fastcall;
#define ZXN_WRITE_MMU1(a) ZXN_WRITE_MMU1_fastcall(a)
extern void ZXN_WRITE_MMU2(unsigned char page) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU2_fastcall(unsigned char page) __preserves_regs(d,e,h,iyl,iyh) __z88dk_fastcall;
#define ZXN_WRITE_MMU2(a) ZXN_WRITE_MMU2_fastcall(a)
extern void ZXN_WRITE_MMU3(unsigned char page) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU3_fastcall(unsigned char page) __preserves_regs(d,e,h,iyl,iyh) __z88dk_fastcall;
#define ZXN_WRITE_MMU3(a) ZXN_WRITE_MMU3_fastcall(a)
extern void ZXN_WRITE_MMU4(unsigned char page) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU4_fastcall(unsigned char page) __preserves_regs(d,e,h,iyl,iyh) __z88dk_fastcall;
#define ZXN_WRITE_MMU4(a) ZXN_WRITE_MMU4_fastcall(a)
extern void ZXN_WRITE_MMU5(unsigned char page) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU5_fastcall(unsigned char page) __preserves_regs(d,e,h,iyl,iyh) __z88dk_fastcall;
#define ZXN_WRITE_MMU5(a) ZXN_WRITE_MMU5_fastcall(a)
extern void ZXN_WRITE_MMU6(unsigned char page) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU6_fastcall(unsigned char page) __preserves_regs(d,e,h,iyl,iyh) __z88dk_fastcall;
#define ZXN_WRITE_MMU6(a) ZXN_WRITE_MMU6_fastcall(a)
extern void ZXN_WRITE_MMU7(unsigned char page) __preserves_regs(d,e,h,iyl,iyh);
extern void ZXN_WRITE_MMU7_fastcall(unsigned char page) __preserves_regs(d,e,h,iyl,iyh) __z88dk_fastcall;
#define ZXN_WRITE_MMU7(a) ZXN_WRITE_MMU7_fastcall(a)
#endif
#endif
|
1f84191f2d09ee457695bc5b523bb56657d7cece
|
e3cdfae1dd874479c928dad193b33a4e3b8a623e
|
/src/bmsave.c
|
41f4d0d27d67e5dbacbce8597027ac518c6f9d21
|
[] |
no_license
|
FireEmblemUniverse/fireemblem8u
|
11493bf94844617b33254110ba006316defb3510
|
b9ad9bcafd9d4ecb7fc13cc77a464e2a82ac8338
|
refs/heads/master
| 2023-09-05T23:39:53.791339
| 2023-09-04T17:31:47
| 2023-09-04T17:31:47
| 121,802,075
| 118
| 31
| null | 2023-09-11T13:08:37
| 2018-02-16T21:21:50
|
Assembly
|
UTF-8
|
C
| false
| false
| 23,618
|
c
|
bmsave.c
|
#include "global.h"
#include "bmitem.h"
#include "agb_sram.h"
#include "bmbattle.h"
#include "bmcontainer.h"
#include "bmdifficulty.h"
#include "fontgrp.h"
#include "uimenu.h"
#include "bmmind.h"
#include "event.h"
#include "bmtrick.h"
#include "functions.h"
#include "bmreliance.h"
#include "bmunit.h"
#include "bmsave.h"
#include "sram-layout.h"
#include "ev_triggercheck.h"
/* variables */
EWRAM_DATA u32 gBonusContentClaimFlags = 0;
EWRAM_DATA u8 gSuspendSaveIdOffset = 0;
u32 GetBonusContentClaimFlags()
{
return gBonusContentClaimFlags;
}
void SetBonusContentClaimFlags(u32 num)
{
gBonusContentClaimFlags = num;
}
void WriteBonusContentClaimFlags(struct GameSaveBlock *sram_dest)
{
WriteAndVerifySramFast(&gBonusContentClaimFlags,
&sram_dest->bonusClaimFlags,
sizeof(gBonusContentClaimFlags));
}
void ReadBonusContentClaimFlags(const struct GameSaveBlock *sram_src)
{
ReadSramFast(&sram_src->bonusClaimFlags,
&gBonusContentClaimFlags,
sizeof(gBonusContentClaimFlags));
}
void WriteLastGameSaveId(int num)
{
struct GlobalSaveInfo info;
ReadGlobalSaveInfo(&info);
info.last_game_save_id = num;
WriteGlobalSaveInfoNoChecksum(&info);
}
int ReadLastGameSaveId()
{
int ret;
struct GlobalSaveInfo info;
if (!ReadGlobalSaveInfo(&info))
return 0;
ret = info.last_game_save_id;
if (ret > SAVE_ID_GAME2)
return SAVE_ID_GAME0;
else if (ret < 0)
return SAVE_ID_GAME0;
else
return ret;
}
void InvalidateGameSave(int index)
{
struct SaveBlockInfo chunk;
struct PlaySt play_st;
if (IsValidSuspendSave(SAVE_ID_SUSPEND)) {
ReadSuspendSavePlaySt(SAVE_ID_SUSPEND, &play_st);
if (play_st.gameSaveSlot == index)
InvalidateSuspendSave(SAVE_ID_SUSPEND);
}
chunk.kind = SAVEBLOCK_KIND_INVALID;
WriteSaveBlockInfo(&chunk, index);
}
void CopyGameSave(int index_src, int index_dest)
{
struct SaveBlockInfo chunk;
void *src = GetSaveReadAddr(index_src);
void *dest = GetSaveWriteAddr(index_dest);
ReadSramFast(src, gGenericBuffer, sizeof(struct GameSaveBlock));
WriteAndVerifySramFast(gGenericBuffer, dest, sizeof(struct GameSaveBlock));
chunk.magic32 = SAVEMAGIC32;
chunk.kind = SAVEBLOCK_KIND_GAME;
WriteSaveBlockInfo(&chunk, index_dest);
}
void WriteNewGameSave(int index, int isDifficult, int mode, int isTutorial)
{
int i;
struct SaveBlockInfo chunk;
struct GameSavePackedUnit unitp;
struct GameSaveBlock *dest = GetSaveWriteAddr(index);
if (0 == mode)
mode = gPlaySt.chapterModeIndex;
if (isTutorial < 0)
isTutorial = gPlaySt.cfgController;
SetGameTime(0);
InitPlayConfig(isDifficult, isTutorial);
InitUnits();
ClearSupplyItems();
ResetPermanentFlags();
InvalidateSuspendSave(SAVE_ID_SUSPEND);
gPlaySt.unk_2C_1 = 0;
gPlaySt.unk_2C_04 = 0;
CpuFill16(0, &gPlaySt.unk_30, sizeof(gPlaySt.unk_30));
gPlaySt.unk_2C_0D = 0;
gPlaySt.chapterModeIndex = mode;
gPlaySt.unk_2B_00 = 1;
gPlaySt.playerName[0] = '\0';
gPlaySt.chapterIndex = 0;
gPlaySt.playthroughIdentifier = GetNewPlaythroughId();
gPlaySt.gameSaveSlot = index;
gPlaySt.unk_2C_2 = GetGlobalCompletionCount();
WriteAndVerifySramFast(&gPlaySt, &dest->playSt, sizeof(gPlaySt));
SetBonusContentClaimFlags(0);
WriteBonusContentClaimFlags(dest);
CpuFill16(0, &unitp, sizeof(unitp));
for (i = 0; i < UNIT_SAVE_AMOUNT_BLUE; i++) {
WriteAndVerifySramFast(&unitp, &dest->units[i], sizeof(unitp));
}
WriteAndVerifySramFast(&unitp, &dest->gmUnit, sizeof(unitp));
WriteSupplyItems(dest->supplyItems);
ClearPidChStatsSaveData(dest);
WritePermanentFlags(dest->permanentFlags);
ClearWorldMapStuff(&dest->wmStuff);
{
struct Dungeon dungeon[2];
CpuFill16(0, dungeon, sizeof(dungeon));
WriteAndVerifySramFast(dungeon, dest->dungeons, sizeof(dungeon));
}
chunk.magic32 = SAVEMAGIC32;
chunk.kind = SAVEBLOCK_KIND_GAME;
WriteSaveBlockInfo(&chunk, index);
WriteLastGameSaveId(index);
}
void WriteGameSave(int slot)
{
int i;
struct SaveBlockInfo chunk;
struct GlobalSaveInfo info;
struct Dungeon dungeon[2];
struct GameSaveBlock *dest = GetSaveWriteAddr(slot);
InvalidateSuspendSave(SAVE_ID_SUSPEND);
gPlaySt.gameSaveSlot = slot;
gPlaySt.time_saved = GetGameClock();
WriteAndVerifySramFast(&gPlaySt, &dest->playSt, sizeof(gPlaySt));
for (i = 0; i < UNIT_SAVE_AMOUNT_BLUE; i++)
WriteGameSavePackedUnit(&gUnitArrayBlue[i], &dest->units[i]);
ReadGlobalSaveInfo(&info);
for (i = 0; i < UNIT_SAVE_AMOUNT_BLUE; i++)
SGM_SetCharacterKnown(UNIT_CHAR_ID(&gUnitArrayBlue[i]), &info);
WriteGlobalSaveInfo(&info);
WriteGMMonsterRnState(&dest->gmUnit);
WriteSupplyItems(dest->supplyItems);
WritePidStats(dest->pidStats);
WriteChapterStats(dest->chapterStats);
WriteBonusContentClaimFlags(dest);
WritePermanentFlags(dest->permanentFlags);
WriteWorldMapStuff(&dest->wmStuff, &gGMData);
SaveDungeonRecords(dungeon);
WriteAndVerifySramFast(dungeon, dest->dungeons, sizeof(dungeon));
chunk.magic32 = SAVEMAGIC32;
chunk.kind = SAVEBLOCK_KIND_GAME;
WriteSaveBlockInfo(&chunk, slot);
WriteLastGameSaveId(slot);
}
void ReadGameSave(int slot)
{
int i;
struct Dungeon dungeon[2];
struct GameSaveBlock *src = GetSaveReadAddr(slot);
if (!(PLAY_FLAG_HARD & gBmSt.gameStateBits))
InvalidateSuspendSave(SAVE_ID_SUSPEND);
ReadSramFast(src, &gPlaySt, sizeof(gPlaySt));
SetGameTime(gPlaySt.time_saved);
gPlaySt.gameSaveSlot = slot;
InitUnits();
for (i = 0; i < UNIT_SAVE_AMOUNT_BLUE; i++)
LoadSavedUnit(src->units + i, &gUnitArrayBlue[i]);
ReadGMMonsterRnState(&src->gmUnit);
ReadSupplyItems(src->supplyItems);
ReadPermanentFlags(src->permanentFlags);
ReadPidStats(src->pidStats);
ReadChapterStats(src->chapterStats);
ReadBonusContentClaimFlags(src);
ReadWorldMapStuff(&src->wmStuff, &gGMData);
ReadSramFast(src->dungeons, dungeon, sizeof(dungeon));
LoadDungeonRecords(dungeon);
WriteLastGameSaveId(slot);
}
bool IsSaveValid(int index)
{
return ReadSaveBlockInfo(NULL, index);
}
void ReadGameSavePlaySt(int slot, struct PlaySt *buf)
{
const struct GameSaveBlock *src = GetSaveReadAddr(slot);
ReadSramFast(&src->playSt, buf, sizeof(struct PlaySt));
}
u32 LoadSavedBonusClaimFlags(int slot)
{
u32 buf;
const struct GameSaveBlock *src = GetSaveReadAddr(slot);
ReadSramFast(&src->bonusClaimFlags, &buf, sizeof(buf));
return buf;
}
void LoadSavedWMStuff(int slot, struct GMapData *dest)
{
const struct GameSaveBlock *src = GetSaveReadAddr(slot);
ReadWorldMapStuff(&src->wmStuff, dest);
}
s8 LoadSavedEid8A(int slot)
{
const struct GameSaveBlock *sram_base = GetSaveReadAddr(slot);
ReadPermanentFlags_ret(sram_base->permanentFlags, gGenericBuffer);
return CheckPermanentFlagFrom(0x8A, gGenericBuffer);
}
bool IsGameNotFirstChapter(struct PlaySt *chapter_data)
{
if (PLAY_FLAG_COMPLETE & chapter_data->chapterStateBits)
return true;
else if (0 != chapter_data->chapterIndex)
return true;
else
return false;
}
bool IsGameSaveNotFirstChapter(int slot)
{
struct PlaySt chapter_data;
if (!IsSaveValid(slot))
return false;
ReadGameSavePlaySt(slot, &chapter_data);
return IsGameNotFirstChapter(&chapter_data);
}
bool IsGameSaveComplete(int slot)
{
struct PlaySt chapter_data;
if (!IsSaveValid(slot))
return false;
ReadGameSavePlaySt(slot, &chapter_data);
return (PLAY_FLAG_COMPLETE & chapter_data.chapterStateBits);
}
void WriteGameSavePackedUnit(struct Unit *unit, void *sram_dest)
{
int i;
struct GameSavePackedUnit unitp;
unitp.pid = UNIT_CHAR_ID(unit);
unitp.jid = unit->pClassData->number;
if (NULL == unit->pCharacterData) {
struct Unit tmp_unit;
unit = &tmp_unit;
ClearUnit(&tmp_unit);
unitp.pid = 0;
unitp.jid = 0;
}
#if BUGFIX
else {
unitp.pid = unit->pinfo->id;
unitp.jid = unit->jinfo->id;
}
#endif
unitp.level = unit->level;
unitp.exp = unit->exp;
unitp.xPos = unit->xPos;
unitp.yPos = unit->yPos;
unitp.max_hp = unit->maxHP;
unitp.pow = unit->pow;
unitp.skl = unit->skl;
unitp.spd = unit->spd;
unitp.def = unit->def;
unitp.res = unit->res;
unitp.lck = unit->lck;
unitp.con_bonus = unit->conBonus;
unitp.mov_bonus = unit->movBonus;
unitp.item1 = unit->items[0];
unitp.item2 = unit->items[1];
unitp.item3 = unit->items[2];
unitp.item4 = unit->items[3];
unitp.item5 = unit->items[4];
unitp.flag = 0;
if (US_DEAD & unit->state)
unitp.flag |= PACKED_US_DEAD;
if (US_NOT_DEPLOYED & unit->state)
unitp.flag |= PACKED_US_UNDEPLOYED;
if (US_SOLOANIM_1 & unit->state)
unitp.flag |= PACKED_US_SOLO_ANIM1;
if (US_SOLOANIM_2 & unit->state)
unitp.flag |= PACKED_US_SOLO_ANIM2;
if (US_GROWTH_BOOST & unit->state)
unitp.flag |= PACKED_US_METIS_TOME;
if (US_BIT16 & unit->state)
unitp.flag |= PACKED_US_B4;
if (US_BIT25 & unit->state)
unitp.flag |= PACKED_US_B5;
if (US_BIT21 & unit->state)
unitp.flag |= PACKED_US_NEW_FRIEND;
for (i = 0; i < 8; i++)
unitp.wpnRanks[i] = unit->ranks[i];
for (i = 0; i < UNIT_SUPPORT_MAX_COUNT; i++)
unitp.supports[i] = unit->supports[i];
WriteAndVerifySramFast(&unitp, sram_dest, sizeof(unitp));
}
void LoadSavedUnit(const void *sram_src, struct Unit *unit)
{
int i;
struct GameSavePackedUnit unitp;
ReadSramFast(sram_src, &unitp, sizeof(unitp));
unit->pCharacterData = GetCharacterData(unitp.pid);
unit->pClassData = GetClassData(unitp.jid);
unit->level = unitp.level;
unit->exp = unitp.exp;
unit->xPos = unitp.xPos;
unit->yPos = unitp.yPos;
unit->maxHP = unitp.max_hp;
unit->pow = unitp.pow;
unit->skl = unitp.skl;
unit->spd = unitp.spd;
unit->def = unitp.def;
unit->res = unitp.res;
unit->lck = unitp.lck;
unit->conBonus = unitp.con_bonus;
unit->movBonus = unitp.mov_bonus;
unit->items[0] = unitp.item1;
unit->items[1] = unitp.item2;
unit->items[2] = unitp.item3;
unit->items[3] = unitp.item4;
unit->items[4] = unitp.item5;
if (unit->exp > 99)
unit->exp = -1;
unit->state = 0;
if (PACKED_US_DEAD & unitp.flag)
unit->state = US_HIDDEN | US_DEAD;
if (PACKED_US_UNDEPLOYED & unitp.flag)
unit->state |= US_HIDDEN | US_NOT_DEPLOYED;
if (PACKED_US_SOLO_ANIM1 & unitp.flag)
unit->state |= US_SOLOANIM_1;
if (PACKED_US_SOLO_ANIM2 & unitp.flag)
unit->state |= US_SOLOANIM_2;
if (PACKED_US_METIS_TOME & unitp.flag)
unit->state |= US_GROWTH_BOOST;
if (PACKED_US_B4 & unitp.flag)
unit->state |= US_BIT16;
if (PACKED_US_B5 & unitp.flag)
unit->state |= US_BIT25;
if (PACKED_US_NEW_FRIEND & unitp.flag)
unit->state |= US_BIT21;
for (i = 0; i < 8; i++)
unit->ranks[i] = unitp.wpnRanks[i];
for (i = 0; i < UNIT_SUPPORT_MAX_COUNT; i++)
unit->supports[i] = unitp.supports[i];
SetUnitHp(unit, GetUnitMaxHp(unit));
unit->supportBits = 0;
/* mins zero */
if (0x7F == unit->exp)
unit->exp = -1;
if (0x3F == unit->xPos)
unit->xPos = -1;
if (0x3F == unit->yPos)
unit->yPos = -1;
}
void WriteGMMonsterRnState(void *sram_dest)
{
u32 buf[2];
sub_80A71E4(buf);
WriteAndVerifySramFast(buf, sram_dest, sizeof(buf));
}
void ReadGMMonsterRnState(const void *sram_src)
{
u32 buf[2];
ReadSramFast(sram_src, buf, sizeof(buf));
sub_80A71F8(buf);
}
void InvalidateSuspendSave(int slot)
{
struct SaveBlockInfo chunk;
chunk.kind = SAVEBLOCK_KIND_INVALID;
WriteSaveBlockInfo(&chunk, slot);
if (SAVE_ID_SUSPEND == slot)
WriteSaveBlockInfo(&chunk, SAVE_ID_SUSPEND_ALT);
}
void WriteSuspendSave(int slot)
{
struct SuspendSaveBlock *dest;
struct SaveBlockInfo chunk;
u8 list[MENU_OVERRIDE_MAX];
struct Dungeon dungeon[2];
int i, val;
struct SuspendSavePackedUnit *buf;
if (PLAY_FLAG_TUTORIAL & gPlaySt.chapterStateBits)
return;
if (!IsSramWorking())
return;
slot += GetNextSuspendSaveId();
dest = GetSaveWriteAddr(slot);
gPlaySt.time_saved = GetGameClock();
WriteAndVerifySramFast(&gPlaySt, &dest->playSt, sizeof(gPlaySt));
StoreRNStateToActionStruct();
WriteAndVerifySramFast(&gActionData, &dest->action, sizeof(struct ActionData));
buf = (struct SuspendSavePackedUnit *)gGenericBuffer;
for (i = 0; i < UNIT_SAVE_AMOUNT_BLUE; i++)
EncodeSuspendSavePackedUnit(&gUnitArrayBlue[i], buf++);
WriteSramFast(gGenericBuffer, (u8 *)dest->blueUnits, UNIT_SAVE_AMOUNT_BLUE * sizeof(struct SuspendSavePackedUnit));
buf = (struct SuspendSavePackedUnit *)gGenericBuffer;
for (i = 0; i < UNIT_SAVE_AMOUNT_RED; i++)
EncodeSuspendSavePackedUnit(&gUnitArrayRed[i], buf++);
for (i = 0; i < UNIT_SAVE_AMOUNT_GREEN; i++)
EncodeSuspendSavePackedUnit(&gUnitArrayGreen[i], buf++);
WriteSramFast(gGenericBuffer, (u8 *)dest->redUnits, (UNIT_SAVE_AMOUNT_RED + UNIT_SAVE_AMOUNT_GREEN) * sizeof(struct SuspendSavePackedUnit)); // TODO: maybe pack them into a single struct?
WritePermanentFlags(dest->permanentFlags);
WriteChapterFlags(dest->chapterFlags);
WriteSupplyItems(dest->supplyItems);
WritePidStats(dest->pidStats);
WriteChapterStats(dest->chapterStats);
WriteTraps(dest->traps);
GetForceDisabledMenuItems(list);
WriteAndVerifySramFast(list, dest->menuOverride, sizeof(list));
WriteWorldMapStuff(&dest->wmStuff, &gGMData);
/**
* I think this maybe a coincidence that I$ find that gm-generated-monster does not require the suspend save space
*/
SaveDungeonRecords(dungeon);
WriteAndVerifySramFast(dungeon, &dest->wmMonsterUnit, sizeof(dungeon));
SaveDungeonState(dungeon);
WriteAndVerifySramFast(dungeon, &dest->dungeon, sizeof(struct Dungeon));
val = GetEventSlotCounter();
WriteAndVerifySramFast(&val, &dest->eventSlotCnt, sizeof(int));
chunk.magic32 = SAVEMAGIC32;
chunk.kind = SAVEBLOCK_KIND_SUSPEND;
WriteSaveBlockInfo(&chunk, slot);
gBmSt.just_resumed = false;
WriteSwappedSuspendSaveId();
}
void ReadSuspendSave(int slot)
{
int i, val;
u8 list[MENU_OVERRIDE_MAX];
struct Dungeon dungeon[2];
struct SuspendSaveBlock *src = GetSaveReadAddr(slot + gSuspendSaveIdOffset);
ReadSramFast(&src->playSt, &gPlaySt, sizeof(gPlaySt));
SetGameTime(gPlaySt.time_saved);
ReadSramFast(&src->action, &gActionData, sizeof(struct ActionData));
LoadRNStateFromActionStruct();
InitUnits();
for (i = 0; i < UNIT_SAVE_AMOUNT_BLUE; i++)
ReadSuspendSavePackedUnit(&src->blueUnits[i], &gUnitArrayBlue[i]);
for (i = 0; i < UNIT_SAVE_AMOUNT_RED; i++)
ReadSuspendSavePackedUnit(&src->redUnits[i], &gUnitArrayRed[i]);
for (i = 0; i < UNIT_SAVE_AMOUNT_GREEN; i++)
ReadSuspendSavePackedUnit(&src->greenUnits[i], &gUnitArrayGreen[i]);
ReadPidStats(src->pidStats);
ReadChapterStats(src->chapterStats);
ReadSupplyItems(src->supplyItems);
ReadPermanentFlags(src->permanentFlags);
ReadChapterFlags(src->chapterFlags);
ReadTraps(src->traps);
ReadSramFast(src->menuOverride, list, sizeof(list));
SetForceDisabledMenuItems(list);
ReadWorldMapStuff(&src->wmStuff, &gGMData);
ReadSramFast(&src->wmMonsterUnit, dungeon, sizeof(dungeon));
LoadDungeonRecords(dungeon);
ReadSramFast(&src->dungeon, dungeon, sizeof(struct Dungeon));
LoadDungeonState(dungeon);
ReadSramFast(&src->eventSlotCnt, &val, sizeof(int));
SetEventSlotCounter(val);
SetBonusContentClaimFlags(LoadSavedBonusClaimFlags(gPlaySt.gameSaveSlot));
}
u8 IsValidSuspendSave(int slot)
{
if (!IsSramWorking())
return false;
if (SAVE_ID_SUSPEND != slot)
return false;
gSuspendSaveIdOffset = GetLastSuspendSaveId();
if (ReadSaveBlockInfo(NULL, gSuspendSaveIdOffset + 3))
return true;
gSuspendSaveIdOffset = GetNextSuspendSaveId();
if (ReadSaveBlockInfo(NULL, gSuspendSaveIdOffset + 3))
return true;
gSuspendSaveIdOffset = 0x7F;
return false;
}
void ReadSuspendSavePlaySt(int slot, struct PlaySt *buf)
{
ReadGameSavePlaySt(slot + gSuspendSaveIdOffset, buf);
}
void EncodeSuspendSavePackedUnit(struct Unit *unit, void *buf)
{
u8 ai1_byte;
int i;
struct SuspendSavePackedUnit *unit_su = buf;
if (NULL == unit->pCharacterData) {
unit_su->pid = 0;
return;
}
unit_su->pid = UNIT_CHAR_ID(unit);
unit_su->jid = unit->pClassData->number;
unit_su->level = unit->level;
unit_su->exp = unit->exp;
unit_su->state = unit->state;
unit_su->xPos = unit->xPos;
unit_su->yPos = unit->yPos;
unit_su->maxHP = unit->maxHP;
unit_su->curHP = unit->curHP;
unit_su->pow = unit->pow;
unit_su->skl = unit->skl;
unit_su->spd = unit->spd;
unit_su->def = unit->def;
unit_su->res = unit->res;
unit_su->lck = unit->lck;
unit_su->conBonus = unit->conBonus;
unit_su->statusIndex_l = unit->statusIndex;
unit_su->statusDuration = unit->statusDuration;
unit_su->torchDuration = unit->torchDuration;
unit_su->barrierDuration = unit->barrierDuration;
unit_su->rescue = unit->rescue;
unit_su->movBonus = unit->movBonus;
unit_su->ballistaIndex =
(0x7F & unit->ballistaIndex) | (0x01 & unit->supportBits) << 0x07;
unit_su->item1 = (0x3FFF & unit->items[0]) | (0x06 & unit->supportBits) << 0x0D;
unit_su->item2 = (0x3FFF & unit->items[1]) | (0x18 & unit->supportBits) << 0x0B;
unit_su->item3 = (0x3FFF & unit->items[2]) | (0x60 & unit->supportBits) << 0x09;
unit_su->item4 = unit->items[3];
unit_su->item5 = unit->items[4];
for (i = 0; i < 8; i++)
unit_su->ranks[i] = unit->ranks[i];
for (i = 0; i < UNIT_SUPPORT_MAX_COUNT; i++)
unit_su->supports[i] = unit->supports[i];
unit_su->ai1 = unit->ai1;
ai1_byte = unit->ai1 & 0x7F;
if (unit->statusIndex & 8)
ai1_byte |= 0x80;
unit_su->ai1 = ai1_byte;
unit_su->ai1data = unit->ai1data;
unit_su->ai2 = unit->ai2;
unit_su->ai2data = unit->ai2data;
unit_su->ai3And4 = unit->ai3And4;
unit_su->_u46 = unit->_u46;
unit_su->aiFlags = unit->aiFlags;
}
void ReadSuspendSavePackedUnit(const void *sram_src, struct Unit *unit)
{
int i;
struct SuspendSavePackedUnit unit_su;
ReadSramFast(sram_src, &unit_su, sizeof(unit_su));
unit->pCharacterData = GetCharacterData(unit_su.pid);
unit->pClassData = GetClassData(unit_su.jid);
unit->level = unit_su.level;
unit->exp = unit_su.exp;
unit->state = unit_su.state;
unit->xPos = unit_su.xPos;
unit->yPos = unit_su.yPos;
unit->maxHP = unit_su.maxHP;
unit->curHP = unit_su.curHP;
unit->pow = unit_su.pow;
unit->skl = unit_su.skl;
unit->spd = unit_su.spd;
unit->def = unit_su.def;
unit->res = unit_su.res;
unit->lck = unit_su.lck;
unit->conBonus = unit_su.conBonus;
unit->statusIndex = unit_su.statusIndex_l;
unit->statusIndex |= (unit_su.ai1 & 0x80) ? 8 : 0;
unit->statusDuration = unit_su.statusDuration;
unit->torchDuration = unit_su.torchDuration;
unit->barrierDuration = unit_su.barrierDuration;
unit->rescue = unit_su.rescue;
unit->movBonus = unit_su.movBonus;
unit->ballistaIndex = unit_su.ballistaIndex & 0x7F;
unit->items[0] = unit_su.item1 & 0x3FFF;
unit->items[1] = unit_su.item2 & 0x3FFF;
unit->items[2] = unit_su.item3 & 0x3FFF;
unit->items[3] = unit_su.item4;
unit->items[4] = unit_su.item5;
unit->supportBits = (unit_su.ballistaIndex & 0x80) >> 7 |
(unit_su.item1 & 0xC000) >> 0x0D |
(unit_su.item2 & 0xC000) >> 0x0B |
(unit_su.item3 & 0xC000) >> 0x09;
for (i = 0; i < 8; i++)
unit->ranks[i] = unit_su.ranks[i];
for (i = 0; i < UNIT_SUPPORT_MAX_COUNT; i++)
unit->supports[i] = unit_su.supports[i];
unit->ai1 = unit_su.ai1 & 0x7F;
unit->ai1data = unit_su.ai1data;
unit->ai2 = unit_su.ai2;
unit->ai2data = unit_su.ai2data;
unit->ai3And4 = unit_su.ai3And4;
unit->_u46 = unit_su._u46;
unit->aiFlags = unit_su.aiFlags;
if (0x7F == unit->exp)
unit->exp = -1;
if (0x3F == unit->xPos)
unit->xPos = -1;
if (0x3F == unit->yPos)
unit->yPos = -1;
}
void WriteTraps(void *sram_dest)
{
WriteAndVerifySramFast(GetTrap(0), sram_dest, TRAP_MAX_COUNT * sizeof(struct Trap));
}
void ReadTraps(void *sram_dest)
{
ReadSramFast(sram_dest, GetTrap(0), TRAP_MAX_COUNT * sizeof(struct Trap));
}
int GetLastSuspendSaveId()
{
struct GlobalSaveInfo header;
ReadGlobalSaveInfo(&header);
if (1 == header.last_suspend_slot)
return 1;
else
return 0;
}
int GetNextSuspendSaveId()
{
return 1 - GetLastSuspendSaveId();
}
void WriteSwappedSuspendSaveId()
{
struct GlobalSaveInfo header;
ReadGlobalSaveInfo(&header);
header.last_suspend_slot = 0 == header.last_suspend_slot;
WriteGlobalSaveInfoNoChecksum(&header);
}
int SramChecksum32(void *sram_src, int size)
{
ReadSramFast(sram_src, gGenericBuffer, size);
return ComputeChecksum32((const u16*)gGenericBuffer, size);
}
bool VerifySaveBlockChecksum(struct SaveBlockInfo *buf)
{
int size = buf->size;
void *sram_dest = SramOffsetToAddr(buf->offset);
int check_sum = SramChecksum32(sram_dest, size);
if (buf->checksum32 != check_sum)
return false;
else
return true;
}
void PopulateSaveBlockChecksum(struct SaveBlockInfo* buf)
{
int size = buf->size;
void *sram_dest = SramOffsetToAddr(buf->offset);
buf->checksum32 = SramChecksum32(sram_dest, size);
}
u16 GetGameStateChecksum_Unused()
{
int i;
u16 ret = 0;
for (i = 0; i < UNIT_SAVE_AMOUNT_BLUE; i++) {
if (0 == gUnitArrayBlue[i].pCharacterData)
continue;
gUnitArrayBlue[i].pMapSpriteHandle = 0;
ret += SramChecksum32(&gUnitArrayBlue[i], sizeof(struct GameSavePackedUnit));
}
for (i = 0; i < UNIT_SAVE_AMOUNT_RED; i++) {
if (0 == gUnitArrayRed[i].pCharacterData)
continue;
gUnitArrayRed[i].pMapSpriteHandle = 0;
ret += SramChecksum32(&gUnitArrayRed[i], sizeof(struct GameSavePackedUnit));
}
for (i = 0; i < UNIT_SAVE_AMOUNT_GREEN; i++) {
if (0 == gUnitArrayGreen[i].pCharacterData)
continue;
gUnitArrayGreen[i].pMapSpriteHandle = 0;
ret += SramChecksum32(&gUnitArrayGreen[i], sizeof(struct GameSavePackedUnit));
}
ret += SramChecksum32(GetPermanentFlagBits(), GetPermanentFlagBitsSize() / 2);
ret += SramChecksum32(GetChapterFlagBits(), GetChapterFlagBitsSize() / 2);
ret += SramChecksum32(GetTrap(0), (TRAP_MAX_COUNT * sizeof(struct Trap)) / 2);
return ret;
}
void sub_80A6544()
{
u8 buf[8];
}
bool IsMultiArenaSaveValid(int index)
{
return ReadSaveBlockInfo(NULL, index);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.