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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ae2d09e61fceff523dd9423e2f8b16cfa3931e8b
|
336d3942e52ba91604d479e590a1e35d6d7c14a4
|
/deps/jemalloc/test/unit/decay.c
|
bdb6d0a3967e116ac6811fe84ec12fbac2ce7895
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
redis/redis
|
8fb932a09677ed8854c94d81c941655eceda2138
|
e792653753dc62b5a00822121e585511542a024b
|
refs/heads/unstable
| 2023-08-29T14:53:21.757052
| 2023-08-27T08:42:55
| 2023-08-27T08:42:55
| 156,018
| 19,822
| 6,754
|
BSD-3-Clause
| 2023-09-14T18:06:48
| 2009-03-21T22:32:25
|
C
|
UTF-8
|
C
| false
| false
| 8,576
|
c
|
decay.c
|
#include "test/jemalloc_test.h"
#include "jemalloc/internal/decay.h"
TEST_BEGIN(test_decay_init) {
decay_t decay;
memset(&decay, 0, sizeof(decay));
nstime_t curtime;
nstime_init(&curtime, 0);
ssize_t decay_ms = 1000;
assert_true(decay_ms_valid(decay_ms), "");
expect_false(decay_init(&decay, &curtime, decay_ms),
"Failed to initialize decay");
expect_zd_eq(decay_ms_read(&decay), decay_ms,
"Decay_ms was initialized incorrectly");
expect_u64_ne(decay_epoch_duration_ns(&decay), 0,
"Epoch duration was initialized incorrectly");
}
TEST_END
TEST_BEGIN(test_decay_ms_valid) {
expect_false(decay_ms_valid(-7),
"Misclassified negative decay as valid");
expect_true(decay_ms_valid(-1),
"Misclassified -1 (never decay) as invalid decay");
expect_true(decay_ms_valid(8943),
"Misclassified valid decay");
if (SSIZE_MAX > NSTIME_SEC_MAX) {
expect_false(
decay_ms_valid((ssize_t)(NSTIME_SEC_MAX * KQU(1000) + 39)),
"Misclassified too large decay");
}
}
TEST_END
TEST_BEGIN(test_decay_npages_purge_in) {
decay_t decay;
memset(&decay, 0, sizeof(decay));
nstime_t curtime;
nstime_init(&curtime, 0);
uint64_t decay_ms = 1000;
nstime_t decay_nstime;
nstime_init(&decay_nstime, decay_ms * 1000 * 1000);
expect_false(decay_init(&decay, &curtime, (ssize_t)decay_ms),
"Failed to initialize decay");
size_t new_pages = 100;
nstime_t time;
nstime_copy(&time, &decay_nstime);
expect_u64_eq(decay_npages_purge_in(&decay, &time, new_pages),
new_pages, "Not all pages are expected to decay in decay_ms");
nstime_init(&time, 0);
expect_u64_eq(decay_npages_purge_in(&decay, &time, new_pages), 0,
"More than zero pages are expected to instantly decay");
nstime_copy(&time, &decay_nstime);
nstime_idivide(&time, 2);
expect_u64_eq(decay_npages_purge_in(&decay, &time, new_pages),
new_pages / 2, "Not half of pages decay in half the decay period");
}
TEST_END
TEST_BEGIN(test_decay_maybe_advance_epoch) {
decay_t decay;
memset(&decay, 0, sizeof(decay));
nstime_t curtime;
nstime_init(&curtime, 0);
uint64_t decay_ms = 1000;
bool err = decay_init(&decay, &curtime, (ssize_t)decay_ms);
expect_false(err, "");
bool advanced;
advanced = decay_maybe_advance_epoch(&decay, &curtime, 0);
expect_false(advanced, "Epoch advanced while time didn't");
nstime_t interval;
nstime_init(&interval, decay_epoch_duration_ns(&decay));
nstime_add(&curtime, &interval);
advanced = decay_maybe_advance_epoch(&decay, &curtime, 0);
expect_false(advanced, "Epoch advanced after first interval");
nstime_add(&curtime, &interval);
advanced = decay_maybe_advance_epoch(&decay, &curtime, 0);
expect_true(advanced, "Epoch didn't advance after two intervals");
}
TEST_END
TEST_BEGIN(test_decay_empty) {
/* If we never have any decaying pages, npages_limit should be 0. */
decay_t decay;
memset(&decay, 0, sizeof(decay));
nstime_t curtime;
nstime_init(&curtime, 0);
uint64_t decay_ms = 1000;
uint64_t decay_ns = decay_ms * 1000 * 1000;
bool err = decay_init(&decay, &curtime, (ssize_t)decay_ms);
assert_false(err, "");
uint64_t time_between_calls = decay_epoch_duration_ns(&decay) / 5;
int nepochs = 0;
for (uint64_t i = 0; i < decay_ns / time_between_calls * 10; i++) {
size_t dirty_pages = 0;
nstime_init(&curtime, i * time_between_calls);
bool epoch_advanced = decay_maybe_advance_epoch(&decay,
&curtime, dirty_pages);
if (epoch_advanced) {
nepochs++;
expect_zu_eq(decay_npages_limit_get(&decay), 0,
"Unexpectedly increased npages_limit");
}
}
expect_d_gt(nepochs, 0, "Epochs never advanced");
}
TEST_END
/*
* Verify that npages_limit correctly decays as the time goes.
*
* During first 'nepoch_init' epochs, add new dirty pages.
* After that, let them decay and verify npages_limit decreases.
* Then proceed with another 'nepoch_init' epochs and check that
* all dirty pages are flushed out of backlog, bringing npages_limit
* down to zero.
*/
TEST_BEGIN(test_decay) {
const uint64_t nepoch_init = 10;
decay_t decay;
memset(&decay, 0, sizeof(decay));
nstime_t curtime;
nstime_init(&curtime, 0);
uint64_t decay_ms = 1000;
uint64_t decay_ns = decay_ms * 1000 * 1000;
bool err = decay_init(&decay, &curtime, (ssize_t)decay_ms);
assert_false(err, "");
expect_zu_eq(decay_npages_limit_get(&decay), 0,
"Empty decay returned nonzero npages_limit");
nstime_t epochtime;
nstime_init(&epochtime, decay_epoch_duration_ns(&decay));
const size_t dirty_pages_per_epoch = 1000;
size_t dirty_pages = 0;
uint64_t epoch_ns = decay_epoch_duration_ns(&decay);
bool epoch_advanced = false;
/* Populate backlog with some dirty pages */
for (uint64_t i = 0; i < nepoch_init; i++) {
nstime_add(&curtime, &epochtime);
dirty_pages += dirty_pages_per_epoch;
epoch_advanced |= decay_maybe_advance_epoch(&decay, &curtime,
dirty_pages);
}
expect_true(epoch_advanced, "Epoch never advanced");
size_t npages_limit = decay_npages_limit_get(&decay);
expect_zu_gt(npages_limit, 0, "npages_limit is incorrectly equal "
"to zero after dirty pages have been added");
/* Keep dirty pages unchanged and verify that npages_limit decreases */
for (uint64_t i = nepoch_init; i * epoch_ns < decay_ns; ++i) {
nstime_add(&curtime, &epochtime);
epoch_advanced = decay_maybe_advance_epoch(&decay, &curtime,
dirty_pages);
if (epoch_advanced) {
size_t npages_limit_new = decay_npages_limit_get(&decay);
expect_zu_lt(npages_limit_new, npages_limit,
"napges_limit failed to decay");
npages_limit = npages_limit_new;
}
}
expect_zu_gt(npages_limit, 0, "npages_limit decayed to zero earlier "
"than decay_ms since last dirty page was added");
/* Completely push all dirty pages out of the backlog */
epoch_advanced = false;
for (uint64_t i = 0; i < nepoch_init; i++) {
nstime_add(&curtime, &epochtime);
epoch_advanced |= decay_maybe_advance_epoch(&decay, &curtime,
dirty_pages);
}
expect_true(epoch_advanced, "Epoch never advanced");
npages_limit = decay_npages_limit_get(&decay);
expect_zu_eq(npages_limit, 0, "npages_limit didn't decay to 0 after "
"decay_ms since last bump in dirty pages");
}
TEST_END
TEST_BEGIN(test_decay_ns_until_purge) {
const uint64_t nepoch_init = 10;
decay_t decay;
memset(&decay, 0, sizeof(decay));
nstime_t curtime;
nstime_init(&curtime, 0);
uint64_t decay_ms = 1000;
uint64_t decay_ns = decay_ms * 1000 * 1000;
bool err = decay_init(&decay, &curtime, (ssize_t)decay_ms);
assert_false(err, "");
nstime_t epochtime;
nstime_init(&epochtime, decay_epoch_duration_ns(&decay));
uint64_t ns_until_purge_empty = decay_ns_until_purge(&decay, 0, 0);
expect_u64_eq(ns_until_purge_empty, DECAY_UNBOUNDED_TIME_TO_PURGE,
"Failed to return unbounded wait time for zero threshold");
const size_t dirty_pages_per_epoch = 1000;
size_t dirty_pages = 0;
bool epoch_advanced = false;
for (uint64_t i = 0; i < nepoch_init; i++) {
nstime_add(&curtime, &epochtime);
dirty_pages += dirty_pages_per_epoch;
epoch_advanced |= decay_maybe_advance_epoch(&decay, &curtime,
dirty_pages);
}
expect_true(epoch_advanced, "Epoch never advanced");
uint64_t ns_until_purge_all = decay_ns_until_purge(&decay,
dirty_pages, dirty_pages);
expect_u64_ge(ns_until_purge_all, decay_ns,
"Incorrectly calculated time to purge all pages");
uint64_t ns_until_purge_none = decay_ns_until_purge(&decay,
dirty_pages, 0);
expect_u64_eq(ns_until_purge_none, decay_epoch_duration_ns(&decay) * 2,
"Incorrectly calculated time to purge 0 pages");
uint64_t npages_threshold = dirty_pages / 2;
uint64_t ns_until_purge_half = decay_ns_until_purge(&decay,
dirty_pages, npages_threshold);
nstime_t waittime;
nstime_init(&waittime, ns_until_purge_half);
nstime_add(&curtime, &waittime);
decay_maybe_advance_epoch(&decay, &curtime, dirty_pages);
size_t npages_limit = decay_npages_limit_get(&decay);
expect_zu_lt(npages_limit, dirty_pages,
"npages_limit failed to decrease after waiting");
size_t expected = dirty_pages - npages_limit;
int deviation = abs((int)expected - (int)(npages_threshold));
expect_d_lt(deviation, (int)(npages_threshold / 2),
"After waiting, number of pages is out of the expected interval "
"[0.5 * npages_threshold .. 1.5 * npages_threshold]");
}
TEST_END
int
main(void) {
return test(
test_decay_init,
test_decay_ms_valid,
test_decay_npages_purge_in,
test_decay_maybe_advance_epoch,
test_decay_empty,
test_decay,
test_decay_ns_until_purge);
}
|
db506f96d2e95b3c0307dfa5f9f67083275660c3
|
fbe68d84e97262d6d26dd65c704a7b50af2b3943
|
/third_party/virtualbox/src/VBox/Frontends/VirtualBox/src/platform/darwin/DarwinKeyboard.h
|
0ad147527b52f1ff3c60a6c063c31c30b5213cad
|
[
"GPL-2.0-only",
"LicenseRef-scancode-unknown-license-reference",
"CDDL-1.0",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"GPL-2.0-or-later",
"MPL-1.0",
"LicenseRef-scancode-generic-exception",
"Apache-2.0",
"OpenSSL",
"MIT"
] |
permissive
|
thalium/icebox
|
c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb
|
6f78952d58da52ea4f0e55b2ab297f28e80c1160
|
refs/heads/master
| 2022-08-14T00:19:36.984579
| 2022-02-22T13:10:31
| 2022-02-22T13:10:31
| 190,019,914
| 585
| 109
|
MIT
| 2022-01-13T20:58:15
| 2019-06-03T14:18:12
|
C++
|
UTF-8
|
C
| false
| false
| 1,973
|
h
|
DarwinKeyboard.h
|
/* $Id: DarwinKeyboard.h $ */
/** @file
* VBox Qt GUI - Common GUI Library - Darwin Keyboard routines.
*
* @todo Move this up somewhere so that the two SDL GUIs can use this code too.
*/
/*
* Copyright (C) 2006-2017 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___DarwinKeyboard_h___
#define ___DarwinKeyboard_h___
#include <iprt/cdefs.h>
#include <CoreFoundation/CFBase.h>
RT_C_DECLS_BEGIN
/** Private hack for missing rightCmdKey enum. */
#define kEventKeyModifierRightCmdKeyMask (1<<27)
/** The scancode mask. */
#define VBOXKEY_SCANCODE_MASK 0x007f
/** Extended key. */
#define VBOXKEY_EXTENDED 0x0080
/** Modifier key. */
#define VBOXKEY_MODIFIER 0x0400
/** Lock key (like num lock and caps lock). */
#define VBOXKEY_LOCK 0x0800
unsigned DarwinKeycodeToSet1Scancode(unsigned uKeyCode);
UInt32 DarwinAdjustModifierMask(UInt32 fModifiers, const void *pvCocoaEvent);
unsigned DarwinModifierMaskToSet1Scancode(UInt32 fModifiers);
unsigned DarwinModifierMaskToDarwinKeycode(UInt32 fModifiers);
UInt32 DarwinKeyCodeToDarwinModifierMask(unsigned uKeyCode);
void DarwinDisableGlobalHotKeys(bool fDisable);
void DarwinGrabKeyboard(bool fGlobalHotkeys);
void DarwinReleaseKeyboard(void);
void * DarwinHidDevicesKeepLedsState(void);
int DarwinHidDevicesApplyAndReleaseLedsState(void *pState);
void DarwinHidDevicesBroadcastLeds(void *pState, bool fNumLockOn, bool fCapsLockOn, bool fScrollLockOn);
RT_C_DECLS_END
#endif
|
fb8981717b484355c2ea8b71833a85a02de54930
|
afcd5ef2409bcdb2384465b47f1c4483473a3144
|
/include/wincert.h
|
9a5953a5aae273791ae22f60e8c077a474f6cf15
|
[
"BSD-2-Clause"
] |
permissive
|
rhboot/shim
|
6f0d88edeb0a500a7a05ae9d898e88c6ab4c7580
|
7ba7440c49d32f911fb9e1c213307947a777085d
|
refs/heads/main
| 2023-09-04T07:51:32.121886
| 2023-08-22T16:43:02
| 2023-08-25T18:14:45
| 3,996,476
| 553
| 231
|
NOASSERTION
| 2023-09-06T11:38:23
| 2012-04-11T18:00:40
|
C
|
UTF-8
|
C
| false
| false
| 902
|
h
|
wincert.h
|
// SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef SHIM_WINCERT_H
#define SHIM_WINCERT_H
///
/// The WIN_CERTIFICATE structure is part of the PE/COFF specification.
///
typedef struct {
///
/// The length of the entire certificate,
/// including the length of the header, in bytes.
///
UINT32 dwLength;
///
/// The revision level of the WIN_CERTIFICATE
/// structure. The current revision level is 0x0200.
///
UINT16 wRevision;
///
/// The certificate type. See WIN_CERT_TYPE_xxx for the UEFI
/// certificate types. The UEFI specification reserves the range of
/// certificate type values from 0x0EF0 to 0x0EFF.
///
UINT16 wCertificateType;
///
/// The following is the actual certificate. The format of
/// the certificate depends on wCertificateType.
///
/// UINT8 bCertificate[ANYSIZE_ARRAY];
///
} WIN_CERTIFICATE;
#endif /* SHIM_WINCERT_H */
|
b1942023ae530c533c25570b5864aefe4c6c5404
|
cf35a104dabc3d3647df66aff9db32d18b002e1b
|
/lib/libstuff/event/xtime.c
|
f8cbb81c77103f4db144fb4d34b8d2e579101942
|
[
"MIT"
] |
permissive
|
0intro/wmii
|
ba2dff4be1a049c7d4475218a914585a3f810ab5
|
024f29d1058b58aa4ee6b956500a78f69355fb53
|
refs/heads/main
| 2023-07-11T18:08:43.660898
| 2023-06-25T18:57:45
| 2023-06-25T18:57:45
| 74,551,919
| 110
| 17
| null | null | null | null |
UTF-8
|
C
| false
| false
| 684
|
c
|
xtime.c
|
/* Copyright ©2006-2010 Kris Maglione <maglione.k at Gmail>
* See LICENSE file for license details.
*/
#include <stuff/x.h>
static int
findtime(Display *d, XEvent *e, XPointer v) {
Window *w;
w = (Window*)v;
if(e->type == PropertyNotify && e->xproperty.window == w->xid) {
event_xtime = e->xproperty.time;
return true;
}
return false;
}
long
event_updatextime(void) {
Window *w;
WinAttr wa;
XEvent e;
long l;
w = createwindow(&scr.root, Rect(0, 0, 1, 1), 0, InputOnly, &wa, 0);
XSelectInput(display, w->xid, PropertyChangeMask);
changeprop_long(w, "ATOM", "ATOM", &l, 0);
XIfEvent(display, &e, findtime, (void*)w);
destroywindow(w);
return event_xtime;
}
|
72c3005b5c44e0e731fe772780ca84fc6d65be4b
|
fb3b6e3000bb179374872d36cffdaaff96993623
|
/src/libnfc-nci/include/buildcfg.h
|
e46dda40aaac037deff7539d773521a3ce38b27e
|
[
"Apache-2.0"
] |
permissive
|
NXPNFCLinux/linux_libnfc-nci
|
3a12d862b9ffaca1a1ebdb529bd01524811596a5
|
449538e5e106666e5263afeaddacc5836fc23d3f
|
refs/heads/master
| 2023-07-07T12:19:52.297795
| 2023-05-22T12:59:33
| 2023-05-22T12:59:33
| 35,533,236
| 141
| 105
|
Apache-2.0
| 2022-07-21T07:09:51
| 2015-05-13T06:56:44
|
C
|
UTF-8
|
C
| false
| false
| 4,625
|
h
|
buildcfg.h
|
/******************************************************************************
*
* Copyright (C) 1999-2012 Broadcom 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.
*
******************************************************************************/
/******************************************************************************
*
* The original Work has been changed by NXP Semiconductors.
*
* Copyright (C) 2014 NXP Semiconductors
*
* 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 __BUILDCFG_H
#define __BUILDCFG_H
#include <string.h>
#include <memory.h>
#include <stdio.h>
#include "data_types.h"
#ifndef NFC_CONTORLLER_ID
#define NFC_CONTORLLER_ID (1)
#endif
#define BTE_APPL_MAX_USERIAL_DEV_NAME (256)
#ifdef BT_TRACE_VERBOSE
#undef BT_TRACE_VERBOSE
#endif
#define BT_TRACE_VERBOSE TRUE
#define TRACE_TASK_INCLUDED TRUE
#define GKI_BUF1_MAX 0
// 2 is in use
#if (NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
#define GKI_BUF3_MAX 70
#else
#define GKI_BUF3_MAX 30
#endif
#define GKI_BUF4_SIZE 2400
#define GKI_BUF4_MAX 30
#define GKI_BUF5_MAX 0
#define GKI_BUF6_MAX 0
#define GKI_BUF7_MAX 0
#define GKI_BUF8_MAX 0
#define GKI_BUF2_SIZE 660
#if (NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
#define GKI_BUF2_MAX 70
#else
#define GKI_BUF2_MAX 50
#endif
#define GKI_BUF0_SIZE 268
#define GKI_BUF0_MAX 40
#define NCI_BUF_POOL_ID GKI_POOL_ID_0
#if (NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
#define GKI_NUM_FIXED_BUF_POOLS 9
#else
#define GKI_NUM_FIXED_BUF_POOLS 4
#endif
#ifdef __cplusplus
extern "C" {
#endif
// +++from bte.h...
enum
{
/* BTE BBY */
/* J3 J4 SW3-3 SW3-2 SW3-1 */
/* -------------------------------------------- */
BTE_MODE_SERIAL_APP, /* OUT OUT OFF OFF OFF Sample serial port application */
BTE_MODE_APPL, /* IN OUT OFF OFF ON Target used with Tester through RPC */
BTE_MODE_RESERVED, /* OUT IN OFF ON OFF Reserved */
BTE_MODE_SAMPLE_APPS, /* IN IN OFF ON ON Sample applications (ICP/HSP) */
BTE_MODE_DONGLE, /* not yet supported ON OFF OFF Dongle mode */
BTE_MODE_APPL_PROTOCOL_TRACE, /* this is a fake mode do allow protocol tracing in application without rpc */
BTE_MODE_INVALID
};
/* Protocol trace mask */
extern UINT32 bte_proto_trace_mask;/* = 0xFFFFFFFF;*/
extern volatile UINT8 bte_target_mode;
// ---from bte.h...
extern UINT8 *scru_dump_hex (UINT8 *p, char *p_title, UINT32 len, UINT32 trace_layer, UINT32 trace_type);
extern void ScrLog(UINT32 trace_set_mask, const char *fmt_str, ...);
extern void DispNci (UINT8 *p, UINT16 len, BOOLEAN is_recv);
extern void downloadFirmwarePatchFile (UINT32 brcm_hw_id);
void ProtoDispAdapterDisplayNciPacket (UINT8* nciPacket, UINT16 nciPacketLen, BOOLEAN is_recv);
#define DISP_NCI ProtoDispAdapterDisplayNciPacket
#define LOGMSG_TAG_NAME "BrcmNfcNfa"
#ifndef _TIMEB
#define _TIMEB
struct _timeb
{
long time;
short millitm;
short timezone;
short dstflag;
};
void _ftime (struct _timeb*);
#endif
#ifdef __cplusplus
};
#endif
#endif
|
86ad7899f92f4d5cc8a96e3866670801780cc2e4
|
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
|
/lang/python39/patches/patch-Modules___ssl.c
|
d09de379d0f8857a3cd6299b458ed767505d5e83
|
[] |
no_license
|
NetBSD/pkgsrc
|
a0732c023519650ef821ab89c23ab6ab59e25bdb
|
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
|
refs/heads/trunk
| 2023-09-01T07:40:12.138283
| 2023-09-01T05:25:19
| 2023-09-01T05:25:19
| 88,439,572
| 321
| 138
| null | 2023-07-12T22:34:14
| 2017-04-16T20:04:15
| null |
UTF-8
|
C
| false
| false
| 623
|
c
|
patch-Modules___ssl.c
|
$NetBSD: patch-Modules___ssl.c,v 1.1 2021/05/20 06:56:43 triaxx Exp $
Fix build failure on FreeBSD 12.
From https://github.com/python/cpython/commit/3309113
--- Modules/_ssl.c.orig 2021-05-14 15:52:07.251636000 +0200
+++ Modules/_ssl.c 2021-05-14 15:52:37.012941000 +0200
@@ -151,6 +151,9 @@
* unless OpenSSL is compiled without the methods. It's the easiest way to
* make 1.0.2, 1.1.0, 1.1.1, and 3.0.0 happy without deprecation warnings.
*/
+#ifndef OPENSSL_NO_SSL3_METHOD
+extern const SSL_METHOD *SSLv3_method(void);
+#endif
#ifndef OPENSSL_NO_TLS1_METHOD
extern const SSL_METHOD *TLSv1_method(void);
#endif
|
0bb3ec71b0c3fd2b546a0bfd91de074f8df98a23
|
318094a1eb9189d171e687ff9ca2a17aa7fb992d
|
/src/canonical.h
|
56c8d5b8d594fa42e945792700f88e6c819bec9b
|
[
"MIT"
] |
permissive
|
ericgjackson/slumbot2019
|
340f0082d3abd63adca871853a11fbc4836271c4
|
2ed42b0c3984ef6b1a7b4aa6ba07d6c1725701c8
|
refs/heads/master
| 2023-08-04T17:01:04.148342
| 2023-08-01T19:54:58
| 2023-08-01T19:54:58
| 177,664,282
| 124
| 33
|
MIT
| 2021-10-03T22:18:40
| 2019-03-25T21:04:43
|
C++
|
UTF-8
|
C
| false
| false
| 378
|
h
|
canonical.h
|
#ifndef _CANONICAL_H_
#define _CANONICAL_H_
#include "cards.h"
void CanonicalizeCards(const Card *raw_board, const Card *raw_hole_cards, int max_street,
Card *canon_board, Card *canon_hole_cards, int *suit_mapping);
void CanonicalizeCards(const Card *raw_board, const Card *raw_hole_cards, int max_street,
Card *canon_board, Card *canon_hole_cards);
#endif
|
416bc366dcccbf104fed52293ded6d0356846e8a
|
e814383d36a10839104efaa4df277996ab220fa3
|
/ompi/mca/mtl/portals4/mtl_portals4_request.h
|
5644bd9192ac77de52094e3e3aabeb03922a7584
|
[
"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
| 4,608
|
h
|
mtl_portals4_request.h
|
/*
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2010-2012 Sandia National Laboratories. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef OMPI_MTL_PORTALS_REQUEST_H
#define OMPI_MTL_PORTALS_REQUEST_H
#include "ompi_config.h"
#include "opal/datatype/opal_convertor.h"
#include "opal/mca/timer/base/base.h"
#include "ompi/mca/mtl/mtl.h"
#include "mtl_portals4.h"
#include <portals4.h>
struct ompi_mtl_portals4_message_t;
struct ompi_mtl_portals4_pending_request_t;
typedef enum { portals4_req_isend,
portals4_req_send,
portals4_req_recv,
portals4_req_probe,
portals4_req_recv_short,
portals4_req_flowctl
} ompi_mtl_portals4_request_type_t;
struct ompi_mtl_portals4_base_request_t {
struct mca_mtl_request_t super;
ompi_mtl_portals4_request_type_t type;
int (*event_callback)(ptl_event_t *ev, struct ompi_mtl_portals4_base_request_t*);
};
typedef struct ompi_mtl_portals4_base_request_t ompi_mtl_portals4_base_request_t;
struct ompi_mtl_portals4_isend_request_t {
ompi_mtl_portals4_base_request_t super;
void *buffer_ptr;
ptl_handle_me_t me_h;
uint64_t opcount;
#if OMPI_MTL_PORTALS4_FLOW_CONTROL
struct ompi_mtl_portals4_pending_request_t *pending;
#endif
ptl_size_t length;
opal_atomic_int32_t pending_get;
opal_atomic_int32_t event_count;
};
typedef struct ompi_mtl_portals4_isend_request_t ompi_mtl_portals4_isend_request_t;
struct ompi_mtl_portals4_send_request_t {
ompi_mtl_portals4_isend_request_t super;
int retval;
volatile int complete;
};
typedef struct ompi_mtl_portals4_send_request_t ompi_mtl_portals4_send_request_t;
struct ompi_mtl_portals4_recv_request_t {
ompi_mtl_portals4_base_request_t super;
void *buffer_ptr;
ptl_handle_me_t me_h;
struct opal_convertor_t *convertor;
void *delivery_ptr;
size_t delivery_len;
volatile bool req_started;
opal_atomic_int32_t pending_reply;
#if OPAL_ENABLE_DEBUG
uint64_t opcount;
ptl_hdr_data_t hdr_data;
#endif
};
typedef struct ompi_mtl_portals4_recv_request_t ompi_mtl_portals4_recv_request_t;
struct ompi_mtl_portals4_rndv_get_frag_t {
opal_free_list_item_t super;
/* the recv request that's composed of these frags */
ompi_mtl_portals4_recv_request_t *request;
/* info extracted from the put_overflow event that is required to retry the rndv-get */
void *frag_start;
ptl_size_t frag_length;
ptl_process_t frag_target;
ptl_hdr_data_t frag_match_bits;
ptl_size_t frag_remote_offset;
/* the absolute time at which this frag times out */
opal_timer_t frag_abs_timeout_usec;
int (*event_callback)(ptl_event_t *ev, struct ompi_mtl_portals4_rndv_get_frag_t*);
#if OPAL_ENABLE_DEBUG
uint32_t frag_num;
#endif
};
typedef struct ompi_mtl_portals4_rndv_get_frag_t ompi_mtl_portals4_rndv_get_frag_t;
OBJ_CLASS_DECLARATION(ompi_mtl_portals4_rndv_get_frag_t);
struct ompi_mtl_portals4_recv_short_request_t {
ompi_mtl_portals4_base_request_t super;
struct ompi_mtl_portals4_recv_short_block_t *block;
};
typedef struct ompi_mtl_portals4_recv_short_request_t ompi_mtl_portals4_recv_short_request_t;
struct ompi_mtl_portals4_probe_request_t {
ompi_mtl_portals4_base_request_t super;
volatile int req_complete;
int found_match;
struct ompi_status_public_t status;
struct ompi_mtl_portals4_message_t *message;
};
typedef struct ompi_mtl_portals4_probe_request_t ompi_mtl_portals4_probe_request_t;
struct ompi_mtl_portals4_request_t {
union {
ompi_mtl_portals4_isend_request_t isend;
ompi_mtl_portals4_send_request_t send;
ompi_mtl_portals4_recv_request_t recv;
ompi_mtl_portals4_recv_short_request_t recv_short;
ompi_mtl_portals4_probe_request_t probe;
} u;
};
typedef struct ompi_mtl_portals4_request_t ompi_mtl_portals4_request_t;
#endif
|
0f7097adfd5e1081e7dd9e5cfa0f03d8fbbd058f
|
ecafcf4501aa0af63925fdae669ab09fa3949077
|
/tests/stream_test_helper.h
|
74af053efd905a5f5f9cf58f37c80b0c4c4ed299
|
[
"Apache-2.0"
] |
permissive
|
awslabs/aws-c-http
|
082753f9556bbd075da7c11cf39e4790f679a110
|
a36253d55279bb910a2fe1566061daa556dcd5ad
|
refs/heads/main
| 2023-09-04T11:20:27.332890
| 2023-09-01T20:29:34
| 2023-09-01T20:29:34
| 142,940,518
| 119
| 41
|
Apache-2.0
| 2023-09-01T20:29:35
| 2018-07-31T00:07:24
|
C
|
UTF-8
|
C
| false
| false
| 1,743
|
h
|
stream_test_helper.h
|
#ifndef AWS_HTTP_STREAM_TEST_HELPER_H
#define AWS_HTTP_STREAM_TEST_HELPER_H
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/http/request_response.h>
struct aws_http_connection;
struct aws_http_headers;
struct aws_http_message;
struct aws_http_stream;
struct client_stream_tester {
struct aws_allocator *alloc;
struct aws_http_stream *stream;
int response_status;
enum aws_http_header_block current_header_block;
/* Array of completed Informational (1xx) responses */
struct aws_http_message *info_responses[4];
size_t num_info_responses;
/* As Informational (1xx) headers arrive, they're buffered here.
* They copied into a new `info_responses` entry when the block is done */
struct aws_http_headers *current_info_headers;
/* Main header-block */
struct aws_http_headers *response_headers;
bool response_headers_done;
/* Trailing header-block */
struct aws_http_headers *response_trailer;
bool response_trailer_done;
struct aws_byte_buf response_body;
bool complete;
int on_complete_error_code;
/* Whether connection is open when on_complete fires */
bool on_complete_connection_is_open;
struct aws_http_stream_metrics metrics;
bool destroyed;
};
struct client_stream_tester_options {
struct aws_http_message *request;
struct aws_http_connection *connection;
};
int client_stream_tester_init(
struct client_stream_tester *tester,
struct aws_allocator *alloc,
const struct client_stream_tester_options *options);
void client_stream_tester_clean_up(struct client_stream_tester *tester);
#endif /* AWS_HTTP_STREAM_TEST_HELPER_H */
|
f22731a935df8b62482ffa102d704602fa4bad79
|
b36f34b6a24d019d624d1cc74f5b29062eef2ba4
|
/frameworks/cclua/src/lua-bindings/lua_cocos2d_types.h
|
bdcda8cf02e8443d1d83315b9cb4270b3e098a1e
|
[
"MIT"
] |
permissive
|
zhongfq/cocos-lua
|
f49c1639f2c9a2a7678f9ed67e58114986ac882f
|
c2cf0f36ac0f0c91fb3456b555cacd8e8587be46
|
refs/heads/main
| 2023-08-17T17:13:05.705639
| 2023-08-17T06:06:36
| 2023-08-17T06:06:36
| 192,316,318
| 165
| 63
|
MIT
| 2023-08-14T23:59:30
| 2019-06-17T09:27:37
|
C
|
UTF-8
|
C
| false
| false
| 1,963
|
h
|
lua_cocos2d_types.h
|
//
// AUTO BUILD, DON'T MODIFY!
//
#ifndef __AUTO_GEN_LUA_COCOS2D_TYPES_H__
#define __AUTO_GEN_LUA_COCOS2D_TYPES_H__
#include "cclua/cclua.h"
#include "cocos2d.h"
#include "ui/CocosGUI.h"
#include "network/WebSocket.h"
#include "lua-bindings/lua_conv_manual.h"
#if CC_USE_NAVMESH
#include "navmesh/CCNavMesh.h"
#endif
OLUA_BEGIN_DECLS
OLUA_LIB int luaopen_cocos2d_types(lua_State *L);
OLUA_END_DECLS
// cocos2d::Vec2
OLUA_LIB void olua_pack_object(lua_State *L, int idx, cocos2d::Vec2 *value);
OLUA_LIB int olua_unpack_object(lua_State *L, const cocos2d::Vec2 *value);
OLUA_LIB bool olua_canpack_object(lua_State *L, int idx, const cocos2d::Vec2 *);
// cocos2d::Vec3
OLUA_LIB void olua_pack_object(lua_State *L, int idx, cocos2d::Vec3 *value);
OLUA_LIB int olua_unpack_object(lua_State *L, const cocos2d::Vec3 *value);
OLUA_LIB bool olua_canpack_object(lua_State *L, int idx, const cocos2d::Vec3 *);
// cocos2d::Vec4
OLUA_LIB void olua_pack_object(lua_State *L, int idx, cocos2d::Vec4 *value);
OLUA_LIB int olua_unpack_object(lua_State *L, const cocos2d::Vec4 *value);
OLUA_LIB bool olua_canpack_object(lua_State *L, int idx, const cocos2d::Vec4 *);
// cocos2d::Size
OLUA_LIB void olua_pack_object(lua_State *L, int idx, cocos2d::Size *value);
OLUA_LIB int olua_unpack_object(lua_State *L, const cocos2d::Size *value);
OLUA_LIB bool olua_canpack_object(lua_State *L, int idx, const cocos2d::Size *);
// cocos2d::Bounds
OLUA_LIB void olua_pack_object(lua_State *L, int idx, cocos2d::Bounds *value);
OLUA_LIB int olua_unpack_object(lua_State *L, const cocos2d::Bounds *value);
OLUA_LIB bool olua_canpack_object(lua_State *L, int idx, const cocos2d::Bounds *);
// cocos2d::ccBezierConfig
OLUA_LIB void olua_pack_object(lua_State *L, int idx, cocos2d::ccBezierConfig *value);
OLUA_LIB int olua_unpack_object(lua_State *L, const cocos2d::ccBezierConfig *value);
OLUA_LIB bool olua_canpack_object(lua_State *L, int idx, const cocos2d::ccBezierConfig *);
#endif
|
70d372e716d562f80ec5eed90e1d7aebfa911909
|
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
|
/x11/xcolors/patches/patch-xcolors.c
|
b6a1fa764d7b4fd8979db3a59e44775e389a2981
|
[] |
no_license
|
NetBSD/pkgsrc
|
a0732c023519650ef821ab89c23ab6ab59e25bdb
|
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
|
refs/heads/trunk
| 2023-09-01T07:40:12.138283
| 2023-09-01T05:25:19
| 2023-09-01T05:25:19
| 88,439,572
| 321
| 138
| null | 2023-07-12T22:34:14
| 2017-04-16T20:04:15
| null |
UTF-8
|
C
| false
| false
| 1,304
|
c
|
patch-xcolors.c
|
$NetBSD: patch-xcolors.c,v 1.1 2013/01/17 16:06:49 joerg Exp $
--- xcolors.c.orig 2013-01-16 14:05:59.000000000 +0000
+++ xcolors.c
@@ -26,12 +26,16 @@ static char*id="$XConsortium: xcolors.c,
#include <X11/Xaw/Label.h>
#include <stdio.h>
#include <ctype.h>
+#include <stdlib.h>
#include <math.h> /* for sqrt() */
#ifndef RGB_TXT
#define RGB_TXT "/usr/lib/X11/rgb.txt"
#endif
+static int l_strcasecmp(char *s1, char *s2);
+static void colordemo(Widget parent, char *startcolor, XColor nearcolor, int maxdist);
+
String fallback_resources[] = {
"*Label.Font: 5x7",
"*panes.Width: 985",
@@ -274,11 +278,7 @@ main(argc, argv)
/* NOTREACHED */
}
-colordemo(parent, startcolor, nearcolor, maxdist)
- Widget parent;
- char *startcolor;
- XColor nearcolor; /* scaled 0-255 */
- int maxdist;
+static void colordemo(Widget parent, char *startcolor, XColor nearcolor, int maxdist)
{
int r, g, b, prev_r, prev_g, prev_b;
char rgb_line[100];
@@ -373,9 +373,8 @@ do_color(parent, colorname)
* Similar to strcmp, but ignores case.
* Always returns 1 if different.
*/
-int
-l_strcasecmp(s1, s2)
- char *s1, *s2;
+static int
+l_strcasecmp(char *s1, char *s2)
{
for ( ; *s1 && *s2 ; s1++, s2++)
if ((isupper(*s1) ? tolower(*s1) : *s1) !=
|
a4fccc4929297fb93cb20404705b93837be30fc5
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/libs/libc/stdio/lib_libstream.c
|
be6a2a1c02115d5f945e88734801bba39a6ea582
|
[
"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
| 4,462
|
c
|
lib_libstream.c
|
/****************************************************************************
* libs/libc/stdio/lib_libstream.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include <nuttx/sched.h>
#include <nuttx/fs/fs.h>
#include <nuttx/lib/lib.h>
#include <nuttx/tls.h>
#include "libc.h"
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: lib_stream_initialize
*
* Description:
* This function is called when a new task is allocated. It initializes
* the streamlist instance that is stored in the task group.
*
****************************************************************************/
void lib_stream_initialize(FAR struct task_group_s *group)
{
FAR struct streamlist *list;
DEBUGASSERT(group && group->tg_info);
list = &group->tg_info->ta_streamlist;
/* Initialize the list access mutex */
nxmutex_init(&list->sl_lock);
list->sl_head = NULL;
list->sl_tail = NULL;
/* Initialize stdin, stdout and stderr stream */
list->sl_std[0].fs_fd = -1;
nxrmutex_init(&list->sl_std[0].fs_lock);
list->sl_std[1].fs_fd = -1;
nxrmutex_init(&list->sl_std[1].fs_lock);
list->sl_std[2].fs_fd = -1;
nxrmutex_init(&list->sl_std[2].fs_lock);
}
/****************************************************************************
* Name: lib_stream_release
*
* Description:
* This function is called when a TCB is destroyed. Note that it does not
* close the files by releasing the inode. That happens separately when
* the file descriptor list is freed.
*
****************************************************************************/
void lib_stream_release(FAR struct task_group_s *group)
{
FAR struct streamlist *list;
DEBUGASSERT(group && group->tg_info);
list = &group->tg_info->ta_streamlist;
/* Destroy the mutex and release the filelist */
nxmutex_destroy(&list->sl_lock);
/* Release each stream in the list */
list->sl_tail = NULL;
while (list->sl_head != NULL)
{
FAR struct file_struct *stream = list->sl_head;
list->sl_head = stream->fs_next;
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
/* Destroy the mutex that protects the IO buffer */
nxrmutex_destroy(&stream->fs_lock);
#endif
/* Release the stream */
#ifdef CONFIG_BUILD_KERNEL
/* If the exiting group is unprivileged, then it has an address
* environment. Don't bother to release the memory in this case...
* There is no point since the memory lies in the user heap which
* will be destroyed anyway. But if this is a privileged group,
* when we still have to release the memory using the kernel
* allocator.
*/
if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0)
#endif
{
group_free(group, stream);
}
}
/* Destroy stdin, stdout and stderr stream */
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
nxrmutex_destroy(&list->sl_std[0].fs_lock);
nxrmutex_destroy(&list->sl_std[1].fs_lock);
nxrmutex_destroy(&list->sl_std[2].fs_lock);
#endif
}
#endif /* CONFIG_BUILD_FLAT || __KERNEL__ */
|
f10c5553bcd744b7a1c34f774079c81d7bc5b16f
|
1661c43eaf9e44dfe7cce269cfaae62e336036f1
|
/test/func/fstatat_at_empty_path.c
|
a31dad62485ff42e90a044996394c4c3e97c8f5c
|
[] |
permissive
|
jart/blink
|
3354eaf084e3e85a50372f1a93fc75ff2b9488b1
|
312a027d0908c1b1f9d1e9ebba837da569606b82
|
refs/heads/master
| 2023-08-31T21:30:40.551686
| 2023-08-22T15:42:44
| 2023-08-22T15:42:44
| 561,183,031
| 6,089
| 192
|
ISC
| 2023-08-22T15:42:46
| 2022-11-03T06:07:09
|
C
|
UTF-8
|
C
| false
| false
| 402
|
c
|
fstatat_at_empty_path.c
|
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
struct stat st;
char path[] = "/tmp/blink.test.XXXXXX";
if (mkstemp(path) != 3) return 1;
if (unlink(path)) return 2;
if (write(3, "hi", 2) != 2) return 3;
if (fstatat(3, "", &st, AT_EMPTY_PATH)) return 4;
if (st.st_size != 2) return 5;
return 0;
}
|
17ccf5471df29980a7f0627ece5a3a17c52ea3de
|
0577a46d8d28e1fd8636893bbdd2b18270bb8eb8
|
/chromium/device/bluetooth/bluetooth_low_energy_defs_win.h
|
32bcc1a979ae36a56158ec99c5e4fc9ba10eeeb6
|
[
"BSD-3-Clause"
] |
permissive
|
ric2b/Vivaldi-browser
|
388a328b4cb838a4c3822357a5529642f86316a5
|
87244f4ee50062e59667bf8b9ca4d5291b6818d7
|
refs/heads/master
| 2022-12-21T04:44:13.804535
| 2022-12-17T16:30:35
| 2022-12-17T16:30:35
| 86,637,416
| 166
| 41
|
BSD-3-Clause
| 2021-03-31T18:49:30
| 2017-03-29T23:09:05
| null |
UTF-8
|
C
| false
| false
| 1,061
|
h
|
bluetooth_low_energy_defs_win.h
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEFS_WIN_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEFS_WIN_H_
#include <windows.h>
#include <cfg.h>
#include <devpkey.h>
#include <ntverp.h> // For VER_PRODUCTBUILD
#include <setupapi.h>
#if VER_PRODUCTBUILD > 9600
// bthledef.h is fixed in the Windows 10 SDK and the extra pop then triggers a
// warning, so we skip it when VER_PRODUCTBUILD is > 9600 (8.1 SDK)
#include <bthledef.h>
#else
#pragma warning(push)
// bthledef.h in the Windows 8.1 SDK is buggy and contains
// #pragma pop
// which should be
// #pragma warning(pop)
// So, we disable the "unknown pragma" warning, then actually pop, and then pop
// our disabling of 4068.
#pragma warning(disable: 4068)
#include <bthledef.h>
#pragma warning(pop)
#pragma warning(pop)
#endif
#include <bluetoothapis.h>
#include <bluetoothleapis.h>
#endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEFS_WIN_H_
|
fbb842ec7a1d0996aa39e1e5e71f013744e075dc
|
e1d9c54e9925e30e388a255b53a93cccad0b94cb
|
/kubernetes/model/v1_ingress.h
|
5891ca740d0d350f52152dec9be5be5625e281dc
|
[
"Apache-2.0",
"curl"
] |
permissive
|
kubernetes-client/c
|
dd4fd8095485c083e0f40f2b48159b1609a6141b
|
5ac5ff25e9809a92a48111b1f77574b6d040b711
|
refs/heads/master
| 2023-08-13T10:51:03.702497
| 2023-08-07T19:18:32
| 2023-08-07T19:18:32
| 247,958,425
| 127
| 47
|
Apache-2.0
| 2023-09-07T20:07:00
| 2020-03-17T11:59:05
|
C
|
UTF-8
|
C
| false
| false
| 1,234
|
h
|
v1_ingress.h
|
/*
* v1_ingress.h
*
* Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend. An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.
*/
#ifndef _v1_ingress_H_
#define _v1_ingress_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
typedef struct v1_ingress_t v1_ingress_t;
#include "v1_ingress_spec.h"
#include "v1_ingress_status.h"
#include "v1_object_meta.h"
typedef struct v1_ingress_t {
char *api_version; // string
char *kind; // string
struct v1_object_meta_t *metadata; //model
struct v1_ingress_spec_t *spec; //model
struct v1_ingress_status_t *status; //model
} v1_ingress_t;
v1_ingress_t *v1_ingress_create(
char *api_version,
char *kind,
v1_object_meta_t *metadata,
v1_ingress_spec_t *spec,
v1_ingress_status_t *status
);
void v1_ingress_free(v1_ingress_t *v1_ingress);
v1_ingress_t *v1_ingress_parseFromJSON(cJSON *v1_ingressJSON);
cJSON *v1_ingress_convertToJSON(v1_ingress_t *v1_ingress);
#endif /* _v1_ingress_H_ */
|
9406d80d09442fc349b2ce3caf692c9a340566d3
|
317410b28757af216145d23259d63fc96d07f613
|
/cpu/br25/audio_common/audio_iis.h
|
bdf84a80b0cb9af29a114210a9c8c805bb10e3b1
|
[
"Apache-2.0"
] |
permissive
|
Jieli-Tech/fw-AC63_BT_SDK
|
48c757dca7e8000ec763bf5466583a4cd8c4a11c
|
393d63758081d56f0bf0a39ac596bee32c33d493
|
refs/heads/master
| 2023-07-18T02:14:56.187266
| 2023-06-21T03:14:20
| 2023-06-21T03:14:20
| 272,586,610
| 113
| 76
|
Apache-2.0
| 2022-10-20T23:07:31
| 2020-06-16T02:02:15
|
C
|
UTF-8
|
C
| false
| false
| 695
|
h
|
audio_iis.h
|
#ifndef _AUDIO_IIS_H_
#define _AUDIO_IIS_H_
#include "audio_link.h"
extern void *audio_iis_output_start(ALINK_PORT port, u8 ch);
extern void audio_iis_output_stop(ALINK_PORT port);
extern int audio_iis_output_write(s16 *data, u32 len);
extern void audio_iis_output_set_srI(u32 sample_rate);
extern int audio_iis_output_sync_write(s16 *data, u32 len, u8 data_sync);
extern int audio_iis_channel_sync_enable(struct audio_sample_sync *samp_sync);
extern int audio_iis_channel_sync_disable(struct audio_sample_sync *samp_sync);
extern void audio_iis_input_start(ALINK_PORT port, u8 ch, void (*handle)(u8 ch, s16 *buf, u32 len));
extern void audio_iis_input_stop(ALINK_PORT port, u8 ch);
#endif
|
41766b1a7ecc0027fe9581bfd8781c896feb2e3a
|
67305fcba68fdf469862aed2959ad1dd5b22a536
|
/examples/19_iot_mqtt/applications/main.c
|
7b1a6109c68aa0fb47f69fd47470732810edf2e9
|
[
"Apache-2.0"
] |
permissive
|
RT-Thread/IoT_Board
|
cdabf100a8d515fbcaa65ab0b72ec67acb0d2c9a
|
2d218a4e06f06dbb356ec00767904f91d00db7cc
|
refs/heads/master
| 2023-09-04T16:51:34.485240
| 2022-01-19T01:26:16
| 2022-01-19T01:26:16
| 161,133,933
| 344
| 238
|
Apache-2.0
| 2023-06-06T04:10:57
| 2018-12-10T07:21:46
|
C
|
UTF-8
|
C
| false
| false
| 5,136
|
c
|
main.c
|
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-01 ZeroFree first implementation
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "paho_mqtt.h"
#include "wifi_config.h"
#include <wlan_mgnt.h>
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
/**
* MQTT URI farmat:
* domain mode
* tcp://iot.eclipse.org:1883
*
* ipv4 mode
* tcp://192.168.10.1:1883
* ssl://192.168.10.1:1884
*
* ipv6 mode
* tcp://[fe80::20c:29ff:fe9a:a07e]:1883
* ssl://[fe80::20c:29ff:fe9a:a07e]:1884
*/
#define MQTT_URI "tcp://iot.eclipse.org:1883"
#define MQTT_USERNAME "admin"
#define MQTT_PASSWORD "admin"
#define MQTT_SUBTOPIC "/mqtt/test/"
#define MQTT_PUBTOPIC "/mqtt/test/"
/* define MQTT client context */
static MQTTClient client;
static void mq_start(void);
static void mq_publish(const char *send_str);
char sup_pub_topic[48] = {0};
int main(void)
{
/* 注册 wlan 回调函数 */
rt_wlan_register_event_handler(RT_WLAN_EVT_READY, (void (*)(int, struct rt_wlan_buff *, void *))mq_start, RT_NULL);
/* 初始化自动连接功能 */
wlan_autoconnect_init();
/* 使能 wlan 自动连接 */
rt_wlan_config_autoreconnect(RT_TRUE);
}
static void mqtt_sub_callback(MQTTClient *c, MessageData *msg_data)
{
*((char *)msg_data->message->payload + msg_data->message->payloadlen) = '\0';
LOG_D("Topic: %.*s receive a message: %.*s",
msg_data->topicName->lenstring.len,
msg_data->topicName->lenstring.data,
msg_data->message->payloadlen,
(char *)msg_data->message->payload);
return;
}
static void mqtt_sub_default_callback(MQTTClient *c, MessageData *msg_data)
{
*((char *)msg_data->message->payload + msg_data->message->payloadlen) = '\0';
LOG_D("mqtt sub default callback: %.*s %.*s",
msg_data->topicName->lenstring.len,
msg_data->topicName->lenstring.data,
msg_data->message->payloadlen,
(char *)msg_data->message->payload);
return;
}
static void mqtt_connect_callback(MQTTClient *c)
{
LOG_I("Start to connect mqtt server");
}
static void mqtt_online_callback(MQTTClient *c)
{
LOG_D("Connect mqtt server success");
LOG_D("Publish message: Hello,RT-Thread! to topic: %s", sup_pub_topic);
mq_publish("Hello,RT-Thread!");
}
static void mqtt_offline_callback(MQTTClient *c)
{
LOG_I("Disconnect from mqtt server");
}
/* 创建与配置 mqtt 客户端 */
static void mq_start(void)
{
/* 初始 condata 参数 */
MQTTPacket_connectData condata = MQTTPacket_connectData_initializer;
static char cid[20] = {0};
static int is_started = 0;
if (is_started)
{
return;
}
/* 配置 MQTT 文本参数 */
{
client.isconnected = 0;
client.uri = MQTT_URI;
/* 生成随机客户端 ID */
rt_snprintf(cid, sizeof(cid), "rtthread%d", rt_tick_get());
rt_snprintf(sup_pub_topic, sizeof(sup_pub_topic), "%s%s", MQTT_PUBTOPIC, cid);
/* 配置连接参数 */
memcpy(&client.condata, &condata, sizeof(condata));
client.condata.clientID.cstring = cid;
client.condata.keepAliveInterval = 60;
client.condata.cleansession = 1;
client.condata.username.cstring = MQTT_USERNAME;
client.condata.password.cstring = MQTT_PASSWORD;
/* 配置 mqtt 参数 */
client.condata.willFlag = 0;
client.condata.will.qos = 1;
client.condata.will.retained = 0;
client.condata.will.topicName.cstring = sup_pub_topic;
client.buf_size = client.readbuf_size = 1024;
client.buf = malloc(client.buf_size);
client.readbuf = malloc(client.readbuf_size);
if (!(client.buf && client.readbuf))
{
LOG_E("no memory for MQTT client buffer!");
goto _exit;
}
/* 设置事件回调 */
client.connect_callback = mqtt_connect_callback;
client.online_callback = mqtt_online_callback;
client.offline_callback = mqtt_offline_callback;
/* 设置要订阅的 topic 和 topic 对应的回调函数 */
client.messageHandlers[0].topicFilter = sup_pub_topic;
client.messageHandlers[0].callback = mqtt_sub_callback;
client.messageHandlers[0].qos = QOS1;
/* 设置默认订阅回调函数 */
client.defaultMessageHandler = mqtt_sub_default_callback;
}
/* 启动 MQTT 客户端 */
LOG_D("Start mqtt client and subscribe topic:%s", sup_pub_topic);
paho_mqtt_start(&client);
is_started = 1;
_exit:
return;
}
/* MQTT 消息发布函数 */
static void mq_publish(const char *send_str)
{
MQTTMessage message;
const char *msg_str = send_str;
const char *topic = sup_pub_topic;
message.qos = QOS1;
message.retained = 0;
message.payload = (void *)msg_str;
message.payloadlen = strlen(message.payload);
MQTTPublish(&client, topic, &message);
return;
}
|
ce47c7e4834720a8cf21286b069c85d3064134e5
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/Infineon/libraries/IFX_PSOC6_HAL/mtb-pdl-cat1/devices/COMPONENT_CAT1A/include/ip/cyip_lpcomp.h
|
039ba903bc99065421696985af55dd3f3de5783d
|
[
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 8,521
|
h
|
cyip_lpcomp.h
|
/***************************************************************************//**
* \file cyip_lpcomp.h
*
* \brief
* LPCOMP IP definitions
*
********************************************************************************
* \copyright
* (c) (2016-2022), Cypress Semiconductor Corporation (an Infineon company) or
* an affiliate of Cypress Semiconductor Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#ifndef _CYIP_LPCOMP_H_
#define _CYIP_LPCOMP_H_
#include "cyip_headers.h"
/*******************************************************************************
* LPCOMP
*******************************************************************************/
#define LPCOMP_SECTION_SIZE 0x00010000UL
/**
* \brief Low Power Comparators (LPCOMP)
*/
typedef struct {
__IOM uint32_t CONFIG; /*!< 0x00000000 LPCOMP Configuration Register */
__IM uint32_t STATUS; /*!< 0x00000004 LPCOMP Status Register */
__IM uint32_t RESERVED[2];
__IOM uint32_t INTR; /*!< 0x00000010 LPCOMP Interrupt request register */
__IOM uint32_t INTR_SET; /*!< 0x00000014 LPCOMP Interrupt set register */
__IOM uint32_t INTR_MASK; /*!< 0x00000018 LPCOMP Interrupt request mask */
__IM uint32_t INTR_MASKED; /*!< 0x0000001C LPCOMP Interrupt request masked */
__IM uint32_t RESERVED1[8];
__IOM uint32_t CMP0_CTRL; /*!< 0x00000040 Comparator 0 control Register */
__IM uint32_t RESERVED2[3];
__IOM uint32_t CMP0_SW; /*!< 0x00000050 Comparator 0 switch control */
__IOM uint32_t CMP0_SW_CLEAR; /*!< 0x00000054 Comparator 0 switch control clear */
__IM uint32_t RESERVED3[10];
__IOM uint32_t CMP1_CTRL; /*!< 0x00000080 Comparator 1 control Register */
__IM uint32_t RESERVED4[3];
__IOM uint32_t CMP1_SW; /*!< 0x00000090 Comparator 1 switch control */
__IOM uint32_t CMP1_SW_CLEAR; /*!< 0x00000094 Comparator 1 switch control clear */
} LPCOMP_V1_Type; /*!< Size = 152 (0x98) */
/* LPCOMP.CONFIG */
#define LPCOMP_CONFIG_LPREF_EN_Pos 30UL
#define LPCOMP_CONFIG_LPREF_EN_Msk 0x40000000UL
#define LPCOMP_CONFIG_ENABLED_Pos 31UL
#define LPCOMP_CONFIG_ENABLED_Msk 0x80000000UL
/* LPCOMP.STATUS */
#define LPCOMP_STATUS_OUT0_Pos 0UL
#define LPCOMP_STATUS_OUT0_Msk 0x1UL
#define LPCOMP_STATUS_OUT1_Pos 16UL
#define LPCOMP_STATUS_OUT1_Msk 0x10000UL
/* LPCOMP.INTR */
#define LPCOMP_INTR_COMP0_Pos 0UL
#define LPCOMP_INTR_COMP0_Msk 0x1UL
#define LPCOMP_INTR_COMP1_Pos 1UL
#define LPCOMP_INTR_COMP1_Msk 0x2UL
/* LPCOMP.INTR_SET */
#define LPCOMP_INTR_SET_COMP0_Pos 0UL
#define LPCOMP_INTR_SET_COMP0_Msk 0x1UL
#define LPCOMP_INTR_SET_COMP1_Pos 1UL
#define LPCOMP_INTR_SET_COMP1_Msk 0x2UL
/* LPCOMP.INTR_MASK */
#define LPCOMP_INTR_MASK_COMP0_MASK_Pos 0UL
#define LPCOMP_INTR_MASK_COMP0_MASK_Msk 0x1UL
#define LPCOMP_INTR_MASK_COMP1_MASK_Pos 1UL
#define LPCOMP_INTR_MASK_COMP1_MASK_Msk 0x2UL
/* LPCOMP.INTR_MASKED */
#define LPCOMP_INTR_MASKED_COMP0_MASKED_Pos 0UL
#define LPCOMP_INTR_MASKED_COMP0_MASKED_Msk 0x1UL
#define LPCOMP_INTR_MASKED_COMP1_MASKED_Pos 1UL
#define LPCOMP_INTR_MASKED_COMP1_MASKED_Msk 0x2UL
/* LPCOMP.CMP0_CTRL */
#define LPCOMP_CMP0_CTRL_MODE0_Pos 0UL
#define LPCOMP_CMP0_CTRL_MODE0_Msk 0x3UL
#define LPCOMP_CMP0_CTRL_HYST0_Pos 5UL
#define LPCOMP_CMP0_CTRL_HYST0_Msk 0x20UL
#define LPCOMP_CMP0_CTRL_INTTYPE0_Pos 6UL
#define LPCOMP_CMP0_CTRL_INTTYPE0_Msk 0xC0UL
#define LPCOMP_CMP0_CTRL_DSI_BYPASS0_Pos 10UL
#define LPCOMP_CMP0_CTRL_DSI_BYPASS0_Msk 0x400UL
#define LPCOMP_CMP0_CTRL_DSI_LEVEL0_Pos 11UL
#define LPCOMP_CMP0_CTRL_DSI_LEVEL0_Msk 0x800UL
/* LPCOMP.CMP0_SW */
#define LPCOMP_CMP0_SW_CMP0_IP0_Pos 0UL
#define LPCOMP_CMP0_SW_CMP0_IP0_Msk 0x1UL
#define LPCOMP_CMP0_SW_CMP0_AP0_Pos 1UL
#define LPCOMP_CMP0_SW_CMP0_AP0_Msk 0x2UL
#define LPCOMP_CMP0_SW_CMP0_BP0_Pos 2UL
#define LPCOMP_CMP0_SW_CMP0_BP0_Msk 0x4UL
#define LPCOMP_CMP0_SW_CMP0_IN0_Pos 4UL
#define LPCOMP_CMP0_SW_CMP0_IN0_Msk 0x10UL
#define LPCOMP_CMP0_SW_CMP0_AN0_Pos 5UL
#define LPCOMP_CMP0_SW_CMP0_AN0_Msk 0x20UL
#define LPCOMP_CMP0_SW_CMP0_BN0_Pos 6UL
#define LPCOMP_CMP0_SW_CMP0_BN0_Msk 0x40UL
#define LPCOMP_CMP0_SW_CMP0_VN0_Pos 7UL
#define LPCOMP_CMP0_SW_CMP0_VN0_Msk 0x80UL
/* LPCOMP.CMP0_SW_CLEAR */
#define LPCOMP_CMP0_SW_CLEAR_CMP0_IP0_Pos 0UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_IP0_Msk 0x1UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_AP0_Pos 1UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_AP0_Msk 0x2UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_BP0_Pos 2UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_BP0_Msk 0x4UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_IN0_Pos 4UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_IN0_Msk 0x10UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_AN0_Pos 5UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_AN0_Msk 0x20UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_BN0_Pos 6UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_BN0_Msk 0x40UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_VN0_Pos 7UL
#define LPCOMP_CMP0_SW_CLEAR_CMP0_VN0_Msk 0x80UL
/* LPCOMP.CMP1_CTRL */
#define LPCOMP_CMP1_CTRL_MODE1_Pos 0UL
#define LPCOMP_CMP1_CTRL_MODE1_Msk 0x3UL
#define LPCOMP_CMP1_CTRL_HYST1_Pos 5UL
#define LPCOMP_CMP1_CTRL_HYST1_Msk 0x20UL
#define LPCOMP_CMP1_CTRL_INTTYPE1_Pos 6UL
#define LPCOMP_CMP1_CTRL_INTTYPE1_Msk 0xC0UL
#define LPCOMP_CMP1_CTRL_DSI_BYPASS1_Pos 10UL
#define LPCOMP_CMP1_CTRL_DSI_BYPASS1_Msk 0x400UL
#define LPCOMP_CMP1_CTRL_DSI_LEVEL1_Pos 11UL
#define LPCOMP_CMP1_CTRL_DSI_LEVEL1_Msk 0x800UL
/* LPCOMP.CMP1_SW */
#define LPCOMP_CMP1_SW_CMP1_IP1_Pos 0UL
#define LPCOMP_CMP1_SW_CMP1_IP1_Msk 0x1UL
#define LPCOMP_CMP1_SW_CMP1_AP1_Pos 1UL
#define LPCOMP_CMP1_SW_CMP1_AP1_Msk 0x2UL
#define LPCOMP_CMP1_SW_CMP1_BP1_Pos 2UL
#define LPCOMP_CMP1_SW_CMP1_BP1_Msk 0x4UL
#define LPCOMP_CMP1_SW_CMP1_IN1_Pos 4UL
#define LPCOMP_CMP1_SW_CMP1_IN1_Msk 0x10UL
#define LPCOMP_CMP1_SW_CMP1_AN1_Pos 5UL
#define LPCOMP_CMP1_SW_CMP1_AN1_Msk 0x20UL
#define LPCOMP_CMP1_SW_CMP1_BN1_Pos 6UL
#define LPCOMP_CMP1_SW_CMP1_BN1_Msk 0x40UL
#define LPCOMP_CMP1_SW_CMP1_VN1_Pos 7UL
#define LPCOMP_CMP1_SW_CMP1_VN1_Msk 0x80UL
/* LPCOMP.CMP1_SW_CLEAR */
#define LPCOMP_CMP1_SW_CLEAR_CMP1_IP1_Pos 0UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_IP1_Msk 0x1UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_AP1_Pos 1UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_AP1_Msk 0x2UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_BP1_Pos 2UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_BP1_Msk 0x4UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_IN1_Pos 4UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_IN1_Msk 0x10UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_AN1_Pos 5UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_AN1_Msk 0x20UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_BN1_Pos 6UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_BN1_Msk 0x40UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_VN1_Pos 7UL
#define LPCOMP_CMP1_SW_CLEAR_CMP1_VN1_Msk 0x80UL
#endif /* _CYIP_LPCOMP_H_ */
/* [] END OF FILE */
|
2b8c135af9dbcb84129325ffc5d865f2afb501d1
|
3b3d4927ac4c2cee021d1249806c0f019b0216b1
|
/inc/PPJIoctl.h
|
649515946b3ffdca272ff532da5868b11b8b907f
|
[
"MIT"
] |
permissive
|
njz3/vJoy
|
e1e04e37ce9e1117b722e56edef13d74fadb4229
|
42007bb1d27ade4f0630a114910c627dd3ede6cf
|
refs/heads/master
| 2023-08-26T19:57:41.982218
| 2023-08-17T19:39:18
| 2023-08-17T19:39:18
| 233,026,729
| 237
| 40
|
MIT
| 2023-08-17T19:26:41
| 2020-01-10T10:48:13
|
C++
|
UTF-8
|
C
| false
| false
| 1,212
|
h
|
PPJIoctl.h
|
#ifndef __PPJIOCTL_H__
#define __PPJIOCTL_H__
/* Define to use byte-size values for joystick axes, else dword size */
#undef UCHAR_AXES
#define PPJOY_AXIS_MIN 1
#ifdef UCHAR_AXES
#define PPJOY_AXIS_MAX 127
#else
#define PPJOY_AXIS_MAX 32767
#endif
#define FILE_DEVICE_PPORTJOY FILE_DEVICE_UNKNOWN
#define PPORTJOY_IOCTL(_index_) \
CTL_CODE (FILE_DEVICE_PPORTJOY, _index_, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PPORTJOY_SET_STATE PPORTJOY_IOCTL (0x0)
#define JOYSTICK_STATE_V1 0x53544143
typedef struct
{
ULONG Version;
UCHAR Data[1];
} JOYSTICK_SET_STATE, *PJOYSTICK_SET_STATE;
#define NUM_ANALOG 8 /* Number of analog values which we will provide */
#define NUM_DIGITAL 8 /* Number of digital values which we will provide */
#pragma pack(push,1) /* All fields in structure must be byte aligned. */
typedef struct
{
unsigned long Signature; /* Signature to identify packet to PPJoy IOCTL */
char NumAnalog; /* Num of analog values we pass */
long Analog[NUM_ANALOG]; /* Analog values */
char NumDigital; /* Num of digital values we pass */
char Digital[NUM_DIGITAL]; /* Digital values */
} JOYSTICK_STATE, *PJOYSTICK_STATE;
#pragma pack(pop)
#endif
|
e42dc4ebd93377c32c00dd2d8c59988a7d88518e
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.h
|
7f675dec0e1c72e759362f681ba435529bc5af5c
|
[] |
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
| 1,040
|
h
|
i915_gem_mman.h
|
/* $NetBSD: i915_gem_mman.h,v 1.8 2021/12/19 11:56:52 riastradh Exp $ */
/*
* SPDX-License-Identifier: MIT
*
* Copyright © 2019 Intel Corporation
*/
#ifndef __I915_GEM_MMAN_H__
#define __I915_GEM_MMAN_H__
#include <linux/mm_types.h>
#include <linux/types.h>
struct drm_device;
struct drm_file;
struct drm_i915_gem_object;
struct file;
struct i915_mmap_offset;
struct mutex;
int i915_gem_mmap_gtt_version(void);
#ifdef __NetBSD__
extern const struct uvm_pagerops i915_gem_uvm_ops;
int i915_gem_mmap_object(struct drm_device *, off_t, size_t, int,
struct uvm_object **, voff_t *, struct file *);
#else
int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma);
#endif
int i915_gem_dumb_mmap_offset(struct drm_file *file_priv,
struct drm_device *dev,
u32 handle, u64 *offset);
void __i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj);
void i915_gem_object_release_mmap(struct drm_i915_gem_object *obj);
void i915_gem_object_release_mmap_offset(struct drm_i915_gem_object *obj);
#endif
|
8d964431baf5a21e3b1366f3143ff2dddf375443
|
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
|
/hackathon/zhi/NeuronStudio_zhi/std/nsstring.c
|
f7ad1c4bc71bb4d3b2d19bd10ed3e3f55dd7dc6a
|
[
"MIT"
] |
permissive
|
Vaa3D/vaa3d_tools
|
edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9
|
e6974d5223ae70474efaa85e1253f5df1814fae8
|
refs/heads/master
| 2023-08-03T06:12:01.013752
| 2023-08-02T07:26:01
| 2023-08-02T07:26:01
| 50,527,925
| 107
| 86
|
MIT
| 2023-05-22T23:43:48
| 2016-01-27T18:19:17
|
C++
|
UTF-8
|
C
| false
| false
| 11,424
|
c
|
nsstring.c
|
#include "nsstring.h"
NS_PRIVATE nssize _ns_string_closest_power_of_2( nssize current, nssize value )
{
if( NS_SIZE_MAX / 2 < value )
return NS_SIZE_MAX;
if( 0 == current )
current = 1;
while( current < value )
current <<= 1; /* i.e. multiply by 2 */
return current;
}
NS_PRIVATE NsError _ns_string_do_construct( NsString *string, nssize size, const nschar *s )
{
NsError error;
string->size = 0;
/* NOTE: Assure successful construction of the internal byte array by
initially passing 0 as the size of array. */
ns_verify( NS_SUCCESS( ns_byte_array_construct( &string->buffer, 0 ), error ) );
if( NULL != s )
error = ns_string_set( string, s );
else if( 0 < size )
error = ns_string_resize( string, size );
else
error = ns_no_error();
if( ns_is_error( error ) )
ns_byte_array_destruct( &string->buffer );
return error;
}
void ns_string_destruct( NsString *string )
{
ns_assert( NULL != string );
ns_string_clear( string );
ns_byte_array_destruct( &string->buffer );
}
void ns_string_construct( NsString *string )
{
NsError error;
ns_assert( NULL != string );
ns_verify( NS_SUCCESS( _ns_string_do_construct( string, 0, NULL ), error ) );
}
NsError ns_string_construct_init( NsString *string, const nschar *s )
{
ns_assert( NULL != string );
return _ns_string_do_construct( string, 0, s );
}
NsError ns_string_construct_sized( NsString *string, nssize size )
{
ns_assert( NULL != string );
return _ns_string_do_construct( string, size, NULL );
}
void ns_string_clear( NsString *string )
{
ns_assert( NULL != string );
ns_byte_array_clear( &string->buffer );
string->size = 0;
}
nsboolean ns_string_is_null( const NsString *string )
{
ns_assert( NULL != string );
return 0 == ns_string_capacity( string );
}
const nschar* ns_string_get( const NsString *string )
{
ns_assert( NULL != string );
return ns_string_is_null( string ) ? NULL : ns_string_begin( string );
}
NsError ns_string_set( NsString *string, const nschar *s )
{
nssize size;
NsError error;
ns_assert( NULL != string );
size = ns_ascii_strsize( s );
if( NS_FAILURE( ns_string_resize( string, size ), error ) )
return error;
ns_byte_array_memcpy( &string->buffer, s, size );
string->size = size;
return ns_no_error();
}
NsError ns_string_empty( NsString *string )
{
ns_assert( NULL != string );
return ns_string_set( string, "" );
}
NsError ns_string_resize( NsString *string, nssize size )
{
ns_assert( NULL != string );
/* NOTE: Not allowing the string to shrink. */
if( size <= ns_string_capacity( string ) )
return ns_no_error();
return ns_byte_array_resize(
&string->buffer,
_ns_string_closest_power_of_2( ns_string_capacity( string ), size )
);
}
nssize ns_string_size( const NsString *string )
{
ns_assert( NULL != string );
return string->size;
}
nssize ns_string_capacity( const NsString *string )
{
ns_assert( NULL != string );
return ns_byte_array_size( &string->buffer );
}
/* NOTE: -1 to discard the NULL terminator. */
#define _ns_string_length( string )\
( (string)->size - 1 )
nssize ns_string_length( const NsString *string )
{
ns_assert( NULL != string );
return 0 < string->size ? _ns_string_length( string ) : 0;
/* return ns_string_is_null( string ) ?
0 : ns_ascii_strlen( ns_string_begin( string ) ); */
}
NsError ns_string_append( NsString *string, const nschar *s )
{
ns_assert( NULL != string );
ns_assert( NULL != s );
return ns_string_insert( string, ns_string_length( string ), s );
}
NsError ns_string_append_c( NsString *string, nsunichar c )
{
ns_assert( NULL != string );
return ns_string_insert_c( string, ns_string_length( string ), c );
}
NsError ns_string_prepend( NsString *string, const nschar *s )
{
ns_assert( NULL != string );
ns_assert( NULL != s );
return ns_string_insert( string, 0, s );
}
NsError ns_string_prepend_c( NsString *string, nsunichar c )
{
ns_assert( NULL != string );
return ns_string_insert_c( string, 0, c );
}
NS_PRIVATE NsError _ns_string_insert( NsString *string, nssize at, nssize bytes )
{
nschar *s;
NsError error;
if( NS_FAILURE( ns_string_resize( string, string->size + bytes ), error ) )
return error;
s = ns_string_at( string, at );
ns_memmove( s + bytes, s, ns_ascii_strsize( s ) );
string->size += bytes;
return ns_no_error();
}
NsError ns_string_insert( NsString *string, nssize at, const nschar *s )
{
nssize bytes;
NsError error;
ns_assert( NULL != string );
/* Set the string to the empty string if NULL. This allows appending
or prepending to a string which is initially NULL. */
if( ns_string_is_null( string ) )
if( NS_FAILURE( ns_string_set( string, "" ), error ) )
return error;
ns_assert( at <= ns_string_length( string ) );
ns_assert( NULL != s );
/* NOTE: -1 to discard the null terminator. */
bytes = ns_ascii_strsize( s ) - 1;
if( NS_FAILURE( _ns_string_insert( string, at, bytes ), error ) )
return error;
ns_memcpy( ns_string_at( string, at ), s, bytes );
return ns_no_error();
}
NsError ns_string_insert_c( NsString *string, nssize at, nsunichar c )
{
nschar s[ 16 ]; /* Way more room than needed! */
ns_assert( NULL != string );
ns_sprint( s, NS_FMT_UNICHAR, c );
return ns_string_insert( string, at, s );
}
NsError ns_string_splice_in_c( NsString *string, nschar *I, nsunichar c )
{
ns_assert( NULL != string );
return ns_string_insert_c( string, ns_string_distance( string, I ), c );
}
void ns_string_delete( NsString *string, nssize at, nssize count )
{
nschar *s;
ns_assert( NULL != string );
ns_assert( ! ns_string_is_null( string ) );
/* NOTE: Dont allow null terminator to be deleted,
i.e. assert using '<' instead of '<='. */
ns_assert( at < ns_string_length( string ) );
if( 0 == count )
return;
s = ns_string_at( string, at );
ns_assert( count <= ns_ascii_strlen( s ) );
/* Shift the rest of the string over. */
ns_memmove( s, s + count, ns_ascii_strsize( s + count ) );
string->size -= count;
}
void ns_string_delete_c( NsString *string, nssize at )
{
ns_assert( NULL != string );
ns_string_delete( string, at, 1 );
}
void ns_string_splice_out_c( NsString *string, nschar *I )
{
ns_assert( NULL != string );
ns_string_delete_c( string, ns_string_distance( string, I ) );
}
NsError ns_string_splice_out( NsString *src, nssize at, nssize count, NsString *dest )
{
nschar *I;
nssize n;
NsError error;
ns_assert( NULL != src );
ns_assert( NULL != dest );
ns_assert( at < ns_string_length( src ) );
if( 0 == count )
return ns_no_error();
/* Have to save count to use in final delete operation. */
n = count;
ns_string_resize( dest, 0 );
I = ns_string_at( src, at );
ns_assert( count <= ns_ascii_strlen( I ) );
while( 0 < count )
{
ns_assert( NS_ASCII_NULL != *I );
if( NS_FAILURE( ns_string_append_c( dest, *I ), error ) )
return error;
++I;
--count;
}
ns_string_delete( src, at, n );
return ns_no_error();
}
void ns_string_upper( NsString *string )
{
ns_assert( NULL != string );
ns_assert( ! ns_string_is_null( string ) );
ns_ascii_strupr( ns_string_begin( string ) );
}
void ns_string_lower( NsString *string )
{
ns_assert( NULL != string );
ns_assert( ! ns_string_is_null( string ) );
ns_ascii_strlwr( ns_string_begin( string ) );
}
nsuint ns_string_hash( const NsString *string )
{
ns_assert( NULL != string );
ns_assert( ! ns_string_is_null( string ) );
return ns_ascii_hash( ns_string_begin( string ) );
}
NsError ns_string_getcwd( NsString *string )
{
NsError error;
nschar cwd[ NS_PATH_SIZE ];
ns_assert( NULL != string );
if( NS_FAILURE( ns_getcwd( cwd, NS_PATH_SIZE ), error ) )
return error;
return ns_string_set( string, cwd );
}
NsError ns_string_vformat( NsString *string, const nschar *format, ns_va_list lock_args )
{
return ns_no_error();
}
NsError ns_string_format( NsString *string, const nschar *format, ... )
{
return ns_no_error();
}
NsError ns_string_vformat_and_append( NsString *string, const nschar *format, ns_va_list args )
{
NsString temp;
NsError error;
ns_assert( NULL != string );
ns_assert( NULL != format );
ns_assert( NULL != args );
ns_string_construct( &temp );
if( NS_FAILURE( ns_string_vformat( &temp, format, args ), error ) )
{
ns_string_destruct( &temp );
return error;
}
if( NS_FAILURE( ns_string_append( string, ns_string_get( &temp ) ), error ) )
{
ns_string_destruct( &temp );
return error;
}
ns_string_destruct( &temp );
return ns_no_error();
}
NsError ns_string_format_and_append( NsString *string, const nschar *format, ... )
{
ns_va_list args;
NsError error;
ns_assert( NULL != string );
ns_assert( NULL != format );
ns_va_start( args, format );
error = ns_string_vformat_and_append( string, format, args );
ns_va_end( args );
return error;
}
nssize ns_string_distance( const NsString *string, const nschar *I )
{
const nschar *F, *L;
nssize d;
ns_assert( NULL != string );
d = 0;
F = ns_string_begin( string );
L = ns_string_end( string );
for( ; F != I && F != L; ++F )
++d;
return d;
}
nschar* ns_string_begin( const NsString *string )
{
ns_assert( NULL != string );
ns_assert( ! ns_string_is_null( string ) );
return ( nschar* )ns_byte_array_begin( &string->buffer );
}
nschar* ns_string_end( const NsString *string )
{
ns_assert( NULL != string );
ns_assert( ! ns_string_is_null( string ) );
return ns_string_begin( string ) + _ns_string_length( string );
}
nschar* ns_string_at( const NsString *string, nssize index )
{
ns_assert( NULL != string );
ns_assert( ! ns_string_is_null( string ) );
ns_assert( index <= ns_string_length( string ) );
return ns_string_begin( string ) + index;
}
nsunichar ns_string_getc( const NsString *string, nssize at )
{
ns_assert( NULL != string );
return *( ns_string_at( string, at ) );
}
void ns_string_setc( NsString *string, nssize at, nsunichar c )
{
ns_assert( NULL != string );
*( ns_string_at( string, at ) ) = ( nschar )c;
}
nschar* ns_string_find( const NsString *string, const nschar *s )
{
ns_assert( NULL != string );
ns_assert( NULL != s );
return ns_ascii_strstr( ns_string_begin( string ), s );
}
nschar* ns_string_find_c( const NsString *string, nsunichar c )
{
ns_assert( NULL != string );
return ns_ascii_strchr( ns_string_begin( string ), c );
}
const nschar* ns_string_find_from( const NsString *string, const nschar *at, const nschar *s )
{
ns_assert( NULL != string );
ns_assert( NULL != at );
ns_assert( NULL != s );
return ns_ascii_strstr( at, s );
}
const nschar* ns_string_find_c_from( const NsString *string, const nschar *at, nsunichar c )
{
ns_assert( NULL != string );
ns_assert( NULL != at );
return ns_ascii_strchr( at, c );
}
|
22167207326fad0cc79c56c6270203e843712f38
|
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
|
/third_party/argon2/encoding.c
|
cd9bff6a4f459baeda50e69fc3b59acb043522bd
|
[
"CC0-1.0",
"LicenseRef-scancode-other-copyleft",
"Apache-2.0",
"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
| 18,589
|
c
|
encoding.c
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
╚──────────────────────────────────────────────────────────────────────────────╝
│ │
│ Argon2 reference source code package - reference C implementations │
│ │
│ Copyright 2015 │
│ Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves │
│ │
│ You may use this work under the terms of a Creative Commons CC0 1.0 │
│ License/Waiver or the Apache Public License 2.0, at your option. The │
│ terms of these licenses can be found at: │
│ │
│ - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0 │
│ - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0 │
│ │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/fmt/fmt.h"
#include "libc/limits.h"
#include "libc/str/str.h"
#include "third_party/argon2/core.h"
#include "third_party/argon2/encoding.h"
asm(".ident\t\"\\n\\n\
argon2 (CC0 or Apache2)\\n\
Copyright 2016 Daniel Dinu, Dmitry Khovratovich\\n\
Copyright 2016 Jean-Philippe Aumasson, Samuel Neves\"");
/* clang-format off */
/*
* Example code for a decoder and encoder of "hash strings", with Argon2
* parameters.
*
* This code comprises three sections:
*
* -- The first section contains generic Base64 encoding and decoding
* functions. It is conceptually applicable to any hash function
* implementation that uses Base64 to encode and decode parameters,
* salts and outputs. It could be made into a library, provided that
* the relevant functions are made public (non-static) and be given
* reasonable names to avoid collisions with other functions.
*
* -- The second section is specific to Argon2. It encodes and decodes
* the parameters, salts and outputs. It does not compute the hash
* itself.
*
* The code was originally written by Thomas Pornin <pornin@bolet.org>,
* to whom comments and remarks may be sent. It is released under what
* should amount to Public Domain or its closest equivalent; the
* following mantra is supposed to incarnate that fact with all the
* proper legal rituals:
*
* ---------------------------------------------------------------------
* This file is provided under the terms of Creative Commons CC0 1.0
* Public Domain Dedication. To the extent possible under law, the
* author (Thomas Pornin) has waived all copyright and related or
* neighboring rights to this file. This work is published from: Canada.
* ---------------------------------------------------------------------
*
* Copyright (c) 2015 Thomas Pornin
*/
/* ==================================================================== */
/*
* Common code; could be shared between different hash functions.
*
* Note: the Base64 functions below assume that uppercase letters (resp.
* lowercase letters) have consecutive numerical codes, that fit on 8
* bits. All modern systems use ASCII-compatible charsets, where these
* properties are true. If you are stuck with a dinosaur of a system
* that still defaults to EBCDIC then you already have much bigger
* interoperability issues to deal with.
*/
/*
* Some macros for constant-time comparisons. These work over values in
* the 0..255 range. Returned value is 0x00 on "false", 0xFF on "true".
*/
#define EQ(x, y) ((((0U - ((unsigned)(x) ^ (unsigned)(y))) >> 8) & 0xFF) ^ 0xFF)
#define GT(x, y) ((((unsigned)(y) - (unsigned)(x)) >> 8) & 0xFF)
#define GE(x, y) (GT(y, x) ^ 0xFF)
#define LT(x, y) GT(y, x)
#define LE(x, y) GE(y, x)
/*
* Convert value x (0..63) to corresponding Base64 character.
*/
static int b64_byte_to_char(unsigned x) {
return (LT(x, 26) & (x + 'A')) |
(GE(x, 26) & LT(x, 52) & (x + ('a' - 26))) |
(GE(x, 52) & LT(x, 62) & (x + ('0' - 52))) | (EQ(x, 62) & '+') |
(EQ(x, 63) & '/');
}
/*
* Convert character c to the corresponding 6-bit value. If character c
* is not a Base64 character, then 0xFF (255) is returned.
*/
static unsigned b64_char_to_byte(int c) {
unsigned x;
x = (GE(c, 'A') & LE(c, 'Z') & (c - 'A')) |
(GE(c, 'a') & LE(c, 'z') & (c - ('a' - 26))) |
(GE(c, '0') & LE(c, '9') & (c - ('0' - 52))) | (EQ(c, '+') & 62) |
(EQ(c, '/') & 63);
return x | (EQ(x, 0) & (EQ(c, 'A') ^ 0xFF));
}
/*
* Convert some bytes to Base64. 'dst_len' is the length (in characters)
* of the output buffer 'dst'; if that buffer is not large enough to
* receive the result (including the terminating 0), then (size_t)-1
* is returned. Otherwise, the zero-terminated Base64 string is written
* in the buffer, and the output length (counted WITHOUT the terminating
* zero) is returned.
*/
static size_t to_base64(char *dst, size_t dst_len, const void *src,
size_t src_len) {
size_t olen;
const unsigned char *buf;
unsigned acc, acc_len;
olen = (src_len / 3) << 2;
switch (src_len % 3) {
case 2:
olen++;
/* fall through */
case 1:
olen += 2;
break;
}
if (dst_len <= olen) {
return (size_t)-1;
}
acc = 0;
acc_len = 0;
buf = (const unsigned char *)src;
while (src_len-- > 0) {
acc = (acc << 8) + (*buf++);
acc_len += 8;
while (acc_len >= 6) {
acc_len -= 6;
*dst++ = (char)b64_byte_to_char((acc >> acc_len) & 0x3F);
}
}
if (acc_len > 0) {
*dst++ = (char)b64_byte_to_char((acc << (6 - acc_len)) & 0x3F);
}
*dst++ = 0;
return olen;
}
/*
* Decode Base64 chars into bytes. The '*dst_len' value must initially
* contain the length of the output buffer '*dst'; when the decoding
* ends, the actual number of decoded bytes is written back in
* '*dst_len'.
*
* Decoding stops when a non-Base64 character is encountered, or when
* the output buffer capacity is exceeded. If an error occurred (output
* buffer is too small, invalid last characters leading to unprocessed
* buffered bits), then NULL is returned; otherwise, the returned value
* points to the first non-Base64 character in the source stream, which
* may be the terminating zero.
*/
static const char *from_base64(void *dst, size_t *dst_len, const char *src) {
size_t len;
unsigned char *buf;
unsigned acc, acc_len;
buf = (unsigned char *)dst;
len = 0;
acc = 0;
acc_len = 0;
for (;;) {
unsigned d;
d = b64_char_to_byte(*src);
if (d == 0xFF) {
break;
}
src++;
acc = (acc << 6) + d;
acc_len += 6;
if (acc_len >= 8) {
acc_len -= 8;
if ((len++) >= *dst_len) {
return NULL;
}
*buf++ = (acc >> acc_len) & 0xFF;
}
}
/*
* If the input length is equal to 1 modulo 4 (which is
* invalid), then there will remain 6 unprocessed bits;
* otherwise, only 0, 2 or 4 bits are buffered. The buffered
* bits must also all be zero.
*/
if (acc_len > 4 || (acc & (((unsigned)1 << acc_len) - 1)) != 0) {
return NULL;
}
*dst_len = len;
return src;
}
/*
* Decode decimal integer from 'str'; the value is written in '*v'.
* Returned value is a pointer to the next non-decimal character in the
* string. If there is no digit at all, or the value encoding is not
* minimal (extra leading zeros), or the value does not fit in an
* 'unsigned long', then NULL is returned.
*/
static const char *decode_decimal(const char *str, unsigned long *v) {
const char *orig;
unsigned long acc;
acc = 0;
for (orig = str;; str++) {
int c;
c = *str;
if (c < '0' || c > '9') {
break;
}
c -= '0';
if (acc > (ULONG_MAX / 10)) {
return NULL;
}
acc *= 10;
if ((unsigned long)c > (ULONG_MAX - acc)) {
return NULL;
}
acc += (unsigned long)c;
}
if (str == orig || (*orig == '0' && str != (orig + 1))) {
return NULL;
}
*v = acc;
return str;
}
/* ==================================================================== */
/*
* Code specific to Argon2.
*
* The code below applies the following format:
*
* $argon2<T>[$v=<num>]$m=<num>,t=<num>,p=<num>$<bin>$<bin>
*
* where <T> is either 'd', 'id', or 'i', <num> is a decimal integer (positive,
* fits in an 'unsigned long'), and <bin> is Base64-encoded data (no '=' padding
* characters, no newline or whitespace).
*
* The last two binary chunks (encoded in Base64) are, in that order,
* the salt and the output. Both are required. The binary salt length and the
* output length must be in the allowed ranges defined in argon2.h.
*
* The ctx struct must contain buffers large enough to hold the salt and pwd
* when it is fed into decode_string.
*/
/**
* Decodes an Argon2 hash string into the provided structure 'ctx'.
* The only fields that must be set prior to this call are ctx.saltlen and
* ctx.outlen (which must be the maximal salt and out length values that are
* allowed), ctx.salt and ctx.out (which must be buffers of the specified
* length), and ctx.pwd and ctx.pwdlen which must hold a valid password.
*
* Invalid input string causes an error. On success, the ctx is valid and all
* fields have been initialized.
*
* @return value is ARGON2_OK on success, other ARGON2_ codes on error
*/
int decode_string(argon2_context *ctx, const char *str, argon2_type type) {
/* check for prefix */
#define CC(prefix) \
do { \
size_t cc_len = strlen(prefix); \
if (strncmp(str, prefix, cc_len) != 0) { \
return ARGON2_DECODING_FAIL; \
} \
str += cc_len; \
} while ((void)0, 0)
/* optional prefix checking with supplied code */
#define CC_opt(prefix, code) \
do { \
size_t cc_len = strlen(prefix); \
if (strncmp(str, prefix, cc_len) == 0) { \
str += cc_len; \
{ code; } \
} \
} while ((void)0, 0)
/* Decoding prefix into decimal */
#define DECIMAL(x) \
do { \
unsigned long dec_x; \
str = decode_decimal(str, &dec_x); \
if (str == NULL) { \
return ARGON2_DECODING_FAIL; \
} \
(x) = dec_x; \
} while ((void)0, 0)
/* Decoding prefix into uint32_t decimal */
#define DECIMAL_U32(x) \
do { \
unsigned long dec_x; \
str = decode_decimal(str, &dec_x); \
if (str == NULL || dec_x > UINT32_MAX) { \
return ARGON2_DECODING_FAIL; \
} \
(x) = (uint32_t)dec_x; \
} while ((void)0, 0)
/* Decoding base64 into a binary buffer */
#define BIN(buf, max_len, len) \
do { \
size_t bin_len = (max_len); \
str = from_base64(buf, &bin_len, str); \
if (str == NULL || bin_len > UINT32_MAX) { \
return ARGON2_DECODING_FAIL; \
} \
(len) = (uint32_t)bin_len; \
} while ((void)0, 0)
size_t maxsaltlen = ctx->saltlen;
size_t maxoutlen = ctx->outlen;
int validation_result;
const char* type_string;
/* We should start with the argon2_type we are using */
type_string = argon2_type2string(type, 0);
if (!type_string) {
return ARGON2_INCORRECT_TYPE;
}
CC("$");
CC(type_string);
/* Reading the version number if the default is suppressed */
ctx->version = ARGON2_VERSION_10;
CC_opt("$v=", DECIMAL_U32(ctx->version));
CC("$m=");
DECIMAL_U32(ctx->m_cost);
CC(",t=");
DECIMAL_U32(ctx->t_cost);
CC(",p=");
DECIMAL_U32(ctx->lanes);
ctx->threads = ctx->lanes;
CC("$");
BIN(ctx->salt, maxsaltlen, ctx->saltlen);
CC("$");
BIN(ctx->out, maxoutlen, ctx->outlen);
/* The rest of the fields get the default values */
ctx->secret = NULL;
ctx->secretlen = 0;
ctx->ad = NULL;
ctx->adlen = 0;
ctx->allocate_cbk = NULL;
ctx->free_cbk = NULL;
ctx->flags = ARGON2_DEFAULT_FLAGS;
/* On return, must have valid context */
validation_result = validate_inputs(ctx);
if (validation_result != ARGON2_OK) {
return validation_result;
}
/* Can't have any additional characters */
if (*str == 0) {
return ARGON2_OK;
} else {
return ARGON2_DECODING_FAIL;
}
#undef CC
#undef CC_opt
#undef DECIMAL
#undef BIN
}
/**
* Encodes an Argon2 hash string into the provided buffer. 'dst_len'
* contains the size, in characters, of the 'dst' buffer; if 'dst_len'
* is less than the number of required characters (including the
* terminating 0), then this function returns ARGON2_ENCODING_ERROR.
*
* @return on success, ARGON2_OK is returned
*/
int encode_string(char *dst, size_t dst_len, argon2_context *ctx,
argon2_type type) {
#define SS(str) \
do { \
size_t pp_len = strlen(str); \
if (pp_len >= dst_len) { \
return ARGON2_ENCODING_FAIL; \
} \
memcpy(dst, str, pp_len + 1); \
dst += pp_len; \
dst_len -= pp_len; \
} while ((void)0, 0)
#define SX(x) \
do { \
char tmp[30]; \
sprintf(tmp, "%lu", (unsigned long)(x)); \
SS(tmp); \
} while ((void)0, 0)
#define SB(buf, len) \
do { \
size_t sb_len = to_base64(dst, dst_len, buf, len); \
if (sb_len == (size_t)-1) { \
return ARGON2_ENCODING_FAIL; \
} \
dst += sb_len; \
dst_len -= sb_len; \
} while ((void)0, 0)
const char* type_string = argon2_type2string(type, 0);
int validation_result = validate_inputs(ctx);
if (!type_string) {
return ARGON2_ENCODING_FAIL;
}
if (validation_result != ARGON2_OK) {
return validation_result;
}
SS("$");
SS(type_string);
SS("$v=");
SX(ctx->version);
SS("$m=");
SX(ctx->m_cost);
SS(",t=");
SX(ctx->t_cost);
SS(",p=");
SX(ctx->lanes);
SS("$");
SB(ctx->salt, ctx->saltlen);
SS("$");
SB(ctx->out, ctx->outlen);
return ARGON2_OK;
#undef SS
#undef SX
#undef SB
}
/** Returns length of the encoded byte stream with length len */
size_t b64len(uint32_t len) {
size_t olen = ((size_t)len / 3) << 2;
switch (len % 3) {
case 2:
olen++;
/* fall through */
case 1:
olen += 2;
break;
}
return olen;
}
/** Returns length of the encoded number num */
size_t numlen(uint32_t num) {
size_t len = 1;
while (num >= 10) {
++len;
num = num / 10;
}
return len;
}
|
4b82b1804f08253dbddf7d051a8d85fd70156118
|
8838eb997879add5759b6dfb23f9a646464e53ca
|
/src/kernel/irq/no_irq.c
|
0136a234380606ba80fb0d223b9cb516d3aa6d9c
|
[
"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
| 286
|
c
|
no_irq.c
|
/**
* @file
*
* @date 18.02.2015
* @author Anton Bondarev
*/
#include <kernel/irq.h>
int irq_attach(unsigned int irq_nr, irq_handler_t handler,
unsigned int flags, void *data, const char *dev_name) {
return 0;
}
int irq_detach(unsigned int irq_nr, void *data) {
return 0;
}
|
12b09f560c5aa3fbbd595048db3f72f28b5b2b13
|
771b8d391585df59d8c7438e21e54976c4180011
|
/lib/libOTe/KyberOT/randombytes.h
|
d17bc16bbf0acdf3cee2f966d6f32038eb4dc817
|
[
"MIT",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
cryptobiu/libscapi
|
1f11f92065c1cea418e73b932c9810d374bac060
|
1f70a88548501eaca5fb635194443e7a2b871088
|
refs/heads/master
| 2023-08-10T08:34:21.304797
| 2022-08-16T16:48:20
| 2022-08-16T16:48:20
| 53,246,303
| 186
| 74
|
MIT
| 2023-07-20T11:01:17
| 2016-03-06T08:59:43
|
C++
|
UTF-8
|
C
| false
| false
| 144
|
h
|
randombytes.h
|
#ifndef RANDOMBYTES_H
#define RANDOMBYTES_H
#define _GNU_SOURCE
#include <unistd.h>
void randombytes(unsigned char *x, size_t xlen);
#endif
|
8381003732c7854bd683c9b774d2f17bcae68abf
|
17467a6fb0eeb9531e9e256db0eee0661efd63d2
|
/src/bpft.c
|
8ce1b564bfa8d6b420eb58c192eb5186f6935e34
|
[
"BSD-3-Clause"
] |
permissive
|
DNS-OARC/dnscap
|
973ce26f91b31c91fce0a75cae17740148469713
|
cdd716fc8234c77c113a2988a08de7af42c91903
|
refs/heads/develop
| 2023-07-24T17:14:45.616569
| 2023-07-14T12:13:34
| 2023-07-14T12:13:34
| 4,931,801
| 235
| 65
|
NOASSERTION
| 2023-08-23T12:09:23
| 2012-07-06T22:17:06
|
C
|
UTF-8
|
C
| false
| false
| 7,869
|
c
|
bpft.c
|
/*
* Copyright (c) 2016-2023, OARC, 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.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "bpft.h"
#include "iaddr.h"
#include <ldns/ldns.h>
void prepare_bpft(void)
{
unsigned udp10_mbs, udp10_mbc, udp11_mbc; // udp11_mbs
text_list bpfl;
text_ptr text;
size_t len;
char* p;
/* Prepare the must-be-set and must-be-clear tests. */
udp10_mbs = udp10_mbc = udp11_mbc = 0U; // udp11_mbs
if ((dir_wanted & DIR_INITIATE) != 0) {
if ((dir_wanted & DIR_RESPONSE) == 0)
udp10_mbc |= UDP10_QR_MASK;
} else if ((dir_wanted & DIR_RESPONSE) != 0) {
udp10_mbs |= UDP10_QR_MASK;
}
if ((msg_wanted & MSG_UPDATE) != 0) {
if ((msg_wanted & (MSG_QUERY | MSG_NOTIFY)) == 0)
udp10_mbs |= (LDNS_PACKET_UPDATE << UDP10_OP_SHIFT);
} else if ((msg_wanted & MSG_NOTIFY) != 0) {
if ((msg_wanted & (MSG_QUERY | MSG_UPDATE)) == 0)
udp10_mbs |= (LDNS_PACKET_NOTIFY << UDP10_OP_SHIFT);
} else if ((msg_wanted & MSG_QUERY) != 0) {
udp10_mbc |= UDP10_OP_MASK;
}
if (err_wanted == ERR_NO) {
udp10_mbc |= UDP10_TC_MASK;
udp11_mbc |= UDP11_RC_MASK;
}
/*
* Model
* (vlan) and (transport)
* (vlan) and ((icmp) or (frags) or (dns))
* (vlan) and ((icmp) or (frags) or ((ports) and (hosts)))
* (vlan) and ((icmp) or (frags) or (((tcp) or (udp)) and (hosts)))
* [(vlan) and] ( [(icmp) or] [(frags) or] ( ( [(tcp) or] (udp) ) [and (hosts)] ) )
*/
/* Make a BPF program to do early course kernel-level filtering. */
INIT_LIST(bpfl);
len = 0;
if (!EMPTY(vlans_excl))
len += text_add(&bpfl, "vlan and ("); /* vlan and ( transports ... */
else
len += text_add(&bpfl, "("); /* ( transports ... */
if (wanticmp) {
len += text_add(&bpfl, " ( ip proto 1 or ip proto 58 ) or");
}
if (wantfrags) {
len += text_add(&bpfl, " ( ip[6:2] & 0x1fff != 0 or ip6[6] = 44 ) or");
}
len += text_add(&bpfl, " ("); /* ( dns ... */
len += text_add(&bpfl, " ("); /* ( ports ... */
if (wanttcp) {
len += text_add(&bpfl, " ( tcp port %d ) or", dns_port);
/* tcp packets can be filtered by initiators/responders, but
* not mbs/mbc. */
}
len += text_add(&bpfl, " ( udp port %d and ( ip6 or ( ip", dns_port);
if (udp10_mbc != 0)
len += text_add(&bpfl, " and udp[10] & 0x%x = 0",
udp10_mbc);
if (udp10_mbs != 0)
len += text_add(&bpfl, " and udp[10] & 0x%x = 0x%x",
udp10_mbs, udp10_mbs);
if (udp11_mbc != 0)
len += text_add(&bpfl, " and udp[11] & 0x%x = 0",
udp11_mbc);
/* Dead code, udp11_mbs never set
if (udp11_mbs != 0)
len += text_add(&bpfl, " and udp[11] & 0x%x = 0x%x",
udp11_mbs, udp11_mbs);
*/
if (err_wanted != ERR_NO) {
len += text_add(&bpfl, " and (");
if ((err_wanted & ERR_TRUNC) != 0) {
len += text_add(&bpfl, " udp[10] & 0x%x = 0x%x or", UDP10_TC_MASK, UDP10_TC_MASK);
}
len += text_add(&bpfl, " 0x%x << (udp[11] & 0xf) & 0x%x != 0 )", ERR_RCODE_BASE, err_wanted);
}
len += text_add(&bpfl, " )))"); /* ... udp 53 ) */
len += text_add(&bpfl, " )"); /* ... ports ) */
if (options.bpf_hosts_apply_all) {
len += text_add(&bpfl, " )"); /* ... dns ) */
len += text_add(&bpfl, " )"); /* ... transport ) */
}
if (!EMPTY(initiators) || !EMPTY(responders)) {
const char* or = "or", *lp = "(", *sep;
endpoint_ptr ep;
len += text_add(&bpfl, " and host");
sep = lp;
for (ep = HEAD(initiators);
ep != NULL;
ep = NEXT(ep, link)) {
len += text_add(&bpfl, " %s %s", sep, ia_str(ep->ia));
sep = or ;
}
for (ep = HEAD(responders);
ep != NULL;
ep = NEXT(ep, link)) {
len += text_add(&bpfl, " %s %s", sep, ia_str(ep->ia));
sep = or ;
}
len += text_add(&bpfl, " )");
}
if (!EMPTY(not_initiators) || !EMPTY(not_responders)) {
const char* or = "or", *lp = "(", *sep;
endpoint_ptr ep;
len += text_add(&bpfl, " and not host");
sep = lp;
for (ep = HEAD(not_initiators);
ep != NULL;
ep = NEXT(ep, link)) {
len += text_add(&bpfl, " %s %s", sep, ia_str(ep->ia));
sep = or ;
}
for (ep = HEAD(not_responders);
ep != NULL;
ep = NEXT(ep, link)) {
len += text_add(&bpfl, " %s %s", sep, ia_str(ep->ia));
sep = or ;
}
len += text_add(&bpfl, " )");
}
if (!options.bpf_hosts_apply_all) {
len += text_add(&bpfl, " )"); /* ... dns ) */
len += text_add(&bpfl, " )"); /* ... transport ) */
}
if (extra_bpf)
len += text_add(&bpfl, " and ( %s )", extra_bpf);
bpft = calloc(len + 1, sizeof(char));
assert(bpft != NULL);
p = bpft;
for (text = HEAD(bpfl); text != NULL; text = NEXT(text, link)) {
memcpy(p, text->text, text->len);
p += text->len;
}
text_free(&bpfl);
if (!EMPTY(vlans_incl)) {
char* bpft_vlan;
len = (2 * len) + 64; /* add enough for the extra in snprintf() below */
bpft_vlan = calloc(len, sizeof(char));
assert(bpft_vlan != NULL);
snprintf(bpft_vlan, len, "( %s ) or ( vlan and ( %s ) )", bpft, bpft);
free(bpft);
bpft = bpft_vlan;
}
if (dumptrace >= 1)
fprintf(stderr, "%s: \"%s\"\n", ProgramName, bpft);
}
size_t text_add(text_list* list, const char* fmt, ...)
{
text_ptr text;
va_list ap;
int len;
text = calloc(1, sizeof *text);
assert(text != NULL);
INIT_LINK(text, link);
va_start(ap, fmt);
len = vasprintf(&text->text, fmt, ap);
assert(len >= 0);
va_end(ap);
text->len = len;
APPEND(*list, text, link);
return (text->len);
}
void text_free(text_list* list)
{
text_ptr at, text;
for (at = HEAD(*list); at;) {
text = at;
at = NEXT(text, link);
UNLINK(*list, text, link);
free(text->text);
assert(text != (void*)-1);
free(text);
}
}
|
f4262f3b6c9454fa05b113b5fe3060d83c931f0d
|
de21f9075f55640514c29ef0f1fe3f0690845764
|
/regression/cbmc/gcc_builtin_sub_overflow/main.c
|
28e8fce2df021323ce9732f97cde0a3c9225f39d
|
[
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-4-Clause"
] |
permissive
|
diffblue/cbmc
|
975a074ac445febb3b5715f8792beb545522dc18
|
decd2839c2f51a54b2ad0f3e89fdc1b4bf78cd16
|
refs/heads/develop
| 2023-08-31T05:52:05.342195
| 2023-08-30T13:31:51
| 2023-08-30T13:31:51
| 51,877,056
| 589
| 309
|
NOASSERTION
| 2023-09-14T18:49:17
| 2016-02-16T23:03:52
|
C++
|
UTF-8
|
C
| false
| false
| 3,954
|
c
|
main.c
|
#include <assert.h>
#include <limits.h>
#ifndef __GNUC__
_Bool __builtin_sub_overflow();
_Bool __builtin_sub_overflow_p();
_Bool __builtin_ssub_overflow(int, int, int *);
_Bool __builtin_ssubl_overflow(long, long, long *);
_Bool __builtin_ssubll_overflow(long long, long long, long long *);
_Bool __builtin_usub_overflow(unsigned int, unsigned int, unsigned int *);
_Bool __builtin_usubl_overflow(unsigned long, unsigned long, unsigned long *);
_Bool __builtin_usubll_overflow(
unsigned long long,
unsigned long long,
unsigned long long *);
#endif
void check_int(void)
{
int result;
assert(!__builtin_ssub_overflow(1, 1, &result));
assert(result == 0);
assert(__builtin_ssub_overflow(INT_MIN, 1, &result));
assert(!__builtin_ssub_overflow(INT_MIN / 2, INT_MAX / 2, &result));
assert(result - 1 == INT_MIN);
assert(0 && "reachability");
}
void check_long(void)
{
long result;
assert(!__builtin_ssubl_overflow(1l, 1l, &result));
assert(result == 0l);
assert(__builtin_ssubl_overflow(LONG_MIN, 1l, &result));
assert(!__builtin_ssubl_overflow(LONG_MIN / 2l, LONG_MAX / 2l, &result));
assert(result - 1l == LONG_MIN);
assert(0 && "reachability");
}
void check_long_long(void)
{
long result;
assert(!__builtin_ssubll_overflow(1ll, 1ll, &result));
assert(result == 0ll);
assert(__builtin_ssubll_overflow(LLONG_MIN, 1ll, &result));
assert(!__builtin_ssubll_overflow(LLONG_MIN / 2ll, LLONG_MAX / 2ll, &result));
#if !defined(_WIN32)
// Visual Studio x86/32 bit has an 8-byte "long long" type with corresponding
// LLONG_MAX and LLONG_MIN constants (9223372036854775807i64 and
// -9223372036854775807i64 - 1, respectively), but compiles these to 32-bit
// values. The result is that -LLONG_MAX wraps around to the 32-bit value of
// -LLONG_MIN (-2147483648), with the consequence that result == LLONG_MIN
// after the above subtraction. Therefore, disable this assertion on Visual
// Studio x86/32 bit.
assert(result - 1ll == LLONG_MIN);
#endif
assert(0 && "reachability");
}
void check_unsigned(void)
{
unsigned result;
assert(!__builtin_usub_overflow(1u, 1u, &result));
assert(result == 0u);
assert(__builtin_usub_overflow(0u, 1u, &result));
assert(!__builtin_usub_overflow(UINT_MAX / 2u, UINT_MAX / 2u, &result));
assert(result == 0u);
assert(__builtin_usub_overflow(UINT_MAX / 2u, UINT_MAX, &result));
assert(0 && "reachability");
}
void check_unsigned_long(void)
{
unsigned long result;
assert(!__builtin_usubl_overflow(1ul, 1ul, &result));
assert(result == 0ul);
assert(__builtin_usubl_overflow(0ul, 1ul, &result));
assert(!__builtin_usubl_overflow(ULONG_MAX / 2ul, ULONG_MAX / 2ul, &result));
assert(result == 0ul);
assert(__builtin_usubl_overflow(ULONG_MAX / 2ul, ULONG_MAX, &result));
assert(0 && "reachability");
}
void check_unsigned_long_long(void)
{
unsigned long long result;
assert(!__builtin_usubll_overflow(1ull, 1ull, &result));
assert(result == 0ull);
assert(__builtin_usubll_overflow(0ull, 1ull, &result));
assert(
!__builtin_usubll_overflow(ULLONG_MAX / 2ull, ULLONG_MAX / 2ull, &result));
assert(result == 0ull);
assert(__builtin_usubll_overflow(ULLONG_MAX / 2ull, ULLONG_MAX, &result));
assert(0 && "reachability");
}
void check_generic(void)
{
unsigned char small_result;
long long big_result;
assert(__builtin_sub_overflow(5, 10, &small_result));
assert(!__builtin_sub_overflow(5, 10, &big_result));
assert(big_result == -5ll);
assert(!__builtin_sub_overflow(10, 5, &small_result));
assert(small_result == 5);
assert(!__builtin_sub_overflow(10, 5, &big_result));
assert(big_result == 5ll);
assert(!__builtin_sub_overflow(INT_MIN, INT_MAX, &big_result));
assert(big_result == 2ll * INT_MIN + 1);
assert(0 && "reachability");
}
int main(void)
{
check_int();
check_long();
check_long_long();
check_unsigned();
check_unsigned_long();
check_unsigned_long_long();
check_generic();
}
|
8f16774e9248d7ad4286f14eb3b3ca99ff037964
|
581bdcc078d282e388f1b655d4cfc4e08152d117
|
/tools/peview/pepogoprp.c
|
3dc8ac7846120c27fa80413f8cb03085e69eb4cc
|
[
"MIT",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"LGPL-2.1-or-later",
"GPL-2.0-only",
"LicenseRef-scancode-public-domain"
] |
permissive
|
winsiderss/systeminformer
|
774928be871f0055263ac5e62ae0a598b098486b
|
5a6b442acd45d681f699a133d476a3211d072871
|
refs/heads/master
| 2023-08-28T15:43:41.074679
| 2023-08-27T20:59:20
| 2023-08-27T20:59:20
| 50,824,485
| 2,137
| 292
|
MIT
| 2023-09-10T22:35:12
| 2016-02-01T08:10:21
|
C
|
UTF-8
|
C
| false
| false
| 18,943
|
c
|
pepogoprp.c
|
/*
* Copyright (c) 2022 Winsider Seminars & Solutions, Inc. All rights reserved.
*
* This file is part of System Informer.
*
* Authors:
*
* dmex 2020-2022
*
*/
#include <peview.h>
#include "../thirdparty/ssdeep/fuzzy.h"
#include "../thirdparty/tlsh/tlsh_wrapper.h"
typedef struct _PVP_PE_POGO_CONTEXT
{
HWND WindowHandle;
HWND ListViewHandle;
HIMAGELIST ListViewImageList;
PH_LAYOUT_MANAGER LayoutManager;
PPV_PROPPAGECONTEXT PropSheetContext;
} PVP_PE_POGO_CONTEXT, *PPVP_PE_POGO_CONTEXT;
typedef struct _PVP_PE_CRT_CONTEXT
{
HWND WindowHandle;
HWND ListViewHandle;
HIMAGELIST ListViewImageList;
PH_LAYOUT_MANAGER LayoutManager;
PPV_PROPPAGECONTEXT PropSheetContext;
} PVP_PE_CRT_CONTEXT, *PPVP_PE_CRT_CONTEXT;
VOID PvEnumerateImagePogoSections(
_In_ HWND WindowHandle,
_In_ HWND ListViewHandle
)
{
ULONG count = 0;
PH_MAPPED_IMAGE_DEBUG_POGO pogo;
ExtendedListView_SetRedraw(ListViewHandle, FALSE);
ListView_DeleteAllItems(ListViewHandle);
if (NT_SUCCESS(PhGetMappedImagePogo(&PvMappedImage, &pogo)))
{
for (ULONG i = 0; i < pogo.NumberOfEntries; i++)
{
PPH_IMAGE_DEBUG_POGO_ENTRY entry = PTR_ADD_OFFSET(pogo.PogoEntries, i * sizeof(PH_IMAGE_DEBUG_POGO_ENTRY));
PIMAGE_SECTION_HEADER section;
PVOID imageSectionData;
PPH_STRING hashString;
INT lvItemIndex;
WCHAR value[PH_INT64_STR_LEN_1];
PhPrintUInt64(value, ++count);
lvItemIndex = PhAddListViewItem(ListViewHandle, MAXINT, value, NULL);
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 1, entry->Name);
PhPrintPointer(value, UlongToPtr(entry->Rva));
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 2, value);
PhPrintPointer(value, PTR_ADD_OFFSET(entry->Rva, entry->Size));
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 3, value);
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 4, PhaFormatSize(entry->Size, ULONG_MAX)->Buffer);
if (section = PhMappedImageRvaToSection(&PvMappedImage, entry->Rva))
{
WCHAR sectionName[IMAGE_SIZEOF_SHORT_NAME + 1];
if (PhGetMappedImageSectionName(section, sectionName, RTL_NUMBER_OF(sectionName), NULL))
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 5, sectionName);
}
}
if (imageSectionData = PhMappedImageRvaToVa(&PvMappedImage, entry->Rva, NULL))
{
if (hashString = PvHashBuffer(imageSectionData, entry->Size))
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 6, PhGetString(hashString));
PhDereferenceObject(hashString);
}
}
else
{
// TODO: POGO-PGU can have an RVA outside image sections. For example:
// C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\vcpackages\vcpkgsrv.exe
}
__try
{
PPH_STRING entropyString;
DOUBLE imageSectionEntropy;
if (imageSectionData = PhMappedImageRvaToVa(&PvMappedImage, entry->Rva, NULL))
{
if (PhCalculateEntropy(imageSectionData, entry->Size, &imageSectionEntropy, NULL))
{
entropyString = PhFormatEntropy(imageSectionEntropy, 2, 0, 0);
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 7, entropyString->Buffer);
PhDereferenceObject(entropyString);
}
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
PPH_STRING message;
//message = PH_AUTO(PhGetNtMessage(GetExceptionCode()));
message = PH_AUTO(PhGetWin32Message(PhNtStatusToDosError(GetExceptionCode()))); // WIN32_FROM_NTSTATUS
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 7, PhGetStringOrEmpty(message));
}
__try
{
PVOID imageSectionData;
PPH_STRING ssdeepHashString = NULL;
if (imageSectionData = PhMappedImageRvaToVa(&PvMappedImage, entry->Rva, NULL))
{
fuzzy_hash_buffer(imageSectionData, entry->Size, &ssdeepHashString);
if (!PhIsNullOrEmptyString(ssdeepHashString))
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 8, ssdeepHashString->Buffer);
PhDereferenceObject(ssdeepHashString);
}
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
PPH_STRING message;
//message = PH_AUTO(PhGetNtMessage(GetExceptionCode()));
message = PH_AUTO(PhGetWin32Message(PhNtStatusToDosError(GetExceptionCode()))); // WIN32_FROM_NTSTATUS
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 8, PhGetStringOrEmpty(message));
}
__try
{
PVOID imageSectionData;
PPH_STRING tlshHashString = NULL;
if (imageSectionData = PhMappedImageRvaToVa(&PvMappedImage, entry->Rva, NULL))
{
//
// This can fail in TLSH library during finalization when
// "buckets must be more than 50% non-zero" (see: tlsh_impl.cpp)
//
PvGetTlshBufferHash(imageSectionData, entry->Size, &tlshHashString);
if (!PhIsNullOrEmptyString(tlshHashString))
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 9, tlshHashString->Buffer);
PhDereferenceObject(tlshHashString);
}
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
PPH_STRING message;
//message = PH_AUTO(PhGetNtMessage(GetExceptionCode()));
message = PH_AUTO(PhGetWin32Message(PhNtStatusToDosError(GetExceptionCode()))); // WIN32_FROM_NTSTATUS
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 9, PhGetStringOrEmpty(message));
}
}
PhFree(pogo.PogoEntries);
}
ExtendedListView_SetRedraw(ListViewHandle, TRUE);
}
INT_PTR CALLBACK PvpPeDebugPogoDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
)
{
PPVP_PE_POGO_CONTEXT context;
if (uMsg == WM_INITDIALOG)
{
context = PhAllocateZero(sizeof(PVP_PE_POGO_CONTEXT));
PhSetWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT, context);
if (lParam)
{
LPPROPSHEETPAGE propSheetPage = (LPPROPSHEETPAGE)lParam;
context->PropSheetContext = (PPV_PROPPAGECONTEXT)propSheetPage->lParam;
}
}
else
{
context = PhGetWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT);
}
if (!context)
return FALSE;
switch (uMsg)
{
case WM_INITDIALOG:
{
context->WindowHandle = hwndDlg;
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
PhSetListViewStyle(context->ListViewHandle, TRUE, TRUE);
PhSetControlTheme(context->ListViewHandle, L"explorer");
PhAddListViewColumn(context->ListViewHandle, 0, 0, 0, LVCFMT_LEFT, 40, L"#");
PhAddListViewColumn(context->ListViewHandle, 1, 1, 1, LVCFMT_LEFT, 100, L"Name");
PhAddListViewColumn(context->ListViewHandle, 2, 2, 2, LVCFMT_LEFT, 100, L"RVA (start)");
PhAddListViewColumn(context->ListViewHandle, 3, 3, 3, LVCFMT_LEFT, 100, L"RVA (end)");
PhAddListViewColumn(context->ListViewHandle, 4, 4, 4, LVCFMT_LEFT, 100, L"Size");
PhAddListViewColumn(context->ListViewHandle, 5, 5, 5, LVCFMT_LEFT, 100, L"Section");
PhAddListViewColumn(context->ListViewHandle, 6, 6, 6, LVCFMT_LEFT, 80, L"Hash");
PhAddListViewColumn(context->ListViewHandle, 7, 7, 7, LVCFMT_LEFT, 100, L"Entropy");
PhAddListViewColumn(context->ListViewHandle, 8, 8, 8, LVCFMT_LEFT, 80, L"SSDEEP");
PhAddListViewColumn(context->ListViewHandle, 9, 9, 9, LVCFMT_LEFT, 80, L"TLSH");
PhSetExtendedListView(context->ListViewHandle);
PhLoadListViewColumnsFromSetting(L"ImageDebugPogoListViewColumns", context->ListViewHandle);
PvConfigTreeBorders(context->ListViewHandle);
PhInitializeLayoutManager(&context->LayoutManager, hwndDlg);
PhAddLayoutItem(&context->LayoutManager, context->ListViewHandle, NULL, PH_ANCHOR_ALL);
PvEnumerateImagePogoSections(hwndDlg, context->ListViewHandle);
PhInitializeWindowTheme(hwndDlg, PhEnableThemeSupport);
}
break;
case WM_DESTROY:
{
PhSaveListViewColumnsToSetting(L"ImageDebugPogoListViewColumns", context->ListViewHandle);
PhDeleteLayoutManager(&context->LayoutManager);
PhRemoveWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT);
PhFree(context);
}
break;
case WM_SHOWWINDOW:
{
if (context->PropSheetContext && !context->PropSheetContext->LayoutInitialized)
{
PvAddPropPageLayoutItem(hwndDlg, hwndDlg, PH_PROP_PAGE_TAB_CONTROL_PARENT, PH_ANCHOR_ALL);
PvDoPropPageLayout(hwndDlg);
context->PropSheetContext->LayoutInitialized = TRUE;
}
}
break;
case WM_SIZE:
{
PhLayoutManagerLayout(&context->LayoutManager);
}
break;
case WM_NOTIFY:
{
PvHandleListViewNotifyForCopy(lParam, context->ListViewHandle);
}
break;
case WM_CONTEXTMENU:
{
PvHandleListViewCommandCopy(hwndDlg, lParam, wParam, context->ListViewHandle);
}
break;
case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORLISTBOX:
{
SetBkMode((HDC)wParam, TRANSPARENT);
SetTextColor((HDC)wParam, RGB(0, 0, 0));
SetDCBrushColor((HDC)wParam, RGB(255, 255, 255));
return (INT_PTR)GetStockBrush(DC_BRUSH);
}
break;
}
return FALSE;
}
_Success_(return)
BOOLEAN PvGetCRTFunctionSegment(
_Out_ PULONG Count,
_Out_ PULONG_PTR Address
)
{
PIMAGE_DEBUG_POGO_SIGNATURE debugEntry;
ULONG debugEntryLength = 0;
ULONG debugEntrySize = 0;
ULONG_PTR first = 0;
ULONG_PTR last = 0;
if (PvMappedImage.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
debugEntrySize = sizeof(ULONG);
else
debugEntrySize = sizeof(ULONGLONG);
if (NT_SUCCESS(PhGetMappedImageDebugEntryByType(
&PvMappedImage,
IMAGE_DEBUG_TYPE_POGO,
&debugEntryLength,
&debugEntry
)))
{
PIMAGE_DEBUG_POGO_ENTRY debugPogoEntry;
if (debugEntry->Signature != IMAGE_DEBUG_POGO_SIGNATURE_LTCG && debugEntry->Signature != IMAGE_DEBUG_POGO_SIGNATURE_PGU)
{
if (!(debugEntry->Signature == 0 && debugEntryLength > sizeof(IMAGE_DEBUG_POGO_SIGNATURE)))
return FALSE;
}
debugPogoEntry = PTR_ADD_OFFSET(debugEntry, sizeof(IMAGE_DEBUG_POGO_SIGNATURE));
while ((ULONG_PTR)debugPogoEntry < (ULONG_PTR)PTR_ADD_OFFSET(debugEntry, debugEntryLength))
{
if (!(debugPogoEntry->Rva && debugPogoEntry->Size))
break;
if (strncmp(debugPogoEntry->Name, ".CRT$", 5) == 0)
{
if (first == 0)
first = debugPogoEntry->Rva;
if (first > debugPogoEntry->Rva)
first = debugPogoEntry->Rva;
if (last == 0)
last = debugPogoEntry->Rva;
if (last < debugPogoEntry->Rva)
last = debugPogoEntry->Rva;
//length += debugPogoEntry->Size;
}
debugPogoEntry = PTR_ADD_OFFSET(debugPogoEntry, ALIGN_UP(UFIELD_OFFSET(IMAGE_DEBUG_POGO_ENTRY, Name) + strlen(debugPogoEntry->Name) + sizeof(ANSI_NULL), ULONG));
}
}
if (first && last)
{
if (Count)
*Count = PtrToUlong(PTR_SUB_OFFSET(last + debugEntrySize, first)) / debugEntrySize;
if (Address)
*Address = first;
return TRUE;
}
return FALSE;
}
VOID PvEnumerateCrtInitializers(
_In_ HWND WindowHandle,
_In_ HWND ListViewHandle
)
{
ULONG64 baseAddress = ULLONG_MAX;
ULONG_PTR array = 0;
ULONG count = 0;
ULONG index = 0;
ULONG size = 0;
if (!PvGetCRTFunctionSegment(&count, &array))
return;
ExtendedListView_SetRedraw(ListViewHandle, FALSE);
ListView_DeleteAllItems(ListViewHandle);
if (PvMappedImage.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
{
baseAddress = (ULONG64)PvMappedImage.NtHeaders32->OptionalHeader.ImageBase;
size = sizeof(ULONG);
}
else
{
baseAddress = (ULONG64)PvMappedImage.NtHeaders->OptionalHeader.ImageBase;
size = sizeof(ULONGLONG);
}
for (ULONG i = 0; i < count; i++)
{
PPH_STRING initSymbol = NULL;
PPH_STRING initSymbolName = NULL;
PH_SYMBOL_RESOLVE_LEVEL symbolResolveLevel = PhsrlInvalid;
ULONG64 displacement = 0;
INT lvItemIndex;
WCHAR value[PH_INT64_STR_LEN_1];
PhPrintUInt64(value, ++index);
lvItemIndex = PhAddListViewItem(ListViewHandle, MAXINT, value, NULL);
PhPrintPointer(value, PTR_ADD_OFFSET(array, UInt32x32To64(i, size)));
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 1, value);
initSymbol = PhGetSymbolFromAddress(
PvSymbolProvider,
(ULONG64)PTR_ADD_OFFSET(baseAddress, PTR_ADD_OFFSET(array, UInt32x32To64(i, size))),
&symbolResolveLevel,
NULL,
&initSymbolName,
&displacement
);
if (initSymbol)
{
switch (symbolResolveLevel)
{
case PhsrlFunction:
{
if (displacement)
{
PhSetListViewSubItem(
ListViewHandle,
lvItemIndex,
2,
PhaFormatString(L"%s+0x%llx", initSymbolName->Buffer, displacement)->Buffer
);
}
else
{
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 2, initSymbolName->Buffer);
}
}
break;
case PhsrlModule:
case PhsrlAddress:
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 2, initSymbol->Buffer);
break;
default:
case PhsrlInvalid:
PhSetListViewSubItem(ListViewHandle, lvItemIndex, 2, L"(unnamed)");
break;
}
if (initSymbolName)
PhDereferenceObject(initSymbolName);
PhDereferenceObject(initSymbol);
}
}
ExtendedListView_SetRedraw(ListViewHandle, TRUE);
}
INT_PTR CALLBACK PvpPeDebugCrtDlgProc(
_In_ HWND hwndDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
)
{
PPVP_PE_CRT_CONTEXT context;
if (uMsg == WM_INITDIALOG)
{
context = PhAllocateZero(sizeof(PVP_PE_CRT_CONTEXT));
PhSetWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT, context);
if (lParam)
{
LPPROPSHEETPAGE propSheetPage = (LPPROPSHEETPAGE)lParam;
context->PropSheetContext = (PPV_PROPPAGECONTEXT)propSheetPage->lParam;
}
}
else
{
context = PhGetWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT);
}
if (!context)
return FALSE;
switch (uMsg)
{
case WM_INITDIALOG:
{
context->WindowHandle = hwndDlg;
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
PhSetListViewStyle(context->ListViewHandle, TRUE, TRUE);
PhSetControlTheme(context->ListViewHandle, L"explorer");
PhAddListViewColumn(context->ListViewHandle, 0, 0, 0, LVCFMT_LEFT, 40, L"#");
PhAddListViewColumn(context->ListViewHandle, 1, 1, 1, LVCFMT_LEFT, 150, L"RVA");
PhAddListViewColumn(context->ListViewHandle, 2, 2, 2, LVCFMT_LEFT, 200, L"Symbol");
PhSetExtendedListView(context->ListViewHandle);
PhLoadListViewColumnsFromSetting(L"ImageDebugCrtListViewColumns", context->ListViewHandle);
PvConfigTreeBorders(context->ListViewHandle);
PhInitializeLayoutManager(&context->LayoutManager, hwndDlg);
PhAddLayoutItem(&context->LayoutManager, context->ListViewHandle, NULL, PH_ANCHOR_ALL);
PvEnumerateCrtInitializers(hwndDlg, context->ListViewHandle);
PhInitializeWindowTheme(hwndDlg, PhEnableThemeSupport);
}
break;
case WM_DESTROY:
{
PhSaveListViewColumnsToSetting(L"ImageDebugCrtListViewColumns", context->ListViewHandle);
PhDeleteLayoutManager(&context->LayoutManager);
PhRemoveWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT);
PhFree(context);
}
break;
case WM_SHOWWINDOW:
{
if (context->PropSheetContext && !context->PropSheetContext->LayoutInitialized)
{
PvAddPropPageLayoutItem(hwndDlg, hwndDlg, PH_PROP_PAGE_TAB_CONTROL_PARENT, PH_ANCHOR_ALL);
PvDoPropPageLayout(hwndDlg);
context->PropSheetContext->LayoutInitialized = TRUE;
}
}
break;
case WM_SIZE:
{
PhLayoutManagerLayout(&context->LayoutManager);
}
break;
case WM_NOTIFY:
{
PvHandleListViewNotifyForCopy(lParam, context->ListViewHandle);
}
break;
case WM_CONTEXTMENU:
{
PvHandleListViewCommandCopy(hwndDlg, lParam, wParam, context->ListViewHandle);
}
break;
case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORLISTBOX:
{
SetBkMode((HDC)wParam, TRANSPARENT);
SetTextColor((HDC)wParam, RGB(0, 0, 0));
SetDCBrushColor((HDC)wParam, RGB(255, 255, 255));
return (INT_PTR)GetStockBrush(DC_BRUSH);
}
break;
}
return FALSE;
}
|
20e81ce8d5eb4a4398479b004b39495f1798346d
|
229a28fc18c13bfe1ba7fc81c38b03651ed8e93b
|
/sw/vendor/riscv-tests/mt/ck_matmul.c
|
753a36dfcaac147f70f96709a6febca5e4e8f55a
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-bsd-3-clause-jtag"
] |
permissive
|
pulp-platform/snitch
|
d3967742434fa21e8af71afa6be35ea5420166ca
|
d026f47843f0ea6c269244c4e6851e0e09141ec3
|
refs/heads/master
| 2023-08-24T08:42:36.230951
| 2023-06-19T09:34:05
| 2023-06-19T09:34:05
| 289,236,605
| 194
| 44
|
Apache-2.0
| 2023-07-11T12:46:26
| 2020-08-21T09:57:34
|
SystemVerilog
|
UTF-8
|
C
| false
| false
| 1,687
|
c
|
ck_matmul.c
|
#include "stdlib.h"
#include "util.h"
#include "dataset.h"
void __attribute__((noinline)) matmul(const int coreid, const int ncores, const int lda, const data_t A[], const data_t B[], data_t C[] )
{
// ***************************** //
// **** ADD YOUR CODE HERE ***** //
// ***************************** //
//
// feel free to make a separate function for MI and MSI versions.
int i, j, k, ii, jj, bsize, start;
bsize = 16;
start = bsize*coreid;
for ( jj = start; jj < lda; jj += bsize*ncores) {
int first = 1;
for ( ii = start; ii !=start || first; ii=(bsize+ii) % lda) {
first = 0;
for ( j = jj; j < lda && j < jj + bsize; j+=4) {
for ( i = ii; i < lda && i < ii + bsize; i+=2) {
data_t c1 = C[i + j*lda];
data_t c2 = C[i + j*lda + 1];
data_t c3 = C[i + (j+1)*lda];
data_t c4 = C[i + (j+1)*lda + 1];
data_t c5 = C[i + (j+2)*lda];
data_t c6 = C[i + (j+2)*lda + 1];
data_t c7 = C[i + (j+3)*lda];
data_t c8 = C[i + (j+3)*lda + 1];
for ( k = 0; k < lda; k+=8){
for (int x = 0; x < 8; x++) {
data_t a = A[j*lda + k+x];
data_t a1 = A[(j+1)*lda +k+x];
data_t a2 = A[(j+2)*lda +k+x];
data_t a3 = A[(j+3)*lda +k+x];
data_t b1 = B[(k+x)*lda + i];
data_t b2 = B[(k+x)*lda + i + 1];
c1 += a * b1;
c2 += a * b2;
c3 += a1* b1;
c4 += a1* b2;
c5 += a2* b1;
c6 += a2* b2;
c7 += a3* b1;
c8 += a3* b2;
}
}
C[i + j*lda] = c1;
C[i + j*lda + 1] = c2;
C[i + (j+1)*lda] = c3;
C[i + (j+1)*lda + 1] = c4;
C[i + (j+2)*lda] = c5;
C[i + (j+2)*lda + 1] = c6;
C[i + (j+3)*lda] = c7;
C[i + (j+3)*lda + 1] = c8;
}
}
}
}
}
|
0d2648462ad142aedaa925e8d26a62572dd8fa00
|
2ef88ec7a0fbd9be0ad69ab6ae6f9c9db7a813ed
|
/wait_pgrp.h
|
0340ee9b8135c0cf4c08ea3668d1f11a0555a09f
|
[
"Apache-2.0"
] |
permissive
|
google/xsecurelock
|
c47405a17ed6883fb0d8be3ad760d23e5b7fd719
|
8a448bd506be8799ced99a63504ef777c642ab97
|
refs/heads/master
| 2023-08-29T15:37:59.436221
| 2023-07-21T11:07:57
| 2023-07-21T11:07:57
| 21,041,510
| 825
| 97
|
Apache-2.0
| 2023-07-21T11:07:59
| 2014-06-20T14:55:28
|
C
|
UTF-8
|
C
| false
| false
| 3,620
|
h
|
wait_pgrp.h
|
/*
Copyright 2018 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef WAIT_PGRP_H
#define WAIT_PGRP_H
#include <limits.h> // for INT_MIN
#include <unistd.h> // for pid_t
#define WAIT_ALREADY_DEAD INT_MIN
#define WAIT_NONPOSITIVE_SIGNAL (INT_MIN + 1)
/*! \brief Initializes WaitPgrp.
*
* Actually just installs an empty SIGCHLD handler so select(), sigsuspend()
* etc. get interrupted by the signal.
*/
void InitWaitPgrp(void);
/*! \brief Fork a subprocess, but do not inherit our signal handlers.
*
* Otherwise behaves exactly like fork().
*/
pid_t ForkWithoutSigHandlers(void);
/*! \brief Starts a new process group.
*
* Must be called from a child process, which will become the process group
* leader. The process group will never die, unless killed using KillPgrp (which
* WaitPgrp calls implicitly when the leader process terminates).
*
* \return Zero if the operation succeeded.
*/
void StartPgrp(void);
/*! \brief Spawns a helper process.
*
* Works just like execv(), but if path is a relative path, it looks it up
* within HELPER_PATH.
*
* If it fails, it logs a message about what it tried to execute and how it
* failed.
*/
int ExecvHelper(const char *path, const char *const argv[]);
/*! \brief Kills the given process group.
*
* \param pid The process group ID.
* \param signo The signal to send to the process group.
* \return Zero if and only if sending the signal succeeded.
*/
int KillPgrp(pid_t pid, int signo);
/*! \brief Waits for the given process group to terminate, or checks its status.
* If the leader process died, kill the entire group.
*
* \param name The name of the process group for logging.
* \param pid The process group ID; it is set to zero if the process group died.
* \param do_block Whether to wait for the process group to terminate.
* \param already_killed Whether the caller already sent SIGTERM to the process
* group. If so, we will not log this signal as that'd be spam.
* \param exit_status Variable that receives the exit status of the leader when
* it terminated. Will be negative for a signal, positive for a regular exit,
* or one of the WAIT_* constants.
* \return True if the process group is still alive.
*/
int WaitPgrp(const char *name, pid_t *pid, int do_block, int already_killed,
int *exit_status);
/*! \brief Waits for the given process to terminate, or checks its status.
*
* \param name The name of the process for logging.
* \param pid The process ID; it is set to zero if the process died.
* \param do_block Whether to wait for the process to terminate.
* \param already_killed Whether the caller already sent SIGTERM to the process.
* If so, we will not log this signal as that'd be spam. \param exit_status
* Variable that receives the exit status of the leader when it terminated.
* Will be negative for a signal, positive for a regular exit, or one of the
* WAIT_* constants.
* \return True if the process is still alive.
*/
int WaitProc(const char *name, pid_t *pid, int do_block, int already_killed,
int *exit_status);
#endif
|
67179985ee3795d77d0a6583e77a94c8abed43ab
|
0577a46d8d28e1fd8636893bbdd2b18270bb8eb8
|
/update_notifier/thirdparty/wxWidgets/art/tango/list_remove.h
|
364f012a8e94357b8afd04c65b53318412eb0c55
|
[
"BSD-3-Clause"
] |
permissive
|
ric2b/Vivaldi-browser
|
388a328b4cb838a4c3822357a5529642f86316a5
|
87244f4ee50062e59667bf8b9ca4d5291b6818d7
|
refs/heads/master
| 2022-12-21T04:44:13.804535
| 2022-12-17T16:30:35
| 2022-12-17T16:30:35
| 86,637,416
| 166
| 41
|
BSD-3-Clause
| 2021-03-31T18:49:30
| 2017-03-29T23:09:05
| null |
UTF-8
|
C
| false
| false
| 3,640
|
h
|
list_remove.h
|
/* list_remove.png - 247 bytes */
static const unsigned char list_remove_16x16_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff,
0x61, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47,
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9,
0x43, 0xbb, 0x7f, 0x00, 0x00, 0x00, 0x09, 0x70,
0x48, 0x59, 0x73, 0x00, 0x00, 0x0d, 0xd7, 0x00,
0x00, 0x0d, 0xd7, 0x01, 0x42, 0x28, 0x9b, 0x78,
0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45,
0x07, 0xd6, 0x01, 0x0b, 0x0f, 0x3b, 0x22, 0x00,
0x5c, 0x12, 0xc2, 0x00, 0x00, 0x00, 0x84, 0x49,
0x44, 0x41, 0x54, 0x38, 0xcb, 0xed, 0x91, 0xb1,
0x09, 0x83, 0x50, 0x10, 0x86, 0xbf, 0x07, 0x69,
0xdc, 0xc0, 0x3a, 0x2b, 0xe8, 0x08, 0x19, 0x23,
0xad, 0x6d, 0x46, 0x08, 0x19, 0x20, 0x0b, 0x88,
0xad, 0x73, 0xc4, 0x05, 0x74, 0x88, 0xd4, 0xb6,
0x22, 0x44, 0xf3, 0xee, 0x4f, 0x21, 0xca, 0xb3,
0xb3, 0x33, 0x85, 0x1f, 0x1c, 0x1c, 0x07, 0xff,
0x77, 0x1c, 0x07, 0x07, 0xfb, 0xe3, 0xe6, 0x26,
0xcd, 0xca, 0x1a, 0x48, 0x36, 0xe6, 0x9a, 0xba,
0xb8, 0xa6, 0x00, 0xa7, 0x60, 0x98, 0x3c, 0x6f,
0x17, 0x46, 0x13, 0x0e, 0x18, 0xbd, 0x56, 0x09,
0x69, 0x2a, 0x07, 0xdc, 0xf3, 0xd7, 0xb2, 0x28,
0x14, 0xd0, 0x7d, 0x3c, 0xef, 0xb6, 0x47, 0x02,
0x33, 0x61, 0x82, 0x7e, 0x10, 0xde, 0x8b, 0xaf,
0x09, 0x33, 0x38, 0xc7, 0xd1, 0x4a, 0x1c, 0x0a,
0x9a, 0x47, 0x5e, 0x6d, 0x3e, 0xe1, 0xf8, 0xfe,
0x3f, 0xf1, 0x03, 0xac, 0x53, 0x2d, 0xdb, 0x46,
0xe4, 0x80, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x49,
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
/* list_remove.png - 306 bytes */
static const unsigned char list_remove_24x24_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
0x10, 0x06, 0x00, 0x00, 0x00, 0xb0, 0xe7, 0xe1,
0xbb, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47,
0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70,
0x48, 0x59, 0x73, 0x00, 0x00, 0x0d, 0xd7, 0x00,
0x00, 0x0d, 0xd7, 0x01, 0x42, 0x28, 0x9b, 0x78,
0x00, 0x00, 0x00, 0x09, 0x76, 0x70, 0x41, 0x67,
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18,
0x00, 0x78, 0x4c, 0xa5, 0xa6, 0x00, 0x00, 0x00,
0xbd, 0x49, 0x44, 0x41, 0x54, 0x58, 0xc3, 0xed,
0xd2, 0xbb, 0x0d, 0x83, 0x30, 0x10, 0x06, 0xe0,
0x1f, 0x29, 0x0d, 0x1b, 0x50, 0xb3, 0x82, 0x3d,
0x02, 0x63, 0xd0, 0xd2, 0x32, 0x02, 0x62, 0x00,
0x16, 0xb0, 0x68, 0x99, 0x83, 0x2c, 0x60, 0x0f,
0x41, 0x4d, 0x8b, 0x90, 0x90, 0x7d, 0x76, 0x0a,
0x07, 0xa5, 0x0c, 0x96, 0x82, 0xd2, 0xdc, 0x57,
0xf8, 0xa5, 0xd3, 0xe9, 0xee, 0x64, 0x80, 0x31,
0xc6, 0x18, 0x63, 0xff, 0x93, 0x5d, 0x0d, 0x94,
0xb2, 0x69, 0xa6, 0x49, 0xeb, 0x78, 0x13, 0xe2,
0xde, 0xb2, 0x8c, 0xd1, 0x7a, 0x1c, 0xeb, 0x5a,
0xca, 0x6f, 0x91, 0x8f, 0xb4, 0xc4, 0x42, 0x0c,
0x43, 0xdb, 0x56, 0x15, 0x60, 0xad, 0xf7, 0x21,
0x00, 0xd9, 0x7b, 0x04, 0xd6, 0x12, 0x85, 0x70,
0x3d, 0x53, 0x08, 0x31, 0xfa, 0xdc, 0xcf, 0x3c,
0x5d, 0xa7, 0xd4, 0x3c, 0x5f, 0x1f, 0x50, 0x62,
0x03, 0xc0, 0xb6, 0x1d, 0x07, 0x11, 0xb0, 0x2c,
0xeb, 0xba, 0xef, 0x9f, 0x02, 0xbc, 0x8f, 0x0d,
0xc5, 0x15, 0x20, 0x8a, 0x27, 0x22, 0xef, 0x01,
0xc0, 0xb9, 0xb8, 0x13, 0xc5, 0x46, 0x9d, 0x3b,
0xe3, 0xe3, 0x7b, 0x59, 0x16, 0x45, 0x9e, 0xa7,
0x56, 0x93, 0xdc, 0x80, 0x31, 0x7d, 0xaf, 0xd4,
0xf3, 0x79, 0xff, 0x17, 0xba, 0x37, 0x3f, 0x63,
0x8c, 0x31, 0xc6, 0x7e, 0xe3, 0x05, 0xb5, 0x9e,
0x63, 0xa8, 0xa1, 0xbc, 0x32, 0xe6, 0x00, 0x00,
0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
0x60, 0x82};
|
a7f15569ef0c576a00136405cc098c934c458891
|
3bd385b466cb035fecd2b0c11ae054d42bf44fc2
|
/src/extended/genome_node.c
|
7853291661e66e0b436f77f0dcc4356f0877ad05
|
[
"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
| 15,627
|
c
|
genome_node.c
|
/*
Copyright (c) 2006-2011 Gordon Gremme <gordon@gremme.org>
Copyright (c) 2006-2008 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 <stdarg.h>
#include "core/assert_api.h"
#include "core/class_alloc_api.h"
#include "core/cstr_api.h"
#include "core/ensure_api.h"
#include "core/hashtable.h"
#include "core/ma_api.h"
#include "core/md5_seqid_api.h"
#include "core/msort.h"
#include "core/parseutils_api.h"
#include "core/queue_api.h"
#include "core/unused_api.h"
#include "extended/eof_node_api.h"
#include "extended/genome_node_rep.h"
#include "extended/gff3_defines.h"
#include "extended/gff3_visitor_api.h"
#include "extended/region_node_api.h"
typedef struct {
void *ptr;
GtFree free_func;
} GtGenomeNodeUserData;
GtGenomeNode* gt_genome_node_ref(GtGenomeNode *gn)
{
gt_assert(gn);
gt_rwlock_wrlock(gn->lock);
gn->reference_count++;
gt_rwlock_unlock(gn->lock);
return gn;
}
const GtGenomeNodeClass*
gt_genome_node_class_new(size_t size,
GtGenomeNodeFreeFunc free,
GtGenomeNodeSetSeqidFunc get_seqid,
GtGenomeNodeGetIdstrFunc get_idstr,
GtGenomeNodeGetRangeFunc get_range,
GtGenomeNodeSetRangeFunc set_range,
GtGenomeNodeChangeSeqidFunc change_seqid,
GtGenomeNodeAcceptFunc accept)
{
GtGenomeNodeClass *c_class;
gt_assert(size);
c_class = gt_class_alloc(sizeof *c_class);
c_class->size = size;
c_class->free = free;
c_class->get_seqid = get_seqid;
c_class->get_idstr = get_idstr;
c_class->get_range = get_range;
c_class->set_range = set_range;
c_class->change_seqid = change_seqid;
c_class->accept = accept;
return c_class;
}
static void userdata_delete(void *data)
{
GtGenomeNodeUserData *ud;
if (!data) return;
ud = (GtGenomeNodeUserData*) data;
if (ud->free_func)
ud->free_func(ud->ptr);
ud->free_func = ud->ptr = NULL;
gt_free(ud);
}
static int compare_genome_node_type(GtGenomeNode *gn_a, GtGenomeNode *gn_b)
{
void *rn_a, *rn_b, *sn_a, *sn_b, *en_a, *en_b;
GtMetaNode *mn_a, *mn_b;
/* meta nodes first */
mn_a = gt_meta_node_try_cast(gn_a);
mn_b = gt_meta_node_try_cast(gn_b);
if (mn_a && !mn_b)
return -1;
if (!mn_a && mn_b)
return 1;
if (mn_a && mn_b) {
int ret = 0;
if (!ret && strcmp(gt_meta_node_get_directive(mn_a),
GT_GFF_VERSION_DIRECTIVE) == 0)
ret = -1;
if (!ret && strcmp(gt_meta_node_get_directive(mn_b),
GT_GFF_VERSION_DIRECTIVE) == 0)
ret = 1;
if (!ret && strcmp(gt_meta_node_get_directive(mn_a),
GT_GVF_VERSION_DIRECTIVE) == 0)
ret = -1;
if (!ret && strcmp(gt_meta_node_get_directive(mn_b),
GT_GVF_VERSION_DIRECTIVE) == 0)
ret = 1;
return ret;
}
/* then region nodes */
rn_a = gt_region_node_try_cast(gn_a);
rn_b = gt_region_node_try_cast(gn_b);
if (rn_a && !rn_b)
return -1;
if (!rn_a && rn_b)
return 1;
/* sequence nodes last, but before eof nodes */
sn_a = gt_sequence_node_try_cast(gn_a);
sn_b = gt_sequence_node_try_cast(gn_b);
en_a = gt_eof_node_try_cast(gn_a);
en_b = gt_eof_node_try_cast(gn_b);
if (sn_a && !sn_b)
return en_b ? -1 : 1;
if (!sn_a && sn_b)
return en_a ? 1 : -1;
if (en_a && !en_b)
return 1;
if (!en_a && en_b)
return -1;
return 0;
}
static inline int gt_genome_node_cmp_generic(GtGenomeNode *gn_a,
GtGenomeNode *gn_b,
bool numeric_cmp)
{
GtRange range_a, range_b;
int rval;
const char *id_a, *id_b;
gt_assert(gn_a && gn_b);
/* ensure that region nodes come first and sequence nodes come last,
otherwise we don't get a valid GFF3 stream */
if ((rval = compare_genome_node_type(gn_a, gn_b)))
return rval;
id_a = gt_str_get(gt_genome_node_get_idstr(gn_a));
id_b = gt_str_get(gt_genome_node_get_idstr(gn_b));
if (numeric_cmp) {
GtUword anum, bnum;
int arval, brval;
arval = gt_parse_uword(&anum, id_a);
brval = gt_parse_uword(&bnum, id_b);
if (arval == 0 && brval == 0)
rval = anum-bnum;
else if (arval == 0)
return -1;
else if (brval == 0)
return 1;
else
rval = 0;
if (rval)
return rval;
} else {
if ((rval = gt_md5_seqid_cmp_seqids(id_a, id_b))) {
return rval;
}
}
range_a = gt_genome_node_get_range(gn_a),
range_b = gt_genome_node_get_range(gn_b);
return gt_range_compare(&range_a, &range_b);
}
int gt_genome_node_cmp(GtGenomeNode *gn_a, GtGenomeNode *gn_b)
{
return gt_genome_node_cmp_generic(gn_a, gn_b, false);
}
int gt_genome_node_cmp_num_seqid(GtGenomeNode *gn_a, GtGenomeNode *gn_b)
{
return gt_genome_node_cmp_generic(gn_a, gn_b, true);
}
static int compare_genome_nodes_with_delta(GtGenomeNode *gn_a,
GtGenomeNode *gn_b,
GtUword delta)
{
GtRange range_a, range_b;
int rval;
const char *id_a, *id_b;
gt_assert(gn_a && gn_b);
/* ensure that sequence regions come first, otherwise we don't get a valid
gff3 stream */
if ((rval = compare_genome_node_type(gn_a, gn_b)))
return rval;
id_a = gt_str_get(gt_genome_node_get_idstr(gn_a));
id_b = gt_str_get(gt_genome_node_get_idstr(gn_b));
if ((rval = gt_md5_seqid_cmp_seqids(id_a, id_b))) {
return rval;
}
range_a = gt_genome_node_get_range(gn_a);
range_b = gt_genome_node_get_range(gn_b);
return gt_range_compare_with_delta(&range_a, &range_b, delta);
}
GtGenomeNode* gt_genome_node_create(const GtGenomeNodeClass *gnc)
{
GtGenomeNode *gn;
gt_assert(gnc && gnc->size);
gn = gt_malloc(gnc->size);
gn->c_class = gnc;
gn->filename = NULL; /* means the node is generated */
gn->line_number = 0;
gn->reference_count = 0;
gn->userdata = NULL;
gn->userdata_nof_items = 0;
#ifdef GT_THREADS_ENABLED
gn->lock = gt_rwlock_new();
#endif
return gn;
}
void gt_genome_node_set_origin(GtGenomeNode *gn, GtStr *filename,
unsigned int line_number)
{
gt_assert(gn && filename && line_number);
gt_str_delete(gn->filename);
gn->filename = gt_str_ref(filename);
gn->line_number = line_number;
}
void* gt_genome_node_cast(GT_UNUSED const GtGenomeNodeClass *gnc,
GtGenomeNode *gn)
{
gt_assert(gnc && gn && gn->c_class == gnc);
return gn;
}
void* gt_genome_node_try_cast(const GtGenomeNodeClass *gnc, GtGenomeNode *gn)
{
gt_assert(gnc && gn);
if (gn->c_class == gnc)
return gn;
return NULL;
}
const char* gt_genome_node_get_filename(const GtGenomeNode *gn)
{
gt_assert(gn);
if (gn->filename)
return gt_str_get(gn->filename);
return "generated";
}
unsigned int gt_genome_node_get_line_number(const GtGenomeNode *gn)
{
gt_assert(gn);
return gn->line_number;
}
GtStr* gt_genome_node_get_seqid(GtGenomeNode *gn)
{
gt_assert(gn && gn->c_class);
if (gn->c_class->get_seqid)
return gn->c_class->get_seqid(gn);
return NULL;
}
GtStr* gt_genome_node_get_idstr(GtGenomeNode *gn)
{
gt_assert(gn && gn->c_class && gn->c_class->get_idstr);
return gn->c_class->get_idstr(gn);
}
GtUword gt_genome_node_get_start(GtGenomeNode *gn)
{
return gt_genome_node_get_range(gn).start;
}
GtUword gt_genome_node_get_end(GtGenomeNode *gn)
{
return gt_genome_node_get_range(gn).end;
}
GtRange gt_genome_node_get_range(GtGenomeNode *gn)
{
gt_assert(gn && gn->c_class && gn->c_class->get_range);
return gn->c_class->get_range(gn);
}
GtUword gt_genome_node_get_length(GtGenomeNode *gn)
{
GtRange range;
gt_assert(gn && gn->c_class && gn->c_class->get_range);
range = gt_genome_node_get_range(gn);
return gt_range_length(&range);
}
void gt_genome_node_set_range(GtGenomeNode *gn, const GtRange *range)
{
gt_assert(gn && gn->c_class);
if (gn->c_class->set_range) {
gt_assert(range->start <= range->end);
gn->c_class->set_range(gn, range);
}
}
void gt_genome_node_change_seqid(GtGenomeNode *gn, GtStr *seqid)
{
gt_assert(gn && gn->c_class && gn->c_class->change_seqid && seqid);
gn->c_class->change_seqid(gn, seqid);
}
int gt_genome_node_accept(GtGenomeNode *gn, GtNodeVisitor *nv, GtError *err)
{
gt_error_check(err);
gt_assert(gn && nv && gn->c_class && gn->c_class->accept);
return gn->c_class->accept(gn, nv, err);
}
int gt_genome_node_compare(GtGenomeNode **gn_a, GtGenomeNode **gn_b)
{
return gt_genome_node_cmp(*gn_a, *gn_b);
}
int gt_genome_node_compare_numeric_seqids(GtGenomeNode **gn_a,
GtGenomeNode **gn_b)
{
return gt_genome_node_cmp_num_seqid(*gn_a, *gn_b);
}
int gt_genome_node_compare_with_data(GtGenomeNode **gn_a, GtGenomeNode **gn_b,
GT_UNUSED void *unused)
{
return gt_genome_node_cmp(*gn_a, *gn_b);
}
int gt_genome_node_compare_delta(GtGenomeNode **gn_a, GtGenomeNode **gn_b,
void *delta)
{
GtUword *deltaptr = delta;
gt_assert(delta);
return compare_genome_nodes_with_delta(*gn_a, *gn_b, *deltaptr);
}
void gt_genome_nodes_sort(GtArray *nodes)
{
qsort(gt_array_get_space(nodes), gt_array_size(nodes),
sizeof (GtGenomeNode*), (GtCompare) gt_genome_node_compare);
}
void gt_genome_nodes_sort_with_func(GtArray *nodes, GtCompare cmp)
{
qsort(gt_array_get_space(nodes), gt_array_size(nodes),
sizeof (GtGenomeNode*), cmp);
}
void gt_genome_nodes_sort_stable(GtArray *nodes)
{
gt_msort(gt_array_get_space(nodes), gt_array_size(nodes),
sizeof (GtGenomeNode*), (GtCompare) gt_genome_node_compare);
}
void gt_genome_nodes_sort_stable_with_func(GtArray *nodes, GtCompare cmp)
{
gt_msort(gt_array_get_space(nodes), gt_array_size(nodes),
sizeof (GtGenomeNode*), cmp);
}
void gt_genome_nodes_show(GtArray *nodes, GtFile *outfp)
{
GtNodeVisitor *gff3_visitor;
GtUword i;
gt_assert(nodes);
gff3_visitor = gt_gff3_visitor_new(outfp);
for (i = 0; i < gt_array_size(nodes); i++) {
GT_UNUSED int had_err;
had_err = gt_genome_node_accept(*(GtGenomeNode**) gt_array_get(nodes, i),
gff3_visitor, NULL);
gt_assert(!had_err); /* should not happen */
}
gt_node_visitor_delete(gff3_visitor);
}
bool gt_genome_nodes_are_equal_region_nodes(GtGenomeNode *gn_a,
GtGenomeNode *gn_b)
{
void *sr_a, *sr_b;
sr_a = gn_a ? gt_region_node_try_cast(gn_a) : NULL;
sr_b = gn_b ? gt_region_node_try_cast(gn_b) : NULL;
if (sr_a && sr_b && !gt_str_cmp(gt_genome_node_get_seqid(gn_a),
gt_genome_node_get_seqid(gn_b))) {
return true;
}
return false;
}
bool gt_genome_nodes_are_sorted(const GtArray *nodes)
{
GtUword i;
gt_assert(nodes);
for (i = 1; i < gt_array_size(nodes); i++) {
if (gt_genome_node_compare(gt_array_get(nodes, i-1),
gt_array_get(nodes, i)) > 0) {
return false;
}
}
return true;
}
void gt_genome_node_add_user_data(GtGenomeNode *gn, const char *key, void *data,
GtFree free_func)
{
GtGenomeNodeUserData *ud, *myud;
gt_assert(gn && key);
ud = gt_malloc(sizeof (GtGenomeNodeUserData));
ud->ptr = data;
ud->free_func = free_func;
if (!gn->userdata) {
gn->userdata = gt_hashmap_new(GT_HASH_STRING, gt_free_func,
userdata_delete);
}
gt_assert(gn->userdata != NULL);
/* remove old data entry first if there is one */
if ((myud = gt_hashmap_get(gn->userdata, key)) != NULL) {
gt_hashmap_remove(gn->userdata, key);
} else {
gn->userdata_nof_items++;
}
gt_hashmap_add(gn->userdata, gt_cstr_dup((char*) key), ud);
}
void* gt_genome_node_get_user_data(const GtGenomeNode *gn, const char *key)
{
GtGenomeNodeUserData *ud;
gt_assert(gn && key);
if (!gn->userdata)
return NULL;
ud = (GtGenomeNodeUserData*) gt_hashmap_get(gn->userdata, key);
return (ud ? ud->ptr : NULL);
}
void gt_genome_node_release_user_data(GtGenomeNode *gn, const char *key)
{
GtGenomeNodeUserData *ud;
gt_assert(gn && key);
if (!gn->userdata)
return;
if ((ud = (GtGenomeNodeUserData*) gt_hashmap_get(gn->userdata, key))) {
gt_hashmap_remove(gn->userdata, (char*) key);
if (--gn->userdata_nof_items == 0) {
gt_hashmap_delete(gn->userdata);
gn->userdata = NULL;
}
}
}
int gt_genome_node_unit_test(GtError *err)
{
int had_err = 0;
GtGenomeNodeClass *gnc;
GtGenomeNode *gn;
void *testptr1 = "foo bar",
*testptr2 = NULL;
const char *testkey1 = "key1",
*testkey2 = "key2";
gt_error_check(err);
testptr2 = gt_malloc(sizeof (char)*4);
/* this is a very simple GtGenomeNodeClass without any callbacks */
gnc = gt_calloc(1, sizeof (GtGenomeNodeClass));
gnc->size = sizeof (GtGenomeNode);
gn = gt_genome_node_create(gnc);
gt_ensure(gt_genome_node_get_user_data(gn, testkey1) == NULL);
gt_ensure(gt_genome_node_get_user_data(gn, testkey2) == NULL);
gt_ensure(gn->userdata_nof_items == 0);
gt_ensure(gn->userdata == NULL);
gt_genome_node_add_user_data(gn, testkey1, testptr1, NULL);
gt_ensure(gt_genome_node_get_user_data(gn, testkey1) != NULL);
gt_ensure(gt_genome_node_get_user_data(gn, testkey1) == testptr1);
gt_ensure(gn->userdata_nof_items == 1);
gt_ensure(gn->userdata != NULL);
gt_genome_node_add_user_data(gn, testkey2, testptr2, gt_free_func);
gt_ensure(gt_genome_node_get_user_data(gn, testkey2) != NULL);
gt_ensure(gt_genome_node_get_user_data(gn, testkey2) == testptr2);
gt_ensure(gn->userdata_nof_items == 2);
gt_genome_node_release_user_data(gn, testkey1);
gt_ensure(gt_genome_node_get_user_data(gn, testkey1) == NULL);
gt_ensure(gn->userdata_nof_items == 1);
gt_genome_node_release_user_data(gn, testkey2);
gt_ensure(gt_genome_node_get_user_data(gn, testkey2) == NULL);
gt_ensure(gn->userdata_nof_items == 0);
gt_ensure(gn->userdata == NULL);
testptr2 = gt_malloc(sizeof (char)*4);
gt_genome_node_add_user_data(gn, testkey1, testptr1, NULL);
gt_genome_node_add_user_data(gn, testkey2, testptr2, gt_free_func);
gt_ensure(gn->userdata != NULL);
gt_genome_node_delete(gn);
gt_free(gnc);
return had_err;
}
void gt_genome_node_delete(GtGenomeNode *gn)
{
if (!gn) return;
gt_rwlock_wrlock(gn->lock);
if (gn->reference_count) {
gn->reference_count--;
gt_rwlock_unlock(gn->lock);
return;
}
gt_assert(gn->c_class);
if (gn->c_class->free)
gn->c_class->free(gn);
gt_str_delete(gn->filename);
if (gn->userdata)
gt_hashmap_delete(gn->userdata);
gt_rwlock_unlock(gn->lock);
#ifdef GT_THREADS_ENABLED
gt_rwlock_delete(gn->lock);
#endif
gt_free(gn);
}
|
a983204f7012968e3028b2710133c3da669030a8
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
|
c471400fe8f054345d4f30c7e632f5f989054bfa
|
[
"GPL-1.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"Linux-syscall-note",
"GPL-2.0-only"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 72,841
|
c
|
hw.c
|
/******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
* Hsinchu 300, Taiwan.
*
* Larry Finger <Larry.Finger@lwfinger.net>
*
*****************************************************************************/
#include "../wifi.h"
#include "../efuse.h"
#include "../base.h"
#include "../regd.h"
#include "../cam.h"
#include "../ps.h"
#include "../pci.h"
#include "reg.h"
#include "def.h"
#include "phy.h"
#include "dm.h"
#include "fw.h"
#include "led.h"
#include "hw.h"
void rtl92se_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
switch (variable) {
case HW_VAR_RCR: {
*((u32 *) (val)) = rtlpci->receive_config;
break;
}
case HW_VAR_RF_STATE: {
*((enum rf_pwrstate *)(val)) = ppsc->rfpwr_state;
break;
}
case HW_VAR_FW_PSMODE_STATUS: {
*((bool *) (val)) = ppsc->fw_current_inpsmode;
break;
}
case HW_VAR_CORRECT_TSF: {
u64 tsf;
u32 *ptsf_low = (u32 *)&tsf;
u32 *ptsf_high = ((u32 *)&tsf) + 1;
*ptsf_high = rtl_read_dword(rtlpriv, (TSFR + 4));
*ptsf_low = rtl_read_dword(rtlpriv, TSFR);
*((u64 *) (val)) = tsf;
break;
}
case HW_VAR_MRC: {
*((bool *)(val)) = rtlpriv->dm.current_mrc_switch;
break;
}
default: {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
"switch case not processed\n");
break;
}
}
}
void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
switch (variable) {
case HW_VAR_ETHER_ADDR:{
rtl_write_dword(rtlpriv, IDR0, ((u32 *)(val))[0]);
rtl_write_word(rtlpriv, IDR4, ((u16 *)(val + 4))[0]);
break;
}
case HW_VAR_BASIC_RATE:{
u16 rate_cfg = ((u16 *) val)[0];
u8 rate_index = 0;
if (rtlhal->version == VERSION_8192S_ACUT)
rate_cfg = rate_cfg & 0x150;
else
rate_cfg = rate_cfg & 0x15f;
rate_cfg |= 0x01;
rtl_write_byte(rtlpriv, RRSR, rate_cfg & 0xff);
rtl_write_byte(rtlpriv, RRSR + 1,
(rate_cfg >> 8) & 0xff);
while (rate_cfg > 0x1) {
rate_cfg = (rate_cfg >> 1);
rate_index++;
}
rtl_write_byte(rtlpriv, INIRTSMCS_SEL, rate_index);
break;
}
case HW_VAR_BSSID:{
rtl_write_dword(rtlpriv, BSSIDR, ((u32 *)(val))[0]);
rtl_write_word(rtlpriv, BSSIDR + 4,
((u16 *)(val + 4))[0]);
break;
}
case HW_VAR_SIFS:{
rtl_write_byte(rtlpriv, SIFS_OFDM, val[0]);
rtl_write_byte(rtlpriv, SIFS_OFDM + 1, val[1]);
break;
}
case HW_VAR_SLOT_TIME:{
u8 e_aci;
RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
"HW_VAR_SLOT_TIME %x\n", val[0]);
rtl_write_byte(rtlpriv, SLOT_TIME, val[0]);
for (e_aci = 0; e_aci < AC_MAX; e_aci++) {
rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_AC_PARAM,
(&e_aci));
}
break;
}
case HW_VAR_ACK_PREAMBLE:{
u8 reg_tmp;
u8 short_preamble = (bool) (*val);
reg_tmp = (mac->cur_40_prime_sc) << 5;
if (short_preamble)
reg_tmp |= 0x80;
rtl_write_byte(rtlpriv, RRSR + 2, reg_tmp);
break;
}
case HW_VAR_AMPDU_MIN_SPACE:{
u8 min_spacing_to_set;
u8 sec_min_space;
min_spacing_to_set = *val;
if (min_spacing_to_set <= 7) {
if (rtlpriv->sec.pairwise_enc_algorithm ==
NO_ENCRYPTION)
sec_min_space = 0;
else
sec_min_space = 1;
if (min_spacing_to_set < sec_min_space)
min_spacing_to_set = sec_min_space;
if (min_spacing_to_set > 5)
min_spacing_to_set = 5;
mac->min_space_cfg =
((mac->min_space_cfg & 0xf8) |
min_spacing_to_set);
*val = min_spacing_to_set;
RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
"Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
mac->min_space_cfg);
rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE,
mac->min_space_cfg);
}
break;
}
case HW_VAR_SHORTGI_DENSITY:{
u8 density_to_set;
density_to_set = *val;
mac->min_space_cfg = rtlpriv->rtlhal.minspace_cfg;
mac->min_space_cfg |= (density_to_set << 3);
RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
"Set HW_VAR_SHORTGI_DENSITY: %#x\n",
mac->min_space_cfg);
rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE,
mac->min_space_cfg);
break;
}
case HW_VAR_AMPDU_FACTOR:{
u8 factor_toset;
u8 regtoset;
u8 factorlevel[18] = {
2, 4, 4, 7, 7, 13, 13,
13, 2, 7, 7, 13, 13,
15, 15, 15, 15, 0};
u8 index = 0;
factor_toset = *val;
if (factor_toset <= 3) {
factor_toset = (1 << (factor_toset + 2));
if (factor_toset > 0xf)
factor_toset = 0xf;
for (index = 0; index < 17; index++) {
if (factorlevel[index] > factor_toset)
factorlevel[index] =
factor_toset;
}
for (index = 0; index < 8; index++) {
regtoset = ((factorlevel[index * 2]) |
(factorlevel[index *
2 + 1] << 4));
rtl_write_byte(rtlpriv,
AGGLEN_LMT_L + index,
regtoset);
}
regtoset = ((factorlevel[16]) |
(factorlevel[17] << 4));
rtl_write_byte(rtlpriv, AGGLEN_LMT_H, regtoset);
RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
"Set HW_VAR_AMPDU_FACTOR: %#x\n",
factor_toset);
}
break;
}
case HW_VAR_AC_PARAM:{
u8 e_aci = *val;
rtl92s_dm_init_edca_turbo(hw);
if (rtlpci->acm_method != eAcmWay2_SW)
rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_ACM_CTRL,
&e_aci);
break;
}
case HW_VAR_ACM_CTRL:{
u8 e_aci = *val;
union aci_aifsn *p_aci_aifsn = (union aci_aifsn *)(&(
mac->ac[0].aifs));
u8 acm = p_aci_aifsn->f.acm;
u8 acm_ctrl = rtl_read_byte(rtlpriv, AcmHwCtrl);
acm_ctrl = acm_ctrl | ((rtlpci->acm_method == 2) ?
0x0 : 0x1);
if (acm) {
switch (e_aci) {
case AC0_BE:
acm_ctrl |= AcmHw_BeqEn;
break;
case AC2_VI:
acm_ctrl |= AcmHw_ViqEn;
break;
case AC3_VO:
acm_ctrl |= AcmHw_VoqEn;
break;
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
"HW_VAR_ACM_CTRL acm set failed: eACI is %d\n",
acm);
break;
}
} else {
switch (e_aci) {
case AC0_BE:
acm_ctrl &= (~AcmHw_BeqEn);
break;
case AC2_VI:
acm_ctrl &= (~AcmHw_ViqEn);
break;
case AC3_VO:
acm_ctrl &= (~AcmHw_BeqEn);
break;
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
"switch case not processed\n");
break;
}
}
RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE,
"HW_VAR_ACM_CTRL Write 0x%X\n", acm_ctrl);
rtl_write_byte(rtlpriv, AcmHwCtrl, acm_ctrl);
break;
}
case HW_VAR_RCR:{
rtl_write_dword(rtlpriv, RCR, ((u32 *) (val))[0]);
rtlpci->receive_config = ((u32 *) (val))[0];
break;
}
case HW_VAR_RETRY_LIMIT:{
u8 retry_limit = val[0];
rtl_write_word(rtlpriv, RETRY_LIMIT,
retry_limit << RETRY_LIMIT_SHORT_SHIFT |
retry_limit << RETRY_LIMIT_LONG_SHIFT);
break;
}
case HW_VAR_DUAL_TSF_RST: {
break;
}
case HW_VAR_EFUSE_BYTES: {
rtlefuse->efuse_usedbytes = *((u16 *) val);
break;
}
case HW_VAR_EFUSE_USAGE: {
rtlefuse->efuse_usedpercentage = *val;
break;
}
case HW_VAR_IO_CMD: {
break;
}
case HW_VAR_WPA_CONFIG: {
rtl_write_byte(rtlpriv, REG_SECR, *val);
break;
}
case HW_VAR_SET_RPWM:{
break;
}
case HW_VAR_H2C_FW_PWRMODE:{
break;
}
case HW_VAR_FW_PSMODE_STATUS: {
ppsc->fw_current_inpsmode = *((bool *) val);
break;
}
case HW_VAR_H2C_FW_JOINBSSRPT:{
break;
}
case HW_VAR_AID:{
break;
}
case HW_VAR_CORRECT_TSF:{
break;
}
case HW_VAR_MRC: {
bool bmrc_toset = *((bool *)val);
u8 u1bdata = 0;
if (bmrc_toset) {
rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE,
MASKBYTE0, 0x33);
u1bdata = (u8)rtl_get_bbreg(hw,
ROFDM1_TRXPATHENABLE,
MASKBYTE0);
rtl_set_bbreg(hw, ROFDM1_TRXPATHENABLE,
MASKBYTE0,
((u1bdata & 0xf0) | 0x03));
u1bdata = (u8)rtl_get_bbreg(hw,
ROFDM0_TRXPATHENABLE,
MASKBYTE1);
rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE,
MASKBYTE1,
(u1bdata | 0x04));
/* Update current settings. */
rtlpriv->dm.current_mrc_switch = bmrc_toset;
} else {
rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE,
MASKBYTE0, 0x13);
u1bdata = (u8)rtl_get_bbreg(hw,
ROFDM1_TRXPATHENABLE,
MASKBYTE0);
rtl_set_bbreg(hw, ROFDM1_TRXPATHENABLE,
MASKBYTE0,
((u1bdata & 0xf0) | 0x01));
u1bdata = (u8)rtl_get_bbreg(hw,
ROFDM0_TRXPATHENABLE,
MASKBYTE1);
rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE,
MASKBYTE1, (u1bdata & 0xfb));
/* Update current settings. */
rtlpriv->dm.current_mrc_switch = bmrc_toset;
}
break;
}
case HW_VAR_FW_LPS_ACTION: {
bool enter_fwlps = *((bool *)val);
u8 rpwm_val, fw_pwrmode;
bool fw_current_inps;
if (enter_fwlps) {
rpwm_val = 0x02; /* RF off */
fw_current_inps = true;
rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_FW_PSMODE_STATUS,
(u8 *)(&fw_current_inps));
rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_H2C_FW_PWRMODE,
(u8 *)(&ppsc->fwctrl_psmode));
rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_SET_RPWM,
(u8 *)(&rpwm_val));
} else {
rpwm_val = 0x0C; /* RF on */
fw_pwrmode = FW_PS_ACTIVE_MODE;
fw_current_inps = false;
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM,
(u8 *)(&rpwm_val));
rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_H2C_FW_PWRMODE,
(u8 *)(&fw_pwrmode));
rtlpriv->cfg->ops->set_hw_reg(hw,
HW_VAR_FW_PSMODE_STATUS,
(u8 *)(&fw_current_inps));
}
break; }
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
"switch case not processed\n");
break;
}
}
void rtl92se_enable_hw_security_config(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
u8 sec_reg_value = 0x0;
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
"PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
rtlpriv->sec.pairwise_enc_algorithm,
rtlpriv->sec.group_enc_algorithm);
if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
"not open hw encryption\n");
return;
}
sec_reg_value = SCR_TXENCENABLE | SCR_RXENCENABLE;
if (rtlpriv->sec.use_defaultkey) {
sec_reg_value |= SCR_TXUSEDK;
sec_reg_value |= SCR_RXUSEDK;
}
RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "The SECR-value %x\n",
sec_reg_value);
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value);
}
static u8 _rtl92se_halset_sysclk(struct ieee80211_hw *hw, u8 data)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
u8 waitcount = 100;
bool bresult = false;
u8 tmpvalue;
rtl_write_byte(rtlpriv, SYS_CLKR + 1, data);
/* Wait the MAC synchronized. */
udelay(400);
/* Check if it is set ready. */
tmpvalue = rtl_read_byte(rtlpriv, SYS_CLKR + 1);
bresult = ((tmpvalue & BIT(7)) == (data & BIT(7)));
if ((data & (BIT(6) | BIT(7))) == false) {
waitcount = 100;
tmpvalue = 0;
while (1) {
waitcount--;
tmpvalue = rtl_read_byte(rtlpriv, SYS_CLKR + 1);
if ((tmpvalue & BIT(6)))
break;
pr_err("wait for BIT(6) return value %x\n", tmpvalue);
if (waitcount == 0)
break;
udelay(10);
}
if (waitcount == 0)
bresult = false;
else
bresult = true;
}
return bresult;
}
void rtl8192se_gpiobit3_cfg_inputmode(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
u8 u1tmp;
/* The following config GPIO function */
rtl_write_byte(rtlpriv, MAC_PINMUX_CFG, (GPIOMUX_EN | GPIOSEL_GPIO));
u1tmp = rtl_read_byte(rtlpriv, GPIO_IO_SEL);
/* config GPIO3 to input */
u1tmp &= HAL_8192S_HW_GPIO_OFF_MASK;
rtl_write_byte(rtlpriv, GPIO_IO_SEL, u1tmp);
}
static u8 _rtl92se_rf_onoff_detect(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
u8 u1tmp;
u8 retval = ERFON;
/* The following config GPIO function */
rtl_write_byte(rtlpriv, MAC_PINMUX_CFG, (GPIOMUX_EN | GPIOSEL_GPIO));
u1tmp = rtl_read_byte(rtlpriv, GPIO_IO_SEL);
/* config GPIO3 to input */
u1tmp &= HAL_8192S_HW_GPIO_OFF_MASK;
rtl_write_byte(rtlpriv, GPIO_IO_SEL, u1tmp);
/* On some of the platform, driver cannot read correct
* value without delay between Write_GPIO_SEL and Read_GPIO_IN */
mdelay(10);
/* check GPIO3 */
u1tmp = rtl_read_byte(rtlpriv, GPIO_IN_SE);
retval = (u1tmp & HAL_8192S_HW_GPIO_OFF_BIT) ? ERFON : ERFOFF;
return retval;
}
static void _rtl92se_macconfig_before_fwdownload(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
u8 i;
u8 tmpu1b;
u16 tmpu2b;
u8 pollingcnt = 20;
if (rtlpci->first_init) {
/* Reset PCIE Digital */
tmpu1b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
tmpu1b &= 0xFE;
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b);
udelay(1);
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b | BIT(0));
}
/* Switch to SW IO control */
tmpu1b = rtl_read_byte(rtlpriv, (SYS_CLKR + 1));
if (tmpu1b & BIT(7)) {
tmpu1b &= ~(BIT(6) | BIT(7));
/* Set failed, return to prevent hang. */
if (!_rtl92se_halset_sysclk(hw, tmpu1b))
return;
}
rtl_write_byte(rtlpriv, AFE_PLL_CTRL, 0x0);
udelay(50);
rtl_write_byte(rtlpriv, LDOA15_CTRL, 0x34);
udelay(50);
/* Clear FW RPWM for FW control LPS.*/
rtl_write_byte(rtlpriv, RPWM, 0x0);
/* Reset MAC-IO and CPU and Core Digital BIT(10)/11/15 */
tmpu1b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
tmpu1b &= 0x73;
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b);
/* wait for BIT 10/11/15 to pull high automatically!! */
mdelay(1);
rtl_write_byte(rtlpriv, CMDR, 0);
rtl_write_byte(rtlpriv, TCR, 0);
/* Data sheet not define 0x562!!! Copy from WMAC!!!!! */
tmpu1b = rtl_read_byte(rtlpriv, 0x562);
tmpu1b |= 0x08;
rtl_write_byte(rtlpriv, 0x562, tmpu1b);
tmpu1b &= ~(BIT(3));
rtl_write_byte(rtlpriv, 0x562, tmpu1b);
/* Enable AFE clock source */
tmpu1b = rtl_read_byte(rtlpriv, AFE_XTAL_CTRL);
rtl_write_byte(rtlpriv, AFE_XTAL_CTRL, (tmpu1b | 0x01));
/* Delay 1.5ms */
mdelay(2);
tmpu1b = rtl_read_byte(rtlpriv, AFE_XTAL_CTRL + 1);
rtl_write_byte(rtlpriv, AFE_XTAL_CTRL + 1, (tmpu1b & 0xfb));
/* Enable AFE Macro Block's Bandgap */
tmpu1b = rtl_read_byte(rtlpriv, AFE_MISC);
rtl_write_byte(rtlpriv, AFE_MISC, (tmpu1b | BIT(0)));
mdelay(1);
/* Enable AFE Mbias */
tmpu1b = rtl_read_byte(rtlpriv, AFE_MISC);
rtl_write_byte(rtlpriv, AFE_MISC, (tmpu1b | 0x02));
mdelay(1);
/* Enable LDOA15 block */
tmpu1b = rtl_read_byte(rtlpriv, LDOA15_CTRL);
rtl_write_byte(rtlpriv, LDOA15_CTRL, (tmpu1b | BIT(0)));
/* Set Digital Vdd to Retention isolation Path. */
tmpu2b = rtl_read_word(rtlpriv, REG_SYS_ISO_CTRL);
rtl_write_word(rtlpriv, REG_SYS_ISO_CTRL, (tmpu2b | BIT(11)));
/* For warm reboot NIC disappera bug. */
tmpu2b = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN);
rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(13)));
rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL + 1, 0x68);
/* Enable AFE PLL Macro Block */
/* We need to delay 100u before enabling PLL. */
udelay(200);
tmpu1b = rtl_read_byte(rtlpriv, AFE_PLL_CTRL);
rtl_write_byte(rtlpriv, AFE_PLL_CTRL, (tmpu1b | BIT(0) | BIT(4)));
/* for divider reset */
udelay(100);
rtl_write_byte(rtlpriv, AFE_PLL_CTRL, (tmpu1b | BIT(0) |
BIT(4) | BIT(6)));
udelay(10);
rtl_write_byte(rtlpriv, AFE_PLL_CTRL, (tmpu1b | BIT(0) | BIT(4)));
udelay(10);
/* Enable MAC 80MHZ clock */
tmpu1b = rtl_read_byte(rtlpriv, AFE_PLL_CTRL + 1);
rtl_write_byte(rtlpriv, AFE_PLL_CTRL + 1, (tmpu1b | BIT(0)));
mdelay(1);
/* Release isolation AFE PLL & MD */
rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL, 0xA6);
/* Enable MAC clock */
tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
rtl_write_word(rtlpriv, SYS_CLKR, (tmpu2b | BIT(12) | BIT(11)));
/* Enable Core digital and enable IOREG R/W */
tmpu2b = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN);
rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(11)));
tmpu1b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b & ~(BIT(7)));
/* enable REG_EN */
rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(11) | BIT(15)));
/* Switch the control path. */
tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
rtl_write_word(rtlpriv, SYS_CLKR, (tmpu2b & (~BIT(2))));
tmpu1b = rtl_read_byte(rtlpriv, (SYS_CLKR + 1));
tmpu1b = ((tmpu1b | BIT(7)) & (~BIT(6)));
if (!_rtl92se_halset_sysclk(hw, tmpu1b))
return; /* Set failed, return to prevent hang. */
rtl_write_word(rtlpriv, CMDR, 0x07FC);
/* MH We must enable the section of code to prevent load IMEM fail. */
/* Load MAC register from WMAc temporarily We simulate macreg. */
/* txt HW will provide MAC txt later */
rtl_write_byte(rtlpriv, 0x6, 0x30);
rtl_write_byte(rtlpriv, 0x49, 0xf0);
rtl_write_byte(rtlpriv, 0x4b, 0x81);
rtl_write_byte(rtlpriv, 0xb5, 0x21);
rtl_write_byte(rtlpriv, 0xdc, 0xff);
rtl_write_byte(rtlpriv, 0xdd, 0xff);
rtl_write_byte(rtlpriv, 0xde, 0xff);
rtl_write_byte(rtlpriv, 0xdf, 0xff);
rtl_write_byte(rtlpriv, 0x11a, 0x00);
rtl_write_byte(rtlpriv, 0x11b, 0x00);
for (i = 0; i < 32; i++)
rtl_write_byte(rtlpriv, INIMCS_SEL + i, 0x1b);
rtl_write_byte(rtlpriv, 0x236, 0xff);
rtl_write_byte(rtlpriv, 0x503, 0x22);
if (ppsc->support_aspm && !ppsc->support_backdoor)
rtl_write_byte(rtlpriv, 0x560, 0x40);
else
rtl_write_byte(rtlpriv, 0x560, 0x00);
rtl_write_byte(rtlpriv, DBG_PORT, 0x91);
/* Set RX Desc Address */
rtl_write_dword(rtlpriv, RDQDA, rtlpci->rx_ring[RX_MPDU_QUEUE].dma);
rtl_write_dword(rtlpriv, RCDA, rtlpci->rx_ring[RX_CMD_QUEUE].dma);
/* Set TX Desc Address */
rtl_write_dword(rtlpriv, TBKDA, rtlpci->tx_ring[BK_QUEUE].dma);
rtl_write_dword(rtlpriv, TBEDA, rtlpci->tx_ring[BE_QUEUE].dma);
rtl_write_dword(rtlpriv, TVIDA, rtlpci->tx_ring[VI_QUEUE].dma);
rtl_write_dword(rtlpriv, TVODA, rtlpci->tx_ring[VO_QUEUE].dma);
rtl_write_dword(rtlpriv, TBDA, rtlpci->tx_ring[BEACON_QUEUE].dma);
rtl_write_dword(rtlpriv, TCDA, rtlpci->tx_ring[TXCMD_QUEUE].dma);
rtl_write_dword(rtlpriv, TMDA, rtlpci->tx_ring[MGNT_QUEUE].dma);
rtl_write_dword(rtlpriv, THPDA, rtlpci->tx_ring[HIGH_QUEUE].dma);
rtl_write_dword(rtlpriv, HDA, rtlpci->tx_ring[HCCA_QUEUE].dma);
rtl_write_word(rtlpriv, CMDR, 0x37FC);
/* To make sure that TxDMA can ready to download FW. */
/* We should reset TxDMA if IMEM RPT was not ready. */
do {
tmpu1b = rtl_read_byte(rtlpriv, TCR);
if ((tmpu1b & TXDMA_INIT_VALUE) == TXDMA_INIT_VALUE)
break;
udelay(5);
} while (pollingcnt--);
if (pollingcnt <= 0) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
"Polling TXDMA_INIT_VALUE timeout!! Current TCR(%#x)\n",
tmpu1b);
tmpu1b = rtl_read_byte(rtlpriv, CMDR);
rtl_write_byte(rtlpriv, CMDR, tmpu1b & (~TXDMA_EN));
udelay(2);
/* Reset TxDMA */
rtl_write_byte(rtlpriv, CMDR, tmpu1b | TXDMA_EN);
}
/* After MACIO reset,we must refresh LED state. */
if ((ppsc->rfoff_reason == RF_CHANGE_BY_IPS) ||
(ppsc->rfoff_reason == 0)) {
struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
struct rtl_led *pLed0 = &(pcipriv->ledctl.sw_led0);
enum rf_pwrstate rfpwr_state_toset;
rfpwr_state_toset = _rtl92se_rf_onoff_detect(hw);
if (rfpwr_state_toset == ERFON)
rtl92se_sw_led_on(hw, pLed0);
}
}
static void _rtl92se_macconfig_after_fwdownload(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
u8 i;
u16 tmpu2b;
/* 1. System Configure Register (Offset: 0x0000 - 0x003F) */
/* 2. Command Control Register (Offset: 0x0040 - 0x004F) */
/* Turn on 0x40 Command register */
rtl_write_word(rtlpriv, CMDR, (BBRSTN | BB_GLB_RSTN |
SCHEDULE_EN | MACRXEN | MACTXEN | DDMA_EN | FW2HW_EN |
RXDMA_EN | TXDMA_EN | HCI_RXDMA_EN | HCI_TXDMA_EN));
/* Set TCR TX DMA pre 2 FULL enable bit */
rtl_write_dword(rtlpriv, TCR, rtl_read_dword(rtlpriv, TCR) |
TXDMAPRE2FULL);
/* Set RCR */
rtl_write_dword(rtlpriv, RCR, rtlpci->receive_config);
/* 3. MACID Setting Register (Offset: 0x0050 - 0x007F) */
/* 4. Timing Control Register (Offset: 0x0080 - 0x009F) */
/* Set CCK/OFDM SIFS */
/* CCK SIFS shall always be 10us. */
rtl_write_word(rtlpriv, SIFS_CCK, 0x0a0a);
rtl_write_word(rtlpriv, SIFS_OFDM, 0x1010);
/* Set AckTimeout */
rtl_write_byte(rtlpriv, ACK_TIMEOUT, 0x40);
/* Beacon related */
rtl_write_word(rtlpriv, BCN_INTERVAL, 100);
rtl_write_word(rtlpriv, ATIMWND, 2);
/* 5. FIFO Control Register (Offset: 0x00A0 - 0x015F) */
/* 5.1 Initialize Number of Reserved Pages in Firmware Queue */
/* Firmware allocate now, associate with FW internal setting.!!! */
/* 5.2 Setting TX/RX page size 0/1/2/3/4=64/128/256/512/1024 */
/* 5.3 Set driver info, we only accept PHY status now. */
/* 5.4 Set RXDMA arbitration to control RXDMA/MAC/FW R/W for RXFIFO */
rtl_write_byte(rtlpriv, RXDMA, rtl_read_byte(rtlpriv, RXDMA) | BIT(6));
/* 6. Adaptive Control Register (Offset: 0x0160 - 0x01CF) */
/* Set RRSR to all legacy rate and HT rate
* CCK rate is supported by default.
* CCK rate will be filtered out only when associated
* AP does not support it.
* Only enable ACK rate to OFDM 24M
* Disable RRSR for CCK rate in A-Cut */
if (rtlhal->version == VERSION_8192S_ACUT)
rtl_write_byte(rtlpriv, RRSR, 0xf0);
else if (rtlhal->version == VERSION_8192S_BCUT)
rtl_write_byte(rtlpriv, RRSR, 0xff);
rtl_write_byte(rtlpriv, RRSR + 1, 0x01);
rtl_write_byte(rtlpriv, RRSR + 2, 0x00);
/* A-Cut IC do not support CCK rate. We forbid ARFR to */
/* fallback to CCK rate */
for (i = 0; i < 8; i++) {
/*Disable RRSR for CCK rate in A-Cut */
if (rtlhal->version == VERSION_8192S_ACUT)
rtl_write_dword(rtlpriv, ARFR0 + i * 4, 0x1f0ff0f0);
}
/* Different rate use different AMPDU size */
/* MCS32/ MCS15_SG use max AMPDU size 15*2=30K */
rtl_write_byte(rtlpriv, AGGLEN_LMT_H, 0x0f);
/* MCS0/1/2/3 use max AMPDU size 4*2=8K */
rtl_write_word(rtlpriv, AGGLEN_LMT_L, 0x7442);
/* MCS4/5 use max AMPDU size 8*2=16K 6/7 use 10*2=20K */
rtl_write_word(rtlpriv, AGGLEN_LMT_L + 2, 0xddd7);
/* MCS8/9 use max AMPDU size 8*2=16K 10/11 use 10*2=20K */
rtl_write_word(rtlpriv, AGGLEN_LMT_L + 4, 0xd772);
/* MCS12/13/14/15 use max AMPDU size 15*2=30K */
rtl_write_word(rtlpriv, AGGLEN_LMT_L + 6, 0xfffd);
/* Set Data / Response auto rate fallack retry count */
rtl_write_dword(rtlpriv, DARFRC, 0x04010000);
rtl_write_dword(rtlpriv, DARFRC + 4, 0x09070605);
rtl_write_dword(rtlpriv, RARFRC, 0x04010000);
rtl_write_dword(rtlpriv, RARFRC + 4, 0x09070605);
/* 7. EDCA Setting Register (Offset: 0x01D0 - 0x01FF) */
/* Set all rate to support SG */
rtl_write_word(rtlpriv, SG_RATE, 0xFFFF);
/* 8. WMAC, BA, and CCX related Register (Offset: 0x0200 - 0x023F) */
/* Set NAV protection length */
rtl_write_word(rtlpriv, NAV_PROT_LEN, 0x0080);
/* CF-END Threshold */
rtl_write_byte(rtlpriv, CFEND_TH, 0xFF);
/* Set AMPDU minimum space */
rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE, 0x07);
/* Set TXOP stall control for several queue/HI/BCN/MGT/ */
rtl_write_byte(rtlpriv, TXOP_STALL_CTRL, 0x00);
/* 9. Security Control Register (Offset: 0x0240 - 0x025F) */
/* 10. Power Save Control Register (Offset: 0x0260 - 0x02DF) */
/* 11. General Purpose Register (Offset: 0x02E0 - 0x02FF) */
/* 12. Host Interrupt Status Register (Offset: 0x0300 - 0x030F) */
/* 13. Test Mode and Debug Control Register (Offset: 0x0310 - 0x034F) */
/* 14. Set driver info, we only accept PHY status now. */
rtl_write_byte(rtlpriv, RXDRVINFO_SZ, 4);
/* 15. For EEPROM R/W Workaround */
/* 16. For EFUSE to share REG_SYS_FUNC_EN with EEPROM!!! */
tmpu2b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN);
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, tmpu2b | BIT(13));
tmpu2b = rtl_read_byte(rtlpriv, REG_SYS_ISO_CTRL);
rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL, tmpu2b & (~BIT(8)));
/* 17. For EFUSE */
/* We may R/W EFUSE in EEPROM mode */
if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) {
u8 tempval;
tempval = rtl_read_byte(rtlpriv, REG_SYS_ISO_CTRL + 1);
tempval &= 0xFE;
rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL + 1, tempval);
/* Change Program timing */
rtl_write_byte(rtlpriv, REG_EFUSE_CTRL + 3, 0x72);
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "EFUSE CONFIG OK\n");
}
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "OK\n");
}
static void _rtl92se_hw_configure(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_phy *rtlphy = &(rtlpriv->phy);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
u8 reg_bw_opmode = 0;
u32 reg_rrsr = 0;
u8 regtmp = 0;
reg_bw_opmode = BW_OPMODE_20MHZ;
reg_rrsr = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
regtmp = rtl_read_byte(rtlpriv, INIRTSMCS_SEL);
reg_rrsr = ((reg_rrsr & 0x000fffff) << 8) | regtmp;
rtl_write_dword(rtlpriv, INIRTSMCS_SEL, reg_rrsr);
rtl_write_byte(rtlpriv, BW_OPMODE, reg_bw_opmode);
/* Set Retry Limit here */
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
(u8 *)(&rtlpci->shortretry_limit));
rtl_write_byte(rtlpriv, MLT, 0x8f);
/* For Min Spacing configuration. */
switch (rtlphy->rf_type) {
case RF_1T2R:
case RF_1T1R:
rtlhal->minspace_cfg = (MAX_MSS_DENSITY_1T << 3);
break;
case RF_2T2R:
case RF_2T2R_GREEN:
rtlhal->minspace_cfg = (MAX_MSS_DENSITY_2T << 3);
break;
}
rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE, rtlhal->minspace_cfg);
}
int rtl92se_hw_init(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_phy *rtlphy = &(rtlpriv->phy);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
u8 tmp_byte = 0;
unsigned long flags;
bool rtstatus = true;
u8 tmp_u1b;
int err = false;
u8 i;
int wdcapra_add[] = {
EDCAPARA_BE, EDCAPARA_BK,
EDCAPARA_VI, EDCAPARA_VO};
u8 secr_value = 0x0;
rtlpci->being_init_adapter = true;
/* As this function can take a very long time (up to 350 ms)
* and can be called with irqs disabled, reenable the irqs
* to let the other devices continue being serviced.
*
* It is safe doing so since our own interrupts will only be enabled
* in a subsequent step.
*/
local_save_flags(flags);
local_irq_enable();
rtlpriv->intf_ops->disable_aspm(hw);
/* 1. MAC Initialize */
/* Before FW download, we have to set some MAC register */
_rtl92se_macconfig_before_fwdownload(hw);
rtlhal->version = (enum version_8192s)((rtl_read_dword(rtlpriv,
PMC_FSM) >> 16) & 0xF);
rtl8192se_gpiobit3_cfg_inputmode(hw);
/* 2. download firmware */
rtstatus = rtl92s_download_fw(hw);
if (!rtstatus) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
"Failed to download FW. Init HW without FW now... "
"Please copy FW into /lib/firmware/rtlwifi\n");
err = 1;
goto exit;
}
/* After FW download, we have to reset MAC register */
_rtl92se_macconfig_after_fwdownload(hw);
/*Retrieve default FW Cmd IO map. */
rtlhal->fwcmd_iomap = rtl_read_word(rtlpriv, LBUS_MON_ADDR);
rtlhal->fwcmd_ioparam = rtl_read_dword(rtlpriv, LBUS_ADDR_MASK);
/* 3. Initialize MAC/PHY Config by MACPHY_reg.txt */
if (!rtl92s_phy_mac_config(hw)) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "MAC Config failed\n");
err = rtstatus;
goto exit;
}
/* because last function modify RCR, so we update
* rcr var here, or TP will unstable for receive_config
* is wrong, RX RCR_ACRC32 will cause TP unstabel & Rx
* RCR_APP_ICV will cause mac80211 unassoc for cisco 1252
*/
rtlpci->receive_config = rtl_read_dword(rtlpriv, RCR);
rtlpci->receive_config &= ~(RCR_ACRC32 | RCR_AICV);
rtl_write_dword(rtlpriv, RCR, rtlpci->receive_config);
/* Make sure BB/RF write OK. We should prevent enter IPS. radio off. */
/* We must set flag avoid BB/RF config period later!! */
rtl_write_dword(rtlpriv, CMDR, 0x37FC);
/* 4. Initialize BB After MAC Config PHY_reg.txt, AGC_Tab.txt */
if (!rtl92s_phy_bb_config(hw)) {
RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "BB Config failed\n");
err = rtstatus;
goto exit;
}
/* 5. Initiailze RF RAIO_A.txt RF RAIO_B.txt */
/* Before initalizing RF. We can not use FW to do RF-R/W. */
rtlphy->rf_mode = RF_OP_BY_SW_3WIRE;
/* Before RF-R/W we must execute the IO from Scott's suggestion. */
rtl_write_byte(rtlpriv, AFE_XTAL_CTRL + 1, 0xDB);
if (rtlhal->version == VERSION_8192S_ACUT)
rtl_write_byte(rtlpriv, SPS1_CTRL + 3, 0x07);
else
rtl_write_byte(rtlpriv, RF_CTRL, 0x07);
if (!rtl92s_phy_rf_config(hw)) {
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "RF Config failed\n");
err = rtstatus;
goto exit;
}
/* After read predefined TXT, we must set BB/MAC/RF
* register as our requirement */
rtlphy->rfreg_chnlval[0] = rtl92s_phy_query_rf_reg(hw,
(enum radio_path)0,
RF_CHNLBW,
RFREG_OFFSET_MASK);
rtlphy->rfreg_chnlval[1] = rtl92s_phy_query_rf_reg(hw,
(enum radio_path)1,
RF_CHNLBW,
RFREG_OFFSET_MASK);
/*---- Set CCK and OFDM Block "ON"----*/
rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0x1);
rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0x1);
/*3 Set Hardware(Do nothing now) */
_rtl92se_hw_configure(hw);
/* Read EEPROM TX power index and PHY_REG_PG.txt to capture correct */
/* TX power index for different rate set. */
/* Get original hw reg values */
rtl92s_phy_get_hw_reg_originalvalue(hw);
/* Write correct tx power index */
rtl92s_phy_set_txpower(hw, rtlphy->current_channel);
/* We must set MAC address after firmware download. */
for (i = 0; i < 6; i++)
rtl_write_byte(rtlpriv, MACIDR0 + i, rtlefuse->dev_addr[i]);
/* EEPROM R/W workaround */
tmp_u1b = rtl_read_byte(rtlpriv, MAC_PINMUX_CFG);
rtl_write_byte(rtlpriv, MAC_PINMUX_CFG, tmp_u1b & (~BIT(3)));
rtl_write_byte(rtlpriv, 0x4d, 0x0);
if (hal_get_firmwareversion(rtlpriv) >= 0x49) {
tmp_byte = rtl_read_byte(rtlpriv, FW_RSVD_PG_CRTL) & (~BIT(4));
tmp_byte = tmp_byte | BIT(5);
rtl_write_byte(rtlpriv, FW_RSVD_PG_CRTL, tmp_byte);
rtl_write_dword(rtlpriv, TXDESC_MSK, 0xFFFFCFFF);
}
/* We enable high power and RA related mechanism after NIC
* initialized. */
if (hal_get_firmwareversion(rtlpriv) >= 0x35) {
/* Fw v.53 and later. */
rtl92s_phy_set_fw_cmd(hw, FW_CMD_RA_INIT);
} else if (hal_get_firmwareversion(rtlpriv) == 0x34) {
/* Fw v.52. */
rtl_write_dword(rtlpriv, WFM5, FW_RA_INIT);
rtl92s_phy_chk_fwcmd_iodone(hw);
} else {
/* Compatible earlier FW version. */
rtl_write_dword(rtlpriv, WFM5, FW_RA_RESET);
rtl92s_phy_chk_fwcmd_iodone(hw);
rtl_write_dword(rtlpriv, WFM5, FW_RA_ACTIVE);
rtl92s_phy_chk_fwcmd_iodone(hw);
rtl_write_dword(rtlpriv, WFM5, FW_RA_REFRESH);
rtl92s_phy_chk_fwcmd_iodone(hw);
}
/* Add to prevent ASPM bug. */
/* Always enable hst and NIC clock request. */
rtl92s_phy_switch_ephy_parameter(hw);
/* Security related
* 1. Clear all H/W keys.
* 2. Enable H/W encryption/decryption. */
rtl_cam_reset_all_entry(hw);
secr_value |= SCR_TXENCENABLE;
secr_value |= SCR_RXENCENABLE;
secr_value |= SCR_NOSKMC;
rtl_write_byte(rtlpriv, REG_SECR, secr_value);
for (i = 0; i < 4; i++)
rtl_write_dword(rtlpriv, wdcapra_add[i], 0x5e4322);
if (rtlphy->rf_type == RF_1T2R) {
bool mrc2set = true;
/* Turn on B-Path */
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_MRC, (u8 *)&mrc2set);
}
rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_ON);
rtl92s_dm_init(hw);
exit:
local_irq_restore(flags);
rtlpci->being_init_adapter = false;
return err;
}
void rtl92se_set_mac_addr(struct rtl_io *io, const u8 *addr)
{
/* This is a stub. */
}
void rtl92se_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
u32 reg_rcr = rtlpci->receive_config;
if (rtlpriv->psc.rfpwr_state != ERFON)
return;
if (check_bssid) {
reg_rcr |= (RCR_CBSSID);
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr));
} else if (!check_bssid) {
reg_rcr &= (~RCR_CBSSID);
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr));
}
}
static int _rtl92se_set_media_status(struct ieee80211_hw *hw,
enum nl80211_iftype type)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
u8 bt_msr = rtl_read_byte(rtlpriv, MSR);
u32 temp;
bt_msr &= ~MSR_LINK_MASK;
switch (type) {
case NL80211_IFTYPE_UNSPECIFIED:
bt_msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT);
RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
"Set Network type to NO LINK!\n");
break;
case NL80211_IFTYPE_ADHOC:
bt_msr |= (MSR_LINK_ADHOC << MSR_LINK_SHIFT);
RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
"Set Network type to Ad Hoc!\n");
break;
case NL80211_IFTYPE_STATION:
bt_msr |= (MSR_LINK_MANAGED << MSR_LINK_SHIFT);
RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
"Set Network type to STA!\n");
break;
case NL80211_IFTYPE_AP:
bt_msr |= (MSR_LINK_MASTER << MSR_LINK_SHIFT);
RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
"Set Network type to AP!\n");
break;
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
"Network type %d not supported!\n", type);
return 1;
break;
}
rtl_write_byte(rtlpriv, (MSR), bt_msr);
temp = rtl_read_dword(rtlpriv, TCR);
rtl_write_dword(rtlpriv, TCR, temp & (~BIT(8)));
rtl_write_dword(rtlpriv, TCR, temp | BIT(8));
return 0;
}
/* HW_VAR_MEDIA_STATUS & HW_VAR_CECHK_BSSID */
int rtl92se_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
if (_rtl92se_set_media_status(hw, type))
return -EOPNOTSUPP;
if (rtlpriv->mac80211.link_state == MAC80211_LINKED) {
if (type != NL80211_IFTYPE_AP)
rtl92se_set_check_bssid(hw, true);
} else {
rtl92se_set_check_bssid(hw, false);
}
return 0;
}
/* don't set REG_EDCA_BE_PARAM here because mac80211 will send pkt when scan */
void rtl92se_set_qos(struct ieee80211_hw *hw, int aci)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
rtl92s_dm_init_edca_turbo(hw);
switch (aci) {
case AC1_BK:
rtl_write_dword(rtlpriv, EDCAPARA_BK, 0xa44f);
break;
case AC0_BE:
/* rtl_write_dword(rtlpriv, EDCAPARA_BE, u4b_ac_param); */
break;
case AC2_VI:
rtl_write_dword(rtlpriv, EDCAPARA_VI, 0x5e4322);
break;
case AC3_VO:
rtl_write_dword(rtlpriv, EDCAPARA_VO, 0x2f3222);
break;
default:
RT_ASSERT(false, "invalid aci: %d !\n", aci);
break;
}
}
void rtl92se_enable_interrupt(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]);
/* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */
rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F);
}
void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv;
struct rtl_pci *rtlpci;
rtlpriv = rtl_priv(hw);
/* if firmware not available, no interrupts */
if (!rtlpriv || !rtlpriv->max_fw_size)
return;
rtlpci = rtl_pcidev(rtl_pcipriv(hw));
rtl_write_dword(rtlpriv, INTA_MASK, 0);
rtl_write_dword(rtlpriv, INTA_MASK + 4, 0);
synchronize_irq(rtlpci->pdev->irq);
}
static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
u8 waitcnt = 100;
bool result = false;
u8 tmp;
rtl_write_byte(rtlpriv, SYS_CLKR + 1, data);
/* Wait the MAC synchronized. */
udelay(400);
/* Check if it is set ready. */
tmp = rtl_read_byte(rtlpriv, SYS_CLKR + 1);
result = ((tmp & BIT(7)) == (data & BIT(7)));
if ((data & (BIT(6) | BIT(7))) == false) {
waitcnt = 100;
tmp = 0;
while (1) {
waitcnt--;
tmp = rtl_read_byte(rtlpriv, SYS_CLKR + 1);
if ((tmp & BIT(6)))
break;
pr_err("wait for BIT(6) return value %x\n", tmp);
if (waitcnt == 0)
break;
udelay(10);
}
if (waitcnt == 0)
result = false;
else
result = true;
}
return result;
}
static void _rtl92s_phy_set_rfhalt(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
u8 u1btmp;
if (rtlhal->driver_going2unload)
rtl_write_byte(rtlpriv, 0x560, 0x0);
/* Power save for BB/RF */
u1btmp = rtl_read_byte(rtlpriv, LDOV12D_CTRL);
u1btmp |= BIT(0);
rtl_write_byte(rtlpriv, LDOV12D_CTRL, u1btmp);
rtl_write_byte(rtlpriv, SPS1_CTRL, 0x0);
rtl_write_byte(rtlpriv, TXPAUSE, 0xFF);
rtl_write_word(rtlpriv, CMDR, 0x57FC);
udelay(100);
rtl_write_word(rtlpriv, CMDR, 0x77FC);
rtl_write_byte(rtlpriv, PHY_CCA, 0x0);
udelay(10);
rtl_write_word(rtlpriv, CMDR, 0x37FC);
udelay(10);
rtl_write_word(rtlpriv, CMDR, 0x77FC);
udelay(10);
rtl_write_word(rtlpriv, CMDR, 0x57FC);
rtl_write_word(rtlpriv, CMDR, 0x0000);
if (rtlhal->driver_going2unload) {
u1btmp = rtl_read_byte(rtlpriv, (REG_SYS_FUNC_EN + 1));
u1btmp &= ~(BIT(0));
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, u1btmp);
}
u1btmp = rtl_read_byte(rtlpriv, (SYS_CLKR + 1));
/* Add description. After switch control path. register
* after page1 will be invisible. We can not do any IO
* for register>0x40. After resume&MACIO reset, we need
* to remember previous reg content. */
if (u1btmp & BIT(7)) {
u1btmp &= ~(BIT(6) | BIT(7));
if (!_rtl92s_set_sysclk(hw, u1btmp)) {
pr_err("Switch ctrl path fail\n");
return;
}
}
/* Power save for MAC */
if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS &&
!rtlhal->driver_going2unload) {
/* enable LED function */
rtl_write_byte(rtlpriv, 0x03, 0xF9);
/* SW/HW radio off or halt adapter!! For example S3/S4 */
} else {
/* LED function disable. Power range is about 8mA now. */
/* if write 0xF1 disconnet_pci power
* ifconfig wlan0 down power are both high 35:70 */
/* if write oxF9 disconnet_pci power
* ifconfig wlan0 down power are both low 12:45*/
rtl_write_byte(rtlpriv, 0x03, 0xF9);
}
rtl_write_byte(rtlpriv, SYS_CLKR + 1, 0x70);
rtl_write_byte(rtlpriv, AFE_PLL_CTRL + 1, 0x68);
rtl_write_byte(rtlpriv, AFE_PLL_CTRL, 0x00);
rtl_write_byte(rtlpriv, LDOA15_CTRL, 0x34);
rtl_write_byte(rtlpriv, AFE_XTAL_CTRL, 0x0E);
RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
}
static void _rtl92se_gen_refreshledstate(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
struct rtl_led *pLed0 = &(pcipriv->ledctl.sw_led0);
if (rtlpci->up_first_time == 1)
return;
if (rtlpriv->psc.rfoff_reason == RF_CHANGE_BY_IPS)
rtl92se_sw_led_on(hw, pLed0);
else
rtl92se_sw_led_off(hw, pLed0);
}
static void _rtl92se_power_domain_init(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
u16 tmpu2b;
u8 tmpu1b;
rtlpriv->psc.pwrdomain_protect = true;
tmpu1b = rtl_read_byte(rtlpriv, (SYS_CLKR + 1));
if (tmpu1b & BIT(7)) {
tmpu1b &= ~(BIT(6) | BIT(7));
if (!_rtl92s_set_sysclk(hw, tmpu1b)) {
rtlpriv->psc.pwrdomain_protect = false;
return;
}
}
rtl_write_byte(rtlpriv, AFE_PLL_CTRL, 0x0);
rtl_write_byte(rtlpriv, LDOA15_CTRL, 0x34);
/* Reset MAC-IO and CPU and Core Digital BIT10/11/15 */
tmpu1b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
/* If IPS we need to turn LED on. So we not
* not disable BIT 3/7 of reg3. */
if (rtlpriv->psc.rfoff_reason & (RF_CHANGE_BY_IPS | RF_CHANGE_BY_HW))
tmpu1b &= 0xFB;
else
tmpu1b &= 0x73;
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b);
/* wait for BIT 10/11/15 to pull high automatically!! */
mdelay(1);
rtl_write_byte(rtlpriv, CMDR, 0);
rtl_write_byte(rtlpriv, TCR, 0);
/* Data sheet not define 0x562!!! Copy from WMAC!!!!! */
tmpu1b = rtl_read_byte(rtlpriv, 0x562);
tmpu1b |= 0x08;
rtl_write_byte(rtlpriv, 0x562, tmpu1b);
tmpu1b &= ~(BIT(3));
rtl_write_byte(rtlpriv, 0x562, tmpu1b);
/* Enable AFE clock source */
tmpu1b = rtl_read_byte(rtlpriv, AFE_XTAL_CTRL);
rtl_write_byte(rtlpriv, AFE_XTAL_CTRL, (tmpu1b | 0x01));
/* Delay 1.5ms */
udelay(1500);
tmpu1b = rtl_read_byte(rtlpriv, AFE_XTAL_CTRL + 1);
rtl_write_byte(rtlpriv, AFE_XTAL_CTRL + 1, (tmpu1b & 0xfb));
/* Enable AFE Macro Block's Bandgap */
tmpu1b = rtl_read_byte(rtlpriv, AFE_MISC);
rtl_write_byte(rtlpriv, AFE_MISC, (tmpu1b | BIT(0)));
mdelay(1);
/* Enable AFE Mbias */
tmpu1b = rtl_read_byte(rtlpriv, AFE_MISC);
rtl_write_byte(rtlpriv, AFE_MISC, (tmpu1b | 0x02));
mdelay(1);
/* Enable LDOA15 block */
tmpu1b = rtl_read_byte(rtlpriv, LDOA15_CTRL);
rtl_write_byte(rtlpriv, LDOA15_CTRL, (tmpu1b | BIT(0)));
/* Set Digital Vdd to Retention isolation Path. */
tmpu2b = rtl_read_word(rtlpriv, REG_SYS_ISO_CTRL);
rtl_write_word(rtlpriv, REG_SYS_ISO_CTRL, (tmpu2b | BIT(11)));
/* For warm reboot NIC disappera bug. */
tmpu2b = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN);
rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(13)));
rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL + 1, 0x68);
/* Enable AFE PLL Macro Block */
tmpu1b = rtl_read_byte(rtlpriv, AFE_PLL_CTRL);
rtl_write_byte(rtlpriv, AFE_PLL_CTRL, (tmpu1b | BIT(0) | BIT(4)));
/* Enable MAC 80MHZ clock */
tmpu1b = rtl_read_byte(rtlpriv, AFE_PLL_CTRL + 1);
rtl_write_byte(rtlpriv, AFE_PLL_CTRL + 1, (tmpu1b | BIT(0)));
mdelay(1);
/* Release isolation AFE PLL & MD */
rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL, 0xA6);
/* Enable MAC clock */
tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
rtl_write_word(rtlpriv, SYS_CLKR, (tmpu2b | BIT(12) | BIT(11)));
/* Enable Core digital and enable IOREG R/W */
tmpu2b = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN);
rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(11)));
/* enable REG_EN */
rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(11) | BIT(15)));
/* Switch the control path. */
tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
rtl_write_word(rtlpriv, SYS_CLKR, (tmpu2b & (~BIT(2))));
tmpu1b = rtl_read_byte(rtlpriv, (SYS_CLKR + 1));
tmpu1b = ((tmpu1b | BIT(7)) & (~BIT(6)));
if (!_rtl92s_set_sysclk(hw, tmpu1b)) {
rtlpriv->psc.pwrdomain_protect = false;
return;
}
rtl_write_word(rtlpriv, CMDR, 0x37FC);
/* After MACIO reset,we must refresh LED state. */
_rtl92se_gen_refreshledstate(hw);
rtlpriv->psc.pwrdomain_protect = false;
}
void rtl92se_card_disable(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
enum nl80211_iftype opmode;
u8 wait = 30;
rtlpriv->intf_ops->enable_aspm(hw);
if (rtlpci->driver_is_goingto_unload ||
ppsc->rfoff_reason > RF_CHANGE_BY_PS)
rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF);
/* we should chnge GPIO to input mode
* this will drop away current about 25mA*/
rtl8192se_gpiobit3_cfg_inputmode(hw);
/* this is very important for ips power save */
while (wait-- >= 10 && rtlpriv->psc.pwrdomain_protect) {
if (rtlpriv->psc.pwrdomain_protect)
mdelay(20);
else
break;
}
mac->link_state = MAC80211_NOLINK;
opmode = NL80211_IFTYPE_UNSPECIFIED;
_rtl92se_set_media_status(hw, opmode);
_rtl92s_phy_set_rfhalt(hw);
udelay(100);
}
void rtl92se_interrupt_recognized(struct ieee80211_hw *hw, u32 *p_inta,
u32 *p_intb)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
*p_inta = rtl_read_dword(rtlpriv, ISR) & rtlpci->irq_mask[0];
rtl_write_dword(rtlpriv, ISR, *p_inta);
*p_intb = rtl_read_dword(rtlpriv, ISR + 4) & rtlpci->irq_mask[1];
rtl_write_dword(rtlpriv, ISR + 4, *p_intb);
}
void rtl92se_set_beacon_related_registers(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
u16 bcntime_cfg = 0;
u16 bcn_cw = 6, bcn_ifs = 0xf;
u16 atim_window = 2;
/* ATIM Window (in unit of TU). */
rtl_write_word(rtlpriv, ATIMWND, atim_window);
/* Beacon interval (in unit of TU). */
rtl_write_word(rtlpriv, BCN_INTERVAL, mac->beacon_interval);
/* DrvErlyInt (in unit of TU). (Time to send
* interrupt to notify driver to change
* beacon content) */
rtl_write_word(rtlpriv, BCN_DRV_EARLY_INT, 10 << 4);
/* BcnDMATIM(in unit of us). Indicates the
* time before TBTT to perform beacon queue DMA */
rtl_write_word(rtlpriv, BCN_DMATIME, 256);
/* Force beacon frame transmission even
* after receiving beacon frame from
* other ad hoc STA */
rtl_write_byte(rtlpriv, BCN_ERR_THRESH, 100);
/* Beacon Time Configuration */
if (mac->opmode == NL80211_IFTYPE_ADHOC)
bcntime_cfg |= (bcn_cw << BCN_TCFG_CW_SHIFT);
/* TODO: bcn_ifs may required to be changed on ASIC */
bcntime_cfg |= bcn_ifs << BCN_TCFG_IFS;
/*for beacon changed */
rtl92s_phy_set_beacon_hwreg(hw, mac->beacon_interval);
}
void rtl92se_set_beacon_interval(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
u16 bcn_interval = mac->beacon_interval;
/* Beacon interval (in unit of TU). */
rtl_write_word(rtlpriv, BCN_INTERVAL, bcn_interval);
/* 2008.10.24 added by tynli for beacon changed. */
rtl92s_phy_set_beacon_hwreg(hw, bcn_interval);
}
void rtl92se_update_interrupt_mask(struct ieee80211_hw *hw,
u32 add_msr, u32 rm_msr)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, "add_msr:%x, rm_msr:%x\n",
add_msr, rm_msr);
if (add_msr)
rtlpci->irq_mask[0] |= add_msr;
if (rm_msr)
rtlpci->irq_mask[0] &= (~rm_msr);
rtl92se_disable_interrupt(hw);
rtl92se_enable_interrupt(hw);
}
static void _rtl8192se_get_IC_Inferiority(struct ieee80211_hw *hw)
{
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
u8 efuse_id;
rtlhal->ic_class = IC_INFERIORITY_A;
/* Only retrieving while using EFUSE. */
if ((rtlefuse->epromtype == EEPROM_BOOT_EFUSE) &&
!rtlefuse->autoload_failflag) {
efuse_id = efuse_read_1byte(hw, EFUSE_IC_ID_OFFSET);
if (efuse_id == 0xfe)
rtlhal->ic_class = IC_INFERIORITY_B;
}
}
static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
struct rtl_phy *rtlphy = &(rtlpriv->phy);
u16 i, usvalue;
u16 eeprom_id;
u8 tempval;
u8 hwinfo[HWSET_MAX_SIZE_92S];
u8 rf_path, index;
if (rtlefuse->epromtype == EEPROM_93C46) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
"RTL819X Not boot from eeprom, check it !!\n");
} else if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) {
rtl_efuse_shadow_map_update(hw);
memcpy((void *)hwinfo, (void *)
&rtlefuse->efuse_map[EFUSE_INIT_MAP][0],
HWSET_MAX_SIZE_92S);
}
RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP",
hwinfo, HWSET_MAX_SIZE_92S);
eeprom_id = *((u16 *)&hwinfo[0]);
if (eeprom_id != RTL8190_EEPROM_ID) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
"EEPROM ID(%#x) is invalid!!\n", eeprom_id);
rtlefuse->autoload_failflag = true;
} else {
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
rtlefuse->autoload_failflag = false;
}
if (rtlefuse->autoload_failflag)
return;
_rtl8192se_get_IC_Inferiority(hw);
/* Read IC Version && Channel Plan */
/* VID, DID SE 0xA-D */
rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
"EEPROMId = 0x%4x\n", eeprom_id);
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
"EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
"EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
"EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
"EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
for (i = 0; i < 6; i += 2) {
usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
*((u16 *) (&rtlefuse->dev_addr[i])) = usvalue;
}
for (i = 0; i < 6; i++)
rtl_write_byte(rtlpriv, MACIDR0 + i, rtlefuse->dev_addr[i]);
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr);
/* Get Tx Power Level by Channel */
/* Read Tx power of Channel 1 ~ 14 from EEPROM. */
/* 92S suupport RF A & B */
for (rf_path = 0; rf_path < 2; rf_path++) {
for (i = 0; i < 3; i++) {
/* Read CCK RF A & B Tx power */
rtlefuse->eeprom_chnlarea_txpwr_cck[rf_path][i] =
hwinfo[EEPROM_TXPOWERBASE + rf_path * 3 + i];
/* Read OFDM RF A & B Tx power for 1T */
rtlefuse->eeprom_chnlarea_txpwr_ht40_1s[rf_path][i] =
hwinfo[EEPROM_TXPOWERBASE + 6 + rf_path * 3 + i];
/* Read OFDM RF A & B Tx power for 2T */
rtlefuse->eprom_chnl_txpwr_ht40_2sdf[rf_path][i]
= hwinfo[EEPROM_TXPOWERBASE + 12 +
rf_path * 3 + i];
}
}
for (rf_path = 0; rf_path < 2; rf_path++)
for (i = 0; i < 3; i++)
RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
"RF(%d) EEPROM CCK Area(%d) = 0x%x\n",
rf_path, i,
rtlefuse->eeprom_chnlarea_txpwr_cck
[rf_path][i]);
for (rf_path = 0; rf_path < 2; rf_path++)
for (i = 0; i < 3; i++)
RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
"RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
rf_path, i,
rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
[rf_path][i]);
for (rf_path = 0; rf_path < 2; rf_path++)
for (i = 0; i < 3; i++)
RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
"RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
rf_path, i,
rtlefuse->eprom_chnl_txpwr_ht40_2sdf
[rf_path][i]);
for (rf_path = 0; rf_path < 2; rf_path++) {
/* Assign dedicated channel tx power */
for (i = 0; i < 14; i++) {
/* channel 1~3 use the same Tx Power Level. */
if (i < 3)
index = 0;
/* Channel 4-8 */
else if (i < 8)
index = 1;
/* Channel 9-14 */
else
index = 2;
/* Record A & B CCK /OFDM - 1T/2T Channel area
* tx power */
rtlefuse->txpwrlevel_cck[rf_path][i] =
rtlefuse->eeprom_chnlarea_txpwr_cck
[rf_path][index];
rtlefuse->txpwrlevel_ht40_1s[rf_path][i] =
rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
[rf_path][index];
rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
rtlefuse->eprom_chnl_txpwr_ht40_2sdf
[rf_path][index];
}
for (i = 0; i < 14; i++) {
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n",
rf_path, i,
rtlefuse->txpwrlevel_cck[rf_path][i],
rtlefuse->txpwrlevel_ht40_1s[rf_path][i],
rtlefuse->txpwrlevel_ht40_2s[rf_path][i]);
}
}
for (rf_path = 0; rf_path < 2; rf_path++) {
for (i = 0; i < 3; i++) {
/* Read Power diff limit. */
rtlefuse->eeprom_pwrgroup[rf_path][i] =
hwinfo[EEPROM_TXPWRGROUP + rf_path * 3 + i];
}
}
for (rf_path = 0; rf_path < 2; rf_path++) {
/* Fill Pwr group */
for (i = 0; i < 14; i++) {
/* Chanel 1-3 */
if (i < 3)
index = 0;
/* Channel 4-8 */
else if (i < 8)
index = 1;
/* Channel 9-13 */
else
index = 2;
rtlefuse->pwrgroup_ht20[rf_path][i] =
(rtlefuse->eeprom_pwrgroup[rf_path][index] &
0xf);
rtlefuse->pwrgroup_ht40[rf_path][i] =
((rtlefuse->eeprom_pwrgroup[rf_path][index] &
0xf0) >> 4);
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"RF-%d pwrgroup_ht20[%d] = 0x%x\n",
rf_path, i,
rtlefuse->pwrgroup_ht20[rf_path][i]);
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"RF-%d pwrgroup_ht40[%d] = 0x%x\n",
rf_path, i,
rtlefuse->pwrgroup_ht40[rf_path][i]);
}
}
for (i = 0; i < 14; i++) {
/* Read tx power difference between HT OFDM 20/40 MHZ */
/* channel 1-3 */
if (i < 3)
index = 0;
/* Channel 4-8 */
else if (i < 8)
index = 1;
/* Channel 9-14 */
else
index = 2;
tempval = hwinfo[EEPROM_TX_PWR_HT20_DIFF + index] & 0xff;
rtlefuse->txpwr_ht20diff[RF90_PATH_A][i] = (tempval & 0xF);
rtlefuse->txpwr_ht20diff[RF90_PATH_B][i] =
((tempval >> 4) & 0xF);
/* Read OFDM<->HT tx power diff */
/* Channel 1-3 */
if (i < 3)
index = 0;
/* Channel 4-8 */
else if (i < 8)
index = 0x11;
/* Channel 9-14 */
else
index = 1;
tempval = hwinfo[EEPROM_TX_PWR_OFDM_DIFF + index] & 0xff;
rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i] =
(tempval & 0xF);
rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i] =
((tempval >> 4) & 0xF);
tempval = hwinfo[TX_PWR_SAFETY_CHK];
rtlefuse->txpwr_safetyflag = (tempval & 0x01);
}
rtlefuse->eeprom_regulatory = 0;
if (rtlefuse->eeprom_version >= 2) {
/* BIT(0)~2 */
if (rtlefuse->eeprom_version >= 4)
rtlefuse->eeprom_regulatory =
(hwinfo[EEPROM_REGULATORY] & 0x7);
else /* BIT(0) */
rtlefuse->eeprom_regulatory =
(hwinfo[EEPROM_REGULATORY] & 0x1);
}
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
for (i = 0; i < 14; i++)
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"RF-A Ht20 to HT40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]);
for (i = 0; i < 14; i++)
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"RF-A Legacy to Ht40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]);
for (i = 0; i < 14; i++)
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"RF-B Ht20 to HT40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]);
for (i = 0; i < 14; i++)
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"RF-B Legacy to HT40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"TxPwrSafetyFlag = %d\n", rtlefuse->txpwr_safetyflag);
/* Read RF-indication and Tx Power gain
* index diff of legacy to HT OFDM rate. */
tempval = hwinfo[EEPROM_RFIND_POWERDIFF] & 0xff;
rtlefuse->eeprom_txpowerdiff = tempval;
rtlefuse->legacy_httxpowerdiff =
rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][0];
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"TxPowerDiff = %#x\n", rtlefuse->eeprom_txpowerdiff);
/* Get TSSI value for each path. */
usvalue = *(u16 *)&hwinfo[EEPROM_TSSI_A];
rtlefuse->eeprom_tssi[RF90_PATH_A] = (u8)((usvalue & 0xff00) >> 8);
usvalue = hwinfo[EEPROM_TSSI_B];
rtlefuse->eeprom_tssi[RF90_PATH_B] = (u8)(usvalue & 0xff);
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, "TSSI_A = 0x%x, TSSI_B = 0x%x\n",
rtlefuse->eeprom_tssi[RF90_PATH_A],
rtlefuse->eeprom_tssi[RF90_PATH_B]);
/* Read antenna tx power offset of B/C/D to A from EEPROM */
/* and read ThermalMeter from EEPROM */
tempval = hwinfo[EEPROM_THERMALMETER];
rtlefuse->eeprom_thermalmeter = tempval;
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter);
/* ThermalMeter, BIT(0)~3 for RFIC1, BIT(4)~7 for RFIC2 */
rtlefuse->thermalmeter[0] = (rtlefuse->eeprom_thermalmeter & 0x1f);
rtlefuse->tssi_13dbm = rtlefuse->eeprom_thermalmeter * 100;
/* Read CrystalCap from EEPROM */
tempval = hwinfo[EEPROM_CRYSTALCAP] >> 4;
rtlefuse->eeprom_crystalcap = tempval;
/* CrystalCap, BIT(12)~15 */
rtlefuse->crystalcap = rtlefuse->eeprom_crystalcap;
/* Read IC Version && Channel Plan */
/* Version ID, Channel plan */
rtlefuse->eeprom_channelplan = hwinfo[EEPROM_CHANNELPLAN];
rtlefuse->txpwr_fromeprom = true;
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"EEPROM ChannelPlan = 0x%4x\n", rtlefuse->eeprom_channelplan);
/* Read Customer ID or Board Type!!! */
tempval = hwinfo[EEPROM_BOARDTYPE];
/* Change RF type definition */
if (tempval == 0)
rtlphy->rf_type = RF_2T2R;
else if (tempval == 1)
rtlphy->rf_type = RF_1T2R;
else if (tempval == 2)
rtlphy->rf_type = RF_1T2R;
else if (tempval == 3)
rtlphy->rf_type = RF_1T1R;
/* 1T2R but 1SS (1x1 receive combining) */
rtlefuse->b1x1_recvcombine = false;
if (rtlphy->rf_type == RF_1T2R) {
tempval = rtl_read_byte(rtlpriv, 0x07);
if (!(tempval & BIT(0))) {
rtlefuse->b1x1_recvcombine = true;
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
"RF_TYPE=1T2R but only 1SS\n");
}
}
rtlefuse->b1ss_support = rtlefuse->b1x1_recvcombine;
rtlefuse->eeprom_oemid = *&hwinfo[EEPROM_CUSTOMID];
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROM Customer ID: 0x%2x",
rtlefuse->eeprom_oemid);
/* set channel paln to world wide 13 */
rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13;
}
void rtl92se_read_eeprom_info(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
u8 tmp_u1b = 0;
tmp_u1b = rtl_read_byte(rtlpriv, EPROM_CMD);
if (tmp_u1b & BIT(4)) {
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n");
rtlefuse->epromtype = EEPROM_93C46;
} else {
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n");
rtlefuse->epromtype = EEPROM_BOOT_EFUSE;
}
if (tmp_u1b & BIT(5)) {
RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
rtlefuse->autoload_failflag = false;
_rtl92se_read_adapter_info(hw);
} else {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Autoload ERR!!\n");
rtlefuse->autoload_failflag = true;
}
}
static void rtl92se_update_hal_rate_table(struct ieee80211_hw *hw,
struct ieee80211_sta *sta)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_phy *rtlphy = &(rtlpriv->phy);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
u32 ratr_value;
u8 ratr_index = 0;
u8 nmode = mac->ht_enable;
u8 mimo_ps = IEEE80211_SMPS_OFF;
u16 shortgi_rate = 0;
u32 tmp_ratr_value = 0;
u8 curtxbw_40mhz = mac->bw_40;
u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
1 : 0;
u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
1 : 0;
enum wireless_mode wirelessmode = mac->mode;
if (rtlhal->current_bandtype == BAND_ON_5G)
ratr_value = sta->supp_rates[1] << 4;
else
ratr_value = sta->supp_rates[0];
if (mac->opmode == NL80211_IFTYPE_ADHOC)
ratr_value = 0xfff;
ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
sta->ht_cap.mcs.rx_mask[0] << 12);
switch (wirelessmode) {
case WIRELESS_MODE_B:
ratr_value &= 0x0000000D;
break;
case WIRELESS_MODE_G:
ratr_value &= 0x00000FF5;
break;
case WIRELESS_MODE_N_24G:
case WIRELESS_MODE_N_5G:
nmode = 1;
if (mimo_ps == IEEE80211_SMPS_STATIC) {
ratr_value &= 0x0007F005;
} else {
u32 ratr_mask;
if (get_rf_type(rtlphy) == RF_1T2R ||
get_rf_type(rtlphy) == RF_1T1R) {
if (curtxbw_40mhz)
ratr_mask = 0x000ff015;
else
ratr_mask = 0x000ff005;
} else {
if (curtxbw_40mhz)
ratr_mask = 0x0f0ff015;
else
ratr_mask = 0x0f0ff005;
}
ratr_value &= ratr_mask;
}
break;
default:
if (rtlphy->rf_type == RF_1T2R)
ratr_value &= 0x000ff0ff;
else
ratr_value &= 0x0f0ff0ff;
break;
}
if (rtlpriv->rtlhal.version >= VERSION_8192S_BCUT)
ratr_value &= 0x0FFFFFFF;
else if (rtlpriv->rtlhal.version == VERSION_8192S_ACUT)
ratr_value &= 0x0FFFFFF0;
if (nmode && ((curtxbw_40mhz &&
curshortgi_40mhz) || (!curtxbw_40mhz &&
curshortgi_20mhz))) {
ratr_value |= 0x10000000;
tmp_ratr_value = (ratr_value >> 12);
for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) {
if ((1 << shortgi_rate) & tmp_ratr_value)
break;
}
shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) |
(shortgi_rate << 4) | (shortgi_rate);
rtl_write_byte(rtlpriv, SG_RATE, shortgi_rate);
}
rtl_write_dword(rtlpriv, ARFR0 + ratr_index * 4, ratr_value);
if (ratr_value & 0xfffff000)
rtl92s_phy_set_fw_cmd(hw, FW_CMD_RA_REFRESH_N);
else
rtl92s_phy_set_fw_cmd(hw, FW_CMD_RA_REFRESH_BG);
RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n",
rtl_read_dword(rtlpriv, ARFR0));
}
static void rtl92se_update_hal_rate_mask(struct ieee80211_hw *hw,
struct ieee80211_sta *sta,
u8 rssi_level)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_phy *rtlphy = &(rtlpriv->phy);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_sta_info *sta_entry = NULL;
u32 ratr_bitmap;
u8 ratr_index = 0;
u8 curtxbw_40mhz = (sta->bandwidth >= IEEE80211_STA_RX_BW_40) ? 1 : 0;
u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
1 : 0;
u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
1 : 0;
enum wireless_mode wirelessmode = 0;
bool shortgi = false;
u32 ratr_value = 0;
u8 shortgi_rate = 0;
u32 mask = 0;
u32 band = 0;
bool bmulticast = false;
u8 macid = 0;
u8 mimo_ps = IEEE80211_SMPS_OFF;
sta_entry = (struct rtl_sta_info *) sta->drv_priv;
wirelessmode = sta_entry->wireless_mode;
if (mac->opmode == NL80211_IFTYPE_STATION)
curtxbw_40mhz = mac->bw_40;
else if (mac->opmode == NL80211_IFTYPE_AP ||
mac->opmode == NL80211_IFTYPE_ADHOC)
macid = sta->aid + 1;
if (rtlhal->current_bandtype == BAND_ON_5G)
ratr_bitmap = sta->supp_rates[1] << 4;
else
ratr_bitmap = sta->supp_rates[0];
if (mac->opmode == NL80211_IFTYPE_ADHOC)
ratr_bitmap = 0xfff;
ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
sta->ht_cap.mcs.rx_mask[0] << 12);
switch (wirelessmode) {
case WIRELESS_MODE_B:
band |= WIRELESS_11B;
ratr_index = RATR_INX_WIRELESS_B;
if (ratr_bitmap & 0x0000000c)
ratr_bitmap &= 0x0000000d;
else
ratr_bitmap &= 0x0000000f;
break;
case WIRELESS_MODE_G:
band |= (WIRELESS_11G | WIRELESS_11B);
ratr_index = RATR_INX_WIRELESS_GB;
if (rssi_level == 1)
ratr_bitmap &= 0x00000f00;
else if (rssi_level == 2)
ratr_bitmap &= 0x00000ff0;
else
ratr_bitmap &= 0x00000ff5;
break;
case WIRELESS_MODE_A:
band |= WIRELESS_11A;
ratr_index = RATR_INX_WIRELESS_A;
ratr_bitmap &= 0x00000ff0;
break;
case WIRELESS_MODE_N_24G:
case WIRELESS_MODE_N_5G:
band |= (WIRELESS_11N | WIRELESS_11G | WIRELESS_11B);
ratr_index = RATR_INX_WIRELESS_NGB;
if (mimo_ps == IEEE80211_SMPS_STATIC) {
if (rssi_level == 1)
ratr_bitmap &= 0x00070000;
else if (rssi_level == 2)
ratr_bitmap &= 0x0007f000;
else
ratr_bitmap &= 0x0007f005;
} else {
if (rtlphy->rf_type == RF_1T2R ||
rtlphy->rf_type == RF_1T1R) {
if (rssi_level == 1) {
ratr_bitmap &= 0x000f0000;
} else if (rssi_level == 3) {
ratr_bitmap &= 0x000fc000;
} else if (rssi_level == 5) {
ratr_bitmap &= 0x000ff000;
} else {
if (curtxbw_40mhz)
ratr_bitmap &= 0x000ff015;
else
ratr_bitmap &= 0x000ff005;
}
} else {
if (rssi_level == 1) {
ratr_bitmap &= 0x0f8f0000;
} else if (rssi_level == 3) {
ratr_bitmap &= 0x0f8fc000;
} else if (rssi_level == 5) {
ratr_bitmap &= 0x0f8ff000;
} else {
if (curtxbw_40mhz)
ratr_bitmap &= 0x0f8ff015;
else
ratr_bitmap &= 0x0f8ff005;
}
}
}
if ((curtxbw_40mhz && curshortgi_40mhz) ||
(!curtxbw_40mhz && curshortgi_20mhz)) {
if (macid == 0)
shortgi = true;
else if (macid == 1)
shortgi = false;
}
break;
default:
band |= (WIRELESS_11N | WIRELESS_11G | WIRELESS_11B);
ratr_index = RATR_INX_WIRELESS_NGB;
if (rtlphy->rf_type == RF_1T2R)
ratr_bitmap &= 0x000ff0ff;
else
ratr_bitmap &= 0x0f8ff0ff;
break;
}
sta_entry->ratr_index = ratr_index;
if (rtlpriv->rtlhal.version >= VERSION_8192S_BCUT)
ratr_bitmap &= 0x0FFFFFFF;
else if (rtlpriv->rtlhal.version == VERSION_8192S_ACUT)
ratr_bitmap &= 0x0FFFFFF0;
if (shortgi) {
ratr_bitmap |= 0x10000000;
/* Get MAX MCS available. */
ratr_value = (ratr_bitmap >> 12);
for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) {
if ((1 << shortgi_rate) & ratr_value)
break;
}
shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) |
(shortgi_rate << 4) | (shortgi_rate);
rtl_write_byte(rtlpriv, SG_RATE, shortgi_rate);
}
mask |= (bmulticast ? 1 : 0) << 9 | (macid & 0x1f) << 4 | (band & 0xf);
RT_TRACE(rtlpriv, COMP_RATR, DBG_TRACE, "mask = %x, bitmap = %x\n",
mask, ratr_bitmap);
rtl_write_dword(rtlpriv, 0x2c4, ratr_bitmap);
rtl_write_dword(rtlpriv, WFM5, (FW_RA_UPDATE_MASK | (mask << 8)));
if (macid != 0)
sta_entry->ratr_index = ratr_index;
}
void rtl92se_update_hal_rate_tbl(struct ieee80211_hw *hw,
struct ieee80211_sta *sta, u8 rssi_level)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
if (rtlpriv->dm.useramask)
rtl92se_update_hal_rate_mask(hw, sta, rssi_level);
else
rtl92se_update_hal_rate_table(hw, sta);
}
void rtl92se_update_channel_access_setting(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
u16 sifs_timer;
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
&mac->slot_time);
sifs_timer = 0x0e0e;
rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SIFS, (u8 *)&sifs_timer);
}
/* this ifunction is for RFKILL, it's different with windows,
* because UI will disable wireless when GPIO Radio Off.
* And here we not check or Disable/Enable ASPM like windows*/
bool rtl92se_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
enum rf_pwrstate rfpwr_toset /*, cur_rfstate */;
unsigned long flag = 0;
bool actuallyset = false;
bool turnonbypowerdomain = false;
/* just 8191se can check gpio before firstup, 92c/92d have fixed it */
if ((rtlpci->up_first_time == 1) || (rtlpci->being_init_adapter))
return false;
if (ppsc->swrf_processing)
return false;
spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag);
if (ppsc->rfchange_inprogress) {
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag);
return false;
} else {
ppsc->rfchange_inprogress = true;
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag);
}
/* cur_rfstate = ppsc->rfpwr_state;*/
/* because after _rtl92s_phy_set_rfhalt, all power
* closed, so we must open some power for GPIO check,
* or we will always check GPIO RFOFF here,
* And we should close power after GPIO check */
if (RT_IN_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC)) {
_rtl92se_power_domain_init(hw);
turnonbypowerdomain = true;
}
rfpwr_toset = _rtl92se_rf_onoff_detect(hw);
if ((ppsc->hwradiooff) && (rfpwr_toset == ERFON)) {
RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
"RFKILL-HW Radio ON, RF ON\n");
rfpwr_toset = ERFON;
ppsc->hwradiooff = false;
actuallyset = true;
} else if ((!ppsc->hwradiooff) && (rfpwr_toset == ERFOFF)) {
RT_TRACE(rtlpriv, COMP_RF,
DBG_DMESG, "RFKILL-HW Radio OFF, RF OFF\n");
rfpwr_toset = ERFOFF;
ppsc->hwradiooff = true;
actuallyset = true;
}
if (actuallyset) {
spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag);
ppsc->rfchange_inprogress = false;
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag);
/* this not include ifconfig wlan0 down case */
/* } else if (rfpwr_toset == ERFOFF || cur_rfstate == ERFOFF) { */
} else {
/* because power_domain_init may be happen when
* _rtl92s_phy_set_rfhalt, this will open some powers
* and cause current increasing about 40 mA for ips,
* rfoff and ifconfig down, so we set
* _rtl92s_phy_set_rfhalt again here */
if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC &&
turnonbypowerdomain) {
_rtl92s_phy_set_rfhalt(hw);
RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
}
spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag);
ppsc->rfchange_inprogress = false;
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag);
}
*valid = 1;
return !ppsc->hwradiooff;
}
/* Is_wepkey just used for WEP used as group & pairwise key
* if pairwise is AES ang group is WEP Is_wepkey == false.*/
void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr,
bool is_group, u8 enc_algo, bool is_wepkey, bool clear_all)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
u8 *macaddr = p_macaddr;
u32 entry_id = 0;
bool is_pairwise = false;
static u8 cam_const_addr[4][6] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
};
static u8 cam_const_broad[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
if (clear_all) {
u8 idx = 0;
u8 cam_offset = 0;
u8 clear_number = 5;
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n");
for (idx = 0; idx < clear_number; idx++) {
rtl_cam_mark_invalid(hw, cam_offset + idx);
rtl_cam_empty_entry(hw, cam_offset + idx);
if (idx < 5) {
memset(rtlpriv->sec.key_buf[idx], 0,
MAX_KEY_LEN);
rtlpriv->sec.key_len[idx] = 0;
}
}
} else {
switch (enc_algo) {
case WEP40_ENCRYPTION:
enc_algo = CAM_WEP40;
break;
case WEP104_ENCRYPTION:
enc_algo = CAM_WEP104;
break;
case TKIP_ENCRYPTION:
enc_algo = CAM_TKIP;
break;
case AESCCMP_ENCRYPTION:
enc_algo = CAM_AES;
break;
default:
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
"switch case not processed\n");
enc_algo = CAM_TKIP;
break;
}
if (is_wepkey || rtlpriv->sec.use_defaultkey) {
macaddr = cam_const_addr[key_index];
entry_id = key_index;
} else {
if (is_group) {
macaddr = cam_const_broad;
entry_id = key_index;
} else {
if (mac->opmode == NL80211_IFTYPE_AP) {
entry_id = rtl_cam_get_free_entry(hw,
p_macaddr);
if (entry_id >= TOTAL_CAM_ENTRY) {
RT_TRACE(rtlpriv,
COMP_SEC, DBG_EMERG,
"Can not find free hw security cam entry\n");
return;
}
} else {
entry_id = CAM_PAIRWISE_KEY_POSITION;
}
key_index = PAIRWISE_KEYIDX;
is_pairwise = true;
}
}
if (rtlpriv->sec.key_len[key_index] == 0) {
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
"delete one entry, entry_id is %d\n",
entry_id);
if (mac->opmode == NL80211_IFTYPE_AP)
rtl_cam_del_entry(hw, p_macaddr);
rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
} else {
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
"add one entry\n");
if (is_pairwise) {
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
"set Pairwise key\n");
rtl_cam_add_one_entry(hw, macaddr, key_index,
entry_id, enc_algo,
CAM_CONFIG_NO_USEDK,
rtlpriv->sec.key_buf[key_index]);
} else {
RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
"set group key\n");
if (mac->opmode == NL80211_IFTYPE_ADHOC) {
rtl_cam_add_one_entry(hw,
rtlefuse->dev_addr,
PAIRWISE_KEYIDX,
CAM_PAIRWISE_KEY_POSITION,
enc_algo, CAM_CONFIG_NO_USEDK,
rtlpriv->sec.key_buf[entry_id]);
}
rtl_cam_add_one_entry(hw, macaddr, key_index,
entry_id, enc_algo,
CAM_CONFIG_NO_USEDK,
rtlpriv->sec.key_buf[entry_id]);
}
}
}
}
void rtl92se_suspend(struct ieee80211_hw *hw)
{
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
rtlpci->up_first_time = true;
}
void rtl92se_resume(struct ieee80211_hw *hw)
{
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
u32 val;
pci_read_config_dword(rtlpci->pdev, 0x40, &val);
if ((val & 0x0000ff00) != 0)
pci_write_config_dword(rtlpci->pdev, 0x40,
val & 0xffff00ff);
}
/* Turn on AAP (RCR:bit 0) for promicuous mode. */
void rtl92se_allow_all_destaddr(struct ieee80211_hw *hw,
bool allow_all_da, bool write_into_reg)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
if (allow_all_da) /* Set BIT0 */
rtlpci->receive_config |= RCR_AAP;
else /* Clear BIT0 */
rtlpci->receive_config &= ~RCR_AAP;
if (write_into_reg)
rtl_write_dword(rtlpriv, RCR, rtlpci->receive_config);
RT_TRACE(rtlpriv, COMP_TURBO | COMP_INIT, DBG_LOUD,
"receive_config=0x%08X, write_into_reg=%d\n",
rtlpci->receive_config, write_into_reg);
}
|
3e2cc623258bbe3a6b4461aa9cbd0e38e3e674a1
|
9d72247289d2a918797235bd5157566c40a4b342
|
/src/request_util.c
|
71e9125e3de7fbce4d76190904153599a16483a4
|
[
"MIT"
] |
permissive
|
jeremycw/httpserver.h
|
ab022634a9177b877242e598a9c9fa1d2bad30f6
|
1cee758aba7c2272cb65e28d506e5384d4f96d73
|
refs/heads/master
| 2023-07-06T10:45:49.191814
| 2023-02-21T23:51:35
| 2023-02-21T23:51:35
| 222,545,982
| 1,814
| 143
|
MIT
| 2023-07-04T12:30:20
| 2019-11-18T21:15:09
|
C
|
UTF-8
|
C
| false
| false
| 3,740
|
c
|
request_util.c
|
#include <stdlib.h>
#include <string.h>
#ifndef HTTPSERVER_IMPL
#include "common.h"
#include "request_util.h"
#endif
int _hs_case_insensitive_cmp(char const *a, char const *b, int len) {
for (int i = 0; i < len; i++) {
char c1 = a[i] >= 'A' && a[i] <= 'Z' ? a[i] + 32 : a[i];
char c2 = b[i] >= 'A' && b[i] <= 'Z' ? b[i] + 32 : b[i];
if (c1 != c2)
return 0;
}
return 1;
}
http_string_t hs_get_token_string(http_request_t *request,
enum hsh_token_e token_type) {
http_string_t str = {0, 0};
if (request->tokens.buf == NULL)
return str;
for (int i = 0; i < request->tokens.size; i++) {
struct hsh_token_s token = request->tokens.buf[i];
if (token.type == token_type) {
str.buf = &request->buffer.buf[token.index];
str.len = token.len;
return str;
}
}
return str;
}
http_string_t hs_request_header(http_request_t *request, char const *key) {
int len = strlen(key);
for (int i = 0; i < request->tokens.size; i++) {
struct hsh_token_s token = request->tokens.buf[i];
if (token.type == HSH_TOK_HEADER_KEY && token.len == len) {
if (_hs_case_insensitive_cmp(&request->buffer.buf[token.index], key,
len)) {
token = request->tokens.buf[i + 1];
return (http_string_t){.buf = &request->buffer.buf[token.index],
.len = token.len};
}
}
}
return (http_string_t){};
}
void hs_request_detect_keep_alive_flag(http_request_t *request) {
http_string_t str = hs_get_token_string(request, HSH_TOK_VERSION);
if (str.buf == NULL)
return;
int version = str.buf[str.len - 1] == '1';
str = hs_request_header(request, "Connection");
if ((str.len == 5 && _hs_case_insensitive_cmp(str.buf, "close", 5)) ||
(str.len == 0 && version == HTTP_1_0)) {
HTTP_FLAG_CLEAR(request->flags, HTTP_KEEP_ALIVE);
} else {
HTTP_FLAG_SET(request->flags, HTTP_KEEP_ALIVE);
}
}
int _hs_get_header_key_val(http_request_t *request, http_string_t *key,
http_string_t *val, int iter) {
struct hsh_token_s token = request->tokens.buf[iter];
if (request->tokens.buf[iter].type == HSH_TOK_HEADERS_DONE)
return 0;
*key = (http_string_t){.buf = &request->buffer.buf[token.index],
.len = token.len};
token = request->tokens.buf[iter + 1];
*val = (http_string_t){.buf = &request->buffer.buf[token.index],
.len = token.len};
return 1;
}
int hs_request_iterate_headers(http_request_t *request, http_string_t *key,
http_string_t *val, int *iter) {
if (*iter == 0) {
for (; *iter < request->tokens.size; (*iter)++) {
struct hsh_token_s token = request->tokens.buf[*iter];
if (token.type == HSH_TOK_HEADER_KEY) {
int more = _hs_get_header_key_val(request, key, val, *iter);
(*iter)++;
return more;
}
}
return 0;
} else {
(*iter)++;
int more = _hs_get_header_key_val(request, key, val, *iter);
(*iter)++;
return more;
}
}
void hs_request_set_keep_alive_flag(http_request_t *request, int directive) {
if (directive == HTTP_KEEP_ALIVE) {
HTTP_FLAG_CLEAR(request->flags, HTTP_AUTOMATIC);
HTTP_FLAG_SET(request->flags, HTTP_KEEP_ALIVE);
} else if (directive == HTTP_CLOSE) {
HTTP_FLAG_CLEAR(request->flags, HTTP_AUTOMATIC);
HTTP_FLAG_CLEAR(request->flags, HTTP_KEEP_ALIVE);
}
}
http_string_t hs_request_chunk(struct http_request_s *request) {
struct hsh_token_s token = request->tokens.buf[request->tokens.size - 1];
return (http_string_t){.buf = &request->buffer.buf[token.index],
.len = token.len};
}
|
373c2d7a0ac4cd66d0024b5548c4a6e2c4c02d76
|
631fa563ce427d7851ec7a1839532fd06d94ed45
|
/tests/tests/thumb-to-arm/thumb.c
|
1ccf121f261b9bfa32842c0710a91b5e517f6c1b
|
[
"Apache-2.0"
] |
permissive
|
cojocar/bin2llvm
|
72d6e5821834becf8e04208673c0f52bb586711e
|
56f20d39b4dd0ece862067158220aabeb0121426
|
refs/heads/master
| 2020-12-30T15:41:51.225129
| 2018-06-05T12:43:23
| 2018-06-05T12:43:29
| 91,162,880
| 144
| 17
| null | null | null | null |
UTF-8
|
C
| false
| false
| 94
|
c
|
thumb.c
|
extern void call_me_from_thumb(void);
void
call_me_from_arm(void)
{
call_me_from_thumb();
}
|
ce3c7d925a4cdc5bf3b47ac0de16a0a83c27c62a
|
ca4c4631f3d47a90b8415bbe70dbc7cae18c071e
|
/unit_tests/matrix_free/UnitTestLinearDiffusionMetric.C
|
cac95382b286de2a579f2a04d4e1597f0aa9c191
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
Exawind/nalu-wind
|
5765078c445d379ea952d2b25a01f5ff490837a6
|
722cd7757a412c9306645963808047824c312a17
|
refs/heads/master
| 2023-08-16T17:44:54.744168
| 2023-08-15T18:05:23
| 2023-08-15T18:05:23
| 132,016,365
| 111
| 87
|
NOASSERTION
| 2023-09-14T04:02:07
| 2018-05-03T15:39:32
|
C
|
UTF-8
|
C
| false
| false
| 3,460
|
c
|
UnitTestLinearDiffusionMetric.C
|
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC
// (NTESS), National Renewable Energy Laboratory, University of Texas Austin,
// Northwest Research Associates. Under the terms of Contract DE-NA0003525
// with NTESS, the U.S. Government retains certain rights in this software.
//
// This software is released under the BSD 3-clause license. See LICENSE file
// for more details.
//
#include "matrix_free/LinearDiffusionMetric.h"
#include "matrix_free/LobattoQuadratureRule.h"
#include "StkSimdComparisons.h"
#include <Kokkos_Core.hpp>
#include <stk_simd/Simd.hpp>
#include "matrix_free/KokkosViewTypes.h"
#include "gtest/gtest.h"
#include "mpi.h"
namespace sierra {
namespace nalu {
namespace matrix_free {
namespace {
template <int p>
void
diffusion_single_cube_hex_p()
{
const int num_elems_1D = 32 / p;
const int num_elems_3D = num_elems_1D * num_elems_1D * num_elems_1D;
vector_view<p> coords("coordinates", num_elems_3D);
scalar_view<p> alpha("alpha", num_elems_3D);
Kokkos::parallel_for(
num_elems_3D, KOKKOS_LAMBDA(int index) {
for (int k = 0; k < p + 1; ++k) {
for (int j = 0; j < p + 1; ++j) {
for (int i = 0; i < p + 1; ++i) {
constexpr auto nodes = GLL<p>::nodes;
alpha(index, k, j, i) = 1.0;
coords(index, k, j, i, 0) = nodes[i];
coords(index, k, j, i, 1) = nodes[j];
coords(index, k, j, i, 2) = nodes[k];
}
}
}
});
const auto diffusion_d = geom::diffusion_metric<p>(alpha, coords);
auto diffusion_h = Kokkos::create_mirror_view(diffusion_d);
Kokkos::deep_copy(diffusion_h, diffusion_d);
for (int index = 0; index < num_elems_3D; ++index) {
for (int k = 0; k < p + 1; ++k) {
for (int j = 0; j < p + 1; ++j) {
for (int i = 0; i < p; ++i) {
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 0, i, k, j, 0), -1.0, 1e-10)
<< "index: " << index;
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 0, i, k, j, 1), +0.0, 1e-10)
<< "index: " << index;
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 0, i, k, k, 2), +0.0, 1e-10)
<< "index: " << index;
}
}
}
for (int k = 0; k < p + 1; ++k) {
for (int j = 0; j < p; ++j) {
for (int i = 0; i < p + 1; ++i) {
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 1, j, k, i, 0), -1.0, 1e-10)
<< "index: " << index;
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 1, j, k, i, 1), +0.0, 1e-10)
<< "index: " << index;
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 1, j, k, i, 2), +0.0, 1e-10)
<< "index: " << index;
}
}
}
for (int k = 0; k < p; ++k) {
for (int j = 0; j < p + 1; ++j) {
for (int i = 0; i < p + 1; ++i) {
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 2, k, j, i, 0), -1.0, 1e-10)
<< "index: " << index;
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 2, k, j, i, 1), +0.0, 1e-10)
<< "index: " << index;
ASSERT_DOUBLETYPE_NEAR(diffusion_h(index, 2, k, j, i, 2), +0.0, 1e-10)
<< "index: " << index;
}
}
}
}
}
} // namespace
TEST(linear_diffusion_metric, single_cube_hex8)
{
diffusion_single_cube_hex_p<1>();
}
TEST(linear_diffusion_metric, single_cube_hex27)
{
diffusion_single_cube_hex_p<2>();
}
} // namespace matrix_free
} // namespace nalu
} // namespace sierra
|
49465984f210a9c95eb9c7c3f2965c741dc0c797
|
1b6222f79e5c3a80c224eaa8c656c87a778d57f5
|
/wlm_integration/torque/qstatenv.c
|
b26a766777a595797bd1c615d11f8ab07e15fb10
|
[
"BSD-3-Clause-LBNL"
] |
permissive
|
NERSC/shifter
|
beebfd66d9f36ea5509cff5031316d654d89f0ba
|
0784ae5b34537c5ca35f464249070f90c6884ca2
|
refs/heads/master
| 2023-05-30T06:07:25.121789
| 2022-10-22T00:07:54
| 2022-10-22T00:07:54
| 52,631,494
| 374
| 89
|
NOASSERTION
| 2023-01-31T00:37:09
| 2016-02-26T20:42:28
|
C
|
UTF-8
|
C
| false
| false
| 4,003
|
c
|
qstatenv.c
|
/******************************************************************************
** qsetenv - A program to add/replace an environment variable in a PBS job
**
** Author: Douglas Jacobsen <dmjacobsen@lbl.gov>
** Date : 2014/08/15
**
** Copyright (C) 2014, The Regents of the University of California.
** All Rights Reserved
**
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <pbs_error.h>
#include <pbs_ifl.h>
#define QSETENV_VERSION "1.0"
#define IN_VALUE 1
#define IN_QUOTE 4
void usage(int status) {
printf("qstatenv [-s <server>] <jobid>\n");
printf("\n");
printf(" server : PBS/torque server to connect to\n");
printf(" jobid : jobnumber.servername of the job to change\n");
printf("\n");
printf("OPTIONS\n");
printf(" --help,-h : show this help message\n");
printf(" --version,-V : show version number\n");
exit(status);
}
char *job_getenv_varstr(struct batch_status *job) {
char *ref_variables = NULL;
struct attrl *attribute = NULL;
if (job == NULL) {
return NULL;
}
/* examine attribute list to get current environment variables */
attribute = job->attribs;
while (attribute != NULL) {
if (strcmp(attribute->name, ATTR_v) == 0) {
ref_variables = strdup(attribute->value);
return ref_variables;
}
attribute = attribute->next;
}
return NULL;
}
int main(int argc, char **argv) {
char *server = NULL;
char *jobid = NULL;
int server_fd = 0;
int ret = 0;
int c = 0;
struct batch_status *job = NULL;
char *var_string = NULL;
struct option prg_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
};
for ( ; ; ) {
int option_index = 0;
c = getopt_long(argc, argv, "s:hV",
prg_options, &option_index
);
if (c == -1) break;
switch (c) {
case 'h':
usage(0);
break;
case 'V':
printf("qstatenv version: %s; for torque version %s\n", QSETENV_VERSION, TORQUE_VERSION);
exit(0);
break;
case 's':
server = optarg;
break;
}
}
for (c = optind; c != argc; c++) {
switch (c-optind) {
case 0:
jobid = argv[c];
break;
default:
printf("Too many arguments!\n");
usage(1);
break;
}
}
if (jobid == NULL) {
printf("Too few arguments!\n");
usage(1);
}
if (server == NULL) {
server = pbs_get_server_list();
}
char *tok_server = server;
char *tgt_server = NULL;
while ((tgt_server = strtok(tok_server, ",")) != NULL) {
tok_server = NULL;
server_fd = pbs_connect(tgt_server);
if (server_fd > 0) {
break;
}
}
if (server_fd <= 0) {
fprintf(stderr, "Failed to connect to PBS server!\n");
exit(1);
}
job = pbs_statjob(server_fd, jobid, NULL, 0);
if (job != NULL) {
char *tok_string, *tgt_string;
var_string = job_getenv_varstr(job);
if (var_string != NULL) {
tok_string = var_string;
while ((tgt_string = strtok(tok_string, ",")) != NULL) {
tok_string = NULL;
if (strchr(tgt_string, '=')) {
printf("%s\n", tgt_string);
}
}
} else {
ret = 1;
}
} else {
ret = 1;
}
if (var_string != NULL) {
free(var_string);
}
if (job != NULL) {
pbs_statfree(job);
job = NULL;
}
pbs_disconnect(server_fd);
if (ret != 0) {
return 1;
}
return 0;
}
|
7544c7d8e4e9a73cbdd4d382f7fafa0352ceef90
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/alpha/include/uapi/asm/termios.h
|
580ed1e4854c03482a51903682bf546cc07f7232
|
[
"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
| 1,466
|
h
|
termios.h
|
#ifndef _UAPI_ALPHA_TERMIOS_H
#define _UAPI_ALPHA_TERMIOS_H
#include <asm/ioctls.h>
#include <asm/termbits.h>
struct sgttyb {
char sg_ispeed;
char sg_ospeed;
char sg_erase;
char sg_kill;
short sg_flags;
};
struct tchars {
char t_intrc;
char t_quitc;
char t_startc;
char t_stopc;
char t_eofc;
char t_brkc;
};
struct ltchars {
char t_suspc;
char t_dsuspc;
char t_rprntc;
char t_flushc;
char t_werasc;
char t_lnextc;
};
struct winsize {
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel;
unsigned short ws_ypixel;
};
#define NCC 8
struct termio {
unsigned short c_iflag; /* input mode flags */
unsigned short c_oflag; /* output mode flags */
unsigned short c_cflag; /* control mode flags */
unsigned short c_lflag; /* local mode flags */
unsigned char c_line; /* line discipline */
unsigned char c_cc[NCC]; /* control characters */
};
/*
* c_cc characters in the termio structure. Oh, how I love being
* backwardly compatible. Notice that character 4 and 5 are
* interpreted differently depending on whether ICANON is set in
* c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise
* as _VMIN and V_TIME. This is for compatibility with OSF/1 (which
* is compatible with sysV)...
*/
#define _VINTR 0
#define _VQUIT 1
#define _VERASE 2
#define _VKILL 3
#define _VEOF 4
#define _VMIN 4
#define _VEOL 5
#define _VTIME 5
#define _VEOL2 6
#define _VSWTC 7
#endif /* _UAPI_ALPHA_TERMIOS_H */
|
314b485ba01e020963059bea57c809bea9d09543
|
ecce427678ecff2a93a47f3b1b664202c7d27617
|
/actors/blue_coin_switch/collision.inc.c
|
5134eac2936ebc717d5e0860474224429bf3da6d
|
[] |
no_license
|
sm64pc/sm64ex
|
ecf37f31b3f7426c4874254660d856030d789714
|
54cd27ccee45a2403b45f07a00d6043c51149969
|
refs/heads/nightly
| 2023-08-11T12:14:34.424168
| 2023-07-01T11:45:50
| 2023-07-01T11:45:50
| 262,091,731
| 795
| 238
| null | 2023-07-01T11:45:51
| 2020-05-07T15:43:27
|
C
|
UTF-8
|
C
| false
| false
| 679
|
c
|
collision.inc.c
|
// Blue Coin Switch
// 0x08000E98 - 0x08000F10
const Collision blue_coin_switch_seg8_collision_08000E98[] = {
COL_INIT(),
COL_VERTEX_INIT(0x8),
COL_VERTEX(26, 0, 26),
COL_VERTEX(26, 26, 26),
COL_VERTEX(-25, 26, 26),
COL_VERTEX(-25, 0, 26),
COL_VERTEX(26, 0, -25),
COL_VERTEX(26, 26, -25),
COL_VERTEX(-25, 26, -25),
COL_VERTEX(-25, 0, -25),
COL_TRI_INIT(SURFACE_DEFAULT, 10),
COL_TRI(0, 1, 2),
COL_TRI(0, 2, 3),
COL_TRI(4, 5, 1),
COL_TRI(5, 6, 2),
COL_TRI(5, 2, 1),
COL_TRI(7, 6, 5),
COL_TRI(7, 5, 4),
COL_TRI(3, 6, 7),
COL_TRI(3, 2, 6),
COL_TRI(4, 1, 0),
COL_TRI_STOP(),
COL_END(),
};
|
175e83c650665243c2aeb2bb49b365f179d5e500
|
8a51a96f61699f0318315ccc89cef39f6866f2b5
|
/src/interfaces/ecpg/test/expected/preproc-variable.c
|
cce377021be6496975432e0b8bb59a30918be0eb
|
[
"PostgreSQL"
] |
permissive
|
postgres/postgres
|
979febf2b41c00090d1256228f768f33e7ef3b6f
|
b5934bfd6071fed3a38cea0cfaa93afda63d9c0c
|
refs/heads/master
| 2023-08-31T00:10:01.373472
| 2023-08-30T23:07:48
| 2023-08-30T23:07:48
| 927,442
| 13,691
| 4,807
|
NOASSERTION
| 2023-09-09T13:59:15
| 2010-09-21T11:35:45
|
C
|
UTF-8
|
C
| false
| false
| 7,176
|
c
|
preproc-variable.c
|
/* Processed by ecpg (regression mode) */
/* These include files are added by the preprocessor */
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "variable.pgc"
#include <stdlib.h>
#include <string.h>
#line 1 "regression.h"
#line 4 "variable.pgc"
/* exec sql whenever sqlerror stop ; */
#line 6 "variable.pgc"
/* exec sql type c is char reference */
#line 8 "variable.pgc"
typedef char* c;
/* exec sql type ind is union {
#line 11 "variable.pgc"
int integer ;
#line 11 "variable.pgc"
short smallint ;
} */
#line 11 "variable.pgc"
typedef union { int integer; short smallint; } ind;
#define BUFFERSIZ 8
/* exec sql type str is [ BUFFERSIZ ] */
#line 15 "variable.pgc"
/* declare cur cursor for select name , born , age , married , children from family */
#line 18 "variable.pgc"
int
main (void)
{
struct birthinfo {
#line 23 "variable.pgc"
long born ;
#line 23 "variable.pgc"
short age ;
} ;
#line 23 "variable.pgc"
/* exec sql begin declare section */
#line 27 "variable.pgc"
struct personal_struct {
#line 25 "variable.pgc"
struct varchar_1 { int len; char arr[ BUFFERSIZ ]; } name ;
#line 26 "variable.pgc"
struct birthinfo birth ;
} personal , * p ;
#line 30 "variable.pgc"
struct personal_indicator {
#line 28 "variable.pgc"
int ind_name ;
#line 29 "variable.pgc"
struct birthinfo ind_birth ;
} ind_personal , * i ;
#line 31 "variable.pgc"
ind ind_children ;
struct t1 {
#line 32 "variable.pgc"
struct varchar_2 { int len; char arr[ BUFFERSIZ ]; } name ;
} ; struct t2 {
#line 32 "variable.pgc"
struct varchar_3 { int len; char arr[ BUFFERSIZ ]; } name ;
} ;
#line 33 "variable.pgc"
static struct varchar_4 { int len; char arr[ 50 ]; } vc1 ; static struct varchar_5 { int len; char arr[ 50 ]; } vc2 ; static struct varchar_6 { int len; char arr[ 255 ]; } vc3 ;
#line 34 "variable.pgc"
static int i1 , i2 , i3 ;
/* exec sql end declare section */
#line 35 "variable.pgc"
#line 37 "variable.pgc"
char * married = NULL ;
#line 37 "variable.pgc"
#line 38 "variable.pgc"
long ind_married ;
#line 38 "variable.pgc"
#line 39 "variable.pgc"
ind children ;
#line 39 "variable.pgc"
int loopcount;
char msg[128];
ECPGdebug(1, stderr);
strcpy(msg, "connect");
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
#line 46 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 46 "variable.pgc"
strcpy(msg, "set");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
#line 49 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 49 "variable.pgc"
strcpy(msg, "create");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer )", ECPGt_EOIT, ECPGt_EORT);
#line 52 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 52 "variable.pgc"
strcpy(msg, "insert");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 )", ECPGt_EOIT, ECPGt_EORT);
#line 55 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 55 "variable.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 )", ECPGt_EOIT, ECPGt_EORT);
#line 56 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 56 "variable.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , age ) values ( 'Child 1' , 16 )", ECPGt_EOIT, ECPGt_EORT);
#line 57 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 57 "variable.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , age ) values ( 'Child 2' , 14 )", ECPGt_EOIT, ECPGt_EORT);
#line 58 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 58 "variable.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into family ( name , age ) values ( 'Child 3' , 9 )", ECPGt_EOIT, ECPGt_EORT);
#line 59 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 59 "variable.pgc"
strcpy(msg, "commit");
{ ECPGtrans(__LINE__, NULL, "commit");
#line 62 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 62 "variable.pgc"
strcpy(msg, "open");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT);
#line 65 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 65 "variable.pgc"
/* exec sql whenever not found break ; */
#line 67 "variable.pgc"
p=&personal;
i=&ind_personal;
memset(i, 0, sizeof(ind_personal));
for (loopcount = 0; loopcount < 100; loopcount++) {
strcpy(msg, "fetch");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur", ECPGt_EOIT,
ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)-1,sizeof( struct birthinfo ),
ECPGt_int,&(i->ind_name),(long)1,(long)-1,sizeof( struct birthinfo ),
ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof( struct birthinfo ),
ECPGt_long,&(i->ind_birth.born),(long)1,(long)1,sizeof( struct birthinfo ),
ECPGt_short,&(p->birth.age),(long)1,(long)1,sizeof( struct birthinfo ),
ECPGt_short,&(i->ind_birth.age),(long)1,(long)1,sizeof( struct birthinfo ),
ECPGt_char,&(married),(long)0,(long)1,(1)*sizeof(char),
ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long),
ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int),
ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT);
#line 74 "variable.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
#line 74 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 74 "variable.pgc"
printf("%8.8s", personal.name.arr);
if (i->ind_birth.born >= 0)
printf(", born %ld", personal.birth.born);
if (i->ind_birth.age >= 0)
printf(", age = %d", personal.birth.age);
if (ind_married >= 0)
printf(", married %s", married);
if (ind_children.smallint >= 0)
printf(", children = %d", children.integer);
putchar('\n');
free(married);
married = NULL;
}
strcpy(msg, "close");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
#line 91 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 91 "variable.pgc"
strcpy(msg, "drop");
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table family", ECPGt_EOIT, ECPGt_EORT);
#line 94 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 94 "variable.pgc"
strcpy(msg, "commit");
{ ECPGtrans(__LINE__, NULL, "commit");
#line 97 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 97 "variable.pgc"
strcpy(msg, "disconnect");
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 100 "variable.pgc"
if (sqlca.sqlcode < 0) exit (1);}
#line 100 "variable.pgc"
/* this just to silence unused-variable warnings: */
vc1.len = vc2.len = vc3.len = 0;
i1 = i2 = i3 = 0;
printf("%d %d %d %d %d %d\n",
vc1.len, vc2.len, vc3.len,
i1, i2, i3);
return 0;
}
|
97b5354841228ef8d19923ca8fc967368e5907ec
|
85ccd32aa73eecf274a937f1fc3b6f4d484b77da
|
/test cases/linuxlike/3 linker script/prog.c
|
b010b15873ea2d849318f96409973ed59220f872
|
[
"Apache-2.0"
] |
permissive
|
mesonbuild/meson
|
48321cf4235dfcc0194fed90ff43a57367592bf7
|
cf5adf0c646474f0259d123fad60ca5ed38ec891
|
refs/heads/master
| 2023-09-01T05:58:50.807952
| 2023-03-17T20:27:37
| 2023-08-31T11:52:41
| 19,784,232
| 5,122
| 1,848
|
Apache-2.0
| 2023-09-14T15:47:23
| 2014-05-14T15:08:16
|
Python
|
UTF-8
|
C
| false
| false
| 65
|
c
|
prog.c
|
#include"bob.h"
int main(void) {
return bobMcBob() != 42;
}
|
98634bdb5808a4e87b1ccae284bdf669c0cac7c6
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/musl/src/complex/catanl.c
|
e62526c00672b42b91592334b2f113326c40e9a7
|
[
"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,891
|
c
|
catanl.c
|
/* origin: OpenBSD /usr/src/lib/libm/src/s_catanl.c */
/*
* Copyright (c) 2008 Stephen L. Moshier <steve@moshier.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.
*/
/*
* Complex circular arc tangent
*
*
* SYNOPSIS:
*
* long double complex catanl();
* long double complex z, w;
*
* w = catanl( z );
*
*
* DESCRIPTION:
*
* If
* z = x + iy,
*
* then
* 1 ( 2x )
* Re w = - arctan(-----------) + k PI
* 2 ( 2 2)
* (1 - x - y )
*
* ( 2 2)
* 1 (x + (y+1) )
* Im w = - log(------------)
* 4 ( 2 2)
* (x + (y-1) )
*
* Where k is an arbitrary integer.
*
*
* ACCURACY:
*
* Relative error:
* arithmetic domain # trials peak rms
* DEC -10,+10 5900 1.3e-16 7.8e-18
* IEEE -10,+10 30000 2.3e-15 8.5e-17
* The check catan( ctan(z) ) = z, with |x| and |y| < PI/2,
* had peak relative error 1.5e-16, rms relative error
* 2.9e-17. See also clog().
*/
#include <complex.h>
#include <float.h>
#include "complex_impl.h"
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double complex catanl(long double complex z)
{
return catan(z);
}
#else
static const long double PIL = 3.141592653589793238462643383279502884197169L;
static const long double DP1 = 3.14159265358979323829596852490908531763125L;
static const long double DP2 = 1.6667485837041756656403424829301998703007e-19L;
static const long double DP3 = 1.8830410776607851167459095484560349402753e-39L;
static long double redupil(long double x)
{
long double t;
long i;
t = x / PIL;
if (t >= 0.0L)
t += 0.5L;
else
t -= 0.5L;
i = t; /* the multiple */
t = i;
t = ((x - t * DP1) - t * DP2) - t * DP3;
return t;
}
long double complex catanl(long double complex z)
{
long double complex w;
long double a, t, x, x2, y;
x = creall(z);
y = cimagl(z);
x2 = x * x;
a = 1.0L - x2 - (y * y);
t = atan2l(2.0L * x, a) * 0.5L;
w = redupil(t);
t = y - 1.0L;
a = x2 + (t * t);
t = y + 1.0L;
a = (x2 + (t * t)) / a;
w = CMPLXF(w, 0.25L * logl(a));
return w;
}
#endif
|
0c02846c7c79c3cf2610c3a8e2ecca3b3eae45cc
|
fb47ab6337a71029dee71933e449cf7f6805fc0f
|
/platform/nrf52xxx/clock.c
|
54ffb60e2c423d5bf7606429b1204351aaf8a61b
|
[
"MIT"
] |
permissive
|
littlekernel/lk
|
7e7ba50b87b1f2e0b6e2f052c59249825c91975b
|
30dc320054f70910e1c1ee40a6948ee99672acec
|
refs/heads/master
| 2023-09-02T00:47:52.203963
| 2023-06-21T22:42:35
| 2023-06-21T22:42:35
| 3,058,456
| 3,077
| 618
|
MIT
| 2023-08-30T09:41:31
| 2011-12-27T19:19:36
|
C
|
UTF-8
|
C
| false
| false
| 2,727
|
c
|
clock.c
|
/*
* Copyright (c) 2020 Eric Holland
*
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#include <sys/types.h>
#include <lk/err.h>
#include <kernel/event.h>
#include <nrfx.h>
#include <nrfx_clock.h>
#include <hal/nrf_clock.h>
#include <platform/clock.h>
event_t hf_clk_evt = EVENT_INITIAL_VALUE(hf_clk_evt, false, 0);
event_t lf_clk_evt = EVENT_INITIAL_VALUE(lf_clk_evt, false, 0);
void nrf52_POWER_CLOCK_IRQ(void) {
arm_cm_irq_entry();
nrfx_clock_irq_handler();
arm_cm_irq_exit(true);
}
// Handler runs in interrupt context
void nrf52_clock_handler(nrfx_clock_evt_type_t event) {
switch (event) {
case NRFX_CLOCK_EVT_HFCLK_STARTED :
event_signal(&hf_clk_evt, false);
break;
case NRFX_CLOCK_EVT_LFCLK_STARTED :
event_signal(&lf_clk_evt, false);
break;
default:
break;
}
}
status_t nrf52_clock_init(void) {
status_t status = nrfx_clock_init(nrf52_clock_handler);
if (status == NO_ERROR) {
nrfx_clock_enable();
}
return status;
}
status_t nrf52_clock_hf_use_xtal_source(void) {
// Check if already running on hfclk xtal
if (nrfx_clock_hfclk_is_running()) {
return NO_ERROR;
}
event_unsignal(&hf_clk_evt);
nrfx_clock_hfclk_start();
if (event_wait_timeout(&hf_clk_evt, 100) != NO_ERROR) {
dprintf(CRITICAL, "Timeout waiting for hf source\n");
return ERR_TIMED_OUT;
}
return NO_ERROR;
}
// Switch to using the internal 64MHz oscillator for HF clock
void nrf52_clock_hf_use_internal_source(void) {
//The clock controller will automatically switch to the internal
// oscillator as the source when the external xtal is stopped.
// this nrfx function is poorly named as it does not stop the hf clock
// but only stops the external xtal oscillator.
nrfx_clock_hfclk_stop();
}
status_t nrf52_clock_lfclk_enable(nrf_clock_lfclk_t src) {
if (nrfx_clock_lfclk_is_running()) {
nrf_clock_lfclk_t current_src = nrf_clock_lf_actv_src_get(NRF_CLOCK);
if (current_src == src) {
//Already running on the requested source, do nothing.
return NO_ERROR;
}
// If we make it here, it is running, but not right source, so shut it down to change
nrfx_clock_lfclk_stop();
}
nrf_clock_lf_src_set(NRF_CLOCK, src);
event_unsignal(&lf_clk_evt);
nrfx_clock_lfclk_start();
if (event_wait_timeout(&lf_clk_evt, 100) != NO_ERROR) {
dprintf(CRITICAL, "Timeout waiting for lf clock start\n");
return ERR_TIMED_OUT;
}
return NO_ERROR;
}
|
d3cc3bc89db756f60f2703a82d35de678efbd025
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/libs/libc/unistd/lib_getpgid.c
|
d09bceb9b2830588824e95604ff9ae3aa885a759
|
[
"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
| 2,531
|
c
|
lib_getpgid.c
|
/****************************************************************************
* libs/libc/unistd/lib_getpgid.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/sched.h>
#include <nuttx/signal.h>
#include <unistd.h>
#include <errno.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: getpgid
*
* Description:
* Get the Process Group ID of the required process id. But since NuttX do
* not support process group, so the process group id are same as process
* id, so this method will return the pid that transferred in directly,
* which is same as getpgrp() method
*
* Input parameters:
* pid - the process id that required to fetch the process group id
*
* Returned Value:
* getpgid() shall return a process group ID. Otherwise, it shall return
* (pid_t)-1 and set errno to indicate the error. If the given process id
* are invalid, set errno as EINVAL, if the given process id do not exist,
* set errno as ESRCH
*
****************************************************************************/
pid_t getpgid(pid_t pid)
{
if (pid < 0)
{
set_errno(EINVAL);
return INVALID_PROCESS_ID;
}
if (pid == 0)
{
return getpgrp();
}
else if (_SIG_KILL(pid, 0) < 0)
{
return INVALID_PROCESS_ID;
}
return pid;
}
|
6c741dcc43c48acafcff08bb94a24894d79e8b23
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/include/any-linux-any/linux/netfilter/xt_hashlimit.h
|
c4ac8bf926432c353d23f1f2e6cb50b93a2d7aea
|
[
"MIT"
] |
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
| 3,255
|
h
|
xt_hashlimit.h
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _XT_HASHLIMIT_H
#define _XT_HASHLIMIT_H
#include <linux/types.h>
#include <linux/limits.h>
#include <linux/if.h>
/* timings are in milliseconds. */
#define XT_HASHLIMIT_SCALE 10000
#define XT_HASHLIMIT_SCALE_v2 1000000llu
/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
* seconds, or one packet every 59 hours.
*/
/* packet length accounting is done in 16-byte steps */
#define XT_HASHLIMIT_BYTE_SHIFT 4
/* details of this structure hidden by the implementation */
struct xt_hashlimit_htable;
enum {
XT_HASHLIMIT_HASH_DIP = 1 << 0,
XT_HASHLIMIT_HASH_DPT = 1 << 1,
XT_HASHLIMIT_HASH_SIP = 1 << 2,
XT_HASHLIMIT_HASH_SPT = 1 << 3,
XT_HASHLIMIT_INVERT = 1 << 4,
XT_HASHLIMIT_BYTES = 1 << 5,
XT_HASHLIMIT_RATE_MATCH = 1 << 6,
};
struct hashlimit_cfg {
__u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
__u32 avg; /* Average secs between packets * scale */
__u32 burst; /* Period multiplier for upper limit. */
/* user specified */
__u32 size; /* how many buckets */
__u32 max; /* max number of entries */
__u32 gc_interval; /* gc interval */
__u32 expire; /* when do entries expire? */
};
struct xt_hashlimit_info {
char name [IFNAMSIZ]; /* name */
struct hashlimit_cfg cfg;
/* Used internally by the kernel */
struct xt_hashlimit_htable *hinfo;
union {
void *ptr;
struct xt_hashlimit_info *master;
} u;
};
struct hashlimit_cfg1 {
__u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
__u32 avg; /* Average secs between packets * scale */
__u32 burst; /* Period multiplier for upper limit. */
/* user specified */
__u32 size; /* how many buckets */
__u32 max; /* max number of entries */
__u32 gc_interval; /* gc interval */
__u32 expire; /* when do entries expire? */
__u8 srcmask, dstmask;
};
struct hashlimit_cfg2 {
__u64 avg; /* Average secs between packets * scale */
__u64 burst; /* Period multiplier for upper limit. */
__u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
/* user specified */
__u32 size; /* how many buckets */
__u32 max; /* max number of entries */
__u32 gc_interval; /* gc interval */
__u32 expire; /* when do entries expire? */
__u8 srcmask, dstmask;
};
struct hashlimit_cfg3 {
__u64 avg; /* Average secs between packets * scale */
__u64 burst; /* Period multiplier for upper limit. */
__u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
/* user specified */
__u32 size; /* how many buckets */
__u32 max; /* max number of entries */
__u32 gc_interval; /* gc interval */
__u32 expire; /* when do entries expire? */
__u32 interval;
__u8 srcmask, dstmask;
};
struct xt_hashlimit_mtinfo1 {
char name[IFNAMSIZ];
struct hashlimit_cfg1 cfg;
/* Used internally by the kernel */
struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
};
struct xt_hashlimit_mtinfo2 {
char name[NAME_MAX];
struct hashlimit_cfg2 cfg;
/* Used internally by the kernel */
struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
};
struct xt_hashlimit_mtinfo3 {
char name[NAME_MAX];
struct hashlimit_cfg3 cfg;
/* Used internally by the kernel */
struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
};
#endif /* _XT_HASHLIMIT_H */
|
a148f86b0f7496c92633b53dc2f7412d88e04abc
|
f367e4b66a1ee42e85830b31df88f63723c36a47
|
/lib/cfl/include/cfl/cfl_kvlist.h
|
5f920e583e016a6e7360a5aee869df19c5337fc6
|
[
"Apache-2.0"
] |
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
| 2,526
|
h
|
cfl_kvlist.h
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* CFL
* ===
* Copyright (C) 2022 The CFL Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CFL_KVLIST_H
#define CFL_KVLIST_H
#include <stdio.h>
#include <cfl/cfl_sds.h>
#include <cfl/cfl_list.h>
#include <cfl/cfl_variant.h>
struct cfl_kvpair {
cfl_sds_t key; /* Key */
struct cfl_variant *val; /* Value */
struct cfl_list _head; /* Link to list cfl_kvlist->list */
};
struct cfl_kvlist {
struct cfl_list list;
};
struct cfl_kvlist *cfl_kvlist_create();
void cfl_kvlist_destroy(struct cfl_kvlist *list);
int cfl_kvlist_insert_string(struct cfl_kvlist *list,
char *key, char *value);
int cfl_kvlist_insert_bytes(struct cfl_kvlist *list,
char *key, char *value,
size_t value_length);
int cfl_kvlist_insert_reference(struct cfl_kvlist *list,
char *key, void *value);
int cfl_kvlist_insert_bool(struct cfl_kvlist *list,
char *key, int value);
int cfl_kvlist_insert_int64(struct cfl_kvlist *list,
char *key, int64_t value);
int cfl_kvlist_insert_double(struct cfl_kvlist *list,
char *key, double value);
int cfl_kvlist_insert_array(struct cfl_kvlist *list,
char *key, struct cfl_array *value);
int cfl_kvlist_insert_new_array(struct cfl_kvlist *list,
char *key, size_t size);
int cfl_kvlist_insert_kvlist(struct cfl_kvlist *list,
char *key, struct cfl_kvlist *value);
int cfl_kvlist_insert(struct cfl_kvlist *list,
char *key, struct cfl_variant *value);
int cfl_kvlist_count(struct cfl_kvlist *list);
struct cfl_variant *cfl_kvlist_fetch(struct cfl_kvlist *list, char *key);
int cfl_kvlist_print(FILE *fp, struct cfl_kvlist *list);
#endif
|
41333960137efe62346409dcbc556acc02021b08
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/apm32/libraries/APM32F0xx_Library/APM32F0xx_StdPeriphDriver/inc/apm32f0xx_dma.h
|
0b9d69e4e23d5e1bf03de246197c5399775057b4
|
[
"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
| 31,647
|
h
|
apm32f0xx_dma.h
|
/*!
* @file apm32f0xx_dma.h
*
* @brief This file contains all the functions prototypes for the DMA firmware
*
* @version V1.0.3
*
* @date 2022-09-20
*
* @attention
*
* Copyright (C) 2020-2022 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
*
* The program is only for reference, which is distributed in the hope
* that it will be useful and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
* and limitations under the License.
*/
/* Define to prevent recursive inclusion */
#ifndef __APM32F0XX_DMA_H
#define __APM32F0XX_DMA_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes */
#include "apm32f0xx.h"
/** @addtogroup APM32F0xx_StdPeriphDriver
@{
*/
/** @addtogroup DMA_Driver
@{
*/
/** @defgroup DMA_Macros Macros
@{
*/
/**@} end of group DMA_Macros*/
/** @defgroup DMA_Enumerations Enumerations
@{
*/
/**
* @brief DMA data transfer direction
*/
typedef enum
{
DMA_DIR_PERIPHERAL = ((uint8_t)0), /*!< Peripheral to memory */
DMA_DIR_MEMORY = ((uint8_t)1), /*!< Memory to peripheral */
} DMA_DIR_T;
/**
* @brief DMA peripheral increment mode
*/
typedef enum
{
DMA_PERIPHERAL_INC_DISABLE = ((uint8_t)0), /*!< Disable peripheral address increment mode */
DMA_PERIPHERAL_INC_ENABLE = ((uint8_t)1), /*!< Enable peripheral address increment mode */
} DMA_PERIPHERAL_INC_T;
/**
* @brief DMA memory increment mode
*/
typedef enum
{
DMA_MEMORY_INC_DISABLE = ((uint8_t)0), /*!< Disable memory address increment mode */
DMA_MEMORY_INC_ENABLE = ((uint8_t)1), /*!< Enable memory address increment mode */
} DMA_MEMORY_INC_T;
/**
* @brief DMA peripheral data size
*/
typedef enum
{
DMA_PERIPHERAL_DATASIZE_BYTE = ((uint8_t)0x00), /*!< Set peripheral data size to byte */
DMA_PERIPHERAL_DATASIZE_HALFWORD = ((uint8_t)0x01), /*!< Set peripheral data size to half-word */
DMA_PERIPHERAL_DATASIZE_WORD = ((uint8_t)0x02), /*!< Set peripheral data size to word */
} DMA_PERIPHERAL_DATASIZE_T;
/**
* @brief DMA memory data size
*/
typedef enum
{
DMA_MEMORY_DATASIZE_BYTE = ((uint8_t)0x00), /*!< Set memory data size to byte */
DMA_MEMORY_DATASIZE_HALFWORD = ((uint8_t)0x01), /*!< Set memory data size to half-word */
DMA_MEMORY_DATASIZE_WORD = ((uint8_t)0x02), /*!< Set memory data size to word */
} DMA_MEMORY_DATASIZE_T;
/**
* @brief DMA circular mode
*/
typedef enum
{
DMA_CIRCULAR_DISABLE = ((uint8_t)0), /*!< Disable circular mode */
DMA_CIRCULAR_ENABLE = ((uint8_t)1), /*!< Enable circular mode */
} DMA_CIRCULAR_T;
/**
* @brief DMA priority level
*/
typedef enum
{
DMA_PRIORITY_LEVEL_LOW = ((uint8_t)0x00), /*!< Set priority level to low */
DMA_PRIORITY_LEVEL_MEDIUM = ((uint8_t)0x01), /*!< Set priority level to medium */
DMA_PRIORITY_LEVEL_HIGHT = ((uint8_t)0x02), /*!< Set priority level to high */
DMA_PRIORITY_LEVEL_VERYHIGH = ((uint8_t)0x03), /*!< Set priority level to very high */
} DMA_PRIORITY_LEVEL_T;
/**
* @brief DMA memory to memory
*/
typedef enum
{
DMA_M2M_DISABLE = ((uint8_t)0), /*!< Disable memory to memory mode */
DMA_M2M_ENABLE = ((uint8_t)1), /*!< Enable memory to memory mode */
} DMA_M2M_T;
/**
* @brief DMA channels remapping definition
*/
typedef enum
{
DMA1_CHANNEL1_DEFAULT = (uint32_t)0x00000000, /*!< DMA1 channel1 remapping DEFAULT */
DMA1_CHANNEL1_ADC = (uint32_t)0x00000001, /*!< DMA1 channel1 remapping ADC */
DMA1_CHANNEL1_TMR17_CH1 = (uint32_t)0x00000007, /*!< DMA1 channel1 remapping TMR17_CH1 */
DMA1_CHANNEL1_TMR17_UP = (uint32_t)0x00000007, /*!< DMA1 channel1 remapping TMR17_UP */
DMA1_CHANNEL1_USART1_RX = (uint32_t)0x00000008, /*!< DMA1 channel1 remapping USART1_RX */
DMA1_CHANNEL1_USART2_RX = (uint32_t)0x00000009, /*!< DMA1 channel1 remapping USART2_RX */
DMA1_CHANNEL1_USART3_RX = (uint32_t)0x0000000A, /*!< DMA1 channel1 remapping USART3_RX */
DMA1_CHANNEL1_USART4_RX = (uint32_t)0x0000000B, /*!< DMA1 channel1 remapping USART4_RX */
DMA1_CHANNEL1_USART5_RX = (uint32_t)0x0000000C, /*!< DMA1 channel1 remapping USART5_RX */
DMA1_CHANNEL1_USART6_RX = (uint32_t)0x0000000D, /*!< DMA1 channel1 remapping USART6_RX */
DMA1_CHANNEL1_USART7_RX = (uint32_t)0x0000000E, /*!< DMA1 channel1 remapping USART7_RX */
DMA1_CHANNEL1_USART8_RX = (uint32_t)0x0000000F, /*!< DMA1 channel1 remapping USART8_RX */
DMA1_CHANNEL2_DEFAULT = (uint32_t)0x10000000, /*!< DMA1 channel2 remapping DEFAULT */
DMA1_CHANNEL2_ADC = (uint32_t)0x10000010, /*!< DMA1 channel2 remapping ADC */
DMA1_CHANNEL2_I2C1_TX = (uint32_t)0x10000020, /*!< DMA1 channel2 remapping I2C1_TX */
DMA1_CHANNEL2_SPI1_RX = (uint32_t)0x10000030, /*!< DMA1 channel2 remapping SPI1_RX */
DMA1_CHANNEL2_TMR1_CH1 = (uint32_t)0x10000040, /*!< DMA1 channel2 remapping TMR1_CH1 */
DMA1_CHANNEL2_TMR17_CH1 = (uint32_t)0x10000070, /*!< DMA1 channel2 remapping TMR17_CH1 */
DMA1_CHANNEL2_TMR17_UP = (uint32_t)0x10000070, /*!< DMA1 channel2 remapping TMR17_UP */
DMA1_CHANNEL2_USART1_TX = (uint32_t)0x10000080, /*!< DMA1 channel2 remapping USART1_TX */
DMA1_CHANNEL2_USART2_TX = (uint32_t)0x10000090, /*!< DMA1 channel2 remapping USART2_TX */
DMA1_CHANNEL2_USART3_TX = (uint32_t)0x100000A0, /*!< DMA1 channel2 remapping USART3_TX */
DMA1_CHANNEL2_USART4_TX = (uint32_t)0x100000B0, /*!< DMA1 channel2 remapping USART4_TX */
DMA1_CHANNEL2_USART5_TX = (uint32_t)0x100000C0, /*!< DMA1 channel2 remapping USART5_TX */
DMA1_CHANNEL2_USART6_TX = (uint32_t)0x100000D0, /*!< DMA1 channel2 remapping USART6_TX */
DMA1_CHANNEL2_USART7_TX = (uint32_t)0x100000E0, /*!< DMA1 channel2 remapping USART7_TX */
DMA1_CHANNEL2_USART8_TX = (uint32_t)0x100000F0, /*!< DMA1 channel2 remapping USART8_TX */
DMA1_CHANNEL3_DEFAULT = (uint32_t)0x20000000, /*!< DMA1 channel3 remapping DEFAULT */
DMA1_CHANNEL3_TMR6_UP = (uint32_t)0x20000100, /*!< DMA1 channel3 remapping TMR6_UP */
DMA1_CHANNEL3_DAC_CH1 = (uint32_t)0x20000100, /*!< DMA1 channel3 remapping DAC_CH1 */
DMA1_CHANNEL3_I2C1_RX = (uint32_t)0x20000200, /*!< DMA1 channel3 remapping I2C1_RX */
DMA1_CHANNEL3_SPI1_TX = (uint32_t)0x20000300, /*!< DMA1 channel3 remapping SPI1_TX */
DMA1_CHANNEL3_TMR1_CH2 = (uint32_t)0x20000400, /*!< DMA1 channel3 remapping TMR1_CH2 */
DMA1_CHANNEL3_TMR2_CH2 = (uint32_t)0x20000500, /*!< DMA1 channel3 remapping TMR2_CH2 */
DMA1_CHANNEL3_TMR16_CH1 = (uint32_t)0x20000700, /*!< DMA1 channel3 remapping TMR16_CH1 */
DMA1_CHANNEL3_TMR16_UP = (uint32_t)0x20000700, /*!< DMA1 channel3 remapping TMR16_UP */
DMA1_CHANNEL3_USART1_RX = (uint32_t)0x20000800, /*!< DMA1 channel3 remapping USART1_RX */
DMA1_CHANNEL3_USART2_RX = (uint32_t)0x20000900, /*!< DMA1 channel3 remapping USART2_RX */
DMA1_CHANNEL3_USART3_RX = (uint32_t)0x20000A00, /*!< DMA1 channel3 remapping USART3_RX */
DMA1_CHANNEL3_USART4_RX = (uint32_t)0x20000B00, /*!< DMA1 channel3 remapping USART4_RX */
DMA1_CHANNEL3_USART5_RX = (uint32_t)0x20000C00, /*!< DMA1 channel3 remapping USART5_RX */
DMA1_CHANNEL3_USART6_RX = (uint32_t)0x20000D00, /*!< DMA1 channel3 remapping USART6_RX */
DMA1_CHANNEL3_USART7_RX = (uint32_t)0x20000E00, /*!< DMA1 channel3 remapping USART7_RX */
DMA1_CHANNEL3_USART8_RX = (uint32_t)0x20000F00, /*!< DMA1 channel3 remapping USART8_RX */
DMA1_CHANNEL4_DEFAULT = (uint32_t)0x30000000, /*!< DMA1 channel4 remapping DEFAULT */
DMA1_CHANNEL4_TMR7_UP = (uint32_t)0x30001000, /*!< DMA1 channel4 remapping TMR7_UP */
DMA1_CHANNEL4_DAC_CH2 = (uint32_t)0x30001000, /*!< DMA1 channel4 remapping DAC_CH2 */
DMA1_CHANNEL4_I2C2_TX = (uint32_t)0x30002000, /*!< DMA1 channel4 remapping I2C2_TX */
DMA1_CHANNEL4_SPI2_RX = (uint32_t)0x30003000, /*!< DMA1 channel4 remapping SPI2_RX */
DMA1_CHANNEL4_TMR2_CH4 = (uint32_t)0x30005000, /*!< DMA1 channel4 remapping TMR2_CH4 */
DMA1_CHANNEL4_TMR3_CH1 = (uint32_t)0x30006000, /*!< DMA1 channel4 remapping TMR3_CH1 */
DMA1_CHANNEL4_TMR3_TRIG = (uint32_t)0x30006000, /*!< DMA1 channel4 remapping TMR3_TRIG */
DMA1_CHANNEL4_TMR16_CH1 = (uint32_t)0x30007000, /*!< DMA1 channel4 remapping TMR16_CH1 */
DMA1_CHANNEL4_TMR16_UP = (uint32_t)0x30007000, /*!< DMA1 channel4 remapping TMR16_UP */
DMA1_CHANNEL4_USART1_TX = (uint32_t)0x30008000, /*!< DMA1 channel4 remapping USART1_TX */
DMA1_CHANNEL4_USART2_TX = (uint32_t)0x30009000, /*!< DMA1 channel4 remapping USART2_TX */
DMA1_CHANNEL4_USART3_TX = (uint32_t)0x3000A000, /*!< DMA1 channel4 remapping USART3_TX */
DMA1_CHANNEL4_USART4_TX = (uint32_t)0x3000B000, /*!< DMA1 channel4 remapping USART4_TX */
DMA1_CHANNEL4_USART5_TX = (uint32_t)0x3000C000, /*!< DMA1 channel4 remapping USART5_TX */
DMA1_CHANNEL4_USART6_TX = (uint32_t)0x3000D000, /*!< DMA1 channel4 remapping USART6_TX */
DMA1_CHANNEL4_USART7_TX = (uint32_t)0x3000E000, /*!< DMA1 channel4 remapping USART7_TX */
DMA1_CHANNEL4_USART8_TX = (uint32_t)0x3000F000, /*!< DMA1 channel4 remapping USART8_TX */
DMA1_CHANNEL5_DEFAULT = (uint32_t)0x40000000, /*!< DMA1 channel5 remapping DEFAULT */
DMA1_CHANNEL5_I2C2_RX = (uint32_t)0x40020000, /*!< DMA1 channel5 remapping I2C2_RX */
DMA1_CHANNEL5_SPI2_TX = (uint32_t)0x40030000, /*!< DMA1 channel5 remapping SPI2_TX */
DMA1_CHANNEL5_TMR1_CH3 = (uint32_t)0x40040000, /*!< DMA1 channel5 remapping TMR1_CH3 */
DMA1_CHANNEL5_USART1_RX = (uint32_t)0x40080000, /*!< DMA1 channel5 remapping USART1_RX */
DMA1_CHANNEL5_USART2_RX = (uint32_t)0x40090000, /*!< DMA1 channel5 remapping USART2_RX */
DMA1_CHANNEL5_USART3_RX = (uint32_t)0x400A0000, /*!< DMA1 channel5 remapping USART3_RX */
DMA1_CHANNEL5_USART4_RX = (uint32_t)0x400B0000, /*!< DMA1 channel5 remapping USART4_RX */
DMA1_CHANNEL5_USART5_RX = (uint32_t)0x400C0000, /*!< DMA1 channel5 remapping USART5_RX */
DMA1_CHANNEL5_USART6_RX = (uint32_t)0x400D0000, /*!< DMA1 channel5 remapping USART6_RX */
DMA1_CHANNEL5_USART7_RX = (uint32_t)0x400E0000, /*!< DMA1 channel5 remapping USART7_RX */
DMA1_CHANNEL5_USART8_RX = (uint32_t)0x400F0000, /*!< DMA1 channel5 remapping USART8_RX */
DMA1_CHANNEL6_DEFAULT = (uint32_t)0x50000000, /*!< DMA1 channel6 remapping DEFAULT */
DMA1_CHANNEL6_I2C1_TX = (uint32_t)0x50200000, /*!< DMA1 channel6 remapping I2C1_TX */
DMA1_CHANNEL6_SPI2_RX = (uint32_t)0x50300000, /*!< DMA1 channel6 remapping SPI2_RX */
DMA1_CHANNEL6_TMR1_CH1 = (uint32_t)0x50400000, /*!< DMA1 channel6 remapping TMR1_CH1 */
DMA1_CHANNEL6_TMR1_CH2 = (uint32_t)0x50400000, /*!< DMA1 channel6 remapping TMR1_CH2 */
DMA1_CHANNEL6_TMR1_CH3 = (uint32_t)0x50400000, /*!< DMA1 channel6 remapping TMR1_CH3 */
DMA1_CHANNEL6_TMR3_CH1 = (uint32_t)0x50600000, /*!< DMA1 channel6 remapping TMR3_CH1 */
DMA1_CHANNEL6_TMR3_TRIG = (uint32_t)0x50600000, /*!< DMA1 channel6 remapping TMR3_TRIG */
DMA1_CHANNEL6_TMR16_CH1 = (uint32_t)0x50700000, /*!< DMA1 channel6 remapping TMR16_CH1 */
DMA1_CHANNEL6_TMR16_UP = (uint32_t)0x50700000, /*!< DMA1 channel6 remapping TMR16_UP */
DMA1_CHANNEL6_USART1_RX = (uint32_t)0x50800000, /*!< DMA1 channel6 remapping USART1_RX */
DMA1_CHANNEL6_USART2_RX = (uint32_t)0x50900000, /*!< DMA1 channel6 remapping USART2_RX */
DMA1_CHANNEL6_USART3_RX = (uint32_t)0x50A00000, /*!< DMA1 channel6 remapping USART3_RX */
DMA1_CHANNEL6_USART4_RX = (uint32_t)0x50B00000, /*!< DMA1 channel6 remapping USART4_RX */
DMA1_CHANNEL6_USART5_RX = (uint32_t)0x50C00000, /*!< DMA1 channel6 remapping USART5_RX */
DMA1_CHANNEL6_USART6_RX = (uint32_t)0x50D00000, /*!< DMA1 channel6 remapping USART6_RX */
DMA1_CHANNEL6_USART7_RX = (uint32_t)0x50E00000, /*!< DMA1 channel6 remapping USART7_RX */
DMA1_CHANNEL6_USART8_RX = (uint32_t)0x50F00000, /*!< DMA1 channel6 remapping USART8_RX */
DMA1_CHANNEL7_DEFAULT = (uint32_t)0x60000000, /*!< DMA1 channel7 remapping DEFAULT */
DMA1_CHANNEL7_I2C1_RX = (uint32_t)0x62000000, /*!< DMA1 channel7 remapping I2C1_RX */
DMA1_CHANNEL7_SPI2_TX = (uint32_t)0x63000000, /*!< DMA1 channel7 remapping SPI2_TX */
DMA1_CHANNEL7_TMR2_CH2 = (uint32_t)0x65000000, /*!< DMA1 channel7 remapping TMR2_CH2 */
DMA1_CHANNEL7_TMR2_CH4 = (uint32_t)0x65000000, /*!< DMA1 channel7 remapping TMR2_CH4 */
DMA1_CHANNEL7_TMR17_CH1 = (uint32_t)0x67000000, /*!< DMA1 channel7 remapping TMR17_CH1 */
DMA1_CHANNEL7_TMR17_UP = (uint32_t)0x67000000, /*!< DMA1 channel7 remapping TMR17_UP */
DMA1_CHANNEL7_USART1_TX = (uint32_t)0x68000000, /*!< DMA1 channel7 remapping USART1_TX */
DMA1_CHANNEL7_USART2_TX = (uint32_t)0x69000000, /*!< DMA1 channel7 remapping USART2_TX */
DMA1_CHANNEL7_USART3_TX = (uint32_t)0x6A000000, /*!< DMA1 channel7 remapping USART3_TX */
DMA1_CHANNEL7_USART4_TX = (uint32_t)0x6B000000, /*!< DMA1 channel7 remapping USART4_TX */
DMA1_CHANNEL7_USART5_TX = (uint32_t)0x6C000000, /*!< DMA1 channel7 remapping USART5_TX */
DMA1_CHANNEL7_USART6_TX = (uint32_t)0x6D000000, /*!< DMA1 channel7 remapping USART6_TX */
DMA1_CHANNEL7_USART7_TX = (uint32_t)0x6E000000, /*!< DMA1 channel7 remapping USART7_TX */
DMA1_CHANNEL7_USART8_TX = (uint32_t)0x6F000000, /*!< DMA1 channel7 remapping USART8_TX */
DMA2_CHANNEL1_DEFAULT = (uint32_t)0x00000000, /*!< DMA2 channel1 remapping DEFAULT */
DMA2_CHANNEL1_I2C2_TX = (uint32_t)0x00000002, /*!< DMA2 channel1 remapping I2C2_TX */
DMA2_CHANNEL1_USART1_TX = (uint32_t)0x00000008, /*!< DMA2 channel1 remapping USART1_TX */
DMA2_CHANNEL1_USART2_TX = (uint32_t)0x00000009, /*!< DMA2 channel1 remapping USART2_TX */
DMA2_CHANNEL1_USART3_TX = (uint32_t)0x0000000A, /*!< DMA2 channel1 remapping USART3_TX */
DMA2_CHANNEL1_USART4_TX = (uint32_t)0x0000000B, /*!< DMA2 channel1 remapping USART4_TX */
DMA2_CHANNEL1_USART5_TX = (uint32_t)0x0000000C, /*!< DMA2 channel1 remapping USART5_TX */
DMA2_CHANNEL1_USART6_TX = (uint32_t)0x0000000D, /*!< DMA2 channel1 remapping USART6_TX */
DMA2_CHANNEL1_USART7_TX = (uint32_t)0x0000000E, /*!< DMA2 channel1 remapping USART7_TX */
DMA2_CHANNEL1_USART8_TX = (uint32_t)0x0000000F, /*!< DMA2 channel1 remapping USART8_TX */
DMA2_CHANNEL2_DEFAULT = (uint32_t)0x00000000, /*!< DMA2 channel2 remapping DEFAULT */
DMA2_CHANNEL2_I2C2_RX = (uint32_t)0x00000020, /*!< DMA2 channel2 remapping I2C2_RX */
DMA2_CHANNEL2_USART1_RX = (uint32_t)0x00000080, /*!< DMA2 channel2 remapping USART1_RX */
DMA2_CHANNEL2_USART2_RX = (uint32_t)0x00000090, /*!< DMA2 channel2 remapping USART2_RX */
DMA2_CHANNEL2_USART3_RX = (uint32_t)0x000000A0, /*!< DMA2 channel2 remapping USART3_RX */
DMA2_CHANNEL2_USART4_RX = (uint32_t)0x000000B0, /*!< DMA2 channel2 remapping USART4_RX */
DMA2_CHANNEL2_USART5_RX = (uint32_t)0x000000C0, /*!< DMA2 channel2 remapping USART5_RX */
DMA2_CHANNEL2_USART6_RX = (uint32_t)0x000000D0, /*!< DMA2 channel2 remapping USART6_RX */
DMA2_CHANNEL2_USART7_RX = (uint32_t)0x000000E0, /*!< DMA2 channel2 remapping USART7_RX */
DMA2_CHANNEL2_USART8_RX = (uint32_t)0x000000F0, /*!< DMA2 channel2 remapping USART8_RX */
DMA2_CHANNEL3_DEFAULT = (uint32_t)0x00000000, /*!< DMA2 channel3 remapping DEFAULT */
DMA2_CHANNEL3_TMR6_UP = (uint32_t)0x00000100, /*!< DMA2 channel3 remapping TMR6_UP */
DMA2_CHANNEL3_DAC_CH1 = (uint32_t)0x00000100, /*!< DMA2 channel3 remapping DAC_CH1 */
DMA2_CHANNEL3_SPI1_RX = (uint32_t)0x00000300, /*!< DMA2 channel3 remapping SPI1_RX */
DMA2_CHANNEL3_USART1_RX = (uint32_t)0x00000800, /*!< DMA2 channel3 remapping USART1_RX */
DMA2_CHANNEL3_USART2_RX = (uint32_t)0x00000900, /*!< DMA2 channel3 remapping USART2_RX */
DMA2_CHANNEL3_USART3_RX = (uint32_t)0x00000A00, /*!< DMA2 channel3 remapping USART3_RX */
DMA2_CHANNEL3_USART4_RX = (uint32_t)0x00000B00, /*!< DMA2 channel3 remapping USART4_RX */
DMA2_CHANNEL3_USART5_RX = (uint32_t)0x00000C00, /*!< DMA2 channel3 remapping USART5_RX */
DMA2_CHANNEL3_USART6_RX = (uint32_t)0x00000D00, /*!< DMA2 channel3 remapping USART6_RX */
DMA2_CHANNEL3_USART7_RX = (uint32_t)0x00000E00, /*!< DMA2 channel3 remapping USART7_RX */
DMA2_CHANNEL3_USART8_RX = (uint32_t)0x00000F00, /*!< DMA2 channel3 remapping USART8_RX */
DMA2_CHANNEL4_DEFAULT = (uint32_t)0x00000000, /*!< DMA2 channel4 remapping DEFAULT */
DMA2_CHANNEL4_TMR7_UP = (uint32_t)0x00001000, /*!< DMA2 channel4 remapping TMR7_UP */
DMA2_CHANNEL4_DAC_CH2 = (uint32_t)0x00001000, /*!< DMA2 channel4 remapping DAC_CH2 */
DMA2_CHANNEL4_SPI1_TX = (uint32_t)0x00003000, /*!< DMA2 channel4 remapping SPI1_TX */
DMA2_CHANNEL4_USART1_TX = (uint32_t)0x00008000, /*!< DMA2 channel4 remapping USART1_TX */
DMA2_CHANNEL4_USART2_TX = (uint32_t)0x00009000, /*!< DMA2 channel4 remapping USART2_TX */
DMA2_CHANNEL4_USART3_TX = (uint32_t)0x0000A000, /*!< DMA2 channel4 remapping USART3_TX */
DMA2_CHANNEL4_USART4_TX = (uint32_t)0x0000B000, /*!< DMA2 channel4 remapping USART4_TX */
DMA2_CHANNEL4_USART5_TX = (uint32_t)0x0000C000, /*!< DMA2 channel4 remapping USART5_TX */
DMA2_CHANNEL4_USART6_TX = (uint32_t)0x0000D000, /*!< DMA2 channel4 remapping USART6_TX */
DMA2_CHANNEL4_USART7_TX = (uint32_t)0x0000E000, /*!< DMA2 channel4 remapping USART7_TX */
DMA2_CHANNEL4_USART8_TX = (uint32_t)0x0000F000, /*!< DMA2 channel4 remapping USART8_TX */
DMA2_CHANNEL5_DEFAULT = (uint32_t)0x00000000, /*!< DMA2 channel5 remapping DEFAULT */
DMA2_CHANNEL5_ADC = (uint32_t)0x00010000, /*!< DMA2 channel5 remapping ADC */
DMA2_CHANNEL5_USART1_TX = (uint32_t)0x00080000, /*!< DMA2 channel5 remapping USART1_TX */
DMA2_CHANNEL5_USART2_TX = (uint32_t)0x00090000, /*!< DMA2 channel5 remapping USART2_TX */
DMA2_CHANNEL5_USART3_TX = (uint32_t)0x000A0000, /*!< DMA2 channel5 remapping USART3_TX */
DMA2_CHANNEL5_USART4_TX = (uint32_t)0x000B0000, /*!< DMA2 channel5 remapping USART4_TX */
DMA2_CHANNEL5_USART5_TX = (uint32_t)0x000C0000, /*!< DMA2 channel5 remapping USART5_TX */
DMA2_CHANNEL5_USART6_TX = (uint32_t)0x000D0000, /*!< DMA2 channel5 remapping USART6_TX */
DMA2_CHANNEL5_USART7_TX = (uint32_t)0x000E0000, /*!< DMA2 channel5 remapping USART7_TX */
DMA2_CHANNEL5_USART8_TX = (uint32_t)0x000F0000, /*!< DMA2 channel5 remapping USART8_TX */
} DMA_CHANNEL_REMAP_T;
/**
* @brief DMA flag definition
*/
typedef enum
{
DMA1_FLAG_AL1 = ((uint32_t)0x00000001), /*!< Channel 1 All flag */
DMA1_FLAG_TF1 = ((uint32_t)0X00000002), /*!< Channel 1 Transfer Complete flag */
DMA1_FLAG_HT1 = ((uint32_t)0X00000004), /*!< Channel 1 Half Transfer Complete flag */
DMA1_FLAG_TE1 = ((uint32_t)0X00000008), /*!< Channel 1 Transfer Error flag */
DMA1_FLAG_AL2 = ((uint32_t)0x00000010), /*!< Channel 2 All flag */
DMA1_FLAG_TF2 = ((uint32_t)0x00000020), /*!< Channel 2 Transfer Complete flag */
DMA1_FLAG_HT2 = ((uint32_t)0x00000040), /*!< Channel 2 Half Transfer Complete flag */
DMA1_FLAG_TE2 = ((uint32_t)0x00000080), /*!< Channel 2 Transfer Error flag */
DMA1_FLAG_AL3 = ((uint32_t)0x00000100), /*!< Channel 3 All flag */
DMA1_FLAG_TF3 = ((uint32_t)0x00000200), /*!< Channel 3 Transfer Complete flag */
DMA1_FLAG_HT3 = ((uint32_t)0x00000400), /*!< Channel 3 Half Transfer Complete flag */
DMA1_FLAG_TE3 = ((uint32_t)0x00000800), /*!< Channel 3 Transfer Error flag */
DMA1_FLAG_AL4 = ((uint32_t)0x00001000), /*!< Channel 4 All flag */
DMA1_FLAG_TF4 = ((uint32_t)0x00002000), /*!< Channel 4 Transfer Complete flag */
DMA1_FLAG_HT4 = ((uint32_t)0x00004000), /*!< Channel 4 Half Transfer Complete flag */
DMA1_FLAG_TE4 = ((uint32_t)0x00008000), /*!< Channel 4 Transfer Error flag */
DMA1_FLAG_AL5 = ((uint32_t)0x00010000), /*!< Channel 5 All flag */
DMA1_FLAG_TF5 = ((uint32_t)0x00020000), /*!< Channel 5 Transfer Complete flag */
DMA1_FLAG_HT5 = ((uint32_t)0x00040000), /*!< Channel 5 Half Transfer Complete flag */
DMA1_FLAG_TE5 = ((uint32_t)0x00080000), /*!< Channel 5 Transfer Error flag */
/* Only for APM32F072 and APM32F091 devices */
DMA1_FLAG_AL6 = ((uint32_t)0x00100000), /*!< Channel 6 All flag */
DMA1_FLAG_TF6 = ((uint32_t)0x00200000), /*!< Channel 6 Transfer Complete flag */
DMA1_FLAG_HT6 = ((uint32_t)0x00400000), /*!< Channel 6 Half Transfer Complete flag */
DMA1_FLAG_TE6 = ((uint32_t)0x00800000), /*!< Channel 6 Transfer Error flag */
/* Only for APM32F072 and APM32F091 devices */
DMA1_FLAG_AL7 = ((uint32_t)0x01000000), /*!< Channel 7 All flag */
DMA1_FLAG_TF7 = ((uint32_t)0x02000000), /*!< Channel 7 Transfer Complete flag */
DMA1_FLAG_HT7 = ((uint32_t)0x04000000), /*!< Channel 7 Half Transfer Complete flag */
DMA1_FLAG_TE7 = ((uint32_t)0x08000000), /*!< Channel 7 Transfer Error flag */
/* Only for APM32F091 devices */
DMA2_FLAG_AL1 = ((uint32_t)0x10000001), /*!< Channel 1 All flag */
DMA2_FLAG_TF1 = ((uint32_t)0X00000002), /*!< Channel 1 Transfer Complete flag */
DMA2_FLAG_HT1 = ((uint32_t)0X00000004), /*!< Channel 1 Half Transfer Complete flag */
DMA2_FLAG_TE1 = ((uint32_t)0X00000008), /*!< Channel 1 Transfer Error flag */
/* Only for APM32F091 devices */
DMA2_FLAG_AL2 = ((uint32_t)0x10000010), /*!< Channel 2 All flag */
DMA2_FLAG_TF2 = ((uint32_t)0x10000020), /*!< Channel 2 Transfer Complete flag */
DMA2_FLAG_HT2 = ((uint32_t)0x10000040), /*!< Channel 2 Half Transfer Complete flag */
DMA2_FLAG_TE2 = ((uint32_t)0x10000080), /*!< Channel 2 Transfer Error flag */
/* Only for APM32F091 devices */
DMA2_FLAG_AL3 = ((uint32_t)0x10000100), /*!< Channel 3 All flag */
DMA2_FLAG_TF3 = ((uint32_t)0x10000200), /*!< Channel 3 Transfer Complete flag */
DMA2_FLAG_HT3 = ((uint32_t)0x10000400), /*!< Channel 3 Half Transfer Complete flag */
DMA2_FLAG_TE3 = ((uint32_t)0x10000800), /*!< Channel 3 Transfer Error flag */
/* Only for APM32F091 devices */
DMA2_FLAG_AL4 = ((uint32_t)0x10001000), /*!< Channel 4 All flag */
DMA2_FLAG_TF4 = ((uint32_t)0x10002000), /*!< Channel 4 Transfer Complete flag */
DMA2_FLAG_HT4 = ((uint32_t)0x10004000), /*!< Channel 4 Half Transfer Complete flag */
DMA2_FLAG_TE4 = ((uint32_t)0x10008000), /*!< Channel 4 Transfer Error flag */
/* Only for APM32F091 devices */
DMA2_FLAG_AL5 = ((uint32_t)0x10010000), /*!< Channel 5 All flag */
DMA2_FLAG_TF5 = ((uint32_t)0x10020000), /*!< Channel 5 Transfer Complete flag */
DMA2_FLAG_HT5 = ((uint32_t)0x10040000), /*!< Channel 5 Half Transfer Complete flag */
DMA2_FLAG_TE5 = ((uint32_t)0x10080000), /*!< Channel 5 Transfer Error flag */
} DMA_FLAG_T;
/**
* @brief DMA interrupt flag definition
*/
typedef enum
{
DMA1_INT_FLAG_AL1 = ((uint32_t)0x00000001), /*!< Channel 1 All interrupt flag */
DMA1_INT_FLAG_TF1 = ((uint32_t)0x00000002), /*!< Channel 1 Transfer Complete interrupt flag */
DMA1_INT_FLAG_HT1 = ((uint32_t)0x00000004), /*!< Channel 1 Half Transfer Complete interrupt flag */
DMA1_INT_FLAG_TE1 = ((uint32_t)0x00000008), /*!< Channel 1 Transfer Error interrupt flag */
DMA1_INT_FLAG_AL2 = ((uint32_t)0x00000010), /*!< Channel 2 All interrupt flag */
DMA1_INT_FLAG_TF2 = ((uint32_t)0x00000020), /*!< Channel 2 Transfer Complete interrupt flag */
DMA1_INT_FLAG_HT2 = ((uint32_t)0x00000040), /*!< Channel 2 Half Transfer Complete interrupt flag */
DMA1_INT_FLAG_TE2 = ((uint32_t)0x00000080), /*!< Channel 2 Transfer Error interrupt flag */
DMA1_INT_FLAG_AL3 = ((uint32_t)0x00000100), /*!< Channel 3 All interrupt flag */
DMA1_INT_FLAG_TF3 = ((uint32_t)0x00000200), /*!< Channel 3 Transfer Complete interrupt flag */
DMA1_INT_FLAG_HT3 = ((uint32_t)0x00000400), /*!< Channel 3 Half Transfer Complete interrupt flag */
DMA1_INT_FLAG_TE3 = ((uint32_t)0x00000800), /*!< Channel 3 Transfer Error interrupt flag */
DMA1_INT_FLAG_AL4 = ((uint32_t)0x00001000), /*!< Channel 4 All interrupt flag */
DMA1_INT_FLAG_TF4 = ((uint32_t)0x00002000), /*!< Channel 4 Transfer Complete interrupt flag */
DMA1_INT_FLAG_HT4 = ((uint32_t)0x00004000), /*!< Channel 4 Half Transfer Complete interrupt flag */
DMA1_INT_FLAG_TE4 = ((uint32_t)0x00008000), /*!< Channel 4 Transfer Error interrupt flag */
DMA1_INT_FLAG_AL5 = ((uint32_t)0x00010000), /*!< Channel 5 All interrupt flag */
DMA1_INT_FLAG_TF5 = ((uint32_t)0x00020000), /*!< Channel 5 Transfer Complete interrupt flag */
DMA1_INT_FLAG_HT5 = ((uint32_t)0x00040000), /*!< Channel 5 Half Transfer Complete interrupt flag */
DMA1_INT_FLAG_TE5 = ((uint32_t)0x00080000), /*!< Channel 5 Transfer Error interrupt flag */
/* Only for APM32F072 and APM32F091 devices */
DMA1_INT_FLAG_AL6 = ((uint32_t)0x00100000), /*!< Channel 6 All interrupt flag */
DMA1_INT_FLAG_TF6 = ((uint32_t)0x00200000), /*!< Channel 6 Transfer Complete interrupt flag */
DMA1_INT_FLAG_HT6 = ((uint32_t)0x00400000), /*!< Channel 6 Half Transfer Complete interrupt flag */
DMA1_INT_FLAG_TE6 = ((uint32_t)0x00800000), /*!< Channel 6 Transfer Error interrupt flag */
/* Only for APM32F072 and APM32F091 devices */
DMA1_INT_FLAG_AL7 = ((uint32_t)0x01000000), /*!< Channel 7 All interrupt flag */
DMA1_INT_FLAG_TF7 = ((uint32_t)0x02000000), /*!< Channel 7 Transfer Complete interrupt flag */
DMA1_INT_FLAG_HT7 = ((uint32_t)0x04000000), /*!< Channel 7 Half Transfer Complete interrupt flag */
DMA1_INT_FLAG_TE7 = ((uint32_t)0x08000000), /*!< Channel 7 Transfer Error interrupt flag */
/* Only for APM32F091 devices */
DMA2_INT_FLAG_AL1 = ((uint32_t)0x10000001), /*!< Channel 1 All interrupt flag */
DMA2_INT_FLAG_TF1 = ((uint32_t)0x10000002), /*!< Channel 1 Transfer Complete interrupt flag */
DMA2_INT_FLAG_HT1 = ((uint32_t)0x10000004), /*!< Channel 1 Half Transfer Complete interrupt flag */
DMA2_INT_FLAG_TE1 = ((uint32_t)0x10000008), /*!< Channel 1 Transfer Error interrupt flag */
/* Only for APM32F091 devices */
DMA2_INT_FLAG_AL2 = ((uint32_t)0x10000010), /*!< Channel 2 All interrupt flag */
DMA2_INT_FLAG_TF2 = ((uint32_t)0x10000020), /*!< Channel 2 Transfer Complete interrupt flag */
DMA2_INT_FLAG_HT2 = ((uint32_t)0x10000040), /*!< Channel 2 Half Transfer Complete interrupt flag */
DMA2_INT_FLAG_TE2 = ((uint32_t)0x10000080), /*!< Channel 2 Transfer Error interrupt flag */
/* Only for APM32F091 devices */
DMA2_INT_FLAG_AL3 = ((uint32_t)0x10000100), /*!< Channel 3 All interrupt flag */
DMA2_INT_FLAG_TF3 = ((uint32_t)0x10000200), /*!< Channel 3 Transfer Complete interrupt flag */
DMA2_INT_FLAG_HT3 = ((uint32_t)0x10000400), /*!< Channel 3 Half Transfer Complete interrupt flag */
DMA2_INT_FLAG_TE3 = ((uint32_t)0x10000800), /*!< Channel 3 Transfer Error interrupt flag */
/* Only for APM32F091 devices */
DMA2_INT_FLAG_AL4 = ((uint32_t)0x10001000), /*!< Channel 4 All interrupt flag */
DMA2_INT_FLAG_TF4 = ((uint32_t)0x10002000), /*!< Channel 4 Transfer Complete interrupt flag */
DMA2_INT_FLAG_HT4 = ((uint32_t)0x10004000), /*!< Channel 4 Half Transfer Complete interrupt flag */
DMA2_INT_FLAG_TE4 = ((uint32_t)0x10008000), /*!< Channel 4 Transfer Error interrupt flag */
/* Only for APM32F091 devices */
DMA2_INT_FLAG_AL5 = ((uint32_t)0x10010000), /*!< Channel 5 All interrupt flag */
DMA2_INT_FLAG_TF5 = ((uint32_t)0x10020000), /*!< Channel 5 Transfer Complete interrupt flag */
DMA2_INT_FLAG_HT5 = ((uint32_t)0x10040000), /*!< Channel 5 Half Transfer Complete interrupt flag */
DMA2_INT_FLAG_TE5 = ((uint32_t)0x10080000), /*!< Channel 5 Transfer Error interrupt flag */
} DMA_INT_FLAG_T;
/**
* @brief DMA interrupt source
*/
typedef enum
{
DMA_INT_TFIE = BIT1, /*!< Transfer complete interrupt enable */
DMA_INT_HTIE = BIT2, /*!< Half Transfer interrupt enable */
DMA_INT_TEIE = BIT3, /*!< Transfer error interrupt enable */
} DMA_INT_T;
/**@} end of group DMA_Enumerations */
/** @defgroup DMA_Structures Structures
@{
*/
/**
* @brief DMA Config struct definition
*/
typedef struct
{
uint32_t memoryAddress; /*!< Specifies the DMA memory base address */
uint32_t peripheralAddress; /*!< Specifies the DMA peripheral base address */
DMA_DIR_T direction; /*!< Specifies the DMA data transfer direction */
uint32_t bufferSize; /*!< Specifies the DMA buffer size */
DMA_MEMORY_DATASIZE_T memoryDataSize; /*!< Specifies the DMA memory data size */
DMA_PERIPHERAL_DATASIZE_T peripheralDataSize; /*!< Specifies the DMA peripheral data size */
DMA_MEMORY_INC_T memoryInc; /*!< Specifies the DMA memory address increment */
DMA_PERIPHERAL_INC_T peripheralInc; /*!< Specifies the DMA peripheral address increment */
DMA_CIRCULAR_T circular; /*!< Specifies the DMA circular mode */
DMA_PRIORITY_LEVEL_T priority; /*!< Specifies the DMA software priority */
DMA_M2M_T memoryTomemory; /*!< Specifies the DMA memory-to-memory transfer */
} DMA_Config_T;
/**@} end of group DMA_Structures */
/** @defgroup DMA_Variables Variables
@{
*/
/**@} end of group DMA_Variables*/
/** @defgroup DMA_Functions Functions
@{
*/
/* Reset and configuration */
void DMA_Reset(DMA_CHANNEL_T* channel);
void DMA_Config(DMA_CHANNEL_T* channel, DMA_Config_T* dmaConfig);
void DMA_ConfigStructInit(DMA_Config_T* dmaConfig);
void DMA_Enable(DMA_CHANNEL_T* channel);
void DMA_Disable(DMA_CHANNEL_T* channel);
/* Data number */
void DMA_SetDataNumber(DMA_CHANNEL_T* channel, uint32_t dataNumber);
uint32_t DMA_ReadDataNumber(DMA_CHANNEL_T* channel);
/* Channel remap (Only for APM32F091 devices) */
void DMA_ConfigRemap(DMA_T* dma, DMA_CHANNEL_REMAP_T remap);
/* interrupt */
void DMA_EnableInterrupt(DMA_CHANNEL_T* channel, uint32_t interrupt);
void DMA_DisableInterrupt(DMA_CHANNEL_T* channel, uint32_t interrupt);
/* Flag */
uint8_t DMA_ReadStatusFlag(DMA_FLAG_T flag);
void DMA_ClearStatusFlag(uint32_t flag);
uint8_t DMA_ReadIntFlag(DMA_INT_FLAG_T flag);
void DMA_ClearIntFlag(uint32_t flag);
#ifdef __cplusplus
}
#endif
#endif /* __APM32F0XX_DMA_H */
/**@} end of group DMA_Functions */
/**@} end of group DMA_Driver */
/**@} end of group APM32F0xx_StdPeriphDriver */
|
6e9f39fb5bac3b8f6675bf16002ffe3af7d5b6f3
|
e814383d36a10839104efaa4df277996ab220fa3
|
/3rd-party/romio341/adio/common/ad_iread_fake.c
|
167c7e0d235b1c17a4e1e8cd632d3620bf5873fc
|
[
"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,914
|
c
|
ad_iread_fake.c
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include "adio.h"
#include "mpiu_greq.h"
/* Generic implementation of IreadContig calls the blocking ReadContig
* immediately.
*/
void ADIOI_FAKE_IreadContig(ADIO_File fd, void *buf, int count,
MPI_Datatype datatype, int file_ptr_type,
ADIO_Offset offset, ADIO_Request * request, int *error_code)
{
ADIO_Status status;
MPI_Count typesize;
int read_count;
MPI_Offset nbytes;
/* Call the blocking function. It will create an error code
* if necessary.
*/
ADIO_ReadContig(fd, buf, count, datatype, file_ptr_type, offset, &status, error_code);
if (*error_code == MPI_SUCCESS) {
MPI_Type_size_x(datatype, &typesize);
MPI_Get_count(&status, datatype, &read_count);
nbytes = read_count * typesize;
} else {
nbytes = 0;
}
MPIO_Completed_request_create(&fd, nbytes, error_code, request);
}
/* Generic implementation of IreadStrided calls the blocking ReadStrided
* immediately.
*/
void ADIOI_FAKE_IreadStrided(ADIO_File fd, void *buf, int count,
MPI_Datatype datatype, int file_ptr_type,
ADIO_Offset offset, ADIO_Request * request, int *error_code)
{
ADIO_Status status;
MPI_Count typesize;
int read_count;
MPI_Offset nbytes;
/* Call the blocking function. It will create an error code
* if necessary.
*/
ADIO_ReadStrided(fd, buf, count, datatype, file_ptr_type, offset, &status, error_code);
if (*error_code == MPI_SUCCESS) {
MPI_Type_size_x(datatype, &typesize);
MPI_Get_count(&status, datatype, &read_count);
nbytes = read_count * typesize;
} else {
nbytes = 0;
}
MPIO_Completed_request_create(&fd, nbytes, error_code, request);
}
|
db15c87ac5e401b72ef3cd0bfcca66d06081467a
|
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
|
/graphics/graphviz/patches/patch-plugin_xlib_gvdevice__xlib.c
|
26e3c0455ce7833557552804e0a5515e41f9b748
|
[] |
no_license
|
NetBSD/pkgsrc
|
a0732c023519650ef821ab89c23ab6ab59e25bdb
|
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
|
refs/heads/trunk
| 2023-09-01T07:40:12.138283
| 2023-09-01T05:25:19
| 2023-09-01T05:25:19
| 88,439,572
| 321
| 138
| null | 2023-07-12T22:34:14
| 2017-04-16T20:04:15
| null |
UTF-8
|
C
| false
| false
| 412
|
c
|
patch-plugin_xlib_gvdevice__xlib.c
|
$NetBSD: patch-plugin_xlib_gvdevice__xlib.c,v 1.3 2022/07/22 12:04:46 micha Exp $
SunOS inotify requires sys/filio.h for FIONREAD.
--- plugin/xlib/gvdevice_xlib.c.orig 2020-04-08 07:51:58.000000000 +0000
+++ plugin/xlib/gvdevice_xlib.c
@@ -32,6 +32,9 @@
#endif
#ifdef HAVE_SYS_INOTIFY_H
#include <sys/inotify.h>
+#ifdef __sun
+#include <sys/filio.h>
+#endif
#endif
#include <errno.h>
#ifdef HAVE_FCNTL_H
|
9b43e762d7065fc94c1bf37fc420deb24f33da09
|
59864cbd213b5da6f50d6255b0a021564b3d5bd4
|
/challenges/LMS/pov_2/pov.c
|
e55e4445ea84c23ea9dcc3543950cad48d7be9b4
|
[
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-unknown",
"BSD-2-Clause"
] |
permissive
|
trailofbits/cb-multios
|
8af96a4fbc3b34644367faa135347f88e0e0d0a3
|
810d7b24b1f62f56ef49b148fe155b0d0629cad2
|
refs/heads/master
| 2023-09-05T03:56:20.229403
| 2022-12-27T15:47:54
| 2022-12-27T15:47:54
| 41,688,943
| 522
| 133
|
MIT
| 2023-06-29T02:47:13
| 2015-08-31T17:04:31
|
C
|
UTF-8
|
C
| false
| false
| 2,725
|
c
|
pov.c
|
#include "libpov.h"
int main(int cgc_argc, char *cgc_argv[]) {
cgc_negotiate_type1(0x0, 0x0, 0);
do {
//*** writing data
static unsigned char write_00000_00000[] =
"\x31\x73\x31\x73\x00\x00\x00\x13\x83\x7e\x1c\xd8\x7a\x98\x5c\xe8"
"\xc0\xcf\x03\x00\x01\x00\x06\x00\x28\x37\xd4\xc8\x23\xf6\x31\x73"
"\x31\x73\x00\x00\x00\x13\x83\x7e\x1c\xd8\x7a\x98\x5c\xe8\xc0\xcf"
"\x01\x00\x05\x00\xad\x00\x56\xc6\xd4\x6a\x79\x2d\x99\x74\xcc\xea"
"\xad\xe1\x02\x4f\x76\x01\xab\x03\x84\xa9\xc9\xc8\xbf\xe5\x4c\xa5"
"\xb9\x38\x06\x9c\x5a\xe5\xef\x6b\xdb\xb8\x92\xb8\x8c\x24\x0e\x9e"
"\xf6\x75\x2f\x54\xf4\x7d\x17\x10\xbf\x06\xa7\xda\xa5\xb3\x01\x08"
"\x8f\x91\x2b\xa9\x25\x48\x3d\xe5\x48\x81\xf2\xec\x79\x61\xd1\x80"
"\x5a\x98\xb7\xe1\xb9\x2f\x0b\xcf\xea\xe6\xe3\x5b\xe0\x4f\x67\x5e"
"\x12\xd9\x15\x4e\xf8\x05\x8f\xf8\xcc\xb9\x08\xd9\x73\x57\x04\x55"
"\x73\xc0\x6d\x29\xa5\x6f\x19\x12\x05\xb4\xcf\x9d\x3d\xd4\x46\xfd"
"\x36\x69\x95\x1d\xbc\xe1\x64\xb8\x4e\xd4\x29\x8b\xb7\x6e\x2c\xbe"
"\x58\x24\x02\xce\x15\xc9\x84\x6b\x7b\xa4\x4a\x70\x9f\xc5\x1b\x1d"
"\x72\x54\x5b\xa5\x8e\x70\xbb\xbf\x57\x44\x55\xa2\xf7\x79\x3b\x04"
"\x4c\x12\x43\x31\x73\x31\x73\x00\x00\x00\x13\x83\x7e\x1c\xd8\x7a"
"\x98\x5c\xe8\xc0\xcf\x00\x00\x05\x00\x81\x00\x7b\xfb\xfe\x21\x0f"
"\x8e\x40\x18\x84\x6e\xeb\xef\x96\xf3\xbd\x65\x7d\xec\x9a\xf7\x51"
"\xbb\xc1\x74\x8c\xb0\xc9\xe2\xdd\xab\x08\xbe\xc8\xb6\xa1\xff\x07"
"\x65\xa6\x6e\xc3\x00\x45\x8e\x9d\xc1\x2a\xae\x30\x5a\x6f\x95\x64"
"\x22\x09\xa1\x07\x1e\x19\xbd\x6b\x64\x20\xd1\x80\xee\xd9\xb6\x42"
"\xe0\xa8\xaf\xd3\x5a\xb3\x05\x75\x42\x5d\xee\x5f\x50\x8b\x61\xed"
"\xbd\xe6\xc1\xd1\xbb\xb1\xdd\xd3\xa8\xfb\x91\x18\x0f\xb6\xc9\x8d"
"\x7e\x59\x56\x8b\x23\x09\x16\x49\x7a\xba\x6f\x48\x3f\x7e\xfb\xae"
"\xb9\x7e\x7c\xb9\xe6\x37\xb1\x98\xc0\x0e\xbd\x8c\x31\x73\x31\x73"
"\x00\x00\x00\x13\x83\x7e\x1c\xd8\x7a\x98\x5c\xe8\xc0\xcf\x02\x00"
"\x05\x00\x14\x00\x48\xc8\x55\xd4\xc4\x54\x05\xcb\xbc\xae\xdb\x19"
"\xa3\xd8\x82\x67\xb8\x86\x24\xfa\x31\x73\x31\x73\x00\x00\x00\x13"
"\x83\x7e\x1c\xd8\x7a\x98\x5c\xe8\xc0\xcf\x04\x00\x05\x00\x02\x00"
"\xf2\xa3";
static unsigned int write_00000_00000_len = 450;
unsigned char *write_00000 = NULL;
unsigned int write_00000_len = 0;
write_00000 = cgc_append_buf(write_00000, &write_00000_len, write_00000_00000, write_00000_00000_len);
if (write_00000_len > 0) {
cgc_transmit_all(1, write_00000, write_00000_len);
}
cgc_free(write_00000);
} while (0);
}
|
d9458c3bda35ab952be9aeb7e308d298e8a1fe35
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/libdrm/src/tests/modetest/cursor.c
|
829bced18119650352add1584b1b3ae14ee9c103
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"BSD-3-Clause",
"GPL-2.0-or-later"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 4,880
|
c
|
cursor.c
|
/*
* DRM based mode setting test program
* Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com>
*
* 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 <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <pthread.h>
#include <unistd.h>
#include "xf86drm.h"
#include "xf86drmMode.h"
#include "util/common.h"
#include "buffers.h"
#include "cursor.h"
struct cursor {
int fd;
uint32_t bo_handle;
uint32_t crtc_id;
uint32_t crtc_w, crtc_h;
uint32_t w, h;
/* current state */
uint32_t enabled, x, y;
int32_t dx, dy;
};
#define MAX_CURSORS 8
static struct cursor cursors[MAX_CURSORS];
static int ncursors;
static pthread_t cursor_thread;
static int cursor_running;
/*
* Timer driven program loops through these steps to move/enable/disable
* the cursor
*/
struct cursor_step {
void (*run)(struct cursor *cursor, const struct cursor_step *step);
uint32_t msec;
uint32_t repeat;
int arg;
};
static uint32_t indx, count;
static void set_cursor(struct cursor *cursor, const struct cursor_step *step)
{
int enabled = (step->arg ^ count) & 0x1;
uint32_t handle = 0;
if (enabled)
handle = cursor->bo_handle;
cursor->enabled = enabled;
drmModeSetCursor(cursor->fd, cursor->crtc_id, handle, cursor->w, cursor->h);
}
static void move_cursor(struct cursor *cursor, const struct cursor_step *step)
{
int x = cursor->x;
int y = cursor->y;
if (!cursor->enabled)
drmModeSetCursor(cursor->fd, cursor->crtc_id,
cursor->bo_handle, cursor->w, cursor->h);
/* calculate new cursor position: */
x += cursor->dx * step->arg;
y += cursor->dy * step->arg;
if (x < 0) {
x = 0;
cursor->dx = 1;
} else if (x > (int)cursor->crtc_w) {
x = cursor->crtc_w - 1;
cursor->dx = -1;
}
if (y < 0) {
y = 0;
cursor->dy = 1;
} else if (y > (int)cursor->crtc_h) {
y = cursor->crtc_h - 1;
cursor->dy = -1;
}
cursor->x = x;
cursor->y = y;
drmModeMoveCursor(cursor->fd, cursor->crtc_id, x, y);
}
static const struct cursor_step steps[] = {
{ set_cursor, 10, 0, 1 }, /* enable */
{ move_cursor, 1, 100, 1 },
{ move_cursor, 1, 10, 10 },
{ set_cursor, 1, 100, 0 }, /* disable/enable loop */
{ move_cursor, 1, 10, 10 },
{ move_cursor, 9, 100, 1 },
{ move_cursor, 11, 100, 5 },
{ set_cursor, 17, 10, 0 }, /* disable/enable loop */
{ move_cursor, 9, 100, 1 },
{ set_cursor, 13, 10, 0 }, /* disable/enable loop */
{ move_cursor, 9, 100, 1 },
{ set_cursor, 13, 10, 0 }, /* disable/enable loop */
{ set_cursor, 10, 0, 0 }, /* disable */
};
static void *cursor_thread_func(void *data)
{
while (cursor_running) {
const struct cursor_step *step = &steps[indx % ARRAY_SIZE(steps)];
int i;
for (i = 0; i < ncursors; i++) {
struct cursor *cursor = &cursors[i];
step->run(cursor, step);
}
/* iterate to next count/step: */
if (count < step->repeat) {
count++;
} else {
count = 0;
indx++;
}
usleep(1000 * step->msec);
}
return NULL;
}
int cursor_init(int fd, uint32_t bo_handle, uint32_t crtc_id,
uint32_t crtc_w, uint32_t crtc_h, uint32_t w, uint32_t h)
{
struct cursor *cursor = &cursors[ncursors];
assert(ncursors < MAX_CURSORS);
cursor->fd = fd;
cursor->bo_handle = bo_handle;
cursor->crtc_id = crtc_id;
cursor->crtc_w = crtc_w;
cursor->crtc_h = crtc_h;
cursor->w = w;
cursor->h = h;
cursor->enabled = 0;
cursor->x = w/2;
cursor->y = h/2;
cursor->dx = 1;
cursor->dy = 1;
ncursors++;
return 0;
}
int cursor_start(void)
{
cursor_running = 1;
pthread_create(&cursor_thread, NULL, cursor_thread_func, NULL);
printf("starting cursor\n");
return 0;
}
int cursor_stop(void)
{
cursor_running = 0;
pthread_join(cursor_thread, NULL);
printf("cursor stopped\n");
return 0;
}
|
eae7aa73d84ee29db80611d9645c50c425bc3241
|
986c21d401983789d9b3e5255bcf9d76070f65ec
|
/src/plugins/poshuku/plugins/dcac/effectscommon.h
|
12f963a1651140471ccdbb3202ca69593a86e985
|
[
"BSL-1.0"
] |
permissive
|
0xd34df00d/leechcraft
|
613454669be3a0cecddd11504950372c8614c4c8
|
15c091d15262abb0a011db03a98322248b96b46f
|
refs/heads/master
| 2023-07-21T05:08:21.348281
| 2023-06-04T16:50:17
| 2023-06-04T16:50:17
| 119,854
| 149
| 71
| null | 2017-09-03T14:16:15
| 2009-02-02T13:52:45
|
C++
|
UTF-8
|
C
| false
| false
| 623
|
h
|
effectscommon.h
|
/**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2014 Georg Rudoy
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
**********************************************************************/
#pragma once
#include <QtGlobal>
#if defined (Q_PROCESSOR_X86_64) || defined (Q_PROCESSOR_X86)
#define SSE_ENABLED
#include <tmmintrin.h>
#include <immintrin.h>
#include <avxintrin.h>
#include <avx2intrin.h>
#endif
|
c70732307e2e6cb90691cbb0a06e4d3a8c75ff72
|
ae31542273a142210a1ff30fb76ed9d45d38eba9
|
/src/backend/access/rmgrdesc/spgdesc.c
|
40c1c8b3f98e833075232efac94cb3ff1f550a08
|
[
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"PostgreSQL",
"OpenSSL",
"LicenseRef-scancode-stream-benchmark",
"ISC",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-ssleay-windows",
"BSD-2-Clause",
"Python-2.0"
] |
permissive
|
greenplum-db/gpdb
|
8334837bceb2d5d51a684500793d11b190117c6a
|
2c0f8f0fb24a2d7a7da114dc80f5f5a2712fca50
|
refs/heads/main
| 2023-08-22T02:03:03.806269
| 2023-08-21T22:59:53
| 2023-08-22T01:17:10
| 44,781,140
| 6,417
| 2,082
|
Apache-2.0
| 2023-09-14T20:33:42
| 2015-10-23T00:25:17
|
C
|
UTF-8
|
C
| false
| false
| 2,977
|
c
|
spgdesc.c
|
/*-------------------------------------------------------------------------
*
* spgdesc.c
* rmgr descriptor routines for access/spgist/spgxlog.c
*
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/backend/access/rmgrdesc/spgdesc.c
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/spgxlog.h"
void
spg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
switch (info)
{
case XLOG_SPGIST_ADD_LEAF:
{
spgxlogAddLeaf *xlrec = (spgxlogAddLeaf *) rec;
appendStringInfoString(buf, "add leaf to page");
appendStringInfo(buf, "; off %u; headoff %u; parentoff %u",
xlrec->offnumLeaf, xlrec->offnumHeadLeaf,
xlrec->offnumParent);
if (xlrec->newPage)
appendStringInfoString(buf, " (newpage)");
if (xlrec->storesNulls)
appendStringInfoString(buf, " (nulls)");
}
break;
case XLOG_SPGIST_MOVE_LEAFS:
appendStringInfo(buf, "%u leafs",
((spgxlogMoveLeafs *) rec)->nMoves);
break;
case XLOG_SPGIST_ADD_NODE:
appendStringInfo(buf, "off %u",
((spgxlogAddNode *) rec)->offnum);
break;
case XLOG_SPGIST_SPLIT_TUPLE:
appendStringInfo(buf, "prefix off: %u, postfix off: %u (same %d, new %d)",
((spgxlogSplitTuple *) rec)->offnumPrefix,
((spgxlogSplitTuple *) rec)->offnumPostfix,
((spgxlogSplitTuple *) rec)->postfixBlkSame,
((spgxlogSplitTuple *) rec)->newPage
);
break;
case XLOG_SPGIST_PICKSPLIT:
{
spgxlogPickSplit *xlrec = (spgxlogPickSplit *) rec;
appendStringInfo(buf, "ndel %u; nins %u",
xlrec->nDelete, xlrec->nInsert);
if (xlrec->innerIsParent)
appendStringInfoString(buf, " (innerIsParent)");
if (xlrec->isRootSplit)
appendStringInfoString(buf, " (isRootSplit)");
}
break;
case XLOG_SPGIST_VACUUM_LEAF:
/* no further information */
break;
case XLOG_SPGIST_VACUUM_ROOT:
/* no further information */
break;
case XLOG_SPGIST_VACUUM_REDIRECT:
appendStringInfo(buf, "newest XID %u",
((spgxlogVacuumRedirect *) rec)->newestRedirectXid);
break;
}
}
const char *
spg_identify(uint8 info)
{
const char *id = NULL;
switch (info & ~XLR_INFO_MASK)
{
case XLOG_SPGIST_ADD_LEAF:
id = "ADD_LEAF";
break;
case XLOG_SPGIST_MOVE_LEAFS:
id = "MOVE_LEAFS";
break;
case XLOG_SPGIST_ADD_NODE:
id = "ADD_NODE";
break;
case XLOG_SPGIST_SPLIT_TUPLE:
id = "SPLIT_TUPLE";
break;
case XLOG_SPGIST_PICKSPLIT:
id = "PICKSPLIT";
break;
case XLOG_SPGIST_VACUUM_LEAF:
id = "VACUUM_LEAF";
break;
case XLOG_SPGIST_VACUUM_ROOT:
id = "VACUUM_ROOT";
break;
case XLOG_SPGIST_VACUUM_REDIRECT:
id = "VACUUM_REDIRECT";
break;
}
return id;
}
|
d8196394cb14092eb872aa7c7eda38dc90803550
|
30c2631ed046d7662476b94fb7f5286c47377f60
|
/examples/c/rules/cyclic_variables/include/cyclic_variables.h
|
3af53d32bdc4d3bbf9d3d2ca383545a5a7facde6
|
[
"MIT"
] |
permissive
|
SanderMertens/flecs
|
a840093340f0d1eb2bd30ec1585296f81f2aab39
|
41fb856c4e1162f44b59d7881ef508d64d56bf10
|
refs/heads/master
| 2023-08-24T16:21:41.790084
| 2023-08-24T08:38:57
| 2023-08-24T08:49:52
| 146,155,284
| 4,731
| 456
|
MIT
| 2023-09-05T16:01:58
| 2018-08-26T05:53:05
|
C
|
UTF-8
|
C
| false
| false
| 244
|
h
|
cyclic_variables.h
|
#ifndef CYCLIC_VARIABLES_H
#define CYCLIC_VARIABLES_H
/* This generated file contains includes for project dependencies */
#include "cyclic_variables/bake_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
|
824fbd9ca843f5a3f43bf064c41938e7cf607c14
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/xnnpack/src/src/xnnpack/zip.h
|
e617e69c60be14e70c6ece9ceca05af15d929135
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla"
] |
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,247
|
h
|
zip.h
|
// Copyright (c) Facebook, Inc. and its affiliates.
// All rights reserved.
//
// Copyright 2019 Google LLC
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <xnnpack/common.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DECLARE_X8_ZIPC_UKERNEL_FUNCTION(fn_name) \
XNN_INTERNAL void fn_name( \
size_t n, \
const uint8_t* x, \
uint8_t* y);
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x2_ukernel__neon)
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x2_ukernel__scalar)
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x2_ukernel__sse2)
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x3_ukernel__neon)
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x3_ukernel__scalar)
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x3_ukernel__sse2)
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x4_ukernel__neon)
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x4_ukernel__scalar)
DECLARE_X8_ZIPC_UKERNEL_FUNCTION(xnn_x8_zip_x4_ukernel__sse2)
#define DECLARE_X32_ZIPC_UKERNEL_FUNCTION(fn_name) \
XNN_INTERNAL void fn_name( \
size_t n, \
const uint32_t* x, \
uint32_t* y);
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x2_ukernel__neon)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x2_ukernel__scalar)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x2_ukernel__sse2)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x2_ukernel__wasmsimd)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x3_ukernel__neon)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x3_ukernel__scalar)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x3_ukernel__sse2)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x3_ukernel__wasmsimd)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x4_ukernel__neon)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x4_ukernel__scalar)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x4_ukernel__sse2)
DECLARE_X32_ZIPC_UKERNEL_FUNCTION(xnn_x32_zip_x4_ukernel__wasmsimd)
#define DECLARE_X8_ZIPV_UKERNEL_FUNCTION(fn_name) \
XNN_INTERNAL void fn_name( \
size_t n, \
size_t m, \
const uint8_t* x, \
uint8_t* y);
DECLARE_X8_ZIPV_UKERNEL_FUNCTION(xnn_x8_zip_xm_ukernel__neon)
DECLARE_X8_ZIPV_UKERNEL_FUNCTION(xnn_x8_zip_xm_ukernel__scalar)
DECLARE_X8_ZIPV_UKERNEL_FUNCTION(xnn_x8_zip_xm_ukernel__sse2)
#define DECLARE_X32_ZIPV_UKERNEL_FUNCTION(fn_name) \
XNN_INTERNAL void fn_name( \
size_t n, \
size_t m, \
const uint32_t* x, \
uint32_t* y);
DECLARE_X32_ZIPV_UKERNEL_FUNCTION(xnn_x32_zip_xm_ukernel__neon)
DECLARE_X32_ZIPV_UKERNEL_FUNCTION(xnn_x32_zip_xm_ukernel__scalar)
DECLARE_X32_ZIPV_UKERNEL_FUNCTION(xnn_x32_zip_xm_ukernel__sse2)
DECLARE_X32_ZIPV_UKERNEL_FUNCTION(xnn_x32_zip_xm_ukernel__wasmsimd)
#ifdef __cplusplus
} // extern "C"
#endif
|
cc5cdb723e44f0e21ebfb2075cb13f323643b041
|
bed3ac926beac0f4e0293303d7b2a6031ee476c9
|
/Modules/ThirdParty/VNL/src/vxl/v3p/netlib/libf2c/s_cat.c
|
00811071aac99d5794a9f197fd943fe3dfa60c23
|
[
"IJG",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"SMLNJ",
"BSD-3-Clause",
"BSD-4.3TAHOE",
"LicenseRef-scancode-free-unknown",
"Spencer-86",
"LicenseRef-scancode-llnl",
"FSFUL",
"Libpng",
"libtiff",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-hdf5",
"MIT",
"NTP",
"LicenseRef-scancode-mit-old-style",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference",
"MPL-2.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] |
permissive
|
InsightSoftwareConsortium/ITK
|
ed9dbbc5b8b3f7511f007c0fc0eebb3ad37b88eb
|
3eb8fd7cdfbc5ac2d0c2e5e776848a4cbab3d7e1
|
refs/heads/master
| 2023-08-31T17:21:47.754304
| 2023-08-31T00:58:51
| 2023-08-31T14:12:21
| 800,928
| 1,229
| 656
|
Apache-2.0
| 2023-09-14T17:54:00
| 2010-07-27T15:48:04
|
C++
|
UTF-8
|
C
| false
| false
| 2,032
|
c
|
s_cat.c
|
/* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the
* target of a concatenation to appear on its right-hand side (contrary
* to the Fortran 77 Standard, but in accordance with Fortran 90).
*/
#include "v3p_f2c.h"
#ifndef NO_OVERWRITE
#include "stdio.h"
#undef abs
#ifdef KR_headers
extern char *F77_aloc();
extern void free();
extern void exit_();
#else
#undef min
#undef max
#include "stdlib.h"
extern
#ifdef __cplusplus
"C"
#endif
char *F77_aloc(ftnlen, char*);
#endif
#include "string.h"
#endif /* NO_OVERWRITE */
#ifdef __cplusplus
extern "C" {
#endif
int
#ifdef KR_headers
s_cat(lp, rpp, rnp, np, ll) char *lp, **rpp; integer *rnp, *np; ftnlen ll;
#else
s_cat(char *lp, char **rpp, integer *rnp, integer *np, ftnlen ll)
#endif
{
ftnlen i, nc;
char *rp;
ftnlen n = *np;
#ifndef NO_OVERWRITE
ftnlen L, m;
char *lp0, *lp1;
lp0 = 0;
lp1 = lp;
L = ll;
i = 0;
while(i < n) {
rp = rpp[i];
m = rnp[i++];
if (rp >= lp1 || rp + m <= lp) {
if ((L -= m) <= 0) {
n = i;
break;
}
lp1 += m;
continue;
}
lp0 = lp;
lp = F77_aloc(L = ll, "s_cat");
break;
}
lp1 = lp;
#endif /* NO_OVERWRITE */
for(i = 0 ; i < n ; ++i) {
nc = ll;
if(rnp[i] < nc)
nc = rnp[i];
ll -= nc;
rp = rpp[i];
while(--nc >= 0)
*lp++ = *rp++;
}
while(--ll >= 0)
*lp++ = ' ';
#ifndef NO_OVERWRITE
if (lp0) {
memcpy(lp0, lp1, L);
free(lp1);
}
#endif
return 0;
}
#ifdef __cplusplus
}
#endif
|
f0b1e1c576bcb98e7d42b38501b1af7030c7a9f7
|
e72db16e9747386afd01edd1dd36d9589a3f71ef
|
/src/test/obj_recreate/obj_recreate.c
|
c69a5c1202d4bb0d13dc8c44d65b97ded64fbce7
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
pmem/pmdk
|
5e49feee8017574340db2a0f9b4e2eab99f8581c
|
ccadb16227bddea1bdcc518bd8f298d551b2baad
|
refs/heads/master
| 2023-08-31T02:28:06.884934
| 2023-08-30T14:52:25
| 2023-08-30T14:52:25
| 23,637,153
| 1,017
| 402
|
NOASSERTION
| 2023-09-07T11:52:42
| 2014-09-03T20:55:23
|
C
|
UTF-8
|
C
| false
| false
| 1,968
|
c
|
obj_recreate.c
|
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2015-2017, Intel Corporation */
/*
* obj_recreate.c -- recreate pool on dirty file and check consistency
*/
#include "unittest.h"
POBJ_LAYOUT_BEGIN(recreate);
POBJ_LAYOUT_ROOT(recreate, struct root);
POBJ_LAYOUT_TOID(recreate, struct foo);
POBJ_LAYOUT_END(recreate);
struct foo {
int bar;
};
struct root {
TOID(struct foo) foo;
};
#define LAYOUT_NAME "obj_recreate"
#define N PMEMOBJ_MIN_POOL
int
main(int argc, char *argv[])
{
START(argc, argv, "obj_recreate");
/* root doesn't count */
UT_COMPILE_ERROR_ON(POBJ_LAYOUT_TYPES_NUM(recreate) != 1);
if (argc < 2)
UT_FATAL("usage: %s file-name [trunc]", argv[0]);
const char *path = argv[1];
PMEMobjpool *pop = NULL;
/* create pool 2*N */
pop = pmemobj_create(path, LAYOUT_NAME, 2 * N, S_IWUSR | S_IRUSR);
if (pop == NULL)
UT_FATAL("!pmemobj_create: %s", path);
/* allocate 1.5*N */
TOID(struct root) root = (TOID(struct root))pmemobj_root(pop,
(size_t)(1.5 * N));
/* use root object for something */
POBJ_NEW(pop, &D_RW(root)->foo, struct foo, NULL, NULL);
pmemobj_close(pop);
int fd = OPEN(path, O_RDWR);
if (argc >= 3 && strcmp(argv[2], "trunc") == 0) {
UT_OUT("truncating");
/* shrink file to N */
FTRUNCATE(fd, N);
}
size_t zero_len = Ut_pagesize;
/* zero first page */
void *p = MMAP(NULL, zero_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
memset(p, 0, zero_len);
MUNMAP(p, zero_len);
CLOSE(fd);
/* create pool on existing file */
pop = pmemobj_create(path, LAYOUT_NAME, 0, S_IWUSR | S_IRUSR);
if (pop == NULL)
UT_FATAL("!pmemobj_create: %s", path);
/* try to allocate 0.7*N */
root = (TOID(struct root))pmemobj_root(pop, (size_t)(0.5 * N));
if (TOID_IS_NULL(root))
UT_FATAL("couldn't allocate root object");
/* validate root object is empty */
if (!TOID_IS_NULL(D_RW(root)->foo))
UT_FATAL("root object is already filled after pmemobj_create!");
pmemobj_close(pop);
DONE(NULL);
}
|
ec62b8acbf0d2b0b33b14d492911d076d422f65c
|
8551168c7b71c31eebad0f9b0c71eebbcc743000
|
/src/game/pdmode.c
|
93ad30885ee1c7c82f623faf6c57febaddbc0e16
|
[
"MIT"
] |
permissive
|
n64decomp/perfect_dark
|
0db80e8ecba74741b959962e55c835a91c920f44
|
0235a971d6fb1a0d4421856d5a65aa8067bd4658
|
refs/heads/master
| 2023-08-31T04:27:53.864767
| 2023-08-29T11:36:58
| 2023-08-29T11:36:58
| 241,214,589
| 452
| 47
|
MIT
| 2023-08-21T08:53:40
| 2020-02-17T21:46:45
|
C
|
UTF-8
|
C
| false
| false
| 805
|
c
|
pdmode.c
|
#include <ultra64.h>
#include "constants.h"
#include "game/pdmode.h"
#include "game/bondgun.h"
#include "game/game_0b0fd0.h"
#include "game/inv.h"
#include "game/playermgr.h"
#include "game/options.h"
#include "bss.h"
#include "data.h"
#include "types.h"
f32 pdmodeGetEnemyReactionSpeed(void)
{
return 0;
}
f32 pdmodeGetEnemyHealth(void)
{
if (g_MissionConfig.pdmode) {
return g_MissionConfig.pdmodehealthf;
}
return 1;
}
f32 pdmodeGetEnemyDamage(void)
{
if (g_MissionConfig.pdmode) {
return g_MissionConfig.pdmodedamagef;
}
return 1;
}
f32 pdmodeGetEnemyAccuracy(void)
{
if (g_MissionConfig.pdmode) {
return g_MissionConfig.pdmodeaccuracyf;
}
return 1;
}
void func0f01b148(u32 arg0)
{
var800624e0 = arg0;
}
void titleSetNextStage(s32 stagenum)
{
g_TitleNextStage = stagenum;
}
|
4e66be4225114a599e93b96fca4d8db905cde649
|
c7c73566784a7896100e993606e1bd8fdd0ea94e
|
/dtool/src/parser-inc/android/log.h
|
c4533d68f8b2978a5bd3b13f2a732077a34e792c
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
panda3d/panda3d
|
c3f94df2206ff7cfe4a3b370777a56fb11a07926
|
160ba090a5e80068f61f34fc3d6f49dbb6ad52c5
|
refs/heads/master
| 2023-08-21T13:23:16.904756
| 2021-04-11T22:55:33
| 2023-08-06T06:09:32
| 13,212,165
| 4,417
| 1,072
|
NOASSERTION
| 2023-09-09T19:26:14
| 2013-09-30T10:20:25
|
C++
|
UTF-8
|
C
| false
| false
| 212
|
h
|
log.h
|
#pragma once
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/cdefs.h>
typedef enum android_LogPriority android_LogPriority;
typedef enum log_id log_id_t;
struct __android_log_message;
|
49c797060d5251fd6cc49eee38a042a4a4fde2ed
|
e100cedc265380fd666b08bd99ffdbeb4dfe0d3c
|
/include/SFML/Graphics/Rect.h
|
b3e3be19d1b659b00d74dd4f277fb77a3f6355e5
|
[
"Zlib"
] |
permissive
|
SFML/CSFML
|
50db0712f6f28c8958748df374a95a8c52a8063d
|
a80542d67d86dd37b9c6693e11ee666cbcfbe9f1
|
refs/heads/master
| 2023-08-19T00:21:35.753336
| 2023-08-06T22:12:44
| 2023-08-07T11:36:07
| 2,008,752
| 308
| 182
|
NOASSERTION
| 2023-09-09T21:36:25
| 2011-07-06T20:35:15
|
C
|
UTF-8
|
C
| false
| false
| 3,747
|
h
|
Rect.h
|
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_RECT_H
#define SFML_RECT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h>
#include <SFML/System/Vector2.h>
////////////////////////////////////////////////////////////
/// sfFloatRect and sfIntRect are utility classes for
/// manipulating rectangles.
////////////////////////////////////////////////////////////
typedef struct
{
float left;
float top;
float width;
float height;
} sfFloatRect;
typedef struct
{
int left;
int top;
int width;
int height;
} sfIntRect;
////////////////////////////////////////////////////////////
/// \brief Check if a point is inside a rectangle's area
///
/// \param rect Rectangle to test
/// \param x X coordinate of the point to test
/// \param y Y coordinate of the point to test
///
/// \return sfTrue if the point is inside
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfFloatRect_contains(const sfFloatRect* rect, float x, float y);
CSFML_GRAPHICS_API sfBool sfIntRect_contains(const sfIntRect* rect, int x, int y);
////////////////////////////////////////////////////////////
/// \brief Check intersection between two rectangles
///
/// \param rect1 First rectangle to test
/// \param rect2 Second rectangle to test
/// \param intersection Rectangle to be filled with overlapping rect (can be NULL)
///
/// \return sfTrue if rectangles overlap
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfBool sfFloatRect_intersects(const sfFloatRect* rect1, const sfFloatRect* rect2, sfFloatRect* intersection);
CSFML_GRAPHICS_API sfBool sfIntRect_intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntRect* intersection);
////////////////////////////////////////////////////////////
/// \brief Get the position of the rectangle's top-left corner
///
/// \return Position of rectangle
///
/// \see getSize
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfFloatRect_getPosition(const sfFloatRect* rect);
CSFML_GRAPHICS_API sfVector2i sfIntRect_getPosition(const sfIntRect* rect);
////////////////////////////////////////////////////////////
/// \brief Get the size of the rectangle
///
/// \return Size of rectangle
///
/// \see getPosition
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfFloatRect_getSize(const sfFloatRect* rect);
CSFML_GRAPHICS_API sfVector2i sfIntRect_getSize(const sfIntRect* rect);
#endif // SFML_RECT_H
|
bfbf9ac1b6385e2ce0620afb3aa44948dec12755
|
e73547787354afd9b717ea57fe8dd0695d161821
|
/src/world/partner/sushie.h
|
b8e8a1c0937fd830180cb2489ff0fa5cc5c2dc71
|
[] |
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
| 488
|
h
|
sushie.h
|
#ifndef _WORLD_PARTNER_SUSHIE_H_
#define _WORLD_PARTNER_SUSHIE_H_
#include "common.h"
#include "script_api/map.h"
void world_sushie_init(Npc*);
void world_sushie_pre_battle(Npc*);
void world_sushie_post_battle(Npc*);
void world_sushie_sync_player_position(void);
extern EvtScript EVS_WorldSushie_TakeOut;
extern EvtScript EVS_WorldSushie_Update;
extern EvtScript EVS_WorldSushie_UseAbility;
extern EvtScript EVS_WorldSushie_PutAway;
extern EvtScript EVS_WorldSushie_EnterMap;
#endif
|
5a880dc72cce41757047927c6f0a59c17dc4729e
|
a11e4bdd6157b22067288d860507fa20abea033d
|
/src/bin/e_error.c
|
a993ea5dfabced732452f47c698a5e76df04b6cd
|
[
"BSD-2-Clause"
] |
permissive
|
JeffHoogland/moksha
|
85a0f39dc97daa61d35e64a511013d21552db288
|
c56013644d8cd8e32101bb38a8d1e4ebd9d47f37
|
refs/heads/master
| 2023-08-24T05:39:13.415948
| 2023-08-22T19:49:32
| 2023-08-22T19:49:32
| 34,704,822
| 179
| 51
|
NOASSERTION
| 2023-09-06T14:41:31
| 2015-04-28T02:59:19
|
C
|
UTF-8
|
C
| false
| false
| 327
|
c
|
e_error.c
|
#include "e.h"
/* local subsystem functions */
/* local subsystem globals */
/* externally accessible functions */
EAPI void
e_error_message_show_internal(char *txt)
{
/* FIXME: maybe log these to a file and display them at some point */
printf("<<<< Moksha Error >>>>\n%s\n", txt);
}
/* local subsystem functions */
|
90db9f8a19f4a9b5b26df4fd53bea9a8506192b9
|
1efd2de8bf77ec00eb2fcaf5749278495946d920
|
/src/pipeline/pipeline_internal.h
|
eb0e3d8be98d0bcb6ea3c117eb62406683514fbf
|
[
"BSD-2-Clause",
"BSD-2-Clause-Patent"
] |
permissive
|
daos-stack/daos
|
6f55bf3061fd830d5b8d28506e1295e2d3a27c38
|
ed5eed5df43a68571afe123132a743824c02637a
|
refs/heads/master
| 2023-08-31T21:43:37.606145
| 2023-08-31T16:38:00
| 2023-08-31T16:38:00
| 69,390,670
| 631
| 300
|
NOASSERTION
| 2023-09-14T18:55:15
| 2016-09-27T19:21:29
|
C
|
UTF-8
|
C
| false
| false
| 5,119
|
h
|
pipeline_internal.h
|
/**
* (C) Copyright 2016-2023 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
#ifndef __DAOS_PIPE_INTERNAL_H__
#define __DAOS_PIPE_INTERNAL_H__
#include <daos_pipeline.h>
struct filter_part_run_t {
d_iov_t *dkey;
uint32_t nr_iods;
daos_iod_t *iods;
/*daos_iom_t *ioms;*/
d_sg_list_t *akeys;
struct filter_part_compiled_t *parts;
uint32_t part_idx;
char *data_out;
size_t data_len_out;
bool log_out;
d_iov_t *iov_aggr;
uint64_t value_u_out;
int64_t value_i_out;
double value_r_out;
double value_d_out;
};
typedef int filter_func_t(struct filter_part_run_t *args);
struct filter_part_compiled_t {
uint32_t num_operands;
uint32_t idx_end_subtree;
d_iov_t *iov;
size_t data_offset;
size_t data_len;
filter_func_t *filter_func;
};
struct filter_compiled_t {
uint32_t num_parts;
struct filter_part_compiled_t *parts;
};
struct pipeline_compiled_t {
uint32_t num_filters;
struct filter_compiled_t *filters;
uint32_t num_aggr_filters;
struct filter_compiled_t *aggr_filters;
};
typedef struct {
uint32_t nr;
daos_iod_t *iods;
} daos_pipeline_iods_t;
typedef struct {
uint32_t nr;
d_sg_list_t *sgls;
} daos_pipeline_sgls_t;
void ds_pipeline_run_handler(crt_rpc_t *rpc);
int d_pipeline_check(daos_pipeline_t *pipeline);
void pipeline_aggregations_init(daos_pipeline_t *pipeline,
d_sg_list_t *sgl_agg);
void pipeline_aggregations_fixavgs(daos_pipeline_t *pipeline, double total, d_sg_list_t *sgl_agg);
int pipeline_compile(daos_pipeline_t *pipe, struct pipeline_compiled_t *comp_pipe);
void pipeline_compile_free(struct pipeline_compiled_t *comp_pipe);
typedef uint8_t _uint8_t;
typedef uint16_t _uint16_t;
typedef uint32_t _uint32_t;
typedef uint64_t _uint64_t;
typedef int8_t _int8_t;
typedef int16_t _int16_t;
typedef int32_t _int32_t;
typedef int64_t _int64_t;
typedef float _float;
typedef double _double;
filter_func_t filter_func_eq_u;
filter_func_t filter_func_eq_i;
filter_func_t filter_func_eq_d;
filter_func_t filter_func_eq_st;
filter_func_t filter_func_ne_u;
filter_func_t filter_func_ne_i;
filter_func_t filter_func_ne_d;
filter_func_t filter_func_ne_st;
filter_func_t filter_func_lt_u;
filter_func_t filter_func_lt_i;
filter_func_t filter_func_lt_d;
filter_func_t filter_func_lt_st;
filter_func_t filter_func_le_u;
filter_func_t filter_func_le_i;
filter_func_t filter_func_le_d;
filter_func_t filter_func_le_st;
filter_func_t filter_func_ge_u;
filter_func_t filter_func_ge_i;
filter_func_t filter_func_ge_d;
filter_func_t filter_func_ge_st;
filter_func_t filter_func_gt_u;
filter_func_t filter_func_gt_i;
filter_func_t filter_func_gt_d;
filter_func_t filter_func_gt_st;
filter_func_t filter_func_add_u;
filter_func_t filter_func_add_i;
filter_func_t filter_func_add_d;
filter_func_t filter_func_sub_u;
filter_func_t filter_func_sub_i;
filter_func_t filter_func_sub_d;
filter_func_t filter_func_mul_u;
filter_func_t filter_func_mul_i;
filter_func_t filter_func_mul_d;
filter_func_t filter_func_div_u;
filter_func_t filter_func_div_i;
filter_func_t filter_func_div_d;
filter_func_t aggr_func_sum_u;
filter_func_t aggr_func_sum_i;
filter_func_t aggr_func_sum_d;
filter_func_t aggr_func_max_u;
filter_func_t aggr_func_max_i;
filter_func_t aggr_func_max_d;
filter_func_t aggr_func_min_u;
filter_func_t aggr_func_min_i;
filter_func_t aggr_func_min_d;
filter_func_t filter_func_bitand_u;
filter_func_t filter_func_bitand_i;
filter_func_t filter_func_like;
filter_func_t filter_func_isnull;
filter_func_t filter_func_isnotnull;
filter_func_t filter_func_not;
filter_func_t filter_func_and;
filter_func_t filter_func_or;
filter_func_t getdata_func_dkey_u1;
filter_func_t getdata_func_dkey_u2;
filter_func_t getdata_func_dkey_u4;
filter_func_t getdata_func_dkey_u8;
filter_func_t getdata_func_dkey_i1;
filter_func_t getdata_func_dkey_i2;
filter_func_t getdata_func_dkey_i4;
filter_func_t getdata_func_dkey_i8;
filter_func_t getdata_func_dkey_r4;
filter_func_t getdata_func_dkey_r8;
filter_func_t getdata_func_dkey_raw;
filter_func_t getdata_func_dkey_st;
filter_func_t getdata_func_dkey_cst;
filter_func_t getdata_func_akey_u1;
filter_func_t getdata_func_akey_u2;
filter_func_t getdata_func_akey_u4;
filter_func_t getdata_func_akey_u8;
filter_func_t getdata_func_akey_i1;
filter_func_t getdata_func_akey_i2;
filter_func_t getdata_func_akey_i4;
filter_func_t getdata_func_akey_i8;
filter_func_t getdata_func_akey_r4;
filter_func_t getdata_func_akey_r8;
filter_func_t getdata_func_akey_raw;
filter_func_t getdata_func_akey_st;
filter_func_t getdata_func_akey_cst;
filter_func_t getdata_func_const_u1;
filter_func_t getdata_func_const_u2;
filter_func_t getdata_func_const_u4;
filter_func_t getdata_func_const_u8;
filter_func_t getdata_func_const_i1;
filter_func_t getdata_func_const_i2;
filter_func_t getdata_func_const_i4;
filter_func_t getdata_func_const_i8;
filter_func_t getdata_func_const_r4;
filter_func_t getdata_func_const_r8;
filter_func_t getdata_func_const_raw;
filter_func_t getdata_func_const_st;
filter_func_t getdata_func_const_cst;
#endif /* __DAOS_PIPE_INTERNAL_H__ */
|
0a243bcde9d04978a041dbd0052d5e836469279a
|
73b0f9c30d07993ad74f7f2bcbc0fe61f1d1a3ce
|
/native/iosTest/Pods/Headers/Private/RCT-Folly/folly/Executor.h
|
542650dd3d9470b9652f5129b05392944d9ef118
|
[
"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
| 38
|
h
|
Executor.h
|
../../../../RCT-Folly/folly/Executor.h
|
47bb974a7a96a832d75d3711ccfb297a99dce3cd
|
30b736259b38c916e96f8e1517f92231070f5464
|
/nimble/host/include/host/ble_hs_hci.h
|
237712080a5bc299fd38b94a4ce80da526318e6d
|
[
"Apache-2.0",
"LicenseRef-scancode-gary-s-brown",
"BSD-3-Clause"
] |
permissive
|
apache/mynewt-nimble
|
5bcc87df4482705c5a6542467bab028c8fd4e5fe
|
b5e107e9c55f32d18b16e5afc0a7e1720b901b68
|
refs/heads/master
| 2023-09-01T19:28:57.874159
| 2023-08-31T09:07:59
| 2023-08-31T14:46:07
| 113,086,218
| 606
| 354
|
Apache-2.0
| 2023-09-14T12:14:19
| 2017-12-04T19:34:47
|
C
|
UTF-8
|
C
| false
| false
| 4,569
|
h
|
ble_hs_hci.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 H_BLE_HS_HCI_
#define H_BLE_HS_HCI_
/**
* @brief Bluetooth Host HCI utils
* @defgroup bt_host_hci Bluetooth Host HCI utils
* @ingroup bt_host
* @{
*/
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Queries the controller for the channel map used with the specified
* connection. The channel map is represented as an array of five bytes, with
* each bit corresponding to an individual channel. The array is interpreted
* as little-endian, such that:
* map[0] & 0x01 --> Channel 0.
* map[0] & 0x02 --> Channel 1.
* ...
* map[1] & 0x01 --> Channel 8.
*
* As there are 37 channels, only the first 37 bits get written.
*
* If a bit is 1, the corresponding channel is used. Otherwise, the channel is
* unused.
*
* @param conn_handle The handle of the connection whose channel map
* is being read.
* @param out_chan_map On success, the retrieved channel map gets
* written here. This buffer must have a size
* >= 5 bytes.
*
* @return 0 on success;
* A BLE host HCI return code if the controller
* rejected the request;
* A BLE host core return code on unexpected
* error.
*/
int ble_hs_hci_read_chan_map(uint16_t conn_handle, uint8_t *out_chan_map);
/**
* Instructs the controller to use the specified channel map. The channel map
* is represented as an array of five bytes, with each bit corresponding to an
* individual channel. The array is interpreted as little-endian, such that:
* map[0] & 0x01 --> Channel 0.
* map[0] & 0x02 --> Channel 1.
* ...
* map[1] & 0x01 --> Channel 8.
*
* As there are 37 channels, only the first 37 bits should be written are used.
*
* If a bit is 1, the corresponding channel can be used. Otherwise, the
* channel should not be used.
*
* @param chan_map The channel map to configure. This buffer
* should have a size of 5 bytes.
*
* @return 0 on success;
* A BLE host HCI return code if the controller
* rejected the request;
* A BLE host core return code on unexpected
* error.
*/
int ble_hs_hci_set_chan_class(const uint8_t *chan_map);
/**
* Reads random data into buffer from controller.
* This allows to use BLE controller as a source of true random data.
*
* @param dst Destination buffer.
* @param len Destination buffer length.
*
* @return 0 on success;
* A BLE host HCI return code if the controller
* rejected the request;
* A BLE host core return code on unexpected
* error.
*/
int ble_hs_hci_rand(void *dst, int len);
#if MYNEWT_VAL(BLE_HCI_VS)
/**
* Send an arbitrary HCI command to the controller.
*
* The command has to be a vendor-specific command, i.e. OGF=0x3f is always
* assumed.
*
* @param ocf OCF for vendor-specific HCI command
* @param cmdbuf command buffer
* @param cmdlen length of command buffer
* @param rspbuf response buffer
* @param rsplen length of response buffer
* @return 0 on success, error code on failure
*/
int ble_hs_hci_send_vs_cmd(uint16_t ocf, const void *cmdbuf, uint8_t cmdlen,
void *rspbuf, uint8_t rsplen);
#endif
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif
|
966898bb2739a57dee26b0bd812fb86d45cae70e
|
6832a9c81b16ead373325f70fb97753d6a211539
|
/src/wrapped/generated/wrappedlibjpeg62undefs.h
|
9e328009244055fa6411f840665ef3fff73c7a04
|
[
"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
| 320
|
h
|
wrappedlibjpeg62undefs.h
|
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.0.0.11) *
*******************************************************************/
#ifndef __wrappedlibjpeg62UNDEFS_H_
#define __wrappedlibjpeg62UNDEFS_H_
#endif // __wrappedlibjpeg62UNDEFS_H_
|
2513a39d2225057f77e2ebfa73e436e61640edf8
|
2df5bdb83ad89c9961f554b426b8ea165942384b
|
/src/logging.h
|
ec7e104040c76fde438184b35c4545b4fc1b72e0
|
[
"BSD-2-Clause"
] |
permissive
|
varnish/hitch
|
d5e2b62db2daf38eddc47577a1d80aa78a3b3932
|
c5c2e758508741e374164bd8c88b418d83b42706
|
refs/heads/master
| 2023-08-19T21:00:28.424109
| 2023-08-09T11:39:10
| 2023-08-09T11:39:21
| 33,190,756
| 1,974
| 225
|
NOASSERTION
| 2023-08-08T11:06:04
| 2015-03-31T14:42:05
|
C
|
UTF-8
|
C
| false
| false
| 3,043
|
h
|
logging.h
|
/**
* Copyright 2016 Varnish Software
*
* 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 VARNISH SOFTWARE ``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 BUMP
* TECHNOLOGIES, INC. 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 LOGGING_H_INCLUDED
#define LOGGING_H_INCLUDED
#include "config.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <ev.h>
#include <stdio.h>
#include <syslog.h>
// #include "asn_gentm.h"
#include "configuration.h"
#include "hitch.h"
// #include "miniobj.h"
// #include "ringbuffer.h"
// #include "vas.h"
// #include "vsb.h"
double Time_now(void);
void WLOG(int level, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
void logproxy(int level, const proxystate* ps, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
void VWLOG(int level, const char *fmt, va_list ap);
void WLOG(int level, const char *fmt, ...);
void log_ssl_error(proxystate *ps, const char *what, ...);
void fail(const char *s);
#define LOG(...) \
do { \
if (CONFIG->LOG_LEVEL > 1) \
WLOG(LOG_INFO, __VA_ARGS__ ); \
} while (0)
#define ERR(...) \
do { \
if (CONFIG->LOG_LEVEL > 0) \
WLOG(LOG_ERR, __VA_ARGS__ ); \
} while (0)
#define LOGL(...) WLOG(LOG_INFO, __VA_ARGS__)
#define SOCKERR(msg) \
do { \
if (errno == ECONNRESET) { \
LOG(msg ": %s\n", strerror(errno)); \
} else { \
ERR(msg ": %s\n", strerror(errno)); \
} \
} while (0)
#define LOGPROXY(...) \
do { \
if (CONFIG->LOG_LEVEL > 1 && \
(logfile || CONFIG->SYSLOG)) \
logproxy(LOG_INFO, __VA_ARGS__ ); \
} while(0)
#define ERRPROXY(...) \
do { \
if (CONFIG->LOG_LEVEL > 0 && \
(logfile || CONFIG->SYSLOG)) \
logproxy(LOG_ERR, __VA_ARGS__ ); \
} while (0)
#endif /* LOGGING_H_INCLUDED */
|
74809fc5bbced01c681d0a72f6bd18607ef8b891
|
7b92efd7dfb60d9b0a498871d5ffa699d0cf7d9e
|
/src/modules/out_udp.c
|
63e0bb5a5ac2ea71daffb759d20ba44b6ee4852c
|
[
"ISC"
] |
permissive
|
shinyblink/sled
|
854499be7c589b2d705050b41b8324ed66948e45
|
9d8e60ccbf6d8a30db83f41a8a4435d4c6b317a1
|
refs/heads/master
| 2023-07-24T08:30:03.348039
| 2023-07-08T14:00:54
| 2023-07-08T22:17:15
| 115,367,599
| 107
| 20
|
ISC
| 2023-07-08T22:17:17
| 2017-12-25T23:06:04
|
C
|
UTF-8
|
C
| false
| false
| 5,790
|
c
|
out_udp.c
|
// UDP output.
// Follows the protocol of CalcProgrammer1/KeyboardVisualizer's LED strip code.
// Quite a big mess. It works, however.
//
// Copyright (c) 2019, Adrian "vifino" Pistol <vifino@tty.sh>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice 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 <types.h>
#include <timers.h>
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <util.h>
#include <assert.h>
#define BUFLEN 1024
#define TILE_PLAIN 1
#define TILE_SNAKE 2
static int sock = -1;
struct sockaddr_in sio;
static int port;
static int X_SIZE;
static int Y_SIZE;
static int tiletype;
static char* envdup;
#define NUMPIX (X_SIZE * Y_SIZE)
// Message will be:
// 0xAA <R,G,B bytes..> <2 bytes checksum, unsigned short, hi, low>
static byte* message;
int init (int moduleno, char* argstr) {
// Partially initialize the socket.
if ((sock=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
perror("out_udp: Failed to initialize socket");
return 2;
}
memset((char *) &sio, 0, sizeof(struct sockaddr_in));
sio.sin_family = AF_INET;
// Parse string. This sucks.
if (argstr == NULL) {
eprintf("UDP argstring not set. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 3;
}
char* data = argstr;
char* ip = data;
char* portstr;
if (strsep(&data, ":") == NULL) {
eprintf("UDP argstring doesn't contain a port seperator. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 3;
}
if ((portstr = strsep(&data, ",")) == NULL) { // can't find anything after : before ,
eprintf("UDP argstring doesn't contain port. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 3;
}
if (inet_aton(ip, &sio.sin_addr) == 0) {
eprintf("UDP argstring doesn't contain a valid IP. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 4;
}
char* xd;
if ((xd = strsep(&data, "x")) == NULL) { // can't find anything after ,
eprintf("UDP argstring doesn't contain X size. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 3;
}
port = util_parse_int(portstr);
if (port == 0) {
eprintf("UDP argstring doesn't contain a valid port. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 4;
}
sio.sin_port = htons(port);
char* yd;
if ((yd = strsep(&data, ",")) == NULL) { // can't find anything after ,
eprintf("UDP argstring doesn't contain Y size. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 3;
}
X_SIZE = util_parse_int(xd);
if (X_SIZE == 0) {
eprintf("UDP argstring doesn't contain a X matrix size. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 4;
}
Y_SIZE = util_parse_int(yd);
if (Y_SIZE == 0) {
eprintf("UDP argstring doesn't contain a Y matrix size. Example: -o udp:192.168.69.42:1234,16x8,snake\n");
return 4;
}
// parse tiletype
char* tilename = data;
tiletype = -1;
if (strcmp(tilename, "plain") == 0) tiletype = TILE_PLAIN;
if (strcmp(tilename, "snake") == 0) tiletype = TILE_SNAKE;
if (tiletype == -1) {
eprintf("UDP argstring doesn't contain a valid tiling type. Example: MATRIX=192.168.69.42:1234,16x8,snake\n");
return 4;
}
// Allocate the message buffer.
message = calloc((NUMPIX * 3) + 3, 1);
assert(message); // 2lazy to handle it properly.
message[0] = 0xAA;
// Free stuff.
free(argstr);
return 0;
}
int getx(int _modno) {
return X_SIZE;
}
int gety(int _modno) {
return Y_SIZE;
}
int ppos(int x, int y) {
assert(x >= 0);
assert(y >= 0);
assert(x < X_SIZE);
assert(y < Y_SIZE);
switch (tiletype) {
case TILE_PLAIN:
return (x + (y * X_SIZE));
break;
case TILE_SNAKE:
return (((y % 2) == 0 ? x : (X_SIZE - 1) - x) + X_SIZE * y);
break;
}
return -1;
}
int set(int _modno, int x, int y, RGB color) {
assert(x >= 0);
assert(y >= 0);
assert(x < X_SIZE);
assert(y < Y_SIZE);
int pos = (ppos(x, y) * 3) + 1;
message[pos + 0] = color.red;
message[pos + 1] = color.green;
message[pos + 2] = color.blue;
return 0;
}
RGB get(int _modno, int x, int y) {
assert(x >= 0);
assert(y >= 0);
assert(x < X_SIZE);
assert(y < Y_SIZE);
int pos = (ppos(x, y) * 3) + 1;
return RGB(message[pos + 0], message[pos + 1], message[pos + 2]);
}
int clear(int _modno) {
// message[1] to skip a byte (the 0xAA);
memset(&message[1], '\0', NUMPIX);
return 0;
};
int render(void) {
// calculate checksum
unsigned short chksum = 0;
int i;
for (i = 0; i <= (NUMPIX * 3); ++i)
chksum += message[i];
message[(NUMPIX * 3) + 1] = chksum >> 8; // high byte.
message[(NUMPIX * 3) + 2] = chksum & 0x00FF; // low byte.
// send udp packet.
if (sendto(sock, message, ((NUMPIX * 3) + 3), 0, (struct sockaddr*) &sio, sizeof(sio)) == -1) {
perror("out_udp: Failed to send UDP packet");
return 5;
}
return 0;
}
oscore_time wait_until(int _modno, oscore_time desired_usec) {
// Hey, we can just delegate work to someone else. Yay!
return timers_timers_wait_until_core(desired_usec);
}
void wait_until_break(int _modno) {
return timers_timers_wait_until_break_core();
}
void deinit(int _modno) {
close(sock);
free(message);
}
|
19c1d4c83e721c0cd5a8edb737fb33cbb8053ed9
|
8723bbb0ffe8f590342892f40cda4c4f8e4fb7c3
|
/Class/DFU/usbd_dfu.c
|
516aae32dbf64ac33c92a5523bccbbc1367b3d47
|
[
"Apache-2.0"
] |
permissive
|
IntergatedCircuits/USBDevice
|
ef403dc2aea6a9a902da449a05a52746eb31cd1e
|
32b1e327fb7caa0e012de50da7b4b5e0669ee8c0
|
refs/heads/master
| 2022-05-08T16:46:18.218239
| 2022-03-25T11:22:06
| 2022-03-25T11:22:06
| 121,952,517
| 215
| 49
|
Apache-2.0
| 2020-05-01T19:36:13
| 2018-02-18T13:05:10
|
C
|
UTF-8
|
C
| false
| false
| 35,791
|
c
|
usbd_dfu.c
|
/**
******************************************************************************
* @file usbd_dfu.c
* @author Benedek Kupper
* @version 0.1
* @date 2018-03-11
* @brief USB Device Firmware Upgrade Class implementation
*
* Copyright (c) 2018 Benedek Kupper
*
* 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 <private/usbd_internal.h>
#include <usbd_dfu.h>
#include <string.h>
#if (USBD_DFU_ALTSETTINGS != 0)
#define DFU_APP(ITF) ((USBD_DFU_AppType*)(&(ITF)->App[(ITF)->Base.AltSelector]))
#else
#define DFU_APP(ITF) ((USBD_DFU_AppType*)((ITF)->App))
#endif
#define DFU_CLASS_REQ_COUNT (sizeof(dfu_validStates)/sizeof(dfu_validStates[0]))
#define DFU_ATTR_WILL_DETACH 0x08
#define DFU_ATTR_MANIFESTATION_TOLERANT 0x04
#define DFU_ATTR_CAN_UPLOAD 0x02
#define DFU_ATTR_CAN_DNLOAD 0x01
#ifndef USBD_DFU_ST_EXTENSION
#define USBD_DFU_ST_EXTENSION 0
#endif
/* DFU STMicroelectronics Extension (DFUSE) commands */
#define DFUSE_CMD_GETCOMMANDS 0x00
#define DFUSE_CMD_SETADDRESSPOINTER 0x21
#define DFUSE_CMD_ERASE 0x41
#define DFUSE_CMD_READ_UNPROTECT 0x92
#define DFUSE_GETADDRESS(ITF, DESC) \
((uint8_t*)((ITF)->Address + (((ITF)->BlockNum - 2) * (DESC)->DFUFD.wTransferSize)))
typedef PACKED(struct) {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bmAttributes; /*
[bitCanDnload]
[bitCanUpload]
[bitManifestationTolerant] means no USB reset is needed
[bitWillDetach] means Disconnect-Connect for DFU_DETACH
4b reserved */
uint16_t wDetachTimeOut;
uint16_t wTransferSize;
uint16_t bcdDFUVersion;
}USBD_DFU_FuncDescType;
typedef PACKED(struct)
{
/* DFU Interface Descriptor */
USB_InterfaceDescType DFU;
/* DFU Functional Descriptor */
USBD_DFU_FuncDescType DFUFD;
}USBD_DFU_DescType;
static const USBD_DFU_DescType dfu_desc = {
.DFU = { /* DFU Interface Descriptor */
.bLength = sizeof(dfu_desc.DFU),
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 0,
.bInterfaceClass = 0xFE, /* bInterfaceClass: Application Specific Class Code */
.bInterfaceSubClass = 0x01, /* bInterfaceSubClass: Device Firmware Upgrade Code */
.bInterfaceProtocol = 0x01, /* bInterfaceProtocol: 1=runtime, 2=boot mode */
.iInterface = USBD_ISTR_INTERFACES,
},
.DFUFD = { /* DFU Functional Descriptor */
.bLength = sizeof(dfu_desc.DFUFD),
.bDescriptorType = DFU_DESC_TYPE_FUNCTIONAL,
.bmAttributes =
#if (USBD_DFU_MANIFEST_TOLERANT != 0)
DFU_ATTR_MANIFESTATION_TOLERANT |
#endif
DFU_ATTR_WILL_DETACH,
.wDetachTimeOut = 100, /* Wait time [ms] between DFU_DETACH and USB reset */
.wTransferSize = USBD_EP0_BUFFER_SIZE,
#if (USBD_DFU_ST_EXTENSION != 0)
.bcdDFUVersion = 0x011A,
#else
.bcdDFUVersion = 0x0101,
#endif
},
};
#if (USBD_DFU_ST_EXTENSION != 0)
__alignment(USBD_DATA_ALIGNMENT)
/* List of supported DFU SE commands */
static const uint8_t dfuse_cmds[] __align(USBD_DATA_ALIGNMENT) = {
DFUSE_CMD_GETCOMMANDS,
DFUSE_CMD_SETADDRESSPOINTER,
DFUSE_CMD_ERASE,
};
#endif
/** @brief Bitmask stores which request (key) is valid in which DFU states (value) */
static const uint16_t dfu_validStates[] = {
/* DFU_REQ_DETACH */
(1 << DFU_STATE_APP_IDLE),
/* DFU_REQ_DNLOAD */
(1 << DFU_STATE_IDLE) | (1 << DFU_STATE_DNLOAD_IDLE),
/* DFU_REQ_UPLOAD */
(1 << DFU_STATE_IDLE) | (1 << DFU_STATE_UPLOAD_IDLE),
/* DFU_REQ_GETSTATUS */
(1 << DFU_STATE_APP_IDLE) | (1 << DFU_STATE_APP_DETACH) |
(1 << DFU_STATE_IDLE) | (1 << DFU_STATE_DNLOAD_SYNC) |
(1 << DFU_STATE_DNLOAD_IDLE) | (1 << DFU_STATE_MANIFEST_SYNC) |
(1 << DFU_STATE_UPLOAD_IDLE) | (1 << DFU_STATE_ERROR),
/* DFU_REQ_CLRSTATUS */
(1 << DFU_STATE_ERROR),
/* DFU_REQ_GETSTATE */
(1 << DFU_STATE_APP_IDLE) | (1 << DFU_STATE_APP_DETACH) |
(1 << DFU_STATE_IDLE) | (1 << DFU_STATE_DNLOAD_SYNC) |
(1 << DFU_STATE_DNLOAD_IDLE) | (1 << DFU_STATE_MANIFEST_SYNC) |
(1 << DFU_STATE_UPLOAD_IDLE) | (1 << DFU_STATE_ERROR),
/* DFU_REQ_ABORT */
(1 << DFU_STATE_IDLE) | (1 << DFU_STATE_DNLOAD_SYNC) |
(1 << DFU_STATE_DNLOAD_IDLE) | (1 << DFU_STATE_MANIFEST_SYNC) |
(1 << DFU_STATE_UPLOAD_IDLE),
};
static USBD_ReturnType dfu_detach (USBD_DFU_IfHandleType *itf);
static USBD_ReturnType dfu_download (USBD_DFU_IfHandleType *itf);
static USBD_ReturnType dfu_upload (USBD_DFU_IfHandleType *itf);
static USBD_ReturnType dfu_getStatus (USBD_DFU_IfHandleType *itf);
static USBD_ReturnType dfu_clearStatus (USBD_DFU_IfHandleType *itf);
static USBD_ReturnType dfu_getState (USBD_DFU_IfHandleType *itf);
static USBD_ReturnType dfu_abort (USBD_DFU_IfHandleType *itf);
#if (USBD_DFU_ALTSETTINGS != 0)
static uint16_t dfu_getAltsDesc (USBD_DFU_IfHandleType *itf, uint8_t ifNum, uint8_t * dest);
#else
static uint16_t dfu_getDesc (USBD_DFU_IfHandleType *itf, uint8_t ifNum, uint8_t * dest);
#endif
static const char * dfu_getString (USBD_DFU_IfHandleType *itf, uint8_t intNum);
static void dfu_init (USBD_DFU_IfHandleType *itf);
static void dfu_deinit (USBD_DFU_IfHandleType *itf);
static USBD_ReturnType dfu_setupStage (USBD_DFU_IfHandleType *itf);
static void dfu_dataStage (USBD_DFU_IfHandleType *itf);
/* DFU interface class callbacks structure */
static const USBD_ClassType dfu_cbks = {
#if (USBD_DFU_ALTSETTINGS != 0)
.GetDescriptor = (USBD_IfDescCbkType) dfu_getAltsDesc,
#else
.GetDescriptor = (USBD_IfDescCbkType) dfu_getDesc,
#endif
.GetString = (USBD_IfStrCbkType) dfu_getString,
.Init = (USBD_IfCbkType) dfu_init,
.Deinit = (USBD_IfCbkType) dfu_deinit,
.SetupStage = (USBD_IfSetupCbkType) dfu_setupStage,
.DataStage = (USBD_IfCbkType) dfu_dataStage,
#if (USBD_MS_OS_DESC_VERSION > 0)
.MsCompatibleId = "WINUSB",
#else
#warning "Without Microsoft OS descriptor support the WinUSB/other function driver will have to be installed manually on Windows OS!"
#endif /* (USBD_MS_OS_DESC_VERSION > 0) */
};
static USBD_ReturnType (*const dfu_reqFns[])(USBD_DFU_IfHandleType *itf) = {
dfu_detach,
dfu_download,
dfu_upload,
dfu_getStatus,
dfu_clearStatus,
dfu_getState,
dfu_abort,
};
static uint16_t rodfu_getDesc (USBD_DFU_IfHandleType *itf, uint8_t ifNum, uint8_t * dest);
static USBD_ReturnType rodfu_setupStage(USBD_DFU_IfHandleType *itf);
/* Reboot-only DFU interface class callbacks structure */
static const USBD_ClassType rodfu_cbks = {
.GetDescriptor = (USBD_IfDescCbkType) rodfu_getDesc,
.GetString = (USBD_IfStrCbkType) dfu_getString,
.SetupStage = (USBD_IfSetupCbkType) rodfu_setupStage,
#if (USBD_MS_OS_DESC_VERSION > 0)
.MsCompatibleId = "WINUSB",
#endif /* (USBD_MS_OS_DESC_VERSION > 0) */
};
/** @ingroup USBD_DFU
* @defgroup USBD_DFU_Private_Functions DFU Private Functions
* @{ */
/**
* @brief Copies the interface descriptor to the destination buffer.
* @param itf: reference of the DFU interface
* @param ifNum: the index of the current interface in the device
* @param dest: the destination buffer
* @return Length of the copied descriptor
*/
static uint16_t rodfu_getDesc(USBD_DFU_IfHandleType *itf, uint8_t ifNum, uint8_t * dest)
{
USBD_DFU_DescType *desc = (USBD_DFU_DescType*)dest;
uint16_t len = sizeof(dfu_desc);
memcpy(dest, &dfu_desc, sizeof(dfu_desc));
desc->DFUFD.wDetachTimeOut = itf->Config.DetachTimeout_ms;
/* Adjustment of interface indexes */
desc->DFU.bInterfaceNumber = ifNum;
desc->DFU.iInterface = USBD_IIF_INDEX(ifNum, 0);
return len;
}
#if (USBD_DFU_ALTSETTINGS != 0)
/**
* @brief Copies the interface descriptor to the destination buffer.
* @param itf: reference of the DFU interface
* @param ifNum: the index of the current interface in the device
* @param dest: the destination buffer
* @return Length of the copied descriptor
*/
static uint16_t dfu_getAltsDesc(USBD_DFU_IfHandleType *itf, uint8_t ifNum, uint8_t * dest)
{
uint8_t as;
uint16_t len = 0;
USBD_DFU_FuncDescType *desc = (USBD_DFU_FuncDescType*)(dest +
(itf->Base.AltCount * sizeof(dfu_desc.DFU)));
/* Copy the DFU func desc after the interface descriptors */
memcpy(desc, &dfu_desc.DFUFD, sizeof(dfu_desc.DFUFD));
desc->wDetachTimeOut = itf->Config.DetachTimeout_ms;
/* Copy the descriptors many times, add alternate setting indexes */
for (as = 0; as < itf->Base.AltCount; as++)
{
USB_InterfaceDescType *ifdesc = (USB_InterfaceDescType*)&dest[len];
memcpy(ifdesc, &dfu_desc.DFU, sizeof(dfu_desc.DFU));
len += sizeof(dfu_desc.DFU);
/* Set attributes */
if ((itf->App[as].Erase != NULL) && (itf->App[as].Write != NULL))
{
desc->bmAttributes |= DFU_ATTR_CAN_DNLOAD;
}
if (itf->App[as].Read != NULL)
{
desc->bmAttributes |= DFU_ATTR_CAN_UPLOAD;
}
/* Adjustment of interface indexes */
ifdesc->bInterfaceNumber = ifNum;
ifdesc->bAlternateSetting = as;
ifdesc->iInterface = USBD_IIF_INDEX(ifNum, as);
}
len += sizeof(dfu_desc.DFUFD);
return len;
}
#else
/**
* @brief Copies the interface descriptor to the destination buffer.
* @param itf: reference of the DFU interface
* @param ifNum: the index of the current interface in the device
* @param dest: the destination buffer
* @return Length of the copied descriptor
*/
static uint16_t dfu_getDesc(USBD_DFU_IfHandleType *itf, uint8_t ifNum, uint8_t * dest)
{
USBD_DFU_DescType *desc = (USBD_DFU_DescType*)dest;
uint16_t len = rodfu_getDesc(itf, ifNum, dest);
/* Set attributes */
if ((DFU_APP(itf)->Erase != NULL) && (DFU_APP(itf)->Write != NULL))
{
desc->DFUFD.bmAttributes |= DFU_ATTR_CAN_DNLOAD;
}
if (DFU_APP(itf)->Read != NULL)
{
desc->DFUFD.bmAttributes |= DFU_ATTR_CAN_UPLOAD;
}
/* Switch between runtime (0x01) and DFU mode (0x02) protocol */
if (itf->DevStatus.State >= DFU_STATE_IDLE)
{
desc->DFU.bInterfaceProtocol = 0x02;
}
return len;
}
#endif /* (USBD_DFU_ALTSETTINGS != 0) */
/**
* @brief Returns the selected interface string.
* @param itf: reference of the DFU interface
* @param intNum: interface-internal string index
* @return The referenced string
*/
static const char* dfu_getString(USBD_DFU_IfHandleType *itf, uint8_t intNum)
{
#if (USBD_DFU_ALTSETTINGS != 0)
if (intNum < itf->Base.AltCount)
{
return itf->App[intNum].Name;
}
else
{
return NULL;
}
#else
return itf->App->Name;
#endif
}
/**
* @brief Initializes the interface by resetting the internal variables
* and initializing the attached application.
* @param itf: reference of the DFU interface
*/
static void dfu_init(USBD_DFU_IfHandleType *itf)
{
/* Internal variables initialization */
itf->DevStatus.__reserved = 0;
itf->DevStatus.iString = 0;
itf->DevStatus.PollTimeout = 0;
itf->Tag[0] = itf->Tag[1] = 0;
/* DFU mode only */
if (itf->DevStatus.State >= DFU_STATE_IDLE)
{
dfu_abort(itf);
itf->Address = (uint8_t*)DFU_APP(itf)->Firmware.Address;
/* Initialize media */
USBD_SAFE_CALLBACK(DFU_APP(itf)->Init, );
}
}
/**
* @brief Removes other USB interfaces from the device if in APP_DETACH state.
* Otherwise deinitializes the interface's attached application.
* @param itf: reference of the DFU interface
*/
static void dfu_deinit(USBD_DFU_IfHandleType *itf)
{
/* In DFU mode */
if (itf->DevStatus.State >= DFU_STATE_IDLE)
{
/* Deinitialize media */
USBD_SAFE_CALLBACK(DFU_APP(itf)->Deinit, );
}
}
/**
* @brief Performs the interface-specific setup request handling.
* @param itf: reference of the DFU interface
* @return OK if the setup request is accepted, INVALID otherwise
*/
static USBD_ReturnType rodfu_setupStage(USBD_DFU_IfHandleType *itf)
{
USBD_ReturnType retval = USBD_E_INVALID;
USBD_HandleType *dev = itf->Base.Device;
switch (dev->Setup.RequestType.Type)
{
case USB_REQ_TYPE_STANDARD:
{
/* DFU specific descriptors can be requested */
if (dev->Setup.Request == USB_REQ_GET_DESCRIPTOR)
{
switch (dev->Setup.Value >> 8)
{
/* Return DFU func. descriptor */
case DFU_DESC_TYPE_FUNCTIONAL:
{
#if USBD_DATA_ALIGNMENT > 1
void* data = dev->CtrlData;
memcpy(dev->CtrlData, &dfu_desc.DFUFD, sizeof(dfu_desc.DFUFD));
#else
void* data = &dfu_desc.DFUFD;
#endif
retval = USBD_CtrlSendData(dev, data, sizeof(dfu_desc.DFUFD));
break;
}
default:
break;
}
}
break;
}
case USB_REQ_TYPE_CLASS:
{
switch (dev->Setup.Request)
{
case DFU_REQ_DETACH:
retval = dfu_detach(itf);
break;
case DFU_REQ_GETSTATUS:
return USBD_CtrlSendData(dev,
&itf->DevStatus, sizeof(itf->DevStatus));
break;
case DFU_REQ_GETSTATE:
retval = dfu_getState(itf);
break;
default:
break;
}
break;
}
default:
break;
}
return retval;
}
/**
* @brief Performs the interface-specific setup request handling.
* @param itf: reference of the DFU interface
* @return OK if the setup request is accepted, INVALID otherwise
*/
static USBD_ReturnType dfu_setupStage(USBD_DFU_IfHandleType *itf)
{
USBD_ReturnType retval = USBD_E_INVALID;
USBD_HandleType *dev = itf->Base.Device;
switch (dev->Setup.RequestType.Type)
{
case USB_REQ_TYPE_STANDARD:
{
/* DFU specific descriptors can be requested */
if (dev->Setup.Request == USB_REQ_GET_DESCRIPTOR)
{
switch (dev->Setup.Value >> 8)
{
/* Return DFU func. descriptor */
case DFU_DESC_TYPE_FUNCTIONAL:
{
uint16_t len = dfu_cbks.GetDescriptor((void*)itf, 0, dev->CtrlData);
memcpy(dev->CtrlData, &dev->CtrlData[len - sizeof(dfu_desc.DFUFD)],
sizeof(dfu_desc.DFUFD));
retval = USBD_CtrlSendData(dev, dev->CtrlData,
sizeof(dfu_desc.DFUFD));
break;
}
default:
break;
}
}
break;
}
case USB_REQ_TYPE_CLASS:
{
uint8_t reqId = dev->Setup.Request;
uint16_t stateMask = 1 << itf->DevStatus.State;
/* Call the operation indexed by bRequest
* only if it can be executed in the current state */
if ((reqId < DFU_CLASS_REQ_COUNT) &&
((dfu_validStates[reqId] & stateMask) != 0) &&
(USBD_E_OK == dfu_reqFns[reqId](itf)))
{
retval = USBD_E_OK;
}
/* Don't leave APP mode */
else if (itf->DevStatus.State < DFU_STATE_IDLE)
{
itf->DevStatus.State = DFU_STATE_APP_IDLE;
}
else /* Enter error state on unexpected request */
{
itf->DevStatus.State = DFU_STATE_ERROR;
itf->DevStatus.Status = DFU_ERROR_STALLEDPKT;
}
break;
}
default:
break;
}
return retval;
}
/**
* @brief Handles the DFU DETACH request, which is followed by
* USB reset and device reconfiguration to DFU mode.
* When configured, performs attach-detach sequence.
* @param itf: reference of the DFU interface
* @return OK
*/
static USBD_ReturnType dfu_detach(USBD_DFU_IfHandleType *itf)
{
itf->DevStatus.State = DFU_STATE_APP_DETACH;
/* Check the detach capability in the DFU functional descriptor */
if ((dfu_desc.DFUFD.bmAttributes & DFU_ATTR_WILL_DETACH) != 0)
{
/* Set tag to DFU mode */
itf->Tag[0] = DFU_MODE_TAG;
itf->Tag[1] = ~DFU_MODE_TAG;
/* Reset the system into DFU mode */
USBD_SAFE_CALLBACK(itf->Config.Reboot, );
}
return USBD_E_OK;
}
/**
* @brief Saves context data for block downloading.
* @param itf: reference of the DFU interface
* @return INVALID if the request is rejected, OK otherwise
*/
static USBD_ReturnType dfu_download(USBD_DFU_IfHandleType *itf)
{
USBD_ReturnType retval = USBD_E_INVALID;
USBD_HandleType *dev = itf->Base.Device;
if (dev->Setup.Length > dfu_desc.DFUFD.wTransferSize)
{
/* Oversized request, invalid */
}
else if (dev->Setup.Length > 0)
{
/* Check for download support */
if ((DFU_APP(itf)->Erase != NULL) && (DFU_APP(itf)->Write != NULL))
{
#if (USBD_DFU_ST_EXTENSION == 0)
if (itf->DevStatus.State == DFU_STATE_IDLE)
{
/* Initialize address at first block */
itf->Address = (uint8_t*)DFU_APP(itf)->Firmware.Address;
itf->BlockNum = 0xFFFF;
}
/* Checks for valid sequence and overall length */
if ((dev->Setup.Value == ((itf->BlockNum + 1) & 0xFFFF)) &&
#else
if (
#endif /* (USBD_DFU_ST_EXTENSION == 0) */
(((uint32_t)itf->Address + dev->Setup.Length) <
(DFU_APP(itf)->Firmware.Address + DFU_APP(itf)->Firmware.TotalSize)))
{
/* Update the global length and block number */
itf->BlockNum = dev->Setup.Value;
itf->BlockLength = dev->Setup.Length;
/* Update the state machine */
itf->DevStatus.State = DFU_STATE_DNLOAD_SYNC;
/* Prepare the reception of the buffer over EP0 */
retval = USBD_CtrlReceiveData(dev, dev->CtrlData, itf->BlockLength);
}
}
}
/* Deviation from spec: allow 0 length Dnload in IDLE state to
* put device in manifestation mode ->
* It is possible to return to application mode without effective update */
else
{
itf->BlockLength = 1;
itf->DevStatus.State = DFU_STATE_MANIFEST_SYNC;
retval = USBD_E_OK;
}
return retval;
}
/**
* @brief Reads and sends a firmware block to the host.
* @param itf: reference of the DFU interface
* @return INVALID if the request is rejected, OK otherwise
*/
static USBD_ReturnType dfu_upload(USBD_DFU_IfHandleType *itf)
{
USBD_ReturnType retval = USBD_E_INVALID;
USBD_HandleType *dev = itf->Base.Device;
if (dev->Setup.Length > dfu_desc.DFUFD.wTransferSize)
{
/* Oversized request, invalid */
}
/* Send data to host if supported */
else if ((dev->Setup.Length > 0) && (DFU_APP(itf)->Read != NULL))
{
uint8_t *data = dev->CtrlData;
#if (USBD_DFU_ST_EXTENSION != 0)
itf->BlockNum = dev->Setup.Value;
/* Get commands */
if (itf->BlockNum == 0)
{
itf->DevStatus.State = (dev->Setup.Length > sizeof(dfuse_cmds)) ?
DFU_STATE_IDLE : DFU_STATE_UPLOAD_IDLE;
/* Return with supported commands */
retval = USBD_CtrlSendData(dev, (void*)dfuse_cmds, sizeof(dfuse_cmds));
}
/* Read memory */
else if (itf->BlockNum > 1)
{
uint8_t *addr = DFUSE_GETADDRESS(itf, &dfu_desc);
/* Check overall length */
if (((uint32_t)addr + dev->Setup.Length) <
(DFU_APP(itf)->Firmware.Address + DFU_APP(itf)->Firmware.TotalSize))
{
itf->DevStatus.State = DFU_STATE_UPLOAD_IDLE;
DFU_APP(itf)->Read(addr, data, dev->Setup.Length);
retval = USBD_CtrlSendData(dev, data, dev->Setup.Length);
}
}
#else
/* The host sends DFU_UPLOAD requests to the device until it
* responds with a short frame as an end of file (EOF) indicator.
* The device is responsible for selecting the address range
* to upload and formatting the firmware image appropriately. */
if (itf->DevStatus.State == DFU_STATE_IDLE)
{
/* Initialize address at first block */
itf->Address = (uint8_t*)DFU_APP(itf)->Firmware.Address;
itf->BlockNum = 0xFFFF;
}
/* Check for correct sequence */
if (dev->Setup.Value == ((itf->BlockNum + 1) & 0xFFFF))
{
uint16_t len;
uint32_t progress = (uint32_t)itf->Address - DFU_APP(itf)->Firmware.Address;
/* Shorten the block size if it's the end of the firmware memory,
* return to IDLE */
if ((progress + dev->Setup.Length) > DFU_APP(itf)->Firmware.TotalSize)
{
len = DFU_APP(itf)->Firmware.TotalSize - progress;
itf->DevStatus.State = DFU_STATE_IDLE;
}
else
{
len = dev->Setup.Length;
itf->DevStatus.State = DFU_STATE_UPLOAD_IDLE;
}
DFU_APP(itf)->Read(itf->Address, data, len);
/* Increment address for next block upload */
itf->Address += len;
itf->BlockNum = dev->Setup.Value;
retval = USBD_CtrlSendData(dev, data, len);
}
#endif /* (USBD_DFU_ST_EXTENSION != 0) */
}
else /* No data stage */
{
itf->DevStatus.State = DFU_STATE_IDLE;
retval = USBD_E_OK;
}
return retval;
}
/**
* @brief Updates and sends the DFU Status through the control pipe.
* @param itf: reference of the DFU interface
* @return OK
*/
static USBD_ReturnType dfu_getStatus(USBD_DFU_IfHandleType *itf)
{
USBD_HandleType *dev = itf->Base.Device;
/* Provide timeout values before starting download / manifestation */
if ((itf->DevStatus.State == DFU_STATE_DNLOAD_SYNC) ||
(itf->DevStatus.State == DFU_STATE_MANIFEST_SYNC))
{
if (itf->BlockLength > 0)
{
if (DFU_APP(itf)->GetTimeout_ms != NULL)
{
/* Read the poll timeout */
itf->DevStatus.PollTimeout = DFU_APP(itf)->GetTimeout_ms(
itf->Address,
itf->BlockLength);
}
/* DNLOAD_SYNC -> DNLOAD_BUSY
* MANIFEST_SYNC -> MANIFEST */
itf->DevStatus.State += 1;
}
else if (itf->DevStatus.State == DFU_STATE_DNLOAD_SYNC)
{
/* Download has been completed */
itf->DevStatus.State = DFU_STATE_DNLOAD_IDLE;
}
else /* DFU_STATE_MANIFEST_SYNC */
{
/* Manifestation has been completed */
itf->DevStatus.State = DFU_STATE_IDLE;
}
}
/* Send the status data over EP0 */
USBD_CtrlSendData(dev, &itf->DevStatus, sizeof(itf->DevStatus));
return USBD_E_OK;
}
/**
* @brief Clears the error status from the DFU interface.
* @param itf: reference of the DFU interface
* @return OK
*/
static USBD_ReturnType dfu_clearStatus(USBD_DFU_IfHandleType *itf)
{
itf->DevStatus.State = DFU_STATE_IDLE;
itf->DevStatus.Status = DFU_ERROR_NONE;
itf->DevStatus.PollTimeout = 0;
return USBD_E_OK;
}
/**
* @brief Sends the DFU state through the control pipe.
* @param itf: reference of the DFU interface
* @return OK
*/
static USBD_ReturnType dfu_getState(USBD_DFU_IfHandleType *itf)
{
return USBD_CtrlSendData(itf->Base.Device,
&itf->DevStatus.State, sizeof(itf->DevStatus.State));
}
/**
* @brief Returns the DFU to dfuIDLE state.
* @param itf: reference of the DFU interface
* @return OK
*/
static USBD_ReturnType dfu_abort(USBD_DFU_IfHandleType *itf)
{
itf->DevStatus.State = DFU_STATE_IDLE;
itf->DevStatus.Status = DFU_ERROR_NONE;
itf->DevStatus.PollTimeout = 0;
itf->BlockNum = 0;
itf->BlockLength = 0;
return USBD_E_OK;
}
/**
* @brief Performs time-consuming memory operations after a successful GetStatus transfer.
* @param itf: reference of the DFU interface
*/
static void dfu_dataStage(USBD_DFU_IfHandleType *itf)
{
USBD_HandleType *dev = itf->Base.Device;
/* Perform after GetStatus request */
if ((dev->Setup.RequestType.Type == USB_REQ_TYPE_CLASS) &&
(dev->Setup.Request == DFU_REQ_GETSTATUS))
{
switch (itf->DevStatus.State)
{
case DFU_STATE_DNLOAD_BUSY:
{
#if (USBD_DFU_ST_EXTENSION != 0)
/* Regular Download Command */
if (itf->BlockNum > 1)
{
itf->DevStatus.Status = DFU_APP(itf)->Write(
DFUSE_GETADDRESS(itf, &dfu_desc),
dev->CtrlData,
itf->BlockLength);
}
/* Execute special command */
else if (itf->BlockNum == 0)
{
PACKED(struct) {
uint8_t Cmd;
uint8_t *Address;
} *dfuseCmd = (void*)dev->CtrlData;
switch (dfuseCmd->Cmd)
{
/* Change the address pointer for more optimal flashing */
case DFUSE_CMD_SETADDRESSPOINTER:
if (itf->BlockLength == 5)
{
itf->Address = dfuseCmd->Address;
}
break;
/* Erase a flash block */
case DFUSE_CMD_ERASE:
if (itf->BlockLength == 5)
{
itf->Address = dfuseCmd->Address;
itf->DevStatus.Status = DFU_APP(itf)->Erase(
itf->Address);
}
break;
case DFUSE_CMD_READ_UNPROTECT:
case DFUSE_CMD_GETCOMMANDS:
break;
/* Not supported */
default:
itf->DevStatus.Status = DFU_ERROR_STALLEDPKT;
break;
}
}
#else
/* Erase firmware on the first block */
if (itf->Address == (uint8_t*)DFU_APP(itf)->Firmware.Address)
{
itf->DevStatus.Status = DFU_APP(itf)->Erase(
itf->Address);
}
/* Write after erase */
if (itf->DevStatus.Status == DFU_ERROR_NONE)
{
itf->DevStatus.Status = DFU_APP(itf)->Write(
itf->Address,
dev->CtrlData,
itf->BlockLength);
itf->Address += itf->BlockLength;
}
#endif /* (USBD_DFU_ST_EXTENSION != 0) */
/* New state if no errors occurred */
itf->DevStatus.State = DFU_STATE_DNLOAD_SYNC;
itf->BlockLength = 0;
itf->DevStatus.PollTimeout = 0;
break;
}
case DFU_STATE_MANIFEST:
{
/* Perform manifestation */
if (DFU_APP(itf)->Manifest != NULL)
{
itf->DevStatus.Status = DFU_APP(itf)->Manifest();
}
if (itf->DevStatus.Status == DFU_ERROR_NONE)
{
#if (USBD_DFU_MANIFEST_TOLERANT != 0)
itf->DevStatus.State = DFU_STATE_MANIFEST_SYNC;
itf->BlockLength = 0;
itf->DevStatus.PollTimeout = 0;
#else
itf->DevStatus.State = DFU_STATE_MANIFEST_WAIT_RESET;
/* Disconnect the USB device */
USBD_Deinit(itf->Base.Device);
/* Generate system reset to allow jumping to the user code */
USBD_SAFE_CALLBACK(itf->Config.Reboot, );
#endif
}
break;
}
default:
break;
}
}
/* If any operation encountered error, enter error state */
if (itf->DevStatus.Status != DFU_ERROR_NONE)
{
itf->DevStatus.State = DFU_STATE_ERROR;
}
}
/** @} */
/** @defgroup USBD_DFU_Exported_Functions_Boot DFU Exported Functions for Bootloader
* @{ */
/**
* @brief Sets the necessary fields of the DFU interface.
* @note This function shall be called in the DFU bootloader even if it jumps
* to the application immediately.
* @param itf: reference of the DFU interface
* @param pReboot: reference of the system rebooting function
* @param app: reference of the program memory handler
* @param appCount: array size of app parameter (only used when USBD_DFU_ALTSETTINGS != 0)
*/
void USBD_DFU_BootInit(USBD_DFU_IfHandleType *itf,
USBD_DFU_RebootCbkType pReboot,
const USBD_DFU_AppType *app, uint8_t appCount)
{
itf->Base.Class = &dfu_cbks;
#if (USBD_DFU_ALTSETTINGS != 0)
itf->Base.AltCount = appCount;
#else
itf->Base.AltCount = 1;
#endif
itf->Base.AltSelector = 0;
itf->App = app;
itf->Config.Reboot = pReboot;
/* If DFU state is entered due to detach request, enter IDLE state
* Otherwise assume application firmware is missing */
if (USBD_DFU_IsRequested(itf))
{
itf->DevStatus.State = DFU_STATE_IDLE;
itf->DevStatus.Status = DFU_ERROR_NONE;
}
else
{
itf->DevStatus.State = DFU_STATE_ERROR;
itf->DevStatus.Status = DFU_ERROR_FIRMWARE;
}
}
/**
* @brief Determines if DFU operation has been requested before the reset.
* @param itf: reference of the DFU interface
* @return TRUE if DFU mode is requested, FALSE otherwise
*/
int USBD_DFU_IsRequested(USBD_DFU_IfHandleType *itf)
{
return ((itf->Tag[0] == DFU_MODE_TAG) && (itf->Tag[1] == (~DFU_MODE_TAG)));
}
/** @} */
/** @defgroup USBD_DFU_Exported_Functions_App DFU Exported Functions for Application
* @{ */
/**
* @brief Sets the necessary fields of the DFU interface.
* @note This function shall be called in the main application code.
* @param itf: reference of the DFU interface
* @param detachTimeout_ms: The necessary amount of time to safely shut down
* the application before entering DFU mode
*/
void USBD_DFU_AppInit(USBD_DFU_IfHandleType *itf, uint16_t detachTimeout_ms)
{
itf->Config.DetachTimeout_ms = detachTimeout_ms;
/* Setting state in application */
itf->DevStatus.State = DFU_STATE_APP_IDLE;
itf->DevStatus.Status = DFU_ERROR_NONE;
}
/**
* @brief Mounts a reboot-only version of the DFU interface to the USB Device
* at the next interface slot. Used for devices which have DFU implementation
* in ROM.
* @note The interface reference shall have its Config structure
* properly set before this function is called.
* @param itf: reference of the DFU interface
* @param dev: reference of the USB Device
* @return OK if the mounting was successful,
* ERROR if it failed due to insufficient device interface slots
*/
USBD_ReturnType USBD_DFU_MountRebootOnly(USBD_DFU_IfHandleType *itf, USBD_HandleType *dev)
{
USBD_ReturnType retval = USBD_E_ERROR;
if (dev->IfCount < USBD_MAX_IF_COUNT)
{
/* Binding interfaces */
itf->Base.Device = dev;
itf->Base.Class = &rodfu_cbks;
itf->Base.AltCount = 1;
itf->Base.AltSelector = 0;
/* Setting state in application */
itf->DevStatus.State = DFU_STATE_APP_IDLE;
itf->DevStatus.Status = DFU_ERROR_NONE;
itf->DevStatus.__reserved = 0;
itf->DevStatus.iString = 0;
itf->DevStatus.PollTimeout = 0;
dev->IF[dev->IfCount] = (USBD_IfHandleType*)itf;
dev->IfCount++;
retval = USBD_E_OK;
}
return retval;
}
/** @} */
/** @defgroup USBD_DFU_Exported_Functions DFU Common Exported Functions
* @{ */
/**
* @brief Mounts the DFU interface to the USB Device at the next interface slot.
* @note The interface reference shall have its Config structure and App reference
* properly set before this function is called.
* @param itf: reference of the DFU interface
* @param dev: reference of the USB Device
* @return OK if the mounting was successful,
* ERROR if it failed due to insufficient device interface slots
*/
USBD_ReturnType USBD_DFU_MountInterface(USBD_DFU_IfHandleType *itf, USBD_HandleType *dev)
{
USBD_ReturnType retval = USBD_E_ERROR;
if (dev->IfCount < USBD_MAX_IF_COUNT)
{
/* Binding interfaces */
itf->Base.Device = dev;
dev->IF[dev->IfCount] = (USBD_IfHandleType*)itf;
dev->IfCount++;
retval = USBD_E_OK;
}
return retval;
}
/** @} */
|
932eadde5da5acff27355e1eb21226e89a94426b
|
3d44c763f0bd72117579cdd87bbf305ffd191e8b
|
/src/core/options.h
|
9c5d48171831793569026a706251baa050798c45
|
[
"MIT"
] |
permissive
|
nanomsg/nng
|
6e597e664a4126c3d8e8b16e9c22a33ac773c9c4
|
5ac5be5cacacdb8d6cac2fa362fce6d78e4dc389
|
refs/heads/master
| 2023-08-31T04:28:18.215853
| 2023-08-23T19:23:18
| 2023-08-28T05:58:40
| 76,157,774
| 3,407
| 489
|
MIT
| 2023-09-14T09:01:13
| 2016-12-11T06:14:28
|
C
|
UTF-8
|
C
| false
| false
| 3,872
|
h
|
options.h
|
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 Devolutions <info@devolutions.net>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
#ifndef CORE_OPTIONS_H
#define CORE_OPTIONS_H
// Integer limits.
#define NNI_MAXINT ((int) 2147483647)
#define NNI_MININT ((int) -2147483648)
// We limit the maximum size to 4GB. That's intentional because some of the
// underlying protocols cannot cope with anything bigger than 32-bits.
#define NNI_MINSZ (0)
#define NNI_MAXSZ ((size_t) 0xffffffff)
// Option helpers. These can be called from protocols or transports
// in their own option handling, centralizing the logic for dealing with
// variable sized options.
extern int nni_copyin_ms(nni_duration *, const void *, size_t, nni_type);
extern int nni_copyin_bool(bool *, const void *, size_t, nni_type);
extern int nni_copyin_int(int *, const void *, size_t, int, int, nni_type);
extern int nni_copyin_size(
size_t *, const void *, size_t, size_t, size_t, nni_type);
extern int nni_copyin_str(char *, const void *, size_t, size_t, nni_type);
extern int nni_copyin_ptr(void **, const void *, size_t, nni_type);
extern int nni_copyin_u64(uint64_t *, const void *, size_t, nni_type);
extern int nni_copyin_sockaddr(nng_sockaddr *, const void *, size_t, nni_type);
// nni_copyout_xxx copies out a type of the named value. It assumes that
// the type is aligned and the size correct, unless NNI_TYPE_OPAQUE is passed.
extern int nni_copyout(const void *, size_t, void *, size_t *);
extern int nni_copyout_bool(bool, void *, size_t *, nni_type);
extern int nni_copyout_int(int, void *, size_t *, nni_type);
extern int nni_copyout_ms(nng_duration, void *, size_t *, nni_type);
extern int nni_copyout_ptr(void *, void *, size_t *, nni_type);
extern int nni_copyout_size(size_t, void *, size_t *, nni_type);
extern int nni_copyout_sockaddr(
const nng_sockaddr *, void *, size_t *, nni_type);
extern int nni_copyout_u64(uint64_t, void *, size_t *, nni_type);
// nni_copyout_str copies out a string. If the type is NNI_TYPE_STRING,
// then it passes through a pointer, created by nni_strdup().
extern int nni_copyout_str(const char *, void *, size_t *, nni_type);
// nni_option is used for socket, protocol, transport, and similar options.
// Note that only for transports, the o_set member may be called with a NULL
// instance parameter, in which case the request should only validate the
// argument and do nothing further.
typedef struct nni_option_s nni_option;
struct nni_option_s {
// o_name is the name of the option.
const char *o_name;
// o_get is used to retrieve the value of the option. The
// size supplied will limit how much data is copied. Regardless,
// the actual size of the object that would have been copied
// is supplied by the function in the size. If the object did
// not fit, then NNG_EINVAL is returned.
int (*o_get)(void *, void *, size_t *, nni_type);
// o_set is used to set the value of the option. For transport
// endpoints only, the instance parameter (first argument) may be
// NULL, in which case only a generic validation of the parameters
// is performed. (This is used when setting socket options before
int (*o_set)(void *, const void *, size_t, nni_type);
};
// nni_getopt and nni_setopt are helper functions to implement options
// based on arrays of nni_option structures.
extern int nni_getopt(
const nni_option *, const char *, void *, void *, size_t *, nni_type);
extern int nni_setopt(
const nni_option *, const char *, void *, const void *, size_t, nni_type);
#endif // CORE_OPTIONS_H
|
3eeba16858b76f7bab9b35a481eb2437aa2490b9
|
3b955b6c1122d6caea1175b24bea7b22aa5b9069
|
/libs/libtim/utils/support.h
|
3ac620d6b5fcb4fe8291ccccbe3b39ee8a7d5510
|
[] |
no_license
|
yoyofr/modizer
|
52930c995424c6243859008d1b5e84b5fcda1aa4
|
68457a14344208bf1ca1660b3952aa59dff3aaea
|
refs/heads/master
| 2023-04-30T00:43:18.365195
| 2023-04-17T08:47:41
| 2023-04-17T08:47:41
| 3,095,707
| 110
| 43
| null | 2021-03-20T17:29:09
| 2012-01-03T17:06:30
|
C
|
UTF-8
|
C
| false
| false
| 2,799
|
h
|
support.h
|
/*
TiMidity++ -- MIDI to WAVE converter and player
Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ___SUPPORT_H_
#define ___SUPPORT_H_
#ifndef HAVE_VSNPRINTF
#include <stdarg.h> /* for va_list */
extern int vsnprintf(char *buff, size_t bufsiz, const char *fmt, va_list ap);
#endif
#ifndef HAVE_SNPRINTF
extern int snprintf(char *buff, size_t bufsiz, const char *fmt, ...);
#endif /* HAVE_SNPRINTF */
#ifndef HAVE_STRERROR
extern char *strerror(int errnum);
#endif /* HAVE_STRERROR */
/* There is no prototype of usleep() on Solaris. Why? */
#if !defined(HAVE_USLEEP) || defined(SOLARIS)
extern int usleep(unsigned int usec);
#endif
#ifdef __W32__
#define sleep(time) Sleep(time)
#else
#ifndef HAVE_SLEEP
#define sleep(s) usleep((s) * 1000000)
#endif /* HAVE_SLEEP */
#endif
#ifndef HAVE_STRDUP
extern char *strdup(const char *s);
#endif /* HAVE_STRDUP */
#ifndef HAVE_GETCWD
extern char *getcwd(char *buf, size_t size);
#endif /* HAVE_GETCWD */
#ifndef HAVE_STRSTR
//#define strstr(s,c) index(s,c)
#endif /* HAVE_STRSTR */
#ifndef HAVE_STRNCASECMP
//extern int strncasecmp(char *s1, char *s2, unsigned int len);
#endif /* HAVE_STRNCASECMP */
#ifndef HAVE_MKSTEMP
extern int mkstemp(char *template);
#endif /* HAVE_MKSTEMP */
#ifndef HAVE_SYS_STAT_H
#ifdef __W32__
#include <sys/stat.h> /* they have. */
#elif defined(__MACOS__)
#define S_IFDIR 1
#define S_ISDIR(m) ((m) & S_IFDIR)
struct stat {
short st_mode;
short st_dev;
long st_ino;
unsigned long st_size;
unsigned long st_mtime, st_ctime, st_btime;
};
int stat(const char *filename, struct stat *st);
#endif /* __W32__ */
#else
#include <sys/stat.h>
#endif /* HAVE_SYS_STAT_H*/
#endif /* ___SUPPORT_H_ */
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode)&0xF000) == 0x4000)
#endif /* S_ISDIR */
#ifndef HAVE_STRLCPY
#include <stddef.h>
extern size_t strlcpy(char *dst, const char *src, size_t size);
#endif
#ifndef HAVE_STRLCAT
#include <stddef.h>
extern size_t strlcat(char *dst, const char *src, size_t size);
#endif
|
caeb5d517c685bb4dfc57d2b082d7830c32cc338
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/framework/src/security/security_internal.h
|
2befe462dc107aeab4894b719889e08a72371e48
|
[
"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
| 9,263
|
h
|
security_internal.h
|
/****************************************************************************
*
* Copyright 2019 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. SEC the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************/
#pragma once
#include <stdio.h>
#include <string.h>
#include <tinyara/seclink.h>
#include <security/security_common.h>
#if (defined(CONFIG_ARCH_BOARD_ARTIK053S) || defined(CONFIG_ARCH_BOARD_ARTIK053)) && defined(CONFIG_S5J_HAVE_SSS)
#include "../../../os/arch/arm/src/s5j/sss/isp_custom.h"
#define FACTORYKEY_CERT (0x00010122)
#endif
#ifdef LINUX
#define SECAPI_LOG printf
#else
#define SECAPI_LOG sfdbg
#endif
#define SECAPI_TAG "[SECAPI]"
#define SECAPI_ERR \
do { \
SECAPI_LOG(SECAPI_TAG "ERR\t%s:%d\n", __FILE__, __LINE__); \
} while (0)
#define SECAPI_DUMMY
#define SECAPI_CALL3(func, res, rsc_clean) \
do { \
int secapi_res = func; \
if (secapi_res != SECLINK_OK) { \
SECAPI_ERR; \
rsc_clean; \
return secutils_convert_error_h2s(secapi_res); \
} \
} while (0)
#define SECAPI_CALL2(func, res) \
do { \
SECAPI_CALL3(func, res, SECAPI_DUMMY); \
} while (0)
#define SECAPI_CALL(func) \
do { \
SECAPI_CALL2(func, SECURITY_ERROR); \
} while (0)
#define SECAPI_ENTER \
do { \
SECAPI_LOG(SECAPI_TAG "---> %s:%d\n", __FILE__, __LINE__); \
} while (0)
#define SECAPI_RETURN(res) \
do { \
SECAPI_LOG(SECAPI_TAG "<--- %s:%d\n", __FILE__, __LINE__); \
return res; \
} while (0)
/* convert a value from seclink then return it
*/
#define SECAPI_HAL_RETURN(res) \
do { \
SECAPI_RETURN(secutils_convert_error_h2s(res)); \
} while (0)
#define SECAPI_DATA_SCOPY(hal, sec) \
do { \
sec->data = hal.data; \
sec->length = hal.data_len; \
} while (0)
#define SECAPI_DATA_DCOPY(hal, sec) \
do { \
memcpy(sec->data, hal.data, hal.data_len); \
sec->length = hal.data_len; \
} while (0)
#define SECAPI_DATA_ALLOC_HAL(hal, sec) \
do { \
sec->data = (char *)malloc(hal->data_len); \
if (!sec->data) { \
return -2; \
} \
} while (0)
#define SECAPI_PRIV_DCOPY(hal, sec) \
do { \
memcpy(sec->data, hal.priv, hal.priv_len); \
sec->length = hal.priv_len; \
} while (0)
#define SECAPI_FREE(hal) \
do { \
free(hal->data); \
hal->data = NULL; \
hal->length = 0; \
} while (0)
#define SECAPI_ISHANDLE_VALID(ctx) \
do { \
if (!ctx) { \
SECAPI_ERR; \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
#define SECAPI_CONVERT_PATH(path, idx) \
do { \
int32_t c_res = secutils_convert_path_s2h(path, idx); \
if (c_res < 0) { \
SECAPI_RETURN(SECURITY_INVALID_KEY_INDEX); \
} \
} while (0)
#define SECAPI_CONVERT_AESPARAM(sec, hal) \
do { \
int c_res = secutils_convert_aesparam_s2h(sec, hal); \
if (c_res < 0) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
#define SECAPI_CONVERT_KEYTYPE(sec, hal) \
do { \
hal = secutils_convert_key_s2h(sec); \
if (hal == HAL_KEY_UNKNOWN) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
#define SECAPI_CONVERT_RSAPARAM(sec, hal) \
do { \
int c_res = secutils_convert_rsaparam_s2h(sec, hal); \
if (c_res < 0) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
#define SECAPI_CONVERT_ECDSAPARAM(sec, hal) \
do { \
int c_res = secutils_convert_ecdsaparam_s2h(sec, hal); \
if (c_res < 0) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
#define SECAPI_CONVERT_ECDHPARAM(sec, hal) \
do { \
int c_res = secutils_convert_ecdhparam_s2h(sec, hal); \
if (c_res < 0) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
#define SECAPI_CONVERT_DHPARAM_H2S(hal, sec) \
do { \
int c_res = secutils_convert_dhparam_h2s(hal, sec); \
if (c_res == -1) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} else if (c_res == -2) \
SECAPI_RETURN(SECURITY_ALLOC_ERROR); \
} while (0)
#define SECAPI_CONVERT_DHPARAM(sec, hal) \
do { \
int c_res = secutils_convert_dhparam_s2h(sec, hal); \
if (c_res < 0) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
#define SECAPI_CONVERT_HASHMODE(mode, type) \
do { \
type = secutils_convert_hashmode_s2h(mode); \
if (type == HAL_HASH_UNKNOWN) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
#define SECAPI_CONVERT_HMACMODE(mode, type) \
do { \
type = secutils_convert_hmacmode_s2h(mode); \
if (type == HAL_HMAC_UNKNOWN) { \
SECAPI_RETURN(SECURITY_INVALID_INPUT_PARAMS); \
} \
} while (0)
struct security_ctx {
sl_ctx sl_hnd;
void *data1; // used to get data from HAL
unsigned int dlen1;
void *data2;
unsigned int dlen2;
void *data3;
unsigned int dlen3;
};
hal_key_type secutils_convert_key_s2h(security_key_type sec);
hal_hash_type secutils_convert_hashmode_s2h(security_hash_mode mode);
hal_hmac_type secutils_convert_hmacmode_s2h(security_hmac_mode mode);
hal_aes_algo secutils_convert_aesmode_s2h(security_aes_mode mode);
hal_rsa_algo secutils_convert_rsamode_s2h(security_rsa_mode mode);
hal_ecdsa_curve secutils_convert_ecdsamode_s2h(security_ecdsa_mode mode);
hal_dh_key_type secutils_convert_dhmode_s2h(security_dh_mode mode);
hal_key_type secutils_convert_ecdsamode_to_key_s2h(security_ecdsa_mode mode);
security_error secutils_convert_error_h2s(int herr);
int secutils_convert_path_s2h(const char *path, uint32_t *slot);
int secutils_convert_aesparam_s2h(security_aes_param *sparam, hal_aes_param *hparam);
int secutils_convert_rsaparam_s2h(security_rsa_param *sparam, hal_rsa_mode *hparam);
int secutils_convert_ecdsaparam_s2h(security_ecdsa_param *eparam, hal_ecdsa_mode *hmode);
int secutils_convert_dhparam_s2h(security_dh_param *dparam, hal_dh_data *hdata);
int secutils_convert_ecdhparam_s2h(security_ecdh_param *eparam, hal_ecdh_data *hdata);
int secutils_convert_dhparam_h2s(hal_dh_data *hdata, security_dh_param *dparam);
|
7b9c3bc934f602caaacd07e2c48f4131d97ee53d
|
4496090591e7328310cedee096fc1cf2834e73a3
|
/gln/mods/torchext/src/extlib_cuda.h
|
292fd9f0480527eb220056aeb85427af2dcb68bd
|
[
"MIT"
] |
permissive
|
Hanjun-Dai/GLN
|
d8db9d8d7085428f997b902f60dae11e9922eed8
|
b5bd7b181a61a8289cc1d1a33825b2c417bed0ef
|
refs/heads/master
| 2022-12-24T05:31:11.005237
| 2022-12-10T06:54:20
| 2022-12-10T06:54:20
| 217,782,224
| 106
| 30
| null | null | null | null |
UTF-8
|
C
| false
| false
| 302
|
h
|
extlib_cuda.h
|
#ifndef EXTLIB_CUDA_H
#define EXTLIB_CUDA_H
#include <torch/extension.h>
torch::Tensor jagged_log_softmax_forward_cuda(torch::Tensor logits, torch::Tensor prefix_sum);
torch::Tensor jagged_log_softmax_backward_cuda(torch::Tensor output, torch::Tensor grad_output, torch::Tensor prefix_sum);
#endif
|
8fc70ba54434f099f9416f34e5cc985bc96c230a
|
19a9f2c19bcb81c4a14ba17831d3098de7731fb5
|
/ni/src/ncl/ncep_130_gtb.h
|
e1cbb509167f8e6070c37afa0474d62e995ffa18
|
[
"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
| 11,317
|
h
|
ncep_130_gtb.h
|
/*
*
* US National Weather Service - NCEP (WMC)
* For Land Modeling and Land Data Assimilation
*
* Center: 7
* Subcenter: 0
* Parameter table version: 130
*/
TBLE2 ncep_130_params[] = {
{1, "Pressure", "Pa", "PRES"},
{2, "Pressure reduced to MSL", "Pa", "PRMSL"},
{3, "Pressure tendency", "Pa/s", "PTEND"},
{4, "Potential vorticity", "km^2/kg/s", "PVORT"},
{5, "ICAO Standard Atmosphere Reference Height", "M", "ICAHT"},
{6, "Geopotential", "m^2/s^2", "GP"},
{7, "Geopotential height", "gpm", "HGT"},
{8, "Geometric height", "m", "DIST"},
{9, "Std dev of height", "m", "HSTDV"},
{10, "Total ozone", "Dobson", "TOZONE"},
{11, "Temperature", "K", "TMP"},
{12, "Virtual temperature", "K", "VTMP"},
{13, "Potential temperature", "K", "POT"},
{14, "Pseudo-adiabatic potential temperature", "K", "EPOT"},
{15, "Maximum temperature", "K", "T_MAX"},
{16, "Minimum temperature", "K", "T_MIN"},
{17, "Dew point temperature", "K", "DPT"},
{18, "Dew point depression", "K", "DEPR"},
{19, "Lapse rate", "K/m", "LAPR"},
{20, "Visibility", "m", "VIS"},
{21, "Radar spectra (1)", "non-dim", "RDSP1"},
{22, "Radar spectra (2)", "non-dim", "RDSP2"},
{23, "Radar spectra (3)", "non-dim", "RDSP3"},
{24, "Parcel lifted index (to 500 hPa)", "K", "PLI"},
{25, "Temperature anomaly", "K", "TMP_A"},
{26, "Pressure anomaly", "Pa", "PRESA"},
{27, "Geopotential height anomaly", "gpm", "GPA"},
{28, "Wave spectra (1)", "non-dim", "WVSP1"},
{29, "Wave spectra (2)", "non-dim", "WVSP2"},
{30, "Wave spectra (3)", "non-dim", "WVSP3"},
{31, "Wind direction", "deg", "WDIR"},
{32, "Wind speed", "m/s", "WIND"},
{33, "u-component of wind", "m/s", "U_GRD"},
{34, "v-component of wind", "m/s", "V_GRD"},
{35, "Stream function", "m^2/s", "STRM"},
{36, "Velocity potential", "m^2/s", "V_POT"},
{37, "Montgomery stream function", "m^2/s^2", "MNTSF"},
{38, "Sigma coord. vertical velocity", "/s", "SGCVV"},
{39, "Pressure vertical velocity", "Pa/s", "V_VEL"},
{40, "Geometric vertical velocity", "m/s", "DZDT"},
{41, "Absolute vorticity", "/s", "ABS_V"},
{42, "Absolute divergence", "/s", "ABS_D"},
{43, "Relative vorticity", "/s", "REL_V"},
{44, "Relative divergence", "/s", "REL_D"},
{45, "Vertical u-component shear", "/s", "VUCSH"},
{46, "Vertical v-component shear", "/s", "VVCSH"},
{47, "Direction of current", "deg", "DIR_C"},
{48, "Speed of current", "m/s", "SP_C"},
{49, "u-component of current", "m/s", "UOGRD"},
{50, "v-component of current", "m/s", "VOGRD"},
{51, "Specific humidity", "kg/kg", "SPF_H"},
{52, "Relative humidity", "%", "R_H"},
{53, "Humidity mixing ratio", "kg/kg", "MIXR"},
{54, "Precipitable water", "kg/m^2", "P_WAT"},
{55, "Vapor pressure", "Pa", "VAPP"},
{56, "Saturation deficit", "Pa", "SAT_D"},
{57, "Evaporation", "kg/m^2", "EVP"},
{58, "Cloud Ice", "kg/m^2", "C_ICE"},
{59, "Precipitation rate", "kg/m^2/s", "PRATE"},
{60, "Thunderstorm probability", "%", "TSTM"},
{61, "Total precipitation", "kg/m^2", "A_PCP"},
{62, "Large scale precipitation", "kg/m^2", "NCPCP"},
{63, "Convective precipitation", "kg/m^2", "ACPCP"},
{64, "Snowfall rate water equivalent.", "kg/m^2/s", "SRWEQ"},
{65, "Water equivalent of accum. snow depth", "kg/m^2", "WEASD"},
{66, "Snow depth", "m", "SNO_D"},
{67, "Mixed layer depth", "m", "MIXHT"},
{68, "Transient thermocline depth", "m", "TTHDP"},
{69, "Main thermocline depth", "m", "MTHD"},
{70, "Main thermocline anomaly", "m", "MTH_A"},
{71, "Total cloud cover", "%", "T_CDC"},
{72, "Convective cloud cover", "%", "CDCON"},
{73, "Low level cloud cover", "%", "L_CDC"},
{74, "Mid level cloud cover", "%", "M_CDC"},
{75, "High level cloud cover", "%", "H_CDC"},
{76, "Cloud water", "kg/m^2", "C_WAT"},
{77, "Best lifted index (to 500 hPa)", "K", "BLI"},
{78, "Convective snow", "kg/m^2", "SNO_C"},
{79, "Large scale snow", "kg/m^2", "SNO_L"},
{80, "Water temperature", "K", "WTMP"},
{81, "Land-sea mask (land=1;sea=0)", "fraction", "LAND"},
{82, "Deviation of sea level from mean", "m", "DSL_M"},
{83, "Surface roughness", "m", "SFC_R"},
{84, "Albedo", "%", "ALBDO"},
{85, "Soil temperature", "K", "TSOIL"},
{86, "Soil moisture content", "kg/m^2", "SOIL_M"},
{87, "Vegetation", "%", "VEG"},
{88, "Salinity", "kg/kg", "SALTY"},
{89, "Density", "kg/m^3", "DEN"},
{90, "Water runoff", "kg/m^2", "WATR"},
{91, "Ice concentration (ice=1;no ice=0)", "fraction", "ICE_C"},
{92, "Ice thickness", "m", "ICETK"},
{93, "Direction of ice drift", "deg", "DICED"},
{94, "Speed of ice drift", "m/s", "SICED"},
{95, "u-component of ice drift", "m/s", "U_ICE"},
{96, "v-component of ice drift", "m/s", "V_ICE"},
{97, "Ice growth rate", "m/s", "ICE_G"},
{98, "Ice divergence", "/s", "ICE_D"},
{99, "Snow melt", "kg/m^2", "SNO_M"},
{100, "Sig height of wind waves and swell", "m", "HTSGW"},
{101, "Direction of wind waves", "deg", "WVDIR"},
{102, "Significant height of wind waves", "m", "WVHGT"},
{103, "Mean period of wind waves", "s", "WVPER"},
{104, "Direction of swell waves", "deg", "SWDIR"},
{105, "Significant height of swell waves", "m", "SWELL"},
{106, "Mean period of swell waves", "s", "SWPER"},
{107, "Primary wave direction", "deg", "DIRPW"},
{108, "Primary wave mean period", "s", "PERPW"},
{109, "Secondary wave direction", "deg", "DIRSW"},
{110, "Secondary wave mean period", "s", "PERSW"},
{111, "Net short wave radiation (surface)", "W/m^2", "NSWRS"},
{112, "Net long wave radiation(surface)", "W/m^2", "NLWRS"},
{113, "Net short wave radiation (top)", "W/m^2", "NSWRT"},
{114, "Net long wave radiation (top)", "W/m^2", "NLWRT"},
{115, "Long wave radiation", "W/m^2", "LWAVR"},
{116, "Short wave radiation", "W/m^2", "SWAVR"},
{117, "Global radiation", "W/m^2", "G_RAD"},
{118, "Brightness temperature", "K", "BRTMP"},
{119, "Radiance with respect to wave no.", "W/m/sr", "LWRAD"},
{120, "Radiance with respect ot wave len.", "W/m^3/sr", "SWRAD"},
{121, "Latent heat flux", "W/m^2", "LHTFL"},
{122, "Sensible heat flux", "W/m^2", "SHTFL"},
{123, "Boundary layer dissipation", "W/m^2", "BLYDP"},
{124, "Momentum flux, u component", "N/m^2", "U_FLX"},
{125, "Momentum flux, v component", "N/m^2", "V_FLX"},
{126, "Wind mixing energy", "J", "WMIXE"},
{127, "Image data", "none", "IMG_D"},
{144, "Volumetric soil moisture (frozen + liquid)", "fraction", "SOILW"},
{145, "Potential latent heat flux (potential evaporation)", "W/m^2", "PEVPR"},
{146, "Vegetation canopy temperature", "K", "VEGT"},
{147, "Bare soil surface skin temperature", "K", "BARET"},
{148, "Average surface skin temperature", "K", "AVSFT"},
{149, "Effective radiative skin temperature", "K", "RADT"},
{150, "Surface water storage", "kg/m^2", "SSTOR"},
{151, "Liquid soil moisture content (non-frozen)", "kg/m^2", "LSOIL"},
{152, "Open water evaporation (standing water)", "W/m^2", "EWATR"},
{153, "Number concentration for rain particles", "non-dim", "NCRAIN"},
{154, "Land Surface Precipitation Accumulation", "kg/m^2", "LSPA"},
{155, "Ground Heat Flux", "W/m^2", "GFLUX"},
{156, "Convective inhibition", "J/kg", "CIN"},
{157, "Convective available potential energy", "J/kg", "CAPE"},
{158, "Turbulent Kinetic Energy", "J/kg", "TKE"},
{159, "Maximum snow albedo", "%", "MXSALB"},
{160, "Liquid volumetric soil moisture (non-frozen)", "fraction", "SOILL"},
{161, "Frozen precipitation (e.g. snowfall)", "kg/m^2", "ASNOW"},
{162, "Liquid precipitation (rainfall)", "kg/m^2", "ARAIN"},
{163, "Groundwater recharge", "kg/m^2", "GWREC"},
{164, "Flood plain recharge", "kg/m^2", "QREC"},
{165, "Snow temperature, depth-avg", "K", "SNOWT"},
{166, "Visible beam downward solar flux", "W/m^2", "VBDSF"},
{167, "Visible diffuse downward solar flux", "W/m^2", "VDDSF"},
{168, "Near IR beam downward solar flux", "W/m^2", "NBDSF"},
{169, "Near IR diffuse downward solar flux", "W/m^2", "NDDSF"},
{170, "Snow-free albedo", "%", "SNFALB"},
{171, "Number of soil layers in root zone", "non-dim", "RLYRS"},
{172, "Momentum flux", "N/m^2", "MFLX"},
{176, "Latitude (-90 to +90)", "deg", "NLAT"},
{177, "East longitude (0-360)", "deg", "ELON"},
{178, "Field Capacity (soil moisture)", "fraction", "FLDCAP"},
{179, "Aerodynamic conductance", "m/s", "ACOND"},
{180, "Snow age", "s", "SNOAG"},
{181, "Canopy conductance", "m/s", "CCOND"},
{182, "Leaf area index (0-9)", "non-dim", "LAI"},
{183, "Roughness length for heat", "m", "SFCRH"},
{184, "Snow albedo (over snow cover area only)", "%", "SALBD"},
{187, "Normalized Difference Vegetation Index", "non-dim", "NDVI"},
{188, "Canopy drip", "kg/m^2", "DRIP"},
{189, "Visible, Black Sky Albedo", "%", "VBSALB"},
{190, "Visible, White Sky Albedo", "%", "VWSALB"},
{191, "Near IR, Black Sky Albedo", "%", "NBSALB"},
{192, "Near IR, White Sky Albedo", "%", "NWSALB"},
{193, "Freezing Rain", "kg/m^2", "FRZR"},
{194, "Frozen Rain", "kg/m^2", "FROZR"},
{195, "Total Snow", "kg/m^2", "TSNOW"},
{196, "Model Terrain Height", "m", "MTERH"},
{198, "Sublimation (evaporation from snow)", "W/m^2", "SBSNO"},
{199, "Direct evaporation from bare soil", "W/m^2", "EVBS"},
{200, "Canopy water evaporation", "W/m^2", "EVCW"},
{201, "Virtual Temperature Based Convective Inhibition", "J/kg", "VTCIN"},
{202, "Virtual Temperature Based Convective Available Potential Energy", "J/kg", "VTCAPE"},
{203, "Minimal stomatal resistance", "s/m", "RSMIN"},
{204, "Downward shortwave radiation flux", "W/m^2", "DSWRF"},
{205, "Downward longwave radiation flux", "W/m^2", "DLWRF"},
{206, "Vertically Integrated Liquid", "kg m^-2", "VIL"},
{207, "Moisture availability", "%", "MSTAV"},
{208, "Exchange coefficient", "(kg/m^3)(m/s)", "SFEXC"},
{210, "Transpiration", "W/m^2", "TRANS"},
{211, "Upward short wave radiation flux", "W/m^2", "USWRF"},
{212, "Upward long wave radiation flux", "W/m^2", "ULWRF"},
{219, "Wilting point", "fraction", "WILT"},
{220, "Field Capacity", "fraction", "FLDCP"},
{221, "Planetary boundary layer height", "m", "HPBL"},
{222, "Surface slope type", "Index", "SLTYP"},
{223, "Plant canopy surface water", "kg/m^2", "CNWAT"},
{224, "Soil type", "Index (0-9)", "SOTYP"},
{225, "Vegetation type", "Index (0-13)", "VGTYP"},
{226, "Blackadar's mixing length scale", "m", "BMIXL"},
{227, "Asymptotic mixing length scale", "m", "AMIXL"},
{228, "Potential evaporation", "kg/m^2", "PEVAP"},
{229, "Snow phase-change heat flux", "W/m^2", "SNOHF"},
{230, "Transpiration stress-onset (soil moisture)", "fraction", "SMREF"},
{231, "Direct evaporation cease (soil moisture)", "fraction", "SMDRY"},
{234, "Subsurface runoff (baseflow)", "kg/m^2", "BGRUN"},
{235, "Surface runoff (non-infiltrating)", "kg/m^2", "SSRUN"},
{238, "Snow cover", "%", "SNOWC"},
{239, "Snow temperature", "K", "SNOT"},
{240, "Soil porosity", "fraction", "POROS"},
{241, "Simulated brightness temperature for GOES11, channel 2", "K", "SBT112"},
{242, "Simulated brightness temperature for GOES11, channel 3", "K", "SBT113"},
{243, "Simulated brightness temperature for GOES11, channel 4", "K", "SBT114"},
{244, "Simulated brightness temperature for GOES11, channel 5", "K", "SBT115"},
{246, "Solar parameter in canopy conductance", "fraction", "RCS"},
{247, "Temperature parameter in canopy conductance", "fraction", "RCT"},
{248, "Humidity parameter in canopy conductance", "fraction", "RCQ"},
{249, "Soil moisture parameter in canopy conductance", "fraction", "RCSOL"},
{252, "Surface drag coefficient", "non-dim", "CD"},
{253, "Surface friction velocity", "m/s", "FRICV"},
{254, "Richardson number", "non-dim", "RI"}
};
|
4d10e4b510097c76dea38ad5bb73ef3d96c5d755
|
e48198ffea7b0b80669253fb970fdcc1d2f4c518
|
/src/memfile_test.c
|
a35261946942be8717f014b3c2294d6b3718006e
|
[
"GPL-1.0-or-later",
"Vim",
"GPL-2.0-only"
] |
permissive
|
vim/vim
|
f9ea5913ff884c87bc11f7826b1fc277fba8a2b5
|
816fbcc262687b81fc46f82f7bbeb1453addfe0c
|
refs/heads/master
| 2023-09-01T16:01:56.964678
| 2023-08-31T21:52:30
| 2023-08-31T21:52:30
| 40,997,482
| 37,589
| 7,920
|
Vim
| 2023-09-14T20:57:43
| 2015-08-18T21:03:56
|
Vim Script
|
UTF-8
|
C
| false
| false
| 3,079
|
c
|
memfile_test.c
|
/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
* memfile_test.c: Unittests for memfile.c
* Mostly by Ivan Krasilnikov.
*/
#undef NDEBUG
#include <assert.h>
// Must include main.c because it contains much more than just main()
#define NO_VIM_MAIN
#include "main.c"
// This file has to be included because the tested functions are static
#include "memfile.c"
#define index_to_key(i) ((i) ^ 15167)
#define TEST_COUNT 50000
/*
* Test mf_hash_*() functions.
*/
static void
test_mf_hash(void)
{
mf_hashtab_T ht;
mf_hashitem_T *item;
blocknr_T key;
long_u i;
long_u num_buckets;
mf_hash_init(&ht);
// insert some items and check invariants
for (i = 0; i < TEST_COUNT; i++)
{
assert(ht.mht_count == i);
// check that number of buckets is a power of 2
num_buckets = ht.mht_mask + 1;
assert(num_buckets > 0 && (num_buckets & (num_buckets - 1)) == 0);
// check load factor
assert(ht.mht_count <= (num_buckets << MHT_LOG_LOAD_FACTOR));
if (i < (MHT_INIT_SIZE << MHT_LOG_LOAD_FACTOR))
{
// first expansion shouldn't have occurred yet
assert(num_buckets == MHT_INIT_SIZE);
assert(ht.mht_buckets == ht.mht_small_buckets);
}
else
{
assert(num_buckets > MHT_INIT_SIZE);
assert(ht.mht_buckets != ht.mht_small_buckets);
}
key = index_to_key(i);
assert(mf_hash_find(&ht, key) == NULL);
// allocate and add new item
item = LALLOC_CLEAR_ONE(mf_hashitem_T);
assert(item != NULL);
item->mhi_key = key;
mf_hash_add_item(&ht, item);
assert(mf_hash_find(&ht, key) == item);
if (ht.mht_mask + 1 != num_buckets)
{
// hash table was expanded
assert(ht.mht_mask + 1 == num_buckets * MHT_GROWTH_FACTOR);
assert(i + 1 == (num_buckets << MHT_LOG_LOAD_FACTOR));
}
}
// check presence of inserted items
for (i = 0; i < TEST_COUNT; i++)
{
key = index_to_key(i);
item = mf_hash_find(&ht, key);
assert(item != NULL);
assert(item->mhi_key == key);
}
// delete some items
for (i = 0; i < TEST_COUNT; i++)
{
if (i % 100 < 70)
{
key = index_to_key(i);
item = mf_hash_find(&ht, key);
assert(item != NULL);
assert(item->mhi_key == key);
mf_hash_rem_item(&ht, item);
assert(mf_hash_find(&ht, key) == NULL);
mf_hash_add_item(&ht, item);
assert(mf_hash_find(&ht, key) == item);
mf_hash_rem_item(&ht, item);
assert(mf_hash_find(&ht, key) == NULL);
vim_free(item);
}
}
// check again
for (i = 0; i < TEST_COUNT; i++)
{
key = index_to_key(i);
item = mf_hash_find(&ht, key);
if (i % 100 < 70)
{
assert(item == NULL);
}
else
{
assert(item != NULL);
assert(item->mhi_key == key);
}
}
// free hash table and all remaining items
mf_hash_free_all(&ht);
}
int
main(void)
{
test_mf_hash();
return 0;
}
|
09702b40fdee37072801990fafbea78976e5f931
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/games/ace-of-penguins/files/patch-lib_table.c
|
241aefc72d186d249bff495cb4cc2d4e457a68ec
|
[
"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
| 309
|
c
|
patch-lib_table.c
|
--- lib/table.c.orig 2020-08-27 17:10:12 UTC
+++ lib/table.c
@@ -57,7 +57,7 @@ static int ex=0, ey=0, ew=0, eh=0;
static int graphics_disabled = 1;
OptionDesc *app_options;
-OptionDesc *xwin_options;
+extern OptionDesc *xwin_options;
static OptionDesc *options[5];
static OptionDesc ace_options[] = {
|
5ca04547d14beb3d1f8276d47dd890f789b6fb92
|
75732426f13d523ab1c7be7bee23c2152eb9a77c
|
/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_export_registration.h
|
2ee709702e4cb6010079256423c84d8e52173396
|
[
"Apache-2.0",
"BSD-3-Clause",
"MIT"
] |
permissive
|
apache/celix
|
841da4d364432bff49c796f908d64090cec1d759
|
28118976b802f421f4789ece0c15e791f542712f
|
refs/heads/master
| 2023-09-04T22:17:43.815664
| 2023-09-04T01:22:00
| 2023-09-04T01:22:00
| 22,781,134
| 158
| 114
|
Apache-2.0
| 2023-09-12T01:22:30
| 2014-08-09T07:00:07
|
C
|
UTF-8
|
C
| false
| false
| 2,309
|
h
|
rsa_shm_export_registration.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 _RSA_SHM_EXPORT_REGISTRATION_H_
#define _RSA_SHM_EXPORT_REGISTRATION_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "export_registration.h"
#include "endpoint_description.h"
#include "celix_cleanup.h"
#include "celix_log_helper.h"
#include "celix_types.h"
#include "celix_properties.h"
#include "celix_errno.h"
#include <sys/uio.h>
celix_status_t exportRegistration_create(celix_bundle_context_t *context,
celix_log_helper_t *logHelper, service_reference_pt reference,
endpoint_description_t *endpointDesc, export_registration_t **exportOut);
void exportRegistration_addRef(export_registration_t *registration);
void exportRegistration_release(export_registration_t *registration);
CELIX_DEFINE_AUTOPTR_CLEANUP_FUNC(export_registration_t, exportRegistration_release)
celix_status_t exportRegistration_getExportReference(export_registration_t *registration,
export_reference_t **out);
celix_status_t exportRegistration_getException(export_registration_t *registration);
celix_status_t exportReference_getExportedEndpoint(export_reference_t *reference,
endpoint_description_t **endpoint);
celix_status_t exportReference_getExportedService(export_reference_t *reference,
service_reference_pt *ref);
celix_status_t exportRegistration_call(export_registration_t *exportReg, celix_properties_t *metadata,
const struct iovec *request, struct iovec *response);
#ifdef __cplusplus
}
#endif
#endif /* _RSA_SHM_EXPORT_REGISTRATION_H_ */
|
9a07479e264d33a51a659a015becec4bcdea48de
|
883bba35d3074b1836efe5f96e2682e2ae2d8cae
|
/UniversalWindowsPlatformSamples/CSharpProjectExample/bin/Il2CppOutputProject/IL2CPP/libil2cpp/os/c-api/Time-c-api.h
|
a21666e45168e6c081d968cb6a315d16e5c21348
|
[
"MIT"
] |
permissive
|
Unity-Technologies/DesktopSamples
|
3dabe5cbafae64479d87c3ed993630f6a755e3a2
|
835e350c2517ddd65302159053447f35ad50666e
|
refs/heads/master
| 2023-07-18T19:45:01.327055
| 2022-03-04T00:42:41
| 2022-03-04T00:42:41
| 218,365,346
| 200
| 84
|
MIT
| 2020-02-12T01:05:53
| 2019-10-29T19:17:52
|
C++
|
UTF-8
|
C
| false
| false
| 364
|
h
|
Time-c-api.h
|
#pragma once
#include "il2cpp-config-platforms.h"
#include <stdint.h>
#if defined(__cplusplus)
extern "C"
{
#endif
uint32_t UnityPalGetTicksMillisecondsMonotonic();
int64_t STDCALL UnityPalGetTicks100NanosecondsMonotonic();
int64_t UnityPalGetTicks100NanosecondsDateTime();
int64_t STDCALL UnityPalGetSystemTimeAsFileTime();
#if defined(__cplusplus)
}
#endif
|
e8abb711e7be4fdc324aaeff21eaf0916d7c5151
|
baa9fffc817a2a993d4ecc774d3f277783308c20
|
/src/ucs/config/ucm_opts.c
|
d7fea6452909fc516cecbd73ff1b57a63e465d00
|
[
"BSD-3-Clause"
] |
permissive
|
openucx/ucx
|
9a0f2205295afbdf3cff14b5d24af781b123f5ea
|
73a48700badb7cbace64d94b82f408e2a26fca32
|
refs/heads/master
| 2023-09-01T16:51:26.913950
| 2023-09-01T13:02:25
| 2023-09-01T13:02:25
| 25,379,390
| 966
| 420
|
NOASSERTION
| 2023-09-14T12:29:35
| 2014-10-17T22:17:24
|
C
|
UTF-8
|
C
| false
| false
| 4,888
|
c
|
ucm_opts.c
|
/**
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2001-2018. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "parser.h"
#include <ucm/api/ucm.h>
#include <ucm/util/log.h>
#include <ucm/util/sys.h>
#include <ucm/mmap/mmap.h>
#include <ucs/sys/compiler.h>
#define UCM_CONFIG_PREFIX "MEM_"
static const char *ucm_module_unload_prevent_modes[] = {
[UCM_UNLOAD_PREVENT_MODE_LAZY] = "lazy",
[UCM_UNLOAD_PREVENT_MODE_NOW] = "now",
[UCM_UNLOAD_PREVENT_MODE_NONE] = "none",
[UCM_UNLOAD_PREVENT_MODE_LAST] = NULL
};
static ucs_config_field_t ucm_global_config_table[] = {
{"LOG_LEVEL", "warn",
"Logging level for memory events", ucs_offsetof(ucm_global_config_t, log_level),
UCS_CONFIG_TYPE_ENUM(ucm_log_level_names)},
{"ALLOC_ALIGN", "16",
"Minimal alignment of allocated blocks",
ucs_offsetof(ucm_global_config_t, alloc_alignment), UCS_CONFIG_TYPE_MEMUNITS},
{"EVENTS", "yes",
"Enable memory events",
ucs_offsetof(ucm_global_config_t, enable_events), UCS_CONFIG_TYPE_BOOL},
{"MMAP_HOOK_MODE", UCM_DEFAULT_HOOK_MODE_STR,
"MMAP hook mode\n"
" none - Don't set mmap hooks.\n"
" reloc - Use ELF relocation table to set hooks.\n"
#if UCM_BISTRO_HOOKS
" bistro - Use binary instrumentation to set hooks.\n"
#endif
,ucs_offsetof(ucm_global_config_t, mmap_hook_mode),
UCS_CONFIG_TYPE_ENUM(ucm_mmap_hook_modes)},
{"MALLOC_HOOKS", "yes",
"Enable using glibc malloc hooks",
ucs_offsetof(ucm_global_config_t, enable_malloc_hooks),
UCS_CONFIG_TYPE_BOOL},
{"MALLOC_RELOC", "yes",
"Enable installing malloc symbols in the relocation table.\n"
"This is unsafe and off by default, because sometimes glibc\n"
"calls malloc/free without going through the relocation table,\n"
"which would use the original implementation and not ours.",
ucs_offsetof(ucm_global_config_t, enable_malloc_reloc), UCS_CONFIG_TYPE_BOOL},
{"CUDA_HOOK_MODE",
#if UCM_BISTRO_HOOKS
UCM_MMAP_HOOK_BISTRO_STR,
#else
UCM_MMAP_HOOK_RELOC_STR,
#endif
"Cuda memory hook modes. A combination of:\n"
" none - Don't set Cuda hooks.\n"
" reloc - Use ELF relocation table to set hooks. In this mode, if any\n"
" part of the application is linked with Cuda runtime statically,\n"
" some memory events may be missed and not reported."
#if UCM_BISTRO_HOOKS
" bistro - Use binary instrumentation to set hooks. In this mode, it's\n"
" possible to intercept calls from the Cuda runtime library to\n"
" Cuda driver APIs, so memory events are reported properly even\n"
" for statically-linked applications."
#endif
,ucs_offsetof(ucm_global_config_t, cuda_hook_modes),
UCS_CONFIG_TYPE_BITMAP(ucm_mmap_hook_modes)},
{"CUDA_RELOC", "yes",
"The configuration parameter replaced by UCX_MEM_CUDA_HOOK_MODE",
UCS_CONFIG_DEPRECATED_FIELD_OFFSET, UCS_CONFIG_TYPE_DEPRECATED},
{"DYNAMIC_MMAP_THRESH", "yes",
"Enable dynamic mmap threshold: for every released block, the\n"
"mmap threshold is adjusted upward to the size of the size of\n"
"the block, and trim threshold is adjust to twice the size of\n"
"the dynamic mmap threshold.\n"
"Note: dynamic mmap threshold is disabled when running on valgrind.",
ucs_offsetof(ucm_global_config_t, enable_dynamic_mmap_thresh),
UCS_CONFIG_TYPE_BOOL},
{"DLOPEN_PROCESS_RPATH", "yes",
"Process RPATH section of caller module during dynamic libraries opening.",
ucs_offsetof(ucm_global_config_t, dlopen_process_rpath),
UCS_CONFIG_TYPE_BOOL},
{"MODULE_UNLOAD_PREVENT_MODE", "lazy",
"Module unload prevention mode\n"
" lazy - use RTLD_LAZY flag to add reference to module.\n"
" now - use RTLD_NOW flag to add reference to module.\n"
" none - don't prevent module unload, use it for debug purposes only.",
ucs_offsetof(ucm_global_config_t, module_unload_prevent_mode),
UCS_CONFIG_TYPE_ENUM(ucm_module_unload_prevent_modes)},
{"BISTRO_FORCE_FAR_JUMP", "n",
"Force far jump when applying bistro patches. Used for testing purpose.",
ucs_offsetof(ucm_global_config_t, bistro_force_far_jump),
UCS_CONFIG_TYPE_BOOL},
{NULL}
};
UCS_CONFIG_DECLARE_TABLE(ucm_global_config_table, "UCM", UCM_CONFIG_PREFIX,
ucm_global_config_t)
void ucs_init_ucm_opts()
{
ucm_global_config_t ucm_opts;
UCS_CONFIG_ADD_TABLE(ucm_global_config_table, &ucs_config_global_list);
(void)ucs_config_parser_fill_opts(&ucm_opts,
UCS_CONFIG_GET_TABLE(
ucm_global_config_table),
UCS_DEFAULT_ENV_PREFIX, 0);
ucm_set_global_opts(&ucm_opts);
}
void ucs_cleanup_ucm_opts()
{
UCS_CONFIG_REMOVE_TABLE(ucm_global_config_table);
}
|
b479dc2510eb41144225683be07451b9f4fa9a09
|
90aa35bc3bd339d194180252fd2e1d3f3cd7aff9
|
/test/test_MultiMalloc.c
|
55468c6a6d2e8a9dd6cddbcfc756da34d6a9ef2d
|
[
"MIT"
] |
permissive
|
rhempel/umm_malloc
|
2000bc221ad9b8cfb54f00b507d83131d7f3779a
|
20e13dd5704d10c5932cbac05b6af8417e8965a7
|
refs/heads/master
| 2023-08-08T00:55:40.362983
| 2023-07-17T14:17:33
| 2023-07-23T02:33:52
| 31,398,957
| 354
| 105
|
MIT
| 2023-07-23T02:33:54
| 2015-02-27T02:06:46
|
C
|
UTF-8
|
C
| false
| false
| 3,834
|
c
|
test_MultiMalloc.c
|
#include "unity.h"
#include <umm_malloc_cfg.h>
#include <umm_malloc.h>
#include <support_umm_malloc.h>
/* Use the default DBGLOG_LEVEL and DBGLOG_FUNCTION */
#define DBGLOG_LEVEL 0
#ifdef DBGLOG_ENABLE
#include "dbglog/dbglog.h"
#endif
void setUp(void) {
umm_init();
umm_critical_depth = 0;
umm_max_critical_depth = 0;
}
void tearDown(void) {
TEST_ASSERT_LESS_OR_EQUAL(1, umm_max_critical_depth);
}
struct block_test_values MultiMallocManySmall_test_values[] =
{ {0, false, 1, 0, 6, 6}
, {1, false, 2, 0, 0, 0}
, {2, false, 3, 1, 0, 0}
, {3, false, 4, 2, 0, 0}
, {4, false, 5, 3, 0, 0}
, {5, false, 6, 4, 0, 0}
, {6, true, UMM_LASTBLOCK, 5, 0, 0}
, {UMM_LASTBLOCK, false, 0, 6, 0, 0}};
void testMultiMallocManySmall(void) {
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[1][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[2][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[3][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[4][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[5][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_TRUE(check_blocks(MultiMallocManySmall_test_values, ARRAYELEMENTCOUNT(MultiMallocManySmall_test_values)));
}
struct block_test_values MultiMallocManyMed_test_values[] =
{ { 0, false, 1, 0, 2501, 2501}
, { 1, false, 501, 0, 0, 0}
, { 501, false, 1001, 1, 0, 0}
, {1001, false, 1501, 501, 0, 0}
, {1501, false, 2001, 1001, 0, 0}
, {2001, false, 2501, 1501, 0, 0}
, {2501, true, UMM_LASTBLOCK, 2001, 0, 0}
, {UMM_LASTBLOCK, false, 0, 2501, 0, 0}};
void testMultiMallocManyMed(void) {
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[ 1][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_BLOCK_BODY_SIZE * 500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[ 501][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_BLOCK_BODY_SIZE * 500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[1001][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_BLOCK_BODY_SIZE * 500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[1501][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_BLOCK_BODY_SIZE * 500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[2001][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_BLOCK_BODY_SIZE * 500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_TRUE(check_blocks(MultiMallocManyMed_test_values, ARRAYELEMENTCOUNT(MultiMallocManyMed_test_values)));
}
struct block_test_values MultiMallocManyLarge_test_values[] =
{ { 0, false, 1, 0, 7501, 7501}
, { 1, false, 2501, 0, 0, 0}
, { 2501, false, 5001, 1, 0, 0}
, { 5001, false, 7501, 2501, 0, 0}
, { 7501, true, UMM_LASTBLOCK, 5001, 0, 0}
, {UMM_LASTBLOCK, false, 0, 7501, 0, 0}};
void testMultiMallocManyLarge(void) {
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[ 1][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_BLOCK_BODY_SIZE * 2500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[2501][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_BLOCK_BODY_SIZE * 2500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)&test_umm_heap[5001][UMM_BLOCK_HEADER_SIZE], umm_malloc(UMM_BLOCK_BODY_SIZE * 2500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_EQUAL_PTR((void *)NULL, umm_malloc(UMM_BLOCK_BODY_SIZE * 2500 - UMM_FIRST_BLOCK_BODY_SIZE));
TEST_ASSERT_TRUE(check_blocks(MultiMallocManyLarge_test_values, ARRAYELEMENTCOUNT(MultiMallocManyLarge_test_values)));
}
|
9456f8a73679b61e0c65d6f6da32fb5104ee6694
|
1efb2283837c9b70bc6449cec877799e4efa3268
|
/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_nemesis.h
|
6bb04ce2c8e39168c12c896e11428dc9702ea4c3
|
[
"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
| 219
|
h
|
mpidi_ch3_nemesis.h
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#ifndef MPIDI_CH3_NEMESIS_H_INCLUDED
#define MPIDI_CH3_NEMESIS_H_INCLUDED
#endif /* MPIDI_CH3_NEMESIS_H_INCLUDED */
|
1c491c87e3f66862e815b072459f84de9e8147fc
|
55540f3e86f1d5d86ef6b5d295a63518e274efe3
|
/toolchain/riscv/Linux/riscv64-unknown-elf/include/sys/resource.h
|
b99506bd80511d59397480f27e7db6bfa8492adf
|
[
"Apache-2.0"
] |
permissive
|
bouffalolab/bl_iot_sdk
|
bc5eaf036b70f8c65dd389439062b169f8d09daa
|
b90664de0bd4c1897a9f1f5d9e360a9631d38b34
|
refs/heads/master
| 2023-08-31T03:38:03.369853
| 2023-08-16T08:50:33
| 2023-08-18T09:13:27
| 307,347,250
| 244
| 101
|
Apache-2.0
| 2023-08-28T06:29:02
| 2020-10-26T11:16:30
|
C
|
UTF-8
|
C
| false
| false
| 345
|
h
|
resource.h
|
#ifndef _SYS_RESOURCE_H_
#define _SYS_RESOURCE_H_
#include <sys/time.h>
#define RUSAGE_SELF 0 /* calling process */
#define RUSAGE_CHILDREN -1 /* terminated child processes */
struct rusage {
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
};
int getrusage (int, struct rusage*);
#endif
|
4410eb6d00721a7f3992c1f36a1367cc916775b8
|
1a774e91ee2e6d31a38739dabf6b2c8b6c08390f
|
/gdbplus/gdb-1824/src/gdb/search.c
|
53bd8aba9b69987199dc346c3d142d003d5850c2
|
[] |
no_license
|
yanqi27/core_analyzer
|
f4fec3c1052cd04203c2c07682466ec6adde0b8f
|
8f19a0d8d083d3c030dff88c50dec7ad351613e0
|
refs/heads/master
| 2023-05-11T07:44:09.222621
| 2023-05-05T15:08:43
| 2023-05-05T15:08:43
| 49,509,271
| 305
| 68
| null | 2023-07-25T14:16:53
| 2016-01-12T15:30:53
|
C
|
UTF-8
|
C
| false
| false
| 26
|
c
|
search.c
|
../../../../src/search.cpp
|
5775d2dde25c0cb7e4474f825e9635e307a723e2
|
90b45421155e34002fd133c7939d1f3bbb1173ff
|
/src/daemontools-extras/lolsyslog.c
|
e62bdef73cc1c0967cd4ec49a50abbe04e9b4745
|
[
"ISC"
] |
permissive
|
skarnet/s6
|
6ac71ec910f7d8a40bcd1e668eae3eaf6fab98df
|
1cbe4b09e027e31d258c24feee0be46958888b93
|
refs/heads/master
| 2023-08-18T08:02:16.943355
| 2023-08-10T15:42:00
| 2023-08-10T15:42:00
| 31,460,641
| 724
| 48
|
ISC
| 2020-06-26T11:56:36
| 2015-02-28T11:26:29
|
C
|
UTF-8
|
C
| false
| false
| 1,897
|
c
|
lolsyslog.c
|
/* ISC license. */
#undef INTERNAL_MARK
#ifndef SYSLOG_NAMES
#define SYSLOG_NAMES
#endif
#include <skalibs/nonposix.h>
#include <string.h>
#include <syslog.h>
#include <skalibs/types.h>
#include "lolsyslog.h"
#ifndef INTERNAL_MARK
typedef struct CODE_s CODE, *CODE_ref ;
struct CODE_s
{
char *c_name ;
unsigned int c_val ;
} ;
#define LOG_PRI(p) ((p) & LOG_PRIMASK)
#define LOG_FAC(p) (((p) & LOG_FACMASK) / (LOG_PRIMASK + 1))
static CODE const facilitynames[] =
{
{ "kern", LOG_KERN },
{ "user", LOG_USER },
{ "mail", LOG_MAIL },
{ "news", LOG_NEWS },
{ "uucp", LOG_UUCP },
{ "daemon", LOG_DAEMON },
{ "auth", LOG_AUTH },
{ "cron", LOG_CRON },
{ "lpr", LOG_LPR },
#ifdef LOG_SYSLOG
{ "syslog", LOG_SYSLOG },
#endif
#ifdef LOG_AUDIT
{ "audit", LOG_AUDIT },
#endif
{ "local0", LOG_LOCAL0 },
{ "local1", LOG_LOCAL1 },
{ "local2", LOG_LOCAL2 },
{ "local3", LOG_LOCAL3 },
{ "local4", LOG_LOCAL4 },
{ "local5", LOG_LOCAL5 },
{ "local6", LOG_LOCAL6 },
{ "local7", LOG_LOCAL7 },
{ 0, -1 }
} ;
static CODE const prioritynames[] =
{
{ "emerg", LOG_EMERG },
{ "alert", LOG_ALERT },
{ "crit", LOG_CRIT },
{ "err", LOG_ERR },
{ "warning", LOG_WARNING },
{ "notice", LOG_NOTICE },
{ "info", LOG_INFO },
{ "debug", LOG_DEBUG },
{ 0, -1 }
} ;
#endif
size_t lolsyslog_string (char *out, char const *in)
{
size_t i ;
unsigned int fpr ;
int fp ;
CODE const *p = facilitynames ;
if (in[0] != '<' || !(i = uint_scan(in+1, &fpr)) || in[1+i] != '>') return 0 ;
fp = LOG_FAC(fpr) << 3 ;
for (; p->c_name ; p++) if (p->c_val == fp) break ;
out = stpcpy(out, p->c_name ? p->c_name : "unknown") ;
*out++ = '.' ;
p = prioritynames ;
fp = LOG_PRI(fpr) ;
for (; p->c_name ; p++) if (p->c_val == fp) break ;
out = stpcpy(out, p->c_name ? p->c_name : "unknown") ;
*out++ = ':' ; *out++ = ' ' ; *out++ = 0 ;
return i+2 ;
}
|
9154ba94a2112f7a2a36e1357c6c0ff980c83ce5
|
badb70a0b235c98ac034cfe5b4bfafda36647831
|
/Staging/OpenHfsPlus/fsw_efi.c
|
df75f08ee7eb60fdf19b8d091b964aa87e3bdb25
|
[
"BSD-3-Clause"
] |
permissive
|
acidanthera/OpenCorePkg
|
f34a7d67b22c74fb5ab559e48519e5f5855b6751
|
1d5b1736fe5a5ef7662b5c076c6d11aac96fd5d6
|
refs/heads/master
| 2023-08-30T21:03:02.993659
| 2023-08-28T23:30:43
| 2023-08-28T23:30:43
| 179,354,282
| 13,212
| 2,999
|
BSD-3-Clause
| 2023-09-10T18:29:53
| 2019-04-03T19:14:29
|
C
|
UTF-8
|
C
| false
| false
| 40,746
|
c
|
fsw_efi.c
|
/**
* \file fsw_efi.c
* EFI host environment code.
*/
/*-
* Copyright (c) 2006 Christoph Pfisterer
*
* 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 Christoph Pfisterer nor the names of the
* 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 "fsw_efi.h"
#define DEBUG_LEVEL 0
#ifndef FSTYPE
/** The file system type name to use. */
#define FSTYPE ext2
#endif
/** Helper macro for stringification. */
#define FSW_EFI_STRINGIFY(x) #x
/** Expands to the EFI driver name given the file system type name. */
#define FSW_EFI_DRIVER_NAME(t) L"Fsw " FSW_EFI_STRINGIFY(t) L" File System Driver"
// function prototypes
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Supported(IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath);
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Start(IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath);
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Stop(IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer);
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName);
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName);
void fsw_efi_change_blocksize(struct fsw_volume *vol,
fsw_u32 old_phys_blocksize, fsw_u32 old_log_blocksize,
fsw_u32 new_phys_blocksize, fsw_u32 new_log_blocksize);
fsw_status_t fsw_efi_read_block(struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer);
EFI_STATUS fsw_efi_map_status(fsw_status_t fsw_status, FSW_VOLUME_DATA *Volume);
EFI_STATUS EFIAPI fsw_efi_FileSystem_OpenVolume(IN EFI_FILE_IO_INTERFACE *This,
OUT EFI_FILE **Root);
EFI_STATUS fsw_efi_dnode_to_FileHandle(IN struct fsw_dnode *dno,
OUT EFI_FILE **NewFileHandle);
EFI_STATUS fsw_efi_file_read(IN FSW_FILE_DATA *File,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer);
EFI_STATUS fsw_efi_file_getpos(IN FSW_FILE_DATA *File,
OUT UINT64 *Position);
EFI_STATUS fsw_efi_file_setpos(IN FSW_FILE_DATA *File,
IN UINT64 Position);
EFI_STATUS fsw_efi_dir_open(IN FSW_FILE_DATA *File,
OUT EFI_FILE **NewHandle,
IN CHAR16 *FileName,
IN UINT64 OpenMode,
IN UINT64 Attributes);
EFI_STATUS fsw_efi_dir_read(IN FSW_FILE_DATA *File,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer);
EFI_STATUS fsw_efi_dir_setpos(IN FSW_FILE_DATA *File,
IN UINT64 Position);
EFI_STATUS fsw_efi_dnode_getinfo(IN FSW_FILE_DATA *File,
IN EFI_GUID *InformationType,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer);
EFI_STATUS fsw_efi_dnode_fill_FileInfo(IN FSW_VOLUME_DATA *Volume,
IN struct fsw_dnode *dno,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer);
EFI_STATUS fsw_efi_bless_info(IN FSW_VOLUME_DATA *Volume,
IN UINT32 type,
OUT VOID *Buffer,
IN OUT UINTN *BufferSize);
/**
* Interface structure for the EFI Driver Binding protocol.
*/
EFI_DRIVER_BINDING_PROTOCOL fsw_efi_DriverBinding_table = {
fsw_efi_DriverBinding_Supported,
fsw_efi_DriverBinding_Start,
fsw_efi_DriverBinding_Stop,
0x10,
NULL,
NULL
};
/**
* Interface structure for the EFI Component Name protocol.
*/
EFI_COMPONENT_NAME_PROTOCOL fsw_efi_ComponentName_table = {
fsw_efi_ComponentName_GetDriverName,
fsw_efi_ComponentName_GetControllerName,
"eng"
};
/**
* Dispatch table for our FSW host driver.
*/
struct fsw_host_table fsw_efi_host_table = {
FSW_STRING_TYPE_UTF16,
fsw_efi_change_blocksize,
fsw_efi_read_block
};
extern struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME(FSTYPE);
/**
* Image entry point. Installs the Driver Binding and Component Name protocols
* on the image's handle. Actually mounting a file system is initiated through
* the Driver Binding protocol at the firmware's request.
*/
EFI_STATUS EFIAPI fsw_efi_main(IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS Status;
// complete Driver Binding protocol instance
fsw_efi_DriverBinding_table.ImageHandle = ImageHandle;
fsw_efi_DriverBinding_table.DriverBindingHandle = ImageHandle;
// install Driver Binding protocol
Status = BS->InstallProtocolInterface(&fsw_efi_DriverBinding_table.DriverBindingHandle,
&gEfiDriverBindingProtocolGuid,
EFI_NATIVE_INTERFACE,
&fsw_efi_DriverBinding_table);
if (EFI_ERROR (Status)) {
return Status;
}
// install Component Name protocol
Status = BS->InstallProtocolInterface(&fsw_efi_DriverBinding_table.DriverBindingHandle,
&gEfiComponentNameProtocolGuid,
EFI_NATIVE_INTERFACE,
&fsw_efi_ComponentName_table);
if (EFI_ERROR (Status)) {
return Status;
}
return EFI_SUCCESS;
}
/**
* Driver Binding EFI protocol, Supported function. This function is called by EFI
* to test if this driver can handle a certain device. Our implementation only checks
* if the device is a disk (i.e. that it supports the Block I/O and Disk I/O protocols)
* and implicitly checks if the disk is already in use by another driver.
*/
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Supported(IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
{
EFI_STATUS Status;
EFI_DISK_IO *DiskIo;
// we check for both DiskIO and BlockIO protocols
// first, open DiskIO
Status = BS->OpenProtocol(ControllerHandle,
&gEfiDiskIoProtocolGuid,
(VOID **) &DiskIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR(Status))
return Status;
// we were just checking, close it again
BS->CloseProtocol(ControllerHandle,
&gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle);
// next, check BlockIO without actually opening it
Status = BS->OpenProtocol(ControllerHandle,
&gEfiBlockIoProtocolGuid,
NULL,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
return Status;
}
/**
* Driver Binding EFI protocol, Start function. This function is called by EFI
* to start driving the given device. It is still possible at this point to
* return EFI_UNSUPPORTED, and in fact we will do so if the file system driver
* cannot find the superblock signature (or equivalent) that it expects.
*
* This function allocates memory for a per-volume structure, opens the
* required protocols (just Disk I/O in our case, Block I/O is only looked
* at to get the MediaId field), and lets the FSW core mount the file system.
* If successful, an EFI Simple File System protocol is exported on the
* device handle.
*/
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Start(IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
{
EFI_STATUS Status;
EFI_BLOCK_IO *BlockIo;
EFI_DISK_IO *DiskIo;
FSW_VOLUME_DATA *Volume;
#if DEBUG_LEVEL
Print(L"fsw_efi_DriverBinding_Start\n");
#endif
// open consumed protocols
Status = BS->OpenProtocol(ControllerHandle,
&gEfiBlockIoProtocolGuid,
(VOID **) &BlockIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL); // NOTE: we only want to look at the MediaId
if (EFI_ERROR(Status)) {
Print(L"Fsw ERROR: OpenProtocol(BlockIo) returned %x\n", Status);
return Status;
}
Status = BS->OpenProtocol(ControllerHandle,
&gEfiDiskIoProtocolGuid,
(VOID **) &DiskIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR(Status)) {
Print(L"Fsw ERROR: OpenProtocol(DiskIo) returned %x\n", Status);
return Status;
}
// allocate volume structure
Volume = AllocateZeroPool(sizeof(FSW_VOLUME_DATA));
Volume->Signature = FSW_VOLUME_DATA_SIGNATURE;
Volume->Handle = ControllerHandle;
Volume->DiskIo = DiskIo;
Volume->MediaId = BlockIo->Media->MediaId;
Volume->LastIOStatus = EFI_SUCCESS;
// mount the filesystem
Status = fsw_efi_map_status(fsw_mount(Volume, &fsw_efi_host_table,
&FSW_FSTYPE_TABLE_NAME(FSTYPE), &Volume->vol),
Volume);
if (!EFI_ERROR(Status)) {
// register the SimpleFileSystem protocol
Volume->FileSystem.Revision = EFI_FILE_IO_INTERFACE_REVISION;
Volume->FileSystem.OpenVolume = fsw_efi_FileSystem_OpenVolume;
Status = BS->InstallMultipleProtocolInterfaces(&ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid, &Volume->FileSystem,
NULL);
if (EFI_ERROR(Status))
Print(L"Fsw ERROR: InstallMultipleProtocolInterfaces returned %x\n", Status);
}
// on errors, close the opened protocols
if (EFI_ERROR(Status)) {
if (Volume->vol != NULL)
fsw_unmount(Volume->vol);
FreePool(Volume);
BS->CloseProtocol(ControllerHandle,
&gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle);
}
return Status;
}
/**
* Driver Binding EFI protocol, Stop function. This function is called by EFI
* to stop the driver on the given device. This translates to an unmount
* call for the FSW core.
*
* We assume that all file handles on the volume have been closed before
* the driver is stopped. At least with the EFI shell, that is actually the
* case; it closes all file handles between commands.
*/
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Stop(IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer)
{
EFI_STATUS Status;
EFI_FILE_IO_INTERFACE *FileSystem;
FSW_VOLUME_DATA *Volume;
#if DEBUG_LEVEL
Print(L"fsw_efi_DriverBinding_Stop\n");
#endif
// get the installed SimpleFileSystem interface
Status = BS->OpenProtocol(ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid,
(VOID **) &FileSystem,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR(Status))
return EFI_UNSUPPORTED;
// get private data structure
Volume = FSW_VOLUME_FROM_FILE_SYSTEM(FileSystem);
// uninstall Simple File System protocol
Status = BS->UninstallMultipleProtocolInterfaces(ControllerHandle,
&gEfiSimpleFileSystemProtocolGuid, &Volume->FileSystem,
NULL);
if (EFI_ERROR(Status)) {
Print(L"Fsw ERROR: UninstallMultipleProtocolInterfaces returned %x\n", Status);
return Status;
}
#if DEBUG_LEVEL
Print(L"fsw_efi_DriverBinding_Stop: protocol uninstalled successfully\n");
#endif
// release private data structure
if (Volume->vol != NULL)
fsw_unmount(Volume->vol);
FreePool(Volume);
// close the consumed protocols
Status = BS->CloseProtocol(ControllerHandle,
&gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle);
return Status;
}
/**
* Component Name EFI protocol, GetDriverName function. Used by the EFI
* environment to inquire the name of this driver. The name returned is
* based on the file system type actually used in compilation.
*/
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName)
{
if (Language == NULL || DriverName == NULL)
return EFI_INVALID_PARAMETER;
if (Language[0] == 'e' && Language[1] == 'n' && Language[2] == 'g' && Language[3] == 0) {
*DriverName = FSW_EFI_DRIVER_NAME(FSTYPE);
return EFI_SUCCESS;
}
return EFI_UNSUPPORTED;
}
/**
* Component Name EFI protocol, GetControllerName function. Not implemented
* because this is not a "bus" driver in the sense of the EFI Driver Model.
*/
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName)
{
return EFI_UNSUPPORTED;
}
/**
* FSW interface function for block size changes. This function is called by the FSW core
* when the file system driver changes the block sizes for the volume.
*/
void fsw_efi_change_blocksize(struct fsw_volume *vol,
fsw_u32 old_phys_blocksize, fsw_u32 old_log_blocksize,
fsw_u32 new_phys_blocksize, fsw_u32 new_log_blocksize)
{
// nothing to do
}
/**
* FSW interface function to read data blocks. This function is called by the FSW core
* to read a block of data from the device. The buffer is allocated by the core code.
*/
fsw_status_t fsw_efi_read_block(struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer)
{
EFI_STATUS Status;
FSW_VOLUME_DATA *Volume = (FSW_VOLUME_DATA *)vol->host_data;
FSW_MSG_DEBUGV((FSW_MSGSTR("fsw_efi_read_block: %d (%d)\n"), phys_bno, vol->phys_blocksize));
// read from disk
Status = Volume->DiskIo->ReadDisk(Volume->DiskIo, Volume->MediaId,
(UINT64)phys_bno * vol->phys_blocksize,
vol->phys_blocksize,
buffer);
Volume->LastIOStatus = Status;
if (EFI_ERROR(Status))
return FSW_IO_ERROR;
return FSW_SUCCESS;
}
/**
* Map FSW status codes to EFI status codes. The FSW_IO_ERROR code is only produced
* by fsw_efi_read_block, so we map it back to the EFI status code remembered from
* the last I/O operation.
*/
EFI_STATUS fsw_efi_map_status(fsw_status_t fsw_status, FSW_VOLUME_DATA *Volume)
{
switch (fsw_status) {
case FSW_SUCCESS:
return EFI_SUCCESS;
case FSW_OUT_OF_MEMORY:
return EFI_VOLUME_CORRUPTED;
case FSW_IO_ERROR:
return Volume->LastIOStatus;
case FSW_UNSUPPORTED:
return EFI_UNSUPPORTED;
case FSW_NOT_FOUND:
return EFI_NOT_FOUND;
case FSW_VOLUME_CORRUPTED:
return EFI_VOLUME_CORRUPTED;
default:
return EFI_DEVICE_ERROR;
}
}
/**
* File System EFI protocol, OpenVolume function. Creates a file handle for
* the root directory and returns it. Note that this function may be called
* multiple times and returns a new file handle each time. Each returned
* handle is closed by the client using it.
*/
EFI_STATUS EFIAPI fsw_efi_FileSystem_OpenVolume(IN EFI_FILE_IO_INTERFACE *This,
OUT EFI_FILE **Root)
{
EFI_STATUS Status;
FSW_VOLUME_DATA *Volume = FSW_VOLUME_FROM_FILE_SYSTEM(This);
#if DEBUG_LEVEL
Print(L"fsw_efi_FileSystem_OpenVolume\n");
#endif
Status = fsw_efi_dnode_to_FileHandle(Volume->vol->root, Root);
return Status;
}
/**
* File Handle EFI protocol, Open function. Dispatches the call
* based on the kind of file handle.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_Open(IN EFI_FILE *This,
OUT EFI_FILE **NewHandle,
IN CHAR16 *FileName,
IN UINT64 OpenMode,
IN UINT64 Attributes)
{
FSW_FILE_DATA *File = FSW_FILE_FROM_FILE_HANDLE(This);
if (File->Type == FSW_EFI_FILE_TYPE_DIR)
return fsw_efi_dir_open(File, NewHandle, FileName, OpenMode, Attributes);
// not supported for regular files
return EFI_UNSUPPORTED;
}
/**
* File Handle EFI protocol, Close function. Closes the FSW shandle
* and frees the memory used for the structure.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_Close(IN EFI_FILE *This)
{
FSW_FILE_DATA *File = FSW_FILE_FROM_FILE_HANDLE(This);
#if DEBUG_LEVEL
Print(L"fsw_efi_FileHandle_Close\n");
#endif
fsw_shandle_close(&File->shand);
FreePool(File);
return EFI_SUCCESS;
}
/**
* File Handle EFI protocol, Delete function. Calls through to Close
* and returns a warning because this driver is read-only.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_Delete(IN EFI_FILE *This)
{
EFI_STATUS Status;
Status = This->Close(This);
if (Status == EFI_SUCCESS) {
// this driver is read-only
Status = EFI_WARN_DELETE_FAILURE;
}
return Status;
}
/**
* File Handle EFI protocol, Read function. Dispatches the call
* based on the kind of file handle.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_Read(IN EFI_FILE *This,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer)
{
FSW_FILE_DATA *File = FSW_FILE_FROM_FILE_HANDLE(This);
if (File->Type == FSW_EFI_FILE_TYPE_FILE)
return fsw_efi_file_read(File, BufferSize, Buffer);
else if (File->Type == FSW_EFI_FILE_TYPE_DIR)
return fsw_efi_dir_read(File, BufferSize, Buffer);
return EFI_UNSUPPORTED;
}
/**
* File Handle EFI protocol, Write function. Returns unsupported status
* because this driver is read-only.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_Write(IN EFI_FILE *This,
IN OUT UINTN *BufferSize,
IN VOID *Buffer)
{
// this driver is read-only
return EFI_WRITE_PROTECTED;
}
/**
* File Handle EFI protocol, GetPosition function. Dispatches the call
* based on the kind of file handle.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_GetPosition(IN EFI_FILE *This,
OUT UINT64 *Position)
{
FSW_FILE_DATA *File = FSW_FILE_FROM_FILE_HANDLE(This);
if (File->Type == FSW_EFI_FILE_TYPE_FILE)
return fsw_efi_file_getpos(File, Position);
// not defined for directories
return EFI_UNSUPPORTED;
}
/**
* File Handle EFI protocol, SetPosition function. Dispatches the call
* based on the kind of file handle.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_SetPosition(IN EFI_FILE *This,
IN UINT64 Position)
{
FSW_FILE_DATA *File = FSW_FILE_FROM_FILE_HANDLE(This);
if (File->Type == FSW_EFI_FILE_TYPE_FILE)
return fsw_efi_file_setpos(File, Position);
else if (File->Type == FSW_EFI_FILE_TYPE_DIR)
return fsw_efi_dir_setpos(File, Position);
return EFI_UNSUPPORTED;
}
/**
* File Handle EFI protocol, GetInfo function. Dispatches to the common
* function implementing this.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_GetInfo(IN EFI_FILE *This,
IN EFI_GUID *InformationType,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer)
{
FSW_FILE_DATA *File = FSW_FILE_FROM_FILE_HANDLE(This);
return fsw_efi_dnode_getinfo(File, InformationType, BufferSize, Buffer);
}
/**
* File Handle EFI protocol, SetInfo function. Returns unsupported status
* because this driver is read-only.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_SetInfo(IN EFI_FILE *This,
IN EFI_GUID *InformationType,
IN UINTN BufferSize,
IN VOID *Buffer)
{
// this driver is read-only
return EFI_WRITE_PROTECTED;
}
/**
* File Handle EFI protocol, Flush function. Returns unsupported status
* because this driver is read-only.
*/
EFI_STATUS EFIAPI fsw_efi_FileHandle_Flush(IN EFI_FILE *This)
{
// this driver is read-only
return EFI_WRITE_PROTECTED;
}
/**
* Set up a file handle for a dnode. This function allocates a data structure
* for a file handle, opens a FSW shandle and populates the EFI_FILE structure
* with the interface functions.
*/
EFI_STATUS fsw_efi_dnode_to_FileHandle(IN struct fsw_dnode *dno,
OUT EFI_FILE **NewFileHandle)
{
EFI_STATUS Status;
FSW_FILE_DATA *File;
// make sure the dnode has complete info
Status = fsw_efi_map_status(fsw_dnode_fill(dno), (FSW_VOLUME_DATA *)dno->vol->host_data);
if (EFI_ERROR(Status))
return Status;
// check type
if (dno->type != FSW_DNODE_TYPE_FILE && dno->type != FSW_DNODE_TYPE_DIR)
return EFI_UNSUPPORTED;
// allocate file structure
File = AllocateZeroPool(sizeof(FSW_FILE_DATA));
File->Signature = FSW_FILE_DATA_SIGNATURE;
if (dno->type == FSW_DNODE_TYPE_FILE)
File->Type = FSW_EFI_FILE_TYPE_FILE;
else if (dno->type == FSW_DNODE_TYPE_DIR)
File->Type = FSW_EFI_FILE_TYPE_DIR;
// open shandle
Status = fsw_efi_map_status(fsw_shandle_open(dno, &File->shand),
(FSW_VOLUME_DATA *)dno->vol->host_data);
if (EFI_ERROR(Status)) {
FreePool(File);
return Status;
}
// populate the file handle
File->FileHandle.Revision = EFI_FILE_HANDLE_REVISION;
File->FileHandle.Open = fsw_efi_FileHandle_Open;
File->FileHandle.Close = fsw_efi_FileHandle_Close;
File->FileHandle.Delete = fsw_efi_FileHandle_Delete;
File->FileHandle.Read = fsw_efi_FileHandle_Read;
File->FileHandle.Write = fsw_efi_FileHandle_Write;
File->FileHandle.GetPosition = fsw_efi_FileHandle_GetPosition;
File->FileHandle.SetPosition = fsw_efi_FileHandle_SetPosition;
File->FileHandle.GetInfo = fsw_efi_FileHandle_GetInfo;
File->FileHandle.SetInfo = fsw_efi_FileHandle_SetInfo;
File->FileHandle.Flush = fsw_efi_FileHandle_Flush;
*NewFileHandle = &File->FileHandle;
return EFI_SUCCESS;
}
/**
* Data read function for regular files. Calls through to fsw_shandle_read.
*/
EFI_STATUS fsw_efi_file_read(IN FSW_FILE_DATA *File,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer)
{
EFI_STATUS Status;
fsw_u32 buffer_size;
#if DEBUG_LEVEL
Print(L"fsw_efi_file_read %d bytes\n", *BufferSize);
#endif
buffer_size = (fsw_u32) *BufferSize;
Status = fsw_efi_map_status(fsw_shandle_read(&File->shand, &buffer_size, Buffer),
(FSW_VOLUME_DATA *)File->shand.dnode->vol->host_data);
*BufferSize = buffer_size;
return Status;
}
/**
* Get file position for regular files.
*/
EFI_STATUS fsw_efi_file_getpos(IN FSW_FILE_DATA *File,
OUT UINT64 *Position)
{
*Position = File->shand.pos;
return EFI_SUCCESS;
}
/**
* Set file position for regular files. EFI specifies the all-ones value
* to be a special value for the end of the file.
*/
EFI_STATUS fsw_efi_file_setpos(IN FSW_FILE_DATA *File,
IN UINT64 Position)
{
if (Position == 0xFFFFFFFFFFFFFFFFULL)
File->shand.pos = File->shand.dnode->size;
else
File->shand.pos = Position;
return EFI_SUCCESS;
}
/**
* Open function used to open new file handles relative to a directory.
* In EFI, the "open file" function is implemented by directory file handles
* and is passed a relative or volume-absolute path to the file or directory
* to open. We use fsw_dnode_lookup_path to find the node plus an additional
* call to fsw_dnode_resolve because EFI has no concept of symbolic links.
*/
EFI_STATUS fsw_efi_dir_open(IN FSW_FILE_DATA *File,
OUT EFI_FILE **NewHandle,
IN CHAR16 *FileName,
IN UINT64 OpenMode,
IN UINT64 Attributes)
{
EFI_STATUS Status;
FSW_VOLUME_DATA *Volume = (FSW_VOLUME_DATA *)File->shand.dnode->vol->host_data;
struct fsw_dnode *dno;
struct fsw_dnode *target_dno;
struct fsw_string lookup_path;
#if DEBUG_LEVEL
Print(L"fsw_efi_dir_open: '%s'\n", FileName);
#endif
if (OpenMode != EFI_FILE_MODE_READ)
return EFI_WRITE_PROTECTED;
lookup_path.type = FSW_STRING_TYPE_UTF16;
lookup_path.len = (int) StrLen(FileName);
lookup_path.size = lookup_path.len * sizeof(fsw_u16);
lookup_path.data = FileName;
// resolve the path (symlinks along the way are automatically resolved)
Status = fsw_efi_map_status(fsw_dnode_lookup_path(File->shand.dnode, &lookup_path, '\\', &dno),
Volume);
if (EFI_ERROR(Status))
return Status;
// if the final node is a symlink, also resolve it
Status = fsw_efi_map_status(fsw_dnode_resolve(dno, &target_dno),
Volume);
fsw_dnode_release(dno);
if (EFI_ERROR(Status))
return Status;
dno = target_dno;
// make a new EFI handle for the target dnode
Status = fsw_efi_dnode_to_FileHandle(dno, NewHandle);
fsw_dnode_release(dno);
return Status;
}
/**
* Read function for directories. A file handle read on a directory retrieves
* the next directory entry.
*/
EFI_STATUS fsw_efi_dir_read(IN FSW_FILE_DATA *File,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer)
{
EFI_STATUS Status;
FSW_VOLUME_DATA *Volume = (FSW_VOLUME_DATA *)File->shand.dnode->vol->host_data;
struct fsw_dnode *dno;
#if DEBUG_LEVEL
Print(L"fsw_efi_dir_read...\n");
#endif
// read the next entry
Status = fsw_efi_map_status(fsw_dnode_dir_read(&File->shand, &dno),
Volume);
if (Status == EFI_NOT_FOUND) {
// end of directory
*BufferSize = 0;
#if DEBUG_LEVEL
Print(L"...no more entries\n");
#endif
return EFI_SUCCESS;
}
if (EFI_ERROR(Status))
return Status;
// get info into buffer
Status = fsw_efi_dnode_fill_FileInfo(Volume, dno, BufferSize, Buffer);
fsw_dnode_release(dno);
return Status;
}
/**
* Set file position for directories. The only allowed set position operation
* for directories is to rewind the directory completely by setting the
* position to zero.
*/
EFI_STATUS fsw_efi_dir_setpos(IN FSW_FILE_DATA *File,
IN UINT64 Position)
{
if (Position == 0) {
File->shand.pos = 0;
return EFI_SUCCESS;
} else {
// directories can only rewind to the start
return EFI_UNSUPPORTED;
}
}
EFI_STATUS fsw_efi_bless_info(IN FSW_VOLUME_DATA *Volume,
IN UINT32 BlessType,
OUT VOID *Buffer,
IN OUT UINTN *BufferSize) {
EFI_STATUS Status;
UINTN RequiredSize;
EFI_DEVICE_PATH_PROTOCOL *devicePathProtocol;
struct fsw_string PathStr;
UINT16 *PathChars;
#if DEBUG_LEVEL
Print(L"fsw_efi_bless_info.1\n");
#endif
Status = fsw_efi_map_status(fsw_get_bless_info(Volume->vol, BlessType, &PathStr), Volume);
if (Status)
return EFI_NOT_FOUND;
// We assume that PathStr is in UTF16
// Reserve one symbol for '\0'
RequiredSize = (PathStr.len + 1) * sizeof(UINT16);
if ((PathChars = AllocatePool(RequiredSize)) == NULL) {
fsw_strfree (&PathStr);
return EFI_OUT_OF_RESOURCES;
}
CopyMem(PathChars, PathStr.data, PathStr.size);
PathChars[PathStr.len] = 0;
fsw_strfree(&PathStr);
#if DEBUG_LEVEL
Print(L"fsw_efi_bless_info.2 type=%d, res=%s\n", BlessType, PathChars);
#endif
devicePathProtocol = FileDevicePath(Volume->Handle, PathChars);
FreePool(PathChars);
RequiredSize = GetDevicePathSize(devicePathProtocol);
if (*BufferSize < RequiredSize)
Status = EFI_BUFFER_TOO_SMALL;
else {
CopyMem(Buffer, devicePathProtocol, RequiredSize);
Status = EFI_SUCCESS;
}
*BufferSize = RequiredSize;
FreePool(devicePathProtocol);
return Status;
}
/**
* Get file or volume information. This function implements the GetInfo call
* for all file handles. Control is dispatched according to the type of information
* requested by the caller.
*/
EFI_STATUS fsw_efi_dnode_getinfo(IN FSW_FILE_DATA *File,
IN EFI_GUID *InformationType,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer)
{
EFI_STATUS Status;
FSW_VOLUME_DATA *Volume = (FSW_VOLUME_DATA *)File->shand.dnode->vol->host_data;
EFI_FILE_SYSTEM_INFO *FSInfo;
UINTN RequiredSize;
struct fsw_volume_stat vsb;
if (CompareGuid(InformationType, &gEfiFileInfoGuid)) {
#if DEBUG_LEVEL
Print(L"fsw_efi_dnode_getinfo: FILE_INFO\n");
#endif
Status = fsw_efi_dnode_fill_FileInfo(Volume, File->shand.dnode, BufferSize, Buffer);
} else if (CompareGuid(InformationType, &gEfiFileSystemInfoGuid)) {
#if DEBUG_LEVEL
Print(L"fsw_efi_dnode_getinfo: FILE_SYSTEM_INFO\n");
#endif
// check buffer size
RequiredSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + fsw_efi_strsize(&Volume->vol->label);
if (*BufferSize < RequiredSize) {
*BufferSize = RequiredSize;
return EFI_BUFFER_TOO_SMALL;
}
// fill structure
FSInfo = (EFI_FILE_SYSTEM_INFO *)Buffer;
FSInfo->Size = RequiredSize;
FSInfo->ReadOnly = TRUE;
FSInfo->BlockSize = Volume->vol->log_blocksize;
fsw_efi_strcpy(FSInfo->VolumeLabel, &Volume->vol->label);
// get the missing info from the fs driver
ZeroMem(&vsb, sizeof(struct fsw_volume_stat));
Status = fsw_efi_map_status(fsw_volume_stat(Volume->vol, &vsb), Volume);
if (EFI_ERROR(Status))
return Status;
FSInfo->VolumeSize = vsb.total_bytes;
FSInfo->FreeSpace = vsb.free_bytes;
// prepare for return
*BufferSize = RequiredSize;
Status = EFI_SUCCESS;
} else if (CompareGuid(InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
#if DEBUG_LEVEL
Print(L"fsw_efi_dnode_getinfo: FILE_SYSTEM_VOLUME_LABEL\n");
#endif
// check buffer size
RequiredSize = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO + fsw_efi_strsize(&Volume->vol->label);
if (*BufferSize < RequiredSize) {
*BufferSize = RequiredSize;
return EFI_BUFFER_TOO_SMALL;
}
// copy volume label
fsw_efi_strcpy(((EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *)Buffer)->VolumeLabel, &Volume->vol->label);
// prepare for return
*BufferSize = RequiredSize;
Status = EFI_SUCCESS;
} else if (CompareGuid(InformationType, &gAppleBlessedSystemFileInfoGuid)) {
Status = fsw_efi_bless_info(Volume, BLESSED_TYPE_SYSTEM_FILE, Buffer, BufferSize);
} else if (CompareGuid(InformationType, &gAppleBlessedSystemFolderInfoGuid)) {
Status = fsw_efi_bless_info(Volume, BLESSED_TYPE_SYSTEM_FOLDER, Buffer, BufferSize);
} else if (CompareGuid(InformationType, &gAppleBlessedOsxFolderInfoGuid)) {
Status = fsw_efi_bless_info(Volume, BLESSED_TYPE_OSX_FOLDER, Buffer, BufferSize);
} else {
Status = EFI_UNSUPPORTED;
}
return Status;
}
/**
* Time mapping callback for the fsw_dnode_stat call. This function converts
* a Posix style timestamp into an EFI_TIME structure and writes it to the
* appropriate member of the EFI_FILE_INFO structure that we're filling.
*/
static void fsw_efi_store_time_posix(struct fsw_dnode_stat *sb, int which, fsw_u32 posix_time)
{
EFI_FILE_INFO *FileInfo = (EFI_FILE_INFO *)sb->host_data;
if (which == FSW_DNODE_STAT_CTIME)
fsw_efi_decode_time(&FileInfo->CreateTime, posix_time);
else if (which == FSW_DNODE_STAT_MTIME)
fsw_efi_decode_time(&FileInfo->ModificationTime, posix_time);
else if (which == FSW_DNODE_STAT_ATIME)
fsw_efi_decode_time(&FileInfo->LastAccessTime, posix_time);
}
/**
* Mode mapping callback for the fsw_dnode_stat call. This function looks at
* the Posix mode passed by the file system driver and makes appropriate
* adjustments to the EFI_FILE_INFO structure that we're filling.
*/
static void fsw_efi_store_attr_posix(struct fsw_dnode_stat *sb, fsw_u16 posix_mode)
{
EFI_FILE_INFO *FileInfo = (EFI_FILE_INFO *)sb->host_data;
if ((posix_mode & S_IWUSR) == 0)
FileInfo->Attribute |= EFI_FILE_READ_ONLY;
}
/**
* Common function to fill an EFI_FILE_INFO with information about a dnode.
*/
EFI_STATUS fsw_efi_dnode_fill_FileInfo(IN FSW_VOLUME_DATA *Volume,
IN struct fsw_dnode *dno,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer)
{
EFI_STATUS Status;
EFI_FILE_INFO *FileInfo;
UINTN RequiredSize;
struct fsw_dnode_stat sb;
struct fsw_dnode *target_dno;
// make sure the dnode has complete info
Status = fsw_efi_map_status(fsw_dnode_fill(dno), Volume);
if (EFI_ERROR(Status))
return Status;
// TODO: check/assert that the dno's name is in UTF16
// check buffer size
RequiredSize = SIZE_OF_EFI_FILE_INFO + fsw_efi_strsize(&dno->name);
if (*BufferSize < RequiredSize) {
// TODO: wind back the directory in this case
#if DEBUG_LEVEL
Print(L"...BUFFER TOO SMALL\n");
#endif
*BufferSize = RequiredSize;
return EFI_BUFFER_TOO_SMALL;
}
// fill structure
ZeroMem(Buffer, RequiredSize);
FileInfo = (EFI_FILE_INFO *)Buffer;
// copy name before symlink resolving
fsw_efi_strcpy(FileInfo->FileName, &dno->name);
// resolve symlink if needed
Status = fsw_efi_map_status (fsw_dnode_resolve (dno, &target_dno), Volume);
if (EFI_ERROR (Status))
return Status;
// make sure the dnode has complete info
Status = fsw_efi_map_status(fsw_dnode_fill(dno), Volume);
if (EFI_ERROR(Status)) {
fsw_dnode_release (target_dno);
return Status;
}
fsw_dnode_release(dno);
dno = target_dno;
FileInfo->Size = RequiredSize;
FileInfo->FileSize = dno->size;
FileInfo->Attribute = 0;
if (dno->type == FSW_DNODE_TYPE_DIR)
FileInfo->Attribute |= EFI_FILE_DIRECTORY;
fsw_efi_strcpy(FileInfo->FileName, &dno->name);
// get the missing info from the fs driver
ZeroMem(&sb, sizeof(struct fsw_dnode_stat));
sb.store_time_posix = fsw_efi_store_time_posix;
sb.store_attr_posix = fsw_efi_store_attr_posix;
sb.host_data = FileInfo;
Status = fsw_efi_map_status(fsw_dnode_stat(dno, &sb), Volume);
if (EFI_ERROR(Status))
return Status;
FileInfo->PhysicalSize = sb.used_bytes;
// prepare for return
*BufferSize = RequiredSize;
#if DEBUG_LEVEL
Print(L"...returning '%s'\n", FileInfo->FileName);
#endif
return EFI_SUCCESS;
}
// EOF
|
415cfde252d1783d8eddac354a3fe0b093efc2a9
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/ffmpeg/libavdevice/sdl2.c
|
342a253dc09a95298246ed0d7c2a5bf0781cf84c
|
[
"BSD-3-Clause",
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"LGPL-2.1-only",
"LGPL-3.0-only",
"GPL-2.0-only",
"LGPL-2.1-or-later",
"GPL-3.0-or-later",
"LGPL-3.0-or-later",
"IJG",
"LicenseRef-scancode-other-permissive",
"GPL-2.0-or-later",
"GPL-3.0-only"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 13,215
|
c
|
sdl2.c
|
/*
* Copyright (c) 2016 Josh de Kock
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* libSDL2 output device
*/
#include <SDL.h>
#include <SDL_thread.h>
#include "libavutil/avstring.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/time.h"
#include "avdevice.h"
#include "libavformat/mux.h"
typedef struct {
AVClass *class;
SDL_Window *window;
SDL_Renderer *renderer;
char *window_title;
int window_width, window_height; /**< size of the window */
int window_x, window_y; /**< position of the window */
int window_fullscreen;
int window_borderless;
int enable_quit_action;
SDL_Texture *texture;
int texture_fmt;
SDL_Rect texture_rect;
int inited;
} SDLContext;
static const struct sdl_texture_format_entry {
enum AVPixelFormat format; int texture_fmt;
} sdl_texture_format_map[] = {
/*
* Not implemented in FFmpeg, but leaving here for completeness.
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ARGB4444 },
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_RGBA4444 },
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ABGR4444 },
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_BGRA4444 },
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ARGB1555 },
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_RGBA5551 },
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ABGR1555 },
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_BGRA5551 },
* { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ARGB2101010 },
*/
{ AV_PIX_FMT_RGB8, SDL_PIXELFORMAT_RGB332 },
{ AV_PIX_FMT_RGB444, SDL_PIXELFORMAT_RGB444 },
{ AV_PIX_FMT_RGB555, SDL_PIXELFORMAT_RGB555 },
{ AV_PIX_FMT_BGR555, SDL_PIXELFORMAT_BGR555 },
{ AV_PIX_FMT_RGB565, SDL_PIXELFORMAT_RGB565 },
{ AV_PIX_FMT_BGR565, SDL_PIXELFORMAT_BGR565 },
{ AV_PIX_FMT_RGB24, SDL_PIXELFORMAT_RGB24 },
{ AV_PIX_FMT_BGR24, SDL_PIXELFORMAT_BGR24 },
{ AV_PIX_FMT_0RGB32, SDL_PIXELFORMAT_RGB888 },
{ AV_PIX_FMT_0BGR32, SDL_PIXELFORMAT_BGR888 },
#if HAVE_BIGENDIAN
{ AV_PIX_FMT_RGB0, SDL_PIXELFORMAT_RGBX8888 },
{ AV_PIX_FMT_BGR0, SDL_PIXELFORMAT_BGRX8888 },
#else
{ AV_PIX_FMT_0BGR, SDL_PIXELFORMAT_RGBX8888 },
{ AV_PIX_FMT_0RGB, SDL_PIXELFORMAT_BGRX8888 },
#endif
{ AV_PIX_FMT_RGB32, SDL_PIXELFORMAT_ARGB8888 },
{ AV_PIX_FMT_RGB32_1, SDL_PIXELFORMAT_RGBA8888 },
{ AV_PIX_FMT_BGR32, SDL_PIXELFORMAT_ABGR8888 },
{ AV_PIX_FMT_BGR32_1, SDL_PIXELFORMAT_BGRA8888 },
{ AV_PIX_FMT_YUV420P, SDL_PIXELFORMAT_IYUV },
{ AV_PIX_FMT_YUYV422, SDL_PIXELFORMAT_YUY2 },
{ AV_PIX_FMT_UYVY422, SDL_PIXELFORMAT_UYVY },
{ AV_PIX_FMT_NONE, 0 },
};
static void compute_texture_rect(AVFormatContext *s)
{
AVRational sar, dar; /* sample and display aspect ratios */
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
AVCodecParameters *codecpar = st->codecpar;
SDL_Rect *texture_rect = &sdl->texture_rect;
/* compute texture width and height from the codec context information */
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
dar = av_mul_q(sar, (AVRational){ codecpar->width, codecpar->height });
/* we suppose the screen has a 1/1 sample aspect ratio */
if (sdl->window_width && sdl->window_height) {
/* fit in the window */
if (av_cmp_q(dar, (AVRational){ sdl->window_width, sdl->window_height }) > 0) {
/* fit in width */
texture_rect->w = sdl->window_width;
texture_rect->h = av_rescale(texture_rect->w, dar.den, dar.num);
} else {
/* fit in height */
texture_rect->h = sdl->window_height;
texture_rect->w = av_rescale(texture_rect->h, dar.num, dar.den);
}
} else {
if (sar.num > sar.den) {
texture_rect->w = codecpar->width;
texture_rect->h = av_rescale(texture_rect->w, dar.den, dar.num);
} else {
texture_rect->h = codecpar->height;
texture_rect->w = av_rescale(texture_rect->h, dar.num, dar.den);
}
sdl->window_width = texture_rect->w;
sdl->window_height = texture_rect->h;
}
texture_rect->x = (sdl->window_width - texture_rect->w) / 2;
texture_rect->y = (sdl->window_height - texture_rect->h) / 2;
}
static int sdl2_write_trailer(AVFormatContext *s)
{
SDLContext *sdl = s->priv_data;
if (sdl->texture)
SDL_DestroyTexture(sdl->texture);
sdl->texture = NULL;
if (sdl->renderer)
SDL_DestroyRenderer(sdl->renderer);
sdl->renderer = NULL;
if (sdl->window)
SDL_DestroyWindow(sdl->window);
sdl->window = NULL;
if (!sdl->inited)
SDL_Quit();
return 0;
}
static int sdl2_write_header(AVFormatContext *s)
{
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
AVCodecParameters *codecpar = st->codecpar;
int i, ret = 0;
int flags = 0;
if (!sdl->window_title)
sdl->window_title = av_strdup(s->url);
if (SDL_WasInit(SDL_INIT_VIDEO)) {
av_log(s, AV_LOG_WARNING,
"SDL video subsystem was already inited, you could have multiple SDL outputs. This may cause unknown behaviour.\n");
sdl->inited = 1;
}
if ( s->nb_streams > 1
|| codecpar->codec_type != AVMEDIA_TYPE_VIDEO
|| codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
goto fail;
}
for (i = 0; sdl_texture_format_map[i].format != AV_PIX_FMT_NONE; i++) {
if (sdl_texture_format_map[i].format == codecpar->format) {
sdl->texture_fmt = sdl_texture_format_map[i].texture_fmt;
break;
}
}
if (!sdl->texture_fmt) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s'.\n",
av_get_pix_fmt_name(codecpar->format));
goto fail;
}
/* resize texture to width and height from the codec context information */
flags = SDL_WINDOW_HIDDEN |
(sdl->window_fullscreen ? SDL_WINDOW_FULLSCREEN : 0) |
(sdl->window_borderless ? SDL_WINDOW_BORDERLESS : SDL_WINDOW_RESIZABLE);
/* initialization */
if (!sdl->inited){
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
av_log(s, AV_LOG_ERROR, "Unable to initialize SDL: %s\n", SDL_GetError());
goto fail;
}
}
compute_texture_rect(s);
if (SDL_CreateWindowAndRenderer(sdl->window_width, sdl->window_height,
flags, &sdl->window, &sdl->renderer) != 0){
av_log(sdl, AV_LOG_ERROR, "Couldn't create window and renderer: %s\n", SDL_GetError());
goto fail;
}
SDL_SetWindowTitle(sdl->window, sdl->window_title);
SDL_SetWindowPosition(sdl->window, sdl->window_x, sdl->window_y);
SDL_ShowWindow(sdl->window);
sdl->texture = SDL_CreateTexture(sdl->renderer, sdl->texture_fmt, SDL_TEXTUREACCESS_STREAMING,
codecpar->width, codecpar->height);
if (!sdl->texture) {
av_log(sdl, AV_LOG_ERROR, "Unable to set create mode: %s\n", SDL_GetError());
goto fail;
}
av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d\n",
codecpar->width, codecpar->height, av_get_pix_fmt_name(codecpar->format),
sdl->window_width, sdl->window_height);
sdl->inited = 1;
return 0;
fail:
sdl2_write_trailer(s);
return ret;
}
static int sdl2_write_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, quit = 0;
SDLContext *sdl = s->priv_data;
AVCodecParameters *codecpar = s->streams[0]->codecpar;
uint8_t *data[4];
int linesize[4];
SDL_Event event;
if (SDL_PollEvent(&event)){
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_ESCAPE:
case SDLK_q:
quit = 1;
break;
default:
break;
}
break;
case SDL_QUIT:
quit = 1;
break;
case SDL_WINDOWEVENT:
switch(event.window.event){
case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_SIZE_CHANGED:
sdl->window_width = event.window.data1;
sdl->window_height = event.window.data2;
compute_texture_rect(s);
break;
default:
break;
}
break;
default:
break;
}
}
if (quit && sdl->enable_quit_action) {
sdl2_write_trailer(s);
return AVERROR(EIO);
}
av_image_fill_arrays(data, linesize, pkt->data, codecpar->format, codecpar->width, codecpar->height, 1);
switch (sdl->texture_fmt) {
/* case SDL_PIXELFORMAT_ARGB4444:
* case SDL_PIXELFORMAT_RGBA4444:
* case SDL_PIXELFORMAT_ABGR4444:
* case SDL_PIXELFORMAT_BGRA4444:
* case SDL_PIXELFORMAT_ARGB1555:
* case SDL_PIXELFORMAT_RGBA5551:
* case SDL_PIXELFORMAT_ABGR1555:
* case SDL_PIXELFORMAT_BGRA5551:
* case SDL_PIXELFORMAT_ARGB2101010:
*/
case SDL_PIXELFORMAT_IYUV:
case SDL_PIXELFORMAT_YUY2:
case SDL_PIXELFORMAT_UYVY:
ret = SDL_UpdateYUVTexture(sdl->texture, NULL,
data[0], linesize[0],
data[1], linesize[1],
data[2], linesize[2]);
break;
case SDL_PIXELFORMAT_RGB332:
case SDL_PIXELFORMAT_RGB444:
case SDL_PIXELFORMAT_RGB555:
case SDL_PIXELFORMAT_BGR555:
case SDL_PIXELFORMAT_RGB565:
case SDL_PIXELFORMAT_BGR565:
case SDL_PIXELFORMAT_RGB24:
case SDL_PIXELFORMAT_BGR24:
case SDL_PIXELFORMAT_RGB888:
case SDL_PIXELFORMAT_RGBX8888:
case SDL_PIXELFORMAT_BGR888:
case SDL_PIXELFORMAT_BGRX8888:
case SDL_PIXELFORMAT_ARGB8888:
case SDL_PIXELFORMAT_RGBA8888:
case SDL_PIXELFORMAT_ABGR8888:
case SDL_PIXELFORMAT_BGRA8888:
ret = SDL_UpdateTexture(sdl->texture, NULL, data[0], linesize[0]);
break;
default:
av_log(NULL, AV_LOG_FATAL, "Unsupported pixel format\n");
ret = -1;
break;
}
SDL_RenderClear(sdl->renderer);
SDL_RenderCopy(sdl->renderer, sdl->texture, NULL, &sdl->texture_rect);
SDL_RenderPresent(sdl->renderer);
return ret;
}
#define OFFSET(x) offsetof(SDLContext,x)
static const AVOption options[] = {
{ "window_title", "set SDL window title", OFFSET(window_title), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
{ "window_size", "set SDL window forced size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
{ "window_x", "set SDL window x position", OFFSET(window_x), AV_OPT_TYPE_INT, { .i64 = SDL_WINDOWPOS_CENTERED }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ "window_y", "set SDL window y position", OFFSET(window_y), AV_OPT_TYPE_INT, { .i64 = SDL_WINDOWPOS_CENTERED }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ "window_fullscreen", "set SDL window fullscreen", OFFSET(window_fullscreen), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
{ "window_borderless", "set SDL window border off", OFFSET(window_borderless), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
{ "window_enable_quit", "set if quit action is available", OFFSET(enable_quit_action), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
};
static const AVClass sdl2_class = {
.class_name = "sdl2 outdev",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
.category = AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT,
};
const FFOutputFormat ff_sdl2_muxer = {
.p.name = "sdl,sdl2",
.p.long_name = NULL_IF_CONFIG_SMALL("SDL2 output device"),
.priv_data_size = sizeof(SDLContext),
.p.audio_codec = AV_CODEC_ID_NONE,
.p.video_codec = AV_CODEC_ID_RAWVIDEO,
.write_header = sdl2_write_header,
.write_packet = sdl2_write_packet,
.write_trailer = sdl2_write_trailer,
.p.flags = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS,
.p.priv_class = &sdl2_class,
};
|
d0dda7612edf0024a98771eb038db98cfe542381
|
b8906afecca06f48f2cd289a9997f670b26c4721
|
/platform/shared/ruby/missing/stdlib.c
|
93d46998add08f87cccffae87cebbcf5a9b2a192
|
[
"GPL-2.0-only",
"MIT"
] |
permissive
|
rhomobile/rhodes
|
51bd88921c51bd618948f9a557de17fc297e7cc2
|
fc8409c9c281684a49d7ff6805ddc565de09a6d5
|
refs/heads/master
| 2023-09-01T17:45:36.149868
| 2023-08-31T20:56:06
| 2023-08-31T20:56:06
| 54,084
| 504
| 155
|
MIT
| 2023-09-12T00:14:29
| 2008-09-18T21:55:16
|
C
|
UTF-8
|
C
| false
| false
| 125
|
c
|
stdlib.c
|
#ifdef OS_ANDROID
#include <sys/types.h>
int mblen(const char *mbstr, size_t count)
{
return 1;
}
#endif // OS_ANDROID
|
0120d47690ffb27bbd6df779886c25b80129e42e
|
da1500e0d3040497614d5327d2461a22e934b4d8
|
/third_party/llvm-project/compiler-rt/test/builtins/Unit/negvsi2_test.c
|
4e275210664bfdfd844cb18bc177b2a79c8cbdb6
|
[
"NCSA",
"MIT",
"LLVM-exception",
"Apache-2.0",
"BSD-3-Clause",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] |
permissive
|
youtube/cobalt
|
34085fc93972ebe05b988b15410e99845efd1968
|
acefdaaadd3ef46f10f63d1acae2259e4024d383
|
refs/heads/main
| 2023-09-01T13:09:47.225174
| 2023-09-01T08:54:54
| 2023-09-01T08:54:54
| 50,049,789
| 169
| 80
|
BSD-3-Clause
| 2023-09-14T21:50:50
| 2016-01-20T18:11:34
| null |
UTF-8
|
C
| false
| false
| 1,021
|
c
|
negvsi2_test.c
|
// RUN: %clang_builtins %s %librt -o %t && %run %t
// REQUIRES: librt_has_negvsi2
#include "int_lib.h"
#include <stdio.h>
// Returns: -a
// Effects: aborts if -a overflows
COMPILER_RT_ABI si_int __negvsi2(si_int a);
int test__negvsi2(si_int a)
{
si_int x = __negvsi2(a);
si_int expected = -a;
if (x != expected)
printf("error in __negvsi2(0x%X) = %d, expected %d\n", a, x, expected);
return x != expected;
}
int main()
{
// if (test__negvsi2(0x80000000)) // should abort
// return 1;
if (test__negvsi2(0x00000000))
return 1;
if (test__negvsi2(0x00000001))
return 1;
if (test__negvsi2(0x00000002))
return 1;
if (test__negvsi2(0x7FFFFFFE))
return 1;
if (test__negvsi2(0x7FFFFFFF))
return 1;
if (test__negvsi2(0x80000001))
return 1;
if (test__negvsi2(0x80000002))
return 1;
if (test__negvsi2(0xFFFFFFFE))
return 1;
if (test__negvsi2(0xFFFFFFFF))
return 1;
return 0;
}
|
4364f276f7d192858fd3fab246b85c0adcfdc925
|
59864cbd213b5da6f50d6255b0a021564b3d5bd4
|
/challenges/TextSearch/src/trex.c
|
bc00cd72de694315c0c5af83b3131767e951de72
|
[
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-unknown",
"BSD-2-Clause"
] |
permissive
|
trailofbits/cb-multios
|
8af96a4fbc3b34644367faa135347f88e0e0d0a3
|
810d7b24b1f62f56ef49b148fe155b0d0629cad2
|
refs/heads/master
| 2023-09-05T03:56:20.229403
| 2022-12-27T15:47:54
| 2022-12-27T15:47:54
| 41,688,943
| 522
| 133
|
MIT
| 2023-06-29T02:47:13
| 2015-08-31T17:04:31
|
C
|
UTF-8
|
C
| false
| false
| 6,374
|
c
|
trex.c
|
/*
* Copyright (c) 2014 Kaprica Security, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include "libcgc.h"
#include "cgc_stdarg.h"
#include "cgc_stdlib.h"
#include "cgc_string.h"
#include "cgc_trex.h"
#include "cgc_constants.h"
#define MAX_STATES 1000
static state_t **g_stack = NULL;
static int *g_states_checked = NULL;
static int *g_epsilon_loop = NULL;
static int g_state_length = 0;
static void cgc_debug_state_helper(state_t *state, int level) {
if (!state)
return;
int i;
unsigned char str[] = {0,0};
str[0] = state->input;
for (i = 0; i < g_state_length; i++)
if (g_states_checked[i] == state->id)
return;
g_states_checked[g_state_length++] = state->id;
for (i = 0; i < level; i++)
cgc_printf("---");
if(str[0] == EPSILON)
cgc_printf(">%d", state->id);
else
cgc_printf(">%s", str);
if (state->is_accepting_state)
cgc_printf("::Accepting State Id::%d", state->id);
cgc_printf("\n");
cgc_debug_state_helper(state->t1, level + 1);
cgc_debug_state_helper(state->t2, level + 1);
}
static int cgc_match_helper(state_t *state, unsigned char *str, int match_len, match_type_e match_type) {
if (!state)
return 0;
#ifdef PATCHED
if (g_epsilon_loop[state->id] > cgc_strlen(str))
#else
if (g_epsilon_loop[state->id] >= cgc_strlen(str))
#endif
g_epsilon_loop[state->id] = cgc_strlen(str);
else
return 0;
// Defaults to matching ALL
int len1 = 0, len2 = 0, step = 1, i;
if(state->input == EPSILON) {
step = 0;
if (match_type == PARTIAL) {
if(state->is_accepting_state && match_len)
return match_len;
} else if(!*str && state->is_accepting_state && match_len) {
return match_len;
}
} else if(*str == state->input) {
if (match_type == PARTIAL) {
if(state->is_accepting_state)
return match_len + 1;
} else if(!str[1] && state->is_accepting_state) {
return match_len + 1;
}
} else {
return 0;
}
if (match_type == PARTIAL)
if(state->is_accepting_state && match_len)
return match_len + 1;
len2 = cgc_match_helper(state->t2, str + step, match_len + step, match_type);
len1 = cgc_match_helper(state->t1, str + step, match_len + step, match_type);
return len1 >= len2 ? len1 : len2;
}
void cgc_debug_state(state_t *state)
{
if(g_states_checked == NULL)
g_states_checked = cgc_malloc(sizeof(int) * MAX_STATES);
g_state_length = 0;
return cgc_debug_state_helper(state, 0);
}
void cgc_match(state_t *state, unsigned char *str, match_type_e match_type)
{
int i, match_len = 0, end_of_str = 0;
unsigned char *tstr = cgc_malloc(cgc_strlen(str) + 1), *line = tstr, *tline = tstr, *ptstr = tstr;
cgc_memcpy(tstr, str, cgc_strlen(str) + 1);
if(g_epsilon_loop == NULL)
g_epsilon_loop = cgc_malloc(sizeof(int) * MAX_STATES);
while(!end_of_str) {
tstr++;
if (*tstr == '\n' || *tstr == '\0') {
end_of_str = *tstr ? 0 : 1;
*tstr = '\0';
while(!match_len && *tline) {
for (i = 0; i < MAX_STATES; i++)
g_epsilon_loop[i] = MAX_STATES;
match_len = cgc_match_helper(state, tline, 0, match_type);
if (match_len) {
cgc_printf("%s\n", line);
break;
} else if (match_type == ALL) {
break;
} else {
tline++;
}
}
match_len = 0;
line = ++tstr;
tline = line;
}
}
cgc_free(ptstr);
}
state_t *cgc_evalrpn(unsigned char *rpn) {
if (!g_stack)
g_stack = cgc_malloc(sizeof(state_t *) * MAX_STATES);
state_t **stack = g_stack;
state_t *temp_state;
state_t *arg1, *arg2;
for (; *rpn; rpn++ ) {
#ifdef PATCHED
temp_state = NULL;
#endif
switch (*rpn) {
default:
temp_state = cgc_create_state(*rpn);
break;
case CONCAT:
if (stack == g_stack) break;
POP(stack, arg2);
if (stack == g_stack) break;
POP(stack, arg1);
temp_state = cgc_op_concat(arg1, arg2);
break;
case UNION:
if (stack == g_stack) break;
POP(stack, arg2);
if (stack == g_stack) break;
POP(stack, arg1);
temp_state = cgc_op_union(arg1, arg2);
break;
case STAR:
if (stack == g_stack) break;
POP(stack, arg1);
temp_state = cgc_op_star(arg1);
break;
case QMARK:
if (stack == g_stack) break;
POP(stack, arg1);
temp_state = cgc_op_qmark(arg1);
break;
case PLUS:
if (stack == g_stack) break;
POP(stack, arg1);
temp_state = cgc_op_plus(arg1);
break;
}
if ( !temp_state )
goto failed;
PUSH(stack, temp_state);
}
if (stack == g_stack) goto failed;
POP(stack, arg1);
return arg1;
failed:
cgc_clear_trex();
return NULL;
}
|
e469ffb3b48267b8c42acfd2e70a987871467eda
|
bed3ac926beac0f4e0293303d7b2a6031ee476c9
|
/Modules/ThirdParty/TIFF/src/itktiff/tif_apple.c
|
087b1a59740002dd6f4516fd2a56e05570668743
|
[
"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
| 6,901
|
c
|
tif_apple.c
|
/* Header */
/*
* Copyright (c) 1988-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
/*
* TIFF Library Macintosh-specific routines.
*
* These routines use only Toolbox and high-level File Manager traps.
* They make no calls to the THINK C "unix" compatibility library. Also,
* malloc is not used directly but it is still referenced internally by
* the ANSI library in rare cases. Heap fragmentation by the malloc ring
* buffer is therefore minimized.
*
* O_RDONLY and O_RDWR are treated identically here. The tif_mode flag is
* checked in TIFFWriteCheck().
*
* Create below fills in a blank creator signature and sets the file type
* to 'TIFF'. It is much better for the application to do this by Create'ing
* the file first and TIFFOpen'ing it later.
* ---------
* This code has been "Carbonized", and may not work with older MacOS versions.
* If so, grab the tif_apple.c out of an older libtiff distribution, like
* 3.5.5 from www.libtiff.org.
*/
#include "tiffiop.h"
#include <Errors.h>
#include <Files.h>
#include <Memory.h>
#include <Script.h>
#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) || defined(applec)
#define CtoPstr c2pstr
#endif
static tsize_t
_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size)
{
return (FSRead((short) fd, (long*) &size, (char*) buf) == noErr ?
size : (tsize_t) -1);
}
static tsize_t
_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
{
return (FSWrite((short) fd, (long*) &size, (char*) buf) == noErr ?
size : (tsize_t) -1);
}
static toff_t
_tiffSeekProc(thandle_t fd, toff_t off, int whence)
{
long fpos, size;
if (GetEOF((short) fd, &size) != noErr)
return EOF;
(void) GetFPos((short) fd, &fpos);
switch (whence) {
case SEEK_CUR:
if (off + fpos > size)
SetEOF((short) fd, off + fpos);
if (SetFPos((short) fd, fsFromMark, off) != noErr)
return EOF;
break;
case SEEK_END:
if (off > 0)
SetEOF((short) fd, off + size);
if (SetFPos((short) fd, fsFromStart, off + size) != noErr)
return EOF;
break;
case SEEK_SET:
if (off > size)
SetEOF((short) fd, off);
if (SetFPos((short) fd, fsFromStart, off) != noErr)
return EOF;
break;
}
return (toff_t)(GetFPos((short) fd, &fpos) == noErr ? fpos : EOF);
}
static int
_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
{
return (0);
}
static void
_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size)
{
}
static int
_tiffCloseProc(thandle_t fd)
{
return (FSClose((short) fd));
}
static toff_t
_tiffSizeProc(thandle_t fd)
{
long size;
if (GetEOF((short) fd, &size) != noErr) {
TIFFError("_tiffSizeProc", "%s: Cannot get file size");
return (-1L);
}
return ((toff_t) size);
}
/*
* Open a TIFF file descriptor for read/writing.
*/
TIFF*
TIFFFdOpen(int fd, const char* name, const char* mode)
{
TIFF* tif;
tif = TIFFClientOpen(name, mode, (thandle_t) fd,
_tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc,
_tiffSizeProc, _tiffMapProc, _tiffUnmapProc);
if (tif)
tif->tif_fd = fd;
return (tif);
}
static void ourc2pstr( char* inString )
{
int sLen = strlen( inString );
BlockMoveData( inString, &inString[1], sLen );
inString[0] = sLen;
}
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
Str255 pname;
FInfo finfo;
short fref;
OSErr err;
FSSpec fSpec;
strcpy((char*) pname, name);
ourc2pstr((char*) pname);
err = FSMakeFSSpec( 0, 0, pname, &fSpec );
switch (_TIFFgetMode(mode, module)) {
default:
return ((TIFF*) 0);
case O_RDWR | O_CREAT | O_TRUNC:
if (FSpGetFInfo(&fSpec, &finfo) == noErr)
FSpDelete(&fSpec);
/* fall through */
case O_RDWR | O_CREAT:
if ((err = FSpGetFInfo(&fSpec, &finfo)) == fnfErr) {
if (FSpCreate(&fSpec, ' ', 'TIFF', smSystemScript) != noErr)
goto badCreate;
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
} else if (err == noErr) {
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
} else
goto badOpen;
break;
case O_RDONLY:
if (FSpOpenDF(&fSpec, fsRdPerm, &fref) != noErr)
goto badOpen;
break;
case O_RDWR:
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
break;
}
return (TIFFFdOpen((int) fref, name, mode));
badCreate:
TIFFError(module, "%s: Cannot create", name);
return ((TIFF*) 0);
badOpen:
TIFFError(module, "%s: Cannot open", name);
return ((TIFF*) 0);
}
void
_TIFFmemset(tdata_t p, int v, tsize_t c)
{
memset(p, v, (size_t) c);
}
void
_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
{
memcpy(d, s, (size_t) c);
}
int
_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
{
return (memcmp(p1, p2, (size_t) c));
}
tdata_t
_TIFFmalloc(tsize_t s)
{
return (NewPtr((size_t) s));
}
void
_TIFFfree(tdata_t p)
{
DisposePtr(p);
}
tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
Ptr n = p;
SetPtrSize(p, (size_t) s);
if (MemError() && (n = NewPtr((size_t) s)) != NULL) {
BlockMove(p, n, GetPtrSize(p));
DisposePtr(p);
}
return ((tdata_t) n);
}
static void
appleWarningHandler(const char* module, const char* fmt, va_list ap)
{
if (module != NULL)
fprintf(stderr, "%s: ", module);
fprintf(stderr, "Warning, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFwarningHandler = appleWarningHandler;
static void
appleErrorHandler(const char* module, const char* fmt, va_list ap)
{
if (module != NULL)
fprintf(stderr, "%s: ", module);
vfprintf(stderr, fmt, ap);
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFerrorHandler = appleErrorHandler;
|
4ff357710281d9d137f4ef3f28b492662a48ff70
|
75196819c910f3fd523f1a4d28e5d0fe12570ab1
|
/src/bdb53/test/xa/src2/client.c
|
eee8b038f0208c7bfd42db38f9b7bf87193de11c
|
[
"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,996
|
c
|
client.c
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
*/
/*
* This client is part of Test 2 of the XA test suite. It calls bdb1, which
* in turn calls bdb2. In the test several clients are executed at once to test
* how XA performs with multiple processes.
*/
#include <stdio.h>
#include <string.h>
#include "atmi.h" /* TUXEDO Header File */
#include "../utilities/bdb_xa_util.h"
void my_exit();
char *sendbuf, *rcvbuf;
void
my_exit(string)
char *string;
{
tpfree(sendbuf);
tpfree(rcvbuf);
fprintf(stderr,"SIMPAPP:ERROR call to service %s failed \n",string);
tpterm();
exit(1);
}
int
main(argc, argv)
int argc;
char *argv[];
{
extern char *optarg;
char * msg = NULL;
TPQCTL qctl; /* Q control structures */
long sendlen=10, rcvlen=10, len;
int ret;
char ch;
char * service;
int times = 1;
int i;
int delete = 0;
int need_print = 0;
int nostop =0;
if(argc < 5) {
fprintf(stderr,
"Usage: %s -s service -m messgae [-t times][-d][-p]\n",
argv[0] );
exit(1);
}
while ((ch = getopt(argc, argv, "s:m:t:dpn")) != EOF)
switch (ch) {
case 's':
service = optarg;
break;
case 'm':
msg = optarg;
break;
case 't':
times = atoi(optarg);
break;
case 'd':
delete = 1;
break;
case 'n':
nostop = 1;
break;
}
/* Attach to System/T as a Client Process */
if (tpinit((TPINIT *) NULL) == -1) {
userlog("SIMPAPP:ERROR tpinit failed \n");
userlog("SIMPAPP:SYSTEM ERROR %s \n", tpstrerror(tperrno));
fprintf(stderr, "Simpapp:ERROR Tpinit failed\n");
my_exit("tpinit");
}
if(msg){
sendlen = strlen(msg);
}
/* Allocate STRING buffers for the request and the reply */
if((sendbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
fprintf(stderr,"Simpapp:ERRROR Allocating send buffer\n");
tpterm();
my_exit("tpalloc");
}
if((rcvbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
fprintf(stderr,"Simpapp:ERROR allocating receive buffer\n");
tpfree(sendbuf);
tpterm();
my_exit("tpalloc");
}
strcpy(sendbuf, msg);
for(i=0; i<times; i++){
ret = tpcall(service, sendbuf, 0, &rcvbuf, &rcvlen,(long)0);
if(ret == -1) {
fprintf(stderr,"Simapp:ERROR tpacall to service %s \n",
service);
userlog("SIMPAPP:SYSTEM ERROR %s \n",
tpstrerror(tperrno));
if(nostop && (tperrno != TPENOENT))
continue;
else
my_exit("WRITE");
}
if(verbose) printf("Simpapp: Returned string from : %s\n",
rcvbuf);
if(!delete) continue;
memset(&qctl, '\0', sizeof(qctl));
if (tpdequeue("QSPACE", "MYQUE", (TPQCTL *)&qctl,
(char **)&rcvbuf, &len, TPNOTIME) == -1)
{
userlog("QM diagnostic %ld\n", qctl.diagnostic);
my_exit("queue");
}
else if(verbose){
printf("Simpapp: get string from queue : %s\n", rcvbuf);
}
}
/* Free Buffers & Detach from System/T */
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
exit(0);
}
|
49ba08da00a0bda7f29e015c838ab19cf81fc4da
|
0cc343d927d5db6693006018986715c43acab961
|
/examples/busywaiting/clhlock/clhlock.h
|
ca7b30113dc19b8e1b3f7d1ae8f16816427234d9
|
[
"MIT"
] |
permissive
|
verifast/verifast
|
ec0101fc4a69bd33c5f66be4444169c4e060ead8
|
d152da790c7ebf72ce616533a6c83082629adbdb
|
refs/heads/master
| 2023-08-25T00:13:51.464802
| 2023-08-13T10:00:00
| 2023-08-13T10:00:00
| 14,519,163
| 325
| 64
|
NOASSERTION
| 2023-08-10T21:16:08
| 2013-11-19T08:57:02
|
OCaml
|
UTF-8
|
C
| false
| false
| 2,400
|
h
|
clhlock.h
|
#ifndef CLHLOCK_H
#define CLHLOCK_H
#include "../busywaiting.h"
struct lock;
struct lock_thread;
/*@
predicate lock(struct lock *lock, list<int> level, predicate() inv;);
predicate lock_thread(struct lock_thread *thread);
predicate locked(struct lock_thread *thread, struct lock *lock, list<int> level, predicate() inv, real frac, pair<void *, list<int> > ob);
@*/
struct lock *create_lock();
//@ requires exists<list<int> >(?level) &*& exists<predicate()>(?inv) &*& inv();
//@ ensures lock(result, level, inv);
//@ terminates;
struct lock_thread *create_lock_thread();
//@ requires true;
//@ ensures lock_thread(result);
//@ terminates;
void acquire(struct lock_thread *thread, struct lock *lock);
//@ requires obs(?p, ?obs) &*& lock_thread(thread) &*& [?frac]lock(lock, ?level, ?inv) &*& forall(map(snd, obs), (level_lt)(level)) == true;
//@ ensures locked(thread, lock, level, inv, frac, ?ob) &*& inv() &*& obs(?p1, cons(ob, obs)) &*& is_ancestor_of(p, p1) == true &*& level_of(ob) == level;
//@ terminates;
void release(struct lock_thread *thread);
//@ requires locked(thread, ?lock, ?level, ?inv, ?frac, ?ob) &*& inv() &*& obs(?p, ?obs) &*& mem(ob, obs) == true;
//@ ensures obs(?p1, remove(ob, obs)) &*& lock_thread(thread) &*& [frac]lock(lock, level, inv) &*& is_ancestor_of(p, p1) == true;
//@ terminates;
/*@
typedef lemma void release_ghost_op(int threadId, predicate() inv, list<pathcomp> p, list<pair<void *, list<int> > > obs, predicate() pre, predicate(list<pathcomp>) post)();
requires obs(?p1, obs) &*& pre() &*& currentThread == threadId &*& is_ancestor_of(p, p1) == true;
ensures obs(p1, obs) &*& inv() &*& post(p1);
@*/
void release_with_ghost_op(struct lock_thread *thread);
//@ requires locked(thread, ?lock, ?level, ?inv, ?frac, ?ob) &*& obs(?p, ?obs) &*& mem(ob, obs) == true &*& is_release_ghost_op(_, currentThread, inv, p, remove(ob, obs), ?pre, ?post) &*& pre();
//@ ensures post(?p1) &*& obs(?p2, remove(ob, obs)) &*& lock_thread(thread) &*& [frac]lock(lock, level, inv) &*& is_ancestor_of(p1, p2) == true;
//@ terminates;
void dispose_lock_thread(struct lock_thread *thread);
//@ requires lock_thread(thread);
//@ ensures true;
//@ terminates;
void dispose_lock(struct lock *lock);
//@ requires lock(lock, ?level, ?inv);
//@ ensures inv();
//@ terminates;
#endif
|
5c733e638253129db6f584867c3c69e35ff5914a
|
3aaa073883848add281af28204826a8a30c16ea7
|
/src/flash_samd21.c
|
04348aced851eb2941010f5186f4ed1d20505d9e
|
[
"MIT",
"LicenseRef-scancode-other-permissive"
] |
permissive
|
microsoft/uf2-samdx1
|
87602735c7eac7b1c046ea93640c9f41364787cb
|
4c900345561949f1c37a367d72eb8e420b01f72f
|
refs/heads/master
| 2023-09-02T17:00:41.918304
| 2023-06-06T16:52:20
| 2023-06-06T16:52:20
| 74,169,458
| 160
| 103
|
NOASSERTION
| 2023-06-06T16:52:22
| 2016-11-18T21:55:23
|
C
|
UTF-8
|
C
| false
| false
| 3,313
|
c
|
flash_samd21.c
|
#include "uf2.h"
// this actually generates less code than a function
#define wait_ready() \
while (NVMCTRL->INTFLAG.bit.READY == 0) \
;
void flash_erase_row(uint32_t *dst) {
wait_ready();
NVMCTRL->STATUS.reg = NVMCTRL_STATUS_MASK;
// Execute "ER" Erase Row
NVMCTRL->ADDR.reg = (uint32_t)dst / 2;
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_ER;
wait_ready();
}
void flash_erase_to_end(uint32_t *start_address) {
// Note: the flash memory is erased in ROWS, that is in
// block of 4 pages.
// Even if the starting address is the last byte
// of a ROW the entire
// ROW is erased anyway.
uint32_t dst_addr = (uint32_t) start_address; // starting address
while (dst_addr < FLASH_SIZE) {
flash_erase_row((void *)dst_addr);
dst_addr += FLASH_ROW_SIZE;
}
}
void copy_words(uint32_t *dst, uint32_t *src, uint32_t n_words) {
while (n_words--)
*dst++ = *src++;
}
void flash_write_words(uint32_t *dst, uint32_t *src, uint32_t n_words) {
// Set automatic page write
NVMCTRL->CTRLB.bit.MANW = 0;
while (n_words > 0) {
uint32_t len = (FLASH_PAGE_SIZE >> 2) < n_words ? (FLASH_PAGE_SIZE >> 2) : n_words;
n_words -= len;
// Execute "PBC" Page Buffer Clear
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC;
wait_ready();
// make sure there are no other memory writes here
// otherwise we get lock-ups
while (len--)
*dst++ = *src++;
// Execute "WP" Write Page
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_WP;
wait_ready();
}
}
void flash_write(void) {
uint32_t *src = (void *)0x20006000;
uint32_t *dst = (void *)*src++;
uint32_t n_rows = *src++;
NVMCTRL->CTRLB.bit.MANW = 1;
while (n_rows--) {
wait_ready();
NVMCTRL->STATUS.reg = NVMCTRL_STATUS_MASK;
// Execute "ER" Erase Row
NVMCTRL->ADDR.reg = (uint32_t)dst / 2;
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_ER;
wait_ready();
// there are 4 pages to a row
for (int i = 0; i < 4; ++i) {
// Execute "PBC" Page Buffer Clear
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC;
wait_ready();
uint32_t len = FLASH_PAGE_SIZE >> 2;
while (len--)
*dst++ = *src++;
// Execute "WP" Write Page
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_WP;
wait_ready();
}
}
}
// Skip writing blocks that are identical to the existing block.
// only disable for debugging/timing
#define QUICK_FLASH 1
void flash_write_row(uint32_t *dst, uint32_t *src) {
#if QUICK_FLASH
bool src_different = false;
for (int i = 0; i < FLASH_ROW_SIZE / 4; ++i) {
if (src[i] != dst[i]) {
src_different = true;
break;
}
}
if (!src_different) {
return;
}
#endif
flash_erase_row(dst);
flash_write_words(dst, src, FLASH_ROW_SIZE / 4);
}
|
cd5de952a9ca4478a63b10278b534fcff3657f14
|
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
|
/lib/libc/include/wasm-wasi-musl/__header_sys_ioctl.h
|
f2cf4ee73da0ec186ead8fd2ffb5721c8c972eea
|
[
"MIT"
] |
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
| 222
|
h
|
__header_sys_ioctl.h
|
#ifndef __wasilibc___header_sys_ioctl_h
#define __wasilibc___header_sys_ioctl_h
#define FIONREAD 1
#define FIONBIO 2
#ifdef __cplusplus
extern "C" {
#endif
int ioctl(int, int, ...);
#ifdef __cplusplus
}
#endif
#endif
|
bdee6464da37697def1e153209d813928694ecb8
|
f79dec3c4033ca3cbb55d8a51a748cc7b8b6fbab
|
/lang/python35/patches/patch-Modules_socketmodule.c
|
46f40438c9f03ced97248fcb14e836118803a009
|
[] |
no_license
|
jsonn/pkgsrc
|
fb34c4a6a2d350e8e415f3c4955d4989fcd86881
|
c1514b5f4a3726d90e30aa16b0c209adbc276d17
|
refs/heads/trunk
| 2021-01-24T09:10:01.038867
| 2017-07-07T15:49:43
| 2017-07-07T15:49:43
| 2,095,004
| 106
| 47
| null | 2016-09-19T09:26:01
| 2011-07-23T23:49:04
|
Makefile
|
UTF-8
|
C
| false
| false
| 2,469
|
c
|
patch-Modules_socketmodule.c
|
$NetBSD: patch-Modules_socketmodule.c,v 1.1 2017/05/30 14:04:54 bouyer Exp $
Support NetBSD's socketcan implementation
--- Modules/socketmodule.c.orig 2017-01-17 08:57:53.000000000 +0100
+++ Modules/socketmodule.c 2017-05-30 15:43:04.200284076 +0200
@@ -1346,8 +1346,13 @@
/* need to look up interface name given index */
if (a->can_ifindex) {
ifr.ifr_ifindex = a->can_ifindex;
+#ifdef __NetBSD__
+ if (if_indextoname(a->can_ifindex, ifr.ifr_name) != NULL)
+ ifname = ifr.ifr_name;
+#else
if (ioctl(sockfd, SIOCGIFNAME, &ifr) == 0)
ifname = ifr.ifr_name;
+#endif /* __NetBSD__ */
}
return Py_BuildValue("O&h", PyUnicode_DecodeFSDefault,
@@ -1834,12 +1839,14 @@
}
#endif
-#if defined(AF_CAN) && defined(CAN_RAW) && defined(CAN_BCM)
+#if defined(AF_CAN) && defined(CAN_RAW)
case AF_CAN:
switch (s->sock_proto) {
case CAN_RAW:
+#ifdef CAN_BCM
/* fall-through */
case CAN_BCM:
+#endif
{
struct sockaddr_can *addr;
PyObject *interfaceName;
@@ -1859,7 +1866,12 @@
} else if ((size_t)len < sizeof(ifr.ifr_name)) {
strncpy(ifr.ifr_name, PyBytes_AS_STRING(interfaceName), sizeof(ifr.ifr_name));
ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0';
- if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0) {
+#ifdef __NetBSD__
+ if ((ifr.ifr_ifindex = if_nametoindex(ifr.ifr_name)) == 0)
+#else
+ if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0)
+#endif
+ {
s->errorhandler();
Py_DECREF(interfaceName);
return 0;
@@ -6688,6 +6700,20 @@
PyModule_AddIntConstant(m, "CAN_BCM_RX_TIMEOUT", RX_TIMEOUT);
PyModule_AddIntConstant(m, "CAN_BCM_RX_CHANGED", RX_CHANGED);
#endif
+#ifdef HAVE_NETCAN_CAN_H
+ PyModule_AddIntMacro(m, CAN_EFF_FLAG);
+ PyModule_AddIntMacro(m, CAN_RTR_FLAG);
+ PyModule_AddIntMacro(m, CAN_ERR_FLAG);
+
+ PyModule_AddIntMacro(m, CAN_SFF_MASK);
+ PyModule_AddIntMacro(m, CAN_EFF_MASK);
+ PyModule_AddIntMacro(m, CAN_ERR_MASK);
+
+ PyModule_AddIntMacro(m, CAN_RAW_FILTER);
+ /* PyModule_AddIntMacro(m, CAN_RAW_ERR_FILTER); */
+ PyModule_AddIntMacro(m, CAN_RAW_LOOPBACK);
+ PyModule_AddIntMacro(m, CAN_RAW_RECV_OWN_MSGS);
+#endif
#ifdef SOL_RDS
PyModule_AddIntMacro(m, SOL_RDS);
#endif
|
a71fe45b1f7a818faca3c3d560383ff7d698d21a
|
544a8f2110fc156ec0bc7554e3857cc1b431084f
|
/rad1olib/spi-flash.c
|
928dbfc232793e9010d41cc066f203f946875f09
|
[] |
no_license
|
rad1o/f1rmware
|
7288bf3714f12da7829008853e011ce5b32c673c
|
eda4f0b9095be4dabb8476de9cef21d9614f16fb
|
refs/heads/master
| 2022-11-03T20:20:30.220203
| 2022-10-26T20:01:13
| 2022-10-26T20:01:31
| 37,091,288
| 190
| 135
| null | 2022-10-26T19:57:25
| 2015-06-08T20:34:46
|
C
|
UTF-8
|
C
| false
| false
| 8,776
|
c
|
spi-flash.c
|
#include <rad1olib/spi-flash.h>
#include <rad1olib/pins.h>
#include <rad1olib/setup.h>
#include <rad1olib/assert.h>
#include <libopencm3/lpc43xx/rgu.h>
#include <libopencm3/lpc43xx/cgu.h>
#include <libopencm3/lpc43xx/scu.h>
#include <libopencm3/lpc43xx/spifi.h>
#include <r0ketlib/print.h>
#include <r0ketlib/itoa.h>
#define FLASH_SECTOR_SIZE 4096
/* opc datalen, dout, fieldform, intlen, frameform */
/* 0: serial 1: op only */
/* 1: q data 2: op + 1 */
/* 2: op serial 3: op + 2 */
/* 4: op + 3 */
#define OP_WRITE_ENABLE 0x06, 0, 0, 0, 0, 1
#define OP_READ_S1 0x05, 1, 0, 0, 0, 1
#define OP_READ_S2 0x35, 1, 0, 0, 0, 1
#define OP_WRITE_ST 0x01, 2, 1, 0, 0, 1
#define OP_READ 0x0B, /*x*/0, 0, 0, 1, 1+3
#define OP_QREAD 0xEB, /*x*/0, 0, 2, 3, 1+3
#define OP_QREAD_2 0xE7, /*x*/0, 0, 2, 2, 1+3
#define OP_QREAD_8 0xE3, /*x*/0, 0, 2, 1, 1+3
#define OP_PROGRAM 0x02, /*x*/0, 1, 0, 0, 1+3
#define OP_QPROGRAM 0x32, /*x*/0, 1, 1, 0, 1+3
#define OP_SECT_ERASE_4K 0x20, 0, 0, 0, 0, 1+3
#define OP_SECT_ERASE_32K 0x52, 0, 0, 0, 0, 1+3
#define OP_SECT_ERASE_64K 0xD8, 0, 0, 0, 0, 1+3
#define OP_CHIP_ERASE 0xC7, 0, 0, 0, 0, 1
#define OP_DEVICE_ID 0x92, 2, 0, 0, 1, 1+3
#define OP_DEVICE_ID_Q 0x94, 2, 0, 2, 3, 1+3
#define OP_UNIQUE_ID 0x4B, 8, 0, 0, 4, 1
#define OP_JEDEC_ID 0x9F, 3, 0, 0, 0, 1
#define MK_SPIFI_CMD_2(opcode,datalen,dout,fieldform,intlen,frameform) \
SPIFI_CMD_DATALEN(datalen) | \
SPIFI_CMD_DOUT(dout) | \
SPIFI_CMD_FIELDFORM(fieldform) | \
SPIFI_CMD_INTLEN(intlen) | \
SPIFI_CMD_FRAMEFORM(frameform) | \
SPIFI_CMD_OPCODE(opcode)
#define MK_SPIFI_CMD(args...) MK_SPIFI_CMD_2(args)
static void wait_spifi(void){
while ((SPIFI_STAT & SPIFI_STAT_CMD_MASK) >0){
delayNop(10); //_WFI();
};
}
void flash_wait_write(){
while (flash_status1() & S1_BUSY){
delayNop(10); // _WFI();
};
}
uint8_t flash_status1(void){
uint8_t data;
SPIFI_CMD = MK_SPIFI_CMD(OP_READ_S1);
data = SPIFI_DATA_BYTE;
wait_spifi();
return data;
}
uint8_t flash_status2(void){
uint8_t data;
SPIFI_CMD = MK_SPIFI_CMD(OP_READ_S2);
data = SPIFI_DATA_BYTE;
wait_spifi();
return data;
};
void flashInit(void){
RESET_CTRL1 = RESET_CTRL1_SPIFI_RST;
/* Init SPIFI */
SETUPpin(SPIFI_SCK);
SETUPpin(SPIFI_SIO3);
SETUPpin(SPIFI_SIO2);
SETUPpin(SPIFI_MISO);
SETUPpin(SPIFI_MOSI);
SETUPpin(SPIFI_CS);
/* DIVC is expexted to be at 68 MHz.
the flash could go up to 104, but that produces bit errors */
CGU_BASE_SPIFI_CLK = CGU_BASE_SPIFI_CLK_CLK_SEL(CGU_SRC_IDIVC);
/* config SPIFI, use defaults */
SPIFI_CTRL = SPIFI_CTRL_TIMEOUT(0xffff)|SPIFI_CTRL_CSHIGH(0xf)|SPIFI_CTRL_FBCLK(1);
if (!(flash_status2()&S2_QE)){ /* make sure Quad Enable is set */
flash_write_enable();
SPIFI_CMD = MK_SPIFI_CMD(OP_WRITE_ST);
SPIFI_DATA_BYTE = 0; /* S1 */
SPIFI_DATA_BYTE = S2_QE; /* S2 */
wait_spifi();
};
}
void flash_read(uint32_t addr, uint32_t len, uint8_t * data){
uint32_t idx=0;
SPIFI_ADDR = addr;
// SPIFI_IDATA= 0x0; /* We actually don't care about these bits */
SPIFI_CMD = MK_SPIFI_CMD(OP_QREAD) | SPIFI_CMD_DATALEN(len);
while (idx<len){
data[idx++] = SPIFI_DATA_BYTE;
}
wait_spifi();
};
void flash_read_sector(uint32_t addr, uint32_t * data){
uint32_t idx=0;
SPIFI_ADDR = addr & ~(FLASH_SECTOR_SIZE-1);
SPIFI_CMD = MK_SPIFI_CMD(OP_QREAD_8) | SPIFI_CMD_DATALEN(FLASH_SECTOR_SIZE);
while (idx<FLASH_SECTOR_SIZE/sizeof(uint32_t)){
data[idx++] = SPIFI_DATA;
}
wait_spifi();
}
void flash_write_enable(void){
SPIFI_CMD = MK_SPIFI_CMD(OP_WRITE_ENABLE);
wait_spifi();
};
void flash_program(uint32_t addr, uint32_t len, const uint8_t * data){
uint32_t idx=0;
flash_write_enable();
SPIFI_ADDR = addr;
SPIFI_CMD = MK_SPIFI_CMD(OP_QPROGRAM)|SPIFI_CMD_DATALEN(len);
while (idx<len){
SPIFI_DATA_BYTE = data[idx++];
}
wait_spifi();
}
#define FLASH_PROGRAM_SIZE 256
void flash_random_program(uint32_t addr, uint32_t len, const uint8_t * data){
uint16_t cut=0;
uint16_t offset = addr & (FLASH_PROGRAM_SIZE-1);
/*
lcdPrint("p:");
lcdPrint(IntToStr(addr,8,F_HEX));
lcdPrint(" ");
lcdPrint(IntToStr(len,4,F_HEX));
lcdPrintln(" ");
lcdPrint("-:");
lcdPrint(IntToStr(data,8,F_HEX));
lcdPrint(" ");
lcdPrint(IntToStr(data[0],2,F_HEX));
lcdPrintln(" ");
lcdDisplay(); */
while (offset+len> FLASH_PROGRAM_SIZE){
cut=FLASH_PROGRAM_SIZE-offset;
flash_program(addr,cut,data);
flash_wait_write();
addr+=cut;
offset=0;
len-=cut;
data+=cut;
};
flash_program(addr,cut,data);
flash_wait_write();
}
void flash_program4(uint32_t addr, uint16_t len, const uint32_t * data){
uint32_t idx=0;
flash_write_enable();
SPIFI_ADDR = addr;
SPIFI_CMD = MK_SPIFI_CMD(OP_QPROGRAM)|SPIFI_CMD_DATALEN(len);
while (idx<len){
SPIFI_DATA = data[idx++];
}
wait_spifi();
};
void flash_usb_program(uint32_t addr, uint16_t len, const uint8_t * data){
ASSERT(addr%FLASH_PROGRAM_SIZE==0);
ASSERT(((uintptr_t)data)%4==0);
ASSERT(len==512);
flash_program4(addr,
FLASH_PROGRAM_SIZE/sizeof(uint32_t),
(uint32_t *)data);
flash_program4(addr+FLASH_PROGRAM_SIZE,
FLASH_PROGRAM_SIZE/sizeof(uint32_t),
(uint32_t *)(data+FLASH_PROGRAM_SIZE));
};
void flash_erase(uint32_t addr){ /* erase 4k sector */
flash_write_enable();
SPIFI_ADDR = addr;
SPIFI_CMD = MK_SPIFI_CMD(OP_SECT_ERASE_4K);
wait_spifi();
}
#define gran uint32_t
/* read/modify/write a FLASH_SECTOR_SIZE sector. len should be multiple of 256 */
void flash_write_sector(uint32_t addr, uint16_t len, gran * data){
uint32_t cache[FLASH_SECTOR_SIZE/sizeof(gran)]; /* maybe Assert SP */
uint16_t offset = addr&(FLASH_SECTOR_SIZE-1);
uint16_t idx;
uint8_t program_needed=0;
uint8_t erase_needed=0;
addr &= ~(FLASH_SECTOR_SIZE-1);
len /= sizeof(gran);
flash_read_sector(addr,cache);
for(idx=0;idx<len;idx++){
if (~cache[idx+offset] & data[idx]){
erase_needed=1;
break;
};
if (cache[idx+offset] != data[idx]){
program_needed=1;
};
};
if (erase_needed){
program_needed=0;
flash_erase(addr);
for(idx=0;idx<FLASH_SECTOR_SIZE/sizeof(gran);idx++){
if(idx>=offset && idx <offset+len){
cache[idx]=data[idx-offset];
};
if (cache[idx]!= ~((gran)0)){
program_needed=1;
};
};
flash_wait_write();
if(program_needed){
flash_program4(addr, FLASH_SECTOR_SIZE/sizeof(gran), cache);
flash_wait_write();
};
}else{
if(program_needed){
flash_program4(addr+offset,len,data);
flash_wait_write();
};
};
}
#undef gran
void flash_write(uint32_t addr, uint16_t len, const uint8_t * data){
/* assumes buffer does not straddle sector boundary */
uint8_t cache[FLASH_SECTOR_SIZE]; /* maybe Assert SP */
uint16_t offset = addr&(FLASH_SECTOR_SIZE-1);
uint16_t idx;
uint8_t program_needed=0;
uint8_t erase_needed=0;
addr &= ~(FLASH_SECTOR_SIZE-1);
flash_read(addr,FLASH_SECTOR_SIZE,cache);
for(idx=0;idx<len;idx++){
if (~cache[idx+offset] & data[idx]){
erase_needed=1;
break;
};
if (cache[idx+offset] != data[idx]){
program_needed=1;
};
};
/* lcdPrint("P:");
lcdPrint(IntToStr(addr,8,F_HEX));
lcdPrint(" ");
lcdPrint(IntToStr(len,4,F_HEX));
lcdPrintln(" ");
lcdPrint("+:");
lcdPrint(IntToStr(data,8,F_HEX));
lcdPrint(" ");
lcdPrint(IntToStr(data[0],2,F_HEX));
lcdPrintln(" ");
lcdDisplay(); */
if (erase_needed){
program_needed=0;
flash_erase(addr);
for(idx=0;idx<FLASH_SECTOR_SIZE;idx++){
if(idx>=offset && idx <offset+len){
cache[idx]=data[idx-offset];
};
if (cache[idx]!= ~((uint8_t)0)){
program_needed=1;
};
};
flash_wait_write();
if(program_needed){
flash_random_program(addr, FLASH_SECTOR_SIZE, cache);
flash_wait_write();
};
}else{
if(program_needed){
flash_random_program(addr+offset,len,data);
flash_wait_write();
};
};
}
void flash_random_write(uint32_t addr, uint16_t len, const uint8_t * data){
uint16_t offset = addr&(FLASH_SECTOR_SIZE-1);
uint16_t cut;
while(offset+len > FLASH_SECTOR_SIZE){
cut=FLASH_SECTOR_SIZE-offset;
flash_write(addr,cut,data);
addr+=cut;
offset=0;
len-=cut;
data+=cut;
};
flash_write(addr,len,data);
};
|
f5b3eeb198af860d0cddc5231d0a041d0dbc10ef
|
e73547787354afd9b717ea57fe8dd0695d161821
|
/src/world/area_dgb/dgb_10/dgb_10_2_main.c
|
68a099ffd2fda35d8c7f4e5c0f71574e95764e60
|
[] |
no_license
|
pmret/papermario
|
8b514b19653cef8d6145e47499b3636b8c474a37
|
9774b26d93f1045dd2a67e502b6efc9599fb6c31
|
refs/heads/main
| 2023-08-31T07:09:48.951514
| 2023-08-21T18:07:08
| 2023-08-21T18:07:08
| 287,151,133
| 904
| 139
| null | 2023-09-14T02:44:23
| 2020-08-13T01:22:57
|
C
|
UTF-8
|
C
| false
| false
| 2,309
|
c
|
dgb_10_2_main.c
|
#include "dgb_10.h"
EvtScript N(EVS_ExitWalk_dgb_09_3) = EVT_EXIT_WALK(40, dgb_10_ENTRY_0, "dgb_09", dgb_09_ENTRY_3);
EvtScript N(EVS_BindExitTriggers) = {
EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExitWalk_dgb_09_3)), TRIGGER_FLOOR_ABOVE, COLLIDER_deilis, 1, 0)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_EnterMap) = {
EVT_CALL(GetEntryID, LVar0)
EVT_SWITCH(LVar0)
EVT_CASE_EQ(dgb_10_ENTRY_0)
EVT_SET(LVar0, EVT_PTR(N(EVS_BindExitTriggers)))
EVT_EXEC(EnterWalk)
EVT_WAIT(1)
EVT_CASE_EQ(dgb_10_ENTRY_1)
EVT_CALL(UseSettingsFrom, CAM_DEFAULT, 375, 0, -188)
EVT_CALL(SetPanTarget, CAM_DEFAULT, 375, 0, -188)
EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
EVT_CALL(DisablePlayerInput, TRUE)
EVT_CALL(DisablePlayerPhysics, TRUE)
EVT_CALL(SetPlayerActionState, ACTION_STATE_JUMP)
EVT_WAIT(1)
EVT_CALL(SetPlayerJumpscale, EVT_FLOAT(0.7))
EVT_CALL(PlayerJump, 375, 0, -188, 20)
EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 0)
EVT_CALL(DisablePlayerPhysics, FALSE)
EVT_CALL(DisablePlayerInput, FALSE)
EVT_CALL(SetPlayerActionState, ACTION_STATE_IDLE)
EVT_EXEC(N(EVS_BindExitTriggers))
EVT_END_SWITCH
EVT_RETURN
EVT_END
};
EvtScript N(EVS_Main) = {
EVT_SET(GB_WorldLocation, LOCATION_TUBBAS_MANOR)
EVT_CALL(SetSpriteShading, SHADING_NONE)
EVT_SETUP_CAMERA_ALT_NO_LEAD()
EVT_EXEC_WAIT(N(EVS_MakeEntities))
EVT_EXEC(N(EVS_SetupHoles))
EVT_EXEC(N(EVS_SetupMusic))
EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilits, COLLIDER_FLAGS_UPPER_MASK)
EVT_CALL(EnableModel, MODEL_o117, FALSE)
EVT_CALL(EnableModel, MODEL_o116, FALSE)
EVT_CALL(EnableModel, MODEL_o113, FALSE)
EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilitt1, COLLIDER_FLAGS_UPPER_MASK)
EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilitt2, COLLIDER_FLAGS_UPPER_MASK)
EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilitt3, COLLIDER_FLAGS_UPPER_MASK)
EVT_EXEC(N(EVS_EnterMap))
EVT_RETURN
EVT_END
};
|
4d006989e7a2865242345de561df90131bf9fd7d
|
a91796ab826878e54d91c32249f45bb919e0c149
|
/modules/core/include/opencv2/core/cv_cpu_helper.h
|
41fc9d50fa1ec1691e357ffc46c7fb22081d8c8d
|
[
"Apache-2.0"
] |
permissive
|
opencv/opencv
|
8f1c8b5a16980f78de7c6e73a4340d302d1211cc
|
a308dfca9856574d37abe7628b965e29861fb105
|
refs/heads/4.x
| 2023-09-01T12:37:49.132527
| 2023-08-30T06:53:59
| 2023-08-30T06:53:59
| 5,108,051
| 68,495
| 62,910
|
Apache-2.0
| 2023-09-14T17:37:48
| 2012-07-19T09:40:17
|
C++
|
UTF-8
|
C
| false
| false
| 29,877
|
h
|
cv_cpu_helper.h
|
// AUTOGENERATED, DO NOT EDIT
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE
# define CV_TRY_SSE 1
# define CV_CPU_FORCE_SSE 1
# define CV_CPU_HAS_SUPPORT_SSE 1
# define CV_CPU_CALL_SSE(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_SSE_(fn, args) return (opt_SSE::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE
# define CV_TRY_SSE 1
# define CV_CPU_FORCE_SSE 0
# define CV_CPU_HAS_SUPPORT_SSE (cv::checkHardwareSupport(CV_CPU_SSE))
# define CV_CPU_CALL_SSE(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args)
# define CV_CPU_CALL_SSE_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args)
#else
# define CV_TRY_SSE 0
# define CV_CPU_FORCE_SSE 0
# define CV_CPU_HAS_SUPPORT_SSE 0
# define CV_CPU_CALL_SSE(fn, args)
# define CV_CPU_CALL_SSE_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_SSE(fn, args, mode, ...) CV_CPU_CALL_SSE(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE2
# define CV_TRY_SSE2 1
# define CV_CPU_FORCE_SSE2 1
# define CV_CPU_HAS_SUPPORT_SSE2 1
# define CV_CPU_CALL_SSE2(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_SSE2_(fn, args) return (opt_SSE2::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE2
# define CV_TRY_SSE2 1
# define CV_CPU_FORCE_SSE2 0
# define CV_CPU_HAS_SUPPORT_SSE2 (cv::checkHardwareSupport(CV_CPU_SSE2))
# define CV_CPU_CALL_SSE2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args)
# define CV_CPU_CALL_SSE2_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args)
#else
# define CV_TRY_SSE2 0
# define CV_CPU_FORCE_SSE2 0
# define CV_CPU_HAS_SUPPORT_SSE2 0
# define CV_CPU_CALL_SSE2(fn, args)
# define CV_CPU_CALL_SSE2_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_SSE2(fn, args, mode, ...) CV_CPU_CALL_SSE2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE3
# define CV_TRY_SSE3 1
# define CV_CPU_FORCE_SSE3 1
# define CV_CPU_HAS_SUPPORT_SSE3 1
# define CV_CPU_CALL_SSE3(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_SSE3_(fn, args) return (opt_SSE3::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE3
# define CV_TRY_SSE3 1
# define CV_CPU_FORCE_SSE3 0
# define CV_CPU_HAS_SUPPORT_SSE3 (cv::checkHardwareSupport(CV_CPU_SSE3))
# define CV_CPU_CALL_SSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args)
# define CV_CPU_CALL_SSE3_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args)
#else
# define CV_TRY_SSE3 0
# define CV_CPU_FORCE_SSE3 0
# define CV_CPU_HAS_SUPPORT_SSE3 0
# define CV_CPU_CALL_SSE3(fn, args)
# define CV_CPU_CALL_SSE3_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_SSE3(fn, args, mode, ...) CV_CPU_CALL_SSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSSE3
# define CV_TRY_SSSE3 1
# define CV_CPU_FORCE_SSSE3 1
# define CV_CPU_HAS_SUPPORT_SSSE3 1
# define CV_CPU_CALL_SSSE3(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_SSSE3_(fn, args) return (opt_SSSE3::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSSE3
# define CV_TRY_SSSE3 1
# define CV_CPU_FORCE_SSSE3 0
# define CV_CPU_HAS_SUPPORT_SSSE3 (cv::checkHardwareSupport(CV_CPU_SSSE3))
# define CV_CPU_CALL_SSSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args)
# define CV_CPU_CALL_SSSE3_(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args)
#else
# define CV_TRY_SSSE3 0
# define CV_CPU_FORCE_SSSE3 0
# define CV_CPU_HAS_SUPPORT_SSSE3 0
# define CV_CPU_CALL_SSSE3(fn, args)
# define CV_CPU_CALL_SSSE3_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_SSSE3(fn, args, mode, ...) CV_CPU_CALL_SSSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_1
# define CV_TRY_SSE4_1 1
# define CV_CPU_FORCE_SSE4_1 1
# define CV_CPU_HAS_SUPPORT_SSE4_1 1
# define CV_CPU_CALL_SSE4_1(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_SSE4_1_(fn, args) return (opt_SSE4_1::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_1
# define CV_TRY_SSE4_1 1
# define CV_CPU_FORCE_SSE4_1 0
# define CV_CPU_HAS_SUPPORT_SSE4_1 (cv::checkHardwareSupport(CV_CPU_SSE4_1))
# define CV_CPU_CALL_SSE4_1(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args)
# define CV_CPU_CALL_SSE4_1_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args)
#else
# define CV_TRY_SSE4_1 0
# define CV_CPU_FORCE_SSE4_1 0
# define CV_CPU_HAS_SUPPORT_SSE4_1 0
# define CV_CPU_CALL_SSE4_1(fn, args)
# define CV_CPU_CALL_SSE4_1_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_SSE4_1(fn, args, mode, ...) CV_CPU_CALL_SSE4_1(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_2
# define CV_TRY_SSE4_2 1
# define CV_CPU_FORCE_SSE4_2 1
# define CV_CPU_HAS_SUPPORT_SSE4_2 1
# define CV_CPU_CALL_SSE4_2(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_SSE4_2_(fn, args) return (opt_SSE4_2::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_2
# define CV_TRY_SSE4_2 1
# define CV_CPU_FORCE_SSE4_2 0
# define CV_CPU_HAS_SUPPORT_SSE4_2 (cv::checkHardwareSupport(CV_CPU_SSE4_2))
# define CV_CPU_CALL_SSE4_2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args)
# define CV_CPU_CALL_SSE4_2_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args)
#else
# define CV_TRY_SSE4_2 0
# define CV_CPU_FORCE_SSE4_2 0
# define CV_CPU_HAS_SUPPORT_SSE4_2 0
# define CV_CPU_CALL_SSE4_2(fn, args)
# define CV_CPU_CALL_SSE4_2_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_SSE4_2(fn, args, mode, ...) CV_CPU_CALL_SSE4_2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_POPCNT
# define CV_TRY_POPCNT 1
# define CV_CPU_FORCE_POPCNT 1
# define CV_CPU_HAS_SUPPORT_POPCNT 1
# define CV_CPU_CALL_POPCNT(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_POPCNT_(fn, args) return (opt_POPCNT::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_POPCNT
# define CV_TRY_POPCNT 1
# define CV_CPU_FORCE_POPCNT 0
# define CV_CPU_HAS_SUPPORT_POPCNT (cv::checkHardwareSupport(CV_CPU_POPCNT))
# define CV_CPU_CALL_POPCNT(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args)
# define CV_CPU_CALL_POPCNT_(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args)
#else
# define CV_TRY_POPCNT 0
# define CV_CPU_FORCE_POPCNT 0
# define CV_CPU_HAS_SUPPORT_POPCNT 0
# define CV_CPU_CALL_POPCNT(fn, args)
# define CV_CPU_CALL_POPCNT_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_POPCNT(fn, args, mode, ...) CV_CPU_CALL_POPCNT(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX
# define CV_TRY_AVX 1
# define CV_CPU_FORCE_AVX 1
# define CV_CPU_HAS_SUPPORT_AVX 1
# define CV_CPU_CALL_AVX(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX_(fn, args) return (opt_AVX::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX
# define CV_TRY_AVX 1
# define CV_CPU_FORCE_AVX 0
# define CV_CPU_HAS_SUPPORT_AVX (cv::checkHardwareSupport(CV_CPU_AVX))
# define CV_CPU_CALL_AVX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args)
# define CV_CPU_CALL_AVX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args)
#else
# define CV_TRY_AVX 0
# define CV_CPU_FORCE_AVX 0
# define CV_CPU_HAS_SUPPORT_AVX 0
# define CV_CPU_CALL_AVX(fn, args)
# define CV_CPU_CALL_AVX_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX(fn, args, mode, ...) CV_CPU_CALL_AVX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FP16
# define CV_TRY_FP16 1
# define CV_CPU_FORCE_FP16 1
# define CV_CPU_HAS_SUPPORT_FP16 1
# define CV_CPU_CALL_FP16(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_FP16_(fn, args) return (opt_FP16::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FP16
# define CV_TRY_FP16 1
# define CV_CPU_FORCE_FP16 0
# define CV_CPU_HAS_SUPPORT_FP16 (cv::checkHardwareSupport(CV_CPU_FP16))
# define CV_CPU_CALL_FP16(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args)
# define CV_CPU_CALL_FP16_(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args)
#else
# define CV_TRY_FP16 0
# define CV_CPU_FORCE_FP16 0
# define CV_CPU_HAS_SUPPORT_FP16 0
# define CV_CPU_CALL_FP16(fn, args)
# define CV_CPU_CALL_FP16_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_FP16(fn, args, mode, ...) CV_CPU_CALL_FP16(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX2
# define CV_TRY_AVX2 1
# define CV_CPU_FORCE_AVX2 1
# define CV_CPU_HAS_SUPPORT_AVX2 1
# define CV_CPU_CALL_AVX2(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX2_(fn, args) return (opt_AVX2::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX2
# define CV_TRY_AVX2 1
# define CV_CPU_FORCE_AVX2 0
# define CV_CPU_HAS_SUPPORT_AVX2 (cv::checkHardwareSupport(CV_CPU_AVX2))
# define CV_CPU_CALL_AVX2(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args)
# define CV_CPU_CALL_AVX2_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args)
#else
# define CV_TRY_AVX2 0
# define CV_CPU_FORCE_AVX2 0
# define CV_CPU_HAS_SUPPORT_AVX2 0
# define CV_CPU_CALL_AVX2(fn, args)
# define CV_CPU_CALL_AVX2_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX2(fn, args, mode, ...) CV_CPU_CALL_AVX2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FMA3
# define CV_TRY_FMA3 1
# define CV_CPU_FORCE_FMA3 1
# define CV_CPU_HAS_SUPPORT_FMA3 1
# define CV_CPU_CALL_FMA3(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_FMA3_(fn, args) return (opt_FMA3::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FMA3
# define CV_TRY_FMA3 1
# define CV_CPU_FORCE_FMA3 0
# define CV_CPU_HAS_SUPPORT_FMA3 (cv::checkHardwareSupport(CV_CPU_FMA3))
# define CV_CPU_CALL_FMA3(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args)
# define CV_CPU_CALL_FMA3_(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args)
#else
# define CV_TRY_FMA3 0
# define CV_CPU_FORCE_FMA3 0
# define CV_CPU_HAS_SUPPORT_FMA3 0
# define CV_CPU_CALL_FMA3(fn, args)
# define CV_CPU_CALL_FMA3_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_FMA3(fn, args, mode, ...) CV_CPU_CALL_FMA3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX_512F
# define CV_TRY_AVX_512F 1
# define CV_CPU_FORCE_AVX_512F 1
# define CV_CPU_HAS_SUPPORT_AVX_512F 1
# define CV_CPU_CALL_AVX_512F(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX_512F_(fn, args) return (opt_AVX_512F::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX_512F
# define CV_TRY_AVX_512F 1
# define CV_CPU_FORCE_AVX_512F 0
# define CV_CPU_HAS_SUPPORT_AVX_512F (cv::checkHardwareSupport(CV_CPU_AVX_512F))
# define CV_CPU_CALL_AVX_512F(fn, args) if (CV_CPU_HAS_SUPPORT_AVX_512F) return (opt_AVX_512F::fn args)
# define CV_CPU_CALL_AVX_512F_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX_512F) return (opt_AVX_512F::fn args)
#else
# define CV_TRY_AVX_512F 0
# define CV_CPU_FORCE_AVX_512F 0
# define CV_CPU_HAS_SUPPORT_AVX_512F 0
# define CV_CPU_CALL_AVX_512F(fn, args)
# define CV_CPU_CALL_AVX_512F_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX_512F(fn, args, mode, ...) CV_CPU_CALL_AVX_512F(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_COMMON
# define CV_TRY_AVX512_COMMON 1
# define CV_CPU_FORCE_AVX512_COMMON 1
# define CV_CPU_HAS_SUPPORT_AVX512_COMMON 1
# define CV_CPU_CALL_AVX512_COMMON(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX512_COMMON_(fn, args) return (opt_AVX512_COMMON::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_COMMON
# define CV_TRY_AVX512_COMMON 1
# define CV_CPU_FORCE_AVX512_COMMON 0
# define CV_CPU_HAS_SUPPORT_AVX512_COMMON (cv::checkHardwareSupport(CV_CPU_AVX512_COMMON))
# define CV_CPU_CALL_AVX512_COMMON(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_COMMON) return (opt_AVX512_COMMON::fn args)
# define CV_CPU_CALL_AVX512_COMMON_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_COMMON) return (opt_AVX512_COMMON::fn args)
#else
# define CV_TRY_AVX512_COMMON 0
# define CV_CPU_FORCE_AVX512_COMMON 0
# define CV_CPU_HAS_SUPPORT_AVX512_COMMON 0
# define CV_CPU_CALL_AVX512_COMMON(fn, args)
# define CV_CPU_CALL_AVX512_COMMON_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_COMMON(fn, args, mode, ...) CV_CPU_CALL_AVX512_COMMON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_KNL
# define CV_TRY_AVX512_KNL 1
# define CV_CPU_FORCE_AVX512_KNL 1
# define CV_CPU_HAS_SUPPORT_AVX512_KNL 1
# define CV_CPU_CALL_AVX512_KNL(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX512_KNL_(fn, args) return (opt_AVX512_KNL::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_KNL
# define CV_TRY_AVX512_KNL 1
# define CV_CPU_FORCE_AVX512_KNL 0
# define CV_CPU_HAS_SUPPORT_AVX512_KNL (cv::checkHardwareSupport(CV_CPU_AVX512_KNL))
# define CV_CPU_CALL_AVX512_KNL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNL) return (opt_AVX512_KNL::fn args)
# define CV_CPU_CALL_AVX512_KNL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNL) return (opt_AVX512_KNL::fn args)
#else
# define CV_TRY_AVX512_KNL 0
# define CV_CPU_FORCE_AVX512_KNL 0
# define CV_CPU_HAS_SUPPORT_AVX512_KNL 0
# define CV_CPU_CALL_AVX512_KNL(fn, args)
# define CV_CPU_CALL_AVX512_KNL_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_KNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_KNL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_KNM
# define CV_TRY_AVX512_KNM 1
# define CV_CPU_FORCE_AVX512_KNM 1
# define CV_CPU_HAS_SUPPORT_AVX512_KNM 1
# define CV_CPU_CALL_AVX512_KNM(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX512_KNM_(fn, args) return (opt_AVX512_KNM::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_KNM
# define CV_TRY_AVX512_KNM 1
# define CV_CPU_FORCE_AVX512_KNM 0
# define CV_CPU_HAS_SUPPORT_AVX512_KNM (cv::checkHardwareSupport(CV_CPU_AVX512_KNM))
# define CV_CPU_CALL_AVX512_KNM(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNM) return (opt_AVX512_KNM::fn args)
# define CV_CPU_CALL_AVX512_KNM_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNM) return (opt_AVX512_KNM::fn args)
#else
# define CV_TRY_AVX512_KNM 0
# define CV_CPU_FORCE_AVX512_KNM 0
# define CV_CPU_HAS_SUPPORT_AVX512_KNM 0
# define CV_CPU_CALL_AVX512_KNM(fn, args)
# define CV_CPU_CALL_AVX512_KNM_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_KNM(fn, args, mode, ...) CV_CPU_CALL_AVX512_KNM(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_SKX
# define CV_TRY_AVX512_SKX 1
# define CV_CPU_FORCE_AVX512_SKX 1
# define CV_CPU_HAS_SUPPORT_AVX512_SKX 1
# define CV_CPU_CALL_AVX512_SKX(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX512_SKX_(fn, args) return (opt_AVX512_SKX::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_SKX
# define CV_TRY_AVX512_SKX 1
# define CV_CPU_FORCE_AVX512_SKX 0
# define CV_CPU_HAS_SUPPORT_AVX512_SKX (cv::checkHardwareSupport(CV_CPU_AVX512_SKX))
# define CV_CPU_CALL_AVX512_SKX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_SKX) return (opt_AVX512_SKX::fn args)
# define CV_CPU_CALL_AVX512_SKX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_SKX) return (opt_AVX512_SKX::fn args)
#else
# define CV_TRY_AVX512_SKX 0
# define CV_CPU_FORCE_AVX512_SKX 0
# define CV_CPU_HAS_SUPPORT_AVX512_SKX 0
# define CV_CPU_CALL_AVX512_SKX(fn, args)
# define CV_CPU_CALL_AVX512_SKX_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_SKX(fn, args, mode, ...) CV_CPU_CALL_AVX512_SKX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CNL
# define CV_TRY_AVX512_CNL 1
# define CV_CPU_FORCE_AVX512_CNL 1
# define CV_CPU_HAS_SUPPORT_AVX512_CNL 1
# define CV_CPU_CALL_AVX512_CNL(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX512_CNL_(fn, args) return (opt_AVX512_CNL::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CNL
# define CV_TRY_AVX512_CNL 1
# define CV_CPU_FORCE_AVX512_CNL 0
# define CV_CPU_HAS_SUPPORT_AVX512_CNL (cv::checkHardwareSupport(CV_CPU_AVX512_CNL))
# define CV_CPU_CALL_AVX512_CNL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CNL) return (opt_AVX512_CNL::fn args)
# define CV_CPU_CALL_AVX512_CNL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CNL) return (opt_AVX512_CNL::fn args)
#else
# define CV_TRY_AVX512_CNL 0
# define CV_CPU_FORCE_AVX512_CNL 0
# define CV_CPU_HAS_SUPPORT_AVX512_CNL 0
# define CV_CPU_CALL_AVX512_CNL(fn, args)
# define CV_CPU_CALL_AVX512_CNL_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_CNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_CNL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CLX
# define CV_TRY_AVX512_CLX 1
# define CV_CPU_FORCE_AVX512_CLX 1
# define CV_CPU_HAS_SUPPORT_AVX512_CLX 1
# define CV_CPU_CALL_AVX512_CLX(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX512_CLX_(fn, args) return (opt_AVX512_CLX::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CLX
# define CV_TRY_AVX512_CLX 1
# define CV_CPU_FORCE_AVX512_CLX 0
# define CV_CPU_HAS_SUPPORT_AVX512_CLX (cv::checkHardwareSupport(CV_CPU_AVX512_CLX))
# define CV_CPU_CALL_AVX512_CLX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args)
# define CV_CPU_CALL_AVX512_CLX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args)
#else
# define CV_TRY_AVX512_CLX 0
# define CV_CPU_FORCE_AVX512_CLX 0
# define CV_CPU_HAS_SUPPORT_AVX512_CLX 0
# define CV_CPU_CALL_AVX512_CLX(fn, args)
# define CV_CPU_CALL_AVX512_CLX_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_CLX(fn, args, mode, ...) CV_CPU_CALL_AVX512_CLX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_ICL
# define CV_TRY_AVX512_ICL 1
# define CV_CPU_FORCE_AVX512_ICL 1
# define CV_CPU_HAS_SUPPORT_AVX512_ICL 1
# define CV_CPU_CALL_AVX512_ICL(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_AVX512_ICL_(fn, args) return (opt_AVX512_ICL::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_ICL
# define CV_TRY_AVX512_ICL 1
# define CV_CPU_FORCE_AVX512_ICL 0
# define CV_CPU_HAS_SUPPORT_AVX512_ICL (cv::checkHardwareSupport(CV_CPU_AVX512_ICL))
# define CV_CPU_CALL_AVX512_ICL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_ICL) return (opt_AVX512_ICL::fn args)
# define CV_CPU_CALL_AVX512_ICL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_ICL) return (opt_AVX512_ICL::fn args)
#else
# define CV_TRY_AVX512_ICL 0
# define CV_CPU_FORCE_AVX512_ICL 0
# define CV_CPU_HAS_SUPPORT_AVX512_ICL 0
# define CV_CPU_CALL_AVX512_ICL(fn, args)
# define CV_CPU_CALL_AVX512_ICL_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_AVX512_ICL(fn, args, mode, ...) CV_CPU_CALL_AVX512_ICL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON
# define CV_TRY_NEON 1
# define CV_CPU_FORCE_NEON 1
# define CV_CPU_HAS_SUPPORT_NEON 1
# define CV_CPU_CALL_NEON(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_NEON_(fn, args) return (opt_NEON::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON
# define CV_TRY_NEON 1
# define CV_CPU_FORCE_NEON 0
# define CV_CPU_HAS_SUPPORT_NEON (cv::checkHardwareSupport(CV_CPU_NEON))
# define CV_CPU_CALL_NEON(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args)
# define CV_CPU_CALL_NEON_(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args)
#else
# define CV_TRY_NEON 0
# define CV_CPU_FORCE_NEON 0
# define CV_CPU_HAS_SUPPORT_NEON 0
# define CV_CPU_CALL_NEON(fn, args)
# define CV_CPU_CALL_NEON_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_NEON(fn, args, mode, ...) CV_CPU_CALL_NEON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON_DOTPROD
# define CV_TRY_NEON_DOTPROD 1
# define CV_CPU_FORCE_NEON_DOTPROD 1
# define CV_CPU_HAS_SUPPORT_NEON_DOTPROD 1
# define CV_CPU_CALL_NEON_DOTPROD(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_NEON_DOTPROD_(fn, args) return (opt_NEON_DOTPROD::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON_DOTPROD
# define CV_TRY_NEON_DOTPROD 1
# define CV_CPU_FORCE_NEON_DOTPROD 0
# define CV_CPU_HAS_SUPPORT_NEON_DOTPROD (cv::checkHardwareSupport(CV_CPU_NEON_DOTPROD))
# define CV_CPU_CALL_NEON_DOTPROD(fn, args) if (CV_CPU_HAS_SUPPORT_NEON_DOTPROD) return (opt_NEON_DOTPROD::fn args)
# define CV_CPU_CALL_NEON_DOTPROD_(fn, args) if (CV_CPU_HAS_SUPPORT_NEON_DOTPROD) return (opt_NEON_DOTPROD::fn args)
#else
# define CV_TRY_NEON_DOTPROD 0
# define CV_CPU_FORCE_NEON_DOTPROD 0
# define CV_CPU_HAS_SUPPORT_NEON_DOTPROD 0
# define CV_CPU_CALL_NEON_DOTPROD(fn, args)
# define CV_CPU_CALL_NEON_DOTPROD_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_NEON_DOTPROD(fn, args, mode, ...) CV_CPU_CALL_NEON_DOTPROD(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_MSA
# define CV_TRY_MSA 1
# define CV_CPU_FORCE_MSA 1
# define CV_CPU_HAS_SUPPORT_MSA 1
# define CV_CPU_CALL_MSA(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_MSA_(fn, args) return (opt_MSA::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_MSA
# define CV_TRY_MSA 1
# define CV_CPU_FORCE_MSA 0
# define CV_CPU_HAS_SUPPORT_MSA (cv::checkHardwareSupport(CV_CPU_MSA))
# define CV_CPU_CALL_MSA(fn, args) if (CV_CPU_HAS_SUPPORT_MSA) return (opt_MSA::fn args)
# define CV_CPU_CALL_MSA_(fn, args) if (CV_CPU_HAS_SUPPORT_MSA) return (opt_MSA::fn args)
#else
# define CV_TRY_MSA 0
# define CV_CPU_FORCE_MSA 0
# define CV_CPU_HAS_SUPPORT_MSA 0
# define CV_CPU_CALL_MSA(fn, args)
# define CV_CPU_CALL_MSA_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_MSA(fn, args, mode, ...) CV_CPU_CALL_MSA(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX
# define CV_TRY_VSX 1
# define CV_CPU_FORCE_VSX 1
# define CV_CPU_HAS_SUPPORT_VSX 1
# define CV_CPU_CALL_VSX(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_VSX_(fn, args) return (opt_VSX::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX
# define CV_TRY_VSX 1
# define CV_CPU_FORCE_VSX 0
# define CV_CPU_HAS_SUPPORT_VSX (cv::checkHardwareSupport(CV_CPU_VSX))
# define CV_CPU_CALL_VSX(fn, args) if (CV_CPU_HAS_SUPPORT_VSX) return (opt_VSX::fn args)
# define CV_CPU_CALL_VSX_(fn, args) if (CV_CPU_HAS_SUPPORT_VSX) return (opt_VSX::fn args)
#else
# define CV_TRY_VSX 0
# define CV_CPU_FORCE_VSX 0
# define CV_CPU_HAS_SUPPORT_VSX 0
# define CV_CPU_CALL_VSX(fn, args)
# define CV_CPU_CALL_VSX_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_VSX(fn, args, mode, ...) CV_CPU_CALL_VSX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX3
# define CV_TRY_VSX3 1
# define CV_CPU_FORCE_VSX3 1
# define CV_CPU_HAS_SUPPORT_VSX3 1
# define CV_CPU_CALL_VSX3(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_VSX3_(fn, args) return (opt_VSX3::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX3
# define CV_TRY_VSX3 1
# define CV_CPU_FORCE_VSX3 0
# define CV_CPU_HAS_SUPPORT_VSX3 (cv::checkHardwareSupport(CV_CPU_VSX3))
# define CV_CPU_CALL_VSX3(fn, args) if (CV_CPU_HAS_SUPPORT_VSX3) return (opt_VSX3::fn args)
# define CV_CPU_CALL_VSX3_(fn, args) if (CV_CPU_HAS_SUPPORT_VSX3) return (opt_VSX3::fn args)
#else
# define CV_TRY_VSX3 0
# define CV_CPU_FORCE_VSX3 0
# define CV_CPU_HAS_SUPPORT_VSX3 0
# define CV_CPU_CALL_VSX3(fn, args)
# define CV_CPU_CALL_VSX3_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_VSX3(fn, args, mode, ...) CV_CPU_CALL_VSX3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_RVV
# define CV_TRY_RVV 1
# define CV_CPU_FORCE_RVV 1
# define CV_CPU_HAS_SUPPORT_RVV 1
# define CV_CPU_CALL_RVV(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_RVV_(fn, args) return (opt_RVV::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_RVV
# define CV_TRY_RVV 1
# define CV_CPU_FORCE_RVV 0
# define CV_CPU_HAS_SUPPORT_RVV (cv::checkHardwareSupport(CV_CPU_RVV))
# define CV_CPU_CALL_RVV(fn, args) if (CV_CPU_HAS_SUPPORT_RVV) return (opt_RVV::fn args)
# define CV_CPU_CALL_RVV_(fn, args) if (CV_CPU_HAS_SUPPORT_RVV) return (opt_RVV::fn args)
#else
# define CV_TRY_RVV 0
# define CV_CPU_FORCE_RVV 0
# define CV_CPU_HAS_SUPPORT_RVV 0
# define CV_CPU_CALL_RVV(fn, args)
# define CV_CPU_CALL_RVV_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_RVV(fn, args, mode, ...) CV_CPU_CALL_RVV(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_LASX
# define CV_TRY_LASX 1
# define CV_CPU_FORCE_LASX 1
# define CV_CPU_HAS_SUPPORT_LASX 1
# define CV_CPU_CALL_LASX(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_LASX_(fn, args) return (opt_LASX::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_LASX
# define CV_TRY_LASX 1
# define CV_CPU_FORCE_LASX 0
# define CV_CPU_HAS_SUPPORT_LASX (cv::checkHardwareSupport(CV_CPU_LASX))
# define CV_CPU_CALL_LASX(fn, args) if (CV_CPU_HAS_SUPPORT_LASX) return (opt_LASX::fn args)
# define CV_CPU_CALL_LASX_(fn, args) if (CV_CPU_HAS_SUPPORT_LASX) return (opt_LASX::fn args)
#else
# define CV_TRY_LASX 0
# define CV_CPU_FORCE_LASX 0
# define CV_CPU_HAS_SUPPORT_LASX 0
# define CV_CPU_CALL_LASX(fn, args)
# define CV_CPU_CALL_LASX_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_LASX(fn, args, mode, ...) CV_CPU_CALL_LASX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
|
b08758220686dac7415c2ed578996b7130870870
|
a4f995f33d9f2b12ce80f7906ad664b740a15090
|
/Lilu/Headers/hde64.h
|
6082faea6fb8b66e5194eb2578c6f42155b3de17
|
[
"BSD-3-Clause"
] |
permissive
|
acidanthera/Lilu
|
351be22cc9cbee201601a70e5dd4edb7dd131f7d
|
472442f344531f88d31628da44f0778655a8e532
|
refs/heads/master
| 2023-08-27T23:55:36.523357
| 2023-08-13T09:58:29
| 2023-08-13T09:58:29
| 82,815,770
| 3,068
| 506
|
BSD-3-Clause
| 2023-06-25T23:57:54
| 2017-02-22T14:47:14
|
C
|
UTF-8
|
C
| false
| false
| 17
|
h
|
hde64.h
|
../../hde/hde64.h
|
7983003017881bc9e17d3b18ae1663d8ee436c50
|
7df190df28da7e4ff166e55dc8ce780f11236a9f
|
/src/router/yukon/sk98lin/h/sktwsi.h
|
34b1cdfcc44ce0ec70f0f6de4f7e5ff6228cf67e
|
[] |
no_license
|
mirror/dd-wrt
|
25416946e6132aa54b35809de61834a1825a9a36
|
8f2934a5a2adfbb59b471375aa3a38de5d036531
|
refs/heads/master
| 2023-08-31T14:54:47.496685
| 2023-08-30T17:40:54
| 2023-08-30T17:40:54
| 7,470,282
| 520
| 281
| null | 2023-05-29T20:56:24
| 2013-01-06T17:21:29
| null |
UTF-8
|
C
| false
| false
| 6,436
|
h
|
sktwsi.h
|
/******************************************************************************
*
* Name: $Id: //Release/Yukon_1G/Shared/twsi/V4/h/sktwsi.h#4 $
* Project: Gigabit Ethernet Adapters, TWSI-Module
* Version: $Revision: #4 $, $Change: 4277 $
* Date: $DateTime: 2010/11/05 10:41:17 $
* Purpose: Defines to access Voltage and Temperature Sensor
*
******************************************************************************/
/******************************************************************************
*
* LICENSE:
* (C)Copyright Marvell.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The information in this file is provided "AS IS" without warranty.
* /LICENSE
*
******************************************************************************/
/*
* SKTWSI.H contains all TWSI specific defines
*/
#ifndef _SKTWSI_H_
#define _SKTWSI_H_
typedef struct s_Sensor SK_SENSOR;
#include "h/skgetwsi.h"
/*
* Define the TWSI events.
*/
#define SK_I2CEV_IRQ 1 /* IRQ happened Event */
#define SK_I2CEV_TIM 2 /* Timeout event */
#define SK_I2CEV_CLEAR 3 /* Clear MIB Values */
/*
* Define READ and WRITE Constants.
*/
#define I2C_READ 0
#define I2C_WRITE 1
#define I2C_BURST 1
#define I2C_SINGLE 0
#define SKERR_I2C_E001 (SK_ERRBASE_I2C+1)
#define SKERR_I2C_E001MSG "Sensor index unknown"
#define SKERR_I2C_E002 (SKERR_I2C_E001+1)
#define SKERR_I2C_E002MSG "TWSI: transfer does not complete"
#define SKERR_I2C_E003 (SKERR_I2C_E002+1)
#define SKERR_I2C_E003MSG "LM80: NAK on device send"
#define SKERR_I2C_E004 (SKERR_I2C_E003+1)
#define SKERR_I2C_E004MSG "LM80: NAK on register send"
#define SKERR_I2C_E005 (SKERR_I2C_E004+1)
#define SKERR_I2C_E005MSG "LM80: NAK on device (2) send"
#define SKERR_I2C_E006 (SKERR_I2C_E005+1)
#define SKERR_I2C_E006MSG "Unknown event"
#define SKERR_I2C_E007 (SKERR_I2C_E006+1)
#define SKERR_I2C_E007MSG "LM80 read out of state"
#define SKERR_I2C_E008 (SKERR_I2C_E007+1)
#define SKERR_I2C_E008MSG "Unexpected sensor read completed"
#define SKERR_I2C_E009 (SKERR_I2C_E008+1)
#define SKERR_I2C_E009MSG "WARNING: temperature sensor out of range"
#define SKERR_I2C_E010 (SKERR_I2C_E009+1)
#define SKERR_I2C_E010MSG "WARNING: voltage sensor out of range"
#define SKERR_I2C_E011 (SKERR_I2C_E010+1)
#define SKERR_I2C_E011MSG "ERROR: temperature sensor out of range"
#define SKERR_I2C_E012 (SKERR_I2C_E011+1)
#define SKERR_I2C_E012MSG "ERROR: voltage sensor out of range"
#define SKERR_I2C_E013 (SKERR_I2C_E012+1)
#define SKERR_I2C_E013MSG "ERROR: couldn't init sensor"
#define SKERR_I2C_E014 (SKERR_I2C_E013+1)
#define SKERR_I2C_E014MSG "WARNING: fan sensor out of range"
#define SKERR_I2C_E015 (SKERR_I2C_E014+1)
#define SKERR_I2C_E015MSG "ERROR: fan sensor out of range"
#define SKERR_I2C_E016 (SKERR_I2C_E015+1)
#define SKERR_I2C_E016MSG "TWSI: active transfer does not complete"
/*
* Define Timeout values
*/
#define SK_I2C_TIM_LONG 2000000L /* 2 seconds */
#define SK_I2C_TIM_SHORT 100000L /* 100 milliseconds */
#define SK_I2C_TIM_WATCH 1000000L /* 1 second */
/*
* Define trap and error log hold times
*/
#ifndef SK_SEN_ERR_TR_HOLD
#define SK_SEN_ERR_TR_HOLD ( 4*SK_TICKS_PER_SEC)
#endif
#ifndef SK_SEN_ERR_LOG_HOLD
#define SK_SEN_ERR_LOG_HOLD (60*SK_TICKS_PER_SEC)
#endif
#ifndef SK_SEN_WARN_TR_HOLD
#define SK_SEN_WARN_TR_HOLD (15*SK_TICKS_PER_SEC)
#endif
#ifndef SK_SEN_WARN_LOG_HOLD
#define SK_SEN_WARN_LOG_HOLD (15*60*SK_TICKS_PER_SEC)
#endif
/*
* Defines for SenType
*/
#define SK_SEN_UNKNOWN 0
#define SK_SEN_TEMP 1
#define SK_SEN_VOLT 2
#define SK_SEN_FAN 3
/*
* Define for the SenErrorFlag
*/
#define SK_SEN_ERR_NOT_PRESENT 0 /* Error Flag: Sensor not present */
#define SK_SEN_ERR_OK 1 /* Error Flag: O.K. */
#define SK_SEN_ERR_WARN 2 /* Error Flag: Warning */
#define SK_SEN_ERR_ERR 3 /* Error Flag: Error */
#define SK_SEN_ERR_FAULTY 4 /* Error Flag: Faulty */
/*
* Define the Sensor struct
*/
struct s_Sensor {
char *SenDesc; /* Description */
int SenType; /* Voltage or Temperature */
SK_I32 SenValue; /* Current value of the sensor */
SK_I32 SenThreErrHigh; /* High error Threshhold of this sensor */
SK_I32 SenThreWarnHigh; /* High warning Threshhold of this sensor */
SK_I32 SenThreErrLow; /* Lower error Threshold of the sensor */
SK_I32 SenThreWarnLow; /* Lower warning Threshold of the sensor */
int SenErrFlag; /* Sensor indicated an error */
SK_BOOL SenInit; /* Is sensor initialized ? */
SK_U64 SenErrCts; /* Error trap counter */
SK_U64 SenWarnCts; /* Warning trap counter */
SK_U64 SenBegErrTS; /* Begin error timestamp */
SK_U64 SenBegWarnTS; /* Begin warning timestamp */
SK_U64 SenLastErrTrapTS; /* Last error trap timestamp */
SK_U64 SenLastErrLogTS; /* Last error log timestamp */
SK_U64 SenLastWarnTrapTS; /* Last warning trap timestamp */
SK_U64 SenLastWarnLogTS; /* Last warning log timestamp */
int SenState; /* Sensor State (see HW specific include) */
int (*SenRead)(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
/* Sensors read function */
SK_U16 SenReg; /* Register Address for this sensor */
SK_U8 SenDev; /* Device Selection for this sensor */
};
typedef struct s_I2c {
SK_SENSOR SenTable[SK_MAX_SENSORS]; /* Sensor Table */
int CurrSens; /* Which sensor is currently queried */
int MaxSens; /* Max. number of sensors */
int TimerMode; /* Use the timer also to watch the state machine */
int InitLevel; /* Initialized Level */
#ifndef SK_DIAG
int DummyReads; /* Number of non-checked dummy reads */
SK_TIMER SenTimer; /* Sensors timer */
#endif /* !SK_DIAG */
} SK_I2C;
extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
extern int SkI2cWrite(SK_AC *pAC, SK_IOC IoC, SK_U32 Data, int Dev, int Size,
int Reg, int Burst);
extern int SkI2cWait(SK_AC *pAC, SK_IOC IoC, int Event);
extern int SkI2cReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
#ifdef SK_DIAG
extern SK_U32 SkI2cRead(SK_AC *pAC, SK_IOC IoC, int Dev, int Size, int Reg,
int Burst);
#else /* !SK_DIAG */
extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
extern void SkI2cWaitIrq(SK_AC *pAC, SK_IOC IoC);
extern void SkI2cIsr(SK_AC *pAC, SK_IOC IoC);
#endif /* !SK_DIAG */
#endif /* n_SKTWSI_H */
|
6d7e51976ca589556470b46ac6f9392279793128
|
34cfb15a219a735d58fcaadfb71ef1606a9114dc
|
/ext/src/swow_defer.c
|
d762bfbc0b85bc67b5be7c9a8382172d3123cae0
|
[
"ISC",
"BSL-1.0",
"MIT",
"Apache-2.0",
"BSD-2-Clause"
] |
permissive
|
swow/swow
|
e32007f3cf1c8daf4accd7d64f9b2b728f5ab103
|
231f580dd1ee84d0364f314387073c5bda9854d2
|
refs/heads/develop
| 2023-08-19T13:51:39.840737
| 2023-08-05T01:51:04
| 2023-08-05T03:13:03
| 295,651,066
| 1,085
| 117
|
Apache-2.0
| 2023-06-15T09:18:12
| 2020-09-15T07:37:43
|
C
|
UTF-8
|
C
| false
| false
| 6,262
|
c
|
swow_defer.c
|
/*
+--------------------------------------------------------------------------+
| Swow |
+--------------------------------------------------------------------------+
| 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. See accompanying LICENSE file. |
+--------------------------------------------------------------------------+
| Author: Twosee <twosee@php.net> |
+--------------------------------------------------------------------------+
*/
#include "swow_defer.h"
#include "swow_known_strings.h"
SWOW_API zend_class_entry *swow_defer_ce;
SWOW_API zend_object_handlers swow_defer_handlers;
#define SWOW_DEFER_KNOWN_STRING_MAP(XX) \
XX(defer_magic_name, "\0Swow\\Defer") \
SWOW_DEFER_KNOWN_STRING_MAP(SWOW_KNOWN_STRING_STORAGE_GEN)
SWOW_API cat_bool_t swow_defer(zval *z_callable)
{
swow_defer_task_t *task = (swow_defer_task_t *) emalloc(sizeof(*task));
/* check callable and fetch the fcc */
do {
char *error;
if (!zend_is_callable_ex(z_callable, NULL, 0, NULL, &task->fcc, &error)) {
cat_update_last_error(CAT_EMISUSE, "Defer task must be callable, %s", error);
efree(error);
efree(task);
return cat_false;
}
efree(error);
} while (0);
/* copy callable (addref) */
ZVAL_COPY(&task->z_callable, z_callable);
/* get or new defer object on symbol table, and push the task to it */
do {
zend_array *symbol_table = zend_rebuild_symbol_table();
swow_defer_t *s_defer;
zval *z_defer;
ZEND_ASSERT(symbol_table && "A symbol table should always be available here");
z_defer = zend_hash_find(symbol_table, SWOW_KNOWN_STRING(defer_magic_name));
if (z_defer == NULL) {
zend_object *defer = swow_object_create(swow_defer_ce);
zval z_defer;
ZVAL_OBJ(&z_defer, defer);
zend_set_local_var(SWOW_KNOWN_STRING(defer_magic_name), &z_defer, true);
s_defer = swow_defer_get_from_object(defer);
} else {
ZEND_ASSERT(Z_TYPE_P(z_defer) == IS_OBJECT && instanceof_function(Z_OBJCE_P(z_defer), swow_defer_ce));
s_defer = swow_defer_get_from_object(Z_OBJ_P(z_defer));
}
cat_queue_push_back(&s_defer->tasks, &task->node);
} while (0);
return cat_true;
}
SWOW_API void swow_defer_do_tasks(swow_defer_t *s_defer)
{
cat_queue_t *tasks = &s_defer->tasks;
swow_defer_task_t *task;
/* must be FILO */
while ((task = cat_queue_back_data(tasks, swow_defer_task_t, node))) {
zend_fcall_info fci;
zval retval;
cat_queue_remove(&task->node);
fci.size = sizeof(fci);
ZVAL_UNDEF(&fci.function_name);
fci.object = NULL;
fci.param_count = 0;
fci.named_params = NULL;
fci.retval = &retval;
(void) swow_call_function_anyway(&fci, &task->fcc);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&task->z_callable);
efree(task);
}
}
SWOW_API void swow_defer_do_main_tasks(void)
{
zval *z_defer = zend_hash_find_known_hash(&EG(symbol_table), SWOW_KNOWN_STRING(defer_magic_name));
if (z_defer != NULL) {
swow_defer_t *s_defer = swow_defer_get_from_object(Z_OBJ_P(z_defer));
swow_defer_do_tasks(s_defer);
}
}
static zend_object *swow_defer_create_object(zend_class_entry *ce)
{
swow_defer_t *s_defer = swow_object_alloc(swow_defer_t, ce, swow_defer_handlers);
cat_queue_init(&s_defer->tasks);
return &s_defer->std;
}
static void swow_defer_dtor_object(zend_object *object)
{
swow_defer_t *s_defer = swow_defer_get_from_object(object);
swow_defer_do_tasks(s_defer);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Swow_Defer___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
static PHP_METHOD(Swow_Defer, __construct)
{
zend_throw_error(NULL, "The object of %s can not be constructed for security reasons", ZEND_THIS_NAME);
}
static const zend_function_entry swow_defer_methods[] = {
PHP_ME(Swow_Defer, __construct, arginfo_class_Swow_Defer___construct, ZEND_ACC_PUBLIC)
PHP_FE_END
};
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_Swow_defer, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, tasks, IS_CALLABLE, 0)
ZEND_END_ARG_INFO()
static PHP_FUNCTION(Swow_defer)
{
zval *z_task;
cat_bool_t ret;
ZEND_PARSE_PARAMETERS_START(1, -1)
Z_PARAM_ZVAL(z_task)
ZEND_PARSE_PARAMETERS_END();
if (UNEXPECTED(swow_forbid_dynamic_call() != SUCCESS)) {
RETURN_THROWS();
}
ret = swow_defer(z_task);
if (UNEXPECTED(!ret)) {
zend_throw_error(NULL, "%s", cat_get_last_error_message());
RETURN_THROWS();
}
}
static const zend_function_entry swow_defer_functions[] = {
PHP_FENTRY(Swow\\defer, PHP_FN(Swow_defer), arginfo_Swow_defer, 0)
PHP_FE_END
};
zend_result swow_defer_module_init(INIT_FUNC_ARGS)
{
SWOW_DEFER_KNOWN_STRING_MAP(SWOW_KNOWN_STRING_INIT_STRL_GEN);
swow_defer_ce = swow_register_internal_class(
"Swow\\Defer", NULL, swow_defer_methods,
&swow_defer_handlers, NULL,
cat_false, cat_false,
swow_defer_create_object, NULL,
XtOffsetOf(swow_defer_t, std)
);
swow_defer_ce->ce_flags |= ZEND_ACC_FINAL;
/* we do not need get_gc because we never expose defer object to user */
swow_defer_handlers.dtor_obj = swow_defer_dtor_object;
if (zend_register_functions(NULL, swow_defer_functions, NULL, type) != SUCCESS) {
return FAILURE;
}
return SUCCESS;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.