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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6ed8bfd2639bc308c6588afa6befc01ddebbb8df
|
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
|
/src/mono/mono/utils/mono-digest.h
|
48c503652a4a1f2db9578c206fbb8a143cee58d8
|
[
"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,638
|
h
|
mono-digest.h
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/**
* \file
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to rpmMD5Init, call rpmMD5Update as
* needed on buffers full of bytes, and then call rpmMD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
/* parts of this file are :
* Written March 1993 by Branko Lankester
* Modified June 1993 by Colin Plumb for altered md5.c.
* Modified October 1995 by Erik Troan for RPM
*/
#ifndef __MONO_DIGEST_H__
#define __MONO_DIGEST_H__
#include <config.h>
#include <glib.h>
#include <mono/utils/mono-publib.h>
#if HAVE_COMMONCRYPTO_COMMONDIGEST_H
#include <CommonCrypto/CommonDigest.h>
#define MonoSHA1Context CC_SHA1_CTX
#define MonoMD5Context CC_MD5_CTX
#else
typedef struct {
guint32 buf[4];
guint32 bits[2];
guchar in[64];
gint doByteReverse;
} MonoMD5Context;
#endif
MONO_API void mono_md5_get_digest (const guchar *buffer, gint buffer_size, guchar digest[16]);
/* use this one when speed is needed */
/* for use in provider code only */
MONO_API void mono_md5_get_digest_from_file (const gchar *filename, guchar digest[16]);
/* raw routines */
MONO_API void mono_md5_init (MonoMD5Context *ctx);
MONO_API void mono_md5_update (MonoMD5Context *ctx, const guchar *buf, guint32 len);
MONO_API void mono_md5_final (MonoMD5Context *ctx, guchar digest[16]);
uint64_t
mono_md5_ctx_byte_length (MonoMD5Context *ctx);
#if !HAVE_COMMONCRYPTO_COMMONDIGEST_H
typedef struct {
guint32 state[5];
guint32 count[2];
unsigned char buffer[64];
} MonoSHA1Context;
#endif
MONO_API void mono_sha1_get_digest (const guchar *buffer, gint buffer_size, guchar digest [20]);
MONO_API void mono_sha1_get_digest_from_file (const gchar *filename, guchar digest [20]);
MONO_API void mono_sha1_init (MonoSHA1Context* context);
MONO_API void mono_sha1_update (MonoSHA1Context* context, const guchar* data, guint32 len);
MONO_API void mono_sha1_final (MonoSHA1Context* context, unsigned char digest[20]);
MONO_API void mono_digest_get_public_token (guchar* token, const guchar *pubkey, guint32 len);
#endif /* __MONO_DIGEST_H__ */
|
b32cbf05cca97b5e8f5085e62d144aca2c5728d8
|
6e1cde66aa5a649138babe297293962cdf97743e
|
/src/os/pl-fmt.c
|
4a94f1c65bdcac7b510ff074c763bdba2aff434b
|
[
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
SWI-Prolog/swipl-devel
|
db56676481984addc09f4f228bc1c41f7f53759f
|
41ac4a569c8e6c3d3b93a21449403962e3de1ece
|
refs/heads/master
| 2023-09-01T03:49:40.696481
| 2023-08-30T18:12:56
| 2023-08-30T18:12:56
| 17,516,793
| 935
| 328
|
NOASSERTION
| 2023-08-26T14:32:33
| 2014-03-07T14:43:14
|
C
|
UTF-8
|
C
| false
| false
| 39,428
|
c
|
pl-fmt.c
|
/* Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@vu.nl
WWW: http://www.swi-prolog.org
Copyright (c) 2011-2022, University of Amsterdam
VU University Amsterdam
SWI-Prolog Solutions b.v.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Formatted output (Prolog predicates format/[1,2,3]). One day, the C
source should also use format() to produce error messages, etc.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "pl-fmt.h"
#include "pl-ctype.h"
#include "pl-utf8.h"
#include "../pl-arith.h"
#include "../pl-proc.h"
#include "../pl-fli.h"
#include "../pl-prims.h"
#include "../pl-write.h"
#include "../pl-pro.h"
#include <ctype.h>
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#ifdef __WINDOWS__
#include "../pl-nt.h"
#endif
typedef foreign_t (*Func1)(term_t a1);
static char * formatInteger(PL_locale *locale, int div, int radix,
bool smll, Number n, Buffer out);
static char * formatFloat(PL_locale *locale, int how, int arg,
Number f, Buffer out);
#define MAXRUBBER 100
struct rubber
{ size_t where; /* where is rubber in output */
size_t size; /* how big should it be */
pl_wchar_t pad; /* padding character */
};
typedef struct
{ IOSTREAM *out; /* our output stream */
int column; /* current column */
tmp_buffer buffer; /* bin for characters with tabs */
size_t buffered; /* characters in buffer */
int pending_rubber; /* number of not-filled ~t's */
struct rubber rub[MAXRUBBER];
} format_state;
#define BUFSIZE 1024
#define DEFAULT (-1)
#define SHIFT { argc--; argv++; }
#define NEED_ARG { if ( argc <= 0 ) \
{ FMT_ERROR("not enough arguments"); \
} \
}
#define FMT_ERROR(fmt) return PL_error(NULL, 0, NULL, ERR_FORMAT, fmt)
#define FMT_ARG(c, a) return PL_error(NULL, 0, NULL, ERR_FORMAT_ARG, c, a)
#define FMT_EXEPTION() return FALSE
static PL_locale prolog_locale =
{ 0,0,LOCALE_MAGIC,1,
L".", NULL
};
static int
update_column(int col, int c)
{ switch(c)
{ case '\n': return 0;
case '\r': return 0;
case '\t': return (col + 1) | 0x7;
case '\b': return (col <= 0 ? 0 : col - 1);
default: return col + 1;
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Low-level output. If there is pending rubber the output is stored in
UTF-8 format in the state's `buffer'. The `buffered' field represents
the number of UTF-8 characters in the buffer.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static WUNUSED int
outchr(format_state *state, int chr)
{ if ( state->pending_rubber )
{ if ( chr > 0x7f )
{ char buf[8];
char *s, *e;
e = utf8_put_char(buf, chr);
for(s=buf; s<e; s++)
addBuffer((Buffer)&state->buffer, *s, char);
} else
{ char c = chr;
addBuffer((Buffer)&state->buffer, c, char);
}
state->buffered++;
} else
{ if ( Sputcode(chr, state->out) < 0 )
return FALSE;
}
state->column = update_column(state->column, chr);
return TRUE;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Emit ASCII 0-terminated strings resulting from sprintf() on numeric
arguments. No fuzz with wide characters here.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static WUNUSED int
outstring(format_state *state, const char *s, size_t len)
{ const char *q;
const char *e = &s[len];
if ( state->pending_rubber )
{ addMultipleBuffer(&state->buffer, s, len, char);
state->buffered += len;
} else
{ for(q=s; q < e; q++)
{ if ( Sputcode(*q&0xff, state->out) < 0 )
return FALSE;
}
}
for(q=s; q < e; q++)
state->column = update_column(state->column, *q&0xff);
return TRUE;
}
static WUNUSED int
oututf8(format_state *state, const char *s, size_t len)
{ const char *e = &s[len];
while(s<e)
{ int chr;
PL_utf8_code_point(&s, e, &chr);
if ( !outchr(state, chr) )
return FALSE;
}
return TRUE;
}
static WUNUSED int
oututf80(format_state *state, const char *s)
{ return oututf8(state, s, strlen(s));
}
static WUNUSED int
outtext(format_state *state, PL_chars_t *txt)
{ switch(txt->encoding)
{ case ENC_ISO_LATIN_1:
return outstring(state, txt->text.t, txt->length);
case ENC_WCHAR:
{ const pl_wchar_t *s = txt->text.w;
const pl_wchar_t *e = &s[txt->length];
while(s<e)
{ int c;
s = get_wchar(s, &c);
if ( !outchr(state, c) )
return FALSE;
}
return TRUE;
}
default:
{ assert(0);
return FALSE;
}
}
}
#define format_predicates (GD->format.predicates)
static int update_column(int, Char);
static bool do_format(IOSTREAM *fd, PL_chars_t *fmt,
int ac, term_t av, Module m);
static void distribute_rubber(struct rubber *, int, int);
static WUNUSED int emit_rubber(format_state *state);
/********************************
* PROLOG CONNECTION *
********************************/
word
pl_format_predicate(term_t chr, term_t descr)
{ int c;
predicate_t proc = NULL;
size_t arity;
if ( !PL_get_char_ex(chr, &c, FALSE) )
fail;
if ( !get_procedure(descr, &proc, 0, GP_CREATE) )
fail;
PL_predicate_info(proc, NULL, &arity, NULL);
if ( arity == 0 )
return PL_error(NULL, 0, "arity must be > 0", ERR_DOMAIN,
PL_new_atom("format_predicate"),
descr);
if ( !format_predicates )
format_predicates = newHTable(8);
updateHTable(format_predicates, (void *)(intptr_t)c, proc);
succeed;
}
word
pl_current_format_predicate(term_t chr, term_t descr, control_t h)
{ GET_LD
intptr_t name;
predicate_t pred;
TableEnum e;
fid_t fid;
switch( ForeignControl(h) )
{ case FRG_FIRST_CALL:
if ( !format_predicates )
fail;
e = newTableEnum(format_predicates);
break;
case FRG_REDO:
e = ForeignContextPtr(h);
break;
case FRG_CUTTED:
e = ForeignContextPtr(h);
freeTableEnum(e);
default:
succeed;
}
if ( !(fid = PL_open_foreign_frame()) )
{ freeTableEnum(e);
return FALSE;
}
while( advanceTableEnum(e, (void**)&name, (void**)&pred) )
{ if ( PL_unify_integer(chr, name) &&
PL_unify_predicate(descr, pred, 0) )
{ PL_close_foreign_frame(fid);
ForeignRedoPtr(e);
}
PL_rewind_foreign_frame(fid);
}
PL_close_foreign_frame(fid);
freeTableEnum(e);
fail;
}
static word
format_impl(IOSTREAM *out, term_t format, term_t Args, Module m)
{ GET_LD
term_t argv;
int argc = 0;
term_t args = PL_copy_term_ref(Args);
int rval;
PL_chars_t fmt;
if ( !PL_get_text(format, &fmt, CVT_ATOM|CVT_STRING|CVT_LIST|BUF_STACK) )
return PL_error("format", 3, NULL, ERR_TYPE, ATOM_text, format);
if ( (argc = (int)lengthList(args, FALSE)) >= 0 )
{ term_t head = PL_new_term_ref();
int n = 0;
argv = PL_new_term_refs(argc);
while( PL_get_list(args, head, args) )
PL_put_term(argv+n++, head);
} else
{ argc = 1;
argv = PL_new_term_refs(argc);
PL_put_term(argv, args);
}
switch(fmt.storage) /* format can do call-back! */
{ case PL_CHARS_RING:
case PL_CHARS_STACK:
PL_save_text(&fmt, BUF_MALLOC);
break;
default:
break;
}
Slock(out);
rval = do_format(out, &fmt, argc, argv, m);
Sunlock(out);
PL_free_text(&fmt);
return rval;
}
word
pl_format3(term_t out, term_t format, term_t args)
{ GET_LD
redir_context ctx;
word rc;
Module m = NULL;
term_t list = PL_new_term_ref();
if ( !PL_strip_module(args, &m, list) )
return FALSE;
if ( (rc=setupOutputRedirect(out, &ctx, FALSE)) )
{ if ( (rc = format_impl(ctx.stream, format, list, m)) )
rc = closeOutputRedirect(&ctx);
else
discardOutputRedirect(&ctx);
}
return rc;
}
word
pl_format(term_t fmt, term_t args)
{ return pl_format3(0, fmt, args);
}
static inline int
get_chr_from_text(const PL_chars_t *t, int index)
{ switch(t->encoding)
{ case ENC_ISO_LATIN_1:
return t->text.t[index]&0xff;
case ENC_WCHAR:
return t->text.w[index];
default:
assert(0);
return 0; /* not reached */
}
}
typedef struct sub_state
{ char buf[BUFSIZE];
char *str;
size_t bufsize;
format_state *fstate;
IOSTREAM *old_stream;
} sub_state;
static int
prepare_sub_format(sub_state *state, format_state *fstate, IOSTREAM *fd)
{ state->fstate = fstate;
if ( !fstate->pending_rubber &&
fd->position &&
fd->position->linepos == fstate->column )
{ state->old_stream = Scurout;
Scurout = fd;
} else
{ state->old_stream = NULL;
state->str = state->buf;
state->bufsize = sizeof(state->buf);
tellString(&state->str, &state->bufsize, ENC_UTF8);
if ( true(fd, SIO_ISATTY) )
set(Scurout, SIO_ISATTY);
}
return TRUE;
}
static int
end_sub_format(sub_state *state, int rc)
{ int lp = Scurout->position->linepos;
if ( state->old_stream )
{ Scurout = state->old_stream;
if ( rc )
state->fstate->column = lp;
} else
{ int lp = Scurout->position->linepos;
toldString();
if ( rc )
{ int c0 = state->fstate->column;
rc = oututf8(state->fstate, state->str, state->bufsize);
state->fstate->column = c0 + lp;
}
if ( state->str != state->buf )
free(state->str);
}
return rc;
}
/********************************
* ACTUAL FORMATTING *
********************************/
static bool
do_format(IOSTREAM *fd, PL_chars_t *fmt, int argc, term_t argv, Module m)
{ GET_LD
format_state state; /* complete state */
int tab_stop = 0; /* padded tab stop */
unsigned int here = 0;
int rc = TRUE;
state.out = fd;
state.pending_rubber = 0;
initBuffer(&state.buffer);
state.buffered = 0;
if ( fd->position )
state.column = fd->position->linepos;
else
state.column = 0;
while(here < fmt->length)
{ int c = get_chr_from_text(fmt, here);
switch(c)
{ case '~':
{ int arg = DEFAULT; /* Numeric argument */
int mod_colon = FALSE; /* Used colon modifier */
predicate_t proc;
/* Get the numeric argument */
c = get_chr_from_text(fmt, ++here);
if ( isDigitW(c) )
{ arg = c - '0';
here++;
while(here < fmt->length)
{ c = get_chr_from_text(fmt, here);
if ( isDigitW(c) )
{ int dw = c - '0';
int arg2 = arg*10 + dw;
if ( (arg2 - dw)/10 != arg ) /* see mul64() in pl-arith.c */
{ FMT_ERROR("argument overflow");
}
arg = arg2;
here++;
} else
break;
}
} else if ( c == '*' )
{ NEED_ARG;
if ( PL_get_integer(argv, &arg) && arg >= 0 )
{ SHIFT;
} else
FMT_ERROR("no or negative integer for `*' argument");
c = get_chr_from_text(fmt, ++here);
} else if ( c == '`' && here < fmt->length )
{ arg = get_chr_from_text(fmt, ++here);
c = get_chr_from_text(fmt, ++here);
}
if ( c == ':' )
{ mod_colon = TRUE;
c = get_chr_from_text(fmt, ++here);
}
/* Check for user defined format */
if ( format_predicates &&
(proc = lookupHTable(format_predicates, (void*)((intptr_t)c))) )
{ size_t arity;
term_t av;
sub_state sstate;
int i;
PL_predicate_info(proc, NULL, &arity, NULL);
av = PL_new_term_refs((int)arity);
if ( arg == DEFAULT )
PL_put_atom(av+0, ATOM_default);
else
PL_put_integer(av+0, arg);
for(i=1; i < arity; i++)
{ NEED_ARG;
PL_put_term(av+i, argv);
SHIFT;
}
if ( !(rc=prepare_sub_format(&sstate, &state, fd)) )
goto out;
rc = PL_call_predicate(NULL, PL_Q_PASS_EXCEPTION, proc, av);
rc = end_sub_format(&sstate, rc);
if ( !rc )
goto out;
here++;
} else
{ switch(c) /* Build in formatting */
{ case 'a': /* atomic */
{ PL_chars_t txt;
NEED_ARG;
if ( !PL_get_text(argv, &txt, CVT_ATOMIC) )
FMT_ARG("a", argv);
SHIFT;
rc = outtext(&state, &txt);
if ( !rc )
goto out;
here++;
break;
}
case 'c': /* ~c: character code */
{ int chr;
NEED_ARG;
if ( PL_get_integer(argv, &chr) && chr >= 0 )
{ int times = (arg == DEFAULT ? 1 : arg);
SHIFT;
while(times-- > 0)
{ rc = outchr(&state, chr);
if ( !rc )
goto out;
}
} else
FMT_ARG("c", argv);
here++;
break;
}
case 'e': /* exponential float */
case 'E': /* Exponential float */
case 'f': /* float */
case 'g': /* shortest of 'f' and 'e' */
case 'G': /* shortest of 'f' and 'E' */
{ AR_CTX
number n;
union {
tmp_buffer b;
buffer b1;
} u;
PL_locale *l;
NEED_ARG;
AR_BEGIN();
if ( !valueExpression(argv, &n) )
{ char f[2];
f[0] = c;
f[1] = EOS;
AR_CLEANUP();
FMT_ARG(f, argv); /* returns error */
}
SHIFT;
if ( c == 'f' && mod_colon )
l = fd->locale;
else
l = &prolog_locale;
initBuffer(&u.b);
rc = formatFloat(l, c, arg, &n, &u.b1) != NULL;
clearNumber(&n);
AR_END();
if ( rc )
rc = oututf80(&state, baseBuffer(&u.b, char));
discardBuffer(&u.b);
if ( !rc )
goto out;
here++;
break;
}
case 'd': /* integer */
case 'D': /* grouped integer */
case 'r': /* radix number */
case 'R': /* Radix number */
case 'I': /* Prolog 1_000_000 */
{ AR_CTX
number i;
tmp_buffer b;
NEED_ARG;
AR_BEGIN();
if ( !valueExpression(argv, &i) ||
!toIntegerNumber(&i, 0) )
{ char f[2];
f[0] = c;
f[1] = EOS;
AR_CLEANUP();
FMT_ARG(f, argv);
}
SHIFT;
initBuffer(&b);
if ( c == 'd' || c == 'D' )
{ PL_locale ltmp;
PL_locale *l;
static char grouping[] = {3,0};
if ( c == 'D' )
{ ltmp.thousands_sep = L",";
ltmp.decimal_point = L".";
ltmp.grouping = grouping;
l = <mp;
} else if ( mod_colon )
{ l = fd->locale;
} else
{ l = NULL;
}
if ( arg == DEFAULT )
arg = 0;
if ( !formatInteger(l, arg, 10, TRUE, &i, (Buffer)&b) )
FMT_EXEPTION();
} else if ( c == 'I' )
{ PL_locale ltmp;
char grouping[2];
grouping[0] = (arg == DEFAULT ? 3 : arg);
grouping[1] = '\0';
ltmp.thousands_sep = L"_";
ltmp.grouping = grouping;
if ( !formatInteger(<mp, 0, 10, TRUE, &i, (Buffer)&b) )
FMT_EXEPTION();
} else /* r,R */
{ if ( arg == DEFAULT )
arg = 8;
if ( arg < 2 || arg > 36 )
{ term_t r = PL_new_term_ref();
PL_put_integer(r, arg);
return PL_error(NULL, 0, NULL, ERR_DOMAIN,
ATOM_radix, r);
}
if ( !formatInteger(NULL, 0, arg, c == 'r', &i, (Buffer)&b) )
FMT_EXEPTION();
}
clearNumber(&i);
AR_END();
rc = oututf80(&state, baseBuffer(&b, char));
discardBuffer(&b);
if ( !rc )
goto out;
here++;
break;
}
case 's': /* string */
{ PL_chars_t txt;
NEED_ARG;
if ( !PL_get_text(argv, &txt, CVT_ATOM|CVT_LIST|CVT_STRING) )
FMT_ARG("s", argv);
if ( arg != DEFAULT )
{ if ( arg < 0 )
arg = 0;
if ( arg < txt.length )
txt.length = arg;
}
rc = outtext(&state, &txt);
PL_free_text(&txt);
SHIFT;
if ( !rc )
goto out;
here++;
break;
}
case 'i': /* ignore */
{ NEED_ARG;
SHIFT;
here++;
break;
}
{ Func1 f;
sub_state sstate;
case 'k': /* write_canonical */
f = pl_write_canonical;
goto pl_common;
case 'p': /* print */
f = pl_print;
goto pl_common;
case 'q': /* writeq */
f = pl_writeq;
goto pl_common;
case 'w': /* write */
f = pl_write;
pl_common:
NEED_ARG;
if ( !(rc=prepare_sub_format(&sstate, &state, fd)) )
goto out;
rc = (int)(*f)(argv);
rc = end_sub_format(&sstate, rc);
if ( !rc )
goto out;
SHIFT;
here++;
break;
}
case 'W': /* write_term(Value, Options) */
{ sub_state sstate;
if ( argc < 2 )
{ FMT_ERROR("not enough arguments");
}
if ( !(rc=prepare_sub_format(&sstate, &state, fd)) )
goto out;
rc = (int)pl_write_term(argv, argv+1);
rc = end_sub_format(&sstate, rc);
if ( !rc )
goto out;
SHIFT;
SHIFT;
here++;
break;
}
case '@':
{ term_t ex = 0;
sub_state sstate;
fid_t fid;
if ( argc < 1 )
{ FMT_ERROR("not enough arguments");
}
if ( !(rc=prepare_sub_format(&sstate, &state, fd)) )
goto out;
rc = ( (fid=PL_open_foreign_frame()) &&
callProlog(m, argv, PL_Q_CATCH_EXCEPTION, &ex) );
if ( rc )
PL_rewind_foreign_frame(fid);
rc = end_sub_format(&sstate, rc);
if ( !rc )
{ if ( ex && !PL_exception(0) )
rc = PL_raise_exception(ex);
goto out;
}
SHIFT;
here++;
break;
}
case '~': /* ~ */
{ rc = outchr(&state, '~');
if ( !rc )
goto out;
here++;
break;
}
case 'n': /* \n */
case 'N': /* \n if not on newline */
{ if ( arg == DEFAULT )
arg = 1;
if ( c == 'N' && state.column == 0 )
arg--;
while( arg-- > 0 )
{ rc = outchr(&state, '\n');
if ( !rc )
goto out;
}
here++;
break;
}
case 't': /* insert tab */
{ if ( state.pending_rubber >= MAXRUBBER )
FMT_ERROR("Too many tab stops");
state.rub[state.pending_rubber].where = state.buffered;
state.rub[state.pending_rubber].pad =
(arg == DEFAULT ? (pl_wchar_t)' '
: (pl_wchar_t)arg);
state.rub[state.pending_rubber].size = 0;
state.pending_rubber++;
here++;
break;
}
case '|': /* set tab */
{ int stop;
int nl_and_reindent;
if ( arg == DEFAULT )
arg = state.column;
/*FALLTHROUGH*/
case '+': /* tab relative */
if ( arg == DEFAULT )
arg = 8;
stop = (c == '+' ? tab_stop + arg : arg);
if ( stop < state.column && mod_colon )
nl_and_reindent = state.pending_rubber ?
state.rub[state.pending_rubber-1].pad : ' ';
else
nl_and_reindent = 0;
if ( state.pending_rubber == 0 ) /* nothing to distribute */
{ state.rub[0].where = state.buffered;
state.rub[0].pad = ' ';
state.pending_rubber++;
}
distribute_rubber(state.rub,
state.pending_rubber,
stop - state.column);
if ( !(rc=emit_rubber(&state)) )
goto out;
if ( nl_and_reindent )
{ if ( Sputcode('\n', state.out) < 0 )
{ rc = FALSE;
goto out;
}
state.column = update_column(state.column, '\n');
state.rub[0].where = state.buffered;
state.rub[0].pad = nl_and_reindent;
state.pending_rubber++;
distribute_rubber(state.rub,
state.pending_rubber,
stop - state.column);
if ( !(rc=emit_rubber(&state)) )
goto out;
}
state.column = tab_stop = stop;
here++;
break;
}
default:
{ term_t ex = PL_new_term_ref();
PL_put_atom(ex, codeToAtom(c));
return PL_error("format", 2, NULL, ERR_EXISTENCE,
PL_new_atom("format_character"),
ex);
}
}
}
break; /* the '~' switch */
}
default:
{ rc = outchr(&state, c);
if ( !rc )
goto out;
here++;
break;
}
}
}
if ( state.pending_rubber ) /* not closed ~t: flush out */
{ if ( !(rc=emit_rubber(&state)) )
goto out;
}
if ( argc != 0 )
FMT_ERROR("too many arguments");
out:
return rc;
}
static void
distribute_rubber(struct rubber *r, int rn, int space)
{ if ( space > 0 )
{ int s = space / rn;
int n, m;
for(n=0; n < rn; n++) /* give them equal size */
r[n].size = s;
/* distribute from the center */
space -= s*rn;
for(m = rn / 2, n = 0; space; n++, space--)
{ r[m + (n % 2 ? n : -n)].size++;
}
} else
{ int n;
for(n=0; n < rn; n++) /* set all rubber to 0 */
r[n].size = 0;
}
}
static WUNUSED int
emit_rubber(format_state *state)
{ const char *s = baseBuffer(&state->buffer, char);
const char *e = &s[entriesBuffer(&state->buffer, char)];
struct rubber *r = state->rub;
int rn = state->pending_rubber;
size_t j;
for(j = 0; s <= e; j++)
{ int chr;
while ( rn && r->where == j )
{ size_t n;
for(n=0; n<r->size; n++)
{ if ( Sputcode(r->pad, state->out) < 0 )
return FALSE;
}
r++;
rn--;
}
if ( s < e )
{ PL_utf8_code_point(&s, e, &chr);
if ( Sputcode(chr, state->out) < 0 )
return FALSE;
} else
break;
}
discardBuffer(&state->buffer);
initBuffer(&state->buffer);
state->buffered = 0;
state->pending_rubber = 0;
return TRUE;
}
/* format an integer according to a number of modifiers at various
radius. `split' is a boolean asking to put ',' between each group
of three digits (e.g. 67,567,288). `div' askes to divide the number
by radix^`div' before printing. `radix' is the radix used for
conversion. `n' is the number to be converted.
** Fri Aug 19 22:26:41 1988 jan@swivax.UUCP (Jan Wielemaker) */
static void
lappend(const wchar_t *l, int def, Buffer out)
{ if ( l )
{ const wchar_t *e = l+wcslen(l);
while (--e >= l)
{ int c = *e;
if ( c < 128 )
{ addBuffer(out, c, char);
} else
{ char buf[6];
char *e8, *s;
e8=utf8_put_char(buf, c);
for(s=e8; --s>=buf; ) /* must be reversed as we reverse */
{ addBuffer(out, *s, char); /* in the end */
}
}
}
} else
{ addBuffer(out, def, char);
}
}
static void
revert_string(char *s, size_t len)
{ char *e = &s[len-1];
for(; e>s; s++,e--)
{ int c = *e;
*e = *s;
*s = c;
}
}
static char *
formatInteger(PL_locale *locale, int div, int radix, bool smll, Number i,
Buffer out)
{ const char *grouping = NULL;
if ( !locale )
{ locale = &prolog_locale;
} else
{ if ( locale->grouping && locale->grouping[0] &&
locale->thousands_sep && locale->thousands_sep[0] )
grouping = locale->grouping;
}
switch(i->type)
{ case V_INTEGER:
{ int64_t n = i->value.i;
if ( n == 0 && div == 0 )
{ addBuffer(out, '0', char);
} else
{ int before = FALSE; /* before decimal point */
int negative = FALSE;
int gsize = 0;
int dweight;
negative = (n < 0);
while( n != 0 || div >= 0 )
{ if ( div-- == 0 && !before )
{ if ( !isEmptyBuffer(out) )
lappend(locale->decimal_point, '.', out);
before = TRUE;
if ( grouping )
gsize = grouping[0];
}
if ( !negative )
dweight = (int)(n % radix);
else
dweight = -(int)(n % -radix);
addBuffer(out, digitName(dweight, smll), char);
n /= radix;
if ( --gsize == 0 && n != 0 )
{ lappend(locale->thousands_sep, ',', out);
if ( grouping[1] == 0 )
gsize = grouping[0];
else if ( grouping[1] == CHAR_MAX )
gsize = 0;
else
gsize = *++grouping;
}
}
if ( negative )
addBuffer(out, '-', char);
}
revert_string(baseBuffer(out, char), entriesBuffer(out, char));
addBuffer(out, EOS, char);
return baseBuffer(out, char);
}
#ifdef O_BIGNUM
case V_MPZ:
{ GET_LD
size_t len = (double)mpz_sizeinbase(i->value.mpz, 2) * log(radix)/log(2) * 1.2;
char tmp[256];
char *buf;
int rc = TRUE;
if ( len+2 > sizeof(tmp) )
buf = PL_malloc(len+2);
else
buf = tmp;
EXCEPTION_GUARDED({ LD->gmp.persistent++;
mpz_get_str(buf, radix, i->value.mpz);
LD->gmp.persistent--;
},
{ LD->gmp.persistent--;
rc = PL_rethrow();
});
if ( !rc )
return NULL;
if ( !smll && radix > 10 )
{ char *s;
for(s=buf; *s; s++)
*s = toupper(*s);
}
if ( grouping || div > 0 )
{ int before = FALSE; /* before decimal point */
int gsize = 0;
char *e = buf+strlen(buf)-1;
while(e >= buf || div >= 0)
{ if ( div-- == 0 && !before )
{ if ( !isEmptyBuffer(out) )
lappend(locale->decimal_point, '.', out);
before = TRUE;
if ( grouping )
gsize = grouping[0];
}
addBuffer(out, *e, char);
e--;
if ( --gsize == 0 && e >= buf && *e != '-' )
{ lappend(locale->thousands_sep, ',', out);
if ( grouping[1] == 0 )
gsize = grouping[0];
else if ( grouping[1] == CHAR_MAX )
gsize = 0;
else
gsize = *++grouping;
}
}
revert_string(baseBuffer(out, char), entriesBuffer(out, char));
} else
{ addMultipleBuffer(out, buf, strlen(buf), char);
}
if ( buf != tmp )
PL_free(buf);
addBuffer(out, EOS, char);
return baseBuffer(out, char);
}
#endif /*O_BIGNUM*/
default:
assert(0);
return NULL;
}
}
static int
countGroups(const char *grouping, int len)
{ int groups = 0;
int gsize = grouping[0];
while(len>0)
{ len -= gsize;
if ( len > 0 )
groups++;
if ( grouping[1] == 0 )
{ if ( len > 1 )
groups += (len-1)/grouping[0];
return groups;
} else if ( grouping[1] == CHAR_MAX )
{ return groups;
} else
{ gsize = *++grouping;
}
}
return groups;
}
static int
ths_to_utf8(char *u8, const wchar_t *s, size_t len)
{ char *e = u8+len-7;
for( ; u8<e && *s; s++)
u8 = utf8_put_char(u8,*s);
*u8 = EOS;
return *s == 0;
}
static int
same_decimal_point(PL_locale *l1, PL_locale *l2)
{ if ( l1->decimal_point && l2->decimal_point &&
wcscmp(l1->decimal_point, l2->decimal_point) == 0 )
return TRUE;
if ( !l1->decimal_point && !l2->decimal_point )
return TRUE;
return FALSE;
}
static int
utf8_dp(PL_locale *l, char *s, int *len)
{ if ( l->decimal_point )
{ if ( !ths_to_utf8(s, l->decimal_point, 20) )
return FALSE;
*len = (int)strlen(s);
} else
{ *s++ = '.';
*s = EOS;
*len = 1;
}
return TRUE;
}
/* localizeDecimalPoint() replaces the decimal point as entered by the
local sensitive print functions by the one in the specified locale.
This is overly complicated. Needs more testing, in particular for
locales with (in UTF-8) multibyte decimal points.
*/
static int
localizeDecimalPoint(PL_locale *locale, Buffer b)
{ if ( locale == GD->locale.default_locale ||
same_decimal_point(GD->locale.default_locale, locale) )
return TRUE;
if ( locale->decimal_point && locale->decimal_point[0] )
{ char *s = baseBuffer(b, char);
char *e;
char dp[20]; int dplen;
char ddp[20]; int ddplen;
if ( !utf8_dp(locale, dp, &dplen) ||
!utf8_dp(GD->locale.default_locale, ddp, &ddplen) )
return FALSE;
if ( *s == '-' )
s++;
for(e=s; *e && isDigit(*e); e++)
;
if ( strncmp(e, ddp, ddplen) == 0 )
{ if ( dplen == ddplen )
{ memcpy(e, dp, dplen);
} else
{ char *ob = baseBuffer(b, char);
if ( dplen > ddplen && !growBuffer(b, dplen-ddplen) )
return PL_no_memory();
e += baseBuffer(b, char) - ob;
memmove(&e[dplen-ddplen], e, strlen(e)+1);
memcpy(e, dp, dplen);
}
}
}
return TRUE;
}
static int
groupDigits(PL_locale *locale, Buffer b)
{ if ( locale->thousands_sep && locale->thousands_sep[0] &&
locale->grouping && locale->grouping[0] )
{ char *s = baseBuffer(b, char);
char *e;
int groups;
if ( *s == '-' )
s++;
for(e=s; *e && isDigit(*e); e++)
;
groups = countGroups(locale->grouping, (int)(e-s));
if ( groups > 0 )
{ char *o;
char *grouping = locale->grouping;
int gsize = grouping[0];
char ths[20];
int thslen;
if ( !ths_to_utf8(ths, locale->thousands_sep, sizeof(ths)) )
return FALSE;
thslen = (int)strlen(ths);
if ( !growBuffer(b, thslen*groups) )
return PL_no_memory();
memmove(&e[groups*thslen], e, strlen(e)+1);
e--;
for(o=e+groups*thslen; e>=s; )
{ *o-- = *e--;
if ( --gsize == 0 && e>=s )
{ o -= thslen-1;
memcpy(o, ths, thslen);
o--;
if ( grouping[1] == 0 )
gsize = grouping[0];
else if ( grouping[1] == CHAR_MAX )
gsize = 0;
else
gsize = *++grouping;
}
}
}
}
return TRUE;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
formatFloat(PL_locale *locale, int how, int arg, Number f, Buffer out)
formats a floating point number to a buffer. `How' is the format
specifier ([eEfgG]), `arg' the argument.
MPZ/MPQ numbers printed using the format specifier `f' are written using
the following algorithm, courtesy of Jan Burse:
Given: A rational n/m
Seeked: The ration rounded to d fractional digits.
Algorithm: Compute (n*10^d+m//2)//m, and place period at d.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static char *
formatFloat(PL_locale *locale, int how, int arg, Number f, Buffer out)
{ if ( arg == DEFAULT )
{ arg = 6;
} else if ( arg < 0 )
{ GET_LD
term_t a = PL_new_term_ref();
PL_put_integer(a, arg);
PL_error(NULL, 0, NULL, ERR_DOMAIN, ATOM_not_less_than_zero, a);
return NULL;
}
switch(f->type)
{
#ifdef O_GMP
mpf_t mpf;
mpz_t t1, t2;
int neg;
int exp;
case V_MPZ:
{ switch(how)
{ case 'f':
{ mpz_init(t1);
mpz_init(t2);
mpz_ui_pow_ui(t1, 10, arg);
mpz_mul(t1, f->value.mpz, t1);
neg = mpz_sgn(t1) < 0;
mpz_abs(t1, t1);
goto print_mpz_f;
}
case 'e':
case 'E':
{ mpz_init(t1);
mpz_init(t2);
mpz_set(t1, f->value.mpz);
neg = mpz_sgn(t1) < 0;
mpz_abs(t1, t1);
if ( mpz_sgn(t1) == 0 )
{ exp = 0;
} else
{ exp = mpz_sizeinbase(t1, 10)-1; /* guess exponent */
mpz_ui_pow_ui(t2, 10, exp);
if (mpz_cmp(t2, t1) > 0) exp--; /* correct exponent */
if (exp > arg)
{ mpz_ui_pow_ui(t2, 10, (exp-arg-1));
mpz_tdiv_q(t1, t1, t2);
mpz_add_ui(t1, t1, 5);
mpz_tdiv_q_ui(t1, t1, 10);
} else
{ mpz_ui_pow_ui(t2, 10, arg-exp);
mpz_mul(t1, t1, t2);
}
}
mpz_set_ui(t2, exp);
goto print_mpz_e;
}
case 'g':
case 'G':
{ mpf_init2(mpf, arg*4);
mpf_set_z(mpf, f->value.mpz);
goto print_mpf;
}
}
}
case V_MPQ:
{ char tmp[12];
int size;
int written;
int fbits;
int digits;
int padding;
switch(how)
{ case 'f':
{ mpz_init(t1);
mpz_init(t2);
mpz_ui_pow_ui(t1, 10, arg);
mpz_mul(t1, mpq_numref(f->value.mpq), t1);
mpz_tdiv_q_ui(t2, mpq_denref(f->value.mpq), 2);
if (mpq_cmp_ui(f->value.mpq, 0, 1) < 0)
{ mpz_sub(t1, t1, t2);
neg=1;
} else
{ mpz_add(t1, t1, t2);
neg=0;
}
mpz_tdiv_q(t1, t1, mpq_denref(f->value.mpq));
mpz_abs(t1, t1);
print_mpz_f:
if ( mpz_sgn(t1) != 0 )
{ size = mpz_sizeinbase(t1, 2) * log(10)/log(2) * 1.2 + 1;
if ( !growBuffer(out, size) )
{ PL_no_memory();
return NULL;
}
mpz_get_str(baseBuffer(out, char), 10, t1);
digits = written = strlen(baseBuffer(out, char));
} else
{ written = digits = 0;
}
if ( digits <= arg )
padding = (arg-digits+1);
else
padding = 0;
size = digits;
if (neg) size++; /* leading - */
if (arg) size++; /* decimal point */
if (padding) size += padding; /* leading '0's */
size++; /* NULL terminator */
if ( !growBuffer(out, size) )
{ PL_no_memory();
return NULL;
}
if (!digits)
{ memset(out->base, '\0', 1);
}
if (padding)
{ memmove(out->base+padding, out->base, written+1);
memset(out->base, '0', padding);
written += padding;
}
if (arg)
{ memmove(out->base+written-(arg-1), out->base+written-arg, arg+1);
if ( locale->decimal_point && locale->decimal_point[0] )
*(out->base+written-arg) = locale->decimal_point[0];
else
*(out->base+written-arg) = '.';
written++;
}
if (neg)
{ memmove(out->base+1, out->base, written+1);
memset(out->base, '-', 1);
written++;
}
out->top = out->base + written;
mpz_clear(t1);
mpz_clear(t2);
break;
}
case 'e':
case 'E':
{ mpz_init(t1);
mpz_init(t2);
if (mpz_cmpabs(mpq_numref(f->value.mpq), mpq_denref(f->value.mpq)) >= 0)
{ mpz_tdiv_q(t1, mpq_numref(f->value.mpq), mpq_denref(f->value.mpq));
exp = mpz_sizeinbase(t1, 10)-1; /* guess exponent */
mpz_ui_pow_ui(t2, 10, exp);
if (mpz_cmpabs(t2, t1) > 0) exp--; /* correct exponent */
} else
{ mpq_t tq1, tq2;
mpq_init(tq1);
mpq_init(tq2);
mpz_set(t1, mpq_numref(f->value.mpq));
mpz_abs(t1, t1);
mpz_tdiv_q(t1, mpq_denref(f->value.mpq), t1);
exp = 0-mpz_sizeinbase(t1, 10); /* guess exponent */
mpz_ui_pow_ui(t2, 10, abs(exp)-1);
mpq_set_z(tq1, t1);
mpq_inv(tq2, f->value.mpq);
if (mpz_cmpabs(t2, t1) == 0 && mpq_cmp(tq1, tq2)==0) exp++;
if (mpz_cmpabs(t2, t1) > 0) exp++; /* correct exponent */
mpq_clear(tq1);
mpq_clear(tq2);
}
mpz_ui_pow_ui(t1, 10, abs(arg-exp));
if (mpz_cmpabs(mpq_numref(f->value.mpq), mpq_denref(f->value.mpq)) >= 0 && exp > arg)
{ mpz_tdiv_q(t1, mpq_numref(f->value.mpq), t1);
} else
{ mpz_mul(t1, mpq_numref(f->value.mpq), t1);
}
mpz_tdiv_q_ui(t2, mpq_denref(f->value.mpq), 2);
if ( mpq_sgn(f->value.mpq) < 0)
{ mpz_sub(t1, t1, t2);
neg=1;
} else
{ mpz_add(t1, t1, t2);
neg=0;
}
mpz_tdiv_q(t1, t1, mpq_denref(f->value.mpq));
mpz_abs(t1, t1);
mpz_ui_pow_ui(t2, 10, arg+1);
if (mpz_cmpabs(t2, t1) == 0)
{ mpz_tdiv_q_ui(t1, t1, 10);
exp++;
}
mpz_set_ui(t2, abs(exp));
print_mpz_e:
if ( mpz_sgn(t1) == 0 )
size = arg+7; /* reserve for 0.+e00<null> */
else
size = mpz_sizeinbase(t1, 10) + mpz_sizeinbase(t2, 10) + 6; /* reserve for -.e+0<null> */
if ( !growBuffer(out, size) )
{ PL_no_memory();
return NULL;
}
written = gmp_snprintf(baseBuffer(out, char), size, "%Zd%c%+03d", t1, how, exp);
if ( mpz_sgn(t1) == 0 )
{ memmove(out->base+arg, out->base, written+1);
memset(out->base, '0', arg);
written += arg;
}
if (arg)
{ memmove(out->base+2, out->base+1, written+1);
if ( locale->decimal_point && locale->decimal_point[0] )
*(out->base+1) = locale->decimal_point[0];
else
*(out->base+1) = '.';
written++;
}
if (neg)
{ memmove(out->base+1, out->base, written+1);
memset(out->base, '-', 1);
written++;
}
out->top = out->base + written;
mpz_clear(t1);
mpz_clear(t2);
return baseBuffer(out, char);
}
case 'g':
case 'G':
{ switch(how)
{ case 'g':
case 'G':
{ mpz_t iv;
mpz_init(iv);
mpz_set_q(iv, f->value.mpq);
fbits = (int)mpz_sizeinbase(iv, 2) + 4*arg;
mpz_clear(iv);
break;
}
default:
fbits = 4*arg;
}
mpf_init2(mpf, fbits);
mpf_set_q(mpf, f->value.mpq);
print_mpf:
Ssprintf(tmp, "%%.%dF%c", arg, how);
size = 0;
written = arg+4;
while(written >= size)
{ size = written+1;
if ( !growBuffer(out, size) ) /* reserve for -.e<null> */
{ PL_no_memory();
return NULL;
}
written = gmp_snprintf(baseBuffer(out, char), size, tmp, mpf);
}
mpf_clear(mpf);
out->top = out->base + written;
break;
}
}
break;
}
#elif O_BF
{ mpz_t n;
case V_MPZ:
mpz_init(n);
mpz_set(n, f->value.mpz);
goto bf_print;
case V_MPQ:
{ bf_flags_t flags;
int upcase;
limb_t prec = ((double)(arg+2) * log(10)/log(2));
if ( how == 'f' ) /* we must compensate for the integer */
{ mpz_t i;
mpz_init(i);
mpz_set_q(i, f->value.mpq);
prec += mpz_sizeinbase(i, 2);
mpz_clear(i);
}
mpz_init(n);
bf_div(n, mpq_numref(f->value.mpq), mpq_denref(f->value.mpq), prec, BF_RNDN);
bf_print:
upcase = FALSE;
switch(how)
{ case 'f':
flags = BF_FTOA_FORMAT_FRAC;
break;
case 'E':
upcase = TRUE;
case 'e':
arg++; /* LibBF counts total, we after . */
flags = BF_FTOA_FORCE_EXP|BF_FTOA_FORMAT_FIXED;
break;
case 'G':
upcase = TRUE;
case 'g':
flags = BF_FTOA_FORMAT_FREE;
break;
default:
flags = 0;
assert(0);
}
size_t size;
char *s = bf_ftoa(&size, n, 10, arg, BF_RNDN|BF_FTOA_PL_QUIRKS|flags);
if ( !growBuffer(out, size+1) )
{ PL_no_memory();
return NULL;
}
strcpy(baseBuffer(out, char), s);
bf_free(n->ctx, s);
if ( upcase )
{ char *exp = strchr(baseBuffer(out, char), 'e');
if ( exp )
*exp = 'E';
}
mpz_clear(n);
break;
}
}
#endif /* O_GMP OR O_BF */
case V_INTEGER:
promoteToFloatNumber(f);
/*FALLTHROUGH*/
case V_FLOAT:
{ char tmp[12];
int written = arg+20;
int size = 0;
Ssprintf(tmp, "%%.%d%c", arg, how);
while(written >= size)
{ size = written+1;
if ( !growBuffer(out, size) )
{ PL_no_memory();
return NULL;
}
written = snprintf(baseBuffer(out, char), size, tmp, f->value.f);
#ifdef __WINDOWS__
if ( written < 0 ) /* pre-C99 Windows snprintf() returns -1 */
written = size*2;
#endif
}
#ifdef __WINDOWS__
/*
Write all ~e formatted floats in POSIX notation:
* exponent must contain at least 2 digits
* only as many digits as necessary to represent the exponent
*/
switch(how)
{ case 'e':
case 'E':
case 'g':
case 'G':
{ if (written >= 7 &&
( *(out->base + written - 5) == 'e' ||
*(out->base + written - 5) == 'E' ) &&
( *(out->base + written - 3) == '0' ))
{ memmove(out->base + written-3, out->base + written-2, 3);
written--;
}
}
}
#endif
out->top = out->base + written;
break;
}
default:
assert(0);
return NULL;
}
if ( locale )
{ if ( !localizeDecimalPoint(locale, out) ||
!groupDigits(locale, out) )
return NULL;
}
return baseBuffer(out, char);
}
|
9dcc6ec3c2d16145471ab0dcf46482fd994e1c8d
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/mvmeppc/include/endian_machdep.h
|
4d8aa01db7076978ef2dd7caa5f50d6bfbf3e597
|
[] |
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
| 105
|
h
|
endian_machdep.h
|
/* $NetBSD: endian_machdep.h,v 1.1 2002/02/27 21:02:15 scw Exp $ */
#include <powerpc/endian_machdep.h>
|
4e2b7cfa4da9e8909aeb0e974fe3f891928640eb
|
4ba76056c744ada0a01fb27b7cad8464cefc7aa0
|
/supports/toolchains/LiveEditor/PainterEngine_LiveEditorModules_Linkkey.c
|
bb9f3ae6c6a35f31aa9cf678c124316d186e0fe4
|
[
"BSD-3-Clause"
] |
permissive
|
matrixcascade/PainterEngine
|
23e110e25a39e1d016ed7936eac23e06932456b4
|
1d3e6e85f337e8a8db44680094ab3f4b988507cb
|
refs/heads/master
| 2023-08-29T11:29:26.934779
| 2023-08-23T09:23:04
| 2023-08-23T09:23:04
| 190,119,926
| 1,989
| 253
|
BSD-3-Clause
| 2023-09-05T12:19:31
| 2019-06-04T03:08:26
|
C
|
UTF-8
|
C
| false
| false
| 6,487
|
c
|
PainterEngine_LiveEditorModules_Linkkey.c
|
#include "PainterEngine_LiveEditorModules_Linkkey.h"
px_void PX_LiveEditorModule_LinkkeyRender(px_surface *psurface,PX_Object *pObject,px_dword elpased)
{
px_int i;
PX_LiveEditorModule_Linkkey *plinkkey=(PX_LiveEditorModule_Linkkey *)pObject->pObject;
for (i=0;i<plinkkey->pLiveFramework->layers.size;i++)
{
PX_LiveLayer *pLayer=PX_VECTORAT(PX_LiveLayer,&plinkkey->pLiveFramework->layers,i);
if (PX_isPoint2DInCircle(plinkkey->cursor,PX_POINT2D(pLayer->keyPoint.x,pLayer->keyPoint.y),5))
{
PX_GeoDrawCircle(psurface,(px_int)(pLayer->keyPoint.x+plinkkey->pLiveFramework->refer_x),(px_int)(pLayer->keyPoint.y+plinkkey->pLiveFramework->refer_y),6,1,PX_COLOR(255,255,0,255));
PX_FontModuleDrawText(psurface,plinkkey->fontmodule,(px_int)(pLayer->keyPoint.x+plinkkey->pLiveFramework->refer_x),(px_int)(pLayer->keyPoint.y+plinkkey->pLiveFramework->refer_y)-6,PX_ALIGN_MIDBOTTOM,pLayer->id,PX_COLOR(255,0,0,255));
}
}
if (plinkkey->startlinkIndex>=0&&plinkkey->startlinkIndex<plinkkey->pLiveFramework->layers.size)
{
PX_LiveLayer *pLayer=PX_VECTORAT(PX_LiveLayer,&plinkkey->pLiveFramework->layers,plinkkey->startlinkIndex);
px_point2D startpt=PX_POINT2D((pLayer->keyPoint.x+plinkkey->pLiveFramework->refer_x),(pLayer->keyPoint.y+plinkkey->pLiveFramework->refer_y));
px_point2D endpt;
endpt=plinkkey->cursor;
endpt.x+=plinkkey->pLiveFramework->refer_x;
endpt.y+=plinkkey->pLiveFramework->refer_y;
PX_GeoDrawArrow(psurface,startpt,endpt,1,PX_COLOR(255,255,0,0));
}
}
px_void PX_LiveEditorModule_LinkkeyOnCursorMove(PX_Object *pObject,PX_Object_Event e,px_void *ptr)
{
PX_LiveEditorModule_Linkkey *plinkkey=(PX_LiveEditorModule_Linkkey *)pObject->pObject;
plinkkey->cursor=PX_POINT2D(PX_Object_Event_GetCursorX(e)-plinkkey->pLiveFramework->refer_x,PX_Object_Event_GetCursorY(e)-plinkkey->pLiveFramework->refer_y);
}
px_void PX_LiveEditorModule_LinkkeyOnCursorDown(PX_Object *pObject,PX_Object_Event e,px_void *ptr)
{
PX_LiveEditorModule_Linkkey *plinkkey=(PX_LiveEditorModule_Linkkey *)pObject->pObject;
px_float x=PX_Object_Event_GetCursorX(e)-plinkkey->pLiveFramework->refer_x;
px_float y=PX_Object_Event_GetCursorY(e)-plinkkey->pLiveFramework->refer_y;
px_int i;
if (plinkkey->startlinkIndex>=0&&plinkkey->startlinkIndex<plinkkey->pLiveFramework->layers.size)
{
PX_LiveLayer *pResLayer=PX_VECTORAT(PX_LiveLayer,&plinkkey->pLiveFramework->layers,plinkkey->startlinkIndex);
for (i=0;i<plinkkey->pLiveFramework->layers.size;i++)
{
PX_LiveLayer *pLayer=PX_VECTORAT(PX_LiveLayer,&plinkkey->pLiveFramework->layers,i);
if (PX_isPoint2DInCircle(PX_POINT2D(x,y),PX_POINT2D(pLayer->keyPoint.x,pLayer->keyPoint.y),5))
{
if (i!=plinkkey->startlinkIndex)
{
if (PX_LiveFrameworkLinkLayerSearchSubLayer(plinkkey->pLiveFramework,pLayer,pResLayer))
{
PX_Object_MessageBoxAlertOk(plinkkey->messagebox,PX_JsonGetString(plinkkey->pLanguageJson,"linkkey.closedlink"),0,0);
}
else
{
PX_LiveFrameworkLinkLayer(plinkkey->pLiveFramework,pResLayer,pLayer);
plinkkey->startlinkIndex=-1;
}
return;
}
}
}
}
else
{
plinkkey->startlinkIndex=-1;
for (i=0;i<plinkkey->pLiveFramework->layers.size;i++)
{
PX_LiveLayer *pLayer=PX_VECTORAT(PX_LiveLayer,&plinkkey->pLiveFramework->layers,i);
if (PX_isPoint2DInCircle(PX_POINT2D(x,y),PX_POINT2D(pLayer->keyPoint.x,pLayer->keyPoint.y),5))
{
plinkkey->startlinkIndex=i;
return;
}
}
}
plinkkey->startlinkIndex=-1;
}
px_void PX_LiveEditorModule_LinkkeyOnButtonReset(PX_Object *pObject,PX_Object_Event e,px_void *ptr)
{
PX_Object *pLinkObject=(PX_Object *)ptr;
PX_LiveEditorModule_Linkkey *plinkkey=(PX_LiveEditorModule_Linkkey *)pLinkObject->pObject;
PX_LiveFrameworkClearLinker(plinkkey->pLiveFramework);
}
px_void PX_LiveEditorModule_LinkkeyOnButtonFinish(PX_Object *pObject,PX_Object_Event e,px_void *ptr)
{
PX_Object *pLinkkeyObject=(PX_Object *)ptr;
PX_LiveEditorModule_Linkkey *pLinkkey=(PX_LiveEditorModule_Linkkey *)pLinkkeyObject->pObject;
pLinkkey->pLiveFramework->showlinker=PX_FALSE;
PX_ObjectExecuteEvent(pLinkkeyObject->pParent,PX_OBJECT_BUILD_EVENT(PX_LIVEFRAMEWORKMODULES_LINKKEY_EVENT_EXIT));
}
PX_Object * PX_LiveEditorModule_LinkkeyInstall(PX_Object *pparent,PX_Runtime *pruntime,PX_FontModule *fm,PX_LiveFramework *pLiveFramework,PX_Json *pLanguageJson)
{
PX_Object *pObject;
PX_LiveEditorModule_Linkkey linkkey,*plinkkey;
PX_memset(&linkkey,0,sizeof(PX_LiveEditorModule_Linkkey));
pObject=PX_ObjectCreateEx(&pruntime->mp_ui,pparent,0,0,0,0,0,0,0,0,PX_LiveEditorModule_LinkkeyRender,0,&linkkey,sizeof(linkkey));
plinkkey=(PX_LiveEditorModule_Linkkey *)pObject->pObject;
plinkkey->pruntime=pruntime;
plinkkey->fontmodule=fm;
plinkkey->pLanguageJson=pLanguageJson;
plinkkey->pLiveFramework=pLiveFramework;
plinkkey->messagebox= PX_Object_MessageBoxCreate(&pruntime->mp_ui,pObject,fm);
plinkkey->root=PX_Object_WidgetCreate(&pruntime->mp_ui,pObject,pruntime->surface_width-280,64,176,62,"",fm);
PX_Object_WidgetShowHideCloseButton(plinkkey->root,PX_FALSE);
plinkkey->button_reset=PX_Object_PushButtonCreate(&pruntime->mp_ui,plinkkey->root,3+85*0,3,84,32,PX_JsonGetString(pLanguageJson,"linkkey.reset"),fm);
plinkkey->button_finish=PX_Object_PushButtonCreate(&pruntime->mp_ui,plinkkey->root,3+85*1,3,84,32,PX_JsonGetString(pLanguageJson,"linkkey.finish"),fm);
PX_ObjectRegisterEvent(plinkkey->button_reset,PX_OBJECT_EVENT_EXECUTE,PX_LiveEditorModule_LinkkeyOnButtonReset,pObject);
PX_ObjectRegisterEvent(plinkkey->button_finish,PX_OBJECT_EVENT_EXECUTE,PX_LiveEditorModule_LinkkeyOnButtonFinish,pObject);
PX_ObjectRegisterEvent(pObject,PX_OBJECT_EVENT_CURSORMOVE,PX_LiveEditorModule_LinkkeyOnCursorMove,pObject);
PX_ObjectRegisterEvent(pObject,PX_OBJECT_EVENT_CURSORDOWN,PX_LiveEditorModule_LinkkeyOnCursorDown,pObject);
return pObject;
}
px_void PX_LiveEditorModule_LinkkeyEnable(PX_Object *pObject)
{
PX_LiveEditorModule_Linkkey *pLinkKey=(PX_LiveEditorModule_Linkkey *)pObject->pObject;
pLinkKey->pLiveFramework->showlinker=PX_TRUE;
pLinkKey->startlinkIndex=-1;
PX_LiveFrameworkReset(pLinkKey->pLiveFramework);
PX_ObjectSetFocus(pObject);
pObject->Enabled=PX_TRUE;
pObject->Visible=PX_TRUE;
}
px_void PX_LiveEditorModule_LinkkeyDisable(PX_Object *pObject)
{
PX_LiveEditorModule_Linkkey *pLinkKey=(PX_LiveEditorModule_Linkkey *)pObject->pObject;
pLinkKey->pLiveFramework->showlinker=PX_FALSE;
pObject->Enabled=PX_FALSE;
pObject->Visible=PX_FALSE;
}
|
6fa0b2f7bf5e22720bcf2c18a4260961e21f559e
|
340cc5d8ba77fbbafefb8a1755ae4dacbfb6953e
|
/src/lib/nfxV3.h
|
e5555ffacd1069f1570e1e3f4b1e0bf7ef51911e
|
[
"BSD-3-Clause"
] |
permissive
|
phaag/nfdump
|
1899c1b376c62040acdc994892949310cf85b32a
|
584453e6e3b4d6f23cf6c83cd2a7298cf0b5c44a
|
refs/heads/master
| 2023-08-31T06:53:13.565444
| 2023-08-20T12:22:46
| 2023-08-20T12:22:46
| 40,435,192
| 703
| 200
|
NOASSERTION
| 2023-08-20T18:40:33
| 2015-08-09T12:12:03
|
C
|
UTF-8
|
C
| false
| false
| 29,764
|
h
|
nfxV3.h
|
/*
* Copyright (c) 2023, Peter Haag
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the author nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _NFXV3_H
#define _NFXV3_H 1
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
#include "id.h"
/*
* V3 extension format
* ===================
*
* The goal of the V3 extension format:
* - simpler and more robust storage format.
* - independent of extension records. No specific ordering required.
* makes it much easier for multi theaded data processing.
* - more flexible record handling, allows variable length records/
*
*/
/*
* V3 data record
* ==============
*
*/
typedef struct recordHeaderV3_s {
// record header
uint16_t type;
uint16_t size;
uint16_t numElements;
uint8_t engineType;
uint8_t engineID;
uint16_t exporterID;
uint8_t flags;
#define V3_FLAG_EVENT 1
#define V3_FLAG_SAMPLED 2
#define V3_FLAG_ANON 4
uint8_t nfversion;
} recordHeaderV3_t;
#define OFFtype offsetof(recordHeaderV3_t, type)
#define SIZEtype MemberSize(recordHeaderV3_t, type)
#define V3HeaderRecordSize sizeof(recordHeaderV3_t)
#define AddV3Header(p, h) \
recordHeaderV3_t *h = (recordHeaderV3_t *)p; \
memset(h, 0, sizeof(recordHeaderV3_t)); \
h->type = V3Record; \
h->size = sizeof(recordHeaderV3_t);
/*
* array record header for nbar, ifname, vrf name records
*/
typedef struct arrayRecordHeader_s {
// record header
uint16_t type;
uint16_t size;
uint16_t numElements;
uint16_t elementSize;
} arrayRecordHeader_t;
#define arrayHeaderSize sizeof(arrayRecordHeader_t)
#define AddArrayHeader(p, h, t, s) \
arrayRecordHeader_t *h = (arrayRecordHeader_t *)p; \
memset(h, 0, sizeof(arrayRecordHeader_t)); \
h->type = t; \
h->size = sizeof(arrayRecordHeader_t); \
h->elementSize = s;
#define PushArrayVarElement(h, x, v, s) \
x##_t *v = (x##_t *)((void *)h + h->size); \
memset(v, 0, s); \
h->numElements++; \
h->size += s;
#define PushArrayNextElement(h, p, t) \
p = (t *)((void *)h + h->size); \
h->numElements++; \
h->size += h->elementSize;
/*
* Extension element header
*/
typedef struct elementHeader_s {
uint16_t type;
uint16_t length;
} __attribute__((__packed__)) elementHeader_t;
/*
* Extension elements
*/
#define EXnull 0
#define MemberSize(type, member) sizeof(((type *)0)->member)
#define VARLENGTH 0xFFFF
typedef struct EXgenericFlow_s {
#define EXgenericFlowID 1
uint64_t msecFirst;
uint64_t msecLast;
#define OFFmsecFirst offsetof(EXgenericFlow_t, msecFirst)
#define SIZEmsecFirst MemberSize(EXgenericFlow_t, msecFirst)
#define OFFmsecLast offsetof(EXgenericFlow_t, msecLast)
#define SIZEmsecLast MemberSize(EXgenericFlow_t, msecLast)
uint64_t msecReceived;
#define OFFmsecReceived offsetof(EXgenericFlow_t, msecReceived)
#define SIZEmsecReceived MemberSize(EXgenericFlow_t, msecReceived)
uint64_t inPackets;
uint64_t inBytes;
#define OFFinPackets offsetof(EXgenericFlow_t, inPackets)
#define SIZEinPackets MemberSize(EXgenericFlow_t, inPackets)
#define OFFinBytes offsetof(EXgenericFlow_t, inBytes)
#define SIZEinBytes MemberSize(EXgenericFlow_t, inBytes)
uint16_t srcPort;
#ifdef GOLANG
uint16_t dstPort;
#else
union {
uint16_t dstPort;
struct {
uint8_t icmpType;
uint8_t icmpCode;
};
};
#endif
#define OFFsrcPort offsetof(EXgenericFlow_t, srcPort)
#define SIZEsrcPort MemberSize(EXgenericFlow_t, srcPort)
#define OFFdstPort offsetof(EXgenericFlow_t, dstPort)
#define SIZEdstPort MemberSize(EXgenericFlow_t, dstPort)
#define OFFicmpCode offsetof(EXgenericFlow_t, icmpCode)
#define SIZEicmpCode MemberSize(EXgenericFlow_t, icmpCode)
#define OFFicmpType offsetof(EXgenericFlow_t, icmpType)
#define SIZEicmpType MemberSize(EXgenericFlow_t, icmpType)
uint8_t proto;
#define OFFproto offsetof(EXgenericFlow_t, proto)
#define SIZEproto MemberSize(EXgenericFlow_t, proto)
uint8_t tcpFlags;
#define OFFtcpFlags offsetof(EXgenericFlow_t, tcpFlags)
#define SIZEtcpFlags MemberSize(EXgenericFlow_t, tcpFlags)
uint8_t fwdStatus;
#define OFFfwdStatus offsetof(EXgenericFlow_t, fwdStatus)
#define SIZEfwdStatus MemberSize(EXgenericFlow_t, fwdStatus)
uint8_t srcTos;
#define OFFsrcTos offsetof(EXgenericFlow_t, srcTos)
#define SIZEsrcTos MemberSize(EXgenericFlow_t, srcTos)
} EXgenericFlow_t;
#define EXgenericFlowSize (sizeof(EXgenericFlow_t) + sizeof(elementHeader_t))
typedef struct EXipv4Flow_s {
#define EXipv4FlowID 2
uint32_t srcAddr;
uint32_t dstAddr;
#define OFFsrc4Addr offsetof(EXipv4Flow_t, srcAddr)
#define SIZEsrc4Addr MemberSize(EXipv4Flow_t, srcAddr)
#define OFFdst4Addr offsetof(EXipv4Flow_t, dstAddr)
#define SIZEdst4Addr MemberSize(EXipv4Flow_t, dstAddr)
} EXipv4Flow_t;
#define EXipv4FlowSize (sizeof(EXipv4Flow_t) + sizeof(elementHeader_t))
typedef struct EXipv6Flow_s {
#define EXipv6FlowID 3
uint64_t srcAddr[2];
uint64_t dstAddr[2];
#define OFFsrc6Addr offsetof(EXipv6Flow_t, srcAddr)
#define SIZEsrc6Addr MemberSize(EXipv6Flow_t, srcAddr)
#define OFFdst6Addr offsetof(EXipv6Flow_t, dstAddr)
#define SIZEdst6Addr MemberSize(EXipv6Flow_t, dstAddr)
} EXipv6Flow_t;
#define EXipv6FlowSize (sizeof(EXipv6Flow_t) + sizeof(elementHeader_t))
typedef struct EXflowMisc_s {
#define EXflowMiscID 4
uint32_t input;
uint32_t output;
#define OFFinput offsetof(EXflowMisc_t, input)
#define SIZEinput MemberSize(EXflowMisc_t, input)
#define OFFoutput offsetof(EXflowMisc_t, output)
#define SIZEoutput MemberSize(EXflowMisc_t, output)
uint8_t srcMask;
uint8_t dstMask;
#define OFFsrcMask offsetof(EXflowMisc_t, srcMask)
#define SIZEsrcMask MemberSize(EXflowMisc_t, srcMask)
#define OFFdstMask offsetof(EXflowMisc_t, dstMask)
#define SIZEdstMask MemberSize(EXflowMisc_t, dstMask)
uint8_t dir;
#define OFFdir offsetof(EXflowMisc_t, dir)
#define SIZEdir MemberSize(EXflowMisc_t, dir)
uint8_t dstTos;
#define OFFdstTos offsetof(EXflowMisc_t, dstTos)
#define SIZEdstTos MemberSize(EXflowMisc_t, dstTos)
uint8_t biFlowDir;
#define OFFbiFlowDir offsetof(EXflowMisc_t, biFlowDir)
#define SIZEbiFlowDir MemberSize(EXflowMisc_t, biFlowDir)
uint8_t flowEndReason;
#define OFFflowEndReason offsetof(EXflowMisc_t, flowEndReason)
#define SIZEflowEndReason MemberSize(EXflowMisc_t, flowEndReason)
// align bytes
uint8_t revTcpFlags;
uint8_t fill;
} EXflowMisc_t;
#define EXflowMiscSize (sizeof(EXflowMisc_t) + sizeof(elementHeader_t))
typedef struct EXcntFlow_s {
#define EXcntFlowID 5
uint64_t flows;
#define OFFflows offsetof(EXcntFlow_t, flows)
#define SIZEflows MemberSize(EXcntFlow_t, flows)
uint64_t outPackets;
uint64_t outBytes;
#define OFFoutPackets offsetof(EXcntFlow_t, outPackets)
#define SIZEoutPackets MemberSize(EXcntFlow_t, outPackets)
#define OFFoutBytes offsetof(EXcntFlow_t, outBytes)
#define SIZEoutBytes MemberSize(EXcntFlow_t, outBytes)
} EXcntFlow_t;
#define EXcntFlowSize (sizeof(EXcntFlow_t) + sizeof(elementHeader_t))
typedef struct EXvLan_s {
#define EXvLanID 6
uint32_t srcVlan;
uint32_t dstVlan;
#define OFFsrcVlan offsetof(EXvLan_t, srcVlan)
#define SIZEsrcVlan MemberSize(EXvLan_t, srcVlan)
#define OFFdstVlan offsetof(EXvLan_t, dstVlan)
#define SIZEdstVlan MemberSize(EXvLan_t, dstVlan)
} EXvLan_t;
#define EXvLanSize (sizeof(EXvLan_t) + sizeof(elementHeader_t))
typedef struct EXasRouting_s {
#define EXasRoutingID 7
uint32_t srcAS;
uint32_t dstAS;
#define OFFsrcAS offsetof(EXasRouting_t, srcAS)
#define SIZEsrcAS MemberSize(EXasRouting_t, srcAS)
#define OFFdstAS offsetof(EXasRouting_t, dstAS)
#define SIZEdstAS MemberSize(EXasRouting_t, dstAS)
} EXasRouting_t;
#define EXasRoutingSize (sizeof(EXasRouting_t) + sizeof(elementHeader_t))
typedef struct EXbgpNextHopV4_s {
#define EXbgpNextHopV4ID 8
uint32_t ip;
#define OFFbgp4NextIP offsetof(EXbgpNextHopV4_t, ip)
#define SIZEbgp4NextIP MemberSize(EXbgpNextHopV4_t, ip)
} EXbgpNextHopV4_t;
#define EXbgpNextHopV4Size (sizeof(EXbgpNextHopV4_t) + sizeof(elementHeader_t))
typedef struct EXbgpNextHopV6_s {
#define EXbgpNextHopV6ID 9
uint64_t ip[2];
#define OFFbgp6NextIP offsetof(EXbgpNextHopV6_t, ip)
#define SIZEbgp6NextIP MemberSize(EXbgpNextHopV6_t, ip)
} EXbgpNextHopV6_t;
#define EXbgpNextHopV6Size (sizeof(EXbgpNextHopV6_t) + sizeof(elementHeader_t))
typedef struct EXipNextHopV4_s {
#define EXipNextHopV4ID 10
uint32_t ip;
#define OFFNext4HopIP offsetof(EXipNextHopV4_t, ip)
#define SIZENext4HopIP MemberSize(EXipNextHopV4_t, ip)
} EXipNextHopV4_t;
#define EXipNextHopV4Size (sizeof(EXipNextHopV4_t) + sizeof(elementHeader_t))
typedef struct EXipNextHopV6_s {
#define EXipNextHopV6ID 11
uint64_t ip[2];
#define OFFNext6HopIP offsetof(EXipNextHopV6_t, ip)
#define SIZENext6HopIP MemberSize(EXipNextHopV6_t, ip)
} EXipNextHopV6_t;
#define EXipNextHopV6Size (sizeof(EXipNextHopV6_t) + sizeof(elementHeader_t))
typedef struct EXipReceivedV4_s {
#define EXipReceivedV4ID 12
uint32_t ip;
#define OFFReceived4IP offsetof(EXipReceivedV4_t, ip)
#define SIZEReceived4IP MemberSize(EXipReceivedV4_t, ip)
} EXipReceivedV4_t;
#define EXipReceivedV4Size (sizeof(EXipReceivedV4_t) + sizeof(elementHeader_t))
typedef struct EXipReceivedV6_s {
#define EXipReceivedV6ID 13
uint64_t ip[2];
#define OFFReceived6IP offsetof(EXipReceivedV6_t, ip)
#define SIZEReceived6IP MemberSize(EXipReceivedV6_t, ip)
} EXipReceivedV6_t;
#define EXipReceivedV6Size (sizeof(EXipReceivedV6_t) + sizeof(elementHeader_t))
typedef struct EXmplsLabel_s {
#define EXmplsLabelID 14
uint32_t mplsLabel[10];
#define OFFmplsLabel1 offsetof(EXmplsLabel_t, mplsLabel[0])
#define SIZEmplsLabel1 MemberSize(EXmplsLabel_t, mplsLabel[0])
#define OFFmplsLabel2 offsetof(EXmplsLabel_t, mplsLabel[1])
#define SIZEmplsLabel2 MemberSize(EXmplsLabel_t, mplsLabel[1])
#define OFFmplsLabel3 offsetof(EXmplsLabel_t, mplsLabel[2])
#define SIZEmplsLabel3 MemberSize(EXmplsLabel_t, mplsLabel[2])
#define OFFmplsLabel4 offsetof(EXmplsLabel_t, mplsLabel[3])
#define SIZEmplsLabel4 MemberSize(EXmplsLabel_t, mplsLabel[3])
#define OFFmplsLabel5 offsetof(EXmplsLabel_t, mplsLabel[4])
#define SIZEmplsLabel5 MemberSize(EXmplsLabel_t, mplsLabel[4])
#define OFFmplsLabel6 offsetof(EXmplsLabel_t, mplsLabel[5])
#define SIZEmplsLabel6 MemberSize(EXmplsLabel_t, mplsLabel[5])
#define OFFmplsLabel7 offsetof(EXmplsLabel_t, mplsLabel[6])
#define SIZEmplsLabel7 MemberSize(EXmplsLabel_t, mplsLabel[6])
#define OFFmplsLabel8 offsetof(EXmplsLabel_t, mplsLabel[7])
#define SIZEmplsLabel8 MemberSize(EXmplsLabel_t, mplsLabel[7])
#define OFFmplsLabel9 offsetof(EXmplsLabel_t, mplsLabel[8])
#define SIZEmplsLabel9 MemberSize(EXmplsLabel_t, mplsLabel[8])
#define OFFmplsLabel10 offsetof(EXmplsLabel_t, mplsLabel[9])
#define SIZEmplsLabel10 MemberSize(EXmplsLabel_t, mplsLabel[9])
} EXmplsLabel_t;
#define EXmplsLabelSize (sizeof(EXmplsLabel_t) + sizeof(elementHeader_t))
typedef struct EXmacAddr_s {
#define EXmacAddrID 15
uint64_t inSrcMac;
uint64_t outDstMac;
uint64_t inDstMac;
uint64_t outSrcMac;
#define OFFinSrcMac offsetof(EXmacAddr_t, inSrcMac)
#define SIZEinSrcMac MemberSize(EXmacAddr_t, inSrcMac)
#define OFFoutDstMac offsetof(EXmacAddr_t, outDstMac)
#define SIZEoutDstMac MemberSize(EXmacAddr_t, outDstMac)
#define OFFinDstMac offsetof(EXmacAddr_t, inDstMac)
#define SIZEinDstMac MemberSize(EXmacAddr_t, inDstMac)
#define OFFoutSrcMac offsetof(EXmacAddr_t, outSrcMac)
#define SIZEoutSrcMac MemberSize(EXmacAddr_t, outSrcMac)
} EXmacAddr_t;
#define EXmacAddrSize (sizeof(EXmacAddr_t) + sizeof(elementHeader_t))
typedef struct EXasAdjacent_s {
#define EXasAdjacentID 16
uint32_t nextAdjacentAS; // NF_F_BGP_ADJ_NEXT_AS(128)
uint32_t prevAdjacentAS; // NF_F_BGP_ADJ_PREV_AS(129)
#define OFFnextAdjacentAS offsetof(EXasAdjacent_t, nextAdjacentAS)
#define SIZEnextAdjacentAS MemberSize(EXasAdjacent_t, nextAdjacentAS)
#define OFFprevAdjacentAS offsetof(EXasAdjacent_t, prevAdjacentAS)
#define SIZEprevAdjacentAS MemberSize(EXasAdjacent_t, prevAdjacentAS)
} EXasAdjacent_t;
#define EXasAdjacentSize (sizeof(EXasAdjacent_t) + sizeof(elementHeader_t))
typedef struct EXlatency_s {
#define EXlatencyID 17
uint64_t usecClientNwDelay; // NF_NPROBE_CLIENT_NW_DELAY_SEC(57554) + NF_NPROBE_CLIENT_NW_DELAY_USEC(57555)
uint64_t usecServerNwDelay; // NF_NPROBE_SERVER_NW_DELAY_SEC(57556) + NF_NPROBE_SERVER_NW_DELAY_USEC(57557)
uint64_t usecApplLatency; // NF_NPROBE_APPL_LATENCY_SEC(57558) + NF_NPROBE_APPL_LATENCY_USEC(57559)
#define OFFusecClientNwDelay offsetof(EXlatency_t, usecClientNwDelay)
#define SIZEusecClientNwDelay MemberSize(EXlatency_t, usecClientNwDelay)
#define OFFusecServerNwDelay offsetof(EXlatency_t, usecServerNwDelay)
#define SIZEusecServerNwDelay MemberSize(EXlatency_t, usecServerNwDelay)
#define OFFusecApplLatency offsetof(EXlatency_t, usecApplLatency)
#define SIZEusecApplLatency MemberSize(EXlatency_t, usecApplLatency)
} EXlatency_t;
#define EXlatencySize (sizeof(EXlatency_t) + sizeof(elementHeader_t))
typedef struct EXsamplerInfo_s {
#define EXsamplerInfoID 18
uint64_t selectorID; // #302 id assigned by the exporting device
uint16_t exporter_sysid; // internal reference to exporter
uint16_t align;
#define OFFsampID offsetof(EXsamplerInfo_t, selectorID)
#define SIZEsampID MemberSize(EXsamplerInfo_t, selectorID)
#define OFFsampExporter offsetof(EXsamplerInfo_t, exporter_sysid)
#define SIZEsampExporter MemberSize(EXsamplerInfo_t, exporter_sysid)
} EXsamplerInfo_t;
#define EXsamplerInfoSize (sizeof(EXsamplerInfo_t) + sizeof(elementHeader_t))
typedef struct EXnselCommon_s {
#define EXnselCommonID 19
uint64_t msecEvent; // NF_F_EVENT_TIME_MSEC(323)
uint32_t connID; // NF_F_CONN_ID(148)
uint16_t fwXevent; // NF_F_FW_EXT_EVENT(33002)
uint8_t fwEvent; // NF_F_FW_EVENT(233), NF_F_FW_EVENT_84(40005)
uint8_t fill;
#define OFFmsecEvent offsetof(EXnselCommon_t, msecEvent)
#define SIZEmsecEvent MemberSize(EXnselCommon_t, msecEvent)
#define OFFconnID offsetof(EXnselCommon_t, connID)
#define SIZEconnID MemberSize(EXnselCommon_t, connID)
#define OFFfwXevent offsetof(EXnselCommon_t, fwXevent)
#define SIZEfwXevent MemberSize(EXnselCommon_t, fwXevent)
#define OFFfwEvent offsetof(EXnselCommon_t, fwEvent)
#define SIZEfwEvent MemberSize(EXnselCommon_t, fwEvent)
} EXnselCommon_t;
#define EXnselCommonSize (sizeof(EXnselCommon_t) + sizeof(elementHeader_t))
typedef struct EXnselXlateIPv4_s {
#define EXnselXlateIPv4ID 20
uint32_t xlateSrcAddr; // NF_F_XLATE_SRC_ADDR_IPV4(225), NF_F_XLATE_SRC_ADDR_84(40001)
uint32_t xlateDstAddr; // NF_F_XLATE_DST_ADDR_IPV4(226), NF_F_XLATE_DST_ADDR_84(40002)
#define OFFxlateSrc4Addr offsetof(EXnselXlateIPv4_t, xlateSrcAddr)
#define SIZExlateSrc4Addr MemberSize(EXnselXlateIPv4_t, xlateSrcAddr)
#define OFFxlateDst4Addr offsetof(EXnselXlateIPv4_t, xlateDstAddr)
#define SIZExlateDst4Addr MemberSize(EXnselXlateIPv4_t, xlateDstAddr)
} EXnselXlateIPv4_t;
#define EXnselXlateIPv4Size (sizeof(EXnselXlateIPv4_t) + sizeof(elementHeader_t))
typedef struct EXnselXlateIPv6_s {
#define EXnselXlateIPv6ID 21
uint64_t xlateSrcAddr[2]; // NF_F_XLATE_SRC_ADDR_IPV6(281),
uint64_t xlateDstAddr[2]; // NF_F_XLATE_DST_ADDR_IPV6(282),
#define OFFxlateSrc6Addr offsetof(EXnselXlateIPv6_t, xlateSrcAddr)
#define SIZExlateSrc6Addr MemberSize(EXnselXlateIPv6_t, xlateSrcAddr)
#define OFFxlateDst6Addr offsetof(EXnselXlateIPv6_t, xlateDstAddr)
#define SIZExlateDst6Addr MemberSize(EXnselXlateIPv6_t, xlateDstAddr)
} EXnselXlateIPv6_t;
#define EXnselXlateIPv6Size (sizeof(EXnselXlateIPv6_t) + sizeof(elementHeader_t))
typedef struct EXnselXlatePort_s {
#define EXnselXlatePortID 22
uint16_t xlateSrcPort; // NF_F_XLATE_SRC_PORT(227), NF_F_XLATE_SRC_PORT_84(40003)
uint16_t xlateDstPort; // NF_F_XLATE_DST_PORT(228), NF_F_XLATE_DST_PORT_84(40004)
#define OFFxlateSrcPort offsetof(EXnselXlatePort_t, xlateSrcPort)
#define SIZExlateSrcPort MemberSize(EXnselXlatePort_t, xlateSrcPort)
#define OFFxlateDstPort offsetof(EXnselXlatePort_t, xlateDstPort)
#define SIZExlateDstPort MemberSize(EXnselXlatePort_t, xlateDstPort)
} EXnselXlatePort_t;
#define EXnselXlatePortSize (sizeof(EXnselXlatePort_t) + sizeof(elementHeader_t))
typedef struct EXnselAcl_s {
#define EXnselAclID 23
uint32_t ingressAcl[3]; // NF_F_INGRESS_ACL_ID(33000)
uint32_t egressAcl[3]; // NF_F_EGRESS_ACL_ID(33001)
#define OFFingressAcl offsetof(EXnselAcl_t, ingressAcl)
#define SIZEingressAcl MemberSize(EXnselAcl_t, ingressAcl)
#define OFFegressAcl offsetof(EXnselAcl_t, egressAcl)
#define SIZEegressAcl MemberSize(EXnselAcl_t, egressAcl)
} EXnselAcl_t;
#define EXnselAclSize (sizeof(EXnselAcl_t) + sizeof(elementHeader_t))
typedef struct EXnselUser_s {
#define EXnselUserID 24
char username[66]; // NF_F_USERNAME(40000),
uint16_t fill2;
#define OFFusername offsetof(EXnselUser_t, username)
#define SIZEusername MemberSize(EXnselUser_t, username)
} EXnselUser_t;
#define EXnselUserSize (sizeof(EXnselUser_t) + sizeof(elementHeader_t))
// NEL
typedef struct EXnelCommon_s {
#define EXnelCommonID 25
uint64_t msecEvent; // NF_F_EVENT_TIME_MSEC(323)
uint32_t natPoolID; // NF_N_NATPOOL_ID(283)
uint8_t natEvent; // NAT_EVENT(230)
uint8_t fill1;
uint16_t fill2;
#define OFFnelMsecEvent offsetof(EXnelCommon_t, msecEvent)
#define SIZEnelMsecEvent MemberSize(EXnelCommon_t, msecEvent)
#define OFFnatPoolID offsetof(EXnelCommon_t, natPoolID)
#define SIZEnatPoolID MemberSize(EXnelCommon_t, natPoolID)
#define OFFnatEvent offsetof(EXnelCommon_t, natEvent)
#define SIZEnatEvent MemberSize(EXnelCommon_t, natEvent)
} EXnelCommon_t;
#define EXnelCommonSize (sizeof(EXnelCommon_t) + sizeof(elementHeader_t))
// comapt record includes vrf fields
// no longer used, but old data may exist
typedef struct EXnelCommonCompat_s {
uint64_t msecEvent; // NF_F_EVENT_TIME_MSEC(323)
uint32_t egressVrf; // NF_N_EGRESS_VRFID(235)
uint32_t ingressVrf; // NF_N_INGRESS_VRFID(234)
uint32_t natPoolID; // NF_N_NATPOOL_ID(283)
uint8_t natEvent; // NAT_EVENT(230)
uint8_t fill1;
uint16_t fill2;
} EXnelCommonCompat_t;
#define EXnelCommonCompatSize (sizeof(EXnelCommonCompat_t) + sizeof(elementHeader_t))
typedef struct EXnelXlatePort_s {
#define EXnelXlatePortID 26
uint16_t blockStart; // NF_F_XLATE_PORT_BLOCK_START(361)
uint16_t blockEnd; // NF_F_XLATE_PORT_BLOCK_END(362)
uint16_t blockStep; // NF_F_XLATE_PORT_BLOCK_STEP(363)
uint16_t blockSize; // NF_F_XLATE_PORT_BLOCK_SIZE(364)
#define OFFnelblockStart offsetof(EXnelXlatePort_t, blockStart)
#define SIZEnelblockStart MemberSize(EXnelXlatePort_t, blockStart)
#define OFFnelblockEnd offsetof(EXnelXlatePort_t, blockEnd)
#define SIZEnelblockEnd MemberSize(EXnelXlatePort_t, blockEnd)
#define OFFnelblockStep offsetof(EXnelXlatePort_t, blockStep)
#define SIZEnelblockStep MemberSize(EXnelXlatePort_t, blockStep)
#define OFFnelblockSize offsetof(EXnelXlatePort_t, blockSize)
#define SIZEnelblockSize MemberSize(EXnelXlatePort_t, blockSize)
} EXnelXlatePort_t;
#define EXnelXlatePortSize (sizeof(EXnelXlatePort_t) + sizeof(elementHeader_t))
typedef struct EXnbarApp_s {
#define EXnbarAppID 27
uint8_t id[4];
#define OFFnbarAppID offsetof(EXnbarApp_t, id)
#define SIZEnbarAppID VARLENGTH
} EXnbarApp_t;
#define EXnbarAppSize (sizeof(EXnbarApp_t) - 4 + sizeof(elementHeader_t))
#define EXlabelID_t elementHeader_t
#define EXlabelID 28
#define EXlabelSize sizeof(elementHeader_t)
#define EXinPayload_t elementHeader_t
#define EXinPayloadID 29
#define EXinPayloadSize sizeof(elementHeader_t)
#define EXoutPayloadID 30
#define EXoutPayloadSize sizeof(elementHeader_t)
typedef struct EXtunIPv4_s {
#define EXtunIPv4ID 31
uint32_t tunSrcAddr;
uint32_t tunDstAddr;
uint32_t tunProto;
#define OFFtunSrc4Addr offsetof(EXtunIPv4_t, tunSrcAddr)
#define SIZEtunSrc4Addr MemberSize(EXtunIPv4_t, tunSrcAddr)
#define OFFtunDst4Addr offsetof(EXtunIPv4_t, tunDstAddr)
#define SIZEtunDst4Addr MemberSize(EXtunIPv4_t, tunDstAddr)
#define OFFtunProto offsetof(EXtunIPv4_t, tunProto)
#define SIZEtunProto MemberSize(EXtunIPv4_t, tunProto)
} EXtunIPv4_t;
#define EXtunIPv4Size (sizeof(EXtunIPv4_t) + sizeof(elementHeader_t))
typedef struct EXtunIPv6_s {
#define EXtunIPv6ID 32
uint64_t tunSrcAddr[2];
uint64_t tunDstAddr[2];
uint32_t tunProto;
#define OFFtunSrc6Addr offsetof(EXtunIPv6_t, tunSrcAddr)
#define SIZEtunSrc6Addr MemberSize(EXtunIPv6_t, tunSrcAddr)
#define OFFtunDst6Addr offsetof(EXtunIPv6_t, tunDstAddr)
#define SIZEtunDst6Addr MemberSize(EXtunIPv6_t, tunDstAddr)
} EXtunIPv6_t;
#define EXtunIPv6Size (sizeof(EXtunIPv6_t) + sizeof(elementHeader_t))
typedef struct EXobservation_s {
#define EXobservationID 33
uint64_t pointID;
uint32_t domainID;
#define OFFpointID offsetof(EXobservation_t, pointID)
#define SIZEpointID MemberSize(EXobservation_t, pointID)
#define OFFdomainID offsetof(EXobservation_t, domainID)
#define SIZEdomainID MemberSize(EXobservation_t, domainID)
} EXobservation_t;
#define EXobservationSize (sizeof(EXobservation_t) + sizeof(elementHeader_t))
typedef struct EXinmonMeta_s {
#define EXinmonMetaID 34
uint16_t frameSize;
uint16_t linkType;
} EXinmonMeta_t;
#define OFFframeSize offsetof(EXinmonMeta_t, frameSize)
#define SIZEframeSize MemberSize(EXinmonMeta_t, frameSize)
#define OFFlinkType offsetof(EXinmonMeta_t, linkType)
#define SIZElinkType MemberSize(EXinmonMeta_t, linkType)
#define EXinmonMetaSize (sizeof(EXinmonMeta_t) + sizeof(elementHeader_t))
typedef struct EXinmonFrame_s {
#define EXinmonFrameID 35
uint8_t packet[4];
} EXinmonFrame_t;
#define OFFpacket offsetof(EXinmonFrame_t, packet)
#define SIZEpacket VARLENGTH
#define EXinmonFrameSize (sizeof(EXinmonFrame_t) - 4 + sizeof(elementHeader_t))
typedef struct EXvrf_s {
#define EXvrfID 36
uint32_t egressVrf; // EGRESS_VRFID(235)
uint32_t ingressVrf; // INGRESS_VRFID(234)
#define OFFegressVrf offsetof(EXvrf_t, egressVrf)
#define SIZEegressVrf MemberSize(EXvrf_t, egressVrf)
#define OFFingressVrf offsetof(EXvrf_t, ingressVrf)
#define SIZEingressVrf MemberSize(EXvrf_t, ingressVrf)
} EXvrf_t;
#define EXvrfSize (sizeof(EXvrf_t) + sizeof(elementHeader_t))
typedef struct EXpfinfo_s {
#define EXpfinfoID 37
uint8_t action;
uint8_t reason;
uint8_t dir;
uint8_t rewritten;
uint32_t rulenr;
uint32_t subrulenr;
uint32_t uid;
uint32_t pid;
char ifname[4];
} EXpfinfo_t;
#define EXpfinfoSize (sizeof(EXpfinfo_t) - 4 + sizeof(elementHeader_t))
// max possible elements
#define MAXEXTENSIONS 38
// push a fixed length extension to the v3 record
// h v3 record header
// x Extension
// v variable of type Extension
#define PushExtension(h, x, v) \
{ \
elementHeader_t *elementHeader = (elementHeader_t *)((void *)h + h->size); \
elementHeader->type = x##ID; \
elementHeader->length = x##Size; \
h->size += sizeof(elementHeader_t); \
} \
x##_t *v = (x##_t *)((void *)h + h->size); \
memset(v, 0, sizeof(x##_t)); \
h->numElements++; \
h->size += sizeof(x##_t);
// push a var length extension to the v3 record
// h v3 record header
// x Extension
// v variable of type Extension
// s additional var length size
#define PushVarLengthExtension(h, x, v, s) \
{ \
elementHeader_t *elementHeader = (elementHeader_t *)((void *)h + h->size); \
elementHeader->type = x##ID; \
elementHeader->length = x##Size + s; \
} \
x##_t *v = (x##_t *)((void *)h + h->size + sizeof(elementHeader_t)); \
memset(v, 0, x##Size + s - sizeof(elementHeader_t)); \
h->numElements++; \
h->size += x##Size + s;
// push a var extension to the v3 record
// h v3 record header
// x Extension - just an element header
// v pointer to the memory os size s
// s var length size
#define PushVarLengthPointer(h, x, v, s) \
{ \
elementHeader_t *elementHeader = (elementHeader_t *)((void *)h + h->size); \
elementHeader->type = x##ID; \
elementHeader->length = sizeof(elementHeader_t) + s; \
h->size += sizeof(elementHeader_t); \
} \
void *v = ((void *)h + h->size); \
memset(v, 0, s); \
h->numElements++; \
h->size += s;
#define EXTENSION(s) \
{ s##ID, s##Size, #s }
static const struct extensionTable_s {
uint32_t id; // id number
uint32_t size; // number of bytes incl. header, 0xFFFF for dyn length
char *name; // name of extension
} extensionTable[] = {
{0, 0, "ExNull"}, EXTENSION(EXgenericFlow), EXTENSION(EXipv4Flow), EXTENSION(EXipv6Flow), EXTENSION(EXflowMisc),
EXTENSION(EXcntFlow), EXTENSION(EXvLan), EXTENSION(EXasRouting), EXTENSION(EXbgpNextHopV4), EXTENSION(EXbgpNextHopV6),
EXTENSION(EXipNextHopV4), EXTENSION(EXipNextHopV6), EXTENSION(EXipReceivedV4), EXTENSION(EXipReceivedV6), EXTENSION(EXmplsLabel),
EXTENSION(EXmacAddr), EXTENSION(EXasAdjacent), EXTENSION(EXlatency), EXTENSION(EXsamplerInfo), EXTENSION(EXnselCommon),
EXTENSION(EXnselXlateIPv4), EXTENSION(EXnselXlateIPv6), EXTENSION(EXnselXlatePort), EXTENSION(EXnselAcl), EXTENSION(EXnselUser),
EXTENSION(EXnelCommon), EXTENSION(EXnelXlatePort), EXTENSION(EXnbarApp), EXTENSION(EXlabel), EXTENSION(EXinPayload),
EXTENSION(EXoutPayload), EXTENSION(EXtunIPv4), EXTENSION(EXtunIPv6), EXTENSION(EXobservation), EXTENSION(EXinmonMeta),
EXTENSION(EXinmonFrame), EXTENSION(EXvrf), EXTENSION(EXpfinfo)};
typedef struct record_map_s {
recordHeaderV3_t *recordHeader;
elementHeader_t *offsetMap[MAXEXTENSIONS];
} record_map_t;
typedef struct sequence_s {
uint16_t inputType;
uint16_t inputLength;
#define NumberCopy 1
#define ByteCopy 2
uint16_t copyMode;
uint16_t extensionID;
unsigned long offsetRel;
uint16_t outputLength;
uint16_t stackID;
} sequence_t;
typedef struct sequencer_s {
struct sequencer_s *next;
void *offsetCache[MAXEXTENSIONS];
sequence_t *sequenceTable;
uint16_t templateID;
uint16_t ExtSize[MAXEXTENSIONS];
uint32_t numSequences;
uint32_t numElements;
size_t inLength;
size_t outLength;
} sequencer_t;
#define SEQ_OK 0
#define SEQ_ERROR -1
#define SEQ_MEM_ERR -2
uint16_t *SetupSequencer(sequencer_t *sequencer, sequence_t *sequenceTable, uint32_t numSequences);
void ClearSequencer(sequencer_t *sequencer);
size_t CalcOutRecordSize(sequencer_t *sequencer, void *in, size_t inSize);
int SequencerRun(sequencer_t *sequencer, const void *inBuff, size_t inSize, void *outBuff, size_t outSize, uint64_t *stack);
void PrintSequencer(sequencer_t *sequencer);
int VerifyV3Record(recordHeaderV3_t *recordHeader);
#endif //_NFXV3_H
|
5ad7bf529ec36823351d11661bdbdde3704826a8
|
6832a9c81b16ead373325f70fb97753d6a211539
|
/src/wrapped/generated/wrappedlibxcbtypes.h
|
86665afb44db7b2332533cf05fc6df70b441ca7a
|
[
"MIT"
] |
permissive
|
ptitSeb/box86
|
2d3a0c4574905ff8d9dc7b5afb5444a273832bd6
|
ad934455c1b40feeebe5e6bd09b9063519102859
|
refs/heads/master
| 2023-08-22T05:30:54.331500
| 2023-08-20T13:01:58
| 2023-08-20T13:01:58
| 164,844,546
| 2,877
| 294
|
MIT
| 2023-07-27T11:19:10
| 2019-01-09T10:49:32
|
C
|
UTF-8
|
C
| false
| false
| 7,531
|
h
|
wrappedlibxcbtypes.h
|
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.0.0.11) *
*******************************************************************/
#ifndef __wrappedlibxcbTYPES_H_
#define __wrappedlibxcbTYPES_H_
#ifndef LIBNAME
#error You should only #include this file inside a wrapped*.c file
#endif
#ifndef ADDED_FUNCTIONS
#define ADDED_FUNCTIONS()
#endif
typedef my_xcb_cookie_t (*xFp_t)(void*);
typedef my_xcb_XXX_iterator_t (*XFp_t)(void*);
typedef my_xcb_cookie_t (*xFpC_t)(void*, uint8_t);
typedef my_xcb_cookie_t (*xFpu_t)(void*, uint32_t);
typedef my_xcb_cookie_t (*xFpp_t)(void*, void*);
typedef my_xcb_cookie_t (*xFpCC_t)(void*, uint8_t, uint8_t);
typedef my_xcb_cookie_t (*xFpup_t)(void*, uint32_t, void*);
typedef my_xcb_cookie_t (*xFppp_t)(void*, void*, void*);
typedef my_xcb_cookie_t (*xFpCWp_t)(void*, uint8_t, uint16_t, void*);
typedef my_xcb_cookie_t (*xFpCuW_t)(void*, uint8_t, uint32_t, uint16_t);
typedef my_xcb_cookie_t (*xFpCuu_t)(void*, uint8_t, uint32_t, uint32_t);
typedef my_xcb_cookie_t (*xFpuWp_t)(void*, uint32_t, uint16_t, void*);
typedef my_xcb_cookie_t (*xFpuuu_t)(void*, uint32_t, uint32_t, uint32_t);
typedef my_xcb_cookie_t (*xFpuup_t)(void*, uint32_t, uint32_t, void*);
typedef int32_t (*iFpppip_t)(void*, void*, void*, int32_t, void*);
typedef my_xcb_cookie_t (*xFpCuup_t)(void*, uint8_t, uint32_t, uint32_t, void*);
typedef my_xcb_cookie_t (*xFpCppp_t)(void*, uint8_t, void*, void*, void*);
typedef my_xcb_cookie_t (*xFpuWWW_t)(void*, uint32_t, uint16_t, uint16_t, uint16_t);
typedef my_xcb_cookie_t (*xFpuuWW_t)(void*, uint32_t, uint32_t, uint16_t, uint16_t);
typedef my_xcb_cookie_t (*xFpuuup_t)(void*, uint32_t, uint32_t, uint32_t, void*);
typedef my_xcb_cookie_t (*xFpCuuCC_t)(void*, uint8_t, uint32_t, uint32_t, uint8_t, uint8_t);
typedef my_xcb_cookie_t (*xFpCuuWW_t)(void*, uint8_t, uint32_t, uint32_t, uint16_t, uint16_t);
typedef my_xcb_cookie_t (*xFpCuuup_t)(void*, uint8_t, uint32_t, uint32_t, uint32_t, void*);
typedef my_xcb_cookie_t (*xFpuuuuu_t)(void*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
typedef my_xcb_cookie_t (*xFpCuwwWW_t)(void*, uint8_t, uint32_t, int16_t, int16_t, uint16_t, uint16_t);
typedef my_xcb_cookie_t (*xFpCuWCCC_t)(void*, uint8_t, uint32_t, uint16_t, uint8_t, uint8_t, uint8_t);
typedef my_xcb_cookie_t (*xFpCuuwwp_t)(void*, uint8_t, uint32_t, uint32_t, int16_t, int16_t, void*);
typedef my_xcb_cookie_t (*xFpCuuuuu_t)(void*, uint8_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
typedef my_xcb_cookie_t (*xFpCuwwWWu_t)(void*, uint8_t, uint32_t, int16_t, int16_t, uint16_t, uint16_t, uint32_t);
typedef my_xcb_cookie_t (*xFpCuuuCup_t)(void*, uint8_t, uint32_t, uint32_t, uint32_t, uint8_t, uint32_t, void*);
typedef my_xcb_cookie_t (*xFpCuWCCuuu_t)(void*, uint8_t, uint32_t, uint16_t, uint8_t, uint8_t, uint32_t, uint32_t, uint32_t);
typedef my_xcb_cookie_t (*xFpuuwwWWww_t)(void*, uint32_t, uint32_t, int16_t, int16_t, uint16_t, uint16_t, int16_t, int16_t);
typedef my_xcb_cookie_t (*xFpCuWCCuuCW_t)(void*, uint8_t, uint32_t, uint16_t, uint8_t, uint8_t, uint32_t, uint32_t, uint8_t, uint16_t);
typedef my_xcb_cookie_t (*xFpuuuwwwwWW_t)(void*, uint32_t, uint32_t, uint32_t, int16_t, int16_t, int16_t, int16_t, uint16_t, uint16_t);
typedef my_xcb_cookie_t (*xFpCuuWWwwCCup_t)(void*, uint8_t, uint32_t, uint32_t, uint16_t, uint16_t, int16_t, int16_t, uint8_t, uint8_t, uint32_t, void*);
typedef my_xcb_cookie_t (*xFpuuuWWWWWWWW_t)(void*, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t);
typedef my_xcb_cookie_t (*xFpCuuwwWWWWuup_t)(void*, uint8_t, uint32_t, uint32_t, int16_t, int16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint32_t, void*);
#define SUPER() ADDED_FUNCTIONS() \
GO(xcb_get_input_focus, xFp_t) \
GO(xcb_get_modifier_mapping, xFp_t) \
GO(xcb_grab_server, xFp_t) \
GO(xcb_ungrab_server, xFp_t) \
GO(xcb_depth_visuals_iterator, XFp_t) \
GO(xcb_screen_allowed_depths_iterator, XFp_t) \
GO(xcb_setup_pixmap_formats_iterator, XFp_t) \
GO(xcb_setup_roots_iterator, XFp_t) \
GO(xcb_bell, xFpC_t) \
GO(xcb_close_font, xFpu_t) \
GO(xcb_close_font_checked, xFpu_t) \
GO(xcb_destroy_window, xFpu_t) \
GO(xcb_free_colormap, xFpu_t) \
GO(xcb_free_colormap_checked, xFpu_t) \
GO(xcb_free_gc, xFpu_t) \
GO(xcb_free_pixmap, xFpu_t) \
GO(xcb_get_atom_name, xFpu_t) \
GO(xcb_get_geometry, xFpu_t) \
GO(xcb_get_geometry_unchecked, xFpu_t) \
GO(xcb_get_selection_owner, xFpu_t) \
GO(xcb_get_selection_owner_unchecked, xFpu_t) \
GO(xcb_get_window_attributes, xFpu_t) \
GO(xcb_get_window_attributes_unchecked, xFpu_t) \
GO(xcb_map_subwindows, xFpu_t) \
GO(xcb_map_window, xFpu_t) \
GO(xcb_map_window_checked, xFpu_t) \
GO(xcb_query_pointer, xFpu_t) \
GO(xcb_query_tree, xFpu_t) \
GO(xcb_query_tree_unchecked, xFpu_t) \
GO(xcb_ungrab_keyboard, xFpu_t) \
GO(xcb_ungrab_keyboard_checked, xFpu_t) \
GO(xcb_ungrab_pointer, xFpu_t) \
GO(xcb_unmap_window, xFpu_t) \
GO(xcb_free_cursor, xFpp_t) \
GO(xcb_no_operation, xFpp_t) \
GO(xcb_get_keyboard_mapping, xFpCC_t) \
GO(xcb_change_keyboard_control, xFpup_t) \
GO(xcb_delete_property, xFppp_t) \
GO(xcb_intern_atom, xFpCWp_t) \
GO(xcb_intern_atom_unchecked, xFpCWp_t) \
GO(xcb_ungrab_button, xFpCuW_t) \
GO(xcb_ungrab_button_checked, xFpCuW_t) \
GO(xcb_ungrab_key, xFpCuW_t) \
GO(xcb_ungrab_key_checked, xFpCuW_t) \
GO(xcb_set_input_focus, xFpCuu_t) \
GO(xcb_configure_window, xFpuWp_t) \
GO(xcb_open_font, xFpuWp_t) \
GO(xcb_open_font_checked, xFpuWp_t) \
GO(xcb_set_selection_owner, xFpuuu_t) \
GO(xcb_change_gc, xFpuup_t) \
GO(xcb_change_gc_checked, xFpuup_t) \
GO(xcb_change_window_attributes, xFpuup_t) \
GO(xcb_change_window_attributes_checked, xFpuup_t) \
GO(xcb_query_text_extents, xFpuup_t) \
GO(xcb_take_socket, iFpppip_t) \
GO(xcb_send_event, xFpCuup_t) \
GO(xcb_create_colormap, xFpCppp_t) \
GO(xcb_alloc_color, xFpuWWW_t) \
GO(xcb_reparent_window, xFpuuWW_t) \
GO(xcb_translate_coordinates, xFpuuWW_t) \
GO(xcb_translate_coordinates_unchecked, xFpuuWW_t) \
GO(xcb_create_gc, xFpuuup_t) \
GO(xcb_create_gc_checked, xFpuuup_t) \
GO(xcb_poly_arc, xFpuuup_t) \
GO(xcb_poly_fill_rectangle, xFpuuup_t) \
GO(xcb_poly_rectangle, xFpuuup_t) \
GO(xcb_poly_segment, xFpuuup_t) \
GO(xcb_grab_keyboard, xFpCuuCC_t) \
GO(xcb_create_pixmap, xFpCuuWW_t) \
GO(xcb_create_pixmap_checked, xFpCuuWW_t) \
GO(xcb_poly_line, xFpCuuup_t) \
GO(xcb_poly_line_checked, xFpCuuup_t) \
GO(xcb_poly_point, xFpCuuup_t) \
GO(xcb_convert_selection, xFpuuuuu_t) \
GO(xcb_clear_area, xFpCuwwWW_t) \
GO(xcb_grab_key, xFpCuWCCC_t) \
GO(xcb_grab_key_checked, xFpCuWCCC_t) \
GO(xcb_image_text_8, xFpCuuwwp_t) \
GO(xcb_image_text_8_checked, xFpCuuwwp_t) \
GO(xcb_get_property, xFpCuuuuu_t) \
GO(xcb_get_property_unchecked, xFpCuuuuu_t) \
GO(xcb_get_image, xFpCuwwWWu_t) \
GO(xcb_get_image_unchecked, xFpCuwwWWu_t) \
GO(xcb_change_property, xFpCuuuCup_t) \
GO(xcb_change_property_checked, xFpCuuuCup_t) \
GO(xcb_grab_pointer, xFpCuWCCuuu_t) \
GO(xcb_warp_pointer, xFpuuwwWWww_t) \
GO(xcb_grab_button, xFpCuWCCuuCW_t) \
GO(xcb_grab_button_checked, xFpCuWCCuuCW_t) \
GO(xcb_copy_area, xFpuuuwwwwWW_t) \
GO(xcb_copy_area_checked, xFpuuuwwwwWW_t) \
GO(xcb_put_image, xFpCuuWWwwCCup_t) \
GO(xcb_create_cursor, xFpuuuWWWWWWWW_t) \
GO(xcb_create_glyph_cursor, xFpuuuWWWWWWWW_t) \
GO(xcb_create_window, xFpCuuwwWWWWuup_t) \
GO(xcb_create_window_checked, xFpCuuwwWWWWuup_t)
#endif // __wrappedlibxcbTYPES_H_
|
5212ce8a673bb4e3962a9c337138ad1c684a1e4d
|
c26d7b0ed875357278e61627da2da0650da77986
|
/tools/virtualmips/utils.c
|
51c383b670b626fdd44f70bdffa3fcfe1c4db385
|
[
"BSD-3-Clause",
"GPL-1.0-or-later"
] |
permissive
|
RetroBSD/retrobsd
|
5343d9e3c424637fc3ad5b03fe720b2744490025
|
486f81f6abff01c7dcc207235cd2979b226a95ff
|
refs/heads/master
| 2023-09-02T23:12:05.110883
| 2023-07-07T18:41:40
| 2023-07-07T18:41:40
| 18,598,087
| 282
| 59
|
BSD-3-Clause
| 2023-07-18T07:35:36
| 2014-04-09T13:25:46
|
C
|
UTF-8
|
C
| false
| false
| 10,829
|
c
|
utils.c
|
/*
* Cisco router simulation platform.
* Copyright (c) 2005,2006 Christophe Fillot. All rights reserved.
*
* Utility functions.
*/
/*
* Copyright (C) yajin 2008 <yajinzhou@gmail.com >
*
* This file is part of the virtualmips distribution.
* See LICENSE file for terms of the license.
*
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <time.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#ifdef __CYGWIN__
#include <malloc.h>
#endif
#include "utils.h"
extern FILE *log_file;
unsigned int get_file_size (const char *file_path)
{
struct stat statbuf;
if (stat (file_path, &statbuf) == -1) {
printf ("Get stat on %s Error:%s\n", file_path, strerror (errno));
return (0);
}
if (S_ISDIR (statbuf.st_mode))
return (0);
if (S_ISREG (statbuf.st_mode))
return (statbuf.st_size);
return 0;
}
/* Dynamic sprintf */
char *dyn_sprintf (const char *fmt, ...)
{
int n, size = 512;
va_list ap;
char *p, *p2;
if ((p = malloc (size)) == NULL) {
perror ("dyn_sprintf: malloc");
return NULL;
}
for (;;) {
/* Try to print in the allocated space */
va_start (ap, fmt);
n = vsnprintf (p, size, fmt, ap);
va_end (ap);
/* If that worked, return the string */
if ((n > -1) && (n < size))
return p;
/* Else try again with more space. */
if (n > -1)
size = n + 1;
else
size *= 2;
free (p);
if ((p2 = malloc (size)) == NULL) {
perror ("dyn_sprintf: realloc");
return NULL;
}
p = p2;
}
free (p2);
}
/* Split a string */
int m_strsplit (char *str, char delim, char **array, int max_count)
{
int i, pos = 0;
size_t len;
char *ptr;
for (i = 0; i < max_count; i++)
array[i] = NULL;
do {
if (pos == max_count)
goto error;
ptr = strchr (str, delim);
if (!ptr)
ptr = str + strlen (str);
len = ptr - str;
if (!(array[pos] = malloc (len + 1)))
goto error;
memcpy (array[pos], str, len);
array[pos][len] = 0;
str = ptr + 1;
pos++;
}
while (*ptr);
return (pos);
error:
for (i = 0; i < max_count; i++)
free (array[i]);
return (-1);
}
/* Tokenize a string */
int m_strtok (char *str, char delim, char **array, int max_count)
{
int i, pos = 0;
size_t len;
char *ptr;
for (i = 0; i < max_count; i++)
array[i] = NULL;
do {
if (pos == max_count)
goto error;
ptr = strchr (str, delim);
if (!ptr)
ptr = str + strlen (str);
len = ptr - str;
if (!(array[pos] = malloc (len + 1)))
goto error;
memcpy (array[pos], str, len);
array[pos][len] = 0;
while (*ptr == delim)
ptr++;
str = ptr;
pos++;
}
while (*ptr);
return (pos);
error:
for (i = 0; i < max_count; i++)
free (array[i]);
return (-1);
}
/* Quote a string */
char *m_strquote (char *buffer, size_t buf_len, char *str)
{
char *p;
if (!(p = strpbrk (str, " \t\"'")))
return str;
snprintf (buffer, buf_len, "\"%s\"", str);
return buffer;
}
/* Ugly function that dumps a structure in hexa and ascii. */
void mem_dump (FILE * f_output, u_char * pkt, u_int len)
{
u_int x, i = 0, tmp;
while (i < len) {
if ((len - i) > 16)
x = 16;
else
x = len - i;
fprintf (f_output, "%4.4x: ", i);
for (tmp = 0; tmp < x; tmp++)
fprintf (f_output, "%2.2x ", pkt[i + tmp]);
for (tmp = x; tmp < 16; tmp++)
fprintf (f_output, " ");
for (tmp = 0; tmp < x; tmp++) {
char c = pkt[i + tmp];
if (((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))
|| ((c >= '0') && (c <= '9')))
fprintf (f_output, "%c", c);
else
fputs (".", f_output);
}
i += x;
fprintf (f_output, "\n");
}
fprintf (f_output, "\n");
}
/* Logging function */
void m_flog (FILE * fd, char *module, char *fmt, va_list ap)
{
struct timeval now;
static char buf[256];
time_t ct;
gettimeofday (&now, 0);
ct = now.tv_sec;
strftime (buf, sizeof (buf), "%b %d %H:%M:%S", localtime (&ct));
if (fd) {
fprintf (fd, "%s.%03ld %s: ", buf, (long) now.tv_usec / 1000, module);
vfprintf (fd, fmt, ap);
fflush (fd);
}
}
#if 0
/* Logging function */
void m_log (char *module, char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
m_flog (log_file, module, fmt, ap);
va_end (ap);
}
#endif
/* Returns a line from specified file (remove trailing '\n') */
char *m_fgets (char *buffer, int size, FILE * fd)
{
int len;
buffer[0] = '\0';
if (fgets (buffer, size, fd) == NULL)
return NULL;
len = strlen (buffer);
if (len == 0)
return NULL;
/* remove trailing '\n' */
if (buffer[len - 1] == '\n')
buffer[len - 1] = '\0';
return buffer;
}
/* Read a file and returns it in a buffer */
ssize_t m_read_file (char *filename, char **buffer)
{
char tmp[256], *ptr, *nptr;
size_t len, tot_len;
FILE *fd;
*buffer = ptr = NULL;
tot_len = 0;
/* Open file for reading */
if ((fd = fopen (filename, "r")) == NULL)
return (-1);
while ((len = fread (tmp, 1, sizeof (tmp), fd)) > 0) {
/* Reallocate memory */
nptr = realloc (ptr, tot_len + len + 1);
if (nptr == NULL) {
if (ptr)
free (ptr);
fclose (fd);
return (-1);
}
ptr = nptr;
/* Ok, memory could be allocated */
memcpy (&ptr[tot_len], tmp, len);
tot_len += len;
}
fclose (fd);
*buffer = ptr;
return (tot_len);
}
/* Allocate aligned memory */
void *m_memalign (size_t boundary, size_t size)
{
void *p;
#if defined(__linux__) || defined(__APPLE__)
if (posix_memalign ((void *) &p, boundary, size))
#else
#if defined(__CYGWIN__) || defined(SUNOS)
if (!(p = memalign (boundary, size)))
#else
if (!(p = malloc (size)))
#endif
#endif
return NULL;
assert (((m_iptr_t) p & (boundary - 1)) == 0);
return p;
}
/* Block specified signal for calling thread */
int m_signal_block (int sig)
{
sigset_t sig_mask;
sigemptyset (&sig_mask);
sigaddset (&sig_mask, sig);
return (pthread_sigmask (SIG_BLOCK, &sig_mask, NULL));
}
/* Unblock specified signal for calling thread */
int m_signal_unblock (int sig)
{
sigset_t sig_mask;
sigemptyset (&sig_mask);
sigaddset (&sig_mask, sig);
return (pthread_sigmask (SIG_UNBLOCK, &sig_mask, NULL));
}
/* Set non-blocking mode on a file descriptor */
int m_fd_set_non_block (int fd)
{
int flags;
if ((flags = fcntl (fd, F_GETFL, 0)) < 1)
return (-1);
return (fcntl (fd, F_SETFL, flags | O_NONBLOCK));
}
/* Map a memory zone from a file */
u_char *memzone_map_file (int fd, size_t len)
{
return (mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
(off_t) 0));
}
/* Map a memory zone from a file, with copy-on-write (COW) */
u_char *memzone_map_cow_file (int fd, size_t len)
{
return (mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd,
(off_t) 0));
}
/* Create a file to serve as a memory zone */
int memzone_create_file (char *filename, size_t len, u_char ** ptr)
{
int fd;
if ((fd = open (filename, O_CREAT | O_RDWR, S_IRWXU)) == -1) {
perror ("memzone_create_file: open");
return (-1);
}
if (ftruncate (fd, len) == -1) {
perror ("memzone_create_file: ftruncate");
close (fd);
return (-1);
}
*ptr = memzone_map_file (fd, len);
if (!*ptr) {
close (fd);
fd = -1;
}
return (fd);
}
/* Open a file to serve as a COW memory zone */
int memzone_open_cow_file (char *filename, size_t len, u_char ** ptr)
{
int fd;
if ((fd = open (filename, O_RDWR, S_IRWXU)) == -1) {
perror ("memzone_open_file: open");
return (-1);
}
*ptr = memzone_map_cow_file (fd, len);
if (!*ptr) {
close (fd);
fd = -1;
}
return (fd);
}
/* Open a file and map it in memory */
int memzone_open_file (char *filename, u_char ** ptr, off_t * fsize)
{
struct stat fprop;
int fd;
if ((fd = open (filename, O_RDWR, S_IRWXU)) == -1)
return (-1);
if (fstat (fd, &fprop) == -1)
goto err_fstat;
*fsize = fprop.st_size;
if (!(*ptr = memzone_map_file (fd, *fsize)))
goto err_mmap;
return (fd);
err_mmap:
err_fstat:
close (fd);
return (-1);
}
/* Compute NVRAM checksum */
m_uint16_t nvram_cksum (m_uint16_t * ptr, size_t count)
{
m_uint32_t sum = 0;
while (count > 1) {
sum = sum + ntohs (*ptr);
ptr++;
count -= sizeof (m_uint16_t);
}
if (count > 0)
sum = sum + ((ntohs (*ptr) & 0xFF) << 8);
while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);
return (~sum);
}
/* Byte-swap a memory block */
void mem_bswap32 (void *ptr, size_t len)
{
m_uint32_t *p = ptr;
size_t count = len >> 2;
int i;
for (i = 0; i < count; i++, p++)
*p = swap32 (*p);
}
/* Reverse a byte */
m_uint8_t m_reverse_u8 (m_uint8_t val)
{
m_uint8_t res = 0;
int i;
for (i = 0; i < 8; i++)
if (val & (1 << i))
res |= 1 << (7 - i);
return (res);
}
void SubstituteLLx (char *out, const char *text, int maxlen)
{
int i;
for (i = 0; i < maxlen && text[i]; i++) {
out[i] = text[i];
}
out[i] = text[i];
}
/*****************************************************************
* Debug
* Print a debug message, if flag is enabled. Like printf,
* only with an extra argument on the front.
* to output debug infomation , you should excute "simos -d [flag]"
****************************************************************/
void Debug (char flag, char *format, ...)
{
// if (DebugIsEnabled(flag)) {
char llformat[1024];
va_list ap;
va_start (ap, format);
SubstituteLLx (llformat, format, 1024);
/* Make this go to stderr also... */
vfprintf (stderr, llformat, ap);
//vCPUPrint(llformat, ap);
fprintf (stderr, "\r");
fflush (stderr);
va_end (ap);
//}
}
|
1ab88a2caaacef5ec8d0781109ea22267e8dba75
|
f47cb02269307e83d86373d9ab4bfb8b46283d22
|
/src/common/cursor.c
|
881ea15b37b03acd887aa2f63217156e8418d270
|
[
"Apache-2.0"
] |
permissive
|
apache/guacamole-server
|
7c8adf3f389f0539df353ef8f7ea6d44144ffb16
|
fe24e2d45ac0ac90588f64b43da6e0d518e59177
|
refs/heads/master
| 2023-09-04T02:42:34.907413
| 2023-08-30T22:57:11
| 2023-08-30T22:57:11
| 54,452,627
| 2,019
| 580
|
Apache-2.0
| 2023-09-13T00:15:57
| 2016-03-22T07:00:06
|
C
|
UTF-8
|
C
| false
| false
| 9,579
|
c
|
cursor.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.
*/
#include "common/blank_cursor.h"
#include "common/dot_cursor.h"
#include "common/cursor.h"
#include "common/ibar_cursor.h"
#include "common/pointer_cursor.h"
#include "common/surface.h"
#include <cairo/cairo.h>
#include <guacamole/client.h>
#include <guacamole/protocol.h>
#include <guacamole/socket.h>
#include <guacamole/timestamp.h>
#include <guacamole/user.h>
#include <pthread.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
/**
* Allocates a cursor as well as an image buffer where the cursor is rendered.
*
* @param client
* The client owning the cursor.
*
* @return
* The newly-allocated cursor or NULL if cursor cannot be allocated.
*/
guac_common_cursor* guac_common_cursor_alloc(guac_client* client) {
guac_common_cursor* cursor = malloc(sizeof(guac_common_cursor));
if (cursor == NULL)
return NULL;
/* Associate cursor with client and allocate cursor buffer */
cursor->client = client;
cursor->buffer = guac_client_alloc_buffer(client);
/* Allocate initial image buffer */
cursor->image_buffer_size = GUAC_COMMON_CURSOR_DEFAULT_SIZE;
cursor->image_buffer = malloc(cursor->image_buffer_size);
/* No cursor image yet */
cursor->width = 0;
cursor->height = 0;
cursor->surface = NULL;
cursor->hotspot_x = 0;
cursor->hotspot_y = 0;
/* No user has moved the mouse yet */
cursor->user = NULL;
cursor->timestamp = guac_timestamp_current();
/* Start cursor in upper-left */
cursor->x = 0;
cursor->y = 0;
pthread_mutex_init(&(cursor->_lock), NULL);
return cursor;
}
void guac_common_cursor_free(guac_common_cursor* cursor) {
pthread_mutex_destroy(&(cursor->_lock));
guac_client* client = cursor->client;
guac_layer* buffer = cursor->buffer;
cairo_surface_t* surface = cursor->surface;
/* Free image buffer and surface */
free(cursor->image_buffer);
if (surface != NULL)
cairo_surface_destroy(surface);
/* Destroy buffer within remotely-connected client */
guac_protocol_send_dispose(client->socket, buffer);
/* Return buffer to pool */
guac_client_free_buffer(client, buffer);
free(cursor);
}
void guac_common_cursor_dup(
guac_common_cursor* cursor, guac_client* client, guac_socket* socket) {
pthread_mutex_lock(&(cursor->_lock));
/* Synchronize location */
guac_protocol_send_mouse(socket, cursor->x, cursor->y, cursor->button_mask,
cursor->timestamp);
/* Synchronize cursor image */
if (cursor->surface != NULL) {
guac_protocol_send_size(socket, cursor->buffer,
cursor->width, cursor->height);
guac_client_stream_png(client, socket, GUAC_COMP_SRC,
cursor->buffer, 0, 0, cursor->surface);
guac_protocol_send_cursor(socket,
cursor->hotspot_x, cursor->hotspot_y,
cursor->buffer, 0, 0, cursor->width, cursor->height);
}
pthread_mutex_unlock(&(cursor->_lock));
guac_socket_flush(socket);
}
/**
* Callback for guac_client_foreach_user() which sends the current cursor
* position and button state to any given user except the user that moved the
* cursor last.
*
* @param data
* A pointer to the guac_common_cursor whose state should be broadcast to
* all users except the user that moved the cursor last.
*
* @return
* Always NULL.
*/
static void* guac_common_cursor_broadcast_state(guac_user* user,
void* data) {
guac_common_cursor* cursor = (guac_common_cursor*) data;
/* Send cursor state only if the user is not moving the cursor */
if (user != cursor->user) {
guac_protocol_send_mouse(user->socket, cursor->x, cursor->y,
cursor->button_mask, cursor->timestamp);
guac_socket_flush(user->socket);
}
return NULL;
}
void guac_common_cursor_update(guac_common_cursor* cursor, guac_user* user,
int x, int y, int button_mask) {
pthread_mutex_lock(&(cursor->_lock));
/* Update current user of cursor */
cursor->user = user;
/* Update cursor state */
cursor->x = x;
cursor->y = y;
cursor->button_mask = button_mask;
/* Store time at which cursor was updated */
cursor->timestamp = guac_timestamp_current();
/* Notify all other users of change in cursor state */
guac_client_foreach_user(cursor->client,
guac_common_cursor_broadcast_state, cursor);
pthread_mutex_unlock(&(cursor->_lock));
}
/**
* Ensures the cursor image buffer has enough room to fit an image with the
* given characteristics. Existing image buffer data may be destroyed.
*
* @param cursor
* The cursor whose buffer size should be checked. If this cursor lacks
* sufficient space to contain a cursor image of the specified width,
* height, and stride, the current contents of this cursor will be
* destroyed and replaced with an new buffer having sufficient space.
*
* @param width
* The required cursor width, in pixels.
*
* @param height
* The required cursor height, in pixels.
*
* @param stride
* The number of bytes in each row of image data.
*/
static void guac_common_cursor_resize(guac_common_cursor* cursor,
int width, int height, int stride) {
int minimum_size = height * stride;
/* Grow image buffer if necessary */
if (cursor->image_buffer_size < minimum_size) {
/* Calculate new size */
cursor->image_buffer_size = minimum_size*2;
/* Destructively reallocate image buffer */
free(cursor->image_buffer);
cursor->image_buffer = malloc(cursor->image_buffer_size);
}
}
void guac_common_cursor_set_argb(guac_common_cursor* cursor, int hx, int hy,
unsigned const char* data, int width, int height, int stride) {
pthread_mutex_lock(&(cursor->_lock));
/* Copy image data */
guac_common_cursor_resize(cursor, width, height, stride);
memcpy(cursor->image_buffer, data, height * stride);
if (cursor->surface != NULL)
cairo_surface_destroy(cursor->surface);
cursor->surface = cairo_image_surface_create_for_data(cursor->image_buffer,
CAIRO_FORMAT_ARGB32, width, height, stride);
/* Set new cursor parameters */
cursor->width = width;
cursor->height = height;
cursor->hotspot_x = hx;
cursor->hotspot_y = hy;
/* Broadcast new cursor image to all users */
guac_protocol_send_size(cursor->client->socket, cursor->buffer,
width, height);
guac_client_stream_png(cursor->client, cursor->client->socket,
GUAC_COMP_SRC, cursor->buffer, 0, 0, cursor->surface);
/* Update cursor image */
guac_protocol_send_cursor(cursor->client->socket,
cursor->hotspot_x, cursor->hotspot_y,
cursor->buffer, 0, 0, cursor->width, cursor->height);
guac_socket_flush(cursor->client->socket);
pthread_mutex_unlock(&(cursor->_lock));
}
void guac_common_cursor_set_surface(guac_common_cursor* cursor, int hx, int hy,
guac_common_surface* surface) {
/* Set cursor to surface contents */
guac_common_cursor_set_argb(cursor, hx, hy, surface->buffer,
surface->width, surface->height, surface->stride);
}
void guac_common_cursor_set_pointer(guac_common_cursor* cursor) {
guac_common_cursor_set_argb(cursor, 0, 0,
guac_common_pointer_cursor,
guac_common_pointer_cursor_width,
guac_common_pointer_cursor_height,
guac_common_pointer_cursor_stride);
}
void guac_common_cursor_set_dot(guac_common_cursor* cursor) {
guac_common_cursor_set_argb(cursor, 2, 2,
guac_common_dot_cursor,
guac_common_dot_cursor_width,
guac_common_dot_cursor_height,
guac_common_dot_cursor_stride);
}
void guac_common_cursor_set_ibar(guac_common_cursor* cursor) {
guac_common_cursor_set_argb(cursor,
guac_common_ibar_cursor_width / 2,
guac_common_ibar_cursor_height / 2,
guac_common_ibar_cursor,
guac_common_ibar_cursor_width,
guac_common_ibar_cursor_height,
guac_common_ibar_cursor_stride);
}
void guac_common_cursor_set_blank(guac_common_cursor* cursor) {
guac_common_cursor_set_argb(cursor, 0, 0,
guac_common_blank_cursor,
guac_common_blank_cursor_width,
guac_common_blank_cursor_height,
guac_common_blank_cursor_stride);
}
void guac_common_cursor_remove_user(guac_common_cursor* cursor,
guac_user* user) {
pthread_mutex_lock(&(cursor->_lock));
/* Disassociate from given user */
if (cursor->user == user)
cursor->user = NULL;
pthread_mutex_unlock(&(cursor->_lock));
}
|
5ecb6a5a4f528581c1a56d3506ae158a302d78c1
|
50dd46b8ece33f3cdd174284b15d1d51f89669d4
|
/third_party/edk2/StdLib/Include/sys/_posix.h
|
706cf7edb4a4129ede3628cd60b9bb07ebd3f047
|
[
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause",
"OpenSSL"
] |
permissive
|
google/google-ctf
|
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
|
df02323eaf945d15e124801c74abaadca2749dc7
|
refs/heads/master
| 2023-08-31T14:30:27.548081
| 2023-08-29T13:04:20
| 2023-08-29T13:04:20
| 131,317,137
| 4,136
| 607
|
Apache-2.0
| 2023-08-30T22:17:02
| 2018-04-27T15:56:03
|
Go
|
UTF-8
|
C
| false
| false
| 3,163
|
h
|
_posix.h
|
#ifndef _SYS__POSIX_H_
#define _SYS__POSIX_H_
/*-
* Copyright (c) 1998 HD Associates, Inc.
* All rights reserved.
* contact: dufault@hda.com
*
* 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 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 AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: _posix.h,v 1.1.1.1 2006/05/30 06:13:04 hhzhou Exp $
*/
/*
* This is a stand alone header file to set up for feature specification
* defined to take place before the inclusion of any standard header.
* It should only handle pre-processor defines.
*
* See section B.2.7 of 1003.1b-1993
*
*/
#ifdef KERNEL
#if !defined(ACTUALLY_LKM_NOT_KERNEL) && !defined(KLD_MODULE)
#include "opt_posix.h"
#endif
/* Only kern_mib.c uses _POSIX_VERSION. Introduce a kernel
* one to avoid other pieces of the kernel getting dependant
* on that.
* XXX Complain if you think this dumb.
*/
/* Make P1003 structures visible for the kernel if
* the P1003_1B option is in effect.
*/
#ifdef P1003_1B
#define _P1003_1B_VISIBLE
#ifndef _KPOSIX_VERSION
#define _KPOSIX_VERSION 199309L
#endif
#endif
#ifndef _KPOSIX_VERSION
#define _KPOSIX_VERSION 199009L
#endif
#define _P1003_1B_VISIBLE_HISTORICALLY
#else
/* Default to existing user space version.
*/
#ifndef _POSIX_VERSION
#define _POSIX_VERSION 199009L
#endif
/* Test for visibility of P1003.1B features:
* If _POSIX_SOURCE and POSIX_C_SOURCE are completely undefined
* they show up.
*
* If they specify a version including P1003.1B then they show up.
*
* (Two macros are added to permit hiding new extensions while
* keeping historic BSD features - that is not done now)
*
*/
#if (!defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)) || \
(_POSIX_VERSION >= 199309L && defined(_POSIX_C_SOURCE) && \
_POSIX_C_SOURCE >= 199309L)
#define _P1003_1B_VISIBLE
#define _P1003_1B_VISIBLE_HISTORICALLY
#endif
#endif /* not KERNEL */
#endif /* _SYS__POSIX_H_ */
|
d63dabc513507074bb50061e7bb560a98487ef9e
|
010279e2ba272d09e9d2c4e903722e5faba2cf7a
|
/contrib/tools/python3/src/Include/internal/pycore_signal.h
|
b921dd170e9f6fe726599557e7d0f4212aaa2f34
|
[
"Apache-2.0",
"LicenseRef-scancode-python-cwi",
"LicenseRef-scancode-other-copyleft",
"Python-2.0",
"BSD-3-Clause",
"0BSD",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown"
] |
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
| 937
|
h
|
pycore_signal.h
|
// Define Py_NSIG constant for signal handling.
#ifndef Py_INTERNAL_SIGNAL_H
#define Py_INTERNAL_SIGNAL_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include <signal.h> // NSIG
#ifdef _SIG_MAXSIG
// gh-91145: On FreeBSD, <signal.h> defines NSIG as 32: it doesn't include
// realtime signals: [SIGRTMIN,SIGRTMAX]. Use _SIG_MAXSIG instead. For
// example on x86-64 FreeBSD 13, SIGRTMAX is 126 and _SIG_MAXSIG is 128.
# define Py_NSIG _SIG_MAXSIG
#elif defined(NSIG)
# define Py_NSIG NSIG
#elif defined(_NSIG)
# define Py_NSIG _NSIG // BSD/SysV
#elif defined(_SIGMAX)
# define Py_NSIG (_SIGMAX + 1) // QNX
#elif defined(SIGMAX)
# define Py_NSIG (SIGMAX + 1) // djgpp
#else
# define Py_NSIG 64 // Use a reasonable default value
#endif
#ifdef __cplusplus
}
#endif
#endif // !Py_INTERNAL_SIGNAL_H
|
1becd5d31e5fbf457b88b4eac9e78f41317b12e9
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/fs/reiserfs/resize.c
|
3ce02cff5e90bd1c26374e12e15a6f56ea8c8803
|
[
"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
| 6,220
|
c
|
resize.c
|
/*
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
*/
/*
* Written by Alexander Zarochentcev.
*
* The kernel part of the (on-line) reiserfs resizer.
*/
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/string.h>
#include <linux/errno.h>
#include "reiserfs.h"
#include <linux/buffer_head.h>
int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
{
int err = 0;
struct reiserfs_super_block *sb;
struct reiserfs_bitmap_info *bitmap;
struct reiserfs_bitmap_info *info;
struct reiserfs_bitmap_info *old_bitmap = SB_AP_BITMAP(s);
struct buffer_head *bh;
struct reiserfs_transaction_handle th;
unsigned int bmap_nr_new, bmap_nr;
unsigned int block_r_new, block_r;
struct reiserfs_list_bitmap *jb;
struct reiserfs_list_bitmap jbitmap[JOURNAL_NUM_BITMAPS];
unsigned long int block_count, free_blocks;
int i;
int copy_size;
sb = SB_DISK_SUPER_BLOCK(s);
if (SB_BLOCK_COUNT(s) >= block_count_new) {
printk("can\'t shrink filesystem on-line\n");
return -EINVAL;
}
/* check the device size */
bh = sb_bread(s, block_count_new - 1);
if (!bh) {
printk("reiserfs_resize: can\'t read last block\n");
return -EINVAL;
}
bforget(bh);
/* old disk layout detection; those partitions can be mounted, but
* cannot be resized */
if (SB_BUFFER_WITH_SB(s)->b_blocknr * SB_BUFFER_WITH_SB(s)->b_size
!= REISERFS_DISK_OFFSET_IN_BYTES) {
printk
("reiserfs_resize: unable to resize a reiserfs without distributed bitmap (fs version < 3.5.12)\n");
return -ENOTSUPP;
}
/* count used bits in last bitmap block */
block_r = SB_BLOCK_COUNT(s) -
(reiserfs_bmap_count(s) - 1) * s->s_blocksize * 8;
/* count bitmap blocks in new fs */
bmap_nr_new = block_count_new / (s->s_blocksize * 8);
block_r_new = block_count_new - bmap_nr_new * s->s_blocksize * 8;
if (block_r_new)
bmap_nr_new++;
else
block_r_new = s->s_blocksize * 8;
/* save old values */
block_count = SB_BLOCK_COUNT(s);
bmap_nr = reiserfs_bmap_count(s);
/* resizing of reiserfs bitmaps (journal and real), if needed */
if (bmap_nr_new > bmap_nr) {
/* reallocate journal bitmaps */
if (reiserfs_allocate_list_bitmaps(s, jbitmap, bmap_nr_new) < 0) {
printk
("reiserfs_resize: unable to allocate memory for journal bitmaps\n");
return -ENOMEM;
}
/* the new journal bitmaps are zero filled, now we copy in the bitmap
** node pointers from the old journal bitmap structs, and then
** transfer the new data structures into the journal struct.
**
** using the copy_size var below allows this code to work for
** both shrinking and expanding the FS.
*/
copy_size = bmap_nr_new < bmap_nr ? bmap_nr_new : bmap_nr;
copy_size =
copy_size * sizeof(struct reiserfs_list_bitmap_node *);
for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
struct reiserfs_bitmap_node **node_tmp;
jb = SB_JOURNAL(s)->j_list_bitmap + i;
memcpy(jbitmap[i].bitmaps, jb->bitmaps, copy_size);
/* just in case vfree schedules on us, copy the new
** pointer into the journal struct before freeing the
** old one
*/
node_tmp = jb->bitmaps;
jb->bitmaps = jbitmap[i].bitmaps;
vfree(node_tmp);
}
/* allocate additional bitmap blocks, reallocate array of bitmap
* block pointers */
bitmap =
vzalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
if (!bitmap) {
/* Journal bitmaps are still supersized, but the memory isn't
* leaked, so I guess it's ok */
printk("reiserfs_resize: unable to allocate memory.\n");
return -ENOMEM;
}
for (i = 0; i < bmap_nr; i++)
bitmap[i] = old_bitmap[i];
/* This doesn't go through the journal, but it doesn't have to.
* The changes are still atomic: We're synced up when the journal
* transaction begins, and the new bitmaps don't matter if the
* transaction fails. */
for (i = bmap_nr; i < bmap_nr_new; i++) {
/* don't use read_bitmap_block since it will cache
* the uninitialized bitmap */
bh = sb_bread(s, i * s->s_blocksize * 8);
if (!bh) {
vfree(bitmap);
return -EIO;
}
memset(bh->b_data, 0, sb_blocksize(sb));
reiserfs_set_le_bit(0, bh->b_data);
reiserfs_cache_bitmap_metadata(s, bh, bitmap + i);
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
reiserfs_write_unlock(s);
sync_dirty_buffer(bh);
reiserfs_write_lock(s);
// update bitmap_info stuff
bitmap[i].free_count = sb_blocksize(sb) * 8 - 1;
brelse(bh);
}
/* free old bitmap blocks array */
SB_AP_BITMAP(s) = bitmap;
vfree(old_bitmap);
}
/* begin transaction, if there was an error, it's fine. Yes, we have
* incorrect bitmaps now, but none of it is ever going to touch the
* disk anyway. */
err = journal_begin(&th, s, 10);
if (err)
return err;
/* Extend old last bitmap block - new blocks have been made available */
info = SB_AP_BITMAP(s) + bmap_nr - 1;
bh = reiserfs_read_bitmap_block(s, bmap_nr - 1);
if (!bh) {
int jerr = journal_end(&th, s, 10);
if (jerr)
return jerr;
return -EIO;
}
reiserfs_prepare_for_journal(s, bh, 1);
for (i = block_r; i < s->s_blocksize * 8; i++)
reiserfs_clear_le_bit(i, bh->b_data);
info->free_count += s->s_blocksize * 8 - block_r;
journal_mark_dirty(&th, s, bh);
brelse(bh);
/* Correct new last bitmap block - It may not be full */
info = SB_AP_BITMAP(s) + bmap_nr_new - 1;
bh = reiserfs_read_bitmap_block(s, bmap_nr_new - 1);
if (!bh) {
int jerr = journal_end(&th, s, 10);
if (jerr)
return jerr;
return -EIO;
}
reiserfs_prepare_for_journal(s, bh, 1);
for (i = block_r_new; i < s->s_blocksize * 8; i++)
reiserfs_set_le_bit(i, bh->b_data);
journal_mark_dirty(&th, s, bh);
brelse(bh);
info->free_count -= s->s_blocksize * 8 - block_r_new;
/* update super */
reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
free_blocks = SB_FREE_BLOCKS(s);
PUT_SB_FREE_BLOCKS(s,
free_blocks + (block_count_new - block_count -
(bmap_nr_new - bmap_nr)));
PUT_SB_BLOCK_COUNT(s, block_count_new);
PUT_SB_BMAP_NR(s, bmap_would_wrap(bmap_nr_new) ? : bmap_nr_new);
journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
SB_JOURNAL(s)->j_must_wait = 1;
return journal_end(&th, s, 10);
}
|
c7c4a5ec4a649a9bb2c91fbe0ef0ecb8cb5e59e7
|
00613931db0dc1113d628b673b8a242fee684fac
|
/Core/Atom/AtomEcho/Arduino/StreamHttpClient_ECHO/src/libhelix-aac/sbrfft.c
|
23b36ac3451f94df1486448402879518800d1192
|
[
"LicenseRef-scancode-unknown-license-reference",
"GPL-3.0-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-proprietary-license",
"MIT"
] |
permissive
|
m5stack/M5-ProductExampleCodes
|
437b9413d92adb43c873149dd768da3d0b979869
|
1bc38736e61a362080d1dffc4020b3a2a1dff6ae
|
refs/heads/master
| 2022-09-16T07:38:54.184583
| 2022-07-21T01:05:46
| 2022-07-21T01:05:46
| 156,688,327
| 316
| 524
|
MIT
| 2022-07-21T01:05:47
| 2018-11-08T10:17:23
|
C
|
UTF-8
|
C
| false
| false
| 9,825
|
c
|
sbrfft.c
|
/* ***** BEGIN LICENSE BLOCK *****
* Source last modified: $Id: sbrfft.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $
*
* Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.
*
* The contents of this file, and the files included with this file,
* are subject to the current version of the RealNetworks Public
* Source License (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the current version of the RealNetworks Community
* Source License (the "RCSL") available at
* http://www.helixcommunity.org/content/rcsl, in which case the RCSL
* will apply. You may also obtain the license terms directly from
* RealNetworks. You may not use this file except in compliance with
* the RPSL or, if you have a valid RCSL with RealNetworks applicable
* to this file, the RCSL. Please see the applicable RPSL or RCSL for
* the rights, obligations and limitations governing use of the
* contents of the file.
*
* This file is part of the Helix DNA Technology. RealNetworks is the
* developer of the Original Code and owns the copyrights in the
* portions it created.
*
* This file, and the files included with this file, is distributed
* and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
* ENJOYMENT OR NON-INFRINGEMENT.
*
* Technology Compatibility Kit Test Suite(s) Location:
* http://www.helixcommunity.org/content/tck
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
/**************************************************************************************
* Fixed-point HE-AAC decoder
* Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
* February 2005
*
* sbrfft.c - optimized FFT for SBR QMF filters
**************************************************************************************/
#include "sbr.h"
#include "assembly.h"
#define SQRT1_2 0x5a82799a
/* swap RE{p0} with RE{p1} and IM{P0} with IM{P1} */
#define swapcplx(p0,p1) \
t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1
/* nfft = 32, hard coded since small, fixed size FFT
static const unsigned char bitrevtab32[9] = {
0x01, 0x04, 0x03, 0x06, 0x00, 0x02, 0x05, 0x07, 0x00,
};
*/
/* twiddle table for radix 4 pass, format = Q31 */
static const int twidTabOdd32[8*6] = {
0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59,
0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59,
0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060,
0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862,
0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862,
0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52,
};
/**************************************************************************************
* Function: BitReverse32
*
* Description: Ken's fast in-place bit reverse
*
* Inputs: buffer of 32 complex samples
*
* Outputs: bit-reversed samples in same buffer
*
* Return: none
**************************************************************************************/
static void BitReverse32(int *inout)
{
int t, t1;
swapcplx(inout[2], inout[32]);
swapcplx(inout[4], inout[16]);
swapcplx(inout[6], inout[48]);
swapcplx(inout[10], inout[40]);
swapcplx(inout[12], inout[24]);
swapcplx(inout[14], inout[56]);
swapcplx(inout[18], inout[36]);
swapcplx(inout[22], inout[52]);
swapcplx(inout[26], inout[44]);
swapcplx(inout[30], inout[60]);
swapcplx(inout[38], inout[50]);
swapcplx(inout[46], inout[58]);
}
/**************************************************************************************
* Function: R8FirstPass32
*
* Description: radix-8 trivial pass for decimation-in-time FFT (log2(N) = 5)
*
* Inputs: buffer of (bit-reversed) samples
*
* Outputs: processed samples in same buffer
*
* Return: none
*
* Notes: assumes 3 guard bits, gains 1 integer bit
* guard bits out = guard bits in - 3 (if inputs are full scale)
* or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2)
* see scaling comments in fft.c for base AAC
* should compile with no stack spills on ARM (verify compiled output)
* current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU
**************************************************************************************/
static void R8FirstPass32(int *r0)
{
int r1, r2, r3, r4, r5, r6, r7;
int r8, r9, r10, r11, r12, r14;
/* number of passes = fft size / 8 = 32 / 8 = 4 */
r1 = (32 >> 3);
do {
r2 = r0[8];
r3 = r0[9];
r4 = r0[10];
r5 = r0[11];
r6 = r0[12];
r7 = r0[13];
r8 = r0[14];
r9 = r0[15];
r10 = r2 + r4;
r11 = r3 + r5;
r12 = r6 + r8;
r14 = r7 + r9;
r2 -= r4;
r3 -= r5;
r6 -= r8;
r7 -= r9;
r4 = r2 - r7;
r5 = r2 + r7;
r8 = r3 - r6;
r9 = r3 + r6;
r2 = r4 - r9;
r3 = r4 + r9;
r6 = r5 - r8;
r7 = r5 + r8;
r2 = MULSHIFT32(SQRT1_2, r2); /* can use r4, r5, r8, or r9 for constant and lo32 scratch reg */
r3 = MULSHIFT32(SQRT1_2, r3);
r6 = MULSHIFT32(SQRT1_2, r6);
r7 = MULSHIFT32(SQRT1_2, r7);
r4 = r10 + r12;
r5 = r10 - r12;
r8 = r11 + r14;
r9 = r11 - r14;
r10 = r0[0];
r11 = r0[2];
r12 = r0[4];
r14 = r0[6];
r10 += r11;
r12 += r14;
r4 >>= 1;
r10 += r12;
r4 += (r10 >> 1);
r0[ 0] = r4;
r4 -= (r10 >> 1);
r4 = (r10 >> 1) - r4;
r0[ 8] = r4;
r9 >>= 1;
r10 -= 2*r12;
r4 = (r10 >> 1) + r9;
r0[ 4] = r4;
r4 = (r10 >> 1) - r9;
r0[12] = r4;
r10 += r12;
r10 -= 2*r11;
r12 -= 2*r14;
r4 = r0[1];
r9 = r0[3];
r11 = r0[5];
r14 = r0[7];
r4 += r9;
r11 += r14;
r8 >>= 1;
r4 += r11;
r8 += (r4 >> 1);
r0[ 1] = r8;
r8 -= (r4 >> 1);
r8 = (r4 >> 1) - r8;
r0[ 9] = r8;
r5 >>= 1;
r4 -= 2*r11;
r8 = (r4 >> 1) - r5;
r0[ 5] = r8;
r8 = (r4 >> 1) + r5;
r0[13] = r8;
r4 += r11;
r4 -= 2*r9;
r11 -= 2*r14;
r9 = r10 - r11;
r10 += r11;
r14 = r4 + r12;
r4 -= r12;
r5 = (r10 >> 1) + r7;
r8 = (r4 >> 1) - r6;
r0[ 2] = r5;
r0[ 3] = r8;
r5 = (r9 >> 1) - r2;
r8 = (r14 >> 1) - r3;
r0[ 6] = r5;
r0[ 7] = r8;
r5 = (r10 >> 1) - r7;
r8 = (r4 >> 1) + r6;
r0[10] = r5;
r0[11] = r8;
r5 = (r9 >> 1) + r2;
r8 = (r14 >> 1) + r3;
r0[14] = r5;
r0[15] = r8;
r0 += 16;
r1--;
} while (r1 != 0);
}
/**************************************************************************************
* Function: R4Core32
*
* Description: radix-4 pass for 32-point decimation-in-time FFT
*
* Inputs: buffer of samples
*
* Outputs: processed samples in same buffer
*
* Return: none
*
* Notes: gain 2 integer bits
* guard bits out = guard bits in - 1 (if inputs are full scale)
* see scaling comments in fft.c for base AAC
* uses 3-mul, 3-add butterflies instead of 4-mul, 2-add
* should compile with no stack spills on ARM (verify compiled output)
* current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU
**************************************************************************************/
static void R4Core32(int *r0)
{
int r2, r3, r4, r5, r6, r7;
int r8, r9, r10, r12, r14;
int *r1;
r1 = (int *)twidTabOdd32;
r10 = 8;
do {
/* can use r14 for lo32 scratch register in all MULSHIFT32 */
r2 = r1[0];
r3 = r1[1];
r4 = r0[16];
r5 = r0[17];
r12 = r4 + r5;
r12 = MULSHIFT32(r3, r12);
r5 = MULSHIFT32(r2, r5) + r12;
r2 += 2*r3;
r4 = MULSHIFT32(r2, r4) - r12;
r2 = r1[2];
r3 = r1[3];
r6 = r0[32];
r7 = r0[33];
r12 = r6 + r7;
r12 = MULSHIFT32(r3, r12);
r7 = MULSHIFT32(r2, r7) + r12;
r2 += 2*r3;
r6 = MULSHIFT32(r2, r6) - r12;
r2 = r1[4];
r3 = r1[5];
r8 = r0[48];
r9 = r0[49];
r12 = r8 + r9;
r12 = MULSHIFT32(r3, r12);
r9 = MULSHIFT32(r2, r9) + r12;
r2 += 2*r3;
r8 = MULSHIFT32(r2, r8) - r12;
r2 = r0[0];
r3 = r0[1];
r12 = r6 + r8;
r8 = r6 - r8;
r14 = r9 - r7;
r9 = r9 + r7;
r6 = (r2 >> 2) - r4;
r7 = (r3 >> 2) - r5;
r4 += (r2 >> 2);
r5 += (r3 >> 2);
r2 = r4 + r12;
r3 = r5 + r9;
r0[0] = r2;
r0[1] = r3;
r2 = r6 - r14;
r3 = r7 - r8;
r0[16] = r2;
r0[17] = r3;
r2 = r4 - r12;
r3 = r5 - r9;
r0[32] = r2;
r0[33] = r3;
r2 = r6 + r14;
r3 = r7 + r8;
r0[48] = r2;
r0[49] = r3;
r0 += 2;
r1 += 6;
r10--;
} while (r10 != 0);
}
/**************************************************************************************
* Function: FFT32C
*
* Description: Ken's very fast in-place radix-4 decimation-in-time FFT
*
* Inputs: buffer of 32 complex samples (before bit-reversal)
*
* Outputs: processed samples in same buffer
*
* Return: none
*
* Notes: assumes 3 guard bits in, gains 3 integer bits
* guard bits out = guard bits in - 2
* (guard bit analysis includes assumptions about steps immediately
* before and after, i.e. PreMul and PostMul for DCT)
**************************************************************************************/
void FFT32C(int *x)
{
/* decimation in time */
BitReverse32(x);
/* 32-point complex FFT */
R8FirstPass32(x); /* gain 1 int bit, lose 2 GB (making assumptions about input) */
R4Core32(x); /* gain 2 int bits, lose 0 GB (making assumptions about input) */
}
|
76d904e0b7c6ed33fddf07f0e888705bcfa0a2e3
|
ec99010e1c3d7960c1723dfe35b76c73cfbbfe22
|
/src/soft_tfidf.h
|
35689839cb28637d1aea61d6a8bba15082f9b203
|
[
"CC-BY-4.0",
"MIT"
] |
permissive
|
openvenues/libpostal
|
d8270049f45feccd1b961c65bb435d1b42d22db6
|
1fe1f0af1f328487e7397560e1b45beb6200ed85
|
refs/heads/master
| 2023-08-16T14:44:06.615711
| 2023-07-06T21:16:05
| 2023-07-06T21:16:05
| 31,570,906
| 3,876
| 466
|
MIT
| 2023-08-21T21:23:36
| 2015-03-03T00:21:31
|
C
|
UTF-8
|
C
| false
| false
| 2,270
|
h
|
soft_tfidf.h
|
#ifndef SOFT_TFIDF_H
#define SOFT_TFIDF_H
#include <stdlib.h>
#include "collections.h"
#include "libpostal.h"
#include "trie_search.h"
/*
This is a variant of Soft-TFIDF as described in:
Cohen, Ravikumar, and Fienberg. A comparison of string distance
metrics for name-matching tasks. (2003)
https://www.cs.cmu.edu/~wcohen/postscript/ijcai-ws-2003.pdf
Soft TFIDF is a hybrid similarity function for strings, typically names,
which combines both global statistics (TF-IDF) and a local similarity
function (e.g. Jaro-Winkler, which the authors suggest performs best).
Given two strings, s1 and s2, each token t1 in s1 is matched with its most
similar counterpart t2 in s2 according to the local distance function.
The Soft-TFIDF similarity is then the dot product of the max token
similarities and the cosine similarity of the TF-IDF vectors for all tokens
if the max similarity is >= a given threshold theta.
This version is a modified Soft-TFIDF. Jaro-Winkler is used as the secondary
distance metric. However, the defintion of two tokens being "similar" is
defined as either:
1. Jaro-Winkler distance >= theta
2. Damerau-Levenshtein edit distance <= max_edit_distance
3. Affine gap edit counts indicate a possible abbreviation (# matches == min(len1, len2))
*/
typedef struct soft_tfidf_options {
double jaro_winkler_min;
size_t jaro_winkler_min_length;
size_t damerau_levenshtein_max;
size_t damerau_levenshtein_min_length;
bool possible_affine_gap_abbreviations;
size_t strict_abbreviation_min_length;
double strict_abbreviation_sim;
} soft_tfidf_options_t;
soft_tfidf_options_t soft_tfidf_default_options(void);
double soft_tfidf_similarity_with_phrases_and_acronyms(size_t num_tokens1, char **tokens1, double *token_scores1, phrase_array *phrases1, uint32_array *ordinal_suffixes1, size_t num_tokens2, char **tokens2, double *token_scores2, phrase_array *phrases2, uint32_array *ordinal_suffixes2, phrase_array *acronym_alignments, phrase_array *multi_word_alignments, soft_tfidf_options_t options, size_t *num_matches);
double soft_tfidf_similarity(size_t num_tokens1, char **tokens1, double *token_scores1, size_t num_tokens2, char **tokens2, double *token_scores2, soft_tfidf_options_t options, size_t *num_matches);
#endif
|
258601dcd0316f7d9df075988e0bebf405f9ca91
|
5687d19cfa21bb81d1dc56067bc3f885e8c6459f
|
/Archived/cpplib_old_eroberts/cslib/winthread.c
|
64780e5ba06ca2285154c28f333afe8cdb9439ba
|
[] |
no_license
|
zelenski/stanford-cpp-library
|
f6215ab14d36c3a88a1756461734b0e0a8e3ac42
|
982e7169513136895baaf8f82c030a278987f840
|
refs/heads/master
| 2023-08-30T11:08:16.395851
| 2022-09-25T01:29:23
| 2022-09-25T01:29:23
| 13,291,163
| 221
| 73
| null | 2023-04-29T22:25:10
| 2013-10-03T05:28:09
|
HTML
|
UTF-8
|
C
| false
| false
| 6,361
|
c
|
winthread.c
|
/*
* File: winthread.c
* Last modified on Mon Oct 20 17:56:40 2008 by eroberts
* -----------------------------------------------------
* This file is the top-level file in the implementation of the
* thread.h interface using WIN32.
*/
#ifdef __WIN32__
#include <stdio.h>
#include <windows.h>
#include "exception.h"
#include "cslib.h"
#include "strlib.h"
#include "thread.h"
/* Constants */
#define MAX_AUTOMATIC_THREAD_NAME 30
/* Define the concrete type for a thread */
struct ThreadCDT {
DWORD id;
string name;
bool terminated;
Lock lock;
};
/* Define the concrete type for a lock */
struct LockCDT {
HANDLE mutex;
HANDLE semaphore;
HANDLE event;
bool exitFlag;
int waitingThreads;
int depth;
Thread owner;
};
/* Define a data block as a wrapper for the thread data */
typedef struct {
proc fn;
void *data;
Thread thread;
} *ThreadDataBlock;
/* Private variables */
static bool initialized = false;
static DWORD threadIndex;
static DWORD cbIndex;
/* Private function prototypes */
static void initThreadPackage(void);
static DWORD threadProc(LPVOID arg);
static void popLockException(void);
/* Section 1 - Functions on threads */
Thread forkThread(proc fn, void *data) {
Thread thread;
ThreadDataBlock data;
HANDLE threadHandle;
if (!initialized) initThreadPackage();
thread = newBlock(Thread);
thread->name = NULL;
thread->terminated = false;
thread->lock = newLock();
data = newBlock(ThreadDataBlock);
data->fn = fn;
data->data = data;
data->thread = thread;
threadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) threadProc,
data, 0, &thread->id);
if (threadHandle == 0) error("forkThread: Can't create new thread");
return thread;
}
void joinThread(Thread thread) {
if (thread->lock == NULL) {
error("joinThread: Can't join with the main thread");
}
synchronized (thread->lock) {
while (!thread->terminated) {
waitThread(thread->lock);
}
}
}
void yield(void) {
switchToThread();
}
Thread GetCurrentThread(void) {
Thread thread;
if (!initialized) initThreadPackage();
thread = (Thread) TlsGetValue(threadIndex);
if (thread == NULL) {
thread = newBlock(Thread);
thread->name = "Main";
thread->id = 0;
TlsSetValue(threadIndex, thread);
}
return thread;
}
void setThreadName(Thread thread, string name) {
thread->name = name;
}
string getThreadName(Thread thread) {
char buffer[MAX_AUTOMATIC_THREAD_NAME];
if (thread == NULL) return "NULL";
if (thread->name == NULL) {
sprintf(buffer, "Thread<%lu>", (long) thread->id);
thread->name = copyString(buffer);
}
return thread->name;
}
/* Section 2 - Functions on locks */
Lock newLock(void) {
Lock lock;
lock = newBlock(Lock);
lock->mutex = CreateMutex(NULL, false, NULL);
lock->semaphore = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);
lock->event = CreateEvent(NULL, false, false, NULL);
lock->exitFlag = false;
lock->waitingThreads = 0;
lock->depth = 0;
return lock;
}
void waitThread(Lock lock) {
lock->waitingThreads++;
signalObjectAndWait(lock->mutex, lock->semaphore, INFINITE, false);
lock->waitingThreads--;
if (lock->waitingThreads == 0) {
signalObjectAndWait(lock->event, lock->mutex, INFINITE, false);
} else {
waitForSingleObject(lock->mutex, INFINITE);
}
}
void signalThread(Lock lock) {
if (lock->waitingThreads > 0) {
ReleaseMutex(lock->mutex);
ReleaseSemaphore(lock->semaphore, lock->waitingThreads, 0);
waitForSingleObject(lock->event, INFINITE);
waitForSingleObject(lock->mutex, INFINITE);
}
}
void lockInternal(Lock lock) {
waitForSingleObject(lock->mutex, INFINITE);
if (lock->depth++ == 0) lock->owner = GetCurrentThread();
}
void unlockInternal(Lock lock) {
if (--lock->depth == 0) lock->owner = NULL;
ReleaseMutex(lock->mutex);
}
bool startSync(Lock lock) {
ExceptionContextBlock *xcb;
if (lock->exitFlag) {
lock->exitFlag = false;
popLockException();
return false;
}
lockInternal(lock);
xcb = newBlock(ExceptionContextBlock *);
xcb->lock = lock;
pushExceptionStack(xcb);
return true;
}
void XEndSync(Lock lock) {
lock->exitFlag = true;
}
Thread getOwner(Lock lock) {
return lock->owner;
}
/* Section 3 -- Internal interface to the exception module */
ExceptionContextBlock *XGetThreadSpecificStack(void) {
ExceptionContextBlock *stack;
if (!initialized) initThreadPackage();
stack = (ExceptionContextBlock *) TlsGetValue(cbIndex);
while (stack != NULL && stack->lock != NULL) {
popLockException();
stack = stack->link;
}
return stack;
}
void pushThreadSpecificStack(ExceptionContextBlock *cptr) {
ExceptionContextBlock *stack;
if (!initialized) initThreadPackage();
stack = (ExceptionContextBlock *) TlsGetValue(cbIndex);
cptr->link = stack;
TlsSetValue(cbIndex, cptr);
}
void popThreadSpecificStack(void) {
ExceptionContextBlock *stack;
if (!initialized) initThreadPackage();
stack = XGetThreadSpecificStack();
if (stack != NULL) stack = stack->link;
TlsSetValue(cbIndex, stack);
}
/* Private functions */
static void initThreadPackage(void) {
threadIndex = TlsAlloc();
cbIndex = TlsAlloc();
if (threadIndex == TLS_OUT_OF_INDEXES || cbIndex == TLS_OUT_OF_INDEXES) {
error("initThreadPackage: Out of thread storage");
}
initialized = true;
}
static DWORD threadProc(LPVOID arg) {
ThreadDataBlock data;
data = (ThreadDataBlock) arg;
if (!TlsSetValue(threadIndex, data->thread)) {
error("forkThread: Can't store thread identifier");
}
if (!TlsSetValue(cbIndex, NULL)) {
error("forkThread: Can't initialize exception handler chain");
}
data->fn(data->data);
synchronized (data->thread->lock) {
data->thread->terminated = true;
signalThread(data->thread->lock);
}
return 0;
}
static void popLockException(void) {
ExceptionContextBlock *stack;
if (!initialized) initThreadPackage();
stack = (ExceptionContextBlock *) TlsGetValue(cbIndex);
if (stack == NULL) error("popLockException: Internal error");
TlsSetValue(cbIndex, stack->link);
unlockInternal((Lock) stack->lock);
freeBlock(stack);
}
#endif
|
cb975061732aacd2c7fca557f804974be3c2eabd
|
c2942191a998e83b9d960cbfe256841687d22cb5
|
/common/math.h
|
672f04d77283447cc132e4b944e9abb20c8e2c80
|
[
"ISC"
] |
permissive
|
switchbrew/nx-hbmenu
|
e7cee8d3eba193a87e65173108b84f395e31b612
|
2c53af56cc9e4559276e7ca3efde853d96e2f151
|
refs/heads/master
| 2023-09-04T08:53:34.749971
| 2022-06-14T22:20:43
| 2022-06-14T22:20:43
| 121,178,203
| 1,196
| 203
|
ISC
| 2023-04-02T22:00:39
| 2018-02-11T23:31:59
|
C
|
UTF-8
|
C
| false
| false
| 158
|
h
|
math.h
|
#pragma once
#include "common.h"
float approxSin(float x);
static inline float clamp(float x, float min, float max) {
return fmin(fmax(x, min), max);
}
|
16e0aacd0eb463f283fedd277ff4a212c017f6db
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/lib/crc-t10dif.c
|
fbbd66ed86cde5ed7724ed8f17986cdf1a37edaa
|
[
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 2,965
|
c
|
crc-t10dif.c
|
/*
* T10 Data Integrity Field CRC16 calculation
*
* Copyright (c) 2007 Oracle Corporation. All rights reserved.
* Written by Martin K. Petersen <martin.petersen@oracle.com>
*
* This source code is licensed under the GNU General Public License,
* Version 2. See the file COPYING for more details.
*/
#include <linux/types.h>
#include <linux/module.h>
#include <linux/crc-t10dif.h>
/* Table generated using the following polynomium:
* x^16 + x^15 + x^11 + x^9 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
* gt: 0x8bb7
*/
static const __u16 t10_dif_crc_table[256] = {
0x0000, 0x8BB7, 0x9CD9, 0x176E, 0xB205, 0x39B2, 0x2EDC, 0xA56B,
0xEFBD, 0x640A, 0x7364, 0xF8D3, 0x5DB8, 0xD60F, 0xC161, 0x4AD6,
0x54CD, 0xDF7A, 0xC814, 0x43A3, 0xE6C8, 0x6D7F, 0x7A11, 0xF1A6,
0xBB70, 0x30C7, 0x27A9, 0xAC1E, 0x0975, 0x82C2, 0x95AC, 0x1E1B,
0xA99A, 0x222D, 0x3543, 0xBEF4, 0x1B9F, 0x9028, 0x8746, 0x0CF1,
0x4627, 0xCD90, 0xDAFE, 0x5149, 0xF422, 0x7F95, 0x68FB, 0xE34C,
0xFD57, 0x76E0, 0x618E, 0xEA39, 0x4F52, 0xC4E5, 0xD38B, 0x583C,
0x12EA, 0x995D, 0x8E33, 0x0584, 0xA0EF, 0x2B58, 0x3C36, 0xB781,
0xD883, 0x5334, 0x445A, 0xCFED, 0x6A86, 0xE131, 0xF65F, 0x7DE8,
0x373E, 0xBC89, 0xABE7, 0x2050, 0x853B, 0x0E8C, 0x19E2, 0x9255,
0x8C4E, 0x07F9, 0x1097, 0x9B20, 0x3E4B, 0xB5FC, 0xA292, 0x2925,
0x63F3, 0xE844, 0xFF2A, 0x749D, 0xD1F6, 0x5A41, 0x4D2F, 0xC698,
0x7119, 0xFAAE, 0xEDC0, 0x6677, 0xC31C, 0x48AB, 0x5FC5, 0xD472,
0x9EA4, 0x1513, 0x027D, 0x89CA, 0x2CA1, 0xA716, 0xB078, 0x3BCF,
0x25D4, 0xAE63, 0xB90D, 0x32BA, 0x97D1, 0x1C66, 0x0B08, 0x80BF,
0xCA69, 0x41DE, 0x56B0, 0xDD07, 0x786C, 0xF3DB, 0xE4B5, 0x6F02,
0x3AB1, 0xB106, 0xA668, 0x2DDF, 0x88B4, 0x0303, 0x146D, 0x9FDA,
0xD50C, 0x5EBB, 0x49D5, 0xC262, 0x6709, 0xECBE, 0xFBD0, 0x7067,
0x6E7C, 0xE5CB, 0xF2A5, 0x7912, 0xDC79, 0x57CE, 0x40A0, 0xCB17,
0x81C1, 0x0A76, 0x1D18, 0x96AF, 0x33C4, 0xB873, 0xAF1D, 0x24AA,
0x932B, 0x189C, 0x0FF2, 0x8445, 0x212E, 0xAA99, 0xBDF7, 0x3640,
0x7C96, 0xF721, 0xE04F, 0x6BF8, 0xCE93, 0x4524, 0x524A, 0xD9FD,
0xC7E6, 0x4C51, 0x5B3F, 0xD088, 0x75E3, 0xFE54, 0xE93A, 0x628D,
0x285B, 0xA3EC, 0xB482, 0x3F35, 0x9A5E, 0x11E9, 0x0687, 0x8D30,
0xE232, 0x6985, 0x7EEB, 0xF55C, 0x5037, 0xDB80, 0xCCEE, 0x4759,
0x0D8F, 0x8638, 0x9156, 0x1AE1, 0xBF8A, 0x343D, 0x2353, 0xA8E4,
0xB6FF, 0x3D48, 0x2A26, 0xA191, 0x04FA, 0x8F4D, 0x9823, 0x1394,
0x5942, 0xD2F5, 0xC59B, 0x4E2C, 0xEB47, 0x60F0, 0x779E, 0xFC29,
0x4BA8, 0xC01F, 0xD771, 0x5CC6, 0xF9AD, 0x721A, 0x6574, 0xEEC3,
0xA415, 0x2FA2, 0x38CC, 0xB37B, 0x1610, 0x9DA7, 0x8AC9, 0x017E,
0x1F65, 0x94D2, 0x83BC, 0x080B, 0xAD60, 0x26D7, 0x31B9, 0xBA0E,
0xF0D8, 0x7B6F, 0x6C01, 0xE7B6, 0x42DD, 0xC96A, 0xDE04, 0x55B3
};
__u16 crc_t10dif(const unsigned char *buffer, size_t len)
{
__u16 crc = 0;
unsigned int i;
for (i = 0 ; i < len ; i++)
crc = (crc << 8) ^ t10_dif_crc_table[((crc >> 8) ^ buffer[i]) & 0xff];
return crc;
}
EXPORT_SYMBOL(crc_t10dif);
MODULE_DESCRIPTION("T10 DIF CRC calculation");
MODULE_LICENSE("GPL");
|
cb582f59e9301b426b9cfabca526aba491014ee8
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/games/netradiant/files/patch-libs-math-vector.h
|
23f0dc1a97c7dd8fc7d36ee8a316d3c47bd6305b
|
[
"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
| 656
|
h
|
patch-libs-math-vector.h
|
--- libs/math/vector.h.orig 2013-06-30 22:04:34.000000000 +0800
+++ libs/math/vector.h 2013-09-06 20:03:32.000000000 +0800
@@ -45,27 +45,14 @@
return static_cast<__int64>( f + 0.5 );
}
-#elif defined( __FreeBSD__ )
+#else // lrint is part of ISO C99
-inline long lrint( double f ){
- return static_cast<long>( f + 0.5 );
-}
-
-inline long long llrint( double f ){
- return static_cast<long long>( f + 0.5 );
-}
-
-#elif defined( __GNUC__ )
-
-// lrint is part of ISO C99
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC9X 1
#define __USE_ISOC99 1
-#else
-#error "unsupported platform"
#endif
#include <cmath>
|
ed1fc0d9c98255e0adf3e51d3a8578cc5b331194
|
e910318d01528d82040507a49eeeb8dade45b31f
|
/extmod/network_cyw43.c
|
adbe427b1dffc27457bfbd130f3c742cd2c0f7a3
|
[
"MIT"
] |
permissive
|
pfalcon/pycopy
|
e844480a5e5cd463530328889daed2ba87552b8a
|
3ac90ae9c3c6bbebfba9cada2d37025e35c62796
|
refs/heads/pfalcon
| 2023-08-30T09:39:52.290147
| 2022-09-08T16:42:38
| 2022-09-08T16:42:38
| 15,507,576
| 753
| 71
|
MIT
| 2021-05-08T04:59:21
| 2013-12-29T11:38:47
|
C
|
UTF-8
|
C
| false
| false
| 18,892
|
c
|
network_cyw43.c
|
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018-2019 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include "py/runtime.h"
#include "py/objstr.h"
#include "py/mphal.h"
#if MICROPY_PY_NETWORK_CYW43
#include "lwip/netif.h"
#include "drivers/cyw43/cyw43.h"
#include "extmod/network_cyw43.h"
#include "modnetwork.h"
typedef struct _network_cyw43_obj_t {
mp_obj_base_t base;
cyw43_t *cyw;
int itf;
} network_cyw43_obj_t;
STATIC const network_cyw43_obj_t network_cyw43_wl0 = { { &mp_network_cyw43_type }, &cyw43_state, 0 };
STATIC const network_cyw43_obj_t network_cyw43_wl1 = { { &mp_network_cyw43_type }, &cyw43_state, 1 };
STATIC void network_cyw43_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
struct netif *netif = &self->cyw->netif[self->itf];
int status = cyw43_tcpip_link_status(self->cyw, self->itf);
const char *status_str;
if (status == CYW43_LINK_DOWN) {
status_str = "down";
} else if (status == CYW43_LINK_JOIN || status == CYW43_LINK_NOIP) {
status_str = "join";
} else if (status == CYW43_LINK_UP) {
status_str = "up";
} else if (status == CYW43_LINK_NONET) {
status_str = "nonet";
} else if (status == CYW43_LINK_BADAUTH) {
status_str = "badauth";
} else {
status_str = "fail";
}
mp_printf(print, "<CYW43 %s %s %u.%u.%u.%u>",
self->itf == 0 ? "STA" : "AP",
status_str,
netif->ip_addr.addr & 0xff,
netif->ip_addr.addr >> 8 & 0xff,
netif->ip_addr.addr >> 16 & 0xff,
netif->ip_addr.addr >> 24
);
}
STATIC mp_obj_t network_cyw43_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 0, 1, false);
if (n_args == 0 || mp_obj_get_int(args[0]) == 0) {
return MP_OBJ_FROM_PTR(&network_cyw43_wl0);
} else {
return MP_OBJ_FROM_PTR(&network_cyw43_wl1);
}
}
STATIC mp_obj_t network_cyw43_send_ethernet(mp_obj_t self_in, mp_obj_t buf_in) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_buffer_info_t buf;
mp_get_buffer_raise(buf_in, &buf, MP_BUFFER_READ);
int ret = cyw43_send_ethernet(self->cyw, self->itf, buf.len, buf.buf, false);
if (ret) {
mp_raise_OSError(-ret);
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(network_cyw43_send_ethernet_obj, network_cyw43_send_ethernet);
STATIC mp_obj_t network_cyw43_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t buf_in) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_buffer_info_t buf;
mp_get_buffer_raise(buf_in, &buf, MP_BUFFER_READ | MP_BUFFER_WRITE);
cyw43_ioctl(self->cyw, mp_obj_get_int(cmd_in), buf.len, buf.buf, self->itf);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(network_cyw43_ioctl_obj, network_cyw43_ioctl);
/*******************************************************************************/
// network API
STATIC mp_obj_t network_cyw43_deinit(mp_obj_t self_in) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
cyw43_deinit(self->cyw);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(network_cyw43_deinit_obj, network_cyw43_deinit);
STATIC mp_obj_t network_cyw43_active(size_t n_args, const mp_obj_t *args) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(args[0]);
if (n_args == 1) {
return mp_obj_new_bool(cyw43_tcpip_link_status(self->cyw, self->itf));
} else {
cyw43_wifi_set_up(self->cyw, self->itf, mp_obj_is_true(args[1]));
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_cyw43_active_obj, 1, 2, network_cyw43_active);
STATIC int network_cyw43_scan_cb(void *env, const cyw43_ev_scan_result_t *res) {
mp_obj_t list = MP_OBJ_FROM_PTR(env);
// Search for existing BSSID to remove duplicates
bool found = false;
size_t len;
mp_obj_t *items;
mp_obj_get_array(list, &len, &items);
for (size_t i = 0; i < len; ++i) {
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(items[i]);
if (memcmp(res->bssid, ((mp_obj_str_t *)MP_OBJ_TO_PTR(t->items[1]))->data, sizeof(res->bssid)) == 0) {
if (res->rssi > MP_OBJ_SMALL_INT_VALUE(t->items[3])) {
t->items[3] = MP_OBJ_NEW_SMALL_INT(res->rssi);
}
t->items[5] = MP_OBJ_NEW_SMALL_INT(MP_OBJ_SMALL_INT_VALUE(t->items[5]) + 1);
found = true;
break;
}
}
// Add to list of results if wanted
if (!found) {
mp_obj_t tuple[6] = {
mp_obj_new_bytes(res->ssid, res->ssid_len),
mp_obj_new_bytes(res->bssid, sizeof(res->bssid)),
MP_OBJ_NEW_SMALL_INT(res->channel),
MP_OBJ_NEW_SMALL_INT(res->rssi),
MP_OBJ_NEW_SMALL_INT(res->auth_mode),
// mp_const_false, // hidden
MP_OBJ_NEW_SMALL_INT(1), // N
};
mp_obj_list_append(list, mp_obj_new_tuple(6, tuple));
}
return 0; // continue scan
}
STATIC mp_obj_t network_cyw43_scan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_passive, ARG_essid, ARG_bssid };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_passive, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_essid, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
{ MP_QSTR_bssid, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
};
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
cyw43_wifi_scan_options_t opts;
opts.scan_type = args[ARG_passive].u_bool ? 1 : 0;
if (args[ARG_essid].u_obj == mp_const_none) {
opts.ssid_len = 0;
} else {
mp_buffer_info_t ssid;
mp_get_buffer_raise(args[ARG_essid].u_obj, &ssid, MP_BUFFER_READ);
opts.ssid_len = MIN(ssid.len, sizeof(opts.ssid));
memcpy(opts.ssid, ssid.buf, opts.ssid_len);
}
if (args[ARG_bssid].u_obj == mp_const_none) {
memset(opts.bssid, 0xff, sizeof(opts.bssid));
} else {
mp_buffer_info_t bssid;
mp_get_buffer_raise(args[ARG_bssid].u_obj, &bssid, MP_BUFFER_READ);
memcpy(opts.bssid, bssid.buf, sizeof(opts.bssid));
}
mp_obj_t res = mp_obj_new_list(0, NULL);
int scan_res = cyw43_wifi_scan(self->cyw, &opts, MP_OBJ_TO_PTR(res), network_cyw43_scan_cb);
if (scan_res < 0) {
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("STA must be active"));
}
// Wait for scan to finish, with a 10s timeout
uint32_t start = mp_hal_ticks_ms();
while (cyw43_wifi_scan_active(self->cyw) && mp_hal_ticks_ms() - start < 10000) {
MICROPY_EVENT_POLL_HOOK
}
return res;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(network_cyw43_scan_obj, 1, network_cyw43_scan);
STATIC mp_obj_t network_cyw43_connect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_essid, ARG_key, ARG_auth, ARG_bssid, ARG_channel };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_essid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
{ MP_QSTR_key, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
{ MP_QSTR_auth, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
{ MP_QSTR_bssid, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
{ MP_QSTR_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
};
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_buffer_info_t ssid;
mp_get_buffer_raise(args[ARG_essid].u_obj, &ssid, MP_BUFFER_READ);
mp_buffer_info_t key;
key.buf = NULL;
if (args[ARG_key].u_obj != mp_const_none) {
mp_get_buffer_raise(args[ARG_key].u_obj, &key, MP_BUFFER_READ);
}
mp_buffer_info_t bssid;
bssid.buf = NULL;
if (args[ARG_bssid].u_obj != mp_const_none) {
mp_get_buffer_raise(args[ARG_bssid].u_obj, &bssid, MP_BUFFER_READ);
if (bssid.len != 6) {
mp_raise_ValueError(NULL);
}
}
int ret = cyw43_wifi_join(self->cyw, ssid.len, ssid.buf, key.len, key.buf, args[ARG_auth].u_int, bssid.buf, args[ARG_channel].u_int);
if (ret != 0) {
mp_raise_OSError(ret);
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(network_cyw43_connect_obj, 1, network_cyw43_connect);
STATIC mp_obj_t network_cyw43_disconnect(mp_obj_t self_in) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
cyw43_wifi_leave(self->cyw, self->itf);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(network_cyw43_disconnect_obj, network_cyw43_disconnect);
STATIC mp_obj_t network_cyw43_isconnected(mp_obj_t self_in) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
return mp_obj_new_bool(cyw43_tcpip_link_status(self->cyw, self->itf) == 3);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(network_cyw43_isconnected_obj, network_cyw43_isconnected);
STATIC mp_obj_t network_cyw43_ifconfig(size_t n_args, const mp_obj_t *args) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(args[0]);
return mod_network_nic_ifconfig(&self->cyw->netif[self->itf], n_args - 1, args + 1);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_cyw43_ifconfig_obj, 1, 2, network_cyw43_ifconfig);
STATIC mp_obj_t network_cyw43_status(size_t n_args, const mp_obj_t *args) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(args[0]);
(void)self;
if (n_args == 1) {
// no arguments: return link status
return MP_OBJ_NEW_SMALL_INT(cyw43_tcpip_link_status(self->cyw, self->itf));
}
// one argument: return status based on query parameter
switch (mp_obj_str_get_qstr(args[1])) {
case MP_QSTR_stations: {
// return list of connected stations
if (self->itf != CYW43_ITF_AP) {
mp_raise_ValueError(MP_ERROR_TEXT("AP required"));
}
int num_stas;
uint8_t macs[32 * 6];
cyw43_wifi_ap_get_stas(self->cyw, &num_stas, macs);
mp_obj_t list = mp_obj_new_list(num_stas, NULL);
for (int i = 0; i < num_stas; ++i) {
mp_obj_t tuple[1] = {
mp_obj_new_bytes(&macs[i * 6], 6),
};
((mp_obj_list_t *)MP_OBJ_TO_PTR(list))->items[i] = mp_obj_new_tuple(1, tuple);
}
return list;
}
}
mp_raise_ValueError(MP_ERROR_TEXT("unknown status param"));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_cyw43_status_obj, 1, 2, network_cyw43_status);
static inline uint32_t nw_get_le32(const uint8_t *buf) {
return buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24;
}
static inline void nw_put_le32(uint8_t *buf, uint32_t x) {
buf[0] = x;
buf[1] = x >> 8;
buf[2] = x >> 16;
buf[3] = x >> 24;
}
STATIC mp_obj_t network_cyw43_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(args[0]);
if (kwargs->used == 0) {
// Get config value
if (n_args != 2) {
mp_raise_TypeError(MP_ERROR_TEXT("must query one param"));
}
switch (mp_obj_str_get_qstr(args[1])) {
case MP_QSTR_antenna: {
uint8_t buf[4];
cyw43_ioctl(self->cyw, CYW43_IOCTL_GET_ANTDIV, 4, buf, self->itf);
return MP_OBJ_NEW_SMALL_INT(nw_get_le32(buf));
}
case MP_QSTR_channel: {
uint8_t buf[4];
cyw43_ioctl(self->cyw, CYW43_IOCTL_GET_CHANNEL, 4, buf, self->itf);
return MP_OBJ_NEW_SMALL_INT(nw_get_le32(buf));
}
case MP_QSTR_essid: {
if (self->itf == CYW43_ITF_STA) {
uint8_t buf[36];
cyw43_ioctl(self->cyw, CYW43_IOCTL_GET_SSID, 36, buf, self->itf);
return mp_obj_new_str((const char *)buf + 4, nw_get_le32(buf));
} else {
size_t len;
const uint8_t *buf;
cyw43_wifi_ap_get_ssid(self->cyw, &len, &buf);
return mp_obj_new_str((const char *)buf, len);
}
}
case MP_QSTR_mac: {
uint8_t buf[6];
cyw43_wifi_get_mac(self->cyw, self->itf, buf);
return mp_obj_new_bytes(buf, 6);
}
case MP_QSTR_txpower: {
uint8_t buf[13];
memcpy(buf, "qtxpower\x00\x00\x00\x00\x00", 13);
cyw43_ioctl(self->cyw, CYW43_IOCTL_GET_VAR, 13, buf, self->itf);
return MP_OBJ_NEW_SMALL_INT(nw_get_le32(buf) / 4);
}
default:
mp_raise_ValueError(MP_ERROR_TEXT("unknown config param"));
}
} else {
// Set config value(s)
if (n_args != 1) {
mp_raise_TypeError(MP_ERROR_TEXT("can't specify pos and kw args"));
}
for (size_t i = 0; i < kwargs->alloc; ++i) {
if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) {
mp_map_elem_t *e = &kwargs->table[i];
switch (mp_obj_str_get_qstr(e->key)) {
case MP_QSTR_antenna: {
uint8_t buf[4];
nw_put_le32(buf, mp_obj_get_int(e->value));
cyw43_ioctl(self->cyw, CYW43_IOCTL_SET_ANTDIV, 4, buf, self->itf);
break;
}
case MP_QSTR_channel: {
cyw43_wifi_ap_set_channel(self->cyw, mp_obj_get_int(e->value));
break;
}
case MP_QSTR_essid: {
size_t len;
const char *str = mp_obj_str_get_data(e->value, &len);
cyw43_wifi_ap_set_ssid(self->cyw, len, (const uint8_t *)str);
break;
}
case MP_QSTR_monitor: {
mp_int_t value = mp_obj_get_int(e->value);
uint8_t buf[9 + 4];
memcpy(buf, "allmulti\x00", 9);
nw_put_le32(buf + 9, value);
cyw43_ioctl(self->cyw, CYW43_IOCTL_SET_VAR, 9 + 4, buf, self->itf);
nw_put_le32(buf, value);
cyw43_ioctl(self->cyw, CYW43_IOCTL_SET_MONITOR, 4, buf, self->itf);
if (value) {
self->cyw->trace_flags |= CYW43_TRACE_MAC;
} else {
self->cyw->trace_flags &= ~CYW43_TRACE_MAC;
}
break;
}
case MP_QSTR_password: {
size_t len;
const char *str = mp_obj_str_get_data(e->value, &len);
cyw43_wifi_ap_set_password(self->cyw, len, (const uint8_t *)str);
break;
}
case MP_QSTR_pm: {
cyw43_wifi_pm(self->cyw, mp_obj_get_int(e->value));
break;
}
case MP_QSTR_trace: {
self->cyw->trace_flags = mp_obj_get_int(e->value);
break;
}
case MP_QSTR_txpower: {
mp_int_t dbm = mp_obj_get_int(e->value);
uint8_t buf[9 + 4];
memcpy(buf, "qtxpower\x00", 9);
nw_put_le32(buf + 9, dbm * 4);
cyw43_ioctl(self->cyw, CYW43_IOCTL_SET_VAR, 9 + 4, buf, self->itf);
break;
}
default:
mp_raise_ValueError(MP_ERROR_TEXT("unknown config param"));
}
}
}
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(network_cyw43_config_obj, 1, network_cyw43_config);
/*******************************************************************************/
// class bindings
STATIC const mp_rom_map_elem_t network_cyw43_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_send_ethernet), MP_ROM_PTR(&network_cyw43_send_ethernet_obj) },
{ MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&network_cyw43_ioctl_obj) },
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&network_cyw43_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_active), MP_ROM_PTR(&network_cyw43_active_obj) },
{ MP_ROM_QSTR(MP_QSTR_scan), MP_ROM_PTR(&network_cyw43_scan_obj) },
{ MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&network_cyw43_connect_obj) },
{ MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&network_cyw43_disconnect_obj) },
{ MP_ROM_QSTR(MP_QSTR_isconnected), MP_ROM_PTR(&network_cyw43_isconnected_obj) },
{ MP_ROM_QSTR(MP_QSTR_ifconfig), MP_ROM_PTR(&network_cyw43_ifconfig_obj) },
{ MP_ROM_QSTR(MP_QSTR_status), MP_ROM_PTR(&network_cyw43_status_obj) },
{ MP_ROM_QSTR(MP_QSTR_config), MP_ROM_PTR(&network_cyw43_config_obj) },
};
STATIC MP_DEFINE_CONST_DICT(network_cyw43_locals_dict, network_cyw43_locals_dict_table);
const mp_obj_type_t mp_network_cyw43_type = {
{ &mp_type_type },
.name = MP_QSTR_CYW43,
.print = network_cyw43_print,
.make_new = network_cyw43_make_new,
.locals_dict = (mp_obj_dict_t *)&network_cyw43_locals_dict,
};
#endif // MICROPY_PY_NETWORK_CYW43
|
0708c827d60b5b37a5a32cdedd4acc627f312ecc
|
64f63e6468d7d1a8239ca8a60cb3a57671d7026e
|
/src/sysmem/sysmem.h
|
14a5a22bafc06ac4182b2bd012c92ce4f90383da
|
[
"BSD-3-Clause",
"MIT"
] |
permissive
|
uofw/uofw
|
511c6877af464a4c18cd62405805ed92b15b39c3
|
c517e4cee6679cf2c0ecb24afaa50a86c6460cf1
|
refs/heads/master
| 2023-02-09T17:10:03.719610
| 2023-02-03T13:11:50
| 2023-02-03T13:11:50
| 6,622,246
| 312
| 93
|
NOASSERTION
| 2023-09-05T19:54:15
| 2012-11-09T23:39:19
|
C
|
UTF-8
|
C
| false
| false
| 3,443
|
h
|
sysmem.h
|
#ifndef SYSMEM_H
#define SYSMEM_H
#include <sysmem_kernel.h>
/*
'->' means it uses a chained list ('->' for single-chained, '<->' for double-chained)
+-------+
+---------| Heap | A heap. Has an UID, name "SceSysmemHeap"
| +-------+ The main one is named "SceSystemMemoryManager". Allocated in a partition.
| |
| v
| +---------+ +-------+
| | First | | |
| ...<->| Heap |<->| Heap |<->... SceSysmemHeapBlock (note: this may be the "Lowheap" from Sony)
| | Block | | Block | These blocks are created as soon as the others can't hold something else from _AllocHeapMemory()
| +---------+ +-------+
| | Lowheap |
| | with | SceSysmemLowheap
| | the info|
| +---------+
| | First | SceSysmemLowheapBlock
| +-->| lowheap | (patterns may be different in complex cases)
| | | block |
| | +---------+
| | .
| | .
| | .
| | +---------+
| | | Last |
| +-->| lowheap |
| | block |
| +---------+
|
+---------+ (no pointer here, but partition id + address + size)
v
+-----------+ +-----------+ +-----------+
| | | | | |
...| Partition |->| Partition |->| Partition |... partitions created through sceKernelCreateMemoryPartition() (SceSysmemMemoryPartition)
| | | | | | Most created by the kernel. Has an UID, name "SceSysmemMemoryPartition"
+-----------+ +-----------+ +-----------+
^ |
+---------------+ |
| v
| +-----------------+ +---------------+
| | (First) | | |
| ...<->| Control block |<->| Control block |<-> ... SceSysmemCtlBlk
| | 30 segments | | 30 segments |
| +-----------------+ +---------------+
| |
| v
| +---------------------+
| | |
| | 1 of the 30 segments| SceSysmemSeg
| | |
| +---------------------+
|
| +------------------------+
| | |
+-------| Block | blocks created through sceKernelAllocPartitionMemory() (SceSysmemMemoryBlock)
| Only holds size & addr | Has an UID, name "SceSysMemMemoryBlock"
+------------------------+ Some kind of "interface" to the SceSysmemSeg, without the internal information
*/
typedef struct {
u32 addr;
u32 size;
} SceSysmemPartInfo;
typedef struct {
u32 memSize;
u32 unk4;
u32 unk8;
SceSysmemPartInfo other1; // 12
SceSysmemPartInfo other2; // 20
SceSysmemPartInfo vshell; // 28
SceSysmemPartInfo scUser; // 36
SceSysmemPartInfo meUser; // 44
SceSysmemPartInfo extSc2Kernel; // 52
SceSysmemPartInfo extScKernel; // 60
SceSysmemPartInfo extMeKernel; // 68
SceSysmemPartInfo extVshell; // 76
} SceSysmemPartTable;
s32 *wmemset(s32 *src, s32 c, u32 n);
#endif
|
63466021251cfd03c1878bb994979768fc178a34
|
431a5c28b8dfcc7d6ca6f4f97bf370cd770547a7
|
/src/tmx/Asn_J2735/include/asn_j2735_r63/PayloadData.h
|
e8a2663107488c01b7a44bbf9a9351cb105d28e9
|
[
"Apache-2.0"
] |
permissive
|
usdot-fhwa-OPS/V2X-Hub
|
134061cfb55d8c83e871f7fd4bbfa5d8d3092eb0
|
aae33e6a16b8a30e1faee31a7ee863d191be06b8
|
refs/heads/develop
| 2023-08-26T10:10:59.989176
| 2023-08-24T14:58:21
| 2023-08-24T14:58:21
| 168,020,929
| 106
| 63
| null | 2023-09-11T20:24:45
| 2019-01-28T19:16:45
|
C
|
UTF-8
|
C
| false
| false
| 1,154
|
h
|
PayloadData.h
|
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "DSRC"
* found in "J2735_201603_ASN_CC.asn"
* `asn1c -gen-PER -fcompound-names -fincludes-quoted -fskeletons-copy`
*/
#ifndef _PayloadData_H_
#define _PayloadData_H_
#include "asn_application.h"
/* Including external dependencies */
#include "OCTET_STRING.h"
#ifdef __cplusplus
extern "C" {
#endif
/* PayloadData */
typedef OCTET_STRING_t PayloadData_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_PayloadData;
asn_struct_free_f PayloadData_free;
asn_struct_print_f PayloadData_print;
asn_constr_check_f PayloadData_constraint;
ber_type_decoder_f PayloadData_decode_ber;
der_type_encoder_f PayloadData_encode_der;
xer_type_decoder_f PayloadData_decode_xer;
xer_type_encoder_f PayloadData_encode_xer;
oer_type_decoder_f PayloadData_decode_oer;
oer_type_encoder_f PayloadData_encode_oer;
per_type_decoder_f PayloadData_decode_uper;
per_type_encoder_f PayloadData_encode_uper;
per_type_decoder_f PayloadData_decode_aper;
per_type_encoder_f PayloadData_encode_aper;
#ifdef __cplusplus
}
#endif
#endif /* _PayloadData_H_ */
#include "asn_internal.h"
|
7b08f995302bfdea984c2fdf13a1deed9360ebb4
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/usr.bin/systat/uvm.c
|
957b4dbf33608ca01c81b2abf928f64940c0508f
|
[] |
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
| 8,822
|
c
|
uvm.c
|
/* $OpenBSD: uvm.c,v 1.6 2022/11/27 23:18:54 kn Exp $ */
/*
* Copyright (c) 2008 Can Erkin Acar <canacar@openbsd.org>
* Copyright (c) 2018 Kenneth R Westerback <krw@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/signal.h>
#include <sys/sysctl.h>
#include <sys/pool.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "systat.h"
#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif
void print_uvm(void);
int read_uvm(void);
int select_uvm(void);
void print_uvmexp_field(field_def *, field_def *, int *, int *, const char *);
void print_uvmexp_line(int);
struct uvmexp uvmexp;
struct uvmexp last_uvmexp;
struct uvmline {
int *v1;
int *ov1;
char *n1;
int *v2;
int *ov2;
char *n2;
int *v3;
int *ov3;
char *n3;
};
struct uvmline uvmline[] = {
{ NULL, NULL, "Page Counters",
NULL, NULL, "Stats Counters",
NULL, NULL, "Fault Counters" },
{ &uvmexp.npages, &last_uvmexp.npages, "npages",
&uvmexp.faults, &last_uvmexp.faults, "faults",
&uvmexp.fltnoram, &last_uvmexp.fltnoram, "fltnoram" },
{ &uvmexp.free, &last_uvmexp.free, "free",
&uvmexp.traps, &last_uvmexp.traps, "traps",
&uvmexp.fltnoanon, &last_uvmexp.fltnoanon, "fltnoanon" },
{ &uvmexp.active, &last_uvmexp.active, "active",
&uvmexp.intrs, &last_uvmexp.intrs, "intrs",
&uvmexp.fltnoamap, &last_uvmexp.fltnoamap, "fltnoamap" },
{ &uvmexp.inactive, &last_uvmexp.inactive, "inactive",
&uvmexp.swtch, &last_uvmexp.swtch, "swtch",
&uvmexp.fltpgwait, &last_uvmexp.fltpgwait, "fltpgwait" },
{ &uvmexp.paging, &last_uvmexp.paging, "paging",
&uvmexp.softs, &last_uvmexp.softs, "softs",
&uvmexp.fltpgrele, &last_uvmexp.fltpgrele, "fltpgrele" },
{ &uvmexp.wired, &last_uvmexp.wired, "wired",
&uvmexp.syscalls, &last_uvmexp.syscalls, "syscalls",
&uvmexp.fltrelck, &last_uvmexp.fltrelck, "fltrelck" },
{ &uvmexp.zeropages, &last_uvmexp.zeropages, "zeropages",
&uvmexp.pageins, &last_uvmexp.pageins, "pageins",
&uvmexp.fltrelckok, &last_uvmexp.fltrelckok, "fltrelckok" },
{ &uvmexp.reserve_pagedaemon, &last_uvmexp.reserve_pagedaemon,
"reserve_pagedaemon",
&uvmexp.pgswapin, &last_uvmexp.pgswapin, "pgswapin",
&uvmexp.fltanget, &last_uvmexp.fltanget, "fltanget" },
{ &uvmexp.reserve_kernel, &last_uvmexp.reserve_kernel, "reserve_kernel",
&uvmexp.pgswapout, &last_uvmexp.pgswapout, "pgswapout",
&uvmexp.fltanretry, &last_uvmexp.fltanretry, "fltanretry" },
{ NULL, NULL, NULL,
&uvmexp.forks, &last_uvmexp.forks, "forks",
&uvmexp.fltamcopy, &last_uvmexp.fltamcopy, "fltamcopy" },
{ NULL, NULL, "Pageout Params",
&uvmexp.forks_ppwait, &last_uvmexp.forks_ppwait, "forks_ppwait",
&uvmexp.fltnamap, &last_uvmexp.fltnamap, "fltnamap" },
{ &uvmexp.freemin, &last_uvmexp.freemin, "freemin",
&uvmexp.forks_sharevm, &last_uvmexp.forks_sharevm, "forks_sharevm",
&uvmexp.fltnomap, &last_uvmexp.fltnomap, "fltnomap" },
{ &uvmexp.freetarg, &last_uvmexp.freetarg, "freetarg",
&uvmexp.pga_zerohit, &last_uvmexp.pga_zerohit, "pga_zerohit",
&uvmexp.fltlget, &last_uvmexp.fltlget, "fltlget" },
{ &uvmexp.inactarg, &last_uvmexp.inactarg, "inactarg",
&uvmexp.pga_zeromiss, &last_uvmexp.pga_zeromiss, "pga_zeromiss",
&uvmexp.fltget, &last_uvmexp.fltget, "fltget" },
{ &uvmexp.wiredmax, &last_uvmexp.wiredmax, "wiredmax",
NULL, NULL, NULL,
&uvmexp.flt_anon, &last_uvmexp.flt_anon, "flt_anon" },
{ &uvmexp.anonmin, &last_uvmexp.anonmin, "anonmin",
NULL, NULL, "Daemon Counters",
&uvmexp.flt_acow, &last_uvmexp.flt_acow, "flt_acow" },
{ &uvmexp.vtextmin, &last_uvmexp.vtextmin, "vtextmin",
&uvmexp.pdwoke, &last_uvmexp.pdwoke, "pdwoke",
&uvmexp.flt_obj, &last_uvmexp.flt_obj, "flt_obj" },
{ &uvmexp.vnodemin, &last_uvmexp.vnodemin, "vnodemin",
&uvmexp.pdrevs, &last_uvmexp.pdrevs, "pdrevs",
&uvmexp.flt_prcopy, &last_uvmexp.flt_prcopy, "flt_prcopy" },
{ &uvmexp.anonminpct, &last_uvmexp.anonminpct, "anonminpct",
&uvmexp.pdswout, &last_uvmexp.pdswout, "pdswout",
&uvmexp.flt_przero, &last_uvmexp.flt_przero, "flt_przero" },
{ &uvmexp.vtextminpct, &last_uvmexp.vtextminpct, "vtextminpct",
&uvmexp.swpgonly, &last_uvmexp.swpgonly, "swpgonly",
NULL, NULL, NULL },
{ &uvmexp.vnodeminpct, &last_uvmexp.vnodeminpct, "vnodeminpct",
&uvmexp.pdfreed, &last_uvmexp.pdfreed, "pdfreed",
NULL, NULL, "Swap Counters" },
{ NULL, NULL, NULL,
&uvmexp.pdscans, &last_uvmexp.pdscans, "pdscans",
&uvmexp.nswapdev, &last_uvmexp.nswapdev, "nswapdev" },
{ NULL, NULL, "Misc Counters",
&uvmexp.pdanscan, &last_uvmexp.pdanscan, "pdanscan",
&uvmexp.swpages, &last_uvmexp.swpages, "swpages" },
{ &uvmexp.fpswtch, &last_uvmexp.fpswtch, "fpswtch",
&uvmexp.pdobscan, &last_uvmexp.pdobscan, "pdobscan",
&uvmexp.swpginuse, &last_uvmexp.swpginuse, "swpginuse" },
{ &uvmexp.kmapent, &last_uvmexp.kmapent, "kmapent",
&uvmexp.pdreact, &last_uvmexp.pdreact, "pdreact",
&uvmexp.swpgonly, &last_uvmexp.swpgonly, "swpgonly" },
{ NULL, NULL, NULL,
&uvmexp.pdbusy, &last_uvmexp.pdbusy, "pdbusy",
&uvmexp.nswget, &last_uvmexp.nswget, "nswget" },
{ NULL, NULL, "Constants",
&uvmexp.pdpageouts, &last_uvmexp.pdpageouts, "pdpageouts",
NULL, NULL, NULL },
{ &uvmexp.pagesize, &last_uvmexp.pagesize, "pagesize",
&uvmexp.pdpending, &last_uvmexp.pdpending, "pdpending",
NULL, NULL, NULL },
{ &uvmexp.pagemask, &last_uvmexp.pagemask, "pagemask",
&uvmexp.pddeact, &last_uvmexp.pddeact, "pddeact",
NULL, NULL, NULL },
{ &uvmexp.pageshift, &last_uvmexp.pageshift, "pageshift",
NULL, NULL, NULL,
NULL, NULL, NULL }
};
field_def fields_uvm[] = {
{"", 5,10,1, FLD_ALIGN_RIGHT, -1,0,0,0 },
{"", 18,19,1, FLD_ALIGN_LEFT, -1,0,0,0 },
{"", 5,10,1, FLD_ALIGN_RIGHT, -1,0,0,0 },
{"", 18,19,1, FLD_ALIGN_LEFT, -1,0,0,0 },
{"", 5,10,1, FLD_ALIGN_RIGHT, -1,0,0,0 },
{"", 18,19,1, FLD_ALIGN_LEFT, -1,0,0,0 },
};
#define FLD_VALUE1 FIELD_ADDR(fields_uvm, 0)
#define FLD_NAME1 FIELD_ADDR(fields_uvm, 1)
#define FLD_VALUE2 FIELD_ADDR(fields_uvm, 2)
#define FLD_NAME2 FIELD_ADDR(fields_uvm, 3)
#define FLD_VALUE3 FIELD_ADDR(fields_uvm, 4)
#define FLD_NAME3 FIELD_ADDR(fields_uvm, 5)
/* Define views */
field_def *view_uvm_0[] = {
FLD_VALUE1, FLD_NAME1,
FLD_VALUE2, FLD_NAME2,
FLD_VALUE3, FLD_NAME3,
NULL
};
/* Define view managers */
struct view_manager uvm_mgr = {
"UVM", select_uvm, read_uvm, NULL, print_header,
print_uvm, keyboard_callback, NULL, NULL
};
field_view uvm_view = {
view_uvm_0,
"uvm",
'5',
&uvm_mgr
};
int
select_uvm(void)
{
return (0);
}
int
read_uvm(void)
{
static int uvmexp_mib[2] = { CTL_VM, VM_UVMEXP };
size_t size;
num_disp = nitems(uvmline);
memcpy(&last_uvmexp, &uvmexp, sizeof(uvmexp));
size = sizeof(uvmexp);
if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) == -1) {
error("Can't get VM_UVMEXP: %s\n", strerror(errno));
memset(&uvmexp, 0, sizeof(uvmexp));
}
return 0;
}
void
print_uvmexp_field(field_def *fvalue, field_def *fname, int *new, int *old,
const char *name)
{
char *uppername;
size_t len, i;
if (new == NULL && name == NULL)
return;
if (new == NULL) {
print_fld_str(fvalue, "=====");
print_fld_str(fname, name);
return;
}
if (*new != 0)
print_fld_ssize(fvalue, *new);
if (*new == *old) {
print_fld_str(fname, name);
return;
}
len = strlen(name);
uppername = malloc(len + 1);
if (uppername == NULL)
err(1, "malloc");
for (i = 0; i < len; i++)
uppername[i] = toupper(name[i]);
uppername[len] = '\0';
print_fld_str(fname, uppername);
free(uppername);
}
void
print_uvm(void)
{
struct uvmline *l;
int i, maxline;
maxline = nitems(uvmline);
if (maxline > (dispstart + maxprint))
maxline = dispstart + maxprint;
for (i = dispstart; i < nitems(uvmline); i++) {
l = &uvmline[i];
print_uvmexp_field(FLD_VALUE1, FLD_NAME1, l->v1, l->ov1, l->n1);
print_uvmexp_field(FLD_VALUE2, FLD_NAME2, l->v2, l->ov2, l->n2);
print_uvmexp_field(FLD_VALUE3, FLD_NAME3, l->v3, l->ov3, l->n3);
end_line();
}
}
int
inituvm(void)
{
add_view(&uvm_view);
read_uvm();
return(0);
}
|
dbee53af74ce4b413baeef55cbe34fe064ad79e3
|
6e1cde66aa5a649138babe297293962cdf97743e
|
/src/pl-atom.c
|
b409529c8ddb68701aa338a636c94d3f58fb4724
|
[
"BSD-2-Clause"
] |
permissive
|
SWI-Prolog/swipl-devel
|
db56676481984addc09f4f228bc1c41f7f53759f
|
41ac4a569c8e6c3d3b93a21449403962e3de1ece
|
refs/heads/master
| 2023-09-01T03:49:40.696481
| 2023-08-30T18:12:56
| 2023-08-30T18:12:56
| 17,516,793
| 935
| 328
|
NOASSERTION
| 2023-08-26T14:32:33
| 2014-03-07T14:43:14
|
C
|
UTF-8
|
C
| false
| false
| 56,271
|
c
|
pl-atom.c
|
/* Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@vu.nl
WWW: http://www.swi-prolog.org
Copyright (c) 1985-2021, University of Amsterdam
VU University Amsterdam
SWI-Prolog Solutions b.v.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*#define O_DEBUG 1*/
#include "pl-atom.h"
#include "pl-setup.h"
#include "pl-gc.h"
#include "pl-fli.h"
#include "pl-pro.h"
#include "pl-read.h"
#include "os/pl-ctype.h"
#undef LD
#define LD LOCAL_LD
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Implementation issues
---------------------
There are two parts in the atom administration. One is a dynamic array
(called buffer) atom_array, which is there to find the atoms back. An
atom as it appears is of type word and of the form
(n<<LMASK_BITS)|TAG_ATOM. The atom structure is located by getting the
n-th pointer from the atom_array dynamic array. See atomValue() for
translating the word into the address of the structure.
Next, there is a hash-table. Thanks to the work by Keri Harris, the atom
table now uses a lock-free algorithm. This works as follows:
- Atoms have a ->next pointer, organizing them as an open hash table.
- The head pointers for the hash-buckets are in a struct atom_table,
of which the most recent is in GD->atoms.table. This structure
contains a pointer to older atom_tables (before resizing). A
resize allocates a new struct atom_table, copies all atoms
(updating Atom->next) and makes the new atom-table current.
Lookup and creation work reliable during this process because
- If the bucket scan accidentally finds the right atom, great.
- If not, but the atom table has changed we retry, now using
the new table where all atoms are properly linked again.
- If the resize is in progress though, we may not find the
atom. In that case we create a new one. As our hash-table
is still too small, we lock and call rehashAtoms(). So,
when we get to linking the new atom into the hash-table,
we will find the table is old, destroy the atom and redo.
- The creation of an atom needs to guarantee that it is added
to the latest table and only added once. We do this by creating
a RESERVED atom and fully preparing it. Now, if we managed to
CAS it into the bucket, we know we are the only one that created
the atom and we make the atom VALID, so others can find it. If
not, we redo the lookup, possibly finding that someone created it
for us. It is possible that another thread inserted another atom
into the same bucket. In that case we have bad luck and must
recreate the atom. Hash collisions should be fairly rare.
Atom garbage collection
-----------------------
There are various categories of atoms:
* Built-in atoms
These are used directly in the C-source of the system and cannot
be removed. These are the atoms upto a certain number. This
number is GD->atoms.builtin
* Foreign referenced atoms
These are references hold in foreign code by means of
PL_new_atom() or other calls returning an atom. The system has
no way to determine the lifetime of them. Foreign code must
keep track of references to atoms using these two functions:
- PL_register_atom(atom_t atom)
- PL_unregister_atom(atom_t atom)
* References from the Prolog stacks
Reference counting is unacceptable here, which implies we must
mark atoms that are accessible from the stacks. This is done
by markAtomsOnStacks().
* References from other structures
Various of the structures contain or may contain atom
references. There are two options: lock/unlock them using
PL_register_atom() on creation/destruction of the structure
or enumerate them and flag the atoms. Currently, we use
registration everywhere, except for temporary structures
used by findall/3 and message queues, which are marked
by markAtomsThreads().
* References from compiled code and records
This uses PL_register_atom(), except for the cases mentioned
above.
Reclaiming
----------
Atoms are reclaimed by collectAtoms(), which is a two pass process.
- First, the atom-array is scanned and unmarked atoms without
references are handed to invalidateAtom(), which
- Uses CAS to reset VALID
- Removes the atom from the hash bucket
- adds atom to chain of invalidated atoms
- sets length to 0;
- In the second pass, we call destroyAtom() for all atoms in
the invalidated chain. destroyAtom() only destroys
the atom if pl_atom_bucket_in_use() returns FALSE. This serves
two purposes:
- Garantee that Atom->name is valid
- Avoid a race between looking up the atom and destroying it:
thread1 thread2
--------------------------------------------
lookupBlob(s, length, type)
v = hash(s)
a = atoms[v]
length == a.length
type == a.type
memcmp(s, a.name)
// we have a match!
AGC
invalidate atom
free atom
lookupBlob(s2)
v = hash(s2)
not found so insert at atoms[v]
CAS ref -> ref+1
The dynamic array gets holes and we remember the first free hole to
avoid too much search. Alternatively, we could turn the holes into some
form of linked list, for example by encoding an integer that expresses
the location of the next hole. We cannot shrink the array, unless all
atoms above a certain index are gone.
Atom GC and multi-threading
---------------------------
This is a hard problem. Atom-GC cannot run while some thread performs
normal GC because the pointer relocation makes it extremely hard to find
referenced atoms. Otherwise, ask all threads to mark their reachable
atoms and run collectAtoms() to reclaim the unreferenced atoms. The lock
LD->thread.scan_lock is used to ensure garbage collection does not run
concurrently with atom garbage collection.
Atom-GC asynchronously walks the stacks of all threads and marks
everything that looks `atom-like', i.e., our collector is a
`conservative' collector. While agc is running the VM will mark atoms as
it pushes them onto the stacks. See e.g., the H_ATOM VMI. An atom that
is unregistered (PL_unregister_atom()) just before AGC starts may not
get marked this way. This is fixed by setting LD->atoms.unregistering.
Note that threads can mark their atoms and continue execution because:
- If a marked atom is no longer needed it is merely not reclaimed this
time (but might be in the next collection).
- New atoms are added to the stacks using pushVolatileAtom(), which
marks the atom if AGC is active.
- Finally, message queues and bags as used by findall/3 complicate
the issue. An atom sent to these structures subsequently may
become inaccessible from the stack (the normal case for findall/3,
which backtracks). If the atom is copied back from the structure
to the stack ('$collect_findall_bag'/3 or thread_get_message/1,2),
the atom can no longer be marked from the structure but is added
to the stacks without locking. We resolve this issue as follows:
- Run marking from queues/bags after marking the stack. This
ensures that atoms added to the these structures get marked,
also if the atom is no longer on the stack.
- If an atom is copied to the stack from such a structure while
AGC is running, we are ok, because this is merely the same issue
as atoms living on the stack. TBD: redesign the structures such
that they can safely be walked.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static int rehashAtoms(void);
static void considerAGC(void);
static unsigned int register_atom(volatile Atom p);
static unsigned int unregister_atom(volatile Atom p);
#ifdef O_DEBUG_ATOMGC
static int tracking(const Atom a);
IOSTREAM *atomLogFd = 0;
#endif
static inline int
bump_atom_references(Atom a, unsigned int ref)
{ for(;;)
{ unsigned int nref = ref+1;
if ( ATOM_REF_COUNT(nref) == 0 )
return TRUE; /* reached max references */
if ( COMPARE_AND_SWAP_UINT(&a->references, ref, nref) )
{ if ( ATOM_REF_COUNT(ref) == 0 )
ATOMIC_DEC(&GD->atoms.unregistered);
return TRUE;
} else
{ ref = a->references;
if ( !ATOM_IS_VALID(ref) )
return FALSE;
}
}
}
/*******************************
* TYPES *
*******************************/
static PL_blob_t text_atom =
{ PL_BLOB_MAGIC,
PL_BLOB_UNIQUE|PL_BLOB_TEXT, /* unique representation of text */
"text"
};
static PL_blob_t unregistered_blob_atom =
{ PL_BLOB_MAGIC,
PL_BLOB_NOCOPY|PL_BLOB_TEXT,
"unregistered"
};
void
PL_register_blob_type(PL_blob_t *type)
{ if ( !type->registered )
{ PL_LOCK(L_MISC);
if ( !type->registered )
{ if ( !GD->atoms.types )
{ GD->atoms.types = type;
} else
{ PL_blob_t *t = GD->atoms.types;
while(t->next)
t = t->next;
t->next = type;
}
if ( true(type, PL_BLOB_TEXT) )
{ type->rank = ++GD->atoms.text_rank;
if ( true(type, PL_BLOB_WCHAR) )
type->padding = sizeof(pl_wchar_t);
else
type->padding = sizeof(char);
} else
{ type->rank = --GD->atoms.nontext_rank;
}
if ( !GD->atoms.initialised )
type->registered = TRUE;
if ( !type->atom_name )
type->atom_name = PL_new_atom(type->name);
type->registered = TRUE;
}
PL_UNLOCK(L_MISC);
}
}
PL_blob_t *
PL_find_blob_type(const char *name)
{ PL_blob_t *t;
PL_LOCK(L_MISC);
for(t = GD->atoms.types; t; t = t->next)
{ if ( streq(name, t->name) )
break;
}
PL_UNLOCK(L_MISC);
return t;
}
int
PL_unregister_blob_type(PL_blob_t *type)
{ size_t index;
int i, last=FALSE;
PL_blob_t **t;
int discarded = 0;
PL_LOCK(L_MISC);
for(t = &GD->atoms.types; *t; t = &(*t)->next)
{ if ( *t == type )
{ *t = type->next;
type->next = NULL;
}
}
PL_UNLOCK(L_MISC);
PL_register_blob_type(&unregistered_blob_atom);
for(index=1, i=0; !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom atom = b + index;
unsigned int refs = atom->references;
PL_blob_t *btype = atom->type;
if ( ATOM_IS_VALID(refs) && btype == type &&
bump_atom_references(atom, refs) )
{ atom->type = &unregistered_blob_atom;
atom->name = "<discarded blob>";
atom->length = strlen(atom->name);
discarded++;
PL_unregister_atom(atom->atom);
}
}
}
return discarded == 0 ? TRUE : FALSE;
}
/*******************************
* BUILT-IN ATOM TABLE *
*******************************/
#define ATOM(s) s
typedef const char * ccharp;
static const ccharp atoms[] = {
#include "pl-atom.ic"
ATOM((char *)NULL)
};
#undef ATOM
#ifdef O_PLMT
#define acquire_atom_table(t, b) \
{ LD->thread.info->access.atom_table = GD->atoms.table; \
t = LD->thread.info->access.atom_table->table; \
b = LD->thread.info->access.atom_table->buckets; \
}
#define release_atom_table() \
{ LD->thread.info->access.atom_table = NULL; \
LD->thread.info->access.atom_bucket = NULL; \
}
#define acquire_atom_bucket(b) \
{ LD->thread.info->access.atom_bucket = (b); \
}
#define release_atom_bucket() \
{ LD->thread.info->access.atom_bucket = NULL; \
}
#else
#define acquire_atom_table(t, b) \
{ t = GD->atoms.table->table; \
b = GD->atoms.table->buckets; \
}
#define release_atom_table() (void)0
#define acquire_atom_bucket(b) (void)0
#define release_atom_bucket() (void)0
#endif
/* Note that we use PL_malloc_uncollectable() here because the pointer in
our block is not the real memory pointer. Probably it is better to
have two pointers; one to the allocated memory and one with the
necessary offset.
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
It might be wise to provide for an option that does not reallocate
atoms. In that case accessing a GC'ed atom causes a crash rather then
another atom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static void
allocateAtomBlock(int idx)
{ if ( !GD->atoms.array.blocks[idx] )
{ size_t bs = (size_t)1<<idx;
size_t i;
Atom newblock;
if ( !(newblock=PL_malloc_uncollectable(bs*sizeof(struct atom))) )
outOfCore();
memset(newblock, 0, bs*sizeof(struct atom));
for(i=0; i<bs; i++)
{ newblock[i].type = ATOM_TYPE_INVALID;
newblock[i].name = "<virgin>";
}
if ( !COMPARE_AND_SWAP_PTR(&GD->atoms.array.blocks[idx],
NULL, newblock-bs) )
PL_free(newblock); /* done by someone else */
}
}
static Atom
reserveAtom(void)
{ size_t index;
#ifdef O_ATOMGC /* try to find a hole! */
int i;
int last = FALSE;
Atom a;
unsigned int ref;
int idx;
for(index=GD->atoms.no_hole_before, i=MSB(index); !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ a = b + index;
ref = a->references;
if ( ATOM_IS_FREE(ref) &&
COMPARE_AND_SWAP_UINT(&a->references, ref, ATOM_RESERVED_REFERENCE) )
{ assert(a->type == ATOM_TYPE_INVALID);
GD->atoms.no_hole_before = index+1;
a->atom = (index<<LMASK_BITS)|TAG_ATOM;
return a;
}
}
}
GD->atoms.no_hole_before = index+1;
#endif /*O_ATOMGC*/
for(;;)
{ index = __atomic_load_n(&GD->atoms.highest, __ATOMIC_ACQUIRE);
idx = MSB(index);
assert(index >= 0);
if ( !GD->atoms.array.blocks[idx] )
allocateAtomBlock(idx);
a = &GD->atoms.array.blocks[idx][index];
ref = a->references;
if ( ATOM_IS_FREE(ref) &&
COMPARE_AND_SWAP_UINT(&a->references, ref, ATOM_RESERVED_REFERENCE) )
{ COMPARE_AND_SWAP_SIZE(&GD->atoms.highest, index, index+1);
a->atom = (index<<LMASK_BITS)|TAG_ATOM;
return a;
}
}
}
/*******************************
* GENERAL LOOKUP *
*******************************/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(*) AGC starting. As we cannot run AGC if we are not in a safe state,
AGC is started using a software interrupt using PL_raise(SIG_ATOM_GC).
Earlier versions only fired the signal at exactly (last+margin) atoms,
but it is possible the signal is not handled due to the thread dying or
the thread starting an indefinite wait. Therefore we keep signalling
every 128 new atoms. Sooner or later some actually active thread will
pick up the request and process it.
PL_handle_signals() decides on the actual invocation of atom-gc and will
treat the signal as bogus if agc has already been performed.
(**) Without this check, some threads may pass the
PL_LOCK(L_REHASH_ATOMS) around rehashAtoms() and create their atom. If
they manage to register the atom in the old table before rehashAtoms()
activates the new table the insertion is successful, but rehashAtoms()
may not have moved the atom to the new table. Now we will repeat if we
bypassed the LOCK as either GD->atoms.rehashing is TRUE or the new table
is activated.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static int
same_name(const Atom a, const char *s, size_t length, const PL_blob_t *type)
{ if ( false(type, PL_BLOB_NOCOPY) )
return length == 0 || memcmp(s, a->name, length) == 0;
else
return s == a->name;
}
word
lookupBlob(const char *s, size_t length, PL_blob_t *type, int *new)
{ GET_LD
unsigned int v0, v, ref;
Atom *table;
int buckets;
Atom a, head;
if ( !type->registered ) /* avoid deadlock */
PL_register_blob_type(type);
if ( alltrue(type, PL_BLOB_UNIQUE|PL_BLOB_NOCOPY) )
v0 = MurmurHashAligned2(&s, sizeof(s), MURMUR_SEED);
else
v0 = MurmurHashAligned2(s, length, MURMUR_SEED);
redo:
acquire_atom_table(table, buckets);
v = v0 & (buckets-1);
head = table[v];
acquire_atom_bucket(table+v);
DEBUG(MSG_HASH_STAT, GD->atoms.lookups++);
if ( true(type, PL_BLOB_UNIQUE) )
{ for(a = table[v]; a; a = a->next)
{ DEBUG(MSG_HASH_STAT, GD->atoms.cmps++);
ref = a->references;
if ( ATOM_IS_RESERVED(ref) &&
length == a->length &&
type == a->type &&
same_name(a, s, length, type) )
{ if ( !ATOM_IS_VALID(ref) )
goto redo;
#ifdef O_ATOMGC
if ( indexAtom(a->atom) >= GD->atoms.builtin &&
!likely(bump_atom_references(a, ref)) )
break; /* atom was just GCed. Re-create */
#endif
#ifdef O_DEBUG_ATOMGC
if ( atomLogFd && tracking(a) )
Sfprintf(atomLogFd, "Lookup `%s' at (#%" PRIuPTR ")\n",
a->name, indexAtom(a->atom));
#endif
*new = FALSE;
release_atom_table();
release_atom_bucket();
return a->atom;
}
}
}
if ( GD->atoms.table->buckets * 2 < GD->statistics.atoms )
{ int rc;
PL_LOCK(L_REHASH_ATOMS);
rc = rehashAtoms();
PL_UNLOCK(L_REHASH_ATOMS);
if ( !rc )
outOfCore();
}
if ( !( table == GD->atoms.table->table && head == table[v] ) )
goto redo;
a = reserveAtom();
a->length = length;
a->type = type;
if ( false(type, PL_BLOB_NOCOPY) )
{ if ( type->padding )
{ size_t pad = type->padding;
a->name = PL_malloc_atomic(length+pad);
memcpy(a->name, s, length);
memset(a->name+length, 0, pad);
ATOMIC_ADD(&GD->statistics.atom_string_space, length+pad);
} else
{ a->name = PL_malloc(length);
memcpy(a->name, s, length);
ATOMIC_ADD(&GD->statistics.atom_string_space, length);
}
} else
{ a->name = (char *)s;
}
#ifdef O_TERMHASH
a->hash_value = v0;
#endif
if ( true(type, PL_BLOB_UNIQUE) )
{ a->next = table[v];
if ( !( !GD->atoms.rehashing && /* See (**) above */
COMPARE_AND_SWAP_PTR(&table[v], head, a) &&
table == GD->atoms.table->table ) )
{ if ( false(type, PL_BLOB_NOCOPY) )
PL_free(a->name);
a->type = ATOM_TYPE_INVALID;
a->name = "<race>";
MEMORY_BARRIER();
a->references = 0;
goto redo;
}
}
#ifdef O_ATOMGC
a->references = 1 | ATOM_VALID_REFERENCE | ATOM_RESERVED_REFERENCE;
#endif
#ifdef O_DEBUG_ATOMGC
if ( atomLogFd && tracking(a) )
Sfprintf(atomLogFd, "Created `%s' at (#%" PRIuPTR "d)\n",
a->name, indexAtom(a->atom));
#endif
*new = TRUE;
if ( type->acquire )
(*type->acquire)(a->atom);
release_atom_table();
release_atom_bucket();
if ( ATOMIC_INC(&GD->statistics.atoms) % 128 == 0 )
considerAGC();
return a->atom;
}
word
lookupAtom(const char *s, size_t length)
{ int new;
return lookupBlob(s, length, &text_atom, &new);
}
/*******************************
* ATOM-GC *
*******************************/
#ifdef O_ATOMGC
#ifdef O_DEBUG_ATOMGC
static char *t_tracking;
static int
tracking(const Atom a)
{ return ( a->type == &text_atom &&
strcmp(a->name, t_tracking) == 0 );
}
void
_PL_debug_register_atom(atom_t a,
const char *file, int line, const char *func)
{ size_t i = indexAtom(a);
size_t mx = GD->atoms.highest;
assert(i>=0 && i<mx);
if ( i >= GD->atoms.builtin )
{ Atom atom = fetchAtomArray(i);
unsigned int refs;
refs = ATOM_REF_COUNT(register_atom(atom));
if ( atomLogFd && tracking(atom) )
Sfprintf(atomLogFd, "%s:%d: %s(): ++ (%d) for `%s' (#%zd)\n",
file, line, func, refs, atom->name, i);
}
}
void
_PL_debug_unregister_atom(atom_t a,
const char *file, int line, const char *func)
{ size_t i = indexAtom(a);
size_t mx = GD->atoms.highest;
assert(i>=0 && i<mx);
if ( i >= GD->atoms.builtin )
{ Atom atom = fetchAtomArray(i);
unsigned int refs;
refs = unregister_atom(atom);
if ( atomLogFd && tracking(atom) )
Sfprintf(atomLogFd, "%s:%d: %s(): -- (%d) for `%s' (#%zd)\n",
file, line, func, refs, atom->name, i);
}
}
word
pl_track_atom(term_t which, term_t stream)
{ char *s;
if ( t_tracking )
remove_string(t_tracking);
t_tracking = NULL;
atomLogFd = NULL;
if ( PL_get_nil(stream) )
succeed;
if ( !PL_get_chars(which, &s, CVT_LIST|CVT_STRING|CVT_EXCEPTION) ||
!PL_get_stream_handle(stream, &atomLogFd) )
return FALSE;
PL_release_stream(atomLogFd);
t_tracking = store_string(s);
succeed;
}
#endif /*O_DEBUG_ATOMGC*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lockAtoms() discards all currently defined atoms for garbage collection.
To be used after loading the program, so we won't traverse the program
atoms each pass.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static void
lockAtoms(void)
{ GD->atoms.builtin = GD->atoms.highest;
GD->atoms.unregistered = 0;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mark an atom from the stacks. We must be prepared to handle fake-atoms!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void
markAtom(atom_t a)
{ size_t i = indexAtom(a);
Atom ap;
if ( i >= GD->atoms.highest )
return; /* not an atom */
if ( i < GD->atoms.builtin )
return; /* locked range */
ap = fetchAtomArray(i);
if ( ATOM_IS_VALID(ap->references) && !ATOM_IS_MARKED(ap->references) )
{
#ifdef O_DEBUG_ATOMGC
if ( atomLogFd && tracking(ap) )
Sfprintf(atomLogFd, "Marked `%s' at (#%zd)\n", ap->name, i);
#endif
ATOMIC_OR(&ap->references, ATOM_MARKED_REFERENCE);
}
}
static void
unmarkAtoms(void)
{ size_t index;
int i, last=FALSE;
for(index=GD->atoms.builtin, i=MSB(index); !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom a = b + index;
if ( ATOM_IS_MARKED(a->references) )
{ ATOMIC_AND(&a->references, ~ATOM_MARKED_REFERENCE);
}
}
}
}
static void
maybe_free_atom_tables(void)
{ AtomTable t = GD->atoms.table;
while ( t )
{ AtomTable t2 = t->prev;
if ( t2 && !pl_atom_table_in_use(t2) )
{ t->prev = t2->prev;
freeHeap(t2->table, t2->buckets * sizeof(Atom));
freeHeap(t2, sizeof(atom_table));
}
t = t->prev;
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
destroyAtom() actually discards an atom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define ATOM_NAME_MUST_FREE 0x1
static Atom invalid_atoms = NULL;
static int
invalidateAtom(Atom a, unsigned int ref)
{ Atom *ap;
#define ATOM_PRE_DESTROY_REFERENCE \
(ATOM_DESTROY_REFERENCE|ATOM_RESERVED_REFERENCE)
if ( !COMPARE_AND_SWAP_UINT(&a->references, ref, ATOM_PRE_DESTROY_REFERENCE) )
{ return FALSE;
}
if ( a->type->release )
{ if ( a->name && !(*a->type->release)(a->atom) )
{ COMPARE_AND_SWAP_UINT(&a->references, ATOM_PRE_DESTROY_REFERENCE, ref);
return FALSE;
}
} else if ( GD->atoms.gc_hook )
{ if ( !(*GD->atoms.gc_hook)(a->atom) )
{ COMPARE_AND_SWAP_UINT(&a->references, ATOM_PRE_DESTROY_REFERENCE, ref);
return FALSE; /* foreign hooks says `no' */
}
}
a->references = ATOM_DESTROY_REFERENCE;
#ifdef O_DEBUG_ATOMGC
if ( atomLogFd && tracking(a) )
Sfprintf(atomLogFd, "Invalidated `%s'\n", a->name);
#endif
if ( true(a->type, PL_BLOB_UNIQUE) )
{ AtomTable table;
uintptr_t mask;
redo:
table = GD->atoms.table;
mask = table->buckets-1;
ap = &table->table[a->hash_value & mask];
if ( *ap == a )
{ if ( !COMPARE_AND_SWAP_PTR(&table->table[a->hash_value & mask], a, a->next) )
{ goto redo;
}
}
else
{ for( ; ; ap = &(*ap)->next )
{ assert(*ap); // MT: TBD: failed a few times!?
if ( *ap == a )
{ *ap = a->next;
break;
}
}
}
}
if ( false(a->type, PL_BLOB_NOCOPY) )
{ size_t slen = a->length + a->type->padding;
ATOMIC_SUB(&GD->statistics.atom_string_space, slen);
ATOMIC_ADD(&GD->statistics.atom_string_space_freed, slen);
a->next_invalid = (uintptr_t)invalid_atoms | ATOM_NAME_MUST_FREE;
} else
{ a->next_invalid = (uintptr_t)invalid_atoms;
}
invalid_atoms = a;
a->length = 0;
return TRUE;
}
static int
destroyAtom(Atom a, Atom **buckets)
{ unsigned int v;
AtomTable t;
size_t index;
while ( buckets && *buckets )
{ t = GD->atoms.table;
while ( t )
{ v = a->hash_value & (t->buckets-1);
if ( *buckets == t->table+v )
{ return FALSE;
}
t = t->prev;
}
buckets++;
}
#ifdef O_DEBUG_ATOMGC
/* tracking() always returns FALSE as the type is lost */
if ( atomLogFd && tracking(a) )
Sfprintf(atomLogFd, "Deleted `%s'\n", a->name);
#endif
if ( a->next_invalid & ATOM_NAME_MUST_FREE )
{ PL_free(a->name);
}
a->name = "<reclaimed>";
a->type = ATOM_TYPE_INVALID;
MEMORY_BARRIER();
a->references = 0;
index = indexAtom(a->atom);
if ( GD->atoms.no_hole_before > index )
GD->atoms.no_hole_before = index;
return TRUE;
}
static size_t
collectAtoms(void)
{ size_t reclaimed = 0;
size_t unregistered = 0;
size_t index;
int i, last=FALSE;
Atom temp, next, prev = NULL; /* = NULL to keep compiler happy */
for(index=GD->atoms.builtin, i=MSB(index); !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom a = b + index;
unsigned int ref = a->references;
if ( !ATOM_IS_VALID(ref) )
{ continue;
}
if ( !ATOM_IS_MARKED(ref) && (ATOM_REF_COUNT(ref) == 0) )
{ invalidateAtom(a, ref);
} else
{ ATOMIC_AND(&a->references, ~ATOM_MARKED_REFERENCE);
if ( ATOM_REF_COUNT(ref) == 0 )
unregistered++;
}
}
}
Atom** buckets = pl_atom_buckets_in_use();
temp = invalid_atoms;
while ( temp && temp == invalid_atoms )
{ next = (Atom)(temp->next_invalid & ~ATOM_NAME_MUST_FREE);
if ( destroyAtom(temp, buckets) )
{ reclaimed++;
invalid_atoms = next;
}
prev = temp;
temp = next;
}
while ( temp )
{ next = (Atom)(temp->next_invalid & ~ATOM_NAME_MUST_FREE);
if ( destroyAtom(temp, buckets) )
{ reclaimed++;
prev->next_invalid = ((uintptr_t)next | (prev->next_invalid & ATOM_NAME_MUST_FREE));
} else
{ prev = temp;
}
temp = next;
}
if ( buckets )
PL_free(buckets);
maybe_free_atom_tables();
GD->atoms.unregistered = GD->atoms.non_garbage = unregistered;
return reclaimed;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pl_garbage_collect_atoms() realised the atom garbage collector (AGC).
Issues around the design of the atom garbage collector are explained at
the start of this file.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
foreign_t
pl_garbage_collect_atoms(void)
{ GET_LD
int64_t oldcollected;
int verbose = truePrologFlag(PLFLAG_TRACE_GC) && !LD->in_print_message;
double t;
sigset_t set;
size_t reclaimed;
int rc = TRUE;
if ( GD->cleaning != CLN_NORMAL ) /* Cleaning up */
return TRUE;
if ( !COMPARE_AND_SWAP_INT(&GD->atoms.gc_active, FALSE, TRUE) )
return TRUE;
if ( verbose )
{ if ( !printMessage(ATOM_informational,
PL_FUNCTOR_CHARS, "agc", 1,
PL_CHARS, "start") )
{ GD->atoms.gc_active = FALSE;
return FALSE;
}
}
LD->atoms.gc_active = TRUE;
PL_LOCK(L_REHASH_ATOMS);
blockSignals(&set);
t = CpuTime(CPU_USER);
unmarkAtoms();
markAtomsOnStacks(LD, NULL);
#ifdef O_ENGINES
forThreadLocalDataUnsuspended(markAtomsOnStacks, NULL);
markAtomsMessageQueues();
#endif
oldcollected = GD->atoms.collected;
reclaimed = collectAtoms();
GD->atoms.collected += reclaimed;
ATOMIC_SUB(&GD->statistics.atoms, reclaimed);
t = CpuTime(CPU_USER) - t;
GD->atoms.gc_time += t;
GD->atoms.gc++;
unblockSignals(&set);
PL_UNLOCK(L_REHASH_ATOMS);
LD->atoms.gc_active = FALSE;
if ( verbose )
rc = printMessage(ATOM_informational,
PL_FUNCTOR_CHARS, "agc", 1,
PL_FUNCTOR_CHARS, "done", 3,
PL_INT64, GD->atoms.collected - oldcollected,
PL_INT, GD->statistics.atoms,
PL_DOUBLE, (double)t);
GD->atoms.gc_active = FALSE;
return rc;
}
PL_agc_hook_t
PL_agc_hook(PL_agc_hook_t new)
{ PL_agc_hook_t old = GD->atoms.gc_hook;
GD->atoms.gc_hook = new;
return old;
}
static void
considerAGC(void)
{ if ( GD->atoms.margin != 0 &&
GD->atoms.unregistered >= GD->atoms.non_garbage + GD->atoms.margin )
{ DEBUG(MSG_AGC_CONSIDER,
Sdprintf("Signal AGC. Unregistered %zd, non-garbage %zd, margin %zd\n",
GD->atoms.unregistered, GD->atoms.non_garbage,
GD->atoms.margin));
signalGCThread(SIG_ATOM_GC);
}
}
#endif /*O_ATOMGC*/
void
resetAtoms()
{
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(un)register atoms. If possible, this is implemented using atomic
operations. This should be safe because:
- When we register an atom, it must be referenced from somewhere
else.
- When we unregister an atom, it must have at least one reference.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static unsigned int
register_atom(volatile Atom p)
{ for(;;)
{ unsigned int ref = p->references;
unsigned int nref = ref+1;
if ( ATOM_REF_COUNT(nref) != 0 )
{ if ( COMPARE_AND_SWAP_UINT(&p->references, ref, nref) )
{ if ( ATOM_REF_COUNT(nref) == 1 )
ATOMIC_DEC(&GD->atoms.unregistered);
return nref;
}
} else
{ return ref;
}
}
}
void
(PL_register_atom)(atom_t a)
{
#ifdef O_ATOMGC
size_t index = indexAtom(a);
if ( index >= GD->atoms.builtin )
{ Atom p = fetchAtomArray(index);
register_atom(p);
}
#endif
}
static char *
dbgAtomName(Atom a, char *enc, char **buf)
{ if ( a->type == &text_atom )
{ if ( enc ) *enc = 'L';
return a->name;
} else if ( isUCSAtom(a) )
{ if ( enc ) *enc = 'W';
return a->name;
} else
{ size_t len = 0;
IOSTREAM *fd = Sopenmem(buf, &len, "w");
(a->type->write)(fd, a->atom, 0);
Sclose(fd);
return *buf;
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Foreign code reduces the reference count. This is safe, unless we are in
the following scenario:
- A threads has done its atom-marking during a GC and is continued.
- Now, it fetches an atom from foreign code and the foreign code calls
PL_unregister_atom() which drops the reference count to zero. We can
now get into the position where the atom is no longer accessible
from foreign code and has not be seen while marking atoms from the
stack.
The locking version of this code is not a problem, as the reference
count cannot be dropped as long as AGC is running. In the unlocked
version, we need to replace 1 by ATOM_MARKED_REFERENCE if AGC is
running. We can be a bit sloppy here: if we do this while AGC is not
running we merely prevent the atom to be collected in the next AGC. The
next AGC resets the flag and thus the atom becomes a candidate for
collection afterwards. So, basically we must do something like this:
if ( agc_running )
{ do
{ unsigned int oldref = p->references;
unsigned int newref = oldref == 1 ? ATOM_MARKED_REFERENCE : oldref-1;
} while( !compare_and_swap(&p->references, oldref, newref) );
} else
{ atomic_dec(&p->references);
}
But, this fails because AGC might kick in between agc_running was tested
FALSE the atomic decrement. This is fixed by putting the atom we are
unregistering in LD->atoms.unregistered and mark this atom from
markAtomsOnStacks().
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static unsigned int
unregister_atom(volatile Atom p)
{ unsigned int refs;
if ( !ATOM_IS_VALID(p->references) )
{ Sdprintf("OOPS: PL_unregister_atom('%s'): invalid atom\n", p->name);
trap_gdb();
}
if ( unlikely(ATOM_REF_COUNT(p->references+1) == 0) )
return ATOM_REF_COUNT(~(unsigned int)0);
if ( GD->atoms.gc_active )
{ unsigned int oldref, newref;
do
{ oldref = p->references;
newref = oldref - 1;
if ( ATOM_REF_COUNT(newref) == 0 )
newref |= ATOM_MARKED_REFERENCE;
} while( !COMPARE_AND_SWAP_UINT(&p->references, oldref, newref) );
refs = ATOM_REF_COUNT(newref);
#ifdef O_DEBUG_ATOMGC
if ( refs == 0 && atomLogFd && tracking(p) )
Sfprintf(atomLogFd, "Marked '%s' at (#%" PRIuPTR ") (unregistered)\n",
p->name, indexAtom(p->atom));
#endif
} else
{ GET_LD
if ( HAS_LD )
{ LD->atoms.unregistering = p->atom;
#ifdef O_DEBUG_ATOMGC
if ( atomLogFd && tracking(p) )
Sfprintf(atomLogFd, "Set atoms.unregistering for '%s' at (#%" PRIuPTR ")\n",
p->name, indexAtom(p->atom));
#endif
}
if ( (refs=ATOM_REF_COUNT(ATOMIC_DEC(&p->references))) == 0 )
ATOMIC_INC(&GD->atoms.unregistered);
}
if ( refs == ATOM_REF_COUNT((unsigned int)-1) )
{ char fmt[100];
char *enc;
char *buf = NULL;
strcpy(fmt, "OOPS: PL_unregister_atom('%Ls'): -1 references\n");
enc = strchr(fmt, '%')+1;
Sdprintf(fmt, dbgAtomName(p, enc, &buf));
if ( buf )
PL_free(buf);
trap_gdb();
}
return refs;
}
void
(PL_unregister_atom)(atom_t a)
{
#ifdef O_ATOMGC
size_t index = indexAtom(a);
if ( index >= GD->atoms.builtin )
{ Atom p;
p = fetchAtomArray(index);
unregister_atom(p);
}
#endif
}
/* TRUE if `a` is a possible candidate for AGC
*/
int
is_volatile_atom(atom_t a)
{
#ifdef O_ATOMGC
size_t index = indexAtom(a);
if ( index >= GD->atoms.builtin )
{ Atom p = fetchAtomArray(index);
return !p->references;
}
#endif
return FALSE;
}
/*******************************
* CHECK *
*******************************/
#ifdef O_DEBUG
static int
findAtomSelf(Atom a)
{ GET_LD
Atom *table;
int buckets;
Atom head, ap;
unsigned int v;
redo:
acquire_atom_table(table, buckets);
v = a->hash_value & (buckets-1);
head = table[v];
acquire_atom_bucket(table+v);
for(ap=head; ap; ap = ap->next )
{ if ( ap == a )
{ release_atom_table();
release_atom_bucket();
return TRUE;
}
}
if ( !( table == GD->atoms.table->table && head == table[v] ) )
goto redo;
return FALSE;
}
int
checkAtoms_src(const char *file, int line)
{ size_t index;
int i, last=FALSE;
int errors = 0;
for(index=1, i=0; !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom a = b + index;
if ( ATOM_IS_VALID(a->references) )
{ if ( !a->type || !a->name || (int)ATOM_REF_COUNT(a->references) < 0 )
{ size_t bs = (size_t)1<<i;
Sdprintf("%s%d: invalid atom %p at index %zd in "
"block at %p (size %d)\n",
file, line, a, index, b+bs, bs);
errors++;
trap_gdb();
}
if ( true(a->type, PL_BLOB_UNIQUE) )
{ if ( !findAtomSelf(a) )
{ Sdprintf("%s%d: cannot find self: %p\n", file, line, a);
}
}
}
}
}
return errors;
}
#endif /*O_DEBUG*/
/*******************************
* REHASH TABLE *
*******************************/
static int
rehashAtoms(void)
{ AtomTable newtab;
uintptr_t mask;
size_t index;
int i, last=FALSE;
if ( GD->cleaning != CLN_NORMAL )
return TRUE; /* no point anymore and foreign ->type */
/* pointers may have gone */
if ( GD->atoms.table->buckets * 2 >= GD->statistics.atoms )
return TRUE;
if ( !(newtab = allocHeap(sizeof(*newtab))) )
return FALSE;
newtab->buckets = GD->atoms.table->buckets * 2;
if ( !(newtab->table = allocHeapOrHalt(newtab->buckets * sizeof(Atom))) )
{ freeHeap(newtab, sizeof(*newtab));
return FALSE;
}
memset(newtab->table, 0, newtab->buckets * sizeof(Atom));
newtab->prev = GD->atoms.table;
mask = newtab->buckets-1;
DEBUG(MSG_HASH_STAT,
Sdprintf("rehashing atoms (%d --> %d)\n",
GD->atoms.table->buckets, newtab->buckets));
GD->atoms.rehashing = TRUE;
for(index=1, i=0; !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ volatile Atom a = b + index;
unsigned int ref;
redo:
ref = a->references;
if ( ATOM_IS_RESERVED(ref) )
{ if ( !ATOM_IS_VALID(ref) )
goto redo;
if ( true(a->type, PL_BLOB_UNIQUE) )
{ size_t v;
v = a->hash_value & mask;
a->next = newtab->table[v];
newtab->table[v] = a;
}
}
}
}
GD->atoms.table = newtab;
GD->atoms.rehashing = FALSE;
return TRUE;
}
word
pl_atom_hashstat(term_t idx, term_t n)
{ GET_LD
long i, m;
int buckets;
Atom *table;
Atom a;
acquire_atom_table(table, buckets);
if ( !PL_get_long(idx, &i) || i < 0 || i >= (long)buckets )
{ release_atom_table();
fail;
}
for(m = 0, a = table[i]; a; a = a->next)
m++;
release_atom_table();
return PL_unify_integer(n, m);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
resetListAtoms() resets the atom '[|]' to point to '.' and switches the
type for '[]' back to the normal text_atom type. This is needed to
switch to traditional mode if the atom table has been initialised.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
int
resetListAtoms(void)
{ Atom a = atomValue(ATOM_dot);
if ( strcmp(a->name, ".") != 0 )
{ Atom *ap2 = &GD->atoms.table->table[a->hash_value & (GD->atoms.table->buckets-1)];
unsigned int v;
static char *s = ".";
DEBUG(0, Sdprintf("Resetting list constructor to ./2\n"));
for( ; ; ap2 = &(*ap2)->next )
{ assert(*ap2); /* MT: TBD: failed a few times!? */
if ( *ap2 == a )
{ *ap2 = a->next;
goto modify;
}
}
assert(0);
modify:
a->name = s;
a->length = strlen(s);
a->hash_value = MurmurHashAligned2(s, a->length, MURMUR_SEED);
v = a->hash_value & (GD->atoms.table->buckets-1);
a->next = GD->atoms.table->table[v];
GD->atoms.table->table[v] = a;
}
a = atomValue(ATOM_nil);
a->type = &text_atom;
return TRUE;
}
static void
registerBuiltinAtoms(void)
{ int size = sizeof(atoms)/sizeof(char *) - 1;
Atom a;
const ccharp *sp;
size_t index;
int idx;
GD->statistics.atoms = size;
for( sp = atoms, index = GD->atoms.highest; *sp; sp++, index++ )
{ const char *s = *sp;
size_t len = strlen(s);
unsigned int v0, v;
idx = MSB(index);
if ( !GD->atoms.array.blocks[idx] )
{ allocateAtomBlock(idx);
}
if ( *s == '.' && len == 1 && !GD->options.traditional )
{ s = "[|]";
len = strlen(s);
}
v0 = MurmurHashAligned2(s, len, MURMUR_SEED);
v = v0 & (GD->atoms.table->buckets-1);
a = &GD->atoms.array.blocks[idx][index];
a->atom = (index<<LMASK_BITS)|TAG_ATOM;
a->name = (char *)s;
a->length = len;
a->type = &text_atom;
#ifdef O_ATOMGC
a->references = ATOM_VALID_REFERENCE | ATOM_RESERVED_REFERENCE;
#endif
#ifdef O_TERMHASH
a->hash_value = v0;
#endif
a->next = GD->atoms.table->table[v];
GD->atoms.table->table[v] = a;
GD->atoms.no_hole_before = index+1;
GD->atoms.highest = index+1;
}
}
#if O_DEBUG
static int
exitAtoms(int status, void *context)
{ (void)status;
(void)context;
Sdprintf("hashstat: %d lookupAtom() calls used %d strcmp() calls\n",
GD->atoms.lookups, GD->atoms.cmps);
return 0;
}
#endif
void
do_init_atoms(void)
{ initPrologThreads();
PL_LOCK(L_INIT_ATOMS);
if ( !GD->atoms.initialised ) /* Atom hash table */
{ GD->atoms.table = allocHeapOrHalt(sizeof(*GD->atoms.table));
GD->atoms.table->buckets = ATOMHASHSIZE;
GD->atoms.table->table = allocHeapOrHalt(ATOMHASHSIZE * sizeof(Atom));
memset(GD->atoms.table->table, 0, ATOMHASHSIZE * sizeof(Atom));
GD->atoms.table->prev = NULL;
GD->atoms.highest = 1;
GD->atoms.no_hole_before = 1;
registerBuiltinAtoms();
#ifdef O_ATOMGC
GD->atoms.margin = 10000;
lockAtoms();
#endif
text_atom.atom_name = ATOM_text;
PL_register_blob_type(&text_atom);
DEBUG(MSG_HASH_STAT, PL_on_halt(exitAtoms, NULL));
#ifdef O_RESERVED_SYMBOLS
initReservedSymbols();
#endif
GD->atoms.initialised = TRUE;
}
PL_UNLOCK(L_INIT_ATOMS);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cleanupAtoms() is called at shutdown. There are three possible scenarios
these days: (1) do not cleanup at all, (2) cleanup the main structures,
leaving the rest to GC or (3) cleanup the whole thing.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void
cleanupAtoms(void)
{ AtomTable table;
size_t index;
int i, last=FALSE;
for(index=GD->atoms.builtin, i=MSB(index); !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom a = b + index;
unsigned int ref = a->references;
if ( !ATOM_IS_VALID(ref) )
continue;
if ( a->type->release )
(*a->type->release)(a->atom);
else if ( GD->atoms.gc_hook )
(*GD->atoms.gc_hook)(a->atom);
if ( false(a->type, PL_BLOB_NOCOPY) )
PL_free(a->name);
}
}
i = 0;
while( GD->atoms.array.blocks[i] )
{ size_t bs = (size_t)1<<i;
PL_free(GD->atoms.array.blocks[i++] + bs);
}
for(i=0; i<256; i++) /* char-code -> char-atom map */
{ atom_t *p;
if ( (p=GD->atoms.for_code[i]) )
{ GD->atoms.for_code[i] = NULL;
PL_free(p);
}
}
table = GD->atoms.table;
while ( table )
{ AtomTable prev = table->prev;
freeHeap(table->table, table->buckets * sizeof(Atom));
freeHeap(table, sizeof(atom_table));
table = prev;
}
if ( GD->atoms.table )
{ GD->atoms.table = NULL;
}
PL_blob_t *bn;
for(PL_blob_t *t=GD->atoms.types; t; t = bn)
{ bn = t->next;
t->next = NULL;
t->registered = FALSE;
t->rank = 0;
t->atom_name = (atom_t)0;
}
GD->atoms.types = NULL;
}
#define current_blob(a, type, call, state) LDFUNC(current_blob, a, type, call, state)
static word
current_blob(DECL_LD term_t a, term_t type, frg_code call, intptr_t state)
{ atom_t type_name = 0;
size_t index;
int i, last=0;
switch( call )
{ case FRG_FIRST_CALL:
{ PL_blob_t *bt;
if ( PL_is_blob(a, &bt) )
{ if ( type )
return PL_unify_atom(type, bt->atom_name);
else if ( false(bt, PL_BLOB_TEXT) )
return FALSE;
succeed;
}
if ( !PL_is_variable(a) )
return FALSE;
index = 1;
break;
}
case FRG_REDO:
index = state;
break;
case FRG_CUTTED:
default:
return TRUE;
}
if ( type )
{ if ( !PL_is_variable(type) &&
!PL_get_atom_ex(type, &type_name) )
return FALSE;
}
for(i=MSB(index); !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom atom = b + index;
unsigned int refs = atom->references;
PL_blob_t *btype = atom->type;
int rc;
if ( ATOM_IS_VALID(refs) && btype &&
(!type_name || type_name == btype->atom_name) &&
atom->atom != ATOM_garbage_collected &&
bump_atom_references(atom, refs) )
{ DEBUG(CHK_ATOM_GARBAGE_COLLECTED,
/* avoid trap through linkVal() check */
if ( atom->atom == ATOM_garbage_collected )
{ PL_unregister_atom(atom->atom);
continue;
});
if ( type )
{ if ( !type_name )
{ if ( !PL_unify_atom(type, btype->atom_name) )
{ PL_unregister_atom(atom->atom);
return FALSE;
}
}
} else if ( false(btype, PL_BLOB_TEXT) )
{ PL_unregister_atom(atom->atom);
continue;
}
rc = PL_unify_atom(a, atom->atom);
PL_unregister_atom(atom->atom);
if ( rc )
ForeignRedoInt(index+1);
else
return rc;
}
}
}
return FALSE;
}
static
PRED_IMPL("current_blob", 2, current_blob, PL_FA_NONDETERMINISTIC)
{ PRED_LD
return current_blob(A1, A2, CTX_CNTRL, CTX_INT);
}
static
PRED_IMPL("current_atom", 1, current_atom, PL_FA_NONDETERMINISTIC)
{ PRED_LD
return current_blob(A1, 0, CTX_CNTRL, CTX_INT);
}
/** blob(@Term, ?Type) is semidet
Type-test for a blob.
*/
static
PRED_IMPL("blob", 2, blob, 0)
{ PRED_LD
PL_blob_t *bt;
if ( PL_is_blob(A1, &bt) )
return PL_unify_atom(A2, bt->atom_name);
return FALSE;
}
static
PRED_IMPL("$atom_references", 2, atom_references, 0)
{ PRED_LD
atom_t atom;
if ( PL_get_atom_ex(A1, &atom) )
{ Atom av = atomValue(atom);
return PL_unify_integer(A2, ATOM_REF_COUNT(av->references));
}
fail;
}
/*******************************
* ATOM COMPLETION *
*******************************/
#define ALT_SIZ 80 /* maximum length of one alternative */
#define ALT_MAX 256 /* maximum number of alternatives */
#define stringMatch(m) ((m)->name->name)
typedef struct match
{ Atom name;
size_t length;
} *Match;
/* An atom without references cannot be part of the program
*/
static int
global_atom(Atom a)
{ return ( ATOM_REF_COUNT(a->references) != 0 ||
indexAtom(a->atom) < GD->atoms.builtin );
}
static int
is_identifier_text(PL_chars_t *txt)
{ if ( txt->length == 0 )
return FALSE;
switch(txt->encoding)
{ case ENC_ISO_LATIN_1:
{ const unsigned char *s = (const unsigned char *)txt->text.t;
const unsigned char *e = &s[txt->length];
if ( !f_is_prolog_atom_start(*s) )
return FALSE;
for(s++; s<e; s++)
{ if ( !f_is_prolog_identifier_continue(*s) )
return FALSE;
}
return TRUE;
}
case ENC_WCHAR:
{ const pl_wchar_t *s = (const pl_wchar_t*)txt->text.w;
const pl_wchar_t *e = &s[txt->length];
if ( !f_is_prolog_atom_start(*s) )
return FALSE;
for(s++; s<e; s++)
{ if ( !f_is_prolog_identifier_continue(*s) )
return FALSE;
}
return TRUE;
}
default:
assert(0);
return FALSE;
}
}
static int
extendAtom(char *prefix, bool *unique, char *common)
{ size_t index;
int i, last=FALSE;
bool first = TRUE;
size_t lp = strlen(prefix);
*unique = TRUE;
for(index=1, i=0; !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom a = b + index;
if ( ATOM_IS_VALID(a->references) && a->type == &text_atom &&
global_atom(a) &&
strprefix(a->name, prefix) &&
strlen(a->name) < LINESIZ )
{ if ( first == TRUE )
{ strcpy(common, a->name+lp);
first = FALSE;
} else
{ char *s = common;
char *q = a->name+lp;
while( *s && *s == *q )
s++, q++;
*s = EOS;
*unique = FALSE;
}
}
}
}
return !first;
}
/** '$complete_atom'(+Prefix, -Common, -Unique) is semidet.
True when Prefix can be extended based on currently defined atoms.
@arg Common is a code list consisting of the characters from Prefix
and the common text for all possible completions
@arg Unique is either =unique= or =not_unique=. In the second case,
this implies that there are longer atoms that have the prefix
Common.
@see '$atom_completions'/2.
@bug This version only handles ISO Latin 1 text
*/
static
PRED_IMPL("$complete_atom", 3, complete_atom, 0)
{ PRED_LD
term_t prefix = A1;
term_t common = A2;
term_t unique = A3;
char *p;
size_t len;
bool u;
char buf[LINESIZ];
char cmm[LINESIZ];
if ( !PL_get_nchars(prefix, &len, &p, CVT_ALL|CVT_EXCEPTION) ||
len >= sizeof(buf) )
return FALSE;
strcpy(buf, p);
if ( extendAtom(p, &u, cmm) )
{ strcat(buf, cmm);
if ( PL_unify_list_codes(common, buf) &&
PL_unify_atom(unique, u ? ATOM_unique
: ATOM_not_unique) )
return TRUE;
}
return FALSE;
}
static int
compareMatch(const void *m1, const void *m2)
{ return strcmp(stringMatch((Match)m1), stringMatch((Match)m2));
}
static int
extend_alternatives(PL_chars_t *prefix, struct match *altv, int *altn)
{ size_t index;
int i, last=FALSE;
*altn = 0;
for(index=1, i=0; !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom a = b + index;
PL_chars_t hit;
if ( index % 256 == 0 && PL_handle_signals() < 0 )
return FALSE; /* interrupted */
if ( ATOM_IS_VALID(a->references) &&
global_atom(a) &&
get_atom_ptr_text(a, &hit) &&
hit.length < ALT_SIZ &&
PL_cmp_text(prefix, 0, &hit, 0, prefix->length) == 0 &&
is_identifier_text(&hit) )
{ Match m = &altv[(*altn)++];
m->name = a;
m->length = a->length;
if ( *altn >= ALT_MAX )
goto out;
}
}
}
out:
qsort(altv, *altn, sizeof(struct match), compareMatch);
return TRUE;
}
/** '$atom_completions'(+Prefix, -Alternatives:list(atom)) is det.
True when Alternatives is a list of all atoms that have prefix Prefix
and are considered completion candidates. Completions candidates are
atoms that
- Are built-in or referenced from some static datastructure
- All characters are legal characters for unquoted atoms
- The atom is at most 80 characters long
*/
static
PRED_IMPL("$atom_completions", 2, atom_completions, 0)
{ PRED_LD
term_t prefix = A1;
term_t alternatives = A2;
PL_chars_t p_text;
struct match altv[ALT_MAX];
int altn;
int i;
term_t alts = PL_copy_term_ref(alternatives);
term_t head = PL_new_term_ref();
if ( !PL_get_text(prefix, &p_text, CVT_ALL|CVT_EXCEPTION) )
return FALSE;
if ( !extend_alternatives(&p_text, altv, &altn) )
return FALSE; /* interrupt */
for(i=0; i<altn; i++)
{ if ( !PL_unify_list(alts, head, alts) ||
!PL_unify_atom(head, altv[i].name->atom) )
return FALSE;
}
return PL_unify_nil(alts);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Completeness generation for the GNU readline library. This function uses
a state variable to indicate the generator should maintain/reset its
state. Horrible!
We must use thread-local data here. Worse is we can't use the normal
Prolog one as there might not be a Prolog engine associated to the
thread.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifdef O_PLMT
#include <pthread.h>
static pthread_once_t key_created = PTHREAD_ONCE_INIT;
static pthread_key_t key;
static void
atom_generator_create_key(void)
{ pthread_key_create(&key, NULL);
}
#else
static size_t atom_genetor_state;
#endif
static int
atom_generator(PL_chars_t *prefix, PL_chars_t *hit, int state)
{ GET_LD
size_t index;
int i, last=FALSE;
#ifdef O_PLMT
if ( !LD )
pthread_once(&key_created, atom_generator_create_key);
#endif
if ( !state )
{ index = 1;
} else
{ if ( HAS_LD )
index = LD->atoms.generator;
else
#ifdef O_PLMT
index = (size_t)pthread_getspecific(key);
#else
index = atom_genetor_state;
#endif
}
for(i=MSB(index); !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom a = b + index;
if ( is_signalled() ) /* Notably allow windows version */
{ if ( PL_handle_signals() < 0 ) /* to break out on ^C */
return FALSE;
}
if ( ATOM_IS_VALID(a->references) && global_atom(a) &&
get_atom_ptr_text(a, hit) &&
hit->length < ALT_SIZ &&
PL_cmp_text(prefix, 0, hit, 0, prefix->length) == 0 &&
is_identifier_text(hit) )
{ if ( HAS_LD )
LD->atoms.generator = index+1;
else
#ifdef O_PLMT
pthread_setspecific(key, (void *)(index+1));
#else
atom_genetor_state = index;
#endif
return TRUE;
}
}
}
return FALSE;
}
char *
PL_atom_generator(const char *prefix, int state)
{ PL_chars_t txt, hit;
PL_init_text(&txt);
txt.text.t = (char *)prefix;
txt.encoding = ENC_ISO_LATIN_1;
txt.length = strlen(prefix);
while ( atom_generator(&txt, &hit, state) )
{ if ( hit.encoding == ENC_ISO_LATIN_1 )
return hit.text.t; /* text is from atoms, thus static */
state = TRUE;
}
return NULL;
}
pl_wchar_t *
PL_atom_generator_w(const pl_wchar_t *prefix,
pl_wchar_t *buffer,
size_t buflen,
int state)
{ PL_chars_t txt, hit;
PL_init_text(&txt);
txt.text.w = (pl_wchar_t *)prefix;
txt.encoding = ENC_WCHAR;
txt.length = wcslen(prefix);
for( ; atom_generator(&txt, &hit, state); state = TRUE )
{ if ( buflen > hit.length+1 )
{ if ( hit.encoding == ENC_WCHAR )
{ wcscpy(buffer, hit.text.w);
} else
{ const unsigned char *s = (const unsigned char *)hit.text.t;
const unsigned char *e = &s[hit.length];
pl_wchar_t *o;
for(o=buffer; s<e;)
*o++ = *s++;
*o = EOS;
}
return buffer;
}
}
return NULL;
}
size_t
atom_space(void)
{ size_t array = ((size_t)2<<MSB(GD->atoms.highest))*sizeof(struct atom);
size_t index;
int i, last=FALSE;
size_t table = GD->atoms.table->buckets * sizeof(Atom);
size_t data = 0;
for(index=1, i=0; !last; i++)
{ size_t upto = (size_t)2<<i;
size_t high = GD->atoms.highest;
Atom b = GD->atoms.array.blocks[i];
if ( upto >= high )
{ upto = high;
last = TRUE;
}
for(; index<upto; index++)
{ Atom a = b + index;
if ( ATOM_IS_VALID(a->references) )
{ data += a->length; /* TBD: malloc rounding? */
}
}
}
return array+table+data;
}
/*******************************
* PUBLISH PREDICATES *
*******************************/
BeginPredDefs(atom)
PRED_DEF("current_blob", 2, current_blob, PL_FA_NONDETERMINISTIC)
PRED_DEF("current_atom", 1, current_atom, PL_FA_NONDETERMINISTIC)
PRED_DEF("blob", 2, blob, 0)
PRED_DEF("$atom_references", 2, atom_references, 0)
PRED_DEF("$atom_completions", 2, atom_completions, 0)
PRED_DEF("$complete_atom", 3, complete_atom, 0)
EndPredDefs
|
7d73521cfb885dfa5b5749131d8151a4867a354a
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/airm2m/air105/libraries/HAL_Driver/Inc/bsp_common.h
|
3aa87ccc46c837fc3d687cbd018ec8b146c980c5
|
[
"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
| 12,335
|
h
|
bsp_common.h
|
/*
* Copyright (c) 2022 OpenLuat & AirM2M
*
* 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.
*/
#ifndef __BSP_COMMON_H__
#define __BSP_COMMON_H__
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include "cmsis_gcc.h"
typedef struct
{
uint32_t param_max_num;
uint32_t param_max_len;
uint32_t param_num;
int8_t *param_str;
}CmdParam;
typedef struct
{
uint8_t Sec;
uint8_t Min;
uint8_t Hour;
uint8_t Week;//表示日期0~6,sun~sat,表示预约时,bit0~bit6,sun~sat
}Time_UserDataStruct;
typedef struct
{
uint16_t Year;
uint8_t Mon;
uint8_t Day;
}Date_UserDataStruct;
typedef union
{
uint32_t dwTime;
Time_UserDataStruct Time;
}Time_Union;
typedef union
{
uint32_t dwDate;
Date_UserDataStruct Date;
}Date_Union;
typedef struct
{
uint8_t *Data;
uint32_t Len;
uint32_t Offset;
uint32_t MaxLength;
uint32_t DataSize;
}Loop_Buffer;
typedef struct
{
uint8_t *Data;
uint32_t Pos;
uint32_t MaxLen;
}Buffer_Struct;
typedef union
{
void *p;
char *pc8;
uint8_t *pu8;
uint16_t *pu16;
uint32_t *pu32;
uint32_t u32;
uint8_t u8[4];
uint16_t u16[2];
}PV_Union;
enum
{
ERROR_NONE,
ERROR_NO_SUCH_ID,
ERROR_PERMISSION_DENIED,
ERROR_PARAM_INVALID,
ERROR_PARAM_OVERFLOW,
ERROR_DEVICE_BUSY,
ERROR_OPERATION_FAILED,
ERROR_BUFFER_FULL,
ERROR_NO_MEMORY,
ERROR_CMD_NOT_SUPPORT,
ERROR_NO_DATA,
ERROR_NO_FLASH,
ERROR_NO_TIMER,
ERROR_TIMEOUT,
ERROR_SSL_HANDSHAKE,
ERROR_PROTOCL,
ERROR_ID_INVALID,
ERROR_MID_INVALID,
ERROR_RETRY_TOO_MUCH,
ERROR_CMD_BLOCK,
LIST_FIND = 1,
LIST_PASS = 0,
LIST_DEL = -1,
DMA_CB_DONE = 0,
UART_CB_TX_BUFFER_DONE,
UART_CB_TX_ALL_DONE,
UART_CB_RX_NEW,
UART_CB_RX_TIMEOUT,
UART_CB_RX_BUFFER_FULL,
UART_CB_ERROR,
UART_CB_CONNECTED, //串口工具对方已经打开
DMA_CB_ERROR = 0xffffffff,
CORE_EVENT_ID_START = 0,
CORE_EVENT_ID_ANY = 0,
CORE_EVENT_TIMEOUT,
CORE_TIMER_TIMEOUT = 0x00010000,
SERVICE_EVENT_ID_START = 0x00100000,
USER_EVENT_ID_START = 0x10000000,
INVALID_EVENT_ID = 0xffffffff,
};
#define INVALID_HANDLE_VALUE ((void *)0xffffffff)
#define INVALID_PARAM (0xffffffff)
#define CRC32_GEN (0x04C11DB7)
#define CRC32_START (0xffffffff)
#define CRC16_CCITT_GEN (0x1021)
#define CRC16_MODBUS_GEN (0x8005)
#define CRC16_START (0xffff)
#define CRC16_IBM_SEED (0xffff)
#define CRC16_CCITT_SEED (0x1D0F)
#define HANDLE void *
#define MIN(X,Y) (((X) < (Y))?(X):(Y))
typedef void (* TaskFun_t)( void * );
typedef void(* CBDataFun_t)(uint8_t *Data, uint32_t Len);
typedef int32_t(*CBFuncEx_t)(void *pData, void *pParam);
typedef uint64_t LongInt;
typedef struct
{
CBFuncEx_t CB;
union {
void *pParam; //用户回调模式
uint32_t MaxCnt; //设置捕获模式时的最大tick,捕获时的tick
}uParam;
union {
struct {
uint8_t Level; //IO输入输出电平,捕获模式下中断时IO电平
uint8_t PullMode; //IO上下拉控制
} IOArg;
struct {
uint8_t ExtiMode; //中断模式
uint8_t PullMode; //IO上下拉控制
} ExitArg;
uint16_t Time; //delay时间,us
} uArg;
uint8_t Operation; //操作类型
uint8_t Arg1; //IO操作时为IOpin,delay操作时则为微调值,0~47,48为1us
}OPQueue_CmdStruct;
__attribute__((weak)) uint8_t OS_CheckInIrq(void);
uint32_t OS_EnterCritical(void);
void OS_ExitCritical(uint32_t Critical);
void *OS_Malloc(uint32_t Size);
void *OS_Zalloc(uint32_t Size);
void OS_Free(void *p);
void *OS_Realloc(void *buf, uint32_t size);
void OS_MemInfo(uint32_t *curalloc, uint32_t *totfree, uint32_t *maxfree);
int32_t OS_InitBuffer(Buffer_Struct *Buf, uint32_t Size);
void OS_DeInitBuffer(Buffer_Struct *Buf);
int32_t OS_ReInitBuffer(Buffer_Struct *Buf, uint32_t Size);
int32_t OS_ReSizeBuffer(Buffer_Struct *Buf, uint32_t Size);
int32_t OS_BufferWrite(Buffer_Struct *Buf, void *Data, uint32_t Len);
int32_t OS_BufferWriteLimit(Buffer_Struct *Buf, void *Data, uint32_t Len);
void OS_BufferRemove(Buffer_Struct *Buf, uint32_t Len);
void Buffer_StaticInit(Buffer_Struct *Buf, void *Src, uint32_t MaxLen);
int32_t Buffer_StaticWrite(Buffer_Struct *Buf, void *Data, uint32_t Len);
void Buffer_Remove(Buffer_Struct *Buf, uint32_t Len);
void LoopBuffer_Init(Loop_Buffer *Buf, void *Src, uint32_t MaxLen, uint32_t DataSize);
uint32_t LoopBuffer_Query(Loop_Buffer *Buf, void *Src, uint32_t Len);
uint32_t LoopBuffer_Read(Loop_Buffer *Buf, void *Src, uint32_t Len);
void LoopBuffer_Del(Loop_Buffer *Buf, uint32_t Len);
uint32_t LoopBuffer_Write(Loop_Buffer *Buf, void *Src, uint32_t Len);
int32_t BSP_SetBit(uint8_t *Data, uint32_t Sn, uint8_t Value);
int32_t BSP_GetBit(uint8_t *Data, uint32_t Sn, uint8_t *Value);
uint8_t BSP_TestBit(uint8_t *Data, uint32_t Sn);
uint8_t XorCheck(void *Src, uint32_t Len, uint8_t CheckStart);
uint8_t SumCheck(uint8_t *Data, uint32_t Len);
uint16_t CRC16Cal(void *Data, uint16_t Len, uint16_t CRC16Last, uint16_t CRCRoot, uint8_t IsReverse);
uint32_t AsciiToU32(uint8_t *Src, uint32_t Len);
void CRC32_CreateTable(uint32_t *Tab, uint32_t Gen);
uint32_t CRC32_Cal(uint32_t * CRC32_Table, uint8_t *Buf, uint32_t Size, uint32_t CRC32Last);
uint32_t CmdParseParam(int8_t* pStr, CmdParam *CmdParam, int8_t Cut);
uint8_t IsLeapYear(uint32_t Year);
LongInt UTC2Tamp(Date_UserDataStruct *Date, Time_UserDataStruct *Time);
uint32_t Tamp2UTC(LongInt Sec, Date_UserDataStruct *Date, Time_UserDataStruct *Time, uint32_t LastDDay);
/*
* 转义解包
* 标识Flag,即包头包尾加入Flag
* 数据中遇到Code F1 -> Flag
* 数据中遇到Code F2 -> Code
* 数据中遇到Flag 出错返回0
*/
uint32_t TransferUnpack(uint8_t Flag, uint8_t Code, uint8_t F1, uint8_t F2, uint8_t *InBuf, uint32_t Len, uint8_t *OutBuf);
/*
* llist相关代码,大部分来自linux内核
*/
/**
* container_of - cast a member of a structure out to the containing structure
*
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
/*
* These are non-NULL pointers that will result in page faults
* under normal circumstances, used to verify that nobody uses
* non-initialized llist entries.
*/
#define LLIST_POISON1 (0)
#define LLIST_POISON2 (0)
/*
* Simple doubly linked llist implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole llists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
typedef struct llist_head_t{
struct llist_head_t *next, *prev;
}llist_head;
#define LLIST_HEAD_INIT(name) { &(name), &(name) }
#define LLIST_HEAD(name) \
llist_head name = LLIST_HEAD_INIT(name)
#define INIT_LLIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal llist manipulation where we know
* the prev/next entries already!
*/
void __llist_add(llist_head *p,
llist_head *prev,
llist_head *next);
/**
* llist_add - add a new entry
* @new: new entry to be added
* @head: llist head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
void llist_add(llist_head *p, llist_head *head);
/**
* llist_add_tail - add a new entry
* @new: new entry to be added
* @head: llist head to add it before
*
* Insert a new entry before the specified head.
* This is useful for implementing queues.
*/
void llist_add_tail(llist_head *p, llist_head *head);
/*
* Delete a llist entry by making the prev/next entries
* point to each other.
*
* This is only for internal llist manipulation where we know
* the prev/next entries already!
*/
void __llist_del(llist_head * prev, llist_head * next);
/**
* llist_del - deletes entry from llist.
* @entry: the element to delete from the llist.
* Note: llist_empty on entry does not return true after this, the entry is
* in an undefined state.
*/
void llist_del(llist_head *entry);
/**
* llist_del_init - deletes entry from llist and reinitialize it.
* @entry: the element to delete from the llist.
*/
void llist_del_init(llist_head *entry);
/**
* llist_move - delete from one llist and add as another's head
* @llist: the entry to move
* @head: the head that will precede our entry
*/
void llist_move(llist_head *llist, llist_head *head);
/**
* llist_move_tail - delete from one llist and add as another's tail
* @llist: the entry to move
* @head: the head that will follow our entry
*/
void llist_move_tail(llist_head *llist,
llist_head *head);
/**
* llist_empty - tests whether a llist is empty
* @head: the llist to test.
*/
int llist_empty(const llist_head *head);
uint32_t llist_num(const llist_head *head);
void *llist_traversal(llist_head *head, CBFuncEx_t cb, void *pData);
/**
* llist_entry - get the struct for this entry
* @ptr: the &llist_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the llist_struct within the struct.
*/
#define llist_entry(ptr, type, member) \
container_of(ptr, type, member)
uint8_t BytesGet8(const void *ptr);
void BytesPut8(void *ptr, uint8_t v);
uint16_t BytesGetBe16(const void *ptr);
void BytesPutBe16(void *ptr, uint16_t v);
uint32_t BytesGetBe32(const void *ptr);
void BytesPutBe32(void *ptr, uint32_t v);
uint16_t BytesGetLe16(const void *ptr);
void BytesPutLe16(void *ptr, uint16_t v);
uint32_t BytesGetLe32(const void *ptr);
void BytesPutLe32(void *ptr, uint32_t v);
uint64_t BytesGetLe64(const void *ptr);
void BytesPutLe64(void *ptr, uint64_t v);
uint8_t BytesGet8FromBuf(Buffer_Struct *Buf);
void BytesPut8ToBuf(Buffer_Struct *Buf, uint8_t v);
uint16_t BytesGetBe16FromBuf(Buffer_Struct *Buf);
void BytesPutBe16ToBuf(Buffer_Struct *Buf, uint16_t v);
uint32_t BytesGetBe32FromBuf(Buffer_Struct *Buf);
void BytesPutBe32ToBuf(Buffer_Struct *Buf, uint32_t v);
uint16_t BytesGetLe16FromBuf(Buffer_Struct *Buf);
void BytesPutLe16ToBuf(Buffer_Struct *Buf, uint16_t v);
uint32_t BytesGetLe32FromBuf(Buffer_Struct *Buf);
void BytesPutLe32ToBuf(Buffer_Struct *Buf, uint32_t v);
uint64_t BytesGetLe64FromBuf(Buffer_Struct *Buf);
void BytesPutLe64ToBuf(Buffer_Struct *Buf, uint64_t v);
float BytesGetFloatFromBuf(Buffer_Struct *Buf);
void BytesPutFloatToBuf(Buffer_Struct *Buf, float v);
double BytesGetDoubleFromBuf(Buffer_Struct *Buf);
void BytesPutDoubleToBuf(Buffer_Struct *Buf, double v);
/*************************************************************************/
#define malloc OS_Malloc
#define free OS_Free
#define realloc OS_Realloc
#define zalloc OS_Zalloc
#define calloc OS_Calloc
#endif
|
3e9525be1dc9b63a94c88b5860d92d4c24228788
|
aa5c1a530f95d629e686ac9124caf1a49a9f23e9
|
/runtime/src/iree/builtins/ukernel/weak.c
|
6ac984089c885ab3a9165af28cf9194139b845ae
|
[
"Apache-2.0",
"LLVM-exception",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
openxla/iree
|
eacf5b239559e1d3b40c38039ac4c26315b523f7
|
13ef677e556d0a1d154e45b052fe016256057f65
|
refs/heads/main
| 2023-09-06T01:19:49.598662
| 2023-09-04T07:01:30
| 2023-09-04T07:01:30
| 208,145,128
| 387
| 110
|
Apache-2.0
| 2023-09-14T20:48:00
| 2019-09-12T20:57:39
|
C++
|
UTF-8
|
C
| false
| false
| 1,084
|
c
|
weak.c
|
// Copyright 2023 The IREE Authors
//
// Licensed 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
#include "iree/builtins/ukernel/mmt4d_internal.h"
#include "iree/builtins/ukernel/pack_internal.h"
#include "iree/builtins/ukernel/query_tile_sizes_internal.h"
#include "iree/builtins/ukernel/unpack_internal.h"
#if defined(IREE_UK_HAVE_WEAK)
IREE_UK_WEAK iree_uk_mmt4d_tile_func_t
iree_uk_mmt4d_select_tile_func_arch(const iree_uk_mmt4d_params_t* params) {
return 0;
}
IREE_UK_WEAK iree_uk_pack_tile_func_t
iree_uk_pack_select_tile_func_arch(const iree_uk_pack_params_t* params) {
return 0;
}
IREE_UK_WEAK iree_uk_unpack_tile_func_t
iree_uk_unpack_select_tile_func_arch(const iree_uk_unpack_params_t* params) {
return 0;
}
IREE_UK_WEAK bool iree_uk_query_matmul_tile_sizes_arch(
const iree_uk_query_tile_sizes_2d_params_t* params,
iree_uk_matmul_tile_sizes_t* out_matmul_tile_sizes) {
return false;
}
#endif // defined(IREE_UK_HAVE_WEAK)
|
eeefeb0757c62b3d82942e50e26d244f98bc41d3
|
a9a591fc3964117db3b16583c3bfa5a24cfc0114
|
/lib/liblfds7.2.0/src/liblfds720/src/lfds720_btree_nodelete_unbalanced/lfds720_btree_nu_cleanup.c
|
5b22d106777a8836bce99c62594d33af827a9301
|
[
"BSD-2-Clause"
] |
permissive
|
grz0zrg/fas
|
9cd0a55c7e86fcf5cafffd44ebdf633f3ee5fefa
|
07b08a77b78781dd5ed7984117f294fe4fcbe3fd
|
refs/heads/master
| 2022-09-18T05:29:27.983761
| 2022-08-30T19:53:19
| 2022-08-30T19:53:19
| 78,288,048
| 142
| 10
|
BSD-2-Clause
| 2021-05-25T01:43:22
| 2017-01-07T15:53:24
|
C
|
UTF-8
|
C
| false
| false
| 3,891
|
c
|
lfds720_btree_nu_cleanup.c
|
/***** includes *****/
#include "lfds720_btree_nu_internal.h"
/****************************************************************************/
void lfds720_btree_nu_cleanup( struct lfds720_btree_nu_state *baus,
void (*element_cleanup_callback)(struct lfds720_btree_nu_state *baus, struct lfds720_btree_nu_element *baue) )
{
enum lfds720_btree_nu_delete_action
delete_action = LFDS720_BTREE_NU_DELETE_SELF; // TRD : to remove compiler warning
struct lfds720_btree_nu_element
*baue,
*temp;
LFDS720_PAL_ASSERT( baus != NULL );
// TRD : element_delete_function can be NULL
/* TRD : we're not lock-free now, so delete at will
but be iterative, so can be used in kernels (where there's little stack)
and be performant, since the user may be
creating/destroying many of these trees
also remember the user may be deallocating user data
so we cannot visit an element twice
we start at the root and iterate till we go to NULL
if the element has zero children, we delete it and move up to its parent
if the element has one child, we delete it, move its child into its place, and continue from its child
if the element has two children, we move left
the purpose of this is to minimize walking around the tree
to prevent visiting an element twice
while also minimizing code complexity
*/
if( element_cleanup_callback == NULL )
return;
LFDS720_MISC_BARRIER_LOAD;
lfds720_btree_nu_get_by_absolute_position( baus, &baue, LFDS720_BTREE_NU_ABSOLUTE_POSITION_ROOT );
while( baue != NULL )
{
if( baue->left == NULL and baue->right == NULL )
delete_action = LFDS720_BTREE_NU_DELETE_SELF;
if( baue->left != NULL and baue->right == NULL )
delete_action = LFDS720_BTREE_NU_DELETE_SELF_REPLACE_WITH_LEFT_CHILD;
if( baue->left == NULL and baue->right != NULL )
delete_action = LFDS720_BTREE_NU_DELETE_SELF_REPLACE_WITH_RIGHT_CHILD;
if( baue->left != NULL and baue->right != NULL )
delete_action = LFDS720_BTREE_NU_DELETE_MOVE_LEFT;
switch( delete_action )
{
case LFDS720_BTREE_NU_DELETE_SELF:
// TRD : if we have a parent (we could be root) set his point to us to NULL
if( baue->up != NULL )
{
if( baue->up->left == baue )
baue->up->left = NULL;
if( baue->up->right == baue )
baue->up->right = NULL;
}
temp = baue;
lfds720_btree_nu_get_by_relative_position( &baue, LFDS720_BTREE_NU_RELATIVE_POSITION_UP );
element_cleanup_callback( baus, temp );
break;
case LFDS720_BTREE_NU_DELETE_SELF_REPLACE_WITH_LEFT_CHILD:
baue->left->up = baue->up;
if( baue->up != NULL )
{
if( baue->up->left == baue )
baue->up->left = baue->left;
if( baue->up->right == baue )
baue->up->right = baue->left;
}
temp = baue;
lfds720_btree_nu_get_by_relative_position( &baue, LFDS720_BTREE_NU_RELATIVE_POSITION_LEFT );
element_cleanup_callback( baus, temp );
break;
case LFDS720_BTREE_NU_DELETE_SELF_REPLACE_WITH_RIGHT_CHILD:
baue->right->up = baue->up;
if( baue->up != NULL )
{
if( baue->up->left == baue )
baue->up->left = baue->right;
if( baue->up->right == baue )
baue->up->right = baue->right;
}
temp = baue;
lfds720_btree_nu_get_by_relative_position( &baue, LFDS720_BTREE_NU_RELATIVE_POSITION_RIGHT );
element_cleanup_callback( baus, temp );
break;
case LFDS720_BTREE_NU_DELETE_MOVE_LEFT:
lfds720_btree_nu_get_by_relative_position( &baue, LFDS720_BTREE_NU_RELATIVE_POSITION_LEFT );
break;
}
}
return;
}
|
8f16a5794dc8b540d38584f4a6b0f7af8d7893a1
|
a36899b1da27a9bf6f89c5fef60bd71b96779fc7
|
/apis/isis-iobc-supervisor/isis-iobc-supervisor/checksum.h
|
dd96c3e7d218424755f957a9675832ec61419a00
|
[
"Apache-2.0"
] |
permissive
|
kubos/kubos
|
b26cb13f8bc60b9e333906f391c51d8c8651d6ce
|
49b4bf78939cac4161374e696f1b8c834921ad7c
|
refs/heads/master
| 2023-08-03T10:19:22.732695
| 2023-02-21T19:32:46
| 2023-02-21T19:32:46
| 117,996,656
| 300
| 70
|
Apache-2.0
| 2023-07-25T22:54:04
| 2018-01-18T14:55:14
|
Rust
|
UTF-8
|
C
| false
| false
| 2,739
|
h
|
checksum.h
|
/*
* Copyright (C) 2014 Innovative Solution In Space B.V.
* Copyright (C) 2017 Kubos Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @defgroup iOBC-Checksum iOBC Supervisor CRC functions
* @addtogroup iOBC-Checksum
* @{
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
/**
* Generate a LUT for CRC 8 calculations with a certain polynomial
*
* @param[in] polynomial 8-bit CRC polynomial to be used
* @param[out] LUT Pointer to memory block where LUT can be stored, needs to be at least 256 * sizeof(uint8_t)
*/
void checksum_prepare_LUTCRC8(uint8_t polynomial, uint8_t * LUT);
/**
* Calculates a CRC 8 checksum according to CRC-8 CCITT, using a LUT
*
* @param[in] data Pointer to data to calculate the checksum for.
* @param[in] length Length of the data in bytes.
* @param[in] LUT Pointer to LUT to use for CRC calculations, prepared using checksum_prepareLUTCRC8()
* @param[in] start_remainder Remainder to start CRC calculation with
* @param[in] endofdata Indicates whether this is the end of larger datablock (TRUE) or not yet (FALSE)
* @return uint8_t 8-bit CRC checksum.
*/
uint8_t checksum_calculate_CRC8LUT(const uint8_t * data, unsigned int length, const uint8_t * LUT, uint8_t start_remainder, bool endofdata);
/**
* Calculates a CRC 8 checksum according to CRC-8 CCITT, using bitwise calculation
*
* @param[in] data Pointer to data to calculate the checksum for.
* @param[in] length Length of the data in bytes.
* @param[in] polynomial 8-bit CRC polynomial to be used.
* @param[in] start_remainder Remainder to start CRC calculation with
* @param[in] endofdata Indicates whether this is the end of larger datablock (TRUE) or not yet (FALSE)
* @return uint8_t 8-bit CRC checksum.
*/
uint8_t checksum_calculate_CRC8(const uint8_t * data, unsigned int length, uint8_t polynomial, uint8_t start_remainder, bool endofdata);
/**
* Calculates a CRC checksum according to the algorithm used in the iOBC supervisor.
* @param[in] data Pointer to data to calculate the checksum for.
* @param[in] length Length of the data in bytes
* @return uint8_t 8-bit CRC checksum.
*/
uint8_t supervisor_calculate_CRC(const uint8_t * data, unsigned int length);
/* @} */
|
f9ce7aa92e8193a8d513cd0b42707443f3805a6d
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/x86/include/i82489reg.h
|
b5cb4634d3f0bed1c7c4c0775d52bddab331e979
|
[] |
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
| 8,285
|
h
|
i82489reg.h
|
/* $NetBSD: i82489reg.h,v 1.19 2019/06/14 05:59:39 msaitoh Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Frank van der Linden.
*
* 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.
*/
/*
* Registers and constants for the 82489DX and Pentium (and up) integrated
* "local" APIC.
*/
#define LAPIC_ID 0x020 /* ID. (xAPIC: RW, x2APIC: RO) */
# define LAPIC_ID_MASK 0xff000000
# define LAPIC_ID_SHIFT 24
#define LAPIC_VERS 0x030 /* Version. RO */
# define LAPIC_VERSION_MASK 0x000000ff
# define LAPIC_VERSION_LVT_MASK 0x00ff0000
# define LAPIC_VERSION_LVT_SHIFT 16
# define LAPIC_VERSION_DIRECTED_EOI 0x01000000
# define LAPIC_VERSION_EXTAPIC_SPACE 0x80000000
#define LAPIC_TPRI 0x080 /* Task Prio. RW */
# define LAPIC_TPRI_MASK 0x000000ff
# define LAPIC_TPRI_INT_MASK 0x000000f0
# define LAPIC_TPRI_SUB_MASK 0x0000000f
#define LAPIC_APRI 0x090 /* Arbitration prio (xAPIC: RO, x2APIC: NA) */
# define LAPIC_APRI_MASK 0x000000ff
#define LAPIC_PPRI 0x0a0 /* Processor prio. RO */
#define LAPIC_EOI 0x0b0 /* End Int. W */
#define LAPIC_RRR 0x0c0 /* Remote read (xAPIC: RO, x2APIC: NA) */
#define LAPIC_LDR 0x0d0 /* Logical dest. (xAPIC: RW, x2APIC: RO) */
#define LAPIC_DFR 0x0e0 /* Dest. format (xAPIC: RW, x2APIC: NA) */
# define LAPIC_DFR_MASK 0xf0000000
# define LAPIC_DFR_FLAT 0xf0000000
# define LAPIC_DFR_CLUSTER 0x00000000
#define LAPIC_SVR 0x0f0 /* Spurious intvec RW */
# define LAPIC_SVR_VECTOR_MASK 0x000000ff
# define LAPIC_SVR_VEC_FIX 0x0000000f
# define LAPIC_SVR_VEC_PROG 0x000000f0
# define LAPIC_SVR_ENABLE 0x00000100
# define LAPIC_SVR_SWEN 0x00000100
# define LAPIC_SVR_FOCUS 0x00000200
# define LAPIC_SVR_FDIS 0x00000200
# define LAPIC_SVR_EOI_BC_DIS 0x00001000
#define LAPIC_ISR 0x100 /* In-Service Status RO */
#define LAPIC_TMR 0x180 /* Trigger Mode RO */
#define LAPIC_IRR 0x200 /* Interrupt Req RO */
#define LAPIC_ESR 0x280 /* Err status. RW */
/* Common definitions for ICR, LVT and MSIDATA */
#define LAPIC_VECTOR_MASK __BITS(7, 0)
#define LAPIC_DLMODE_MASK __BITS(10, 8) /* Delivery Mode */
#define LAPIC_DLMODE_FIXED __SHIFTIN(0, LAPIC_DLMODE_MASK)
#define LAPIC_DLMODE_LOW __SHIFTIN(1, LAPIC_DLMODE_MASK) /* NA in x2APIC */
#define LAPIC_DLMODE_SMI __SHIFTIN(2, LAPIC_DLMODE_MASK)
#define LAPIC_DLMODE_NMI __SHIFTIN(4, LAPIC_DLMODE_MASK)
#define LAPIC_DLMODE_INIT __SHIFTIN(5, LAPIC_DLMODE_MASK)
#define LAPIC_DLMODE_STARTUP __SHIFTIN(6, LAPIC_DLMODE_MASK) /* NA in LVT,MSI*/
#define LAPIC_DLMODE_EXTINT __SHIFTIN(7, LAPIC_DLMODE_MASK) /* NA in x2APIC */
#define LAPIC_DLSTAT_BUSY __BIT(12) /* NA in x2APIC nor MSI */
#define LAPIC_DLSTAT_IDLE 0x00000000
#define LAPIC_LEVEL_MASK __BIT(14) /* LAPIC_LVT_LINT_RIRR in LVT LINT */
#define LAPIC_LEVEL_ASSERT LAPIC_LEVEL_MASK
#define LAPIC_LEVEL_DEASSERT 0x00000000
#define LAPIC_TRIGMODE_MASK __BIT(15)
#define LAPIC_TRIGMODE_EDGE 0x00000000
#define LAPIC_TRIGMODE_LEVEL LAPIC_TRIGMODE_MASK
/* Common definitions for LVT */
#define LAPIC_LVT_MASKED __BIT(16)
#define LAPIC_LVT_CMCI 0x2f0 /* Loc.vec (CMCI) RW */
#define LAPIC_ICRLO 0x300 /* Int. cmd. (xAPIC: RW, x2APIC: RW64) */
# define LAPIC_DSTMODE_MASK __BIT(11)
# define LAPIC_DSTMODE_PHYS __SHIFTIN(0, LAPIC_DSTMODE_MASK)
# define LAPIC_DSTMODE_LOG __SHIFTIN(1, LAPIC_DSTMODE_MASK)
# define LAPIC_DEST_MASK __BITS(19, 18)
# define LAPIC_DEST_DEFAULT __SHIFTIN(0, LAPIC_DEST_MASK)
# define LAPIC_DEST_SELF __SHIFTIN(1, LAPIC_DEST_MASK)
# define LAPIC_DEST_ALLINCL __SHIFTIN(2, LAPIC_DEST_MASK)
# define LAPIC_DEST_ALLEXCL __SHIFTIN(3, LAPIC_DEST_MASK)
#define LAPIC_ICRHI 0x310 /* Int. cmd. (xAPIC: RW, x2APIC: NA) */
#define LAPIC_LVT_TIMER 0x320 /* Loc.vec.(timer) RW */
# define LAPIC_LVT_TMM __BITS(18, 17)
# define LAPIC_LVT_TMM_ONESHOT __SHIFTIN(0, LAPIC_LVT_TMM)
# define LAPIC_LVT_TMM_PERIODIC __SHIFTIN(1, LAPIC_LVT_TMM)
# define LAPIC_LVT_TMM_TSCDLT __SHIFTIN(2, LAPIC_LVT_TMM)
#define LAPIC_LVT_THERM 0x330 /* Loc.vec (Thermal) RW */
#define LAPIC_LVT_PCINT 0x340 /* Loc.vec (Perf Mon) RW */
#define LAPIC_LVT_LINT0 0x350 /* Loc.vec (LINT0) RW */
# define LAPIC_LVT_LINT_INP_POL __BIT(13)
# define LAPIC_LVT_LINT_RIRR __BIT(14)
#define LAPIC_LVT_LINT1 0x360 /* Loc.vec (LINT1) RW */
#define LAPIC_LVT_ERR 0x370 /* Loc.vec (ERROR) RW */
#define LAPIC_ICR_TIMER 0x380 /* Initial count RW */
#define LAPIC_CCR_TIMER 0x390 /* Current count RO */
#define LAPIC_DCR_TIMER 0x3e0 /* Divisor config RW */
# define LAPIC_DCRT_DIV1 0x0b
# define LAPIC_DCRT_DIV2 0x00
# define LAPIC_DCRT_DIV4 0x01
# define LAPIC_DCRT_DIV8 0x02
# define LAPIC_DCRT_DIV16 0x03
# define LAPIC_DCRT_DIV32 0x08
# define LAPIC_DCRT_DIV64 0x09
# define LAPIC_DCRT_DIV128 0x0a
#define LAPIC_SELF_IPI 0x3f0 /* SELF IPI (xAPIC: NA, x2APIC: W) */
# define LAPIC_SELF_IPI_VEC_MASK 0x000000ff
#define LAPIC_MSIADDR_BASE 0xfee00000
#define LAPIC_MSIADDR_DSTID_MASK __BITS(19, 12)
#define LAPIC_MSIADDR_RSVD0_MASK __BITS(11, 4)
#define LAPIC_MSIADDR_RH __BIT(3)
#define LAPIC_MSIADDR_DM __BIT(2)
#define LAPIC_MSIADDR_RSVD1_MASK __BITS(1, 0)
#define LAPIC_BASE 0xfee00000
#define LAPIC_IRQ_MASK(i) (1 << ((i) + 1))
/* Extended APIC registers, valid when CPUID features4 EAPIC is present */
#define LEAPIC_FR 0x400 /* Feature register */
# define LEAPIC_FR_ELC __BITS(23,16) /* Ext. Lvt Count RO */
# define LEAPIC_FR_EIDCAP __BIT(2) /* Ext. Apic ID Cap. RO */
# define LEAPIC_FR_SEIOCAP __BIT(1) /* Specific EOI Cap. RO */
# define LEAPIC_FR_IERCAP __BIT(0) /* Intr. Enable Reg. RO */
#define LEAPIC_CR 0x410 /* Control Register */
# define LEAPIC_CR_EID_ENABLE __BIT(2) /* Ext. Apic ID enable */
# define LEAPIC_CR_SEOI_ENABLE __BIT(1) /* Specific EOI enable */
# define LEAPIC_CR_IER_ENABLE __BIT(0) /* Enable writes to IER */
#define LEAPIC_SEOIR 0x420 /* Specific EOI Register */
# define LEAPIC_SEOI_VEC __BITS(7,0)
#define LEAPIC_IER_480 0x480 /* Interrupts 0-31 */
#define LEAPIC_IER_490 0x490 /* Interrupts 32-63 */
#define LEAPIC_IER_4B0 0x4B0 /* Interrupts 64-95 */
#define LEAPIC_IER_4C0 0x4C0 /* Interrupts 96-127 */
#define LEAPIC_IER_4D0 0x4D0 /* Interrupts 128-159 */
#define LEAPIC_IER_4E0 0x4E0 /* Interrupts 160-191 */
#define LEAPIC_IER_4F0 0x4F0 /* Interrupts 192-255 */
/* Extended Local Vector Table Entries */
#define LEAPIC_LVTR_500 0x500
#define LEAPIC_LVTR_504 0x504
#define LEAPIC_LVTR_508 0x508
#define LEAPIC_LVTR_50C 0x50C
#define LEAPIC_LVTR_510 0x510
#define LEAPIC_LVTR_514 0x514
#define LEAPIC_LVTR_518 0x518
#define LEAPIC_LVTR_51C 0x51C
#define LEAPIC_LVTR_520 0x520
#define LEAPIC_LVTR_524 0x524
#define LEAPIC_LVTR_528 0x528
#define LEAPIC_LVTR_52C 0x52C
#define LEAPIC_LVTR_530 0x530
# define LEAPIC_LVTR_MASK __BIT(16) /* interrupt masked RW */
# define LEAPIC_LVTR_DSTAT __BIT(12) /* delivery state RO */
# define LEAPIC_LVTR_MSGTYPE __BITS(10,8) /* Message type */
# define LEAPIC_LVTR_VEC __BITS(7,0) /* the intr. vector */
|
86ca894680a496d193d4a32a49000fd15216dbcb
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/u-boot_new/arch/blackfin/include/asm/serial4.h
|
65483960b9cb092eb2d8388840460d9717dd9c9f
|
[
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"GPL-2.0-or-later"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 3,490
|
h
|
serial4.h
|
/*
* serial.h - common serial defines for early debug and serial driver.
* any functions defined here must be always_inline since
* initcode cannot have function calls.
*
* Copyright (c) 2004-2011 Analog Devices Inc.
*
* Licensed under the GPL-2 or later.
*/
#ifndef __BFIN_CPU_SERIAL4_H__
#define __BFIN_CPU_SERIAL4_H__
#include <asm/mach-common/bits/uart4.h>
#ifndef __ASSEMBLY__
#include <asm/clock.h>
#define MMR_UART(n) _PASTE_UART(n, UART, REVID)
#define UART_BASE MMR_UART(CONFIG_UART_CONSOLE)
struct bfin_mmr_serial {
u32 revid;
u32 control;
u32 status;
u32 scr;
u32 clock;
u32 emask;
u32 emaskst;
u32 emaskcl;
u32 rbr;
u32 thr;
u32 taip;
u32 tsr;
u32 rsr;
u32 txdiv_cnt;
u32 rxdiv_cnt;
};
#define uart_lsr_t uint32_t
#define _lsr_read(p) bfin_read(&p->status)
#define _lsr_write(p, v) bfin_write(&p->status, v)
__attribute__((always_inline))
static inline void serial_early_do_mach_portmux(char port, int mux_mask,
int mux_func, int port_pin)
{
switch (port) {
case 'D':
bfin_write_PORTD_MUX((bfin_read_PORTD_MUX() &
~mux_mask) | mux_func);
bfin_write_PORTD_FER_SET(port_pin);
break;
case 'G':
bfin_write_PORTG_MUX((bfin_read_PORTG_MUX() &
~mux_mask) | mux_func);
bfin_write_PORTG_FER_SET(port_pin);
break;
}
}
__attribute__((always_inline))
static inline void serial_early_do_portmux(void)
{
#if defined(__ADSPBF60x__)
switch (CONFIG_UART_CONSOLE) {
case 0:
serial_early_do_mach_portmux('D', PORT_x_MUX_7_MASK,
PORT_x_MUX_7_FUNC_2, PD7); /* TX: D; mux 7; func 2; PD7 */
serial_early_do_mach_portmux('D', PORT_x_MUX_8_MASK,
PORT_x_MUX_8_FUNC_2, PD8); /* RX: D; mux 8; func 2; PD8 */
break;
case 1:
serial_early_do_mach_portmux('G', PORT_x_MUX_15_MASK,
PORT_x_MUX_15_FUNC_1, PG15); /* TX: G; mux 15; func 1; PG15 */
serial_early_do_mach_portmux('G', PORT_x_MUX_14_MASK,
PORT_x_MUX_14_FUNC_1, PG14); /* RX: G; mux 14; func 1; PG14 */
break;
}
#else
# if (P_UART(RX) & P_DEFINED) || (P_UART(TX) & P_DEFINED)
# error "missing portmux logic for UART"
# endif
#endif
SSYNC();
}
__attribute__((always_inline))
static inline int uart_init(uint32_t uart_base)
{
/* always enable UART to 8-bit mode */
bfin_write(&pUART->control, UEN | UMOD_UART | WLS_8);
SSYNC();
return 0;
}
__attribute__((always_inline))
static inline int serial_early_init(uint32_t uart_base)
{
/* handle portmux crap on different Blackfins */
serial_do_portmux();
return uart_init(uart_base);
}
__attribute__((always_inline))
static inline int serial_early_uninit(uint32_t uart_base)
{
/* disable the UART by clearing UEN */
bfin_write(&pUART->control, 0);
return 0;
}
__attribute__((always_inline))
static inline void serial_set_divisor(uint32_t uart_base, uint16_t divisor)
{
/* Program the divisor to get the baud rate we want */
bfin_write(&pUART->clock, divisor);
SSYNC();
}
__attribute__((always_inline))
static inline void serial_early_set_baud(uint32_t uart_base, uint32_t baud)
{
uint16_t divisor = early_division(early_get_uart_clk(), baud * 16);
/* Program the divisor to get the baud rate we want */
serial_set_divisor(uart_base, divisor);
}
__attribute__((always_inline))
static inline void serial_early_put_div(uint32_t divisor)
{
uint32_t uart_base = UART_BASE;
bfin_write(&pUART->clock, divisor);
}
__attribute__((always_inline))
static inline uint32_t serial_early_get_div(void)
{
uint32_t uart_base = UART_BASE;
return bfin_read(&pUART->clock);
}
#endif
#endif
|
eae392cc77cdfc8d6a735f427015fa891af643b0
|
c43b5835b4499f4e6d6fa4efda9546dc67ae0767
|
/sfepy/discrete/common/extmods/geomtrans.c
|
31efae02cd32f69c835a440cc2819a34a000e9ab
|
[
"BSD-3-Clause"
] |
permissive
|
sfepy/sfepy
|
4b74e7839b5e7b5e8d90e19ab6e90a068fe33df4
|
0c2d1690e764b601b2687be1e4261b82207ca366
|
refs/heads/master
| 2023-09-04T22:07:28.041123
| 2023-08-28T14:47:50
| 2023-08-28T14:47:50
| 802,525
| 651
| 188
|
BSD-3-Clause
| 2023-09-12T07:28:19
| 2010-07-28T09:14:41
|
Python
|
UTF-8
|
C
| false
| false
| 1,582
|
c
|
geomtrans.c
|
#include "geomtrans.h"
#undef __FUNC__
#define __FUNC__ "gtr_cross_product"
/*!
@par Revision history:
- 22.03.2002, c
*/
int32 gtr_cross_product( float64 obj[3], float64 obj1[3], float64 obj2[3] )
{
obj[0] = obj1[1]*obj2[2]-obj1[2]*obj2[1];
obj[1] = obj1[2]*obj2[0]-obj1[0]*obj2[2];
obj[2] = obj1[0]*obj2[1]-obj1[1]*obj2[0];
return( RET_OK );
}
#undef __FUNC__
#define __FUNC__ "gtr_normalize_v3"
/*!
@par Revision history:
- 22.03.2002, c
*/
int32 gtr_normalize_v3( float64 obj[3], float64 obj1[3], int32 dim,
int32 verbose )
{
float64 norm;
if (dim == 3) {
norm = sqrt( obj1[0] * obj1[0] + obj1[1] * obj1[1] + obj1[2] * obj1[2] );
if (norm > CONST_MachEps) {
obj[0] = obj1[0] / norm;
obj[1] = obj1[1] / norm;
obj[2] = obj1[2] / norm;
} else {
if (verbose) errput( "zero norm!\n" );
obj[0] = obj[1] = obj[2] = 0.0;
}
} else { // dim == 2
norm = sqrt( obj1[0] * obj1[0] + obj1[1] * obj1[1] );
if (norm > CONST_MachEps) {
obj[0] = obj1[0] / norm;
obj[1] = obj1[1] / norm;
} else {
if (verbose) errput( "zero norm!\n" );
obj[0] = obj[1] = 0.0;
}
}
return( RET_OK );
}
#undef __FUNC__
#define __FUNC__ "gtr_dot_v3"
/*!
@par Revision history:
- 08.06.2006, c
*/
int32 gtr_dot_v3( float64 *p_val, float64 obj1[3], float64 obj2[3], int32 dim )
{
if (dim == 3) {
*p_val = obj1[0] * obj2[0] + obj1[1] * obj2[1] + obj1[2] * obj2[2];
} else { // dim == 2
*p_val = obj1[0] * obj2[0] + obj1[1] * obj2[1];
}
return( RET_OK );
}
|
83efd79e222cae4435909c4224db814220ddc9b2
|
167c6226bc77c5daaedab007dfdad4377f588ef4
|
/cpp/ql/test/library-tests/enums/typedefs/test.c
|
4fb9c180382f77fc1d93a3a6861e3287dc1ed053
|
[
"LicenseRef-scancode-public-domain",
"MIT"
] |
permissive
|
github/codeql
|
1eebb449a34f774db9e881b52cb8f7a1b1a53612
|
d109637e2d7ab3b819812eb960c05cb31d9d2168
|
refs/heads/main
| 2023-08-20T11:32:39.162059
| 2023-08-18T14:33:32
| 2023-08-18T14:33:32
| 143,040,428
| 5,987
| 1,363
|
MIT
| 2023-09-14T19:36:50
| 2018-07-31T16:35:51
|
CodeQL
|
UTF-8
|
C
| false
| false
| 54
|
c
|
test.c
|
enum {
E
};
f(void) {
__typeof__(E) j = E;
}
|
1ee8f65bd8706695cc50c4c64d11144008f6f75e
|
e73547787354afd9b717ea57fe8dd0695d161821
|
/src/battle/area/kmr_part_2/area.c
|
67cc9d80c630cd5765e105887ccee0c4dcca39bc
|
[] |
no_license
|
pmret/papermario
|
8b514b19653cef8d6145e47499b3636b8c474a37
|
9774b26d93f1045dd2a67e502b6efc9599fb6c31
|
refs/heads/main
| 2023-08-31T07:09:48.951514
| 2023-08-21T18:07:08
| 2023-08-21T18:07:08
| 287,151,133
| 904
| 139
| null | 2023-09-14T02:44:23
| 2020-08-13T01:22:57
|
C
|
UTF-8
|
C
| false
| false
| 1,438
|
c
|
area.c
|
#include "area.h"
extern ActorBlueprint A(red_goomba_1);
extern ActorBlueprint A(red_goomba_2);
extern ActorBlueprint A(blue_goomba_1);
extern ActorBlueprint A(blue_goomba_2);
extern ActorBlueprint A(goomba_king);
extern ActorBlueprint A(goomnut_tree);
extern Stage A(kmr_02);
extern Stage A(kmr_03);
extern Stage A(kmr_04);
extern Stage A(kmr_05);
extern Stage A(kmr_06);
Vec3i A(BlueMinibossPos) = { 14, 0, -10 };
Vec3i A(RedMinibossPos) = { 54, 0, 32 };
Formation A(Formation_00) = {
ACTOR_BY_POS(A(blue_goomba_1), A(BlueMinibossPos), 10),
ACTOR_BY_POS(A(red_goomba_1), A(RedMinibossPos), 10),
};
Vec3i A(KingBossPos) = { 10, 0, 10 };
Vec3i A(RedBossPos) = { 70, 0, 30 };
Vec3i A(BlueBossPos) = { 125, 0, 20 };
Vec3i A(TreeBossPos) = { -40, 0, -45 };
Formation A(Formation_01) = {
ACTOR_BY_POS(A(goomba_king), A(KingBossPos), 10),
ACTOR_BY_POS(A(red_goomba_2), A(RedBossPos), 10),
ACTOR_BY_POS(A(blue_goomba_2), A(BlueBossPos), 10),
ACTOR_BY_POS(A(goomnut_tree), A(TreeBossPos), 10),
};
BattleList A(Formations) = {
BATTLE(A(Formation_00), A(kmr_03), "クリレッド,クリブルー"),
BATTLE(A(Formation_01), A(kmr_06), "クリキング,クリレッド,クリブルー"),
{},
};
StageList A(Stages) = {
STAGE("kmr_02", A(kmr_02)),
STAGE("kmr_03", A(kmr_03)),
STAGE("kmr_04", A(kmr_04)),
STAGE("kmr_05", A(kmr_05)),
STAGE("kmr_06", A(kmr_06)),
{},
};
|
142292ad925a1e5d45cb5ff19a89f64919200679
|
44ad9d2de0fd2113501820e814511b355979e3de
|
/include/chemfiles/capi/selection.h
|
bfdcc13aeaf9c098bcae85244f70b65d7acae016
|
[
"GPL-1.0-or-later",
"MPL-2.0",
"BSD-3-Clause",
"MPL-1.0"
] |
permissive
|
chemfiles/chemfiles
|
eae2760c50f01d225ddbf70c6bc7e9be8bd62f65
|
501b7cbb767899aa1e2e23eb8e23787ab5bbcc3b
|
refs/heads/master
| 2023-09-01T07:15:14.741611
| 2023-08-16T09:16:29
| 2023-08-22T14:18:55
| 30,712,631
| 148
| 67
|
BSD-3-Clause
| 2023-09-07T13:58:54
| 2015-02-12T16:50:09
|
C++
|
UTF-8
|
C
| false
| false
| 3,461
|
h
|
selection.h
|
// Chemfiles, a modern library for chemistry file reading and writing
// Copyright (C) Guillaume Fraux and contributors -- BSD license
#ifndef CHEMFILES_CHFL_SELECTION_H
#define CHEMFILES_CHFL_SELECTION_H
#include <stdint.h>
#include "chemfiles/capi/types.h"
#include "chemfiles/exports.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Create a new selection from the given `selection` string.
///
/// The caller of this function should free the associated memory using
/// `chfl_free`.
///
/// @example{capi/chfl_selection/chfl_selection.c}
/// @return A pointer to the selection, or NULL in case of error.
/// You can use `chfl_last_error` to learn about the error.
CHFL_EXPORT CHFL_SELECTION* chfl_selection(const char* selection);
/// Get a copy of a `selection`.
///
/// The copy does not contains any state, and `chfl_selection_evaluate` must be
/// called again before using `chfl_selection_matches`.
///
/// The caller of this function should free the associated memory using
/// `chfl_free`.
///
/// @example{capi/chfl_selection/copy.c}
/// @return A pointer to the new selection, or NULL in case of error.
/// You can use `chfl_last_error` to learn about the error.
CHFL_EXPORT CHFL_SELECTION* chfl_selection_copy(const CHFL_SELECTION* selection);
/// Get the size of a `selection` in `size`.
///
/// The size of a selection is the number of atoms we are selecting together.
/// This value is 1 for the 'atom' context, 2 for the 'pair' and 'bond' context,
/// 3 for the 'three' and 'angles' contexts and 4 for the 'four' and 'dihedral'
/// contexts.
///
/// @example{capi/chfl_selection/size.c}
/// @return The operation status code. You can use `chfl_last_error` to learn
/// about the error if the status code is not `CHFL_SUCCESS`.
CHFL_EXPORT chfl_status chfl_selection_size(
const CHFL_SELECTION* selection, uint64_t* size
);
/// Get the selection string used to create a given `selection` in the `string`
/// buffer.
///
/// The buffer size must be passed in `buffsize`. This function will truncate
/// the selection string to fit in the buffer.
///
/// @example{capi/chfl_selection/string.c}
/// @return The operation status code. You can use `chfl_last_error` to learn
/// about the error if the status code is not `CHFL_SUCCESS`.
CHFL_EXPORT chfl_status chfl_selection_string(
const CHFL_SELECTION* selection, char* string, uint64_t buffsize
);
/// Evaluate a `selection` for a given `frame`, and store the number of matches
/// in `n_matches`.
///
/// Use the `chfl_selection_matches` function to get the matches for this
/// selection.
///
/// @example{capi/chfl_selection/evaluate.c}
/// @return The operation status code. You can use `chfl_last_error` to learn
/// about the error if the status code is not `CHFL_SUCCESS`.
CHFL_EXPORT chfl_status chfl_selection_evaluate(
CHFL_SELECTION* selection, const CHFL_FRAME* frame, uint64_t* n_matches
);
/// Get the matches for a `selection` after a call to `chfl_selection_evaluate`,
/// in `matches`.
///
/// The size of the `matches` array must be passed in `n_matches`.
///
/// @example{capi/chfl_selection/matches.c}
/// @return The operation status code. You can use `chfl_last_error` to learn
/// about the error if the status code is not `CHFL_SUCCESS`.
CHFL_EXPORT chfl_status chfl_selection_matches(
const CHFL_SELECTION* selection, chfl_match matches[], uint64_t n_matches
);
#ifdef __cplusplus
}
#endif
#endif
|
1a02533e73d6f1a0c3833b025c99aaefdaacf21e
|
35e28d7705773eed54345af4440700522c9d1863
|
/deps/libgdal/gdal/frmts/aigrid/aigrid.h
|
ac482f68b62ffc90dbf11feefcc8660973f20c2e
|
[
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"MIT",
"SunPro",
"LicenseRef-scancode-info-zip-2005-02",
"BSD-3-Clause"
] |
permissive
|
naturalatlas/node-gdal
|
0ee3447861bf2d1abc48d4fbdbcf15aba5473a27
|
c83e7858a9ec566cc91d65db74fd07b99789c0f0
|
refs/heads/master
| 2023-09-03T00:11:41.576937
| 2022-03-12T20:41:59
| 2022-03-12T20:41:59
| 19,504,824
| 522
| 122
|
Apache-2.0
| 2022-06-04T20:03:43
| 2014-05-06T18:02:34
|
C++
|
UTF-8
|
C
| false
| false
| 4,785
|
h
|
aigrid.h
|
/******************************************************************************
* $Id: aigrid.h 202f8010aba43611725e3e6ba2ddb5971bc9fdb0 2018-02-25 22:13:32Z Even Rouault $
*
* Project: Arc/Info Binary Grid Translator
* Purpose: Grid file access include file.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* 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.
****************************************************************************/
#ifndef AIGRID_H_INCLUDED
#define AIGRID_H_INCLUDED
#include "cpl_conv.h"
CPL_C_START
#define ESRI_GRID_NO_DATA -2147483647
/*#define ESRI_GRID_FLOAT_NO_DATA -340282306073709652508363335590014353408.0 */
#define ESRI_GRID_FLOAT_NO_DATA -340282346638528859811704183484516925440.0
/* ==================================================================== */
/* Grid Instance */
/* ==================================================================== */
typedef struct {
int nBlocks;
GUInt32 *panBlockOffset;
int *panBlockSize;
VSILFILE *fpGrid; // The w001001.adf file.
int bTriedToLoad;
} AIGTileInfo;
typedef struct {
/* Private information */
AIGTileInfo *pasTileInfo;
int bHasWarned;
int nFailedOpenings;
/* public information */
char *pszCoverName; // Path of coverage directory.
GInt32 nCellType;
GInt32 bCompressed;
#define AIG_CELLTYPE_INT 1
#define AIG_CELLTYPE_FLOAT 2
GInt32 nBlockXSize;
GInt32 nBlockYSize;
GInt32 nBlocksPerRow;
GInt32 nBlocksPerColumn;
int nTileXSize;
int nTileYSize;
int nTilesPerRow;
int nTilesPerColumn;
double dfLLX;
double dfLLY;
double dfURX;
double dfURY;
double dfCellSizeX;
double dfCellSizeY;
int nPixels;
int nLines;
double dfMin;
double dfMax;
double dfMean;
double dfStdDev;
} AIGInfo_t;
/* ==================================================================== */
/* Private APIs */
/* ==================================================================== */
CPLErr AIGAccessTile( AIGInfo_t *psInfo, int iTileX, int iTileY );
CPLErr AIGReadBlock( VSILFILE * fp, GUInt32 nBlockOffset, int nBlockSize,
int nBlockXSize, int nBlockYSize, GInt32 * panData,
int nCellType, int bCompressed );
CPLErr AIGReadHeader( const char *, AIGInfo_t * );
CPLErr AIGReadBlockIndex( AIGInfo_t *, AIGTileInfo *,
const char *pszBasename );
CPLErr AIGReadBounds( const char *, AIGInfo_t * );
CPLErr AIGReadStatistics( const char *, AIGInfo_t * );
CPLErr DecompressCCITTRLETile( unsigned char *pabySrcData, int nSrcBytes,
unsigned char *pabyDstData, int nDstBytes,
int nBlockXSize, int nBlockYSize );
/* ==================================================================== */
/* Public APIs */
/* ==================================================================== */
AIGInfo_t *AIGOpen( const char *, const char * );
CPLErr AIGReadTile( AIGInfo_t *, int, int, GInt32 * );
CPLErr AIGReadFloatTile( AIGInfo_t *, int, int, float * );
void AIGClose( AIGInfo_t * );
VSILFILE *AIGLLOpen( const char *, const char * );
CPL_C_END
#endif /* ndef AIGRID_H_INCLUDED */
|
ffa097f3d41d2d00b544c4162f831435db14e082
|
2c12a63e0690cab8dcbcc8e83c881ad211782881
|
/taskchampion/integration-tests/src/bindings_tests/uuid.c
|
83b02482d13d9a1984d82e45574f1a1cf4975c09
|
[
"MIT"
] |
permissive
|
GothenburgBitFactory/taskwarrior
|
f80a9ec3c22d13698e4646d7a6d3f453dc373b48
|
743ded84c1d3c19ca6d21b3307c49a18d2aa6e39
|
refs/heads/develop
| 2023-09-04T23:38:48.521588
| 2023-09-04T19:50:38
| 2023-09-04T19:50:38
| 120,080,377
| 3,618
| 332
|
MIT
| 2023-09-12T02:05:35
| 2018-02-03T10:14:26
|
C++
|
UTF-8
|
C
| false
| false
| 2,207
|
c
|
uuid.c
|
#include <string.h>
#include "unity.h"
#include "taskchampion.h"
// creating UUIDs does not crash
static void test_uuid_creation(void) {
tc_uuid_new_v4();
tc_uuid_nil();
}
// converting UUIDs to a buf works
static void test_uuid_to_buf(void) {
TEST_ASSERT_EQUAL(TC_UUID_STRING_BYTES, 36);
TCUuid u2 = tc_uuid_nil();
char u2str[TC_UUID_STRING_BYTES];
tc_uuid_to_buf(u2, u2str);
TEST_ASSERT_EQUAL_MEMORY("00000000-0000-0000-0000-000000000000", u2str, TC_UUID_STRING_BYTES);
}
// converting UUIDs to a buf works
static void test_uuid_to_str(void) {
TCUuid u = tc_uuid_nil();
TCString s = tc_uuid_to_str(u);
TEST_ASSERT_EQUAL_STRING(
"00000000-0000-0000-0000-000000000000",
tc_string_content(&s));
tc_string_free(&s);
}
// converting valid UUIDs from string works
static void test_uuid_valid_from_str(void) {
TCUuid u;
char *ustr = "23cb25e0-5d1a-4932-8131-594ac6d3a843";
TEST_ASSERT_EQUAL(TC_RESULT_OK, tc_uuid_from_str(tc_string_borrow(ustr), &u));
TEST_ASSERT_EQUAL(0x23, u.bytes[0]);
TEST_ASSERT_EQUAL(0x43, u.bytes[15]);
}
// converting invalid UUIDs from string fails as expected
static void test_uuid_invalid_string_fails(void) {
TCUuid u;
char *ustr = "not-a-valid-uuid";
TEST_ASSERT_EQUAL(TC_RESULT_ERROR, tc_uuid_from_str(tc_string_borrow(ustr), &u));
}
// converting invalid UTF-8 UUIDs from string fails as expected
static void test_uuid_bad_utf8(void) {
TCUuid u;
char *ustr = "\xf0\x28\x8c\xbc";
TEST_ASSERT_EQUAL(TC_RESULT_ERROR, tc_uuid_from_str(tc_string_borrow(ustr), &u));
}
// converting a string with embedded NUL fails as expected
static void test_uuid_embedded_nul(void) {
TCUuid u;
TEST_ASSERT_EQUAL(TC_RESULT_ERROR, tc_uuid_from_str(tc_string_clone_with_len("ab\0de", 5), &u));
}
int uuid_tests(void) {
UNITY_BEGIN();
// each test case above should be named here, in order.
RUN_TEST(test_uuid_creation);
RUN_TEST(test_uuid_valid_from_str);
RUN_TEST(test_uuid_to_buf);
RUN_TEST(test_uuid_to_str);
RUN_TEST(test_uuid_invalid_string_fails);
RUN_TEST(test_uuid_bad_utf8);
RUN_TEST(test_uuid_embedded_nul);
return UNITY_END();
}
|
9508a2b2cb66e3f53c5194976ca2f231e48ddd3c
|
3f308bd1e45dc44276d57c089e7698b4fcda79a4
|
/doc/zebra/genpsion.c
|
af66745503188097fd7f9d2ec9ee262711a13f9a
|
[] |
no_license
|
jhallen/joes-sandbox
|
b5b6d1acf3f66645c3a00757f217f7a8fe2cad27
|
0ec8c38756e4cdc40fc5f881b7c87e2628d15f24
|
refs/heads/master
| 2022-01-18T21:38:24.514745
| 2022-01-03T01:08:53
| 2022-01-03T01:08:53
| 25,269,713
| 760
| 42
| null | 2020-10-27T05:34:56
| 2014-10-15T19:21:16
|
C
|
UTF-8
|
C
| false
| false
| 1,147
|
c
|
genpsion.c
|
/* Program to generate PSION index and data file */
#include <stdio.h>
#include <string.h>
#include "zstr.h"
#define SIZE 1024
char jindex[SIZE][255];
unsigned short hsh(char *s)
{
unsigned short hval = 0;
while (*s)
hval = (hval * 31 + *s++) % SIZE;
return hval;
}
int main(int argc, char *argv[])
{
char buf[1024];
char gen[10240];
char *field[10];
int x, y, z;
int pos = 1;
FILE *f = fopen("data", "w");
for (x = 0; x != SIZE; ++x)
strcpy(jindex[x], "X");
while (gets(buf)) {
int h;
int opos;
fields(buf, field, ':');
h = hsh(field[0]);
while (strcmp(jindex[h], "X"))
h = (h + 1) % SIZE;
gets(gen);
opos = pos;
for (y = 0; gen[y];) {
for (z = 0;
gen[z + y] && !(gen[z + y] == '^'
&& gen[z + y + 1] == 'F'
&& gen[z + y + 2] == 'S');
++z);
if (gen[z + y]) {
gen[z + y] = 0;
fprintf(f, "%s^FS\n", gen + y);
z += 3;
} else
fprintf(f, "%s\n", gen + y);
++pos;
y += z;
}
sprintf(jindex[h], "%s\t%s\t%s\t%d\t%d", field[0],
field[1], field[2], opos, pos - opos);
}
fclose(f);
for (x = 0; x != SIZE; ++x)
puts(jindex[x]);
return 0;
}
|
147cfd61e961737e53f3618c55bffac0b6e6f112
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/lss/tests/getitimer.c
|
507948fea0899260f7d6017ba62577cb76054e91
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"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,611
|
c
|
getitimer.c
|
/* Copyright 2022, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test_skel.h"
int main(int argc, char *argv[]) {
// We need an invalid timer value. The assert()'s below should
// be static asserts but it is not avalible in older C versions.
#define kInvalidTimer 9999
assert(kInvalidTimer != ITIMER_REAL);
assert(kInvalidTimer != ITIMER_VIRTUAL);
assert(kInvalidTimer != ITIMER_PROF);
// This should fail with EINVAL.
struct kernel_itimerval curr_itimer;
assert(sys_getitimer(kInvalidTimer, &curr_itimer) == -1);
assert(errno == EINVAL);
// Create a read-only page.
size_t page_size = getpagesize();
void* read_only_page = sys_mmap(NULL, page_size, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
assert(read_only_page != MAP_FAILED);
// This should fail with EFAULT.
assert(sys_getitimer(ITIMER_REAL,
(struct kernel_itimerval*) read_only_page) == -1);
assert(errno == EFAULT);
// This should complete without an error.
assert(sys_getitimer(ITIMER_REAL, &curr_itimer) == 0);
// Set up a real time timer with very long interval and value so that
// we do not need to handle SIGALARM in test.
struct kernel_itimerval new_itimer;
const time_t kIntervalSec = 60 * 60 * 24 * 365; // One year.
const long kIntervalUSec = 123;
new_itimer.it_interval.tv_sec = kIntervalSec;
new_itimer.it_interval.tv_usec = kIntervalUSec;
new_itimer.it_value = new_itimer.it_interval;
assert(sys_setitimer(ITIMER_REAL, &new_itimer, NULL) == 0);
assert(sys_getitimer(ITIMER_REAL, &curr_itimer) == 0);
assert(kernel_timeval_eq(&curr_itimer.it_interval, &new_itimer.it_interval));
// Disable timer.
struct kernel_itimerval empty_itimer;
empty_itimer.it_interval.tv_sec = 0;
empty_itimer.it_interval.tv_usec = 0;
empty_itimer.it_value = empty_itimer.it_interval;
assert(sys_setitimer(ITIMER_REAL, &empty_itimer, NULL) == 0);
// We should read back an empty itimer.
assert(sys_getitimer(ITIMER_REAL, &curr_itimer) == 0);
assert(kernel_itimerval_eq(&curr_itimer, &empty_itimer));
return 0;
}
|
7efb1f4b3aab8dd63ac4b21156266e18ac142ca7
|
33377c4d113cf9ea1338077af6bd645f3c5796b3
|
/extensions/webassembly/ringqt/project/ring/src/os_e.c
|
0224d8395f5ed187f0775d3b95e572c3e7f7ab05
|
[
"LicenseRef-scancode-free-unknown",
"MIT"
] |
permissive
|
ring-lang/ring
|
56f55111f751b0274d4f588871f806a8c2734dea
|
2081d2efb41c9dacd49b7a6944b9ca332638ba64
|
refs/heads/master
| 2023-09-04T16:54:44.309452
| 2023-09-03T10:28:57
| 2023-09-03T10:28:57
| 54,633,811
| 1,360
| 555
|
MIT
| 2023-08-03T01:48:24
| 2016-03-24T10:29:27
|
C
|
UTF-8
|
C
| false
| false
| 11,252
|
c
|
os_e.c
|
/*
** Copyright (c) 2013-2023 Mahmoud Fayed <msfclipper@yahoo.com>
** Include Files
*/
#include "ring.h"
/* Functions */
void ring_vm_os_loadfunctions ( RingState *pRingState )
{
RING_API_REGISTER("ismsdos",ring_vm_os_ismsdos);
RING_API_REGISTER("iswindows",ring_vm_os_iswindows);
RING_API_REGISTER("iswindows64",ring_vm_os_iswindows64);
RING_API_REGISTER("isunix",ring_vm_os_isunix);
RING_API_REGISTER("ismacosx",ring_vm_os_ismacosx);
RING_API_REGISTER("islinux",ring_vm_os_islinux);
RING_API_REGISTER("isfreebsd",ring_vm_os_isfreebsd);
RING_API_REGISTER("isandroid",ring_vm_os_isandroid);
RING_API_REGISTER("windowsnl",ring_vm_os_windowsnl);
RING_API_REGISTER("currentdir",ring_vm_os_currentdir);
RING_API_REGISTER("exefilename",ring_vm_os_exefilename);
RING_API_REGISTER("chdir",ring_vm_os_chdir);
RING_API_REGISTER("exefolder",ring_vm_os_exefolder);
RING_API_REGISTER("getarch",ring_vm_os_getarch);
RING_API_REGISTER("system",ring_vm_os_system);
RING_API_REGISTER("shutdown",ring_vm_os_shutdown);
#if RING_MSDOS
#else
/* Environment Variables */
RING_API_REGISTER("sysget",ring_vm_os_sysget);
RING_API_REGISTER("sysset",ring_vm_os_sysset);
RING_API_REGISTER("sysunset",ring_vm_os_sysunset);
RING_API_REGISTER("nofprocessors",ring_vm_os_nofprocessors);
RING_API_REGISTER("uptime",ring_vm_os_uptime);
RING_API_REGISTER("randomize",ring_vm_os_randomize);
#endif
}
void ring_vm_os_ismsdos ( void *pPointer )
{
#if RING_MSDOS
RING_API_RETNUMBER(1);
#else
RING_API_RETNUMBER(0);
#endif
}
void ring_vm_os_iswindows ( void *pPointer )
{
#ifdef _WIN32
RING_API_RETNUMBER(1);
#else
RING_API_RETNUMBER(0);
#endif
}
void ring_vm_os_iswindows64 ( void *pPointer )
{
int lSystem64 ;
#ifdef _WIN64
RING_API_RETNUMBER(1);
#elif _WIN32
HMODULE pModule ;
lSystem64 = 0 ;
pModule = GetModuleHandle(TEXT("kernel32"));
if ( pModule != NULL ) {
fnCheckWindows64 = (LPFN_ISWOW64PROCESS) GetProcAddress(pModule,"IsWow64Process") ;
if ( fnCheckWindows64 != NULL ) {
fnCheckWindows64(GetCurrentProcess(),&lSystem64);
RING_API_RETNUMBER(lSystem64);
return ;
}
}
#endif
RING_API_RETNUMBER(0.0);
}
void ring_vm_os_isunix ( void *pPointer )
{
#if defined(unix) || defined(__unix__) || defined(__unix)
RING_API_RETNUMBER(1);
#else
RING_API_RETNUMBER(0);
#endif
}
void ring_vm_os_ismacosx ( void *pPointer )
{
#if defined(__APPLE__) || defined(__MACH__)
RING_API_RETNUMBER(1);
#else
RING_API_RETNUMBER(0);
#endif
}
void ring_vm_os_islinux ( void *pPointer )
{
#ifdef __linux__
RING_API_RETNUMBER(1);
#else
RING_API_RETNUMBER(0);
#endif
}
void ring_vm_os_isfreebsd ( void *pPointer )
{
#ifdef __FreeBSD__
RING_API_RETNUMBER(1);
#else
RING_API_RETNUMBER(0);
#endif
}
void ring_vm_os_isandroid ( void *pPointer )
{
#ifdef __ANDROID__
RING_API_RETNUMBER(1);
#else
RING_API_RETNUMBER(0);
#endif
}
void ring_vm_os_windowsnl ( void *pPointer )
{
RING_API_RETSTRING("\r\n");
}
void ring_vm_os_currentdir ( void *pPointer )
{
char cDirPath[RING_PATHSIZE] ;
ring_general_currentdir(cDirPath);
RING_API_RETSTRING(cDirPath);
}
void ring_vm_os_exefilename ( void *pPointer )
{
char cDirPath[RING_PATHSIZE] ;
if ( ring_general_exefilename(cDirPath) ) {
RING_API_RETSTRING(cDirPath);
}
}
void ring_vm_os_chdir ( void *pPointer )
{
RING_API_RETNUMBER(ring_general_chdir(RING_API_GETSTRING(1)));
}
void ring_vm_os_exefolder ( void *pPointer )
{
char cDirPath[RING_PATHSIZE] ;
ring_general_exefolder(cDirPath);
RING_API_RETSTRING(cDirPath);
}
void ring_vm_os_getarch ( void *pPointer )
{
#if (defined(_M_X64) || defined(__x86_64__))
RING_API_RETSTRING("x64");
#elif (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__))
RING_API_RETSTRING("x86");
#elif (defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64))
RING_API_RETSTRING("arm64");
#elif (defined(__arm__) || defined(_M_ARM) || defined(__aarch32__))
RING_API_RETSTRING("arm");
#else
RING_API_RETSTRING("unknown");
#endif
}
void ring_vm_os_system ( void *pPointer )
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( RING_API_ISSTRING(1) ) {
system(RING_API_GETSTRING(1));
}
else {
RING_API_ERROR(RING_API_BADPARATYPE);
}
}
void ring_vm_os_shutdown ( void *pPointer )
{
if ( RING_API_PARACOUNT == 1 ) {
if ( RING_API_ISNUMBER(1) ) {
exit(RING_API_GETNUMBER(1));
return ;
}
}
exit(0);
}
#if RING_MSDOS
#else
/* Environment Variables */
void ring_vm_os_sysget ( void *pPointer )
{
char *pData ;
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( RING_API_ISSTRING(1) ) {
pData = getenv(RING_API_GETSTRING(1));
if ( pData != NULL ) {
RING_API_RETSTRING(pData);
}
else {
RING_API_RETSTRING("");
}
}
else {
RING_API_ERROR(RING_API_BADPARATYPE);
}
}
/* Visual C/C++ doesn't provide setenv() & unsetenv() functions */
#ifdef _WIN32
int setenv ( const char *name, const char *value, int overwrite )
{
int errcode = 0 ;
size_t envsize = 0 ;
#ifdef __BORLANDC__
puts(RING_VM_UNSUPPORTEDFUNCTION);
return 0 ;
#else
if ( ! overwrite ) {
errcode = getenv_s(&envsize, NULL, 0, name);
if ( errcode || envsize ) {
return (int) errcode ;
}
}
return (int) _putenv_s(name, value) ;
#endif
}
int unsetenv ( const char *name )
{
#ifdef __BORLANDC__
puts(RING_VM_UNSUPPORTEDFUNCTION);
return 0 ;
#else
return (int) _putenv_s(name, "") ;
#endif
}
#endif
void ring_vm_os_sysset ( void *pPointer )
{
if ( RING_API_PARACOUNT != 2 ) {
RING_API_ERROR(RING_API_MISS2PARA);
return ;
}
if ( ! ( RING_API_ISSTRING(1) && RING_API_ISSTRING(2) ) ) {
RING_API_ERROR(RING_API_BADPARATYPE);
return ;
}
if ( setenv (RING_API_GETSTRING(1),RING_API_GETSTRING(2),1) == 0 ) {
RING_API_RETNUMBER(1);
}
else {
RING_API_RETNUMBER(0);
}
}
void ring_vm_os_sysunset ( void *pPointer )
{
if ( RING_API_PARACOUNT != 1 ) {
RING_API_ERROR(RING_API_MISS1PARA);
return ;
}
if ( RING_API_ISSTRING(1) ) {
if ( unsetenv(RING_API_GETSTRING(1)) == 0 ) {
RING_API_RETNUMBER(1);
}
else {
RING_API_RETNUMBER(0);
}
}
else {
RING_API_ERROR(RING_API_BADPARATYPE);
}
}
void ring_vm_os_nofprocessors ( void *pPointer )
{
#ifdef _WIN32
SYSTEM_INFO sysinfo ;
GetSystemInfo(&sysinfo);
RING_API_RETNUMBER(sysinfo.dwNumberOfProcessors);
#else
RING_API_RETNUMBER((double)sysconf(_SC_NPROCESSORS_ONLN));
#endif
}
/*
** Mac OS doesn't provide clock_gettime function prior v. 10.12
** Custom function is going to work on all Mac OS versions
*/
#if defined __MACH__
int ring_vm_os_gettime ( int clk_id, struct timespec* ts )
{
uint64_t nsec = mach_absolute_time() ;
ts->tv_sec = nsec / NANOSEC ;
ts->tv_nsec = nsec % NANOSEC; ;
return 0 ;
}
#endif
void ring_vm_os_uptime ( void *pPointer )
{
double nTime ;
#ifdef _WIN32
LARGE_INTEGER PerformanceCounterTicks, PerformanceCounterFrequency ;
QueryPerformanceFrequency(&PerformanceCounterFrequency);
QueryPerformanceCounter(&PerformanceCounterTicks);
/* Return the elapsed time in units of 0.1 microseconds for backward compatibility */
nTime = ((double) PerformanceCounterTicks.QuadPart / (double) PerformanceCounterFrequency.QuadPart) * (double) 10000000.0 ;
#else
struct timespec ts ;
ring_vm_os_gettime(CLOCK_UPTIME, &ts);
/* Compensate to match 0.1 ms resolution on Windows */
nTime = ( ( ts.tv_sec * NANOSEC ) + ( ts.tv_nsec ) ) / 100 ;
#endif
RING_API_RETNUMBER(nTime);
}
/*
** Thread safe
** 53 bit thread safe random generator using high precision timer as seed on the Unix systems
** Or using Windows Security Features by the CRT having the _s ("secure") suffix since XP
** This random generator doesn't require a seed to be given by the user
*/
void ring_vm_os_randomize ( void *pPointer )
{
RING_UNSIGNEDLONGLONG nNum1,nNum2 ;
#if ! defined(_WIN32)
struct timespec ts ;
ring_vm_os_gettime(CLOCK_UPTIME, &ts);
/* Compensate to match 0.1 ms resolution on Windows */
nNum1 = ( ( (RING_UNSIGNEDLONGLONG) ts.tv_sec * NANOSEC ) + ts.tv_nsec ) / 100 ;
/* Randomize by using high precision timer */
#if defined(__ANDROID__)
RING_API_ERROR("The Randomize() function is not supported on Android");
return ;
#else
nNum1 = rand_r( (unsigned int *) &ts.tv_nsec ) | ( nNum1 << 32 ) ;
#endif
#else
#ifdef __BORLANDC__
RING_API_ERROR(RING_VM_UNSUPPORTEDFUNCTION);
#else
LARGE_INTEGER ElapsedMicroseconds ;
unsigned int nNum ;
QueryPerformanceCounter(&ElapsedMicroseconds);
rand_s(&nNum);
nNum1 = (RING_UNSIGNEDLONGLONG ) nNum | ( ElapsedMicroseconds.QuadPart << 32 ) ;
#endif
#endif
if ( RING_API_PARACOUNT == 0 ) {
/* Double have Integer precision up to 2^53 */
RING_API_RETNUMBER(nNum1 & 0x001FFFFFFFFFFFFF);
}
else if ( RING_API_PARACOUNT == 1 ) {
if ( RING_API_ISNUMBER(1) ) {
nNum2 = RING_API_GETNUMBER(1) ;
if ( nNum2 > 0 ) {
RING_API_RETNUMBER((nNum1 & 0x001FFFFFFFFFFFFF) % ++nNum2);
}
}
else {
RING_API_ERROR(RING_API_BADPARATYPE);
}
}
else {
RING_API_ERROR(RING_API_BADPARACOUNT);
}
}
#endif
|
a6ada393530cd878282b8dfd06838f6b231ed2a7
|
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
|
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/hdf5/tools/h5copy/h5copy.c
|
b5965ba075a371c58beb93d21971f5cbd3b562fb
|
[
"MIT",
"LicenseRef-scancode-proprietary-license"
] |
permissive
|
windystrife/UnrealEngine_NVIDIAGameWorks
|
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
refs/heads/4.18-GameWorks
| 2023-03-11T02:50:08.471040
| 2022-01-13T20:50:29
| 2022-01-13T20:50:29
| 124,100,479
| 262
| 179
|
MIT
| 2022-12-16T05:36:38
| 2018-03-06T15:44:09
|
C++
|
UTF-8
|
C
| false
| false
| 15,777
|
c
|
h5copy.c
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
#include <string.h>
#include <stdlib.h>
/* Name of tool */
#define PROGRAMNAME "h5copy"
/* command-line options: short and long-named parameters */
static const char *s_opts = "d:f:hi:o:ps:vV";
static struct long_options l_opts[] = {
{ "destination", require_arg, 'd' },
{ "flag", require_arg, 'f' },
{ "help", no_arg, 'h' },
{ "input", require_arg, 'i' },
{ "output", require_arg, 'o' },
{ "parents", no_arg, 'p' },
{ "source", require_arg, 's' },
{ "verbose", no_arg, 'v' },
{ "version", no_arg, 'V' },
{ NULL, 0, '\0' }
};
char *fname_src = NULL;
char *fname_dst = NULL;
char *oname_src = NULL;
char *oname_dst = NULL;
char *str_flag = NULL;
/*-------------------------------------------------------------------------
* Function: leave
*
* Purpose: Shutdown MPI & HDF5 and call exit()
*
* Return: Does not return
*
* Programmer: Quincey Koziol
* Saturday, 31. January 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
leave(int ret)
{
if (fname_src)
HDfree(fname_src);
if (fname_dst)
HDfree(fname_dst);
if (oname_dst)
HDfree(oname_dst);
if (oname_src)
HDfree(oname_src);
if (str_flag)
HDfree(str_flag);
h5tools_close();
HDexit(ret);
}
/*-------------------------------------------------------------------------
* Function: usage
*
* Purpose: Prints a usage message on stderr and then returns.
*
* Return: void
*
* Programmer: Pedro Vicente Nunes, 7/8/2006
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
usage (void)
{
HDfprintf(stdout, "\
usage: h5copy [OPTIONS] [OBJECTS...]\n\
OBJECTS\n\
-i, --input input file name\n\
-o, --output output file name\n\
-s, --source source object name\n\
-d, --destination destination object name\n\
OPTIONS\n\
-h, --help Print a usage message and exit\n\
-p, --parents No error if existing, make parent groups as needed\n\
-v, --verbose Print information about OBJECTS and OPTIONS\n\
-V, --version Print version number and exit\n\
-f, --flag Flag type\n\n\
Flag type is one of the following strings:\n\n\
shallow Copy only immediate members for groups\n\n\
soft Expand soft links into new objects\n\n\
ext Expand external links into new objects\n\n\
ref Copy references and any referenced objects, i.e., objects\n\
that the references point to.\n\
Referenced objects are copied in addition to the objects\n\
specified on the command line and reference datasets are\n\
populated with correct reference values. Copies of referenced\n\
datasets outside the copy range specified on the command line\n\
will normally have a different name from the original.\n\
(Default:Without this option, reference value(s) in any\n\
reference datasets are set to NULL and referenced objects are\n\
not copied unless they are otherwise within the copy range\n\
specified on the command line.)\n\n\
noattr Copy object without copying attributes\n\n\
allflags Switches all flags from the default to the non-default setting\n\n\
These flag types correspond to the following API symbols\n\n\
H5O_COPY_SHALLOW_HIERARCHY_FLAG\n\
H5O_COPY_EXPAND_SOFT_LINK_FLAG\n\
H5O_COPY_EXPAND_EXT_LINK_FLAG\n\
H5O_COPY_EXPAND_REFERENCE_FLAG\n\
H5O_COPY_WITHOUT_ATTR_FLAG\n\
H5O_COPY_ALL\n");
}
/*-------------------------------------------------------------------------
* Function: parse_flag
*
* Purpose: read the flag -f STRING
*
* STRING is one of the following (API symbol and description)
*
* shallow H5O_COPY_SHALLOW_HIERARCHY_FLAG: Copy only immediate members for groups
* soft H5O_COPY_EXPAND_SOFT_LINK_FLAG: Expand soft links into new objects
* ext H5O_COPY_EXPAND_EXT_LINK_FLAG: Expand external links into new objects
* ref H5O_COPY_EXPAND_OBJ_REFERENCE_FLAG: Copy objects that are pointed by references
* noattr H5O_COPY_WITHOUT_ATTR_FLAG Copy object without copying attributes
* allflags Switches all flags from the default to the non-default setting
*
* Return: Success: SUCCEED
* Failure: FAIL
*
* Programmer: Pedro Vicente Nunes, 7/8/2006
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int parse_flag(const char* s_flag, unsigned *flag)
{
unsigned fla=0;
if (HDstrcmp(s_flag,"shallow")==0)
{
fla = H5O_COPY_SHALLOW_HIERARCHY_FLAG;
}
else if (HDstrcmp(s_flag,"soft")==0)
{
fla = H5O_COPY_EXPAND_SOFT_LINK_FLAG;
}
else if (HDstrcmp(s_flag,"ext")==0)
{
fla = H5O_COPY_EXPAND_EXT_LINK_FLAG;
}
else if (HDstrcmp(s_flag,"ref")==0)
{
fla = H5O_COPY_EXPAND_REFERENCE_FLAG;
}
else if (HDstrcmp(s_flag,"noattr")==0)
{
fla = H5O_COPY_WITHOUT_ATTR_FLAG;
}
else if (HDstrcmp(s_flag,"allflags")==0)
{
fla = H5O_COPY_ALL;
}
else if (HDstrcmp(s_flag,"nullmsg")==0)
{
fla = H5O_COPY_PRESERVE_NULL_FLAG;
}
else
{
error_msg("Error in input flag\n");
return -1;
}
*flag = (*flag) | fla;
return 0;
}
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: main program
*
* Programmer: Pedro Vicente Nunes
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
main (int argc, const char *argv[])
{
hid_t fid_src = -1;
hid_t fid_dst = -1;
unsigned flag = 0;
unsigned verbose = 0;
unsigned parents = 0;
hid_t ocpl_id = (-1); /* Object copy property list */
hid_t lcpl_id = (-1); /* Link creation property list */
int opt;
int li_ret;
h5tool_link_info_t linkinfo;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
/* initialize h5tools lib */
h5tools_init();
/* init linkinfo struct */
HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t));
/* Check for no command line parameters */
if(argc == 1)
{
usage();
leave(EXIT_FAILURE);
} /* end if */
/* parse command line options */
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF)
{
switch ((char)opt)
{
case 'd':
oname_dst = HDstrdup(opt_arg);
break;
case 'f':
/* validate flag */
if (parse_flag(opt_arg,&flag)<0)
{
usage();
leave(EXIT_FAILURE);
}
str_flag = HDstrdup(opt_arg);
break;
case 'h':
usage();
leave(EXIT_SUCCESS);
break;
case 'i':
fname_src = HDstrdup(opt_arg);
break;
case 'o':
fname_dst = HDstrdup(opt_arg);
break;
case 'p':
parents = 1;
break;
case 's':
oname_src = HDstrdup(opt_arg);
break;
case 'V':
print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
case 'v':
verbose = 1;
break;
default:
usage();
leave(EXIT_FAILURE);
}
} /* end of while */
/*-------------------------------------------------------------------------
* check for missing file/object names
*-------------------------------------------------------------------------*/
if (fname_src==NULL)
{
error_msg("Input file name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (fname_dst==NULL)
{
error_msg("Output file name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (oname_src==NULL)
{
error_msg("Source object name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (oname_dst==NULL)
{
error_msg("Destination object name missing\n");
usage();
leave(EXIT_FAILURE);
}
/*-------------------------------------------------------------------------
* open output file
*-------------------------------------------------------------------------*/
/* Attempt to open an existing HDF5 file first. Need to open the dst file
before the src file just in case that the dst and src are the same file
*/
fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0);
/*-------------------------------------------------------------------------
* open input file
*-------------------------------------------------------------------------*/
fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0);
/*-------------------------------------------------------------------------
* test for error in opening input file
*-------------------------------------------------------------------------*/
if (fid_src==-1)
{
error_msg("Could not open input file <%s>...Exiting\n", fname_src);
leave(EXIT_FAILURE);
}
/*-------------------------------------------------------------------------
* create an output file when failed to open it
*-------------------------------------------------------------------------*/
/* If we couldn't open an existing file, try creating file */
/* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
if(fid_dst < 0)
fid_dst = H5Fcreate(fname_dst, H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
* test for error in opening output file
*-------------------------------------------------------------------------*/
if (fid_dst==-1)
{
error_msg("Could not open output file <%s>...Exiting\n", fname_dst);
leave(EXIT_FAILURE);
}
/*-------------------------------------------------------------------------
* print some info
*-------------------------------------------------------------------------*/
if (verbose)
{
printf("Copying file <%s> and object <%s> to file <%s> and object <%s>\n",
fname_src, oname_src, fname_dst, oname_dst);
if (flag) {
HDassert(str_flag);
printf("Using %s flag\n", str_flag);
}
}
/*-------------------------------------------------------------------------
* create property lists for copy
*-------------------------------------------------------------------------*/
/* create property to pass copy options */
if ( (ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
goto error;
/* set options for object copy */
if (flag)
{
if ( H5Pset_copy_object(ocpl_id, flag) < 0)
goto error;
}
/* Create link creation property list */
if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
error_msg("Could not create link creation property list\n");
goto error;
} /* end if */
/* Check for creating intermediate groups */
if(parents) {
/* Set the intermediate group creation property */
if(H5Pset_create_intermediate_group(lcpl_id, 1) < 0) {
error_msg("Could not set property for creating parent groups\n");
goto error;
} /* end if */
/* Display some output if requested */
if(verbose)
printf("%s: Creating parent groups\n", h5tools_getprogname());
} /* end if */
else /* error, if parent groups doesn't already exist in destination file */
{
size_t i, len;
len = HDstrlen(oname_dst);
/* check if all the parents groups exist. skip root group */
for (i = 1; i < len; i++)
{
if ('/'==oname_dst[i])
{
char *str_ptr;
str_ptr = (char *)HDcalloc(i + 1, sizeof(char));
HDstrncpy(str_ptr, oname_dst, i);
str_ptr[i]='\0';
if (H5Lexists(fid_dst, str_ptr, H5P_DEFAULT) <= 0)
{
error_msg("group <%s> doesn't exist. Use -p to create parent groups.\n", str_ptr);
HDfree(str_ptr);
goto error;
}
HDfree(str_ptr);
}
}
}
/*-------------------------------------------------------------------------
* do the copy
*-------------------------------------------------------------------------*/
if(verbose)
linkinfo.opt.msg_mode = 1;
li_ret = H5tools_get_symlink_info(fid_src, oname_src, &linkinfo, 1);
if (li_ret == 0) /* dangling link */
{
if(H5Lcopy(fid_src, oname_src,
fid_dst, oname_dst,
H5P_DEFAULT, H5P_DEFAULT) < 0)
goto error;
}
else /* valid link */
{
if (H5Ocopy(fid_src, /* Source file or group identifier */
oname_src, /* Name of the source object to be copied */
fid_dst, /* Destination file or group identifier */
oname_dst, /* Name of the destination object */
ocpl_id, /* Object copy property list */
lcpl_id)<0) /* Link creation property list */
goto error;
}
/* free link info path */
if (linkinfo.trg_path)
HDfree((char*)linkinfo.trg_path);
/* close propertis */
if(H5Pclose(ocpl_id)<0)
goto error;
if(H5Pclose(lcpl_id)<0)
goto error;
/* close files */
if (H5Fclose(fid_src)<0)
goto error;
if (H5Fclose(fid_dst)<0)
goto error;
leave(EXIT_SUCCESS);
error:
printf("Error in copy...Exiting\n");
/* free link info path */
if (linkinfo.trg_path)
HDfree((char*)linkinfo.trg_path);
H5E_BEGIN_TRY {
H5Pclose(ocpl_id);
H5Pclose(lcpl_id);
H5Fclose(fid_src);
H5Fclose(fid_dst);
} H5E_END_TRY;
leave(EXIT_FAILURE);
}
|
0de3187543727696e741ab45683b578439093f49
|
0605b9fa82fae8785baa2583e78baffa12e5eb83
|
/src/third-party/lz4/lz4frame.c
|
08bf0faee1d67338e0cc00e6fa7bdfef5669b145
|
[
"BSD-2-Clause",
"BSD-3-Clause",
"MIT",
"CC-BY-4.0"
] |
permissive
|
facebook/flow
|
18f01601a72f61c1f6736782e992387487689300
|
7b17e57edec4d6a3db43c012ad2d39fafc5b2513
|
refs/heads/main
| 2023-09-01T11:48:01.965821
| 2023-09-01T04:16:56
| 2023-09-01T04:16:56
| 25,880,891
| 21,810
| 2,453
|
MIT
| 2023-09-10T00:33:03
| 2014-10-28T17:17:45
|
OCaml
|
UTF-8
|
C
| false
| false
| 74,931
|
c
|
lz4frame.c
|
/*
LZ4 auto-framing library
Copyright (C) 2011-2016, Yann Collet.
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
You can contact the author at :
- LZ4 homepage : http://www.lz4.org
- LZ4 source repository : https://github.com/lz4/lz4
*/
/* LZ4F is a stand-alone API to create LZ4-compressed Frames
* in full conformance with specification v1.5.0
* All related operations, including memory management, are handled by the library.
* */
/*-************************************
* Compiler Options
**************************************/
#ifdef _MSC_VER /* Visual Studio */
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
#endif
/*-************************************
* Tuning parameters
**************************************/
/*
* LZ4F_HEAPMODE :
* Select how default compression functions will allocate memory for their hash table,
* in memory stack (0:default, fastest), or in memory heap (1:requires malloc()).
*/
#ifndef LZ4F_HEAPMODE
# define LZ4F_HEAPMODE 0
#endif
/*-************************************
* Memory routines
**************************************/
#include <stdlib.h> /* malloc, calloc, free */
#define ALLOC(s) malloc(s)
#define ALLOC_AND_ZERO(s) calloc(1,s)
#define FREEMEM free
#include <string.h> /* memset, memcpy, memmove */
#define MEM_INIT memset
/*-************************************
* Includes
**************************************/
#define LZ4F_STATIC_LINKING_ONLY
#include "lz4frame.h"
#define LZ4_STATIC_LINKING_ONLY
#include "lz4.h"
#define LZ4_HC_STATIC_LINKING_ONLY
#include "lz4hc.h"
#define XXH_STATIC_LINKING_ONLY
#include "xxhash.h"
/*-************************************
* Debug
**************************************/
#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=1)
# include <assert.h>
#else
# ifndef assert
# define assert(condition) ((void)0)
# endif
#endif
#define LZ4F_STATIC_ASSERT(c) { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=2) && !defined(DEBUGLOG)
# include <stdio.h>
static int g_debuglog_enable = 1;
# define DEBUGLOG(l, ...) { \
if ((g_debuglog_enable) && (l<=LZ4_DEBUG)) { \
fprintf(stderr, __FILE__ ": "); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, " \n"); \
} }
#else
# define DEBUGLOG(l, ...) {} /* disabled */
#endif
/*-************************************
* Basic Types
**************************************/
#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
# include <stdint.h>
typedef uint8_t BYTE;
typedef uint16_t U16;
typedef uint32_t U32;
typedef int32_t S32;
typedef uint64_t U64;
#else
typedef unsigned char BYTE;
typedef unsigned short U16;
typedef unsigned int U32;
typedef signed int S32;
typedef unsigned long long U64;
#endif
/* unoptimized version; solves endianess & alignment issues */
static U32 LZ4F_readLE32 (const void* src)
{
const BYTE* const srcPtr = (const BYTE*)src;
U32 value32 = srcPtr[0];
value32 += (srcPtr[1]<<8);
value32 += (srcPtr[2]<<16);
value32 += ((U32)srcPtr[3])<<24;
return value32;
}
static void LZ4F_writeLE32 (void* dst, U32 value32)
{
BYTE* const dstPtr = (BYTE*)dst;
dstPtr[0] = (BYTE)value32;
dstPtr[1] = (BYTE)(value32 >> 8);
dstPtr[2] = (BYTE)(value32 >> 16);
dstPtr[3] = (BYTE)(value32 >> 24);
}
static U64 LZ4F_readLE64 (const void* src)
{
const BYTE* const srcPtr = (const BYTE*)src;
U64 value64 = srcPtr[0];
value64 += ((U64)srcPtr[1]<<8);
value64 += ((U64)srcPtr[2]<<16);
value64 += ((U64)srcPtr[3]<<24);
value64 += ((U64)srcPtr[4]<<32);
value64 += ((U64)srcPtr[5]<<40);
value64 += ((U64)srcPtr[6]<<48);
value64 += ((U64)srcPtr[7]<<56);
return value64;
}
static void LZ4F_writeLE64 (void* dst, U64 value64)
{
BYTE* const dstPtr = (BYTE*)dst;
dstPtr[0] = (BYTE)value64;
dstPtr[1] = (BYTE)(value64 >> 8);
dstPtr[2] = (BYTE)(value64 >> 16);
dstPtr[3] = (BYTE)(value64 >> 24);
dstPtr[4] = (BYTE)(value64 >> 32);
dstPtr[5] = (BYTE)(value64 >> 40);
dstPtr[6] = (BYTE)(value64 >> 48);
dstPtr[7] = (BYTE)(value64 >> 56);
}
/*-************************************
* Constants
**************************************/
#define KB *(1<<10)
#define MB *(1<<20)
#define GB *(1<<30)
#define _1BIT 0x01
#define _2BITS 0x03
#define _3BITS 0x07
#define _4BITS 0x0F
#define _8BITS 0xFF
#define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U
#define LZ4F_MAGICNUMBER 0x184D2204U
#define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U
#define LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB
static const size_t minFHSize = 7;
static const size_t maxFHSize = LZ4F_HEADER_SIZE_MAX; /* 19 */
static const size_t BHSize = 4;
/*-************************************
* Structures and local types
**************************************/
typedef struct LZ4F_cctx_s
{
LZ4F_preferences_t prefs;
U32 version;
U32 cStage;
const LZ4F_CDict* cdict;
size_t maxBlockSize;
size_t maxBufferSize;
BYTE* tmpBuff;
BYTE* tmpIn;
size_t tmpInSize;
U64 totalInSize;
XXH32_state_t xxh;
void* lz4CtxPtr;
U16 lz4CtxAlloc; /* sized for: 0 = none, 1 = lz4 ctx, 2 = lz4hc ctx */
U16 lz4CtxState; /* in use as: 0 = none, 1 = lz4 ctx, 2 = lz4hc ctx */
} LZ4F_cctx_t;
/*-************************************
* Error management
**************************************/
#define LZ4F_GENERATE_STRING(STRING) #STRING,
static const char* LZ4F_errorStrings[] = { LZ4F_LIST_ERRORS(LZ4F_GENERATE_STRING) };
unsigned LZ4F_isError(LZ4F_errorCode_t code)
{
return (code > (LZ4F_errorCode_t)(-LZ4F_ERROR_maxCode));
}
const char* LZ4F_getErrorName(LZ4F_errorCode_t code)
{
static const char* codeError = "Unspecified error code";
if (LZ4F_isError(code)) return LZ4F_errorStrings[-(int)(code)];
return codeError;
}
LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult)
{
if (!LZ4F_isError(functionResult)) return LZ4F_OK_NoError;
return (LZ4F_errorCodes)(-(ptrdiff_t)functionResult);
}
static LZ4F_errorCode_t err0r(LZ4F_errorCodes code)
{
/* A compilation error here means sizeof(ptrdiff_t) is not large enough */
LZ4F_STATIC_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t));
return (LZ4F_errorCode_t)-(ptrdiff_t)code;
}
unsigned LZ4F_getVersion(void) { return LZ4F_VERSION; }
int LZ4F_compressionLevel_max(void) { return LZ4HC_CLEVEL_MAX; }
/*-************************************
* Private functions
**************************************/
#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
static size_t LZ4F_getBlockSize(unsigned blockSizeID)
{
static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
if (blockSizeID == 0) blockSizeID = LZ4F_BLOCKSIZEID_DEFAULT;
blockSizeID -= 4;
if (blockSizeID > 3) return err0r(LZ4F_ERROR_maxBlockSize_invalid);
return blockSizes[blockSizeID];
}
static BYTE LZ4F_headerChecksum (const void* header, size_t length)
{
U32 const xxh = XXH32(header, length, 0);
return (BYTE)(xxh >> 8);
}
/*-************************************
* Simple-pass compression functions
**************************************/
static LZ4F_blockSizeID_t LZ4F_optimalBSID(const LZ4F_blockSizeID_t requestedBSID,
const size_t srcSize)
{
LZ4F_blockSizeID_t proposedBSID = LZ4F_max64KB;
size_t maxBlockSize = 64 KB;
while (requestedBSID > proposedBSID) {
if (srcSize <= maxBlockSize)
return proposedBSID;
proposedBSID = (LZ4F_blockSizeID_t)((int)proposedBSID + 1);
maxBlockSize <<= 2;
}
return requestedBSID;
}
/*! LZ4F_compressBound_internal() :
* Provides dstCapacity given a srcSize to guarantee operation success in worst case situations.
* prefsPtr is optional : if NULL is provided, preferences will be set to cover worst case scenario.
* @return is always the same for a srcSize and prefsPtr, so it can be relied upon to size reusable buffers.
* When srcSize==0, LZ4F_compressBound() provides an upper bound for LZ4F_flush() and LZ4F_compressEnd() operations.
*/
static size_t LZ4F_compressBound_internal(size_t srcSize,
const LZ4F_preferences_t* preferencesPtr,
size_t alreadyBuffered)
{
LZ4F_preferences_t prefsNull;
MEM_INIT(&prefsNull, 0, sizeof(prefsNull));
prefsNull.frameInfo.contentChecksumFlag = LZ4F_contentChecksumEnabled; /* worst case */
{ const LZ4F_preferences_t* const prefsPtr = (preferencesPtr==NULL) ? &prefsNull : preferencesPtr;
U32 const flush = prefsPtr->autoFlush | (srcSize==0);
LZ4F_blockSizeID_t const blockID = prefsPtr->frameInfo.blockSizeID;
size_t const blockSize = LZ4F_getBlockSize(blockID);
size_t const maxBuffered = blockSize - 1;
size_t const bufferedSize = MIN(alreadyBuffered, maxBuffered);
size_t const maxSrcSize = srcSize + bufferedSize;
unsigned const nbFullBlocks = (unsigned)(maxSrcSize / blockSize);
size_t const partialBlockSize = maxSrcSize & (blockSize-1);
size_t const lastBlockSize = flush ? partialBlockSize : 0;
unsigned const nbBlocks = nbFullBlocks + (lastBlockSize>0);
size_t const blockHeaderSize = 4;
size_t const blockCRCSize = 4 * prefsPtr->frameInfo.blockChecksumFlag;
size_t const frameEnd = 4 + (prefsPtr->frameInfo.contentChecksumFlag*4);
return ((blockHeaderSize + blockCRCSize) * nbBlocks) +
(blockSize * nbFullBlocks) + lastBlockSize + frameEnd;
}
}
size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr)
{
LZ4F_preferences_t prefs;
size_t const headerSize = maxFHSize; /* max header size, including optional fields */
if (preferencesPtr!=NULL) prefs = *preferencesPtr;
else MEM_INIT(&prefs, 0, sizeof(prefs));
prefs.autoFlush = 1;
return headerSize + LZ4F_compressBound_internal(srcSize, &prefs, 0);;
}
/*! LZ4F_compressFrame_usingCDict() :
* Compress srcBuffer using a dictionary, in a single step.
* cdict can be NULL, in which case, no dictionary is used.
* dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
* The LZ4F_preferences_t structure is optional : you may provide NULL as argument,
* however, it's the only way to provide a dictID, so it's not recommended.
* @return : number of bytes written into dstBuffer,
* or an error code if it fails (can be tested using LZ4F_isError())
*/
size_t LZ4F_compressFrame_usingCDict(LZ4F_cctx* cctx,
void* dstBuffer, size_t dstCapacity,
const void* srcBuffer, size_t srcSize,
const LZ4F_CDict* cdict,
const LZ4F_preferences_t* preferencesPtr)
{
LZ4F_preferences_t prefs;
LZ4F_compressOptions_t options;
BYTE* const dstStart = (BYTE*) dstBuffer;
BYTE* dstPtr = dstStart;
BYTE* const dstEnd = dstStart + dstCapacity;
if (preferencesPtr!=NULL)
prefs = *preferencesPtr;
else
MEM_INIT(&prefs, 0, sizeof(prefs));
if (prefs.frameInfo.contentSize != 0)
prefs.frameInfo.contentSize = (U64)srcSize; /* auto-correct content size if selected (!=0) */
prefs.frameInfo.blockSizeID = LZ4F_optimalBSID(prefs.frameInfo.blockSizeID, srcSize);
prefs.autoFlush = 1;
if (srcSize <= LZ4F_getBlockSize(prefs.frameInfo.blockSizeID))
prefs.frameInfo.blockMode = LZ4F_blockIndependent; /* only one block => no need for inter-block link */
MEM_INIT(&options, 0, sizeof(options));
options.stableSrc = 1;
if (dstCapacity < LZ4F_compressFrameBound(srcSize, &prefs)) /* condition to guarantee success */
return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
{ size_t const headerSize = LZ4F_compressBegin_usingCDict(cctx, dstBuffer, dstCapacity, cdict, &prefs); /* write header */
if (LZ4F_isError(headerSize)) return headerSize;
dstPtr += headerSize; /* header size */ }
{ size_t const cSize = LZ4F_compressUpdate(cctx, dstPtr, dstEnd-dstPtr, srcBuffer, srcSize, &options);
if (LZ4F_isError(cSize)) return cSize;
dstPtr += cSize; }
{ size_t const tailSize = LZ4F_compressEnd(cctx, dstPtr, dstEnd-dstPtr, &options); /* flush last block, and generate suffix */
if (LZ4F_isError(tailSize)) return tailSize;
dstPtr += tailSize; }
return (dstPtr - dstStart);
}
/*! LZ4F_compressFrame() :
* Compress an entire srcBuffer into a valid LZ4 frame, in a single step.
* dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
* The LZ4F_preferences_t structure is optional : you can provide NULL as argument. All preferences will be set to default.
* @return : number of bytes written into dstBuffer.
* or an error code if it fails (can be tested using LZ4F_isError())
*/
size_t LZ4F_compressFrame(void* dstBuffer, size_t dstCapacity,
const void* srcBuffer, size_t srcSize,
const LZ4F_preferences_t* preferencesPtr)
{
size_t result;
#if (LZ4F_HEAPMODE)
LZ4F_cctx_t *cctxPtr;
result = LZ4F_createCompressionContext(&cctxPtr, LZ4F_VERSION);
if (LZ4F_isError(result)) return result;
#else
LZ4F_cctx_t cctx;
LZ4_stream_t lz4ctx;
LZ4F_cctx_t *cctxPtr = &cctx;
DEBUGLOG(4, "LZ4F_compressFrame");
MEM_INIT(&cctx, 0, sizeof(cctx));
cctx.version = LZ4F_VERSION;
cctx.maxBufferSize = 5 MB; /* mess with real buffer size to prevent dynamic allocation; works only because autoflush==1 & stableSrc==1 */
if (preferencesPtr == NULL ||
preferencesPtr->compressionLevel < LZ4HC_CLEVEL_MIN)
{
LZ4_resetStream(&lz4ctx);
cctxPtr->lz4CtxPtr = &lz4ctx;
cctxPtr->lz4CtxAlloc = 1;
cctxPtr->lz4CtxState = 1;
}
#endif
result = LZ4F_compressFrame_usingCDict(cctxPtr, dstBuffer, dstCapacity,
srcBuffer, srcSize,
NULL, preferencesPtr);
#if (LZ4F_HEAPMODE)
LZ4F_freeCompressionContext(cctxPtr);
#else
if (preferencesPtr != NULL &&
preferencesPtr->compressionLevel >= LZ4HC_CLEVEL_MIN)
{
FREEMEM(cctxPtr->lz4CtxPtr);
}
#endif
return result;
}
/*-***************************************************
* Dictionary compression
*****************************************************/
struct LZ4F_CDict_s {
void* dictContent;
LZ4_stream_t* fastCtx;
LZ4_streamHC_t* HCCtx;
}; /* typedef'd to LZ4F_CDict within lz4frame_static.h */
/*! LZ4F_createCDict() :
* When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.
* LZ4F_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
* LZ4F_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
* `dictBuffer` can be released after LZ4F_CDict creation, since its content is copied within CDict
* @return : digested dictionary for compression, or NULL if failed */
LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize)
{
const char* dictStart = (const char*)dictBuffer;
LZ4F_CDict* cdict = (LZ4F_CDict*) ALLOC(sizeof(*cdict));
DEBUGLOG(4, "LZ4F_createCDict");
if (!cdict) return NULL;
if (dictSize > 64 KB) {
dictStart += dictSize - 64 KB;
dictSize = 64 KB;
}
cdict->dictContent = ALLOC(dictSize);
cdict->fastCtx = LZ4_createStream();
cdict->HCCtx = LZ4_createStreamHC();
if (!cdict->dictContent || !cdict->fastCtx || !cdict->HCCtx) {
LZ4F_freeCDict(cdict);
return NULL;
}
memcpy(cdict->dictContent, dictStart, dictSize);
LZ4_loadDict (cdict->fastCtx, (const char*)cdict->dictContent, (int)dictSize);
LZ4_setCompressionLevel(cdict->HCCtx, LZ4HC_CLEVEL_DEFAULT);
LZ4_loadDictHC(cdict->HCCtx, (const char*)cdict->dictContent, (int)dictSize);
return cdict;
}
void LZ4F_freeCDict(LZ4F_CDict* cdict)
{
if (cdict==NULL) return; /* support free on NULL */
FREEMEM(cdict->dictContent);
LZ4_freeStream(cdict->fastCtx);
LZ4_freeStreamHC(cdict->HCCtx);
FREEMEM(cdict);
}
/*-*********************************
* Advanced compression functions
***********************************/
/*! LZ4F_createCompressionContext() :
* The first thing to do is to create a compressionContext object, which will be used in all compression operations.
* This is achieved using LZ4F_createCompressionContext(), which takes as argument a version and an LZ4F_preferences_t structure.
* The version provided MUST be LZ4F_VERSION. It is intended to track potential incompatible differences between different binaries.
* The function will provide a pointer to an allocated LZ4F_compressionContext_t object.
* If the result LZ4F_errorCode_t is not OK_NoError, there was an error during context creation.
* Object can release its memory using LZ4F_freeCompressionContext();
*/
LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_compressionContext_t* LZ4F_compressionContextPtr, unsigned version)
{
LZ4F_cctx_t* const cctxPtr = (LZ4F_cctx_t*)ALLOC_AND_ZERO(sizeof(LZ4F_cctx_t));
if (cctxPtr==NULL) return err0r(LZ4F_ERROR_allocation_failed);
cctxPtr->version = version;
cctxPtr->cStage = 0; /* Next stage : init stream */
*LZ4F_compressionContextPtr = (LZ4F_compressionContext_t)cctxPtr;
return LZ4F_OK_NoError;
}
LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_compressionContext_t LZ4F_compressionContext)
{
LZ4F_cctx_t* const cctxPtr = (LZ4F_cctx_t*)LZ4F_compressionContext;
if (cctxPtr != NULL) { /* support free on NULL */
FREEMEM(cctxPtr->lz4CtxPtr); /* works because LZ4_streamHC_t and LZ4_stream_t are simple POD types */
FREEMEM(cctxPtr->tmpBuff);
FREEMEM(LZ4F_compressionContext);
}
return LZ4F_OK_NoError;
}
/**
* This function prepares the internal LZ4(HC) stream for a new compression,
* resetting the context and attaching the dictionary, if there is one.
*
* It needs to be called at the beginning of each independent compression
* stream (i.e., at the beginning of a frame in blockLinked mode, or at the
* beginning of each block in blockIndependent mode).
*/
static void LZ4F_initStream(void* ctx,
const LZ4F_CDict* cdict,
int level,
LZ4F_blockMode_t blockMode) {
if (level < LZ4HC_CLEVEL_MIN) {
if (cdict != NULL || blockMode == LZ4F_blockLinked) {
/* In these cases, we will call LZ4_compress_fast_continue(),
* which needs an already reset context. Otherwise, we'll call a
* one-shot API. The non-continued APIs internally perform their own
* resets at the beginning of their calls, where they know what
* tableType they need the context to be in. So in that case this
* would be misguided / wasted work. */
LZ4_resetStream_fast((LZ4_stream_t*)ctx);
}
LZ4_attach_dictionary((LZ4_stream_t *)ctx, cdict ? cdict->fastCtx : NULL);
} else {
LZ4_resetStreamHC_fast((LZ4_streamHC_t*)ctx, level);
LZ4_attach_HC_dictionary((LZ4_streamHC_t *)ctx, cdict ? cdict->HCCtx : NULL);
}
}
/*! LZ4F_compressBegin_usingCDict() :
* init streaming compression and writes frame header into dstBuffer.
* dstBuffer must be >= LZ4F_HEADER_SIZE_MAX bytes.
* @return : number of bytes written into dstBuffer for the header
* or an error code (can be tested using LZ4F_isError())
*/
size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctxPtr,
void* dstBuffer, size_t dstCapacity,
const LZ4F_CDict* cdict,
const LZ4F_preferences_t* preferencesPtr)
{
LZ4F_preferences_t prefNull;
BYTE* const dstStart = (BYTE*)dstBuffer;
BYTE* dstPtr = dstStart;
BYTE* headerStart;
if (dstCapacity < maxFHSize) return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
MEM_INIT(&prefNull, 0, sizeof(prefNull));
if (preferencesPtr == NULL) preferencesPtr = &prefNull;
cctxPtr->prefs = *preferencesPtr;
/* Ctx Management */
{ U16 const ctxTypeID = (cctxPtr->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) ? 1 : 2;
if (cctxPtr->lz4CtxAlloc < ctxTypeID) {
FREEMEM(cctxPtr->lz4CtxPtr);
if (cctxPtr->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) {
cctxPtr->lz4CtxPtr = (void*)LZ4_createStream();
} else {
cctxPtr->lz4CtxPtr = (void*)LZ4_createStreamHC();
}
if (cctxPtr->lz4CtxPtr == NULL) return err0r(LZ4F_ERROR_allocation_failed);
cctxPtr->lz4CtxAlloc = ctxTypeID;
cctxPtr->lz4CtxState = ctxTypeID;
} else if (cctxPtr->lz4CtxState != ctxTypeID) {
/* otherwise, a sufficient buffer is allocated, but we need to
* reset it to the correct context type */
if (cctxPtr->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) {
LZ4_resetStream((LZ4_stream_t *) cctxPtr->lz4CtxPtr);
} else {
LZ4_resetStreamHC((LZ4_streamHC_t *) cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel);
}
cctxPtr->lz4CtxState = ctxTypeID;
}
}
/* Buffer Management */
if (cctxPtr->prefs.frameInfo.blockSizeID == 0)
cctxPtr->prefs.frameInfo.blockSizeID = LZ4F_BLOCKSIZEID_DEFAULT;
cctxPtr->maxBlockSize = LZ4F_getBlockSize(cctxPtr->prefs.frameInfo.blockSizeID);
{ size_t const requiredBuffSize = preferencesPtr->autoFlush ?
(cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) * 64 KB : /* only needs windows size */
cctxPtr->maxBlockSize + ((cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) * 128 KB);
if (cctxPtr->maxBufferSize < requiredBuffSize) {
cctxPtr->maxBufferSize = 0;
FREEMEM(cctxPtr->tmpBuff);
cctxPtr->tmpBuff = (BYTE*)ALLOC_AND_ZERO(requiredBuffSize);
if (cctxPtr->tmpBuff == NULL) return err0r(LZ4F_ERROR_allocation_failed);
cctxPtr->maxBufferSize = requiredBuffSize;
} }
cctxPtr->tmpIn = cctxPtr->tmpBuff;
cctxPtr->tmpInSize = 0;
XXH32_reset(&(cctxPtr->xxh), 0);
/* context init */
cctxPtr->cdict = cdict;
if (cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) {
/* frame init only for blockLinked : blockIndependent will be init at each block */
LZ4F_initStream(cctxPtr->lz4CtxPtr, cdict, cctxPtr->prefs.compressionLevel, LZ4F_blockLinked);
}
if (preferencesPtr->compressionLevel >= LZ4HC_CLEVEL_MIN) {
LZ4_favorDecompressionSpeed((LZ4_streamHC_t*)cctxPtr->lz4CtxPtr, (int)preferencesPtr->favorDecSpeed);
}
/* Magic Number */
LZ4F_writeLE32(dstPtr, LZ4F_MAGICNUMBER);
dstPtr += 4;
headerStart = dstPtr;
/* FLG Byte */
*dstPtr++ = (BYTE)(((1 & _2BITS) << 6) /* Version('01') */
+ ((cctxPtr->prefs.frameInfo.blockMode & _1BIT ) << 5)
+ ((cctxPtr->prefs.frameInfo.blockChecksumFlag & _1BIT ) << 4)
+ ((cctxPtr->prefs.frameInfo.contentSize > 0) << 3)
+ ((cctxPtr->prefs.frameInfo.contentChecksumFlag & _1BIT ) << 2)
+ (cctxPtr->prefs.frameInfo.dictID > 0) );
/* BD Byte */
*dstPtr++ = (BYTE)((cctxPtr->prefs.frameInfo.blockSizeID & _3BITS) << 4);
/* Optional Frame content size field */
if (cctxPtr->prefs.frameInfo.contentSize) {
LZ4F_writeLE64(dstPtr, cctxPtr->prefs.frameInfo.contentSize);
dstPtr += 8;
cctxPtr->totalInSize = 0;
}
/* Optional dictionary ID field */
if (cctxPtr->prefs.frameInfo.dictID) {
LZ4F_writeLE32(dstPtr, cctxPtr->prefs.frameInfo.dictID);
dstPtr += 4;
}
/* Header CRC Byte */
*dstPtr = LZ4F_headerChecksum(headerStart, dstPtr - headerStart);
dstPtr++;
cctxPtr->cStage = 1; /* header written, now request input data block */
return (dstPtr - dstStart);
}
/*! LZ4F_compressBegin() :
* init streaming compression and writes frame header into dstBuffer.
* dstBuffer must be >= LZ4F_HEADER_SIZE_MAX bytes.
* preferencesPtr can be NULL, in which case default parameters are selected.
* @return : number of bytes written into dstBuffer for the header
* or an error code (can be tested using LZ4F_isError())
*/
size_t LZ4F_compressBegin(LZ4F_cctx* cctxPtr,
void* dstBuffer, size_t dstCapacity,
const LZ4F_preferences_t* preferencesPtr)
{
return LZ4F_compressBegin_usingCDict(cctxPtr, dstBuffer, dstCapacity,
NULL, preferencesPtr);
}
/* LZ4F_compressBound() :
* @return minimum capacity of dstBuffer for a given srcSize to handle worst case scenario.
* LZ4F_preferences_t structure is optional : if NULL, preferences will be set to cover worst case scenario.
* This function cannot fail.
*/
size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t* preferencesPtr)
{
return LZ4F_compressBound_internal(srcSize, preferencesPtr, (size_t)-1);
}
typedef int (*compressFunc_t)(void* ctx, const char* src, char* dst, int srcSize, int dstSize, int level, const LZ4F_CDict* cdict);
/*! LZ4F_makeBlock():
* compress a single block, add header and checksum
* assumption : dst buffer capacity is >= srcSize */
static size_t LZ4F_makeBlock(void* dst, const void* src, size_t srcSize,
compressFunc_t compress, void* lz4ctx, int level,
const LZ4F_CDict* cdict, LZ4F_blockChecksum_t crcFlag)
{
BYTE* const cSizePtr = (BYTE*)dst;
U32 cSize = (U32)compress(lz4ctx, (const char*)src, (char*)(cSizePtr+4),
(int)(srcSize), (int)(srcSize-1),
level, cdict);
LZ4F_writeLE32(cSizePtr, cSize);
if (cSize == 0) { /* compression failed */
cSize = (U32)srcSize;
LZ4F_writeLE32(cSizePtr, cSize | LZ4F_BLOCKUNCOMPRESSED_FLAG);
memcpy(cSizePtr+4, src, srcSize);
}
if (crcFlag) {
U32 const crc32 = XXH32(cSizePtr+4, cSize, 0); /* checksum of compressed data */
LZ4F_writeLE32(cSizePtr+4+cSize, crc32);
}
return 4 + cSize + ((U32)crcFlag)*4;
}
static int LZ4F_compressBlock(void* ctx, const char* src, char* dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict* cdict)
{
int const acceleration = (level < 0) ? -level + 1 : 1;
LZ4F_initStream(ctx, cdict, level, LZ4F_blockIndependent);
if (cdict) {
return LZ4_compress_fast_continue((LZ4_stream_t*)ctx, src, dst, srcSize, dstCapacity, acceleration);
} else {
return LZ4_compress_fast_extState_fastReset(ctx, src, dst, srcSize, dstCapacity, acceleration);
}
}
static int LZ4F_compressBlock_continue(void* ctx, const char* src, char* dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict* cdict)
{
int const acceleration = (level < 0) ? -level + 1 : 1;
(void)cdict; /* init once at beginning of frame */
return LZ4_compress_fast_continue((LZ4_stream_t*)ctx, src, dst, srcSize, dstCapacity, acceleration);
}
static int LZ4F_compressBlockHC(void* ctx, const char* src, char* dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict* cdict)
{
LZ4F_initStream(ctx, cdict, level, LZ4F_blockIndependent);
if (cdict) {
return LZ4_compress_HC_continue((LZ4_streamHC_t*)ctx, src, dst, srcSize, dstCapacity);
}
return LZ4_compress_HC_extStateHC_fastReset(ctx, src, dst, srcSize, dstCapacity, level);
}
static int LZ4F_compressBlockHC_continue(void* ctx, const char* src, char* dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict* cdict)
{
(void)level; (void)cdict; /* init once at beginning of frame */
return LZ4_compress_HC_continue((LZ4_streamHC_t*)ctx, src, dst, srcSize, dstCapacity);
}
static compressFunc_t LZ4F_selectCompression(LZ4F_blockMode_t blockMode, int level)
{
if (level < LZ4HC_CLEVEL_MIN) {
if (blockMode == LZ4F_blockIndependent) return LZ4F_compressBlock;
return LZ4F_compressBlock_continue;
}
if (blockMode == LZ4F_blockIndependent) return LZ4F_compressBlockHC;
return LZ4F_compressBlockHC_continue;
}
static int LZ4F_localSaveDict(LZ4F_cctx_t* cctxPtr)
{
if (cctxPtr->prefs.compressionLevel < LZ4HC_CLEVEL_MIN)
return LZ4_saveDict ((LZ4_stream_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB);
return LZ4_saveDictHC ((LZ4_streamHC_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB);
}
typedef enum { notDone, fromTmpBuffer, fromSrcBuffer } LZ4F_lastBlockStatus;
/*! LZ4F_compressUpdate() :
* LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary.
* dstBuffer MUST be >= LZ4F_compressBound(srcSize, preferencesPtr).
* LZ4F_compressOptions_t structure is optional : you can provide NULL as argument.
* @return : the number of bytes written into dstBuffer. It can be zero, meaning input data was just buffered.
* or an error code if it fails (which can be tested using LZ4F_isError())
*/
size_t LZ4F_compressUpdate(LZ4F_cctx* cctxPtr,
void* dstBuffer, size_t dstCapacity,
const void* srcBuffer, size_t srcSize,
const LZ4F_compressOptions_t* compressOptionsPtr)
{
LZ4F_compressOptions_t cOptionsNull;
size_t const blockSize = cctxPtr->maxBlockSize;
const BYTE* srcPtr = (const BYTE*)srcBuffer;
const BYTE* const srcEnd = srcPtr + srcSize;
BYTE* const dstStart = (BYTE*)dstBuffer;
BYTE* dstPtr = dstStart;
LZ4F_lastBlockStatus lastBlockCompressed = notDone;
compressFunc_t const compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel);
DEBUGLOG(4, "LZ4F_compressUpdate (srcSize=%zu)", srcSize);
if (cctxPtr->cStage != 1) return err0r(LZ4F_ERROR_GENERIC);
if (dstCapacity < LZ4F_compressBound_internal(srcSize, &(cctxPtr->prefs), cctxPtr->tmpInSize))
return err0r(LZ4F_ERROR_dstMaxSize_tooSmall);
MEM_INIT(&cOptionsNull, 0, sizeof(cOptionsNull));
if (compressOptionsPtr == NULL) compressOptionsPtr = &cOptionsNull;
/* complete tmp buffer */
if (cctxPtr->tmpInSize > 0) { /* some data already within tmp buffer */
size_t const sizeToCopy = blockSize - cctxPtr->tmpInSize;
if (sizeToCopy > srcSize) {
/* add src to tmpIn buffer */
memcpy(cctxPtr->tmpIn + cctxPtr->tmpInSize, srcBuffer, srcSize);
srcPtr = srcEnd;
cctxPtr->tmpInSize += srcSize;
/* still needs some CRC */
} else {
/* complete tmpIn block and then compress it */
lastBlockCompressed = fromTmpBuffer;
memcpy(cctxPtr->tmpIn + cctxPtr->tmpInSize, srcBuffer, sizeToCopy);
srcPtr += sizeToCopy;
dstPtr += LZ4F_makeBlock(dstPtr, cctxPtr->tmpIn, blockSize,
compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
cctxPtr->cdict, cctxPtr->prefs.frameInfo.blockChecksumFlag);
if (cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) cctxPtr->tmpIn += blockSize;
cctxPtr->tmpInSize = 0;
}
}
while ((size_t)(srcEnd - srcPtr) >= blockSize) {
/* compress full blocks */
lastBlockCompressed = fromSrcBuffer;
dstPtr += LZ4F_makeBlock(dstPtr, srcPtr, blockSize,
compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
cctxPtr->cdict, cctxPtr->prefs.frameInfo.blockChecksumFlag);
srcPtr += blockSize;
}
if ((cctxPtr->prefs.autoFlush) && (srcPtr < srcEnd)) {
/* compress remaining input < blockSize */
lastBlockCompressed = fromSrcBuffer;
dstPtr += LZ4F_makeBlock(dstPtr, srcPtr, srcEnd - srcPtr,
compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
cctxPtr->cdict, cctxPtr->prefs.frameInfo.blockChecksumFlag);
srcPtr = srcEnd;
}
/* preserve dictionary if necessary */
if ((cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) && (lastBlockCompressed==fromSrcBuffer)) {
if (compressOptionsPtr->stableSrc) {
cctxPtr->tmpIn = cctxPtr->tmpBuff;
} else {
int const realDictSize = LZ4F_localSaveDict(cctxPtr);
if (realDictSize==0) return err0r(LZ4F_ERROR_GENERIC);
cctxPtr->tmpIn = cctxPtr->tmpBuff + realDictSize;
}
}
/* keep tmpIn within limits */
if ((cctxPtr->tmpIn + blockSize) > (cctxPtr->tmpBuff + cctxPtr->maxBufferSize) /* necessarily LZ4F_blockLinked && lastBlockCompressed==fromTmpBuffer */
&& !(cctxPtr->prefs.autoFlush))
{
int const realDictSize = LZ4F_localSaveDict(cctxPtr);
cctxPtr->tmpIn = cctxPtr->tmpBuff + realDictSize;
}
/* some input data left, necessarily < blockSize */
if (srcPtr < srcEnd) {
/* fill tmp buffer */
size_t const sizeToCopy = srcEnd - srcPtr;
memcpy(cctxPtr->tmpIn, srcPtr, sizeToCopy);
cctxPtr->tmpInSize = sizeToCopy;
}
if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled)
XXH32_update(&(cctxPtr->xxh), srcBuffer, srcSize);
cctxPtr->totalInSize += srcSize;
return dstPtr - dstStart;
}
/*! LZ4F_flush() :
* Should you need to create compressed data immediately, without waiting for a block to be filled,
* you can call LZ4_flush(), which will immediately compress any remaining data stored within compressionContext.
* The result of the function is the number of bytes written into dstBuffer
* (it can be zero, this means there was no data left within compressionContext)
* The function outputs an error code if it fails (can be tested using LZ4F_isError())
* The LZ4F_compressOptions_t structure is optional : you can provide NULL as argument.
*/
size_t LZ4F_flush(LZ4F_cctx* cctxPtr, void* dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t* compressOptionsPtr)
{
BYTE* const dstStart = (BYTE*)dstBuffer;
BYTE* dstPtr = dstStart;
compressFunc_t compress;
if (cctxPtr->tmpInSize == 0) return 0; /* nothing to flush */
if (cctxPtr->cStage != 1) return err0r(LZ4F_ERROR_GENERIC);
if (dstCapacity < (cctxPtr->tmpInSize + 4)) return err0r(LZ4F_ERROR_dstMaxSize_tooSmall); /* +4 : block header(4) */
(void)compressOptionsPtr; /* not yet useful */
/* select compression function */
compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel);
/* compress tmp buffer */
dstPtr += LZ4F_makeBlock(dstPtr, cctxPtr->tmpIn, cctxPtr->tmpInSize,
compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
cctxPtr->cdict, cctxPtr->prefs.frameInfo.blockChecksumFlag);
if (cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) cctxPtr->tmpIn += cctxPtr->tmpInSize;
cctxPtr->tmpInSize = 0;
/* keep tmpIn within limits */
if ((cctxPtr->tmpIn + cctxPtr->maxBlockSize) > (cctxPtr->tmpBuff + cctxPtr->maxBufferSize)) { /* necessarily LZ4F_blockLinked */
int realDictSize = LZ4F_localSaveDict(cctxPtr);
cctxPtr->tmpIn = cctxPtr->tmpBuff + realDictSize;
}
return dstPtr - dstStart;
}
/*! LZ4F_compressEnd() :
* When you want to properly finish the compressed frame, just call LZ4F_compressEnd().
* It will flush whatever data remained within compressionContext (like LZ4_flush())
* but also properly finalize the frame, with an endMark and a checksum.
* The result of the function is the number of bytes written into dstBuffer (necessarily >= 4 (endMark size))
* The function outputs an error code if it fails (can be tested using LZ4F_isError())
* The LZ4F_compressOptions_t structure is optional : you can provide NULL as argument.
* compressionContext can then be used again, starting with LZ4F_compressBegin(). The preferences will remain the same.
*/
size_t LZ4F_compressEnd(LZ4F_cctx* cctxPtr, void* dstBuffer, size_t dstMaxSize, const LZ4F_compressOptions_t* compressOptionsPtr)
{
BYTE* const dstStart = (BYTE*)dstBuffer;
BYTE* dstPtr = dstStart;
size_t const flushSize = LZ4F_flush(cctxPtr, dstBuffer, dstMaxSize, compressOptionsPtr);
if (LZ4F_isError(flushSize)) return flushSize;
dstPtr += flushSize;
LZ4F_writeLE32(dstPtr, 0);
dstPtr+=4; /* endMark */
if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled) {
U32 const xxh = XXH32_digest(&(cctxPtr->xxh));
LZ4F_writeLE32(dstPtr, xxh);
dstPtr+=4; /* content Checksum */
}
cctxPtr->cStage = 0; /* state is now re-usable (with identical preferences) */
cctxPtr->maxBufferSize = 0; /* reuse HC context */
if (cctxPtr->prefs.frameInfo.contentSize) {
if (cctxPtr->prefs.frameInfo.contentSize != cctxPtr->totalInSize)
return err0r(LZ4F_ERROR_frameSize_wrong);
}
return dstPtr - dstStart;
}
/*-***************************************************
* Frame Decompression
*****************************************************/
typedef enum {
dstage_getFrameHeader=0, dstage_storeFrameHeader,
dstage_init,
dstage_getBlockHeader, dstage_storeBlockHeader,
dstage_copyDirect, dstage_getBlockChecksum,
dstage_getCBlock, dstage_storeCBlock,
dstage_flushOut,
dstage_getSuffix, dstage_storeSuffix,
dstage_getSFrameSize, dstage_storeSFrameSize,
dstage_skipSkippable
} dStage_t;
struct LZ4F_dctx_s {
LZ4F_frameInfo_t frameInfo;
U32 version;
dStage_t dStage;
U64 frameRemainingSize;
size_t maxBlockSize;
size_t maxBufferSize;
BYTE* tmpIn;
size_t tmpInSize;
size_t tmpInTarget;
BYTE* tmpOutBuffer;
const BYTE* dict;
size_t dictSize;
BYTE* tmpOut;
size_t tmpOutSize;
size_t tmpOutStart;
XXH32_state_t xxh;
XXH32_state_t blockChecksum;
BYTE header[LZ4F_HEADER_SIZE_MAX];
}; /* typedef'd to LZ4F_dctx in lz4frame.h */
/*! LZ4F_createDecompressionContext() :
* Create a decompressionContext object, which will track all decompression operations.
* Provides a pointer to a fully allocated and initialized LZ4F_decompressionContext object.
* Object can later be released using LZ4F_freeDecompressionContext().
* @return : if != 0, there was an error during context creation.
*/
LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx** LZ4F_decompressionContextPtr, unsigned versionNumber)
{
LZ4F_dctx* const dctx = (LZ4F_dctx*)ALLOC_AND_ZERO(sizeof(LZ4F_dctx));
if (dctx==NULL) return err0r(LZ4F_ERROR_GENERIC);
dctx->version = versionNumber;
*LZ4F_decompressionContextPtr = dctx;
return LZ4F_OK_NoError;
}
LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx* dctx)
{
LZ4F_errorCode_t result = LZ4F_OK_NoError;
if (dctx != NULL) { /* can accept NULL input, like free() */
result = (LZ4F_errorCode_t)dctx->dStage;
FREEMEM(dctx->tmpIn);
FREEMEM(dctx->tmpOutBuffer);
FREEMEM(dctx);
}
return result;
}
/*==--- Streaming Decompression operations ---==*/
void LZ4F_resetDecompressionContext(LZ4F_dctx* dctx)
{
dctx->dStage = dstage_getFrameHeader;
dctx->dict = NULL;
dctx->dictSize = 0;
}
/*! LZ4F_headerSize() :
* @return : size of frame header
* or an error code, which can be tested using LZ4F_isError()
*/
static size_t LZ4F_headerSize(const void* src, size_t srcSize)
{
/* minimal srcSize to determine header size */
if (srcSize < 5) return err0r(LZ4F_ERROR_frameHeader_incomplete);
/* special case : skippable frames */
if ((LZ4F_readLE32(src) & 0xFFFFFFF0U) == LZ4F_MAGIC_SKIPPABLE_START) return 8;
/* control magic number */
if (LZ4F_readLE32(src) != LZ4F_MAGICNUMBER)
return err0r(LZ4F_ERROR_frameType_unknown);
/* Frame Header Size */
{ BYTE const FLG = ((const BYTE*)src)[4];
U32 const contentSizeFlag = (FLG>>3) & _1BIT;
U32 const dictIDFlag = FLG & _1BIT;
return minFHSize + (contentSizeFlag*8) + (dictIDFlag*4);
}
}
/*! LZ4F_decodeHeader() :
* input : `src` points at the **beginning of the frame**
* output : set internal values of dctx, such as
* dctx->frameInfo and dctx->dStage.
* Also allocates internal buffers.
* @return : nb Bytes read from src (necessarily <= srcSize)
* or an error code (testable with LZ4F_isError())
*/
static size_t LZ4F_decodeHeader(LZ4F_dctx* dctx, const void* src, size_t srcSize)
{
unsigned blockMode, blockChecksumFlag, contentSizeFlag, contentChecksumFlag, dictIDFlag, blockSizeID;
size_t frameHeaderSize;
const BYTE* srcPtr = (const BYTE*)src;
/* need to decode header to get frameInfo */
if (srcSize < minFHSize) return err0r(LZ4F_ERROR_frameHeader_incomplete); /* minimal frame header size */
MEM_INIT(&(dctx->frameInfo), 0, sizeof(dctx->frameInfo));
/* special case : skippable frames */
if ((LZ4F_readLE32(srcPtr) & 0xFFFFFFF0U) == LZ4F_MAGIC_SKIPPABLE_START) {
dctx->frameInfo.frameType = LZ4F_skippableFrame;
if (src == (void*)(dctx->header)) {
dctx->tmpInSize = srcSize;
dctx->tmpInTarget = 8;
dctx->dStage = dstage_storeSFrameSize;
return srcSize;
} else {
dctx->dStage = dstage_getSFrameSize;
return 4;
}
}
/* control magic number */
if (LZ4F_readLE32(srcPtr) != LZ4F_MAGICNUMBER)
return err0r(LZ4F_ERROR_frameType_unknown);
dctx->frameInfo.frameType = LZ4F_frame;
/* Flags */
{ U32 const FLG = srcPtr[4];
U32 const version = (FLG>>6) & _2BITS;
blockChecksumFlag = (FLG>>4) & _1BIT;
blockMode = (FLG>>5) & _1BIT;
contentSizeFlag = (FLG>>3) & _1BIT;
contentChecksumFlag = (FLG>>2) & _1BIT;
dictIDFlag = FLG & _1BIT;
/* validate */
if (((FLG>>1)&_1BIT) != 0) return err0r(LZ4F_ERROR_reservedFlag_set); /* Reserved bit */
if (version != 1) return err0r(LZ4F_ERROR_headerVersion_wrong); /* Version Number, only supported value */
}
/* Frame Header Size */
frameHeaderSize = minFHSize + (contentSizeFlag*8) + (dictIDFlag*4);
if (srcSize < frameHeaderSize) {
/* not enough input to fully decode frame header */
if (srcPtr != dctx->header)
memcpy(dctx->header, srcPtr, srcSize);
dctx->tmpInSize = srcSize;
dctx->tmpInTarget = frameHeaderSize;
dctx->dStage = dstage_storeFrameHeader;
return srcSize;
}
{ U32 const BD = srcPtr[5];
blockSizeID = (BD>>4) & _3BITS;
/* validate */
if (((BD>>7)&_1BIT) != 0) return err0r(LZ4F_ERROR_reservedFlag_set); /* Reserved bit */
if (blockSizeID < 4) return err0r(LZ4F_ERROR_maxBlockSize_invalid); /* 4-7 only supported values for the time being */
if (((BD>>0)&_4BITS) != 0) return err0r(LZ4F_ERROR_reservedFlag_set); /* Reserved bits */
}
/* check header */
{ BYTE const HC = LZ4F_headerChecksum(srcPtr+4, frameHeaderSize-5);
if (HC != srcPtr[frameHeaderSize-1])
return err0r(LZ4F_ERROR_headerChecksum_invalid);
}
/* save */
dctx->frameInfo.blockMode = (LZ4F_blockMode_t)blockMode;
dctx->frameInfo.blockChecksumFlag = (LZ4F_blockChecksum_t)blockChecksumFlag;
dctx->frameInfo.contentChecksumFlag = (LZ4F_contentChecksum_t)contentChecksumFlag;
dctx->frameInfo.blockSizeID = (LZ4F_blockSizeID_t)blockSizeID;
dctx->maxBlockSize = LZ4F_getBlockSize(blockSizeID);
if (contentSizeFlag)
dctx->frameRemainingSize =
dctx->frameInfo.contentSize = LZ4F_readLE64(srcPtr+6);
if (dictIDFlag)
dctx->frameInfo.dictID = LZ4F_readLE32(srcPtr + frameHeaderSize - 5);
dctx->dStage = dstage_init;
return frameHeaderSize;
}
/*! LZ4F_getFrameInfo() :
* This function extracts frame parameters (max blockSize, frame checksum, etc.).
* Usage is optional. Objective is to provide relevant information for allocation purposes.
* This function works in 2 situations :
* - At the beginning of a new frame, in which case it will decode this information from `srcBuffer`, and start the decoding process.
* Amount of input data provided must be large enough to successfully decode the frame header.
* A header size is variable, but is guaranteed to be <= LZ4F_HEADER_SIZE_MAX bytes. It's possible to provide more input data than this minimum.
* - After decoding has been started. In which case, no input is read, frame parameters are extracted from dctx.
* The number of bytes consumed from srcBuffer will be updated within *srcSizePtr (necessarily <= original value).
* Decompression must resume from (srcBuffer + *srcSizePtr).
* @return : an hint about how many srcSize bytes LZ4F_decompress() expects for next call,
* or an error code which can be tested using LZ4F_isError()
* note 1 : in case of error, dctx is not modified. Decoding operations can resume from where they stopped.
* note 2 : frame parameters are *copied into* an already allocated LZ4F_frameInfo_t structure.
*/
LZ4F_errorCode_t LZ4F_getFrameInfo(LZ4F_dctx* dctx, LZ4F_frameInfo_t* frameInfoPtr,
const void* srcBuffer, size_t* srcSizePtr)
{
if (dctx->dStage > dstage_storeFrameHeader) { /* assumption : dstage_* header enum at beginning of range */
/* frameInfo already decoded */
size_t o=0, i=0;
*srcSizePtr = 0;
*frameInfoPtr = dctx->frameInfo;
/* returns : recommended nb of bytes for LZ4F_decompress() */
return LZ4F_decompress(dctx, NULL, &o, NULL, &i, NULL);
} else {
if (dctx->dStage == dstage_storeFrameHeader) {
/* frame decoding already started, in the middle of header => automatic fail */
*srcSizePtr = 0;
return err0r(LZ4F_ERROR_frameDecoding_alreadyStarted);
} else {
size_t decodeResult;
size_t const hSize = LZ4F_headerSize(srcBuffer, *srcSizePtr);
if (LZ4F_isError(hSize)) { *srcSizePtr=0; return hSize; }
if (*srcSizePtr < hSize) {
*srcSizePtr=0;
return err0r(LZ4F_ERROR_frameHeader_incomplete);
}
decodeResult = LZ4F_decodeHeader(dctx, srcBuffer, hSize);
if (LZ4F_isError(decodeResult)) {
*srcSizePtr = 0;
} else {
*srcSizePtr = decodeResult;
decodeResult = BHSize; /* block header size */
}
*frameInfoPtr = dctx->frameInfo;
return decodeResult;
} }
}
/* LZ4F_updateDict() :
* only used for LZ4F_blockLinked mode */
static void LZ4F_updateDict(LZ4F_dctx* dctx,
const BYTE* dstPtr, size_t dstSize, const BYTE* dstBufferStart,
unsigned withinTmp)
{
if (dctx->dictSize==0)
dctx->dict = (const BYTE*)dstPtr; /* priority to dictionary continuity */
if (dctx->dict + dctx->dictSize == dstPtr) { /* dictionary continuity, directly within dstBuffer */
dctx->dictSize += dstSize;
return;
}
if (dstPtr - dstBufferStart + dstSize >= 64 KB) { /* history in dstBuffer becomes large enough to become dictionary */
dctx->dict = (const BYTE*)dstBufferStart;
dctx->dictSize = dstPtr - dstBufferStart + dstSize;
return;
}
assert(dstSize < 64 KB); /* if dstSize >= 64 KB, dictionary would be set into dstBuffer directly */
/* dstBuffer does not contain whole useful history (64 KB), so it must be saved within tmpOut */
if ((withinTmp) && (dctx->dict == dctx->tmpOutBuffer)) { /* continue history within tmpOutBuffer */
/* withinTmp expectation : content of [dstPtr,dstSize] is same as [dict+dictSize,dstSize], so we just extend it */
assert(dctx->dict + dctx->dictSize == dctx->tmpOut + dctx->tmpOutStart);
dctx->dictSize += dstSize;
return;
}
if (withinTmp) { /* copy relevant dict portion in front of tmpOut within tmpOutBuffer */
size_t const preserveSize = dctx->tmpOut - dctx->tmpOutBuffer;
size_t copySize = 64 KB - dctx->tmpOutSize;
const BYTE* const oldDictEnd = dctx->dict + dctx->dictSize - dctx->tmpOutStart;
if (dctx->tmpOutSize > 64 KB) copySize = 0;
if (copySize > preserveSize) copySize = preserveSize;
memcpy(dctx->tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
dctx->dict = dctx->tmpOutBuffer;
dctx->dictSize = preserveSize + dctx->tmpOutStart + dstSize;
return;
}
if (dctx->dict == dctx->tmpOutBuffer) { /* copy dst into tmp to complete dict */
if (dctx->dictSize + dstSize > dctx->maxBufferSize) { /* tmp buffer not large enough */
size_t const preserveSize = 64 KB - dstSize;
memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - preserveSize, preserveSize);
dctx->dictSize = preserveSize;
}
memcpy(dctx->tmpOutBuffer + dctx->dictSize, dstPtr, dstSize);
dctx->dictSize += dstSize;
return;
}
/* join dict & dest into tmp */
{ size_t preserveSize = 64 KB - dstSize;
if (preserveSize > dctx->dictSize) preserveSize = dctx->dictSize;
memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - preserveSize, preserveSize);
memcpy(dctx->tmpOutBuffer + preserveSize, dstPtr, dstSize);
dctx->dict = dctx->tmpOutBuffer;
dctx->dictSize = preserveSize + dstSize;
}
}
/*! LZ4F_decompress() :
* Call this function repetitively to regenerate compressed data in srcBuffer.
* The function will attempt to decode up to *srcSizePtr bytes from srcBuffer
* into dstBuffer of capacity *dstSizePtr.
*
* The number of bytes regenerated into dstBuffer will be provided within *dstSizePtr (necessarily <= original value).
*
* The number of bytes effectively read from srcBuffer will be provided within *srcSizePtr (necessarily <= original value).
* If number of bytes read is < number of bytes provided, then decompression operation is not complete.
* Remaining data will have to be presented again in a subsequent invocation.
*
* The function result is an hint of the better srcSize to use for next call to LZ4F_decompress.
* Schematically, it's the size of the current (or remaining) compressed block + header of next block.
* Respecting the hint provides a small boost to performance, since it allows less buffer shuffling.
* Note that this is just a hint, and it's always possible to any srcSize value.
* When a frame is fully decoded, @return will be 0.
* If decompression failed, @return is an error code which can be tested using LZ4F_isError().
*/
size_t LZ4F_decompress(LZ4F_dctx* dctx,
void* dstBuffer, size_t* dstSizePtr,
const void* srcBuffer, size_t* srcSizePtr,
const LZ4F_decompressOptions_t* decompressOptionsPtr)
{
LZ4F_decompressOptions_t optionsNull;
const BYTE* const srcStart = (const BYTE*)srcBuffer;
const BYTE* const srcEnd = srcStart + *srcSizePtr;
const BYTE* srcPtr = srcStart;
BYTE* const dstStart = (BYTE*)dstBuffer;
BYTE* const dstEnd = dstStart + *dstSizePtr;
BYTE* dstPtr = dstStart;
const BYTE* selectedIn = NULL;
unsigned doAnotherStage = 1;
size_t nextSrcSizeHint = 1;
MEM_INIT(&optionsNull, 0, sizeof(optionsNull));
if (decompressOptionsPtr==NULL) decompressOptionsPtr = &optionsNull;
*srcSizePtr = 0;
*dstSizePtr = 0;
/* behaves as a state machine */
while (doAnotherStage) {
switch(dctx->dStage)
{
case dstage_getFrameHeader:
if ((size_t)(srcEnd-srcPtr) >= maxFHSize) { /* enough to decode - shortcut */
size_t const hSize = LZ4F_decodeHeader(dctx, srcPtr, srcEnd-srcPtr); /* will update dStage appropriately */
if (LZ4F_isError(hSize)) return hSize;
srcPtr += hSize;
break;
}
dctx->tmpInSize = 0;
if (srcEnd-srcPtr == 0) return minFHSize; /* 0-size input */
dctx->tmpInTarget = minFHSize; /* minimum size to decode header */
dctx->dStage = dstage_storeFrameHeader;
/* fall-through */
case dstage_storeFrameHeader:
{ size_t const sizeToCopy = MIN(dctx->tmpInTarget - dctx->tmpInSize, (size_t)(srcEnd - srcPtr));
memcpy(dctx->header + dctx->tmpInSize, srcPtr, sizeToCopy);
dctx->tmpInSize += sizeToCopy;
srcPtr += sizeToCopy;
}
if (dctx->tmpInSize < dctx->tmpInTarget) {
nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize) + BHSize; /* rest of header + nextBlockHeader */
doAnotherStage = 0; /* not enough src data, ask for some more */
break;
}
{ size_t const hSize = LZ4F_decodeHeader(dctx, dctx->header, dctx->tmpInTarget); /* will update dStage appropriately */
if (LZ4F_isError(hSize)) return hSize;
}
break;
case dstage_init:
if (dctx->frameInfo.contentChecksumFlag) XXH32_reset(&(dctx->xxh), 0);
/* internal buffers allocation */
{ size_t const bufferNeeded = dctx->maxBlockSize
+ ((dctx->frameInfo.blockMode==LZ4F_blockLinked) * 128 KB);
if (bufferNeeded > dctx->maxBufferSize) { /* tmp buffers too small */
dctx->maxBufferSize = 0; /* ensure allocation will be re-attempted on next entry*/
FREEMEM(dctx->tmpIn);
dctx->tmpIn = (BYTE*)ALLOC(dctx->maxBlockSize + 4 /* block checksum */);
if (dctx->tmpIn == NULL)
return err0r(LZ4F_ERROR_allocation_failed);
FREEMEM(dctx->tmpOutBuffer);
dctx->tmpOutBuffer= (BYTE*)ALLOC(bufferNeeded);
if (dctx->tmpOutBuffer== NULL)
return err0r(LZ4F_ERROR_allocation_failed);
dctx->maxBufferSize = bufferNeeded;
} }
dctx->tmpInSize = 0;
dctx->tmpInTarget = 0;
dctx->tmpOut = dctx->tmpOutBuffer;
dctx->tmpOutStart = 0;
dctx->tmpOutSize = 0;
dctx->dStage = dstage_getBlockHeader;
/* fall-through */
case dstage_getBlockHeader:
if ((size_t)(srcEnd - srcPtr) >= BHSize) {
selectedIn = srcPtr;
srcPtr += BHSize;
} else {
/* not enough input to read cBlockSize field */
dctx->tmpInSize = 0;
dctx->dStage = dstage_storeBlockHeader;
}
if (dctx->dStage == dstage_storeBlockHeader) /* can be skipped */
case dstage_storeBlockHeader:
{ size_t const remainingInput = (size_t)(srcEnd - srcPtr);
size_t const wantedData = BHSize - dctx->tmpInSize;
size_t const sizeToCopy = MIN(wantedData, remainingInput);
memcpy(dctx->tmpIn + dctx->tmpInSize, srcPtr, sizeToCopy);
srcPtr += sizeToCopy;
dctx->tmpInSize += sizeToCopy;
if (dctx->tmpInSize < BHSize) { /* not enough input for cBlockSize */
nextSrcSizeHint = BHSize - dctx->tmpInSize;
doAnotherStage = 0;
break;
}
selectedIn = dctx->tmpIn;
} /* if (dctx->dStage == dstage_storeBlockHeader) */
/* decode block header */
{ size_t const nextCBlockSize = LZ4F_readLE32(selectedIn) & 0x7FFFFFFFU;
size_t const crcSize = dctx->frameInfo.blockChecksumFlag * 4;
if (nextCBlockSize==0) { /* frameEnd signal, no more block */
dctx->dStage = dstage_getSuffix;
break;
}
if (nextCBlockSize > dctx->maxBlockSize)
return err0r(LZ4F_ERROR_maxBlockSize_invalid);
if (LZ4F_readLE32(selectedIn) & LZ4F_BLOCKUNCOMPRESSED_FLAG) {
/* next block is uncompressed */
dctx->tmpInTarget = nextCBlockSize;
if (dctx->frameInfo.blockChecksumFlag) {
XXH32_reset(&dctx->blockChecksum, 0);
}
dctx->dStage = dstage_copyDirect;
break;
}
/* next block is a compressed block */
dctx->tmpInTarget = nextCBlockSize + crcSize;
dctx->dStage = dstage_getCBlock;
if (dstPtr==dstEnd) {
nextSrcSizeHint = nextCBlockSize + crcSize + BHSize;
doAnotherStage = 0;
}
break;
}
case dstage_copyDirect: /* uncompressed block */
{ size_t const minBuffSize = MIN((size_t)(srcEnd-srcPtr), (size_t)(dstEnd-dstPtr));
size_t const sizeToCopy = MIN(dctx->tmpInTarget, minBuffSize);
memcpy(dstPtr, srcPtr, sizeToCopy);
if (dctx->frameInfo.blockChecksumFlag) {
XXH32_update(&dctx->blockChecksum, srcPtr, sizeToCopy);
}
if (dctx->frameInfo.contentChecksumFlag)
XXH32_update(&dctx->xxh, srcPtr, sizeToCopy);
if (dctx->frameInfo.contentSize)
dctx->frameRemainingSize -= sizeToCopy;
/* history management (linked blocks only)*/
if (dctx->frameInfo.blockMode == LZ4F_blockLinked)
LZ4F_updateDict(dctx, dstPtr, sizeToCopy, dstStart, 0);
srcPtr += sizeToCopy;
dstPtr += sizeToCopy;
if (sizeToCopy == dctx->tmpInTarget) { /* all done */
if (dctx->frameInfo.blockChecksumFlag) {
dctx->tmpInSize = 0;
dctx->dStage = dstage_getBlockChecksum;
} else
dctx->dStage = dstage_getBlockHeader; /* new block */
break;
}
dctx->tmpInTarget -= sizeToCopy; /* need to copy more */
nextSrcSizeHint = dctx->tmpInTarget +
+ dctx->frameInfo.contentChecksumFlag * 4 /* block checksum */
+ BHSize /* next header size */;
doAnotherStage = 0;
break;
}
/* check block checksum for recently transferred uncompressed block */
case dstage_getBlockChecksum:
{ const void* crcSrc;
if ((srcEnd-srcPtr >= 4) && (dctx->tmpInSize==0)) {
crcSrc = srcPtr;
srcPtr += 4;
} else {
size_t const stillToCopy = 4 - dctx->tmpInSize;
size_t const sizeToCopy = MIN(stillToCopy, (size_t)(srcEnd-srcPtr));
memcpy(dctx->header + dctx->tmpInSize, srcPtr, sizeToCopy);
dctx->tmpInSize += sizeToCopy;
srcPtr += sizeToCopy;
if (dctx->tmpInSize < 4) { /* all input consumed */
doAnotherStage = 0;
break;
}
crcSrc = dctx->header;
}
{ U32 const readCRC = LZ4F_readLE32(crcSrc);
U32 const calcCRC = XXH32_digest(&dctx->blockChecksum);
if (readCRC != calcCRC)
return err0r(LZ4F_ERROR_blockChecksum_invalid);
} }
dctx->dStage = dstage_getBlockHeader; /* new block */
break;
case dstage_getCBlock:
if ((size_t)(srcEnd-srcPtr) < dctx->tmpInTarget) {
dctx->tmpInSize = 0;
dctx->dStage = dstage_storeCBlock;
break;
}
/* input large enough to read full block directly */
selectedIn = srcPtr;
srcPtr += dctx->tmpInTarget;
if (0) /* jump over next block */
case dstage_storeCBlock:
{ size_t const wantedData = dctx->tmpInTarget - dctx->tmpInSize;
size_t const inputLeft = (size_t)(srcEnd-srcPtr);
size_t const sizeToCopy = MIN(wantedData, inputLeft);
memcpy(dctx->tmpIn + dctx->tmpInSize, srcPtr, sizeToCopy);
dctx->tmpInSize += sizeToCopy;
srcPtr += sizeToCopy;
if (dctx->tmpInSize < dctx->tmpInTarget) { /* need more input */
nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize) + BHSize;
doAnotherStage=0;
break;
}
selectedIn = dctx->tmpIn;
}
/* At this stage, input is large enough to decode a block */
if (dctx->frameInfo.blockChecksumFlag) {
dctx->tmpInTarget -= 4;
assert(selectedIn != NULL); /* selectedIn is defined at this stage (either srcPtr, or dctx->tmpIn) */
{ U32 const readBlockCrc = LZ4F_readLE32(selectedIn + dctx->tmpInTarget);
U32 const calcBlockCrc = XXH32(selectedIn, dctx->tmpInTarget, 0);
if (readBlockCrc != calcBlockCrc)
return err0r(LZ4F_ERROR_blockChecksum_invalid);
} }
if ((size_t)(dstEnd-dstPtr) >= dctx->maxBlockSize) {
const char* dict = (const char*)dctx->dict;
size_t dictSize = dctx->dictSize;
int decodedSize;
if (dict && dictSize > 1 GB) {
/* the dictSize param is an int, avoid truncation / sign issues */
dict += dictSize - 64 KB;
dictSize = 64 KB;
}
/* enough capacity in `dst` to decompress directly there */
decodedSize = LZ4_decompress_safe_usingDict(
(const char*)selectedIn, (char*)dstPtr,
(int)dctx->tmpInTarget, (int)dctx->maxBlockSize,
dict, (int)dictSize);
if (decodedSize < 0) return err0r(LZ4F_ERROR_GENERIC); /* decompression failed */
if (dctx->frameInfo.contentChecksumFlag)
XXH32_update(&(dctx->xxh), dstPtr, decodedSize);
if (dctx->frameInfo.contentSize)
dctx->frameRemainingSize -= decodedSize;
/* dictionary management */
if (dctx->frameInfo.blockMode==LZ4F_blockLinked)
LZ4F_updateDict(dctx, dstPtr, decodedSize, dstStart, 0);
dstPtr += decodedSize;
dctx->dStage = dstage_getBlockHeader;
break;
}
/* not enough place into dst : decode into tmpOut */
/* ensure enough place for tmpOut */
if (dctx->frameInfo.blockMode == LZ4F_blockLinked) {
if (dctx->dict == dctx->tmpOutBuffer) {
if (dctx->dictSize > 128 KB) {
memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - 64 KB, 64 KB);
dctx->dictSize = 64 KB;
}
dctx->tmpOut = dctx->tmpOutBuffer + dctx->dictSize;
} else { /* dict not within tmp */
size_t const reservedDictSpace = MIN(dctx->dictSize, 64 KB);
dctx->tmpOut = dctx->tmpOutBuffer + reservedDictSpace;
} }
/* Decode block */
{ const char* dict = (const char*)dctx->dict;
size_t dictSize = dctx->dictSize;
int decodedSize;
if (dict && dictSize > 1 GB) {
/* the dictSize param is an int, avoid truncation / sign issues */
dict += dictSize - 64 KB;
dictSize = 64 KB;
}
decodedSize = LZ4_decompress_safe_usingDict(
(const char*)selectedIn, (char*)dctx->tmpOut,
(int)dctx->tmpInTarget, (int)dctx->maxBlockSize,
dict, (int)dictSize);
if (decodedSize < 0) /* decompression failed */
return err0r(LZ4F_ERROR_decompressionFailed);
if (dctx->frameInfo.contentChecksumFlag)
XXH32_update(&(dctx->xxh), dctx->tmpOut, decodedSize);
if (dctx->frameInfo.contentSize)
dctx->frameRemainingSize -= decodedSize;
dctx->tmpOutSize = decodedSize;
dctx->tmpOutStart = 0;
dctx->dStage = dstage_flushOut;
}
/* fall-through */
case dstage_flushOut: /* flush decoded data from tmpOut to dstBuffer */
{ size_t const sizeToCopy = MIN(dctx->tmpOutSize - dctx->tmpOutStart, (size_t)(dstEnd-dstPtr));
memcpy(dstPtr, dctx->tmpOut + dctx->tmpOutStart, sizeToCopy);
/* dictionary management */
if (dctx->frameInfo.blockMode == LZ4F_blockLinked)
LZ4F_updateDict(dctx, dstPtr, sizeToCopy, dstStart, 1 /*withinTmp*/);
dctx->tmpOutStart += sizeToCopy;
dstPtr += sizeToCopy;
if (dctx->tmpOutStart == dctx->tmpOutSize) { /* all flushed */
dctx->dStage = dstage_getBlockHeader; /* get next block */
break;
}
/* could not flush everything : stop there, just request a block header */
doAnotherStage = 0;
nextSrcSizeHint = BHSize;
break;
}
case dstage_getSuffix:
if (dctx->frameRemainingSize)
return err0r(LZ4F_ERROR_frameSize_wrong); /* incorrect frame size decoded */
if (!dctx->frameInfo.contentChecksumFlag) { /* no checksum, frame is completed */
nextSrcSizeHint = 0;
LZ4F_resetDecompressionContext(dctx);
doAnotherStage = 0;
break;
}
if ((srcEnd - srcPtr) < 4) { /* not enough size for entire CRC */
dctx->tmpInSize = 0;
dctx->dStage = dstage_storeSuffix;
} else {
selectedIn = srcPtr;
srcPtr += 4;
}
if (dctx->dStage == dstage_storeSuffix) /* can be skipped */
case dstage_storeSuffix:
{ size_t const remainingInput = (size_t)(srcEnd - srcPtr);
size_t const wantedData = 4 - dctx->tmpInSize;
size_t const sizeToCopy = MIN(wantedData, remainingInput);
memcpy(dctx->tmpIn + dctx->tmpInSize, srcPtr, sizeToCopy);
srcPtr += sizeToCopy;
dctx->tmpInSize += sizeToCopy;
if (dctx->tmpInSize < 4) { /* not enough input to read complete suffix */
nextSrcSizeHint = 4 - dctx->tmpInSize;
doAnotherStage=0;
break;
}
selectedIn = dctx->tmpIn;
} /* if (dctx->dStage == dstage_storeSuffix) */
/* case dstage_checkSuffix: */ /* no direct entry, avoid initialization risks */
{ U32 const readCRC = LZ4F_readLE32(selectedIn);
U32 const resultCRC = XXH32_digest(&(dctx->xxh));
if (readCRC != resultCRC)
return err0r(LZ4F_ERROR_contentChecksum_invalid);
nextSrcSizeHint = 0;
LZ4F_resetDecompressionContext(dctx);
doAnotherStage = 0;
break;
}
case dstage_getSFrameSize:
if ((srcEnd - srcPtr) >= 4) {
selectedIn = srcPtr;
srcPtr += 4;
} else {
/* not enough input to read cBlockSize field */
dctx->tmpInSize = 4;
dctx->tmpInTarget = 8;
dctx->dStage = dstage_storeSFrameSize;
}
if (dctx->dStage == dstage_storeSFrameSize)
case dstage_storeSFrameSize:
{ size_t const sizeToCopy = MIN(dctx->tmpInTarget - dctx->tmpInSize,
(size_t)(srcEnd - srcPtr) );
memcpy(dctx->header + dctx->tmpInSize, srcPtr, sizeToCopy);
srcPtr += sizeToCopy;
dctx->tmpInSize += sizeToCopy;
if (dctx->tmpInSize < dctx->tmpInTarget) {
/* not enough input to get full sBlockSize; wait for more */
nextSrcSizeHint = dctx->tmpInTarget - dctx->tmpInSize;
doAnotherStage = 0;
break;
}
selectedIn = dctx->header + 4;
} /* if (dctx->dStage == dstage_storeSFrameSize) */
/* case dstage_decodeSFrameSize: */ /* no direct entry */
{ size_t const SFrameSize = LZ4F_readLE32(selectedIn);
dctx->frameInfo.contentSize = SFrameSize;
dctx->tmpInTarget = SFrameSize;
dctx->dStage = dstage_skipSkippable;
break;
}
case dstage_skipSkippable:
{ size_t const skipSize = MIN(dctx->tmpInTarget, (size_t)(srcEnd-srcPtr));
srcPtr += skipSize;
dctx->tmpInTarget -= skipSize;
doAnotherStage = 0;
nextSrcSizeHint = dctx->tmpInTarget;
if (nextSrcSizeHint) break; /* still more to skip */
/* frame fully skipped : prepare context for a new frame */
LZ4F_resetDecompressionContext(dctx);
break;
}
} /* switch (dctx->dStage) */
} /* while (doAnotherStage) */
/* preserve history within tmp whenever necessary */
LZ4F_STATIC_ASSERT((unsigned)dstage_init == 2);
if ( (dctx->frameInfo.blockMode==LZ4F_blockLinked) /* next block will use up to 64KB from previous ones */
&& (dctx->dict != dctx->tmpOutBuffer) /* dictionary is not already within tmp */
&& (!decompressOptionsPtr->stableDst) /* cannot rely on dst data to remain there for next call */
&& ((unsigned)(dctx->dStage)-2 < (unsigned)(dstage_getSuffix)-2) ) /* valid stages : [init ... getSuffix[ */
{
if (dctx->dStage == dstage_flushOut) {
size_t const preserveSize = dctx->tmpOut - dctx->tmpOutBuffer;
size_t copySize = 64 KB - dctx->tmpOutSize;
const BYTE* oldDictEnd = dctx->dict + dctx->dictSize - dctx->tmpOutStart;
if (dctx->tmpOutSize > 64 KB) copySize = 0;
if (copySize > preserveSize) copySize = preserveSize;
if (copySize > 0)
memcpy(dctx->tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
dctx->dict = dctx->tmpOutBuffer;
dctx->dictSize = preserveSize + dctx->tmpOutStart;
} else {
const BYTE* const oldDictEnd = dctx->dict + dctx->dictSize;
size_t const newDictSize = MIN(dctx->dictSize, 64 KB);
if (newDictSize > 0)
memcpy(dctx->tmpOutBuffer, oldDictEnd - newDictSize, newDictSize);
dctx->dict = dctx->tmpOutBuffer;
dctx->dictSize = newDictSize;
dctx->tmpOut = dctx->tmpOutBuffer + newDictSize;
}
}
*srcSizePtr = (srcPtr - srcStart);
*dstSizePtr = (dstPtr - dstStart);
return nextSrcSizeHint;
}
/*! LZ4F_decompress_usingDict() :
* Same as LZ4F_decompress(), using a predefined dictionary.
* Dictionary is used "in place", without any preprocessing.
* It must remain accessible throughout the entire frame decoding.
*/
size_t LZ4F_decompress_usingDict(LZ4F_dctx* dctx,
void* dstBuffer, size_t* dstSizePtr,
const void* srcBuffer, size_t* srcSizePtr,
const void* dict, size_t dictSize,
const LZ4F_decompressOptions_t* decompressOptionsPtr)
{
if (dctx->dStage <= dstage_init) {
dctx->dict = (const BYTE*)dict;
dctx->dictSize = dictSize;
}
return LZ4F_decompress(dctx, dstBuffer, dstSizePtr,
srcBuffer, srcSizePtr,
decompressOptionsPtr);
}
|
c3a42053625d061703b3bb76f5bb8bf48004d05d
|
2ed0ca7920c77a3283a2b223a3d03b93358cc986
|
/pepper/apps/mr_genotyper_map.c
|
acd83dfbac6b0e73586a08274b1989d946719869
|
[
"BSD-3-Clause",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
pepper-project/pequin
|
a363c7ae1fe098eb52c3f188d84ff1688dce703f
|
db440e8f99fc214f76c6e691dc7fbdc190eb73a4
|
refs/heads/master
| 2022-05-13T22:50:39.532896
| 2022-04-05T22:32:30
| 2022-04-05T22:32:30
| 60,874,766
| 127
| 45
|
NOASSERTION
| 2020-09-28T23:30:29
| 2016-06-10T20:23:47
|
C
|
UTF-8
|
C
| false
| false
| 5,890
|
c
|
mr_genotyper_map.c
|
#include "mr_genotyper.h"
const fix_t matching_penalties[80*3] = {
-1, -1, -1,
-45011, -41190, -37821,
-28371, -35263, -44375,
-19795, -31301, -50928,
-14448, -28506, -57482,
-10818, -26466, -64036,
-8232, -24944, -70589,
-6333, -23790, -77143,
-4910, -22906, -83696,
-3829, -22222, -90250,
-2998, -21691, -96804,
-2355, -21276, -103357,
-1854, -20950, -109911,
-1462, -20695, -116464,
-1155, -20493, -123018,
-914, -20334, -129572,
-723, -20208, -136125,
-573, -20108, -142679,
-454, -20030, -149232,
-360, -19967, -155786,
-285, -19918, -162340,
-226, -19878, -168893,
-179, -19847, -175447,
-142, -19823, -182000,
-113, -19803, -188554,
-89, -19787, -195108,
-71, -19775, -201661,
-56, -19765, -208215,
-44, -19757, -214768,
-35, -19751, -221322,
-27, -19746, -227876,
-22, -19742, -234429,
-17, -19739, -240983,
-13, -19737, -247536,
-10, -19735, -254090,
-8, -19733, -260644,
-6, -19732, -267197,
-5, -19731, -273751,
-4, -19730, -280304,
-3, -19730, -286858,
-2, -19729, -293412,
-1, -19729, -299965,
-1, -19728, -306519,
0, -19728, -313072,
0, -19728, -319626,
0, -19728, -326180,
0, -19728, -332733,
0, -19728, -339287,
0, -19728, -345840,
0, -19728, -352394,
0, -19727, -358948,
0, -19727, -365501,
0, -19727, -372055,
0, -19727, -378608,
0, -19727, -385162,
0, -19727, -391716,
0, -19727, -398269,
0, -19727, -404823,
0, -19727, -411376,
0, -19727, -417930,
0, -19727, -424484,
0, -19727, -431037,
0, -19727, -437591,
0, -19727, -444144,
0, -19727, -450698,
0, -19727, -457252,
0, -19727, -463805,
0, -19727, -470359,
0, -19727, -476912,
0, -19727, -483466,
0, -19727, -490020,
0, -19727, -496573,
0, -19727, -503127,
0, -19727, -509680,
0, -19727, -516234,
0, -19727, -522788,
0, -19727, -529341,
0, -19727, -535895,
0, -19727, -542448,
0, -19727, -549002
};
//Assumes phred is a multiple of 10
fix_t q_base_given_genotype(phred_score_t phred, int mismatchA, int mismatchB){
int i, j;
fix_t toRet = 0;
for(i = 10; i <= 70; i+=10){
fix_t penalty = 0;
if (i == phred){
//0 mismatches - full, 1 mismatch - half,
// 2 mismatches - none
if (mismatchA){
if (mismatchB){
penalty = matching_penalties[i*3 + 2];
} else {
penalty = matching_penalties[i*3 + 1];
}
} else {
if (mismatchB){
penalty = matching_penalties[i*3 + 1];
} else {
penalty = matching_penalties[i*3 + 0];
}
}
}
toRet += penalty;
}
return toRet;
}
const fix_t reference_priors_lut[4][NUM_GENOTYPES] = {
//Generated by the call
//DiploidGenotypePriors.getReferencePolarizedPriors(ref,
// DiploidGenotypePriors.HUMAN_HETEROZYGOSITY,
// 0.01);
//in the GATK and rounding the results to fix_t
//A
{-42, -228162, -228162, -228162, -247604, -358948, -358948, -247604,
-358948, -247604, },
//T
{-247604, -358948, -358948, -228162, -247604, -358948, -228162,
-247604, -228162, -42, },
//G
{-247604, -358948, -228162, -358948, -247604, -228162, -358948, -42,
-228162, -247604, },
//C
{-247604, -228162, -358948, -358948, -42, -228162, -228162, -247604,
-358948, -247604, },
};
void getReferencePolarizedPriors(fix_t* priors, nucleotide_base_t ref){
nucleotide_base_t i;
int j;
for(i = 0; i < 4; i++){
if (i == ref){
for(j = 0; j < NUM_GENOTYPES; j++){
priors[j] = reference_priors_lut[i][j];
}
}
}
}
typedef struct _top_two_calls {
single_locus_genotype_t best_call;
fix_t qual_best_call;
fix_t qual_second_best_call;
} top_two_calls;
void consider_possibility(top_two_calls* caller, single_locus_genotype_t call, fix_t likelihood){
//Is this more likely than the current best?
if (likelihood > caller->qual_best_call){
//Shift both down
caller->best_call = call;
caller->qual_second_best_call = caller->qual_best_call;
caller->qual_best_call = likelihood;
} else {
//Is this more likely than the second best?
if (likelihood > caller->qual_second_best_call){
caller->qual_second_best_call = likelihood;
}
}
}
void map (MapperIn *mapper_input, MapperOut *mapper_output) {
int i;
MapperChunkOut* out = &mapper_output->output[0];
//Only one reducer.
assert_zero(NUM_REDUCERS-1);
//Iterate over pileups, making genotyping calls
for(i = 0; i < NUM_LOCI_PER_MAPPER; i++){
//Compute likelihoods that the organism sequenced has a particular
//genotype at this locus
fix_t likelihood [NUM_GENOTYPES];
//Keep track of the top two possibilities
top_two_calls caller = {0, FIX_T_MIN, FIX_T_MIN};
//Information: The reference base for this locus
nucleotide_base_t ref = mapper_input->refseq[i];
getReferencePolarizedPriors(likelihood, ref);
single_locus_genotype_t j;
for(j = 0; j < NUM_GENOTYPES; j++){
//More information: the sequence reads at this locus
int u;
for (u = 0; u < MAX_SIZE_PILEUP; u++){
phred_score_t qual = mapper_input->data[i].pileup[u].quality;
//Truncate qual to the next lowest multiple of 10
qual -= qual % 10; //Optimization.
nucleotide_base_t base = mapper_input->data[i].pileup[u].base;
//If qual is too small (for now, ignore 0's), ignore the base.
if (qual != 0){
likelihood[j] += q_base_given_genotype(qual,
base != GENOTYPES[j][0],
base != GENOTYPES[j][1]);
}
}
//Consider this possibility.
consider_possibility(&caller, j, likelihood[j]);
}
//Make the call based on the top two likelihoods
single_locus_genotype_call* call = out->calls + i;
call->call = caller.best_call;
//Call quality is the LOD between the best call and second call
call->quality = caller.qual_best_call - caller.qual_second_best_call;
}
}
// include this header _only_ after the above are defined
#include <mapred_map.h>
|
85c5c294d80c8845459107a9cdaa4c0578a216fd
|
75196819c910f3fd523f1a4d28e5d0fe12570ab1
|
/src/bdb53/src/dbinc_auto/heap_ext.h
|
8bc24b619bb2da67ec18ec80e0579e9a8e88c289
|
[
"MIT",
"BSD-3-Clause",
"Sleepycat"
] |
permissive
|
gridcoin-community/Gridcoin-Research
|
889967579b5b05bcc3ae836697a0f173b5ae91ea
|
21414dd0f63c9a34060f7f762f08d1a52aeb9e87
|
refs/heads/development
| 2023-09-04T09:21:55.006935
| 2023-09-03T17:45:20
| 2023-09-03T17:45:20
| 23,332,350
| 292
| 117
|
MIT
| 2023-09-11T10:22:10
| 2014-08-25T23:41:04
|
HTML
|
UTF-8
|
C
| false
| false
| 2,988
|
h
|
heap_ext.h
|
/* DO NOT EDIT: automatically built by dist/s_include. */
#ifndef _heap_ext_h_
#define _heap_ext_h_
#if defined(__cplusplus)
extern "C" {
#endif
int __heapc_init __P((DBC *));
int __heap_ditem __P((DBC *, PAGE *, u_int32_t, u_int32_t));
int __heap_append __P((DBC *, DBT *, DBT *));
int __heap_pitem __P((DBC *, PAGE *, u_int32_t, u_int32_t, DBT *, DBT *));
int __heapc_dup __P((DBC *, DBC *));
int __heapc_gsplit __P((DBC *, DBT *, void **, u_int32_t *));
int __heapc_refresh __P((DBC *));
int __heap_init_recover __P((ENV *, DB_DISTAB *));
int __heap_addrem_print __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
int __heap_pg_alloc_print __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
int __heap_trunc_meta_print __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
int __heap_trunc_page_print __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
int __heap_init_print __P((ENV *, DB_DISTAB *));
int __heap_backup __P((DB_ENV *, DB *, DB_THREAD_INFO *, DB_FH *, void *, u_int32_t));
int __heap_pgin __P((DB *, db_pgno_t, void *, DBT *));
int __heap_pgout __P((DB *, db_pgno_t, void *, DBT *));
int __heap_mswap __P((ENV *, PAGE *));
int __heap_db_create __P((DB *));
int __heap_db_close __P((DB *));
int __heap_get_heapsize __P((DB *, u_int32_t *, u_int32_t *));
int __heap_get_heap_regionsize __P((DB *, u_int32_t *));
int __heap_set_heapsize __P((DB *, u_int32_t, u_int32_t, u_int32_t));
int __heap_set_heap_regionsize __P((DB *, u_int32_t));
int __heap_exist __P((void));
int __heap_open __P((DB *, DB_THREAD_INFO *, DB_TXN *, const char *, db_pgno_t, u_int32_t));
int __heap_metachk __P((DB *, const char *, HEAPMETA *));
int __heap_read_meta __P((DB *, DB_THREAD_INFO *, DB_TXN *, db_pgno_t, u_int32_t));
int __heap_new_file __P((DB *, DB_THREAD_INFO *, DB_TXN *, DB_FH *, const char *));
int __heap_create_region __P((DBC *, db_pgno_t));
int __heap_addrem_recover __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
int __heap_pg_alloc_recover __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
int __heap_trunc_meta_recover __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
int __heap_trunc_page_recover __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
int __heap_truncate __P((DBC *, u_int32_t *));
int __heap_stat __P((DBC *, void *, u_int32_t));
int __heap_stat_print __P((DBC *, u_int32_t));
void __heap_print_cursor __P((DBC *));
int __heap_stat_callback __P((DBC *, PAGE *, void *, int *));
int __heap_traverse __P((DBC *, int (*)(DBC *, PAGE *, void *, int *), void *));
int __db_no_heap_am __P((ENV *));
int __heap_vrfy_meta __P((DB *, VRFY_DBINFO *, HEAPMETA *, db_pgno_t, u_int32_t));
int __heap_vrfy __P((DB *, VRFY_DBINFO *, PAGE *, db_pgno_t, u_int32_t));
int __heap_vrfy_structure __P((DB *, VRFY_DBINFO *, u_int32_t));
int __heap_salvage __P((DB *, VRFY_DBINFO *, db_pgno_t, PAGE *, void *, int (*)(void *, const void *), u_int32_t));
int __heap_meta2pgset __P((DB *, VRFY_DBINFO *, HEAPMETA *, DB *));
#if defined(__cplusplus)
}
#endif
#endif /* !_heap_ext_h_ */
|
5c49c9eeecf447cebfd6c2eb1632c7303a5e9906
|
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
|
/dsp/tty/quant.h
|
a0422ebf46fd1529612573555d0db6b1bd39b2ae
|
[
"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
| 2,695
|
h
|
quant.h
|
#ifndef DSP_TTY_QUANT_H_
#define DSP_TTY_QUANT_H_
#include "dsp/tty/ttyrgb.h"
#include "libc/assert.h"
#include "libc/intrin/bits.h"
#include "libc/limits.h"
#include "libc/str/str.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#define TL 0
#define TR 1
#define BL 2
#define BR 3
typedef float ttyrgb_m128 __attribute__((__vector_size__(16), __may_alias__));
typedef ttyrgb_m128 (*tty2rgbf_f)(struct TtyRgb);
typedef char *(*setbg_f)(char *, struct TtyRgb);
typedef char *(*setbgfg_f)(char *, struct TtyRgb, struct TtyRgb);
typedef char *(*setfg_f)(char *, struct TtyRgb);
typedef struct TtyRgb (*rgb2tty_f)(int, int, int);
typedef struct TtyRgb (*rgb2ttyf_f)(ttyrgb_m128);
typedef struct TtyRgb (*tty2rgb_f)(struct TtyRgb);
typedef struct TtyRgb ttypalette_t[2][8];
enum TtyQuantizationAlgorithm {
kTtyQuantAnsi,
kTtyQuantTrue,
kTtyQuantXterm256,
};
enum TtyBlocksSelection {
kTtyBlocksUnicode,
kTtyBlocksCp437,
};
enum TtyQuantizationChannels {
kTtyQuantGrayscale = 1,
kTtyQuantRgb = 3,
};
struct TtyQuant {
enum TtyQuantizationAlgorithm alg;
enum TtyBlocksSelection blocks;
enum TtyQuantizationChannels chans;
unsigned min;
unsigned max;
setbg_f setbg;
setfg_f setfg;
setbgfg_f setbgfg;
rgb2tty_f rgb2tty;
rgb2ttyf_f rgb2ttyf;
tty2rgb_f tty2rgb;
tty2rgbf_f tty2rgbf;
const ttypalette_t *palette;
};
extern const ttypalette_t kCgaPalette;
extern const ttypalette_t kXtermPalette;
extern const ttypalette_t kTangoPalette;
extern const uint8_t kXtermCubeSteps[6];
extern double g_xterm256_gamma;
extern struct TtyRgb g_ansi2rgb_[256];
extern struct TtyQuant g_ttyquant_;
extern const uint8_t kXtermXlat[2][256];
extern const uint8_t kXtermCube[6];
void ttyquantsetup(enum TtyQuantizationAlgorithm, enum TtyQuantizationChannels,
enum TtyBlocksSelection);
extern char *ttyraster(char *, const struct TtyRgb *, size_t, size_t,
struct TtyRgb, struct TtyRgb);
#ifndef ttyquant
#define ttyquant() (&g_ttyquant_)
#define TTYQUANT() __veil("r", &g_ttyquant_)
#define rgb2tty(...) (ttyquant()->rgb2tty(__VA_ARGS__))
#define tty2rgb(...) (ttyquant()->tty2rgb(__VA_ARGS__))
#define rgb2ttyf(...) (ttyquant()->rgb2ttyf(__VA_ARGS__))
#define tty2rgbf(...) (ttyquant()->tty2rgbf(__VA_ARGS__))
#define setbg(...) (ttyquant()->setbg(__VA_ARGS__))
#define setfg(...) (ttyquant()->setfg(__VA_ARGS__))
#define setbgfg(...) (ttyquant()->setbgfg(__VA_ARGS__))
#endif /* ttyquant */
forceinline bool ttyeq(struct TtyRgb x, struct TtyRgb y) {
return x.r == y.r && x.g == y.g && x.b == y.b;
}
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* DSP_TTY_QUANT_H_ */
|
97e19eb19bada42385c1c051e9f087337216757a
|
984bc4181baec6e5a4b05a657e666b0e9f89f3f3
|
/include/TfTest/tftest.h
|
2f6dd25691e6a1f1fd9b769e8c0a480159561635
|
[
"BSD-3-Clause"
] |
permissive
|
treefrogframework/treefrog-framework
|
0173245ff92162d2107af79861505981980d1eca
|
a1df97793e8cc628779378e5adae9af6987460c1
|
refs/heads/master
| 2023-08-22T03:57:58.891846
| 2023-05-18T14:00:42
| 2023-05-18T14:00:42
| 7,067,532
| 1,152
| 263
|
BSD-3-Clause
| 2023-08-08T20:25:03
| 2012-12-08T13:17:01
|
C++
|
UTF-8
|
C
| false
| false
| 27
|
h
|
tftest.h
|
#include "../src/tftest.h"
|
fbccece7d7f0921ca2a31504e3f8a8dfd1543d64
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/audio/mp3_check/files/patch-mp3__check.c
|
33aba00551ff4bdc0304df930a77770b8e2e08e2
|
[
"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
| 246
|
c
|
patch-mp3__check.c
|
--- mp3_check.c.orig 2000-07-29 06:51:38 UTC
+++ mp3_check.c
@@ -60,6 +60,7 @@ GOALS: Initially, making a higly accura
#include <errno.h>
#include <stdio.h>
+#include <getopt.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
|
bcf945de15c3cbaf393a5148bb2a2fd2c52a2566
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/allwinner/libraries/sunxi-hal/hal/source/sdmmc/hal_sdhost.c
|
12d3307743db09075b5c8b7cb41ee854de62aa69
|
[
"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
| 84,935
|
c
|
hal_sdhost.c
|
/**
* @file hal_sdhost.c
* @author ALLWINNERTECH IOT WLAN Team
*/
/*
* Copyright (C) 2017 ALLWINNERTECH TECHNOLOGY CO., LTD. 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 ALLWINNERTECH TECHNOLOGY CO., LTD. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, )|hhst->sdio_irq_maskPROCUREMENT 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 "_sdhost.h"
#include "sunxi_hal_common.h"
#include "stdint.h"
//#include "io.h"
//#include "hal_prcm.h"
#include "hal_ccm.h"
#include "hal_gpio.h"
#include "hal_board.h"
#include "hal_dev.h"
#include "hal_clock.h"
#include "sdmmc/sys/param.h"
#include "hal_sdhost.h"
#ifdef CONFIG_USE_SDIO
#include "sdio.h"
#endif
#include "sdmmc.h"
#include "_sd_define.h"
#include "_core.h"
#ifndef CONFIG_KERNEL_FREERTOS
#include "osal/os/RT-Thread/os_util.h"
#else
#include "osal/os/FreeRTOS/os_util.h"
#endif
#include "interrupt.h"
//#include "k_arch.h"
extern uint32_t sdmmc_pinctrl_init(struct mmc_host *host);
extern int mmc_gpiod_request_cd_irq(struct mmc_host* host);
//#define __dsb__() dsb(0xf)
#ifndef UINT_MAX
#define UINT_MAX (~0U)
#endif
/*
#define SDC_REQUEST_IRQ(n, hdl) HAL_NVIC_SetIRQHandler(n, hdl)
#define SDC_SetPriority(n, l) HAL_NVIC_SetPriority(n, l)
#define SDC_ENABLE_IRQ(n) HAL_NVIC_EnableIRQ(n)
#define SDC_CONFIG_IRQ(n, hdl, l) HAL_NVIC_ConfigExtIRQ(n, hdl, l)
#define SDC_DISABLE_IRQ(n) HAL_NVIC_DisableIRQ(n)
#define SDC_CLEAR_IRQPINGD(n) HAL_NVIC_ClearPendingIRQ(n)
#define SDC_IRQHandler NVIC_IRQHandler
*/
#define SDC_REQUEST_IRQ(n, hdl,d) ({SDC_LOGD("%s,%d,sdc %d irq request \n",__func__, __LINE__, d->sdc_id);\
request_irq(n, hdl, 0, "sdmmc",d);})
#define SDC_FREE_IRQ(n, d) (free_irq(n, d))
#define SDC_SetPriority(n, l) ({SDC_LOGN("Not imp %s,%d\n", __FUNCTION__,__LINE__);})
#define SDC_ENABLE_IRQ(n) enable_irq(n)
#define SDC_CONFIG_IRQ(n, hdl, l) ({SDC_LOGN("Not imp %s,%d\n", __FUNCTION__,__LINE__);})
#define SDC_DISABLE_IRQ(n) disable_irq(n)
//#define SDC_CLEAR_IRQPINGD(n) gic_clear_pending(n)
#define SDC_CLEAR_IRQPINGD(n) ({SDC_LOGN("Not imp %s,%d\n", __FUNCTION__,__LINE__);})
//#define SDC_CLEAR_IRQPINGD(n) free_irq(n)
//#define SDC_IRQHandler interrupt_handler_t
#define SDC_IRQHandler irq_handler_t *
#define NUSE_STANDARD_INTERFACE 1
#ifdef NUSE_STANDARD_INTERFACE
#define SDC1_SUPPORT 1
#define SDC_CCM_SDC0_SCLK_CTRL (SDC_CCM_BASE + 0x830)
#define SDC_CCM_SDC1_SCLK_CTRL (SDC_CCM_BASE + 0x834)
#define SDC_CCM_SDC_BUS_GATE_RESET (SDC_CCM_BASE + 0x84c)
/*
#define SDC0_CCM_BusForceReset() HAL_CCM_BusForcePeriphReset(CCM_BUS_PERIPH_BIT_SDC0)
#define SDC0_CCM_BusReleaseRest() HAL_CCM_BusReleasePeriphReset(CCM_BUS_PERIPH_BIT_SDC0)
#define SDC0_CCM_BusEnableClock() HAL_CCM_BusEnablePeriphClock(CCM_BUS_PERIPH_BIT_SDC0)
#define SDC0_CCM_BusDisableClock() HAL_CCM_BusDisablePeriphClock(CCM_BUS_PERIPH_BIT_SDC0)
#define SDC0_CCM_EnableMClock() HAL_CCM_SDC0_EnableMClock()
#define SDC0_DisableMClock HAL_CCM_SDC0_DisableMClock
#define SDC0_SetMClock HAL_CCM_SDC0_SetMClock
*/
#define SDC0_CCM_BusForceReset() ({int v = readl(SDC_CCM_SDC_BUS_GATE_RESET); v &= ~(1<<16); writel(v,SDC_CCM_SDC_BUS_GATE_RESET);})
#define SDC0_CCM_BusReleaseRest() ({int v = readl(SDC_CCM_SDC_BUS_GATE_RESET); v |= (1<<16); writel(v,SDC_CCM_SDC_BUS_GATE_RESET);})
#define SDC0_CCM_BusEnableClock() ({int v = readl(SDC_CCM_SDC_BUS_GATE_RESET); v |= (1<<0); writel(v,SDC_CCM_SDC_BUS_GATE_RESET);})
#define SDC0_CCM_BusDisableClock() ({int v = readl(SDC_CCM_SDC_BUS_GATE_RESET); v &= ~(1<<0); writel(v,SDC_CCM_SDC_BUS_GATE_RESET);})
#define SDC0_CCM_EnableMClock() ({int v = readl(SDC_CCM_SDC0_SCLK_CTRL); v |= (1<<31); writel(v,SDC_CCM_SDC0_SCLK_CTRL);})
#define SDC0_DisableMClock() ({int v = readl(SDC_CCM_SDC0_SCLK_CTRL); v &= ~(1<<31); writel(v,SDC_CCM_SDC0_SCLK_CTRL);})
#define SDC1_CCM_BusForceReset() ({int v = readl(SDC_CCM_SDC_BUS_GATE_RESET); v &= ~(1<<17); writel(v,SDC_CCM_SDC_BUS_GATE_RESET);})
#define SDC1_CCM_BusReleaseRest() ({int v = readl(SDC_CCM_SDC_BUS_GATE_RESET); v |= (1<<17); writel(v,SDC_CCM_SDC_BUS_GATE_RESET);})
#define SDC1_CCM_BusEnableClock() ({int v = readl(SDC_CCM_SDC_BUS_GATE_RESET); v |= (1<<1); writel(v,SDC_CCM_SDC_BUS_GATE_RESET);})
#define SDC1_CCM_BusDisableClock() ({int v = readl(SDC_CCM_SDC_BUS_GATE_RESET); v &= ~(1<<1); writel(v,SDC_CCM_SDC_BUS_GATE_RESET);})
#define SDC1_CCM_EnableMClock() ({int v = readl(SDC_CCM_SDC1_SCLK_CTRL); v |= (1<<31); writel(v,SDC_CCM_SDC1_SCLK_CTRL);})
#define SDC1_DisableMClock() ({int v = readl(SDC_CCM_SDC1_SCLK_CTRL); v &= ~(1<<31); writel(v,SDC_CCM_SDC1_SCLK_CTRL);})
#define SDC1_SET_GPIO_MUX() ({int v = readl(SDC_GPIO_BASE + 0xd8);\
SDC_LOGD("RAW SET SDC1 MUX\n");\
v &= ~(0xffffff); v |=0x222222;\
writel(v,SDC_GPIO_BASE + 0xd8);\
SDC_LOGD("RAW SDC1 MUX %x\n", readl(SDC_GPIO_BASE + 0xd8));})
#define SDC1_SET_GPIO_DRV() ({int v = readl(SDC_GPIO_BASE + 0xec);\
SDC_LOGD("RAW SET SDC1 DRV\n");\
v &= ~(0xfff);\
v |=0x000; writel(v,SDC_GPIO_BASE + 0xec);\
SDC_LOGD("RAW SDC1 DRV %x\n",readl(SDC_GPIO_BASE + 0xec));})
#define SDC1_SET_GPIO_PULL() ({int v = readl(SDC_GPIO_BASE + 0xf4);\
SDC_LOGD("RAW SET SDC1 PULL\n");\
v &= ~(0xfff);\
v |=0x555; writel(v,SDC_GPIO_BASE + 0xf4);\
SDC_LOGD("RAW SDC1 PULL %x\n",readl(SDC_GPIO_BASE + 0xf4));})
#define SDC_TIG_SET_GPIO_MUX() ({int v = readl(SDC_GPIO_BASE + 0x28);\
SDC_LOGD("+RAW SET TIG SDC MUX %x\n", SDC_GPIO_BASE + 0x28);\
v &= ~(0x0000F000); v |=0x00001000;\
writel(v,SDC_GPIO_BASE + 0x28);\
SDC_LOGD("-RAW SDC TIG MUX %x\n", readl(SDC_GPIO_BASE + 0x28));})
#define SDC_TIG_SET_GPIO_DRV() ({int v = readl(SDC_GPIO_BASE + 0x38);\
SDC_LOGD("+RAW SET SDC TIG DRV %x\n", SDC_GPIO_BASE + 0x38);\
v &= ~(0x00C00000);\
v |=0x00C00000; writel(v,SDC_GPIO_BASE + 0x38);\
SDC_LOGD("-RAW SDC TRG DRV %x\n",readl(SDC_GPIO_BASE + 0x38));})
#define SDC_TIG_SET_GPIO_PULL() ({int v = readl(SDC_GPIO_BASE + 0x40);\
SDC_LOGD("+RAW SET SDC TRG PULL %x\n", SDC_GPIO_BASE + 0x40);\
v &= ~(0x00C00000);\
v |=0x00400000; writel(v,SDC_GPIO_BASE + 0x40);\
SDC_LOGD("-RAW SDC1 PULL %x\n",readl(SDC_GPIO_BASE + 0x40));})
#define SDC_TIG_SET_GPIO_DAT() ({int v = readl(SDC_GPIO_BASE + 0x34);\
SDC_LOGD("+raw set sdc trg dat %x\n",SDC_GPIO_BASE + 0x34);\
v &= ~(0x00000800);\
v |=0x00000800; writel(v,SDC_GPIO_BASE + 0x34);\
SDC_LOGD("-RAW SDC1 DAT %x\n",readl(SDC_GPIO_BASE + 0x34));})
#define SDC_TIG_CLR_GPIO_DAT() ({int v = readl(SDC_GPIO_BASE + 0x34);\
SDC_LOGD("RAW SET SDC TRG dat\n");\
v &= ~(0x00000800);\
v |=0x00000000; writel(v,SDC_GPIO_BASE + 0x34);\
SDC_LOGD("RAW SDC1 dat %x\n",readl(SDC_GPIO_BASE + 0x34));})
#define HAL_BoardIoctl(a,b,c) ({SDC_LOGN("NOT IMP %s,%d\n",__FUNCTION__, __LINE__);})
#define HAL_GPIO_ReadPin(cd_gpios, data) ({hal_gpio_get_data(cd_gpios, (gpio_data_t *)data);\
*(data);})
#else
#define SDC0_CCM_BusForceReset() HAL_CCM_BusForcePeriphReset(CCM_BUS_PERIPH_BIT_SDC0)
#define SDC0_CCM_BusReleaseRest() HAL_CCM_BusReleasePeriphReset(CCM_BUS_PERIPH_BIT_SDC0)
#define SDC0_CCM_BusEnableClock() HAL_CCM_BusEnablePeriphClock(CCM_BUS_PERIPH_BIT_SDC0)
#define SDC0_CCM_BusDisableClock() HAL_CCM_BusDisablePeriphClock(CCM_BUS_PERIPH_BIT_SDC0)
#define SDC0_CCM_EnableMClock() HAL_CCM_SDC0_EnableMClock()
#define SDC0_DisableMClock HAL_CCM_SDC0_DisableMClock
#define SDC0_SetMClock HAL_CCM_SDC0_SetMClock
#define SDC1_SUPPORT 1
#define SDC1_CCM_BusForceReset() HAL_CCM_BusForcePeriphReset(CCM_BUS_PERIPH_BIT_SDC1)
#define SDC1_CCM_BusReleaseRest() HAL_CCM_BusReleasePeriphReset(CCM_BUS_PERIPH_BIT_SDC1)
#define SDC1_CCM_BusEnableClock() HAL_CCM_BusEnablePeriphClock(CCM_BUS_PERIPH_BIT_SDC1)
#define SDC1_CCM_BusDisableClock() HAL_CCM_BusDisablePeriphClock(CCM_BUS_PERIPH_BIT_SDC1)
#define SDC1_CCM_EnableMClock() HAL_CCM_SDC1_EnableMClock()
#define SDC1_DisableMClock HAL_CCM_SDC1_DisableMClock
#define SDC1_SetMClock HAL_CCM_SDC1_SetMClock
#endif /* NUSE_STANDARD_INTERFACE */
#ifndef SDC1_SUPPORT
#define SDC1_SUPPORT 0
#endif
#define MEMS_VA2PA(x) __va_to_pa(x)
#if 0
#define mci_readl(host, reg) \
({ uint32_t val;\
SDC_LOGD("+reg add 0x%x\n", (uint32_t)(host)->reg_base + reg);\
val = readl((uint32_t)(host)->reg_base + reg);\
SDC_LOGD("%s,%d\n", __FUNCTION__, __LINE__);\
SDC_LOGD("-reg val 0x%x\n", val);\
val;})
#define mci_writel(value, host, reg) \
({ uint32_t val;\
SDC_LOGD("+reg add 0x%x write val 0x%x\n", (uint32_t)(host)->reg_base + reg, value);\
writel((value), (uint32_t)(host)->reg_base + reg);\
val = readl((uint32_t)(host)->reg_base + reg);\
SDC_LOGD("%s,%d\n", __FUNCTION__, __LINE__);\
SDC_LOGD("-reg read val 0x%x\n", val);})
#define mci_readw(host, reg) \
({ uint32_t val;\
SDC_LOGD("+reg add 0x%x\n", (uint32_t)(host)->reg_base + reg);\
val = readw((uint32_t)(host)->reg_base + reg);\
SDC_LOGD("%s,%d\n", __FUNCTION__, __LINE__);\
SDC_LOGD("-reg val 0x%x\n", val);\
val;})
#define mci_writew(value, host, reg) \
({ uint32_t val;\
SDC_LOGD("+reg add 0x%x write val 0x%x\n", (uint32_t)(host)->reg_base + reg, value);\
writew((value), (uint32_t)(host)->reg_base + reg);\
val = readl((uint32_t)(host)->reg_base + reg);\
SDC_LOGD("%s,%d\n", __FUNCTION__, __LINE__);\
SDC_LOGD("-reg read val 0x%x\n", val);})
#define mci_readb(host, reg) \
({ uint32_t val;\
SDC_LOGD("+reg add 0x%x\n", (uint32_t)(host)->reg_base + reg);\
val = readb((uint32_t)(host)->reg_base + reg);\
SDC_LOGD("%s,%d\n", __FUNCTION__, __LINE__);\
SDC_LOGD("-reg val 0x%x\n", val);\
val;})
#define mci_writeb(value, host, reg) \
({ uint32_t val;\
SDC_LOGD("+reg add 0x%x write val 0x%x\n", (uint32_t)(host)->reg_base + reg, value);\
writeb((value), (uint32_t)(host)->reg_base + reg);\
val = readl((uint32_t)(host)->reg_base + reg);\
SDC_LOGD("%s,%d\n", __FUNCTION__, __LINE__);\
SDC_LOGD("-reg read val 0x%x\n", val);})
#else
#define mci_readl(host, reg) \
readl(HAL_PT_TO_U((host)->reg_base) + reg)
#define mci_writel(value, host, reg) \
writel((value), HAL_PT_TO_U((host)->reg_base) + reg)
#define mci_writew(value, host, reg) \
writew((value), HAL_PT_TO_U((host)->reg_base) + reg)
#define mci_readw(host, reg) \
readw(HAL_PT_TO_U((host)->reg_base) + reg)
#define mci_readb(host, reg) \
readb(HAL_PT_TO_U((host)->reg_base) + reg)
#define mci_writeb(value, host, reg) \
writeb((value),HAL_PT_TO_U((host)->reg_base) + reg)
#endif
#define SDC_BUSY_WAIT_LOOP (0xffffffff)
int32_t __mci_check_bit_clear(struct mmc_host *host, uint32_t reg_offset, uint32_t bit_map);
static struct mmc_host *_mci_host[SDC_NUM];
/**
* sdc timer timeout flags
*/
static int __sdc_init_timeout_flags = 0;
static uint64_t __mci_get_rate(uint64_t bytes, uint64_t time_us)
{
uint64_t ns;
ns = time_us * 1000;
bytes *= 1000000000;
while (ns > UINT_MAX) {
bytes >>= 1;
ns >>= 1;
}
if (!ns)
return 0;
do_div(bytes, (uint32_t)ns);
return bytes;
}
static void __mci_force_dump_host_info(struct mmc_host *host)
{
uint16_t debug_mask = host->debug_mask;
host->debug_mask |= ROM_DUMP_MASK | ROM_ERR_MASK;
SDC_LOGE("*force dump gpio reg*\n");
sdc_hex_dump_word((void *)SDC_GPIO_BASE+0xb0,0xff);
sdc_hex_dump_word((void *)SDC_GPIO_BASE+0x340,0xff);
SDC_LOGE("*force dump ccmu reg*\n");
sdc_hex_dump_word((void *)SDC_CCM_SDC0_SCLK_CTRL ,0xff);
sdc_hex_dump_word((void *)SDC_CCM_BASE ,0xff);
SDC_LOGE("*force dump smc reg*\n");
sdc_hex_dump_word((void *)(SMC0_BASE + 0x1000UL * host->sdc_id) ,0x150);
SDC_LOGE("force dump state wait:%x,int_sum %x, int_err %x\n",\
(unsigned int)host->wait, (unsigned int)host->int_sum, (unsigned int)host->int_err);
SDC_LOGE("force dump done dma_done:%x,transfer_done %x\n",\
(unsigned int)host->dma_done, (unsigned int)host->trans_done);
host->debug_mask = debug_mask;
}
static int32_t __mci_exit_host(struct mmc_host *host)
{
uint32_t rval;
#ifdef CONFIG_SDC_SUPPORT_1V8
host->voltage = SDC_WOLTAGE_OFF;
#endif
rval = mci_readl(host, SDXC_REG_GCTRL) | SDXC_HWReset;
mci_writel(rval, host, SDXC_REG_GCTRL);
__mci_check_bit_clear(host, SDXC_REG_GCTRL, SDXC_HWReset);
return 0;
}
static __inline void __mci_sel_access_mode(struct mmc_host *host, uint32_t access_mode)
{
mci_writel((mci_readl(host, SDXC_REG_GCTRL) & (~SDXC_ACCESS_BY_AHB)) | access_mode,
host, SDXC_REG_GCTRL);
}
static int32_t __mci_reset(struct mmc_host *host)
{
uint32_t value;
uint32_t time = HAL_Ticks() + HAL_MSecsToTicks(1000) + 1;
value = mci_readl(host, SDXC_REG_GCTRL)|SDXC_HWReset;
mci_writel(value, host, SDXC_REG_GCTRL);
while ((mci_readl(host, SDXC_REG_GCTRL) & SDXC_SoftReset) && (HAL_TimeBefore(HAL_Ticks(), time)));
if (mci_readl(host, SDXC_REG_GCTRL) & SDXC_SoftReset) {
SDC_LOGE("SDC reset time out\n");
return -1;
}
SDC_LOGD("%s,%d SDC reset finish \n", __func__, __LINE__);
return 0;
}
static int32_t __mci_program_clk(struct mmc_host *host)
{
uint32_t value;
int32_t ret = 0;
uint32_t time = HAL_Ticks() + HAL_MSecsToTicks(1000) + 1;
/* disable command done interrupt */
mci_writel((mci_readl(host, SDXC_REG_IMASK) & (~SDXC_CmdDone))|host->sdio_irq_mask,
host, SDXC_REG_IMASK);
mci_writel(mci_readl(host, SDXC_REG_CLKCR) | SDXC_Mask_Data0,\
host, SDXC_REG_CLKCR);
value = SDXC_Start | SDXC_UPCLKOnly | SDXC_WaitPreOver;
mci_writel(value, host, SDXC_REG_CMDR);
do {
value = mci_readl(host, SDXC_REG_CMDR);
} while ((value & SDXC_Start) && HAL_TimeBefore(HAL_Ticks(), time));
if (mci_readl(host, SDXC_REG_CMDR) & SDXC_Start) {
SDC_LOGE("%s,%d SDC change clock time out\n", __func__, __LINE__);
__mci_force_dump_host_info(host);
ret = -1;
}
/* clear command done flag */
value = mci_readl(host, SDXC_REG_RINTR);
mci_writel(value, host, SDXC_REG_RINTR);
mci_writel(mci_readl(host, SDXC_REG_CLKCR) & ~SDXC_Mask_Data0,\
host, SDXC_REG_CLKCR);
/* enable command done interrupt */
mci_writel((mci_readl(host, SDXC_REG_IMASK) | SDXC_CmdDone)|host->sdio_irq_mask,
host, SDXC_REG_IMASK);
return ret;
}
static void __mci_trans_by_ahb(struct mmc_host *host, struct mmc_data *data)
{
uint32_t i, j;
uint32_t *buf_temp; /* Cortex-M3/4 can access data with unaligned address */
uint32_t time;
for (i = 0; i < data->sg_len; i++) {
buf_temp = data->sg[i].buffer;
if (data->flags & MMC_DATA_READ) {
for (j = 0; j < (data->sg[i].len >> 2); j++) { /* sg[i].len should be multiply of 4 */
time = HAL_Ticks() + HAL_MSecsToTicks(1000) + 1 ;
while ((mci_readl(host, SDXC_REG_STAS) & SDXC_FIFOEmpty) &&
(HAL_TimeBefore(HAL_Ticks(), time)) && host->present);
if(mci_readl(host, SDXC_REG_STAS) & SDXC_FIFOEmpty){
SDC_LOGE("read from fifo timeout1\n");
return;
}
buf_temp[j] = mci_readl(host, SDXC_REG_FIFO);
}
if((data->sg[i].len) & 0x3) {
time = HAL_Ticks() + HAL_MSecsToTicks(1000) + 1;
while ((mci_readl(host, SDXC_REG_STAS) & SDXC_FIFOEmpty) &&
(HAL_TimeBefore(HAL_Ticks(), time)) && host->present);
if(mci_readl(host, SDXC_REG_STAS) & SDXC_FIFOEmpty){
SDC_LOGE("read from fifo timeout2\n");
return;
}
if(((data->sg[i].len) & 0x3) == 2){
buf_temp[j] = (uint16_t)mci_readl(host, SDXC_REG_FIFO);
}else if(((data->sg[i].len) & 0x3) == 1){
buf_temp[j] = (uint8_t)mci_readl(host, SDXC_REG_FIFO);
}else
SDC_BUG_ON(1);
}
} else if (data->flags & MMC_DATA_WRITE) {
for (j = 0; j < (data->sg[i].len >> 2); j++) { /* sg[i].len should be multiply of 4 */
time = HAL_Ticks() + HAL_MSecsToTicks(1000) + 1;
while ((mci_readl(host, SDXC_REG_STAS) & SDXC_FIFOFull) &&
(HAL_TimeBefore(HAL_Ticks(), time)) && host->present);
if(mci_readl(host, SDXC_REG_STAS) & SDXC_FIFOFull){
SDC_LOGE("write to fifo timeout1\n");
return;
}
mci_writel(buf_temp[j], host, SDXC_REG_FIFO);
}
if((data->sg[i].len) & 0x3) {
time = HAL_Ticks() + HAL_MSecsToTicks(1000) + 1;
while ((mci_readl(host, SDXC_REG_STAS) & SDXC_FIFOFull) &&
(HAL_TimeBefore(HAL_Ticks(), time)) && host->present);
if(mci_readl(host, SDXC_REG_STAS) & SDXC_FIFOFull){
SDC_LOGE("write to fifo timeout2\n");
return;
}
if(((data->sg[i].len) & 0x3) == 2){
mci_writel((uint16_t)buf_temp[j], host, SDXC_REG_FIFO);
}else if(((data->sg[i].len) & 0x3) == 1){
mci_writel((uint8_t)buf_temp[j], host, SDXC_REG_FIFO);
}else
SDC_BUG_ON(1);
}
} else {
SDC_LOGW("illigle data request\n");
SDC_BUG_ON(1);
return ;
}
}
HAL_WMB();
}
static smc_idma_des *__mci_alloc_idma_des(struct mmc_host *host, struct mmc_data *data)
{
smc_idma_des *pdes = host->idma_des;
uint32_t des_idx = 0;
uint32_t buff_frag_num = 0;
uint32_t remain;
uint32_t i, j;
uint32_t config;
/* init IDMA Descriptor, two mode: 1-fixed skip length, 2-chain mode */
for (i = 0; i < data->sg_len; i++) {
buff_frag_num = data->sg[i].len >> SDXC_DES_NUM_SHIFT; /* num = len/8192 = len>>13 */
remain = data->sg[i].len & (SDXC_DES_BUFFER_MAX_LEN - 1);
if (remain) {
buff_frag_num++;
} else {
remain = SDXC_DES_BUFFER_MAX_LEN;
}
for (j = 0; j < buff_frag_num; j++, des_idx++) {
SDC_Memset((void *)&pdes[des_idx], 0, sizeof(smc_idma_des));
config = SDXC_IDMAC_DES0_CH | SDXC_IDMAC_DES0_OWN | SDXC_IDMAC_DES0_DIC;
if (buff_frag_num > 1 && j != buff_frag_num - 1) {
pdes[des_idx].data_buf1_sz = SDXC_DES_BUFFER_MAX_LEN;
} else {
pdes[des_idx].data_buf1_sz = remain;
}
pdes[des_idx].buf_addr_ptr1 = SDXC_IDMAC_DES_ADDR((uint32_t)MEMS_VA2PA(HAL_PT_TO_U(data->sg[i].buffer)) + j * SDXC_DES_BUFFER_MAX_LEN);
if (i == 0 && j == 0) {
config |= SDXC_IDMAC_DES0_FD;
}
if ((i == data->sg_len - 1) && (j == buff_frag_num - 1)) {
config &= ~SDXC_IDMAC_DES0_DIC;
config |= SDXC_IDMAC_DES0_LD | SDXC_IDMAC_DES0_ER;
pdes[des_idx].buf_addr_ptr2 = 0;
} else {
pdes[des_idx].buf_addr_ptr2 = SDXC_IDMAC_DES_ADDR((uint32_t)MEMS_VA2PA(HAL_PT_TO_U(&pdes[des_idx + 1])));
}
pdes[des_idx].config = config;
SDC_LOGD("sg %lu, frag %lu, remain %lu, des[%lu](%p): [0]:%lx, [1]:%lx, [2]:%lx, [3]:%lx\n",
HAL_PR_SZ_L(i), HAL_PR_SZ_L(j), HAL_PR_SZ_L(remain), HAL_PR_SZ_L(des_idx), &pdes[des_idx],
HAL_PR_SZ_L(((uint32_t *)&pdes[des_idx])[0]), HAL_PR_SZ_L(((uint32_t *)&pdes[des_idx])[1]),
HAL_PR_SZ_L(((uint32_t *)&pdes[des_idx])[2]), HAL_PR_SZ_L(((uint32_t *)&pdes[des_idx])[3]));
}
}
HAL_FlushDcacheRegion((unsigned long)pdes, HAL_ALIGN(SDXC_MAX_DES_NUM * sizeof(smc_idma_des), OS_CACHE_ALIGN_BYTES));
HAL_WMB();
return pdes;
}
static smc_idma_des *__mci_prepare_dma(struct mmc_host *host, struct mmc_data *data)
{
uint32_t temp;
smc_idma_des *pdes = NULL;
/* creat descriptor list, two mode: 1-fixed skip length, 2-chain mode */
pdes = __mci_alloc_idma_des(host, data);
if (NULL == pdes) {
SDC_LOGW("alloc IDMA descriptor failed\n");
return NULL;
}
temp = mci_readl(host, SDXC_REG_GCTRL);
temp |= SDXC_DMAEnb;
mci_writel(temp, host, SDXC_REG_GCTRL);
temp |= (SDXC_DMAReset | SDXC_FIFOReset);
mci_writel(temp, host, SDXC_REG_GCTRL);
__mci_check_bit_clear(host, SDXC_REG_GCTRL, (SDXC_DMAReset | SDXC_FIFOReset));
mci_writel(SDXC_IDMACSoftRST, host, SDXC_REG_DMAC); /* reset IDMAC */
__mci_check_bit_clear(host, SDXC_REG_DMAC, SDXC_IDMACSoftRST);
temp = SDXC_IDMACFixBurst | SDXC_IDMACIDMAOn;
mci_writel(temp, host, SDXC_REG_DMAC);
/* enable IDMA interrupt, here not use */
temp = mci_readl(host, SDXC_REG_IDIE);
temp &= ~(SDXC_IDMACReceiveInt | SDXC_IDMACTransmitInt);
if (data->flags & MMC_DATA_WRITE) {
;//temp |= SDXC_IDMACTransmitInt; /* disable dma int for less irqs */
} else {
temp |= SDXC_IDMACReceiveInt;
}
mci_writel(temp, host, SDXC_REG_IDIE);
/* write descriptor address to register */
mci_writel(SDXC_IDMAC_DES_ADDR((uint32_t)MEMS_VA2PA(HAL_PT_TO_U(pdes))), host, SDXC_REG_DLBA);
/* write water level */
mci_writel((BURST_SIZE << 28) | (SMC_RX_WLEVEL << 16) | SMC_TX_WLEVEL,
host, SDXC_REG_FTRGL);
return pdes;
}
static void __mci_free_idma_des(smc_idma_des *pdes)
{
pdes->config &= ~SDXC_IDMAC_DES0_OWN;
}
int32_t __mci_wait_access_done(struct mmc_host *host)
{
int32_t own_set = 0;
uint32_t time = HAL_Ticks() + HAL_MSecsToTicks(1000) + 1;
while (!(mci_readl(host, SDXC_REG_GCTRL) & SDXC_MemAccessDone) && (HAL_TimeBefore(HAL_Ticks(), time)));
if (!(mci_readl(host, SDXC_REG_GCTRL) & SDXC_MemAccessDone)) {
SDC_LOGE("wait memory access done timeout !!\n");
}
return own_set;
}
static int32_t __mci_request_done(struct mmc_host *host)
{
struct mmc_request *mrq = host->mrq;
unsigned long iflags;
uint32_t temp;
int32_t ret = 0;
iflags = HAL_EnterCriticalSection();
if (host->wait != SDC_WAIT_FINALIZE) {
HAL_ExitCriticalSection(iflags);
SDC_LOGW("%s nothing finalize, wt %lx\n", __func__, HAL_PR_SZ_L(host->wait));
return -1;
}
host->wait = SDC_WAIT_NONE;
host->trans_done = 0;
host->dma_done = 0;
HAL_ExitCriticalSection(iflags);
if (host->int_sum & SDXC_IntErrBit) {
SDC_LOGE("SDC err, cmd %ld, %s%s%s%s%s%s%s%s%s%s\n",
HAL_PR_SZ_L(host->smc_cmd & SDXC_CMD_OPCODE),
host->int_sum & SDXC_RespErr ? " RE" : "",
host->int_sum & SDXC_RespCRCErr ? " RCE" : "",
host->int_sum & SDXC_DataCRCErr ? " DCE" : "",
host->int_sum & SDXC_RespTimeout ? " RTO" : "",
host->int_sum & SDXC_DataTimeout ? " DTO" : "",
host->int_sum & SDXC_DataStarve ? " DS" : "",
host->int_sum & SDXC_FIFORunErr ? " FRE" : "",
host->int_sum & SDXC_HardWLocked ? " HL" : "",
host->int_sum & SDXC_StartBitErr ? " SBE" : "",
host->int_sum & SDXC_EndBitErr ? " EBE" : "");
sdc_hex_dump_word((void *)(SDC_GPIO_BASE+0xB0),0xff);
if (host->sdc_id == 0) {
sdc_hex_dump_word((void *)SDC_CCM_SDC0_SCLK_CTRL ,0x200);
sdc_hex_dump_word((void *)SMC0_BASE ,0x200);
} else if (host->sdc_id == 1) {
sdc_hex_dump_word((void *)SDC_CCM_SDC1_SCLK_CTRL ,0x200);
sdc_hex_dump_word((void *)SMC1_BASE ,0x200);
}
ret = -1;
goto out;
}
if (mrq->cmd->flags & MMC_RSP_136) {
mrq->cmd->resp[0] = mci_readl(host, SDXC_REG_RESP3);
mrq->cmd->resp[1] = mci_readl(host, SDXC_REG_RESP2);
mrq->cmd->resp[2] = mci_readl(host, SDXC_REG_RESP1);
mrq->cmd->resp[3] = mci_readl(host, SDXC_REG_RESP0);
} else
mrq->cmd->resp[0] = mci_readl(host, SDXC_REG_RESP0);
out:
if (mrq->data) {
if (host->dma_hdle) {
__mci_wait_access_done(host);
mci_writel(0x337, host, SDXC_REG_IDST); /* clear interrupt flags */
mci_writel(0, host, SDXC_REG_IDIE); /* disable idma interrupt */
mci_writel(0, host, SDXC_REG_DMAC); /* idma off */
temp = mci_readl(host, SDXC_REG_GCTRL);
mci_writel(temp | SDXC_DMAReset, host, SDXC_REG_GCTRL);
temp &= ~SDXC_DMAEnb;
mci_writel(temp, host, SDXC_REG_GCTRL); /* disable IDMA */
temp |= SDXC_FIFOReset;
mci_writel(temp, host, SDXC_REG_GCTRL);
__mci_free_idma_des((void *)host->dma_hdle);
host->dma_hdle = NULL;
}
mci_writel(mci_readl(host, SDXC_REG_GCTRL) | SDXC_FIFOReset,
host, SDXC_REG_GCTRL);
}
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_DETECT_BY_D3){
mci_writel((SDXC_CardInsert|SDXC_CardRemove)|host->sdio_irq_mask, host, SDXC_REG_IMASK);
} else
#endif
{
mci_writel(host->sdio_irq_mask, host, SDXC_REG_IMASK);
}
if (host->int_sum & (SDXC_RespErr | SDXC_HardWLocked | SDXC_RespTimeout)) {
SDC_LOGE("sdc %d abnormal status: %s\n", __LINE__,
host->int_sum & SDXC_HardWLocked ? "HardWLocked" : "RespErr");
}
mci_writel(0xffff, host, SDXC_REG_RINTR);
SDC_LOGD("SDC done, resp %lx %lx %lx %lx\n", HAL_PR_SZ_L(mrq->cmd->resp[0]),
HAL_PR_SZ_L(mrq->cmd->resp[1]), HAL_PR_SZ_L(mrq->cmd->resp[2]), HAL_PR_SZ_L(mrq->cmd->resp[3]));
if (mrq->data && (host->int_sum & SDXC_IntErrBit)) {
SDC_LOGW("found data error, need to send stop command !!\n");
__mci_reset(host);
__mci_program_clk(host);
}
host->int_err = 0;
return ret;
}
#define mci_writel_irq(value, host, reg) \
({ uint32_t val;\
printf("+irq reg add 0x%x write val 0x%x\n", (uint32_t)(host)->reg_base + reg, value);\
writel((value), (uint32_t)(host)->reg_base + reg);\
val = readl((uint32_t)(host)->reg_base + reg);\
printf("%s,%d\n", __FUNCTION__, __LINE__);\
printf("-irq reg read val 0x%x\n", (unsigned int)val);})
//#ifdef CONFIG_SDIO_IRQ_SUPPORT
__nonxip_text
static void __mci_enable_sdio_irq(struct mmc_host *host, int enable)
{
uint32_t imask;
uint32_t flags = HAL_EnterCriticalSection();
imask = mci_readl(host, SDXC_REG_IMASK);
if (enable){
// mci_writel(SDXC_SDIOInt, host, SDXC_REG_RINTR);
host->sdio_irq_mask = SDXC_SDIOInt;
imask |= SDXC_SDIOInt;
}else{
host->sdio_irq_mask = 0;
imask &= ~SDXC_SDIOInt;
}
mci_writel(imask, host, SDXC_REG_IMASK);
HAL_ExitCriticalSection(flags);
}
__nonxip_text
static inline void __mci_signal_sdio_irq(struct mmc_host *host)
{
// if (!host->card || !host->card->irq_handler) {
if (!host->card) {
SDC_IT_LOGE("BUG at __mci_signal_sdio_irq():%d\n", __LINE__);
return;
}
#ifdef SD_PERF_TRACE_ON
host->start_sdio_irq_times_ns = HAL_GetTimeNs();
host->sdio_irq_count ++;
#endif
__mci_enable_sdio_irq(host, 0);
host->sdio_irq_pending = true;
//if (host.sdio_irq_thread)
//xTaskResumeFromISR(host->sdio_irq_thread.handle);
OS_SemaphoreRelease(&host->sdio_irq_signal);
}
void rom_HAL_SDC_Enable_Sdio_Irq(struct mmc_host *host, int enable)
{
uint32_t flags = 0;
__mci_enable_sdio_irq(host,enable);
}
//#endif
static void __mci_clk_prepare_enable(struct mmc_host *host)
{
if (host->sdc_id == 0) {
SDC0_CCM_BusEnableClock(); /* clock enable */
SDC0_CCM_BusReleaseRest(); /* reset and gating */
SDC0_CCM_EnableMClock();
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC1_CCM_BusEnableClock(); /* clock enable */
SDC1_CCM_BusReleaseRest(); /* reset and gating */
SDC1_CCM_EnableMClock();
#endif
}
}
static void __mci_clk_disable_unprepare(struct mmc_host *host)
{
if (host->sdc_id == 0) {
SDC0_CCM_BusDisableClock();
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC1_CCM_BusDisableClock();
#endif
}
}
static void __mci_hold_io(struct mmc_host* host)
{
#ifdef __CONFIG_ARCH_APP_CORE
#ifndef NUSE_STANDARD_INTERFACE
/* disable gpio to avoid power leakage */
if (host->pin_ref) {
HAL_BoardIoctl(HAL_BIR_PINMUX_DEINIT, HAL_MKDEV(HAL_DEV_MAJOR_SDC,
host->sdc_id), SDCGPIO_BAS);
host->pin_ref = 0;
}
#else
SDC_LOGN("Not implement %s,%d\n", __FUNCTION__, __LINE__);
#endif
#endif
}
static void __mci_restore_io(struct mmc_host* host)
{
#ifdef __CONFIG_ARCH_APP_CORE
#ifndef NUSE_STANDARD_INTERFACE
if (host->pin_ref == 0) {
HAL_BoardIoctl(HAL_BIR_PINMUX_INIT, HAL_MKDEV(HAL_DEV_MAJOR_SDC,
host->sdc_id), SDCGPIO_BAS);
host->pin_ref = 1;
}
#else
SDC_LOGN("Not implement %s,%d\n", __FUNCTION__, __LINE__);
#endif
#
#endif
}
__nonxip_text
static irqreturn_t __mci_irq_handler(uint32_t sdc_id)
{
struct mmc_host *host = _mci_host[sdc_id];
uint32_t sdio_int = 0;
uint32_t raw_int;
uint32_t msk_int;
uint32_t idma_inte;
uint32_t idma_int;
#if (defined(__CONFIG_SECTION_ATTRIBUTE_NONXIP) && SDC_DEBUG)
__nonxip_rodata static const char __s_func[] = "__mci_irq_handler";
#endif
//SDC_IT_LOGD("***%s,%d***\n",__FUNCTION__, __LINE__);
if (!host) {
SDC_IT_LOGE_RAW(ROM_ERR_MASK, "%s,%d no host exist!\n", __func__, __LINE__);
return IRQ_NONE;
}
if (!host->present) {
if (host->sdc_id == 0) {
SDC0_CCM_BusEnableClock();
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC1_CCM_BusEnableClock();
#endif
}
}
idma_int = mci_readl(host, SDXC_REG_IDST);
idma_inte = mci_readl(host, SDXC_REG_IDIE);
raw_int = mci_readl(host, SDXC_REG_RINTR);
msk_int = mci_readl(host, SDXC_REG_MISTA);
if (!msk_int && !idma_int) {
SDC_IT_LOGE("sdc nop irq: ri:%08lx mi:%08lx ie:%08lx idi:%08lx\n",
HAL_PR_SZ_L(raw_int), HAL_PR_SZ_L(msk_int), HAL_PR_SZ_L(idma_inte), HAL_PR_SZ_L(idma_int));
return IRQ_NONE;
}
host->int_sum = raw_int;
SDC_IT_LOGD("sdc %d ri:%02x(%02x), mi:%x, ie:%x, idi:%x\n", __LINE__,
(int)raw_int, (int)host->int_sum,
(int)msk_int, (int)idma_inte, (int)idma_int);
(void)idma_inte;
#ifdef CONFIG_SDIO_IRQ_SUPPORT
if (msk_int & SDXC_SDIOInt) {
sdio_int = 1;
mci_writel(SDXC_SDIOInt, host, SDXC_REG_RINTR);
goto sdio_out;
}
#endif
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_DETECT_BY_D3) {
if (msk_int & SDXC_CardInsert) {
SDC_IT_LOGN("Card Insert !!\n");
host->present = 1;
SDC_IT_ModTimer(&host->cd_timer, 10);
} else if (msk_int & SDXC_CardRemove) {
SDC_IT_LOGN("Card Remove !!\n");
host->present = 0;
SDC_IT_ModTimer(&host->cd_timer, 10);
}
}
#endif
if (host->wait == SDC_WAIT_NONE && !sdio_int) {
SDC_IT_LOGE("%s nothing to complete, ri:%08lx, mi:%08lx\n",
__s_func, HAL_PR_SZ_L(raw_int), HAL_PR_SZ_L(msk_int));
goto irq_out;
}
if ((raw_int & SDXC_IntErrBit) || (idma_int & SDXC_IDMA_ERR)) {
host->int_err = raw_int & SDXC_IntErrBit;
host->wait = SDC_WAIT_FINALIZE;
SDC_IT_LOGE("%s,%d raw_int:%lx err!\n", __s_func, __LINE__, HAL_PR_SZ_L(raw_int));
goto irq_out;
}
if (raw_int & SDXC_HardWLocked) {
SDC_IT_LOGE("command hardware lock\n");
}
if (idma_int & (SDXC_IDMACTransmitInt|SDXC_IDMACReceiveInt)) {
host->dma_done = 1;
mci_writel(idma_int, host, SDXC_REG_IDST);
}
if (msk_int & (SDXC_AutoCMDDone|SDXC_DataOver|SDXC_CmdDone|SDXC_VolChgDone))
host->trans_done = 1;
if ((host->trans_done && \
(host->wait == SDC_WAIT_AUTOCMD_DONE || host->wait == SDC_WAIT_DATA_OVER
|| host->wait == SDC_WAIT_CMD_DONE || host->wait == SDC_WAIT_SWITCH1V8))
|| (host->trans_done && host->dma_done && (host->wait & SDC_WAIT_IDMA_DONE))) {
host->wait = SDC_WAIT_FINALIZE;
}
irq_out:
mci_writel(msk_int & (~SDXC_SDIOInt), host, SDXC_REG_RINTR);
if (host->wait == SDC_WAIT_FINALIZE) {
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_DETECT_BY_D3){
mci_writel(SDXC_CardInsert|SDXC_CardRemove|host->sdio_irq_mask,
host, SDXC_REG_IMASK);
} else
#endif
{
mci_writel(host->sdio_irq_mask, host, SDXC_REG_IMASK);
}
HAL_WMB();
if(!OS_IsISRContext()){
SDC_BUG_ON(1);
sys_abort();
}
SDC_SemPost(&host->lock);
SDC_IT_LOGD("SDC irq post, trans:%d, dma:%d\n",
(int)host->trans_done, (int)host->dma_done);
}
#ifdef CONFIG_SDIO_IRQ_SUPPORT
sdio_out:
if (sdio_int)
__mci_signal_sdio_irq(host);
#endif
return IRQ_HANDLED;
}
__nonxip_text
irqreturn_t SDC0_IRQHandler(int id, void *data)
{
return __mci_irq_handler(SDC0);
}
#if SDC1_SUPPORT
__nonxip_text
irqreturn_t SDC1_IRQHandler(int id, void *data) //static
{
return __mci_irq_handler(SDC1);
}
#endif
/* clock config:
* SYS_CRYSTAL: 26M
* 400K, SCLK-26M, 26M/(2^3)/(7+1)/2 = 361K
* SYS_CRYSTAL: 24M
* 400K, SCLK-24M, 24M/(2^2)/(7+1)/2 = 375K
*
* 25M, SCLK-192M, 192M/(2^0)/(3+1)/2 = 24M
* 50M, SCLK-192M, 192M/(2^0)/(1+1)/2 = 48M
* 64M, SCLK-192M, 192M/(2^0)/(1+1)/2 = 48M
*/
#define DEFINE_SYS_CRYSTAL HAL_GetHFClock()
#define DEFINE_SYS_DEVCLK HAL_GetDevClock()
static int32_t __mci_update_clock(struct mmc_host *host, uint32_t cclk)
{
uint32_t sclk;
uint32_t div;
uint32_t rval;
uint32_t src = 0;
uint32_t m, n;
if (cclk > DEFINE_SYS_CRYSTAL/2) {
#ifdef NUSE_STANDARD_INTERFACE
src = 1;
#else
src = CCM_AHB_PERIPH_CLK_SRC_DEVCLK;
#endif
sclk = DEFINE_SYS_DEVCLK;
} else {
#ifdef NUSE_STANDARD_INTERFACE
src = 0;
#else
src = CCM_AHB_PERIPH_CLK_SRC_HFCLK;
#endif
sclk = DEFINE_SYS_CRYSTAL;
}
cclk = cclk * 2; /* 2x MODE clock configure */
div = (2 * sclk + cclk) / (2 * cclk);
div = div == 0 ? 1 : div;
if (div > 128) {
n = 3;
m = 16;
SDC_LOGE("source clk is too high!\n");
} else if (div > 64) {
n = 3;
m = div >> 3;
} else if (div > 32) {
n = 2;
m = div >> 2;
} else if (div > 16) {
n = 1;
m = div >> 1;
} else {
n = 0;
m = div;
}
m = m - 1;
#ifdef NUSE_STANDARD_INTERFACE
/*
if (src) {
rval |= (2U << 20) | (1 << 8);
SDC_LOGN("%s,%d check spec. bit20, 8!!\n", __func__, __LINE__);
}
*/
if (host->sdc_id == 0) {
rval = readl(SDC_CCM_SDC0_SCLK_CTRL);
rval &= ~(1U<<31);
writel(rval,SDC_CCM_SDC0_SCLK_CTRL);
HAL_WMB();
rval = (src << 24) | (n << 8) | (m);
writel(rval,SDC_CCM_SDC0_SCLK_CTRL);
HAL_WMB();
rval = readl(SDC_CCM_SDC0_SCLK_CTRL);
rval |= (1U<<31);
writel(rval,SDC_CCM_SDC0_SCLK_CTRL);
HAL_WMB();
SDC_LOGN("SDC clock=%ld kHz,src:%x, n:%d, m:%d\n",
HAL_PR_SZ_L((src ? DEFINE_SYS_DEVCLK:DEFINE_SYS_CRYSTAL)/(1<<n)/(m+1)/2),
(int)src, (int)n, (int)m);
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
rval = readl(SDC_CCM_SDC1_SCLK_CTRL);
rval &= ~(1U<<31);
writel(rval,SDC_CCM_SDC1_SCLK_CTRL);
HAL_WMB();
rval = (src << 24) | (n << 8) | (m);
writel(rval,SDC_CCM_SDC1_SCLK_CTRL);
HAL_WMB();
rval = readl(SDC_CCM_SDC1_SCLK_CTRL);
rval |= (1U<<31);
writel(rval,SDC_CCM_SDC1_SCLK_CTRL);
HAL_WMB();
SDC_LOGN("SDC clock=%ld kHz,src:%x, n:%d, m:%d\n",
HAL_PR_SZ_L((src?DEFINE_SYS_DEVCLK:DEFINE_SYS_CRYSTAL)/(1<<n)/(m+1)/2),
(int)src, (int)n, (int)m);
#endif
}
#else
if (host->sdc_id == 0) {
SDC0_DisableMClock();
SDC0_SetMClock(src, n << CCM_PERIPH_CLK_DIV_N_SHIFT, m << CCM_PERIPH_CLK_DIV_M_SHIFT);
SDC0_CCM_EnableMClock();
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC1_DisableMClock();
SDC1_SetMClock(src, n << CCM_PERIPH_CLK_DIV_N_SHIFT, m << CCM_PERIPH_CLK_DIV_M_SHIFT);
SDC1_CCM_EnableMClock();
#endif
}
SDC_LOGN("SDC source:%u MHz clock=%u kHz, src:%x, n:%d, m:%d\n", sclk/1000000,
sclk/(1<<n)/(m+1)/2000, (int)src, (int)n, (int)m);
#endif
/* clear internal divider */
rval = mci_readl(host, SDXC_REG_CLKCR) & (~0xff);
mci_writel(rval, host, SDXC_REG_CLKCR);
sdc_hex_dump_word((void *)SDC_CCM_BASE ,0x900);
return cclk;
}
int32_t rom_HAL_SDC_Update_Clk(struct mmc_host *host, uint32_t clk)
{
uint32_t rval;
if (!host || clk < 200000) { /* 200K */
SDC_LOGE_RAW(ROM_ERR_MASK, "%s,%d err", __func__, __LINE__);
return -1;
}
/* Disable Clock */
rval = mci_readl(host, SDXC_REG_CLKCR) & (~SDXC_CardClkOn) & (~SDXC_LowPowerOn);
mci_writel(rval, host, SDXC_REG_CLKCR);
if (__mci_program_clk(host)) {
SDC_LOGE("Clock Program Failed 0!!\n");
return -1;
}
__mci_update_clock(host, clk);
/* Re-enable Clock */
rval = mci_readl(host, SDXC_REG_CLKCR) | (SDXC_CardClkOn);// | SDXC_LowPowerOn;
mci_writel(rval, host, SDXC_REG_CLKCR);
if (__mci_program_clk(host)) {
SDC_LOGE("Clock Program Failed 1!!\n");
return -1;
}
host->clk = clk;
return 0;
}
static int32_t __mci_update_clk(struct mmc_host *host)
{
uint32_t rval;
int32_t ret = 0;
uint32_t time = HAL_Ticks() + HAL_MSecsToTicks(1000) + 1;
mci_writel(mci_readl(host, SDXC_REG_CLKCR) | SDXC_Mask_Data0,\
host, SDXC_REG_CLKCR);
rval = SDXC_Start|SDXC_UPCLKOnly|SDXC_WaitPreOver;
#ifdef CONFIG_SDC_SUPPORT_1V8
if (host->voltage_switching)
rval |= SDXC_VolSwitch;
#endif
mci_writel(rval, host, SDXC_REG_CMDR);
do {
rval = mci_readl(host, SDXC_REG_CMDR);
} while ((rval & SDXC_Start) && HAL_TimeBefore(HAL_Ticks(), time));
if (mci_readl(host, SDXC_REG_CMDR) & SDXC_Start) {
SDC_LOGE("sdc update clock timeout, fatal error!!!\n");
__mci_force_dump_host_info(host);
ret = -1;
}
if (!ret)
SDC_LOGD("sdc update clock ok\n");
/* clear command done flag */
rval = mci_readl(host, SDXC_REG_RINTR);
mci_writel(rval, host, SDXC_REG_RINTR);
mci_writel(mci_readl(host, SDXC_REG_CLKCR) & ~SDXC_Mask_Data0,\
host, SDXC_REG_CLKCR);
return ret;
}
int32_t rom_HAL_SDC_Clk_PWR_Opt(struct mmc_host *host, uint32_t oclk_en, uint32_t pwr_save)
{
uint32_t rval;
if (!host->power_on)
return 0;
rval = mci_readl(host, SDXC_REG_CLKCR);
rval &= ~(SDXC_CardClkOn | SDXC_LowPowerOn);
if (oclk_en)
rval |= SDXC_CardClkOn;
if (pwr_save)
rval |= SDXC_LowPowerOn;
mci_writel(rval, host, SDXC_REG_CLKCR);
__mci_update_clk(host);
return 0;
}
static void __mci_debounce_onoff(struct mmc_host *host, uint32_t onoff)
{
uint32_t rval = mci_readl(host, SDXC_REG_GCTRL);
rval &= ~SDXC_DebounceEnb;
if (onoff)
rval |= SDXC_DebounceEnb;
mci_writel(rval, host, SDXC_REG_GCTRL);
SDC_LOGD("%s,%d,%ld\n",__FUNCTION__,__LINE__, HAL_PR_SZ_L(onoff));
}
uint32_t HAL_SDC_Is_Busy(struct mmc_host *host)
{
return mci_readl(host, SDXC_REG_STAS) & SDXC_CardBusy;
}
static int32_t __mci_check_busy_over(struct mmc_host *host)
{
uint32_t i;
for(i = 0; i< SDC_BUSY_WAIT_LOOP; i++){
if(!(mci_readl(host, SDXC_REG_STAS) & SDXC_CardBusy)){
return 0;
}
if(i>(SDC_BUSY_WAIT_LOOP/8)) {
mmc_mdelay(10);
if(i%8)
SDC_LOGW("Waiting reg %x bitmap %x clear v %x,i %x\n",\
HAL_PR_SZ(HAL_PT_TO_U(host->reg_base)) + SDXC_REG_STAS,\
(unsigned int)SDXC_CardBusy,\
(unsigned int)mci_readl(host, SDXC_CardBusy),\
(unsigned int)i);
}
SDC_LOGD("Waiting reg %x bitmap %x clear v %x,i %x\n",\
HAL_PR_SZ(HAL_PT_TO_U(host->reg_base)) + SDXC_REG_STAS,\
(unsigned int)SDXC_CardBusy,\
(unsigned int)mci_readl(host, SDXC_CardBusy),\
(unsigned int)i);
}
SDC_LOGE("Wait busy timeout %x,%x\n",
(unsigned int)mci_readl(host, SDXC_REG_STAS), (unsigned int)i);
return -1;
}
int32_t __mci_check_bit_clear(struct mmc_host *host, uint32_t reg_offset, uint32_t bit_map)
{
uint32_t i;
for(i = 0; i< SDC_BUSY_WAIT_LOOP; i++){
if(!(mci_readl(host, reg_offset) & bit_map)){
SDC_LOGD("Wait reg %p bitmap %x clear v %lx,i %x ok\n",\
(host->reg_base) + reg_offset,\
(unsigned int)bit_map,\
HAL_PR_SZ_L(mci_readl(host, reg_offset)),\
(unsigned int)i);
return 0;
}
if(i>(SDC_BUSY_WAIT_LOOP/8)) {
mmc_mdelay(10);
if(i%8)
SDC_LOGW("Waiting reg %p bitmap %x clear v %lx,i %x\n",\
(host->reg_base) + reg_offset,\
(unsigned int)bit_map,\
HAL_PR_SZ_L(mci_readl(host, reg_offset)),\
(unsigned int)i);
}
}
SDC_LOGE("Wait reg %p bitmap %x clear timeout v %lx,i %x\n",\
(host->reg_base) + reg_offset,\
(unsigned int) bit_map,\
HAL_PR_SZ_L(mci_readl(host, reg_offset)),\
(unsigned int)i);
return -1;
}
void HAL_SDC_Set_BusWidth(struct mmc_host *host, uint32_t width)
{
if (!host) {
SDC_LOGE_RAW(ROM_ERR_MASK, "%s,%d err", __func__, __LINE__);
return ;
}
switch (width) {
case MMC_BUS_WIDTH_1:
mci_writel(SDXC_WIDTH1, host, SDXC_REG_WIDTH);
break;
case MMC_BUS_WIDTH_4:
mci_writel(SDXC_WIDTH4, host, SDXC_REG_WIDTH);
break;
#ifdef CONFIG_USE_MMC
case MMC_BUS_WIDTH_8:
mci_writel(SDXC_WIDTH8, host, SDXC_REG_WIDTH);
break;
#endif
default:
SDC_BUG_ON(1);
return ;
}
host->buswidth = width;
}
static void __mci_send_cmd(struct mmc_host *host, struct mmc_command *cmd)
{
uint32_t imask = SDXC_IntErrBit;
uint32_t cmd_val = SDXC_Start | (cmd->opcode & 0x3f);
unsigned long iflags;
uint32_t wait = SDC_WAIT_CMD_DONE;
struct mmc_data *data = cmd->data;
if (cmd->opcode == MMC_GO_IDLE_STATE) {
cmd_val |= SDXC_SendInitSeq;
imask |= SDXC_CmdDone;
}
#ifdef CONFIG_SDC_SUPPORT_1V8
if (cmd->opcode == SD_SWITCH_VOLTAGE) {
cmd_val |= SDXC_VolSwitch;
imask |= SDXC_VolChgDone;
host->voltage_switching = 1;
wait = SDC_WAIT_SWITCH1V8;
/* switch controller to high power mode */
HAL_SDC_Clk_PWR_Opt(host, 1, 0);
}
#endif
if (cmd->flags & MMC_RSP_PRESENT) { /* with response */
cmd_val |= SDXC_RspExp;
if (cmd->flags & MMC_RSP_136) /* long response */
cmd_val |= SDXC_LongRsp;
if (cmd->flags & MMC_RSP_CRC)
cmd_val |= SDXC_CheckRspCRC;
if (mmc_cmd_type(cmd) == MMC_CMD_ADTC) { /* with data */
if (!data) {
SDC_LOGE("%s,%d no data exist!\n", __func__, __LINE__);
return ;
}
cmd_val |= SDXC_DataExp | SDXC_WaitPreOver;
wait = SDC_WAIT_DATA_OVER;
if (data->flags & MMC_DATA_STREAM) { /* sequence mode */
imask |= SDXC_AutoCMDDone;
cmd_val |= SDXC_Seqmod | SDXC_SendAutoStop;
wait = SDC_WAIT_AUTOCMD_DONE;
}
if (cmd->stop) {
imask |= SDXC_AutoCMDDone;
cmd_val |= SDXC_SendAutoStop;
wait = SDC_WAIT_AUTOCMD_DONE;
} else
imask |= SDXC_DataOver;
if (data->flags & MMC_DATA_WRITE) {
cmd_val |= SDXC_Write;
} else if (host->dma_hdle) {
wait |= SDC_WAIT_IDMA_DONE;
}
SDC_LOGD("blk_size:%lu, sg len:%lu\n",HAL_PR_SZ_L(data->blksz), HAL_PR_SZ_L(data->sg->len));
} else
imask |= SDXC_CmdDone;
} else
imask |= SDXC_CmdDone;
SDC_LOGD("sdc cmd:%ld(%lx), arg:%lx ie:%lx wt:%lx len:%lu\n",
HAL_PR_SZ_L(cmd_val & SDXC_CMD_OPCODE), HAL_PR_SZ_L(cmd_val), HAL_PR_SZ_L(cmd->arg), HAL_PR_SZ_L(imask), HAL_PR_SZ_L(wait),
HAL_PR_SZ_L(cmd->data ? cmd->data->blksz * cmd->data->blocks : 0));
iflags = HAL_EnterCriticalSection();
host->smc_cmd = cmd_val;
host->wait = wait;
mci_writel(imask | host->sdio_irq_mask, host, SDXC_REG_IMASK);
if (cmd_val & SDXC_SendAutoStop)
mci_writel(0, host, SDXC_REG_A12A);
else
mci_writel(0xffff, host, SDXC_REG_A12A);
mci_writel(cmd->arg, host, SDXC_REG_CARG);
HAL_WMB();
mci_writel(cmd_val, host, SDXC_REG_CMDR);
HAL_ExitCriticalSection(iflags);
if (data && NULL == host->dma_hdle) {
__mci_trans_by_ahb(host, data);
}
}
#ifdef SD_PERF_TRACE_ON
static void __mci_start_data_time_stats(struct mmc_host *host, struct mmc_request *mrq)
{
if((mrq->data) && (mmc_cmd_type(mrq->cmd) == MMC_CMD_ADTC)){
if( (mrq->data->blksz * mrq->data->blocks) > 4 )
host->start_times_us = HAL_GetTimeUs();
}
}
/*this func can not be called by irq_server_function;
*because there are using printf(only printf support u64).
*if you want to use it in irq_server_funciton,printf to printk
* */
static void __mci_end_data_time_stats(struct mmc_host *host, struct mmc_request *mrq)
{
if((mrq->data) && (mmc_cmd_type(mrq->cmd) == MMC_CMD_ADTC) \
&& ((mrq->data->blksz * mrq->data->blocks) > 4)){
uint64_t time_use_us = (uint64_t)HAL_GetTimeUs() - host->start_times_us;
if((mrq->data->flags) & MMC_DATA_WRITE ) {
host->wbytes += mrq->data->blksz * mrq->data->blocks ;
host->wtimes_us += time_use_us;
host->wcount ++;
if(host->wcount && !(host->wcount % SD_PERF_TRACE_COUNT)) {
printf("Stats Total write:bytes %lld, time us %lu, count %lld, %lld KB\n",\
host->wbytes, host->wtimes_us, host->wcount,\
__mci_get_rate(host->wbytes, host->wtimes_us)/1024);
//host->wtimes_us = 0;
//host->wbytes = 0;
//host->wcount = 0;
}
} else if((mrq->data->flags) & MMC_DATA_READ) {
host->rbytes += mrq->data->blksz * mrq->data->blocks;
host->rtimes_us += time_use_us;
host->rcount++;
if( host->rcount &&!(host->rcount % SD_PERF_TRACE_COUNT)) {
printf("Stats Total read: byte %lld, time us %lu, count %lld, %lldKB\n",\
host->rbytes, host->rtimes_us, host->rcount,\
__mci_get_rate(host->rbytes, host->rtimes_us)/1024);
//host->rtimes_us = 0;
//host->rbytes = 0;
//host->rcount = 0;
}
}
}
}
#endif
int32_t do_rom_HAL_SDC_Request(struct mmc_host *host, struct mmc_request *mrq)
{
int32_t ret = 0;
struct mmc_command *cmd = mrq->cmd;
struct mmc_data *data = mrq->data;
#ifdef CONFIG_SDC_DMA_USED
uint32_t sdc_use_dma = host->dma_use;
#else
uint32_t sdc_use_dma = 0;
#endif
if (!host->present) {
SDC_LOGW("sdc:%p no medium present\n", host);
SDC_SemRest((&host->lock));
return -1;
}
#ifdef CONFIG_SD_PM
if (host->suspend) {
SDC_LOGE("sdc:%p has suspended!\n", host);
return -1;
}
#endif
#ifdef SD_PERF_TRACE_ON
__mci_start_data_time_stats(host, mrq);
#endif
__mci_check_busy_over(host);
__mci_check_bit_clear(host, SDXC_REG_GCTRL, SDXC_HWReset);
SDC_MutexLock(&host->thread_lock, SDC_THREAD_TIMEOUT);
/* disable debounce */
__mci_debounce_onoff(host, 0);
host->mrq = mrq;
if (data) {
uint32_t i;
uint32_t byte_cnt = 0;
struct scatterlist *sg = data->sg;
uint32_t sg_len = data->sg_len;
unsigned long addr = 0;
uint32_t len = 0;
for (i = 0; i < sg_len; i++) {
addr = HAL_PT_TO_U(sg[i].buffer);
len = sg[i].len;
byte_cnt += sg[i].len;
#ifdef CONFIG_SDC_DMA_USED
if ((addr & 0x03)) {
sdc_use_dma = 0;
SDC_LOGW("unalign addr %lx, len %ld wr %lx\n", HAL_PR_SZ_L(addr), HAL_PR_SZ_L(len), HAL_PR_SZ_L(data->flags & MMC_DATA_WRITE));
continue;
}
if((addr & (OS_CACHE_ALIGN_BYTES - 1))\
|| (len & (OS_CACHE_ALIGN_BYTES - 1))) {
SDC_LOGD("unalign addr %lx, len %ld wr %lx\n", HAL_PR_SZ_L(addr), HAL_PR_SZ_L(len), HAL_PR_SZ_L(data->flags & MMC_DATA_WRITE));
}
HAL_FlushDcacheRegion((unsigned long)sg[i].buffer, HAL_ALIGN(sg[i].len, OS_CACHE_ALIGN_BYTES));
#endif
}
#ifdef CONFIG_SDC_DMA_USED
if (byte_cnt <= SDC_MAX_CPU_TRANS_LEN) {
sdc_use_dma = 0;
}
#endif
if (byte_cnt != (data->blksz * data->blocks)) {
SDC_LOGE("sg data len %ld not equel data's len %ld\n", HAL_PR_SZ_L(byte_cnt), HAL_PR_SZ_L(data->blksz * data->blocks));
}
mci_writel(data->blksz, host, SDXC_REG_BLKSZ);
mci_writel(byte_cnt, host, SDXC_REG_BCNTR);
if (sdc_use_dma && byte_cnt > SDC_MAX_CPU_TRANS_LEN) { /* transfer by idma */
__mci_sel_access_mode(host, SDXC_ACCESS_BY_DMA);
host->dma_hdle = __mci_prepare_dma(host, data);
if (NULL == host->dma_hdle) {
SDC_LOGW("SDC prepare DMA failed\n");
__mci_sel_access_mode(host, SDXC_ACCESS_BY_AHB);
}
} else {
/* switch data bus to ahb */
__mci_sel_access_mode(host, SDXC_ACCESS_BY_AHB);
}
}
__mci_send_cmd(host, cmd);
#if defined(CONFIG_SOC_SUN20IW1) && defined(CONFIG_OS_MELIS)
struct timespec64 time0 ={0}, time1={0};
do_gettimeofday(&time0);
ret = SDC_SemPend(&host->lock, SDC_DMA_TIMEOUT);
do_gettimeofday(&time1);
if ((ret != HAL_OK && host->present) && \
(((time1.tv_sec*1000+time1.tv_nsec/1000000) - (time0.tv_sec*1000+time0.tv_nsec/1000000)) < SDC_DMA_TIMEOUT))
{
//增加这里的原因是防止读写sdmmc的task被esKRNL_TimeDlyResume,出现这种情况,会导致信号量提前退出
//如果是正常的timeout则不会跑到这里面
SDC_LOGE("===SDC_SemPend abnormal===\n");
ret = SDC_SemPend(&host->lock, SDC_DMA_TIMEOUT);
}
#else
ret = SDC_SemPend(&host->lock, SDC_DMA_TIMEOUT);
#endif
if (ret != HAL_OK && host->present){
uint32_t sg_len = data->sg_len;
uint32_t i;
uint32_t rval = 0;
SDC_LOGE("sdc cmd:%ld, wait command done timeout !!\n",
HAL_PR_SZ_L(host->smc_cmd & SDXC_CMD_OPCODE));
host->debug_mask |= ROM_DUMP_MASK | ROM_ERR_MASK;
#if 1
__mci_force_dump_host_info(host);
if (data) {
SDC_LOGE("dump data blksz %ld,blocks %ld,flags %lx\n", HAL_PR_SZ_L(data->blksz), HAL_PR_SZ_L(data->blocks), HAL_PR_SZ_L(data->flags));
}
#endif
SDC_LOGE("%s,%d\n",__FUNCTION__,__LINE__);
for (i = 0; i < sg_len; i++) {
struct scatterlist *sg = data->sg;
uint32_t *buf_temp = (uint32_t *)sg[i].buffer;
#ifdef CONFIG_SDC_DMA_USED
if (HAL_PT_TO_U(sg[i].buffer) & 0x03) {
sdc_use_dma = 0;
SDC_LOGW("%s,%d\n",__FUNCTION__,__LINE__);
break;
}
SDC_LOGE("%s,%d\n",__FUNCTION__,__LINE__);
HAL_InvalidDcacheRegion((unsigned long )(sg[i].buffer), HAL_ALIGN(sg[i].len, OS_CACHE_ALIGN_BYTES));
SDC_LOGE("%s,%d\n",__FUNCTION__,__LINE__);
SDC_LOGE("buf addr %lx buffer0 %x buffer1 %x\n", HAL_PR_SZ_L(sg[i].buffer), (unsigned int)buf_temp[0],(unsigned int) buf_temp[1]);
#endif
}
SDC_LOGE("%s,%d\n",__FUNCTION__,__LINE__);
mci_writel(0xdeb, host, SDXC_REG_TMOUT);
SDC_LOGE("*force wr smc timeout reg %x*\n",(unsigned int)mci_readl(host, SDXC_REG_TMOUT));
#if 1
SDC_LOGE("*force dump sram*\n");
rval = readl(0x03000000+0x0048);
rval |= 1 << 4;
writel(rval, 0x03000000+0x0048);
sdc_hex_dump_word((void *)SMC1_BASE ,0x100);
#endif
SDC_LOGE("%s,%d\n",__FUNCTION__,__LINE__);
SDC_BUG_ON(1);
sys_abort();
/*sdc_hex_dump_word((void *)0x4002000 ,0x200);*/
host->debug_mask &= ~ROM_DUMP_MASK;
goto out;
}
ret = __mci_request_done(host);
if (ret) {
goto out;
}
out:
/* enable debounce */
__mci_debounce_onoff(host, 1);
if(data && (data->flags & MMC_DATA_READ )){
uint32_t i;
uint32_t byte_cnt = 0;
struct scatterlist *sg = data->sg;
uint32_t sg_len = data->sg_len;
for (i = 0; i < sg_len; i++) {
byte_cnt += sg[i].len;
#ifdef CONFIG_SDC_DMA_USED
if (HAL_PT_TO_U(sg[i].buffer) & 0x03) {
sdc_use_dma = 0;
break;
}
HAL_InvalidDcacheRegion((unsigned long)(sg[i].buffer), HAL_ALIGN(sg[i].len, OS_CACHE_ALIGN_BYTES));
#endif
}
}
SDC_MutexUnlock(&host->thread_lock);
#ifdef SD_PERF_TRACE_ON
__mci_end_data_time_stats(host, mrq);
#endif
return ret;
}
int32_t rom_HAL_SDC_Request(struct mmc_host *host, struct mmc_request *mrq)
{
int32_t ret = 0;
#ifdef CONFIG_SDC_DMA_USED
uint32_t sdc_use_dma_buf = 0;
struct scatterlist sg_dma = {0};
struct scatterlist *sg = NULL;
uint32_t sg_len = 0;
struct mmc_data *data;
uint32_t i = 0;
uint32_t byte_cnt = 0;
unsigned long addr = 0;
uint32_t len = 0;
if (mrq->data) {
data = mrq->data;
sg_len = data->sg_len;
sg = data->sg;
for (i = 0; i < sg_len; i++) {
addr = HAL_PT_TO_U(sg[i].buffer);
len = sg[i].len;
byte_cnt += sg[i].len;
if ((addr & 0x03)\
|| (addr & (OS_CACHE_ALIGN_BYTES - 1))
|| (len & (OS_CACHE_ALIGN_BYTES - 1))) {
sdc_use_dma_buf = 1;
SDC_LOGD("try to use dma debounce buff, addr %lx, len %ld\n", \
HAL_PR_SZ_L(addr), HAL_PR_SZ_L(byte_cnt));
}
}
if (sdc_use_dma_buf) {
if (byte_cnt > SDC_ALIGN_DMA_BUF_SIZE) {
SDC_LOGE("byte count %ld over dma debounce buf size %d\n", \
HAL_PR_SZ_L(byte_cnt), SDC_ALIGN_DMA_BUF_SIZE);
return -1;
} else if (byte_cnt < SDC_MAX_CPU_TRANS_LEN) {
SDC_LOGD("byte cnt %ld is too small not use dma align buf\n", \
HAL_PR_SZ_L(byte_cnt));
sdc_use_dma_buf = 0;
} else {
uint32_t total_len = 0;
if (data->flags & MMC_DATA_WRITE) {
for (i = 0; i < sg_len; i++) {
addr = HAL_PT_TO_U(sg[i].buffer);
len = sg[i].len;
HAL_Memcpy((char *)(host->align_dma_buf + total_len), (char *)addr, len);
total_len += len;
}
}
sg_dma.buffer = host->align_dma_buf;
sg_dma.len = byte_cnt;
data->sg = &sg_dma;
data->sg_len = 1;
SDC_LOGD("use dma debounce buff addr %lx, len %d, align_dma_buf %lx\n", \
HAL_PT_TO_U(sg[0].buffer),\
(unsigned int)byte_cnt,\
HAL_PT_TO_U(host->align_dma_buf));
}
}
}
#endif
ret = do_rom_HAL_SDC_Request(host, mrq);
#ifdef CONFIG_SDC_DMA_USED
if(!ret && data && sdc_use_dma_buf) {
if (data->flags & MMC_DATA_READ) {
uint32_t total_len = 0;
for (i = 0; i < sg_len; i++) {
addr = HAL_PT_TO_U(sg[i].buffer);
len = sg[i].len;
HAL_Memcpy((char *)addr, (char *)(host->align_dma_buf + total_len), len);
total_len += len;
}
SDC_LOGD("copy back to dst buffer%ld\n", HAL_PR_SZ_L(byte_cnt));
}
data->sg = sg;
data->sg_len = sg_len;
}
#endif
return ret;
}
#ifdef CONFIG_SDC_EXCLUSIVE_HOST
/**
* HAL_SDC_Claim_Host - exclusively claim a host
* @host: mmc host to claim
*
* Claim a host for a set of operations.
*/
int32_t HAL_SDC_Claim_Host(struct mmc_host *host)
{
return (SDC_SemPend(&host->exclusive_lock, OS_WAIT_FOREVER) == OS_OK ? 0 : -1);
}
/**
* HAL_SDC_Release_Host - release a host
* @host: mmc host to release
*
* Release a MMC host, allowing others to claim the host
* for their operations.
*/
void HAL_SDC_Release_Host(struct mmc_host *host)
{
SDC_SemPost(&host->exclusive_lock);
}
#endif
#ifdef CONFIG_SDC_READONLY_USED
int32_t HAL_SDC_Get_ReadOnly(struct mmc_host *host)
{
uint32_t wp_val;
GPIO_PinMuxParam *ro_gpio = &host->ro_gpio;
wp_val = (GPIO_PIN_HIGH == HAL_GPIO_ReadPin(ro_gpio->port, ro_gpio->pin)) ? 1 : 0;
SDC_LOGN("sdc fetch card wp pin status: %u\n", (unsigned int)wp_val);
if (!wp_val) {
host->read_only = 0;
return 0;
} else {
SDC_LOGN("Card is write-protected\n");
host->read_only = 1;
return 1;
}
return 0;
}
#endif
#ifdef CONFIG_DETECT_CARD
static irqreturn_t __mci_cd_irq(int unuse, void *arg);
static void __mci_enable_cd_pin_irq(struct mmc_host *host)
{
//SDC_LOGD("Not implement %s,%d\n", __FUNCTION__,__LINE__);
//SDC_ENABLE_IRQ(host->cd_irq);
hal_gpio_irq_enable(host->cd_irq);
}
static void __mci_disable_cd_pin_irq(struct mmc_host *host)
{
// HAL_GPIO_DisableIRQ(host->cd_port, host->cd_pin);
// SDC_LOGE("Not implement %s,%d\n", __FUNCTION__,__LINE__);
//SDC_DISABLE_IRQ(host->cd_irq);
hal_gpio_irq_disable(host->cd_irq);
}
static void __mci_voltage_stable_det(void *arg)
{
struct mmc_host *host = (struct mmc_host *)arg;
if (!host->present || host->wait_voltage_stable || !host->cd_delay) {
host->wait_voltage_stable = 0;
__mci_enable_cd_pin_irq(host);
host->param.cd_cb(host->present);
} else {
SDC_ModTimer(&host->cd_timer, host->cd_delay);
host->wait_voltage_stable = 1;
}
}
static void __mci_cd_timer(void *arg)
{
struct mmc_host *host = (struct mmc_host *)arg;
uint32_t gpio_val = 0;
uint32_t present;
gpio_val = (host->cd_pin_present_val == HAL_GPIO_ReadPin(host->cd_gpio_pin, &gpio_val)) ? 1 : 0;
//SDC_LOGE("Not implement %s,%d\n", __FUNCTION__,__LINE__);
if (gpio_val) {
present = 1;
} else {
present = 0;
}
SDC_LOGD("cd %lu, host present %lu, cur present %lu\n",
HAL_PR_SZ_L(gpio_val), HAL_PR_SZ_L(host->present), HAL_PR_SZ_L(present));
if (host->present ^ present || host->wait_voltage_stable) {
SDC_LOGD("sdc detect change, present %lu\n", HAL_PR_SZ_L(present));
host->present = present;
__mci_voltage_stable_det(host);
}
else {
__mci_enable_cd_pin_irq(host);
}
__sdc_init_timeout_flags = 1;
return ;
}
static void __mci_dat3_det(void *arg)
{
struct mmc_host *host = (struct mmc_host *)arg;
SDC_LOGD("***dat3 det***\n");
__mci_voltage_stable_det(host);
}
static irqreturn_t __mci_cd_irq(int unuse, void *arg)
{
struct mmc_host *host = (struct mmc_host *)arg;
SDC_LOGD("***in cd***\n");
if (!SDC_TimerIsActive(&host->cd_timer) || host->wait_voltage_stable) {
host->wait_voltage_stable = 0;
SDC_ModTimer(&host->cd_timer, 10);
__mci_disable_cd_pin_irq(host);
}
return (irqreturn_t)NULL;
}
#endif
int32_t rom_HAL_SDC_PowerOn(struct mmc_host *host)
{
uint32_t rval;
if (!host) {
SDC_LOGE_RAW(ROM_ERR_MASK, "%s,%d err", __func__, __LINE__);
return -1;
}
SDC_LOGD("MMC Driver init host\n");
__mci_restore_io(host);
__mci_clk_prepare_enable(host);
/* delay 1ms ? */
__mci_update_clock(host, 400000);
host->clk = 400000;
/* reset controller*/
rval = mci_readl(host, SDXC_REG_GCTRL)|SDXC_HWReset|SDXC_INTEnb|
SDXC_AccessDoneDirect;
mci_writel(rval, host, SDXC_REG_GCTRL);
__mci_check_bit_clear(host, SDXC_REG_GCTRL, SDXC_HWReset);
SDC_LOGD("%s,%d\n",__FUNCTION__,__LINE__);
mci_writel(0xffffffff, host, SDXC_REG_RINTR);
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_DETECT_BY_D3) {
mci_writel(SDXC_CardInsert|SDXC_CardRemove|host->sdio_irq_mask, host, SDXC_REG_IMASK);
} else
#endif
{
mci_writel(host->sdio_irq_mask, host, SDXC_REG_IMASK);
}
#define SDMC_DATA_TIMEOUT 0x0ffffffU
#define SDMC_RESP_TIMEOUT 0xffU
/* Set Data & Response Timeout Value */
mci_writel((SDMC_DATA_TIMEOUT<<8)|SDMC_RESP_TIMEOUT, host, SDXC_REG_TMOUT);
#undef SDMC_RESP_TIMEOUT
#undef SDMC_DATA_TIMEOUT
HAL_SDC_Set_BusWidth(host, MMC_BUS_WIDTH_1);
#ifdef SDC_DEBUG
mci_writel(0xdeb, host, SDXC_REG_DBGC);
mci_writel(0xceaa0000, host, SDXC_REG_FUNS);
#endif
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_DETECT_BY_D3){
rval |= SDXC_DebounceEnb;
}
mci_writel(rval, host, SDXC_REG_GCTRL);
#endif
if (host->sdc_id == 0) {
SDC_ENABLE_IRQ(SDC0_IRQn);
}
#if SDC1_SUPPORT
else if (host->sdc_id == 1)
SDC_ENABLE_IRQ(SDC1_IRQn);
#endif
host->power_on = 1;
return 0;
}
int32_t rom_HAL_SDC_PowerOff(struct mmc_host *host)
{
if (!host) {
SDC_LOGE_RAW(ROM_ERR_MASK, "%s,%d err", __func__, __LINE__);
return -1;
}
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode != CARD_DETECT_BY_D3)
#endif
{
uint32_t rval;
if (host->sdc_id == 0)
SDC_DISABLE_IRQ(SDC0_IRQn);
#if SDC1_SUPPORT
else if (host->sdc_id == 1)
SDC_DISABLE_IRQ(SDC1_IRQn);
#endif
rval = mci_readl(host, SDXC_REG_GCTRL) | SDXC_HWReset;
mci_writel(rval, host, SDXC_REG_GCTRL);
__mci_check_bit_clear(host, SDXC_REG_GCTRL, SDXC_HWReset);
rval = mci_readl(host, SDXC_REG_MISTA);
mci_writel(rval & (~SDXC_SDIOInt), host, SDXC_REG_RINTR);
if (host->sdc_id == 0)
SDC_CLEAR_IRQPINGD(SDC0_IRQn);
#if SDC1_SUPPORT
else if (host->sdc_id == 1)
SDC_CLEAR_IRQPINGD(SDC1_IRQn);
#endif
__mci_clk_disable_unprepare(host);
__mci_hold_io(host);
host->power_on = 0;
}
return 0;
}
#ifdef CONFIG_SD_PM
static void __mci_regs_save(struct mmc_host *host)
{
struct __mci_ctrl_regs *bak_regs = &host->regs_back;
bak_regs->gctrl = mci_readl(host, SDXC_REG_GCTRL);
bak_regs->clkc = mci_readl(host, SDXC_REG_CLKCR);
bak_regs->timeout = mci_readl(host, SDXC_REG_TMOUT);
bak_regs->buswid = mci_readl(host, SDXC_REG_WIDTH);
bak_regs->waterlvl = mci_readl(host, SDXC_REG_FTRGL);
bak_regs->funcsel = mci_readl(host, SDXC_REG_FUNS);
bak_regs->idmacc = mci_readl(host, SDXC_REG_DMAC);
}
static void __mci_regs_restore(struct mmc_host *host)
{
struct __mci_ctrl_regs* bak_regs = &host->regs_back;
mci_writel(bak_regs->gctrl, host, SDXC_REG_GCTRL);
mci_writel(bak_regs->clkc, host, SDXC_REG_CLKCR);
mci_writel(bak_regs->timeout, host, SDXC_REG_TMOUT);
mci_writel(bak_regs->buswid, host, SDXC_REG_WIDTH);
mci_writel(bak_regs->waterlvl, host, SDXC_REG_FTRGL);
mci_writel(bak_regs->funcsel, host, SDXC_REG_FUNS);
#ifdef SDC_DEBUG
mci_writel(0xdeb, host, SDXC_REG_DBGC);
mci_writel(0xceaa0000, host, SDXC_REG_FUNS);
#endif
mci_writel(bak_regs->idmacc, host, SDXC_REG_DMAC);
}
static int __mci_suspend(struct soc_device *dev, enum suspend_state_t state)
{
int ret = 0;
struct mmc_host *host = dev->platform_data;
uint32_t _timeout = HAL_Ticks() + HAL_MSecsToTicks(SDC_DMA_TIMEOUT) + 1;
if (host->bus_ops && host->bus_ops->suspend)
ret = host->bus_ops->suspend(host);
if (ret) {
if (host->bus_ops->resume)
host->bus_ops->resume(host);
SDC_LOGE("%s bus id:%d faild\n", __func__, host->sdc_id);
goto err;
}
host->suspend = 1;
while ((host->wait != SDC_WAIT_NONE) && HAL_TimeBefore(HAL_Ticks(), _timeout)) {
}
if (HAL_TimeAfterEqual(HAL_Ticks(), _timeout) && (host->wait != SDC_WAIT_NONE)) {
ret = -1;
host->suspend = 0;
if (host->bus_ops && host->bus_ops->resume)
ret = host->bus_ops->resume(host);
SDC_LOGE("%s id:%d faild\n", __func__, host->sdc_id);
goto err;
}
__mci_regs_save(host);
/* gate clock for lower power */
if (host->sdc_id == 0) {
SDC0_DisableMClock();
SDC0_CCM_BusForceReset();
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC1_DisableMClock();
SDC1_CCM_BusForceReset();
#endif
}
__mci_clk_disable_unprepare(host);
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_DETECT_BY_D3) {
__mci_exit_host(host);
if (host->sdc_id == 0) {
SDC0_DisableMClock();
SDC0_CCM_BusForceReset();
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC1_DisableMClock();
SDC1_CCM_BusForceReset();
#endif
}
__mci_hold_io(host);
SDC_LOGD("sdc card_power_off ok\n");
//__mci_set_vddio(host, SDC_WOLTAGE_OFF);
//usleep_range(1000, 1500);
host->power_on = 0;
}
#endif
SDC_LOGD("%s id:%d ok\n", __func__, host->sdc_id);
err:
return ret;
}
static int __mci_resume(struct soc_device *dev, enum suspend_state_t state)
{
int ret = 0;
struct mmc_host *host = dev->platform_data;
uint32_t clk = host->clk;
__mci_restore_io(host);
if (host->sdc_id == 0) {
SDC0_CCM_BusForceReset();
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC1_CCM_BusForceReset();
#endif
}
__mci_clk_disable_unprepare(host);
mmc_udelay(35);
/* enable clock for resotre */
__mci_clk_prepare_enable(host);
mmc_udelay(50);
__mci_update_clock(host, clk);
mmc_udelay(100);
__mci_regs_restore(host);
#ifdef CONFIG_DETECT_CARD
#else
mci_writel(SDXC_CardInsert, host, SDXC_REG_RINTR);
#endif
__mci_update_clk(host);
/* register IRQ */
if (host->sdc_id == 0)
SDC_CONFIG_IRQ(SDC0_IRQn, &SDC0_IRQHandler, NVIC_PERIPH_PRIO_DEFAULT);
#if SDC1_SUPPORT
else if (host->sdc_id == 1)
SDC_CONFIG_IRQ(SDC1_IRQn, &SDC1_IRQHandler, NVIC_PERIPH_PRIO_DEFAULT);
#endif
mmc_udelay(100);
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_DETECT_BY_GPIO_IRQ)
__mci_cd_timer(host);
if (host->param.cd_mode == CARD_DETECT_BY_D3) {
uint32_t rval = 0;
//__mci_set_vddio(host, host->regulator_voltage);
//usleep_range(1000, 1500);
host->power_on = 1;
__mci_restore_io(host);
__mci_clk_prepare_enable(host);
mmc_mdelay(1);
rval = mci_readl(host, SDXC_REG_RINTR);
SDC_LOGD(">> REG_RINTR=0x%x\n", (unsigned int)rval);
(void)rval;
}
#endif
host->suspend = 0;
if (host->bus_ops && host->bus_ops->resume)
ret = host->bus_ops->resume(host);
SDC_LOGD("%s id:%d ok\n", __func__, host->sdc_id);
return ret;
}
static const struct soc_device_driver sdc_drv = {
.name = "sdc",
.suspend = __mci_suspend,
.resume = __mci_resume,
};
static struct soc_device sdc_dev[SDC_NUM] = {
{ .name = "sdc0", .driver = &sdc_drv, },
{ .name = "sdc1", .driver = &sdc_drv, }
};
#define SDC_DEV(id) (&sdc_dev[id])
#endif /* CONFIG_SD_PM */
int hal_sdc_init_timeout(void)
{
return __sdc_init_timeout_flags;
}
/**
* @brief Initializes the SDC peripheral.
* @param sdc_id:
* @arg sdc_id->SDC ID.
* @param param:
* @arg param->[in] The configuration information.
* @retval SDC handler.
*/
struct mmc_host *hal_sdc_init(struct mmc_host *host)
{
__sdc_init_timeout_flags = 0;
#ifdef __CONFIG_ARCH_APP_CORE
const HAL_SDCGPIOCfg *sd_gpio_cfg = NULL;
const HAL_SDCGPIOCfg sd_gpio_cfg_entry;
sd_gpio_cfg = &sd_gpio_cfg_entry;
#endif
int ret = 0;
if (host->State != SDC_STATE_RESET) {
SDC_LOGW("%s----%d reinit sdc!\n", __func__,__LINE__);
return NULL;
}
if (host->sdc_id == 0) {
host->reg_base = (volatile void *)SMC0_BASE;
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
host->reg_base = (volatile void *)SMC1_BASE;
#endif
} else {
SDC_LOGW("%s unsupport sdc id:%d!\n", __func__, host->sdc_id);
return NULL;
}
#ifdef __CONFIG_PLATFORM_FPGA
host->caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_WAIT_WHILE_BUSY |
MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50;
if (HAL_GetDevClock() > 25000000) {
host->caps |= MMC_CAP_SD_HIGHSPEED;
}
#else
host->caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | MMC_CAP_WAIT_WHILE_BUSY | \
MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50|MMC_CAP_SDIO_IRQ;
if (host->param.low_speed)
host->caps &= ~(MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED);
#endif
#ifdef CONFIG_SD_PM
host->pm_caps = MMC_PM_KEEP_POWER | MMC_PM_WAKE_SDIO_IRQ;
#endif
#ifdef __CONFIG_ARCH_APP_CORE
#ifdef NUSE_STANDARD_INTERFACE
if (host->sdc_id == 0) {
#ifndef SDC_FPGA
sdmmc_pinctrl_init(host);
#endif
host->caps |= MMC_CAP_4_BIT_DATA;
} else if (host->sdc_id == 1) {
sdmmc_pinctrl_init(host);
#if 0
SDC1_SET_GPIO_PULL();
SDC1_SET_GPIO_DRV();
SDC1_SET_GPIO_MUX();
#endif
host->caps &= ~MMC_CAP_4_BIT_DATA;
}
#else
HAL_BoardIoctl(HAL_BIR_GET_CFG, HAL_MKDEV(HAL_DEV_MAJOR_SDC, host->sdc_id),
(uint32_t)&sd_gpio_cfg);
/*test gpio_detect by gpio irq*/
sd_gpio_cfg->has_detect_gpio = 1;
if (!sd_gpio_cfg)
host->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA;
else if (sd_gpio_cfg->data_bits == 8)
host->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA;
else if (sd_gpio_cfg->data_bits == 4)
host->caps |= MMC_CAP_4_BIT_DATA;
#endif
#else
host->caps |= MMC_CAP_4_BIT_DATA;
#endif
__mci_restore_io(host);
host->clk = 400000;
/* register IRQ */
if (host->sdc_id == 0) {
ret = SDC_REQUEST_IRQ(SDC0_IRQn, SDC0_IRQHandler, host);
if (ret != 0) {
SDC_LOGE("%s,%d err:%d\n",__func__, __LINE__, ret);
return NULL;
}
SDC_SetPriority(SDC0_IRQn, NVIC_PERIPH_PRIO_DEFAULT);
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
ret = SDC_REQUEST_IRQ(SDC1_IRQn, SDC1_IRQHandler, host);
if (ret != 0) {
SDC_LOGE("%s,%d err:%d\n",__func__, __LINE__, ret);
return NULL;
}
SDC_SetPriority(SDC1_IRQn, NVIC_PERIPH_PRIO_DEFAULT);
#endif
}
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_ALWAYS_PRESENT) {
host->present = 1;
} else if (host->param.cd_mode == CARD_DETECT_BY_GPIO_IRQ) {
#if 0
if (!sd_gpio_cfg || (!sd_gpio_cfg->has_detect_gpio)) {
SDC_LOGE("%s,%d cd_mode:%ld with no detect_gpio!\n",
__func__, __LINE__, host->param.cd_mode);
return NULL;
}
#endif
//host->cd_port = sd_gpio_cfg->detect_port;
//host->cd_pin = sd_gpio_cfg->detect_pin;
//host->cd_pin_present_val = sd_gpio_cfg->detect_pin_present_val;
#ifndef CONFIG_DRIVERS_SDC_CDPIN_PRESENT_VAL
#define CONFIG_DRIVERS_SDC_CDPIN_PRESENT_VAL 0
#endif
host->cd_pin_present_val = CONFIG_DRIVERS_SDC_CDPIN_PRESENT_VAL;
//HAL_BoardIoctl(HAL_BIR_PINMUX_INIT, HAL_MKDEV(HAL_DEV_MAJOR_SDC,
// host->sdc_id), SDCGPIO_DET);
SDC_LOGN("%s,%d no imp\n",__func__, __LINE__);
//host->cd_delay = sd_gpio_cfg->detect_delay;
host->cd_delay = 10; /* short delay */
SDC_InitTimer(&host->cd_timer, &__mci_cd_timer, host, 10);
//HAL_GPIO_SetDebounce(&Irq_param, (2U << 4) | 1); /* set debounce clock */
__mci_enable_cd_pin_irq(host);
SDC_LOGN("%s,%d no imp\n",__func__, __LINE__);
host->present = (host->cd_pin_present_val ==
HAL_GPIO_ReadPin(host->cd_gpio_pin, &host->present)) ? 1 : 0;
//host->present = 1;
} else if (host->param.cd_mode == CARD_DETECT_BY_D3) {
uint32_t rval;
//host->cd_delay = sd_gpio_cfg->detect_delay;
host->cd_delay = 100;
__mci_clk_prepare_enable(host);
mmc_mdelay(1);
host->present = 1;
rval = mci_readl(host, SDXC_REG_RINTR);
SDC_LOGD("sdc +> REG_RINTR=0x%x\n", (unsigned int)rval);
if ((rval & SDXC_CardRemove)) {
SDC_LOGD("sdc data[3] detect Card Remove\n");
host->present = 0;
}
SDC_InitTimer(&host->cd_timer, &__mci_dat3_det, host, 300);
}
#else
host->present = 1;
#endif
host->align_dma_buf = HAL_MallocAlign(SDC_ALIGN_DMA_BUF_SIZE);
host->idma_des = HAL_MallocAlign(HAL_ALIGN(SDXC_MAX_DES_NUM * sizeof(smc_idma_des), OS_CACHE_ALIGN_BYTES));
if (HAL_PT_TO_U(host->idma_des) & 0x07U) {
SDC_LOGE_RAW(ROM_ERR_MASK, "%s malloc not aligned by 8B\n", __func__);
return NULL;
}
SDC_LOGD("idma_des %lx\n",HAL_PR_SZ_L(host->idma_des));
host->max_blk_count = 8192;
host->max_blk_size = 4096;
host->max_req_size = host->max_blk_size * host->max_blk_count;
host->max_seg_size = host->max_req_size;
host->max_segs = 128;
host->ocr_avail = MMC_VDD_28_29 | MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32
| MMC_VDD_32_33 | MMC_VDD_33_34;
SDC_LOGN("SDC Host Capability:0x%x Ocr avail:0x%x\n", (unsigned int)host->caps, (unsigned int)host->ocr_avail);
/* init semaphore */
SDC_SemCreate(&host->lock, 0);
SDC_MutexCreate(&host->thread_lock);
#ifdef CONFIG_SDC_EXCLUSIVE_HOST
SDC_SemCreate(&host->exclusive_lock, 1);
#endif
#ifdef CONFIG_DETECT_CARD
if (host->param.cd_mode == CARD_DETECT_BY_D3 && host->present == 0) {
SDC_LOGD("SDC power init.\n");
HAL_SDC_PowerOn(host);
} else if (host->present == 0) {
/* if card is not present and the card detect mode is not CARD_DETECT_BY_D3,
* we shutdown io voltage to save power. */
SDC_LOGD("SDC no card detected, shutdown io voltage.\n");
__mci_hold_io(host);
//__mci_set_vddio(host, SDC_VOLTAGE_OFF);
}
#endif
#ifdef CONFIG_SD_PM
SDC_DEV(host->sdc_id)->platform_data = host;
pm_register_ops(SDC_DEV(host->sdc_id));
#endif
host->State = SDC_STATE_READY;
host->wait = SDC_WAIT_NONE;
#ifdef CONFIG_DETECT_CARD
//if (host->param.cd_mode != CARD_ALWAYS_PRESENT && host->present) {
if (host->param.cd_mode != CARD_ALWAYS_PRESENT) {
host->wait_voltage_stable = 1;
if (host->cd_delay == 0) {
SDC_ModTimer(&host->cd_timer, 10);
} else {
SDC_ModTimer(&host->cd_timer, host->cd_delay);
}
}
SDC_LOGN("SDC cd_mode:%d present_val:%d\n", (unsigned int)host->param.cd_mode,
(unsigned int)host->cd_pin_present_val);
#endif
SDC_LOGN("SDC id:%d dma_use:%d present:%d\n driver version %s init ok.\n", (unsigned int)host->sdc_id,
(unsigned int)host->dma_use, (unsigned int)host->present ,SDMMC_DRIVER_VERSION);
#ifdef SDC_FPGA
SDC_LOGN("SDC ***Warning: use FPGA config,Are you sure?***\n wmb,cache unsupport now\n");
#endif
sdc_hex_dump_word((const void *)(SDC_GPIO_BASE+0xb0),0x400);
sdc_hex_dump_word((const void *)0x4002000, 0x200);
return host;
}
/**
* @brief DeInitializes the SDC peripheral.
* @param sdc_id:
* @arg sdc_id-> SDC ID.
* @retval None.
*/
int32_t hal_sdc_deinit(uint32_t sdc_id)
{
struct mmc_host *host = _mci_host[sdc_id];
if (!host) {
SDC_LOGE_RAW(ROM_ERR_MASK, "%s,%d err", __func__, __LINE__);
return -1;
}
#ifdef CONFIG_DETECT_CARD
host->param.cd_mode = 0;
#endif
#ifdef CONFIG_SD_PM
pm_unregister_ops(SDC_DEV(host->sdc_id));
#endif
__mci_exit_host(host);
if (host->sdc_id == 0) {
SDC0_DisableMClock();
SDC0_CCM_BusForceReset();
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC1_DisableMClock();
SDC1_CCM_BusForceReset();
#endif
}
#ifdef CONFIG_DETECT_CARD
HAL_BoardIoctl(HAL_BIR_PINMUX_DEINIT, HAL_MKDEV(HAL_DEV_MAJOR_SDC,
host->sdc_id), SDCGPIO_DET);
#endif
#ifdef CONFIG_SDC_EXCLUSIVE_HOST
SDC_SemDel(&host->exclusive_lock);
#endif
SDC_MutexDelete(&host->thread_lock);
SDC_SemDel(&host->lock);
HAL_FreeAlign(host->idma_des);
HAL_FreeAlign(host->align_dma_buf);
#ifdef CONFIG_DETECT_CARD
if ((host->param.cd_mode == CARD_DETECT_BY_GPIO_IRQ)||
(host->param.cd_mode == CARD_DETECT_BY_D3)) {
SDC_DelTimer(&host->cd_timer);
}
#endif
if (host->sdc_id == 0) {
SDC_FREE_IRQ(SDC0_IRQn, host);
#if SDC1_SUPPORT
} else if (host->sdc_id == 1) {
SDC_FREE_IRQ(SDC1_IRQn, host);
#endif
}
SDC_LOGD("sdc:%ld deinit ok.\n", HAL_PR_SZ_L(sdc_id));
return 0;
}
/**
* @brief malloc for sd host.
* @param sdc_id:
* @arg host ID.
* @retval 0 if success or other if failed.
*/
struct mmc_host *hal_sdc_create(uint32_t sdc_id, SDC_InitTypeDef *param)
{
struct mmc_host *host = _mci_host[sdc_id];
int ret;
rt_kprintf("hal_sdc_create %d\n",sdc_id);
if (host) {
SDC_LOGE_RAW(ROM_ERR_MASK, "%s has already created!\n", __func__);
return host;
}
host = HAL_Malloc(sizeof(struct mmc_host));
if (host == NULL) {
SDC_LOGE_RAW(ROM_ERR_MASK, "%s malloc fail\n", __func__);
} else {
SDC_Memset(host, 0, sizeof(struct mmc_host));
host->sdc_id = sdc_id;
host->ref = 0;
#ifdef __CONFIG_ARCH_APP_CORE
memcpy(&host->param, param, sizeof(SDC_InitTypeDef));
host->debug_mask = param->debug_mask;
host->dma_use = param->dma_use;
#ifdef CONFIG_DETECT_CARD
if (param->cd_mode == CARD_DETECT_BY_GPIO_IRQ || param->cd_mode == CARD_DETECT_BY_D3) {
host->cd_gpio_isr = __mci_cd_irq;
ret = mmc_gpiod_request_cd_irq(host);
if (!param->cd_cb && ret < 0) {
HAL_Free(host);
SDC_LOGE("%s,%d cd_mode:%ld with no cb!\n",
__func__, __LINE__, HAL_PR_SZ_L(param->cd_mode));
return NULL;
}
}
#endif
#endif
_mci_host[sdc_id] = host;
SDC_LOGN("%s host:%p id:%d\n", __func__, host, host->sdc_id);
}
return host;
}
/**
* @brief free for sd host.
* @param host:
* @arg host ID.
* @param flg:
* @arg 0:normal delete, 1:unnormal delete, internal use.
* @retval 0 if success or other if failed.
*/
int32_t hal_sdc_destroy(struct mmc_host *host)
{
if (host == NULL) {
SDC_LOGW_RAW(ROM_WRN_MASK, "%s host not exit!\n", __func__);
return -1;
}
if (host->ref != 0) {
SDC_LOGW("%s fail, ref:%d\n", __func__, host->ref);
return -1;
}
_mci_host[host->sdc_id] = NULL;
SDC_LOGD("%s host:%p id:%d\n", __func__, host, host->sdc_id);
HAL_Free(host);
return 0;
}
/**
* @brief get pointer of mmc_host.
* @param sdc_id:
* @arg host ID.
* @retval pointer of mmc_card if success or NULL if failed.
*/
struct mmc_host *hal_sdc_open(uint32_t sdc_id)
{
struct mmc_host *host = _mci_host[sdc_id];
if (host == NULL || host->sdc_id != sdc_id) {
SDC_LOGW_RAW(ROM_WRN_MASK, "%s host not exit! id:%d,host:%x\n", __func__, (unsigned int)sdc_id, HAL_PR_SZ(HAL_PT_TO_U(host)));
return NULL;
}
host->ref++;
return host;
}
/**
* @brief close mmc_host.
* @param host_id:
* @arg host ID.
* @retval 0 if success or other if failed.
*/
uint32_t hal_sdc_close(uint32_t sdc_id)
{
struct mmc_host *host = _mci_host[sdc_id];
if (host == NULL || host->sdc_id != sdc_id || host->ref < 1) {
SDC_LOGW_RAW(ROM_WRN_MASK, "%s fail! id:%ld\n", __func__, HAL_PR_SZ_L(sdc_id));
return -1;
}
host->ref--;
return 0;
}
|
3bb8cbcdae3056ef8b6abae76feeab2df3ffb7a4
|
6432ea7a083ff6ba21ea17af9ee47b9c371760f7
|
/stage0/src/util/test.h
|
bd5a3b07e3d977bc33046493486b9f3605eb1275
|
[
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"
] |
permissive
|
leanprover/lean4
|
4bdf9790294964627eb9be79f5e8f6157780b4cc
|
f1f9dc0f2f531af3312398999d8b8303fa5f096b
|
refs/heads/master
| 2023-08-30T01:57:45.786981
| 2023-08-29T23:14:28
| 2023-08-29T23:14:28
| 129,571,436
| 2,827
| 311
|
Apache-2.0
| 2023-09-14T18:29:16
| 2018-04-15T02:49:20
|
Lean
|
UTF-8
|
C
| false
| false
| 323
|
h
|
test.h
|
/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
// always define LEAN_DEBUG for unit-tests
#ifndef LEAN_DEBUG
#define LEAN_DEBUG
#endif
#include "runtime/debug.h"
#include "runtime/stackinfo.h"
|
aec905a705f8626245a025fa0e853b917d178e87
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/u-boot_new/arch/arm/cpu/armv7/keystone/psc.c
|
c844dc84d503acae325013ccdab22c428a4f7537
|
[
"GPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 6,833
|
c
|
psc.c
|
/*
* Keystone: PSC configuration module
*
* (C) Copyright 2012-2014
* Texas Instruments Incorporated, <www.ti.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <asm-generic/errno.h>
#include <asm/io.h>
#include <asm/processor.h>
#include <asm/arch/psc_defs.h>
#define DEVICE_REG32_R(addr) __raw_readl((u32 *)(addr))
#define DEVICE_REG32_W(addr, val) __raw_writel(val, (u32 *)(addr))
#ifdef CONFIG_SOC_K2HK
#define DEVICE_PSC_BASE K2HK_PSC_BASE
#endif
int psc_delay(void)
{
udelay(10);
return 10;
}
/*
* FUNCTION PURPOSE: Wait for end of transitional state
*
* DESCRIPTION: Polls pstat for the selected domain and waits for transitions
* to be complete.
*
* Since this is boot loader code it is *ASSUMED* that interrupts
* are disabled and no other core is mucking around with the psc
* at the same time.
*
* Returns 0 when the domain is free. Returns -1 if a timeout
* occurred waiting for the completion.
*/
int psc_wait(u32 domain_num)
{
u32 retry;
u32 ptstat;
/*
* Do nothing if the power domain is in transition. This should never
* happen since the boot code is the only software accesses psc.
* It's still remotely possible that the hardware state machines
* initiate transitions.
* Don't trap if the domain (or a module in this domain) is
* stuck in transition.
*/
retry = 0;
do {
ptstat = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_PSTAT);
ptstat = ptstat & (1 << domain_num);
} while ((ptstat != 0) && ((retry += psc_delay()) <
PSC_PTSTAT_TIMEOUT_LIMIT));
if (retry >= PSC_PTSTAT_TIMEOUT_LIMIT)
return -1;
return 0;
}
u32 psc_get_domain_num(u32 mod_num)
{
u32 domain_num;
/* Get the power domain associated with the module number */
domain_num = DEVICE_REG32_R(DEVICE_PSC_BASE +
PSC_REG_MDCFG(mod_num));
domain_num = PSC_REG_MDCFG_GET_PD(domain_num);
return domain_num;
}
/*
* FUNCTION PURPOSE: Power up/down a module
*
* DESCRIPTION: Powers up/down the requested module and the associated power
* domain if required. No action is taken it the module is
* already powered up/down.
*
* This only controls modules. The domain in which the module
* resides will be left in the power on state. Multiple modules
* can exist in a power domain, so powering down the domain based
* on a single module is not done.
*
* Returns 0 on success, -1 if the module can't be powered up, or
* if there is a timeout waiting for the transition.
*/
int psc_set_state(u32 mod_num, u32 state)
{
u32 domain_num;
u32 pdctl;
u32 mdctl;
u32 ptcmd;
u32 reset_iso;
u32 v;
/*
* Get the power domain associated with the module number, and reset
* isolation functionality
*/
v = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCFG(mod_num));
domain_num = PSC_REG_MDCFG_GET_PD(v);
reset_iso = PSC_REG_MDCFG_GET_RESET_ISO(v);
/* Wait for the status of the domain/module to be non-transitional */
if (psc_wait(domain_num) != 0)
return -1;
/*
* Perform configuration even if the current status matches the
* existing state
*
* Set the next state of the power domain to on. It's OK if the domain
* is always on. This code will not ever power down a domain, so no
* change is made if the new state is power down.
*/
if (state == PSC_REG_VAL_MDCTL_NEXT_ON) {
pdctl = DEVICE_REG32_R(DEVICE_PSC_BASE +
PSC_REG_PDCTL(domain_num));
pdctl = PSC_REG_PDCTL_SET_NEXT(pdctl,
PSC_REG_VAL_PDCTL_NEXT_ON);
DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_PDCTL(domain_num),
pdctl);
}
/* Set the next state for the module to enabled/disabled */
mdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num));
mdctl = PSC_REG_MDCTL_SET_NEXT(mdctl, state);
mdctl = PSC_REG_MDCTL_SET_RESET_ISO(mdctl, reset_iso);
DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num), mdctl);
/* Trigger the enable */
ptcmd = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_PTCMD);
ptcmd |= (u32)(1<<domain_num);
DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_PTCMD, ptcmd);
/* Wait on the complete */
return psc_wait(domain_num);
}
/*
* FUNCTION PURPOSE: Power up a module
*
* DESCRIPTION: Powers up the requested module and the associated power domain
* if required. No action is taken it the module is already
* powered up.
*
* Returns 0 on success, -1 if the module can't be powered up, or
* if there is a timeout waiting for the transition.
*/
int psc_enable_module(u32 mod_num)
{
u32 mdctl;
/* Set the bit to apply reset */
mdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num));
if ((mdctl & 0x3f) == PSC_REG_VAL_MDSTAT_STATE_ON)
return 0;
return psc_set_state(mod_num, PSC_REG_VAL_MDCTL_NEXT_ON);
}
/*
* FUNCTION PURPOSE: Power down a module
*
* DESCRIPTION: Powers down the requested module.
*
* Returns 0 on success, -1 on failure or timeout.
*/
int psc_disable_module(u32 mod_num)
{
u32 mdctl;
/* Set the bit to apply reset */
mdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num));
if ((mdctl & 0x3f) == 0)
return 0;
mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl, 0);
DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num), mdctl);
return psc_set_state(mod_num, PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE);
}
/*
* FUNCTION PURPOSE: Set the reset isolation bit in mdctl
*
* DESCRIPTION: The reset isolation enable bit is set. The state of the module
* is not changed. Returns 0 if the module config showed that
* reset isolation is supported. Returns 1 otherwise. This is not
* an error, but setting the bit in mdctl has no effect.
*/
int psc_set_reset_iso(u32 mod_num)
{
u32 v;
u32 mdctl;
/* Set the reset isolation bit */
mdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num));
mdctl = PSC_REG_MDCTL_SET_RESET_ISO(mdctl, 1);
DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_MDCTL(mod_num), mdctl);
v = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_MDCFG(mod_num));
if (PSC_REG_MDCFG_GET_RESET_ISO(v) == 1)
return 0;
return 1;
}
/*
* FUNCTION PURPOSE: Disable a power domain
*
* DESCRIPTION: The power domain is disabled
*/
int psc_disable_domain(u32 domain_num)
{
u32 pdctl;
u32 ptcmd;
pdctl = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_PDCTL(domain_num));
pdctl = PSC_REG_PDCTL_SET_NEXT(pdctl, PSC_REG_VAL_PDCTL_NEXT_OFF);
pdctl = PSC_REG_PDCTL_SET_PDMODE(pdctl, PSC_REG_VAL_PDCTL_PDMODE_SLEEP);
DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_PDCTL(domain_num), pdctl);
ptcmd = DEVICE_REG32_R(DEVICE_PSC_BASE + PSC_REG_PTCMD);
ptcmd |= (u32)(1 << domain_num);
DEVICE_REG32_W(DEVICE_PSC_BASE + PSC_REG_PTCMD, ptcmd);
return psc_wait(domain_num);
}
|
cd0fecea3f98651df5a077fdf61ac0a4b90c95c0
|
e814383d36a10839104efaa4df277996ab220fa3
|
/ompi/mca/hook/demo/hook_demo_fns.c
|
c700eef24ea1a307a499bd4bedc7e18787ee5aba
|
[
"mpich2",
"BSD-3-Clause-Open-MPI"
] |
permissive
|
open-mpi/ompi
|
a1d7483ae1d83dd8fd8ae3ee95e832e0a0ee04e3
|
1edfdb025c4450f694600083ad871cf06c8d45cd
|
refs/heads/main
| 2023-09-01T01:30:02.040705
| 2023-08-29T17:32:18
| 2023-08-29T17:32:18
| 24,107,001
| 2,008
| 973
|
NOASSERTION
| 2023-09-14T20:59:26
| 2014-09-16T16:08:30
|
C
|
UTF-8
|
C
| false
| false
| 1,398
|
c
|
hook_demo_fns.c
|
/*
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "hook_demo.h"
#define DEBUG_OUTPUT( fn_name ) \
do { \
opal_output(0, "hook:demo: %s", __func__ ); \
} while(0)
void ompi_hook_demo_mpi_initialized_top(int *flag) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_initialized_bottom(int *flag) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_finalized_top(int *flag) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_finalized_bottom(int *flag) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_init_top(int argc, char **argv, int requested, int *provided) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_init_top_post_opal(int argc, char **argv, int requested, int *provided) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_init_bottom(int argc, char **argv, int requested, int *provided) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_init_error(int argc, char **argv, int requested, int *provided) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_finalize_top(void) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_mpi_finalize_bottom(void) {
DEBUG_OUTPUT();
}
void ompi_hook_demo_extra_mpi_init_bottom(int argc, char **argv, int requested, int *provided) {
DEBUG_OUTPUT();
}
|
bccd7698c5644c326f54045b962b09cba7a97660
|
bed3ac926beac0f4e0293303d7b2a6031ee476c9
|
/Modules/ThirdParty/VNL/src/vxl/v3p/netlib/temperton/gpfa.c
|
e6d424af30219e4b55b489332a4adfc8882fcd4c
|
[
"IJG",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"SMLNJ",
"BSD-3-Clause",
"BSD-4.3TAHOE",
"LicenseRef-scancode-free-unknown",
"Spencer-86",
"LicenseRef-scancode-llnl",
"FSFUL",
"Libpng",
"libtiff",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-hdf5",
"MIT",
"NTP",
"LicenseRef-scancode-mit-old-style",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"MPL-2.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] |
permissive
|
InsightSoftwareConsortium/ITK
|
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
|
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
|
refs/heads/master
| 2023-08-31T17:21:47.754304
| 2023-08-31T00:58:51
| 2023-08-31T14:12:21
| 800,928
| 1,229
| 656
|
Apache-2.0
| 2023-09-14T17:54:00
| 2010-07-27T15:48:04
|
C++
|
UTF-8
|
C
| false
| false
| 4,575
|
c
|
gpfa.c
|
/* temperton/gpfa.f -- translated by f2c (version 20050501).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "v3p_netlib.h"
/* Table of constant values */
static integer c__2 = 2;
static integer c__3 = 3;
/* SUBROUTINE 'GPFA' */
/* SELF-SORTING IN-PLACE GENERALIZED PRIME FACTOR (COMPLEX) FFT */
/* *** THIS IS THE ALL-FORTRAN VERSION *** */
/* ------------------------------- */
/* CALL GPFA(A,B,TRIGS,INC,JUMP,N,LOT,ISIGN,NPQR) */
/* A IS FIRST REAL INPUT/OUTPUT VECTOR */
/* B IS FIRST IMAGINARY INPUT/OUTPUT VECTOR */
/* TRIGS IS A TABLE OF TWIDDLE FACTORS, PRECALCULATED */
/* BY CALLING SUBROUTINE 'SETGPFA' */
/* INC IS THE INCREMENT WITHIN EACH DATA VECTOR */
/* JUMP IS THE INCREMENT BETWEEN DATA VECTORS */
/* N IS THE LENGTH OF THE TRANSFORMS: */
/* ----------------------------------- */
/* N = (2**IP) * (3**IQ) * (5**IR) */
/* ----------------------------------- */
/* LOT IS THE NUMBER OF TRANSFORMS */
/* ISIGN = +1 FOR FORWARD TRANSFORM */
/* = -1 FOR INVERSE TRANSFORM */
/* NPQR = NPQR OBTAINED FROM SETGPFA */
/* WRITTEN BY CLIVE TEMPERTON */
/* RECHERCHE EN PREVISION NUMERIQUE */
/* ATMOSPHERIC ENVIRONMENT SERVICE, CANADA */
/* MODIFIED FOR VXL PROJECT TO ADD NPQR ARGUMENT */
/* ---------------------------------------------------------------------- */
/* DEFINITION OF TRANSFORM */
/* ----------------------- */
/* X(J) = SUM(K=0,...,N-1)(C(K)*EXP(ISIGN*2*I*J*K*PI/N)) */
/* --------------------------------------------------------------------- */
/* FOR A MATHEMATICAL DEVELOPMENT OF THE ALGORITHM USED, */
/* SEE: */
/* C TEMPERTON : "A GENERALIZED PRIME FACTOR FFT ALGORITHM */
/* FOR ANY N = (2**P)(3**Q)(5**R)", */
/* SIAM J. SCI. STAT. COMP., MAY 1992. */
/* ---------------------------------------------------------------------- */
/*< SUBROUTINE GPFA(A,B,TRIGS,INC,JUMP,N,LOT,ISIGN,NPQR) >*/
/* Subroutine */ int gpfa_(real *a, real *b, real *trigs, integer *inc,
integer *jump, integer *n, integer *lot, integer *isign, integer *
npqr)
{
/* Builtin functions */
integer pow_ii(integer *, integer *);
/* Local variables */
integer i__, ip, iq, ir;
extern /* Subroutine */ int gpfa2f_(real *, real *, real *, integer *,
integer *, integer *, integer *, integer *, integer *), gpfa3f_(
real *, real *, real *, integer *, integer *, integer *, integer *
, integer *, integer *), gpfa5f_(real *, real *, real *, integer *
, integer *, integer *, integer *, integer *, integer *);
/*< REAL A(*), B(*), TRIGS(*) >*/
/*< INTEGER INC, JUMP, N, LOT, ISIGN, NPQR(3) >*/
/*< IP = NPQR(1) >*/
/* Parameter adjustments */
--npqr;
--trigs;
--b;
--a;
/* Function Body */
ip = npqr[1];
/*< IQ = NPQR(2) >*/
iq = npqr[2];
/*< IR = NPQR(3) >*/
ir = npqr[3];
/* COMPUTE THE TRANSFORM */
/* --------------------- */
/*< I = 1 >*/
i__ = 1;
/*< IF (IP.GT.0) THEN >*/
if (ip > 0) {
/*< CALL GPFA2F(A,B,TRIGS,INC,JUMP,N,IP,LOT,ISIGN) >*/
gpfa2f_(&a[1], &b[1], &trigs[1], inc, jump, n, &ip, lot, isign);
/*< I = I + 2 * ( 2**IP) >*/
i__ += pow_ii(&c__2, &ip) << 1;
/*< ENDIF >*/
}
/*< IF (IQ.GT.0) THEN >*/
if (iq > 0) {
/*< CALL GPFA3F(A,B,TRIGS(I),INC,JUMP,N,IQ,LOT,ISIGN) >*/
gpfa3f_(&a[1], &b[1], &trigs[i__], inc, jump, n, &iq, lot, isign);
/*< I = I + 2 * (3**IQ) >*/
i__ += pow_ii(&c__3, &iq) << 1;
/*< ENDIF >*/
}
/*< IF (IR.GT.0) THEN >*/
if (ir > 0) {
/*< CALL GPFA5F(A,B,TRIGS(I),INC,JUMP,N,IR,LOT,ISIGN) >*/
gpfa5f_(&a[1], &b[1], &trigs[i__], inc, jump, n, &ir, lot, isign);
/*< ENDIF >*/
}
/*< RETURN >*/
return 0;
/*< END >*/
} /* gpfa_ */
#ifdef __cplusplus
}
#endif
|
06b22ba917c905fae98a40d0949ce1f561405a67
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/boards/arm/lpc43xx/lpc4370-link2/src/lpc4370-link2.h
|
35aadeee3d04821fbb91a3f75a02c4c3c17c8e40
|
[
"MIT-open-group",
"BSD-3-Clause",
"HPND-sell-variant",
"BSD-4-Clause-UC",
"LicenseRef-scancode-warranty-disclaimer",
"MIT-0",
"LicenseRef-scancode-bsd-atmel",
"LicenseRef-scancode-gary-s-brown",
"LicenseRef-scancode-proprietary-license",
"SunPro",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"LicenseRef-scancode-other-permissive",
"HPND",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"GPL-1.0-or-later",
"CC-BY-2.0",
"CC-BY-4.0"
] |
permissive
|
apache/nuttx
|
14519a7bff4a87935d94fb8fb2b19edb501c7cec
|
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
|
refs/heads/master
| 2023-08-25T06:55:45.822534
| 2023-08-23T16:03:31
| 2023-08-24T21:25:47
| 228,103,273
| 407
| 241
|
Apache-2.0
| 2023-09-14T18:26:05
| 2019-12-14T23:27:55
|
C
|
UTF-8
|
C
| false
| false
| 3,843
|
h
|
lpc4370-link2.h
|
/****************************************************************************
* boards/arm/lpc43xx/lpc4370-link2/src/lpc4370-link2.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_LPC43XX_LPC4370_LINK2_SRC_LPC4370_LINK2_H
#define __BOARDS_ARM_LPC43XX_LPC4370_LINK2_SRC_LPC4370_LINK2_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include "lpc43_pinconfig.h"
#include "lpc43_gpio.h"
#include "lpc43_spifi.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Do we need to register I2C drivers on behalf of the I2C tool? */
#define HAVE_I2CTOOL 1
#if !defined(CONFIG_SYSTEM_I2CTOOL) || !defined(CONFIG_I2C_DRIVER)
# undef HAVE_I2CTOOL
#endif
/* LED definitions **********************************************************/
/* The LPC4370-LINK2 has one user-controllable LED labelled D6 controlled by
* the signal LED_3V3:
*
* ---- ------- -------------
* LED SIGNAL MCU
* ---- ------- -------------
* D6 LED_3V3 PE_7 GPIO0[8]
* ---- ------- -------------
*
* A low output illuminates the LED.
*
* Definitions to configure LED pins as GPIOs:
*
* - Floating
* - Normal drive
* - No buffering, glitch filtering, slew=slow
*/
#define PINCONFIG_LED PINCONF_GPIO0p8
/* Definitions to configure LED GPIO as outputs */
#define GPIO_LED (GPIO_MODE_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN8)
/* Button definitions *******************************************************/
/* to be provided */
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
/****************************************************************************
* Name: board_spifi_initialize
*
* Description:
* Initialize SPIFI.
*
****************************************************************************/
void board_spifi_initialize(void);
/****************************************************************************
* Name: lpc43_adc_setup
*
* Description:
* Initialize ADC and register the ADC driver.
*
****************************************************************************/
#ifdef CONFIG_ADC
int lpc43_adc_setup(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_LPC43XX_LPC4370_LINK2_SRC_LPC4370_LINK2_H */
|
b85ef1b74332c0f39140f3384b6ab3027f9a41fd
|
fa1ad2e2ac7e376fc7cb3b3a6e1bb88eed3e80be
|
/govern/data-security/krb-1.2.1/src/util/profile/prof_init.c
|
6791683eea9a3fd6857e2e3315bb0a299f5b7851
|
[
"Apache-2.0",
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-mit-modification-obligations",
"BSD-4-Clause",
"LicenseRef-scancode-generic-export-compliance",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-mit-old-style",
"BSD-4-Clause-UC",
"LicenseRef-scancode-rsa-1990",
"MIT-CMU",
"LicenseRef-scancode-mit-no-advert-export-control",
"CC-BY-SA-3.0",
"LicenseRef-scancode-proprietary-license",
"GPL-2.0-or-later",
"LicenseRef-scancode-michigan-disclaimer",
"ISC",
"LicenseRef-scancode-nrl-permission",
"FreeBSD-DOC",
"LicenseRef-scancode-rsa-md4",
"RSA-MD",
"OLDAP-2.8",
"FSFULLRWD",
"BSD-2-Clause",
"LicenseRef-scancode-brian-gladman"
] |
permissive
|
alldatacenter/alldata
|
7bc7713c9f1d56ad6b8e59ea03206d1073b7e047
|
8d5f9a2d49ab8f9e85ccf058cb02c2fda287afc6
|
refs/heads/master
| 2023-08-05T07:32:25.442740
| 2023-08-03T13:17:24
| 2023-08-03T13:17:24
| 213,321,771
| 774
| 250
|
Apache-2.0
| 2023-09-06T17:35:32
| 2019-10-07T07:36:18
| null |
UTF-8
|
C
| false
| false
| 19,616
|
c
|
prof_init.c
|
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* prof_init.c --- routines that manipulate the user-visible profile_t
* object.
*/
#include "prof_int.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <errno.h>
/* Create a vtable profile, possibly with a library handle. The new profile
* takes ownership of the handle refcount on success. */
static errcode_t
init_module(struct profile_vtable *vtable, void *cbdata,
prf_lib_handle_t handle, profile_t *ret_profile)
{
profile_t profile;
struct profile_vtable *vt_copy;
/* Check that the vtable's minor version is sane and that mandatory methods
* are implemented. */
if (vtable->minor_ver < 1 || !vtable->get_values || !vtable->free_values)
return EINVAL;
if (vtable->cleanup && !vtable->copy)
return EINVAL;
if (vtable->iterator_create &&
(!vtable->iterator || !vtable->iterator_free || !vtable->free_string))
return EINVAL;
profile = malloc(sizeof(*profile));
if (!profile)
return ENOMEM;
memset(profile, 0, sizeof(*profile));
vt_copy = malloc(sizeof(*vt_copy));
if (!vt_copy) {
free(profile);
return ENOMEM;
}
/* It's safe to just copy the caller's vtable for now. If the minor
* version is bumped, we'll need to copy individual fields. */
*vt_copy = *vtable;
profile->vt = vt_copy;
profile->cbdata = cbdata;
profile->lib_handle = handle;
profile->magic = PROF_MAGIC_PROFILE;
*ret_profile = profile;
return 0;
}
/* Parse modspec into the module path and residual string. */
static errcode_t
parse_modspec(const char *modspec, char **ret_path, char **ret_residual)
{
const char *p;
char *path, *fullpath, *residual;
errcode_t ret;
*ret_path = *ret_residual = NULL;
/* Find the separator, skipping a Windows drive letter if present. */
p = (*modspec != '\0' && modspec[1] == ':') ? modspec + 2 : modspec;
p = strchr(p, ':');
if (p == NULL)
return PROF_MODULE_SYNTAX;
/* Copy the path. */
path = malloc(p - modspec + 1);
if (path == NULL)
return ENOMEM;
memcpy(path, modspec, p - modspec);
path[p - modspec] = '\0';
/* Compose the path with LIBDIR if it's not absolute. */
ret = k5_path_join(LIBDIR, path, &fullpath);
free(path);
if (ret)
return ret;
residual = strdup(p + 1);
if (residual == NULL) {
free(fullpath);
return ENOMEM;
}
*ret_path = fullpath;
*ret_residual = residual;
return 0;
}
/* Load a dynamic profile module as specified by modspec and create a vtable
* profile for it in *ret_profile. */
static errcode_t
init_load_module(const char *modspec, profile_t *ret_profile)
{
char *modpath = NULL, *residual = NULL;
struct errinfo einfo = { 0 };
prf_lib_handle_t lib_handle = NULL;
struct plugin_file_handle *plhandle = NULL;
void *cbdata = NULL, (*fptr)();
int have_lock = 0, have_cbdata = 0;
struct profile_vtable vtable = { 1 }; /* Set minor_ver to 1, rest null. */
errcode_t err;
profile_module_init_fn initfn;
err = parse_modspec(modspec, &modpath, &residual);
if (err)
goto cleanup;
/* Allocate a reference-counted library handle container. */
lib_handle = malloc(sizeof(*lib_handle));
if (lib_handle == NULL)
goto cleanup;
err = k5_mutex_init(&lib_handle->lock);
if (err)
goto cleanup;
have_lock = 1;
/* Open the module and get its initializer. */
err = krb5int_open_plugin(modpath, &plhandle, &einfo);
if (err)
goto cleanup;
err = krb5int_get_plugin_func(plhandle, "profile_module_init", &fptr,
&einfo);
if (err == ENOENT)
err = PROF_MODULE_INVALID;
if (err)
goto cleanup;
/* Get the profile vtable and callback data pointer. */
initfn = (profile_module_init_fn)fptr;
err = (*initfn)(residual, &vtable, &cbdata);
if (err)
goto cleanup;
have_cbdata = 1;
/* Create a vtable profile with the information obtained. */
lib_handle->plugin_handle = plhandle;
lib_handle->refcount = 1;
err = init_module(&vtable, cbdata, lib_handle, ret_profile);
cleanup:
free(modpath);
free(residual);
k5_clear_error(&einfo);
if (err) {
if (have_cbdata && vtable.cleanup)
vtable.cleanup(cbdata);
if (have_lock)
k5_mutex_destroy(&lib_handle->lock);
free(lib_handle);
if (plhandle)
krb5int_close_plugin(plhandle);
}
return err;
}
errcode_t KRB5_CALLCONV
profile_init_flags(const_profile_filespec_t *files, int flags,
profile_t *ret_profile)
{
const_profile_filespec_t *fs;
profile_t profile;
prf_file_t new_file, last = 0;
errcode_t retval = 0, access_retval = 0;
char *modspec = NULL, **modspec_arg;
profile = malloc(sizeof(struct _profile_t));
if (!profile)
return ENOMEM;
memset(profile, 0, sizeof(struct _profile_t));
profile->magic = PROF_MAGIC_PROFILE;
/*
* If the filenames list is not specified or empty, return an empty
* profile.
*/
if ( files && !PROFILE_LAST_FILESPEC(*files) ) {
for (fs = files; !PROFILE_LAST_FILESPEC(*fs); fs++) {
/* Allow a module declaration if it is permitted by flags and this
* is the first file parsed. */
modspec_arg = ((flags & PROFILE_INIT_ALLOW_MODULE) && !last) ?
&modspec : NULL;
retval = profile_open_file(*fs, &new_file, modspec_arg);
if (retval == PROF_MODULE && modspec) {
/* Stop parsing files and load a dynamic module instead. */
free(profile);
retval = init_load_module(modspec, ret_profile);
free(modspec);
return retval;
}
/* if this file is missing, skip to the next */
if (retval == ENOENT) {
continue;
}
/* If we can't read this file, remember it but keep going. */
if (retval == EACCES || retval == EPERM) {
access_retval = retval;
continue;
}
if (retval) {
profile_release(profile);
return retval;
}
if (last)
last->next = new_file;
else
profile->first_file = new_file;
last = new_file;
}
/*
* If last is still null after the loop, then all the files were
* missing or unreadable, so return the appropriate error.
*/
if (!last) {
profile_release(profile);
return access_retval ? access_retval : ENOENT;
}
}
*ret_profile = profile;
return 0;
}
errcode_t KRB5_CALLCONV
profile_init(const_profile_filespec_t *files, profile_t *ret_profile)
{
return profile_init_flags(files, 0, ret_profile);
}
errcode_t KRB5_CALLCONV
profile_init_vtable(struct profile_vtable *vtable, void *cbdata,
profile_t *ret_profile)
{
return init_module(vtable, cbdata, NULL, ret_profile);
}
/* Copy a vtable profile. */
static errcode_t
copy_vtable_profile(profile_t profile, profile_t *ret_new_profile)
{
errcode_t err;
void *cbdata;
profile_t new_profile;
*ret_new_profile = NULL;
if (profile->vt->copy) {
/* Make a copy of profile's cbdata for the new profile. */
err = profile->vt->copy(profile->cbdata, &cbdata);
if (err)
return err;
err = init_module(profile->vt, cbdata, profile->lib_handle,
&new_profile);
if (err && profile->vt->cleanup)
profile->vt->cleanup(cbdata);
} else {
/* Use the same cbdata as the old profile. */
err = init_module(profile->vt, profile->cbdata, profile->lib_handle,
&new_profile);
}
if (err)
return err;
/* Increment the refcount on the library handle if there is one. */
if (profile->lib_handle) {
k5_mutex_lock(&profile->lib_handle->lock);
profile->lib_handle->refcount++;
k5_mutex_unlock(&profile->lib_handle->lock);
}
*ret_new_profile = new_profile;
return 0;
}
#define COUNT_LINKED_LIST(COUNT, PTYPE, START, FIELD) \
{ \
size_t cll_counter = 0; \
PTYPE cll_ptr = (START); \
while (cll_ptr != NULL) { \
cll_counter++; \
cll_ptr = cll_ptr->FIELD; \
} \
(COUNT) = cll_counter; \
}
errcode_t KRB5_CALLCONV
profile_copy(profile_t old_profile, profile_t *new_profile)
{
size_t size, i;
const_profile_filespec_t *files;
prf_file_t file;
errcode_t err;
if (old_profile->vt)
return copy_vtable_profile(old_profile, new_profile);
/* The fields we care about are read-only after creation, so
no locking is needed. */
COUNT_LINKED_LIST (size, prf_file_t, old_profile->first_file, next);
files = malloc ((size+1) * sizeof(*files));
if (files == NULL)
return ENOMEM;
for (i = 0, file = old_profile->first_file; i < size; i++, file = file->next)
files[i] = file->data->filespec;
files[size] = NULL;
err = profile_init (files, new_profile);
free (files);
return err;
}
errcode_t KRB5_CALLCONV
profile_init_path(const_profile_filespec_list_t filepath,
profile_t *ret_profile)
{
unsigned int n_entries;
int i;
unsigned int ent_len;
const char *s, *t;
profile_filespec_t *filenames;
errcode_t retval;
/* count the distinct filename components */
for(s = filepath, n_entries = 1; *s; s++) {
if (*s == ':')
n_entries++;
}
/* the array is NULL terminated */
filenames = (profile_filespec_t*) malloc((n_entries+1) * sizeof(char*));
if (filenames == 0)
return ENOMEM;
/* measure, copy, and skip each one */
for(s = filepath, i=0; (t = strchr(s, ':')) || (t=s+strlen(s)); s=t+1, i++) {
ent_len = (unsigned int) (t-s);
filenames[i] = (char*) malloc(ent_len + 1);
if (filenames[i] == 0) {
/* if malloc fails, free the ones that worked */
while(--i >= 0) free(filenames[i]);
free(filenames);
return ENOMEM;
}
strncpy(filenames[i], s, ent_len);
filenames[i][ent_len] = 0;
if (*t == 0) {
i++;
break;
}
}
/* cap the array */
filenames[i] = 0;
retval = profile_init_flags((const_profile_filespec_t *) filenames, 0,
ret_profile);
/* count back down and free the entries */
while(--i >= 0) free(filenames[i]);
free(filenames);
return retval;
}
errcode_t KRB5_CALLCONV
profile_is_writable(profile_t profile, int *writable)
{
if (!profile || profile->magic != PROF_MAGIC_PROFILE)
return PROF_MAGIC_PROFILE;
if (!writable)
return EINVAL;
*writable = 0;
if (profile->vt) {
if (profile->vt->writable)
return profile->vt->writable(profile->cbdata, writable);
else
return 0;
}
if (profile->first_file)
*writable = profile_file_is_writable(profile->first_file);
return 0;
}
errcode_t KRB5_CALLCONV
profile_is_modified(profile_t profile, int *modified)
{
if (!profile || profile->magic != PROF_MAGIC_PROFILE)
return PROF_MAGIC_PROFILE;
if (!modified)
return EINVAL;
*modified = 0;
if (profile->vt) {
if (profile->vt->modified)
return profile->vt->modified(profile->cbdata, modified);
else
return 0;
}
if (profile->first_file)
*modified = (profile->first_file->data->flags & PROFILE_FILE_DIRTY);
return 0;
}
errcode_t KRB5_CALLCONV
profile_flush(profile_t profile)
{
if (!profile || profile->magic != PROF_MAGIC_PROFILE)
return PROF_MAGIC_PROFILE;
if (profile->vt) {
if (profile->vt->flush)
return profile->vt->flush(profile->cbdata);
return 0;
}
if (profile->first_file)
return profile_flush_file(profile->first_file);
return 0;
}
errcode_t KRB5_CALLCONV
profile_flush_to_file(profile_t profile, const_profile_filespec_t outfile)
{
if (!profile || profile->magic != PROF_MAGIC_PROFILE)
return PROF_MAGIC_PROFILE;
if (profile->vt)
return PROF_UNSUPPORTED;
if (profile->first_file)
return profile_flush_file_to_file(profile->first_file,
outfile);
return 0;
}
errcode_t KRB5_CALLCONV
profile_flush_to_buffer(profile_t profile, char **buf)
{
if (profile->vt)
return PROF_UNSUPPORTED;
return profile_flush_file_data_to_buffer(profile->first_file->data, buf);
}
void KRB5_CALLCONV
profile_free_buffer(profile_t profile, char *buf)
{
free(buf);
}
void KRB5_CALLCONV
profile_abandon(profile_t profile)
{
prf_file_t p, next;
if (!profile || profile->magic != PROF_MAGIC_PROFILE)
return;
if (profile->vt) {
if (profile->vt->cleanup)
profile->vt->cleanup(profile->cbdata);
if (profile->lib_handle) {
/* Decrement the refcount on the handle and maybe free it. */
k5_mutex_lock(&profile->lib_handle->lock);
if (--profile->lib_handle->refcount == 0) {
krb5int_close_plugin(profile->lib_handle->plugin_handle);
k5_mutex_unlock(&profile->lib_handle->lock);
k5_mutex_destroy(&profile->lib_handle->lock);
free(profile->lib_handle);
} else
k5_mutex_unlock(&profile->lib_handle->lock);
}
free(profile->vt);
} else {
for (p = profile->first_file; p; p = next) {
next = p->next;
profile_free_file(p);
}
}
profile->magic = 0;
free(profile);
}
void KRB5_CALLCONV
profile_release(profile_t profile)
{
prf_file_t p, next;
if (!profile || profile->magic != PROF_MAGIC_PROFILE)
return;
if (profile->vt) {
/* Flush the profile and then delegate to profile_abandon. */
if (profile->vt->flush)
profile->vt->flush(profile->cbdata);
profile_abandon(profile);
return;
} else {
for (p = profile->first_file; p; p = next) {
next = p->next;
profile_close_file(p);
}
}
profile->magic = 0;
free(profile);
}
/*
* Here begins the profile serialization functions.
*/
errcode_t profile_ser_size(const char *unused, profile_t profile,
size_t *sizep)
{
size_t required;
prf_file_t pfp;
required = 3*sizeof(int32_t);
for (pfp = profile->first_file; pfp; pfp = pfp->next) {
required += sizeof(int32_t);
required += strlen(pfp->data->filespec);
}
*sizep += required;
return 0;
}
static void pack_int32(int32_t oval, unsigned char **bufpp, size_t *remainp)
{
store_32_be(oval, *bufpp);
*bufpp += sizeof(int32_t);
*remainp -= sizeof(int32_t);
}
errcode_t profile_ser_externalize(const char *unused, profile_t profile,
unsigned char **bufpp, size_t *remainp)
{
errcode_t retval;
size_t required;
unsigned char *bp;
size_t remain;
prf_file_t pfp;
int32_t fcount, slen;
required = 0;
bp = *bufpp;
remain = *remainp;
retval = EINVAL;
if (profile) {
retval = ENOMEM;
(void) profile_ser_size(unused, profile, &required);
if (required <= remain) {
fcount = 0;
for (pfp = profile->first_file; pfp; pfp = pfp->next)
fcount++;
pack_int32(PROF_MAGIC_PROFILE, &bp, &remain);
pack_int32(fcount, &bp, &remain);
for (pfp = profile->first_file; pfp; pfp = pfp->next) {
slen = (int32_t) strlen(pfp->data->filespec);
pack_int32(slen, &bp, &remain);
if (slen) {
memcpy(bp, pfp->data->filespec, (size_t) slen);
bp += slen;
remain -= (size_t) slen;
}
}
pack_int32(PROF_MAGIC_PROFILE, &bp, &remain);
retval = 0;
*bufpp = bp;
*remainp = remain;
}
}
return(retval);
}
static int unpack_int32(int32_t *intp, unsigned char **bufpp,
size_t *remainp)
{
if (*remainp >= sizeof(int32_t)) {
*intp = load_32_be(*bufpp);
*bufpp += sizeof(int32_t);
*remainp -= sizeof(int32_t);
return 0;
}
else
return 1;
}
errcode_t profile_ser_internalize(const char *unused, profile_t *profilep,
unsigned char **bufpp, size_t *remainp)
{
errcode_t retval;
unsigned char *bp;
size_t remain;
int i;
int32_t fcount, tmp;
profile_filespec_t *flist = 0;
bp = *bufpp;
remain = *remainp;
fcount = 0;
if (remain >= 12)
(void) unpack_int32(&tmp, &bp, &remain);
else
tmp = 0;
if (tmp != PROF_MAGIC_PROFILE) {
retval = EINVAL;
goto cleanup;
}
(void) unpack_int32(&fcount, &bp, &remain);
retval = ENOMEM;
flist = (profile_filespec_t *) malloc(sizeof(profile_filespec_t) * (size_t) (fcount + 1));
if (!flist)
goto cleanup;
memset(flist, 0, sizeof(char *) * (size_t) (fcount+1));
for (i=0; i<fcount; i++) {
if (!unpack_int32(&tmp, &bp, &remain)) {
flist[i] = (char *) malloc((size_t) (tmp+1));
if (!flist[i])
goto cleanup;
memcpy(flist[i], bp, (size_t) tmp);
flist[i][tmp] = '\0';
bp += tmp;
remain -= (size_t) tmp;
}
}
if (unpack_int32(&tmp, &bp, &remain) ||
(tmp != PROF_MAGIC_PROFILE)) {
retval = EINVAL;
goto cleanup;
}
if ((retval = profile_init((const_profile_filespec_t *) flist,
profilep)))
goto cleanup;
*bufpp = bp;
*remainp = remain;
cleanup:
if (flist) {
for (i=0; i<fcount; i++) {
if (flist[i])
free(flist[i]);
}
free(flist);
}
return(retval);
}
|
fe0322b9f6b360f6113b9bfae24cafeefdc743e9
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/tests/usr.bin/xlint/lint1/msg_062.c
|
d6a9baf4819d6904744f5306ce80bf772670a1c3
|
[] |
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
| 436
|
c
|
msg_062.c
|
/* $NetBSD: msg_062.c,v 1.7 2023/07/07 19:45:22 rillig Exp $ */
# 3 "msg_062.c"
// Test for message: function prototype parameters must have types [62]
/* lint1-extra-flags: -X 351 */
/* expect+1: error: old-style declaration; add 'int' [1] */
outer() {
/* expect+2: warning: function prototype parameters must have types [62] */
/* expect+1: warning: dubious static function 'inner' at block level [93] */
static int inner(a);
}
|
58f7b28e1712fd21d2b51f1d4bfcf2c930e8c3a2
|
1efb2283837c9b70bc6449cec877799e4efa3268
|
/src/mpid/ch4/shm/src/shm_impl.h
|
dd5f6b5ccf047739f28a0c2bcff9085bdfc561af
|
[
"mpich2"
] |
permissive
|
pmodels/mpich
|
d2392e8e30536cad3e500c16aa1e71211101d83f
|
2d265f9f5f93ebdd07ad547423bc6212868262a4
|
refs/heads/main
| 2023-09-04T05:50:15.041823
| 2023-09-01T23:07:33
| 2023-09-01T23:07:33
| 70,918,679
| 506
| 313
|
NOASSERTION
| 2023-09-14T14:38:36
| 2016-10-14T14:39:42
|
C
|
UTF-8
|
C
| false
| false
| 727
|
h
|
shm_impl.h
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
/*
* If inlining is turned off, this file will be used to call into the shared memory module. It will
* use the function pointer structure to call the appropriate functions rather than directly
* inlining them.
*/
#ifndef SHM_IMPL_H_INCLUDED
#define SHM_IMPL_H_INCLUDED
#ifdef MPIDI_ENABLE_AM_ONLY
#include "shm_am_fallback.h"
#else
#include "shm_coll.h"
#include "shm_p2p.h"
#include "shm_rma.h"
#include "shm_part.h"
#include "shm_hooks.h"
#endif
#include "shm_am.h"
#include "shm_progress.h"
#include "shm_hooks_internal.h"
/* Not-inlined shm functions */
#include "shm_noinline.h"
#endif /* SHM_IMPL_H_INCLUDED */
|
625afcecb85b88a9c1405692090f86348bc50449
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/wasi/libc-top-half/musl/src/math/remainderl.c
|
2a13c1d5af138b8b9607e82c724c3d81f4f3ddd7
|
[
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-musl-exception",
"MIT",
"LLVM-exception",
"Apache-2.0",
"NCSA"
] |
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
| 273
|
c
|
remainderl.c
|
#include <math.h>
#include <float.h>
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double remainderl(long double x, long double y)
{
return remainder(x, y);
}
#else
long double remainderl(long double x, long double y)
{
int q;
return remquol(x, y, &q);
}
#endif
|
f0b9a03b60bbf05b6ecc2e0c3d9e5c3277e05653
|
95a14668d0e9289decb373e7222c3e9bb5778ccf
|
/tests/client/test_client.c
|
b1602c96ef3b38afdb8e9e1a483ffb434fabfed0
|
[
"MIT"
] |
permissive
|
TimeToogo/ff-proxy
|
9cc124a15d504d982da4892e1863a4dc4318512d
|
8a71365fa8f5748c5c42b2c5e44e0a35829ec772
|
refs/heads/master
| 2023-08-22T01:42:44.680667
| 2023-02-05T12:31:46
| 2023-02-05T12:31:46
| 239,283,589
| 763
| 58
|
MIT
| 2023-07-25T21:15:29
| 2020-02-09T10:16:17
|
C
|
UTF-8
|
C
| false
| false
| 11,640
|
c
|
test_client.c
|
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "../include/unity.h"
#include "../../client/c/client_p.h"
#include "../../client/c/client.h"
#include "../../src/os/linux_endian.h"
void test_client_generate_request_id()
{
uint64_t request_id = ff_client_generate_request_id();
uint64_t request_id2 = ff_client_generate_request_id();
TEST_ASSERT_NOT_EQUAL_MESSAGE(request_id, request_id2, "request ids must be random");
}
void test_client_send_request_no_packets()
{
struct ff_client_packet packets[0];
struct ff_client_config config =
{
.ip_address = "127.0.0.1",
.port = "8088",
};
uint8_t res = ff_client_send_request(&config, packets, sizeof(packets) / sizeof(packets[0]));
TEST_ASSERT_EQUAL_MESSAGE(0, res, "return value check failed");
}
void test_client_send_request_two_packets()
{
uint8_t packet_1_value[] = {1, 2, 3, 4};
uint8_t packet_2_value[] = {200, 201, 203, 204, 205};
struct ff_client_packet packets[] = {
{.length = sizeof(packet_1_value), .value = (uint8_t *)&packet_1_value},
{.length = sizeof(packet_2_value), .value = (uint8_t *)&packet_2_value},
};
struct ff_client_config config =
{
.ip_address = "127.0.0.1",
.port = "8088",
};
uint8_t res = ff_client_send_request(&config, packets, sizeof(packets) / sizeof(packets[0]));
TEST_ASSERT_EQUAL_MESSAGE(0, res, "return value check failed");
}
void test_client_create_payload_options()
{
struct ff_client_config config = {.https = true};
struct ff_request *request = ff_request_alloc();
uint8_t result = ff_client_create_payload_options(request, &config);
TEST_ASSERT_EQUAL_MESSAGE(3, result, "return value check failed");
TEST_ASSERT_NOT_EQUAL_MESSAGE(NULL, request->payload, "payload check failed");
TEST_ASSERT_EQUAL_MESSAGE(FF_REQUEST_OPTION_TYPE_HTTPS, request->payload->value[0], "option (1) type failed");
ff_request_free(request);
}
void test_client_read_payload_from_file()
{
char contents[] = "hello world";
char *tmp_file = "/tmp/ff_test_file";
FILE *fd = fopen(tmp_file, "w+");
fwrite(contents, sizeof(contents[0]), sizeof(contents) - 1, fd);
fseek(fd, 0, SEEK_SET);
struct ff_request *request = ff_request_alloc();
ff_client_read_payload_from_file(request, fd);
TEST_ASSERT_EQUAL_MESSAGE(strlen(contents), request->payload_length, "payload_length check failed");
TEST_ASSERT_EQUAL_MESSAGE(strlen(contents), request->payload->length, "payload->length check failed");
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(contents, request->payload->value, strlen(contents), "payload value check failed");
ff_request_free(request);
fclose(fd);
}
void test_client_packetise_request_empty_request()
{
struct ff_request *request = ff_request_alloc();
uint16_t packet_count;
struct ff_client_packet *packets = ff_client_packetise_request(request, &packet_count);
TEST_ASSERT_EQUAL_MESSAGE(0, packet_count, "packet count check failed");
ff_request_free(request);
FREE(packets);
}
void test_client_packetise_request_single_packet()
{
char payload[] = "hello world";
struct ff_request *request = ff_request_alloc();
request->options = (struct ff_request_option_node **)malloc(sizeof(struct ff_request_option_node *) * 1);
request->options[0] = ff_request_option_node_alloc();
request->options[0]->type = FF_REQUEST_OPTION_TYPE_EOL;
request->options[0]->length = 0;
request->options_length++;
request->payload = ff_request_payload_node_alloc();
ff_request_payload_load_buff(request->payload, strlen(payload), payload);
request->payload->length = strlen(payload);
request->payload_length = strlen(payload);
uint16_t packet_count;
struct ff_client_packet *packets = ff_client_packetise_request(request, &packet_count);
TEST_ASSERT_EQUAL_MESSAGE(1, packet_count, "packet count check failed");
TEST_ASSERT_EQUAL_MESSAGE(
sizeof(struct __raw_ff_request_header) + request->options_length * sizeof(struct __raw_ff_request_option_header) + strlen(payload),
packets[0].length,
"payload length check failed");
struct __raw_ff_request_header *packet_header = (struct __raw_ff_request_header *)packets[0].value;
TEST_ASSERT_EQUAL_MESSAGE(FF_VERSION_1, ntohs(packet_header->version), "packet version check failed");
TEST_ASSERT_NOT_EQUAL_MESSAGE(0, ntohll(packet_header->request_id), "packet request id check failed");
TEST_ASSERT_EQUAL_MESSAGE(0, ntohl(packet_header->chunk_offset), "packet chunk offset check failed");
TEST_ASSERT_EQUAL_MESSAGE(strlen(payload), ntohs(packet_header->chunk_length), "packet chunk length check failed");
TEST_ASSERT_EQUAL_MESSAGE(strlen(payload), ntohl(packet_header->total_length), "packet total length check failed");
struct __raw_ff_request_option_header *option_1 = (struct __raw_ff_request_option_header *)((void *)packet_header + sizeof(struct __raw_ff_request_header));
TEST_ASSERT_EQUAL_MESSAGE(FF_REQUEST_OPTION_TYPE_EOL, option_1->type, "option (1) type check failed");
TEST_ASSERT_EQUAL_MESSAGE(0, ntohs(option_1->length), "option (1) type check failed");
uint8_t *packet_payload = (uint8_t *)((void *)option_1 + sizeof(struct __raw_ff_request_option_header));
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(payload, (char *)packet_payload, strlen(payload), "packet payload check failed");
ff_request_free(request);
FREE(packets[0].value);
FREE(packets);
}
void test_client_packetise_request_multiple_packets_with_option()
{
uint8_t payload[2000] = {0};
for (size_t i = 0; i < sizeof(payload); i++)
{
payload[i] = (uint8_t)(i % 255);
}
struct ff_request *request = ff_request_alloc();
request->options = (struct ff_request_option_node **)malloc(sizeof(struct ff_request_option_node *) * 2);
request->options[0] = ff_request_option_node_alloc();
request->options[0]->type = FF_REQUEST_OPTION_TYPE_HTTPS;
request->options[0]->length = 1;
request->options[0]->value = malloc(1);
request->options[0]->value[0] = 1;
request->options_length++;
request->options[1] = ff_request_option_node_alloc();
request->options[1]->type = FF_REQUEST_OPTION_TYPE_EOL;
request->options[1]->length = 0;
request->options_length++;
request->payload = ff_request_payload_node_alloc();
ff_request_payload_load_buff(request->payload, sizeof(payload), payload);
request->payload->length = sizeof(payload);
request->payload_length = sizeof(payload);
uint16_t packet_count;
struct ff_client_packet *packets = ff_client_packetise_request(request, &packet_count);
TEST_ASSERT_EQUAL_MESSAGE(2, packet_count, "packet count check failed");
// Test packet 1
TEST_ASSERT_EQUAL_MESSAGE(
FF_CLIENT_MAX_PACKET_LENGTH,
packets[0].length,
"packet (1) payload length check failed");
struct __raw_ff_request_header *p1_header = (struct __raw_ff_request_header *)packets[0].value;
TEST_ASSERT_EQUAL_MESSAGE(FF_VERSION_1, ntohs(p1_header->version), "packet (1) version check failed");
TEST_ASSERT_NOT_EQUAL_MESSAGE(0, ntohll(p1_header->request_id), "packet (1) request id check failed");
TEST_ASSERT_EQUAL_MESSAGE(0, ntohl(p1_header->chunk_offset), "packet (1) chunk offset check failed");
TEST_ASSERT_EQUAL_MESSAGE(
FF_CLIENT_MAX_PACKET_LENGTH - sizeof(struct __raw_ff_request_header) - 2 * sizeof(struct __raw_ff_request_option_header) - 1,
ntohs(p1_header->chunk_length),
"packet (1) chunk length check failed");
TEST_ASSERT_EQUAL_MESSAGE(sizeof(payload), ntohl(p1_header->total_length), "packet (1) total length check failed");
struct __raw_ff_request_option_header *p1_option_1 = (struct __raw_ff_request_option_header *)((void *)p1_header + sizeof(struct __raw_ff_request_header));
TEST_ASSERT_EQUAL_MESSAGE(FF_REQUEST_OPTION_TYPE_HTTPS, p1_option_1->type, "packet (1) option (1) type check failed");
TEST_ASSERT_EQUAL_MESSAGE(1, ntohs(p1_option_1->length), "packet (1) option (1) type check failed");
TEST_ASSERT_EQUAL_MESSAGE(1, *((uint8_t *)p1_option_1 + sizeof(struct __raw_ff_request_option_header)), "packet (1) option (1) value check failed");
struct __raw_ff_request_option_header *p1_option_2 = (struct __raw_ff_request_option_header *)((void *)p1_option_1 + sizeof(struct __raw_ff_request_option_header) + 1);
TEST_ASSERT_EQUAL_MESSAGE(FF_REQUEST_OPTION_TYPE_EOL, p1_option_2->type, "packet (1) option (2) type check failed");
TEST_ASSERT_EQUAL_MESSAGE(0, ntohs(p1_option_2->length), "packet (1) option (2) type check failed");
uint8_t *p1_payload = (uint8_t *)((void *)p1_option_2 + sizeof(struct __raw_ff_request_option_header));
TEST_ASSERT_EQUAL_CHAR_ARRAY_MESSAGE(payload, p1_payload, ntohs(p1_header->chunk_length), "packet (1) payload check failed");
// Test packet 2
TEST_ASSERT_EQUAL_MESSAGE(
sizeof(struct __raw_ff_request_header) + sizeof(struct __raw_ff_request_option_header) + sizeof(payload) - ntohs(p1_header->chunk_length),
packets[1].length,
"packet (2) payload length check failed");
struct __raw_ff_request_header *p2_header = (struct __raw_ff_request_header *)packets[1].value;
TEST_ASSERT_EQUAL_MESSAGE(FF_VERSION_1, ntohs(p2_header->version), "packet (2) version check failed");
TEST_ASSERT_NOT_EQUAL_MESSAGE(0, ntohll(p2_header->request_id), "packet (2) request id check failed");
TEST_ASSERT_EQUAL_MESSAGE(ntohs(p1_header->chunk_length), ntohl(p2_header->chunk_offset), "packet (2) chunk offset check failed");
TEST_ASSERT_EQUAL_MESSAGE(
sizeof(payload) - ntohs(p1_header->chunk_length),
ntohs(p2_header->chunk_length),
"packet (2) chunk length check failed");
TEST_ASSERT_EQUAL_MESSAGE(sizeof(payload), ntohl(p2_header->total_length), "packet (2) total length check failed");
struct __raw_ff_request_option_header *p2_option_1 = (struct __raw_ff_request_option_header *)((void *)p2_header + sizeof(struct __raw_ff_request_header));
TEST_ASSERT_EQUAL_MESSAGE(FF_REQUEST_OPTION_TYPE_EOL, p2_option_1->type, "packet (2) option (1) type check failed");
TEST_ASSERT_EQUAL_MESSAGE(0, ntohs(p2_option_1->length), "packet (2) option (1) type check failed");
uint8_t *p2_payload = (uint8_t *)((void *)p2_option_1 + sizeof(struct __raw_ff_request_option_header));
TEST_ASSERT_EQUAL_CHAR_ARRAY_MESSAGE(payload + ntohs(p1_header->chunk_length), p2_payload, ntohs(p2_header->chunk_length), "packet (2) payload check failed");
TEST_ASSERT_EQUAL_MESSAGE(ntohll(p1_header->request_id), ntohll(p2_header->request_id), "request ids must match");
ff_request_free(request);
FREE(packets[0].value);
FREE(packets[1].value);
FREE(packets);
}
void test_client_make_request_http_and_encrypted()
{
char contents[] = "hello world";
char *tmp_file = "/tmp/ff_test_file";
FILE *fd = fopen(tmp_file, "w+");
fwrite(contents, sizeof(contents[0]), sizeof(contents) - 1, fd);
fseek(fd, 0, SEEK_SET);
struct ff_client_config *config = malloc(sizeof(struct ff_client_config));
config->https = true;
config->encryption.key = (uint8_t *)"test key";
config->encryption.pbkdf2_iterations = 1000;
config->ip_address = "127.0.0.1";
config->port = "12345";
config->logging_level = FF_DEBUG;
int res = ff_client_make_request(config, fd);
TEST_ASSERT_EQUAL_MESSAGE(0, res, "return value check failed");
FREE(config);
fclose(fd);
}
|
5413ce57ca2d91914b32be7e63f85ffcb133bc0f
|
4c1a9887afb2a62b862ae954158ced183199a30e
|
/src/win32/getopt/getopt.c
|
417b0aecffe6af02065ab996ae1272b7b657b25d
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] |
permissive
|
stlink-org/stlink
|
503957cfa50e6c53d8e597fe4bc6564307f7fa9f
|
f3fcaf2553e5d99a8cc40dca55fae500cbb42050
|
refs/heads/develop
| 2023-09-04T07:06:51.760213
| 2023-09-01T20:50:35
| 2023-09-01T20:50:35
| 1,253,879
| 1,706
| 450
|
BSD-3-Clause
| 2023-09-04T14:26:31
| 2011-01-14T09:19:12
|
C
|
UTF-8
|
C
| false
| false
| 7,481
|
c
|
getopt.c
|
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "getopt.h"
#if !defined(_MSC_VER)
const int32_t no_argument = 0;
const int32_t required_argument = 1;
const int32_t optional_argument = 2;
#endif
char* optarg;
int32_t optopt;
int32_t optind = 1; // The variable optind [...] shall be initialized to 1 by the system
int32_t opterr;
static char* optcursor = NULL;
/* Implemented based on [1] and [2] for optional arguments.
* optopt is handled FreeBSD-style, per [3].
* Other GNU and FreeBSD extensions are purely accidental.
*
* [1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html
* [2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
* [3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE
*/
int32_t getopt(int32_t argc, char* const argv[], const char* optstring) {
int32_t optchar = -1;
const char* optdecl = NULL;
optarg = NULL;
opterr = 0;
optopt = 0;
/* Unspecified, but we need it to avoid overrunning the argv bounds. */
if (optind >= argc) { goto no_more_optchars; }
/* If, when getopt() is called argv[optind] is a null pointer,
* getopt() shall return -1 without changing optind.
*/
if (argv[optind] == NULL) { goto no_more_optchars; }
/* If, when getopt() is called *argv[optind] is not the character '-',
* getopt() shall return -1 without changing optind.
*/
if (*argv[optind] != '-') { goto no_more_optchars; }
/* If, when getopt() is called argv[optind] points to the string "-",
* getopt() shall return -1 without changing optind.
*/
if (strcmp(argv[optind], "-") == 0) { goto no_more_optchars; }
/* If, when getopt() is called argv[optind] points to the string "--",
* getopt() shall return -1 after incrementing optind.
*/
if (strcmp(argv[optind], "--") == 0) {
++optind;
goto no_more_optchars;
}
if (optcursor == NULL || *optcursor == '\0') { optcursor = argv[optind] + 1; }
optchar = *optcursor;
/* FreeBSD: The variable optopt saves the last known option character returned by getopt(). */
optopt = optchar;
/* The getopt() function shall return the next option character (if one is found)
* from argv that matches a character in optstring, if there is one that matches.
*/
optdecl = strchr(optstring, optchar);
if (optdecl) {
/* [I]f a character is followed by a colon, the option takes an argument. */
if (optdecl[1] == ':') {
optarg = ++optcursor;
if (*optarg == '\0') {
/* GNU extension: Two colons mean an option takes an optional arg;
* if there is text in the current argv-element (i.e., in the same word
* as the option name itself, for example, "-oarg"), then it is returned
* in optarg, otherwise optarg is set to zero.
*/
if (optdecl[2] != ':') {
/* If the option was the last character in the string pointed to by
* an element of argv, then optarg shall contain the next element
* of argv, and optind shall be incremented by 2. If the resulting
* value of optind is greater than argc, this indicates a missing
* option-argument, and getopt() shall return an error indication.
* Otherwise, optarg shall point to the string following the
* option character in that element of argv, and optind shall be
* incremented by 1.
*/
if (++optind < argc) {
optarg = argv[optind];
} else {
/* If it detects a missing option-argument, it shall return the
* colon character ( ':' ) if the first character of optstring
* was a colon, or a question-mark character ( '?' ) otherwise.
*/
optarg = NULL;
optchar = (optstring[0] == ':') ? ':' : '?';
}
} else {
optarg = NULL;
}
}
optcursor = NULL;
}
} else {
/* If getopt() encounters an option character that is not contained in
* optstring, it shall return the question-mark ( '?' ) character.
*/
optchar = '?';
}
if (optcursor == NULL || *++optcursor == '\0') { ++optind; }
return(optchar);
no_more_optchars:
optcursor = NULL;
return(-1);
}
/* Implementation based on http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html */
int32_t getopt_long(int32_t argc,
char* const argv[],
const char* optstring,
const struct option* longopts,
int* longindex) {
const struct option* o = longopts;
const struct option* match = NULL;
int32_t num_matches = 0;
uint32_t argument_name_length = 0;
const char* current_argument = NULL;
int32_t retval = -1;
optarg = NULL;
optopt = 0;
if (optind >= argc) { return(-1); }
if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0) {
return(getopt(argc, argv, optstring));
}
// it's an option; starts with -- and is longer than two chars
current_argument = argv[optind] + 2;
argument_name_length = strcspn(current_argument, "=");
for ( ; o->name; ++o)
if (strncmp(o->name, current_argument, argument_name_length) == 0) {
match = o;
++num_matches;
}
if (num_matches == 1) {
/* If longindex is not NULL, it points to a variable which is set to the
* index of the long option relative to longopts.
*/
if (longindex) { *longindex = (match - longopts); }
/* If flag is NULL, then getopt_long() shall return val.
* Otherwise, getopt_long() returns 0, and flag shall point to a variable
* which shall be set to val if the option is found, but left unchanged if
* the option is not found.
*/
if (match->flag) { *(match->flag) = match->val; }
retval = match->flag ? 0 : match->val;
if (match->has_arg != no_argument) {
optarg = strchr(argv[optind], '=');
if (optarg != NULL) { ++optarg; }
if (match->has_arg == required_argument) {
/* Only scan the next argv for required arguments. Behavior is not
specified, but has been observed with Ubuntu. */
if (optarg == NULL && ++optind < argc) { optarg = argv[optind]; }
if (optarg == NULL) { retval = ':'; }
}
} else if (strchr(argv[optind], '=')) {
/* An argument was provided to a non-argument option.
* I haven't seen this specified explicitly, but both GNU and BSD-based
* implementations show this behavior.
*/
retval = '?';
}
} else {
// unknown option or ambiguous match
retval = '?';
}
++optind;
return(retval);
}
|
a1ca7e9d5cee6f3f2f8e6aa2f3307b622a7eb9da
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/musl/src/string/memcpy.c
|
06e88742b1144a3b770184cc34dc14d96bdd2134
|
[
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-musl-exception"
] |
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
| 2,641
|
c
|
memcpy.c
|
#include <string.h>
#include <stdint.h>
#include <endian.h>
void *memcpy(void *restrict dest, const void *restrict src, size_t n)
{
unsigned char *d = dest;
const unsigned char *s = src;
#ifdef __GNUC__
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define LS >>
#define RS <<
#else
#define LS <<
#define RS >>
#endif
typedef uint32_t __attribute__((__may_alias__)) u32;
uint32_t w, x;
for (; (uintptr_t)s % 4 && n; n--) *d++ = *s++;
if ((uintptr_t)d % 4 == 0) {
for (; n>=16; s+=16, d+=16, n-=16) {
*(u32 *)(d+0) = *(u32 *)(s+0);
*(u32 *)(d+4) = *(u32 *)(s+4);
*(u32 *)(d+8) = *(u32 *)(s+8);
*(u32 *)(d+12) = *(u32 *)(s+12);
}
if (n&8) {
*(u32 *)(d+0) = *(u32 *)(s+0);
*(u32 *)(d+4) = *(u32 *)(s+4);
d += 8; s += 8;
}
if (n&4) {
*(u32 *)(d+0) = *(u32 *)(s+0);
d += 4; s += 4;
}
if (n&2) {
*d++ = *s++; *d++ = *s++;
}
if (n&1) {
*d = *s;
}
return dest;
}
if (n >= 32) switch ((uintptr_t)d % 4) {
case 1:
w = *(u32 *)s;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
n -= 3;
for (; n>=17; s+=16, d+=16, n-=16) {
x = *(u32 *)(s+1);
*(u32 *)(d+0) = (w LS 24) | (x RS 8);
w = *(u32 *)(s+5);
*(u32 *)(d+4) = (x LS 24) | (w RS 8);
x = *(u32 *)(s+9);
*(u32 *)(d+8) = (w LS 24) | (x RS 8);
w = *(u32 *)(s+13);
*(u32 *)(d+12) = (x LS 24) | (w RS 8);
}
break;
case 2:
w = *(u32 *)s;
*d++ = *s++;
*d++ = *s++;
n -= 2;
for (; n>=18; s+=16, d+=16, n-=16) {
x = *(u32 *)(s+2);
*(u32 *)(d+0) = (w LS 16) | (x RS 16);
w = *(u32 *)(s+6);
*(u32 *)(d+4) = (x LS 16) | (w RS 16);
x = *(u32 *)(s+10);
*(u32 *)(d+8) = (w LS 16) | (x RS 16);
w = *(u32 *)(s+14);
*(u32 *)(d+12) = (x LS 16) | (w RS 16);
}
break;
case 3:
w = *(u32 *)s;
*d++ = *s++;
n -= 1;
for (; n>=19; s+=16, d+=16, n-=16) {
x = *(u32 *)(s+3);
*(u32 *)(d+0) = (w LS 8) | (x RS 24);
w = *(u32 *)(s+7);
*(u32 *)(d+4) = (x LS 8) | (w RS 24);
x = *(u32 *)(s+11);
*(u32 *)(d+8) = (w LS 8) | (x RS 24);
w = *(u32 *)(s+15);
*(u32 *)(d+12) = (x LS 8) | (w RS 24);
}
break;
}
if (n&16) {
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
}
if (n&8) {
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
}
if (n&4) {
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
}
if (n&2) {
*d++ = *s++; *d++ = *s++;
}
if (n&1) {
*d = *s;
}
return dest;
#endif
for (; n; n--) *d++ = *s++;
return dest;
}
|
f03adc04ebe30a6bc4217d41a2b63ab5294383dd
|
035660e8cc10571ebbd0d4393fef063bb7eb98f6
|
/include/z64eff_footmark.h
|
6d5fe3026aef36d65555ea15b5b490ad04fa3a78
|
[] |
no_license
|
zeldaret/mm
|
f163a5e7c4314105777369fa7671ce9c2a99922a
|
4ae00e909e74044f05155683b49d2561f91de7ba
|
refs/heads/master
| 2023-08-06T07:22:04.912966
| 2023-08-04T20:36:03
| 2023-08-04T20:36:03
| 247,875,852
| 915
| 328
| null | 2023-09-14T11:48:59
| 2020-03-17T04:03:07
|
C
|
UTF-8
|
C
| false
| false
| 928
|
h
|
z64eff_footmark.h
|
#ifndef Z64EFF_FOOTMARK_H
#define Z64EFF_FOOTMARK_H
#include "ultra64.h"
#include "z64math.h"
struct PlayState;
struct Actor;
typedef struct EffFootmark {
/* 0x00 */ MtxF mf;
/* 0x40 */ struct Actor* actor;
/* 0x44 */ Vec3f pos;
/* 0x50 */ u8 flags; // bit 0 - footmark fades out
/* 0x51 */ u8 id;
/* 0x52 */ u8 red;
/* 0x53 */ u8 blue;
/* 0x54 */ u8 green;
/* 0x56 */ u16 alpha;
/* 0x58 */ u16 alphaChange;
/* 0x5A */ u16 size;
/* 0x5C */ u16 fadeOutDelay;
/* 0x5E */ u16 age;
} EffFootmark; // size = 0x60
#define FOOTMARK_FLAG_1 (1 << 0)
void EffFootmark_Init(struct PlayState* play);
void EffFootmark_Add(struct PlayState* play, MtxF* mf, struct Actor* actor, u8 id, Vec3f* pos, u16 size, u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeOutDelay);
void EffFootmark_Update(struct PlayState* play);
void EffFootmark_Draw(struct PlayState* play);
#endif
|
07210de6f14e833e0efde757c1b8f040ad292823
|
d1ad72d5061a6f667157e327141ffe1f48459e72
|
/tripping.c
|
23b2972650f973780e21f4005ab4c56f82690e64
|
[
"Zlib"
] |
permissive
|
rakitzis/rc
|
2b012e3dc4bb32b6384e3fb85fe9c76925caccf0
|
4aaba1a9cb9fdbb8660696a87850836ffdb09599
|
refs/heads/master
| 2023-06-22T13:56:06.545466
| 2023-06-14T07:02:58
| 2023-06-14T09:05:04
| 16,213,024
| 247
| 38
|
NOASSERTION
| 2023-06-13T17:34:50
| 2014-01-24T18:31:00
|
C
|
UTF-8
|
C
| false
| false
| 713
|
c
|
tripping.c
|
/* This is an auxiliary test program for rc. */
#include "config.h"
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
static void out0(void) {
putchar('t'); putchar('r');
putchar('\0');
putchar('u'); putchar('e');
putchar('\n');
}
static void ctrl_a(void) {
puts("a\001ab\002b");
}
static void makenonblock(void) {
int flags;
if ((flags = fcntl(0, F_GETFL)) == -1)
perror("fcntl 1");
flags |= O_NONBLOCK;
if (fcntl(0, F_SETFL, (long) flags) == -1)
perror("fcntl 2");
}
int main(int argc, char **argv) {
switch(argv[1][0]) {
case '0':
out0();
break;
case 'a':
ctrl_a();
break;
case 'n':
makenonblock();
break;
}
return 0;
}
|
4f038cb5b2e73d614dec0611cd19258c93d8facd
|
90af59a569a9f5affed4f33369032a1fde714bd2
|
/software/standalone/ethernet/src/main.c
|
2e14810b07e5f62cf0c28356ba242b2fdee14ba0
|
[
"MIT"
] |
permissive
|
SpinalHDL/SaxonSoc
|
80b25c109fc43c61b1cb4a36fc06b243439f6104
|
db626f4eb6fdef19565e15f9e37229dbfbad2ae7
|
refs/heads/dev-0.3
| 2023-08-23T11:28:37.791303
| 2023-08-09T19:16:56
| 2023-08-09T19:16:56
| 159,960,289
| 130
| 46
|
MIT
| 2022-10-03T10:58:30
| 2018-12-01T15:49:01
|
Scala
|
UTF-8
|
C
| false
| false
| 4,256
|
c
|
main.c
|
#include "type.h"
#include "bsp.h"
#include "ethernetConfig.h"
#include "spi.h"
#include "gpio.h"
#include "mac.h"
u16 mdio_read(u32 spi, u32 cs, u32 phy, u32 reg){
u16 data;
spi_select(spi, cs);
spi_write(spi, 0x60 | (phy >> 1) & 0x0F);
spi_write(spi, (phy << 7) & 0x80 | (reg << 2) & 0x7C);
data = ((u16) spi_read(spi)) << 8;
data |= ((u16) spi_read(spi)) << 0;
spi_diselect(spi, cs);
return data;
}
void mdio_write(u32 spi, u32 cs, u32 phy, u32 reg, u16 data){
spi_select(spi, cs);
spi_write(spi, 0x50 | (phy >> 1) & 0x0F);
spi_write(spi, (phy << 7) & 0x80 | (reg << 2) & 0x7C | 0x02);
spi_write(spi, data >> 8);
spi_write(spi, data >> 0);
spi_diselect(spi, cs);
}
void mdio_init(u32 spi, u32 cs){
spi_diselect(spi, cs);
gpio_setOutput(RESETN_GPIO, 0);
bsp_uDelay(100);
gpio_setOutput(RESETN_GPIO, RESETN_PIN);
bsp_uDelay(200000);
spi_select(spi, cs);
spi_write(spi, 0xFF);
spi_write(spi, 0xFF);
spi_write(spi, 0xFF);
spi_write(spi, 0xFF);
spi_diselect(spi, cs);
bsp_uDelay(100);
}
void putU8Hex(u8 value){
for(s32 i = 1; i >= 0;i--){
u32 hex = (value >> i*4) & 0xF;
bsp_putChar(hex > 9 ? 'A' + hex - 10 : '0' + hex);
}
}
//#pragma GCC optimize ("O3")
void main() {
bsp_putString("Ethernet demo");
mac_setCtrl(MAC, MAC_CTRL_TX_RESET | MAC_CTRL_RX_RESET);
bsp_uDelay(10);
mac_setCtrl(MAC, 0);
// TX
while(1){
// while(!mac_txReady(MAC));
// static u8 frame[] = {0x33,0x33,0x00,0x00,0x00,0x02,0x00,0x0A,0xCD,0x2C,0x15,0x94,0x86,0xDD,0x60,0x0B,0xDD,0x41,0x00,0x08,0x3A,0xFF,0xFE,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x3B,0x9A,0x3C,0xE0,0xE2,0x39,0x55,0xFF,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x85,0x00,0xCC,0x86,0x00,0x00,0x00,0x00,0x59,0x01,0xA3,0x28};
// u32 bits = sizeof(frame)*8;
// u32 words = (bits+31)/32;
// u32 *ptr = (u32*) frame;
// while(mac_getTxAvailability(MAC) == 0);
// mac_pushTx(MAC, bits);
// while(words != 0){
// u32 tockens = mac_getTxAvailability(MAC);
// if(tockens > words) tockens = words;
// words -= tockens;
// while(tockens != 0){
// mac_pushTx(MAC, *ptr++);
// tockens--;
// }
// }
static u32 counter = 0;
while(!mac_txReady(MAC));
u32 bits = 32;
u32 words = (bits+31)/32;
while(mac_getTxAvailability(MAC) < 2);
mac_pushTx(MAC, bits);
mac_pushTx(MAC, counter++);
/* bsp_putChar('*');
bsp_uDelay(1000*500);*/
}
// RX
// while(1){
// while(!mac_rxPending(MAC));
//
// u32 bits = mac_getRx(MAC);
// u32 words = (bits+31)/32;
// u32 byteRemaining = (bits+7)/8;
// for(u32 wordId = 0;wordId < words;wordId++){
// u32 word = mac_getRx(MAC);
// u32 byteCount = byteRemaining > 4 ? 4 : byteRemaining;
// for(u32 byteId = 0;byteId < byteCount; byteId++){
// putU8Hex(word >> byteId*8);
// }
// bsp_putChar(' ');
// byteRemaining -= byteCount;
// }
// bsp_putChar('\n');
// bsp_putChar('\n');
// bsp_putChar('\n');
// }
// MDIO
// u32 clkDivider = BSP_CLINT_HZ/(1000000*2)-1;
//
// Spi_Config spiCfg;
// spiCfg.cpol = 0;
// spiCfg.cpha = 0;
// spiCfg.mode = 1;
// spiCfg.clkDivider = clkDivider;
// spiCfg.ssSetup = clkDivider;
// spiCfg.ssHold = clkDivider;
// spiCfg.ssDisable = clkDivider;
// spi_applyConfig(SPI, &spiCfg);
//
// gpio_setOutputEnable(RESETN_GPIO, RESETN_PIN);
//
// u32 address = 0;
// while(1){
// mdio_init(SPI,SPI_CS);
//
// u16 control = mdio_read(SPI, SPI_CS, 1, 0);
// u16 status = mdio_read(SPI, SPI_CS, 1, 1);
// u16 id1 = mdio_read(SPI, SPI_CS, 1, 2);
// u16 id2 = mdio_read(SPI, SPI_CS, 1, 3);
// mdio_write(SPI, SPI_CS, 1, 0, control | 0x0200);
// while(1){
// control = mdio_read(SPI, SPI_CS, 1, 1);
// bsp_uDelay(50000);
// }
//
// asm("nop");
// }
bsp_putString("done");
}
|
66b9249af6e4175cd3c3d78ec01235c28180ef4f
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/os/board/rtl8730e/src/component/soc/amebad2/atf/include/drivers/console.h
|
761816ac74310795fa261711cd5fcf97012d1ea7
|
[
"GPL-1.0-or-later",
"BSD-3-Clause",
"ISC",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"Apache-2.0"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 2,943
|
h
|
console.h
|
/*
* Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef CONSOLE_H
#define CONSOLE_H
#include <lib/utils_def.h>
#define CONSOLE_T_NEXT (U(0) * REGSZ)
#define CONSOLE_T_FLAGS (U(1) * REGSZ)
#define CONSOLE_T_PUTC (U(2) * REGSZ)
#define CONSOLE_T_GETC (U(3) * REGSZ)
#define CONSOLE_T_FLUSH (U(4) * REGSZ)
#define CONSOLE_T_BASE (U(5) * REGSZ)
#define CONSOLE_T_DRVDATA (U(6) * REGSZ)
#define CONSOLE_FLAG_BOOT (U(1) << 0)
#define CONSOLE_FLAG_RUNTIME (U(1) << 1)
#define CONSOLE_FLAG_CRASH (U(1) << 2)
/* Bits 3 to 7 reserved for additional scopes in future expansion. */
#define CONSOLE_FLAG_SCOPE_MASK ((U(1) << 8) - 1)
/* Bits 8 to 31 for non-scope use. */
#define CONSOLE_FLAG_TRANSLATE_CRLF (U(1) << 8)
/* Returned by getc callbacks when receive FIFO is empty. */
#define ERROR_NO_PENDING_CHAR (-1)
/* Returned by console_xxx() if no registered console implements xxx. */
#define ERROR_NO_VALID_CONSOLE (-128)
#ifndef __ASSEMBLER__
#include <stdint.h>
typedef struct console {
struct console *next;
/*
* Only the low 32 bits are used. The type is u_register_t to align the
* fields of the struct to 64 bits in AArch64 and 32 bits in AArch32
*/
u_register_t flags;
int (*const putc)(int character, struct console *console);
int (*const getc)(struct console *console);
int (*const flush)(struct console *console);
uintptr_t base;
/* Additional private driver data may follow here. */
} console_t;
/* offset macro assertions for console_t */
#include <drivers/console_assertions.h>
/*
* Add a console_t instance to the console list. This should only be called by
* console drivers after they have initialized all fields in the console
* structure. Platforms seeking to register a new console need to call the
* respective console__register() function instead.
*/
int console_register(console_t *console);
/* Remove a single console_t instance from the console list. Return a pointer to
* the console that was removed if it was found, or NULL if not. */
console_t *console_unregister(console_t *console);
/* Returns 1 if this console is already registered, 0 if not */
int console_is_registered(console_t *console);
/*
* Set scope mask of a console that determines in what states it is active.
* By default they are registered with (CONSOLE_FLAG_BOOT|CONSOLE_FLAG_CRASH).
*/
void console_set_scope(console_t *console, unsigned int scope);
/* Switch to a new global console state (CONSOLE_FLAG_BOOT/RUNTIME/CRASH). */
void console_switch_state(unsigned int new_state);
/* Output a character on all consoles registered for the current state. */
int console_putc(int c);
/* Read a character (blocking) from any console registered for current state. */
int console_getc(void);
/* Flush all consoles registered for the current state. */
int console_flush(void);
#endif /* __ASSEMBLER__ */
#endif /* CONSOLE_H */
|
1d3ade3c105d29815c3414cf90a358b01f8db832
|
ae90aa32e949a5eab9665f526f886f05860161d2
|
/code/c/cadvance/bits/bits.c
|
7a34983593c2b40d6895da2a37e73a1ccd67012a
|
[
"CC-BY-SA-3.0",
"MIT"
] |
permissive
|
cccbook/sp
|
4097ab760cfb013b689dc4739a439de29d85d324
|
aff23e6b18ba6221022b14b024fd562427c46d9a
|
refs/heads/master
| 2022-05-22T03:31:33.324045
| 2019-06-06T07:04:37
| 2019-06-06T07:04:37
| 156,299,694
| 257
| 96
|
MIT
| 2022-03-19T08:48:32
| 2018-11-05T23:56:37
|
Assembly
|
UTF-8
|
C
| false
| false
| 280
|
c
|
bits.c
|
// 參考: https://github.com/cccbook/bottomupcs/wiki/02-binary
#include <stdio.h>
int main(int argc, char *argv[])
{
unsigned char mask = 0x0F;
unsigned char data = 0xA5;
unsigned char maskData = mask & data;
printf("%02x & %02x = %02x\n", data, mask, maskData);
}
|
02893c61529ee13782910a8c51a2894de952c77e
|
b732361d6b3405c3e79ac0a7d8361cf5b329b015
|
/ext/phalcon/cache/cachefactory.zep.h
|
dd359eabc2fda737238c9095546ec5a9d6c86f11
|
[
"BSD-3-Clause"
] |
permissive
|
phalcon/cphalcon
|
4a5b26f47b5c2a4107541d7fd73c595c0d90ed73
|
fc183e11e8b96c43daf7d893244846206dc2aa73
|
refs/heads/master
| 2023-03-07T22:09:48.814291
| 2023-02-28T16:45:15
| 2023-02-28T16:45:15
| 2,854,337
| 8,135
| 2,343
|
BSD-3-Clause
| 2023-09-12T12:41:13
| 2011-11-26T05:52:50
|
PHP
|
UTF-8
|
C
| false
| true
| 1,674
|
h
|
cachefactory.zep.h
|
extern zend_class_entry *phalcon_cache_cachefactory_ce;
ZEPHIR_INIT_CLASS(Phalcon_Cache_CacheFactory);
PHP_METHOD(Phalcon_Cache_CacheFactory, __construct);
PHP_METHOD(Phalcon_Cache_CacheFactory, load);
PHP_METHOD(Phalcon_Cache_CacheFactory, newInstance);
PHP_METHOD(Phalcon_Cache_CacheFactory, getExceptionClass);
ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_cache_cachefactory___construct, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, factory, Phalcon\\Cache\\AdapterFactory, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_cache_cachefactory_load, 0, 1, Phalcon\\Cache\\CacheInterface, 0)
ZEND_ARG_INFO(0, config)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_cache_cachefactory_newinstance, 0, 1, Phalcon\\Cache\\CacheInterface, 0)
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
#else
ZEND_ARG_ARRAY_INFO(0, options, 0)
#endif
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_cache_cachefactory_getexceptionclass, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(phalcon_cache_cachefactory_method_entry) {
PHP_ME(Phalcon_Cache_CacheFactory, __construct, arginfo_phalcon_cache_cachefactory___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(Phalcon_Cache_CacheFactory, load, arginfo_phalcon_cache_cachefactory_load, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Cache_CacheFactory, newInstance, arginfo_phalcon_cache_cachefactory_newinstance, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Cache_CacheFactory, getExceptionClass, arginfo_phalcon_cache_cachefactory_getexceptionclass, ZEND_ACC_PROTECTED)
PHP_FE_END
};
|
e3eb941176801220607189e90cd27d67379d85cc
|
a5f3b0001cdb692aeffc444a16f79a0c4422b9d0
|
/main/cppu/inc/typelib/uik.h
|
e522c0858a46137d2c544f358591bc978c13b43c
|
[
"Apache-2.0",
"CPL-1.0",
"bzip2-1.0.6",
"LicenseRef-scancode-other-permissive",
"Zlib",
"LZMA-exception",
"LGPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-philippe-de-muyter",
"OFL-1.1",
"LGPL-2.1-only",
"MPL-1.1",
"X11",
"LGPL-2.1-or-later",
"GPL-2.0-only",
"OpenSSL",
"LicenseRef-scancode-cpl-0.5",
"GPL-1.0-or-later",
"NPL-1.1",
"MIT",
"MPL-2.0",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-unknown-license-reference",
"MPL-1.0",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"BSL-1.0",
"LicenseRef-scancode-docbook",
"LicenseRef-scancode-mit-old-style",
"Python-2.0",
"BSD-3-Clause",
"IJG",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-2.0-or-later",
"LGPL-2.0-only",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown",
"BSD-2-Clause",
"Autoconf-exception-generic",
"PSF-2.0",
"NTP",
"LicenseRef-scancode-python-cwi",
"Afmparse",
"W3C",
"W3C-19980720",
"curl",
"LicenseRef-scancode-x11-xconsortium-veillard",
"Bitstream-Vera",
"HPND-sell-variant",
"ICU"
] |
permissive
|
apache/openoffice
|
b9518e36d784898c6c2ea3ebd44458a5e47825bb
|
681286523c50f34f13f05f7b87ce0c70e28295de
|
refs/heads/trunk
| 2023-08-30T15:25:48.357535
| 2023-08-28T19:50:26
| 2023-08-28T19:50:26
| 14,357,669
| 907
| 379
|
Apache-2.0
| 2023-08-16T20:49:37
| 2013-11-13T08:00:13
|
C++
|
UTF-8
|
C
| false
| false
| 1,418
|
h
|
uik.h
|
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef _TYPELIB_UIK_H_
#define _TYPELIB_UIK_H_
#include <sal/types.h>
#if defined( SAL_W32)
#pragma pack(push, 8)
#elif defined(SAL_OS2)
#pragma pack(push, 8)
#endif
/** Binary typelib uik struct. Internally not used anymore.
*/
typedef struct _typelib_Uik
{
sal_uInt32 m_Data1;
sal_uInt16 m_Data2;
sal_uInt16 m_Data3;
sal_uInt32 m_Data4;
sal_uInt32 m_Data5;
} typelib_Uik;
#if defined( SAL_W32) || defined(SAL_OS2)
# pragma pack(pop)
#endif
#endif
|
cad75ab1875a9e369679ccd2f913cd1c26ab9d43
|
3aa5f79c95dcdf57f881ce4bfa5f11a2a3d15176
|
/src/Blinker/BlinkerDataTicker.h
|
0202291ee09c0120f82a368d07a26c4ef183551c
|
[
"MIT"
] |
permissive
|
blinker-iot/blinker-library
|
726fae1b31d7c160d61c16bac74623ecc5a15874
|
10ff6172ef20e2c478bcbdf4ee7d73aef53d85c7
|
refs/heads/master
| 2023-08-21T20:50:12.755097
| 2023-05-10T12:12:24
| 2023-05-10T12:12:24
| 126,308,611
| 2,670
| 246
|
MIT
| 2023-05-10T12:12:19
| 2018-03-22T09:08:13
|
C++
|
UTF-8
|
C
| false
| false
| 639
|
h
|
BlinkerDataTicker.h
|
// #ifndef BlinkerDataTicker_H
// #define BlinkerDataTicker_H
// #if defined(ESP8266) || defined(ESP32)
// #include "Blinker/BlinkerConfig.h"
// #include "Blinker/BlinkerDebug.h"
// #include "Blinker/BlinkerTimer.h"
// #include <Ticker.h>
// Ticker dataTicker;
// bool _dataTrigged = false;
// uint32_t _data_time = 60;
// void dataInit(uint8_t mins, uint8_t seconds, uint32_t tickers = 60)
// {
// _data_time = tickers;
// if (_data_time == 60)
// {
// uint32_t tTime = _data_time - seconds;
// dataTicker.
// }
// }
// void dataHandle()
// {
// _dataTrigged = true;
// }
// #endif
// #endif
|
6d0d8fb61e311b8db9de840d306ce1fb1156c909
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/dev/i2c/at24cxx.c
|
6f525cfdd5c48bc74dd46c2c08a717c52ae4dae8
|
[] |
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
| 11,559
|
c
|
at24cxx.c
|
/* $NetBSD: at24cxx.c,v 1.41 2021/01/28 14:57:43 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Steve C. Woodford and Jason R. Thorpe for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.41 2021/01/28 14:57:43 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/fcntl.h>
#include <sys/uio.h>
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/event.h>
#include <sys/bus.h>
#include <dev/i2c/i2cvar.h>
#include <dev/i2c/at24cxxvar.h>
#include "ioconf.h"
/*
* AT24Cxx EEPROM I2C address:
* 101 0xxx
* (and others depending on the exact model) The bigger 8-bit parts
* decode multiple addresses. The bigger 16-bit parts do too (those
* larger than 512kb). Be sure to check the datasheet of your EEPROM
* because there's much variation between models.
*/
#define AT24CXX_ADDRMASK 0x3f8
#define AT24CXX_ADDR 0x50
#define AT24CXX_WRITE_CYCLE_MS 10
#define AT24CXX_ADDR_HI(a) (((a) >> 8) & 0xff)
#define AT24CXX_ADDR_LO(a) ((a) & 0xff)
#include "seeprom.h"
#if NSEEPROM > 0
struct seeprom_softc {
device_t sc_dev;
i2c_tag_t sc_tag;
int sc_address;
int sc_size;
int sc_cmdlen;
int sc_open;
};
static int seeprom_match(device_t, cfdata_t, void *);
static void seeprom_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(seeprom, sizeof(struct seeprom_softc),
seeprom_match, seeprom_attach, NULL, NULL);
dev_type_open(seeprom_open);
dev_type_close(seeprom_close);
dev_type_read(seeprom_read);
dev_type_write(seeprom_write);
const struct cdevsw seeprom_cdevsw = {
.d_open = seeprom_open,
.d_close = seeprom_close,
.d_read = seeprom_read,
.d_write = seeprom_write,
.d_ioctl = noioctl,
.d_stop = nostop,
.d_tty = notty,
.d_poll = nopoll,
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
.d_discard = nodiscard,
.d_flag = D_OTHER
};
static int seeprom_wait_idle(struct seeprom_softc *);
static const struct device_compatible_entry compat_data[] = {
{ .compat = "i2c-at24c01", .value = 128 },
{ .compat = "i2c-at24c02", .value = 256 },
{ .compat = "i2c-at24c04", .value = 512 },
{ .compat = "i2c-at24c08", .value = 1024 },
{ .compat = "i2c-at24c16", .value = 2048 },
{ .compat = "i2c-at24c32", .value = 4096 },
{ .compat = "i2c-at24c64", .value = 8192 },
{ .compat = "i2c-at24c128", .value = 16384 },
{ .compat = "i2c-at24c256", .value = 32768 },
{ .compat = "i2c-at24c512", .value = 65536 },
{ .compat = "i2c-at34c02", .value = 256 },
{ .compat = "atmel,24c02", .value = 256 },
{ .compat = "atmel,24c16", .value = 2048 },
{ .compat = "atmel,24c256", .value = 32768 },
DEVICE_COMPAT_EOL
};
static int
seeprom_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
int match_result;
if (iic_use_direct_match(ia, cf, compat_data, &match_result))
return match_result;
if ((ia->ia_addr & AT24CXX_ADDRMASK) == AT24CXX_ADDR)
return I2C_MATCH_ADDRESS_ONLY;
return 0;
}
static void
seeprom_attach(device_t parent, device_t self, void *aux)
{
struct seeprom_softc *sc = device_private(self);
struct i2c_attach_args *ia = aux;
const struct device_compatible_entry *dce;
sc->sc_tag = ia->ia_tag;
sc->sc_address = ia->ia_addr;
sc->sc_dev = self;
if (ia->ia_name != NULL) {
aprint_naive(": %s", ia->ia_name);
aprint_normal(": %s", ia->ia_name);
} else {
aprint_naive(": EEPROM");
aprint_normal(": AT24Cxx or compatible EEPROM");
}
/*
* The AT24C01A/02/04/08/16 EEPROMs use a 1 byte command
* word to select the offset into the EEPROM page. The
* AT24C04/08/16 decode fewer of the i2c address bits,
* using the bottom 1, 2, or 3 to select the 256-byte
* super-page.
*
* The AT24C32/64/128/256/512 EEPROMs use a 2 byte command
* word and decode all of the i2c address bits.
*
* The AT24C1024 EEPROMs use a 2 byte command and also do bank
* switching to select the proper super-page. This isn't
* supported by this driver.
*/
if (device_cfdata(self)->cf_flags)
sc->sc_size = (device_cfdata(self)->cf_flags << 7);
if (sc->sc_size <= 0) {
if ((dce = iic_compatible_lookup(ia, compat_data)) != NULL)
sc->sc_size = dce->value;
}
switch (sc->sc_size) {
case 128: /* 1Kbit */
case 256: /* 2Kbit */
case 512: /* 4Kbit */
case 1024: /* 8Kbit */
case 2048: /* 16Kbit */
sc->sc_cmdlen = 1;
aprint_normal(": size %d\n", sc->sc_size);
break;
case 4096: /* 32Kbit */
case 8192: /* 64Kbit */
case 16384: /* 128Kbit */
case 32768: /* 256Kbit */
case 65536: /* 512Kbit */
sc->sc_cmdlen = 2;
aprint_normal(": size %d\n", sc->sc_size);
break;
default:
/*
* Default to 2KB. If we happen to have a 2KB
* EEPROM this will allow us to access it. If we
* have a smaller one, the worst that can happen
* is that we end up trying to read a different
* EEPROM on the bus when accessing it.
*
* Obviously this will not work for 4KB or 8KB
* EEPROMs, but them's the breaks.
*/
aprint_normal("\n");
aprint_error_dev(self, "invalid size specified; "
"assuming 2KB (16Kb)\n");
sc->sc_size = 2048;
sc->sc_cmdlen = 1;
}
sc->sc_open = 0;
}
/*ARGSUSED*/
int
seeprom_open(dev_t dev, int flag, int fmt, struct lwp *l)
{
struct seeprom_softc *sc;
if ((sc = device_lookup_private(&seeprom_cd, minor(dev))) == NULL)
return (ENXIO);
/* XXX: Locking */
if (sc->sc_open)
return (EBUSY);
sc->sc_open = 1;
return (0);
}
/*ARGSUSED*/
int
seeprom_close(dev_t dev, int flag, int fmt, struct lwp *l)
{
struct seeprom_softc *sc;
if ((sc = device_lookup_private(&seeprom_cd, minor(dev))) == NULL)
return (ENXIO);
sc->sc_open = 0;
return (0);
}
/*ARGSUSED*/
int
seeprom_read(dev_t dev, struct uio *uio, int flags)
{
struct seeprom_softc *sc;
i2c_addr_t addr;
u_int8_t ch, cmdbuf[2];
int a, error;
if ((sc = device_lookup_private(&seeprom_cd, minor(dev))) == NULL)
return (ENXIO);
if (uio->uio_offset >= sc->sc_size)
return (EINVAL);
/*
* Even though the AT24Cxx EEPROMs support sequential
* reads within a page, some I2C controllers do not
* support anything other than single-byte transfers,
* so we're stuck with this lowest-common-denominator.
*/
while (uio->uio_resid > 0 && uio->uio_offset < sc->sc_size) {
a = (int)uio->uio_offset;
if (sc->sc_cmdlen == 1) {
addr = sc->sc_address + (a >> 8);
cmdbuf[0] = a & 0xff;
} else {
addr = sc->sc_address;
cmdbuf[0] = AT24CXX_ADDR_HI(a);
cmdbuf[1] = AT24CXX_ADDR_LO(a);
}
if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0)
return (error);
if ((error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
addr, cmdbuf, sc->sc_cmdlen,
&ch, 1, 0)) != 0) {
iic_release_bus(sc->sc_tag, 0);
aprint_error_dev(sc->sc_dev,
"seeprom_read: byte read failed at 0x%x\n", a);
return (error);
}
iic_release_bus(sc->sc_tag, 0);
if ((error = uiomove(&ch, 1, uio)) != 0) {
return (error);
}
}
return (0);
}
/*ARGSUSED*/
int
seeprom_write(dev_t dev, struct uio *uio, int flags)
{
struct seeprom_softc *sc;
i2c_addr_t addr;
u_int8_t ch, cmdbuf[2];
int a, error;
if ((sc = device_lookup_private(&seeprom_cd, minor(dev))) == NULL)
return (ENXIO);
if (uio->uio_offset >= sc->sc_size)
return (EINVAL);
/*
* See seeprom_read() for why we don't use sequential
* writes within a page.
*/
while (uio->uio_resid > 0 && uio->uio_offset < sc->sc_size) {
a = (int)uio->uio_offset;
if (sc->sc_cmdlen == 1) {
addr = sc->sc_address + (a >> 8);
cmdbuf[0] = a & 0xff;
} else {
addr = sc->sc_address;
cmdbuf[0] = AT24CXX_ADDR_HI(a);
cmdbuf[1] = AT24CXX_ADDR_LO(a);
}
if ((error = uiomove(&ch, 1, uio)) != 0) {
iic_release_bus(sc->sc_tag, 0);
return (error);
}
if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0)
return (error);
if ((error = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
addr, cmdbuf, sc->sc_cmdlen,
&ch, 1, 0)) != 0) {
iic_release_bus(sc->sc_tag, 0);
aprint_error_dev(sc->sc_dev,
"seeprom_write: byte write failed at 0x%x\n", a);
return (error);
}
iic_release_bus(sc->sc_tag, 0);
/* Wait until the device commits the byte. */
if ((error = seeprom_wait_idle(sc)) != 0) {
return (error);
}
}
return (0);
}
static int
seeprom_wait_idle(struct seeprom_softc *sc)
{
uint8_t cmdbuf[2] = { 0, 0 };
int rv, timeout;
u_int8_t dummy;
int error;
timeout = (1000 / hz) / AT24CXX_WRITE_CYCLE_MS;
if (timeout == 0)
timeout = 1;
delay(10);
/*
* Read the byte at address 0. This is just a dummy
* read to wait for the EEPROM's write cycle to complete.
*/
for (;;) {
if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0)
return error;
error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
sc->sc_address, cmdbuf, sc->sc_cmdlen, &dummy, 1, 0);
iic_release_bus(sc->sc_tag, 0);
if (error == 0)
break;
rv = kpause("seepromwr", true, timeout, NULL);
if (rv != EWOULDBLOCK && rv != 0)
return (rv);
}
return (0);
}
#endif /* NSEEPROM > 0 */
int
seeprom_bootstrap_read(i2c_tag_t tag, int i2caddr, int offset, int devsize,
u_int8_t *rvp, size_t len)
{
i2c_addr_t addr;
int cmdlen;
uint8_t cmdbuf[2];
if (len == 0)
return (0);
/* We are very forgiving about devsize during bootstrap. */
cmdlen = (devsize >= 4096) ? 2 : 1;
if (iic_acquire_bus(tag, 0) != 0)
return (-1);
while (len) {
if (cmdlen == 1) {
addr = i2caddr + (offset >> 8);
cmdbuf[0] = offset & 0xff;
} else {
addr = i2caddr;
cmdbuf[0] = AT24CXX_ADDR_HI(offset);
cmdbuf[1] = AT24CXX_ADDR_LO(offset);
}
/* Read a single byte. */
if (iic_exec(tag, I2C_OP_READ_WITH_STOP, addr,
cmdbuf, cmdlen, rvp, 1, 0)) {
iic_release_bus(tag, 0);
return (-1);
}
len--;
rvp++;
offset++;
}
iic_release_bus(tag, 0);
return (0);
}
|
bd159a2ed930d4a0f2ee7b92b2e4ab25f5cb9d94
|
b2d5907cb1777f897154eb408b67240e30af26a6
|
/tests/code_quality/unsafe.c
|
125252ba5b8c69bbc50b2a0374a67ca67caf3386
|
[
"MIT"
] |
permissive
|
Konstantin8105/c4go
|
494dc7696cecf71228c1d80350f1a11916887148
|
c5400a76df0f5157f234547bef3ae8fb7b692685
|
refs/heads/master
| 2023-08-16T20:14:09.217497
| 2023-08-16T13:18:51
| 2023-08-16T13:18:51
| 127,093,867
| 380
| 48
|
MIT
| 2023-08-16T11:18:07
| 2018-03-28T06:24:57
|
C
|
UTF-8
|
C
| false
| false
| 785
|
c
|
unsafe.c
|
#define unsafetype(type, name) \
void name() \
{ \
type t; \
type* pt = &t; \
(void)(t); \
(void)(pt); \
}
struct str {
int i;
};
union un {
int i;
double d;
};
typedef double db;
// integers
unsafetype(char, test_char);
unsafetype(short, test_short);
unsafetype(int, test_int);
unsafetype(long, test_long);
unsafetype(long int, test_li);
unsafetype(long long, test_ll);
unsafetype(long long int, test_lli);
// floats
unsafetype(float, test_f);
unsafetype(double, test_d);
unsafetype(long double, test_ld);
// struct
unsafetype(struct str, test_struct);
// union
unsafetype(union un, test_un);
// typedef
unsafetype(db, test_typedef);
|
989521af710cb18ceff6316f985f4becdb785459
|
6223530200223fd0add9a081a25cb6daf3a8d3c3
|
/examples/generators/pjex/pjex0.c
|
59ac77f95001eb1dc211dca956bfb3d29df20d65
|
[
"MIT",
"LicenseRef-scancode-dco-1.1"
] |
permissive
|
Boolector/boolector
|
959aec7715c3122763f803733f0af4f6124801d9
|
13a8a06d561041cafcaf5458e404c1ec354b2841
|
refs/heads/master
| 2023-06-08T03:52:44.634825
| 2023-01-10T22:48:06
| 2023-01-10T22:48:06
| 134,006,909
| 280
| 58
|
NOASSERTION
| 2023-09-11T23:31:41
| 2018-05-18T21:44:21
|
SMT
|
UTF-8
|
C
| false
| false
| 1,938
|
c
|
pjex0.c
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main (int argc, char** argv)
{
int d = -1, w, i, sat = 0;
for (i = 1; i < argc; i++)
{
if (!strcmp (argv[i], "-h"))
{
printf ("usage: pjex [-h][-s|--sat] <num-bits>\n");
exit (0);
}
if (!strcmp (argv[i], "-s") || !strcmp (argv[i], "--sat"))
sat = 1;
else if (argv[i][0] == '-')
{
fprintf (stderr, "*** pjex: invalid option '%s'\n", argv[i]);
printf ("usage: pjex [-h][-s|--sat] <num-bits>\n");
exit (1);
}
else if (d > 0)
{
fprintf (stderr, "*** pjex: multiple '<num-bits>' options\n");
printf ("usage: pjex [-h][-s|--sat] <num-bits>\n");
exit (1);
}
else if ((d = atoi (argv[i])) <= 1)
{
fprintf (stderr, "*** pjex: argument '%s' invalid\n", argv[i]);
printf ("usage: pjex [-h][-s|--sat] <num-bits>\n");
exit (1);
}
}
if (d < 0)
{
fprintf (stderr, "*** pjex: argument missing\n");
printf ("usage: pjex [-h][-s|--sat] <num-bits>\n");
exit (1);
}
printf ("; Variant of Pete Jeavons Example CSP example\n");
w = 1;
while ((1 << (w - 1)) <= d) w++;
printf ("; d = %d, w = %d\n", d, w);
printf ("(set-logic QF_BV)\n");
printf ("(declare-fun ub () (_ BitVec %d))\n", w);
for (i = 0; i <= 2 * d - 1; i++)
printf ("(declare-fun x1a%d () (_ BitVec %d))\n", i, w),
printf ("(declare-fun x2a%d () (_ BitVec %d))\n", i, w);
printf ("(assert (= ub (_ bv%d %d)))\n", d, w);
for (i = 0; i <= 2 * d - 1; i++)
printf ("(assert (bvult x1a%d ub))\n", i),
printf ("(assert (bvult x2a%d ub))\n", i);
for (i = 0; i < 2 * d - 1; i++)
{
if (i == 2 * d - 2 && sat) printf (";");
printf ("(assert (bvult (bvadd x1a%d x2a%d) (bvadd x1a%d x2a%d)))\n",
i,
i,
i + 1,
i + 1);
}
printf ("(check-sat)\n");
printf ("(exit)\n");
return 0;
}
|
7c5e708b627f144c752f21032f25203e201b1f21
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/hc32/libraries/hc32f460_ddl/drivers/hc32_ll_driver/inc/hc32f460_ll_interrupts_share.h
|
7d26a9718c254cf550e16c3da8200dc87d06c918
|
[
"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
| 10,814
|
h
|
hc32f460_ll_interrupts_share.h
|
/**
*******************************************************************************
* @file hc32f460_ll_interrupts_share.h
* @brief This file contains all the functions prototypes of the interrupt driver
* library.
@verbatim
Change Logs:
Date Author Notes
2022-03-31 CDT First version
@endverbatim
*******************************************************************************
* Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
*
* This software component is licensed by XHSC under BSD 3-Clause license
* (the "License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
*******************************************************************************
*/
#ifndef __HC32F460_LL_INTERRUPTS_SHARE_H__
#define __HC32F460_LL_INTERRUPTS_SHARE_H__
/* C binding of definitions if building with C++ compiler */
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
* Include files
******************************************************************************/
#include "hc32_ll_def.h"
#include "hc32f4xx.h"
#include "hc32f4xx_conf.h"
/**
* @addtogroup LL_Driver
* @{
*/
/**
* @addtogroup LL_HC32F460_SHARE_INTERRUPTS
* @{
*/
#if (LL_INTERRUPTS_SHARE_ENABLE == DDL_ON)
/*******************************************************************************
* Global type definitions ('typedef')
******************************************************************************/
/*******************************************************************************
* Global pre-processor symbols/macros ('#define')
******************************************************************************/
/*******************************************************************************
* Global variable definitions ('extern')
******************************************************************************/
/*******************************************************************************
Global function prototypes (definition in C source)
******************************************************************************/
/**
* @addtogroup Share_Interrupts_Global_Functions
* @{
*/
int32_t INTC_ShareIrqCmd(en_int_src_t enIntSrc, en_functional_state_t enNewState);
void IRQ128_Handler(void);
void IRQ129_Handler(void);
void IRQ130_Handler(void);
void IRQ131_Handler(void);
void IRQ132_Handler(void);
void IRQ136_Handler(void);
void IRQ137_Handler(void);
void IRQ138_Handler(void);
void IRQ139_Handler(void);
void IRQ140_Handler(void);
void IRQ141_Handler(void);
void IRQ142_Handler(void);
void IRQ143_Handler(void);
void EXTINT00_IrqHandler(void);
void EXTINT01_IrqHandler(void);
void EXTINT02_IrqHandler(void);
void EXTINT03_IrqHandler(void);
void EXTINT04_IrqHandler(void);
void EXTINT05_IrqHandler(void);
void EXTINT06_IrqHandler(void);
void EXTINT07_IrqHandler(void);
void EXTINT08_IrqHandler(void);
void EXTINT09_IrqHandler(void);
void EXTINT10_IrqHandler(void);
void EXTINT11_IrqHandler(void);
void EXTINT12_IrqHandler(void);
void EXTINT13_IrqHandler(void);
void EXTINT14_IrqHandler(void);
void EXTINT15_IrqHandler(void);
void DMA1_TC0_IrqHandler(void);
void DMA1_TC1_IrqHandler(void);
void DMA1_TC2_IrqHandler(void);
void DMA1_TC3_IrqHandler(void);
void DMA2_TC0_IrqHandler(void);
void DMA2_TC1_IrqHandler(void);
void DMA2_TC2_IrqHandler(void);
void DMA2_TC3_IrqHandler(void);
void DMA1_BTC0_IrqHandler(void);
void DMA1_BTC1_IrqHandler(void);
void DMA1_BTC2_IrqHandler(void);
void DMA1_BTC3_IrqHandler(void);
void DMA2_BTC0_IrqHandler(void);
void DMA2_BTC1_IrqHandler(void);
void DMA2_BTC2_IrqHandler(void);
void DMA2_BTC3_IrqHandler(void);
void DMA1_Error0_IrqHandler(void);
void DMA1_Error1_IrqHandler(void);
void DMA1_Error2_IrqHandler(void);
void DMA1_Error3_IrqHandler(void);
void DMA2_Error0_IrqHandler(void);
void DMA2_Error1_IrqHandler(void);
void DMA2_Error2_IrqHandler(void);
void DMA2_Error3_IrqHandler(void);
void EFM_ProgramEraseError_IrqHandler(void);
void EFM_ColError_IrqHandler(void);
void EFM_OpEnd_IrqHandler(void);
void QSPI_Error_IrqHandler(void);
void DCU1_IrqHandler(void);
void DCU2_IrqHandler(void);
void DCU3_IrqHandler(void);
void DCU4_IrqHandler(void);
void TMR0_1_CmpA_IrqHandler(void);
void TMR0_1_CmpB_IrqHandler(void);
void TMR0_2_CmpA_IrqHandler(void);
void TMR0_2_CmpB_IrqHandler(void);
void CLK_XtalStop_IrqHandler(void);
void PWC_WakeupTimer_IrqHandler(void);
void SWDT_IrqHandler(void);
void WDT_IrqHandler(void);
void TMR6_1_GCmpA_IrqHandler(void);
void TMR6_1_GCmpB_IrqHandler(void);
void TMR6_1_GCmpC_IrqHandler(void);
void TMR6_1_GCmpD_IrqHandler(void);
void TMR6_1_GCmpE_IrqHandler(void);
void TMR6_1_GCmpF_IrqHandler(void);
void TMR6_1_GOvf_IrqHandler(void);
void TMR6_1_GUdf_IrqHandler(void);
void TMR6_1_GDte_IrqHandler(void);
void TMR6_1_SCmpA_IrqHandler(void);
void TMR6_1_SCmpB_IrqHandler(void);
void TMR6_2_GCmpA_IrqHandler(void);
void TMR6_2_GCmpB_IrqHandler(void);
void TMR6_2_GCmpC_IrqHandler(void);
void TMR6_2_GCmpD_IrqHandler(void);
void TMR6_2_GCmpE_IrqHandler(void);
void TMR6_2_GCmpF_IrqHandler(void);
void TMR6_2_GOvf_IrqHandler(void);
void TMR6_2_GUdf_IrqHandler(void);
void TMR6_2_GDte_IrqHandler(void);
void TMR6_2_SCmpA_IrqHandler(void);
void TMR6_2_SCmpB_IrqHandler(void);
void TMR6_3_GCmpA_IrqHandler(void);
void TMR6_3_GCmpB_IrqHandler(void);
void TMR6_3_GCmpC_IrqHandler(void);
void TMR6_3_GCmpD_IrqHandler(void);
void TMR6_3_GCmpE_IrqHandler(void);
void TMR6_3_GCmpF_IrqHandler(void);
void TMR6_3_GOvf_IrqHandler(void);
void TMR6_3_GUdf_IrqHandler(void);
void TMR6_3_GDte_IrqHandler(void);
void TMR6_3_SCmpA_IrqHandler(void);
void TMR6_3_SCmpB_IrqHandler(void);
void TMRA_1_Ovf_IrqHandler(void);
void TMRA_1_Udf_IrqHandler(void);
void TMRA_1_Cmp_IrqHandler(void);
void TMRA_2_Ovf_IrqHandler(void);
void TMRA_2_Udf_IrqHandler(void);
void TMRA_2_Cmp_IrqHandler(void);
void TMRA_3_Ovf_IrqHandler(void);
void TMRA_3_Udf_IrqHandler(void);
void TMRA_3_Cmp_IrqHandler(void);
void TMRA_4_Ovf_IrqHandler(void);
void TMRA_4_Udf_IrqHandler(void);
void TMRA_4_Cmp_IrqHandler(void);
void TMRA_5_Ovf_IrqHandler(void);
void TMRA_5_Udf_IrqHandler(void);
void TMRA_5_Cmp_IrqHandler(void);
void TMRA_6_Ovf_IrqHandler(void);
void TMRA_6_Udf_IrqHandler(void);
void TMRA_6_Cmp_IrqHandler(void);
void USBFS_Global_IrqHandler(void);
void USART1_RxError_IrqHandler(void);
void USART1_RxFull_IrqHandler(void);
void USART1_TxEmpty_IrqHandler(void);
void USART1_TxComplete_IrqHandler(void);
void USART1_RxTO_IrqHandler(void);
void USART2_RxError_IrqHandler(void);
void USART2_RxFull_IrqHandler(void);
void USART2_TxEmpty_IrqHandler(void);
void USART2_TxComplete_IrqHandler(void);
void USART2_RxTO_IrqHandler(void);
void USART3_RxError_IrqHandler(void);
void USART3_RxFull_IrqHandler(void);
void USART3_TxEmpty_IrqHandler(void);
void USART3_TxComplete_IrqHandler(void);
void USART3_RxTO_IrqHandler(void);
void USART4_RxError_IrqHandler(void);
void USART4_RxFull_IrqHandler(void);
void USART4_TxEmpty_IrqHandler(void);
void USART4_TxComplete_IrqHandler(void);
void USART4_RxTO_IrqHandler(void);
void SPI1_RxFull_IrqHandler(void);
void SPI1_TxEmpty_IrqHandler(void);
void SPI1_Error_IrqHandler(void);
void SPI1_Idle_IrqHandler(void);
void SPI2_RxFull_IrqHandler(void);
void SPI2_TxEmpty_IrqHandler(void);
void SPI2_Error_IrqHandler(void);
void SPI2_Idle_IrqHandler(void);
void SPI3_RxFull_IrqHandler(void);
void SPI3_TxEmpty_IrqHandler(void);
void SPI3_Error_IrqHandler(void);
void SPI3_Idle_IrqHandler(void);
void SPI4_RxFull_IrqHandler(void);
void SPI4_TxEmpty_IrqHandler(void);
void SPI4_Error_IrqHandler(void);
void SPI4_Idle_IrqHandler(void);
void TMR4_1_GCmpUH_IrqHandler(void);
void TMR4_1_GCmpUL_IrqHandler(void);
void TMR4_1_GCmpVH_IrqHandler(void);
void TMR4_1_GCmpVL_IrqHandler(void);
void TMR4_1_GCmpWH_IrqHandler(void);
void TMR4_1_GCmpWL_IrqHandler(void);
void TMR4_1_GOvf_IrqHandler(void);
void TMR4_1_GUdf_IrqHandler(void);
void TMR4_1_ReloadU_IrqHandler(void);
void TMR4_1_ReloadV_IrqHandler(void);
void TMR4_1_ReloadW_IrqHandler(void);
void TMR4_2_GCmpUH_IrqHandler(void);
void TMR4_2_GCmpUL_IrqHandler(void);
void TMR4_2_GCmpVH_IrqHandler(void);
void TMR4_2_GCmpVL_IrqHandler(void);
void TMR4_2_GCmpWH_IrqHandler(void);
void TMR4_2_GCmpWL_IrqHandler(void);
void TMR4_2_GOvf_IrqHandler(void);
void TMR4_2_GUdf_IrqHandler(void);
void TMR4_2_ReloadU_IrqHandler(void);
void TMR4_2_ReloadV_IrqHandler(void);
void TMR4_2_ReloadW_IrqHandler(void);
void TMR4_3_GCmpUH_IrqHandler(void);
void TMR4_3_GCmpUL_IrqHandler(void);
void TMR4_3_GCmpVH_IrqHandler(void);
void TMR4_3_GCmpVL_IrqHandler(void);
void TMR4_3_GCmpWH_IrqHandler(void);
void TMR4_3_GCmpWL_IrqHandler(void);
void TMR4_3_GOvf_IrqHandler(void);
void TMR4_3_GUdf_IrqHandler(void);
void TMR4_3_ReloadU_IrqHandler(void);
void TMR4_3_ReloadV_IrqHandler(void);
void TMR4_3_ReloadW_IrqHandler(void);
void EMB_GR0_IrqHandler(void);
void EMB_GR1_IrqHandler(void);
void EMB_GR2_IrqHandler(void);
void EMB_GR3_IrqHandler(void);
void I2S1_Tx_IrqHandler(void);
void I2S1_Rx_IrqHandler(void);
void I2S1_Error_IrqHandler(void);
void I2S2_Tx_IrqHandler(void);
void I2S2_Rx_IrqHandler(void);
void I2S2_Error_IrqHandler(void);
void I2S3_Tx_IrqHandler(void);
void I2S3_Rx_IrqHandler(void);
void I2S3_Error_IrqHandler(void);
void I2S4_Tx_IrqHandler(void);
void I2S4_Rx_IrqHandler(void);
void I2S4_Error_IrqHandler(void);
void I2C1_RxFull_IrqHandler(void);
void I2C1_TxComplete_IrqHandler(void);
void I2C1_TxEmpty_IrqHandler(void);
void I2C1_Error_IrqHandler(void);
void I2C2_RxFull_IrqHandler(void);
void I2C2_TxComplete_IrqHandler(void);
void I2C2_TxEmpty_IrqHandler(void);
void I2C2_Error_IrqHandler(void);
void I2C3_RxFull_IrqHandler(void);
void I2C3_TxComplete_IrqHandler(void);
void I2C3_TxEmpty_IrqHandler(void);
void I2C3_Error_IrqHandler(void);
void PWC_LVD1_IrqHandler(void);
void PWC_LVD2_IrqHandler(void);
void FCM_Error_IrqHandler(void);
void FCM_End_IrqHandler(void);
void FCM_Ovf_IrqHandler(void);
void ADC1_SeqA_IrqHandler(void);
void ADC1_SeqB_IrqHandler(void);
void ADC1_ChCmp_IrqHandler(void);
void ADC1_SeqCmp_IrqHandler(void);
void ADC2_SeqA_IrqHandler(void);
void ADC2_SeqB_IrqHandler(void);
void ADC2_ChCmp_IrqHandler(void);
void ADC2_SeqCmp_IrqHandler(void);
void SDIOC1_IrqHandler(void);
void SDIOC2_IrqHandler(void);
void CAN_IrqHandler(void);
/**
* @}
*/
#endif /* LL_INTERRUPTS_SHARE_ENABLE */
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __HC32F4A0_LL_INTERRUPTS_SHARE_H__ */
/*******************************************************************************
* EOF (not truncated)
******************************************************************************/
|
ff8842d1df8892e7af9df10fee85030865d30cb8
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/crypto/adiantum/adiantum_selftest.c
|
3e7bc8983a9a07acf94d3d8c61f4a4c90e4788a9
|
[] |
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
| 79,422
|
c
|
adiantum_selftest.c
|
/* $NetBSD: adiantum_selftest.c,v 1.1 2020/06/29 23:44:01 riastradh Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: adiantum_selftest.c,v 1.1 2020/06/29 23:44:01 riastradh Exp $");
#include <sys/types.h>
#ifdef _KERNEL
#include <sys/systm.h>
#include <lib/libkern/libkern.h>
#else
#include <string.h>
#include <stdio.h>
#include <openssl/aes.h>
struct aesenc {
AES_KEY enckey;
};
struct aesdec {
AES_KEY deckey;
};
static void
hexdump(int (*prf)(const char *, ...) __printflike(1,2), const char *prefix,
const void *buf, size_t len)
{
const uint8_t *p = buf;
size_t i;
(*prf)("%s (%zu bytes)\n", prefix, len);
for (i = 0; i < len; i++) {
if (i % 16 == 8)
(*prf)(" ");
else
(*prf)(" ");
(*prf)("%02hhx", p[i]);
if ((i + 1) % 16 == 0)
(*prf)("\n");
}
if (i % 16)
(*prf)("\n");
}
#endif
#include "adiantum.h"
/* https://github.com/google/adiantum/blob/aab35db7bfb6e05d5ad0b41b5088a9f5a840bde3/test_vectors/ours/Adiantum/Adiantum_XChaCha12_32_AES256.json */
int
adiantum_selftest(void)
{
static const struct {
uint8_t k[32];
unsigned tlen;
uint8_t t[64];
unsigned len;
uint8_t p[4096];
uint8_t c[4096];
} C[] = {
[0] = {
.k = {
0x7f,0xc7,0x15,0x2a, 0xe1,0xf5,0xfd,0xa4,
0x17,0x67,0x69,0xae, 0xc9,0x2b,0xba,0x82,
0xa3,0x14,0xe7,0xcf, 0xad,0xfd,0x85,0x40,
0xda,0x7b,0x7d,0x24, 0xbd,0xf1,0x7d,0x07,
},
.tlen = 0,
.len = 16,
.p = {
0x9b,0xe3,0x82,0xc6, 0x5a,0xc1,0x9f,0xad,
0x46,0x59,0xb8,0x0b, 0xac,0xc8,0x57,0xa0,
},
.c = {
0x82,0x0a,0xe4,0x44, 0x77,0xdd,0x9a,0x18,
0x6f,0x80,0x28,0x8b, 0x25,0x07,0x0e,0x85,
},
},
[1] = {
.k = {
0x26,0x6a,0xf9,0x4a, 0x21,0x49,0x6b,0x4e,
0x3e,0xff,0x43,0x46, 0x9c,0xc1,0xfa,0x72,
0x0e,0x77,0x9a,0xd5, 0x37,0x47,0x00,0x38,
0xb3,0x6f,0x58,0x6c, 0xde,0xc0,0xa6,0x74,
},
.tlen = 0,
.len = 128,
.p = {
0xdd,0x07,0xfe,0x61, 0x97,0x0c,0x31,0x48,
0x09,0xbf,0xdb,0x9b, 0x4b,0x7d,0x9c,0x80,
0xe6,0x11,0xe5,0x76, 0x5b,0xcc,0x76,0xdf,
0x34,0xd5,0x23,0xcd, 0xe1,0xdc,0x4e,0x4f,
0x65,0x20,0x58,0x8e, 0xe8,0x2c,0xc2,0x64,
0x32,0x83,0x7a,0xbf, 0xe1,0xca,0x0b,0x4b,
0xc6,0xec,0x0d,0xc5, 0x4a,0xb6,0x9b,0xa5,
0xc4,0x01,0x54,0xf5, 0xb5,0xfa,0x8f,0x58,
0x45,0x72,0x28,0xd8, 0x55,0x21,0xa2,0x5c,
0x7d,0xc8,0x0c,0x3c, 0x3c,0x99,0xc4,0x1a,
0xc2,0xe7,0x1c,0x0c, 0x14,0x72,0x1d,0xf8,
0x45,0xb7,0x9c,0x97, 0x07,0x04,0x9b,0x91,
0x5e,0x95,0xef,0x5f, 0xe6,0xad,0xbd,0xbb,
0xe7,0xd1,0x22,0xc3, 0x98,0x44,0x89,0x05,
0xe8,0x63,0x0d,0x44, 0xcb,0x36,0xd5,0x43,
0xcc,0x05,0x7c,0x31, 0xd3,0xbc,0x17,0x7f,
},
.c = {
0xba,0xd3,0xbf,0xbf, 0xb2,0x4e,0x1a,0xfd,
0x59,0xbe,0x9d,0x40, 0xe0,0x27,0x94,0xdd,
0x5c,0x08,0x1c,0xa5, 0xd0,0x25,0x87,0xca,
0x15,0x6a,0x35,0xe9, 0x8a,0x05,0x67,0x53,
0x04,0x4d,0xdf,0x35, 0x07,0x19,0x25,0xa0,
0x44,0x1a,0x5b,0xd6, 0x8b,0x0f,0xd3,0x36,
0x8a,0x60,0x8c,0x6b, 0x53,0xdb,0x69,0xb0,
0x37,0x69,0xb5,0x1b, 0x1f,0xf5,0xd5,0xab,
0x47,0x3a,0x45,0xb2, 0x37,0x6c,0xc3,0xc1,
0x1f,0xdb,0x74,0x6b, 0x1f,0x3b,0x2c,0x1a,
0xee,0xff,0xe9,0x28, 0xfe,0xa3,0x49,0x96,
0x7a,0xb3,0x68,0x4e, 0xb1,0xc4,0x85,0xdc,
0x18,0x87,0xfd,0xbf, 0x84,0x39,0xb2,0x20,
0x29,0x46,0x8a,0x3e, 0xa9,0xf9,0xcc,0x56,
0x6b,0x2f,0x43,0x4a, 0x1b,0x48,0x6b,0xd6,
0x03,0x1d,0x66,0xa1, 0x49,0xba,0xe9,0xf5,
},
},
[2] = {
.k = {
0x7c,0xab,0xc4,0x63, 0xc0,0x40,0x5e,0xad,
0x8f,0x02,0x5a,0xa9, 0xba,0x68,0x58,0xe3,
0xb6,0xbb,0x03,0xc9, 0xe6,0x1e,0xe7,0xc3,
0xd7,0x2c,0xf7,0x7a, 0xf7,0x2c,0xd1,0x07,
},
.tlen = 0,
.len = 512,
.p = {
0x4f,0xc9,0x8f,0xa7, 0x81,0x81,0x3a,0xb7,
0x3c,0x55,0x8f,0x8f, 0x18,0xc4,0x7a,0xd2,
0x13,0x70,0x94,0x0f, 0x46,0xb2,0x0f,0x53,
0xde,0xdf,0x06,0xf8, 0x60,0x34,0xad,0x39,
0xe9,0x47,0x23,0x31, 0x94,0xf3,0x59,0x88,
0x96,0x14,0x52,0x3b, 0x88,0xb7,0x55,0xe9,
0x4a,0xbc,0x41,0xea, 0x24,0x03,0x35,0x78,
0xb7,0x4b,0x9f,0x8b, 0xe4,0x36,0x77,0x0a,
0x70,0x19,0x90,0x9b, 0xb1,0x70,0x27,0x23,
0x31,0xd9,0xe5,0x26, 0x36,0x71,0x06,0xc7,
0xd3,0xb1,0xb8,0x52, 0x6a,0xe1,0x95,0x86,
0x76,0xc3,0x02,0x2c, 0xd2,0xe7,0xc2,0x1c,
0x6f,0xcb,0x61,0x56, 0xfc,0x5e,0xf2,0x57,
0x90,0x46,0xfb,0x6a, 0xc1,0x5e,0x56,0x5b,
0x18,0x8d,0x0e,0x4f, 0x4e,0x14,0x4c,0x6d,
0x97,0xf9,0x73,0xed, 0xc5,0x41,0x94,0x24,
0xaa,0x35,0x2f,0x01, 0xef,0x8f,0xb2,0xfd,
0xc2,0xc7,0x8b,0x9c, 0x9b,0x10,0x89,0xec,
0x64,0xbb,0x54,0xa5, 0x01,0xdc,0x51,0x57,
0xc8,0x5a,0x03,0xcb, 0x91,0x73,0xb2,0x08,
0xc3,0xcc,0x3c,0x1b, 0xae,0x3e,0x0f,0xf3,
0x93,0xb9,0xc3,0x27, 0xd7,0x88,0x66,0xa2,
0x40,0xf9,0xfd,0x02, 0x61,0xe1,0x2b,0x5d,
0xc9,0xe8,0xd6,0xac, 0xf0,0xd0,0xe3,0x79,
0x94,0xff,0x50,0x09, 0x4e,0x68,0xe8,0x5e,
0x3f,0x58,0xc8,0xb8, 0x0f,0xd7,0xc2,0x2d,
0x91,0x3e,0x47,0x10, 0x50,0x98,0xa6,0xf9,
0x37,0xd6,0x90,0xed, 0xb7,0x5e,0x3a,0xd0,
0xd7,0x50,0xc4,0x69, 0xe6,0x29,0xb8,0x9a,
0xc1,0x5c,0x2b,0x34, 0x6d,0x44,0x58,0xd6,
0xd4,0x7e,0xe2,0x42, 0x67,0x45,0xe5,0x64,
0x48,0xac,0x00,0xe9, 0xb6,0xd0,0xc3,0xc5,
0x5d,0x9e,0x95,0x4e, 0x10,0x18,0x29,0x86,
0xaa,0x37,0xa3,0x3c, 0xe1,0xd6,0x5d,0x6d,
0x4a,0xca,0xc3,0xe2, 0x25,0xb7,0x49,0x4a,
0x36,0x67,0xc0,0xe1, 0x02,0x45,0xcc,0xd4,
0x11,0x37,0x11,0x8e, 0x54,0xf5,0xea,0x80,
0x04,0x72,0x06,0x36, 0x8f,0xf9,0x1e,0xed,
0x91,0x14,0x9d,0x42, 0x59,0xc1,0x87,0xb8,
0xf1,0xce,0xb2,0x17, 0x42,0xa1,0x2f,0x96,
0xa3,0x50,0xe9,0x01, 0x24,0x9e,0xe5,0xbb,
0x97,0x83,0x31,0x12, 0xa8,0x7c,0xca,0x7b,
0x90,0x33,0xad,0x1c, 0x99,0x81,0x1a,0xb8,
0xa1,0xe0,0xf1,0x5a, 0xbc,0x08,0xde,0xab,
0x69,0x0a,0x89,0xa0, 0x9f,0x02,0x5e,0x3a,
0xf3,0xba,0xb9,0x6e, 0x34,0xdf,0x15,0x13,
0x64,0x51,0xa9,0x55, 0x67,0xa3,0xba,0x6b,
0x35,0xb0,0x8a,0x05, 0xf5,0x79,0x84,0x97,
0x92,0x8e,0x11,0xeb, 0xef,0xec,0x65,0xb5,
0xe6,0x42,0xfb,0x06, 0x33,0x93,0x6b,0xff,
0xc2,0x49,0x15,0x71, 0xb0,0xca,0x62,0xd1,
0x81,0x40,0xd2,0xab, 0x0b,0x7d,0x7e,0x1a,
0xe9,0xec,0xfc,0xde, 0xdb,0xd5,0xa7,0x56,
0x83,0x25,0x0e,0x5e, 0xac,0x0c,0x42,0x26,
0x00,0x59,0x55,0x17, 0x8b,0x5a,0x03,0x7b,
0x85,0xe9,0xc1,0xa3, 0xe4,0xeb,0xd3,0xde,
0xd8,0x81,0xf5,0x31, 0x2c,0xda,0x21,0xbc,
0xb5,0xd9,0x7a,0xd0, 0x1e,0x2a,0x6b,0xcf,
0xad,0x06,0x3c,0xf2, 0xf7,0x5c,0x3a,0xf1,
0xa7,0x0f,0x5f,0x53, 0xe9,0x3f,0x3c,0xf1,
0xb7,0x47,0x53,0x16, 0x19,0xd9,0xef,0xf0,
0xcb,0x16,0xe4,0xc9, 0xa3,0x8f,0xd6,0x3f,
0xf8,0xb2,0x22,0x65, 0xf9,0xa1,0xa3,0x03,
0xe4,0x06,0x75,0x69, 0xf5,0x32,0x48,0x80,
},
.c = {
0x66,0x3f,0xf7,0x7a, 0x20,0xa4,0x35,0xd6,
0x0e,0xe8,0x17,0x32, 0x84,0xae,0xee,0x18,
0x0f,0x64,0x83,0x66, 0xa4,0xf4,0x24,0x53,
0xe6,0x58,0x2e,0xd5, 0x61,0x58,0xdd,0x5f,
0x1d,0xb9,0xba,0x34, 0xd0,0xd3,0x64,0xde,
0x99,0x47,0x92,0x3a, 0x26,0x90,0xbb,0x98,
0xb0,0xbd,0xf4,0x5e, 0x26,0x57,0xe0,0xe1,
0x09,0x27,0xc1,0xc4, 0x86,0x2b,0x4b,0x48,
0xbb,0xcd,0xec,0x2f, 0xd1,0x54,0xe9,0x21,
0xa0,0x40,0x76,0x01, 0x2d,0xb1,0xe7,0x75,
0xa1,0xd7,0x04,0x23, 0x9d,0xd3,0x0f,0x3b,
0x7e,0xb8,0xd0,0x37, 0xe4,0xd9,0x48,0xaa,
0xe1,0x4d,0x0f,0xf6, 0xae,0x29,0x20,0xae,
0xda,0x35,0x18,0x97, 0x2c,0xc2,0xa9,0xdd,
0x6e,0x50,0x73,0x52, 0x0a,0x8a,0x2a,0xd2,
0x2a,0xf4,0x12,0xe9, 0x7d,0x88,0x37,0xae,
0x12,0x81,0x92,0x96, 0xbe,0xea,0x15,0xa4,
0x3c,0x53,0xad,0x1f, 0x75,0x54,0x24,0x81,
0xaa,0x1b,0x92,0x84, 0x7c,0xb2,0xd7,0x10,
0x5e,0xb6,0xab,0x83, 0x25,0xf7,0x03,0x2b,
0xd9,0x53,0x4d,0xf9, 0x41,0x21,0xef,0xef,
0x40,0x3a,0x2d,0x54, 0xa9,0xf0,0x72,0xff,
0x03,0x59,0x2e,0x91, 0x07,0xff,0xe2,0x86,
0x33,0x59,0x98,0xdf, 0xa4,0x7d,0x9e,0x52,
0x95,0xd9,0x77,0x4b, 0xdf,0x93,0xc8,0x2d,
0xbc,0x81,0x2b,0x77, 0x89,0xae,0x52,0xdc,
0xfc,0xb7,0x22,0xf0, 0x1a,0x9d,0xc1,0x28,
0x70,0xe2,0x15,0xe4, 0x77,0x11,0x49,0x09,
0x89,0xf4,0x06,0x00, 0x64,0x78,0xb6,0x3f,
0x63,0x36,0xfd,0x9f, 0x35,0x33,0x85,0x52,
0x18,0x26,0xc1,0x0d, 0xf7,0xab,0x5a,0x06,
0x9c,0x3a,0xab,0x5f, 0x81,0x36,0x39,0xe3,
0xe6,0xf7,0x33,0xb0, 0xec,0xe6,0x8d,0x05,
0xbd,0xc7,0xbd,0x20, 0x5f,0x74,0xdf,0x98,
0x3a,0xa9,0xde,0xae, 0x89,0xee,0xcc,0x60,
0x8b,0x23,0xed,0x0f, 0x55,0x4d,0x56,0xd2,
0x69,0xa5,0xf8,0xff, 0x94,0x62,0x99,0xc6,
0xd4,0x02,0x0b,0xcf, 0xe4,0x86,0x23,0x5e,
0xed,0x12,0x12,0x2e, 0x0a,0x0f,0xda,0x12,
0x0a,0x68,0x56,0xea, 0x16,0x92,0xa5,0xdb,
0xf5,0x9d,0x0e,0xe6, 0x39,0x5d,0x76,0x50,
0x41,0x85,0xb4,0xcc, 0xb3,0x9e,0x84,0x46,
0xd3,0x93,0xcf,0xa1, 0xee,0x5b,0x51,0x94,
0x05,0x46,0x16,0xbb, 0xd1,0xae,0x94,0xe4,
0x1c,0x3d,0xeb,0xf4, 0x09,0x00,0xf7,0x86,
0x57,0x60,0x49,0x94, 0xf5,0xa7,0x7e,0x4b,
0x32,0x4a,0x6a,0xae, 0x2c,0x5f,0x30,0x2d,
0x7c,0xa1,0x71,0x5e, 0x63,0x7a,0x70,0x56,
0x1f,0xaf,0x3e,0xf3, 0x46,0xb5,0x68,0x61,
0xe2,0xd4,0x16,0x6b, 0xaf,0x94,0x07,0xa9,
0x5d,0x7a,0xee,0x4c, 0xad,0x85,0xcc,0x3e,
0x99,0xf3,0xfa,0x21, 0xab,0x9d,0x12,0xdf,
0x33,0x32,0x23,0x68, 0x96,0x8f,0x8f,0x78,
0xb3,0x63,0xa0,0x83, 0x16,0x06,0x64,0xbd,
0xea,0x1f,0x69,0x73, 0x9c,0x54,0xe1,0x60,
0xe8,0x98,0xc9,0x94, 0xe9,0xdf,0x0c,0xee,
0xf4,0x38,0x1e,0x9f, 0x26,0xda,0x3f,0x4c,
0xfd,0x6d,0xf5,0xee, 0x75,0x91,0x7c,0x4f,
0x4d,0xc2,0xe8,0x1a, 0x7b,0x1b,0xa9,0x52,
0x1e,0x24,0x22,0x5a, 0x73,0xa5,0x10,0xa2,
0x37,0x39,0x1e,0xd2, 0xf7,0xe0,0xab,0x77,
0xb7,0x93,0x5d,0x30, 0xd2,0x5a,0x33,0xf4,
0x63,0x98,0xe8,0x6d, 0x3f,0x34,0x4a,0xb9,
0x44,0x57,0x39,0xe7, 0xa9,0xdd,0xac,0x91,
},
},
[3] = {
.k = {
0xac,0x95,0xec,0x00, 0xa5,0x57,0x8e,0x99,
0x14,0x54,0x95,0x60, 0xdc,0xae,0x56,0x66,
0x03,0x22,0xa1,0x55, 0xbf,0xa5,0x2b,0x1c,
0x02,0xc9,0x0c,0x2f, 0xa1,0x5d,0x1b,0x84,
},
.tlen = 0,
.len = 1536,
.p = {
0xd2,0x80,0x06,0x95, 0xcd,0xe1,0x71,0x2c,
0xcf,0x89,0xa6,0xc7, 0x8b,0xa7,0xe3,0xcb,
0x66,0x3e,0x6b,0x58, 0x2a,0x20,0xd1,0xc4,
0x07,0xd6,0x3b,0x03, 0xdc,0x26,0xda,0x1b,
0xe0,0x51,0xd5,0x1c, 0x4c,0xed,0xd0,0xf5,
0xe2,0x7f,0x89,0xe8, 0x3d,0x41,0x1a,0xa0,
0xb1,0xed,0x61,0xa8, 0xc7,0x0a,0xe8,0x69,
0x4d,0xb8,0x18,0x81, 0x6c,0x76,0x67,0x83,
0x8a,0x47,0xa2,0x4b, 0xfb,0xfd,0x6f,0x65,
0x88,0xa8,0xf6,0x6d, 0x9f,0x71,0x6e,0x33,
0x4f,0x82,0xee,0x8f, 0x38,0x5c,0xe4,0x9b,
0x45,0x29,0xca,0xda, 0x9b,0x5d,0x65,0x06,
0xab,0xf5,0x86,0x28, 0x8c,0x3e,0x20,0x38,
0x1a,0x4c,0xb2,0xd9, 0x1f,0xc0,0x10,0x59,
0x6b,0x2c,0xb5,0x41, 0x41,0xc5,0xd9,0xb7,
0x4f,0xc3,0x36,0x08, 0xd4,0xdc,0xff,0x57,
0xd7,0x97,0x77,0x45, 0xc4,0x28,0x93,0x2c,
0xbe,0xdc,0xae,0x1d, 0x18,0xc8,0xfa,0x9a,
0xd4,0x41,0x2e,0x5a, 0x26,0x03,0xae,0x7a,
0xb2,0x6a,0xc0,0x0c, 0xb6,0x3e,0xf0,0x73,
0x36,0xed,0xea,0xc1, 0xae,0x9d,0xc9,0xa1,
0x85,0x4c,0x57,0x14, 0xb0,0xf3,0xf8,0x4e,
0x91,0x99,0x06,0x65, 0x17,0x66,0xc2,0x9a,
0x7a,0x4f,0x39,0x77, 0x32,0x44,0xc8,0x3f,
0xe2,0x3c,0xc2,0x31, 0x0b,0x40,0x84,0xee,
0xa1,0xeb,0xc6,0xc2, 0xb4,0x48,0xe6,0x09,
0xc5,0xf5,0x3d,0x96, 0x90,0xa2,0x1d,0xf2,
0x89,0x26,0x9f,0x10, 0x49,0x30,0x0f,0xe1,
0x5e,0xca,0x1c,0x3f, 0x82,0xda,0xcb,0x8d,
0x91,0x6d,0x08,0x96, 0x9e,0x57,0x88,0x16,
0xee,0xa7,0x9e,0xe8, 0x1b,0xc1,0x63,0xb0,
0x57,0xfa,0xfd,0x56, 0x49,0xec,0x51,0x1d,
0x34,0x2e,0xc6,0xda, 0xc0,0x1d,0x02,0x3e,
0x52,0xaf,0x44,0x24, 0xc6,0x80,0x12,0x64,
0xbe,0x44,0xa8,0x46, 0xb5,0x8d,0x80,0xfd,
0x95,0x4a,0xeb,0x3d, 0x4f,0x85,0x1f,0x1c,
0xa4,0x3f,0x5c,0x0c, 0x71,0xed,0x96,0x41,
0xde,0xb0,0xbd,0x08, 0xf3,0x4d,0x37,0xd2,
0xb1,0x4f,0x71,0x04, 0xf1,0x14,0x66,0x4a,
0x59,0x73,0xdc,0x98, 0x5b,0x61,0x56,0xfd,
0x50,0xe5,0x76,0xd9, 0x6a,0x9f,0x30,0x82,
0x6f,0xdf,0x6e,0x7b, 0x91,0xc2,0x5e,0x4f,
0x74,0x92,0x92,0xb8, 0x24,0xd3,0x30,0x21,
0x5d,0x4b,0xb1,0x01, 0xf7,0x62,0x27,0x94,
0xb3,0x88,0x86,0x75, 0xe8,0xab,0xe8,0x42,
0x50,0x15,0xb7,0xde, 0xc0,0xc4,0x8d,0x4e,
0x08,0x17,0xcb,0xf9, 0x4a,0x2e,0xe3,0x69,
0xbd,0xe7,0xdb,0xd1, 0xf1,0xfa,0x47,0xed,
0x78,0xa9,0x26,0xf0, 0xd1,0xbb,0x02,0xa1,
0x07,0x5c,0x1f,0xe8, 0x2f,0x52,0xd8,0x95,
0xd7,0xa9,0x2b,0x79, 0x77,0xf4,0xee,0xee,
0xbc,0x1f,0xaa,0x46, 0xe7,0x66,0x75,0xb1,
0x43,0x01,0x35,0xac, 0xc6,0x85,0xad,0x44,
0x23,0x59,0x50,0x0b, 0x39,0x47,0x51,0x54,
0x68,0x92,0x89,0x00, 0x08,0xa3,0xaa,0x24,
0x03,0x3f,0xf6,0xab, 0x19,0x42,0xff,0x0c,
0xc5,0xa3,0x96,0xcb, 0xd9,0x6d,0xa0,0xcc,
0x24,0x9e,0x71,0xb1, 0x87,0x95,0x7a,0x2e,
0x31,0x5e,0x17,0x26, 0x5a,0x1b,0xa1,0x33,
0x10,0x3f,0xd7,0xce, 0xa0,0xd9,0xbc,0xd8,
0x72,0xbe,0x75,0xc4, 0x78,0x3b,0x67,0xf5,
0xc3,0x82,0x2d,0x21, 0x49,0x74,0x2e,0xd5,
0x63,0xaa,0xa2,0x54, 0xc5,0xe2,0x98,0x82,
0x39,0xd9,0xda,0x14, 0x3c,0x75,0x18,0xc8,
0x75,0x6a,0xa1,0x7d, 0xfa,0x72,0x0f,0x9b,
0x5a,0xb3,0x7c,0x15, 0xc2,0xa5,0x6d,0x98,
0x02,0x6c,0xa2,0x26, 0xaa,0xc0,0x69,0xc5,
0xa7,0xa2,0xca,0xf5, 0xf3,0x8c,0x80,0x4e,
0x7e,0x47,0xc9,0x87, 0x47,0x36,0xd6,0xc6,
0xe8,0x49,0xb5,0x97, 0xa8,0xdc,0x4a,0x55,
0x6f,0x02,0x79,0x83, 0xe4,0x7c,0x4c,0x69,
0xa6,0x4d,0x4f,0x8a, 0x48,0x18,0x00,0xf9,
0xad,0xd1,0xb2,0xca, 0xc4,0x50,0x47,0x21,
0x4e,0xa7,0xce,0x6e, 0xdf,0xbd,0x2a,0x4d,
0xca,0x13,0x33,0xde, 0xa2,0x30,0xe1,0x03,
0xcd,0x2c,0x74,0xd3, 0x30,0x0d,0x61,0xe6,
0x9d,0xf3,0x09,0xc5, 0x27,0x99,0x0e,0x23,
0xbc,0x21,0xdb,0xdb, 0xeb,0x77,0xea,0xd4,
0x4b,0xbf,0x9b,0x49, 0x30,0xd4,0xc2,0xe7,
0x5e,0x85,0xe8,0xb6, 0xa5,0xe3,0x4e,0x64,
0xf0,0x45,0x95,0x04, 0x9a,0xed,0xaa,0x4d,
0xbd,0x5e,0x03,0x9f, 0xd4,0x2b,0xae,0x14,
0x1a,0x3d,0x49,0x92, 0xd6,0x6f,0x64,0xc7,
0xca,0x18,0x32,0x16, 0xf6,0x07,0x00,0x22,
0xfd,0xe1,0x45,0xe6, 0x19,0x24,0x5b,0x6e,
0xd3,0x67,0xf2,0x60, 0x36,0xf5,0x22,0xeb,
0x5f,0x42,0xba,0x70, 0x38,0xfc,0x98,0x96,
0x58,0x72,0xbf,0x13, 0x60,0xcc,0x32,0x45,
0x8d,0x00,0x44,0x60, 0xaf,0x7a,0x19,0xd6,
0xc0,0x14,0x33,0x96, 0xf3,0x33,0xc3,0xa8,
0x34,0x77,0x69,0x0c, 0x50,0xe5,0xfc,0x1b,
0x42,0x39,0x96,0x24, 0x3a,0x3a,0x47,0x0e,
0x27,0x66,0xa8,0x18, 0x50,0xdf,0x6d,0xa7,
0xad,0x4f,0xe5,0x88, 0x79,0xea,0x30,0xe2,
0xcd,0x27,0x05,0x36, 0x0c,0x3c,0x97,0x12,
0x69,0xa6,0xc0,0xa2, 0xa7,0x58,0x82,0x20,
0x68,0xfc,0xd0,0x81, 0x49,0xc0,0xcf,0xba,
0x90,0xe1,0x03,0xce, 0x70,0xd6,0x94,0x1a,
0xc0,0x22,0x3b,0xdc, 0x7f,0x63,0x6b,0xc4,
0x91,0xc2,0x21,0xdc, 0x84,0x42,0x80,0x04,
0x6f,0x14,0xc3,0x2c, 0x79,0x49,0x3c,0xb1,
0x5f,0xc7,0x69,0x4a, 0x4f,0xf5,0xd5,0x4b,
0x7c,0xe7,0x83,0x79, 0x30,0xff,0x74,0xe0,
0xf7,0xd3,0x6c,0x95, 0xef,0x77,0xe8,0x7b,
0x1f,0x54,0xad,0xc7, 0x4b,0xe8,0x5a,0x37,
0xd7,0xe9,0xfe,0xcb, 0x11,0x7b,0x54,0xb8,
0xd2,0xc7,0x80,0x1d, 0x80,0x17,0xdd,0x21,
0xa6,0xed,0x20,0x2c, 0x8a,0xa1,0x0b,0x3a,
0x08,0xde,0x34,0xe4, 0xa0,0xff,0x68,0xfa,
0x4a,0x01,0xcc,0x4f, 0x57,0x5f,0x84,0x95,
0x88,0xe2,0x7f,0xb7, 0x5d,0x35,0x36,0xe2,
0xa1,0xca,0xc0,0x9b, 0x4a,0xb0,0x6f,0x35,
0xef,0x08,0xd7,0x5a, 0xec,0x4f,0x97,0x20,
0x92,0x2a,0x63,0x1d, 0x15,0x07,0x73,0x1f,
0x97,0xcf,0x28,0x41, 0x65,0x0d,0x41,0xee,
0xca,0xd8,0x90,0x65, 0xaa,0x3d,0x04,0x7f,
0x35,0x4b,0x9e,0xe9, 0x96,0xa9,0x61,0xcb,
0x43,0xc9,0xfa,0x1d, 0xc8,0x85,0x40,0x64,
0x88,0x89,0xea,0xb5, 0xf7,0xe5,0xe4,0xfe,
0xaf,0x8e,0x52,0xf9, 0x7e,0x7d,0x83,0x92,
0x90,0x51,0x4c,0xf0, 0x49,0x52,0x5e,0x56,
0xc9,0xb7,0x4c,0xca, 0x57,0x01,0x3d,0x28,
0xe2,0x7d,0xaa,0x96, 0xd7,0xad,0xad,0xd9,
0xd5,0x1a,0xd5,0xc2, 0xd0,0x5a,0xd3,0x7a,
0x9a,0x91,0xa0,0xb8, 0x6f,0x28,0xff,0xa0,
0x1c,0x1d,0xf1,0x5e, 0x45,0x53,0x3f,0x85,
0x1b,0xc2,0x76,0x51, 0xbf,0x25,0x02,0xf7,
0x10,0xde,0xb7,0x1a, 0x04,0x6c,0x9a,0xeb,
0xb9,0x4b,0x67,0xfb, 0xa1,0x5b,0xa8,0x02,
0x01,0x1f,0x38,0xa9, 0x9d,0x96,0x50,0x07,
0xef,0xa7,0xc3,0xb4, 0x0f,0xcd,0x1b,0x9f,
0xd2,0x08,0x87,0xca, 0xd5,0x65,0x1a,0x5e,
0x1a,0xff,0x97,0xb0, 0x4b,0x43,0x67,0x51,
0x22,0xfd,0x49,0xcd, 0x54,0x2f,0xf8,0x9b,
0xed,0x46,0x7e,0x00, 0x5b,0x67,0x06,0xeb,
0xb7,0x4d,0x1c,0x72, 0x74,0xdd,0xbd,0xb1,
0x71,0x0a,0x28,0xc7, 0x7b,0xa8,0x12,0xac,
0x58,0x53,0xa4,0xfb, 0x41,0x74,0xb4,0x52,
0x95,0x99,0xf6,0x38, 0x53,0xff,0x2d,0x26,
0xef,0x12,0x91,0xc6, 0x52,0xe1,0xa9,0x50,
0xfa,0x8e,0x2e,0x82, 0x8b,0x4f,0xb7,0xad,
0xe1,0x74,0x0d,0xbf, 0x73,0x04,0xdf,0x3f,
0xf6,0xf8,0x09,0x9d, 0xdf,0x18,0x07,0x13,
0xe6,0x60,0xf0,0x6a, 0x98,0x22,0x15,0xdf,
0x0c,0x72,0x6a,0x9d, 0x6e,0x67,0x76,0x61,
0xda,0xbe,0x10,0xd6, 0xf0,0x5f,0x06,0x74,
0x76,0xce,0x63,0xee, 0x91,0x39,0x24,0xa9,
0xcf,0xc7,0xca,0xd5, 0xb4,0xff,0x30,0x6e,
0x05,0x32,0x0c,0x9d, 0xeb,0xfb,0xc6,0x3e,
0xe4,0xc6,0x20,0xc5, 0x3e,0x1d,0x5c,0xd6,
0x05,0xbe,0xb8,0xc3, 0x44,0xe3,0xc9,0xc1,
0x38,0xaa,0xc5,0xc8, 0xe3,0x11,0x8d,0xde,
0xdc,0x48,0x8e,0xe9, 0x38,0xe5,0x80,0xec,
0x82,0x17,0xf2,0xcf, 0x26,0x55,0xf7,0xdc,
0x78,0x7f,0xfb,0xc1, 0xb4,0x6c,0x80,0xcc,
0xf8,0x5a,0xbc,0x8f, 0x9d,0x62,0xfe,0x35,
0x17,0x7c,0x10,0xb7, 0x4a,0x0f,0x81,0x43,
0x11,0xbd,0x33,0x47, 0x9c,0x61,0x02,0xec,
0xab,0xde,0xb2,0x3f, 0x73,0x48,0xfb,0x5c,
0x84,0x4a,0xeb,0xab, 0x58,0x07,0x18,0xdc,
0x57,0x85,0xb8,0xe7, 0xff,0x9c,0xc2,0xc8,
0xb3,0xef,0x5b,0x50, 0x16,0xb1,0x38,0x6e,
0xa7,0xd7,0x9c,0xb1, 0x29,0x6b,0x74,0x9c,
0x50,0xcc,0x90,0xee, 0x86,0x2a,0x7c,0x07,
0xd4,0xcb,0xc2,0x24, 0x53,0xb0,0x3f,0x4f,
0x9b,0xc4,0x62,0x73, 0x85,0x3d,0x1e,0x54,
0x86,0xda,0x1e,0x5e, 0x70,0x73,0x6a,0x2a,
0x29,0x75,0xb7,0x18, 0x1a,0x72,0x81,0x64,
0x58,0xa0,0xb3,0x70, 0x61,0x9f,0x22,0x37,
0xac,0xdc,0xe8,0xaf, 0xe2,0x74,0xe4,0xa7,
0xed,0x92,0x5c,0x47, 0xff,0xc3,0xaf,0x9e,
0x59,0xe1,0x09,0x22, 0x72,0x18,0x96,0x35,
0x23,0x91,0x00,0xa3, 0x7d,0x95,0x25,0x95,
0xd5,0xad,0xf8,0x6e, 0xcc,0x14,0x31,0xb2,
0x52,0x20,0x2a,0x41, 0xf1,0xaf,0x9a,0xaf,
0xdd,0xbd,0x04,0x5a, 0xcd,0x1a,0x86,0xb1,
0x45,0x1b,0x6f,0x7a, 0x02,0x45,0x05,0xef,
0x74,0xdf,0xe8,0x72, 0x1c,0x82,0x57,0xea,
0x2a,0x24,0x1b,0x46, 0x3f,0x66,0x89,0x9f,
0x00,0xb9,0xec,0xf7, 0x59,0x6d,0xeb,0xac,
0xca,0x82,0x14,0x79, 0xbf,0x7f,0xd5,0x18,
0x26,0x6b,0xee,0x34, 0x44,0xee,0x6d,0x8a,
0x82,0x8f,0x4f,0xa3, 0x1a,0xc3,0x9b,0x2e,
0x57,0x83,0xb8,0x7d, 0xa0,0x21,0xc6,0x66,
0x96,0x7d,0x30,0x81, 0x29,0xc7,0x05,0x46,
0x99,0xd4,0x35,0x7b, 0x40,0xe8,0x87,0x60,
0x13,0xa5,0xa6,0xb9, 0x24,0x59,0xca,0xa8,
0xcd,0x62,0xeb,0xc5, 0x22,0xff,0x49,0x64,
0x03,0x2d,0x42,0x01, 0xa2,0x09,0x4a,0x45,
0x41,0x34,0x88,0x44, 0xf4,0xe1,0xa3,0x48,
0xcf,0x2d,0xee,0xee, 0xbf,0x83,0x1a,0x42,
0x8d,0xa4,0x15,0x3d, 0xfc,0x92,0x67,0x91,
},
.c = {
0x5c,0xb9,0xab,0x7c, 0xe4,0x0b,0xbe,0xa5,
0x17,0x18,0xdf,0xd7, 0x17,0x13,0x98,0xbd,
0xcb,0x1c,0xa3,0x39, 0x9c,0xbc,0x19,0x1f,
0xca,0xcb,0x50,0x89, 0x1d,0x69,0xc3,0xcb,
0xd1,0x76,0x70,0x6b, 0x7c,0x62,0x49,0xe8,
0xb1,0xa8,0xb7,0x58, 0x87,0xf6,0x79,0xf7,
0xf2,0xc1,0xd8,0xb2, 0x1d,0xd2,0x1a,0xf5,
0xa0,0x41,0xda,0x17, 0x3f,0xaa,0xdb,0xf6,
0xa9,0xf2,0x49,0x1c, 0x6f,0x20,0xf3,0xae,
0x4a,0x5e,0x55,0xdd, 0xa6,0x9e,0xc4,0x03,
0x07,0x22,0xc0,0xbe, 0x5e,0x58,0xdd,0xf0,
0x7e,0xfe,0xcf,0x2c, 0x96,0x33,0x32,0xbd,
0xe8,0xdf,0x84,0x71, 0x45,0x35,0x40,0x48,
0xcf,0x10,0x45,0x47, 0x97,0x4c,0x20,0x6b,
0x3a,0xdd,0x73,0xd0, 0xce,0x0c,0x4c,0xf1,
0x78,0xcd,0x93,0xd2, 0x21,0x70,0xeb,0x2f,
0x23,0x99,0x64,0xbb, 0x97,0x28,0xe9,0xde,
0xef,0x9c,0xf2,0x7f, 0x4b,0x4d,0x2c,0x66,
0x7b,0x6e,0x70,0xf7, 0x25,0x68,0xea,0x93,
0x3a,0x27,0xbd,0x04, 0x8b,0xcd,0xd9,0xed,
0x1a,0x9d,0xca,0x8f, 0x15,0x2d,0xa1,0x25,
0xb8,0x66,0x1b,0x3d, 0xd4,0xd4,0x9b,0xab,
0x3a,0xa8,0xe8,0x88, 0xc6,0xd2,0x5a,0x28,
0x51,0x4d,0x11,0xb6, 0x4a,0x2b,0x6d,0xe4,
0xc9,0xc1,0x20,0x6f, 0xba,0x23,0x72,0xc9,
0x6d,0x44,0xf0,0xaa, 0x06,0x8c,0x9b,0xbb,
0x4b,0xd2,0xa0,0x94, 0x5f,0x0b,0xc8,0xa3,
0x4c,0xe9,0xe2,0x8a, 0xe5,0xf9,0xe3,0x2c,
0xc7,0x87,0x75,0xc1, 0xc9,0x62,0xb5,0xb4,
0x04,0x86,0x6a,0x31, 0x54,0x0e,0x31,0xf7,
0xad,0xea,0xbb,0xa6, 0x8e,0x6c,0xac,0x24,
0x52,0x2c,0x9d,0x1f, 0xde,0x70,0xfd,0xc4,
0x93,0x8b,0x75,0x6c, 0xef,0xa7,0x89,0xaf,
0x2c,0x4c,0xf6,0x38, 0xdd,0x79,0xfa,0x70,
0x54,0x1e,0x92,0xd4, 0xb4,0x04,0x69,0x8e,
0x6b,0x9e,0x12,0xfe, 0x15,0x15,0xf7,0x99,
0xb6,0x2f,0xfc,0xfa, 0x66,0xe9,0x40,0xb5,
0xd3,0x10,0xbb,0x42, 0xf9,0x68,0x64,0xd4,
0x2a,0xcd,0x43,0x75, 0xb0,0x9c,0x61,0x34,
0xc1,0xc4,0x42,0xf3, 0xf1,0xa7,0x65,0xf4,
0xcb,0x42,0xe9,0xc2, 0x5a,0x05,0xdf,0x98,
0xa3,0xba,0xf7,0xe0, 0x15,0xa1,0xdf,0xf7,
0xce,0xd5,0xf0,0x62, 0x89,0xe1,0x44,0x3a,
0x4f,0x6f,0x75,0x3e, 0xfc,0x19,0xe3,0x5f,
0x36,0x48,0xc1,0x95, 0x08,0x22,0x09,0xf9,
0x07,0x74,0x1c,0xa4, 0x1b,0x7e,0xa8,0x82,
0xca,0x0b,0xd9,0x1e, 0xe3,0x5b,0x1c,0xb5,
0x57,0x13,0x7d,0xbd, 0xbd,0x16,0x88,0xd4,
0xb1,0x8e,0xdb,0x6f, 0x2f,0x7b,0x55,0x72,
0x79,0xc9,0x49,0x7b, 0xf7,0x86,0xa9,0x3d,
0x2d,0x11,0x33,0x7d, 0x82,0x38,0xc7,0xb5,
0x7c,0x6b,0x0b,0x28, 0x42,0x50,0x47,0x69,
0xd8,0x48,0xc6,0x85, 0x0b,0x1b,0xca,0x08,
0x85,0x36,0x6d,0x97, 0xe9,0x3e,0xeb,0xe2,
0x28,0x6a,0x17,0x61, 0x7d,0xcb,0xb6,0xb3,
0x23,0x44,0x76,0xd3, 0x57,0x39,0x9b,0x1d,
0x69,0x30,0xd8,0x3f, 0x21,0xe8,0x68,0x94,
0x82,0x85,0x97,0xb1, 0x1f,0x0c,0x99,0x6e,
0x6e,0x44,0xa6,0x82, 0xd0,0xa2,0xe6,0xfe,
0xff,0x08,0x41,0x49, 0x54,0x18,0x51,0x88,
0x23,0xd5,0x14,0xbd, 0xfe,0xea,0x5d,0x15,
0xd4,0x0b,0x2d,0x92, 0x94,0x8d,0xd4,0xe5,
0xaf,0x60,0x88,0x2b, 0x67,0xae,0xbb,0xa8,
0xec,0xae,0x9b,0x35, 0xa2,0xd7,0xe8,0xb6,
0xe5,0xaa,0x12,0xd5, 0xef,0x05,0x5a,0x64,
0xe0,0xff,0x79,0x16, 0xb6,0xa3,0xdb,0x1e,
0xee,0xe8,0xb7,0xd6, 0x71,0xbd,0x76,0xbf,
0x66,0x2a,0x9c,0xec, 0xbe,0x8c,0xb5,0x8e,
0x8e,0xc0,0x89,0x07, 0x5d,0x22,0xd8,0xe0,
0x27,0xcf,0x58,0x8a, 0x8c,0x4d,0xc7,0xa4,
0x45,0xfc,0xe5,0xa4, 0x32,0x7c,0xbf,0x86,
0xf0,0x82,0x96,0x05, 0x1e,0x86,0x03,0x0f,
0x1f,0x0d,0xf2,0xfc, 0x28,0x62,0x90,0x53,
0xfe,0xd4,0x28,0x52, 0x4f,0xa6,0xbc,0x4d,
0xba,0x5d,0x04,0xc0, 0x83,0x61,0xf6,0x41,
0xc8,0x58,0x40,0x49, 0x1d,0x27,0xd5,0x9f,
0x93,0x4f,0xb5,0x7a, 0xea,0x7b,0x86,0x31,
0x2b,0xe5,0x92,0x51, 0x3e,0x7a,0xbe,0xdb,
0x04,0xae,0x21,0x71, 0x5a,0x70,0xf9,0x9b,
0xa8,0xb6,0xdb,0xcd, 0x21,0x56,0x75,0x2e,
0x98,0x38,0x78,0x4d, 0x51,0x4a,0xa6,0x03,
0x8a,0x84,0xb2,0xf9, 0x6b,0x98,0x6d,0xf3,
0x12,0xaa,0xd4,0xea, 0xb3,0x7c,0xb0,0xd9,
0x5e,0x1c,0xb0,0x69, 0x48,0x67,0x13,0x26,
0xf0,0x25,0x04,0x93, 0x6d,0xc6,0x6c,0xb2,
0xcd,0x7c,0x36,0x62, 0x6d,0x38,0x44,0xe9,
0x6b,0xe2,0x7f,0xc1, 0x40,0xdb,0x55,0xe1,
0xa6,0x71,0x94,0x0a, 0x13,0x5f,0x9e,0x66,
0x3b,0xb3,0x11,0x90, 0xbb,0x68,0xd4,0x11,
0xf2,0xb7,0x61,0xbd, 0xac,0x4a,0x56,0xf4,
0x9e,0xe2,0xd0,0x1e, 0xb4,0xa1,0xb8,0x4e,
0xbb,0xc2,0x73,0x63, 0x04,0x99,0x97,0x9f,
0x76,0x18,0x82,0x11, 0x7e,0xe1,0xcc,0x58,
0xb7,0xb5,0x37,0x78, 0x60,0x19,0x6c,0x2b,
0x6e,0x65,0x15,0x10, 0x3c,0x93,0xf0,0xc5,
0x3d,0x9e,0xeb,0x77, 0x72,0x25,0x95,0xf0,
0x27,0xe8,0xbd,0x81, 0x9c,0x22,0x38,0xa7,
0x8d,0xe9,0x94,0xf2, 0x27,0x8d,0x3a,0x34,
0x36,0xba,0x26,0xa0, 0xd7,0x3e,0xd8,0xbe,
0x60,0xd1,0x53,0x58, 0x56,0xe6,0xf3,0xa1,
0x0d,0x62,0x5e,0x44, 0xd3,0x7c,0xc9,0x25,
0x87,0xc8,0x1a,0x57, 0x7f,0xfa,0x79,0x4a,
0x15,0xf6,0x3e,0x2e, 0xd0,0x6b,0x83,0x9b,
0xe6,0xfe,0x6c,0xd3, 0x8e,0x40,0x4a,0x12,
0x57,0x41,0xc9,0x5a, 0x42,0x91,0x0b,0x28,
0x56,0x38,0xfc,0x45, 0x4b,0x26,0xbf,0x3a,
0xa3,0x46,0x75,0x73, 0xde,0x7e,0x18,0x7c,
0x82,0x92,0x73,0xe6, 0xb5,0xd2,0x1f,0x1c,
0xdd,0xb3,0xd5,0x71, 0x9f,0xd2,0xa5,0xf4,
0xf1,0xcb,0xfe,0xfb, 0xd3,0xb6,0x32,0xbd,
0x8e,0x0d,0x73,0x0a, 0xb6,0xb1,0xfd,0x31,
0xa5,0xa4,0x7a,0xb1, 0xa1,0xbb,0xf0,0x0b,
0x97,0x21,0x27,0xe1, 0xbb,0x6a,0x2a,0x5b,
0x95,0xda,0x01,0xd3, 0x06,0x8e,0x53,0xd8,
0x23,0xa3,0xa9,0x82, 0x8a,0xa2,0x8f,0xdb,
0x87,0x37,0x41,0x41, 0x2b,0x36,0xf3,0xb3,
0xa6,0x32,0x5f,0x3e, 0xbf,0x70,0x3a,0x13,
0xba,0x11,0xa1,0x4e, 0x11,0xa8,0xc0,0xb7,
0xb2,0x1b,0xab,0xc8, 0xcb,0x38,0x35,0x2e,
0x76,0xa7,0x0b,0x5a, 0x6c,0x53,0x83,0x60,
0x4f,0xee,0x91,0xe8, 0xca,0x1e,0x7f,0x76,
0x2b,0x4c,0xe7,0xd4, 0xcb,0xf8,0xeb,0x94,
0x76,0x17,0x68,0x23, 0x95,0x93,0x7f,0x60,
0x80,0x7a,0x85,0x70, 0x95,0x56,0xb9,0x76,
0x76,0xb6,0x8f,0xe2, 0x93,0x60,0xfc,0x70,
0x57,0x4a,0x27,0xc0, 0xfb,0x49,0x2f,0xac,
0xde,0x87,0x2f,0x1a, 0x80,0xca,0x68,0x5e,
0xc6,0x18,0x4e,0x3a, 0x4b,0x36,0xdc,0x24,
0x78,0x7e,0xb0,0x58, 0x85,0x4d,0xa9,0xbc,
0x0d,0x87,0xdd,0x02, 0xa6,0x0d,0x46,0xae,
0xf7,0x2f,0x8e,0xeb, 0xf4,0x29,0xe0,0xbc,
0x9a,0x34,0x30,0xc3, 0x29,0xea,0x2c,0xb3,
0xb4,0xa2,0x9c,0x45, 0x6e,0xcb,0xa4,0x9d,
0x22,0xe6,0x71,0xe0, 0xcb,0x9f,0x05,0xef,
0x2f,0xf7,0x12,0xfd, 0x5d,0x48,0x6c,0x9e,
0x8b,0xaa,0x90,0xb6, 0xa8,0x78,0xeb,0xde,
0xeb,0x4c,0xce,0x7b, 0x62,0x60,0x69,0xc0,
0x54,0xc3,0x13,0x76, 0xdc,0x7e,0xd1,0xc3,
0x8e,0x24,0x58,0x43, 0x3c,0xbc,0xa0,0x75,
0xf2,0x7c,0x2d,0x1e, 0x94,0xec,0x40,0x15,
0xe1,0x78,0xac,0x4a, 0x93,0xef,0x87,0xec,
0x99,0x94,0xcb,0x65, 0xde,0xcb,0x38,0xd7,
0x89,0x90,0xa2,0x68, 0xcf,0xfd,0x98,0xf8,
0x1f,0x06,0xd5,0x6c, 0x53,0x1d,0xd3,0xa7,
0x06,0x0b,0xa9,0x92, 0xbb,0x6e,0x6f,0xaa,
0x5a,0x54,0x71,0xb7, 0x90,0x00,0x06,0x6b,
0xf9,0x34,0xba,0x41, 0x73,0x58,0x98,0xfc,
0xca,0x98,0xbd,0xd3, 0x7d,0xa4,0x49,0xcc,
0xa8,0x19,0xc1,0x40, 0x75,0x81,0x02,0x33,
0xac,0x90,0xcd,0x58, 0xeb,0x1b,0xb4,0x4e,
0xe0,0x8a,0xa9,0x0f, 0x15,0x8e,0x51,0x85,
0x06,0x09,0x92,0x40, 0xe3,0x75,0x60,0x64,
0xcf,0x9b,0x88,0xc7, 0xb0,0xab,0x37,0x5d,
0x43,0x21,0x18,0x09, 0xff,0xec,0xa0,0xb3,
0x47,0x09,0x22,0x4c, 0x55,0xc2,0x2d,0x2b,
0xce,0xb9,0x3a,0xcc, 0xd7,0x0c,0xb2,0x9a,
0xff,0x2a,0x73,0xac, 0x7a,0xf2,0x11,0x73,
0x94,0xd9,0xbe,0x31, 0x9f,0xae,0x62,0xab,
0x03,0xac,0x5f,0xe2, 0x99,0x90,0xfb,0xa5,
0x74,0xc0,0xfa,0xb9, 0x3c,0x96,0x7c,0x36,
0x25,0xab,0xff,0x2f, 0x24,0x65,0x73,0x21,
0xc3,0x21,0x73,0xc9, 0x23,0x06,0x22,0x6c,
0xb2,0x22,0x26,0x1d, 0x88,0x6f,0xd3,0x5f,
0x6f,0x4d,0xf0,0x6d, 0x13,0x70,0x7d,0x67,
0xe8,0x5c,0x3b,0x35, 0x27,0x8a,0x8c,0x65,
0xae,0x50,0x78,0xe1, 0x26,0x07,0xf8,0x18,
0xfc,0xea,0xa3,0x58, 0x73,0x2b,0xca,0x92,
0x10,0xdc,0xb5,0x39, 0xd5,0x2d,0x21,0xfe,
0x79,0xac,0x7d,0xe8, 0x0c,0xe9,0x6d,0x3e,
0xb4,0x8a,0x23,0x65, 0x08,0xbc,0x57,0x51,
0xe1,0xf8,0x8d,0x5b, 0xe4,0xfe,0x14,0x60,
0x02,0xe7,0xd1,0xc2, 0xd2,0x2c,0x3f,0x4d,
0x08,0xd1,0xd0,0xe7, 0x3b,0xcb,0x85,0x84,
0x32,0xd6,0xb9,0xfb, 0xf7,0x45,0xa1,0xaf,
0x9c,0xa3,0x8d,0x37, 0xde,0x03,0x6b,0xf4,
0xae,0x58,0x03,0x26, 0x58,0x4f,0x73,0x49,
0xc8,0x7f,0xa3,0xdd, 0x51,0xf2,0xec,0x34,
0x8f,0xd5,0xe0,0xc2, 0xe5,0x33,0xf7,0x31,
0x33,0xe7,0x98,0x5f, 0x26,0x14,0x4f,0xbb,
0x88,0x1f,0xb3,0x92, 0x4e,0x97,0x2d,0xee,
0x08,0x5f,0x9c,0x14, 0x5f,0xaf,0x6c,0x10,
0xf9,0x47,0x41,0x81, 0xe9,0x99,0x49,0x52,
0x86,0x29,0x55,0xba, 0x2e,0xb6,0x62,0x24,
0x58,0xf7,0x4d,0x99, 0xce,0x75,0xa8,0x45,
0x66,0x27,0x48,0x3f, 0x78,0xe3,0x48,0x7c,
0xd7,0x1a,0x6c,0x89, 0x9d,0xb2,0x6a,0x23,
0x9d,0xd7,0xed,0x82, 0x31,0x94,0x40,0x66,
0xc8,0x28,0x52,0x23, 0xe7,0x61,0xde,0x71,
0x69,0xf2,0x53,0x43, 0x30,0xce,0x6a,0x1a,
0xfe,0x1e,0xeb,0xc2, 0x9f,0x61,0x81,0x94,
0x18,0xed,0x58,0xbb, 0x01,0x13,0x92,0xb3,
0xa6,0x90,0x7f,0xb5, 0xf4,0xbd,0xff,0xae,
},
},
[4] = {
.k = {
0x7f,0x56,0x7d,0x15, 0x77,0xe6,0x83,0xac,
0xd3,0xc5,0xb7,0x39, 0x9e,0x9f,0xf9,0x17,
0xc7,0xff,0x50,0xb0, 0x33,0xee,0x8f,0xd7,
0x3a,0xab,0x0b,0xfe, 0x6d,0xd1,0x41,0x8a,
},
.tlen = 0,
.len = 4096,
.p = {
0x95,0x96,0x98,0xef, 0x73,0x92,0xb5,0x20,
0xec,0xfc,0x4d,0x91, 0x54,0xbf,0x8d,0x9d,
0x54,0xbc,0x4f,0x0f, 0x94,0xfc,0x94,0xcf,
0x07,0xf6,0xef,0xbb, 0xed,0x3f,0xd3,0x60,
0xba,0x85,0x1d,0x04, 0x08,0x54,0x92,0x08,
0x06,0x52,0x7f,0x33, 0xfd,0xf3,0xdf,0x2a,
0x17,0x2d,0xda,0x73, 0x03,0x56,0x21,0xa9,
0xa3,0xab,0xf7,0x24, 0x17,0x39,0x7e,0x0f,
0x00,0xdd,0xac,0x55, 0xb0,0x8b,0x2d,0x72,
0x3b,0x9a,0x36,0x5a, 0xd9,0x0a,0x8e,0x0f,
0xe2,0x1d,0xe8,0x85, 0xc3,0xc1,0x17,0x11,
0xa7,0x2c,0x87,0x77, 0x9d,0x6c,0x3a,0xa6,
0x90,0x59,0x10,0x24, 0xb0,0x92,0xe1,0xb6,
0xa9,0x89,0x7c,0x95, 0x0a,0xf2,0xb2,0xa3,
0x4a,0x40,0x88,0x35, 0x71,0x4e,0xa5,0xc9,
0xde,0xba,0xd7,0x62, 0x56,0x46,0x40,0x1e,
0xda,0x80,0xaf,0x28, 0x5d,0x40,0x36,0xf6,
0x09,0x06,0x29,0x6e, 0xaa,0xca,0xe3,0x9e,
0x9a,0x4f,0x4c,0x7e, 0x71,0x81,0x6f,0x9e,
0x50,0x05,0x91,0x58, 0x13,0x6c,0x75,0x6a,
0xd3,0x0e,0x7e,0xaf, 0xe1,0xbc,0xd9,0x38,
0x18,0x47,0x73,0x3a, 0xf3,0x78,0x6f,0xcc,
0x3e,0xea,0x52,0x82, 0xb9,0x0a,0xc5,0xfe,
0x77,0xd6,0x25,0x56, 0x2f,0xec,0x04,0x59,
0xda,0xd0,0xc9,0x22, 0xb1,0x01,0x60,0x7c,
0x48,0x1a,0x31,0x3e, 0xcd,0x3d,0xc4,0x87,
0xe4,0x83,0xc2,0x06, 0x91,0xf7,0x02,0x86,
0xd2,0x9b,0xfd,0x26, 0x5b,0x9b,0x32,0xd1,
0x5c,0xfd,0xb4,0xa8, 0x58,0x3f,0xd8,0x10,
0x8a,0x56,0xee,0x04, 0xd0,0xbc,0xaa,0xa7,
0x62,0xfd,0x9a,0x52, 0xec,0xb6,0x80,0x52,
0x39,0x9e,0x07,0xc8, 0xb4,0x50,0xba,0x5a,
0xb4,0x9a,0x27,0xdb, 0x93,0xb6,0x98,0xfe,
0x52,0x08,0xa9,0x45, 0xeb,0x03,0x28,0x89,
0x26,0x3c,0x9e,0x97, 0x0f,0x0d,0x0b,0x67,
0xb0,0x00,0x01,0x71, 0x4b,0xa0,0x57,0x62,
0xfe,0xb2,0x6d,0xbb, 0xe6,0xe4,0xdf,0xe9,
0xbf,0xe6,0x21,0x58, 0xd7,0xf6,0x97,0x69,
0xce,0xad,0xd8,0xfa, 0xce,0xe6,0x80,0xa5,
0x60,0x10,0x2a,0x13, 0xb2,0x0b,0xbb,0x88,
0xfb,0x64,0x66,0x00, 0x72,0x8c,0x4e,0x21,
0x47,0x33,0x00,0x1f, 0x85,0xa6,0x3a,0xd3,
0xe2,0x6c,0xc7,0x42, 0xb6,0x7b,0xc0,0x56,
0x75,0xe2,0x61,0x72, 0x15,0xd1,0x88,0x08,
0x3f,0x4d,0xfd,0xe2, 0x68,0x64,0xe5,0x7a,
0x23,0x9b,0x3f,0x6c, 0xc3,0xd6,0x51,0x08,
0x24,0x33,0x24,0x47, 0x7e,0xea,0x23,0xdc,
0x07,0x41,0x66,0xa2, 0xa4,0xeb,0x23,0xa1,
0x37,0x31,0xc0,0x7a, 0xe6,0xa4,0x63,0x05,
0x20,0x44,0xe2,0x70, 0xd3,0x3e,0xee,0xd8,
0x24,0x34,0x5d,0x80, 0xde,0xc2,0x34,0x66,
0x5a,0x2b,0x6a,0x20, 0x4c,0x99,0x0d,0xbc,
0x37,0x59,0xc5,0x8b, 0x70,0x4d,0xb4,0x0e,
0x51,0xec,0x59,0xf6, 0x4f,0x08,0x1e,0x54,
0x3d,0x45,0x31,0x99, 0x4d,0x5e,0x29,0x5f,
0x12,0x57,0x46,0x09, 0x33,0xb9,0xf2,0x66,
0xb4,0xc2,0xfa,0x63, 0xbe,0x42,0x6c,0x21,
0x68,0x33,0x40,0xc6, 0xbd,0xd8,0x8a,0x55,
0xd7,0x90,0x27,0x25, 0x7d,0x1e,0xed,0x02,
0x50,0xd8,0xb1,0xac, 0xfa,0xd9,0xd4,0xcb,
0x1c,0xc9,0x43,0x60, 0x44,0xab,0xd8,0x97,
0x04,0xac,0xef,0x72, 0xa3,0x88,0xdc,0xb0,
0xb0,0xb6,0xc6,0xd4, 0xd0,0x38,0xaf,0xc7,
0xcd,0x8d,0x2a,0xa4, 0x13,0x53,0xd9,0xfd,
0x2d,0x0b,0x91,0xb4, 0x3c,0x3a,0x72,0x11,
0x6c,0x8b,0x96,0xa3, 0xc6,0x0b,0xd6,0x9a,
0xa2,0xb9,0xae,0x76, 0xad,0xfd,0x01,0x90,
0xab,0x93,0x9c,0x4b, 0xde,0x7e,0xf2,0x82,
0x96,0xb9,0x98,0x55, 0xe2,0x68,0xe0,0xd8,
0x61,0xb8,0x91,0x9a, 0xaf,0x92,0xd7,0xe5,
0xeb,0x88,0xc5,0xb0, 0xcb,0x75,0x55,0xa9,
0x94,0x7c,0x9c,0x11, 0x14,0x81,0x1a,0x09,
0x61,0xd8,0x22,0x44, 0x13,0xba,0xe8,0x06,
0x78,0xfd,0xd5,0x82, 0x73,0x19,0x9a,0xd1,
0x5d,0x16,0xf5,0xd8, 0x86,0x7e,0xe3,0xcd,
0xdc,0xe8,0x6a,0x18, 0x05,0xba,0x10,0xe4,
0x06,0xc7,0xb2,0xf3, 0xb2,0x3e,0x1c,0x74,
0x86,0xdd,0xad,0x8c, 0x82,0xf0,0x73,0x15,
0x34,0xac,0x1d,0x95, 0x5e,0xba,0x2a,0xba,
0xf8,0xac,0xbd,0xd7, 0x28,0x74,0x28,0xc7,
0x29,0xa0,0x00,0x11, 0xda,0x31,0x7c,0xab,
0x66,0x4d,0xb2,0x5e, 0xae,0x71,0xc5,0x31,
0xcc,0x2b,0x9f,0x36, 0x2e,0xe6,0x97,0xa4,
0xe1,0xb8,0x4b,0xc9, 0x00,0x87,0x7b,0x54,
0xaa,0xeb,0xff,0x1a, 0x15,0xe8,0x3e,0x11,
0xf7,0x25,0x3a,0xce, 0x94,0x23,0x27,0x44,
0x77,0x80,0x6e,0xdd, 0x3f,0x8e,0x5a,0x92,
0xae,0xee,0xb9,0x00, 0x79,0xc3,0x1d,0xab,
0x17,0xb8,0x2b,0xff, 0x0d,0x64,0x29,0xb7,
0x61,0x4d,0xd0,0x8d, 0x3d,0x36,0x3d,0x13,
0xed,0x12,0xe8,0x08, 0xdd,0x4b,0x37,0xf7,
0x2b,0xe7,0xeb,0x92, 0x78,0x98,0xc2,0xd6,
0x13,0x15,0x94,0xff, 0xef,0xdc,0xda,0x27,
0x7b,0xf9,0x58,0x5b, 0x90,0xf3,0xcd,0x1b,
0x38,0x8a,0x00,0x38, 0x9b,0x95,0xcb,0x18,
0x1f,0x97,0xd2,0x1f, 0x60,0x9d,0x6c,0xac,
0xb8,0x72,0x08,0xd9, 0xc1,0xf4,0x98,0x72,
0xf9,0x44,0xf2,0x2b, 0xe1,0x6e,0x76,0x15,
0x63,0xfc,0x57,0x12, 0x23,0x4a,0xff,0xd3,
0x1f,0x0d,0x0c,0xb9, 0x14,0xf9,0x98,0x52,
0xce,0x90,0x34,0x8c, 0xd4,0x54,0x14,0x9e,
0xf7,0x2c,0xba,0x5f, 0x80,0xb0,0x02,0x68,
0x4f,0xca,0xb0,0xda, 0x44,0x11,0xb4,0xbd,
0x12,0x14,0x80,0x6b, 0xc1,0xce,0xa7,0xfe,
0x0e,0x16,0x69,0x19, 0x3c,0xe7,0xb6,0xfe,
0x5a,0x59,0x02,0xf6, 0x78,0x3e,0xa4,0x65,
0x57,0xa1,0xf2,0x65, 0xad,0x64,0xfc,0xba,
0xd8,0x47,0xc8,0x8d, 0x11,0xf9,0x6a,0x25,
0x22,0xa7,0x7f,0xa9, 0x43,0xe4,0x07,0x6b,
0x49,0x26,0x42,0xe4, 0x03,0x1f,0x56,0xcd,
0xf1,0x49,0xf8,0x0d, 0xea,0x1d,0x4f,0x77,
0x5c,0x3c,0xcd,0x6d, 0x58,0xa8,0x92,0x6d,
0x50,0x4a,0x81,0x6e, 0x09,0x2a,0x15,0x9e,
0x3b,0x56,0xd3,0xb4, 0xef,0xe6,0x12,0xaf,
0x60,0x3b,0x73,0xe7, 0xd8,0x2e,0xab,0x13,
0xfb,0x7e,0xea,0xb1, 0x7b,0x54,0xc5,0x26,
0x41,0x93,0x31,0xda, 0xb5,0x7a,0xe3,0x46,
0x7a,0x8a,0xb0,0x81, 0xab,0xd5,0x90,0x85,
0x4b,0xef,0x30,0x11, 0xb8,0x00,0x19,0x39,
0xd3,0x11,0x54,0x53, 0x48,0x7a,0x7e,0xc5,
0x4e,0x52,0xe5,0x4c, 0xeb,0xa2,0x9f,0x7a,
0xdc,0xb5,0xc8,0x4e, 0x3b,0x5c,0x92,0x0f,
0x19,0xcb,0x0a,0x9d, 0xda,0x01,0xfc,0x17,
0x62,0xc3,0x46,0x63, 0x8b,0x4e,0x85,0x92,
0x75,0x01,0x00,0xb3, 0x74,0xa8,0x23,0xd1,
0xd2,0x91,0x53,0x0f, 0xd0,0xe9,0xed,0x90,
0xde,0x9c,0x8c,0xb7, 0xf1,0x6a,0xd6,0x49,
0x3c,0x22,0x2b,0xd7, 0x73,0x76,0x38,0x79,
0xb5,0x88,0x1e,0xee, 0xdf,0xed,0x9f,0xfd,
0x1a,0x0e,0xe7,0xd5, 0xc6,0xc9,0xfb,0x03,
0xcc,0x84,0xb5,0xd2, 0x49,0xca,0x49,0x0a,
0x1b,0x7c,0x78,0xe4, 0xd1,0x2e,0x7c,0x14,
0x80,0x38,0x9d,0xba, 0x64,0x13,0xd3,0xf8,
0x8e,0x05,0x4a,0xd6, 0x0d,0x73,0x09,0x1e,
0xf1,0x75,0x63,0x59, 0xed,0xfc,0xbe,0x83,
0x56,0x91,0x22,0x84, 0xd2,0x1e,0xf2,0x61,
0x12,0x3d,0x50,0x6c, 0x9f,0xea,0x6b,0xcd,
0x8c,0xac,0x28,0x0d, 0xad,0xf4,0xfd,0x77,
0x45,0x68,0x17,0xb6, 0x03,0x13,0x54,0x7a,
0xc0,0x8e,0x6b,0x56, 0x8a,0xd2,0xc6,0x1b,
0xb3,0x3e,0x4f,0x68, 0x91,0x2e,0x2d,0x35,
0x2a,0x32,0x27,0x86, 0x67,0x36,0x73,0xb8,
0xfc,0x08,0xb8,0xf8, 0x1f,0x67,0x0b,0x32,
0x89,0x00,0xfb,0x2d, 0xbe,0x74,0xae,0x41,
0x3a,0xd3,0xed,0xf1, 0x67,0xee,0xe5,0x26,
0xd4,0x59,0xdc,0x3b, 0x6b,0xf7,0x33,0x67,
0xed,0xef,0xb0,0x5d, 0x5e,0x43,0x34,0xa2,
0x3d,0x55,0x16,0x99, 0x4b,0x90,0x49,0x40,
0x82,0x35,0x0d,0x82, 0xa6,0x16,0xd2,0x41,
0xc8,0x65,0xd4,0xe7, 0x1a,0xdb,0xad,0xe6,
0x48,0x5e,0xeb,0x94, 0xa6,0x9f,0x97,0x1e,
0xd4,0x38,0x5d,0xff, 0x6e,0x17,0x0c,0xd0,
0xb3,0xd5,0xb4,0x06, 0xd7,0xcb,0x8e,0xa3,
0x27,0x75,0x24,0xb5, 0x14,0xe9,0x55,0x94,
0x51,0x14,0xaf,0x15, 0x02,0xd3,0x9c,0x5f,
0x43,0xfe,0x97,0xf4, 0x0b,0x4e,0x4d,0x89,
0x15,0x33,0x4a,0x04, 0x10,0xf3,0xeb,0x13,
0x71,0x86,0xb4,0x8a, 0x2c,0x75,0x04,0x47,
0xb9,0x60,0xe9,0x2a, 0x5a,0xe8,0x7e,0x8b,
0x91,0xa7,0x01,0x49, 0xcf,0xfc,0x48,0x83,
0xa7,0x42,0xc8,0x2f, 0x80,0x92,0x04,0x64,
0x03,0xf7,0x9f,0x1d, 0xc2,0x82,0x0b,0x14,
0x65,0x4d,0x04,0x09, 0x13,0x5f,0xb8,0x66,
0x19,0x14,0x7a,0x09, 0xa7,0xf8,0x73,0x2d,
0x4d,0x90,0x86,0x14, 0x25,0xd6,0xd6,0xf5,
0x82,0x9c,0x32,0xab, 0x5c,0x37,0x12,0x28,
0xd1,0xfe,0xfa,0x0d, 0x90,0x8d,0x28,0x20,
0xb1,0x1e,0xbe,0x30, 0x80,0xd7,0xb1,0x63,
0xd9,0x23,0x83,0x0b, 0x9d,0xf5,0x0e,0x9c,
0xa2,0x88,0x5f,0x2c, 0xf2,0xa6,0x9d,0x23,
0x45,0x1c,0x9b,0x7a, 0xd2,0x60,0xa6,0x0f,
0x44,0xba,0x91,0x3d, 0xc6,0xf7,0xef,0x2f,
0x5c,0xa8,0x5e,0x2b, 0x50,0xd3,0xd1,0x85,
0xfd,0xed,0x52,0x48, 0xe2,0xd9,0xd2,0x12,
0x4e,0x03,0xc9,0x3d, 0x8f,0x8d,0x1f,0x8e,
0x6b,0xd8,0xe3,0x32, 0xa7,0x5b,0x39,0x57,
0x91,0x08,0x52,0x09, 0xa4,0x7a,0x40,0xc6,
0xcf,0xcf,0x68,0xba, 0xb1,0x97,0xf8,0x38,
0x94,0x1d,0x18,0x69, 0x80,0x6a,0x11,0x15,
0xc2,0xfb,0x2d,0x6c, 0xd1,0xd4,0x88,0x50,
0xbb,0xca,0x8c,0x56, 0x36,0xb6,0xc4,0x41,
0x97,0xe6,0xb0,0x5c, 0x7f,0x51,0x00,0x6f,
0x17,0xe5,0xde,0x27, 0xf7,0xb4,0x85,0x3b,
0xc5,0xa1,0x60,0x1c, 0xba,0x21,0xd6,0xed,
0xd5,0x08,0x62,0x80, 0xb4,0x85,0x52,0x15,
0x5c,0x94,0x19,0x3a, 0x10,0x92,0xa4,0x06,
0xf1,0x86,0x02,0xce, 0x94,0xd3,0xd5,0x33,
0xe7,0x59,0x47,0x72, 0x12,0xf4,0x8b,0x06,
0x29,0xa3,0xb0,0x39, 0x78,0x8f,0x46,0x56,
0x4a,0x42,0x4f,0x89, 0x1b,0x3f,0x09,0x12,
0xc4,0x24,0x0b,0x22, 0xf0,0x27,0x04,0x4d,
0x39,0xd8,0x59,0xc8, 0x7c,0x59,0x18,0x0a,
0x36,0xa8,0x3c,0xba, 0x42,0xe2,0xf7,0x7a,
0x23,0x90,0x73,0xff, 0xd6,0xa3,0xb2,0xcf,
0x60,0xc6,0x62,0x76, 0x61,0xa3,0xcd,0x53,
0x94,0x37,0x3c,0x24, 0x4b,0xc1,0xc5,0x3b,
0x26,0xf8,0x67,0x1d, 0xca,0xdd,0x08,0xcb,
0xdb,0x00,0x96,0x34, 0xd0,0x5d,0xef,0x4e,
0x64,0x18,0xb1,0xdc, 0x46,0x13,0xc1,0x8c,
0x87,0xbf,0xa3,0xfe, 0xd7,0x49,0x7e,0xb3,
0x94,0xe4,0x38,0x70, 0x2a,0xde,0xaf,0x73,
0x46,0xda,0xff,0xec, 0xfc,0x18,0xe2,0x02,
0x64,0x5f,0x9b,0xd2, 0xdf,0x8b,0xa8,0xd0,
0x4c,0xd7,0x5c,0xc7, 0x80,0x59,0x4d,0x66,
0x68,0xd3,0x4a,0x51, 0xc3,0x68,0xe2,0x0a,
0x17,0x31,0x4b,0xd7, 0x23,0x28,0x25,0x26,
0x4a,0xef,0x02,0xd7, 0x3a,0x53,0xdb,0x09,
0x19,0x85,0x68,0xab, 0xa9,0x8c,0xff,0x7e,
0x30,0xfb,0x42,0x08, 0xa1,0x5a,0xd1,0xc9,
0x3f,0xc9,0x00,0xfb, 0xd4,0x3e,0xb0,0x1c,
0x99,0xba,0xdc,0xb4, 0x69,0xe7,0xe1,0xb0,
0x67,0x53,0x46,0xa6, 0xc6,0x34,0x5c,0x94,
0xfa,0xd3,0x9b,0x48, 0x92,0xa1,0xd3,0xe5,
0xa7,0xea,0xe1,0x86, 0x5e,0x90,0x26,0x2d,
0x4b,0x85,0xe1,0x68, 0xee,0xc2,0xf1,0x25,
0xb7,0xff,0x01,0x96, 0x61,0x54,0xba,0xf3,
0x09,0x62,0x7f,0xa3, 0x92,0x6b,0xe7,0x00,
0xfc,0xd4,0x04,0xfd, 0x2d,0x42,0x7e,0x56,
0x91,0x33,0x6e,0xf8, 0x08,0x94,0xff,0xce,
0x03,0x7e,0x4d,0x0a, 0x91,0x41,0x4f,0xaa,
0xdd,0xd1,0x8c,0x34, 0x99,0x46,0xb5,0xfb,
0x0e,0x09,0x26,0xcc, 0x6d,0x35,0x58,0x0a,
0xc6,0xc0,0x89,0xa0, 0xbd,0xb6,0x89,0xd1,
0x51,0x64,0x85,0x96, 0x4d,0x6a,0x16,0x26,
0x30,0xb7,0xb3,0xe4, 0x80,0x46,0xaa,0x37,
0x4c,0x9b,0x2b,0xa3, 0x76,0x5e,0x8b,0x52,
0x13,0x42,0xe5,0xe3, 0xa8,0xe9,0xaf,0x83,
0x60,0xc0,0xb0,0xf8, 0x3d,0x82,0x0a,0x21,
0x60,0xd2,0x3f,0x1c, 0xb4,0xb5,0x53,0x31,
0x2e,0x16,0xfd,0xf3, 0xc3,0x46,0xfa,0xcc,
0x45,0x1f,0xd1,0xac, 0x22,0xe2,0x41,0xb5,
0x21,0xf3,0xdd,0x1f, 0x81,0xbf,0x03,0xaf,
0xd6,0x31,0xc1,0x6a, 0x2e,0xff,0xc1,0x2d,
0x44,0x53,0xd0,0xb5, 0xa2,0x7c,0x5f,0xf4,
0x47,0xf7,0x4d,0x1e, 0x77,0xe2,0x29,0xcc,
0xd2,0x46,0x85,0xfa, 0xdb,0x7f,0x46,0xf5,
0xc9,0x60,0x4a,0x2c, 0xb7,0xf2,0xa2,0x2c,
0x9d,0x76,0xcd,0x82, 0x67,0xae,0xbb,0xe0,
0x92,0x56,0x48,0xcb, 0xe5,0xf5,0x3c,0x2c,
0xe0,0xe8,0x6a,0x6a, 0x5a,0x0a,0x20,0x7c,
0xa6,0x9d,0x8e,0x84, 0xfa,0xfe,0x61,0x13,
0x54,0x79,0xe0,0x83, 0xd2,0x15,0xe0,0x33,
0xe4,0xf9,0xad,0xb8, 0x1e,0x75,0x35,0xd3,
0xee,0x7e,0x4a,0x63, 0x2f,0xeb,0xf1,0xe6,
0x22,0xac,0x77,0x74, 0xa1,0xc0,0xa0,0x21,
0x66,0x59,0x7c,0x48, 0x7f,0xaa,0x05,0xe8,
0x51,0xd9,0xc7,0xed, 0xb9,0xea,0x7a,0xdd,
0x23,0x53,0xea,0x8f, 0xef,0xaa,0xe6,0x9e,
0x19,0x21,0x84,0x27, 0xc5,0x78,0x2e,0x8c,
0x52,0x40,0x15,0x1c, 0x2b,0x91,0xb3,0x4c,
0xe8,0xfa,0xd3,0x64, 0x0f,0xf9,0xf4,0xb8,
0x59,0x4d,0x6b,0x2d, 0x44,0x6c,0x8d,0xb2,
0xdb,0x73,0x29,0x66, 0xb1,0xc2,0x28,0xfc,
0x85,0xba,0x60,0x5e, 0x27,0x8f,0xfb,0xb3,
0xc9,0x20,0x43,0xb1, 0x3e,0x18,0x97,0x42,
0x63,0x2d,0x0c,0x97, 0xf2,0xcc,0xcd,0x90,
0x46,0x5f,0x1a,0x85, 0xca,0x44,0x2a,0x1a,
0x52,0xf7,0xbb,0x4e, 0xd1,0xab,0xd5,0xa3,
0x58,0x6b,0xb6,0x5a, 0x88,0x1c,0x9d,0x3b,
0xe2,0x46,0xe4,0x3b, 0x33,0x64,0x6c,0xfd,
0xeb,0x36,0x8e,0x32, 0x1f,0x71,0xbd,0x95,
0xb6,0xfd,0x1a,0xcb, 0xfb,0x4a,0x88,0x27,
0xd6,0x28,0x7b,0x5e, 0xa3,0x8a,0x0c,0x36,
0xa8,0x5d,0x2f,0x28, 0xa9,0xad,0xb2,0x88,
0x9e,0x62,0x9d,0x4a, 0x07,0x74,0x00,0x04,
0x0c,0xc1,0x6a,0x09, 0xe1,0x0b,0xfa,0xf3,
0xd1,0x41,0xdd,0x94, 0x52,0x06,0xb8,0x9e,
0xba,0x81,0xe0,0x52, 0xdf,0x52,0x5d,0x74,
0x40,0x59,0x36,0x05, 0xf2,0x30,0xc4,0x84,
0x85,0xdc,0xb8,0xba, 0xd9,0xf4,0x5f,0x11,
0x83,0xce,0x25,0x57, 0x97,0xf5,0x0f,0xb5,
0x0b,0xd6,0x6d,0x1c, 0xfb,0xf2,0x30,0xda,
0xc2,0x05,0xa8,0xe1, 0xc2,0x57,0x0a,0x05,
0x2d,0x4c,0x8b,0xb7, 0x5a,0xc0,0x8a,0xba,
0xa9,0x85,0x7c,0xf0, 0xb8,0xce,0x72,0x79,
0xf5,0x27,0x99,0xd7, 0xed,0xcf,0x85,0xfa,
0x92,0x15,0xf1,0x47, 0x02,0x24,0x39,0x07,
0x89,0xb6,0xdd,0x4a, 0xb8,0xbc,0xd5,0x9d,
0x4c,0x03,0x8b,0x1d, 0x45,0x58,0x1c,0x86,
0x46,0x71,0x0a,0x0d, 0x7c,0x5b,0xf9,0xdc,
0x60,0xb5,0xb0,0x00, 0x70,0x47,0x83,0xa6,
0x8e,0x79,0xba,0x1d, 0x21,0x20,0xc0,0x24,
0x56,0x35,0x6a,0x49, 0xb6,0xa3,0x58,0x87,
0x16,0xae,0xd9,0x77, 0x62,0xa0,0x61,0xce,
0x3d,0xe6,0x77,0x9e, 0x83,0xec,0xc2,0x04,
0x8c,0xba,0x62,0xac, 0x32,0xda,0xf0,0x89,
0x7b,0x2b,0xb0,0xa3, 0x3a,0x5f,0x8b,0x0d,
0xbd,0xe9,0x14,0xcd, 0x5b,0x7a,0xde,0xd5,
0x0d,0xc3,0x4b,0x38, 0x92,0x31,0x97,0xd8,
0xae,0x89,0x17,0x2c, 0xc9,0x54,0x96,0x66,
0xd0,0x9f,0x60,0x7a, 0x7d,0x63,0x67,0xfc,
0xb6,0x02,0xce,0xcc, 0x97,0x36,0x9c,0x3c,
0x1e,0x69,0x3e,0xdb, 0x54,0x84,0x0a,0x77,
0x6d,0x0b,0x6e,0x10, 0x9f,0xfb,0x2a,0xb1,
0x49,0x31,0x71,0xf2, 0xd1,0x1e,0xea,0x87,
0xb9,0xd6,0x4a,0x4c, 0x57,0x17,0xbc,0x8b,
0x38,0x66,0x2d,0x5f, 0x25,0xca,0x6d,0x10,
0xc6,0x2e,0xd7,0x2c, 0x89,0xf1,0x4c,0x1d,
0xc9,0x9c,0x02,0x23, 0xc6,0x1f,0xd6,0xc3,
0xb8,0xc7,0x85,0x29, 0x75,0x40,0x1e,0x04,
0x6e,0xc7,0xb4,0x60, 0xfc,0xea,0x30,0x8b,
0x4d,0x9d,0xb7,0x5d, 0x91,0xfb,0x8e,0xb8,
0xc2,0x54,0xdf,0xdb, 0x79,0x58,0x32,0xda,
0xd0,0xa1,0xd6,0xd6, 0xc4,0xc8,0xa4,0x16,
0x95,0xbb,0xe5,0x58, 0xd2,0xb6,0x83,0x76,
0x1d,0xd7,0x45,0xbc, 0xb8,0x14,0x79,0x3b,
0x4e,0x1a,0x0b,0x5c, 0xfc,0xa5,0xa0,0xc3,
0xf1,0x64,0x74,0xb0, 0x0d,0x82,0x90,0x62,
0x87,0x02,0x0f,0x71, 0xc7,0xab,0x7d,0x2b,
0x70,0xf1,0x9b,0x9e, 0xe7,0x6b,0x99,0x18,
0x6c,0x54,0x17,0x0b, 0xf5,0x44,0x58,0x54,
0x44,0x9b,0x54,0x30, 0x5e,0xaf,0xa6,0xfa,
0x42,0x37,0xe8,0x67, 0xbf,0xf7,0x6c,0x1e,
0x73,0xd8,0xc7,0x5c, 0xfa,0x51,0xd5,0x1f,
0xab,0xfc,0x91,0x03, 0xc1,0xc1,0x22,0x58,
0xc7,0xe8,0x60,0xae, 0xb6,0x58,0x44,0xad,
0x1e,0x07,0x5d,0x3c, 0x90,0x33,0x43,0xe0,
0x67,0x44,0x9f,0x8c, 0xf3,0xef,0xce,0x3a,
0x22,0x2b,0x1b,0x97, 0x83,0x6f,0x9f,0xd3,
0x46,0xc3,0xa1,0xdf, 0xde,0x60,0xf0,0x32,
0x2e,0xcf,0xed,0x72, 0x27,0x0d,0xa7,0xd0,
0x91,0x6a,0xf0,0x6d, 0x41,0xfa,0x77,0x2e,
0xd8,0x43,0xce,0xe2, 0xf5,0x7a,0x9e,0x04,
0x30,0x4c,0xe7,0x08, 0xf3,0x2e,0x13,0x05,
0x5e,0xfa,0x16,0x2c, 0x6c,0x53,0x02,0xb5,
0x2f,0x2c,0x7d,0x86, 0x61,0x0e,0x5f,0x96,
0xe1,0x1c,0x37,0x87, 0xf0,0x84,0xe4,0x1d,
0x53,0x4d,0xb1,0x13, 0xe2,0xcb,0x71,0x6e,
0x86,0x7b,0xad,0x97, 0x3e,0x16,0xb3,0xb4,
0x0f,0x32,0x01,0x69, 0x31,0x1f,0x49,0x99,
0x7a,0x46,0xd9,0x9b, 0x5f,0x17,0x3d,0xcb,
0xe4,0xfd,0xbc,0xbb, 0xe3,0xec,0x8c,0x54,
0xc4,0x14,0x44,0x89, 0xa3,0x65,0x25,0xc0,
0x06,0x9b,0x7d,0x9b, 0x7f,0x15,0x8f,0x84,
0xe1,0x08,0x0d,0x2c, 0x0a,0x91,0x9a,0x85,
0x4e,0xa1,0x50,0xee, 0x72,0x70,0xf4,0xd2,
0x1c,0x67,0x20,0x1f, 0xe6,0xb2,0x9d,0x95,
0x85,0x7e,0xf2,0x9d, 0xf0,0x73,0x10,0xe7,
0xfc,0x62,0x9d,0xea, 0x8d,0x63,0xdc,0x70,
0xe0,0x2b,0x30,0x01, 0x7c,0xcd,0x24,0x22,
0x03,0xf9,0x8b,0xe4, 0x77,0xef,0x2c,0xdc,
0xa5,0xfb,0x29,0x66, 0x50,0x1c,0xd7,0x4e,
0x8f,0x0f,0xbf,0x61, 0x0c,0xea,0xc0,0xe6,
0xc6,0xc3,0xa1,0xae, 0xf3,0xea,0x4c,0xfb,
0x21,0x96,0xd1,0x38, 0x64,0xe0,0xdd,0xa8,
0xa4,0xd0,0x33,0x82, 0xf0,0xdd,0x91,0x6e,
0x88,0x27,0xe1,0x0d, 0x8b,0xfb,0xc6,0x36,
0xc5,0x9a,0x9d,0xbc, 0x32,0x8f,0x8a,0x3a,
0xfb,0xd0,0x88,0x1e, 0xe5,0xb8,0x68,0x35,
0x4b,0x22,0x72,0x55, 0x9e,0x77,0x39,0x1d,
0x64,0x81,0x6e,0xfd, 0xe3,0x29,0xb8,0xa5,
0x3e,0xc8,0x4c,0x6f, 0x41,0xc2,0xbd,0xb6,
0x15,0xd1,0xd5,0xe9, 0x77,0x97,0xb6,0x54,
0x9e,0x60,0xdd,0xf3, 0x48,0xdb,0x65,0x04,
0x54,0xa2,0x93,0x12, 0xf0,0x66,0x6c,0xae,
0xa2,0x2c,0xb9,0xeb, 0xf0,0x7c,0x9c,0xae,
0x8e,0x49,0xf5,0x0f, 0xfc,0x4b,0x2a,0xdb,
0xaf,0xff,0x96,0x0d, 0xa6,0x05,0xe9,0x37,
0x81,0x43,0x41,0xb2, 0x69,0x88,0xd5,0x2c,
0xa2,0xa9,0x9b,0xf2, 0xf1,0x77,0x68,0x05,
0x84,0x0f,0x6a,0xee, 0xd0,0xb5,0x65,0x4b,
0x35,0x18,0xeb,0x34, 0xba,0x09,0x4f,0xc3,
0x5a,0xac,0x44,0x5b, 0x03,0xf5,0xf5,0x1d,
0x10,0x04,0xfd,0xb5, 0xc4,0x26,0x84,0x13,
0x8a,0xde,0x8d,0xbb, 0x51,0xd0,0x6f,0x58,
0xc1,0xe5,0x9e,0x12, 0xe6,0xba,0x13,0x73,
0x27,0x3e,0x3f,0xf0, 0x4f,0x0f,0x64,0x6c,
0x0e,0x36,0xe9,0xcc, 0x38,0x93,0x9b,0xda,
0xf9,0xfd,0xc2,0xe9, 0x44,0x7a,0x93,0xa6,
0x73,0xf6,0x2a,0xc0, 0x21,0x42,0xbc,0x58,
0x9e,0xe3,0x0c,0x6f, 0xa1,0xd0,0xdd,0x67,
0x14,0x3d,0x49,0xf1, 0x5b,0xc3,0xc3,0xa4,
0x52,0xa3,0xe7,0x0f, 0xb4,0x26,0xf4,0x62,
0x73,0xf5,0x9f,0x75, 0x5b,0x6e,0x38,0xc8,
0x4a,0xcc,0xf6,0xfa, 0xcf,0xfb,0x28,0x02,
0x8a,0xdb,0x6b,0x63, 0x52,0x17,0x94,0x87,
0x71,0xa2,0xf5,0x5a, 0x1d,0x94,0xe3,0xcd,
0x28,0x70,0x96,0xd5, 0xb1,0xaf,0xec,0xd6,
0xea,0xf4,0xfc,0xe9, 0x10,0x66,0xd9,0x8a,
0x1e,0x03,0x03,0xf1, 0x54,0x2d,0xc5,0x8c,
0x85,0x71,0xed,0xa7, 0xa4,0x1e,0x5a,0xff,
0xab,0xb8,0x07,0xb3, 0x0b,0x84,0x00,0x0a,
0x7f,0xa5,0x38,0x20, 0x66,0x33,0x84,0x2f,
0xec,0x16,0x94,0x78, 0xa8,0x42,0x98,0x55,
0xa3,0xe5,0xd3,0x62, 0x2a,0xfc,0xed,0xec,
0x7a,0x96,0x41,0x35, 0xc0,0xd2,0xe6,0x53,
0xf8,0x0f,0x59,0x94, 0x0a,0xa0,0x50,0xef,
0x0d,0x9f,0x04,0x1c, 0x5f,0x48,0xfe,0x33,
0x20,0xca,0x8d,0x09, 0xdd,0x0b,0xf8,0x59,
0xd3,0x63,0x8a,0xa4, 0xf5,0x73,0x6b,0x3e,
0x7e,0x0f,0xff,0xdb, 0x96,0x62,0x4d,0x3a,
0xdb,0x8d,0x8c,0x9b, 0x8c,0xb3,0xa1,0xff,
0x16,0xb9,0x2c,0x8c, 0xf6,0xbb,0x0d,0x9e,
0x6f,0xff,0x24,0x6f, 0x59,0xee,0x02,0xe6,
0x57,0x38,0xbd,0x5f, 0xbd,0xd4,0xe5,0x74,
0x14,0xea,0x85,0xbb, 0x0c,0xfe,0xad,0xad,
0x98,0x82,0x8a,0x81, 0x0b,0x37,0xdc,0x7d,
0xda,0x13,0x74,0x8a, 0xa5,0xaf,0x74,0x82,
0x95,0x35,0x1f,0x0b, 0x03,0x88,0x17,0xf3,
0x67,0x11,0x40,0xd1, 0x9d,0x48,0xec,0x9b,
0xc8,0xb2,0xcc,0xb4, 0x93,0xd2,0x0b,0x0a,
0xd6,0x6f,0x34,0x32, 0xd1,0x9a,0x0d,0x89,
0x93,0x1f,0x96,0x5a, 0x7a,0x57,0x06,0x02,
0x1d,0xbf,0x57,0x3c, 0x9e,0xca,0x5d,0x68,
0xe8,0x4e,0xea,0x4f, 0x0b,0x11,0xf0,0x35,
0x73,0x5a,0x77,0x24, 0x29,0xc3,0x60,0x51,
0xf0,0x15,0x93,0x45, 0x6b,0xb1,0x70,0xe0,
0xda,0xf7,0xf4,0x0a, 0x70,0xd1,0x73,0x3f,
0x9c,0x9d,0x07,0x19, 0xad,0xb2,0x28,0xae,
0xf2,0xe2,0xb6,0xf4, 0xbc,0x71,0x63,0x00,
0xde,0xe3,0xdc,0xb1, 0xa3,0xd5,0x4c,0x34,
0xf8,0x6b,0x68,0x4c, 0x73,0x84,0xab,0xd4,
0x89,0xae,0x07,0x1a, 0x0d,0x3d,0x8e,0xaa,
0x6c,0xa2,0x54,0xb3, 0xd9,0x46,0x81,0x87,
0xe2,0xdc,0x49,0xb1, 0x14,0x5c,0xcc,0x72,
0x56,0xf0,0x0f,0xa9, 0x3d,0x31,0x2f,0x08,
0xbc,0x15,0xb7,0xd3, 0x0d,0x4f,0xd1,0xc9,
0x4e,0xde,0x1c,0x03, 0xd1,0xae,0xaf,0x14,
0x62,0xbc,0x1f,0x33, 0x5c,0x00,0xeb,0xf4,
0x8e,0xf6,0x3e,0x13, 0x6a,0x64,0x42,0x07,
0x60,0x71,0x35,0xf1, 0xd0,0xff,0x8d,0x1f,
0x88,0xc0,0x1c,0x3c, 0x6c,0x1c,0x54,0x71,
0x6b,0x65,0x4a,0xe2, 0xe3,0x5f,0x77,0x56,
0x1c,0x8d,0x2a,0x8d, 0xef,0x92,0x4a,0xa9,
0xf6,0xcf,0xa5,0x67, 0x89,0x8e,0x5a,0xd9,
0x60,0xaa,0x94,0x14, 0x55,0x66,0x8a,0xb0,
0x18,0x4f,0x9e,0x8e, 0xf4,0xdb,0xc1,0x88,
0x9b,0xf0,0x84,0x33, 0x2f,0xcd,0x2c,0xeb,
0x65,0xe6,0x5d,0xde, 0x30,0x97,0xad,0xe6,
0xbc,0xcb,0x83,0x93, 0xf3,0xfd,0x65,0xdc,
0x07,0x27,0xf9,0x0f, 0x4a,0x56,0x5c,0xf7,
0xff,0xa3,0xd1,0xad, 0xd4,0xd1,0x38,0x13,
0x71,0xc9,0x42,0x0f, 0x0d,0x35,0x12,0x32,
0xd2,0x2d,0x2b,0x96, 0xe4,0x01,0xdc,0x55,
0xd8,0x71,0x2c,0x0c, 0xc4,0x55,0x3f,0x16,
0xe8,0xaa,0xe7,0xe8, 0x45,0xfa,0x23,0x23,
0x5e,0x21,0x02,0xab, 0xc8,0x6b,0x88,0x5e,
0xdc,0x90,0x13,0xb5, 0xe7,0x47,0xfa,0x12,
0xd5,0xa7,0x0a,0x06, 0xd2,0x7c,0x62,0x80,
0xb7,0x8e,0x4f,0x77, 0x88,0xb7,0xa2,0x12,
0xdb,0x19,0x1f,0xd8, 0x00,0x82,0xf5,0xf2,
0x59,0x34,0xec,0x91, 0xa8,0xc1,0xd7,0x6e,
0x76,0x10,0xf3,0x15, 0xa6,0x86,0xfa,0xfd,
0x45,0x2f,0x86,0x18, 0x16,0x83,0x16,0x8c,
0x6e,0x99,0x7e,0x43, 0x3f,0x0a,0xba,0x32,
0x94,0x5b,0x15,0x32, 0x66,0xc2,0x3a,0xdc,
0xf3,0xd3,0x1d,0xd1, 0x5d,0x6f,0x5f,0x9a,
0x7f,0xa2,0x90,0xf1, 0xa1,0xd0,0x17,0x33,
0xdf,0x9a,0x2e,0xa2, 0xdc,0x89,0xe6,0xb0,
0xda,0x23,0x2b,0xf6, 0xe9,0x1f,0x82,0x3c,
0x07,0x90,0xab,0x3a, 0xb9,0x87,0xb0,0x02,
0xcc,0xb9,0xe7,0x2e, 0xe7,0xc6,0xee,0xfa,
0xe2,0x16,0xc8,0xc3, 0xd0,0x40,0x15,0xc5,
0xa7,0xc8,0x20,0x42, 0xb7,0x09,0xf8,0x66,
0xeb,0x0e,0x4b,0xd7, 0x91,0x74,0xa3,0x8b,
0x17,0x2a,0x0c,0xee, 0x7f,0xc1,0xea,0x63,
0xc6,0x3c,0x1e,0xea, 0x8b,0xa2,0xd1,0x2e,
0xf3,0xa6,0x0f,0x36, 0xff,0xdd,0x81,0x06,
0xe3,0x63,0xfc,0x0c, 0x38,0xb0,0x23,0xfb,
0x83,0x66,0x81,0x73, 0x5c,0x0b,0x9c,0xd4,
0x23,0xdc,0x7f,0x5c, 0x00,0x8c,0xa6,0xa7,
0x52,0xd4,0xc1,0x00, 0xea,0x99,0x6b,0x59,
0x19,0x8e,0x34,0x32, 0x24,0xea,0x0c,0x61,
0x95,0x9d,0xdb,0xf0, 0x63,0xcc,0xa9,0xfd,
0x1b,0xeb,0xd7,0xbc, 0x0c,0xa4,0x74,0x24,
0xfd,0xfa,0x32,0x58, 0xe3,0x74,0x1c,0x8f,
0x76,0xa6,0x53,0x0d, 0xea,0xde,0x50,0x92,
0xbd,0x3f,0x3d,0x56, 0x8f,0x48,0x4e,0xb7,
0x8c,0x5e,0x83,0x2c, 0xf7,0xec,0x04,0x2c,
0x35,0xdf,0xa9,0x72, 0xc0,0x77,0xf5,0x44,
0xe5,0xa7,0x56,0x3e, 0xa4,0x8d,0xb8,0x6e,
0x31,0x86,0x15,0x1d, 0xc4,0x66,0x86,0x75,
0xf8,0x1a,0xea,0x2f, 0x3a,0xb7,0xbf,0x97,
0xe9,0x11,0x53,0x64, 0xa8,0x71,0xc6,0x78,
0x8a,0x70,0xb5,0x18, 0xd7,0x9c,0xe3,0x44,
0x1a,0x7c,0x6b,0x1b, 0x41,0xe1,0x1c,0x0d,
0x98,0x43,0x67,0x28, 0xb8,0x14,0xb4,0x48,
0x01,0x85,0x79,0x20, 0x94,0x36,0x25,0x3a,
0x5c,0x48,0xd2,0x2e, 0x91,0x91,0xfd,0x85,
0x38,0xc1,0xc5,0xa5, 0x4d,0x52,0x1f,0xb4,
0xe7,0x44,0x7a,0xff, 0xb1,0x65,0xdf,0x53,
0x86,0x2a,0xff,0x25, 0x2b,0xeb,0x3e,0xdc,
0x3d,0xec,0x72,0xae, 0xa9,0xd1,0xdf,0xe9,
0x4a,0x3e,0xe8,0xf1, 0x74,0xe0,0xee,0xd6,
0x0b,0xba,0x9b,0x14, 0x9b,0x0c,0x4a,0xf9,
0x55,0xee,0x7e,0x82, 0xa4,0xb5,0xa5,0xb7,
0x2f,0x75,0x48,0x51, 0x60,0xcc,0x41,0x8e,
0x65,0xe3,0xb7,0x29, 0xe0,0x32,0xe7,0x1b,
0x2f,0xa0,0x80,0xce, 0x73,0x28,0x6c,0xf4,
0xd0,0xc7,0x05,0x69, 0xbd,0x3e,0x2e,0x77,
0x1a,0x7f,0x9a,0x98, 0x60,0x31,0xdb,0x47,
0xc2,0xa2,0x12,0xcb, 0x8c,0x35,0xff,0x58,
0xe3,0x07,0x22,0xe4, 0x2f,0x26,0x87,0x30,
0x16,0xea,0x64,0x4f, 0x44,0x64,0x3d,0xe4,
0x7b,0x41,0x06,0xca, 0xee,0x02,0xcf,0xf3,
0x26,0x4c,0xfe,0x9c, 0xf6,0x64,0x96,0xd4,
0xd9,0x7e,0x04,0x47, 0x1d,0xdb,0xc7,0x8c,
0xae,0xd7,0x9d,0xea, 0xe3,0x3a,0xee,0x24,
0xa9,0x2d,0x65,0xba, 0xd5,0x9f,0x38,0x81,
0x61,0x42,0x15,0xdf, 0xcc,0x29,0xd9,0xf7,
0xd4,0x30,0xb9,0xc9, 0x86,0x76,0xdc,0xee,
0xa5,0x27,0xa6,0x27, 0xa3,0xbb,0x8f,0x3b,
0xaa,0xca,0x01,0x52, 0x37,0x12,0xc0,0x55,
0x39,0x4a,0xb2,0xce, 0x85,0x73,0xf2,0x10,
0x9c,0x7f,0xa6,0x34, 0x7f,0x0f,0x69,0x63,
0x03,0xc4,0xde,0xe2, 0x7b,0x10,0xbf,0x91,
0x3e,0x7e,0xad,0xb7, 0xa8,0x85,0xc7,0x99,
0xae,0x8e,0x7c,0x2e, 0x02,0x25,0x5b,0xd5,
0xf4,0x46,0xd1,0x49, 0x48,0xa0,0x12,0x6a,
0x6a,0x01,0x23,0xb9, 0x7e,0x67,0x8b,0x48,
0xac,0xf7,0x88,0x88, 0xeb,0xd9,0x39,0x3a,
0xc8,0xa0,0x06,0xd9, 0x0b,0x80,0xc4,0x84,
},
.c = {
0x10,0x46,0xb6,0xc8, 0xaa,0x83,0x67,0x7b,
0xc5,0x9a,0x9a,0x0d, 0xe2,0xec,0x6f,0x9a,
0x3e,0x74,0xa7,0xfa, 0x43,0x93,0x9d,0xc5,
0x23,0x27,0xad,0x99, 0x74,0xb4,0xc0,0xe4,
0xd7,0x70,0x5c,0x95, 0x58,0xe3,0x8f,0x72,
0xe3,0x03,0x3d,0xc2, 0xd9,0x69,0x37,0x3e,
0x8e,0x2a,0x0c,0x2b, 0x75,0x59,0x05,0x18,
0x4a,0x50,0x67,0xd4, 0xf5,0x4b,0xb0,0x59,
0x08,0xaf,0xbc,0x6f, 0xb1,0x95,0xa1,0x32,
0xe7,0x77,0x1a,0xfd, 0xaf,0xe8,0x4d,0x32,
0x87,0x9c,0x87,0x90, 0x5e,0xe8,0x08,0xc3,
0xb4,0x0c,0x80,0x9a, 0x9e,0x23,0xeb,0x5a,
0x5c,0x18,0x4a,0x7c, 0xd0,0x4a,0x91,0x57,
0x7e,0x6c,0x53,0xde, 0x98,0xc0,0x09,0x80,
0x8d,0x41,0x0b,0xbc, 0x56,0x5e,0x69,0x61,
0xd3,0x56,0x48,0x43, 0x19,0x49,0x49,0xaf,
0xcf,0xad,0x98,0x3e, 0x88,0x4b,0x44,0x69,
0x73,0xd2,0xcb,0xdf, 0x30,0xdb,0x76,0x1d,
0xfb,0x4b,0xc5,0x66, 0x22,0x34,0x6f,0x07,
0x0b,0xcd,0x1c,0xed, 0x88,0xd9,0x0d,0x30,
0xe9,0x96,0xcb,0xf5, 0xde,0x57,0x5f,0x0b,
0x12,0x11,0xcf,0x52, 0xf5,0x0d,0xf8,0x29,
0x39,0x87,0xb2,0xa5, 0x7f,0x7a,0x2b,0x9d,
0x66,0x11,0x32,0xf4, 0xd4,0x37,0x16,0x75,
0xe3,0x0b,0x55,0x98, 0x44,0x6f,0xc7,0x5c,
0xd4,0x89,0xf8,0xb3, 0xee,0xe4,0x5e,0x45,
0x34,0xc2,0xc0,0xef, 0xdd,0x4d,0xbb,0xb4,
0x0a,0x7b,0xda,0xe3, 0x6e,0x41,0xe1,0xb4,
0x73,0xf8,0x9b,0x65, 0x1c,0x5f,0xdf,0x9c,
0xd7,0x71,0x91,0x72, 0x6f,0x9e,0x8f,0x96,
0x5d,0x45,0x11,0xd1, 0xb9,0x99,0x63,0x50,
0xda,0x36,0xe9,0x75, 0x21,0x9a,0xce,0xc5,
0x1a,0x8a,0x12,0x81, 0x8b,0xeb,0x51,0x7c,
0x00,0x5f,0x58,0x5a, 0x3e,0x65,0x10,0x9e,
0xe3,0x9e,0xf0,0x6b, 0xfe,0x49,0x50,0x2a,
0x2a,0x3b,0xa5,0x42, 0x1b,0x15,0x2b,0x5b,
0x88,0xb8,0xfb,0x6f, 0x0c,0x5d,0x16,0x76,
0x48,0x77,0x4d,0x22, 0xb9,0xf0,0x0a,0x3f,
0xa6,0xdd,0xc8,0x32, 0xcc,0x98,0x76,0x41,
0x84,0x36,0x24,0x6d, 0x88,0x62,0x65,0x40,
0xa4,0x55,0xdc,0x39, 0x74,0xed,0x0f,0x50,
0x08,0xcf,0x69,0x5f, 0x1d,0x31,0xd6,0xb4,
0x39,0x94,0x5b,0x18, 0x88,0x0f,0xcb,0x56,
0xfb,0xf7,0x19,0xe0, 0x80,0xe0,0x4f,0x67,
0x9c,0xab,0x35,0x78, 0xc9,0xca,0x95,0xfa,
0x31,0xf0,0x5f,0xa6, 0xf9,0x71,0xbd,0x7f,
0xb1,0xe2,0x42,0x67, 0x9d,0xfb,0x7f,0xde,
0x41,0xa6,0x7f,0xc7, 0x7f,0x75,0xd8,0x8d,
0x43,0xce,0xe6,0xeb, 0x74,0xee,0x4e,0x35,
0xbc,0x7b,0x7c,0xfc, 0x8b,0x4f,0x1f,0xa2,
0x5e,0x34,0x3b,0x5f, 0xd0,0x05,0x9d,0x4f,
0xfe,0x47,0x59,0xa3, 0xf6,0xb7,0x27,0xb0,
0xa1,0xec,0x1d,0x09, 0x86,0x70,0x48,0x00,
0x03,0x0a,0x15,0x98, 0x2e,0x6d,0x48,0x2a,
0x81,0xa2,0xde,0x11, 0xe4,0xde,0x8b,0xb0,
0x06,0x28,0x03,0x82, 0xe4,0x6e,0x40,0xfb,
0x3c,0x35,0x2d,0x1b, 0x62,0x56,0x87,0xd4,
0xd6,0x06,0x36,0xce, 0x70,0x26,0x2f,0x21,
0xf5,0x47,0x3f,0xf8, 0x57,0x17,0xa9,0x15,
0x30,0xfd,0x1f,0xa6, 0x7a,0x24,0x1c,0xf8,
0x33,0xf3,0xef,0xe1, 0x6c,0xb5,0x0b,0x04,
0x21,0x5d,0xb5,0xff, 0x4f,0xdb,0xd1,0x3d,
0x8f,0x01,0x56,0x7f, 0x0b,0xa4,0xf1,0xf9,
0xdd,0xa3,0x38,0xcb, 0xa9,0xd3,0xdd,0xe3,
0x29,0x5b,0x2b,0x22, 0xd7,0xe8,0x4f,0x02,
0xb1,0x73,0x83,0x80, 0xda,0xd0,0x8e,0x11,
0x9f,0x4d,0xd4,0x0a, 0x86,0x45,0x11,0xa1,
0x9e,0x2e,0xa9,0x59, 0x6d,0x95,0x49,0xc5,
0xc9,0xcd,0x7c,0x71, 0x81,0xac,0x6b,0xb8,
0x1b,0x94,0xe8,0xe3, 0xb2,0xb7,0x8a,0x9b,
0xda,0x5b,0xb7,0xc6, 0x00,0xcb,0x40,0x47,
0x0c,0x38,0x75,0xb8, 0xba,0x6f,0x2b,0x9d,
0x01,0xf3,0xf2,0xc8, 0xf7,0xde,0xcf,0xfb,
0x82,0xa8,0x8f,0x10, 0x75,0x0e,0x27,0xc5,
0x4b,0x9f,0xfe,0x1d, 0x60,0x84,0x69,0x96,
0xac,0xb1,0xd3,0xdd, 0x07,0x4c,0x50,0x94,
0xb1,0x17,0x53,0x23, 0x98,0xbf,0x22,0xf9,
0x2c,0xb0,0x3f,0x62, 0x16,0xa7,0x8f,0xea,
0x43,0x25,0xfb,0x21, 0x18,0xec,0x1a,0xf6,
0x5e,0x64,0xbd,0x3d, 0xcf,0x27,0xf5,0x02,
0xf2,0xaf,0x1b,0x2d, 0x2c,0xcb,0xaa,0x6d,
0x7d,0xa0,0xae,0x31, 0x05,0x51,0x80,0x7f,
0x99,0xcf,0xbd,0x0f, 0x12,0x5a,0xda,0x4a,
0x56,0x22,0xd4,0x22, 0x95,0x2c,0x46,0x5a,
0xb3,0x5a,0x5e,0xd4, 0x27,0x7f,0x06,0xbd,
0x3c,0xf6,0xf2,0x0f, 0x9d,0xbb,0x0c,0x14,
0x8c,0xb1,0x72,0xf2, 0xb0,0xaf,0xda,0xf7,
0x05,0x33,0x78,0x9c, 0x79,0xe9,0xe0,0xc5,
0x8c,0x4b,0x23,0x65, 0xd1,0x70,0x81,0x3d,
0x74,0xfa,0xb6,0xff, 0xf2,0x65,0x21,0x3f,
0xe4,0xc2,0x9e,0x9d, 0x49,0x0e,0xad,0xaf,
0xc2,0x21,0x18,0xa8, 0x19,0xa8,0x69,0x32,
0xcb,0x8e,0xc2,0x9d, 0xf5,0xbd,0x50,0x60,
0x72,0xa2,0xa6,0xad, 0xe6,0x6b,0xd2,0x01,
0x52,0xf9,0xac,0x18, 0xfa,0xe8,0x8d,0x4a,
0x98,0x25,0xd3,0xa8, 0x0e,0x97,0x2d,0xa3,
0xf6,0xf1,0x34,0x7c, 0xf0,0x15,0x06,0x05,
0x31,0xdf,0xc7,0x86, 0x54,0xfb,0x62,0xe2,
0xd5,0x3b,0x72,0xd2, 0x70,0x7c,0x3c,0x62,
0x2f,0xbd,0x47,0x0d, 0x20,0x97,0xf5,0x1f,
0xa1,0xe8,0x4c,0x3e, 0x13,0xec,0xb3,0xcc,
0xc9,0x15,0x01,0x23, 0xe5,0x1f,0x3b,0x2e,
0xc5,0xdd,0x71,0xe3, 0xfa,0x6a,0x44,0x07,
0x25,0x64,0xa5,0xa5, 0x16,0x64,0x14,0xb8,
0x86,0xb1,0xae,0x6f, 0xc5,0xdb,0x6b,0xfa,
0x0f,0x8f,0xc5,0x89, 0x57,0x52,0xeb,0xb3,
0xca,0x4e,0x23,0xac, 0xbd,0xad,0xf5,0x77,
0x58,0x72,0x18,0x2c, 0xb8,0x37,0x0b,0xfd,
0xfd,0x04,0x49,0x4a, 0x7b,0x11,0x82,0x1b,
0xc4,0x5f,0x54,0x46, 0x97,0xe9,0xac,0x64,
0xa7,0x13,0x04,0x56, 0x5a,0x3b,0x17,0x2c,
0x08,0xff,0xa4,0xe2, 0xe4,0x43,0x05,0xfa,
0x94,0x3a,0xbc,0x24, 0xec,0xa8,0x89,0x02,
0xd0,0xbc,0xcf,0x4a, 0xef,0x0f,0x90,0x50,
0xfb,0x6a,0x25,0x4f, 0xdb,0x67,0x5b,0xd8,
0xa1,0x1e,0x95,0x4d, 0xe5,0xd6,0xf3,0x22,
0x2e,0x6f,0x01,0x50, 0xd8,0x2f,0x91,0x47,
0x82,0x0e,0xae,0x18, 0xbf,0x3a,0xc9,0x5a,
0x71,0xcf,0x5e,0xbf, 0x9e,0xec,0x1d,0x11,
0x96,0x33,0x32,0x5e, 0x5e,0xee,0xc8,0xee,
0x52,0x03,0xbc,0x8d, 0x97,0xd2,0x55,0xc5,
0xaf,0x52,0xb0,0x55, 0x8f,0xb8,0x9b,0x83,
0x60,0x9f,0x60,0x92, 0x47,0x1d,0xf2,0x6e,
0xd1,0x93,0xfe,0xc2, 0x77,0x8c,0xb6,0x49,
0x5e,0x3e,0xdb,0xb9, 0x7a,0x58,0x4d,0x18,
0x66,0xc8,0xc2,0x67, 0xf8,0x37,0x7d,0x06,
0x50,0xcc,0x42,0xab, 0x08,0x27,0x8e,0x81,
0x6f,0xb3,0x03,0xbd, 0x41,0x11,0xeb,0x13,
0xf1,0xaf,0xee,0x56, 0xae,0xb3,0x36,0x41,
0xb8,0xc9,0x0a,0x96, 0x88,0x1d,0x98,0x25,
0xc6,0x45,0xeb,0x76, 0x07,0xc1,0xfe,0xae,
0xbc,0x26,0x1f,0xc4, 0x5f,0x70,0x0c,0xae,
0x70,0x00,0xcf,0xc6, 0x77,0x5c,0x9c,0x24,
0x8b,0x4b,0x83,0x32, 0x09,0xb7,0xb1,0x43,
0x4a,0x01,0x42,0x04, 0x4d,0xca,0x5f,0x4e,
0x9b,0x2b,0xa9,0xcb, 0x99,0x0b,0x0e,0x57,
0x09,0xd6,0xe2,0xa0, 0xc1,0x12,0x79,0xf2,
0x6f,0xe1,0x6c,0x7f, 0x0a,0x1a,0xec,0xc1,
0x82,0x4a,0xf8,0x98, 0x22,0xc9,0x81,0x81,
0x5d,0xf8,0x7d,0x9d, 0x86,0x97,0xdd,0x9e,
0x8a,0xb5,0xce,0x6c, 0xfb,0x06,0xc3,0x8a,
0x0d,0x53,0xda,0x12, 0x0c,0x4b,0x6f,0xa0,
0x3f,0x8d,0xc3,0x07, 0x27,0x10,0xaf,0xc5,
0x27,0xfe,0x64,0x17, 0x18,0xa5,0x3a,0xfe,
0x9b,0x91,0xae,0xd0, 0x2d,0x34,0x34,0x9e,
0x9f,0x31,0x5d,0x3e, 0x4c,0x26,0x1e,0xcb,
0x62,0x05,0xd2,0x83, 0x8d,0x71,0xb8,0x57,
0xef,0x3a,0x94,0xb3, 0x3a,0x67,0x1b,0x21,
0x33,0x1f,0x7f,0x10, 0xd8,0xd7,0x89,0x1b,
0x4f,0x51,0x74,0x97, 0x4a,0x0e,0x74,0x59,
0x74,0x66,0xef,0xdd, 0x26,0xb6,0xa1,0x53,
0xd4,0x2f,0xd7,0x76, 0x51,0x27,0xcc,0xe4,
0x94,0xe3,0xed,0x26, 0x13,0x4e,0xe8,0x2c,
0x11,0x6e,0xb3,0x63, 0x51,0x36,0x9c,0x91,
0x2d,0x66,0x2c,0x3e, 0x0a,0xf7,0xa4,0x97,
0x70,0x6d,0x04,0xaa, 0x89,0xe8,0x2c,0x5e,
0xdd,0x01,0x46,0xfc, 0x99,0xce,0xe6,0x32,
0x8a,0x85,0xe6,0x07, 0x1e,0x71,0x5d,0x29,
0x07,0x16,0x0e,0xf9, 0xd4,0xdf,0x54,0xb4,
0x7b,0x7b,0x3f,0xe0, 0xeb,0x73,0xe0,0xe1,
0x92,0x51,0x50,0x74, 0xb5,0x6e,0x08,0x7e,
0x57,0x70,0xb2,0x1b, 0x9c,0xf2,0xa2,0x6b,
0x52,0xa3,0x35,0xf7, 0x22,0x40,0xa6,0x11,
0x30,0xd3,0x5b,0x4b, 0x78,0xc9,0xd7,0x84,
0x9a,0x88,0x9a,0x44, 0xb4,0x88,0xfe,0x8c,
0x3f,0x10,0xab,0xc7, 0xc9,0xb6,0x59,0x9a,
0xf3,0xe6,0xe6,0x4d, 0xea,0x3e,0xe0,0xeb,
0x9e,0xb4,0x41,0xf6, 0xcb,0xfc,0x04,0x73,
0x7d,0xc8,0x00,0xc6, 0xf2,0x10,0x00,0xcf,
0x59,0xed,0x05,0x2a, 0x6a,0xde,0x7a,0xdf,
0x7d,0xa9,0x25,0xc8, 0x6e,0x08,0x60,0xf9,
0xd8,0x23,0x9b,0x20, 0xe5,0x93,0x9c,0x90,
0x3d,0xe0,0xd0,0x33, 0x2d,0xce,0x86,0x93,
0xdc,0xb3,0x9c,0x40, 0x33,0x9a,0xf0,0x71,
0x47,0x0e,0xc4,0xb9, 0x58,0xc4,0x36,0xf1,
0x4c,0x82,0xcf,0x91, 0x9f,0x16,0xce,0x43,
0x58,0x72,0x54,0x51, 0x0d,0x8e,0x1e,0x3d,
0x5e,0x67,0x7e,0x96, 0x6e,0x12,0xb8,0xee,
0x1f,0x8b,0x15,0x3b, 0x49,0x95,0x2f,0xd9,
0xec,0x63,0x56,0xec, 0x4e,0x88,0x37,0x2f,
0xa7,0xd5,0xe5,0x4a, 0x97,0x1f,0x6f,0xa0,
0x40,0x68,0x69,0xee, 0x6a,0xc6,0xbe,0x83,
0xba,0x69,0xb8,0x08, 0x0a,0x5c,0x2f,0xd2,
0x3e,0x3b,0x73,0x40, 0x9c,0x62,0xcc,0xe1,
0x99,0x44,0xa2,0xaa, 0xb8,0xe9,0x48,0xf4,
0x79,0x07,0xe8,0xe8, 0x16,0x99,0x84,0x7b,
0x3d,0x53,0xb2,0x5d, 0x2d,0xa4,0xb0,0x12,
0xb9,0xa9,0x0d,0x77, 0x98,0xa1,0x98,0x90,
0x4e,0xe2,0x14,0xd4, 0x15,0x35,0xd0,0x85,
0xbf,0xa1,0x0f,0x54, 0x05,0xa0,0x90,0x2a,
0x74,0xe3,0xd3,0x1b, 0x5e,0x16,0x07,0xcf,
0x36,0xbd,0xea,0x9b, 0x2d,0x35,0x47,0xea,
0xea,0xb7,0xd1,0xda, 0x66,0x47,0x42,0x47,
0x4e,0x76,0xe5,0x90, 0x0c,0x82,0x15,0x3f,
0x17,0x1b,0xa6,0x04, 0xb6,0x58,0x67,0x42,
0xfb,0x19,0x2a,0xc2, 0xd7,0x6a,0x48,0x36,
0x87,0x53,0x90,0x95, 0x53,0xb7,0xf1,0xbe,
0x0d,0x9f,0xa3,0x74, 0x5f,0x3d,0x89,0xef,
0x29,0x07,0xe1,0xc1, 0x13,0xe0,0xc7,0xf6,
0x53,0xc2,0xe5,0x7e, 0x96,0xdf,0x1f,0x12,
0x98,0xd6,0x7b,0x2d, 0xdb,0x3e,0x01,0x03,
0x05,0xbe,0x66,0x29, 0x42,0xeb,0x5d,0xab,
0xa8,0x13,0x78,0x7f, 0x1e,0x0e,0xfd,0x7f,
0xf1,0xd2,0x59,0xb2, 0x46,0x13,0x1c,0xb8,
0x42,0x4f,0x87,0xb3, 0x26,0x0b,0xed,0x26,
0xb2,0xd5,0x27,0xfc, 0xf1,0xec,0x32,0x66,
0xe1,0x2d,0x27,0x2a, 0xe2,0x80,0xf2,0x72,
0x90,0x3c,0x54,0xfa, 0xaa,0xe6,0x31,0xb0,
0xb7,0xdd,0x97,0x0d, 0x22,0xb5,0x16,0x46,
0x66,0x6d,0x02,0x13, 0x9a,0x7c,0x52,0xfc,
0xf8,0x73,0x0c,0x81, 0xac,0xa3,0x8f,0x40,
0x50,0x2e,0x80,0x3b, 0xb6,0xdf,0x88,0xbb,
0xb5,0xa8,0x13,0xfa, 0xd2,0xd6,0xb8,0x07,
0x47,0x7b,0xa0,0x09, 0x9f,0xc3,0x42,0xab,
0xb8,0xd6,0xca,0xfa, 0x41,0xdc,0x9a,0xb5,
0x96,0xf4,0xfa,0xfd, 0x09,0xca,0x8e,0x47,
0x1d,0x8f,0x8d,0x54, 0x3f,0xbf,0xfd,0x22,
0x30,0x25,0xbd,0xea, 0xb3,0xf6,0x90,0x68,
0x6e,0x2b,0x78,0x8e, 0xc4,0x58,0x1c,0xbd,
0x6b,0x36,0xdc,0x9d, 0x9f,0x27,0xce,0xf6,
0x4f,0x1b,0xeb,0x41, 0x2c,0x07,0xa1,0x1f,
0xaa,0xc3,0x65,0xe0, 0x78,0x85,0x80,0x22,
0x00,0x94,0x1a,0x9f, 0x34,0x2b,0x2b,0x51,
0x94,0x93,0x23,0x20, 0x48,0x2e,0x16,0xd6,
0xdf,0x09,0xa2,0xfa, 0xb8,0x9b,0xf0,0x64,
0x18,0x36,0x78,0xbc, 0xb8,0x5b,0x87,0x90,
0xba,0xd2,0x2e,0x30, 0xe6,0xc5,0xe0,0x0c,
0x81,0x32,0x69,0x9a, 0x8a,0x5a,0x3d,0x6f,
0x06,0xe1,0x3f,0xa9, 0xf2,0x0e,0x21,0xfe,
0x9e,0x63,0x31,0xa9, 0xc3,0x3e,0xb4,0xcd,
0xcb,0x60,0xd9,0x45, 0xc6,0x5f,0xc5,0xca,
0x9e,0xd8,0x40,0x72, 0x39,0x04,0x59,0x2d,
0x4c,0xac,0xdf,0xea, 0x4a,0x78,0xa9,0xd5,
0x87,0xb1,0xd6,0x59, 0x77,0x58,0x4d,0xa7,
0xd3,0x9b,0xfc,0xe3, 0xdd,0x8d,0xf5,0x57,
0x06,0xb3,0x96,0xf1, 0xbe,0xd9,0x07,0x54,
0x36,0xa4,0x8b,0xaa, 0x0b,0xcb,0xd3,0x80,
0x13,0xa6,0x53,0x8e, 0xcc,0x23,0x15,0x02,
0x1e,0x1b,0x2f,0x0a, 0x02,0x5b,0xca,0x50,
0x11,0x28,0x27,0x0e, 0xbe,0xfe,0x76,0x60,
0x1b,0x78,0x58,0x9b, 0xe6,0x0a,0x0a,0xef,
0xa3,0xa5,0x33,0x0d, 0x5b,0x65,0xe1,0x03,
0x38,0xdd,0xf8,0x22, 0x92,0xcd,0x50,0x87,
0x02,0xbc,0x91,0x16, 0xfd,0x05,0x9c,0xcd,
0x72,0xae,0x4c,0xd7, 0xef,0xb3,0x57,0x1a,
0x3f,0x79,0x23,0xfd, 0xf0,0xc3,0xfb,0x68,
0xb4,0xc9,0x93,0x22, 0x33,0xd3,0x01,0x74,
0xe3,0x00,0x31,0xcf, 0x0f,0x23,0xc5,0xf7,
0x09,0x95,0x5a,0xa0, 0x56,0xf9,0xb0,0x20,
0xb1,0xcc,0x8d,0x88, 0xd6,0x27,0x97,0x8d,
0x0e,0xa3,0x3d,0x33, 0x94,0x04,0x44,0x93,
0x67,0x10,0xb6,0xa0, 0x0c,0x2a,0x28,0xd4,
0x1b,0x41,0x86,0xe7, 0x29,0x2c,0x68,0x2a,
0x94,0xf3,0x4f,0x20, 0xa1,0xb4,0x6c,0x9d,
0x85,0x6b,0xa0,0x31, 0xa2,0xbd,0x74,0xf0,
0x0b,0xe5,0x2f,0xb7, 0x8a,0x33,0xd9,0x1f,
0xf2,0xb5,0xad,0x85, 0xc3,0xad,0x47,0x2f,
0x27,0x2a,0xc9,0x32, 0xd8,0xd9,0x05,0xc2,
0x9d,0xbf,0x21,0x88, 0x02,0x05,0x12,0x6e,
0x0f,0xb6,0x64,0x43, 0xa8,0xc3,0x87,0xea,
0xb0,0x81,0x5b,0x51, 0x51,0xf1,0x83,0x7d,
0x94,0x46,0x7f,0x0a, 0x9a,0xef,0xcc,0x68,
0x73,0xef,0x9d,0x3c, 0x0e,0xfc,0x37,0x91,
0xca,0x36,0x2d,0x1d, 0x72,0x7e,0x39,0x9e,
0xad,0xd3,0x55,0x1b, 0x10,0x1e,0xff,0x00,
0xc1,0x45,0x80,0xe7, 0xb4,0xcc,0xc8,0xb0,
0x62,0xbd,0xf9,0xa5, 0x8f,0x05,0xaa,0x3b,
0x86,0x73,0x14,0xf9, 0xee,0x95,0xd0,0xfd,
0x95,0x30,0x68,0x22, 0xc9,0x70,0x66,0x1d,
0x91,0x3f,0xc0,0x19, 0x93,0x07,0x19,0x2d,
0x3c,0x21,0x6b,0xc1, 0x2a,0xeb,0xaa,0xf2,
0xa4,0x45,0x35,0xff, 0x8f,0x24,0x46,0x2c,
0xc8,0x75,0x58,0x68, 0x0f,0x3b,0x87,0x11,
0xcb,0x9f,0xf7,0x28, 0xbd,0x66,0x91,0x01,
0xeb,0x70,0x8e,0x8d, 0xe6,0x01,0xc8,0x48,
0x94,0xfe,0x4e,0xa8, 0xeb,0x90,0xbf,0xd1,
0xcd,0x89,0xc2,0x98, 0x34,0x92,0xf9,0x08,
0xb9,0xbc,0xd4,0x34, 0x1a,0x59,0xcc,0x80,
0x9a,0xe6,0xbc,0xbb, 0x23,0x12,0x9c,0xa4,
0x5b,0x79,0xc6,0x8a, 0xc0,0x03,0x2b,0x16,
0xe5,0x1c,0x0f,0x02, 0x37,0x4f,0x3e,0xc2,
0xf3,0x4d,0x7c,0xcb, 0xde,0x9b,0x66,0x52,
0xf3,0xdd,0x86,0x42, 0x4a,0x81,0x5b,0x96,
0x83,0x2a,0xb1,0x48, 0x31,0x42,0x16,0x16,
0xf8,0x97,0xa3,0x52, 0xeb,0xb6,0xbe,0x99,
0xe1,0xbc,0xa1,0x3a, 0xdd,0xea,0x00,0xfa,
0x11,0x2f,0x0b,0xf8, 0xc7,0xcc,0xba,0x1a,
0xf3,0x36,0x20,0x3f, 0x59,0xea,0xf1,0xc8,
0x08,0xd0,0x6d,0x8e, 0x91,0x1e,0x90,0x91,
0x7b,0x80,0xdc,0xcb, 0x5c,0x94,0x74,0x26,
0xd3,0x5d,0x1a,0x2d, 0xad,0xcf,0xef,0xfa,
0xe9,0xa0,0x17,0xb7, 0x2b,0x7c,0x37,0x83,
0x31,0x78,0x1a,0xcf, 0x04,0xa0,0xe7,0x83,
0x66,0x12,0x4f,0x9d, 0x31,0x6b,0x4d,0xc5,
0x31,0x1b,0x3a,0xd9, 0x79,0x76,0x49,0xc3,
0x19,0xf0,0x3f,0xb5, 0xbc,0x7d,0xa4,0xa7,
0x24,0x44,0x75,0xbb, 0x6d,0x65,0x59,0xf8,
0xe0,0xb9,0xd7,0x29, 0x79,0xce,0x14,0x32,
0xd2,0x3e,0xb8,0x22, 0x4a,0x0a,0x2a,0x6c,
0xb2,0xbd,0xa5,0xd4, 0xc4,0xc5,0x68,0xb3,
0x63,0xe7,0x46,0x05, 0x3a,0x18,0xa5,0xad,
0xcc,0x61,0xc3,0xec, 0x3d,0x42,0xb0,0xa7,
0x23,0x72,0x1e,0x14, 0xd8,0x7e,0x68,0x60,
0xec,0xe9,0x1d,0x5b, 0x1f,0x86,0xda,0x5e,
0x34,0x74,0x00,0xd3, 0x98,0x98,0x7e,0xbd,
0x6a,0x8b,0xd3,0x6f, 0x31,0xf1,0x62,0xb3,
0xa3,0x86,0x95,0x02, 0x76,0x7d,0x58,0xbc,
0xf8,0xb1,0x52,0xc3, 0x0b,0xd5,0x6b,0x74,
0xa5,0x84,0xef,0xf2, 0x31,0xc1,0xe4,0x83,
0x42,0x12,0xb5,0xe7, 0x61,0xdd,0xba,0x43,
0x39,0xf2,0x44,0x0a, 0xb4,0x62,0x06,0x32,
0x5b,0x33,0x67,0x2e, 0x7a,0x93,0x85,0x1a,
0x07,0x36,0x9f,0xab, 0xf7,0x2a,0x6e,0x3d,
0x3e,0xe3,0x59,0x1b, 0xf8,0xd3,0xe8,0x5f,
0xe5,0x24,0xb3,0x59, 0x80,0xd5,0x11,0x14,
0x98,0x3a,0xb4,0x7d, 0x8f,0x37,0x18,0xb2,
0xa7,0x25,0xf4,0x31, 0x74,0x61,0x3a,0x42,
0x62,0x77,0x37,0x3d, 0x72,0x1b,0x67,0x87,
0xb3,0x59,0x4b,0x08, 0x07,0xdb,0x0b,0x57,
0xfd,0x61,0x99,0x28, 0x3b,0xe5,0x7a,0xb4,
0x6c,0x06,0x95,0x65, 0x2c,0x1c,0x41,0x71,
0x21,0xd7,0x94,0x51, 0x1c,0x8d,0xe6,0x38,
0xc5,0x95,0x7f,0x30, 0xd5,0xc5,0xcc,0xd2,
0x03,0x7f,0x69,0x2e, 0xae,0xc7,0x28,0x2e,
0xc6,0xa9,0x28,0x4b, 0x77,0xc3,0xcf,0xa3,
0xc3,0xd3,0x2d,0x43, 0x47,0x87,0xde,0x38,
0xeb,0x3a,0xb6,0xf9, 0xe7,0x3c,0xb6,0x92,
0x19,0x42,0xf8,0xc2, 0x87,0x50,0xed,0xe6,
0x3d,0x2b,0xb5,0xf8, 0x89,0x14,0x42,0xf7,
0x2c,0x7a,0xbe,0xdc, 0x2f,0x5d,0x49,0x83,
0xf5,0x60,0xe0,0xcf, 0xbc,0x23,0x13,0x4f,
0xb3,0x16,0xd7,0x9a, 0xca,0x16,0x8b,0xa5,
0x08,0x80,0xcf,0x21, 0xbb,0xd8,0x32,0x5e,
0x07,0x8a,0xb3,0x48, 0xba,0x99,0xd4,0xd7,
0x6a,0xae,0x4b,0x9b, 0xb4,0xd7,0x2f,0x87,
0xb0,0x0a,0xd1,0x1b, 0xf1,0x8b,0xf6,0x21,
0x81,0x8e,0xc4,0x79, 0x9a,0x5c,0x75,0xbe,
0x87,0x99,0xe5,0x11, 0xf9,0x9a,0xe1,0xf9,
0x76,0xa2,0x92,0xc6, 0xc0,0xd8,0x05,0xc9,
0x7d,0x8c,0x27,0xc2, 0x7f,0xf4,0xe9,0x4f,
0xb7,0xbc,0xa3,0x3e, 0x66,0x3b,0xaf,0xed,
0x7a,0xd9,0x78,0x20, 0x6b,0xd5,0xe1,0xfe,
0xd5,0x06,0x65,0x11, 0x49,0xac,0x22,0x38,
0x02,0x80,0xec,0x91, 0x11,0x18,0x1a,0x61,
0x3c,0x59,0x4e,0x7a, 0xd8,0xca,0xda,0xd4,
0x27,0xbd,0xf4,0x00, 0x9c,0x1b,0xde,0xf3,
0x6c,0x1f,0x20,0x9a, 0x30,0xc9,0x9b,0x3c,
0xe5,0x55,0xb7,0xb3, 0xc8,0x52,0x9c,0x05,
0xad,0xe8,0x13,0x9e, 0x31,0xc2,0x2c,0xd4,
0x3f,0x18,0x00,0xc4, 0xcf,0x08,0x05,0x7b,
0x5e,0x2a,0x8e,0x11, 0x61,0x03,0xc8,0x39,
0x2b,0x54,0x1a,0xd9, 0x08,0x04,0xc6,0xe9,
0xda,0x69,0xb3,0x0c, 0x83,0x44,0xcd,0xe8,
0x50,0x04,0x72,0xa2, 0xb4,0x10,0x17,0x39,
0x68,0x32,0xdb,0xab, 0xe3,0xee,0x57,0x1b,
0x05,0x45,0x1f,0x5a, 0xdc,0xdc,0x56,0x81,
0x98,0x20,0xfe,0x69, 0x0a,0xa4,0xd6,0x9d,
0x25,0xdd,0x7e,0xd0, 0x2b,0x33,0x41,0x75,
0xf6,0x59,0xa8,0xa3, 0x3c,0xdd,0xd9,0x6b,
0xa8,0xcd,0x1d,0x1f, 0xc5,0x78,0x5b,0x93,
0xdf,0x10,0x71,0xeb, 0xcc,0xbd,0x35,0x4c,
0x07,0x21,0x5f,0xb7, 0x47,0x21,0x6d,0x55,
0x8b,0x72,0x0e,0x4a, 0x2c,0x17,0xfc,0x75,
0x21,0xdd,0x76,0xfd, 0x34,0xfc,0x0f,0x1b,
0xa6,0x77,0x53,0xf9, 0xdb,0x09,0x07,0x58,
0xb0,0x18,0x32,0x03, 0x98,0x79,0xdf,0x55,
0xd3,0x95,0xba,0xa9, 0xb6,0x9f,0xad,0xc4,
0x9d,0xba,0x76,0x36, 0x47,0xb1,0xde,0x78,
0x18,0xa0,0x2f,0x16, 0x41,0xeb,0x4a,0x96,
0x82,0xc4,0xa4,0xde, 0x4b,0xdf,0xee,0xc7,
0x33,0xdf,0xb7,0xde, 0xd3,0xa7,0x0f,0xc7,
0x23,0x61,0x6b,0xd9, 0x15,0xc8,0x09,0xf7,
0xe7,0xf9,0x44,0xba, 0x14,0xdc,0x94,0x5e,
0xd9,0xcc,0x74,0xb2, 0x3d,0xef,0x78,0x15,
0xb5,0xb9,0x56,0xd5, 0xfb,0x47,0x49,0x3a,
0xbc,0x53,0x71,0x8b, 0x72,0x8b,0xb2,0xe3,
0x58,0xbf,0xea,0x47, 0x7a,0x76,0x03,0x48,
0xdd,0x8c,0x30,0x99, 0x81,0x2c,0x5f,0xf6,
0xd3,0x9b,0x8e,0x77, 0x1c,0xb7,0xbd,0x1e,
0xd4,0x28,0x05,0xf7, 0xff,0xdf,0xd6,0xb9,
0x83,0x99,0xbc,0x94, 0xb7,0x41,0x93,0xc4,
0x66,0xff,0x29,0x4d, 0x5c,0xba,0x79,0xd9,
0x6e,0x79,0x47,0x45, 0xd6,0x2d,0xcd,0x79,
0xa1,0xfa,0x49,0xee, 0x8e,0x7f,0x2b,0x08,
0x3f,0x60,0x56,0xcf, 0xcb,0xe8,0x0d,0x55,
0xee,0xa5,0xaf,0x04, 0xde,0x01,0xde,0xce,
0xb6,0x9c,0x68,0x4e, 0xb0,0x88,0xcd,0x89,
0x83,0x6b,0x01,0xb5, 0x78,0xac,0x85,0x3c,
0x2c,0xcf,0x39,0xb6, 0xc8,0x5f,0x0e,0xac,
0x02,0x08,0x56,0xbe, 0xd1,0x8d,0x7d,0x55,
0x69,0x0c,0x33,0x33, 0xff,0x1a,0xd6,0x0b,
0xcf,0x57,0x18,0x01, 0x56,0x5f,0x9c,0x6f,
0xe2,0x24,0xda,0xc3, 0x9f,0x81,0xc3,0x27,
0x46,0x7a,0xb4,0xae, 0xec,0xa4,0x0e,0x41,
0x8b,0xb7,0x16,0xe3, 0x9b,0x2e,0x32,0x75,
0xd9,0x86,0xa2,0x13, 0x68,0x4e,0xbc,0x43,
0xa2,0x78,0x64,0x1a, 0x7c,0xac,0x13,0x70,
0x1c,0x23,0x15,0x5b, 0xda,0x99,0xa5,0x24,
0x3d,0xcf,0x29,0xf7, 0xbc,0x1d,0x10,0xe8,
0x95,0x1a,0x11,0xec, 0xfc,0xfb,0x20,0x1f,
0x09,0x1b,0xe3,0x3d, 0xae,0x82,0x70,0xd7,
0x9e,0xf3,0x18,0x97, 0x89,0xfa,0x42,0x67,
0x70,0x9c,0xc8,0xbe, 0x62,0x98,0xf1,0x82,
0xfc,0x2b,0xf0,0x40, 0xaa,0xdc,0x27,0xf9,
0x21,0x5a,0xc1,0x25, 0x8b,0xef,0xd5,0x48,
0x6c,0x68,0xae,0xbc, 0xcd,0xa9,0x3c,0x1e,
0xe9,0xcf,0xe2,0xd1, 0xc0,0x98,0xa9,0x62,
0x5d,0x1f,0x57,0x7a, 0xca,0x8a,0x0f,0xfb,
0xe3,0xc9,0x7e,0x98, 0x44,0x84,0x67,0x12,
0x60,0x60,0xe5,0xc7, 0xcc,0x72,0x90,0x64,
0x67,0x30,0x6a,0xd8, 0xa1,0x11,0xd5,0x7e,
0x5e,0x0c,0x74,0xa2, 0x6f,0x0a,0xff,0x41,
0xd3,0x9a,0x30,0x56, 0xd4,0xec,0x9a,0x5f,
0x22,0x71,0x6b,0x4e, 0xe6,0xe0,0x19,0x69,
0x56,0x4a,0xba,0x9d, 0x50,0x8a,0x73,0x6a,
0xf1,0x59,0x48,0xd6, 0xcd,0xfa,0xaa,0x0c,
0xbb,0x7c,0xa4,0xbc, 0xf5,0x32,0x95,0x55,
0x1c,0xe9,0x9a,0x60, 0x43,0x10,0xbd,0x27,
0x88,0x2f,0x05,0xcf, 0xce,0x21,0x25,0x3a,
0x07,0xab,0x37,0xfd, 0xf6,0x2f,0xd6,0x51,
0xbe,0xe6,0xcc,0x58, 0x3a,0xab,0x60,0x23,
0x45,0xa0,0xe5,0x79, 0xe5,0xaa,0xed,0xa4,
0x28,0xd0,0x4d,0x37, 0x9c,0x6a,0xd7,0xc2,
0x39,0x22,0xb9,0x3e, 0x0d,0xb8,0x94,0x65,
0x48,0x4d,0x4c,0x02, 0x31,0x7e,0x9c,0xc9,
0xb7,0xd6,0x23,0x1a, 0x94,0x5a,0x13,0x55,
0x78,0x7a,0x29,0x4a, 0xa2,0xfd,0x37,0x24,
0xd8,0xd0,0x9e,0x47, 0x24,0xab,0x26,0x34,
0x28,0xb5,0x2d,0x82, 0x9a,0x4d,0xdd,0x17,
0x68,0xe0,0x07,0x5d, 0xb9,0x2d,0xff,0xa9,
0x0c,0x11,0x59,0x75, 0xda,0x98,0xe9,0xd5,
0xfa,0xb5,0x18,0x16, 0x28,0x17,0x7c,0xad,
0xab,0xee,0x65,0x10, 0x13,0x0d,0x26,0xfa,
0x7f,0xac,0x06,0x43, 0x4d,0x5d,0x3a,0xf4,
0x77,0xe7,0x03,0x17, 0x39,0x9f,0xbe,0x52,
0x9b,0x68,0x2b,0x7f, 0xd3,0xa2,0x7e,0x5c,
0x78,0x22,0xc5,0xe3, 0x17,0x73,0xc6,0x9e,
0x68,0x17,0x74,0x50, 0xf4,0xc5,0xa8,0xc3,
0x66,0xe1,0x05,0xed, 0xdd,0xdb,0xd3,0x11,
0x16,0xad,0x05,0x3a, 0x38,0x55,0x1c,0xf0,
0x93,0x0b,0x22,0x83, 0xc8,0x34,0xc5,0x43,
0x4d,0x65,0x57,0xf3, 0x03,0x56,0x21,0xa9,
0xbd,0x04,0x41,0x49, 0x62,0xfd,0xcc,0xc2,
0x75,0x59,0x09,0xb9, 0x28,0x38,0xcf,0xfb,
0x54,0x64,0x51,0xc2, 0x3e,0xad,0x35,0x3e,
0x31,0x87,0x6e,0xfe, 0xf0,0x41,0xef,0x1d,
0xb8,0x46,0xbe,0x85, 0xb9,0xff,0xa3,0xdb,
0x87,0xf9,0x65,0x95, 0x60,0x53,0x7c,0x9d,
0x26,0x83,0xfc,0xa7, 0xad,0x5a,0xcb,0x8d,
0x81,0xec,0x28,0xeb, 0xdd,0x96,0x25,0x31,
0x24,0x3f,0x59,0x28, 0x60,0x0b,0xc0,0x59,
0xea,0x36,0x15,0xad, 0x70,0xd8,0x70,0xff,
0x9b,0x15,0x76,0xc5, 0x84,0xe6,0x81,0x75,
0x1a,0x1e,0xc9,0xec, 0x33,0xbe,0x10,0xd4,
0x6f,0x10,0x1b,0xa2, 0xdb,0xc6,0x1b,0x0a,
0xfb,0xe9,0x3f,0x4d, 0x04,0x4e,0x33,0x87,
0xb3,0x21,0xad,0x41, 0xbe,0xce,0x26,0x0c,
0x0c,0x84,0x0f,0x9a, 0xb9,0xa7,0xa2,0x36,
0x70,0x49,0xce,0x25, 0x0f,0x69,0x4a,0x4a,
0x3d,0xf5,0xa0,0x9e, 0xad,0x69,0x2d,0x79,
0xdb,0x8b,0x85,0xf6, 0xb8,0x55,0xcd,0xf1,
0xbb,0x04,0x35,0xad, 0xa8,0xb6,0x0d,0x3f,
0x23,0xec,0x39,0xd7, 0xef,0x02,0x95,0x42,
0x11,0xc9,0x70,0xc6, 0xa4,0x65,0x37,0x4d,
0x9f,0x51,0x99,0xd6, 0x9e,0xb1,0x18,0xcf,
0x31,0x81,0xde,0x95, 0x0a,0x8c,0x0c,0x80,
0xdc,0xf7,0x19,0x5d, 0xdc,0x3e,0xee,0x0c,
0x17,0xaf,0xc4,0x9c, 0xbf,0x65,0xf2,0xe1,
0xc9,0xdb,0xc0,0x2a, 0xd0,0xbd,0xa1,0x7f,
0x4b,0x9c,0x5b,0xe6, 0x91,0x98,0xa6,0xdb,
0x72,0xef,0x14,0x38, 0x24,0x77,0x1e,0x71,
0x74,0x63,0x0c,0xd9, 0x16,0x90,0x23,0x4a,
0xe6,0xa4,0xc1,0x53, 0x8b,0xb4,0x7e,0x90,
0x1b,0x68,0x32,0x48, 0x93,0xd8,0x72,0x43,
0x8e,0x32,0x09,0x1e, 0x48,0xfc,0x3a,0xc6,
0x15,0xb9,0x79,0x57, 0x02,0x61,0xc6,0x4b,
0x56,0x1e,0x68,0x4e, 0x65,0x26,0xe5,0x1c,
0xb1,0xd1,0x86,0x1d, 0xea,0x93,0x5a,0x88,
0x4c,0x3b,0x10,0xd1, 0xf7,0x5a,0x4c,0xa3,
0xe7,0x59,0xf5,0x04, 0x7d,0xd7,0xe3,0x2e,
0x2c,0x3e,0x14,0x14, 0x83,0xed,0x3d,0x0b,
0xa4,0xab,0x65,0xcf, 0x39,0xee,0xbe,0x0c,
0x5e,0x4b,0x62,0x5e, 0xb4,0xd2,0x16,0xc7,
0xe0,0x71,0x2b,0x92, 0x1e,0x21,0x45,0x02,
0xfd,0xa1,0xda,0x0b, 0xbe,0xa6,0xe5,0x7f,
0x31,0x8b,0x5a,0xcb, 0x8f,0xb8,0x0c,0xfb,
0x7f,0x2d,0x7e,0xa2, 0x14,0xfd,0xe0,0xbb,
0xa4,0x1b,0xce,0x81, 0x6f,0x25,0xbd,0x72,
0x44,0x00,0x13,0x18, 0x75,0x04,0xf3,0x06,
0xdc,0xf1,0x5b,0xa0, 0xb1,0x5a,0x9a,0xd8,
0x4f,0xe7,0x94,0xe1, 0x65,0xe5,0xb2,0xd1,
0x47,0x6d,0xd8,0x81, 0x22,0x96,0x09,0xd8,
0x5e,0x12,0x73,0x62, 0xd6,0x2c,0xcb,0x45,
0x71,0xa9,0xc1,0x21, 0x16,0x6f,0xf0,0xaa,
0xce,0x19,0x1f,0x68, 0xee,0x17,0x07,0x94,
0x4f,0x93,0x9a,0x12, 0xf7,0x91,0xe1,0xc6,
0x9c,0x29,0xe5,0x06, 0x7a,0x40,0xf5,0xf6,
0x51,0xc8,0x32,0x94, 0x52,0xd9,0x6b,0x9b,
0x3e,0xb5,0xcf,0x1a, 0xf1,0x6c,0x7b,0x0a,
0x16,0x47,0xee,0xa6, 0x46,0x0f,0xed,0xe0,
0x1b,0x3f,0x39,0xfa, 0x4c,0x69,0xeb,0xfb,
0xd0,0x36,0x3b,0x3a, 0x04,0x94,0xa4,0x2f,
0x51,0xe1,0x1a,0x47, 0xc9,0xdb,0xf6,0x09,
0xab,0x35,0x46,0x2c, 0x2f,0xb7,0x19,0xed,
0x55,0x7e,0xa3,0x2c, 0xec,0xff,0x39,0xba,
0x0f,0xfb,0x4f,0x8b, 0xfc,0x36,0x4e,0x5e,
0xa1,0xe8,0x49,0x15, 0x65,0xd2,0xfb,0x11,
0x4b,0x10,0xe6,0x07, 0x82,0x3a,0x5d,0x3f,
0xeb,0xc0,0x0b,0x76, 0x66,0xb5,0xed,0x65,
0xb3,0x9d,0x06,0x13, 0x3b,0x18,0x70,0x7a,
0xbd,0xf7,0xd8,0x20, 0x81,0xc7,0x76,0x2e,
0x21,0x6f,0xdb,0x8e, 0xba,0x83,0x42,0xb1,
},
},
[5] = {
.k = {
0x79,0xce,0xb0,0x8e, 0xf8,0x7a,0x67,0xc6,
0x48,0x2c,0x2a,0xc0, 0xa5,0x45,0x06,0x49,
0xc8,0x90,0xb8,0xe9, 0xc6,0xb6,0xb3,0x50,
0xbd,0x9e,0x46,0x56, 0x26,0xf2,0xb0,0x3b,
},
.tlen = 17,
.t = {
0xe6,0x93,0xbe,0x89, 0xf5,0xee,0x40,0xde,
0xf2,0x9c,0xb5,0xec, 0x6a,0x37,0x23,0x46,
0x0e,
},
.len = 16,
.p = {
0x5d,0x83,0x98,0x37, 0xc6,0x33,0x9e,0x7e,
0x59,0xad,0xd2,0x5b, 0x8a,0x3a,0x9d,0x03,
},
.c = {
0x96,0x23,0x2f,0x7d, 0x52,0xfc,0x98,0x63,
0x98,0xa5,0x8b,0xdf, 0xca,0xbc,0x85,0x2f,
},
},
[6] = {
.k = {
0x9f,0xd3,0x36,0xb1, 0x85,0x07,0xdf,0x19,
0x01,0xea,0xf9,0x52, 0x68,0xbf,0xce,0xe7,
0xd0,0x49,0xf3,0xba, 0x58,0xfb,0x87,0x18,
0x9f,0xca,0x24,0xca, 0x61,0xa3,0xf0,0xda,
},
.tlen = 17,
.t = {
0xea,0xc6,0x72,0x5e, 0x66,0xd4,0xc7,0xbd,
0xa1,0x6e,0xab,0x09, 0xb5,0x58,0x39,0xae,
0x40,
},
.len = 128,
.p = {
0xc7,0xd6,0x73,0x65, 0xcb,0xf3,0xf5,0x3e,
0xb9,0xa7,0xbf,0xb1, 0x54,0xcb,0xac,0x01,
0xee,0xb5,0x94,0x17, 0x40,0x92,0xfd,0xad,
0x8f,0xdb,0x27,0x22, 0x3d,0xb1,0x0b,0xf7,
0xa7,0x46,0x70,0xd0, 0x31,0xdb,0xf9,0xdb,
0xb9,0xb9,0x40,0x4a, 0x0a,0xba,0x77,0x6f,
0x35,0x36,0x9e,0xeb, 0x68,0xe2,0x9e,0xd7,
0xef,0xc2,0x5e,0x21, 0x0d,0xb3,0xb0,0x87,
0xd6,0x43,0x35,0x6e, 0x22,0xa0,0xb7,0xec,
0x26,0xe0,0x7d,0x48, 0xf5,0x5d,0x58,0xd3,
0x29,0xb7,0x1f,0x7e, 0xe9,0x5a,0x02,0xa4,
0xb1,0xde,0x10,0x9f, 0xe1,0xa8,0x5e,0x05,
0xb6,0xa2,0x59,0xca, 0x3e,0xbc,0xd1,0x94,
0x09,0x4e,0x1b,0x37, 0x29,0x9c,0x15,0xef,
0x8c,0x72,0x53,0xbe, 0x6f,0x25,0x2c,0x68,
0x88,0x08,0x0c,0x00, 0x80,0x7a,0x85,0x64,
},
.c = {
0x49,0x36,0x97,0xd2, 0xde,0xa4,0xde,0x92,
0x7d,0x30,0x08,0xc3, 0xd9,0x47,0xd4,0xcb,
0x5b,0x41,0x27,0x2c, 0x06,0xb8,0x2b,0xef,
0x7b,0x57,0x59,0xb7, 0x5b,0x81,0x38,0xb4,
0xd1,0x81,0xb3,0xe8, 0xac,0xf0,0xa0,0x06,
0xcb,0x74,0x31,0x01, 0xe1,0x3d,0xcf,0x6d,
0x57,0xd1,0x65,0xcd, 0xe7,0x33,0x6c,0x03,
0x54,0xf0,0x2c,0x41, 0xb8,0x75,0x07,0x1d,
0x70,0xf0,0x9c,0xbd, 0x8f,0x6b,0xdb,0x76,
0x86,0x5b,0xe0,0xfd, 0xad,0x61,0x7a,0x4c,
0xd6,0xf1,0x85,0x0b, 0xfd,0x0b,0x3a,0x5f,
0xcf,0xfc,0xb0,0x0b, 0x2b,0xc7,0x31,0x07,
0x9d,0x75,0x82,0xd9, 0x14,0xd4,0x33,0xd3,
0xff,0x20,0xf7,0x14, 0xcf,0xe4,0xda,0xca,
0x11,0xcc,0x57,0x8f, 0x51,0x52,0x9d,0x90,
0x01,0xc8,0x4e,0x1f, 0x2a,0x89,0xe2,0x52,
},
},
};
static struct adiantum A;
static uint8_t buf[4096];
unsigned i;
int result = 0;
for (i = 0; i < __arraycount(C); i++) {
adiantum_init(&A, C[i].k);
adiantum_enc(buf, C[i].p, C[i].len, C[i].t, C[i].tlen, &A);
if (memcmp(buf, C[i].c, C[i].len)) {
char prefix[16];
snprintf(prefix, sizeof prefix, "adiantum enc %u", i);
hexdump(printf, prefix, buf, C[i].len);
result = -1;
}
memset(buf, 0, sizeof buf); /* paranoia */
adiantum_dec(buf, C[i].c, C[i].len, C[i].t, C[i].tlen, &A);
if (memcmp(buf, C[i].p, C[i].len)) {
char prefix[16];
snprintf(prefix, sizeof prefix, "adiantum dec %u", i);
hexdump(printf, prefix, buf, C[i].len);
result = -1;
}
}
return result;
}
|
6a152f92b4fcb0d8f1e931994215d7147551031f
|
03666e5f961946fc1a0ac67781ac1425562ef0d7
|
/src/plots/Pseudocolor/PseudocolorPluginInfo.C
|
67796462cf86050e328a7b190583d892649db8da
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
visit-dav/visit
|
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
|
601ae46e0bef2e18425b482a755d03490ade0493
|
refs/heads/develop
| 2023-09-06T08:19:38.397058
| 2023-09-05T21:29:32
| 2023-09-05T21:29:32
| 165,565,988
| 335
| 120
|
BSD-3-Clause
| 2023-09-14T00:53:37
| 2019-01-13T23:27:26
|
C
|
UTF-8
|
C
| false
| false
| 2,567
|
c
|
PseudocolorPluginInfo.C
|
// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers. See the top-level LICENSE file for dates and other
// details. No copyright assignment is required to contribute to VisIt.
// ****************************************************************************
// File: PseudocolorPluginInfo.C
// ****************************************************************************
#include <PseudocolorPluginInfo.h>
#include <PseudocolorAttributes.h>
#include <visit-config.h>
VISIT_PLUGIN_VERSION(Pseudocolor,PLOT_EXPORT)
VISIT_PLOT_PLUGIN_ENTRY(Pseudocolor,General)
// ****************************************************************************
// Method: PseudocolorGeneralPluginInfo::GetName
//
// Purpose:
// Return the name of the plot plugin.
//
// Returns: A pointer to the name of the plot plugin.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
const char *
PseudocolorGeneralPluginInfo::GetName() const
{
return "Pseudocolor";
}
// ****************************************************************************
// Method: PseudocolorGeneralPluginInfo::GetVersion
//
// Purpose:
// Return the version of the plot plugin.
//
// Returns: A pointer to the version of the plot plugin.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
const char *
PseudocolorGeneralPluginInfo::GetVersion() const
{
return "1.0";
}
// ****************************************************************************
// Method: PseudocolorGeneralPluginInfo::GetID
//
// Purpose:
// Return the id of the plot plugin.
//
// Returns: A pointer to the id of the plot plugin.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
const char *
PseudocolorGeneralPluginInfo::GetID() const
{
return "Pseudocolor_1.0";
}
// ****************************************************************************
// Method: PseudocolorGeneralPluginInfo::EnabledByDefault
//
// Purpose:
// Return true if this plugin should be enabled by default; false otherwise.
//
// Returns: true/false
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
bool
PseudocolorGeneralPluginInfo::EnabledByDefault() const
{
return true;
}
|
693201853ae404aeda0a47227c89a4981a5bd131
|
72f6d3ad72b2a4a9b6c5f93c5d1b744e2940b884
|
/lib/handler/configurator/expires.c
|
01d404dd574457007a83020884ed5640cab2eab4
|
[
"MIT"
] |
permissive
|
h2o/h2o
|
70012b6527ceb54e9e2819c9c75242b18e381485
|
b165770ce704c782ddee7428ea4a0b23c8bb7894
|
refs/heads/master
| 2023-08-16T13:16:35.018003
| 2023-08-16T03:56:28
| 2023-08-16T03:56:28
| 23,029,617
| 9,377
| 983
|
MIT
| 2023-09-12T04:49:14
| 2014-08-16T23:59:03
|
C
|
UTF-8
|
C
| false
| false
| 4,622
|
c
|
expires.c
|
/*
* Copyright (c) 2014 DeNA Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include "h2o.h"
#include "h2o/configurator.h"
struct expires_configurator_t {
h2o_configurator_t super;
h2o_expires_args_t **args;
h2o_expires_args_t *_args_stack[H2O_CONFIGURATOR_NUM_LEVELS + 1];
};
static int on_config_expires(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node)
{
struct expires_configurator_t *self = (void *)cmd->configurator;
uint64_t value;
char unit[32];
if (strcasecmp(node->data.scalar, "OFF") == 0) {
free(*self->args);
*self->args = NULL;
} else if (sscanf(node->data.scalar, "%" SCNu64 " %31s", &value, unit) == 2) {
/* convert value to seconds depending on the unit */
if (strncasecmp(unit, H2O_STRLIT("second")) == 0) {
/* ok */
} else if (strncasecmp(unit, H2O_STRLIT("minute")) == 0) {
value *= 60;
} else if (strncasecmp(unit, H2O_STRLIT("hour")) == 0) {
value *= 60 * 60;
} else if (strncasecmp(unit, H2O_STRLIT("day")) == 0) {
value *= 24 * 60 * 60;
} else if (strncasecmp(unit, H2O_STRLIT("month")) == 0) {
value *= 30 * 24 * 60 * 60;
} else if (strncasecmp(unit, H2O_STRLIT("year")) == 0) {
value *= 365 * 30 * 24 * 60 * 60;
} else {
/* TODO add support for H2O_EXPIRES_MODE_MAX_ABSOLUTE that sets the Expires header? */
h2o_configurator_errprintf(cmd, node, "unknown unit:`%s` (see --help)", unit);
return -1;
}
/* save the value */
if (*self->args == NULL)
*self->args = h2o_mem_alloc(sizeof(**self->args));
(*self->args)->mode = H2O_EXPIRES_MODE_MAX_AGE;
(*self->args)->data.max_age = value;
} else {
h2o_configurator_errprintf(cmd, node,
"failed to parse the value, should be in form of: `<number> <unit>` or `OFF` (see --help)");
return -1;
}
return 0;
}
static int on_config_enter(h2o_configurator_t *_self, h2o_configurator_context_t *ctx, yoml_t *node)
{
struct expires_configurator_t *self = (void *)_self;
if (self->args[0] != NULL) {
/* duplicate */
assert(self->args[0]->mode == H2O_EXPIRES_MODE_MAX_AGE);
self->args[1] = h2o_mem_alloc(sizeof(**self->args));
*self->args[1] = *self->args[0];
} else {
self->args[1] = NULL;
}
++self->args;
return 0;
}
static int on_config_exit(h2o_configurator_t *_self, h2o_configurator_context_t *ctx, yoml_t *node)
{
struct expires_configurator_t *self = (void *)_self;
if (*self->args != NULL) {
/* setup */
if (ctx->pathconf != NULL) {
h2o_expires_register(ctx->pathconf, *self->args);
}
/* destruct */
assert((*self->args)->mode == H2O_EXPIRES_MODE_MAX_AGE);
free(*self->args);
*self->args = NULL;
}
--self->args;
return 0;
}
void h2o_expires_register_configurator(h2o_globalconf_t *conf)
{
struct expires_configurator_t *c = (void *)h2o_configurator_create(conf, sizeof(*c));
/* set default vars */
c->args = c->_args_stack;
/* setup handlers */
c->super.enter = on_config_enter;
c->super.exit = on_config_exit;
h2o_configurator_define_command(&c->super, "expires", H2O_CONFIGURATOR_FLAG_ALL_LEVELS | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR,
on_config_expires);
}
|
a68c0556bb841f90c13063f3f605fa20ed776653
|
a8c65b151e703948964dfb377e1a5765f658a023
|
/src/nm_ini_parser.c
|
dee1ac56043b491ec9fcb9d7b1cf55a7b55a796e
|
[
"BSD-2-Clause"
] |
permissive
|
nemuTUI/nemu
|
a4a16921d17e782885df33d91fbb7044c2b3f6d4
|
b3ed6a74c1b957da16f584a39cf4fc99d372cf45
|
refs/heads/master
| 2023-08-03T02:42:28.206791
| 2023-07-25T12:33:57
| 2023-07-25T12:39:33
| 221,912,385
| 250
| 24
|
BSD-2-Clause
| 2023-07-24T10:02:39
| 2019-11-15T11:40:27
|
C
|
UTF-8
|
C
| false
| false
| 6,615
|
c
|
nm_ini_parser.c
|
#include <nm_core.h>
#include <nm_utils.h>
#include <nm_string.h>
#include <nm_ini_parser.h>
typedef struct nm_ini_value_s nm_ini_value_t;
struct nm_ini_value_s {
nm_str_t name;
nm_str_t value;
nm_ini_value_t *next;
};
struct nm_ini_node_s {
nm_str_t name;
nm_ini_node_t *next;
nm_ini_value_t *values_head;
};
static nm_ini_node_t *nm_ini_node_push(nm_ini_node_t **head, nm_str_t *name);
static void nm_ini_value_push(nm_ini_node_t *head,
nm_str_t *name, nm_str_t *value);
nm_ini_node_t *nm_ini_parser_init(const nm_str_t *path)
{
char *buf_ini;
int look_for_sec_end = 0;
int look_for_param_end = 0;
int look_for_value_end = 0;
int comment_block = 0;
nm_str_t sec_name = NM_INIT_STR;
nm_str_t par_name = NM_INIT_STR;
nm_str_t par_value = NM_INIT_STR;
nm_file_map_t file = NM_INIT_FILE;
nm_ini_node_t *head = NULL;
nm_ini_node_t *curr_node = NULL;
file.name = path;
nm_map_file(&file);
buf_ini = file.mp;
for (off_t n = 0; n < file.size; n++, buf_ini++) {
/* skip spaces and tabs */
if (!look_for_value_end && ((*buf_ini == ' ') || (*buf_ini == '\t'))) {
continue;
}
if (*buf_ini == '[') {
look_for_sec_end = 1;
continue;
}
/* skip comments '#...' */
if (comment_block && (*buf_ini != '\n')) {
continue;
}
if (*buf_ini == '#') {
comment_block = 1;
continue;
}
if (comment_block && (*buf_ini == '\n')) {
comment_block = 0;
continue;
}
/* collect section names */
if (look_for_sec_end) {
if (*buf_ini == ']') {
curr_node = nm_ini_node_push(&head, &sec_name);
nm_str_free(&sec_name);
look_for_sec_end = 0;
look_for_param_end = 1;
continue;
}
nm_str_add_char_opt(&sec_name, *buf_ini);
}
/* collect param names */
if (look_for_param_end && !look_for_sec_end) {
if (*buf_ini == '=') {
look_for_param_end = 0;
look_for_value_end = 1;
continue;
}
if (*buf_ini != '\n') {
nm_str_add_char_opt(&par_name, *buf_ini);
}
}
/* collect values */
if (look_for_value_end) {
if (*buf_ini == '\n') {
nm_str_t value = NM_INIT_STR;
char *begin = par_value.data - 1;
char *end = par_value.data + par_value.len;
while (--end != begin && (*end == ' ' || *end == '\t')) {
;
}
++end;
while (++begin != end && (*begin == ' ' || *begin == '\t')) {
;
}
if (begin != end) {
value.data = begin;
value.len = end - begin;
}
look_for_value_end = 0;
look_for_param_end = 1;
nm_ini_value_push(curr_node, &par_name, &value);
nm_str_free(&par_name);
nm_str_free(&par_value);
continue;
}
nm_str_add_char_opt(&par_value, *buf_ini);
}
}
nm_unmap_file(&file);
if (look_for_sec_end) {
nm_bug(_("Bad INI file: missing \"]\" at section name"));
}
return head;
}
void nm_ini_parser_dump(const nm_ini_node_t *head)
{
const nm_ini_node_t *curr = head;
if (curr == NULL) {
return;
}
nm_debug("-=ini cfg start=-\n");
while (curr != NULL) {
const nm_ini_value_t *values = curr->values_head;
nm_debug("section: %s\n", curr->name.data);
while (values != NULL) {
nm_debug("\t%s = %s\n", values->name.data, values->value.data);
values = values->next;
}
curr = curr->next;
}
nm_debug("-=ini cfg end=-\n");
}
void nm_ini_parser_free(nm_ini_node_t *head)
{
nm_ini_node_t *curr = head;
if (curr == NULL) {
return;
}
while (curr != NULL) {
nm_ini_node_t *old = curr;
nm_ini_value_t *values = curr->values_head;
while (values != NULL) {
nm_ini_value_t *old_val = values;
nm_str_free(&values->name);
nm_str_free(&values->value);
values = values->next;
free(old_val);
}
nm_str_free(&curr->name);
curr = curr->next;
free(old);
}
}
static nm_ini_node_t *nm_ini_node_push(nm_ini_node_t **head, nm_str_t *name)
{
nm_ini_node_t *curr = *head;
if (curr == NULL) { /* list is empty */
curr = nm_calloc(1, sizeof(nm_ini_node_t));
*head = curr;
goto fill_data;
}
while (curr->next != NULL) {
curr = curr->next;
}
curr->next = nm_calloc(1, sizeof(nm_ini_node_t));
curr = curr->next;
fill_data:
nm_str_copy(&curr->name, name);
return curr;
}
static void
nm_ini_value_push(nm_ini_node_t *head, nm_str_t *name, nm_str_t *value)
{
nm_ini_value_t *curr;
if (head == NULL) {
nm_bug(_("NULL list head pointer"));
}
curr = head->values_head;
if (curr == NULL) { /* list is empty */
curr = nm_calloc(1, sizeof(nm_ini_value_t));
head->values_head = curr;
goto fill_data;
}
while (curr->next != NULL) {
curr = curr->next;
}
curr->next = nm_calloc(1, sizeof(nm_ini_value_t));
curr = curr->next;
fill_data:
nm_str_copy(&curr->name, name);
nm_str_copy(&curr->value, value);
}
int nm_ini_parser_find(const nm_ini_node_t *head, const char *section,
const char *param, nm_str_t *res)
{
const nm_ini_node_t *curr = head;
int ret = NM_ERR, found = 0;
if (curr == NULL) {
nm_bug(_("NULL list head pointer"));
}
while (curr != NULL) {
const nm_ini_value_t *values;
if (found) {
break;
}
if (nm_str_cmp_st(&curr->name, section) == NM_OK) {
values = curr->values_head;
found = 1;
while (values != NULL) {
if (nm_str_cmp_st(&values->name, param) == NM_OK) {
ret = NM_OK;
nm_str_copy(res, &values->value);
break;
}
values = values->next;
}
}
curr = curr->next;
}
return ret;
}
/* vim:set ts=4 sw=4: */
|
ea24cae763f42a52befa9e11f99336b493db5417
|
515a17dfa8acffb7dbc076dca5be7ef3ddc2952f
|
/tools/external/sra-stat/assembly-statistics.c
|
83836c3086267a5a172caaed388d4d160530fadc
|
[
"LicenseRef-scancode-ncbi",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-us-govt-public-domain"
] |
permissive
|
ncbi/sra-tools
|
d54d2fe00214d9471b6dbd0b90c2fe0062f87cdd
|
1bb9cd2f317a232eb8f1e1d33cfc3582c71b3eec
|
refs/heads/master
| 2023-09-01T11:46:59.189830
| 2023-08-29T16:34:24
| 2023-08-29T16:34:24
| 23,203,598
| 991
| 271
|
NOASSERTION
| 2023-09-14T19:43:38
| 2014-08-21T21:25:38
|
C
|
UTF-8
|
C
| false
| false
| 9,519
|
c
|
assembly-statistics.c
|
/*===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
*/
#include "sra-stat.h" /* Ctx */
#include <insdc/sra.h> /* INSDC_coord_len */
#include <kdb/table.h> /* KTable */
#include <klib/container.h> /* BSTNode */
#include <klib/debug.h> /* DBGMSG */
#include <klib/log.h> /* LOGERR */
#include <klib/out.h> /* OUTMSG */
#include <klib/rc.h>
#include <vdb/blob.h> /* VBlob */
#include <vdb/cursor.h> /* VCursor */
#include <vdb/database.h> /* VDatabase */
#include <vdb/table.h> /* VTable */
#include <vdb/vdb-priv.h> /* VTableOpenKTableRead */
typedef struct {
BSTNode n;
uint64_t length;
} Contig;
static void CC ContigWhack ( BSTNode * n, void * data ) {
free ( n );
}
static
int64_t CC ContigSort ( const BSTNode * item, const BSTNode * n )
{
const Contig * contigl = ( const Contig * ) item;
const Contig * contigr = ( const Contig * ) n;
assert ( contigl && contigr);
return contigl -> length < contigr -> length;
}
typedef struct {
uint64_t assemblyLength;
uint64_t contigLength;
uint64_t count;
uint64_t length;
BSTree bt;
uint64_t l50;
uint64_t n50;
uint64_t l90;
uint64_t n90;
} Contigs;
static void CC ContigNext ( BSTNode * n, void * data ) {
const Contig * contig = ( const Contig * ) n;
Contigs * nl = ( Contigs * ) data;
assert ( contig && nl );
++ nl -> count;
nl -> length += contig -> length;
DBGMSG ( DBG_APP, DBG_COND_1, ( "Contig %lu/%lu: %lu. Total: %lu/%lu\n",
nl -> count, nl -> contigLength, contig -> length,
nl -> length, nl -> assemblyLength ) );
if ( nl -> l50 == 0 && nl -> length * 2 >= nl -> assemblyLength ) {
nl -> n50 = contig -> length;
nl -> l50 = nl -> count;
DBGMSG ( DBG_APP, DBG_COND_1, ( "L50: %lu, N50: %lu (%lu>=%lu/2)\n",
nl -> l50, nl -> n50, nl -> length, nl -> assemblyLength ) );
}
if ( nl -> l90 == 0 &&
.9 * nl -> assemblyLength <= nl -> length )
{
nl -> n90 = contig -> length;
nl -> l90 = nl -> count;
DBGMSG ( DBG_APP, DBG_COND_1, ( "L90: %lu, N90: %lu (%lu*.9>=%lu)\n",
nl -> l90, nl -> n90, nl -> length, nl -> assemblyLength ) );
}
}
static void ContigsInit ( Contigs * self ) {
assert ( self );
memset ( self, 0, sizeof * self );
}
static rc_t ContigsAdd ( Contigs * self, uint32_t length ) {
Contig * contig = ( Contig * ) calloc ( 1, sizeof * contig );
assert ( self );
if ( contig == NULL )
return RC ( rcExe, rcStorage, rcAllocating, rcMemory, rcExhausted );
self -> assemblyLength += length;
++ self -> contigLength;
contig -> length = length;
return BSTreeInsert ( & self -> bt, ( BSTNode * ) contig, ContigSort );
}
static void ContigsCalculateStatistics ( Contigs * self ) {
assert ( self );
BSTreeForEach ( & self -> bt, false, ContigNext, self );
}
static void ContigsFini ( Contigs * self ) {
assert ( self );
BSTreeWhack ( & self -> bt, ContigWhack, NULL );
}
/* Calculate N50, L50 statistics:
see https://en.wikipedia.org/wiki/N50,_L50,_and_related_statistics */
rc_t CC CalculateNL ( const VDatabase * db, Ctx * ctx ) {
rc_t rc = 0;
const VTable * tbl = NULL;
const KTable * ktbl = NULL;
const KIndex * idx = NULL;
const VCursor * cursor = NULL;
uint32_t CMP_READ;
uint32_t READ_LEN;
Contigs contigs;
int64_t start = 1;
uint64_t count = 0;
/* Statictics is calculated just for VDatabase-s */
if ( db == NULL ) {
DBGMSG ( DBG_APP, DBG_COND_1,
( "CalculateAssemblyStatistics skipped: not a database\n" ) );
return 0;
}
rc = VDatabaseOpenTableRead ( db, & tbl, "REFERENCE" );
/* Statictics is calculated just for VDatabase-s with REFERENCE */
if ( rc != 0 && GetRCState ( rc ) == rcNotFound ) {
DBGMSG ( DBG_APP, DBG_COND_1,
( "CalculateAssemblyStatistics skipped: no REFERENCE table\n" ) );
return 0;
}
ContigsInit ( & contigs );
rc = VTableOpenKTableRead ( tbl, & ktbl );
DISP_RC ( rc, "while calling "
"VTableOpenKTableRead(VDatabaseOpenTableRead(REFERENCE))");
if ( rc == 0 ) {
rc = KTableOpenIndexRead ( ktbl, & idx, "i_name" );
DISP_RC ( rc, "while calling KTableOpenIndexRead"
"(VTableOpenKTableRead(VDatabaseOpenTableRead(REFERENCE),i_name)");
}
if ( rc == 0 ) {
rc = VTableCreateCursorRead ( tbl, & cursor );
DISP_RC ( rc, "while calling VTableCreateCursorRead(REFERENCE)");
}
if ( rc == 0 ) {
rc = VCursorAddColumn ( cursor, & CMP_READ, "CMP_READ" );
DISP_RC ( rc, "while calling VCursorAddColumn(REFERENCE,CMP_READ)");
}
if ( rc == 0 ) {
rc = VCursorAddColumn ( cursor, & READ_LEN, "READ_LEN" );
DISP_RC ( rc, "while calling VCursorAddColumn(REFERENCE,READ_LEN)");
}
if ( rc == 0 ) {
rc = VCursorOpen ( cursor );
DISP_RC ( rc, "while calling VCursorOpen(REFERENCE)");
}
for ( start = 1; rc == 0; start += count ) {
uint32_t row_len = 0;
const VBlob * blob = NULL;
size_t key_size = 0;
char key [ 4096 ];
rc = KIndexProjectText ( idx, start, & start, & count,
key, sizeof key, & key_size );
if ( rc == SILENT_RC
( rcDB, rcIndex, rcProjecting, rcId, rcNotFound ) )
{
rc = 0;
break; /* no more references */
}
DISP_RC ( rc, "while calling KIndexProjectText(KTableOpenIndexRead"
"(VTableOpenKTableRead(VDatabaseOpenTableRead(REFERENCE),i_name)");
if ( rc == 0 ) {
rc = VCursorGetBlobDirect ( cursor, & blob, start, CMP_READ );
DISP_RC ( rc, "while calling VCursorGetBlobDirect(CMP_READ)" );
}
if ( rc == 0 ) {
uint32_t elem_bits = 0;
const void * base = NULL;
uint32_t boff = 0;
rc = VBlobCellData ( blob, start,
& elem_bits, & base, & boff, & row_len );
DISP_RC ( rc, "while calling VBlobCellData(CMP_READ)" );
}
if ( rc == 0 ) {
if ( row_len == 0 ) {
/* When CMP_READ is not empty - local reference.
We calculate statistics just for local references */
DBGMSG ( DBG_APP, DBG_COND_1, ( "CalculateAssemblyStatistics: "
"%s skipped: not a local reference\n", key ) );
}
else {
uint64_t length = 0;
INSDC_coord_len buffer = 0;
uint32_t row_len = 0;
rc = VCursorReadDirect ( cursor, start,
READ_LEN, 8, & buffer, sizeof buffer, & row_len );
DISP_RC ( rc, "while calling VCursorReadDirect(READ_LEN,id)" );
if ( rc == 0 )
length = buffer;
if ( rc == 0 && count > 1 ) {
INSDC_coord_len buffer = 0;
uint32_t row_len = 0;
rc = VCursorReadDirect ( cursor, start + count - 1,
READ_LEN, 8, & buffer, sizeof buffer, & row_len );
DISP_RC ( rc,
"while calling VCursorReadDirect(READ_LEN,id+count)" );
if ( rc == 0 )
length = length * ( count - 1) + buffer;
}
if ( rc == 0 )
rc = ContigsAdd ( & contigs, length );
}
}
RELEASE ( VBlob, blob );
}
if ( rc == 0 )
ContigsCalculateStatistics ( & contigs );
RELEASE ( VCursor, cursor );
RELEASE ( KIndex, idx );
RELEASE ( KTable, ktbl );
RELEASE ( VTable, tbl );
if ( rc == 0 ) {
assert ( ctx );
assert ( contigs . assemblyLength == contigs . length );
assert ( contigs . contigLength == contigs . count );
if ( contigs . n90 > 0 ) {
ctx -> l50 = contigs . l50;
ctx -> n50 = contigs . n50;
ctx -> l90 = contigs . l90;
ctx -> n90 = contigs . n90;
ctx -> l = contigs . contigLength;
ctx -> n = contigs . assemblyLength;
}
}
ContigsFini ( & contigs );
return rc;
}
|
67dbc7efb55e216abe64f56ea32198d2d2cc5188
|
f367e4b66a1ee42e85830b31df88f63723c36a47
|
/lib/wasm-micro-runtime-WAMR-1.2.2/core/iwasm/fast-jit/jit_utils.c
|
57a3e8f678cbc3678ebb8712316c4ad94df43abc
|
[
"Apache-2.0",
"LLVM-exception"
] |
permissive
|
fluent/fluent-bit
|
06873e441162b92941024e9a7e9e8fc934150bf7
|
1a41f49dc2f3ae31a780caa9ffd6137b1d703065
|
refs/heads/master
| 2023-09-05T13:44:55.347372
| 2023-09-05T10:14:33
| 2023-09-05T10:14:33
| 29,933,948
| 4,907
| 1,565
|
Apache-2.0
| 2023-09-14T10:17:02
| 2015-01-27T20:41:52
|
C
|
UTF-8
|
C
| false
| false
| 446
|
c
|
jit_utils.c
|
/*
* Copyright (C) 2021 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "jit_utils.h"
JitBitmap *
jit_bitmap_new(uintptr_t begin_index, unsigned bitnum)
{
JitBitmap *bitmap;
if ((bitmap = jit_calloc(offsetof(JitBitmap, map) + (bitnum + 7) / 8))) {
bitmap->begin_index = begin_index;
bitmap->end_index = begin_index + bitnum;
}
return bitmap;
}
|
f7df928564621750f8d18bfb148735cef3efcb89
|
808fc7bff7c6cf8443848809a675ac24a7a0530b
|
/Source/include/SVGKExporterNSImage.h
|
a71a884769864b2a1bc1907553c42eaaf3ad3be8
|
[
"MIT"
] |
permissive
|
SVGKit/SVGKit
|
5499deb7c8b22678ec77eebb99d565df83bb94cf
|
96c330df9627b26c1d3a3eb48a84b4eb5d21d7b3
|
refs/heads/3.x
| 2023-09-04T03:32:26.965270
| 2023-07-05T14:05:32
| 2023-07-05T14:05:32
| 1,561,142
| 3,304
| 933
|
NOASSERTION
| 2023-09-08T14:14:40
| 2011-04-02T22:55:11
|
Objective-C
|
UTF-8
|
C
| false
| false
| 34
|
h
|
SVGKExporterNSImage.h
|
../Exporters/SVGKExporterNSImage.h
|
68c874dbddf48de04cddc2a8d11e1075738789d3
|
3bd385b466cb035fecd2b0c11ae054d42bf44fc2
|
/src/annotationsketch/gt_sketch.c
|
253f9c11ef3f37d520bcf88bf74945a1544b292a
|
[
"LicenseRef-scancode-unknown-license-reference",
"ISC",
"BSD-2-Clause",
"LicenseRef-scancode-mit-old-style",
"Zlib",
"MIT",
"BSD-3-Clause",
"bzip2-1.0.6"
] |
permissive
|
genometools/genometools
|
c366dff04f6baa887f6b3be3ec55bce824b2bae1
|
df1df94b8c05a9c9bf848ffc6755c87b58573da5
|
refs/heads/master
| 2023-04-13T13:57:18.748796
| 2023-04-09T21:29:53
| 2023-04-09T21:29:53
| 11,177,980
| 237
| 63
|
NOASSERTION
| 2023-04-09T21:29:54
| 2013-07-04T13:39:38
|
C
|
UTF-8
|
C
| false
| false
| 17,324
|
c
|
gt_sketch.c
|
/*
Copyright (c) 2007-2013 Sascha Steinbiss <steinbiss@zbh.uni-hamburg.de>
Copyright (c) 2007 Malte Mader <mader@zbh.uni-hamburg.de>
Copyright (c) 2007 Christin Schaerfer <schaerfer@zbh.uni-hamburg.de>
Copyright (c) 2007-2013 Center for Bioinformatics, University of Hamburg
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 <cairo.h>
#include <string.h>
#include "core/cstr_api.h"
#include "core/fileutils_api.h"
#include "core/gtdatapath.h"
#include "core/option_api.h"
#include "core/output_file_api.h"
#include "core/ma_api.h"
#include "core/splitter.h"
#include "core/undef_api.h"
#include "core/unused_api.h"
#include "core/versionfunc_api.h"
#include "core/warning_api.h"
#include "extended/add_introns_stream_api.h"
#include "extended/bed_in_stream.h"
#include "extended/feature_index_memory_api.h"
#include "extended/feature_stream_api.h"
#include "extended/gff3_in_stream.h"
#include "extended/gff3_out_stream_api.h"
#include "extended/gtf_in_stream.h"
#include "extended/sort_stream_api.h"
#include "annotationsketch/block.h"
#include "annotationsketch/canvas_api.h"
#include "annotationsketch/canvas_cairo_file.h"
#include "annotationsketch/diagram.h"
#include "annotationsketch/gt_sketch.h"
#include "annotationsketch/image_info.h"
#include "annotationsketch/layout.h"
#include "annotationsketch/style.h"
typedef struct {
bool pipe,
verbose,
addintrons,
showrecmaps,
flattenfiles,
unsafe,
force,
use_streams;
GtStr *seqid, *format, *stylefile, *input;
GtUword start,
end;
unsigned int width;
} GtSketchArguments;
static void* gt_sketch_arguments_new(void)
{
GtSketchArguments *arguments = gt_calloc(1, sizeof *arguments);
arguments->seqid = gt_str_new();
arguments->format = gt_str_new();
arguments->input = gt_str_new();
arguments->stylefile = gt_str_new();
return arguments;
}
static void gt_sketch_arguments_delete(void *tool_arguments)
{
GtSketchArguments *arguments = tool_arguments;
if (!arguments) return;
gt_str_delete(arguments->seqid);
gt_str_delete(arguments->format);
gt_str_delete(arguments->input);
gt_str_delete(arguments->stylefile);
gt_free(arguments);
}
static GtOptionParser* gt_sketch_option_parser_new(void *tool_arguments)
{
GtSketchArguments *arguments = tool_arguments;
GtOptionParser *op;
GtOption *option, *option2;
static const char *formats[] = { "png",
#ifdef CAIRO_HAS_PDF_SURFACE
"pdf",
#endif
#ifdef CAIRO_HAS_SVG_SURFACE
"svg",
#endif
#ifdef CAIRO_HAS_PS_SURFACE
"ps",
#endif
NULL
};
static const char *inputs[] = {
"gff",
"bed",
"gtf",
NULL
};
gt_assert(arguments);
/* init */
op = gt_option_parser_new("[option ...] image_file [GFF3_file ...]",
"Create graphical representation of GFF3 "
"annotation files.");
/* -pipe */
option = gt_option_new_bool("pipe", "use pipe mode (i.e., show all gff3 "
"features on stdout)", &arguments->pipe, false);
gt_option_parser_add_option(op, option);
/* -flattenfiles */
option = gt_option_new_bool("flattenfiles", "do not group tracks by source "
"file name and remove file names from track "
"description", &arguments->flattenfiles, false);
gt_option_parser_add_option(op, option);
/* -seqid */
option = gt_option_new_string("seqid", "sequence region identifier\n"
"default: first one in file",
arguments->seqid, NULL);
gt_option_parser_add_option(op, option);
gt_option_hide_default(option);
/* -start */
option = gt_option_new_uword_min("start", "start position\n"
"default: first region start",
&arguments->start, GT_UNDEF_UWORD, 1);
gt_option_parser_add_option(op, option);
gt_option_hide_default(option);
/* -end */
option2 = gt_option_new_uword("end", "end position\ndefault: last region end",
&arguments->end, GT_UNDEF_UWORD);
gt_option_parser_add_option(op, option2);
/* -start and -end must be given together */
gt_option_imply(option, option2);
gt_option_imply(option2, option);
gt_option_hide_default(option2);
/* -width */
option = gt_option_new_uint_min("width", "target image width (in pixel)",
&arguments->width,
800, 1);
gt_option_parser_add_option(op, option);
/* -style */
option = gt_option_new_string("style", "style file to use",
arguments->stylefile,
gt_str_get(arguments->stylefile));
gt_option_parser_add_option(op, option);
/* -format */
option = gt_option_new_choice("format", "output graphics format\n"
"choose from png"
#ifdef CAIRO_HAS_PDF_SURFACE
"|pdf"
#endif
#ifdef CAIRO_HAS_SVG_SURFACE
"|svg"
#endif
#ifdef CAIRO_HAS_PS_SURFACE
"|ps"
#endif
"",
arguments->format, formats[0], formats);
gt_option_parser_add_option(op, option);
/* -input */
option = gt_option_new_choice("input", "input data format\n"
"choose from gff|bed|gtf",
arguments->input, inputs[0], inputs);
gt_option_parser_add_option(op, option);
/* -addintrons */
option = gt_option_new_bool("addintrons", "add intron features between "
"existing exon features (before drawing)",
&arguments->addintrons, false);
gt_option_parser_add_option(op, option);
/* -unsafe */
option = gt_option_new_bool("unsafe", "enable unsafe mode for style file",
&arguments->unsafe, false);
gt_option_parser_add_option(op, option);
/* -showrecmaps */
option = gt_option_new_bool("showrecmaps",
"show RecMaps after image creation",
&arguments->showrecmaps, false);
gt_option_is_development_option(option);
gt_option_parser_add_option(op, option);
/* -streams */
option = gt_option_new_bool("streams", "use streams to write data to file",
&arguments->use_streams, false);
gt_option_is_development_option(option);
gt_option_parser_add_option(op, option);
/* -v */
option = gt_option_new_verbose(&arguments->verbose);
gt_option_parser_add_option(op, option);
/* -force */
option = gt_option_new_bool(GT_FORCE_OPT_CSTR, "force writing to output file",
&arguments->force, false);
gt_option_parser_add_option(op, option);
gt_option_parser_set_min_args(op, 1);
return op;
}
static int gt_sketch_arguments_check(GT_UNUSED int rest_argc,
void *tool_arguments,
GT_UNUSED GtError *err)
{
GtSketchArguments *arguments = tool_arguments;
int had_err = 0;
gt_error_check(err);
gt_assert(arguments);
if (arguments->start != GT_UNDEF_UWORD &&
arguments->end != GT_UNDEF_UWORD &&
!(arguments->start < arguments->end)) {
gt_error_set(err, "start of query range ("GT_WU") must be before "
"end of query range ("GT_WU")",
arguments->start, arguments->end);
had_err = -1;
}
return had_err;
}
/* this track selector function is used to disregard file names in track
identifiers */
static void flattened_file_track_selector(GtBlock *block, GtStr *result,
GT_UNUSED void *data)
{
gt_assert(block && result);
gt_str_reset(result);
gt_str_append_cstr(result, gt_block_get_type(block));
}
static int gt_sketch_runner(int argc, const char **argv, int parsed_args,
void *tool_arguments, GT_UNUSED GtError *err)
{
GtSketchArguments *arguments = tool_arguments;
GtNodeStream *in_stream = NULL,
*add_introns_stream = NULL,
*gff3_out_stream = NULL,
*feature_stream = NULL,
*sort_stream = NULL,
*last_stream;
GtFeatureIndex *features = NULL;
const char *file;
char *seqid = NULL;
GtRange qry_range, sequence_region_range;
GtArray *results = NULL;
GtStyle *sty = NULL;
GtStr *prog, *defaultstylefile = NULL;
GtDiagram *d = NULL;
GtLayout *l = NULL;
GtImageInfo* ii = NULL;
GtCanvas *canvas = NULL;
GtUword height;
bool has_seqid;
int had_err = 0;
gt_error_check(err);
gt_assert(arguments);
prog = gt_str_new();
gt_str_append_cstr_nt(prog, argv[0],
gt_cstr_length_up_to_char(argv[0], ' '));
defaultstylefile = gt_get_gtdata_path(gt_str_get(prog), err);
gt_str_delete(prog);
if (!defaultstylefile)
had_err = -1;
if (!had_err) {
gt_str_append_cstr(defaultstylefile, "/sketch/default.style");
}
file = argv[parsed_args];
if (!had_err) {
/* create feature index */
features = gt_feature_index_memory_new();
parsed_args++;
/* create an input stream */
if (strcmp(gt_str_get(arguments->input), "gff") == 0)
{
in_stream = gt_gff3_in_stream_new_unsorted(argc - parsed_args,
argv + parsed_args);
if (arguments->verbose)
gt_gff3_in_stream_show_progress_bar((GtGFF3InStream*) in_stream);
} else if (strcmp(gt_str_get(arguments->input), "bed") == 0)
{
if (argc - parsed_args == 0)
in_stream = gt_bed_in_stream_new(NULL);
else
in_stream = gt_bed_in_stream_new(argv[parsed_args]);
} else if (strcmp(gt_str_get(arguments->input), "gtf") == 0)
{
if (argc - parsed_args == 0)
in_stream = gt_gtf_in_stream_new(NULL);
else
in_stream = gt_gtf_in_stream_new(argv[parsed_args]);
}
last_stream = in_stream;
/* create add introns stream if -addintrons was used */
if (arguments->addintrons) {
sort_stream = gt_sort_stream_new(last_stream);
add_introns_stream = gt_add_introns_stream_new(sort_stream);
last_stream = add_introns_stream;
}
/* create gff3 output stream if -pipe was used */
if (arguments->pipe) {
gff3_out_stream = gt_gff3_out_stream_new(last_stream, NULL);
last_stream = gff3_out_stream;
}
/* create feature stream */
feature_stream = gt_feature_stream_new(last_stream, features);
/* pull the features through the stream and free them afterwards */
had_err = gt_node_stream_pull(feature_stream, err);
gt_node_stream_delete(feature_stream);
gt_node_stream_delete(gff3_out_stream);
gt_node_stream_delete(sort_stream);
gt_node_stream_delete(add_introns_stream);
gt_node_stream_delete(in_stream);
}
if (!had_err) {
had_err = gt_feature_index_has_seqid(features,
&has_seqid,
gt_str_get(arguments->seqid),
err);
}
/* if seqid is empty, take first one added to index */
if (!had_err && strcmp(gt_str_get(arguments->seqid),"") == 0) {
seqid = gt_feature_index_get_first_seqid(features, err);
if (seqid == NULL) {
gt_error_set(err, "GFF input file must contain a sequence region!");
had_err = -1;
}
}
else if (!had_err && !has_seqid) {
gt_error_set(err, "sequence region '%s' does not exist in GFF input file",
gt_str_get(arguments->seqid));
had_err = -1;
}
else if (!had_err)
seqid = gt_cstr_dup(gt_str_get(arguments->seqid));
results = gt_array_new(sizeof (GtGenomeNode*));
if (!had_err) {
had_err = gt_feature_index_get_range_for_seqid(features,
&sequence_region_range,
seqid,
err);
}
if (!had_err) {
qry_range.start = (arguments->start == GT_UNDEF_UWORD ?
sequence_region_range.start :
arguments->start);
qry_range.end = (arguments->end == GT_UNDEF_UWORD ?
sequence_region_range.end :
arguments->end);
}
if (!had_err) {
if (arguments->verbose)
fprintf(stderr, "# of results: "GT_WU"\n", gt_array_size(results));
/* find and load style file */
if (!(sty = gt_style_new(err)))
had_err = -1;
if (gt_str_length(arguments->stylefile) == 0) {
gt_str_append_str(arguments->stylefile, defaultstylefile);
} else {
if (!had_err && gt_file_exists(gt_str_get(arguments->stylefile))) {
if (arguments->unsafe)
gt_style_unsafe_mode(sty);
}
else
{
had_err = -1;
gt_error_set(err, "style file '%s' does not exist!",
gt_str_get(arguments->stylefile));
}
}
if (!had_err)
had_err = gt_style_load_file(sty, gt_str_get(arguments->stylefile), err);
}
if (!had_err) {
/* create and write image file */
if (!(d = gt_diagram_new(features, seqid, &qry_range, sty, err)))
had_err = -1;
if (!had_err && arguments->flattenfiles)
gt_diagram_set_track_selector_func(d, flattened_file_track_selector,
NULL);
if (had_err || !(l = gt_layout_new(d, arguments->width, sty, err)))
had_err = -1;
if (!had_err)
had_err = gt_layout_get_height(l, &height, err);
if (!had_err) {
ii = gt_image_info_new();
if (strcmp(gt_str_get(arguments->format),"pdf")==0) {
canvas = gt_canvas_cairo_file_new(sty, GT_GRAPHICS_PDF,
arguments->width,
height, ii, err);
}
else if (strcmp(gt_str_get(arguments->format),"ps")==0) {
canvas = gt_canvas_cairo_file_new(sty, GT_GRAPHICS_PS,
arguments->width,
height, ii, err);
}
else if (strcmp(gt_str_get(arguments->format),"svg")==0) {
canvas = gt_canvas_cairo_file_new(sty, GT_GRAPHICS_SVG,
arguments->width,
height, ii, err);
}
else {
canvas = gt_canvas_cairo_file_new(sty, GT_GRAPHICS_PNG,
arguments->width,
height, ii, err);
}
if (!canvas)
had_err = -1;
if (!had_err) {
had_err = gt_layout_sketch(l, canvas, err);
}
if (!had_err) {
if (arguments->showrecmaps) {
GtUword i;
const GtRecMap *rm;
for (i = 0; i < gt_image_info_num_of_rec_maps(ii) ;i++) {
char buf[BUFSIZ];
rm = gt_image_info_get_rec_map(ii, i);
(void) gt_rec_map_format_html_imagemap_coords(rm, buf, BUFSIZ);
printf("%s, %s\n",
buf,
gt_feature_node_get_type(gt_rec_map_get_genome_feature(rm)));
}
}
if (arguments->use_streams) {
GtFile *outfile;
GtStr *str = gt_str_new();
gt_canvas_cairo_file_to_stream((GtCanvasCairoFile*) canvas, str);
outfile = gt_file_open(GT_FILE_MODE_UNCOMPRESSED, file, "w+", err);
if (outfile) {
gt_file_xwrite(outfile, gt_str_get_mem(str), gt_str_length(str));
gt_file_delete(outfile);
} else {
had_err = -1;
}
gt_str_delete(str);
} else {
had_err = gt_canvas_cairo_file_to_file((GtCanvasCairoFile*) canvas,
file,
err);
}
}
}
}
/* free */
gt_free(seqid);
gt_canvas_delete(canvas);
gt_layout_delete(l);
gt_image_info_delete(ii);
gt_style_delete(sty);
gt_diagram_delete(d);
gt_array_delete(results);
gt_str_delete(defaultstylefile);
gt_feature_index_delete(features);
return had_err;
}
GtTool* gt_sketch(void)
{
return gt_tool_new(gt_sketch_arguments_new,
gt_sketch_arguments_delete,
gt_sketch_option_parser_new,
gt_sketch_arguments_check,
gt_sketch_runner);
}
|
fd0e79184deb3766258863f3aed43db65db64204
|
3bd385b466cb035fecd2b0c11ae054d42bf44fc2
|
/src/core/bitpackarray.h
|
bd0182e8fda5451b5e5e1dde9af3ae618b5bcbaf
|
[
"LicenseRef-scancode-unknown-license-reference",
"ISC",
"BSD-2-Clause",
"LicenseRef-scancode-mit-old-style",
"Zlib",
"MIT",
"BSD-3-Clause",
"bzip2-1.0.6"
] |
permissive
|
genometools/genometools
|
c366dff04f6baa887f6b3be3ec55bce824b2bae1
|
df1df94b8c05a9c9bf848ffc6755c87b58573da5
|
refs/heads/master
| 2023-04-13T13:57:18.748796
| 2023-04-09T21:29:53
| 2023-04-09T21:29:53
| 11,177,980
| 237
| 63
|
NOASSERTION
| 2023-04-09T21:29:54
| 2013-07-04T13:39:38
|
C
|
UTF-8
|
C
| false
| false
| 6,713
|
h
|
bitpackarray.h
|
/*
Copyright (C) 2007 Thomas Jahns <Thomas.Jahns@gmx.net>
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.
*/
#ifndef BITPACKARRAY_H
#define BITPACKARRAY_H
#ifndef S_SPLINT_S
/**
* \file bitpackarray.h
* \brief The class presented in this file encapsulates a bitstring in
* a data structure to store/retrieve integers at fixed bitlength and
* integrate well with genome tools library.
* \author Thomas Jahns <Thomas.Jahns@gmx.net>
*/
#include <stdlib.h>
#include <string.h>
#include "core/assert_api.h"
#include "core/bitpackstring.h"
#include "core/error_api.h"
#include "core/ma_api.h"
struct BitPackArray
{
BitString store;
BitOffset numElems;
unsigned bitsPerElem;
};
/* SK added the following macro, as we need the structure component,
to store a pointer to the address, which is used when mapping the
bitpackarray as part of a larger memory map */
#define BITPACKARRAYSTOREVAR(BPA) (BPA)->store
typedef struct BitPackArray BitPackArray;
/**
* determine size of BitPackArray structure.
* @param bits number of bits to encode each value stored with
* @param numValues number of values to store
* @return size
*/
static inline size_t sizeofbitarray(unsigned bits, BitOffset numValues)
{
return bitElemsAllocSize(bits * numValues) * sizeof (BitElem);
}
/**
* Create new BitPackArray structure.
* @param bits number of bits to encode each value stored with
* @param numValues number of values to store
* @return pointer to new BitPackArray structure or NULL on failure
*/
static inline BitPackArray *
bitpackarray_new(unsigned bits, BitOffset numValues, bool withstorealloc)
{
BitPackArray *newBPA = gt_malloc(sizeof (*newBPA));
if (newBPA) {
if (withstorealloc) {
if (!(newBPA->store = gt_calloc(bitElemsAllocSize(bits*numValues),
sizeof (BitElem)))) {
gt_free(newBPA);
return NULL;
}
} else {
newBPA->store = NULL;
}
newBPA->bitsPerElem = bits;
newBPA->numElems = numValues;
}
return newBPA;
}
static inline void
bitpackarray_delete(BitPackArray *bpa)
{
if (!bpa) return;
gt_free(bpa->store);
gt_free(bpa);
}
/**
* Stores unsigned integer in BitPackArray at given index.
* @param bparray array to use
* @param index index to store value at.
* @param val value to store (only as many bits as specified on
* BitPackArray construction are stored).
*/
static inline void
bitpackarray_store_uint32(BitPackArray *array, BitOffset index, uint32_t val)
{
gt_assert(array && index < array->numElems
&& array->bitsPerElem <= sizeof (val)*CHAR_BIT);
gt_bsStoreUInt32(array->store,
array->bitsPerElem * index,
array->bitsPerElem,
val);
}
/**
* Stores unsigned integer in BitPackArray at given index.
* @param bparray array to use
* @param index index to store value at.
* @param val value to store (only as many bits as specified on
* BitPackArray construction are stored).
*/
static inline uint32_t
bitpackarray_get_uint32(const BitPackArray *array, BitOffset index)
{
gt_assert(array && index < array->numElems
&& array->bitsPerElem <= sizeof (uint32_t)*CHAR_BIT);
return gt_bsGetUInt32(array->store, array->bitsPerElem * index,
array->bitsPerElem);
}
/**
* Stores unsigned integer in BitPackArray at given index.
* @param bparray array to use
* @param index index to store value at.
* @param val value to store (only as many bits as specified on
* BitPackArray construction are stored).
*/
static inline void
bitpackarray_store_uint64(BitPackArray *array, BitOffset index, uint64_t val)
{
gt_assert(array && index < array->numElems
&& array->bitsPerElem <= sizeof (val)*CHAR_BIT);
gt_bsStoreUInt64(array->store, array->bitsPerElem * index,
array->bitsPerElem, val);
}
/**
* Stores unsigned integer in BitPackArray at given index.
* @param bparray array to use
* @param index index to store value at.
* @param val value to store (only as many bits as specified on
* BitPackArray construction are stored).
*/
static inline uint64_t
bitpackarray_get_uint64(const BitPackArray *array, BitOffset index)
{
gt_assert(array && index < array->numElems
&& array->bitsPerElem <= sizeof (uint64_t)*CHAR_BIT);
return gt_bsGetUInt64(array->store, array->bitsPerElem * index,
array->bitsPerElem);
}
/**
* Unit test function for BitPackArray.
* @return 0 on success, -1 on error.
*/
int gt_bitpackarray_unit_test(GtError*);
/*
static inline void showbitpackarray(const BitPackArray *bitpackarray)
{
GtUword numofunits, idx;
gt_assert(bitpackarray != NULL);
gt_assert(bitpackarray->store != NULL);
numofunits = (GtUword) sizeofbitarray(bitpackarray->bitsPerElem,
bitpackarray->numElems);
printf("numofunits="GT_WU"\n",numofunits);
for (idx=0; idx < numofunits; idx++)
{
printf(""GT_WU": %u\n",idx,(unsigned int) bitpackarray->store[idx]);
fflush(stdout);
}
}
*/
#else
/* some minimal set of declaration to satisfy splint. We cannot use the
original implementation, as this produces many errors when fed into
splint
*/
typedef unsigned char BitElem;
typedef BitElem *BitString;
typedef struct
{
BitString store;
/* and others */
} BitPackArray;
typedef GtUint64 BitOffset;
size_t sizeofbitarray(unsigned bits, BitOffset numValues);
void bitpackarray_delete(BitPackArray *bpa);
BitPackArray *bitpackarray_new(unsigned bits, BitOffset numValues,
bool withstorealloc);
void bitpackarray_store_uint32(BitPackArray *array, BitOffset index,
uint32_t val);
void bitpackarray_store_uint64(BitPackArray *array, BitOffset index,
uint64_t val);
uint32_t bitpackarray_get_uint32(const BitPackArray *array, BitOffset index);
uint64_t bitpackarray_get_uint64(const BitPackArray *array, BitOffset index);
#endif /* S_SPLINT_S */
#endif
|
3565a3ee4da412adadcb07fd88facc5f34b2f1a3
|
f9e7d65cb784c01a0200145ba8d289afe41d4a56
|
/board/asurada/board.c
|
712a89289ede3b4a66666a76d2a2c72d2e3893ee
|
[
"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
| 22,696
|
c
|
board.c
|
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Asurada board configuration */
#include "adc.h"
#include "adc_chip.h"
#include "board/asurada/it5205_sbu.h"
#include "button.h"
#include "charge_manager.h"
#include "charge_state_v2.h"
#include "charger.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
#include "driver/accel_lis2dw12.h"
#include "driver/accelgyro_bmi_common.h"
#include "driver/als_tcs3400.h"
#include "driver/bc12/mt6360.h"
#include "driver/bc12/pi3usb9201.h"
#include "driver/charger/isl923x.h"
#include "driver/ppc/syv682x.h"
#include "driver/tcpm/it83xx_pd.h"
#include "driver/temp_sensor/thermistor.h"
#include "driver/usb_mux/it5205.h"
#include "driver/usb_mux/ps8743.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
#include "keyboard_scan.h"
#include "lid_switch.h"
#include "motion_sense.h"
#include "power.h"
#include "power_button.h"
#include "pwm.h"
#include "pwm_chip.h"
#include "regulator.h"
#include "spi.h"
#include "switch.h"
#include "tablet_mode.h"
#include "task.h"
#include "temp_sensor.h"
#include "timer.h"
#include "uart.h"
#include "usb_charge.h"
#include "usb_mux.h"
#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
static void bc12_interrupt(enum gpio_signal signal);
static void ppc_interrupt(enum gpio_signal signal);
static void x_ec_interrupt(enum gpio_signal signal);
#include "gpio_list.h"
const struct charger_config_t chg_chips[] = {
{
.i2c_port = I2C_PORT_CHARGER,
.i2c_addr_flags = ISL923X_ADDR_FLAGS,
.drv = &isl923x_drv,
},
};
/*
* PWM channels. Must be in the exactly same order as in enum pwm_channel.
* There total three 16 bits clock prescaler registers for all pwm channels,
* so use the same frequency and prescaler register setting is required if
* number of pwm channel greater than three.
*/
const struct pwm_t pwm_channels[] = {
[PWM_CH_LED1] = {
.channel = 0,
.flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
.freq_hz = 324, /* maximum supported frequency */
.pcfsr_sel = PWM_PRESCALER_C4
},
[PWM_CH_LED2] = {
.channel = 1,
.flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
.freq_hz = 324, /* maximum supported frequency */
.pcfsr_sel = PWM_PRESCALER_C4
},
[PWM_CH_LED3] = {
.channel = 2,
.flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
.freq_hz = 324, /* maximum supported frequency */
.pcfsr_sel = PWM_PRESCALER_C4
},
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
/* Wake-up pins for hibernate */
enum gpio_signal hibernate_wake_pins[] = {
GPIO_AC_PRESENT,
GPIO_LID_OPEN,
GPIO_POWER_BUTTON_L,
};
int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
__override void board_hibernate_late(void)
{
/*
* Turn off PP5000_A. Required for devices without Z-state.
* Don't care for devices with Z-state.
*/
gpio_set_level(GPIO_EN_PP5000_A, 0);
/*
* GPIO_EN_SLP_Z not implemented in rev0/1,
* fallback to usual hibernate process.
*/
if (board_get_version() <= 1)
return;
isl9238c_hibernate(CHARGER_SOLO);
gpio_set_level(GPIO_EN_SLP_Z, 1);
/* should not reach here */
__builtin_unreachable();
}
/* power signal list. Must match order of enum power_signal. */
const struct power_signal_info power_signal_list[] = {
{GPIO_PMIC_EC_PWRGD, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_PWR_GOOD"},
{GPIO_AP_IN_SLEEP_L, POWER_SIGNAL_ACTIVE_LOW, "AP_IN_S3_L"},
{GPIO_AP_EC_WATCHDOG_L,
POWER_SIGNAL_ACTIVE_LOW | POWER_SIGNAL_DISABLE_AT_BOOT,
"AP_WDT_ASSERTED"},
};
BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
/* Detect subboard */
static enum board_sub_board board_get_sub_board(void);
/* Initialize board. */
static void board_init(void)
{
/* For Rev0 only. Set GPM0~6 1.8V input. */
IT83XX_GPIO_GCR30 |= BIT(4);
gpio_enable_interrupt(GPIO_AC_PRESENT);
gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL);
/* Enable motion sensor interrupt */
gpio_enable_interrupt(GPIO_BASE_IMU_INT_L);
gpio_enable_interrupt(GPIO_LID_ACCEL_INT_L);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
static void board_tcpc_init(void)
{
gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_ODL);
/* C1: GPIO_USB_C1_PPC_INT_ODL & HDMI: GPIO_PS185_EC_DP_HPD */
gpio_enable_interrupt(GPIO_X_EC_GPIO2);
/* If this is not a Type-C subboard, disable the task. */
if (board_get_sub_board() != SUB_BOARD_TYPEC)
task_disable_task(TASK_ID_PD_C1);
}
/* Must be done after I2C and subboard */
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
/* ADC channels. Must be in the exactly same order as in enum adc_channel. */
const struct adc_t adc_channels[] = {
/* Convert to mV (3000mV/1024). */
{"VBUS", ADC_MAX_MVOLT * 10, ADC_READ_MAX + 1, 0, CHIP_ADC_CH0},
{"BOARD_ID_0", ADC_MAX_MVOLT, ADC_READ_MAX + 1, 0, CHIP_ADC_CH1},
{"BOARD_ID_1", ADC_MAX_MVOLT, ADC_READ_MAX + 1, 0, CHIP_ADC_CH2},
{"CHARGER_AMON_R", ADC_MAX_MVOLT, ADC_READ_MAX + 1, 0, CHIP_ADC_CH3},
{"CHARGER_PMON", ADC_MAX_MVOLT, ADC_READ_MAX + 1, 0, CHIP_ADC_CH6},
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
/* BC12 */
const struct mt6360_config_t mt6360_config = {
.i2c_port = 0,
.i2c_addr_flags = MT6360_PMU_SLAVE_ADDR_FLAGS,
};
const struct pi3usb9201_config_t
pi3usb9201_bc12_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = {
/* [0]: unused */
[1] = {
.i2c_port = 4,
.i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
}
};
struct bc12_config bc12_ports[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{ .drv = &mt6360_drv },
{ .drv = &pi3usb9201_drv },
};
static void bc12_interrupt(enum gpio_signal signal)
{
if (signal == GPIO_USB_C0_BC12_INT_ODL)
task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12, 0);
else
task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12, 0);
}
static void board_sub_bc12_init(void)
{
if (board_get_sub_board() == SUB_BOARD_TYPEC)
gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L);
else
/* If this is not a Type-C subboard, disable the task. */
task_disable_task(TASK_ID_USB_CHG_P1);
}
/* Must be done after I2C and subboard */
DECLARE_HOOK(HOOK_INIT, board_sub_bc12_init, HOOK_PRIO_INIT_I2C + 1);
/*
* I2C channels (A, B, and C) are using the same timing registers (00h~07h)
* at default.
* In order to set frequency independently for each channels,
* We use timing registers 09h~0Bh, and the supported frequency will be:
* 50KHz, 100KHz, 400KHz, or 1MHz.
* I2C channels (D, E and F) can be set different frequency on different ports.
* The I2C(D/E/F) frequency depend on the frequency of SMBus Module and
* the individual prescale register.
* The frequency of SMBus module is 24MHz on default.
* The allowed range of I2C(D/E/F) frequency is as following setting.
* SMBus Module Freq = PLL_CLOCK / ((IT83XX_ECPM_SCDCR2 & 0x0F) + 1)
* (SMBus Module Freq / 510) <= I2C Freq <= (SMBus Module Freq / 8)
* Channel D has multi-function and can be used as UART interface.
* Channel F is reserved for EC debug.
*/
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
{"bat_chg", IT83XX_I2C_CH_A, 100, GPIO_I2C_A_SCL, GPIO_I2C_A_SDA},
{"sensor", IT83XX_I2C_CH_B, 100, GPIO_I2C_B_SCL, GPIO_I2C_B_SDA},
{"usb0", IT83XX_I2C_CH_C, 100, GPIO_I2C_C_SCL, GPIO_I2C_C_SDA},
{"usb1", IT83XX_I2C_CH_E, 100, GPIO_I2C_E_SCL, GPIO_I2C_E_SDA},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
int board_allow_i2c_passthru(int port)
{
return (port == I2C_PORT_VIRTUAL_BATTERY);
}
/* PPC */
struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.i2c_port = I2C_PORT_PPC0,
.i2c_addr_flags = SYV682X_ADDR0_FLAGS,
.drv = &syv682x_drv,
.frs_en = GPIO_USB_C0_FRS_EN,
},
{
.i2c_port = I2C_PORT_PPC1,
.i2c_addr_flags = SYV682X_ADDR0_FLAGS,
.drv = &syv682x_drv,
.frs_en = GPIO_USB_C1_FRS_EN,
},
};
unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
static void ppc_interrupt(enum gpio_signal signal)
{
if (signal == GPIO_USB_C0_PPC_INT_ODL)
/* C0: PPC interrupt */
syv682x_interrupt(0);
}
int debounced_hpd;
/**
* Handle PS185 HPD changing state.
*/
static void ps185_hdmi_hpd_deferred(void)
{
const int new_hpd = gpio_get_level(GPIO_PS185_EC_DP_HPD);
/* HPD status not changed, probably a glitch, just return. */
if (debounced_hpd == new_hpd)
return;
debounced_hpd = new_hpd;
gpio_set_level(GPIO_EC_DPBRDG_HPD_ODL, !debounced_hpd);
CPRINTS(debounced_hpd ? "HDMI plug" : "HDMI unplug");
}
DECLARE_DEFERRED(ps185_hdmi_hpd_deferred);
#define PS185_HPD_DEBOUCE 250
static void hdmi_hpd_interrupt(enum gpio_signal signal)
{
hook_call_deferred(&ps185_hdmi_hpd_deferred_data, PS185_HPD_DEBOUCE);
}
/* HDMI/TYPE-C function shared subboard interrupt */
static void x_ec_interrupt(enum gpio_signal signal)
{
int sub = board_get_sub_board();
if (sub == SUB_BOARD_TYPEC)
/* C1: PPC interrupt */
syv682x_interrupt(1);
else if (sub == SUB_BOARD_HDMI)
hdmi_hpd_interrupt(signal);
else
CPRINTS("Undetected subboard interrupt.");
}
int ppc_get_alert_status(int port)
{
if (port == 0)
return gpio_get_level(GPIO_USB_C0_PPC_INT_ODL) == 0;
if (port == 1 && board_get_sub_board() == SUB_BOARD_TYPEC)
return gpio_get_level(GPIO_USB_C1_PPC_INT_ODL) == 0;
return 0;
}
void board_overcurrent_event(int port, int is_overcurrented)
{
/* TODO: check correct operation for Asurada */
}
/* TCPC */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.bus_type = EC_BUS_TYPE_EMBEDDED,
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
},
{
.bus_type = EC_BUS_TYPE_EMBEDDED,
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
/* Alert is active-low, push-pull */
.flags = 0,
},
};
uint16_t tcpc_get_alert_status(void)
{
/*
* C0 & C1: TCPC is embedded in the EC and processes interrupts in the
* chip code (it83xx/intc.c)
*/
return 0;
}
void board_reset_pd_mcu(void)
{
/*
* C0 & C1: TCPC is embedded in the EC and processes interrupts in the
* chip code (it83xx/intc.c)
*/
}
/* USB-A */
const int usb_port_enable[] = {
GPIO_EN_PP5000_USB_A0_VBUS,
};
BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT);
/* USB Mux */
static int board_ps8743_mux_set(const struct usb_mux *me,
mux_state_t mux_state)
{
int rv = EC_SUCCESS;
int reg = 0;
rv = ps8743_read(me, PS8743_REG_MODE, ®);
if (rv)
return rv;
/* Disable FLIP pin, enable I2C control. */
reg |= PS8743_MODE_FLIP_REG_CONTROL;
/* Disable CE_USB pin, enable I2C control. */
reg |= PS8743_MODE_USB_REG_CONTROL;
/* Disable CE_DP pin, enable I2C control. */
reg |= PS8743_MODE_DP_REG_CONTROL;
/*
* DP specific config
*
* Enable/Disable IN_HPD on the DB.
*/
gpio_set_level(GPIO_USB_C1_DP_IN_HPD,
mux_state & USB_PD_MUX_DP_ENABLED);
return ps8743_write(me, PS8743_REG_MODE, reg);
}
const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.usb_port = 0,
.i2c_port = I2C_PORT_USB_MUX0,
.i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
.driver = &it5205_usb_mux_driver,
},
{
.usb_port = 1,
.i2c_port = I2C_PORT_USB_MUX1,
.i2c_addr_flags = PS8743_I2C_ADDR0_FLAG,
.driver = &ps8743_usb_mux_driver,
.board_set = &board_ps8743_mux_set,
},
};
int board_set_active_charge_port(int port)
{
int i;
int is_valid_port = port == 0 || (port == 1 && board_get_sub_board() ==
SUB_BOARD_TYPEC);
if (!is_valid_port && port != CHARGE_PORT_NONE)
return EC_ERROR_INVAL;
if (port == CHARGE_PORT_NONE) {
CPRINTS("Disabling all charger ports");
/* Disable all ports. */
for (i = 0; i < ppc_cnt; i++) {
/*
* Do not return early if one fails otherwise we can
* get into a boot loop assertion failure.
*/
if (ppc_vbus_sink_enable(i, 0))
CPRINTS("Disabling C%d as sink failed.", i);
}
return EC_SUCCESS;
}
/* Check if the port is sourcing VBUS. */
if (ppc_is_sourcing_vbus(port)) {
CPRINTF("Skip enable C%d", port);
return EC_ERROR_INVAL;
}
CPRINTS("New charge port: C%d", port);
/*
* Turn off the other ports' sink path FETs, before enabling the
* requested charge port.
*/
for (i = 0; i < ppc_cnt; i++) {
if (i == port)
continue;
if (ppc_vbus_sink_enable(i, 0))
CPRINTS("C%d: sink path disable failed.", i);
}
/* Enable requested charge port. */
if (ppc_vbus_sink_enable(port, 1)) {
CPRINTS("C%d: sink path enable failed.", port);
return EC_ERROR_UNKNOWN;
}
return EC_SUCCESS;
}
void board_set_charge_limit(int port, int supplier, int charge_ma,
int max_ma, int charge_mv)
{
charge_set_input_current_limit(
MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
{
/*
* We ignore the cc_pin and PPC vconn because polarity and PPC vconn
* should already be set correctly in the PPC driver via the pd
* state machine.
*/
}
/* Called on AP S3 -> S0 transition */
static void board_chipset_resume(void)
{
gpio_set_level(GPIO_EC_BL_EN_OD, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
/* Called on AP S0 -> S3 transition */
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_EC_BL_EN_OD, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
/* Sub-board */
static enum board_sub_board board_get_sub_board(void)
{
static enum board_sub_board sub = SUB_BOARD_NONE;
if (sub != SUB_BOARD_NONE)
return sub;
/* HDMI board has external pull high. */
if (gpio_get_level(GPIO_EC_X_GPIO3)) {
sub = SUB_BOARD_HDMI;
/* Only has 1 PPC with HDMI subboard */
ppc_cnt = 1;
/* EC_X_GPIO1 */
gpio_set_flags(GPIO_EN_HDMI_PWR, GPIO_OUT_HIGH);
/* X_EC_GPIO2 */
gpio_set_flags(GPIO_PS185_EC_DP_HPD, GPIO_INT_BOTH);
/* EC_X_GPIO3 */
gpio_set_flags(GPIO_PS185_PWRDN_ODL, GPIO_ODR_HIGH);
} else {
sub = SUB_BOARD_TYPEC;
/* EC_X_GPIO1 */
gpio_set_flags(GPIO_USB_C1_FRS_EN, GPIO_OUT_LOW);
/* X_EC_GPIO2 */
gpio_set_flags(GPIO_USB_C1_PPC_INT_ODL,
GPIO_INT_BOTH | GPIO_PULL_UP);
/* EC_X_GPIO3 */
gpio_set_flags(GPIO_USB_C1_DP_IN_HPD, GPIO_OUT_LOW);
}
CPRINTS("Detect %s SUB", sub == SUB_BOARD_HDMI ? "HDMI" : "TYPEC");
return sub;
}
static void sub_board_init(void)
{
board_get_sub_board();
}
DECLARE_HOOK(HOOK_INIT, sub_board_init, HOOK_PRIO_INIT_I2C - 1);
__override uint8_t board_get_usb_pd_port_count(void)
{
if (board_get_sub_board() == SUB_BOARD_TYPEC)
return CONFIG_USB_PD_PORT_MAX_COUNT;
else
return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
}
/* Lid */
#ifndef TEST_BUILD
/* This callback disables keyboard when convertibles are fully open */
void lid_angle_peripheral_enable(int enable)
{
int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON);
if (enable) {
keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE);
} else {
/*
* Ensure that the chipset is off before disabling the keyboard.
* When the chipset is on, the EC keeps the keyboard enabled and
* the AP decides whether to ignore input devices or not.
*/
if (!chipset_in_s0)
keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE);
}
}
#endif
/* SD Card */
int board_regulator_get_info(uint32_t index, char *name,
uint16_t *num_voltages, uint16_t *voltages_mv)
{
enum mt6360_regulator_id id = index;
return mt6360_regulator_get_info(id, name, num_voltages,
voltages_mv);
}
int board_regulator_enable(uint32_t index, uint8_t enable)
{
enum mt6360_regulator_id id = index;
return mt6360_regulator_enable(id, enable);
}
int board_regulator_is_enabled(uint32_t index, uint8_t *enabled)
{
enum mt6360_regulator_id id = index;
return mt6360_regulator_is_enabled(id, enabled);
}
int board_regulator_set_voltage(uint32_t index, uint32_t min_mv,
uint32_t max_mv)
{
enum mt6360_regulator_id id = index;
return mt6360_regulator_set_voltage(id, min_mv, max_mv);
}
int board_regulator_get_voltage(uint32_t index, uint32_t *voltage_mv)
{
enum mt6360_regulator_id id = index;
return mt6360_regulator_get_voltage(id, voltage_mv);
}
/* Sensor */
static struct mutex g_base_mutex;
static struct mutex g_lid_mutex;
static struct bmi_drv_data_t g_bmi160_data;
static struct stprivate_data g_lis2dwl_data;
/* Matrix to rotate accelrator into standard reference frame */
/* TODO: update the matrix after we have assembled unit */
static const mat33_fp_t mag_standard_ref = {
{0, FLOAT_TO_FP(-1), 0},
{FLOAT_TO_FP(-1), 0, 0},
{0, 0, FLOAT_TO_FP(-1)},
};
/* TCS3400 private data */
static struct als_drv_data_t g_tcs3400_data = {
.als_cal.scale = 1,
.als_cal.uscale = 0,
.als_cal.offset = 0,
.als_cal.channel_scale = {
.k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kc */
.cover_scale = ALS_CHANNEL_SCALE(1.0), /* CT */
},
};
#ifdef BOARD_ASURADA
/* Matrix to rotate accelerometer into standard reference frame */
/* for rev 0 */
static const mat33_fp_t base_standard_ref_rev0 = {
{FLOAT_TO_FP(-1), 0, 0},
{0, FLOAT_TO_FP(1), 0},
{0, 0, FLOAT_TO_FP(-1)},
};
static void update_rotation_matrix(void)
{
motion_sensors[BASE_ACCEL].rot_standard_ref =
&base_standard_ref_rev0;
motion_sensors[BASE_GYRO].rot_standard_ref =
&base_standard_ref_rev0;
}
DECLARE_HOOK(HOOK_INIT, update_rotation_matrix, HOOK_PRIO_INIT_ADC + 1);
#endif
static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = {
/*
* TODO: calculate the actual coefficients and scaling factors
*/
.calibration.rgb_cal[X] = {
.offset = 0,
.scale = {
.k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kr */
.cover_scale = ALS_CHANNEL_SCALE(1.0)
},
.coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(0),
},
.calibration.rgb_cal[Y] = {
.offset = 0,
.scale = {
.k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kg */
.cover_scale = ALS_CHANNEL_SCALE(1.0)
},
.coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(0.1),
},
.calibration.rgb_cal[Z] = {
.offset = 0,
.scale = {
.k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kb */
.cover_scale = ALS_CHANNEL_SCALE(1.0)
},
.coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0),
.coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(0),
},
.calibration.irt = INT_TO_FP(1),
.saturation.again = TCS_DEFAULT_AGAIN,
.saturation.atime = TCS_DEFAULT_ATIME,
};
struct motion_sensor_t motion_sensors[] = {
/*
* Note: bmi160: supports accelerometer and gyro sensor
* Requirement: accelerometer sensor must init before gyro sensor
* DO NOT change the order of the following table.
*/
[BASE_ACCEL] = {
.name = "Base Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
.chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_BASE,
.drv = &bmi160_drv,
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
.i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
.rot_standard_ref = NULL, /* identity matrix */
.default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs */
.min_frequency = BMI_ACCEL_MIN_FREQ,
.max_frequency = BMI_ACCEL_MAX_FREQ,
.config = {
/* Sensor on for angle detection */
[SENSOR_CONFIG_EC_S0] = {
.odr = 10000 | ROUND_UP_FLAG,
.ec_rate = 100 * MSEC,
},
/* Sensor on for angle detection */
[SENSOR_CONFIG_EC_S3] = {
.odr = 10000 | ROUND_UP_FLAG,
.ec_rate = 100 * MSEC,
},
},
},
[BASE_GYRO] = {
.name = "Base Gyro",
.active_mask = SENSOR_ACTIVE_S0_S3,
.chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_GYRO,
.location = MOTIONSENSE_LOC_BASE,
.drv = &bmi160_drv,
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
.i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
.default_range = 1000, /* dps */
.rot_standard_ref = NULL, /* identity matrix */
.min_frequency = BMI_GYRO_MIN_FREQ,
.max_frequency = BMI_GYRO_MAX_FREQ,
},
[BASE_MAG] = {
.name = "Base Mag",
.active_mask = SENSOR_ACTIVE_S0_S3,
.chip = MOTIONSENSE_CHIP_BMI160,
.type = MOTIONSENSE_TYPE_MAG,
.location = MOTIONSENSE_LOC_BASE,
.drv = &bmi160_drv,
.mutex = &g_base_mutex,
.drv_data = &g_bmi160_data,
.port = I2C_PORT_ACCEL,
.i2c_spi_addr_flags = BMI160_ADDR0_FLAGS,
.default_range = BIT(11), /* 16LSB / uT, fixed */
.rot_standard_ref = &mag_standard_ref,
.min_frequency = BMM150_MAG_MIN_FREQ,
.max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL),
},
[LID_ACCEL] = {
.name = "Lid Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
.chip = MOTIONSENSE_CHIP_LIS2DWL,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
.drv = &lis2dw12_drv,
.mutex = &g_lid_mutex,
.drv_data = &g_lis2dwl_data,
.int_signal = GPIO_LID_ACCEL_INT_L,
.port = I2C_PORT_ACCEL,
.i2c_spi_addr_flags = LIS2DWL_ADDR1_FLAGS,
.flags = MOTIONSENSE_FLAG_INT_SIGNAL,
.rot_standard_ref = NULL, /* identity matrix */
.default_range = 2, /* g */
.min_frequency = LIS2DW12_ODR_MIN_VAL,
.max_frequency = LIS2DW12_ODR_MAX_VAL,
.config = {
/* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {
.odr = 12500 | ROUND_UP_FLAG,
},
/* Sensor on for lid angle detection */
[SENSOR_CONFIG_EC_S3] = {
.odr = 10000 | ROUND_UP_FLAG,
},
},
},
[CLEAR_ALS] = {
.name = "Clear Light",
.active_mask = SENSOR_ACTIVE_S0_S3,
.chip = MOTIONSENSE_CHIP_TCS3400,
.type = MOTIONSENSE_TYPE_LIGHT,
.location = MOTIONSENSE_LOC_LID,
.drv = &tcs3400_drv,
.drv_data = &g_tcs3400_data,
.port = I2C_PORT_ACCEL,
.i2c_spi_addr_flags = TCS3400_I2C_ADDR_FLAGS,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1x, uscale = 0 */
.min_frequency = TCS3400_LIGHT_MIN_FREQ,
.max_frequency = TCS3400_LIGHT_MAX_FREQ,
.config = {
/* Run ALS sensor in S0 */
[SENSOR_CONFIG_EC_S0] = {
.odr = 1000,
},
},
},
[RGB_ALS] = {
.name = "RGB Light",
.active_mask = SENSOR_ACTIVE_S0_S3,
.chip = MOTIONSENSE_CHIP_TCS3400,
.type = MOTIONSENSE_TYPE_LIGHT_RGB,
.location = MOTIONSENSE_LOC_LID,
.drv = &tcs3400_rgb_drv,
.drv_data = &g_tcs3400_rgb_data,
.rot_standard_ref = NULL,
.default_range = 0x10000, /* scale = 1x, uscale = 0 */
/* freq = 0 indicates we should not use sensor directly */
.min_frequency = 0,
.max_frequency = 0,
},
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
|
9617f68aa051859cd7ac9157ac8e1f30a4f0c266
|
f62ddee2dcadcae0e90f969be513b04e16dabf58
|
/data/dtfabric/runtime_structure.c/read_data-debug-integer-in_struct-as_flags.c
|
40e1ab6ff6bb0d3ade041d93c2ca0abb7b612aa7
|
[
"Apache-2.0",
"GPL-1.0-or-later",
"CC-BY-SA-3.0",
"LicenseRef-scancode-other-copyleft",
"GFDL-1.1-or-later",
"LicenseRef-scancode-unknown-license-reference",
"CC-BY-SA-4.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
| 260
|
c
|
read_data-debug-integer-in_struct-as_flags.c
|
libcnotify_printf(
"%s: ${member_name_description}${tab_alignment}: ${format_indicator}\n",
function,
${structure_name}->${member_name} );
liblnk_debug_print_${member_name}(
${structure_name}->${member_name} );
libcnotify_printf(
"\n" );
|
e9933786dd997ce50bac0f90573503f6b512aa12
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/os/board/rtl8730e/src/component/file_system/fatfs/disk_if/inc/usbdisk.h
|
3998ecedb49137c52c55c61da9c07a9554e856ea
|
[
"GPL-1.0-or-later",
"BSD-3-Clause",
"ISC",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"Apache-2.0"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 153
|
h
|
usbdisk.h
|
#ifndef _USBDISK_H_
#define _USBDISK_H_
#include "fatfs_ext/inc/ff_driver.h"
#include "cmsis.h"
extern ll_diskio_drv USB_disk_Driver;
#endif
|
879c91981ed287cb1097570ab268cbe001b2f21b
|
00c64e0967d197d8c6fc3427954e2d0b2ff13ca0
|
/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vnot.c
|
27e5ead13679eaeaf12838afae891f4adce182b0
|
[
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
triSYCL/sycl
|
893048e80158cf3359c1ad8912da9ccf493faf69
|
5a95a7136a11b75f01ef839d9229780032bbeecf
|
refs/heads/sycl/unified/master
| 2023-08-23T22:06:46.238209
| 2023-05-24T22:54:31
| 2023-05-24T22:54:31
| 178,923,006
| 103
| 17
|
NOASSERTION
| 2023-09-12T20:03:26
| 2019-04-01T18:29:01
| null |
UTF-8
|
C
| false
| false
| 126,114
|
c
|
vnot.c
|
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone \
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \
// RUN: FileCheck --check-prefix=CHECK-RV64 %s
#include <riscv_vector.h>
// CHECK-RV64-LABEL: @test_vnot_v_i8mf8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.nxv1i8.i8.i64(<vscale x 1 x i8> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vint8mf8_t test_vnot_v_i8mf8_tu(vint8mf8_t maskedoff, vint8mf8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.nxv2i8.i8.i64(<vscale x 2 x i8> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vint8mf4_t test_vnot_v_i8mf4_tu(vint8mf4_t maskedoff, vint8mf4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.nxv4i8.i8.i64(<vscale x 4 x i8> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vint8mf2_t test_vnot_v_i8mf2_tu(vint8mf2_t maskedoff, vint8mf2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m1_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.nxv8i8.i8.i64(<vscale x 8 x i8> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vint8m1_t test_vnot_v_i8m1_tu(vint8m1_t maskedoff, vint8m1_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.nxv16i8.i8.i64(<vscale x 16 x i8> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vint8m2_t test_vnot_v_i8m2_tu(vint8m2_t maskedoff, vint8m2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.nxv32i8.i8.i64(<vscale x 32 x i8> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vint8m4_t test_vnot_v_i8m4_tu(vint8m4_t maskedoff, vint8m4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.nxv64i8.i8.i64(<vscale x 64 x i8> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vint8m8_t test_vnot_v_i8m8_tu(vint8m8_t maskedoff, vint8m8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.nxv1i16.i16.i64(<vscale x 1 x i16> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vint16mf4_t test_vnot_v_i16mf4_tu(vint16mf4_t maskedoff, vint16mf4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.nxv2i16.i16.i64(<vscale x 2 x i16> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vint16mf2_t test_vnot_v_i16mf2_tu(vint16mf2_t maskedoff, vint16mf2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m1_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.nxv4i16.i16.i64(<vscale x 4 x i16> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vint16m1_t test_vnot_v_i16m1_tu(vint16m1_t maskedoff, vint16m1_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.nxv8i16.i16.i64(<vscale x 8 x i16> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vint16m2_t test_vnot_v_i16m2_tu(vint16m2_t maskedoff, vint16m2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.nxv16i16.i16.i64(<vscale x 16 x i16> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vint16m4_t test_vnot_v_i16m4_tu(vint16m4_t maskedoff, vint16m4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.nxv32i16.i16.i64(<vscale x 32 x i16> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vint16m8_t test_vnot_v_i16m8_tu(vint16m8_t maskedoff, vint16m8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32mf2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.nxv1i32.i32.i64(<vscale x 1 x i32> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vint32mf2_t test_vnot_v_i32mf2_tu(vint32mf2_t maskedoff, vint32mf2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m1_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.nxv2i32.i32.i64(<vscale x 2 x i32> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vint32m1_t test_vnot_v_i32m1_tu(vint32m1_t maskedoff, vint32m1_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.nxv4i32.i32.i64(<vscale x 4 x i32> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vint32m2_t test_vnot_v_i32m2_tu(vint32m2_t maskedoff, vint32m2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.nxv8i32.i32.i64(<vscale x 8 x i32> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vint32m4_t test_vnot_v_i32m4_tu(vint32m4_t maskedoff, vint32m4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.nxv16i32.i32.i64(<vscale x 16 x i32> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vint32m8_t test_vnot_v_i32m8_tu(vint32m8_t maskedoff, vint32m8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m1_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.nxv1i64.i64.i64(<vscale x 1 x i64> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vint64m1_t test_vnot_v_i64m1_tu(vint64m1_t maskedoff, vint64m1_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.nxv2i64.i64.i64(<vscale x 2 x i64> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vint64m2_t test_vnot_v_i64m2_tu(vint64m2_t maskedoff, vint64m2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.nxv4i64.i64.i64(<vscale x 4 x i64> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vint64m4_t test_vnot_v_i64m4_tu(vint64m4_t maskedoff, vint64m4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.nxv8i64.i64.i64(<vscale x 8 x i64> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vint64m8_t test_vnot_v_i64m8_tu(vint64m8_t maskedoff, vint64m8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.nxv1i8.i8.i64(<vscale x 1 x i8> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vuint8mf8_t test_vnot_v_u8mf8_tu(vuint8mf8_t maskedoff, vuint8mf8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.nxv2i8.i8.i64(<vscale x 2 x i8> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vuint8mf4_t test_vnot_v_u8mf4_tu(vuint8mf4_t maskedoff, vuint8mf4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.nxv4i8.i8.i64(<vscale x 4 x i8> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vuint8mf2_t test_vnot_v_u8mf2_tu(vuint8mf2_t maskedoff, vuint8mf2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m1_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.nxv8i8.i8.i64(<vscale x 8 x i8> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vuint8m1_t test_vnot_v_u8m1_tu(vuint8m1_t maskedoff, vuint8m1_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.nxv16i8.i8.i64(<vscale x 16 x i8> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vuint8m2_t test_vnot_v_u8m2_tu(vuint8m2_t maskedoff, vuint8m2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.nxv32i8.i8.i64(<vscale x 32 x i8> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vuint8m4_t test_vnot_v_u8m4_tu(vuint8m4_t maskedoff, vuint8m4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.nxv64i8.i8.i64(<vscale x 64 x i8> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vuint8m8_t test_vnot_v_u8m8_tu(vuint8m8_t maskedoff, vuint8m8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.nxv1i16.i16.i64(<vscale x 1 x i16> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vuint16mf4_t test_vnot_v_u16mf4_tu(vuint16mf4_t maskedoff, vuint16mf4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.nxv2i16.i16.i64(<vscale x 2 x i16> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vuint16mf2_t test_vnot_v_u16mf2_tu(vuint16mf2_t maskedoff, vuint16mf2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m1_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.nxv4i16.i16.i64(<vscale x 4 x i16> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vuint16m1_t test_vnot_v_u16m1_tu(vuint16m1_t maskedoff, vuint16m1_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.nxv8i16.i16.i64(<vscale x 8 x i16> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vuint16m2_t test_vnot_v_u16m2_tu(vuint16m2_t maskedoff, vuint16m2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.nxv16i16.i16.i64(<vscale x 16 x i16> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vuint16m4_t test_vnot_v_u16m4_tu(vuint16m4_t maskedoff, vuint16m4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.nxv32i16.i16.i64(<vscale x 32 x i16> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vuint16m8_t test_vnot_v_u16m8_tu(vuint16m8_t maskedoff, vuint16m8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32mf2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.nxv1i32.i32.i64(<vscale x 1 x i32> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vuint32mf2_t test_vnot_v_u32mf2_tu(vuint32mf2_t maskedoff, vuint32mf2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m1_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.nxv2i32.i32.i64(<vscale x 2 x i32> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vuint32m1_t test_vnot_v_u32m1_tu(vuint32m1_t maskedoff, vuint32m1_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.nxv4i32.i32.i64(<vscale x 4 x i32> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vuint32m2_t test_vnot_v_u32m2_tu(vuint32m2_t maskedoff, vuint32m2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.nxv8i32.i32.i64(<vscale x 8 x i32> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vuint32m4_t test_vnot_v_u32m4_tu(vuint32m4_t maskedoff, vuint32m4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.nxv16i32.i32.i64(<vscale x 16 x i32> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vuint32m8_t test_vnot_v_u32m8_tu(vuint32m8_t maskedoff, vuint32m8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m1_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.nxv1i64.i64.i64(<vscale x 1 x i64> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vuint64m1_t test_vnot_v_u64m1_tu(vuint64m1_t maskedoff, vuint64m1_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m2_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.nxv2i64.i64.i64(<vscale x 2 x i64> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vuint64m2_t test_vnot_v_u64m2_tu(vuint64m2_t maskedoff, vuint64m2_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m4_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.nxv4i64.i64.i64(<vscale x 4 x i64> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vuint64m4_t test_vnot_v_u64m4_tu(vuint64m4_t maskedoff, vuint64m4_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m8_tu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.nxv8i64.i64.i64(<vscale x 8 x i64> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vuint64m8_t test_vnot_v_u64m8_tu(vuint64m8_t maskedoff, vuint64m8_t op1, size_t vl) {
return vnot_tu(maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.nxv1i8.i8.i64(<vscale x 1 x i8> poison, <vscale x 1 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vint8mf8_t test_vnot_v_i8mf8_ta(vint8mf8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.nxv2i8.i8.i64(<vscale x 2 x i8> poison, <vscale x 2 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vint8mf4_t test_vnot_v_i8mf4_ta(vint8mf4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.nxv4i8.i8.i64(<vscale x 4 x i8> poison, <vscale x 4 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vint8mf2_t test_vnot_v_i8mf2_ta(vint8mf2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m1_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.nxv8i8.i8.i64(<vscale x 8 x i8> poison, <vscale x 8 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vint8m1_t test_vnot_v_i8m1_ta(vint8m1_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.nxv16i8.i8.i64(<vscale x 16 x i8> poison, <vscale x 16 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vint8m2_t test_vnot_v_i8m2_ta(vint8m2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.nxv32i8.i8.i64(<vscale x 32 x i8> poison, <vscale x 32 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vint8m4_t test_vnot_v_i8m4_ta(vint8m4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.nxv64i8.i8.i64(<vscale x 64 x i8> poison, <vscale x 64 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vint8m8_t test_vnot_v_i8m8_ta(vint8m8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.nxv1i16.i16.i64(<vscale x 1 x i16> poison, <vscale x 1 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vint16mf4_t test_vnot_v_i16mf4_ta(vint16mf4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.nxv2i16.i16.i64(<vscale x 2 x i16> poison, <vscale x 2 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vint16mf2_t test_vnot_v_i16mf2_ta(vint16mf2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m1_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.nxv4i16.i16.i64(<vscale x 4 x i16> poison, <vscale x 4 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vint16m1_t test_vnot_v_i16m1_ta(vint16m1_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.nxv8i16.i16.i64(<vscale x 8 x i16> poison, <vscale x 8 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vint16m2_t test_vnot_v_i16m2_ta(vint16m2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.nxv16i16.i16.i64(<vscale x 16 x i16> poison, <vscale x 16 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vint16m4_t test_vnot_v_i16m4_ta(vint16m4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.nxv32i16.i16.i64(<vscale x 32 x i16> poison, <vscale x 32 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vint16m8_t test_vnot_v_i16m8_ta(vint16m8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32mf2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.nxv1i32.i32.i64(<vscale x 1 x i32> poison, <vscale x 1 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vint32mf2_t test_vnot_v_i32mf2_ta(vint32mf2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m1_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.nxv2i32.i32.i64(<vscale x 2 x i32> poison, <vscale x 2 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vint32m1_t test_vnot_v_i32m1_ta(vint32m1_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.nxv4i32.i32.i64(<vscale x 4 x i32> poison, <vscale x 4 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vint32m2_t test_vnot_v_i32m2_ta(vint32m2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.nxv8i32.i32.i64(<vscale x 8 x i32> poison, <vscale x 8 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vint32m4_t test_vnot_v_i32m4_ta(vint32m4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.nxv16i32.i32.i64(<vscale x 16 x i32> poison, <vscale x 16 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vint32m8_t test_vnot_v_i32m8_ta(vint32m8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m1_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.nxv1i64.i64.i64(<vscale x 1 x i64> poison, <vscale x 1 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vint64m1_t test_vnot_v_i64m1_ta(vint64m1_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.nxv2i64.i64.i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vint64m2_t test_vnot_v_i64m2_ta(vint64m2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.nxv4i64.i64.i64(<vscale x 4 x i64> poison, <vscale x 4 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vint64m4_t test_vnot_v_i64m4_ta(vint64m4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.nxv8i64.i64.i64(<vscale x 8 x i64> poison, <vscale x 8 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vint64m8_t test_vnot_v_i64m8_ta(vint64m8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.nxv1i8.i8.i64(<vscale x 1 x i8> poison, <vscale x 1 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vuint8mf8_t test_vnot_v_u8mf8_ta(vuint8mf8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.nxv2i8.i8.i64(<vscale x 2 x i8> poison, <vscale x 2 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vuint8mf4_t test_vnot_v_u8mf4_ta(vuint8mf4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.nxv4i8.i8.i64(<vscale x 4 x i8> poison, <vscale x 4 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vuint8mf2_t test_vnot_v_u8mf2_ta(vuint8mf2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m1_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.nxv8i8.i8.i64(<vscale x 8 x i8> poison, <vscale x 8 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vuint8m1_t test_vnot_v_u8m1_ta(vuint8m1_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.nxv16i8.i8.i64(<vscale x 16 x i8> poison, <vscale x 16 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vuint8m2_t test_vnot_v_u8m2_ta(vuint8m2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.nxv32i8.i8.i64(<vscale x 32 x i8> poison, <vscale x 32 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vuint8m4_t test_vnot_v_u8m4_ta(vuint8m4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.nxv64i8.i8.i64(<vscale x 64 x i8> poison, <vscale x 64 x i8> [[OP1:%.*]], i8 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vuint8m8_t test_vnot_v_u8m8_ta(vuint8m8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.nxv1i16.i16.i64(<vscale x 1 x i16> poison, <vscale x 1 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vuint16mf4_t test_vnot_v_u16mf4_ta(vuint16mf4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.nxv2i16.i16.i64(<vscale x 2 x i16> poison, <vscale x 2 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vuint16mf2_t test_vnot_v_u16mf2_ta(vuint16mf2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m1_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.nxv4i16.i16.i64(<vscale x 4 x i16> poison, <vscale x 4 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vuint16m1_t test_vnot_v_u16m1_ta(vuint16m1_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.nxv8i16.i16.i64(<vscale x 8 x i16> poison, <vscale x 8 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vuint16m2_t test_vnot_v_u16m2_ta(vuint16m2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.nxv16i16.i16.i64(<vscale x 16 x i16> poison, <vscale x 16 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vuint16m4_t test_vnot_v_u16m4_ta(vuint16m4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.nxv32i16.i16.i64(<vscale x 32 x i16> poison, <vscale x 32 x i16> [[OP1:%.*]], i16 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vuint16m8_t test_vnot_v_u16m8_ta(vuint16m8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32mf2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.nxv1i32.i32.i64(<vscale x 1 x i32> poison, <vscale x 1 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vuint32mf2_t test_vnot_v_u32mf2_ta(vuint32mf2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m1_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.nxv2i32.i32.i64(<vscale x 2 x i32> poison, <vscale x 2 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vuint32m1_t test_vnot_v_u32m1_ta(vuint32m1_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.nxv4i32.i32.i64(<vscale x 4 x i32> poison, <vscale x 4 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vuint32m2_t test_vnot_v_u32m2_ta(vuint32m2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.nxv8i32.i32.i64(<vscale x 8 x i32> poison, <vscale x 8 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vuint32m4_t test_vnot_v_u32m4_ta(vuint32m4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.nxv16i32.i32.i64(<vscale x 16 x i32> poison, <vscale x 16 x i32> [[OP1:%.*]], i32 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vuint32m8_t test_vnot_v_u32m8_ta(vuint32m8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m1_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.nxv1i64.i64.i64(<vscale x 1 x i64> poison, <vscale x 1 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vuint64m1_t test_vnot_v_u64m1_ta(vuint64m1_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m2_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.nxv2i64.i64.i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vuint64m2_t test_vnot_v_u64m2_ta(vuint64m2_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m4_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.nxv4i64.i64.i64(<vscale x 4 x i64> poison, <vscale x 4 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vuint64m4_t test_vnot_v_u64m4_ta(vuint64m4_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m8_ta(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.nxv8i64.i64.i64(<vscale x 8 x i64> poison, <vscale x 8 x i64> [[OP1:%.*]], i64 -1, i64 [[VL:%.*]])
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vuint64m8_t test_vnot_v_u64m8_ta(vuint64m8_t op1, size_t vl) {
return vnot_ta(op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.mask.nxv1i8.i8.i64(<vscale x 1 x i8> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vint8mf8_t test_vnot_v_i8mf8_tuma(vbool64_t mask, vint8mf8_t maskedoff, vint8mf8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.mask.nxv2i8.i8.i64(<vscale x 2 x i8> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vint8mf4_t test_vnot_v_i8mf4_tuma(vbool32_t mask, vint8mf4_t maskedoff, vint8mf4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.mask.nxv4i8.i8.i64(<vscale x 4 x i8> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vint8mf2_t test_vnot_v_i8mf2_tuma(vbool16_t mask, vint8mf2_t maskedoff, vint8mf2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m1_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.mask.nxv8i8.i8.i64(<vscale x 8 x i8> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vint8m1_t test_vnot_v_i8m1_tuma(vbool8_t mask, vint8m1_t maskedoff, vint8m1_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.mask.nxv16i8.i8.i64(<vscale x 16 x i8> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vint8m2_t test_vnot_v_i8m2_tuma(vbool4_t mask, vint8m2_t maskedoff, vint8m2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.mask.nxv32i8.i8.i64(<vscale x 32 x i8> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vint8m4_t test_vnot_v_i8m4_tuma(vbool2_t mask, vint8m4_t maskedoff, vint8m4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.mask.nxv64i8.i8.i64(<vscale x 64 x i8> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 -1, <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vint8m8_t test_vnot_v_i8m8_tuma(vbool1_t mask, vint8m8_t maskedoff, vint8m8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.mask.nxv1i16.i16.i64(<vscale x 1 x i16> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vint16mf4_t test_vnot_v_i16mf4_tuma(vbool64_t mask, vint16mf4_t maskedoff, vint16mf4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.mask.nxv2i16.i16.i64(<vscale x 2 x i16> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vint16mf2_t test_vnot_v_i16mf2_tuma(vbool32_t mask, vint16mf2_t maskedoff, vint16mf2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m1_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.mask.nxv4i16.i16.i64(<vscale x 4 x i16> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vint16m1_t test_vnot_v_i16m1_tuma(vbool16_t mask, vint16m1_t maskedoff, vint16m1_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.mask.nxv8i16.i16.i64(<vscale x 8 x i16> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vint16m2_t test_vnot_v_i16m2_tuma(vbool8_t mask, vint16m2_t maskedoff, vint16m2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.mask.nxv16i16.i16.i64(<vscale x 16 x i16> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vint16m4_t test_vnot_v_i16m4_tuma(vbool4_t mask, vint16m4_t maskedoff, vint16m4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.mask.nxv32i16.i16.i64(<vscale x 32 x i16> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vint16m8_t test_vnot_v_i16m8_tuma(vbool2_t mask, vint16m8_t maskedoff, vint16m8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32mf2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.mask.nxv1i32.i32.i64(<vscale x 1 x i32> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vint32mf2_t test_vnot_v_i32mf2_tuma(vbool64_t mask, vint32mf2_t maskedoff, vint32mf2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m1_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.mask.nxv2i32.i32.i64(<vscale x 2 x i32> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vint32m1_t test_vnot_v_i32m1_tuma(vbool32_t mask, vint32m1_t maskedoff, vint32m1_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.mask.nxv4i32.i32.i64(<vscale x 4 x i32> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vint32m2_t test_vnot_v_i32m2_tuma(vbool16_t mask, vint32m2_t maskedoff, vint32m2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.mask.nxv8i32.i32.i64(<vscale x 8 x i32> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vint32m4_t test_vnot_v_i32m4_tuma(vbool8_t mask, vint32m4_t maskedoff, vint32m4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.mask.nxv16i32.i32.i64(<vscale x 16 x i32> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vint32m8_t test_vnot_v_i32m8_tuma(vbool4_t mask, vint32m8_t maskedoff, vint32m8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m1_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.mask.nxv1i64.i64.i64(<vscale x 1 x i64> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vint64m1_t test_vnot_v_i64m1_tuma(vbool64_t mask, vint64m1_t maskedoff, vint64m1_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.mask.nxv2i64.i64.i64(<vscale x 2 x i64> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vint64m2_t test_vnot_v_i64m2_tuma(vbool32_t mask, vint64m2_t maskedoff, vint64m2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.mask.nxv4i64.i64.i64(<vscale x 4 x i64> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vint64m4_t test_vnot_v_i64m4_tuma(vbool16_t mask, vint64m4_t maskedoff, vint64m4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.mask.nxv8i64.i64.i64(<vscale x 8 x i64> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vint64m8_t test_vnot_v_i64m8_tuma(vbool8_t mask, vint64m8_t maskedoff, vint64m8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.mask.nxv1i8.i8.i64(<vscale x 1 x i8> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vuint8mf8_t test_vnot_v_u8mf8_tuma(vbool64_t mask, vuint8mf8_t maskedoff, vuint8mf8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.mask.nxv2i8.i8.i64(<vscale x 2 x i8> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vuint8mf4_t test_vnot_v_u8mf4_tuma(vbool32_t mask, vuint8mf4_t maskedoff, vuint8mf4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.mask.nxv4i8.i8.i64(<vscale x 4 x i8> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vuint8mf2_t test_vnot_v_u8mf2_tuma(vbool16_t mask, vuint8mf2_t maskedoff, vuint8mf2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m1_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.mask.nxv8i8.i8.i64(<vscale x 8 x i8> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vuint8m1_t test_vnot_v_u8m1_tuma(vbool8_t mask, vuint8m1_t maskedoff, vuint8m1_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.mask.nxv16i8.i8.i64(<vscale x 16 x i8> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vuint8m2_t test_vnot_v_u8m2_tuma(vbool4_t mask, vuint8m2_t maskedoff, vuint8m2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.mask.nxv32i8.i8.i64(<vscale x 32 x i8> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vuint8m4_t test_vnot_v_u8m4_tuma(vbool2_t mask, vuint8m4_t maskedoff, vuint8m4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.mask.nxv64i8.i8.i64(<vscale x 64 x i8> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 -1, <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vuint8m8_t test_vnot_v_u8m8_tuma(vbool1_t mask, vuint8m8_t maskedoff, vuint8m8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.mask.nxv1i16.i16.i64(<vscale x 1 x i16> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vuint16mf4_t test_vnot_v_u16mf4_tuma(vbool64_t mask, vuint16mf4_t maskedoff, vuint16mf4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.mask.nxv2i16.i16.i64(<vscale x 2 x i16> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vuint16mf2_t test_vnot_v_u16mf2_tuma(vbool32_t mask, vuint16mf2_t maskedoff, vuint16mf2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m1_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.mask.nxv4i16.i16.i64(<vscale x 4 x i16> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vuint16m1_t test_vnot_v_u16m1_tuma(vbool16_t mask, vuint16m1_t maskedoff, vuint16m1_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.mask.nxv8i16.i16.i64(<vscale x 8 x i16> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vuint16m2_t test_vnot_v_u16m2_tuma(vbool8_t mask, vuint16m2_t maskedoff, vuint16m2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.mask.nxv16i16.i16.i64(<vscale x 16 x i16> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vuint16m4_t test_vnot_v_u16m4_tuma(vbool4_t mask, vuint16m4_t maskedoff, vuint16m4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.mask.nxv32i16.i16.i64(<vscale x 32 x i16> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vuint16m8_t test_vnot_v_u16m8_tuma(vbool2_t mask, vuint16m8_t maskedoff, vuint16m8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32mf2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.mask.nxv1i32.i32.i64(<vscale x 1 x i32> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vuint32mf2_t test_vnot_v_u32mf2_tuma(vbool64_t mask, vuint32mf2_t maskedoff, vuint32mf2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m1_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.mask.nxv2i32.i32.i64(<vscale x 2 x i32> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vuint32m1_t test_vnot_v_u32m1_tuma(vbool32_t mask, vuint32m1_t maskedoff, vuint32m1_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.mask.nxv4i32.i32.i64(<vscale x 4 x i32> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vuint32m2_t test_vnot_v_u32m2_tuma(vbool16_t mask, vuint32m2_t maskedoff, vuint32m2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.mask.nxv8i32.i32.i64(<vscale x 8 x i32> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vuint32m4_t test_vnot_v_u32m4_tuma(vbool8_t mask, vuint32m4_t maskedoff, vuint32m4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.mask.nxv16i32.i32.i64(<vscale x 16 x i32> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vuint32m8_t test_vnot_v_u32m8_tuma(vbool4_t mask, vuint32m8_t maskedoff, vuint32m8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m1_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.mask.nxv1i64.i64.i64(<vscale x 1 x i64> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vuint64m1_t test_vnot_v_u64m1_tuma(vbool64_t mask, vuint64m1_t maskedoff, vuint64m1_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m2_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.mask.nxv2i64.i64.i64(<vscale x 2 x i64> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vuint64m2_t test_vnot_v_u64m2_tuma(vbool32_t mask, vuint64m2_t maskedoff, vuint64m2_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m4_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.mask.nxv4i64.i64.i64(<vscale x 4 x i64> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vuint64m4_t test_vnot_v_u64m4_tuma(vbool16_t mask, vuint64m4_t maskedoff, vuint64m4_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m8_tuma(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.mask.nxv8i64.i64.i64(<vscale x 8 x i64> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vuint64m8_t test_vnot_v_u64m8_tuma(vbool8_t mask, vuint64m8_t maskedoff, vuint64m8_t op1, size_t vl) {
return vnot_tuma(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.mask.nxv1i8.i8.i64(<vscale x 1 x i8> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vint8mf8_t test_vnot_v_i8mf8_tumu(vbool64_t mask, vint8mf8_t maskedoff, vint8mf8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.mask.nxv2i8.i8.i64(<vscale x 2 x i8> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vint8mf4_t test_vnot_v_i8mf4_tumu(vbool32_t mask, vint8mf4_t maskedoff, vint8mf4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.mask.nxv4i8.i8.i64(<vscale x 4 x i8> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vint8mf2_t test_vnot_v_i8mf2_tumu(vbool16_t mask, vint8mf2_t maskedoff, vint8mf2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m1_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.mask.nxv8i8.i8.i64(<vscale x 8 x i8> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vint8m1_t test_vnot_v_i8m1_tumu(vbool8_t mask, vint8m1_t maskedoff, vint8m1_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.mask.nxv16i8.i8.i64(<vscale x 16 x i8> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vint8m2_t test_vnot_v_i8m2_tumu(vbool4_t mask, vint8m2_t maskedoff, vint8m2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.mask.nxv32i8.i8.i64(<vscale x 32 x i8> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vint8m4_t test_vnot_v_i8m4_tumu(vbool2_t mask, vint8m4_t maskedoff, vint8m4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.mask.nxv64i8.i8.i64(<vscale x 64 x i8> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 -1, <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vint8m8_t test_vnot_v_i8m8_tumu(vbool1_t mask, vint8m8_t maskedoff, vint8m8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.mask.nxv1i16.i16.i64(<vscale x 1 x i16> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vint16mf4_t test_vnot_v_i16mf4_tumu(vbool64_t mask, vint16mf4_t maskedoff, vint16mf4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.mask.nxv2i16.i16.i64(<vscale x 2 x i16> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vint16mf2_t test_vnot_v_i16mf2_tumu(vbool32_t mask, vint16mf2_t maskedoff, vint16mf2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m1_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.mask.nxv4i16.i16.i64(<vscale x 4 x i16> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vint16m1_t test_vnot_v_i16m1_tumu(vbool16_t mask, vint16m1_t maskedoff, vint16m1_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.mask.nxv8i16.i16.i64(<vscale x 8 x i16> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vint16m2_t test_vnot_v_i16m2_tumu(vbool8_t mask, vint16m2_t maskedoff, vint16m2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.mask.nxv16i16.i16.i64(<vscale x 16 x i16> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vint16m4_t test_vnot_v_i16m4_tumu(vbool4_t mask, vint16m4_t maskedoff, vint16m4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.mask.nxv32i16.i16.i64(<vscale x 32 x i16> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vint16m8_t test_vnot_v_i16m8_tumu(vbool2_t mask, vint16m8_t maskedoff, vint16m8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32mf2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.mask.nxv1i32.i32.i64(<vscale x 1 x i32> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vint32mf2_t test_vnot_v_i32mf2_tumu(vbool64_t mask, vint32mf2_t maskedoff, vint32mf2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m1_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.mask.nxv2i32.i32.i64(<vscale x 2 x i32> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vint32m1_t test_vnot_v_i32m1_tumu(vbool32_t mask, vint32m1_t maskedoff, vint32m1_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.mask.nxv4i32.i32.i64(<vscale x 4 x i32> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vint32m2_t test_vnot_v_i32m2_tumu(vbool16_t mask, vint32m2_t maskedoff, vint32m2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.mask.nxv8i32.i32.i64(<vscale x 8 x i32> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vint32m4_t test_vnot_v_i32m4_tumu(vbool8_t mask, vint32m4_t maskedoff, vint32m4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.mask.nxv16i32.i32.i64(<vscale x 16 x i32> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vint32m8_t test_vnot_v_i32m8_tumu(vbool4_t mask, vint32m8_t maskedoff, vint32m8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m1_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.mask.nxv1i64.i64.i64(<vscale x 1 x i64> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vint64m1_t test_vnot_v_i64m1_tumu(vbool64_t mask, vint64m1_t maskedoff, vint64m1_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.mask.nxv2i64.i64.i64(<vscale x 2 x i64> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vint64m2_t test_vnot_v_i64m2_tumu(vbool32_t mask, vint64m2_t maskedoff, vint64m2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.mask.nxv4i64.i64.i64(<vscale x 4 x i64> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vint64m4_t test_vnot_v_i64m4_tumu(vbool16_t mask, vint64m4_t maskedoff, vint64m4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.mask.nxv8i64.i64.i64(<vscale x 8 x i64> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vint64m8_t test_vnot_v_i64m8_tumu(vbool8_t mask, vint64m8_t maskedoff, vint64m8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.mask.nxv1i8.i8.i64(<vscale x 1 x i8> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vuint8mf8_t test_vnot_v_u8mf8_tumu(vbool64_t mask, vuint8mf8_t maskedoff, vuint8mf8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.mask.nxv2i8.i8.i64(<vscale x 2 x i8> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vuint8mf4_t test_vnot_v_u8mf4_tumu(vbool32_t mask, vuint8mf4_t maskedoff, vuint8mf4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.mask.nxv4i8.i8.i64(<vscale x 4 x i8> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vuint8mf2_t test_vnot_v_u8mf2_tumu(vbool16_t mask, vuint8mf2_t maskedoff, vuint8mf2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m1_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.mask.nxv8i8.i8.i64(<vscale x 8 x i8> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vuint8m1_t test_vnot_v_u8m1_tumu(vbool8_t mask, vuint8m1_t maskedoff, vuint8m1_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.mask.nxv16i8.i8.i64(<vscale x 16 x i8> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vuint8m2_t test_vnot_v_u8m2_tumu(vbool4_t mask, vuint8m2_t maskedoff, vuint8m2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.mask.nxv32i8.i8.i64(<vscale x 32 x i8> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vuint8m4_t test_vnot_v_u8m4_tumu(vbool2_t mask, vuint8m4_t maskedoff, vuint8m4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.mask.nxv64i8.i8.i64(<vscale x 64 x i8> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 -1, <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vuint8m8_t test_vnot_v_u8m8_tumu(vbool1_t mask, vuint8m8_t maskedoff, vuint8m8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.mask.nxv1i16.i16.i64(<vscale x 1 x i16> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vuint16mf4_t test_vnot_v_u16mf4_tumu(vbool64_t mask, vuint16mf4_t maskedoff, vuint16mf4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.mask.nxv2i16.i16.i64(<vscale x 2 x i16> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vuint16mf2_t test_vnot_v_u16mf2_tumu(vbool32_t mask, vuint16mf2_t maskedoff, vuint16mf2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m1_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.mask.nxv4i16.i16.i64(<vscale x 4 x i16> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vuint16m1_t test_vnot_v_u16m1_tumu(vbool16_t mask, vuint16m1_t maskedoff, vuint16m1_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.mask.nxv8i16.i16.i64(<vscale x 8 x i16> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vuint16m2_t test_vnot_v_u16m2_tumu(vbool8_t mask, vuint16m2_t maskedoff, vuint16m2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.mask.nxv16i16.i16.i64(<vscale x 16 x i16> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vuint16m4_t test_vnot_v_u16m4_tumu(vbool4_t mask, vuint16m4_t maskedoff, vuint16m4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.mask.nxv32i16.i16.i64(<vscale x 32 x i16> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vuint16m8_t test_vnot_v_u16m8_tumu(vbool2_t mask, vuint16m8_t maskedoff, vuint16m8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32mf2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.mask.nxv1i32.i32.i64(<vscale x 1 x i32> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vuint32mf2_t test_vnot_v_u32mf2_tumu(vbool64_t mask, vuint32mf2_t maskedoff, vuint32mf2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m1_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.mask.nxv2i32.i32.i64(<vscale x 2 x i32> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vuint32m1_t test_vnot_v_u32m1_tumu(vbool32_t mask, vuint32m1_t maskedoff, vuint32m1_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.mask.nxv4i32.i32.i64(<vscale x 4 x i32> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vuint32m2_t test_vnot_v_u32m2_tumu(vbool16_t mask, vuint32m2_t maskedoff, vuint32m2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.mask.nxv8i32.i32.i64(<vscale x 8 x i32> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vuint32m4_t test_vnot_v_u32m4_tumu(vbool8_t mask, vuint32m4_t maskedoff, vuint32m4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.mask.nxv16i32.i32.i64(<vscale x 16 x i32> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vuint32m8_t test_vnot_v_u32m8_tumu(vbool4_t mask, vuint32m8_t maskedoff, vuint32m8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m1_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.mask.nxv1i64.i64.i64(<vscale x 1 x i64> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vuint64m1_t test_vnot_v_u64m1_tumu(vbool64_t mask, vuint64m1_t maskedoff, vuint64m1_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m2_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.mask.nxv2i64.i64.i64(<vscale x 2 x i64> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vuint64m2_t test_vnot_v_u64m2_tumu(vbool32_t mask, vuint64m2_t maskedoff, vuint64m2_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m4_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.mask.nxv4i64.i64.i64(<vscale x 4 x i64> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vuint64m4_t test_vnot_v_u64m4_tumu(vbool16_t mask, vuint64m4_t maskedoff, vuint64m4_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m8_tumu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.mask.nxv8i64.i64.i64(<vscale x 8 x i64> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vuint64m8_t test_vnot_v_u64m8_tumu(vbool8_t mask, vuint64m8_t maskedoff, vuint64m8_t op1, size_t vl) {
return vnot_tumu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.mask.nxv1i8.i8.i64(<vscale x 1 x i8> poison, <vscale x 1 x i8> [[OP1:%.*]], i8 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vint8mf8_t test_vnot_v_i8mf8_tama(vbool64_t mask, vint8mf8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.mask.nxv2i8.i8.i64(<vscale x 2 x i8> poison, <vscale x 2 x i8> [[OP1:%.*]], i8 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vint8mf4_t test_vnot_v_i8mf4_tama(vbool32_t mask, vint8mf4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.mask.nxv4i8.i8.i64(<vscale x 4 x i8> poison, <vscale x 4 x i8> [[OP1:%.*]], i8 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vint8mf2_t test_vnot_v_i8mf2_tama(vbool16_t mask, vint8mf2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m1_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.mask.nxv8i8.i8.i64(<vscale x 8 x i8> poison, <vscale x 8 x i8> [[OP1:%.*]], i8 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vint8m1_t test_vnot_v_i8m1_tama(vbool8_t mask, vint8m1_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.mask.nxv16i8.i8.i64(<vscale x 16 x i8> poison, <vscale x 16 x i8> [[OP1:%.*]], i8 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vint8m2_t test_vnot_v_i8m2_tama(vbool4_t mask, vint8m2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.mask.nxv32i8.i8.i64(<vscale x 32 x i8> poison, <vscale x 32 x i8> [[OP1:%.*]], i8 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vint8m4_t test_vnot_v_i8m4_tama(vbool2_t mask, vint8m4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.mask.nxv64i8.i8.i64(<vscale x 64 x i8> poison, <vscale x 64 x i8> [[OP1:%.*]], i8 -1, <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vint8m8_t test_vnot_v_i8m8_tama(vbool1_t mask, vint8m8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.mask.nxv1i16.i16.i64(<vscale x 1 x i16> poison, <vscale x 1 x i16> [[OP1:%.*]], i16 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vint16mf4_t test_vnot_v_i16mf4_tama(vbool64_t mask, vint16mf4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.mask.nxv2i16.i16.i64(<vscale x 2 x i16> poison, <vscale x 2 x i16> [[OP1:%.*]], i16 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vint16mf2_t test_vnot_v_i16mf2_tama(vbool32_t mask, vint16mf2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m1_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.mask.nxv4i16.i16.i64(<vscale x 4 x i16> poison, <vscale x 4 x i16> [[OP1:%.*]], i16 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vint16m1_t test_vnot_v_i16m1_tama(vbool16_t mask, vint16m1_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.mask.nxv8i16.i16.i64(<vscale x 8 x i16> poison, <vscale x 8 x i16> [[OP1:%.*]], i16 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vint16m2_t test_vnot_v_i16m2_tama(vbool8_t mask, vint16m2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.mask.nxv16i16.i16.i64(<vscale x 16 x i16> poison, <vscale x 16 x i16> [[OP1:%.*]], i16 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vint16m4_t test_vnot_v_i16m4_tama(vbool4_t mask, vint16m4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.mask.nxv32i16.i16.i64(<vscale x 32 x i16> poison, <vscale x 32 x i16> [[OP1:%.*]], i16 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vint16m8_t test_vnot_v_i16m8_tama(vbool2_t mask, vint16m8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32mf2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.mask.nxv1i32.i32.i64(<vscale x 1 x i32> poison, <vscale x 1 x i32> [[OP1:%.*]], i32 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vint32mf2_t test_vnot_v_i32mf2_tama(vbool64_t mask, vint32mf2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m1_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.mask.nxv2i32.i32.i64(<vscale x 2 x i32> poison, <vscale x 2 x i32> [[OP1:%.*]], i32 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vint32m1_t test_vnot_v_i32m1_tama(vbool32_t mask, vint32m1_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.mask.nxv4i32.i32.i64(<vscale x 4 x i32> poison, <vscale x 4 x i32> [[OP1:%.*]], i32 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vint32m2_t test_vnot_v_i32m2_tama(vbool16_t mask, vint32m2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.mask.nxv8i32.i32.i64(<vscale x 8 x i32> poison, <vscale x 8 x i32> [[OP1:%.*]], i32 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vint32m4_t test_vnot_v_i32m4_tama(vbool8_t mask, vint32m4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.mask.nxv16i32.i32.i64(<vscale x 16 x i32> poison, <vscale x 16 x i32> [[OP1:%.*]], i32 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vint32m8_t test_vnot_v_i32m8_tama(vbool4_t mask, vint32m8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m1_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.mask.nxv1i64.i64.i64(<vscale x 1 x i64> poison, <vscale x 1 x i64> [[OP1:%.*]], i64 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vint64m1_t test_vnot_v_i64m1_tama(vbool64_t mask, vint64m1_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.mask.nxv2i64.i64.i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> [[OP1:%.*]], i64 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vint64m2_t test_vnot_v_i64m2_tama(vbool32_t mask, vint64m2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.mask.nxv4i64.i64.i64(<vscale x 4 x i64> poison, <vscale x 4 x i64> [[OP1:%.*]], i64 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vint64m4_t test_vnot_v_i64m4_tama(vbool16_t mask, vint64m4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.mask.nxv8i64.i64.i64(<vscale x 8 x i64> poison, <vscale x 8 x i64> [[OP1:%.*]], i64 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vint64m8_t test_vnot_v_i64m8_tama(vbool8_t mask, vint64m8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.mask.nxv1i8.i8.i64(<vscale x 1 x i8> poison, <vscale x 1 x i8> [[OP1:%.*]], i8 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vuint8mf8_t test_vnot_v_u8mf8_tama(vbool64_t mask, vuint8mf8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.mask.nxv2i8.i8.i64(<vscale x 2 x i8> poison, <vscale x 2 x i8> [[OP1:%.*]], i8 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vuint8mf4_t test_vnot_v_u8mf4_tama(vbool32_t mask, vuint8mf4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.mask.nxv4i8.i8.i64(<vscale x 4 x i8> poison, <vscale x 4 x i8> [[OP1:%.*]], i8 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vuint8mf2_t test_vnot_v_u8mf2_tama(vbool16_t mask, vuint8mf2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m1_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.mask.nxv8i8.i8.i64(<vscale x 8 x i8> poison, <vscale x 8 x i8> [[OP1:%.*]], i8 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vuint8m1_t test_vnot_v_u8m1_tama(vbool8_t mask, vuint8m1_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.mask.nxv16i8.i8.i64(<vscale x 16 x i8> poison, <vscale x 16 x i8> [[OP1:%.*]], i8 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vuint8m2_t test_vnot_v_u8m2_tama(vbool4_t mask, vuint8m2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.mask.nxv32i8.i8.i64(<vscale x 32 x i8> poison, <vscale x 32 x i8> [[OP1:%.*]], i8 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vuint8m4_t test_vnot_v_u8m4_tama(vbool2_t mask, vuint8m4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.mask.nxv64i8.i8.i64(<vscale x 64 x i8> poison, <vscale x 64 x i8> [[OP1:%.*]], i8 -1, <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vuint8m8_t test_vnot_v_u8m8_tama(vbool1_t mask, vuint8m8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.mask.nxv1i16.i16.i64(<vscale x 1 x i16> poison, <vscale x 1 x i16> [[OP1:%.*]], i16 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vuint16mf4_t test_vnot_v_u16mf4_tama(vbool64_t mask, vuint16mf4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.mask.nxv2i16.i16.i64(<vscale x 2 x i16> poison, <vscale x 2 x i16> [[OP1:%.*]], i16 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vuint16mf2_t test_vnot_v_u16mf2_tama(vbool32_t mask, vuint16mf2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m1_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.mask.nxv4i16.i16.i64(<vscale x 4 x i16> poison, <vscale x 4 x i16> [[OP1:%.*]], i16 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vuint16m1_t test_vnot_v_u16m1_tama(vbool16_t mask, vuint16m1_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.mask.nxv8i16.i16.i64(<vscale x 8 x i16> poison, <vscale x 8 x i16> [[OP1:%.*]], i16 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vuint16m2_t test_vnot_v_u16m2_tama(vbool8_t mask, vuint16m2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.mask.nxv16i16.i16.i64(<vscale x 16 x i16> poison, <vscale x 16 x i16> [[OP1:%.*]], i16 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vuint16m4_t test_vnot_v_u16m4_tama(vbool4_t mask, vuint16m4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.mask.nxv32i16.i16.i64(<vscale x 32 x i16> poison, <vscale x 32 x i16> [[OP1:%.*]], i16 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vuint16m8_t test_vnot_v_u16m8_tama(vbool2_t mask, vuint16m8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32mf2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.mask.nxv1i32.i32.i64(<vscale x 1 x i32> poison, <vscale x 1 x i32> [[OP1:%.*]], i32 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vuint32mf2_t test_vnot_v_u32mf2_tama(vbool64_t mask, vuint32mf2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m1_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.mask.nxv2i32.i32.i64(<vscale x 2 x i32> poison, <vscale x 2 x i32> [[OP1:%.*]], i32 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vuint32m1_t test_vnot_v_u32m1_tama(vbool32_t mask, vuint32m1_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.mask.nxv4i32.i32.i64(<vscale x 4 x i32> poison, <vscale x 4 x i32> [[OP1:%.*]], i32 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vuint32m2_t test_vnot_v_u32m2_tama(vbool16_t mask, vuint32m2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.mask.nxv8i32.i32.i64(<vscale x 8 x i32> poison, <vscale x 8 x i32> [[OP1:%.*]], i32 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vuint32m4_t test_vnot_v_u32m4_tama(vbool8_t mask, vuint32m4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.mask.nxv16i32.i32.i64(<vscale x 16 x i32> poison, <vscale x 16 x i32> [[OP1:%.*]], i32 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vuint32m8_t test_vnot_v_u32m8_tama(vbool4_t mask, vuint32m8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m1_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.mask.nxv1i64.i64.i64(<vscale x 1 x i64> poison, <vscale x 1 x i64> [[OP1:%.*]], i64 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vuint64m1_t test_vnot_v_u64m1_tama(vbool64_t mask, vuint64m1_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m2_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.mask.nxv2i64.i64.i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> [[OP1:%.*]], i64 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vuint64m2_t test_vnot_v_u64m2_tama(vbool32_t mask, vuint64m2_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m4_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.mask.nxv4i64.i64.i64(<vscale x 4 x i64> poison, <vscale x 4 x i64> [[OP1:%.*]], i64 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vuint64m4_t test_vnot_v_u64m4_tama(vbool16_t mask, vuint64m4_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m8_tama(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.mask.nxv8i64.i64.i64(<vscale x 8 x i64> poison, <vscale x 8 x i64> [[OP1:%.*]], i64 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 3)
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vuint64m8_t test_vnot_v_u64m8_tama(vbool8_t mask, vuint64m8_t op1, size_t vl) {
return vnot_tama(mask, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.mask.nxv1i8.i8.i64(<vscale x 1 x i8> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vint8mf8_t test_vnot_v_i8mf8_tamu(vbool64_t mask, vint8mf8_t maskedoff, vint8mf8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.mask.nxv2i8.i8.i64(<vscale x 2 x i8> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vint8mf4_t test_vnot_v_i8mf4_tamu(vbool32_t mask, vint8mf4_t maskedoff, vint8mf4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8mf2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.mask.nxv4i8.i8.i64(<vscale x 4 x i8> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vint8mf2_t test_vnot_v_i8mf2_tamu(vbool16_t mask, vint8mf2_t maskedoff, vint8mf2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m1_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.mask.nxv8i8.i8.i64(<vscale x 8 x i8> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vint8m1_t test_vnot_v_i8m1_tamu(vbool8_t mask, vint8m1_t maskedoff, vint8m1_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.mask.nxv16i8.i8.i64(<vscale x 16 x i8> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vint8m2_t test_vnot_v_i8m2_tamu(vbool4_t mask, vint8m2_t maskedoff, vint8m2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.mask.nxv32i8.i8.i64(<vscale x 32 x i8> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vint8m4_t test_vnot_v_i8m4_tamu(vbool2_t mask, vint8m4_t maskedoff, vint8m4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i8m8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.mask.nxv64i8.i8.i64(<vscale x 64 x i8> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 -1, <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vint8m8_t test_vnot_v_i8m8_tamu(vbool1_t mask, vint8m8_t maskedoff, vint8m8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.mask.nxv1i16.i16.i64(<vscale x 1 x i16> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vint16mf4_t test_vnot_v_i16mf4_tamu(vbool64_t mask, vint16mf4_t maskedoff, vint16mf4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16mf2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.mask.nxv2i16.i16.i64(<vscale x 2 x i16> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vint16mf2_t test_vnot_v_i16mf2_tamu(vbool32_t mask, vint16mf2_t maskedoff, vint16mf2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m1_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.mask.nxv4i16.i16.i64(<vscale x 4 x i16> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vint16m1_t test_vnot_v_i16m1_tamu(vbool16_t mask, vint16m1_t maskedoff, vint16m1_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.mask.nxv8i16.i16.i64(<vscale x 8 x i16> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vint16m2_t test_vnot_v_i16m2_tamu(vbool8_t mask, vint16m2_t maskedoff, vint16m2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.mask.nxv16i16.i16.i64(<vscale x 16 x i16> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vint16m4_t test_vnot_v_i16m4_tamu(vbool4_t mask, vint16m4_t maskedoff, vint16m4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i16m8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.mask.nxv32i16.i16.i64(<vscale x 32 x i16> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vint16m8_t test_vnot_v_i16m8_tamu(vbool2_t mask, vint16m8_t maskedoff, vint16m8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32mf2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.mask.nxv1i32.i32.i64(<vscale x 1 x i32> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vint32mf2_t test_vnot_v_i32mf2_tamu(vbool64_t mask, vint32mf2_t maskedoff, vint32mf2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m1_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.mask.nxv2i32.i32.i64(<vscale x 2 x i32> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vint32m1_t test_vnot_v_i32m1_tamu(vbool32_t mask, vint32m1_t maskedoff, vint32m1_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.mask.nxv4i32.i32.i64(<vscale x 4 x i32> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vint32m2_t test_vnot_v_i32m2_tamu(vbool16_t mask, vint32m2_t maskedoff, vint32m2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.mask.nxv8i32.i32.i64(<vscale x 8 x i32> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vint32m4_t test_vnot_v_i32m4_tamu(vbool8_t mask, vint32m4_t maskedoff, vint32m4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i32m8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.mask.nxv16i32.i32.i64(<vscale x 16 x i32> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vint32m8_t test_vnot_v_i32m8_tamu(vbool4_t mask, vint32m8_t maskedoff, vint32m8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m1_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.mask.nxv1i64.i64.i64(<vscale x 1 x i64> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vint64m1_t test_vnot_v_i64m1_tamu(vbool64_t mask, vint64m1_t maskedoff, vint64m1_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.mask.nxv2i64.i64.i64(<vscale x 2 x i64> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vint64m2_t test_vnot_v_i64m2_tamu(vbool32_t mask, vint64m2_t maskedoff, vint64m2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.mask.nxv4i64.i64.i64(<vscale x 4 x i64> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vint64m4_t test_vnot_v_i64m4_tamu(vbool16_t mask, vint64m4_t maskedoff, vint64m4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_i64m8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.mask.nxv8i64.i64.i64(<vscale x 8 x i64> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vint64m8_t test_vnot_v_i64m8_tamu(vbool8_t mask, vint64m8_t maskedoff, vint64m8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i8> @llvm.riscv.vxor.mask.nxv1i8.i8.i64(<vscale x 1 x i8> [[MASKEDOFF:%.*]], <vscale x 1 x i8> [[OP1:%.*]], i8 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 1 x i8> [[TMP0]]
//
vuint8mf8_t test_vnot_v_u8mf8_tamu(vbool64_t mask, vuint8mf8_t maskedoff, vuint8mf8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i8> @llvm.riscv.vxor.mask.nxv2i8.i8.i64(<vscale x 2 x i8> [[MASKEDOFF:%.*]], <vscale x 2 x i8> [[OP1:%.*]], i8 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 2 x i8> [[TMP0]]
//
vuint8mf4_t test_vnot_v_u8mf4_tamu(vbool32_t mask, vuint8mf4_t maskedoff, vuint8mf4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8mf2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i8> @llvm.riscv.vxor.mask.nxv4i8.i8.i64(<vscale x 4 x i8> [[MASKEDOFF:%.*]], <vscale x 4 x i8> [[OP1:%.*]], i8 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 4 x i8> [[TMP0]]
//
vuint8mf2_t test_vnot_v_u8mf2_tamu(vbool16_t mask, vuint8mf2_t maskedoff, vuint8mf2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m1_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i8> @llvm.riscv.vxor.mask.nxv8i8.i8.i64(<vscale x 8 x i8> [[MASKEDOFF:%.*]], <vscale x 8 x i8> [[OP1:%.*]], i8 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 8 x i8> [[TMP0]]
//
vuint8m1_t test_vnot_v_u8m1_tamu(vbool8_t mask, vuint8m1_t maskedoff, vuint8m1_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i8> @llvm.riscv.vxor.mask.nxv16i8.i8.i64(<vscale x 16 x i8> [[MASKEDOFF:%.*]], <vscale x 16 x i8> [[OP1:%.*]], i8 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 16 x i8> [[TMP0]]
//
vuint8m2_t test_vnot_v_u8m2_tamu(vbool4_t mask, vuint8m2_t maskedoff, vuint8m2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i8> @llvm.riscv.vxor.mask.nxv32i8.i8.i64(<vscale x 32 x i8> [[MASKEDOFF:%.*]], <vscale x 32 x i8> [[OP1:%.*]], i8 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 32 x i8> [[TMP0]]
//
vuint8m4_t test_vnot_v_u8m4_tamu(vbool2_t mask, vuint8m4_t maskedoff, vuint8m4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u8m8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 64 x i8> @llvm.riscv.vxor.mask.nxv64i8.i8.i64(<vscale x 64 x i8> [[MASKEDOFF:%.*]], <vscale x 64 x i8> [[OP1:%.*]], i8 -1, <vscale x 64 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 64 x i8> [[TMP0]]
//
vuint8m8_t test_vnot_v_u8m8_tamu(vbool1_t mask, vuint8m8_t maskedoff, vuint8m8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i16> @llvm.riscv.vxor.mask.nxv1i16.i16.i64(<vscale x 1 x i16> [[MASKEDOFF:%.*]], <vscale x 1 x i16> [[OP1:%.*]], i16 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 1 x i16> [[TMP0]]
//
vuint16mf4_t test_vnot_v_u16mf4_tamu(vbool64_t mask, vuint16mf4_t maskedoff, vuint16mf4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16mf2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i16> @llvm.riscv.vxor.mask.nxv2i16.i16.i64(<vscale x 2 x i16> [[MASKEDOFF:%.*]], <vscale x 2 x i16> [[OP1:%.*]], i16 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 2 x i16> [[TMP0]]
//
vuint16mf2_t test_vnot_v_u16mf2_tamu(vbool32_t mask, vuint16mf2_t maskedoff, vuint16mf2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m1_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i16> @llvm.riscv.vxor.mask.nxv4i16.i16.i64(<vscale x 4 x i16> [[MASKEDOFF:%.*]], <vscale x 4 x i16> [[OP1:%.*]], i16 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 4 x i16> [[TMP0]]
//
vuint16m1_t test_vnot_v_u16m1_tamu(vbool16_t mask, vuint16m1_t maskedoff, vuint16m1_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i16> @llvm.riscv.vxor.mask.nxv8i16.i16.i64(<vscale x 8 x i16> [[MASKEDOFF:%.*]], <vscale x 8 x i16> [[OP1:%.*]], i16 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 8 x i16> [[TMP0]]
//
vuint16m2_t test_vnot_v_u16m2_tamu(vbool8_t mask, vuint16m2_t maskedoff, vuint16m2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i16> @llvm.riscv.vxor.mask.nxv16i16.i16.i64(<vscale x 16 x i16> [[MASKEDOFF:%.*]], <vscale x 16 x i16> [[OP1:%.*]], i16 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 16 x i16> [[TMP0]]
//
vuint16m4_t test_vnot_v_u16m4_tamu(vbool4_t mask, vuint16m4_t maskedoff, vuint16m4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u16m8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 32 x i16> @llvm.riscv.vxor.mask.nxv32i16.i16.i64(<vscale x 32 x i16> [[MASKEDOFF:%.*]], <vscale x 32 x i16> [[OP1:%.*]], i16 -1, <vscale x 32 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 32 x i16> [[TMP0]]
//
vuint16m8_t test_vnot_v_u16m8_tamu(vbool2_t mask, vuint16m8_t maskedoff, vuint16m8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32mf2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i32> @llvm.riscv.vxor.mask.nxv1i32.i32.i64(<vscale x 1 x i32> [[MASKEDOFF:%.*]], <vscale x 1 x i32> [[OP1:%.*]], i32 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 1 x i32> [[TMP0]]
//
vuint32mf2_t test_vnot_v_u32mf2_tamu(vbool64_t mask, vuint32mf2_t maskedoff, vuint32mf2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m1_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i32> @llvm.riscv.vxor.mask.nxv2i32.i32.i64(<vscale x 2 x i32> [[MASKEDOFF:%.*]], <vscale x 2 x i32> [[OP1:%.*]], i32 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP0]]
//
vuint32m1_t test_vnot_v_u32m1_tamu(vbool32_t mask, vuint32m1_t maskedoff, vuint32m1_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i32> @llvm.riscv.vxor.mask.nxv4i32.i32.i64(<vscale x 4 x i32> [[MASKEDOFF:%.*]], <vscale x 4 x i32> [[OP1:%.*]], i32 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 4 x i32> [[TMP0]]
//
vuint32m2_t test_vnot_v_u32m2_tamu(vbool16_t mask, vuint32m2_t maskedoff, vuint32m2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i32> @llvm.riscv.vxor.mask.nxv8i32.i32.i64(<vscale x 8 x i32> [[MASKEDOFF:%.*]], <vscale x 8 x i32> [[OP1:%.*]], i32 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 8 x i32> [[TMP0]]
//
vuint32m4_t test_vnot_v_u32m4_tamu(vbool8_t mask, vuint32m4_t maskedoff, vuint32m4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u32m8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 16 x i32> @llvm.riscv.vxor.mask.nxv16i32.i32.i64(<vscale x 16 x i32> [[MASKEDOFF:%.*]], <vscale x 16 x i32> [[OP1:%.*]], i32 -1, <vscale x 16 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 16 x i32> [[TMP0]]
//
vuint32m8_t test_vnot_v_u32m8_tamu(vbool4_t mask, vuint32m8_t maskedoff, vuint32m8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m1_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 1 x i64> @llvm.riscv.vxor.mask.nxv1i64.i64.i64(<vscale x 1 x i64> [[MASKEDOFF:%.*]], <vscale x 1 x i64> [[OP1:%.*]], i64 -1, <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 1 x i64> [[TMP0]]
//
vuint64m1_t test_vnot_v_u64m1_tamu(vbool64_t mask, vuint64m1_t maskedoff, vuint64m1_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m2_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 2 x i64> @llvm.riscv.vxor.mask.nxv2i64.i64.i64(<vscale x 2 x i64> [[MASKEDOFF:%.*]], <vscale x 2 x i64> [[OP1:%.*]], i64 -1, <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 2 x i64> [[TMP0]]
//
vuint64m2_t test_vnot_v_u64m2_tamu(vbool32_t mask, vuint64m2_t maskedoff, vuint64m2_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m4_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 4 x i64> @llvm.riscv.vxor.mask.nxv4i64.i64.i64(<vscale x 4 x i64> [[MASKEDOFF:%.*]], <vscale x 4 x i64> [[OP1:%.*]], i64 -1, <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 4 x i64> [[TMP0]]
//
vuint64m4_t test_vnot_v_u64m4_tamu(vbool16_t mask, vuint64m4_t maskedoff, vuint64m4_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
// CHECK-RV64-LABEL: @test_vnot_v_u64m8_tamu(
// CHECK-RV64-NEXT: entry:
// CHECK-RV64-NEXT: [[TMP0:%.*]] = call <vscale x 8 x i64> @llvm.riscv.vxor.mask.nxv8i64.i64.i64(<vscale x 8 x i64> [[MASKEDOFF:%.*]], <vscale x 8 x i64> [[OP1:%.*]], i64 -1, <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 1)
// CHECK-RV64-NEXT: ret <vscale x 8 x i64> [[TMP0]]
//
vuint64m8_t test_vnot_v_u64m8_tamu(vbool8_t mask, vuint64m8_t maskedoff, vuint64m8_t op1, size_t vl) {
return vnot_tamu(mask, maskedoff, op1, vl);
}
|
c8e0d1a766dd9e1baba6781a31c40d01ee3a1499
|
8838eb997879add5759b6dfb23f9a646464e53ca
|
/src/drivers/net/ne2k/ne2k.c
|
e4d51249ffa69b9ccc8579325c643bf4d0d1490c
|
[
"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
| 11,169
|
c
|
ne2k.c
|
/**
* @file
* @brief Device driver for PCI NE2000 PCI clones (e.g. RealTek RTL-8029).
* @details Driver to fool Qemu into sending and receiving
* packets for us via it's model=ne2k_pci emulation
* This driver is unlikely to work with real hardware
* without substantial modifications and is purely for
* helping with the development of network stacks.
* Interrupts are not supported.
*
* @date 11.01.11
* @author Biff
* - Initial implementation
* @author Nikolay Korotky
* @author Ilia Vaprol
* - Adaptation for Embox
*/
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <net/l0/net_entry.h>
#include <asm/io.h>
#include <kernel/irq.h>
#include <net/l2/ethernet.h>
#include "ne2k.h"
#include <net/netdevice.h>
#include <net/inetdevice.h>
#include <net/skbuff.h>
#include <net/util/show_packet.h>
/* The per-packet-header format. */
struct e8390_pkt_hdr {
uint8_t status; /* status */
uint8_t next; /* pointer to next packet. */
uint16_t count; /* header + packet lenght in bytes */
};
static void ne2k_get_addr_from_prom(struct net_device *dev) {
uint8_t i;
dev->addr_len = ETH_ALEN;
/* Copy the station address into the DS8390 registers,
and set the multicast hash bitmap to receive all multicasts. */
out8(NE_PAGE1_STOP, dev->base_addr); /* 0x61 */
out8(NESM_START_PG_RX, dev->base_addr + EN1_CURPAG);
/* Get mac-address from prom*/
out8(E8390_PAGE0 | E8390_RREAD | E8390_NODMA, dev->base_addr + E8390_CMD);
for (i = 0; i < ETH_ALEN; i++) {
dev->dev_addr[i] = in8(dev->base_addr + NE_DATAPORT);
(void)in8(dev->base_addr + NE_DATAPORT);
}
}
/* Configure board */
static void ne2k_config(struct net_device *dev) {
unsigned int base_addr;
int i;
base_addr = dev->base_addr;
/* Stop */
out8(E8390_PAGE0 | E8390_STOP, base_addr);
out8(0x49, base_addr + EN0_DCFG); /*16 bit & normal & 4fifo */
/* Set the transmit page and receive ring. */
out8(NESM_START_PG_TX, base_addr + EN0_TPSR);
out8(NESM_START_PG_RX, base_addr + EN0_STARTPG);
out8(NESM_STOP_PG - 1, base_addr + EN0_BOUNDARY);
out8(NESM_STOP_PG, base_addr + EN0_STOPPG);
out8(0xFF, base_addr + EN0_ISR);
out8(ENISR_ALL, base_addr + EN0_IMR);
out8(E8390_TXCONFIG, base_addr + EN0_TXCR); /* xmit on */
out8(E8390_RXCONFIG, base_addr + EN0_RXCR); /* rx on */
/* Copy the station address and set the multicast
* hash bitmap to recive all multicast */
out8(E8390_NODMA | E8390_PAGE1, dev->base_addr + E8390_CMD);
for (i = 0; i < ETH_ALEN; i++) {
out8(dev->dev_addr[i], dev->base_addr + EN1_PHYS_SHIFT(i));
out8(0xFF, dev->base_addr + EN1_MULT_SHIFT(i));
}
out8(E8390_NODMA | E8390_PAGE0 | E8390_START, dev->base_addr + E8390_CMD);
// out8(E8390_PAGE1 | E8390_STOP, base_addr);
// out8(NESM_START_PG_RX, base_addr + EN1_CURPAG); /* set current page */
}
static void set_tx_count(uint16_t val, unsigned long base_addr) {
/* Set how many bytes we're going to send. */
out8(val & 0xff, EN0_TBCR_LO + base_addr);
out8(val >> 8, EN0_TBCR_HI + base_addr);
}
static void set_rem_address(uint16_t val, unsigned long base_addr) {
out8(val & 0xff, EN0_RSARLO + base_addr);
out8(val >> 8, EN0_RSARHI + base_addr);
}
static void set_rem_byte_count(uint16_t val, unsigned long base_addr) {
out8(val & 0xff, EN0_RCNTLO + base_addr);
out8(val >> 8, EN0_RCNTHI + base_addr);
}
static void copy_data_to_card(uint16_t dest, uint8_t *src,
uint16_t len, unsigned long base_addr) {
out8(E8390_NODMA | E8390_PAGE0, base_addr + NE_CMD); // switch to PAGE0
set_rem_address(dest, base_addr);
set_rem_byte_count(len, base_addr);
out8(E8390_RWRITE | E8390_START | E8390_PAGE0, base_addr + NE_CMD);
if (len & 1) { /* rounding */
len++;
}
outsw(base_addr + NE_DATAPORT, src, len >> 1);
// while (0 == (in8(base_addr + EN0_ISR) & ENISR_RDC)); /* FIXME sometimes it requires much time */
// out8(ENISR_RDC, base_addr + EN0_ISR);
}
static inline void copy_data_from_card(uint16_t src, uint8_t *dest,
uint32_t length, unsigned long base_addr) {
out8(E8390_NODMA | E8390_PAGE0, base_addr + NE_CMD);
set_rem_address(src, base_addr);
set_rem_byte_count(length, base_addr);
out8(E8390_RREAD | E8390_START | E8390_PAGE0, base_addr + NE_CMD);
insw(base_addr + NE_DATAPORT, dest, length>>1);
if (length & 1) {
*(dest + length - 1) = in8(base_addr + NE_DATAPORT);
}
}
static int xmit(struct net_device *dev, struct sk_buff *skb) {
uint16_t count;
unsigned long base_addr;
if ((skb == NULL) || (dev == NULL)) {
return -EINVAL;
}
base_addr = dev->base_addr;
if (in8(base_addr + NE_CMD) & E8390_TRANS) { /* no matter, which page is active */
return -EBUSY;
}
count = skb->len;
copy_data_to_card(NESM_START_PG_TX << 8, skb->mac.raw, count, base_addr);
/* switch off dma */
out8(E8390_NODMA | E8390_START | E8390_PAGE0, base_addr + NE_CMD);
/* send */
set_tx_count(count, base_addr);
out8(NESM_START_PG_TX, base_addr + EN0_TPSR);
out8(E8390_TRANS | E8390_NODMA | E8390_START, base_addr + NE_CMD);
/* Wait for transmission to complete. */
while (in8(base_addr + NE_CMD) & E8390_TRANS);
show_packet(skb->mac.raw, skb->len, "send");
skb_free(skb); /* free packet */
return ENOERR;
}
static struct sk_buff * get_skb_from_card(uint16_t total_length,
uint16_t offset, struct net_device *dev) {
struct sk_buff *skb;
skb = skb_alloc(total_length);
if (skb == NULL) {
return NULL;
}
skb->dev = dev;
copy_data_from_card(offset, skb->mac.raw, total_length, dev->base_addr);
show_packet(skb->mac.raw, skb->len, "recv");
return skb;
}
static void ne2k_receive(struct net_device *dev) {
uint16_t total_length, ring_offset;
uint8_t this_frame, next_frame, current_page;
struct e8390_pkt_hdr rx_frame = {0};
net_device_stats_t *stat;
unsigned long base_addr;
struct sk_buff *skb;
uint8_t tries;
base_addr = dev->base_addr;
stat = &dev->stats;
tries = 10;
while (--tries) { /* XXX It's an infinite loop or not? */
/* Get the current page */
out8(E8390_NODMA | E8390_PAGE1, base_addr + E8390_CMD);
current_page = in8(base_addr + EN1_CURPAG);
out8(E8390_NODMA | E8390_PAGE0, base_addr + E8390_CMD);
/* Remove one frame from the ring. Boundary is always a page behind. */
this_frame = in8(base_addr + EN0_BOUNDARY) + 1;
if (this_frame >= NESM_STOP_PG) {
this_frame = NESM_START_PG_RX;
}
if (this_frame == current_page) {
break; /* No any more package to receive */
}
ring_offset = this_frame << 8;
/* Find out where the next packet is in card memory */
copy_data_from_card(ring_offset, (uint8_t *) &rx_frame, sizeof(rx_frame),
base_addr);
total_length = rx_frame.count - sizeof(rx_frame);
next_frame = this_frame + 1 + (rx_frame.count >> 8);
if ((rx_frame.next != next_frame)
&& (rx_frame.next != next_frame + 1)
&& (rx_frame.next != next_frame - (NESM_STOP_PG - NESM_START_PG_RX))
&& (rx_frame.next != next_frame + 1 - (NESM_STOP_PG - NESM_START_PG_RX))) {
stat->rx_err++;
out8(current_page - 1, base_addr + EN0_BOUNDARY);
continue;
}
if ((total_length < 60) || (total_length > 1518)) {
stat->rx_err++;
} else if ((rx_frame.status & 0x0F) == ENRSR_RXOK) {
skb = get_skb_from_card(total_length, ring_offset + sizeof(struct e8390_pkt_hdr), dev);
if (skb) {
stat->rx_packets++;
stat->rx_bytes += skb->len;
netif_rx(skb);
} else {
stat->rx_dropped++;
}
} else {
if (rx_frame.status & ENRSR_FO) {
stat->rx_fifo_errors++;
}
}
out8(rx_frame.next - 1, base_addr + EN0_BOUNDARY);
}
if (!tries) {
}
out8(ENISR_RX | ENISR_RX_ERR, base_addr + EN0_ISR);
}
static irq_return_t ne2k_handler(unsigned int irq_num, void *dev_id) {
uint8_t isr, status;
net_device_stats_t *stat;
unsigned long base_addr;
stat = &((struct net_device *)dev_id)->stats;
base_addr = ((struct net_device *)dev_id)->base_addr;
out8(E8390_NODMA | E8390_PAGE0, base_addr + E8390_CMD);
/* Get Interrupt Status Register */
while ((isr = in8(base_addr + EN0_ISR)) != 0) {
if (isr & ENISR_OVER) {
stat->rx_over_errors++;
status = in8(base_addr + E8390_CMD);
out8(E8390_NODMA | E8390_PAGE0 | E8390_STOP, base_addr + E8390_CMD);
out8(0x00, base_addr + EN0_RCNTLO);
out8(0x00, base_addr + EN0_RCNTHI);
status = status ? !(isr & (ENISR_TX | ENISR_TX_ERR)) : 0;
out8(E8390_TXOFF, base_addr + EN0_TXCR);
out8(E8390_NODMA | E8390_PAGE0 | E8390_START, base_addr + E8390_CMD);
ne2k_receive(dev_id); /* Remove packets right away. */
out8(ENISR_OVER, base_addr + EN0_ISR);
out8(E8390_TXCONFIG, base_addr + EN0_TXCR); /* xmit on. */
if (status) {
out8(E8390_NODMA | E8390_PAGE0 | E8390_START | E8390_TRANS, base_addr + E8390_CMD); /* resend packet */
}
} else if (isr & (ENISR_RX | ENISR_RX_ERR)) {
ne2k_receive(dev_id);
}
if (isr & ENISR_TX) {
status = in8(base_addr + EN0_TSR);
out8(ENISR_TX, base_addr + EN0_ISR);
if (status & ENTSR_COL) {
stat->collisions++;
}
if (status & ENTSR_PTX) {
stat->tx_packets++;
} else {
stat->tx_err++;
if (status & ENTSR_ABT) { stat->tx_aborted_errors++; }
if (status & ENTSR_CRS) { stat->tx_carrier_errors++; }
if (status & ENTSR_FU) { stat->tx_fifo_errors++; }
if (status & ENTSR_CDH) { stat->tx_heartbeat_errors++; }
if (status & ENTSR_OWC) { stat->tx_window_errors++; }
}
if ((status & ENTSR_COL) && (status & ENTSR_ABT)) {
netdev_flag_down(dev_id, IFF_RUNNING);
}
else {
netdev_flag_up(dev_id, IFF_RUNNING);
}
} else if (isr & ENISR_TX_ERR) {
out8(ENISR_TX_ERR, base_addr + EN0_ISR); // TODO
}
if (isr & ENISR_COUNTERS) {
stat->rx_frame_errors += in8(base_addr + EN0_COUNTER0);
stat->rx_crc_errors += in8(base_addr + EN0_COUNTER1);
stat->rx_missed_errors += in8(base_addr + EN0_COUNTER2);
out8(ENISR_COUNTERS, base_addr + EN0_ISR);
}
if (isr & ENISR_RDC) {
out8(ENISR_RDC, base_addr + EN0_ISR);
}
out8(E8390_NODMA | E8390_PAGE0 | E8390_START, base_addr + E8390_CMD);
}
return IRQ_HANDLED;
}
static int set_mac_address(struct net_device *dev, const void *addr) {
uint32_t i;
if ((dev == NULL) || (addr == NULL)) {
return -EINVAL;
}
out8(E8390_NODMA | E8390_PAGE1, dev->base_addr + E8390_CMD);
for (i = 0; i < ETH_ALEN; i++) {
out8(*((uint8_t *)addr + i), dev->base_addr + EN1_PHYS_SHIFT(i));
}
memcpy(dev->dev_addr, addr, ETH_ALEN);
return ENOERR;
}
static int ne2k_open(struct net_device *dev) {
if (dev == NULL) {
return -EINVAL;
}
ne2k_config(dev);
return ENOERR;
}
static int stop(struct net_device *dev) {
if (dev == NULL) {
return -EINVAL;
}
/* reset */
out8(E8390_PAGE0 | E8390_STOP, dev->base_addr);
out8(0xFF, dev->base_addr + EN0_ISR);
out8(0x00, dev->base_addr + EN0_IMR);
return ENOERR;
}
static const struct net_driver _drv_ops = {
.xmit = xmit,
.start = ne2k_open,
.stop = stop,
.set_macaddr = set_mac_address
};
int ne2k_dev_init(struct net_device *nic) {
int res;
nic->drv_ops = &_drv_ops;
ne2k_get_addr_from_prom(nic);
res = irq_attach(nic->irq, ne2k_handler, IF_SHARESUP, nic, "ne2k");
if (res < 0) {
return res;
}
return inetdev_register_dev(nic);
}
|
a4d85c3c945709418535adebd9522636b14ba14e
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/arch/arm/src/stm32/hardware/stm32f103r_pinmap.h
|
a044ba939c46e7f005647a9758130873d5546849
|
[
"MIT-open-group",
"BSD-3-Clause",
"HPND-sell-variant",
"BSD-4-Clause-UC",
"LicenseRef-scancode-warranty-disclaimer",
"MIT-0",
"LicenseRef-scancode-bsd-atmel",
"LicenseRef-scancode-gary-s-brown",
"LicenseRef-scancode-proprietary-license",
"SunPro",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"LicenseRef-scancode-other-permissive",
"HPND",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"GPL-1.0-or-later",
"CC-BY-2.0",
"CC-BY-4.0"
] |
permissive
|
apache/nuttx
|
14519a7bff4a87935d94fb8fb2b19edb501c7cec
|
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
|
refs/heads/master
| 2023-08-25T06:55:45.822534
| 2023-08-23T16:03:31
| 2023-08-24T21:25:47
| 228,103,273
| 407
| 241
|
Apache-2.0
| 2023-09-14T18:26:05
| 2019-12-14T23:27:55
|
C
|
UTF-8
|
C
| false
| false
| 24,856
|
h
|
stm32f103r_pinmap.h
|
/****************************************************************************
* arch/arm/src/stm32/hardware/stm32f103r_pinmap.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_STM32_HARDWARE_STM32F103R_PINMAP_H
#define __ARCH_ARM_SRC_STM32_HARDWARE_STM32F103R_PINMAP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "stm32_gpio.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* ADC */
#define GPIO_ADC123_IN0_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
#define GPIO_ADC123_IN1_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
#define GPIO_ADC123_IN2_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
#define GPIO_ADC123_IN3_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
#define GPIO_ADC12_IN4_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
#define GPIO_ADC3_IN4_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN6)
#define GPIO_ADC12_IN5_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
#define GPIO_ADC3_IN5_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN7)
#define GPIO_ADC12_IN6_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
#define GPIO_ADC3_IN6_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN8)
#define GPIO_ADC12_IN7_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN7)
#define GPIO_ADC3_IN7_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN9)
#define GPIO_ADC12_IN8_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
#define GPIO_ADC3_IN8_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTF|GPIO_PIN10)
#define GPIO_ADC12_IN9_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
#define GPIO_ADC123_IN10_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN0)
#define GPIO_ADC123_IN11_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN1)
#define GPIO_ADC123_IN12_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN2)
#define GPIO_ADC123_IN13_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN3)
#define GPIO_ADC12_IN14_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN4)
#define GPIO_ADC12_IN15_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN5)
/* DAC - "Once the DAC channelx is enabled, the corresponding GPIO pin
* (PA4 or PA5) is automatically connected to the analog converter output
* (DAC_OUTx). In order to avoid parasitic consumption, the PA4 or PA5 pin
* should first be configured to analog (AIN)."
*/
#define GPIO_DAC1_OUT1_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
#define GPIO_DAC1_OUT2_0 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5)
/* TIMERS */
#if defined(CONFIG_STM32_TIM1_FULL_REMAP)
# define GPIO_TIM1_ETR_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTE|GPIO_PIN7)
# define GPIO_TIM1_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTE|GPIO_PIN9)
# define GPIO_TIM1_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTE|GPIO_PIN9)
# define GPIO_TIM1_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTE|GPIO_PIN11)
# define GPIO_TIM1_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTE|GPIO_PIN11)
# define GPIO_TIM1_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTE|GPIO_PIN13)
# define GPIO_TIM1_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTE|GPIO_PIN13)
# define GPIO_TIM1_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTE|GPIO_PIN14)
# define GPIO_TIM1_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTE|GPIO_PIN14)
# define GPIO_TIM1_BKIN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTE|GPIO_PIN15)
# define GPIO_TIM1_CH1NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTE|GPIO_PIN8)
# define GPIO_TIM1_CH2NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTE|GPIO_PIN10)
# define GPIO_TIM1_CH3NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTE|GPIO_PIN12)
#elif defined(CONFIG_STM32_TIM1_PARTIAL_REMAP)
# define GPIO_TIM1_ETR_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN12)
# define GPIO_TIM1_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN8)
# define GPIO_TIM1_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN8)
# define GPIO_TIM1_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN9)
# define GPIO_TIM1_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN9)
# define GPIO_TIM1_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN10)
# define GPIO_TIM1_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN10)
# define GPIO_TIM1_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN11)
# define GPIO_TIM1_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN11)
# define GPIO_TIM1_BKIN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
# define GPIO_TIM1_CH1NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN7)
# define GPIO_TIM1_CH2NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN0)
# define GPIO_TIM1_CH3NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN1)
#else
# define GPIO_TIM1_ETR_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN12)
# define GPIO_TIM1_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN8)
# define GPIO_TIM1_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN8)
# define GPIO_TIM1_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN9)
# define GPIO_TIM1_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN9)
# define GPIO_TIM1_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN10)
# define GPIO_TIM1_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN10)
# define GPIO_TIM1_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN11)
# define GPIO_TIM1_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN11)
# define GPIO_TIM1_BKIN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN12)
# define GPIO_TIM1_CH1NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN13)
# define GPIO_TIM1_CH2NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN14)
# define GPIO_TIM1_CH3NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN15)
#endif
#if defined(CONFIG_STM32_TIM2_FULL_REMAP)
# define GPIO_TIM2_ETR_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15)
# define GPIO_TIM2_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15)
# define GPIO_TIM2_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN15)
# define GPIO_TIM2_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN3)
# define GPIO_TIM2_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN3)
# define GPIO_TIM2_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN10)
# define GPIO_TIM2_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN10)
# define GPIO_TIM2_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN11)
# define GPIO_TIM2_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN11)
#elif defined(CONFIG_STM32_TIM2_PARTIAL_REMAP_1)
# define GPIO_TIM2_ETR_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15)
# define GPIO_TIM2_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15)
# define GPIO_TIM2_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN15)
# define GPIO_TIM2_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN3)
# define GPIO_TIM2_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN3)
# define GPIO_TIM2_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
# define GPIO_TIM2_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN2)
# define GPIO_TIM2_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
# define GPIO_TIM2_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN3)
#elif defined(CONFIG_STM32_TIM2_PARTIAL_REMAP_2)
# define GPIO_TIM2_ETR_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
# define GPIO_TIM2_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
# define GPIO_TIM2_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN0)
# define GPIO_TIM2_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
# define GPIO_TIM2_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN1)
# define GPIO_TIM2_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN10)
# define GPIO_TIM2_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN10)
# define GPIO_TIM2_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN11)
# define GPIO_TIM2_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN11)
#else
# define GPIO_TIM2_ETR_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
# define GPIO_TIM2_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
# define GPIO_TIM2_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN0)
# define GPIO_TIM2_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
# define GPIO_TIM2_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN1)
# define GPIO_TIM2_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
# define GPIO_TIM2_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN2)
# define GPIO_TIM2_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
# define GPIO_TIM2_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN3)
#endif
#if defined(CONFIG_STM32_TIM3_FULL_REMAP)
# define GPIO_TIM3_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN6)
# define GPIO_TIM3_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN6)
# define GPIO_TIM3_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN7)
# define GPIO_TIM3_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN7)
# define GPIO_TIM3_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN8)
# define GPIO_TIM3_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN8)
# define GPIO_TIM3_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN9)
# define GPIO_TIM3_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN9)
#elif defined(CONFIG_STM32_TIM3_PARTIAL_REMAP)
# define GPIO_TIM3_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN4)
# define GPIO_TIM3_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN4)
# define GPIO_TIM3_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN5)
# define GPIO_TIM3_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN5)
# define GPIO_TIM3_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
# define GPIO_TIM3_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN0)
# define GPIO_TIM3_CH4IN_0 GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
# define GPIO_TIM3_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN1)
#else
# define GPIO_TIM3_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
# define GPIO_TIM3_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN6)
# define GPIO_TIM3_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN7)
# define GPIO_TIM3_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN7)
# define GPIO_TIM3_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0)
# define GPIO_TIM3_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN0)
# define GPIO_TIM3_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1)
# define GPIO_TIM3_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN1)
#endif
#if defined(CONFIG_STM32_TIM4_REMAP)
# define GPIO_TIM4_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN12)
# define GPIO_TIM4_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN12)
# define GPIO_TIM4_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN13)
# define GPIO_TIM4_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN13)
# define GPIO_TIM4_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN14)
# define GPIO_TIM4_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN14)
# define GPIO_TIM4_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN15)
# define GPIO_TIM4_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN15)
#else
# define GPIO_TIM4_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN6)
# define GPIO_TIM4_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN6)
# define GPIO_TIM4_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN7)
# define GPIO_TIM4_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN7)
# define GPIO_TIM4_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN8)
# define GPIO_TIM4_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN8)
# define GPIO_TIM4_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN9)
# define GPIO_TIM4_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN9)
#endif
#define GPIO_TIM5_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
#define GPIO_TIM5_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN0)
#define GPIO_TIM5_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN1)
#define GPIO_TIM5_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN1)
#define GPIO_TIM5_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN2)
#define GPIO_TIM5_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN2)
#define GPIO_TIM5_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
#define GPIO_TIM5_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN3)
#define GPIO_TIM8_ETR_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
#define GPIO_TIM8_CH1IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN6)
#define GPIO_TIM8_CH1OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN6)
#define GPIO_TIM8_CH2IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN7)
#define GPIO_TIM8_CH2OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN7)
#define GPIO_TIM8_CH3IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN8)
#define GPIO_TIM8_CH3OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN8)
#define GPIO_TIM8_CH4IN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN9)
#define GPIO_TIM8_CH4OUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN9)
#define GPIO_TIM8_BKIN_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN6)
#define GPIO_TIM8_CH1NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN7)
#define GPIO_TIM8_CH2NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN0)
#define GPIO_TIM8_CH3NOUT_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN1)
/* USART */
#if defined(CONFIG_STM32_USART1_REMAP)
# define GPIO_USART1_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN6)
# define GPIO_USART1_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN7)
#else
# define GPIO_USART1_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN9)
# define GPIO_USART1_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN10)
#endif
#if defined(CONFIG_STM32_USART2_REMAP)
# define GPIO_USART2_CTS_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN3)
# define GPIO_USART2_RTS_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN4)
# define GPIO_USART2_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN5)
# define GPIO_USART2_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN6)
# define GPIO_USART2_CK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN7)
#else
# define GPIO_USART2_CTS_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN0)
# define GPIO_USART2_RTS_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN1)
# define GPIO_USART2_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN2)
# define GPIO_USART2_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN3)
# define GPIO_USART2_CK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN4)
#endif
#if defined(CONFIG_STM32_USART3_FULL_REMAP)
# define GPIO_USART3_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN8)
# define GPIO_USART3_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN9)
# define GPIO_USART3_CK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN10)
# define GPIO_USART3_CTS_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN11)
# define GPIO_USART3_RTS_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN12)
#elif defined(CONFIG_STM32_USART3_PARTIAL_REMAP)
# define GPIO_USART3_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN10)
# define GPIO_USART3_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN11)
# define GPIO_USART3_CK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN12)
# define GPIO_USART3_CTS_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN13)
# define GPIO_USART3_RTS_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN14)
#else
# define GPIO_USART3_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN10)
# define GPIO_USART3_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN11)
# define GPIO_USART3_CK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN12)
# define GPIO_USART3_CTS_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN13)
# define GPIO_USART3_RTS_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN14)
#endif
#define GPIO_UART4_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN11)
#define GPIO_UART4_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN10)
#define GPIO_UART5_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN2)
#define GPIO_UART5_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN12)
/* SPI */
#if defined(CONFIG_STM32_SPI1_REMAP)
# define GPIO_SPI1_NSS_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15)
# define GPIO_SPI1_SCK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN3)
# define GPIO_SPI1_MISO_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN4)
# define GPIO_SPI1_MOSI_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN5)
#else
# define GPIO_SPI1_NSS_0 (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN4)
# define GPIO_SPI1_SCK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN5)
# define GPIO_SPI1_MISO_0 (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN6)
# define GPIO_SPI1_MOSI_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN7)
#endif
#define GPIO_SPI2_NSS_0 (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN12)
#define GPIO_SPI2_SCK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN13)
#define GPIO_SPI2_MISO_0 (GPIO_INPUT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN14)
#define GPIO_SPI2_MOSI_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN15)
#if defined(CONFIG_STM32_SPI3_REMAP)
# define GPIO_SPI3_NSS_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN4)
# define GPIO_SPI3_SCK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN10)
# define GPIO_SPI3_MISO_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTC|GPIO_PIN11)
# define GPIO_SPI3_MOSI_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN12)
#else
# define GPIO_SPI3_NSS_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN15)
# define GPIO_SPI3_SCK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN3)
# define GPIO_SPI3_MISO_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN4)
# define GPIO_SPI3_MOSI_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN5)
#endif
/* I2C */
#if defined(CONFIG_STM32_I2C1_REMAP)
# define GPIO_I2C1_SCL_0 (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN8)
# define GPIO_I2C1_SDA_0 (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN9)
#else
# define GPIO_I2C1_SCL_0 (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN6)
# define GPIO_I2C1_SDA_0 (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN7)
#endif
#define GPIO_I2C1_SMBA_0 (GPIO_ALT|GPIO_CNF_INFLOAT|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN5)
#define GPIO_I2C2_SCL_0 (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN10)
#define GPIO_I2C2_SDA_0 (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN11)
#define GPIO_I2C2_SMBA_0 (GPIO_ALT|GPIO_CNF_INFLOAT|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN12)
/* CAN */
#if defined(CONFIG_STM32_CAN1_REMAP1)
# define GPIO_CAN1_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN8)
# define GPIO_CAN1_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN9)
#elif defined(CONFIG_STM32_CAN1_REMAP2)
# define GPIO_CAN1_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN0)
# define GPIO_CAN1_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN1)
#else
# define GPIO_CAN1_RX_0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN11)
# define GPIO_CAN1_TX_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTA|GPIO_PIN12)
#endif
/* SDIO */
#define GPIO_SDIO_D0_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN8)
#ifndef CONFIG_STM32_SDIO_WIDTH_D1_ONLY
# define GPIO_SDIO_D1_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN9)
# define GPIO_SDIO_D2_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN10)
# define GPIO_SDIO_D3_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN11)
# define GPIO_SDIO_D4_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN8)
# define GPIO_SDIO_D5_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTB|GPIO_PIN9)
# define GPIO_SDIO_D6_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN6)
# define GPIO_SDIO_D7_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN7)
#endif
#define GPIO_SDIO_CK_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTC|GPIO_PIN12)
#define GPIO_SDIO_CMD_0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_2MHz|GPIO_PORTD|GPIO_PIN2)
#endif /* __ARCH_ARM_SRC_STM32_HARDWARE_STM32F103R_PINMAP_H */
|
701fbe5018f976889dd81b88f9bd07563a6f212c
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/parisc/include/asm/unaligned.h
|
dfc5d3321a54bb72bba3b234586f2332142293ea
|
[
"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
| 433
|
h
|
unaligned.h
|
#ifndef _ASM_PARISC_UNALIGNED_H
#define _ASM_PARISC_UNALIGNED_H
#include <linux/unaligned/be_struct.h>
#include <linux/unaligned/le_byteshift.h>
#include <linux/unaligned/generic.h>
#define get_unaligned __get_unaligned_be
#define put_unaligned __put_unaligned_be
#ifdef __KERNEL__
struct pt_regs;
void handle_unaligned(struct pt_regs *regs);
int check_unaligned(struct pt_regs *regs);
#endif
#endif /* _ASM_PARISC_UNALIGNED_H */
|
200b94bdf03c217225fe1659b97946f283ab7849
|
72f6d3ad72b2a4a9b6c5f93c5d1b744e2940b884
|
/deps/picotls/deps/cifra/src/arm/ext/cutest.h
|
fa3c5d8433af28e6b841016f0197166dd5ac3f36
|
[
"MIT",
"CC0-1.0",
"BSD-2-Clause"
] |
permissive
|
h2o/h2o
|
70012b6527ceb54e9e2819c9c75242b18e381485
|
b165770ce704c782ddee7428ea4a0b23c8bb7894
|
refs/heads/master
| 2023-08-16T13:16:35.018003
| 2023-08-16T03:56:28
| 2023-08-16T03:56:28
| 23,029,617
| 9,377
| 983
|
MIT
| 2023-09-12T04:49:14
| 2014-08-16T23:59:03
|
C
|
UTF-8
|
C
| false
| false
| 1,042
|
h
|
cutest.h
|
/* cutest, for embedded targets. */
#ifndef CUTEST_H
#define CUTEST_H
/* Main interface. */
#define TEST_LIST const struct test__ test_list__[]
#define TEST_CHECK(cond) test_check__((cond), __FILE__, __LINE__, #cond)
/* no TEST_CHECK_ -- we don't have a good enough printf */
/* Implementation */
#include "../semihost.h"
struct test__
{
const char *name;
void (*func)(void);
};
extern const struct test__ test_list__[];
static void test_check__(int cond, const char *file, int line, const char *expr)
{
if (cond)
return; /* pass */
emit("Failed!\n");
emit("File: "); emit(file); emit("\n");
emit("Line: "); emit_uint32(line); emit("\n");
emit("Expr: "); emit(expr); emit("\n");
quit_failure();
}
static void run_test__(const struct test__ *t)
{
emit(" "); emit(t->name); emit(": ");
t->func();
emit("OK\n");
}
int main(void)
{
emit("Running tests:\n");
for (const struct test__ *t = test_list__;
t->name;
t++)
{
run_test__(t);
}
emit("Success\n");
quit_success();
}
#endif
|
6f26fabb3667278529eaa3acd7eb0fb1677c775e
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/external/iotivity/iotivity_1.2-rel/resource/csdk/security/include/internal/amsmgr.h
|
de5a9cca9ebca099fbd1563fb79e29ee8f7bd197
|
[
"Apache-2.0",
"GPL-2.0-only",
"MIT",
"BSD-3-Clause"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 4,488
|
h
|
amsmgr.h
|
//******************************************************************
//
// Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#ifndef IOTVT_SRM_AMSMGR_H
#define IOTVT_SRM_AMSMGR_H
#include <stdlib.h>
#include <stdint.h>
#include "ocstack.h"
#include "logger.h"
#include "policyengine.h"
#include "securevirtualresourcetypes.h"
#include "cainterface.h"
typedef struct PEContext PEContext_t;
/**
* The AMS context.
*/
typedef struct AmsMgrContext
{
OicUuid_t amsDeviceId; /**< DeviceID of the oic.sec.ams service. */
CAEndpoint_t *endpoint;
CARequestInfo_t *requestInfo;
} AmsMgrContext_t;
/**
* This method updates AmsMgr context's endpoint & requestInfo.
*
* @param context is the policy engine context.
* @param endpoint is the CA Endpoint info of the requester.
* @param requestInfo is the CA RequestInfo of the requester.
*
* @return ::OC_STACK_OK if successful, else other value in case of error.
*/
OCStackResult UpdateAmsMgrContext(PEContext_t *context,
const CAEndpoint_t *endpoint,
const CARequestInfo_t *requestInfo);
/**
* This method is called by PolicyEngine to Discover AMS service.
* It sends muticast discovery request such as
* /oic/sec/doxm?deviceid="AMSSrvcDeviceID" to discover AMS service
* with deviceId="AMSSrvcDeviceID".
*
* @param context is the policy engine context.
*
* @return ::OC_STACK_OK,If able to successfully send multicast discovery request.
* else ::OC_STACK_ERROR, If unable to successfully send multicast discovery request
* due to error.
*/
OCStackResult DiscoverAmsService(PEContext_t *context);
/**
* This method sends unicast request to retrieve the secured port info of the
* discovered AMS service. It sends unicast discovery request such as
* /oic/res?rt="oic.sec.doxm" to the discovered AMS service.
*
* @param context is the policy engine context.
*
* @return ::OC_STACK_OK,If able to successfully send unicast discovery request.
* else ::OC_STACK_ERROR, If unable to successfully send unicast discovery request
* due to error.
*/
OCStackResult SendUnicastSecurePortDiscovery(PEContext_t *context,
OCDevAddr *devAddr,
OCConnectivityType connType);
/**
* This method sends unicast request to AMS service to get ACL for
* the Subject and/or Resource. It sends unicast request such as
* /oic/sec/acl?sub="subjectId";rsrc="/a/led" to get the ACL for
* the subject & resource.
*
* @param context is the policy engine context.
*
* @return ::OC_STACK_OK, If able to successfully send unicast ACL request.
* ::OC_STACK_ERROR, If unable to successfully send unicast ACL request due to error.
*
*/
OCStackResult SendAclReq(PEContext_t *context,
OCDevAddr *devAddr,
OCConnectivityType connType,
uint16_t securedPort);
/*
* This method is used by Policy engine to checks Amacl resource.
* If Amacl is found then it fills up context->amsMgrContext->amsDeviceId
* with amsID of the Amacl else leaves it empty.
*
* @param context is the policy engine context.
*
* @return true, if Amacl for the resource is found. false, if Amacl for the
* resource is not found
*/
bool FoundAmaclForRequest(PEContext_t *context);
/*
* This method is used by Policy engine to process AMS request.
*
* @param context is the policy engine context.
*/
void ProcessAMSRequest(PEContext_t *context);
/*
* This method is used by Policy engine to free AMS context requestInfo/
*
* @param requestInfo is the pointer to @ref CARequestInfo_t.
*/
void FreeCARequestInfo(CARequestInfo_t *requestInfo);
#endif //IOTVT_SRM_AMSMGR_H
|
4d70a4130313c014a8b80a5232c35359e57379ae
|
1f399edf85d995443d01f66d77eca0723886d0ff
|
/devicemodel/include/iothread.h
|
fb76e9baad19cc7783551572445c5ec9d1d25cb3
|
[
"BSD-3-Clause"
] |
permissive
|
projectacrn/acrn-hypervisor
|
f9c5864d54929a5d2fa36b5e78c08f19b46b8f98
|
390740aa1b1e9d62c51f8e3afa0c29e07e43fa23
|
refs/heads/master
| 2023-08-18T05:07:01.310327
| 2023-08-11T07:49:36
| 2023-08-16T13:20:27
| 123,983,554
| 1,059
| 686
|
BSD-3-Clause
| 2023-09-14T09:51:10
| 2018-03-05T21:52:25
|
C
|
UTF-8
|
C
| false
| false
| 358
|
h
|
iothread.h
|
/* Copyright (C) 2022 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#ifndef _iothread_CTX_H_
#define _iothread_CTX_H_
struct iothread_mevent {
void (*run)(void *);
void *arg;
int fd;
};
int iothread_add(int fd, struct iothread_mevent *aevt);
int iothread_del(int fd);
int iothread_init(void);
void iothread_deinit(void);
#endif
|
a55b70a09ec3ce82078d02b8527cc48da57ec8a0
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/apps/examples/i2schar/i2schar.h
|
10d86b209662105dcb176dc440c9f1ac0584da33
|
[
"BSD-3-Clause",
"MIT",
"Apache-2.0"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 6,421
|
h
|
i2schar.h
|
/****************************************************************************
*
* Copyright 2017 Samsung Electronics 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.
*
****************************************************************************/
/****************************************************************************
* examples/examples/i2schar/i2schar.h
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __APPS_EXAMPLES_I2SCHAR_I2SCHAR_H
#define __APPS_EXAMPLES_I2SCHAR_I2SCHAR_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <tinyara/config.h>
#include <pthread.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* CONFIG_BUILTIN_APPS - Build the I2SCHAR test as a built-in
* function. Default: Built as a standalone program
* CONFIG_EXAMPLES_I2SCHAR_DEVPATH - The default path to the I2S character
* device. Default: /dev/i2schar0
*/
#ifndef CONFIG_AUDIO_I2SCHAR
#error "I2S character device support is not enabled (CONFIG_AUDIO_I2SCHAR)"
#endif
#ifndef CONFIG_EXAMPLES_I2SCHAR_DEVPATH
#define CONFIG_EXAMPLES_I2SCHAR_DEVPATH "/dev/i2schar0"
#endif
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
#ifndef CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS
#define CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS 4
#endif
#ifndef CONFIG_EXAMPLES_I2SCHAR_TXSTACKSIZE
#define CONFIG_EXAMPLES_I2SCHAR_TXSTACKSIZE 1536
#endif
#else
#undef CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS
#define CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS 0
#endif
#ifdef CONFIG_EXAMPLES_I2SCHAR_RX
#ifndef CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS
#define CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS 4
#endif
#ifndef CONFIG_EXAMPLES_I2SCHAR_RXSTACKSIZE
#define CONFIG_EXAMPLES_I2SCHAR_RXSTACKSIZE 1536
#endif
#else
#undef CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS
#define CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS 0
#endif
#ifndef CONFIG_EXAMPLES_I2SCHAR_BUFSIZE
#define CONFIG_EXAMPLES_I2SCHAR_BUFSIZE 256
#endif
/****************************************************************************
* Public Types
****************************************************************************/
struct i2schar_state_s {
bool initialized;
FAR char *devpath;
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
int txcount;
#endif
#ifdef CONFIG_EXAMPLES_I2SCHAR_RX
int rxcount;
#endif
};
/****************************************************************************
* Public Variables
****************************************************************************/
extern struct i2schar_state_s g_i2schar;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: i2schar_devinit()
*
* Description:
* Perform architecuture-specific initialization of the I2s hardware and
* registration of the I2S character driver CHAR hardware. If
* CONFIG_EXAMPLES_I2SCHAR_DEVINIT is defined, then board-specific logic
* must provide this function.
*
****************************************************************************/
#ifdef CONFIG_EXAMPLES_I2SCHAR_DEVINIT
int i2schar_devinit(void);
#endif
/****************************************************************************
* Name: i2schar_transmitter()
*
* Description:
* This is the entry point for the transmitter thread.
*
****************************************************************************/
#ifdef CONFIG_EXAMPLES_I2SCHAR_TX
pthread_addr_t i2schar_transmitter(pthread_addr_t arg);
#endif
/****************************************************************************
* Name: i2schar_receiver()
*
* Description:
* This is the entry point for the receiver thread.
*
****************************************************************************/
#ifdef CONFIG_EXAMPLES_I2SCHAR_RX
pthread_addr_t i2schar_receiver(pthread_addr_t arg);
#endif
#endif /* __APPS_EXAMPLES_I2SCHAR_I2SCHAR_H */
|
48e17bc6985fe5a385c14175c23cecf4b3d59c9c
|
73b0f9c30d07993ad74f7f2bcbc0fe61f1d1a3ce
|
/native/iosTest/Pods/Headers/Public/RCT-Folly/folly/lang/Align.h
|
280d2a51a036bd44a44a97b2fc642684b2e8e55e
|
[
"MIT"
] |
permissive
|
Nozbe/WatermelonDB
|
84771a637e2c93474220fadee442e5c4ade40f7e
|
fd41fe279e229e9b5013b1dddf777cd7919e1d2d
|
refs/heads/master
| 2023-08-16T18:24:04.893973
| 2023-08-11T11:44:46
| 2023-08-11T11:44:46
| 146,468,829
| 9,358
| 670
|
MIT
| 2023-09-10T08:04:55
| 2018-08-28T15:32:05
|
JavaScript
|
UTF-8
|
C
| false
| false
| 43
|
h
|
Align.h
|
../../../../../RCT-Folly/folly/lang/Align.h
|
c45f81385cc08b493e58965b494bd696dc8413ed
|
19a9f2c19bcb81c4a14ba17831d3098de7731fb5
|
/ncarg2d/src/libncarg_gks/wiss/gwiins.h
|
9a6a6f98bdb73aecca8c41ac4daf5e0c29a5f299
|
[
"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
| 962
|
h
|
gwiins.h
|
C
C $Id: gwiins.h,v 1.4 2008-07-27 03:55:38 haley Exp $
C
C Copyright (C) 2000
C University Corporation for Atmospheric Research
C All Rights Reserved
C
C The use of this Software is governed by a License Agreement.
C
COMMON /GWIINS/ MCODES ,MCONTS ,MVDCFW ,MCIXFW ,MDCCFW ,
+ MIXFW ,MINTFW ,MDCCRG ,MXOFF ,MXSCAL ,
+ MYOFF ,MYSCAL ,MINXVD ,MAXXVD ,MINYVD ,
+ MAXYVD ,MCFRM ,MCOPCL ,MCOPID ,MCNBYT ,
+ MCCBYT ,MCFPP ,MSLFMT ,MEFW
INTEGER MCODES ,MCONTS ,MVDCFW ,MCIXFW ,MDCCFW ,
+ MIXFW ,MINTFW ,MDCCRG ,MXOFF ,MXSCAL ,
+ MYOFF ,MYSCAL ,MINXVD ,MAXXVD ,MINYVD ,
+ MAXYVD ,MCFRM ,MCOPCL ,MCOPID ,MCNBYT ,
+ MCCBYT ,MCFPP ,MSLFMT ,MEFW
|
7a6c19fb5390867c46f441ecd611552829af246c
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/cris/include/arch-v32/mach-fs/mach/hwregs/reg_map.h
|
4146973a58b318f4762c67662c3120c356654bf1
|
[
"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
| 5,558
|
h
|
reg_map.h
|
#ifndef __reg_map_h
#define __reg_map_h
/*
* This file is autogenerated from
* file: ../../mod/fakereg.rmap
* id: fakereg.rmap,v 1.3 2004/02/11 19:53:22 ronny Exp
* last modified: Wed Feb 11 20:53:25 2004
* file: ../../rtl/global.rmap
* id: global.rmap,v 1.3 2003/08/18 15:08:23 mikaeln Exp
* last modified: Mon Aug 18 17:08:23 2003
* file: ../../mod/modreg.rmap
* id: modreg.rmap,v 1.31 2004/02/20 15:40:04 stefans Exp
* last modified: Fri Feb 20 16:40:04 2004
*
* by /n/asic/design/tools/rdesc/src/rdes2c -map -base 0xb0000000 ../../rtl/global.rmap ../../mod/modreg.rmap ../../inst/io_proc/rtl/guinness/iop_top.r ../../inst/memarb/rtl/guinness/marb_top.r ../../mod/fakereg.rmap
* id: $Id: reg_map.h,v 1.1 2007/02/13 11:55:30 starvik Exp $
* Any changes here will be lost.
*
* -*- buffer-read-only: t -*-
*/
typedef enum {
regi_ata = 0xb0032000,
regi_bif_core = 0xb0014000,
regi_bif_dma = 0xb0016000,
regi_bif_slave = 0xb0018000,
regi_config = 0xb003c000,
regi_dma0 = 0xb0000000,
regi_dma1 = 0xb0002000,
regi_dma2 = 0xb0004000,
regi_dma3 = 0xb0006000,
regi_dma4 = 0xb0008000,
regi_dma5 = 0xb000a000,
regi_dma6 = 0xb000c000,
regi_dma7 = 0xb000e000,
regi_dma8 = 0xb0010000,
regi_dma9 = 0xb0012000,
regi_eth0 = 0xb0034000,
regi_eth1 = 0xb0036000,
regi_gio = 0xb001a000,
regi_iop = 0xb0020000,
regi_iop_version = 0xb0020000,
regi_iop_fifo_in0_extra = 0xb0020040,
regi_iop_fifo_in1_extra = 0xb0020080,
regi_iop_fifo_out0_extra = 0xb00200c0,
regi_iop_fifo_out1_extra = 0xb0020100,
regi_iop_trigger_grp0 = 0xb0020140,
regi_iop_trigger_grp1 = 0xb0020180,
regi_iop_trigger_grp2 = 0xb00201c0,
regi_iop_trigger_grp3 = 0xb0020200,
regi_iop_trigger_grp4 = 0xb0020240,
regi_iop_trigger_grp5 = 0xb0020280,
regi_iop_trigger_grp6 = 0xb00202c0,
regi_iop_trigger_grp7 = 0xb0020300,
regi_iop_crc_par0 = 0xb0020380,
regi_iop_crc_par1 = 0xb0020400,
regi_iop_dmc_in0 = 0xb0020480,
regi_iop_dmc_in1 = 0xb0020500,
regi_iop_dmc_out0 = 0xb0020580,
regi_iop_dmc_out1 = 0xb0020600,
regi_iop_fifo_in0 = 0xb0020680,
regi_iop_fifo_in1 = 0xb0020700,
regi_iop_fifo_out0 = 0xb0020780,
regi_iop_fifo_out1 = 0xb0020800,
regi_iop_scrc_in0 = 0xb0020880,
regi_iop_scrc_in1 = 0xb0020900,
regi_iop_scrc_out0 = 0xb0020980,
regi_iop_scrc_out1 = 0xb0020a00,
regi_iop_timer_grp0 = 0xb0020a80,
regi_iop_timer_grp1 = 0xb0020b00,
regi_iop_timer_grp2 = 0xb0020b80,
regi_iop_timer_grp3 = 0xb0020c00,
regi_iop_sap_in = 0xb0020d00,
regi_iop_sap_out = 0xb0020e00,
regi_iop_spu0 = 0xb0020f00,
regi_iop_spu1 = 0xb0021000,
regi_iop_sw_cfg = 0xb0021100,
regi_iop_sw_cpu = 0xb0021200,
regi_iop_sw_mpu = 0xb0021300,
regi_iop_sw_spu0 = 0xb0021400,
regi_iop_sw_spu1 = 0xb0021500,
regi_iop_mpu = 0xb0021600,
regi_irq = 0xb001c000,
regi_irq2 = 0xb005c000,
regi_marb = 0xb003e000,
regi_marb_bp0 = 0xb003e240,
regi_marb_bp1 = 0xb003e280,
regi_marb_bp2 = 0xb003e2c0,
regi_marb_bp3 = 0xb003e300,
regi_pinmux = 0xb0038000,
regi_ser0 = 0xb0026000,
regi_ser1 = 0xb0028000,
regi_ser2 = 0xb002a000,
regi_ser3 = 0xb002c000,
regi_sser0 = 0xb0022000,
regi_sser1 = 0xb0024000,
regi_strcop = 0xb0030000,
regi_strmux = 0xb003a000,
regi_timer = 0xb001e000,
regi_timer0 = 0xb001e000,
regi_timer2 = 0xb005e000,
regi_trace = 0xb0040000,
} reg_scope_instances;
#endif /* __reg_map_h */
|
427369fd0f7ca4654f20c62ff71be02a01f22062
|
488e6c9b8555a253df765edc2232e8750e8b3a1b
|
/firmware-src/sources/commands/max31855_cmd.h
|
26f9727ba8b2fe487617eb91bdf8bfc861ac0edb
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license"
] |
permissive
|
devicehive/esp8266-firmware
|
32edadae1d919438fd13388b562979030cc4472a
|
eb8a61482035bfc93a343db386d4470d17fa13d6
|
refs/heads/develop
| 2021-01-01T16:44:57.970370
| 2019-03-28T12:48:43
| 2019-03-28T12:48:43
| 39,383,605
| 182
| 61
|
MIT
| 2018-05-07T20:43:14
| 2015-07-20T12:53:51
|
C
|
UTF-8
|
C
| false
| false
| 644
|
h
|
max31855_cmd.h
|
/**
* @file
* @brief MAX31855 command handlers.
* @copyright 2016 [DeviceHive](http://devicehive.com)
* @author Nikolay Khabarov
*/
#ifndef _COMMANDS_MAX31855_CMD_H_
#define _COMMANDS_MAX31855_CMD_H_
#include "user_config.h"
#if defined(DH_COMMANDS_MAX31855) && defined(DH_DEVICE_MAX31855)
#include "dhsender_data.h"
/**
* @brief Handle "devices/max31855/read" command.
*/
void dh_handle_devices_max31855_read(COMMAND_RESULT *cmd_res, const char *command,
const char *params, unsigned int params_len);
#endif /* DH_COMMANDS_MAX31855 && DH_DEVICE_MAX31855 */
#endif /* _COMMANDS_MAX31855_CMD_H_ */
|
baf955c44f3193aded8dd97e0ac098bb376159fa
|
2185ff77ca9a5bd22a15e407696a62df9c217e24
|
/web.h
|
b04bc179d9b58a1c5b03cdeae4d2ed3405fb8233
|
[
"BSD-2-Clause",
"LicenseRef-scancode-public-domain",
"MIT",
"BSD-3-Clause"
] |
permissive
|
sysprog21/lab0-c
|
bf3dcbfa585ec307b399e739e4265b1525f6afeb
|
8434ba3db3d4d2b8e1532fd9c5655c6bd1b26688
|
refs/heads/master
| 2023-08-16T15:49:09.907503
| 2023-08-12T03:57:33
| 2023-08-12T03:57:33
| 149,674,932
| 377
| 1,533
|
NOASSERTION
| 2023-08-12T03:57:34
| 2018-09-20T21:53:05
|
C
|
UTF-8
|
C
| false
| false
| 193
|
h
|
web.h
|
#ifndef TINYWEB_H
#define TINYWEB_H
#include <netinet/in.h>
int web_open(int port);
char *web_recv(int fd, struct sockaddr_in *clientaddr);
void web_send(int out_fd, char *buffer);
#endif
|
16cccee117f98ff004474dfa9904e7bcd22d9122
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/native_client/src/trusted/service_runtime/arch/x86_32/nacl_tls_32.c
|
6f53718843698e59af18975e8595ae1db6afcae0
|
[
"BSD-3-Clause",
"Zlib",
"Classpath-exception-2.0",
"BSD-Source-Code",
"LZMA-exception",
"LicenseRef-scancode-unicode",
"LGPL-3.0-only",
"LGPL-2.0-or-later",
"LicenseRef-scancode-philippe-de-muyter",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-intel-osl-1993",
"HPND-sell-variant",
"ICU",
"LicenseRef-scancode-protobuf",
"bzip2-1.0.6",
"Spencer-94",
"NCSA",
"LicenseRef-scancode-nilsson-historical",
"CC0-1.0",
"LicenseRef-scancode-proprietary-license",
"LGPL-2.1-only",
"LicenseRef-scancode-other-copyleft",
"GPL-2.0-or-later",
"NTP",
"GPL-2.0-only",
"LicenseRef-scancode-other-permissive",
"GPL-3.0-only",
"GFDL-1.1-only",
"W3C",
"LicenseRef-scancode-python-cwi",
"GCC-exception-3.1",
"BSL-1.0",
"Python-2.0",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"LicenseRef-scancode-unknown-license-reference",
"CPL-1.0",
"GFDL-1.1-or-later",
"W3C-19980720",
"LGPL-2.0-only",
"LicenseRef-scancode-amd-historical",
"LicenseRef-scancode-ietf",
"SAX-PD",
"LicenseRef-scancode-x11-hanson",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"dtoa",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer",
"PSF-2.0",
"LicenseRef-scancode-newlib-historical",
"LicenseRef-scancode-generic-exception",
"SMLNJ",
"HP-1986",
"LicenseRef-scancode-free-unknown",
"SunPro",
"MPL-1.1"
] |
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
| 2,952
|
c
|
nacl_tls_32.c
|
/*
* Copyright (c) 2012 The Native Client 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 "native_client/src/include/build_config.h"
#include "native_client/src/include/portability.h"
#include "native_client/src/shared/platform/nacl_check.h"
#include "native_client/src/trusted/service_runtime/arch/x86/nacl_ldt_x86.h"
#include "native_client/src/trusted/service_runtime/nacl_app_thread.h"
#include "native_client/src/trusted/service_runtime/nacl_tls.h"
#include "native_client/src/trusted/service_runtime/sel_ldr.h"
int NaClTlsInit(void) {
return NaClLdtInit();
}
void NaClTlsFini(void) {
NaClLdtFini();
}
uint32_t NaClTlsAllocate(struct NaClAppThread *natp) {
/*
* Initialize these so that untrusted code cannot read uninitialized
* values from the %gs segment.
*/
natp->user.gs_segment.new_prog_ctr = 0;
natp->user.gs_segment.new_ecx = 0;
return (uint32_t) NaClLdtAllocateByteSelector(NACL_LDT_DESCRIPTOR_DATA,
/* read_exec_only= */ 1,
&natp->user.gs_segment,
sizeof(natp->user.gs_segment));
}
void NaClTlsFree(struct NaClAppThread *natp) {
NaClLdtDeleteSelector(natp->user.gs);
}
void NaClTlsSetTlsValue1(struct NaClAppThread *natp, uint32_t value) {
natp->user.gs_segment.tls_value1 = value;
}
void NaClTlsSetTlsValue2(struct NaClAppThread *natp, uint32_t value) {
natp->user.gs_segment.tls_value2 = value;
}
uint32_t NaClTlsGetTlsValue1(struct NaClAppThread *natp) {
return natp->user.gs_segment.tls_value1;
}
uint32_t NaClTlsGetTlsValue2(struct NaClAppThread *natp) {
return natp->user.gs_segment.tls_value2;
}
uint32_t NaClGetThreadIdx(struct NaClAppThread *natp) {
return natp->user.gs >> 3;
}
#if NACL_LINUX
/*
* This TLS variable mirrors nacl_current_thread in the x86-64 sandbox,
* except that, on x86-32, we only use it for getting the identity of
* the interrupted thread in a signal handler in the Linux
* implementation of thread suspension.
*
* We should not enable this code on Windows because TLS variables do
* not work inside dynamically-loaded DLLs -- such as chrome.dll -- on
* Windows XP.
*/
static THREAD struct NaClThreadContext *nacl_current_thread;
void NaClTlsSetCurrentThread(struct NaClAppThread *natp) {
nacl_current_thread = &natp->user;
}
struct NaClAppThread *NaClTlsGetCurrentThread(void) {
return NaClAppThreadFromThreadContext(nacl_current_thread);
}
#else
/*
* This is a NOOP, since TLS (or TSD) is not used to keep the thread
* index on the x86-32. We use segmentation (%gs) to provide access
* to the per-thread data, and the segment selector itself tells us
* the thread's identity.
*/
void NaClTlsSetCurrentThread(struct NaClAppThread *natp) {
UNREFERENCED_PARAMETER(natp);
}
#endif
|
fefbc77b0be8586eb2b7a72e2434f90eb7d98495
|
fff6d13af91db925a94b3e3474108fafd519bba0
|
/src/Cog/jkCog.h
|
432ee5776d335191433e6b0d065d21ed5dc98c02
|
[
"LicenseRef-scancode-warranty-disclaimer"
] |
no_license
|
shinyquagsire23/OpenJKDF2
|
94f1364628924ac944466107606b91c6faeec3df
|
b79b8c210878b6f276ed3d1a5dad91d9219e6ce1
|
refs/heads/master
| 2023-07-08T16:41:38.986577
| 2023-06-28T08:47:39
| 2023-06-28T08:47:39
| 139,542,792
| 381
| 34
|
NOASSERTION
| 2023-06-28T08:47:40
| 2018-07-03T07:09:45
|
C
|
UTF-8
|
C
| false
| false
| 215
|
h
|
jkCog.h
|
#ifndef _JKCOG_H
#define _JKCOG_H
#include "types.h"
#include "globals.h"
#include "sithCog.h"
void jkCog_RegisterVerbs();
int jkCog_Startup();
void jkCog_Shutdown();
int jkCog_StringsInit();
#endif // _JKCOG_H
|
e8cad6653b1aa04d60be962c45636c37d7f4dbda
|
e814383d36a10839104efaa4df277996ab220fa3
|
/ompi/mpiext/mpiext.h
|
e5488cdc35799f285a39c2365a9d14d287be17b7
|
[
"mpich2",
"BSD-3-Clause-Open-MPI"
] |
permissive
|
open-mpi/ompi
|
a1d7483ae1d83dd8fd8ae3ee95e832e0a0ee04e3
|
1edfdb025c4450f694600083ad871cf06c8d45cd
|
refs/heads/main
| 2023-09-01T01:30:02.040705
| 2023-08-29T17:32:18
| 2023-08-29T17:32:18
| 24,107,001
| 2,008
| 973
|
NOASSERTION
| 2023-09-14T20:59:26
| 2014-09-16T16:08:30
|
C
|
UTF-8
|
C
| false
| false
| 693
|
h
|
mpiext.h
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2018 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
#include "ompi_config.h"
OMPI_DECLSPEC int ompi_mpiext_init(void);
typedef int (*ompi_mpiext_init_fn_t)(void);
typedef int (*ompi_mpiext_fini_fn_t)(void);
struct ompi_mpiext_component_t {
ompi_mpiext_init_fn_t init;
ompi_mpiext_fini_fn_t fini;
};
typedef struct ompi_mpiext_component_t ompi_mpiext_component_t;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
|
63122ac8717f742bfcd781a771ec997389e7563d
|
bec0383f2afd255a72afeb9049a898615e547327
|
/src/script/script_flags.h
|
7571d2f397c928552bf9e9c322429109def460e8
|
[
"MIT"
] |
permissive
|
Bitcoin-ABC/bitcoin-abc
|
a73024a513be2c9c419f8bece06dbadde2af3fb7
|
57176a00e4d660487c41b92207da4bf27e5c0026
|
refs/heads/master
| 2023-09-04T11:26:24.295624
| 2023-09-01T14:24:40
| 2023-09-04T05:20:03
| 89,913,655
| 1,359
| 768
|
MIT
| 2023-07-19T16:41:26
| 2017-05-01T09:58:15
|
C++
|
UTF-8
|
C
| false
| false
| 4,465
|
h
|
script_flags.h
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2016 The Bitcoin Core developers
// Copyright (c) 2017-2020 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_SCRIPT_SCRIPT_FLAGS_H
#define BITCOIN_SCRIPT_SCRIPT_FLAGS_H
/** Script verification flags */
enum {
SCRIPT_VERIFY_NONE = 0,
// Evaluate P2SH subscripts (softfork safe, BIP16).
// Note: The Segwit Recovery feature is an exception to P2SH
SCRIPT_VERIFY_P2SH = (1U << 0),
// Passing a non-strict-DER signature or one with undefined hashtype to a
// checksig operation causes script failure. Evaluating a pubkey that is not
// (0x04 + 64 bytes) or (0x02 or 0x03 + 32 bytes) by checksig causes script
// failure.
SCRIPT_VERIFY_STRICTENC = (1U << 1),
// Passing a non-strict-DER signature to a checksig operation causes script
// failure (BIP62 rule 1)
SCRIPT_VERIFY_DERSIG = (1U << 2),
// Passing a non-strict-DER signature or one with S > order/2 to a checksig
// operation causes script failure
// (BIP62 rule 5).
SCRIPT_VERIFY_LOW_S = (1U << 3),
// Using a non-push operator in the scriptSig causes script failure
// (BIP62 rule 2).
SCRIPT_VERIFY_SIGPUSHONLY = (1U << 5),
// Require minimal encodings for all push operations (OP_0... OP_16,
// OP_1NEGATE where possible, direct pushes up to 75 bytes, OP_PUSHDATA up
// to 255 bytes, OP_PUSHDATA2 for anything larger). Evaluating any other
// push causes the script to fail (BIP62 rule 3). In addition, whenever a
// stack element is interpreted as a number, it must be of minimal length
// (BIP62 rule 4).
SCRIPT_VERIFY_MINIMALDATA = (1U << 6),
// Discourage use of NOPs reserved for upgrades (NOP1-10)
//
// Provided so that nodes can avoid accepting or mining transactions
// containing executed NOP's whose meaning may change after a soft-fork,
// thus rendering the script invalid; with this flag set executing
// discouraged NOPs fails the script. This verification flag will never be a
// mandatory flag applied to scripts in a block. NOPs that are not executed,
// e.g. within an unexecuted IF ENDIF block, are *not* rejected.
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS = (1U << 7),
// Require that only a single stack element remains after evaluation. This
// changes the success criterion from "At least one stack element must
// remain, and when interpreted as a boolean, it must be true" to "Exactly
// one stack element must remain, and when interpreted as a boolean, it must
// be true".
// (BIP62 rule 6)
// Note: CLEANSTACK should never be used without P2SH.
// Note: The Segwit Recovery feature is an exception to CLEANSTACK
SCRIPT_VERIFY_CLEANSTACK = (1U << 8),
// Verify CHECKLOCKTIMEVERIFY
//
// See BIP65 for details.
SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9),
// support CHECKSEQUENCEVERIFY opcode
//
// See BIP112 for details
SCRIPT_VERIFY_CHECKSEQUENCEVERIFY = (1U << 10),
// Require the argument of OP_IF/NOTIF to be exactly 0x01 or empty vector
//
SCRIPT_VERIFY_MINIMALIF = (1U << 13),
// Signature(s) must be empty vector if an CHECK(MULTI)SIG operation failed
//
SCRIPT_VERIFY_NULLFAIL = (1U << 14),
// Do we accept signature using SIGHASH_FORKID
//
SCRIPT_ENABLE_SIGHASH_FORKID = (1U << 16),
// Do we accept activate replay protection using a different fork id.
//
SCRIPT_ENABLE_REPLAY_PROTECTION = (1U << 17),
// The exception to CLEANSTACK and P2SH for the recovery of coins sent
// to p2sh segwit addresses is not allowed.
SCRIPT_DISALLOW_SEGWIT_RECOVERY = (1U << 20),
// Whether to allow new OP_CHECKMULTISIG logic to trigger. (new multisig
// logic verifies faster, and only allows Schnorr signatures)
SCRIPT_ENABLE_SCHNORR_MULTISIG = (1U << 21),
// Require the number of sigchecks in an input to satisfy a specific
// bound, defined by scriptSig length.
// Note: The Segwit Recovery feature is a (currently moot) exception to
// VERIFY_INPUT_SIGCHECKS
SCRIPT_VERIFY_INPUT_SIGCHECKS = (1U << 22),
// A utility flag to decide whether we must enforce sigcheck limits.
SCRIPT_ENFORCE_SIGCHECKS = (1U << 23),
};
#endif // BITCOIN_SCRIPT_SCRIPT_FLAGS_H
|
2d732bf031541cda80a4e7baa251d7cc154bde70
|
99ecf2e42d663a4ab4abbe968e2dda7a34e23ec8
|
/src/p11kcv.c
|
ee41959d223bee21b19cd2c9a5894fbb1e8c2c44
|
[
"Apache-2.0"
] |
permissive
|
Mastercard/pkcs11-tools
|
de6a93f5baf650fc70d808b51e0fb60735850da2
|
d29802e8ee7b3f6d863231083788fd4d5d96d087
|
refs/heads/master
| 2023-09-01T06:59:29.438052
| 2023-08-18T07:04:19
| 2023-08-18T07:04:19
| 160,555,428
| 116
| 29
|
NOASSERTION
| 2023-09-08T14:08:04
| 2018-12-05T17:38:24
|
C
|
UTF-8
|
C
| false
| false
| 5,859
|
c
|
p11kcv.c
|
/* -*- mode: c; c-file-style:"stroustrup"; -*- */
/*
* Copyright (c) 2018 Mastercard
*
* 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 <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "pkcs11lib.h"
#ifdef _WIN32
#include <openssl/applink.c>
#endif
#define COMMAND_SUMMARY \
"Computes key check value for a symmetric key on PKCS#11 token.\n\n"
/* prototypes */
void print_version_info(char *progname);
void print_usage(char *);
int main( int argc, char **argv);
void print_usage(char *progname)
{
fprintf( stderr,
"USAGE: %s OPTIONS FILTERS\n"
"\n"
COMMAND_SUMMARY
"OPTIONS:\n"
"* -l <pkcs#11 library path> : path to PKCS#11 library\n"
" -m <NSS config dir> ( e.g. '.' or 'sql:.' ) : NSS db directory \n"
" -s <slot number>\n"
" -t <token label> : if present, -s option is ignored\n"
" -p <token PIN> | :::exec:<command> | :::nologin\n"
" -S : login with SO privilege\n"
" -b <len>: size of buffer to HMAC, for HMAC keys (max: %d, default: 0)\n"
" -h : print usage information\n"
" -V : print version information\n"
"|\n"
"+-> arguments marked with an asterix(*) are mandatory\n"
"| (except if environment variable sets the value)\n"
"+-> arguments marked with a plus sign(+) can be repeated\n"
"\n"
"FILTERS:\n"
" FILTER [FILTER ...]: object filter to match, of the form:\n"
" - TYPE\n"
" - [TYPE/[ATTRIBUTE/]]VALUE\n"
"\n"
" TYPE must be be 'seck'\n"
"\n"
" ATTRIBUTE is either:\n"
" - 'id', 'label' or 'sn'\n"
" - an actual PKCS#11 attribute name (e.g. CKA_ENCRYPT)\n"
" when omitted, default is 'label'\n"
"\n"
" VALUE is either:\n"
" - ASCII string\n"
" - {hexadecimal values} between curly braces\n"
"\n"
" ENVIRONMENT VARIABLES:\n"
" PKCS11LIB : path to PKCS#11 library,\n"
" overriden by option -l\n"
" PKCS11NSSDIR : NSS configuration directory directive,\n"
" overriden by option -m\n"
" PKCS11SLOT : token slot (integer)\n"
" overriden by PKCS11TOKENLABEL,\n"
" options -t or -s\n"
" PKCS11TOKENLABEL : token label\n"
" overriden by options -t or -s\n"
" PKCS11PASSWORD : password\n"
" overriden by option -p\n"
"\n"
, pkcs11_ll_basename(progname),
MAX_KCV_CLEARTEXT_SIZE);
exit( RC_ERROR_USAGE );
}
int main( int argc, char ** argv )
{
extern char *optarg;
extern int optind, optopt;
int argnum = 0;
int errflag = 0;
char * library = NULL;
char * nsscfgdir = NULL;
char * password = NULL;
char * slotenv = NULL;
int slot = -1;
int interactive = 1;
char * tokenlabel = NULL;
int so=0;
unsigned hmacdatasize = 0;
pkcs11Context * p11Context = NULL;
func_rc retcode = rc_error_usage;
library = getenv("PKCS11LIB");
nsscfgdir = getenv("PKCS11NSSDIR");
tokenlabel = getenv("PKCS11TOKENLABEL");
if(tokenlabel==NULL) {
slotenv = getenv("PKCS11SLOT");
if (slotenv!=NULL) {
slot=atoi(slotenv);
}
}
password = getenv("PKCS11PASSWORD");
/* get the command-line arguments */
while ( ( argnum = getopt( argc, argv, "l:m:p:s:t:Sb:hV" ) ) != -1 )
{
switch ( argnum )
{
case 'l' :
library = optarg;
break;
case 'm':
nsscfgdir = optarg;
break;
case 'p' :
password = optarg;
break;
case 's':
slot = atoi(optarg);
interactive = 0;
tokenlabel = NULL;
break;
case 't':
tokenlabel = optarg;
interactive = 0;
slot = -1;
break;
case 'b':
hmacdatasize=strtoul(optarg, NULL, 10);
break;
case 'S':
so=1;
break;
case 'h':
print_usage(argv[0]);
break;
case 'V':
print_version_info(argv[0]);
break;
default:
errflag++;
break;
}
}
if ( errflag ) {
fprintf(stderr, "Try `%s -h' for more information.\n", argv[0]);
goto err;
}
if ( library == NULL || optind==argc ) {
fprintf( stderr, "At least one required option or argument is wrong or missing.\n"
"Try `%s -h' for more information.\n", argv[0]);
goto err;
}
if((p11Context = pkcs11_newContext( library, nsscfgdir ))==NULL) {
goto err;
}
/* validate the given provider library exists and can be opened */
if (( retcode = pkcs11_initialize( p11Context ) ) != CKR_OK ) {
goto err;
}
retcode = pkcs11_open_session( p11Context, slot, tokenlabel, password, so, interactive);
if ( retcode == rc_ok )
{
while(optind<argc) {
pkcs11_display_kcv(p11Context, argv[optind++], hmacdatasize);
}
pkcs11_close_session( p11Context );
}
pkcs11_finalize( p11Context );
/* free allocated memory */
err:
pkcs11_freeContext(p11Context);
return retcode;
}
|
a42b3614a10c67edc471f10f224e9c29388d9e13
|
c0bfd93cd7f26a271268e504959256f1e02c6806
|
/components/esp8266/include/esp_private/esp_system_internal.h
|
ff468302b7f1755ff7726bb6acc72aaec1ad94cf
|
[
"Apache-2.0"
] |
permissive
|
espressif/ESP8266_RTOS_SDK
|
606f396e92d2675d9854f0fabd88587fbbbaf267
|
af0cdc36fa2600033d0a09301c754008cf1503c1
|
refs/heads/master
| 2023-08-24T22:40:15.373553
| 2023-05-06T02:04:24
| 2023-05-06T02:04:24
| 27,584,181
| 3,163
| 1,749
|
Apache-2.0
| 2023-08-09T10:48:13
| 2014-12-05T09:27:12
|
C
|
UTF-8
|
C
| false
| false
| 3,506
|
h
|
esp_system_internal.h
|
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// 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.
#pragma once
#include <stdint.h>
#include <esp_system.h>
#ifdef __cplusplus
extern "C" {
#endif
#define RTC_SYS_RAM_SIZE 256
#define ESP_SYSTEM_FAST_BOOT_IMAGE 0x5aa5a55a
/**
* @brief Station's AP base information of old SDK
*/
struct old_ap_ssid {
uint32_t len; //!< SSID length
uint8_t ssid[32]; //!< SSID data
uint8_t passwd[64]; //!< password data
} __attribute__((packed));
/**
* @brief System information of old SDK
*/
struct old_sysconf {
uint8_t reserved_1[0x13C]; //!< reserved data
uint8_t ap_number; //!< number of stored AP
uint8_t ap_index; //!< index of current used AP
uint8_t reserved_2[0x2]; //!< reserved data
struct old_ap_ssid ap_ssid[5]; //!< station's AP base information
} __attribute__((packed));
/**
* The size of structure must not be larger than 256 bytes and all member varible must be uint32_t type
*/
struct _rtc_sys_info {
uint32_t hint; // software reset reason
uint32_t old_sysconf_addr; /*<! old SDK system configuration parameters base address,
if your bootloader is older than v3.2, please don't use this */
struct {
uint32_t magic;
uint32_t image_start;
uint32_t image_size;
uint32_t image_entry;
uint32_t crc32;
} fast_boot;
};
/**
* @brief System information
*/
typedef struct esp_sys_info {
uint32_t version; //!< system version
uint32_t reserved[3]; //!< reserved data
} esp_sys_info_t;
_Static_assert(sizeof(esp_sys_info_t) == 16, "esp_sys_info_t should be 16 bytes");
extern struct _rtc_sys_info rtc_sys_info;
/**
* @brief Internal function to get SoC reset reason at system initialization
*/
void esp_reset_reason_init(void);
/**
* @brief Internal function to set reset reason hint
*
* The hint is used do distinguish different reset reasons when software reset
* is performed.
*
* The hint is stored in RTC store register, RTC_RESET_CAUSE_REG.
*
* @param hint Desired esp_reset_reason_t value for the real reset reason
*/
void esp_reset_reason_set_hint(esp_reset_reason_t hint);
/**
* @brief Get reason of last reset but not clear it for next reset
*
* @return See description of esp_reset_reason_t for explanation of each value.
*/
esp_reset_reason_t esp_reset_reason_early(void);
/**
* @brief Get old SDK configuration parameters base address
*
* @return 0 if it is not upgraded from old SDK or the absolute address of the flash
*/
uint32_t esp_get_old_sysconf_addr(void);
#ifdef __cplusplus
}
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.