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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9b6962fbcc1fabcd0fbea42ea3a77ef1adf79a83
|
40b83dec47e6e24acf12f2c57fbd34a92205aa02
|
/cpu-cycles/libcpucycles/cpucycles/arm64-vct.c
|
a04b59e108edf6d1ba1e61cc82371f27b69be12a
|
[
"CC0-1.0",
"Apache-2.0"
] |
permissive
|
nymtech/nym
|
803133d223108773dfd65838707f00b23c83bdc2
|
a50b4ad211261a3d37a53eafd67770d57568dbeb
|
refs/heads/develop
| 2023-08-30T07:03:32.700384
| 2023-08-29T15:18:36
| 2023-08-29T15:18:36
| 232,312,458
| 896
| 254
| null | 2023-09-14T15:54:13
| 2020-01-07T11:42:53
|
Rust
|
UTF-8
|
C
| false
| false
| 358
|
c
|
arm64-vct.c
|
// version 20230105
// public domain
// djb
// adapted from supercop/cpucycles/vct.c
#include "cpucycles_internal.h"
long long ticks(void)
{
long long result;
asm volatile("mrs %0, CNTVCT_EL0" : "=r" (result));
return result;
}
long long ticks_setup(void)
{
if (!cpucycles_works(ticks)) return cpucycles_SKIP;
return cpucycles_FINDMULTIPLIER;
}
|
06491a5a27a2ddef41c62fc33d0230cefb6016fc
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/drivers/ata/libata-acpi.c
|
cf4e7020adacde5e69881a21adb0c578d31d7a3e
|
[
"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
| 28,836
|
c
|
libata-acpi.c
|
/*
* libata-acpi.c
* Provides ACPI support for PATA/SATA.
*
* Copyright (C) 2006 Intel Corp.
* Copyright (C) 2006 Randy Dunlap
*/
#include <linux/module.h>
#include <linux/ata.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/libata.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <scsi/scsi_device.h>
#include "libata.h"
#include <acpi/acpi_bus.h>
unsigned int ata_acpi_gtf_filter = ATA_ACPI_FILTER_DEFAULT;
module_param_named(acpi_gtf_filter, ata_acpi_gtf_filter, int, 0644);
MODULE_PARM_DESC(acpi_gtf_filter, "filter mask for ACPI _GTF commands, set to filter out (0x1=set xfermode, 0x2=lock/freeze lock, 0x4=DIPM, 0x8=FPDMA non-zero offset, 0x10=FPDMA DMA Setup FIS auto-activate)");
#define NO_PORT_MULT 0xffff
#define SATA_ADR(root, pmp) (((root) << 16) | (pmp))
#define REGS_PER_GTF 7
struct ata_acpi_gtf {
u8 tf[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */
} __packed;
/*
* Helper - belongs in the PCI layer somewhere eventually
*/
static int is_pci_dev(struct device *dev)
{
return (dev->bus == &pci_bus_type);
}
static void ata_acpi_clear_gtf(struct ata_device *dev)
{
kfree(dev->gtf_cache);
dev->gtf_cache = NULL;
}
/**
* ata_ap_acpi_handle - provide the acpi_handle for an ata_port
* @ap: the acpi_handle returned will correspond to this port
*
* Returns the acpi_handle for the ACPI namespace object corresponding to
* the ata_port passed into the function, or NULL if no such object exists
*/
acpi_handle ata_ap_acpi_handle(struct ata_port *ap)
{
if (ap->flags & ATA_FLAG_ACPI_SATA)
return NULL;
return ap->scsi_host ?
DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL;
}
EXPORT_SYMBOL(ata_ap_acpi_handle);
/**
* ata_dev_acpi_handle - provide the acpi_handle for an ata_device
* @dev: the acpi_device returned will correspond to this port
*
* Returns the acpi_handle for the ACPI namespace object corresponding to
* the ata_device passed into the function, or NULL if no such object exists
*/
acpi_handle ata_dev_acpi_handle(struct ata_device *dev)
{
acpi_integer adr;
struct ata_port *ap = dev->link->ap;
if (libata_noacpi || dev->flags & ATA_DFLAG_ACPI_DISABLED)
return NULL;
if (ap->flags & ATA_FLAG_ACPI_SATA) {
if (!sata_pmp_attached(ap))
adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
else
adr = SATA_ADR(ap->port_no, dev->link->pmp);
return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), adr);
} else
return acpi_get_child(ata_ap_acpi_handle(ap), dev->devno);
}
EXPORT_SYMBOL(ata_dev_acpi_handle);
/* @ap and @dev are the same as ata_acpi_handle_hotplug() */
static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
{
if (dev)
dev->flags |= ATA_DFLAG_DETACH;
else {
struct ata_link *tlink;
struct ata_device *tdev;
ata_for_each_link(tlink, ap, EDGE)
ata_for_each_dev(tdev, tlink, ALL)
tdev->flags |= ATA_DFLAG_DETACH;
}
ata_port_schedule_eh(ap);
}
/**
* ata_acpi_handle_hotplug - ACPI event handler backend
* @ap: ATA port ACPI event occurred
* @dev: ATA device ACPI event occurred (can be NULL)
* @event: ACPI event which occurred
*
* All ACPI bay / device realted events end up in this function. If
* the event is port-wide @dev is NULL. If the event is specific to a
* device, @dev points to it.
*
* Hotplug (as opposed to unplug) notification is always handled as
* port-wide while unplug only kills the target device on device-wide
* event.
*
* LOCKING:
* ACPI notify handler context. May sleep.
*/
static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
u32 event)
{
struct ata_eh_info *ehi = &ap->link.eh_info;
int wait = 0;
unsigned long flags;
spin_lock_irqsave(ap->lock, flags);
/*
* When dock driver calls into the routine, it will always use
* ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
* ACPI_NOTIFY_EJECT_REQUEST for remove
*/
switch (event) {
case ACPI_NOTIFY_BUS_CHECK:
case ACPI_NOTIFY_DEVICE_CHECK:
ata_ehi_push_desc(ehi, "ACPI event");
ata_ehi_hotplugged(ehi);
ata_port_freeze(ap);
break;
case ACPI_NOTIFY_EJECT_REQUEST:
ata_ehi_push_desc(ehi, "ACPI event");
ata_acpi_detach_device(ap, dev);
wait = 1;
break;
}
spin_unlock_irqrestore(ap->lock, flags);
if (wait) {
ata_port_wait_eh(ap);
flush_work(&ap->hotplug_task.work);
}
}
static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data)
{
struct ata_device *dev = data;
ata_acpi_handle_hotplug(dev->link->ap, dev, event);
}
static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data)
{
struct ata_port *ap = data;
ata_acpi_handle_hotplug(ap, NULL, event);
}
static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev,
u32 event)
{
struct kobject *kobj = NULL;
char event_string[20];
char *envp[] = { event_string, NULL };
if (dev) {
if (dev->sdev)
kobj = &dev->sdev->sdev_gendev.kobj;
} else
kobj = &ap->dev->kobj;
if (kobj) {
snprintf(event_string, 20, "BAY_EVENT=%d", event);
kobject_uevent_env(kobj, KOBJ_CHANGE, envp);
}
}
static void ata_acpi_ap_uevent(acpi_handle handle, u32 event, void *data)
{
ata_acpi_uevent(data, NULL, event);
}
static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data)
{
struct ata_device *dev = data;
ata_acpi_uevent(dev->link->ap, dev, event);
}
static const struct acpi_dock_ops ata_acpi_dev_dock_ops = {
.handler = ata_acpi_dev_notify_dock,
.uevent = ata_acpi_dev_uevent,
};
static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
.handler = ata_acpi_ap_notify_dock,
.uevent = ata_acpi_ap_uevent,
};
void ata_acpi_hotplug_init(struct ata_host *host)
{
int i;
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];
acpi_handle handle;
struct ata_device *dev;
if (!ap)
continue;
handle = ata_ap_acpi_handle(ap);
if (handle) {
/* we might be on a docking station */
register_hotplug_dock_device(handle,
&ata_acpi_ap_dock_ops, ap,
NULL, NULL);
}
ata_for_each_dev(dev, &ap->link, ALL) {
handle = ata_dev_acpi_handle(dev);
if (!handle)
continue;
/* we might be on a docking station */
register_hotplug_dock_device(handle,
&ata_acpi_dev_dock_ops,
dev, NULL, NULL);
}
}
}
/**
* ata_acpi_dissociate - dissociate ATA host from ACPI objects
* @host: target ATA host
*
* This function is called during driver detach after the whole host
* is shut down.
*
* LOCKING:
* EH context.
*/
void ata_acpi_dissociate(struct ata_host *host)
{
int i;
/* Restore initial _GTM values so that driver which attaches
* afterward can use them too.
*/
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];
const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap);
if (ata_ap_acpi_handle(ap) && gtm)
ata_acpi_stm(ap, gtm);
}
}
static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle,
struct ata_acpi_gtm *gtm)
{
struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER };
union acpi_object *out_obj;
acpi_status status;
int rc = 0;
status = acpi_evaluate_object(handle, "_GTM", NULL, &output);
rc = -ENOENT;
if (status == AE_NOT_FOUND)
goto out_free;
rc = -EINVAL;
if (ACPI_FAILURE(status)) {
ata_port_err(ap, "ACPI get timing mode failed (AE 0x%x)\n",
status);
goto out_free;
}
out_obj = output.pointer;
if (out_obj->type != ACPI_TYPE_BUFFER) {
ata_port_warn(ap, "_GTM returned unexpected object type 0x%x\n",
out_obj->type);
goto out_free;
}
if (out_obj->buffer.length != sizeof(struct ata_acpi_gtm)) {
ata_port_err(ap, "_GTM returned invalid length %d\n",
out_obj->buffer.length);
goto out_free;
}
memcpy(gtm, out_obj->buffer.pointer, sizeof(struct ata_acpi_gtm));
rc = 0;
out_free:
kfree(output.pointer);
return rc;
}
/**
* ata_acpi_gtm - execute _GTM
* @ap: target ATA port
* @gtm: out parameter for _GTM result
*
* Evaluate _GTM and store the result in @gtm.
*
* LOCKING:
* EH context.
*
* RETURNS:
* 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
*/
int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
{
if (ata_ap_acpi_handle(ap))
return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm);
else
return -EINVAL;
}
EXPORT_SYMBOL_GPL(ata_acpi_gtm);
/**
* ata_acpi_stm - execute _STM
* @ap: target ATA port
* @stm: timing parameter to _STM
*
* Evaluate _STM with timing parameter @stm.
*
* LOCKING:
* EH context.
*
* RETURNS:
* 0 on success, -ENOENT if _STM doesn't exist, -errno on failure.
*/
int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm)
{
acpi_status status;
struct ata_acpi_gtm stm_buf = *stm;
struct acpi_object_list input;
union acpi_object in_params[3];
in_params[0].type = ACPI_TYPE_BUFFER;
in_params[0].buffer.length = sizeof(struct ata_acpi_gtm);
in_params[0].buffer.pointer = (u8 *)&stm_buf;
/* Buffers for id may need byteswapping ? */
in_params[1].type = ACPI_TYPE_BUFFER;
in_params[1].buffer.length = 512;
in_params[1].buffer.pointer = (u8 *)ap->link.device[0].id;
in_params[2].type = ACPI_TYPE_BUFFER;
in_params[2].buffer.length = 512;
in_params[2].buffer.pointer = (u8 *)ap->link.device[1].id;
input.count = 3;
input.pointer = in_params;
status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_STM", &input,
NULL);
if (status == AE_NOT_FOUND)
return -ENOENT;
if (ACPI_FAILURE(status)) {
ata_port_err(ap, "ACPI set timing mode failed (status=0x%x)\n",
status);
return -EINVAL;
}
return 0;
}
EXPORT_SYMBOL_GPL(ata_acpi_stm);
/**
* ata_dev_get_GTF - get the drive bootup default taskfile settings
* @dev: target ATA device
* @gtf: output parameter for buffer containing _GTF taskfile arrays
*
* This applies to both PATA and SATA drives.
*
* The _GTF method has no input parameters.
* It returns a variable number of register set values (registers
* hex 1F1..1F7, taskfiles).
* The <variable number> is not known in advance, so have ACPI-CA
* allocate the buffer as needed and return it, then free it later.
*
* LOCKING:
* EH context.
*
* RETURNS:
* Number of taskfiles on success, 0 if _GTF doesn't exist. -EINVAL
* if _GTF is invalid.
*/
static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
{
struct ata_port *ap = dev->link->ap;
acpi_status status;
struct acpi_buffer output;
union acpi_object *out_obj;
int rc = 0;
/* if _GTF is cached, use the cached value */
if (dev->gtf_cache) {
out_obj = dev->gtf_cache;
goto done;
}
/* set up output buffer */
output.length = ACPI_ALLOCATE_BUFFER;
output.pointer = NULL; /* ACPI-CA sets this; save/free it later */
if (ata_msg_probe(ap))
ata_dev_dbg(dev, "%s: ENTER: port#: %d\n",
__func__, ap->port_no);
/* _GTF has no input parameters */
status = acpi_evaluate_object(ata_dev_acpi_handle(dev), "_GTF", NULL,
&output);
out_obj = dev->gtf_cache = output.pointer;
if (ACPI_FAILURE(status)) {
if (status != AE_NOT_FOUND) {
ata_dev_warn(dev, "_GTF evaluation failed (AE 0x%x)\n",
status);
rc = -EINVAL;
}
goto out_free;
}
if (!output.length || !output.pointer) {
if (ata_msg_probe(ap))
ata_dev_dbg(dev, "%s: Run _GTF: length or ptr is NULL (0x%llx, 0x%p)\n",
__func__,
(unsigned long long)output.length,
output.pointer);
rc = -EINVAL;
goto out_free;
}
if (out_obj->type != ACPI_TYPE_BUFFER) {
ata_dev_warn(dev, "_GTF unexpected object type 0x%x\n",
out_obj->type);
rc = -EINVAL;
goto out_free;
}
if (out_obj->buffer.length % REGS_PER_GTF) {
ata_dev_warn(dev, "unexpected _GTF length (%d)\n",
out_obj->buffer.length);
rc = -EINVAL;
goto out_free;
}
done:
rc = out_obj->buffer.length / REGS_PER_GTF;
if (gtf) {
*gtf = (void *)out_obj->buffer.pointer;
if (ata_msg_probe(ap))
ata_dev_dbg(dev, "%s: returning gtf=%p, gtf_count=%d\n",
__func__, *gtf, rc);
}
return rc;
out_free:
ata_acpi_clear_gtf(dev);
return rc;
}
/**
* ata_acpi_gtm_xfermode - determine xfermode from GTM parameter
* @dev: target device
* @gtm: GTM parameter to use
*
* Determine xfermask for @dev from @gtm.
*
* LOCKING:
* None.
*
* RETURNS:
* Determined xfermask.
*/
unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
const struct ata_acpi_gtm *gtm)
{
unsigned long xfer_mask = 0;
unsigned int type;
int unit;
u8 mode;
/* we always use the 0 slot for crap hardware */
unit = dev->devno;
if (!(gtm->flags & 0x10))
unit = 0;
/* PIO */
mode = ata_timing_cycle2mode(ATA_SHIFT_PIO, gtm->drive[unit].pio);
xfer_mask |= ata_xfer_mode2mask(mode);
/* See if we have MWDMA or UDMA data. We don't bother with
* MWDMA if UDMA is available as this means the BIOS set UDMA
* and our error changedown if it works is UDMA to PIO anyway.
*/
if (!(gtm->flags & (1 << (2 * unit))))
type = ATA_SHIFT_MWDMA;
else
type = ATA_SHIFT_UDMA;
mode = ata_timing_cycle2mode(type, gtm->drive[unit].dma);
xfer_mask |= ata_xfer_mode2mask(mode);
return xfer_mask;
}
EXPORT_SYMBOL_GPL(ata_acpi_gtm_xfermask);
/**
* ata_acpi_cbl_80wire - Check for 80 wire cable
* @ap: Port to check
* @gtm: GTM data to use
*
* Return 1 if the @gtm indicates the BIOS selected an 80wire mode.
*/
int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm)
{
struct ata_device *dev;
ata_for_each_dev(dev, &ap->link, ENABLED) {
unsigned long xfer_mask, udma_mask;
xfer_mask = ata_acpi_gtm_xfermask(dev, gtm);
ata_unpack_xfermask(xfer_mask, NULL, NULL, &udma_mask);
if (udma_mask & ~ATA_UDMA_MASK_40C)
return 1;
}
return 0;
}
EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire);
static void ata_acpi_gtf_to_tf(struct ata_device *dev,
const struct ata_acpi_gtf *gtf,
struct ata_taskfile *tf)
{
ata_tf_init(dev, tf);
tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
tf->protocol = ATA_PROT_NODATA;
tf->feature = gtf->tf[0]; /* 0x1f1 */
tf->nsect = gtf->tf[1]; /* 0x1f2 */
tf->lbal = gtf->tf[2]; /* 0x1f3 */
tf->lbam = gtf->tf[3]; /* 0x1f4 */
tf->lbah = gtf->tf[4]; /* 0x1f5 */
tf->device = gtf->tf[5]; /* 0x1f6 */
tf->command = gtf->tf[6]; /* 0x1f7 */
}
static int ata_acpi_filter_tf(struct ata_device *dev,
const struct ata_taskfile *tf,
const struct ata_taskfile *ptf)
{
if (dev->gtf_filter & ATA_ACPI_FILTER_SETXFER) {
/* libata doesn't use ACPI to configure transfer mode.
* It will only confuse device configuration. Skip.
*/
if (tf->command == ATA_CMD_SET_FEATURES &&
tf->feature == SETFEATURES_XFER)
return 1;
}
if (dev->gtf_filter & ATA_ACPI_FILTER_LOCK) {
/* BIOS writers, sorry but we don't wanna lock
* features unless the user explicitly said so.
*/
/* DEVICE CONFIGURATION FREEZE LOCK */
if (tf->command == ATA_CMD_CONF_OVERLAY &&
tf->feature == ATA_DCO_FREEZE_LOCK)
return 1;
/* SECURITY FREEZE LOCK */
if (tf->command == ATA_CMD_SEC_FREEZE_LOCK)
return 1;
/* SET MAX LOCK and SET MAX FREEZE LOCK */
if ((!ptf || ptf->command != ATA_CMD_READ_NATIVE_MAX) &&
tf->command == ATA_CMD_SET_MAX &&
(tf->feature == ATA_SET_MAX_LOCK ||
tf->feature == ATA_SET_MAX_FREEZE_LOCK))
return 1;
}
if (tf->command == ATA_CMD_SET_FEATURES &&
tf->feature == SETFEATURES_SATA_ENABLE) {
/* inhibit enabling DIPM */
if (dev->gtf_filter & ATA_ACPI_FILTER_DIPM &&
tf->nsect == SATA_DIPM)
return 1;
/* inhibit FPDMA non-zero offset */
if (dev->gtf_filter & ATA_ACPI_FILTER_FPDMA_OFFSET &&
(tf->nsect == SATA_FPDMA_OFFSET ||
tf->nsect == SATA_FPDMA_IN_ORDER))
return 1;
/* inhibit FPDMA auto activation */
if (dev->gtf_filter & ATA_ACPI_FILTER_FPDMA_AA &&
tf->nsect == SATA_FPDMA_AA)
return 1;
}
return 0;
}
/**
* ata_acpi_run_tf - send taskfile registers to host controller
* @dev: target ATA device
* @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
*
* Outputs ATA taskfile to standard ATA host controller.
* Writes the control, feature, nsect, lbal, lbam, and lbah registers.
* Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect,
* hob_lbal, hob_lbam, and hob_lbah.
*
* This function waits for idle (!BUSY and !DRQ) after writing
* registers. If the control register has a new value, this
* function also waits for idle after writing control and before
* writing the remaining registers.
*
* LOCKING:
* EH context.
*
* RETURNS:
* 1 if command is executed successfully. 0 if ignored, rejected or
* filtered out, -errno on other errors.
*/
static int ata_acpi_run_tf(struct ata_device *dev,
const struct ata_acpi_gtf *gtf,
const struct ata_acpi_gtf *prev_gtf)
{
struct ata_taskfile *pptf = NULL;
struct ata_taskfile tf, ptf, rtf;
unsigned int err_mask;
const char *level;
const char *descr;
char msg[60];
int rc;
if ((gtf->tf[0] == 0) && (gtf->tf[1] == 0) && (gtf->tf[2] == 0)
&& (gtf->tf[3] == 0) && (gtf->tf[4] == 0) && (gtf->tf[5] == 0)
&& (gtf->tf[6] == 0))
return 0;
ata_acpi_gtf_to_tf(dev, gtf, &tf);
if (prev_gtf) {
ata_acpi_gtf_to_tf(dev, prev_gtf, &ptf);
pptf = &ptf;
}
if (!ata_acpi_filter_tf(dev, &tf, pptf)) {
rtf = tf;
err_mask = ata_exec_internal(dev, &rtf, NULL,
DMA_NONE, NULL, 0, 0);
switch (err_mask) {
case 0:
level = KERN_DEBUG;
snprintf(msg, sizeof(msg), "succeeded");
rc = 1;
break;
case AC_ERR_DEV:
level = KERN_INFO;
snprintf(msg, sizeof(msg),
"rejected by device (Stat=0x%02x Err=0x%02x)",
rtf.command, rtf.feature);
rc = 0;
break;
default:
level = KERN_ERR;
snprintf(msg, sizeof(msg),
"failed (Emask=0x%x Stat=0x%02x Err=0x%02x)",
err_mask, rtf.command, rtf.feature);
rc = -EIO;
break;
}
} else {
level = KERN_INFO;
snprintf(msg, sizeof(msg), "filtered out");
rc = 0;
}
descr = ata_get_cmd_descript(tf.command);
ata_dev_printk(dev, level,
"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x (%s) %s\n",
tf.command, tf.feature, tf.nsect, tf.lbal,
tf.lbam, tf.lbah, tf.device,
(descr ? descr : "unknown"), msg);
return rc;
}
/**
* ata_acpi_exec_tfs - get then write drive taskfile settings
* @dev: target ATA device
* @nr_executed: out parameter for the number of executed commands
*
* Evaluate _GTF and execute returned taskfiles.
*
* LOCKING:
* EH context.
*
* RETURNS:
* Number of executed taskfiles on success, 0 if _GTF doesn't exist.
* -errno on other errors.
*/
static int ata_acpi_exec_tfs(struct ata_device *dev, int *nr_executed)
{
struct ata_acpi_gtf *gtf = NULL, *pgtf = NULL;
int gtf_count, i, rc;
/* get taskfiles */
rc = ata_dev_get_GTF(dev, >f);
if (rc < 0)
return rc;
gtf_count = rc;
/* execute them */
for (i = 0; i < gtf_count; i++, gtf++) {
rc = ata_acpi_run_tf(dev, gtf, pgtf);
if (rc < 0)
break;
if (rc) {
(*nr_executed)++;
pgtf = gtf;
}
}
ata_acpi_clear_gtf(dev);
if (rc < 0)
return rc;
return 0;
}
/**
* ata_acpi_push_id - send Identify data to drive
* @dev: target ATA device
*
* _SDD ACPI object: for SATA mode only
* Must be after Identify (Packet) Device -- uses its data
* ATM this function never returns a failure. It is an optional
* method and if it fails for whatever reason, we should still
* just keep going.
*
* LOCKING:
* EH context.
*
* RETURNS:
* 0 on success, -ENOENT if _SDD doesn't exist, -errno on failure.
*/
static int ata_acpi_push_id(struct ata_device *dev)
{
struct ata_port *ap = dev->link->ap;
acpi_status status;
struct acpi_object_list input;
union acpi_object in_params[1];
if (ata_msg_probe(ap))
ata_dev_dbg(dev, "%s: ix = %d, port#: %d\n",
__func__, dev->devno, ap->port_no);
/* Give the drive Identify data to the drive via the _SDD method */
/* _SDD: set up input parameters */
input.count = 1;
input.pointer = in_params;
in_params[0].type = ACPI_TYPE_BUFFER;
in_params[0].buffer.length = sizeof(dev->id[0]) * ATA_ID_WORDS;
in_params[0].buffer.pointer = (u8 *)dev->id;
/* Output buffer: _SDD has no output */
/* It's OK for _SDD to be missing too. */
swap_buf_le16(dev->id, ATA_ID_WORDS);
status = acpi_evaluate_object(ata_dev_acpi_handle(dev), "_SDD", &input,
NULL);
swap_buf_le16(dev->id, ATA_ID_WORDS);
if (status == AE_NOT_FOUND)
return -ENOENT;
if (ACPI_FAILURE(status)) {
ata_dev_warn(dev, "ACPI _SDD failed (AE 0x%x)\n", status);
return -EIO;
}
return 0;
}
/**
* ata_acpi_on_suspend - ATA ACPI hook called on suspend
* @ap: target ATA port
*
* This function is called when @ap is about to be suspended. All
* devices are already put to sleep but the port_suspend() callback
* hasn't been executed yet. Error return from this function aborts
* suspend.
*
* LOCKING:
* EH context.
*
* RETURNS:
* 0 on success, -errno on failure.
*/
int ata_acpi_on_suspend(struct ata_port *ap)
{
/* nada */
return 0;
}
/**
* ata_acpi_on_resume - ATA ACPI hook called on resume
* @ap: target ATA port
*
* This function is called when @ap is resumed - right after port
* itself is resumed but before any EH action is taken.
*
* LOCKING:
* EH context.
*/
void ata_acpi_on_resume(struct ata_port *ap)
{
const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap);
struct ata_device *dev;
if (ata_ap_acpi_handle(ap) && gtm) {
/* _GTM valid */
/* restore timing parameters */
ata_acpi_stm(ap, gtm);
/* _GTF should immediately follow _STM so that it can
* use values set by _STM. Cache _GTF result and
* schedule _GTF.
*/
ata_for_each_dev(dev, &ap->link, ALL) {
ata_acpi_clear_gtf(dev);
if (ata_dev_enabled(dev) &&
ata_dev_get_GTF(dev, NULL) >= 0)
dev->flags |= ATA_DFLAG_ACPI_PENDING;
}
} else {
/* SATA _GTF needs to be evaulated after _SDD and
* there's no reason to evaluate IDE _GTF early
* without _STM. Clear cache and schedule _GTF.
*/
ata_for_each_dev(dev, &ap->link, ALL) {
ata_acpi_clear_gtf(dev);
if (ata_dev_enabled(dev))
dev->flags |= ATA_DFLAG_ACPI_PENDING;
}
}
}
static int ata_acpi_choose_suspend_state(struct ata_device *dev, bool runtime)
{
int d_max_in = ACPI_STATE_D3_COLD;
if (!runtime)
goto out;
/*
* For ATAPI, runtime D3 cold is only allowed
* for ZPODD in zero power ready state
*/
if (dev->class == ATA_DEV_ATAPI &&
!(zpodd_dev_enabled(dev) && zpodd_zpready(dev)))
d_max_in = ACPI_STATE_D3_HOT;
out:
return acpi_pm_device_sleep_state(&dev->sdev->sdev_gendev,
NULL, d_max_in);
}
static void sata_acpi_set_state(struct ata_port *ap, pm_message_t state)
{
bool runtime = PMSG_IS_AUTO(state);
struct ata_device *dev;
acpi_handle handle;
int acpi_state;
ata_for_each_dev(dev, &ap->link, ENABLED) {
handle = ata_dev_acpi_handle(dev);
if (!handle)
continue;
if (!(state.event & PM_EVENT_RESUME)) {
acpi_state = ata_acpi_choose_suspend_state(dev, runtime);
if (acpi_state == ACPI_STATE_D0)
continue;
if (runtime && zpodd_dev_enabled(dev) &&
acpi_state == ACPI_STATE_D3_COLD)
zpodd_enable_run_wake(dev);
acpi_bus_set_power(handle, acpi_state);
} else {
if (runtime && zpodd_dev_enabled(dev))
zpodd_disable_run_wake(dev);
acpi_bus_set_power(handle, ACPI_STATE_D0);
}
}
}
/* ACPI spec requires _PS0 when IDE power on and _PS3 when power off */
static void pata_acpi_set_state(struct ata_port *ap, pm_message_t state)
{
struct ata_device *dev;
acpi_handle port_handle;
port_handle = ata_ap_acpi_handle(ap);
if (!port_handle)
return;
/* channel first and then drives for power on and vica versa
for power off */
if (state.event & PM_EVENT_RESUME)
acpi_bus_set_power(port_handle, ACPI_STATE_D0);
ata_for_each_dev(dev, &ap->link, ENABLED) {
acpi_handle dev_handle = ata_dev_acpi_handle(dev);
if (!dev_handle)
continue;
acpi_bus_set_power(dev_handle, state.event & PM_EVENT_RESUME ?
ACPI_STATE_D0 : ACPI_STATE_D3);
}
if (!(state.event & PM_EVENT_RESUME))
acpi_bus_set_power(port_handle, ACPI_STATE_D3);
}
/**
* ata_acpi_set_state - set the port power state
* @ap: target ATA port
* @state: state, on/off
*
* This function sets a proper ACPI D state for the device on
* system and runtime PM operations.
*/
void ata_acpi_set_state(struct ata_port *ap, pm_message_t state)
{
if (ap->flags & ATA_FLAG_ACPI_SATA)
sata_acpi_set_state(ap, state);
else
pata_acpi_set_state(ap, state);
}
/**
* ata_acpi_on_devcfg - ATA ACPI hook called on device donfiguration
* @dev: target ATA device
*
* This function is called when @dev is about to be configured.
* IDENTIFY data might have been modified after this hook is run.
*
* LOCKING:
* EH context.
*
* RETURNS:
* Positive number if IDENTIFY data needs to be refreshed, 0 if not,
* -errno on failure.
*/
int ata_acpi_on_devcfg(struct ata_device *dev)
{
struct ata_port *ap = dev->link->ap;
struct ata_eh_context *ehc = &ap->link.eh_context;
int acpi_sata = ap->flags & ATA_FLAG_ACPI_SATA;
int nr_executed = 0;
int rc;
if (!ata_dev_acpi_handle(dev))
return 0;
/* do we need to do _GTF? */
if (!(dev->flags & ATA_DFLAG_ACPI_PENDING) &&
!(acpi_sata && (ehc->i.flags & ATA_EHI_DID_HARDRESET)))
return 0;
/* do _SDD if SATA */
if (acpi_sata) {
rc = ata_acpi_push_id(dev);
if (rc && rc != -ENOENT)
goto acpi_err;
}
/* do _GTF */
rc = ata_acpi_exec_tfs(dev, &nr_executed);
if (rc)
goto acpi_err;
dev->flags &= ~ATA_DFLAG_ACPI_PENDING;
/* refresh IDENTIFY page if any _GTF command has been executed */
if (nr_executed) {
rc = ata_dev_reread_id(dev, 0);
if (rc < 0) {
ata_dev_err(dev,
"failed to IDENTIFY after ACPI commands\n");
return rc;
}
}
return 0;
acpi_err:
/* ignore evaluation failure if we can continue safely */
if (rc == -EINVAL && !nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN))
return 0;
/* fail and let EH retry once more for unknown IO errors */
if (!(dev->flags & ATA_DFLAG_ACPI_FAILED)) {
dev->flags |= ATA_DFLAG_ACPI_FAILED;
return rc;
}
dev->flags |= ATA_DFLAG_ACPI_DISABLED;
ata_dev_warn(dev, "ACPI: failed the second time, disabled\n");
/* We can safely continue if no _GTF command has been executed
* and port is not frozen.
*/
if (!nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN))
return 0;
return rc;
}
/**
* ata_acpi_on_disable - ATA ACPI hook called when a device is disabled
* @dev: target ATA device
*
* This function is called when @dev is about to be disabled.
*
* LOCKING:
* EH context.
*/
void ata_acpi_on_disable(struct ata_device *dev)
{
ata_acpi_clear_gtf(dev);
}
static int compat_pci_ata(struct ata_port *ap)
{
struct device *dev = ap->tdev.parent;
struct pci_dev *pdev;
if (!is_pci_dev(dev))
return 0;
pdev = to_pci_dev(dev);
if ((pdev->class >> 8) != PCI_CLASS_STORAGE_SATA &&
(pdev->class >> 8) != PCI_CLASS_STORAGE_IDE)
return 0;
return 1;
}
static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle)
{
if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA)
return -ENODEV;
*handle = acpi_get_child(DEVICE_ACPI_HANDLE(ap->tdev.parent),
ap->port_no);
if (!*handle)
return -ENODEV;
if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0)
ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
return 0;
}
static int ata_acpi_bind_device(struct ata_port *ap, struct scsi_device *sdev,
acpi_handle *handle)
{
struct ata_device *ata_dev;
if (ap->flags & ATA_FLAG_ACPI_SATA) {
if (!sata_pmp_attached(ap))
ata_dev = &ap->link.device[sdev->id];
else
ata_dev = &ap->pmp_link[sdev->channel].device[sdev->id];
}
else {
ata_dev = &ap->link.device[sdev->id];
}
*handle = ata_dev_acpi_handle(ata_dev);
if (!*handle)
return -ENODEV;
return 0;
}
static int is_ata_port(const struct device *dev)
{
return dev->type == &ata_port_type;
}
static struct ata_port *dev_to_ata_port(struct device *dev)
{
while (!is_ata_port(dev)) {
if (!dev->parent)
return NULL;
dev = dev->parent;
}
return to_ata_port(dev);
}
static int ata_acpi_find_device(struct device *dev, acpi_handle *handle)
{
struct ata_port *ap = dev_to_ata_port(dev);
if (!ap)
return -ENODEV;
if (!compat_pci_ata(ap))
return -ENODEV;
if (scsi_is_host_device(dev))
return ata_acpi_bind_host(ap, handle);
else if (scsi_is_sdev_device(dev)) {
struct scsi_device *sdev = to_scsi_device(dev);
return ata_acpi_bind_device(ap, sdev, handle);
} else
return -ENODEV;
}
static struct acpi_bus_type ata_acpi_bus = {
.name = "ATA",
.find_device = ata_acpi_find_device,
};
int ata_acpi_register(void)
{
return scsi_register_acpi_bus_type(&ata_acpi_bus);
}
void ata_acpi_unregister(void)
{
scsi_unregister_acpi_bus_type(&ata_acpi_bus);
}
|
2c46152f1f756de53a2675017404209e5c59d290
|
5ff4b6986e6799bc0e143e060bafc14369030d8b
|
/toolchain/riscv-isa-sim/riscv/insns/vwsub_wx.h
|
f72341ba8089e65f75d81736fd4140f0748d8ef6
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later",
"LLVM-exception",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-bsd-3-clause-jtag",
"GPL-3.0-or-later"
] |
permissive
|
pulp-platform/mempool
|
7583204b2436cfc12ed95599463e51ad4df51557
|
c98fb3ada4f255623eaf9b09861f397a60c3d96b
|
refs/heads/main
| 2023-08-08T09:07:56.696580
| 2023-07-27T17:24:38
| 2023-07-27T17:24:38
| 223,218,149
| 178
| 28
|
Apache-2.0
| 2023-07-27T17:24:39
| 2019-11-21T16:34:37
|
C
|
UTF-8
|
C
| false
| false
| 100
|
h
|
vwsub_wx.h
|
// vwsub.wx vd, vs2, rs1
VI_CHECK_DDS(false);
VI_VX_LOOP_WIDEN
({
VI_WIDE_WVX_OP(rs1, -, int);
})
|
582a6be3045da41d01f0156b34d1546ab97310e7
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/evbarm/stand/bootimx23/power_prep.c
|
6ea9e175e2fe6cce77285e4c506986b1c3b932f6
|
[] |
no_license
|
NetBSD/src
|
1a9cbc22ed778be638b37869ed4fb5c8dd616166
|
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
|
refs/heads/trunk
| 2023-08-31T13:24:58.105962
| 2023-08-27T15:50:47
| 2023-08-27T15:50:47
| 88,439,547
| 656
| 348
| null | 2023-07-20T20:07:24
| 2017-04-16T20:03:43
| null |
UTF-8
|
C
| false
| false
| 11,314
|
c
|
power_prep.c
|
/* $Id: power_prep.c,v 1.5 2016/08/17 22:04:51 skrll Exp $ */
/*
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Petri Laakso.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <arm/imx/imx23_powerreg.h>
#include <lib/libkern/libkern.h>
#include <lib/libsa/stand.h>
#include "common.h"
#define PWR_CTRL (HW_POWER_BASE + HW_POWER_CTRL)
#define PWR_CTRL_S (HW_POWER_BASE + HW_POWER_CTRL_SET)
#define PWR_CTRL_C (HW_POWER_BASE + HW_POWER_CTRL_CLR)
#define PWR_5VCTRL (HW_POWER_BASE + HW_POWER_5VCTRL)
#define PWR_5VCTRL_S (HW_POWER_BASE + HW_POWER_5VCTRL_SET)
#define PWR_5VCTRL_C (HW_POWER_BASE + HW_POWER_5VCTRL_CLR)
#define PWR_MINPWR (HW_POWER_BASE + HW_POWER_MINPWR)
#define PWR_MINPWR_S (HW_POWER_BASE + HW_POWER_MINPWR_SET)
#define PWR_MINPWR_C (HW_POWER_BASE + HW_POWER_MINPWR_CLR)
#define PWR_CHARGE (HW_POWER_BASE + HW_POWER_CHARGE)
#define PWR_CHARGE_S (HW_POWER_BASE + HW_POWER_CHARGE_SET)
#define PWR_CHARGE_C (HW_POWER_BASE + HW_POWER_CHARGE_CLR)
#define PWR_VDDDCTRL (HW_POWER_BASE + HW_POWER_VDDDCTRL)
#define PWR_VDDACTRL (HW_POWER_BASE + HW_POWER_VDDACTRL)
#define PWR_VDDIOCTRL (HW_POWER_BASE + HW_POWER_VDDIOCTRL)
#define PWR_VDDMEMCTRL (HW_POWER_BASE + HW_POWER_VDDMEMCTRL)
#define PWR_DCDC4P2 (HW_POWER_BASE + HW_POWER_DCDC4P2)
#define PWR_MISC (HW_POWER_BASE + HW_POWER_MISC)
#define PWR_DCLIMITS (HW_POWER_BASE + HW_POWER_DCLIMITS)
#define PWR_LOOPCTRL (HW_POWER_BASE + HW_POWER_LOOPCTRL)
#define PWR_LOOPCTRL_S (HW_POWER_BASE + HW_POWER_LOOPCTRL_SET)
#define PWR_LOOPCTRL_C (HW_POWER_BASE + HW_POWER_LOOPCTRL_CLR)
#define PWR_STATUS (HW_POWER_BASE + HW_POWER_STS)
#define PWR_SPEED (HW_POWER_BASE + HW_POWER_SPEED)
#define PWR_BATTMONITOR (HW_POWER_BASE + HW_POWER_BATTMONITOR)
#define PWR_RESET (HW_POWER_BASE + HW_POWER_RESET)
#define PWR_DEBUG (HW_POWER_BASE + HW_POWER_DEBUG)
#define PWR_SPECIAL (HW_POWER_BASE + HW_POWER_SPECIAL)
#define PWR_VERSION (HW_POWER_BASE + HW_POWER_VERSION)
#define VBUSVALID_TRSH 5 /* 4.4V */
#define CHARGE_4P2_ILIMIT_MAX 0x3f
#define CMPTRIP 0x1f /* DCDC_4P2 pin >= 1.05 * BATTERY pin. */
#define DROPOUT_CTRL 0xa /* BO 100mV, DCDC selects higher. */
void en_vbusvalid(void);
int vbusvalid(void);
void power_tune(void);
void en_4p2_reg(void);
void en_4p2_to_dcdc(void);
void power_vddd_from_dcdc(int, int);
void power_vdda_from_dcdc(int, int);
void power_vddio_from_dcdc(int, int);
void power_vddmem(int);
/*
* Configure the DCDC control logic 5V detection to use VBUSVALID.
*/
void
en_vbusvalid(void)
{
uint32_t tmp_r;
tmp_r = REG_RD(PWR_5VCTRL);
tmp_r &= ~HW_POWER_5VCTRL_VBUSVALID_TRSH;
tmp_r |= __SHIFTIN(VBUSVALID_TRSH, HW_POWER_5VCTRL_VBUSVALID_TRSH);
REG_WR(PWR_5VCTRL, tmp_r);
REG_WR(PWR_5VCTRL_S, HW_POWER_5VCTRL_PWRUP_VBUS_CMPS);
delay(1000);
REG_WR(PWR_5VCTRL_S, HW_POWER_5VCTRL_VBUSVALID_5VDETECT);
return;
}
/*
* Test VBUSVALID.
*/
int
vbusvalid(void)
{
if (REG_RD(PWR_STATUS) & HW_POWER_STS_VBUSVALID)
return 1;
else
return 0;
}
/*
* Set various registers.
*/
void
power_tune(void)
{
uint32_t tmp_r;
REG_WR(PWR_LOOPCTRL_S, HW_POWER_LOOPCTRL_TOGGLE_DIF |
HW_POWER_LOOPCTRL_EN_CM_HYST |
HW_POWER_LOOPCTRL_EN_DF_HYST |
HW_POWER_LOOPCTRL_RCSCALE_THRESH |
__SHIFTIN(3, HW_POWER_LOOPCTRL_EN_RCSCALE));
REG_WR(PWR_MINPWR_S, HW_POWER_MINPWR_DOUBLE_FETS);
REG_WR(PWR_5VCTRL_S, __SHIFTIN(4, HW_POWER_5VCTRL_HEADROOM_ADJ));
tmp_r = REG_RD(PWR_DCLIMITS);
tmp_r &= ~HW_POWER_DCLIMITS_POSLIMIT_BUCK;
tmp_r |= __SHIFTIN(0x30, HW_POWER_DCLIMITS_POSLIMIT_BUCK);
REG_WR(PWR_DCLIMITS, tmp_r);
return;
}
/*
* AN3883.pdf 2.1.3.1 Enabling the 4P2 LinReg
*/
void
en_4p2_reg(void)
{
uint32_t tmp_r;
int ilimit;
/* TRG is 4.2V by default. */
tmp_r = REG_RD(PWR_DCDC4P2);
tmp_r |= HW_POWER_DCDC4P2_ENABLE_4P2;
REG_WR(PWR_DCDC4P2, tmp_r);
REG_WR(PWR_CHARGE_S, HW_POWER_CHARGE_ENABLE_LOAD);
/* Set CHARGE_4P2_ILIMIT to minimum. */
REG_WR(PWR_5VCTRL_C, HW_POWER_5VCTRL_CHARGE_4P2_ILIMIT);
REG_WR(PWR_5VCTRL_S, __SHIFTIN(1, HW_POWER_5VCTRL_CHARGE_4P2_ILIMIT));
/* Power up 4.2V regulation circuit. */
REG_WR(PWR_5VCTRL_C, HW_POWER_5VCTRL_PWD_CHARGE_4P2);
/* Ungate path from 4P2 reg to DCDC. */
tmp_r = REG_RD(PWR_DCDC4P2);
tmp_r |= HW_POWER_DCDC4P2_ENABLE_DCDC;
REG_WR(PWR_DCDC4P2, tmp_r);
delay(10000);
/* Charge 4P2 capacitance. */
tmp_r = REG_RD(PWR_5VCTRL);
for (ilimit = 2; ilimit <= CHARGE_4P2_ILIMIT_MAX; ilimit++) {
tmp_r &= ~HW_POWER_5VCTRL_CHARGE_4P2_ILIMIT;
tmp_r |= __SHIFTIN(ilimit, HW_POWER_5VCTRL_CHARGE_4P2_ILIMIT);
REG_WR(PWR_5VCTRL, tmp_r);
delay(10000);
}
return;
}
/*
* AN3883.pdf 2.1.3.3 Enabling 4P2 Input to DC-DC
*/
void en_4p2_to_dcdc(void)
{
uint32_t tmp_r;
tmp_r = REG_RD(PWR_DCDC4P2);
tmp_r &= ~HW_POWER_DCDC4P2_CMPTRIP;
tmp_r |= __SHIFTIN(CMPTRIP, HW_POWER_DCDC4P2_CMPTRIP);
tmp_r &= ~HW_POWER_DCDC4P2_DROPOUT_CTRL;
tmp_r |= __SHIFTIN(DROPOUT_CTRL, HW_POWER_DCDC4P2_DROPOUT_CTRL);
REG_WR(PWR_DCDC4P2, tmp_r);
REG_WR(PWR_5VCTRL_C, HW_POWER_5VCTRL_DCDC_XFER);
/* Enabling DCDC triggers 5V brownout. */
REG_WR(PWR_5VCTRL_C, HW_POWER_5VCTRL_PWDN_5VBRNOUT);
REG_WR(PWR_5VCTRL_S, HW_POWER_5VCTRL_ENABLE_DCDC);
delay(10000);
REG_WR(PWR_5VCTRL_S, HW_POWER_5VCTRL_PWDN_5VBRNOUT);
/* Now DCDC is using 4P2 so I can remove extra temporary load. */
REG_WR(PWR_CHARGE_C, HW_POWER_CHARGE_ENABLE_LOAD);
return;
}
/*
* Configure VDDD to source power from DCDC.
*/
void
power_vddd_from_dcdc(int target, int brownout)
{
uint32_t tmp_r;
/* BO_OFFSET must be within 800mV - 1475mV */
if (brownout > 1475)
brownout = 1475;
else if (brownout < 800)
brownout = 800;
/* Set LINREG_OFFSET one step below TRG. */
tmp_r = REG_RD(PWR_VDDDCTRL);
tmp_r &= ~HW_POWER_VDDDCTRL_LINREG_OFFSET;
tmp_r |= __SHIFTIN(2, HW_POWER_VDDDCTRL_LINREG_OFFSET);
REG_WR(PWR_VDDDCTRL, tmp_r);
delay(10000);
/* Enable VDDD switching converter output. */
tmp_r = REG_RD(PWR_VDDDCTRL);
tmp_r &= ~HW_POWER_VDDDCTRL_DISABLE_FET;
REG_WR(PWR_VDDDCTRL, tmp_r);
delay(10000);
/* Disable linear regulator output. */
tmp_r = REG_RD(PWR_VDDDCTRL);
tmp_r &= ~HW_POWER_VDDDCTRL_ENABLE_LINREG;
REG_WR(PWR_VDDDCTRL, tmp_r);
delay(10000);
/* Set target voltage and brownout level. */
tmp_r = REG_RD(PWR_VDDDCTRL);
tmp_r &= ~(HW_POWER_VDDDCTRL_BO_OFFSET | HW_POWER_VDDDCTRL_TRG);
tmp_r |= __SHIFTIN(((target - brownout) / 25),
HW_POWER_VDDDCTRL_BO_OFFSET);
tmp_r |= __SHIFTIN(((target - 800) / 25), HW_POWER_VDDDCTRL_TRG);
REG_WR(PWR_VDDDCTRL, tmp_r);
delay(10000);
/* Enable PWDN_BRNOUT. */
REG_WR(PWR_CTRL_C, HW_POWER_CTRL_VDDD_BO_IRQ);
tmp_r = REG_RD(PWR_VDDDCTRL);
tmp_r |= HW_POWER_VDDDCTRL_PWDN_BRNOUT;
REG_WR(PWR_VDDDCTRL, tmp_r);
return;
}
/*
* Configure VDDA to source power from DCDC.
*/
void
power_vdda_from_dcdc(int target, int brownout)
{
uint32_t tmp_r;
/* BO_OFFSET must be within 1400mV - 2175mV */
if (brownout > 2275)
brownout = 2275;
else if (brownout < 1400)
brownout = 1400;
/* Set LINREG_OFFSET one step below TRG. */
tmp_r = REG_RD(PWR_VDDACTRL);
tmp_r &= ~HW_POWER_VDDACTRL_LINREG_OFFSET;
tmp_r |= __SHIFTIN(2, HW_POWER_VDDACTRL_LINREG_OFFSET);
REG_WR(PWR_VDDACTRL, tmp_r);
delay(10000);
/* Enable VDDA switching converter output. */
tmp_r = REG_RD(PWR_VDDACTRL);
tmp_r &= ~HW_POWER_VDDACTRL_DISABLE_FET;
REG_WR(PWR_VDDACTRL, tmp_r);
delay(10000);
/* Disable linear regulator output. */
tmp_r = REG_RD(PWR_VDDACTRL);
tmp_r &= ~HW_POWER_VDDACTRL_ENABLE_LINREG;
REG_WR(PWR_VDDACTRL, tmp_r);
delay(10000);
/* Set target voltage and brownout level. */
tmp_r = REG_RD(PWR_VDDACTRL);
tmp_r &= ~(HW_POWER_VDDACTRL_BO_OFFSET | HW_POWER_VDDACTRL_TRG);
tmp_r |= __SHIFTIN(((target - brownout) / 25),
HW_POWER_VDDACTRL_BO_OFFSET);
tmp_r |= __SHIFTIN(((target - 1500) / 25), HW_POWER_VDDACTRL_TRG);
REG_WR(PWR_VDDACTRL, tmp_r);
delay(10000);
/* Enable PWDN_BRNOUT. */
REG_WR(PWR_CTRL_C, HW_POWER_CTRL_VDDA_BO_IRQ);
tmp_r = REG_RD(PWR_VDDACTRL);
tmp_r |= HW_POWER_VDDACTRL_PWDN_BRNOUT;
REG_WR(PWR_VDDACTRL, tmp_r);
return;
}
/*
* Configure VDDIO to source power from DCDC.
*/
void
power_vddio_from_dcdc(int target, int brownout)
{
uint32_t tmp_r;
/* BO_OFFSET must be within 2700mV - 3475mV */
if (brownout > 3475)
brownout = 3475;
else if (brownout < 2700)
brownout = 2700;
/* Set LINREG_OFFSET one step below TRG. */
tmp_r = REG_RD(PWR_VDDIOCTRL);
tmp_r &= ~HW_POWER_VDDIOCTRL_LINREG_OFFSET;
tmp_r |= __SHIFTIN(2, HW_POWER_VDDIOCTRL_LINREG_OFFSET);
REG_WR(PWR_VDDIOCTRL, tmp_r);
delay(10000);
/* Enable VDDIO switching converter output. */
tmp_r = REG_RD(PWR_VDDIOCTRL);
tmp_r &= ~HW_POWER_VDDIOCTRL_DISABLE_FET;
REG_WR(PWR_VDDIOCTRL, tmp_r);
delay(10000);
/* Set target voltage and brownout level. */
tmp_r = REG_RD(PWR_VDDIOCTRL);
tmp_r &= ~(HW_POWER_VDDIOCTRL_BO_OFFSET | HW_POWER_VDDIOCTRL_TRG);
tmp_r |= __SHIFTIN(((target - brownout) / 25),
HW_POWER_VDDIOCTRL_BO_OFFSET);
tmp_r |= __SHIFTIN(((target - 2800) / 25), HW_POWER_VDDIOCTRL_TRG);
REG_WR(PWR_VDDIOCTRL, tmp_r);
delay(10000);
/* Enable PWDN_BRNOUT. */
REG_WR(PWR_CTRL_C, HW_POWER_CTRL_VDDIO_BO_IRQ);
tmp_r = REG_RD(PWR_VDDIOCTRL);
tmp_r |= HW_POWER_VDDIOCTRL_PWDN_BRNOUT;
REG_WR(PWR_VDDIOCTRL, tmp_r);
return;
}
/*
* AN3883.pdf 2.3.1.2 Setting VDDMEM Target Voltage
*/
void
power_vddmem(int target)
{
uint32_t tmp_r;
/* Set target voltage. */
tmp_r = REG_RD(PWR_VDDMEMCTRL);
tmp_r &= ~(HW_POWER_VDDMEMCTRL_TRG);
tmp_r |= __SHIFTIN(((target - 1700) / 50), HW_POWER_VDDMEMCTRL_TRG);
REG_WR(PWR_VDDMEMCTRL, tmp_r);
delay(10000);
tmp_r = REG_RD(PWR_VDDMEMCTRL);
tmp_r |= (HW_POWER_VDDMEMCTRL_PULLDOWN_ACTIVE |
HW_POWER_VDDMEMCTRL_ENABLE_ILIMIT |
HW_POWER_VDDMEMCTRL_ENABLE_LINREG);
REG_WR(PWR_VDDMEMCTRL, tmp_r);
delay(1000);
tmp_r = REG_RD(PWR_VDDMEMCTRL);
tmp_r &= ~(HW_POWER_VDDMEMCTRL_PULLDOWN_ACTIVE |
HW_POWER_VDDMEMCTRL_ENABLE_ILIMIT);
REG_WR(PWR_VDDMEMCTRL, tmp_r);
return;
}
|
92313c0c0dd46f485465cf4c1df170b643d79b58
|
4caa4cbd5b06a3ceeebb04c077a1baf65375c8e9
|
/src/fs/iwfsmfile.c
|
75cc4d594991a7c88e7060b27553ce237e96ef18
|
[
"MIT"
] |
permissive
|
Softmotions/iowow
|
22cdfa56944fd38d106d603a41a14541f1d96ffb
|
a233a246577f5ba02a643a23b417c7bac7feaf06
|
refs/heads/master
| 2023-08-08T13:19:12.913521
| 2023-08-06T05:21:28
| 2023-08-06T05:21:28
| 40,618,114
| 274
| 25
|
MIT
| 2023-08-06T04:13:54
| 2015-08-12T18:44:57
|
C
|
UTF-8
|
C
| false
| false
| 59,849
|
c
|
iwfsmfile.c
|
/**************************************************************************************************
* IOWOW library
*
* MIT License
*
* Copyright (c) 2012-2022 Softmotions Ltd <[email protected]>
*
* 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 "iwfsmfile.h"
#include "iwavl.h"
#include "iwbits.h"
#include "iwlog.h"
#include "iwp.h"
#include "iwutils.h"
#include "iwcfg.h"
#include <pthread.h>
void iwfs_fsmdbg_dump_fsm_tree(IWFS_FSM *f, const char *hdr);
/**
* Free-space blocks-tree key.
*/
struct bkey {
uint32_t off;
uint32_t len;
};
struct bkey_node {
struct bkey key;
struct iwavl_node node;
};
#define BKEY(nptr_) iwavl_entry(nptr_, struct bkey_node, node)->key
/** Additional options for `_fsm_set_bit_status_lw` routine */
typedef uint8_t fsm_bmopts_t;
/** No options. */
#define FSM_BM_NONE ((fsm_bmopts_t) 0x00U)
/** Do not modify bitmap. */
#define FSM_BM_DRY_RUN ((fsm_bmopts_t) 0x01U)
/** Perform strict checking of bitmap consistency */
#define FSM_BM_STRICT ((fsm_bmopts_t) 0x02U)
/* Maximum size of block: 1Mb */
#define FSM_MAX_BLOCK_POW 20
/* Maximum number of records used in allocation statistics */
#define FSM_MAX_STATS_COUNT 0x0000ffff
#define FSM_ENSURE_OPEN(impl_) \
if (!(impl_) || !(impl_)->f) return IW_ERROR_INVALID_STATE;
#define FSM_ENSURE_OPEN2(f_) \
if (!(f_) || !(f_)->impl) return IW_ERROR_INVALID_STATE;
#define FSMBK_OFFSET(b_) ((b_)->off)
#define FSMBK_LENGTH(b_) ((b_)->len)
////////////////////////////////////////////////////////////////////////////////////////////////////
struct fsm {
IWFS_EXT pool; /**< Underlying rwl file. */
uint64_t bmlen; /**< Free-space bitmap block length in bytes. */
uint64_t bmoff; /**< Free-space bitmap block offset in bytes. */
uint64_t lfbkoff; /**< Offset in blocks of free block chunk with the largest offset. */
uint64_t lfbklen; /**< Length in blocks of free block chunk with the largest offset. */
uint64_t crzsum; /**< Cumulative sum all allocated blocks */
uint64_t crzvar; /**< Record sizes standard variance (deviation^2 * N) */
uint32_t hdrlen; /**< Length of custom file header */
uint32_t crznum; /**< Number of all allocated continuous areas acquired by `allocate` */
uint32_t fsmnum; /**< Number of records in fsm */
IWFS_FSM *f; /**< Self reference. */
IWDLSNR *dlsnr; /**< Data events listener */
struct iwavl_node *root; /**< Free-space tree */
pthread_rwlock_t *ctlrwlk; /**< Methods RW lock */
size_t aunit; /**< System allocation unit size.
- Page size on *NIX
- Minimal allocation unit for WIN32 */
iwfs_fsm_openflags oflags; /**< Operation mode flags. */
iwfs_omode omode; /**< Open mode. */
uint8_t bpow; /**< Block size power for 2 */
bool mmap_all; /**< Mmap all file data */
iwfs_ext_mmap_opts_t mmap_opts; /**< Defaul mmap options used in `add_mmap` */
};
static iwrc _fsm_ensure_size_lw(struct fsm *fsm, off_t size);
////////////////////////////////////////////////////////////////////////////////////////////////////
IW_INLINE int _fsm_cmp_key(const struct bkey *a, const struct bkey *b) {
int ret = ((FSMBK_LENGTH(b) < FSMBK_LENGTH(a)) - (FSMBK_LENGTH(a) < FSMBK_LENGTH(b)));
if (ret) {
return ret;
} else {
return ((FSMBK_OFFSET(b) < FSMBK_OFFSET(a)) - (FSMBK_OFFSET(a) < FSMBK_OFFSET(b)));
}
}
IW_INLINE int _fsm_cmp_node(const struct iwavl_node *an, const struct iwavl_node *bn) {
const struct bkey *ak = &BKEY(an);
const struct bkey *bk = &BKEY(bn);
return _fsm_cmp_key(ak, bk);
}
IW_INLINE int _fsm_cmp_ctx(const void *ctx, const struct iwavl_node *bn) {
const struct bkey *ak = ctx;
const struct bkey *bk = &BKEY(bn);
return _fsm_cmp_key(ak, bk);
}
IW_INLINE iwrc _fsm_ctrl_wlock(struct fsm *fsm) {
int rci = fsm->ctlrwlk ? pthread_rwlock_wrlock(fsm->ctlrwlk) : 0;
return (rci ? iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci) : 0);
}
IW_INLINE iwrc _fsm_ctrl_rlock(struct fsm *fsm) {
int rci = fsm->ctlrwlk ? pthread_rwlock_rdlock(fsm->ctlrwlk) : 0;
return (rci ? iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci) : 0);
}
IW_INLINE iwrc _fsm_ctrl_unlock(struct fsm *fsm) {
int rci = fsm->ctlrwlk ? pthread_rwlock_unlock(fsm->ctlrwlk) : 0;
return (rci ? iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci) : 0);
}
IW_INLINE iwrc _fsm_bmptr(struct fsm *fsm, uint64_t **bmptr) {
size_t sp;
uint8_t *mm;
*bmptr = 0;
// get mmap pointer without locked
iwrc rc = fsm->pool.probe_mmap(&fsm->pool, fsm->mmap_all ? 0 : fsm->bmoff, &mm, &sp);
RCRET(rc);
if (fsm->mmap_all) {
if (sp < fsm->bmoff + fsm->bmlen) {
return IWFS_ERROR_NOT_MMAPED;
}
*bmptr = (uint64_t*) (mm + fsm->bmoff);
} else {
if (sp < fsm->bmlen) {
return IWFS_ERROR_NOT_MMAPED;
}
*bmptr = (uint64_t*) mm;
}
return 0;
}
IW_INLINE WUR iwrc _fsm_init_bkey_node(struct bkey_node *n, uint64_t offset_blk, uint64_t len_blk) {
if (offset_blk > (uint32_t) -1 || len_blk > (uint32_t) -1) {
return IW_ERROR_OVERFLOW;
}
n->key.off = (uint32_t) offset_blk;
n->key.len = (uint32_t) len_blk;
return 0;
}
IW_INLINE iwrc _fsm_init_bkey(struct bkey *k, uint64_t offset_blk, uint64_t len_blk) {
if (offset_blk > (uint32_t) -1 || len_blk > (uint32_t) -1) {
return IW_ERROR_OVERFLOW;
}
k->off = (uint32_t) offset_blk;
k->len = (uint32_t) len_blk;
return 0;
}
IW_INLINE void _fsm_del_fbk2(struct fsm *fsm, struct iwavl_node *n) {
iwavl_remove(&fsm->root, n), --fsm->fsmnum;
struct bkey_node *bk = iwavl_entry(n, struct bkey_node, node);
if (bk->key.off == fsm->lfbkoff) {
fsm->lfbkoff = 0;
fsm->lfbklen = 0;
}
free(bk);
}
IW_INLINE void _fsm_del_fbk(struct fsm *fsm, uint64_t offset_blk, uint64_t length_blk) {
struct bkey bkey;
if (!_fsm_init_bkey(&bkey, offset_blk, length_blk)) {
struct iwavl_node *n = iwavl_lookup(fsm->root, &bkey, _fsm_cmp_ctx);
assert(n);
if (n) {
_fsm_del_fbk2(fsm, n);
}
}
}
IW_INLINE iwrc _fsm_put_fbk(struct fsm *fsm, uint64_t offset_blk, uint64_t length_blk) {
iwrc rc = 0;
struct bkey_node *bk;
RCB(finish, bk = malloc(sizeof(*bk)));
RCC(rc, finish, _fsm_init_bkey_node(bk, offset_blk, length_blk));
if (iwavl_insert(&fsm->root, &bk->node, _fsm_cmp_node)) {
free(bk);
} else {
++fsm->fsmnum;
if (offset_blk + length_blk >= fsm->lfbkoff + fsm->lfbklen) {
fsm->lfbkoff = offset_blk;
fsm->lfbklen = length_blk;
}
}
finish:
if (rc) {
free(bk);
}
return rc;
}
IW_INLINE const struct iwavl_node* _fsm_find_matching_fblock_lw(
struct fsm *fsm,
uint64_t offset_blk,
uint64_t length_blk,
iwfs_fsm_aflags opts
) {
struct bkey bk;
const struct iwavl_node *ub, *lb;
if (_fsm_init_bkey(&bk, offset_blk, length_blk)) {
return 0;
}
iwavl_lookup_bounds(fsm->root, &bk, _fsm_cmp_ctx, &lb, &ub);
struct bkey *uk = ub ? &BKEY(ub) : 0;
struct bkey *lk = lb ? &BKEY(lb) : 0;
uint64_t lklength = lk ? FSMBK_LENGTH(lk) : 0;
uint64_t uklength = uk ? FSMBK_LENGTH(uk) : 0;
if (lklength == length_blk) {
return lb;
} else if (uklength == length_blk) {
return ub;
}
if (lklength > length_blk) {
return lb;
} else if (uklength > length_blk) {
return ub;
}
return 0;
}
/**
* @brief Set the allocation bits in the fsm bitmap.
*
* @param fms
* @param offset_bits Bit offset in the bitmap.
* @param length_bits Number of bits to set
* @param bit_status If `1` bits will be set to `1` otherwise `0`
* @param opts Operation options
*/
static iwrc _fsm_set_bit_status_lw(
struct fsm *fsm,
const uint64_t offset_bits,
const uint64_t length_bits_,
const int bit_status,
const fsm_bmopts_t opts
) {
iwrc rc;
size_t sp;
uint8_t *mm;
register int64_t length_bits = length_bits_;
register uint64_t *p, set_mask;
uint64_t bend = offset_bits + length_bits;
int set_bits;
if (bend < offset_bits) { // overflow
return IW_ERROR_OUT_OF_BOUNDS;
}
assert(fsm->bmlen * 8 >= offset_bits + length_bits);
if (fsm->bmlen * 8 < offset_bits + length_bits) {
return IWFS_ERROR_FSM_SEGMENTATION;
}
if (fsm->mmap_all) {
rc = fsm->pool.probe_mmap(&fsm->pool, 0, &mm, &sp);
RCRET(rc);
if (sp < fsm->bmoff + fsm->bmlen) {
return IWFS_ERROR_NOT_MMAPED;
} else {
mm += fsm->bmoff;
}
} else {
rc = fsm->pool.probe_mmap(&fsm->pool, fsm->bmoff, &mm, &sp);
RCRET(rc);
if (sp < fsm->bmlen) {
return IWFS_ERROR_NOT_MMAPED;
}
}
p = ((uint64_t*) mm) + offset_bits / 64;
set_bits = 64 - (offset_bits & (64 - 1)); // NOLINT
set_mask = (~((uint64_t) 0) << (offset_bits & (64 - 1)));
#ifdef IW_BIGENDIAN
while (length_bits - set_bits >= 0) {
uint64_t pv = *p;
pv = IW_ITOHLL(pv);
if (bit_status) {
if ((opts & FSM_BM_STRICT) && (pv & set_mask)) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
}
if ((opts & FSM_BM_DRY_RUN) == 0) {
pv |= set_mask;
*p = IW_HTOILL(pv);
}
} else {
if ((opts & FSM_BM_STRICT) && ((pv & set_mask) != set_mask)) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
}
if ((opts & FSM_BM_DRY_RUN) == 0) {
pv &= ~set_mask;
*p = IW_HTOILL(pv);
}
}
length_bits -= set_bits;
set_bits = 64;
set_mask = ~((uint64_t) 0);
++p;
}
if (length_bits) {
uint64_t pv = *p;
pv = IW_ITOHLL(pv);
set_mask &= (bend & (64 - 1)) ? ((((uint64_t) 1) << (bend & (64 - 1))) - 1) : ~((uint64_t) 0);
if (bit_status) {
if ((opts & FSM_BM_STRICT) && (pv & set_mask)) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
}
if ((opts & FSM_BM_DRY_RUN) == 0) {
pv |= set_mask;
*p = IW_HTOILL(pv);
}
} else {
if ((opts & FSM_BM_STRICT) && ((pv & set_mask) != set_mask)) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
}
if ((opts & FSM_BM_DRY_RUN) == 0) {
pv &= ~set_mask;
*p = IW_HTOILL(pv);
}
}
}
#else
while (length_bits - set_bits >= 0) {
if (bit_status) {
if ((opts & FSM_BM_STRICT) && (*p & set_mask)) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
}
if ((opts & FSM_BM_DRY_RUN) == 0) {
*p |= set_mask;
}
} else {
if ((opts & FSM_BM_STRICT) && ((*p & set_mask) != set_mask)) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
}
if ((opts & FSM_BM_DRY_RUN) == 0) {
*p &= ~set_mask;
}
}
length_bits -= set_bits;
set_bits = 64;
set_mask = ~((uint64_t) 0);
++p;
}
if (length_bits) {
set_mask &= (bend & (64 - 1)) ? ((((uint64_t) 1) << (bend & (64 - 1))) - 1) : ~((uint64_t) 0);
if (bit_status) {
if ((opts & FSM_BM_STRICT) && (*p & set_mask)) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
}
if ((opts & FSM_BM_DRY_RUN) == 0) {
*p |= set_mask;
}
} else {
if ((opts & FSM_BM_STRICT) && ((*p & set_mask) != set_mask)) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
}
if ((opts & FSM_BM_DRY_RUN) == 0) {
*p &= ~set_mask;
}
}
}
#endif
if (!rc && fsm->dlsnr) {
uint64_t so = offset_bits / 8;
uint64_t lb = length_bits_ + offset_bits % 8;
uint64_t dl = lb / 8;
if (lb % 8) {
++dl;
}
rc = fsm->dlsnr->onwrite(fsm->dlsnr, fsm->bmoff + so, mm + so, dl, 0);
}
return rc;
}
/**
* @brief Allocate a continuous segment of blocks with page aligned offset.
*
* @param fsm `struct fsm`
* @param length_blk Desired segment length in blocks.
* @param [in,out] offset_blk Allocated segment offset in blocks will be stored into.
It also specified the desired segment offset to provide
* allocation locality.
* @param [out] olength_blk Assigned segment length in blocks.
* @param max_offset_blk Maximal offset of allocated block.
* @param opts Allocation options.
*/
static iwrc _fsm_blk_allocate_aligned_lw(
struct fsm *fsm,
const uint64_t length_blk,
uint64_t *offset_blk,
uint64_t *olength_blk,
const uint64_t max_offset_blk,
const iwfs_fsm_aflags opts
) {
fsm_bmopts_t bopts = FSM_BM_NONE;
size_t aunit_blk = (fsm->aunit >> fsm->bpow);
assert(fsm && length_blk > 0);
if (fsm->oflags & IWFSM_STRICT) {
bopts |= FSM_BM_STRICT;
}
*olength_blk = 0;
*offset_blk = 0;
/* First attempt */
const struct iwavl_node *nn = _fsm_find_matching_fblock_lw(fsm, 0, length_blk + aunit_blk, opts);
if (!nn) {
nn = _fsm_find_matching_fblock_lw(fsm, 0, length_blk, opts);
if (!nn) {
return IWFS_ERROR_NO_FREE_SPACE;
}
}
struct bkey *nk = &BKEY(nn);
uint64_t akoff = FSMBK_OFFSET(nk);
uint64_t aklen = FSMBK_LENGTH(nk);
uint64_t noff = IW_ROUNDUP(akoff, aunit_blk);
if ((noff <= max_offset_blk) && (noff < aklen + akoff) && (aklen - (noff - akoff) >= length_blk)) {
_fsm_del_fbk(fsm, akoff, aklen);
aklen = aklen - (noff - akoff);
if (noff > akoff) {
_fsm_put_fbk(fsm, akoff, noff - akoff);
}
if (aklen > length_blk) {
_fsm_put_fbk(fsm, noff + length_blk, aklen - length_blk);
}
*offset_blk = noff;
*olength_blk = length_blk;
return _fsm_set_bit_status_lw(fsm, noff, length_blk, 1, bopts);
}
aklen = 0;
akoff = UINT64_MAX;
// full scan
for (struct iwavl_node *n = iwavl_first_in_order(fsm->root); n; n = iwavl_next_in_order(n)) {
struct bkey *k = &BKEY(n);
uint64_t koff = FSMBK_OFFSET(k);
uint64_t klen = FSMBK_LENGTH(k);
if (koff < akoff) {
noff = IW_ROUNDUP(koff, aunit_blk);
if (noff <= max_offset_blk && (noff < klen + koff) && (klen - (noff - koff) >= length_blk)) {
akoff = koff;
aklen = klen;
}
}
}
if (akoff == UINT64_MAX) {
return IWFS_ERROR_NO_FREE_SPACE;
}
_fsm_del_fbk(fsm, akoff, aklen);
noff = IW_ROUNDUP(akoff, aunit_blk);
aklen = aklen - (noff - akoff);
if (noff > akoff) {
_fsm_put_fbk(fsm, akoff, noff - akoff);
}
if (aklen > length_blk) {
_fsm_put_fbk(fsm, noff + length_blk, aklen - length_blk);
}
*offset_blk = noff;
*olength_blk = length_blk;
return _fsm_set_bit_status_lw(fsm, noff, length_blk, 1, bopts);
}
static void _fsm_node_destroy(struct iwavl_node *root) {
for (struct iwavl_node *n = iwavl_first_in_postorder(root), *p;
n && (p = iwavl_get_parent(n), 1);
n = iwavl_next_in_postorder(n, p)) {
struct bkey_node *bk = iwavl_entry(n, struct bkey_node, node);
free(bk);
}
}
/**
* @brief Load existing bitmap area into free-space search tree.
* @param fsm `struct fsm`
* @param bm Bitmap area start ptr
* @param len Bitmap area length in bytes.
*/
static void _fsm_load_fsm_lw(struct fsm *fsm, const uint8_t *bm, uint64_t len) {
uint64_t cbnum = 0, fbklength = 0, fbkoffset = 0;
_fsm_node_destroy(fsm->root);
fsm->root = 0;
fsm->fsmnum = 0;
for (uint64_t b = 0; b < len; ++b) {
register uint8_t bb = bm[b];
if (bb == 0) {
fbklength += 8;
cbnum += 8;
} else if (bb == 0xffU) {
if (fbklength) {
fbkoffset = cbnum - fbklength;
_fsm_put_fbk(fsm, fbkoffset, fbklength);
fbklength = 0;
}
cbnum += 8;
} else {
for (int i = 0; i < 8; ++i, ++cbnum) {
if (bb & (1U << i)) {
if (fbklength) {
fbkoffset = cbnum - fbklength;
_fsm_put_fbk(fsm, fbkoffset, fbklength);
fbklength = 0;
}
} else {
++fbklength;
}
}
}
}
if (fbklength > 0) {
fbkoffset = len * 8 - fbklength;
_fsm_put_fbk(fsm, fbkoffset, fbklength);
}
}
/**
* @brief Flush a current `iwfsmfile` metadata into the file header.
* @param fsm
* @param is_sync If `1` perform mmap sync.
* @return
*/
static iwrc _fsm_write_meta_lw(struct fsm *fsm) {
uint64_t llv;
size_t wlen;
uint32_t sp = 0, lv;
uint8_t hdr[IWFSM_CUSTOM_HDR_DATA_OFFSET] = { 0 };
/*
[FSM_CTL_MAGICK u32][block pow u8]
[bmoffset u64][bmlength u64]
[u64 crzsum][u32 crznum][u64 crszvar][u256 reserved]
[custom header size u32][custom header data...]
[fsm data...]
*/
/* magic */
lv = IW_HTOIL(IWFSM_MAGICK);
assert(sp + sizeof(lv) <= IWFSM_CUSTOM_HDR_DATA_OFFSET);
memcpy(hdr + sp, &lv, sizeof(lv));
sp += sizeof(lv);
/* block pow */
static_assert(sizeof(fsm->bpow) == 1, "sizeof(fms->bpow) == 1");
assert(sp + sizeof(fsm->bpow) <= IWFSM_CUSTOM_HDR_DATA_OFFSET);
memcpy(hdr + sp, &fsm->bpow, sizeof(fsm->bpow));
sp += sizeof(fsm->bpow);
/* fsm bitmap block offset */
llv = fsm->bmoff;
llv = IW_HTOILL(llv);
assert(sp + sizeof(llv) <= IWFSM_CUSTOM_HDR_DATA_OFFSET);
memcpy(hdr + sp, &llv, sizeof(llv));
sp += sizeof(llv);
/* fsm bitmap block length */
llv = fsm->bmlen;
llv = IW_HTOILL(llv);
assert(sp + sizeof(llv) <= IWFSM_CUSTOM_HDR_DATA_OFFSET);
memcpy(hdr + sp, &llv, sizeof(llv));
sp += sizeof(llv);
/* Cumulative sum of record sizes acquired by `allocate` */
llv = fsm->crzsum;
llv = IW_HTOILL(llv);
assert(sp + sizeof(llv) <= IWFSM_CUSTOM_HDR_DATA_OFFSET);
memcpy(hdr + sp, &llv, sizeof(llv));
sp += sizeof(llv);
/* Cumulative number of records acquired by `allocated` */
lv = fsm->crznum;
lv = IW_HTOIL(lv);
assert(sp + sizeof(lv) <= IWFSM_CUSTOM_HDR_DATA_OFFSET);
memcpy(hdr + sp, &lv, sizeof(lv));
sp += sizeof(lv);
/* Record sizes standard variance (deviation^2 * N) */
llv = fsm->crzvar;
llv = IW_HTOILL(llv);
assert(sp + sizeof(lv) <= IWFSM_CUSTOM_HDR_DATA_OFFSET);
memcpy(hdr + sp, &llv, sizeof(llv));
sp += sizeof(llv);
/* Reserved */
sp += 32;
/* Size of header */
lv = fsm->hdrlen;
lv = IW_HTOIL(lv);
assert(sp + sizeof(lv) <= IWFSM_CUSTOM_HDR_DATA_OFFSET);
memcpy(hdr + sp, &lv, sizeof(lv));
sp += sizeof(lv);
assert(sp == IWFSM_CUSTOM_HDR_DATA_OFFSET);
return fsm->pool.write(&fsm->pool, 0, hdr, IWFSM_CUSTOM_HDR_DATA_OFFSET, &wlen);
}
/**
* @brief Search for the first next set bit position
* starting from the specified offset bit (INCLUDED).
*/
static uint64_t _fsm_find_next_set_bit(
const uint64_t *addr,
register uint64_t offset_bit,
const uint64_t max_offset_bit,
int *found
) {
*found = 0;
register uint64_t bit, size;
register const uint64_t *p = addr + offset_bit / 64;
if (offset_bit >= max_offset_bit) {
return 0;
}
bit = offset_bit & (64 - 1);
offset_bit -= bit;
size = max_offset_bit - offset_bit;
#ifdef IW_BIGENDIAN
uint64_t pv = *p;
if (bit) {
pv = IW_ITOHLL(pv) & (~((uint64_t) 0) << bit);
if (pv) {
pv = iwbits_find_first_sbit64(pv);
if (pv >= size) {
return 0;
} else {
*found = 1;
return offset_bit + pv;
}
}
if (size <= 64) {
return 0;
}
offset_bit += 64;
size -= 64;
++p;
}
while (size & ~(64 - 1)) {
pv = *(p++);
if (pv) {
*found = 1;
return offset_bit + iwbits_find_first_sbit64(IW_ITOHLL(pv));
}
offset_bit += 64;
size -= 64;
}
if (!size) {
return 0;
}
pv = *p;
pv = IW_ITOHLL(pv) & (~((uint64_t) 0) >> (64 - size));
if (pv) {
*found = 1;
return offset_bit + iwbits_find_first_sbit64(pv);
} else {
return 0;
}
#else
register uint64_t tmp;
if (bit) {
tmp = *p & (~((uint64_t) 0) << bit);
if (tmp) {
tmp = iwbits_find_first_sbit64(tmp);
if (tmp >= size) {
return 0;
} else {
*found = 1;
return offset_bit + tmp;
}
}
if (size <= 64) {
return 0;
}
offset_bit += 64;
size -= 64;
++p;
}
while (size & ~(64 - 1)) {
if ((tmp = *(p++))) {
*found = 1;
return offset_bit + iwbits_find_first_sbit64(tmp);
}
offset_bit += 64;
size -= 64;
}
if (!size) {
return 0;
}
tmp = (*p) & (~((uint64_t) 0) >> (64 - size));
if (tmp) {
*found = 1;
return offset_bit + iwbits_find_first_sbit64(tmp);
} else {
return 0;
}
#endif
}
/**
* @brief Search for the first previous set bit position
* starting from the specified offset_bit (EXCLUDED).
*/
static uint64_t _fsm_find_prev_set_bit(
const uint64_t *addr,
register uint64_t offset_bit,
const uint64_t min_offset_bit,
int *found
) {
register const uint64_t *p;
register uint64_t tmp, bit, size;
*found = 0;
if (min_offset_bit >= offset_bit) {
return 0;
}
size = offset_bit - min_offset_bit;
bit = offset_bit & (64 - 1);
p = addr + offset_bit / 64;
#ifdef IW_BIGENDIAN
uint64_t pv;
if (bit) {
pv = *p;
pv = (iwbits_reverse_64(IW_ITOHLL(pv)) >> (64 - bit));
if (pv) {
pv = iwbits_find_first_sbit64(pv);
if (pv >= size) {
return 0;
} else {
*found = 1;
assert(offset_bit > pv);
return offset_bit > pv ? offset_bit - pv - 1 : 0;
}
}
offset_bit -= bit;
size -= bit;
}
while (size & ~(64 - 1)) {
if (*(--p)) {
pv = *p;
*found = 1;
tmp = iwbits_find_first_sbit64(iwbits_reverse_64(IW_ITOHLL(pv)));
assert(offset_bit > tmp);
return offset_bit > tmp ? offset_bit - tmp - 1 : 0;
}
offset_bit -= 64;
size -= 64;
}
if (size == 0) {
return 0;
}
pv = *(--p);
tmp = iwbits_reverse_64(IW_ITOHLL(pv)) & ((((uint64_t) 1) << size) - 1);
#else
if (bit) {
tmp = (iwbits_reverse_64(*p) >> (64 - bit));
if (tmp) {
tmp = iwbits_find_first_sbit64(tmp);
if (tmp >= size) {
return 0;
} else {
*found = 1;
assert(offset_bit > tmp);
return offset_bit > tmp ? offset_bit - tmp - 1 : 0;
}
}
offset_bit -= bit;
size -= bit;
}
while (size & ~(64 - 1)) {
if (*(--p)) {
*found = 1;
tmp = iwbits_find_first_sbit64(iwbits_reverse_64(*p));
assert(offset_bit > tmp);
return offset_bit > tmp ? offset_bit - tmp - 1 : 0;
}
offset_bit -= 64;
size -= 64;
}
if (size == 0) {
return 0;
}
tmp = iwbits_reverse_64(*(--p)) & ((((uint64_t) 1) << size) - 1);
#endif
if (tmp) {
uint64_t tmp2;
*found = 1;
tmp2 = iwbits_find_first_sbit64(tmp);
assert(offset_bit > tmp2);
return offset_bit > tmp2 ? offset_bit - tmp2 - 1 : 0;
} else {
return 0;
}
}
/**
* @brief Return a previously allocated blocks
* back into the free-blocks pool.
*
* @param fms `struct fsm`
* @param offset_blk Starting block number of the specified range.
* @param length_blk Range size in blocks.
*/
static iwrc _fsm_blk_deallocate_lw(
struct fsm *fsm,
const uint64_t offset_blk,
const uint64_t length_blk
) {
iwrc rc;
uint64_t *bmptr;
uint64_t left, right;
int hasleft = 0, hasright = 0;
uint64_t key_offset = offset_blk, key_length = length_blk;
uint64_t rm_offset = 0, rm_length = 0;
uint64_t lfbkoff = fsm->lfbkoff;
uint64_t end_offset_blk = offset_blk + length_blk;
fsm_bmopts_t bopts = FSM_BM_NONE;
if (fsm->oflags & IWFSM_STRICT) {
bopts |= FSM_BM_STRICT;
}
rc = _fsm_set_bit_status_lw(fsm, offset_blk, length_blk, 0, bopts);
RCRET(rc);
rc = _fsm_bmptr(fsm, &bmptr);
RCRET(rc);
/* Merge with neighborhoods */
left = _fsm_find_prev_set_bit(bmptr, offset_blk, 0, &hasleft);
if (lfbkoff && (lfbkoff == end_offset_blk)) {
right = lfbkoff + fsm->lfbklen;
hasright = 1;
} else {
uint64_t maxoff = lfbkoff ? lfbkoff : (fsm->bmlen << 3);
right = _fsm_find_next_set_bit(bmptr, end_offset_blk, maxoff, &hasright);
}
if (hasleft) {
if (offset_blk > left + 1) {
left += 1;
rm_offset = left;
rm_length = offset_blk - left;
_fsm_del_fbk(fsm, rm_offset, rm_length);
key_offset = rm_offset;
key_length += rm_length;
}
} else if (offset_blk > 0) { /* zero start */
rm_offset = 0;
rm_length = offset_blk;
_fsm_del_fbk(fsm, rm_offset, rm_length);
key_offset = rm_offset;
key_length += rm_length;
}
if (hasright && (right > end_offset_blk)) {
rm_offset = end_offset_blk;
rm_length = right - end_offset_blk;
_fsm_del_fbk(fsm, rm_offset, rm_length);
key_length += rm_length;
}
IWRC(_fsm_put_fbk(fsm, key_offset, key_length), rc);
return rc;
}
/**
* @brief Initialize a new free-space bitmap area.
*
* If bitmap exists, its content will be moved into newly created area.
* Blocks from the previous bitmap are will disposed and deallocated.
*
* @param fsm `struct fsm
* @param bmoff Byte offset of the new bitmap. Value must be page aligned.
* @param bmlen Byte length of the new bitmap. Value must be page aligned.
Its length must not be lesser than length of old bitmap.
*/
static iwrc _fsm_init_lw(struct fsm *fsm, uint64_t bmoff, uint64_t bmlen) {
iwrc rc;
uint8_t *mm, *mm2;
size_t sp, sp2;
uint64_t old_bmoff, old_bmlen;
IWFS_EXT *pool = &fsm->pool;
if ((bmlen & ((1U << fsm->bpow) - 1)) || (bmoff & ((1U << fsm->bpow) - 1)) || (bmoff & (fsm->aunit - 1))) {
return IWFS_ERROR_RANGE_NOT_ALIGNED;
}
if (bmlen < fsm->bmlen) {
rc = IW_ERROR_INVALID_ARGS;
iwlog_ecode_error(rc, "Length of the newly initiated bitmap area (bmlen): %" PRIu64
" must not be lesser than the current bitmap area length %" PRIu64 "",
bmlen, fsm->bmlen);
return rc;
}
if (bmlen * 8 < ((bmoff + bmlen) >> fsm->bpow) + 1) {
rc = IW_ERROR_INVALID_ARGS;
iwlog_ecode_error(rc, "Length of the newly initiated bitmap area (bmlen): %" PRIu64
" is not enough to handle bitmap itself and the file header area.",
bmlen);
return rc;
}
rc = _fsm_ensure_size_lw(fsm, bmoff + bmlen);
RCRET(rc);
if (fsm->mmap_all) {
// get mmap area without locking, since we ensured what pool file will not be remapped
rc = pool->probe_mmap(pool, 0, &mm, &sp);
RCRET(rc);
if (sp < bmoff + bmlen) {
return IWFS_ERROR_NOT_MMAPED;
} else {
mm += bmoff;
}
} else {
// get mmap area without locking, since we ensured what pool file will not be remapped
rc = pool->probe_mmap(pool, bmoff, &mm, &sp);
RCRET(rc);
if (sp < bmlen) {
return IWFS_ERROR_NOT_MMAPED;
}
}
if (fsm->bmlen) {
/* We have an old active bitmap. Lets copy its content to the new location.*/
if (IW_RANGES_OVERLAP(fsm->bmoff, fsm->bmoff + fsm->bmlen, bmoff, bmoff + bmlen)) {
iwlog_ecode_error2(rc, "New and old bitmap areas are overlaped");
return IW_ERROR_INVALID_ARGS;
}
if (fsm->mmap_all) {
mm2 = mm - bmoff + fsm->bmoff;
} else {
rc = pool->probe_mmap(pool, fsm->bmoff, &mm2, &sp2);
if (!rc && (sp2 < fsm->bmlen)) {
rc = IWFS_ERROR_NOT_MMAPED;
}
if (rc) {
iwlog_ecode_error2(rc, "Old bitmap area is not mmaped");
return rc;
}
}
assert(!((fsm->bmlen - bmlen) & ((1U << fsm->bpow) - 1)));
if (fsm->dlsnr) {
rc = fsm->dlsnr->onwrite(fsm->dlsnr, bmoff, mm2, fsm->bmlen, 0);
RCRET(rc);
}
memcpy(mm, mm2, fsm->bmlen);
if (bmlen > fsm->bmlen) {
memset(mm + fsm->bmlen, 0, bmlen - fsm->bmlen);
if (fsm->dlsnr) {
rc = fsm->dlsnr->onset(fsm->dlsnr, bmoff + fsm->bmlen, 0, bmlen - fsm->bmlen, 0);
RCRET(rc);
}
}
} else {
mm2 = 0;
memset(mm, 0, bmlen);
if (fsm->dlsnr) {
rc = fsm->dlsnr->onset(fsm->dlsnr, bmoff, 0, bmlen, 0);
RCRET(rc);
}
}
/* Backup the previous bitmap range */
old_bmlen = fsm->bmlen;
old_bmoff = fsm->bmoff;
fsm->bmoff = bmoff;
fsm->bmlen = bmlen;
RCC(rc, rollback, _fsm_set_bit_status_lw(fsm, (bmoff >> fsm->bpow), (bmlen >> fsm->bpow), 1, FSM_BM_NONE));
if (!old_bmlen) { /* First time initialization */
/* Header allocation */
RCC(rc, rollback, _fsm_set_bit_status_lw(fsm, 0, (fsm->hdrlen >> fsm->bpow), 1, FSM_BM_NONE));
}
/* Reload fsm tree */
_fsm_load_fsm_lw(fsm, mm, bmlen);
/* Flush new meta */
RCC(rc, rollback, _fsm_write_meta_lw(fsm));
RCC(rc, rollback, pool->sync(pool, IWFS_FDATASYNC));
if (old_bmlen) {
/* Now we are save to deallocate the old bitmap */
rc = _fsm_blk_deallocate_lw(fsm, (old_bmoff >> fsm->bpow), (old_bmlen >> fsm->bpow));
if (!fsm->mmap_all) {
pool->remove_mmap(pool, old_bmoff);
}
}
return rc;
rollback:
/* try to rollback previous bitmap state */
fsm->bmoff = old_bmoff;
fsm->bmlen = old_bmlen;
if (old_bmlen && mm2) {
_fsm_load_fsm_lw(fsm, mm2, old_bmlen);
}
pool->sync(pool, IWFS_FDATASYNC);
return rc;
}
/**
* @brief Resize bitmap area.
* @param fsm `structfsm
* @param size New size of bitmap area in bytes.
*/
static iwrc _fsm_resize_fsm_bitmap_lw(struct fsm *fsm, uint64_t size) {
iwrc rc;
uint64_t bmoffset = 0, bmlen, sp;
IWFS_EXT *pool = &fsm->pool;
if (fsm->bmlen >= size) {
return 0;
}
bmlen = IW_ROUNDUP(size, fsm->aunit); /* align to the system page size. */
rc = _fsm_blk_allocate_aligned_lw(
fsm, (bmlen >> fsm->bpow), &bmoffset, &sp, UINT64_MAX,
IWFSM_ALLOC_NO_STATS | IWFSM_ALLOC_NO_EXTEND | IWFSM_ALLOC_NO_OVERALLOCATE);
if (!rc) {
bmoffset = bmoffset << fsm->bpow;
bmlen = sp << fsm->bpow;
} else if (rc == IWFS_ERROR_NO_FREE_SPACE) {
bmoffset = fsm->bmlen * (1 << fsm->bpow) * 8;
bmoffset = IW_ROUNDUP(bmoffset, fsm->aunit);
}
if (!fsm->mmap_all) {
rc = pool->add_mmap(pool, bmoffset, bmlen, fsm->mmap_opts);
RCRET(rc);
}
rc = _fsm_init_lw(fsm, bmoffset, bmlen);
if (rc && !fsm->mmap_all) {
pool->remove_mmap(pool, bmoffset);
}
return rc;
}
/**
* @brief Allocate a continuous segment of blocks.
*
* @param fsm `struct fsm
* @param length_blk Desired segment length in blocks.
* @param [in,out] offset_blk Allocated segment offset in blocks will be stored into.
* It also specified the desired segment offset to provide allocation locality.
* @param [out] olength_blk Assigned segment length in blocks.
* @param opts
*/
static iwrc _fsm_blk_allocate_lw(
struct fsm *fsm,
uint64_t length_blk,
uint64_t *offset_blk,
uint64_t *olength_blk,
iwfs_fsm_aflags opts
) {
iwrc rc;
struct iwavl_node *nn;
fsm_bmopts_t bopts = FSM_BM_NONE;
if (opts & IWFSM_ALLOC_PAGE_ALIGNED) {
while (1) {
rc = _fsm_blk_allocate_aligned_lw(fsm, length_blk, offset_blk, olength_blk, UINT64_MAX, opts);
if (rc == IWFS_ERROR_NO_FREE_SPACE) {
if (opts & IWFSM_ALLOC_NO_EXTEND) {
return IWFS_ERROR_NO_FREE_SPACE;
}
rc = _fsm_resize_fsm_bitmap_lw(fsm, fsm->bmlen << 1);
RCRET(rc);
continue;
}
if (!rc && (opts & IWFSM_SOLID_ALLOCATED_SPACE)) {
uint64_t bs = *offset_blk;
int64_t bl = *olength_blk;
rc = _fsm_ensure_size_lw(fsm, (bs << fsm->bpow) + (bl << fsm->bpow));
}
return rc;
}
}
*olength_blk = length_blk;
start:
nn = (struct iwavl_node*) _fsm_find_matching_fblock_lw(fsm, *offset_blk, length_blk, opts);
if (nn) { /* use existing free space block */
const struct bkey *nk = &BKEY(nn);
uint64_t nlength = FSMBK_LENGTH(nk);
*offset_blk = FSMBK_OFFSET(nk);
_fsm_del_fbk2(fsm, nn);
if (nlength > length_blk) { /* re-save rest of free-space */
if (!(opts & IWFSM_ALLOC_NO_OVERALLOCATE) && fsm->crznum) {
/* todo use lognormal distribution? */
double_t d = ((double_t) fsm->crzsum / (double_t) fsm->crznum) /*avg*/
- (double) (nlength - length_blk); /*rest blk size*/
double_t s = ((double_t) fsm->crzvar / (double_t) fsm->crznum) * 6.0; /* blk size dispersion * 6 */
if ((s > 1) && (d > 0) && (d * d > s)) {
/* its better to attach rest of block to
the record */
*olength_blk = nlength;
} else {
_fsm_put_fbk(fsm, (*offset_blk + length_blk), (nlength - length_blk));
}
} else {
_fsm_put_fbk(fsm, (*offset_blk + length_blk), (nlength - length_blk));
}
}
} else {
if (opts & IWFSM_ALLOC_NO_EXTEND) {
return IWFS_ERROR_NO_FREE_SPACE;
}
rc = _fsm_resize_fsm_bitmap_lw(fsm, fsm->bmlen << 1);
RCRET(rc);
goto start;
}
if (fsm->oflags & IWFSM_STRICT) {
bopts |= FSM_BM_STRICT;
}
rc = _fsm_set_bit_status_lw(fsm, *offset_blk, *olength_blk, 1, bopts);
if (!rc && !(opts & IWFSM_ALLOC_NO_STATS)) {
double_t avg;
/* Update allocation statistics */
if (fsm->crznum > FSM_MAX_STATS_COUNT) {
fsm->crznum = 0;
fsm->crzsum = 0;
fsm->crzvar = 0;
}
++fsm->crznum;
fsm->crzsum += length_blk;
avg = (double_t) fsm->crzsum / (double_t) fsm->crznum; /* average */
fsm->crzvar
+= (uint64_t) (((double_t) length_blk - avg) * ((double_t) length_blk - avg) + 0.5L); /* variance */
}
if (!rc && (opts & IWFSM_SOLID_ALLOCATED_SPACE)) {
uint64_t bs = *offset_blk;
int64_t bl = *olength_blk;
rc = _fsm_ensure_size_lw(fsm, (bs << fsm->bpow) + (bl << fsm->bpow));
}
if (!rc && (opts & IWFSM_SYNC_BMAP)) {
uint64_t *bmptr;
if (!_fsm_bmptr(fsm, &bmptr)) {
IWFS_EXT *pool = &fsm->pool;
rc = pool->sync_mmap(pool, fsm->bmoff, IWFS_SYNCDEFAULT);
}
}
return rc;
}
/**
* @brief Remove all free blocks from the and of file and trim its size.
*/
static iwrc _fsm_trim_tail_lw(struct fsm *fsm) {
iwrc rc;
int hasleft;
uint64_t length, lastblk, *bmptr;
IWFS_EXT_STATE fstate;
uint64_t offset = 0;
if (!(fsm->omode & IWFS_OWRITE)) {
return 0;
}
/* find free space for fsm with lesser offset than actual */
rc = _fsm_blk_allocate_aligned_lw(
fsm, (fsm->bmlen >> fsm->bpow), &offset, &length, (fsm->bmoff >> fsm->bpow),
IWFSM_ALLOC_NO_EXTEND | IWFSM_ALLOC_NO_OVERALLOCATE | IWFSM_ALLOC_NO_STATS);
if (rc && (rc != IWFS_ERROR_NO_FREE_SPACE)) {
return rc;
}
if (rc) {
rc = 0;
} else if ((offset << fsm->bpow) < fsm->bmoff) {
offset = offset << fsm->bpow;
length = length << fsm->bpow;
assert(offset != fsm->bmoff);
fsm->pool.add_mmap(&fsm->pool, offset, length, fsm->mmap_opts);
RCC(rc, finish, _fsm_init_lw(fsm, offset, length));
} else {
/* shoud never be reached */
assert(0);
RCC(rc, finish, _fsm_blk_deallocate_lw(fsm, offset, length));
}
RCC(rc, finish, _fsm_bmptr(fsm, &bmptr)); // -V519
lastblk = (fsm->bmoff + fsm->bmlen) >> fsm->bpow;
offset = _fsm_find_prev_set_bit(bmptr, (fsm->bmlen << 3), lastblk, &hasleft);
if (hasleft) {
lastblk = offset + 1;
}
rc = fsm->pool.state(&fsm->pool, &fstate);
if (!rc && (fstate.fsize > (lastblk << fsm->bpow))) {
rc = fsm->pool.truncate(&fsm->pool, lastblk << fsm->bpow);
}
finish:
return rc;
}
static iwrc _fsm_init_impl(struct fsm *fsm, const IWFS_FSM_OPTS *opts) {
fsm->oflags = opts->oflags;
fsm->aunit = iwp_alloc_unit();
fsm->bpow = opts->bpow;
fsm->mmap_all = opts->mmap_all;
if (!fsm->bpow) {
fsm->bpow = 6; // 64bit block
} else if (fsm->bpow > FSM_MAX_BLOCK_POW) {
return IWFS_ERROR_INVALID_BLOCK_SIZE;
} else if ((1U << fsm->bpow) > fsm->aunit) {
return IWFS_ERROR_PLATFORM_PAGE;
}
return 0;
}
static iwrc _fsm_init_locks(struct fsm *fsm, const IWFS_FSM_OPTS *opts) {
if (opts->oflags & IWFSM_NOLOCKS) {
fsm->ctlrwlk = 0;
return 0;
}
fsm->ctlrwlk = calloc(1, sizeof(*fsm->ctlrwlk));
if (!fsm->ctlrwlk) {
return iwrc_set_errno(IW_ERROR_ALLOC, errno);
}
int rci = pthread_rwlock_init(fsm->ctlrwlk, 0);
if (rci) {
free(fsm->ctlrwlk);
fsm->ctlrwlk = 0;
return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci);
}
return 0;
}
static iwrc _fsm_destroy_locks(struct fsm *fsm) {
if (!fsm->ctlrwlk) {
return 0;
}
iwrc rc = 0;
int rci = pthread_rwlock_destroy(fsm->ctlrwlk);
if (rci) {
IWRC(iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci), rc);
}
free(fsm->ctlrwlk);
fsm->ctlrwlk = 0;
return rc;
}
static iwrc _fsm_read_meta_lr(struct fsm *fsm) {
iwrc rc;
uint32_t lv;
uint64_t llv;
size_t sp, rp = 0;
uint8_t hdr[IWFSM_CUSTOM_HDR_DATA_OFFSET] = { 0 };
/*
[FSM_CTL_MAGICK u32][block pow u8]
[bmoffset u64][bmlength u64]
[u64 crzsum][u32 crznum][u64 crszvar][u256 reserved]
[custom header size u32][custom header data...]
[fsm data...]
*/
rc = fsm->pool.read(&fsm->pool, 0, hdr, IWFSM_CUSTOM_HDR_DATA_OFFSET, &sp);
if (rc) {
iwlog_ecode_error3(rc);
return rc;
}
/* Magic */
memcpy(&lv, hdr + rp, sizeof(lv)); // -V512
lv = IW_ITOHL(lv);
if (lv != IWFSM_MAGICK) {
rc = IWFS_ERROR_INVALID_FILEMETA;
iwlog_ecode_error2(rc, "Invalid file magic number");
return rc;
}
rp += sizeof(lv);
/* Block pow */
memcpy(&fsm->bpow, hdr + rp, sizeof(fsm->bpow));
rp += sizeof(fsm->bpow);
if (fsm->bpow > FSM_MAX_BLOCK_POW) {
rc = IWFS_ERROR_INVALID_FILEMETA;
iwlog_ecode_error(rc, "Invalid file blocks pow: %u", fsm->bpow);
return rc;
}
if ((1U << fsm->bpow) > fsm->aunit) {
rc = IWFS_ERROR_PLATFORM_PAGE;
iwlog_ecode_error(rc, "Block size: %u must not be greater than system page size: %zu",
(1U << fsm->bpow), fsm->aunit);
}
/* Free-space bitmap offset */
memcpy(&llv, hdr + rp, sizeof(llv));
llv = IW_ITOHLL(llv);
fsm->bmoff = llv;
rp += sizeof(llv);
/* Free-space bitmap length */
memcpy(&llv, hdr + rp, sizeof(llv));
llv = IW_ITOHLL(llv);
fsm->bmlen = llv;
if (llv & (64 - 1)) {
rc = IWFS_ERROR_INVALID_FILEMETA;
iwlog_ecode_error(rc, "Free-space bitmap length is not 64bit aligned: %" PRIuMAX "", fsm->bmlen);
}
rp += sizeof(llv);
/* Cumulative sum of record sizes acquired by `allocate` */
memcpy(&llv, hdr + rp, sizeof(llv));
llv = IW_ITOHLL(llv);
fsm->crzsum = llv;
rp += sizeof(llv);
/* Cumulative number of records acquired by `allocated` */
memcpy(&lv, hdr + rp, sizeof(lv));
lv = IW_ITOHL(lv);
fsm->crznum = lv;
rp += sizeof(lv);
/* Record sizes standard variance (deviation^2 * N) */
memcpy(&llv, hdr + rp, sizeof(llv));
llv = IW_ITOHLL(llv);
fsm->crzvar = llv;
rp += sizeof(llv);
/* Reserved */
rp += 32;
/* Header size */
memcpy(&lv, hdr + rp, sizeof(lv));
lv = IW_ITOHL(lv);
fsm->hdrlen = lv;
rp += sizeof(lv);
assert(rp == IWFSM_CUSTOM_HDR_DATA_OFFSET);
return rc;
}
static iwrc _fsm_init_new_lw(struct fsm *fsm, const IWFS_FSM_OPTS *opts) {
FSM_ENSURE_OPEN(fsm);
iwrc rc;
uint64_t bmlen, bmoff;
IWFS_EXT *pool = &fsm->pool;
assert(fsm->aunit && fsm->bpow);
fsm->hdrlen = opts->hdrlen + IWFSM_CUSTOM_HDR_DATA_OFFSET;
fsm->hdrlen = IW_ROUNDUP(fsm->hdrlen, 1ULL << fsm->bpow);
bmlen = opts->bmlen > 0 ? IW_ROUNDUP(opts->bmlen, fsm->aunit) : fsm->aunit;
bmoff = IW_ROUNDUP(fsm->hdrlen, fsm->aunit);
if (fsm->mmap_all) {
/* mmap whole file */
rc = pool->add_mmap(pool, 0, SIZE_T_MAX, fsm->mmap_opts);
RCRET(rc);
} else {
/* mmap header */
rc = pool->add_mmap(pool, 0, fsm->hdrlen, fsm->mmap_opts);
RCRET(rc);
/* mmap the fsm bitmap index */
rc = pool->add_mmap(pool, bmoff, bmlen, fsm->mmap_opts);
RCRET(rc);
}
return _fsm_init_lw(fsm, bmoff, bmlen);
}
static iwrc _fsm_init_existing_lw(struct fsm *fsm) {
FSM_ENSURE_OPEN(fsm);
iwrc rc;
size_t sp;
uint8_t *mm;
IWFS_EXT *pool = &fsm->pool;
RCC(rc, finish, _fsm_read_meta_lr(fsm));
if (fsm->mmap_all) {
/* mmap the whole file */
RCC(rc, finish, pool->add_mmap(pool, 0, SIZE_T_MAX, fsm->mmap_opts));
RCC(rc, finish, pool->probe_mmap(pool, 0, &mm, &sp));
if (sp < fsm->bmoff + fsm->bmlen) {
rc = IWFS_ERROR_NOT_MMAPED;
goto finish;
} else {
mm += fsm->bmoff;
}
} else {
/* mmap the header of file */
RCC(rc, finish, pool->add_mmap(pool, 0, fsm->hdrlen, fsm->mmap_opts));
/* mmap the fsm bitmap index */
RCC(rc, finish, pool->add_mmap(pool, fsm->bmoff, fsm->bmlen, fsm->mmap_opts));
RCC(rc, finish, pool->probe_mmap(pool, fsm->bmoff, &mm, &sp));
if (sp < fsm->bmlen) {
rc = IWFS_ERROR_NOT_MMAPED;
goto finish;
}
}
_fsm_load_fsm_lw(fsm, mm, fsm->bmlen);
finish:
return rc;
}
/**
* @brief Check if all blocks within the specified range have been `allocated`.
*
* @param fsm `struct fsm`
* @param offset_blk Starting block number of the specified range.
* @param length_blk Range size in blocks.
* @param [out] ret Checking result.
*/
static iwrc _fsm_is_fully_allocated_lr(struct fsm *fsm, uint64_t offset_blk, uint64_t length_blk, int *ret) {
uint64_t end = offset_blk + length_blk;
*ret = 1;
if ((length_blk < 1) || (end < offset_blk) || (end > (fsm->bmlen << 3))) {
*ret = 0;
return 0;
}
iwrc rc = _fsm_set_bit_status_lw(fsm, offset_blk, length_blk, 0, FSM_BM_DRY_RUN | FSM_BM_STRICT);
if (rc == IWFS_ERROR_FSM_SEGMENTATION) {
*ret = 0;
return 0;
}
return rc;
}
/*************************************************************************************************
* Public API *
*************************************************************************************************/
static iwrc _fsm_write(struct IWFS_FSM *f, off_t off, const void *buf, size_t siz, size_t *sp) {
FSM_ENSURE_OPEN2(f);
struct fsm *fsm = f->impl;
iwrc rc = _fsm_ctrl_rlock(fsm);
RCRET(rc);
if (fsm->oflags & IWFSM_STRICT) {
int allocated = 0;
IWRC(_fsm_is_fully_allocated_lr(fsm,
(uint64_t) off >> fsm->bpow,
IW_ROUNDUP(siz, 1ULL << fsm->bpow) >> fsm->bpow,
&allocated), rc);
if (!rc) {
if (!allocated) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
} else {
rc = fsm->pool.write(&fsm->pool, off, buf, siz, sp);
}
}
} else {
rc = fsm->pool.write(&fsm->pool, off, buf, siz, sp);
}
_fsm_ctrl_unlock(fsm);
return rc;
}
static iwrc _fsm_read(struct IWFS_FSM *f, off_t off, void *buf, size_t siz, size_t *sp) {
FSM_ENSURE_OPEN2(f);
struct fsm *fsm = f->impl;
iwrc rc = _fsm_ctrl_rlock(fsm);
RCRET(rc);
if (fsm->oflags & IWFSM_STRICT) {
int allocated = 0;
IWRC(_fsm_is_fully_allocated_lr(fsm, (uint64_t) off >> fsm->bpow,
IW_ROUNDUP(siz, 1ULL << fsm->bpow) >> fsm->bpow,
&allocated), rc);
if (!rc) {
if (!allocated) {
rc = IWFS_ERROR_FSM_SEGMENTATION;
} else {
rc = fsm->pool.read(&fsm->pool, off, buf, siz, sp);
}
}
} else {
rc = fsm->pool.read(&fsm->pool, off, buf, siz, sp);
}
_fsm_ctrl_unlock(fsm);
return rc;
}
static iwrc _fsm_sync(struct IWFS_FSM *f, iwfs_sync_flags flags) {
FSM_ENSURE_OPEN2(f);
iwrc rc = _fsm_ctrl_rlock(f->impl);
RCRET(rc);
IWRC(_fsm_write_meta_lw(f->impl), rc);
IWRC(f->impl->pool.sync(&f->impl->pool, flags), rc);
IWRC(_fsm_ctrl_unlock(f->impl), rc);
return rc;
}
static iwrc _fsm_close(struct IWFS_FSM *f) {
if (!f || !f->impl) {
return 0;
}
iwrc rc = 0;
struct fsm *fsm = f->impl;
IWRC(_fsm_ctrl_wlock(fsm), rc);
if (fsm->root && (fsm->omode & IWFS_OWRITE)) {
if (!(fsm->oflags & IWFSM_NO_TRIM_ON_CLOSE)) {
IWRC(_fsm_trim_tail_lw(fsm), rc);
}
IWRC(_fsm_write_meta_lw(fsm), rc);
if (!fsm->dlsnr) {
IWRC(fsm->pool.sync(&fsm->pool, IWFS_SYNCDEFAULT), rc);
}
}
IWRC(fsm->pool.close(&fsm->pool), rc);
_fsm_node_destroy(fsm->root);
IWRC(_fsm_ctrl_unlock(fsm), rc);
IWRC(_fsm_destroy_locks(fsm), rc);
f->impl = 0;
free(fsm);
return rc;
}
IW_INLINE iwrc _fsm_ensure_size_lw(struct fsm *fsm, off_t size) {
return fsm->pool.ensure_size(&fsm->pool, size);
}
static iwrc _fsm_ensure_size(struct IWFS_FSM *f, off_t size) {
FSM_ENSURE_OPEN2(f);
iwrc rc = _fsm_ctrl_rlock(f->impl);
RCRET(rc);
if (f->impl->bmoff + f->impl->bmlen > size) {
rc = IWFS_ERROR_RESIZE_FAIL;
goto finish;
}
rc = _fsm_ensure_size_lw(f->impl, size);
finish:
IWRC(_fsm_ctrl_unlock(f->impl), rc);
return rc;
}
static iwrc _fsm_add_mmap(struct IWFS_FSM *f, off_t off, size_t maxlen, iwfs_ext_mmap_opts_t opts) {
FSM_ENSURE_OPEN2(f);
return f->impl->pool.add_mmap(&f->impl->pool, off, maxlen, opts);
}
static iwrc _fsm_remap_all(struct IWFS_FSM *f) {
FSM_ENSURE_OPEN2(f);
return f->impl->pool.remap_all(&f->impl->pool);
}
iwrc _fsm_acquire_mmap(struct IWFS_FSM *f, off_t off, uint8_t **mm, size_t *sp) {
return f->impl->pool.acquire_mmap(&f->impl->pool, off, mm, sp);
}
iwrc _fsm_release_mmap(struct IWFS_FSM *f) {
return f->impl->pool.release_mmap(&f->impl->pool);
}
static iwrc _fsm_probe_mmap(struct IWFS_FSM *f, off_t off, uint8_t **mm, size_t *sp) {
FSM_ENSURE_OPEN2(f);
return f->impl->pool.probe_mmap(&f->impl->pool, off, mm, sp);
}
static iwrc _fsm_remove_mmap(struct IWFS_FSM *f, off_t off) {
FSM_ENSURE_OPEN2(f);
return f->impl->pool.remove_mmap(&f->impl->pool, off);
}
static iwrc _fsm_sync_mmap(struct IWFS_FSM *f, off_t off, iwfs_sync_flags flags) {
FSM_ENSURE_OPEN2(f);
return f->impl->pool.sync_mmap(&f->impl->pool, off, flags);
}
static iwrc _fsm_allocate(struct IWFS_FSM *f, off_t len, off_t *oaddr, off_t *olen, iwfs_fsm_aflags opts) {
FSM_ENSURE_OPEN2(f);
iwrc rc;
uint64_t sbnum, nlen;
struct fsm *fsm = f->impl;
*olen = 0;
if (!(fsm->omode & IWFS_OWRITE)) {
return IW_ERROR_READONLY;
}
if (len <= 0) {
return IW_ERROR_INVALID_ARGS;
}
/* Required blocks number */
sbnum = (uint64_t) *oaddr >> fsm->bpow;
len = IW_ROUNDUP(len, 1ULL << fsm->bpow);
rc = _fsm_ctrl_wlock(fsm);
RCRET(rc);
rc = _fsm_blk_allocate_lw(f->impl, (uint64_t) len >> fsm->bpow, &sbnum, &nlen, opts);
if (!rc) {
*olen = (nlen << fsm->bpow);
*oaddr = (sbnum << fsm->bpow);
}
IWRC(_fsm_ctrl_unlock(fsm), rc);
return rc;
}
static iwrc _fsm_reallocate(struct IWFS_FSM *f, off_t nlen, off_t *oaddr, off_t *olen, iwfs_fsm_aflags opts) {
FSM_ENSURE_OPEN2(f);
iwrc rc;
struct fsm *fsm = f->impl;
if (!(fsm->omode & IWFS_OWRITE)) {
return IW_ERROR_READONLY;
}
if ((*oaddr & ((1ULL << fsm->bpow) - 1)) || (*olen & ((1ULL << fsm->bpow) - 1))) {
return IWFS_ERROR_RANGE_NOT_ALIGNED;
}
uint64_t sp;
uint64_t nlen_blk = IW_ROUNDUP((uint64_t) nlen, 1ULL << fsm->bpow) >> fsm->bpow;
uint64_t olen_blk = (uint64_t) *olen >> fsm->bpow;
uint64_t oaddr_blk = (uint64_t) *oaddr >> fsm->bpow;
uint64_t naddr_blk = oaddr_blk;
if (nlen_blk == olen_blk) {
return 0;
}
rc = _fsm_ctrl_wlock(fsm);
RCRET(rc);
if (nlen_blk < olen_blk) {
rc = _fsm_blk_deallocate_lw(fsm, oaddr_blk + nlen_blk, olen_blk - nlen_blk);
if (!rc) {
*oaddr = oaddr_blk << fsm->bpow;
*olen = nlen_blk << fsm->bpow;
}
} else {
RCC(rc, finish, _fsm_blk_allocate_lw(fsm, nlen_blk, &naddr_blk, &sp, opts));
if (naddr_blk != oaddr_blk) {
RCC(rc, finish, fsm->pool.copy(&fsm->pool, *oaddr, (size_t) *olen, naddr_blk << fsm->bpow));
}
RCC(rc, finish, _fsm_blk_deallocate_lw(fsm, oaddr_blk, olen_blk));
*oaddr = naddr_blk << fsm->bpow;
*olen = sp << fsm->bpow;
}
finish:
IWRC(_fsm_ctrl_unlock(fsm), rc);
return rc;
}
static iwrc _fsm_deallocate(struct IWFS_FSM *f, off_t addr, off_t len) {
FSM_ENSURE_OPEN2(f);
iwrc rc;
struct fsm *fsm = f->impl;
off_t offset_blk = (uint64_t) addr >> fsm->bpow;
off_t length_blk = (uint64_t) len >> fsm->bpow;
if (!(fsm->omode & IWFS_OWRITE)) {
return IW_ERROR_READONLY;
}
if (addr & ((1ULL << fsm->bpow) - 1)) {
return IWFS_ERROR_RANGE_NOT_ALIGNED;
}
rc = _fsm_ctrl_wlock(fsm);
RCRET(rc);
if ( IW_RANGES_OVERLAP(offset_blk, offset_blk + length_blk, 0, (fsm->hdrlen >> fsm->bpow))
|| IW_RANGES_OVERLAP(offset_blk, offset_blk + length_blk, (fsm->bmoff >> fsm->bpow),
(fsm->bmoff >> fsm->bpow) + (fsm->bmlen >> fsm->bpow))) {
// Deny deallocations in header or free-space bitmap itself
IWRC(_fsm_ctrl_unlock(fsm), rc);
return IWFS_ERROR_FSM_SEGMENTATION;
}
rc = _fsm_blk_deallocate_lw(fsm, (uint64_t) offset_blk, (uint64_t) length_blk);
IWRC(_fsm_ctrl_unlock(fsm), rc);
return rc;
}
static iwrc _fsm_check_allocation_status(struct IWFS_FSM *f, off_t addr, off_t len, bool allocated) {
struct fsm *fsm = f->impl;
if ((addr & ((1ULL << fsm->bpow) - 1)) || (len & ((1ULL << fsm->bpow) - 1))) {
return IWFS_ERROR_RANGE_NOT_ALIGNED;
}
iwrc rc = _fsm_ctrl_rlock(fsm);
RCRET(rc);
off_t offset_blk = (uint64_t) addr >> fsm->bpow;
off_t length_blk = (uint64_t) len >> fsm->bpow;
if ( IW_RANGES_OVERLAP(offset_blk, offset_blk + length_blk, 0, (fsm->hdrlen >> fsm->bpow))
|| IW_RANGES_OVERLAP(offset_blk, offset_blk + length_blk, (fsm->bmoff >> fsm->bpow),
(fsm->bmoff >> fsm->bpow) + (fsm->bmlen >> fsm->bpow))) {
IWRC(_fsm_ctrl_unlock(fsm), rc);
return IWFS_ERROR_FSM_SEGMENTATION;
}
rc = _fsm_set_bit_status_lw(fsm, (uint64_t) offset_blk, (uint64_t) length_blk,
allocated ? 0 : 1, FSM_BM_DRY_RUN | FSM_BM_STRICT);
IWRC(_fsm_ctrl_unlock(fsm), rc);
return rc;
}
static iwrc _fsm_writehdr(struct IWFS_FSM *f, off_t off, const void *buf, off_t siz) {
FSM_ENSURE_OPEN2(f);
iwrc rc;
uint8_t *mm;
if (siz < 1) {
return 0;
}
struct fsm *fsm = f->impl;
if ((IWFSM_CUSTOM_HDR_DATA_OFFSET + off + siz) > fsm->hdrlen) {
return IW_ERROR_OUT_OF_BOUNDS;
}
rc = fsm->pool.acquire_mmap(&fsm->pool, 0, &mm, 0);
if (!rc) {
if (fsm->dlsnr) {
rc = fsm->dlsnr->onwrite(fsm->dlsnr, IWFSM_CUSTOM_HDR_DATA_OFFSET + off, buf, siz, 0);
}
memmove(mm + IWFSM_CUSTOM_HDR_DATA_OFFSET + off, buf, (size_t) siz);
IWRC(fsm->pool.release_mmap(&fsm->pool), rc);
}
return rc;
}
static iwrc _fsm_readhdr(struct IWFS_FSM *f, off_t off, void *buf, off_t siz) {
FSM_ENSURE_OPEN2(f);
iwrc rc;
uint8_t *mm;
if (siz < 1) {
return 0;
}
struct fsm *fsm = f->impl;
if ((IWFSM_CUSTOM_HDR_DATA_OFFSET + off + siz) > fsm->hdrlen) {
return IW_ERROR_OUT_OF_BOUNDS;
}
rc = fsm->pool.acquire_mmap(&fsm->pool, 0, &mm, 0);
if (!rc) {
memmove(buf, mm + IWFSM_CUSTOM_HDR_DATA_OFFSET + off, (size_t) siz);
rc = fsm->pool.release_mmap(&fsm->pool);
}
return rc;
}
static iwrc _fsm_clear(struct IWFS_FSM *f, iwfs_fsm_clrfalgs clrflags) {
FSM_ENSURE_OPEN2(f);
struct fsm *fsm = f->impl;
uint64_t bmoff, bmlen;
iwrc rc = _fsm_ctrl_wlock(fsm);
bmlen = fsm->bmlen;
if (!bmlen) {
goto finish;
}
if (!fsm->mmap_all && fsm->bmoff) {
IWRC(fsm->pool.remove_mmap(&fsm->pool, fsm->bmoff), rc);
}
bmoff = IW_ROUNDUP(fsm->hdrlen, fsm->aunit);
if (!fsm->mmap_all) {
IWRC(fsm->pool.add_mmap(&fsm->pool, bmoff, bmlen, fsm->mmap_opts), rc);
}
RCGO(rc, finish);
fsm->bmlen = 0;
fsm->bmoff = 0;
rc = _fsm_init_lw(fsm, bmoff, bmlen);
if (!rc && (clrflags & IWFSM_CLEAR_TRIM)) {
rc = _fsm_trim_tail_lw(fsm);
}
finish:
IWRC(_fsm_ctrl_unlock(fsm), rc);
return rc;
}
static iwrc _fsm_extfile(struct IWFS_FSM *f, IWFS_EXT **ext) {
FSM_ENSURE_OPEN2(f);
*ext = &f->impl->pool;
return 0;
}
static iwrc _fsm_state(struct IWFS_FSM *f, IWFS_FSM_STATE *state) {
FSM_ENSURE_OPEN2(f);
struct fsm *fsm = f->impl;
iwrc rc = _fsm_ctrl_rlock(fsm);
memset(state, 0, sizeof(*state));
IWRC(fsm->pool.state(&fsm->pool, &state->exfile), rc);
state->block_size = 1U << fsm->bpow;
state->oflags = fsm->oflags;
state->hdrlen = fsm->hdrlen;
state->blocks_num = fsm->bmlen << 3;
state->free_segments_num = fsm->fsmnum;
state->avg_alloc_size = fsm->crznum > 0 ? (double_t) fsm->crzsum / (double_t) fsm->crznum : 0;
state->alloc_dispersion = fsm->crznum > 0 ? (double_t) fsm->crzvar / (double_t) fsm->crznum : 0;
IWRC(_fsm_ctrl_unlock(fsm), rc);
return rc;
}
iwrc iwfs_fsmfile_open(IWFS_FSM *f, const IWFS_FSM_OPTS *opts) {
assert(f && opts);
iwrc rc = 0;
IWFS_EXT_STATE fstate = { 0 };
const char *path = opts->exfile.file.path;
memset(f, 0, sizeof(*f));
RCC(rc, finish, iwfs_fsmfile_init());
f->write = _fsm_write;
f->read = _fsm_read;
f->close = _fsm_close;
f->sync = _fsm_sync;
f->state = _fsm_state;
f->ensure_size = _fsm_ensure_size;
f->add_mmap = _fsm_add_mmap;
f->remap_all = _fsm_remap_all;
f->acquire_mmap = _fsm_acquire_mmap;
f->probe_mmap = _fsm_probe_mmap;
f->release_mmap = _fsm_release_mmap;
f->remove_mmap = _fsm_remove_mmap;
f->sync_mmap = _fsm_sync_mmap;
f->allocate = _fsm_allocate;
f->reallocate = _fsm_reallocate;
f->deallocate = _fsm_deallocate;
f->check_allocation_status = _fsm_check_allocation_status;
f->writehdr = _fsm_writehdr;
f->readhdr = _fsm_readhdr;
f->clear = _fsm_clear;
f->extfile = _fsm_extfile;
if (!path) {
return IW_ERROR_INVALID_ARGS;
}
struct fsm *fsm = f->impl = calloc(1, sizeof(*f->impl));
if (!fsm) {
return iwrc_set_errno(IW_ERROR_ALLOC, errno);
}
fsm->f = f;
fsm->dlsnr = opts->exfile.file.dlsnr; // Copy data changes listener address
fsm->mmap_opts = opts->mmap_opts;
IWFS_EXT_OPTS rwl_opts = opts->exfile;
rwl_opts.use_locks = !(opts->oflags & IWFSM_NOLOCKS);
RCC(rc, finish, _fsm_init_impl(fsm, opts));
RCC(rc, finish, _fsm_init_locks(fsm, opts));
RCC(rc, finish, iwfs_exfile_open(&fsm->pool, &rwl_opts));
RCC(rc, finish, fsm->pool.state(&fsm->pool, &fstate));
fsm->omode = fstate.file.opts.omode;
if (fstate.file.ostatus & IWFS_OPEN_NEW) {
rc = _fsm_init_new_lw(fsm, opts);
} else {
rc = _fsm_init_existing_lw(fsm);
}
finish:
if (rc) {
if (f->impl) {
IWRC(_fsm_destroy_locks(f->impl), rc); // we are not locked
IWRC(_fsm_close(f), rc);
}
}
return rc;
}
static const char* _fsmfile_ecodefn(locale_t locale, uint32_t ecode) {
if (!((ecode > _IWFS_FSM_ERROR_START) && (ecode < _IWFS_FSM_ERROR_END))) {
return 0;
}
switch (ecode) {
case IWFS_ERROR_NO_FREE_SPACE:
return "No free space. (IWFS_ERROR_NO_FREE_SPACE)";
case IWFS_ERROR_INVALID_BLOCK_SIZE:
return "Invalid block size specified. (IWFS_ERROR_INVALID_BLOCK_SIZE)";
case IWFS_ERROR_RANGE_NOT_ALIGNED:
return "Specified range/offset is not aligned with page/block. "
"(IWFS_ERROR_RANGE_NOT_ALIGNED)";
case IWFS_ERROR_FSM_SEGMENTATION:
return "Free-space map segmentation error. (IWFS_ERROR_FSM_SEGMENTATION)";
case IWFS_ERROR_INVALID_FILEMETA:
return "Invalid file metadata. (IWFS_ERROR_INVALID_FILEMETA)";
case IWFS_ERROR_PLATFORM_PAGE:
return "The block size incompatible with platform page size, data "
"migration required. (IWFS_ERROR_PLATFORM_PAGE)";
case IWFS_ERROR_RESIZE_FAIL:
return "Failed to resize file, "
"conflicting with free-space map location (IWFS_ERROR_RESIZE_FAIL)";
default:
break;
}
return 0;
}
iwrc iwfs_fsmfile_init(void) {
static int _fsmfile_initialized = 0;
iwrc rc = iw_init();
RCRET(rc);
if (!__sync_bool_compare_and_swap(&_fsmfile_initialized, 0, 1)) {
return 0; // initialized already
}
return iwlog_register_ecodefn(_fsmfile_ecodefn);
}
/*************************************************************************************************
* Debug API *
*************************************************************************************************/
uint64_t iwfs_fsmdbg_number_of_free_areas(IWFS_FSM *f) {
struct fsm *fsm = f->impl;
return fsm->fsmnum;
}
uint64_t iwfs_fsmdbg_find_next_set_bit(
const uint64_t *addr, uint64_t offset_bit, uint64_t max_offset_bit,
int *found
) {
return _fsm_find_next_set_bit(addr, offset_bit, max_offset_bit, found);
}
uint64_t iwfs_fsmdbg_find_prev_set_bit(
const uint64_t *addr, uint64_t offset_bit, uint64_t min_offset_bit,
int *found
) {
return _fsm_find_prev_set_bit(addr, offset_bit, min_offset_bit, found);
}
void iwfs_fsmdbg_dump_fsm_tree(IWFS_FSM *f, const char *hdr) {
assert(f);
struct fsm *fsm = f->impl;
fprintf(stderr, "FSM TREE: %s\n", hdr);
if (!fsm->root) {
fprintf(stderr, "NONE\n");
return;
}
for (struct iwavl_node *n = iwavl_first_in_order(fsm->root); n; n = iwavl_next_in_order(n)) {
struct bkey *k = &BKEY(n);
uint64_t koff = FSMBK_OFFSET(k);
uint64_t klen = FSMBK_LENGTH(k);
fprintf(stderr, "[%" PRIu64 " %" PRIu64 "]\n", koff, klen);
}
}
const char* byte_to_binary(int x) {
static char b[9];
b[0] = '\0';
int z;
for (z = 1; z <= 128; z <<= 1) {
strcat(b, ((x & z) == z) ? "1" : "0");
}
return b;
}
iwrc iwfs_fsmdb_dump_fsm_bitmap(IWFS_FSM *f) {
assert(f);
size_t sp;
uint8_t *mm;
struct fsm *fsm = f->impl;
iwrc rc;
if (fsm->mmap_all) {
rc = fsm->pool.probe_mmap(&fsm->pool, 0, &mm, &sp);
if (!rc) {
if (sp <= fsm->bmoff) {
rc = IWFS_ERROR_NOT_MMAPED;
} else {
mm += fsm->bmoff;
sp = sp - fsm->bmoff;
}
}
} else {
rc = fsm->pool.probe_mmap(&fsm->pool, fsm->bmoff, &mm, &sp);
}
if (rc) {
iwlog_ecode_error3(rc);
return rc;
}
int i = ((fsm->hdrlen >> fsm->bpow) >> 3);
// if (impl->bmoff == impl->aunit) {
// i += ((impl->bmlen >> impl->bpow) >> 3);
// }
for ( ; i < sp && i < fsm->bmlen; ++i) {
uint8_t b = *(mm + i);
fprintf(stderr, "%s", byte_to_binary(b));
}
printf("\n");
return 0;
}
iwrc iwfs_fsmdbg_state(IWFS_FSM *f, IWFS_FSMDBG_STATE *d) {
FSM_ENSURE_OPEN2(f);
struct fsm *fsm = f->impl;
iwrc rc = _fsm_ctrl_rlock(fsm);
memset(d, 0, sizeof(*d));
IWRC(fsm->pool.state(&fsm->pool, &d->state.exfile), rc);
d->state.block_size = 1U << fsm->bpow;
d->state.oflags = fsm->oflags;
d->state.hdrlen = fsm->hdrlen;
d->state.blocks_num = fsm->bmlen << 3;
d->state.free_segments_num = fsm->fsmnum;
d->state.avg_alloc_size = fsm->crznum > 0 ? (double_t) fsm->crzsum / (double_t) fsm->crznum : 0;
d->state.alloc_dispersion = fsm->crznum > 0 ? (double_t) fsm->crzvar / (double_t) fsm->crznum : 0;
d->bmoff = fsm->bmoff;
d->bmlen = fsm->bmlen;
d->lfbkoff = fsm->lfbkoff;
d->lfbklen = fsm->lfbklen;
IWRC(_fsm_ctrl_unlock(fsm), rc);
return rc;
}
|
b4fb189e29d3cad9c4cc86fda367846d95dd9d99
|
2d07a646d50c6cc1547b069ecd27c512623d8574
|
/src/core/os.h
|
4a26c2c8fc5aeb21fa29b70a144247c7922f17b0
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
bjornbytes/lovr
|
da40e59eb9c42debbc6e22356d55194283740323
|
072452a4dafb466e8af9a4bc546b60ae077f8566
|
refs/heads/master
| 2023-08-16T13:42:30.581144
| 2023-07-29T10:37:18
| 2023-07-29T10:37:18
| 62,519,414
| 1,699
| 164
|
MIT
| 2023-09-13T22:21:32
| 2016-07-03T23:36:45
|
C
|
UTF-8
|
C
| false
| false
| 3,311
|
h
|
os.h
|
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#pragma once
typedef struct os_window_config {
uint32_t width;
uint32_t height;
bool fullscreen;
bool resizable;
const char* title;
struct {
void* data;
uint32_t width;
uint32_t height;
} icon;
} os_window_config;
typedef enum {
MOUSE_LEFT,
MOUSE_RIGHT
} os_mouse_button;
typedef enum {
MOUSE_MODE_NORMAL,
MOUSE_MODE_GRABBED
} os_mouse_mode;
typedef enum {
KEY_A,
KEY_B,
KEY_C,
KEY_D,
KEY_E,
KEY_F,
KEY_G,
KEY_H,
KEY_I,
KEY_J,
KEY_K,
KEY_L,
KEY_M,
KEY_N,
KEY_O,
KEY_P,
KEY_Q,
KEY_R,
KEY_S,
KEY_T,
KEY_U,
KEY_V,
KEY_W,
KEY_X,
KEY_Y,
KEY_Z,
KEY_0,
KEY_1,
KEY_2,
KEY_3,
KEY_4,
KEY_5,
KEY_6,
KEY_7,
KEY_8,
KEY_9,
KEY_SPACE,
KEY_ENTER,
KEY_TAB,
KEY_ESCAPE,
KEY_BACKSPACE,
KEY_UP,
KEY_DOWN,
KEY_LEFT,
KEY_RIGHT,
KEY_HOME,
KEY_END,
KEY_PAGE_UP,
KEY_PAGE_DOWN,
KEY_INSERT,
KEY_DELETE,
KEY_F1,
KEY_F2,
KEY_F3,
KEY_F4,
KEY_F5,
KEY_F6,
KEY_F7,
KEY_F8,
KEY_F9,
KEY_F10,
KEY_F11,
KEY_F12,
KEY_BACKTICK,
KEY_MINUS,
KEY_EQUALS,
KEY_LEFT_BRACKET,
KEY_RIGHT_BRACKET,
KEY_BACKSLASH,
KEY_SEMICOLON,
KEY_APOSTROPHE,
KEY_COMMA,
KEY_PERIOD,
KEY_SLASH,
KEY_LEFT_CONTROL,
KEY_LEFT_SHIFT,
KEY_LEFT_ALT,
KEY_LEFT_OS,
KEY_RIGHT_CONTROL,
KEY_RIGHT_SHIFT,
KEY_RIGHT_ALT,
KEY_RIGHT_OS,
KEY_CAPS_LOCK,
KEY_SCROLL_LOCK,
KEY_NUM_LOCK,
KEY_COUNT
} os_key;
typedef enum {
BUTTON_PRESSED,
BUTTON_RELEASED
} os_button_action;
typedef enum {
OS_PERMISSION_AUDIO_CAPTURE
} os_permission;
typedef void fn_gl_proc(void);
typedef void fn_quit(void);
typedef void fn_focus(bool focused);
typedef void fn_resize(uint32_t width, uint32_t height);
typedef void fn_key(os_button_action action, os_key key, uint32_t scancode, bool repeat);
typedef void fn_text(uint32_t codepoint);
typedef void fn_permission(os_permission permission, bool granted);
bool os_init(void);
void os_destroy(void);
const char* os_get_name(void);
uint32_t os_get_core_count(void);
void os_open_console(void);
double os_get_time(void);
void os_sleep(double seconds);
void os_request_permission(os_permission permission);
void* os_vm_init(size_t size);
bool os_vm_free(void* p, size_t size);
bool os_vm_commit(void* p, size_t size);
bool os_vm_release(void* p, size_t size);
void os_poll_events(void);
void os_on_quit(fn_quit* callback);
void os_on_focus(fn_focus* callback);
void os_on_resize(fn_resize* callback);
void os_on_key(fn_key* callback);
void os_on_text(fn_text* callback);
void os_on_permission(fn_permission* callback);
bool os_window_open(const os_window_config* config);
bool os_window_is_open(void);
void os_window_get_size(uint32_t* width, uint32_t* height);
float os_window_get_pixel_density(void);
size_t os_get_home_directory(char* buffer, size_t size);
size_t os_get_data_directory(char* buffer, size_t size);
size_t os_get_working_directory(char* buffer, size_t size);
size_t os_get_executable_path(char* buffer, size_t size);
size_t os_get_bundle_path(char* buffer, size_t size, const char** root);
void os_get_mouse_position(double* x, double* y);
void os_set_mouse_mode(os_mouse_mode mode);
bool os_is_mouse_down(os_mouse_button button);
bool os_is_key_down(os_key key);
|
62a2b38927916f52b9f9d0a7aef6c3a6c56d962c
|
6d162c19c9f1dc1d03f330cad63d0dcde1df082d
|
/qrenderdoc/3rdparty/qt/include/QtWidgets/qtwidgets-config.h
|
3229c5626be0e4705b873ce9acd7b09975b41bcf
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-2.0-or-later",
"LGPL-3.0-only",
"GPL-3.0-only",
"Python-2.0",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-mit-old-style",
"LGPL-2.1-or-later",
"LGPL-2.1-only",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
"bzip2-1.0.6",
"Bison-exception-2.2",
"MIT-open-group",
"X11",
"blessing",
"BSD-3-Clause",
"BSD-4.3TAHOE",
"GPL-2.0-only",
"LicenseRef-scancode-free-unknown",
"IJG",
"xlock",
"HPND",
"LicenseRef-scancode-xfree86-1.0",
"LicenseRef-scancode-pcre",
"Libpng",
"FTL",
"Zlib",
"GPL-1.0-or-later",
"libtiff",
"LicenseRef-scancode-ietf",
"LicenseRef-scancode-cavium-malloc",
"LicenseRef-scancode-public-domain",
"HPND-sell-variant",
"ICU",
"BSD-2-Clause",
"LicenseRef-scancode-lcs-telegraphics",
"dtoa",
"LicenseRef-scancode-mit-veillard-variant",
"LicenseRef-scancode-public-domain-disclaimer",
"GFDL-1.1-or-later",
"CC-BY-SA-4.0",
"CC-BY-SA-3.0",
"GFDL-1.3-or-later",
"OpenSSL"
] |
permissive
|
baldurk/renderdoc
|
24efbb84446a9d443bb9350013f3bfab9e9c5923
|
a214ffcaf38bf5319b2b23d3d014cf3772cda3c6
|
refs/heads/v1.x
| 2023-08-16T21:20:43.886587
| 2023-07-28T22:34:10
| 2023-08-15T09:09:40
| 17,253,131
| 7,729
| 1,358
|
MIT
| 2023-09-13T09:36:53
| 2014-02-27T15:16:30
|
C++
|
UTF-8
|
C
| false
| false
| 2,499
|
h
|
qtwidgets-config.h
|
#define QT_FEATURE_abstractbutton 1
#define QT_FEATURE_abstractslider 1
#define QT_FEATURE_groupbox 1
#define QT_FEATURE_buttongroup 1
#define QT_FEATURE_label 1
#define QT_FEATURE_pushbutton 1
#define QT_FEATURE_menu 1
#define QT_FEATURE_lineedit 1
#define QT_FEATURE_spinbox 1
#define QT_FEATURE_slider 1
#define QT_FEATURE_scrollbar 1
#define QT_FEATURE_scrollarea 1
#define QT_FEATURE_itemviews 1
#define QT_FEATURE_tableview 1
#define QT_FEATURE_toolbutton 1
#define QT_FEATURE_calendarwidget 1
#define QT_FEATURE_checkbox 1
#define QT_FEATURE_dialog 1
#define QT_FEATURE_dialogbuttonbox 1
#define QT_FEATURE_colordialog 1
#define QT_FEATURE_listview 1
#define QT_FEATURE_columnview 1
#define QT_FEATURE_combobox 1
#define QT_FEATURE_commandlinkbutton 1
#define QT_FEATURE_completer 1
#define QT_FEATURE_contextmenu 1
#define QT_FEATURE_datawidgetmapper 1
#define QT_FEATURE_datetimeedit 1
#define QT_FEATURE_dial 1
#define QT_FEATURE_filesystemmodel 1
#define QT_FEATURE_dirmodel 1
#define QT_FEATURE_resizehandler 1
#define QT_FEATURE_mainwindow 1
#define QT_FEATURE_dockwidget 1
#define QT_FEATURE_textedit 1
#define QT_FEATURE_errormessage 1
#define QT_FEATURE_splitter 1
#define QT_FEATURE_stackedwidget 1
#define QT_FEATURE_treeview 1
#define QT_FEATURE_filedialog 1
#define QT_FEATURE_fontcombobox 1
#define QT_FEATURE_fontdialog 1
#define QT_FEATURE_formlayout 1
#define QT_FEATURE_fscompleter 1
#define QT_FEATURE_graphicsview 1
#define QT_FEATURE_graphicseffect 1
#define QT_FEATURE_inputdialog 1
#define QT_FEATURE_keysequenceedit 1
#define QT_FEATURE_lcdnumber 1
#define QT_FEATURE_listwidget 1
#define QT_FEATURE_mdiarea 1
#define QT_FEATURE_menubar 1
#define QT_FEATURE_messagebox 1
#define QT_FEATURE_paint_debug 1
#define QT_FEATURE_progressbar 1
#define QT_FEATURE_progressdialog 1
#define QT_FEATURE_radiobutton 1
#define QT_FEATURE_rubberband 1
#define QT_FEATURE_scroller 1
#define QT_FEATURE_sizegrip 1
#define QT_FEATURE_splashscreen 1
#define QT_FEATURE_statusbar 1
#define QT_FEATURE_statustip 1
#define QT_FEATURE_style_stylesheet 1
#define QT_FEATURE_syntaxhighlighter 1
#define QT_FEATURE_tabbar 1
#define QT_FEATURE_tablewidget 1
#define QT_FEATURE_tabwidget 1
#define QT_FEATURE_textbrowser 1
#define QT_FEATURE_toolbar 1
#define QT_FEATURE_toolbox 1
#define QT_FEATURE_tooltip 1
#define QT_FEATURE_treewidget 1
#define QT_FEATURE_undocommand 1
#define QT_FEATURE_undostack 1
#define QT_FEATURE_undogroup 1
#define QT_FEATURE_undoview 1
#define QT_FEATURE_wizard 1
|
fdd4fdc47684f6d501ad3c21167636b8932ceba9
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/www/qt5-webengine/files/patch-src_3rdparty_chromium_third__party_libXNVCtrl_NVCtrl.c
|
ac5f5048d107a87d963811870fb709de6f37d907
|
[
"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
| 601
|
c
|
patch-src_3rdparty_chromium_third__party_libXNVCtrl_NVCtrl.c
|
--- src/3rdparty/chromium/third_party/libXNVCtrl/NVCtrl.c.orig 2018-11-13 18:25:11 UTC
+++ src/3rdparty/chromium/third_party/libXNVCtrl/NVCtrl.c
@@ -27,10 +27,6 @@
* libXNVCtrl library properly protects the Display connection.
*/
-#if !defined(XTHREADS)
-#define XTHREADS
-#endif /* XTHREADS */
-
#define NEED_EVENTS
#define NEED_REPLIES
#include <stdint.h>
@@ -39,6 +35,11 @@
#include <X11/Xutil.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
+
+#if !defined(XTHREADS)
+#define XTHREADS
+#endif /* XTHREADS */
+
#include "NVCtrlLib.h"
#include "nv_control.h"
|
b209ec7aecd16f73c178dc1236356753ab94e756
|
98ee5bc94e754d9b1802d66d7b5c5fcf184a6c90
|
/lib/include/snow3g_submit.h
|
1f7293115a012087d15475d4addc8aef67c5dbf0
|
[
"BSD-3-Clause"
] |
permissive
|
intel/intel-ipsec-mb
|
f180701ca3dbdc26f310c5706cb3e8577defa2df
|
9e17d6cad1f99e64f3534053a3ff096c46646058
|
refs/heads/main
| 2023-08-30T13:20:47.709185
| 2023-08-28T13:17:46
| 2023-08-29T13:14:00
| 73,856,328
| 255
| 89
|
BSD-3-Clause
| 2023-08-30T08:42:45
| 2016-11-15T21:22:17
|
C
|
UTF-8
|
C
| false
| false
| 2,958
|
h
|
snow3g_submit.h
|
/*******************************************************************************
Copyright (c) 2012-2023, Intel Corporation
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 Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#ifndef SNOW3G_SUBMIT_H
#define SNOW3G_SUBMIT_H
#include "intel-ipsec-mb.h"
static inline IMB_JOB *def_submit_snow3g_uea2_job(IMB_MGR *state, IMB_JOB *job)
{
const snow3g_key_schedule_t *key = job->enc_keys;
const uint32_t bitlen = (uint32_t) job->msg_len_to_cipher_in_bits;
const uint32_t bitoff = (uint32_t) job->cipher_start_offset_in_bits;
/* Use bit length API if
* - msg length is not a multiple of bytes
* - bit offset is not a multiple of bytes
*/
if ((bitlen & 0x07) || (bitoff & 0x07)) {
IMB_SNOW3G_F8_1_BUFFER_BIT(state, key, job->iv, job->src,
job->dst, bitlen, bitoff);
} else {
const uint32_t bytelen = bitlen >> 3;
const uint32_t byteoff = bitoff >> 3;
const void *src = job->src + byteoff;
void *dst = job->dst + byteoff;
IMB_SNOW3G_F8_1_BUFFER(state, key, job->iv, src, dst, bytelen);
}
job->status |= IMB_STATUS_COMPLETED_CIPHER;
return job;
}
static inline IMB_JOB *def_flush_snow3g_uea2_job(IMB_MGR *state)
{
(void) state;
return NULL;
}
#endif /* SNOW3G_SUBMIT_H */
|
73bf6a4d7da1e572b123305cd73a8327c7b96c1c
|
3499b1145f0827498625ec0ac71ba82bbbbda4ed
|
/board-package-source/libraries/Arduboy/src/ab_logo.c
|
3718e5cde969f5bb9c3970dd3d85dca135af7bd7
|
[
"BSD-3-Clause",
"BSD-2-Clause",
"CC0-1.0"
] |
permissive
|
MrBlinky/Arduboy-homemade-package
|
09120974a9c6a9ad1871ac68cbf852bb253bbd8e
|
3b71be313e1a4daaa745a15cdf2b58c92b101441
|
refs/heads/master
| 2023-07-22T18:36:15.664481
| 2023-07-15T22:08:51
| 2023-07-15T22:08:51
| 121,283,656
| 104
| 31
|
CC0-1.0
| 2023-01-02T08:24:54
| 2018-02-12T18:16:15
|
C++
|
UTF-8
|
C
| false
| false
| 1,246
|
c
|
ab_logo.c
|
#include <avr/pgmspace.h>
#ifndef ARDUBOY_LOGO_CREATED
#define ARDUBOY_LOGO_CREATED
// arduboy_logo.png
// 88x16
PROGMEM const unsigned char arduboy_logo[] = {
0xF0, 0xF8, 0x9C, 0x8E, 0x87, 0x83, 0x87, 0x8E, 0x9C, 0xF8,
0xF0, 0x00, 0x00, 0xFE, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03,
0x07, 0x0E, 0xFC, 0xF8, 0x00, 0x00, 0xFE, 0xFF, 0x03, 0x03,
0x03, 0x03, 0x03, 0x07, 0x0E, 0xFC, 0xF8, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x00, 0x00, 0xFE, 0xFF, 0x83, 0x83, 0x83, 0x83, 0x83, 0xC7,
0xEE, 0x7C, 0x38, 0x00, 0x00, 0xF8, 0xFC, 0x0E, 0x07, 0x03,
0x03, 0x03, 0x07, 0x0E, 0xFC, 0xF8, 0x00, 0x00, 0x3F, 0x7F,
0xE0, 0xC0, 0x80, 0x80, 0xC0, 0xE0, 0x7F, 0x3F, 0xFF, 0xFF,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0x00,
0x00, 0xFF, 0xFF, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0x3E, 0x77,
0xE3, 0xC1, 0x00, 0x00, 0x7F, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0,
0xC0, 0xE0, 0x70, 0x3F, 0x1F, 0x00, 0x00, 0x1F, 0x3F, 0x70,
0xE0, 0xC0, 0xC0, 0xC0, 0xE0, 0x70, 0x3F, 0x1F, 0x00, 0x00,
0x7F, 0xFF, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xE3, 0x77, 0x3E,
0x1C, 0x00, 0x00, 0x1F, 0x3F, 0x70, 0xE0, 0xC0, 0xC0, 0xC0,
0xE0, 0x70, 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00
};
#endif
|
ccc9dee273b29502ee66d57654c14f21c731fe35
|
a990004e8263ed825eb4ee21c7eb842dd886cde2
|
/src/lib/crypto/test/iso8859.c
|
bed724491092ca4f2aae0a77314378aac318f6ca
|
[
"BSD-2-Clause"
] |
permissive
|
opendnssec/SoftHSMv2
|
8233f100f47c62f3b091c00706d9d13bfd1486bc
|
f4661af6680e187f220921c0a91d17d71a680345
|
refs/heads/develop
| 2023-08-04T23:48:24.514490
| 2023-08-02T20:51:58
| 2023-08-02T20:51:58
| 10,314,787
| 643
| 327
|
NOASSERTION
| 2023-09-01T07:23:24
| 2013-05-27T12:54:47
|
C++
|
UTF-8
|
C
| false
| false
| 878
|
c
|
iso8859.c
|
/* This code was taken from http://www.fourmilab.ch/random/ where it states that:
This software is in the public domain. Permission to use, copy, modify, and distribute
this software and its documentation for any purpose and without fee is hereby granted,
without any conditions or restrictions. This software is provided “as is” without
express or implied warranty. */
/* ISO 8859/1 Latin-1 alphabetic and upper and lower case bit vector tables. */
/* LINTLIBRARY */
unsigned char isoalpha[32] = {
0,0,0,0,0,0,0,0,127,255,255,224,127,255,255,224,0,0,0,0,0,0,0,0,255,255,
254,255,255,255,254,255
};
unsigned char isoupper[32] = {
0,0,0,0,0,0,0,0,127,255,255,224,0,0,0,0,0,0,0,0,0,0,0,0,255,255,254,254,
0,0,0,0
};
unsigned char isolower[32] = {
0,0,0,0,0,0,0,0,0,0,0,0,127,255,255,224,0,0,0,0,0,0,0,0,0,0,0,1,255,255,
254,255
};
|
57154331f66ef1921c4dfe17370ee4978bb97a09
|
a91796ab826878e54d91c32249f45bb919e0c149
|
/3rdparty/libtiff/tif_fax3sm.c
|
ba2fc532e8014ba7842da95821e6ad95ead1f87d
|
[
"libtiff",
"IJG",
"Zlib",
"BSD-3-Clause",
"Libpng",
"LicenseRef-scancode-unknown-license-reference",
"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
| 104,760
|
c
|
tif_fax3sm.c
|
/* WARNING, this file was automatically generated by the
mkg3states program */
#include <stdint.h>
#include "tiff.h"
#include "tif_fax3.h"
const TIFFFaxTabEnt TIFFFaxMainTable[128] = {
{12,7,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},
{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{5,6,2},{3,1,0},{5,3,1},{3,1,0},
{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},
{4,3,1},{3,1,0},{5,7,3},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},
{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{4,6,2},{3,1,0},
{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},
{2,3,0},{3,1,0},{4,3,1},{3,1,0},{6,7,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},
{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},
{5,6,2},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},
{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},{4,7,3},{3,1,0},{5,3,1},{3,1,0},
{2,3,0},{3,1,0},{4,3,1},{3,1,0},{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},
{4,3,1},{3,1,0},{4,6,2},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0},
{1,4,0},{3,1,0},{5,3,1},{3,1,0},{2,3,0},{3,1,0},{4,3,1},{3,1,0}
};
const TIFFFaxTabEnt TIFFFaxWhiteTable[4096] = {
{12,11,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},
{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},
{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},
{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1792},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},
{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},
{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},
{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},
{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},
{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},
{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},
{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},
{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},
{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},
{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},
{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1856},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},
{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},
{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},
{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},
{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},
{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},
{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},
{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},
{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},
{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{11,12,2112},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},
{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},
{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},
{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},
{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},
{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},
{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},
{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2368},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},
{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},
{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},
{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},
{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},
{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},
{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},
{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},
{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},
{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},
{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},
{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},
{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{11,12,1984},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},
{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},
{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},
{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},
{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},
{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},
{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},
{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1920},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},
{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},
{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},
{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},
{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},
{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},
{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},
{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},
{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},
{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},
{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},
{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2240},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},
{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},
{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},
{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},
{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},
{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},
{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},
{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},
{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},
{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{11,12,2496},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},
{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},
{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},
{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{12,11,0},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},
{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},
{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},
{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},
{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1792},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},
{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},
{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},
{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},
{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},
{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},
{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},
{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},
{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},
{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},
{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},
{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},
{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{11,11,1856},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},
{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},
{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},
{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},
{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},
{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},
{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},{7,8,31},{7,5,8},
{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2176},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},
{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},
{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1600},{7,4,5},
{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},
{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},
{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},
{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},
{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},{7,8,43},{7,6,17},
{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},
{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},
{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,768},{7,4,6},
{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2432},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},{7,7,19},{7,5,8},
{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},
{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},{9,9,1408},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},
{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},
{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},
{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},
{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},
{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,960},{7,4,6},
{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},
{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{11,12,2048},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},
{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},
{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},{7,8,32},{7,5,8},
{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},
{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},
{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1536},{7,4,5},
{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},
{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,11,1920},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},
{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,896},{7,4,6},
{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},
{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},
{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},{7,8,44},{7,6,17},
{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},
{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},
{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},
{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},
{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},
{7,8,55},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},
{7,8,53},{7,5,9},{9,8,448},{7,4,6},{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1472},{7,4,5},{7,8,43},{7,6,17},{9,9,1216},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},
{7,8,61},{7,4,4},{7,4,2},{7,4,7},{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},
{9,9,960},{7,4,6},{7,8,31},{7,5,8},{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,9,704},{7,4,6},{7,8,37},{9,5,128},
{7,7,25},{7,6,15},{9,8,320},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},
{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{11,12,2304},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,7,20},{9,5,128},{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},
{7,7,27},{7,4,5},{7,8,40},{7,6,16},{9,9,832},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},
{9,8,512},{7,4,6},{7,8,36},{9,5,128},{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{9,9,1600},{7,4,5},{7,8,44},{7,6,17},{9,9,1344},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},
{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},
{7,4,2},{7,4,7},{7,8,48},{7,4,3},{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1088},{7,4,6},
{7,8,32},{7,5,8},{7,8,58},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},
{7,5,11},{7,4,5},{7,7,26},{7,5,9},{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},
{9,8,384},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},
{9,7,256},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{0,0,0},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},
{7,7,24},{7,6,14},{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},
{7,8,39},{7,6,16},{9,8,576},{7,4,6},{7,7,19},{7,5,8},{7,8,55},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,45},{7,4,3},{7,5,11},{7,4,5},{7,8,53},{7,5,9},{9,8,448},{7,4,6},
{7,8,35},{9,5,128},{7,8,51},{7,6,15},{7,8,63},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},
{9,9,1536},{7,4,5},{7,8,43},{7,6,17},{9,9,1280},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,8,29},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},
{9,6,1664},{7,4,6},{7,8,33},{9,5,128},{7,8,49},{7,6,14},{7,8,61},{7,4,4},{7,4,2},{7,4,7},
{7,8,47},{7,4,3},{7,8,59},{7,4,5},{7,8,41},{7,6,16},{9,9,1024},{7,4,6},{7,8,31},{7,5,8},
{7,8,57},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},
{7,7,26},{7,5,9},{9,9,768},{7,4,6},{7,8,37},{9,5,128},{7,7,25},{7,6,15},{9,8,320},{7,4,4},
{7,4,2},{7,4,7},{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},
{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},{11,12,2560},{7,4,3},
{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},{7,7,20},{9,5,128},{7,7,24},{7,6,14},
{7,7,28},{7,4,4},{7,4,2},{7,4,7},{7,7,23},{7,4,3},{7,7,27},{7,4,5},{7,8,40},{7,6,16},
{9,9,896},{7,4,6},{7,7,19},{7,5,8},{7,8,56},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7},
{7,8,46},{7,4,3},{7,5,11},{7,4,5},{7,8,54},{7,5,9},{9,8,512},{7,4,6},{7,8,36},{9,5,128},
{7,8,52},{7,6,15},{7,8,0},{7,4,4},{7,4,2},{7,4,7},{7,6,13},{7,4,3},{9,9,1728},{7,4,5},
{7,8,44},{7,6,17},{9,9,1408},{7,4,6},{7,6,1},{7,5,8},{9,6,192},{9,5,64},{7,5,10},{7,4,4},
{7,4,2},{7,4,7},{7,8,30},{7,4,3},{7,5,11},{7,4,5},{7,6,12},{7,5,9},{9,6,1664},{7,4,6},
{7,8,34},{9,5,128},{7,8,50},{7,6,14},{7,8,62},{7,4,4},{7,4,2},{7,4,7},{7,8,48},{7,4,3},
{7,8,60},{7,4,5},{7,8,42},{7,6,16},{9,9,1152},{7,4,6},{7,8,32},{7,5,8},{7,8,58},{9,5,64},
{7,5,10},{7,4,4},{7,4,2},{7,4,7},{7,7,22},{7,4,3},{7,5,11},{7,4,5},{7,7,26},{7,5,9},
{9,8,640},{7,4,6},{7,8,38},{9,5,128},{7,7,25},{7,6,15},{9,8,384},{7,4,4},{7,4,2},{7,4,7},
{7,6,13},{7,4,3},{7,7,18},{7,4,5},{7,7,21},{7,6,17},{9,7,256},{7,4,6},{7,6,1},{7,5,8},
{9,6,192},{9,5,64},{7,5,10},{7,4,4},{7,4,2},{7,4,7}
};
const TIFFFaxTabEnt TIFFFaxBlackTable[8192] = {
{12,11,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,11,23},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,11,25},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,128},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,56},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,30},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,57},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,11,21},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,54},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,52},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,48},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{11,12,2112},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,44},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,36},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,384},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,28},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,60},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,40},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2368},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{11,12,1984},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,50},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,34},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1664},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,26},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1408},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,32},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,61},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,42},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{10,13,1024},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,13,768},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,62},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2240},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,46},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,38},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,512},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,11,19},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{11,12,2496},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,11,25},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{10,12,192},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1280},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,31},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,58},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,11,21},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,896},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,640},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,49},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2176},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,45},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,37},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{10,12,448},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,29},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,13,1536},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,41},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2432},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{11,12,2048},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,51},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,35},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,320},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,27},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,59},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,33},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,256},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,43},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,13,1152},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,55},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,63},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{11,12,2304},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,47},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,39},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,53},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2560},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,25},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,12,128},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,56},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,30},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{11,11,1856},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,57},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,21},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,54},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,52},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,48},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2112},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,44},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,36},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,12,384},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,28},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,60},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,40},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{11,12,2368},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,1984},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,50},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,34},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{10,13,1728},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,26},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,13,1472},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,32},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,61},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,42},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1088},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,832},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,62},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{11,12,2240},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,46},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,38},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,576},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2496},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{12,11,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,18},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{11,11,1792},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,23},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,11,20},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,25},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,192},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1344},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,31},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,11,1856},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,58},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,21},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{10,13,960},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,13,704},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,49},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2176},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,45},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,37},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,448},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,29},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1600},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,41},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{11,12,2432},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,0},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,10,18},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,17},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2048},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,51},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,35},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{10,12,320},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,27},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,59},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,33},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{11,11,1920},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,12,256},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,43},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,13,1216},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{0,0,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,8,13},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,9,15},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,55},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,63},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2304},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,12,47},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,12,39},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,12,53},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,12},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{0,0,0},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,8,13},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,11,19},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,11,24},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,11,22},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{11,12,2560},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,7,10},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,10,16},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2},{8,10,0},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},
{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{10,10,64},{8,2,3},
{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,9},{8,2,3},{8,3,1},{8,2,2},
{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,11},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},
{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},
{8,8,14},{8,2,3},{8,3,1},{8,2,2},{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,6,8},{8,2,3},
{8,3,1},{8,2,2},{8,4,5},{8,2,3},{8,3,4},{8,2,2},{8,7,12},{8,2,3},{8,3,1},{8,2,2},
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2}
};
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
|
9fe7329fd84e5891b385b924f799e98a9210145c
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/arch/um/drivers/cow.h
|
6673508f342603554c4fbe874511ab6df14af45f
|
[
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 1,037
|
h
|
cow.h
|
#ifndef __COW_H__
#define __COW_H__
#include <asm/types.h>
extern int init_cow_file(int fd, char *cow_file, char *backing_file,
int sectorsize, int alignment, int *bitmap_offset_out,
unsigned long *bitmap_len_out, int *data_offset_out);
extern int file_reader(__u64 offset, char *buf, int len, void *arg);
extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
void *arg, __u32 *version_out,
char **backing_file_out, time_t *mtime_out,
unsigned long long *size_out, int *sectorsize_out,
__u32 *align_out, int *bitmap_offset_out);
extern int write_cow_header(char *cow_file, int fd, char *backing_file,
int sectorsize, int alignment,
unsigned long long *size);
extern void cow_sizes(int version, __u64 size, int sectorsize, int align,
int bitmap_offset, unsigned long *bitmap_len_out,
int *data_offset_out);
#endif
/*
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
|
384206b9cc8189c5c107e8e90786a8724005d1bb
|
ff443629c167f318d071f62886581167c51690c4
|
/src/secp256k1/src/secp256k1.c
|
4c11e7f0b8b582e213020ebf9e837bb6d6d40ad2
|
[
"MIT"
] |
permissive
|
bitcoin/bitcoin
|
a618b2555d9fe5a2b613e5fec0f4b1eca3b4d86f
|
6f03c45f6bb5a6edaa3051968b6a1ca4f84d2ccb
|
refs/heads/master
| 2023-09-05T00:16:48.295861
| 2023-09-02T17:43:00
| 2023-09-02T17:46:33
| 1,181,927
| 77,104
| 33,708
|
MIT
| 2023-09-14T20:47:31
| 2010-12-19T15:16:43
|
C++
|
UTF-8
|
C
| false
| false
| 29,174
|
c
|
secp256k1.c
|
/***********************************************************************
* Copyright (c) 2013-2015 Pieter Wuille *
* Distributed under the MIT software license, see the accompanying *
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
***********************************************************************/
/* This is a C project. It should not be compiled with a C++ compiler,
* and we error out if we detect one.
*
* We still want to be able to test the project with a C++ compiler
* because it is still good to know if this will lead to real trouble, so
* there is a possibility to override the check. But be warned that
* compiling with a C++ compiler is not supported. */
#if defined(__cplusplus) && !defined(SECP256K1_CPLUSPLUS_TEST_OVERRIDE)
#error Trying to compile a C project with a C++ compiler.
#endif
#define SECP256K1_BUILD
#include "../include/secp256k1.h"
#include "../include/secp256k1_preallocated.h"
#include "assumptions.h"
#include "checkmem.h"
#include "util.h"
#include "field_impl.h"
#include "scalar_impl.h"
#include "group_impl.h"
#include "ecmult_impl.h"
#include "ecmult_const_impl.h"
#include "ecmult_gen_impl.h"
#include "ecdsa_impl.h"
#include "eckey_impl.h"
#include "hash_impl.h"
#include "int128_impl.h"
#include "scratch_impl.h"
#include "selftest.h"
#ifdef SECP256K1_NO_BUILD
# error "secp256k1.h processed without SECP256K1_BUILD defined while building secp256k1.c"
#endif
#define ARG_CHECK(cond) do { \
if (EXPECT(!(cond), 0)) { \
secp256k1_callback_call(&ctx->illegal_callback, #cond); \
return 0; \
} \
} while(0)
#define ARG_CHECK_VOID(cond) do { \
if (EXPECT(!(cond), 0)) { \
secp256k1_callback_call(&ctx->illegal_callback, #cond); \
return; \
} \
} while(0)
/* Note that whenever you change the context struct, you must also change the
* context_eq function. */
struct secp256k1_context_struct {
secp256k1_ecmult_gen_context ecmult_gen_ctx;
secp256k1_callback illegal_callback;
secp256k1_callback error_callback;
int declassify;
};
static const secp256k1_context secp256k1_context_static_ = {
{ 0 },
{ secp256k1_default_illegal_callback_fn, 0 },
{ secp256k1_default_error_callback_fn, 0 },
0
};
const secp256k1_context *secp256k1_context_static = &secp256k1_context_static_;
const secp256k1_context *secp256k1_context_no_precomp = &secp256k1_context_static_;
/* Helper function that determines if a context is proper, i.e., is not the static context or a copy thereof.
*
* This is intended for "context" functions such as secp256k1_context_clone. Function which need specific
* features of a context should still check for these features directly. For example, a function that needs
* ecmult_gen should directly check for the existence of the ecmult_gen context. */
static int secp256k1_context_is_proper(const secp256k1_context* ctx) {
return secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx);
}
void secp256k1_selftest(void) {
if (!secp256k1_selftest_passes()) {
secp256k1_callback_call(&default_error_callback, "self test failed");
}
}
size_t secp256k1_context_preallocated_size(unsigned int flags) {
size_t ret = sizeof(secp256k1_context);
/* A return value of 0 is reserved as an indicator for errors when we call this function internally. */
VERIFY_CHECK(ret != 0);
if (EXPECT((flags & SECP256K1_FLAGS_TYPE_MASK) != SECP256K1_FLAGS_TYPE_CONTEXT, 0)) {
secp256k1_callback_call(&default_illegal_callback,
"Invalid flags");
return 0;
}
if (EXPECT(!SECP256K1_CHECKMEM_RUNNING() && (flags & SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY), 0)) {
secp256k1_callback_call(&default_illegal_callback,
"Declassify flag requires running with memory checking");
return 0;
}
return ret;
}
size_t secp256k1_context_preallocated_clone_size(const secp256k1_context* ctx) {
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(secp256k1_context_is_proper(ctx));
return sizeof(secp256k1_context);
}
secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigned int flags) {
size_t prealloc_size;
secp256k1_context* ret;
secp256k1_selftest();
prealloc_size = secp256k1_context_preallocated_size(flags);
if (prealloc_size == 0) {
return NULL;
}
VERIFY_CHECK(prealloc != NULL);
ret = (secp256k1_context*)prealloc;
ret->illegal_callback = default_illegal_callback;
ret->error_callback = default_error_callback;
/* Flags have been checked by secp256k1_context_preallocated_size. */
VERIFY_CHECK((flags & SECP256K1_FLAGS_TYPE_MASK) == SECP256K1_FLAGS_TYPE_CONTEXT);
secp256k1_ecmult_gen_context_build(&ret->ecmult_gen_ctx);
ret->declassify = !!(flags & SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY);
return ret;
}
secp256k1_context* secp256k1_context_create(unsigned int flags) {
size_t const prealloc_size = secp256k1_context_preallocated_size(flags);
secp256k1_context* ctx = (secp256k1_context*)checked_malloc(&default_error_callback, prealloc_size);
if (EXPECT(secp256k1_context_preallocated_create(ctx, flags) == NULL, 0)) {
free(ctx);
return NULL;
}
return ctx;
}
secp256k1_context* secp256k1_context_preallocated_clone(const secp256k1_context* ctx, void* prealloc) {
secp256k1_context* ret;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(prealloc != NULL);
ARG_CHECK(secp256k1_context_is_proper(ctx));
ret = (secp256k1_context*)prealloc;
*ret = *ctx;
return ret;
}
secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
secp256k1_context* ret;
size_t prealloc_size;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(secp256k1_context_is_proper(ctx));
prealloc_size = secp256k1_context_preallocated_clone_size(ctx);
ret = (secp256k1_context*)checked_malloc(&ctx->error_callback, prealloc_size);
ret = secp256k1_context_preallocated_clone(ctx, ret);
return ret;
}
void secp256k1_context_preallocated_destroy(secp256k1_context* ctx) {
ARG_CHECK_VOID(ctx == NULL || secp256k1_context_is_proper(ctx));
/* Defined as noop */
if (ctx == NULL) {
return;
}
secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);
}
void secp256k1_context_destroy(secp256k1_context* ctx) {
ARG_CHECK_VOID(ctx == NULL || secp256k1_context_is_proper(ctx));
/* Defined as noop */
if (ctx == NULL) {
return;
}
secp256k1_context_preallocated_destroy(ctx);
free(ctx);
}
void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
/* We compare pointers instead of checking secp256k1_context_is_proper() here
because setting callbacks is allowed on *copies* of the static context:
it's harmless and makes testing easier. */
ARG_CHECK_VOID(ctx != secp256k1_context_static);
if (fun == NULL) {
fun = secp256k1_default_illegal_callback_fn;
}
ctx->illegal_callback.fn = fun;
ctx->illegal_callback.data = data;
}
void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
/* We compare pointers instead of checking secp256k1_context_is_proper() here
because setting callbacks is allowed on *copies* of the static context:
it's harmless and makes testing easier. */
ARG_CHECK_VOID(ctx != secp256k1_context_static);
if (fun == NULL) {
fun = secp256k1_default_error_callback_fn;
}
ctx->error_callback.fn = fun;
ctx->error_callback.data = data;
}
secp256k1_scratch_space* secp256k1_scratch_space_create(const secp256k1_context* ctx, size_t max_size) {
VERIFY_CHECK(ctx != NULL);
return secp256k1_scratch_create(&ctx->error_callback, max_size);
}
void secp256k1_scratch_space_destroy(const secp256k1_context *ctx, secp256k1_scratch_space* scratch) {
VERIFY_CHECK(ctx != NULL);
secp256k1_scratch_destroy(&ctx->error_callback, scratch);
}
/* Mark memory as no-longer-secret for the purpose of analysing constant-time behaviour
* of the software.
*/
static SECP256K1_INLINE void secp256k1_declassify(const secp256k1_context* ctx, const void *p, size_t len) {
if (EXPECT(ctx->declassify, 0)) SECP256K1_CHECKMEM_DEFINE(p, len);
}
static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) {
if (sizeof(secp256k1_ge_storage) == 64) {
/* When the secp256k1_ge_storage type is exactly 64 byte, use its
* representation inside secp256k1_pubkey, as conversion is very fast.
* Note that secp256k1_pubkey_save must use the same representation. */
secp256k1_ge_storage s;
memcpy(&s, &pubkey->data[0], sizeof(s));
secp256k1_ge_from_storage(ge, &s);
} else {
/* Otherwise, fall back to 32-byte big endian for X and Y. */
secp256k1_fe x, y;
ARG_CHECK(secp256k1_fe_set_b32_limit(&x, pubkey->data));
ARG_CHECK(secp256k1_fe_set_b32_limit(&y, pubkey->data + 32));
secp256k1_ge_set_xy(ge, &x, &y);
}
ARG_CHECK(!secp256k1_fe_is_zero(&ge->x));
return 1;
}
static void secp256k1_pubkey_save(secp256k1_pubkey* pubkey, secp256k1_ge* ge) {
if (sizeof(secp256k1_ge_storage) == 64) {
secp256k1_ge_storage s;
secp256k1_ge_to_storage(&s, ge);
memcpy(&pubkey->data[0], &s, sizeof(s));
} else {
VERIFY_CHECK(!secp256k1_ge_is_infinity(ge));
secp256k1_fe_normalize_var(&ge->x);
secp256k1_fe_normalize_var(&ge->y);
secp256k1_fe_get_b32(pubkey->data, &ge->x);
secp256k1_fe_get_b32(pubkey->data + 32, &ge->y);
}
}
int secp256k1_ec_pubkey_parse(const secp256k1_context* ctx, secp256k1_pubkey* pubkey, const unsigned char *input, size_t inputlen) {
secp256k1_ge Q;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(pubkey != NULL);
memset(pubkey, 0, sizeof(*pubkey));
ARG_CHECK(input != NULL);
if (!secp256k1_eckey_pubkey_parse(&Q, input, inputlen)) {
return 0;
}
if (!secp256k1_ge_is_in_correct_subgroup(&Q)) {
return 0;
}
secp256k1_pubkey_save(pubkey, &Q);
secp256k1_ge_clear(&Q);
return 1;
}
int secp256k1_ec_pubkey_serialize(const secp256k1_context* ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey* pubkey, unsigned int flags) {
secp256k1_ge Q;
size_t len;
int ret = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(outputlen != NULL);
ARG_CHECK(*outputlen >= ((flags & SECP256K1_FLAGS_BIT_COMPRESSION) ? 33u : 65u));
len = *outputlen;
*outputlen = 0;
ARG_CHECK(output != NULL);
memset(output, 0, len);
ARG_CHECK(pubkey != NULL);
ARG_CHECK((flags & SECP256K1_FLAGS_TYPE_MASK) == SECP256K1_FLAGS_TYPE_COMPRESSION);
if (secp256k1_pubkey_load(ctx, &Q, pubkey)) {
ret = secp256k1_eckey_pubkey_serialize(&Q, output, &len, flags & SECP256K1_FLAGS_BIT_COMPRESSION);
if (ret) {
*outputlen = len;
}
}
return ret;
}
int secp256k1_ec_pubkey_cmp(const secp256k1_context* ctx, const secp256k1_pubkey* pubkey0, const secp256k1_pubkey* pubkey1) {
unsigned char out[2][33];
const secp256k1_pubkey* pk[2];
int i;
VERIFY_CHECK(ctx != NULL);
pk[0] = pubkey0; pk[1] = pubkey1;
for (i = 0; i < 2; i++) {
size_t out_size = sizeof(out[i]);
/* If the public key is NULL or invalid, ec_pubkey_serialize will call
* the illegal_callback and return 0. In that case we will serialize the
* key as all zeros which is less than any valid public key. This
* results in consistent comparisons even if NULL or invalid pubkeys are
* involved and prevents edge cases such as sorting algorithms that use
* this function and do not terminate as a result. */
if (!secp256k1_ec_pubkey_serialize(ctx, out[i], &out_size, pk[i], SECP256K1_EC_COMPRESSED)) {
/* Note that ec_pubkey_serialize should already set the output to
* zero in that case, but it's not guaranteed by the API, we can't
* test it and writing a VERIFY_CHECK is more complex than
* explicitly memsetting (again). */
memset(out[i], 0, sizeof(out[i]));
}
}
return secp256k1_memcmp_var(out[0], out[1], sizeof(out[0]));
}
static void secp256k1_ecdsa_signature_load(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, const secp256k1_ecdsa_signature* sig) {
(void)ctx;
if (sizeof(secp256k1_scalar) == 32) {
/* When the secp256k1_scalar type is exactly 32 byte, use its
* representation inside secp256k1_ecdsa_signature, as conversion is very fast.
* Note that secp256k1_ecdsa_signature_save must use the same representation. */
memcpy(r, &sig->data[0], 32);
memcpy(s, &sig->data[32], 32);
} else {
secp256k1_scalar_set_b32(r, &sig->data[0], NULL);
secp256k1_scalar_set_b32(s, &sig->data[32], NULL);
}
}
static void secp256k1_ecdsa_signature_save(secp256k1_ecdsa_signature* sig, const secp256k1_scalar* r, const secp256k1_scalar* s) {
if (sizeof(secp256k1_scalar) == 32) {
memcpy(&sig->data[0], r, 32);
memcpy(&sig->data[32], s, 32);
} else {
secp256k1_scalar_get_b32(&sig->data[0], r);
secp256k1_scalar_get_b32(&sig->data[32], s);
}
}
int secp256k1_ecdsa_signature_parse_der(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input, size_t inputlen) {
secp256k1_scalar r, s;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(sig != NULL);
ARG_CHECK(input != NULL);
if (secp256k1_ecdsa_sig_parse(&r, &s, input, inputlen)) {
secp256k1_ecdsa_signature_save(sig, &r, &s);
return 1;
} else {
memset(sig, 0, sizeof(*sig));
return 0;
}
}
int secp256k1_ecdsa_signature_parse_compact(const secp256k1_context* ctx, secp256k1_ecdsa_signature* sig, const unsigned char *input64) {
secp256k1_scalar r, s;
int ret = 1;
int overflow = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(sig != NULL);
ARG_CHECK(input64 != NULL);
secp256k1_scalar_set_b32(&r, &input64[0], &overflow);
ret &= !overflow;
secp256k1_scalar_set_b32(&s, &input64[32], &overflow);
ret &= !overflow;
if (ret) {
secp256k1_ecdsa_signature_save(sig, &r, &s);
} else {
memset(sig, 0, sizeof(*sig));
}
return ret;
}
int secp256k1_ecdsa_signature_serialize_der(const secp256k1_context* ctx, unsigned char *output, size_t *outputlen, const secp256k1_ecdsa_signature* sig) {
secp256k1_scalar r, s;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(output != NULL);
ARG_CHECK(outputlen != NULL);
ARG_CHECK(sig != NULL);
secp256k1_ecdsa_signature_load(ctx, &r, &s, sig);
return secp256k1_ecdsa_sig_serialize(output, outputlen, &r, &s);
}
int secp256k1_ecdsa_signature_serialize_compact(const secp256k1_context* ctx, unsigned char *output64, const secp256k1_ecdsa_signature* sig) {
secp256k1_scalar r, s;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(output64 != NULL);
ARG_CHECK(sig != NULL);
secp256k1_ecdsa_signature_load(ctx, &r, &s, sig);
secp256k1_scalar_get_b32(&output64[0], &r);
secp256k1_scalar_get_b32(&output64[32], &s);
return 1;
}
int secp256k1_ecdsa_signature_normalize(const secp256k1_context* ctx, secp256k1_ecdsa_signature *sigout, const secp256k1_ecdsa_signature *sigin) {
secp256k1_scalar r, s;
int ret = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(sigin != NULL);
secp256k1_ecdsa_signature_load(ctx, &r, &s, sigin);
ret = secp256k1_scalar_is_high(&s);
if (sigout != NULL) {
if (ret) {
secp256k1_scalar_negate(&s, &s);
}
secp256k1_ecdsa_signature_save(sigout, &r, &s);
}
return ret;
}
int secp256k1_ecdsa_verify(const secp256k1_context* ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msghash32, const secp256k1_pubkey *pubkey) {
secp256k1_ge q;
secp256k1_scalar r, s;
secp256k1_scalar m;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(msghash32 != NULL);
ARG_CHECK(sig != NULL);
ARG_CHECK(pubkey != NULL);
secp256k1_scalar_set_b32(&m, msghash32, NULL);
secp256k1_ecdsa_signature_load(ctx, &r, &s, sig);
return (!secp256k1_scalar_is_high(&s) &&
secp256k1_pubkey_load(ctx, &q, pubkey) &&
secp256k1_ecdsa_sig_verify(&r, &s, &q, &m));
}
static SECP256K1_INLINE void buffer_append(unsigned char *buf, unsigned int *offset, const void *data, unsigned int len) {
memcpy(buf + *offset, data, len);
*offset += len;
}
static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) {
unsigned char keydata[112];
unsigned int offset = 0;
secp256k1_rfc6979_hmac_sha256 rng;
unsigned int i;
secp256k1_scalar msg;
unsigned char msgmod32[32];
secp256k1_scalar_set_b32(&msg, msg32, NULL);
secp256k1_scalar_get_b32(msgmod32, &msg);
/* We feed a byte array to the PRNG as input, consisting of:
* - the private key (32 bytes) and reduced message (32 bytes), see RFC 6979 3.2d.
* - optionally 32 extra bytes of data, see RFC 6979 3.6 Additional Data.
* - optionally 16 extra bytes with the algorithm name.
* Because the arguments have distinct fixed lengths it is not possible for
* different argument mixtures to emulate each other and result in the same
* nonces.
*/
buffer_append(keydata, &offset, key32, 32);
buffer_append(keydata, &offset, msgmod32, 32);
if (data != NULL) {
buffer_append(keydata, &offset, data, 32);
}
if (algo16 != NULL) {
buffer_append(keydata, &offset, algo16, 16);
}
secp256k1_rfc6979_hmac_sha256_initialize(&rng, keydata, offset);
memset(keydata, 0, sizeof(keydata));
for (i = 0; i <= counter; i++) {
secp256k1_rfc6979_hmac_sha256_generate(&rng, nonce32, 32);
}
secp256k1_rfc6979_hmac_sha256_finalize(&rng);
return 1;
}
const secp256k1_nonce_function secp256k1_nonce_function_rfc6979 = nonce_function_rfc6979;
const secp256k1_nonce_function secp256k1_nonce_function_default = nonce_function_rfc6979;
static int secp256k1_ecdsa_sign_inner(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, int* recid, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) {
secp256k1_scalar sec, non, msg;
int ret = 0;
int is_sec_valid;
unsigned char nonce32[32];
unsigned int count = 0;
/* Default initialization here is important so we won't pass uninit values to the cmov in the end */
*r = secp256k1_scalar_zero;
*s = secp256k1_scalar_zero;
if (recid) {
*recid = 0;
}
if (noncefp == NULL) {
noncefp = secp256k1_nonce_function_default;
}
/* Fail if the secret key is invalid. */
is_sec_valid = secp256k1_scalar_set_b32_seckey(&sec, seckey);
secp256k1_scalar_cmov(&sec, &secp256k1_scalar_one, !is_sec_valid);
secp256k1_scalar_set_b32(&msg, msg32, NULL);
while (1) {
int is_nonce_valid;
ret = !!noncefp(nonce32, msg32, seckey, NULL, (void*)noncedata, count);
if (!ret) {
break;
}
is_nonce_valid = secp256k1_scalar_set_b32_seckey(&non, nonce32);
/* The nonce is still secret here, but it being invalid is is less likely than 1:2^255. */
secp256k1_declassify(ctx, &is_nonce_valid, sizeof(is_nonce_valid));
if (is_nonce_valid) {
ret = secp256k1_ecdsa_sig_sign(&ctx->ecmult_gen_ctx, r, s, &sec, &msg, &non, recid);
/* The final signature is no longer a secret, nor is the fact that we were successful or not. */
secp256k1_declassify(ctx, &ret, sizeof(ret));
if (ret) {
break;
}
}
count++;
}
/* We don't want to declassify is_sec_valid and therefore the range of
* seckey. As a result is_sec_valid is included in ret only after ret was
* used as a branching variable. */
ret &= is_sec_valid;
memset(nonce32, 0, 32);
secp256k1_scalar_clear(&msg);
secp256k1_scalar_clear(&non);
secp256k1_scalar_clear(&sec);
secp256k1_scalar_cmov(r, &secp256k1_scalar_zero, !ret);
secp256k1_scalar_cmov(s, &secp256k1_scalar_zero, !ret);
if (recid) {
const int zero = 0;
secp256k1_int_cmov(recid, &zero, !ret);
}
return ret;
}
int secp256k1_ecdsa_sign(const secp256k1_context* ctx, secp256k1_ecdsa_signature *signature, const unsigned char *msghash32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) {
secp256k1_scalar r, s;
int ret;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx));
ARG_CHECK(msghash32 != NULL);
ARG_CHECK(signature != NULL);
ARG_CHECK(seckey != NULL);
ret = secp256k1_ecdsa_sign_inner(ctx, &r, &s, NULL, msghash32, seckey, noncefp, noncedata);
secp256k1_ecdsa_signature_save(signature, &r, &s);
return ret;
}
int secp256k1_ec_seckey_verify(const secp256k1_context* ctx, const unsigned char *seckey) {
secp256k1_scalar sec;
int ret;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(seckey != NULL);
ret = secp256k1_scalar_set_b32_seckey(&sec, seckey);
secp256k1_scalar_clear(&sec);
return ret;
}
static int secp256k1_ec_pubkey_create_helper(const secp256k1_ecmult_gen_context *ecmult_gen_ctx, secp256k1_scalar *seckey_scalar, secp256k1_ge *p, const unsigned char *seckey) {
secp256k1_gej pj;
int ret;
ret = secp256k1_scalar_set_b32_seckey(seckey_scalar, seckey);
secp256k1_scalar_cmov(seckey_scalar, &secp256k1_scalar_one, !ret);
secp256k1_ecmult_gen(ecmult_gen_ctx, &pj, seckey_scalar);
secp256k1_ge_set_gej(p, &pj);
return ret;
}
int secp256k1_ec_pubkey_create(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *seckey) {
secp256k1_ge p;
secp256k1_scalar seckey_scalar;
int ret = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(pubkey != NULL);
memset(pubkey, 0, sizeof(*pubkey));
ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx));
ARG_CHECK(seckey != NULL);
ret = secp256k1_ec_pubkey_create_helper(&ctx->ecmult_gen_ctx, &seckey_scalar, &p, seckey);
secp256k1_pubkey_save(pubkey, &p);
secp256k1_memczero(pubkey, sizeof(*pubkey), !ret);
secp256k1_scalar_clear(&seckey_scalar);
return ret;
}
int secp256k1_ec_seckey_negate(const secp256k1_context* ctx, unsigned char *seckey) {
secp256k1_scalar sec;
int ret = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(seckey != NULL);
ret = secp256k1_scalar_set_b32_seckey(&sec, seckey);
secp256k1_scalar_cmov(&sec, &secp256k1_scalar_zero, !ret);
secp256k1_scalar_negate(&sec, &sec);
secp256k1_scalar_get_b32(seckey, &sec);
secp256k1_scalar_clear(&sec);
return ret;
}
int secp256k1_ec_privkey_negate(const secp256k1_context* ctx, unsigned char *seckey) {
return secp256k1_ec_seckey_negate(ctx, seckey);
}
int secp256k1_ec_pubkey_negate(const secp256k1_context* ctx, secp256k1_pubkey *pubkey) {
int ret = 0;
secp256k1_ge p;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(pubkey != NULL);
ret = secp256k1_pubkey_load(ctx, &p, pubkey);
memset(pubkey, 0, sizeof(*pubkey));
if (ret) {
secp256k1_ge_neg(&p, &p);
secp256k1_pubkey_save(pubkey, &p);
}
return ret;
}
static int secp256k1_ec_seckey_tweak_add_helper(secp256k1_scalar *sec, const unsigned char *tweak32) {
secp256k1_scalar term;
int overflow = 0;
int ret = 0;
secp256k1_scalar_set_b32(&term, tweak32, &overflow);
ret = (!overflow) & secp256k1_eckey_privkey_tweak_add(sec, &term);
secp256k1_scalar_clear(&term);
return ret;
}
int secp256k1_ec_seckey_tweak_add(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak32) {
secp256k1_scalar sec;
int ret = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(seckey != NULL);
ARG_CHECK(tweak32 != NULL);
ret = secp256k1_scalar_set_b32_seckey(&sec, seckey);
ret &= secp256k1_ec_seckey_tweak_add_helper(&sec, tweak32);
secp256k1_scalar_cmov(&sec, &secp256k1_scalar_zero, !ret);
secp256k1_scalar_get_b32(seckey, &sec);
secp256k1_scalar_clear(&sec);
return ret;
}
int secp256k1_ec_privkey_tweak_add(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak32) {
return secp256k1_ec_seckey_tweak_add(ctx, seckey, tweak32);
}
static int secp256k1_ec_pubkey_tweak_add_helper(secp256k1_ge *p, const unsigned char *tweak32) {
secp256k1_scalar term;
int overflow = 0;
secp256k1_scalar_set_b32(&term, tweak32, &overflow);
return !overflow && secp256k1_eckey_pubkey_tweak_add(p, &term);
}
int secp256k1_ec_pubkey_tweak_add(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak32) {
secp256k1_ge p;
int ret = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(pubkey != NULL);
ARG_CHECK(tweak32 != NULL);
ret = secp256k1_pubkey_load(ctx, &p, pubkey);
memset(pubkey, 0, sizeof(*pubkey));
ret = ret && secp256k1_ec_pubkey_tweak_add_helper(&p, tweak32);
if (ret) {
secp256k1_pubkey_save(pubkey, &p);
}
return ret;
}
int secp256k1_ec_seckey_tweak_mul(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak32) {
secp256k1_scalar factor;
secp256k1_scalar sec;
int ret = 0;
int overflow = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(seckey != NULL);
ARG_CHECK(tweak32 != NULL);
secp256k1_scalar_set_b32(&factor, tweak32, &overflow);
ret = secp256k1_scalar_set_b32_seckey(&sec, seckey);
ret &= (!overflow) & secp256k1_eckey_privkey_tweak_mul(&sec, &factor);
secp256k1_scalar_cmov(&sec, &secp256k1_scalar_zero, !ret);
secp256k1_scalar_get_b32(seckey, &sec);
secp256k1_scalar_clear(&sec);
secp256k1_scalar_clear(&factor);
return ret;
}
int secp256k1_ec_privkey_tweak_mul(const secp256k1_context* ctx, unsigned char *seckey, const unsigned char *tweak32) {
return secp256k1_ec_seckey_tweak_mul(ctx, seckey, tweak32);
}
int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context* ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak32) {
secp256k1_ge p;
secp256k1_scalar factor;
int ret = 0;
int overflow = 0;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(pubkey != NULL);
ARG_CHECK(tweak32 != NULL);
secp256k1_scalar_set_b32(&factor, tweak32, &overflow);
ret = !overflow && secp256k1_pubkey_load(ctx, &p, pubkey);
memset(pubkey, 0, sizeof(*pubkey));
if (ret) {
if (secp256k1_eckey_pubkey_tweak_mul(&p, &factor)) {
secp256k1_pubkey_save(pubkey, &p);
} else {
ret = 0;
}
}
return ret;
}
int secp256k1_context_randomize(secp256k1_context* ctx, const unsigned char *seed32) {
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(secp256k1_context_is_proper(ctx));
if (secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx)) {
secp256k1_ecmult_gen_blind(&ctx->ecmult_gen_ctx, seed32);
}
return 1;
}
int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *pubnonce, const secp256k1_pubkey * const *pubnonces, size_t n) {
size_t i;
secp256k1_gej Qj;
secp256k1_ge Q;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(pubnonce != NULL);
memset(pubnonce, 0, sizeof(*pubnonce));
ARG_CHECK(n >= 1);
ARG_CHECK(pubnonces != NULL);
secp256k1_gej_set_infinity(&Qj);
for (i = 0; i < n; i++) {
ARG_CHECK(pubnonces[i] != NULL);
secp256k1_pubkey_load(ctx, &Q, pubnonces[i]);
secp256k1_gej_add_ge(&Qj, &Qj, &Q);
}
if (secp256k1_gej_is_infinity(&Qj)) {
return 0;
}
secp256k1_ge_set_gej(&Q, &Qj);
secp256k1_pubkey_save(pubnonce, &Q);
return 1;
}
int secp256k1_tagged_sha256(const secp256k1_context* ctx, unsigned char *hash32, const unsigned char *tag, size_t taglen, const unsigned char *msg, size_t msglen) {
secp256k1_sha256 sha;
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(hash32 != NULL);
ARG_CHECK(tag != NULL);
ARG_CHECK(msg != NULL);
secp256k1_sha256_initialize_tagged(&sha, tag, taglen);
secp256k1_sha256_write(&sha, msg, msglen);
secp256k1_sha256_finalize(&sha, hash32);
return 1;
}
#ifdef ENABLE_MODULE_ECDH
# include "modules/ecdh/main_impl.h"
#endif
#ifdef ENABLE_MODULE_RECOVERY
# include "modules/recovery/main_impl.h"
#endif
#ifdef ENABLE_MODULE_EXTRAKEYS
# include "modules/extrakeys/main_impl.h"
#endif
#ifdef ENABLE_MODULE_SCHNORRSIG
# include "modules/schnorrsig/main_impl.h"
#endif
#ifdef ENABLE_MODULE_ELLSWIFT
# include "modules/ellswift/main_impl.h"
#endif
|
e3aa39a533c5c31bf3f5b327e07312100f642ead
|
8838eb997879add5759b6dfb23f9a646464e53ca
|
/src/include/hal/mem_barriers.h
|
499e1dde347ced37c3ea32171610701fa278b823
|
[
"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
| 353
|
h
|
mem_barriers.h
|
/**
* @file mem_barriers.h
* @brief Header file for memory barriers
*
* @author Michele Di Giorgio
* @date 23.11.2015
*/
#ifndef HAL_MEM_BARRIERS_H_
#define HAL_MEM_BARRIERS_H_
#include <module/embox/arch/mem_barriers.h>
#ifndef __ASSEMBLER__
extern void data_mem_barrier(void);
#endif /* __ASSEMBLER__ */
#endif /* HAL_MEM_BARRIERS_H_ */
|
9dce0d437e01ad718b0ae3ae2a90042d2e10ed59
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/components/net/lwip/lwip-2.1.2/src/apps/altcp_tls/altcp_tls_mbedtls_mem.c
|
04d47ae51c77f2b992cf603153af133ddaea2146
|
[
"BSD-3-Clause",
"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
| 6,720
|
c
|
altcp_tls_mbedtls_mem.c
|
/**
* @file
* Application layered TCP connection API (to be used from TCPIP thread)
*
* This file contains memory management functions for a TLS layer using mbedTLS.
*
* ATTENTION: For production usage, you might want to override this file with
* your own implementation since this implementation simply uses the
* lwIP heap without caring for fragmentation or leaving heap for
* other parts of lwIP!
*/
/*
* Copyright (c) 2017 Simon Goldschmidt
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR 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.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Simon Goldschmidt <[email protected]>
*
* Missing things / @todo:
* - RX data is acknowledged after receiving (tcp_recved is called when enqueueing
* the pbuf for mbedTLS receive, not when processed by mbedTLS or the inner
* connection; altcp_recved() from inner connection does nothing)
* - TX data is marked as 'sent' (i.e. acknowledged; sent callback is called) right
* after enqueueing for transmission, not when actually ACKed be the remote host.
*/
#include "lwip/opt.h"
#if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */
#include "lwip/apps/altcp_tls_mbedtls_opts.h"
#if LWIP_ALTCP_TLS && LWIP_ALTCP_TLS_MBEDTLS
#include "altcp_tls_mbedtls_mem.h"
#include "altcp_tls_mbedtls_structs.h"
#include "lwip/mem.h"
#include "mbedtls/platform.h"
#include <string.h>
#ifndef ALTCP_MBEDTLS_MEM_DEBUG
#define ALTCP_MBEDTLS_MEM_DEBUG LWIP_DBG_OFF
#endif
#if defined(MBEDTLS_PLATFORM_MEMORY) && \
(!defined(MBEDTLS_PLATFORM_FREE_MACRO) || \
defined(MBEDTLS_PLATFORM_CALLOC_MACRO))
#define ALTCP_MBEDTLS_PLATFORM_ALLOC 1
#else
#define ALTCP_MBEDTLS_PLATFORM_ALLOC 0
#endif
#if ALTCP_MBEDTLS_PLATFORM_ALLOC
#ifndef ALTCP_MBEDTLS_PLATFORM_ALLOC_STATS
#define ALTCP_MBEDTLS_PLATFORM_ALLOC_STATS 0
#endif
/* This is an example/debug implementation of alloc/free functions only */
typedef struct altcp_mbedtls_malloc_helper_s {
size_t c;
size_t len;
} altcp_mbedtls_malloc_helper_t;
#if ALTCP_MBEDTLS_PLATFORM_ALLOC_STATS
typedef struct altcp_mbedtls_malloc_stats_s {
size_t allocedBytes;
size_t allocCnt;
size_t maxBytes;
size_t totalBytes;
} altcp_mbedtls_malloc_stats_t;
altcp_mbedtls_malloc_stats_t altcp_mbedtls_malloc_stats;
volatile int altcp_mbedtls_malloc_clear_stats;
#endif
static void *
tls_malloc(size_t c, size_t len)
{
altcp_mbedtls_malloc_helper_t *hlpr;
void *ret;
size_t alloc_size;
#if ALTCP_MBEDTLS_PLATFORM_ALLOC_STATS
if (altcp_mbedtls_malloc_clear_stats) {
altcp_mbedtls_malloc_clear_stats = 0;
memset(&altcp_mbedtls_malloc_stats, 0, sizeof(altcp_mbedtls_malloc_stats));
}
#endif
alloc_size = sizeof(altcp_mbedtls_malloc_helper_t) + (c * len);
/* check for maximum allocation size, mainly to prevent mem_size_t overflow */
if (alloc_size > MEM_SIZE) {
LWIP_DEBUGF(ALTCP_MBEDTLS_MEM_DEBUG, ("mbedtls allocation too big: %c * %d bytes vs MEM_SIZE=%d",
(int)c, (int)len, (int)MEM_SIZE));
return NULL;
}
hlpr = (altcp_mbedtls_malloc_helper_t *)mem_malloc((mem_size_t)alloc_size);
if (hlpr == NULL) {
LWIP_DEBUGF(ALTCP_MBEDTLS_MEM_DEBUG, ("mbedtls alloc callback failed for %c * %d bytes", (int)c, (int)len));
return NULL;
}
#if ALTCP_MBEDTLS_PLATFORM_ALLOC_STATS
altcp_mbedtls_malloc_stats.allocCnt++;
altcp_mbedtls_malloc_stats.allocedBytes += c * len;
if (altcp_mbedtls_malloc_stats.allocedBytes > altcp_mbedtls_malloc_stats.maxBytes) {
altcp_mbedtls_malloc_stats.maxBytes = altcp_mbedtls_malloc_stats.allocedBytes;
}
altcp_mbedtls_malloc_stats.totalBytes += c * len;
#endif
hlpr->c = c;
hlpr->len = len;
ret = hlpr + 1;
/* zeroing the allocated chunk is required by mbedTLS! */
memset(ret, 0, c * len);
return ret;
}
static void
tls_free(void *ptr)
{
altcp_mbedtls_malloc_helper_t *hlpr;
if (ptr == NULL) {
/* this obviously happened in mbedtls... */
return;
}
hlpr = ((altcp_mbedtls_malloc_helper_t *)ptr) - 1;
#if ALTCP_MBEDTLS_PLATFORM_ALLOC_STATS
if (!altcp_mbedtls_malloc_clear_stats) {
altcp_mbedtls_malloc_stats.allocedBytes -= hlpr->c * hlpr->len;
}
#endif
mem_free(hlpr);
}
#endif /* ALTCP_MBEDTLS_PLATFORM_ALLOC*/
void
altcp_mbedtls_mem_init(void)
{
/* not much to do here when using the heap */
#if ALTCP_MBEDTLS_PLATFORM_ALLOC
/* set mbedtls allocation methods */
mbedtls_platform_set_calloc_free(&tls_malloc, &tls_free);
#endif
}
altcp_mbedtls_state_t *
altcp_mbedtls_alloc(void *conf)
{
altcp_mbedtls_state_t *ret = (altcp_mbedtls_state_t *)mem_calloc(1, sizeof(altcp_mbedtls_state_t));
if (ret != NULL) {
ret->conf = conf;
}
return ret;
}
void
altcp_mbedtls_free(void *conf, altcp_mbedtls_state_t *state)
{
LWIP_UNUSED_ARG(conf);
LWIP_ASSERT("state != NULL", state != NULL);
mem_free(state);
}
void *
altcp_mbedtls_alloc_config(size_t size)
{
void *ret;
size_t checked_size = (mem_size_t)size;
if (size != checked_size) {
/* allocation too big (mem_size_t overflow) */
return NULL;
}
ret = (altcp_mbedtls_state_t *)mem_calloc(1, (mem_size_t)size);
return ret;
}
void
altcp_mbedtls_free_config(void *item)
{
LWIP_ASSERT("item != NULL", item != NULL);
mem_free(item);
}
#endif /* LWIP_ALTCP_TLS && LWIP_ALTCP_TLS_MBEDTLS */
#endif /* LWIP_ALTCP */
|
0c570b6abf2d52b86883db8b40083faf9a6eecd1
|
61da6274995cf914291af51bd02e60f408fdfedd
|
/src/misc/debug.h
|
aa59fb8de60703120c9d859d639f4704ca32dd3f
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] |
permissive
|
mrirecon/bart
|
360d518b4c79836d506803aa4a77e8e252ab820b
|
a3c9dc313f79c4c52f1ba3e617d5831ef088ddf7
|
refs/heads/master
| 2023-08-31T11:01:08.932824
| 2023-08-30T12:15:35
| 2023-08-30T13:51:18
| 23,212,230
| 264
| 185
|
BSD-3-Clause
| 2023-08-03T18:43:36
| 2014-08-22T03:57:09
|
C
|
UTF-8
|
C
| false
| false
| 2,334
|
h
|
debug.h
|
/* Copyright 2013. The Regents of the University of California.
* Copyright 2016. Martin Uecker.
* Copyright 2018. Damien Nguyen.
* All rights reserved. Use of this source code is governed by
* a BSD-style license which can be found in the LICENSE file.
*/
#ifndef __DEBUG_H
#define __DEBUG_H 1
#include <stdarg.h>
#include <stddef.h>
#include "misc/cppwrap.h"
extern void dump_cfl(const char* name, int D, const long dimensions[__VLA(D)], const _Complex float* x);
extern void dump_multi_cfl(const char* name, int N, int D[__VLA(N)], const long* dimensions[__VLA(N)], const _Complex float* x[__VLA(N)]);
extern double timestamp(void);
extern int debug_level;
extern _Bool debug_logging;
enum debug_levels { DP_ERROR, DP_WARN, DP_INFO, DP_DEBUG1, DP_DEBUG2, DP_DEBUG3, DP_DEBUG4, DP_TRACE, DP_ALL };
extern void debug_printf(int level, const char* fmt, ...);
extern void debug_vprintf(int level, const char* fmt, va_list ap);
#ifdef REDEFINE_PRINTF_FOR_TRACE
#define debug_printf(level, ...) \
debug_printf_trace(__FUNCTION__, __FILE__, __LINE__, level, __VA_ARGS__)
#define debug_vprintf(level, fmt, ap) \
debug_vprintf_trace(__FUNCTION__, __FILE__, __LINE__, level, fmt, ap)
#endif
extern void debug_printf_trace(const char* func_name,
const char* file,
int line,
int level, const char* fmt, ...);
extern void debug_vprintf_trace(const char* func_name,
const char* file,
int line,
int level, const char* fmt, va_list ap);
#define BART_OUT(...) debug_printf_trace(__FUNCTION__, __FILE__, __LINE__, DP_INFO, __VA_ARGS__)
#define BART_ERR(...) debug_printf_trace(__FUNCTION__, __FILE__, __LINE__, DP_ERROR, __VA_ARGS__)
#define BART_WARN(...) debug_printf_trace(__FUNCTION__, __FILE__, __LINE__, DP_WARN, __VA_ARGS__)
extern void debug_backtrace(size_t n);
#ifdef USE_DWARF
extern void debug_good_backtrace(int skip);
const char* debug_good_backtrace_string(int skip);
#endif // USE_DWARF
extern void debug_trace(const char* fmt, ...);
#define TRACE() debug_trace("%s:%d %s\n", __FILE__, __LINE__, __func__)
#ifdef USE_LOG_BACKEND
// this function must be provided by a vendor backend
extern void vendor_log(int level,
const char* func_name,
const char* file,
unsigned int line,
const char* message);
#endif
#include "misc/cppwrap.h"
#endif // __DEBUG_H
|
eec752bfa35038599d03d7a26a70b5f1e9646fa8
|
fbe68d84e97262d6d26dd65c704a7b50af2b3943
|
/third_party/virtualbox/src/VBox/GuestHost/OpenGL/packer/pack_bounds.c
|
191383bd49b8f8c852847c38c7fdafe509d73fc2
|
[
"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,458
|
c
|
pack_bounds.c
|
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "packer.h"
#include "cr_opcodes.h"
#include "cr_mem.h"
void PACK_APIENTRY crPackBoundsInfoCR( CR_PACKER_CONTEXT_ARGDECL const CRrecti *bounds, const GLbyte *payload, GLint len, GLint num_opcodes )
{
CR_GET_PACKER_CONTEXT(pc);
/* Don't get the buffered_ptr here because we've already
* verified that there's enough space for everything. */
unsigned char *data_ptr;
int len_aligned, total_len;
CR_LOCK_PACKER_CONTEXT(pc);
data_ptr = pc->buffer.data_current;
len_aligned = ( len + 0x3 ) & ~0x3;
total_len = 24 + len_aligned;
WRITE_DATA( 0, int, total_len );
WRITE_DATA( 4, int, bounds->x1 );
WRITE_DATA( 8, int, bounds->y1 );
WRITE_DATA( 12, int, bounds->x2 );
WRITE_DATA( 16, int, bounds->y2 );
WRITE_DATA( 20, int, num_opcodes );
/* skip the BOUNDSINFO */
data_ptr += 24;
/* put in padding opcodes (deliberately bogus) */
switch ( len_aligned - len )
{
case 3: *data_ptr++ = 0xff; RT_FALL_THRU();
case 2: *data_ptr++ = 0xff; RT_FALL_THRU();
case 1: *data_ptr++ = 0xff; RT_FALL_THRU();
default: break;
}
crMemcpy( data_ptr, payload, len );
WRITE_OPCODE( pc, CR_BOUNDSINFOCR_OPCODE );
pc->buffer.data_current += 24 + len_aligned;
CR_UNLOCK_PACKER_CONTEXT(pc);
}
|
61b6bb7b5ad45813374cfcbbb5f7c98e1e50c910
|
847ebadf2b0e7c01ad33ce92b42528a1a5c4846c
|
/ofproto/ofproto-dpif-xlate-cache.c
|
9224ee2e6d5df8321eb7fb5ec07afbb248c63ebf
|
[
"BSD-3-Clause",
"ISC",
"Apache-2.0",
"SISSL",
"GPL-2.0-only",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] |
permissive
|
openvswitch/ovs
|
6f782527cf5fde4ccfd25e68d359b91ff41acf8a
|
bc79a7bf033fa4cda8ccfc5481db3cfccd72650c
|
refs/heads/master
| 2023-09-04T06:31:47.899017
| 2023-08-03T16:19:12
| 2023-09-01T20:15:05
| 18,383,364
| 3,366
| 2,259
|
Apache-2.0
| 2023-08-17T13:17:13
| 2014-04-02T22:15:28
|
C
|
UTF-8
|
C
| false
| false
| 8,341
|
c
|
ofproto-dpif-xlate-cache.c
|
/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */
#include <config.h>
#include "ofproto/ofproto-dpif-xlate-cache.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <net/if.h>
#include <sys/socket.h>
#include "bfd.h"
#include "bitmap.h"
#include "bond.h"
#include "bundle.h"
#include "byte-order.h"
#include "connmgr.h"
#include "coverage.h"
#include "dp-packet.h"
#include "dpif.h"
#include "learn.h"
#include "mac-learning.h"
#include "netdev-vport.h"
#include "ofproto/ofproto-dpif-mirror.h"
#include "ofproto/ofproto-dpif-xlate.h"
#include "ofproto/ofproto-dpif.h"
#include "ofproto/ofproto-provider.h"
#include "openvswitch/dynamic-string.h"
#include "openvswitch/vlog.h"
#include "ovs-router.h"
#include "packets.h"
#include "tnl-neigh-cache.h"
#include "util.h"
VLOG_DEFINE_THIS_MODULE(ofproto_xlate_cache);
void
xlate_cache_init(struct xlate_cache *xcache)
{
ofpbuf_init(&xcache->entries, 120);
}
struct xlate_cache *
xlate_cache_new(void)
{
struct xlate_cache *xcache = xmalloc(sizeof *xcache);
xlate_cache_init(xcache);
return xcache;
}
struct xc_entry *
xlate_cache_add_entry(struct xlate_cache *xcache, enum xc_type type)
{
struct xc_entry *entry;
entry = ofpbuf_put_zeros(&xcache->entries, sizeof *entry);
entry->type = type;
return entry;
}
static void
xlate_cache_netdev(struct xc_entry *entry, const struct dpif_flow_stats *stats)
{
if (entry->dev.tx) {
netdev_vport_inc_tx(entry->dev.tx, stats);
}
if (entry->dev.rx) {
netdev_vport_inc_rx(entry->dev.rx, stats);
}
if (entry->dev.bfd) {
bfd_account_rx(entry->dev.bfd, stats);
}
}
/* Push stats and perform side effects of flow translation. */
void
xlate_push_stats_entry(struct xc_entry *entry,
struct dpif_flow_stats *stats, bool offloaded)
{
struct eth_addr dmac;
switch (entry->type) {
case XC_TABLE:
ofproto_dpif_credit_table_stats(entry->table.ofproto,
entry->table.id,
entry->table.match
? stats->n_packets : 0,
entry->table.match
? 0 : stats->n_packets);
break;
case XC_RULE:
rule_dpif_credit_stats(entry->rule, stats, offloaded);
break;
case XC_BOND:
bond_account(entry->bond.bond, entry->bond.flow,
entry->bond.vid, stats->n_bytes);
break;
case XC_NETDEV:
xlate_cache_netdev(entry, stats);
break;
case XC_NETFLOW:
netflow_flow_update(entry->nf.netflow, entry->nf.flow,
entry->nf.iface, stats);
break;
case XC_MIRROR:
mirror_update_stats(entry->mirror.mbridge,
entry->mirror.mirrors,
stats->n_packets, stats->n_bytes);
break;
case XC_LEARN: {
enum ofperr error;
error = ofproto_flow_mod_learn(entry->learn.ofm, true,
entry->learn.limit, NULL);
if (error) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_WARN_RL(&rl, "xcache LEARN action execution failed.");
}
break;
}
case XC_NORMAL:
xlate_mac_learning_update(entry->normal.ofproto,
entry->normal.in_port,
entry->normal.dl_src,
entry->normal.vlan,
entry->normal.is_gratuitous_arp);
break;
case XC_FIN_TIMEOUT:
if (stats->tcp_flags & (TCP_FIN | TCP_RST)) {
ofproto_rule_reduce_timeouts(&entry->fin.rule->up, entry->fin.idle,
entry->fin.hard);
}
break;
case XC_GROUP:
group_dpif_credit_stats(entry->group.group, entry->group.bucket,
stats);
break;
case XC_TNL_NEIGH:
/* Lookup neighbor to avoid timeout. */
tnl_neigh_lookup(entry->tnl_neigh_cache.br_name,
&entry->tnl_neigh_cache.d_ipv6, &dmac);
break;
case XC_TUNNEL_HEADER:
if (entry->tunnel_hdr.operation == ADD) {
stats->n_bytes += stats->n_packets * entry->tunnel_hdr.hdr_size;
} else {
stats->n_bytes -= stats->n_packets * entry->tunnel_hdr.hdr_size;
}
break;
default:
OVS_NOT_REACHED();
}
}
void
xlate_push_stats(struct xlate_cache *xcache,
struct dpif_flow_stats *stats, bool offloaded)
{
if (!stats->n_packets) {
return;
}
struct xc_entry *entry;
struct ofpbuf entries = xcache->entries;
XC_ENTRY_FOR_EACH (entry, &entries) {
xlate_push_stats_entry(entry, stats, offloaded);
}
}
static void
xlate_dev_unref(struct xc_entry *entry)
{
if (entry->dev.tx) {
netdev_close(entry->dev.tx);
}
if (entry->dev.rx) {
netdev_close(entry->dev.rx);
}
if (entry->dev.bfd) {
bfd_unref(entry->dev.bfd);
}
}
static void
xlate_cache_clear_netflow(struct netflow *netflow, struct flow *flow)
{
netflow_flow_clear(netflow, flow);
netflow_unref(netflow);
free(flow);
}
void
xlate_cache_clear_entry(struct xc_entry *entry)
{
switch (entry->type) {
case XC_TABLE:
ofproto_unref(&(entry->table.ofproto->up));
break;
case XC_RULE:
ofproto_rule_unref(&entry->rule->up);
break;
case XC_BOND:
free(entry->bond.flow);
bond_unref(entry->bond.bond);
break;
case XC_NETDEV:
xlate_dev_unref(entry);
break;
case XC_NETFLOW:
xlate_cache_clear_netflow(entry->nf.netflow, entry->nf.flow);
break;
case XC_MIRROR:
mbridge_unref(entry->mirror.mbridge);
break;
case XC_LEARN:
ofproto_flow_mod_uninit(entry->learn.ofm);
free(entry->learn.ofm);
break;
case XC_NORMAL:
ofproto_unref(&(entry->normal.ofproto->up));
break;
case XC_FIN_TIMEOUT:
/* 'u.fin.rule' is always already held as a XC_RULE, which
* has already released it's reference above. */
break;
case XC_GROUP:
ofproto_group_unref(&entry->group.group->up);
break;
case XC_TNL_NEIGH:
break;
case XC_TUNNEL_HEADER:
break;
default:
OVS_NOT_REACHED();
}
}
void
xlate_cache_clear(struct xlate_cache *xcache)
{
if (!xcache) {
return;
}
struct xc_entry *entry;
struct ofpbuf entries = xcache->entries;
XC_ENTRY_FOR_EACH (entry, &entries) {
xlate_cache_clear_entry(entry);
}
ofpbuf_clear(&xcache->entries);
}
void
xlate_cache_uninit(struct xlate_cache *xcache)
{
if (!xcache) {
return;
}
xlate_cache_clear(xcache);
ofpbuf_uninit(&xcache->entries);
}
void
xlate_cache_delete(struct xlate_cache *xcache)
{
xlate_cache_uninit(xcache);
free(xcache);
}
/* Append all the entries in src into dst and remove them from src.
* The caller must own both xc-caches to use this function.
* The 'src' entries are not freed in this function as its owned by caller.
*/
void
xlate_cache_steal_entries(struct xlate_cache *dst, struct xlate_cache *src)
{
if (!dst || !src) {
return;
}
struct ofpbuf *src_entries = &src->entries;
struct ofpbuf *dst_entries = &dst->entries;
void *p;
p = ofpbuf_put_uninit(dst_entries, src_entries->size);
memcpy(p, src_entries->data, src_entries->size);
ofpbuf_clear(src_entries);
}
|
f75504a9ced43ce1c95c812aa9ef2f3c0ae6c931
|
4f93f5a27b6c872903b9acf8d20fb736716a26df
|
/src/clair3_pileup.c
|
af1443d6d62db5edfb0085a7a351e368933c73f1
|
[
"BSD-3-Clause"
] |
permissive
|
HKU-BAL/Clair3
|
cf388ae3d0b0332eb8df125fb1e1a97120a90ed1
|
181f55d7a741855597d083baffc4551949d2837e
|
refs/heads/main
| 2023-07-28T05:34:32.917498
| 2023-07-20T02:58:19
| 2023-07-20T02:58:19
| 352,969,947
| 162
| 18
| null | 2023-06-01T14:15:31
| 2021-03-30T11:02:58
|
Python
|
UTF-8
|
C
| false
| false
| 19,180
|
c
|
clair3_pileup.c
|
#define _GNU_SOURCE
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "htslib/sam.h"
#include "htslib/faidx.h"
#include "kvec.h"
#include "medaka_bamiter.h"
#include "medaka_common.h"
#include "clair3_pileup.h"
#include "medaka_khcounter.h"
#define bam1_seq(b) ((b)->data + (b)->core.n_cigar*4 + (b)->core.l_qname)
#define bam1_seqi(s, i) (bam_seqi((s), (i)))
#define bam_nt16_rev_table seq_nt16_str
#define bam_nt16_table seq_nt16_table
/** Constructs a pileup data structure.
*
* @param n_cols number of pileup columns.
* @param buffer_cols number of pileup columns.
* @param feature_length length of feature vector.
* @param num_dtypes number of datatypes in pileup.
* @param num_homop maximum homopolymer length to consider.
* @param fixed_size if not zero data matrix is allocated as fixed_size * n_cols, ignoring other arguments
* @see destroy_plp_data
* @returns a plp_data pointer.
*
* The return value can be freed with destroy_plp_data.
*
*/
plp_data create_plp_data(size_t n_cols, size_t buffer_cols, size_t feature_length, size_t num_dtypes, size_t num_homop, size_t fixed_size) {
assert(buffer_cols >= n_cols);
plp_data data = xalloc(1, sizeof(_plp_data), "plp_data");
data->buffer_cols = buffer_cols;
data->num_dtypes = num_dtypes;
data->num_homop = num_homop;
data->n_cols = n_cols;
if (fixed_size != 0) {
assert(buffer_cols == n_cols);
data->matrix = xalloc(fixed_size * n_cols, sizeof(int), "matrix");
} else {
data->matrix = xalloc(feature_length * num_dtypes * buffer_cols * num_homop, sizeof(size_t), "matrix");
}
data->major = xalloc(buffer_cols, sizeof(size_t), "major");
data->minor = xalloc(buffer_cols, sizeof(size_t), "minor");
data->all_alt_info = NULL;
data->pos_ref_count = NULL;
data->pos_total_count = NULL;
return data;
}
/** Enlarge the internal buffers of a pileup data structure.
*
* @param pileup a plp_data pointer.
* @param buffer_cols number of pileup columns for which to allocate memory
*
*/
void enlarge_plp_data(plp_data pileup, size_t buffer_cols, size_t feature_length) {
assert(buffer_cols > pileup->buffer_cols);
size_t old_size = feature_length * pileup->num_dtypes * pileup->num_homop * pileup->buffer_cols;
size_t new_size = feature_length * pileup->num_dtypes * pileup->num_homop * buffer_cols;
pileup->matrix = xrealloc(pileup->matrix, new_size * sizeof(size_t), "matrix");
pileup->major = xrealloc(pileup->major, buffer_cols * sizeof(size_t), "major");
pileup->minor = xrealloc(pileup->minor, buffer_cols * sizeof(size_t), "minor");
// zero out new part of matrix
for (size_t i = old_size; i < new_size; ++i) {
pileup->matrix[i] = 0;
}
pileup->buffer_cols = buffer_cols;
}
/** Destroys a pileup data structure.
*
* @param data the object to cleanup.
* @returns void.
*
*/
void destroy_plp_data(plp_data data, bool gvcf) {
free(data->matrix);
free(data->major);
free(data->minor);
for (size_t i = 0; i < data->candidates_num; i++) {
free(data->all_alt_info[i]);
}
if (gvcf == true) {
free(data->pos_ref_count);
free(data->pos_total_count);
}
free(data->all_alt_info);
free(data);
}
/** Generates clair3-style pileup feature data in a region of a bam.
*
* @param region 1-based region string.
* @param bam_file input aligment file.
* @param tag_value by which to filter data.
* @param keep_missing alignments which do not have tag.
* @param weibull_summation use predefined bam tags to perform homopolymer partial counts.
* @returns a pileup data pointer.
*
* The return value can be freed with destroy_plp_data.
*
* If num_dtypes is 1, dtypes should be NULL; all reads in the bam will be
* treated equally. If num_dtypes is not 1, dtypes should be an array of
* strings, these strings being prefixes of query names of reads within the
* bam file. Any read not matching the prefixes will cause exit(1).
*
* If tag_name is not NULL alignments are filtered by the (integer) tag value.
* When tag_name is given the behaviour for alignments without the tag is
* determined by keep_missing.
*
*/
/**
* The pileup input is 594 integers – 33 genome positions wide with 18 features at each position –
*
* A+, C+, G+, T+, I_S+, I^1 S+, D_S+, D^1_S+, D_R+, A-, C-, G-, T-, I_S-, I^1_S-, D_S-, D^1_S-, and D_R-
*
* A, C, G, T, I, D, +, - means the count of read support of the four nucleotides: insertion,
* deletion, positive strand, and negative strand. Superscript “1” means only the indel with the
* highest read support is counted (i.e., all indels are counted if without “1“). Subscript “S”/“R” means
* the starting/non-starting position of an indel. For example, a 3bp deletion with the most reads support
* will have the first deleted base counted in either D1_S+ or D1_S-, and the second and third deleted bases
* counted in either D_R+ or D_R-. The design was determined experimentally, but the rationale is that for
* 1bp indels that are easy to call, look into the differences between the “S” counts, but reduce the
* quality if the “R” counts and discrepancy between positions increase.
*
*/
plp_data calculate_clair3_pileup(const char *region, const bam_fset* bam_set, const char * fasta_path, size_t min_depth, float min_snp_af, float min_indel_af, size_t min_mq, size_t max_indel_length, bool call_snp_only, size_t max_depth, bool gvcf) {
// extract `chr`:`start`-`end` from `region`
// (start is one-based and end-inclusive),
// hts_parse_reg below sets return value to point
// at ":", copy the input then set ":" to null terminator
// to get `chr`.
int start, end;
char *chr = xalloc(strlen(region) + 1, sizeof(char), "chr");
strcpy(chr, region);
char *reg_chr = (char *) hts_parse_reg(chr, &start, &end);
// start and end now zero-based end exclusive
if (reg_chr) {
*reg_chr = '\0';
} else {
fprintf(stderr, "Failed to parse region: '%s'.\n", region);
}
// open bam etc.
// this is all now deferred to the caller
htsFile *fp = bam_set->fp;
hts_idx_t *idx = bam_set->idx;
sam_hdr_t *hdr = bam_set->hdr;
// setup bam interator
mplp_data *data = xalloc(1, sizeof(mplp_data), "pileup init data");
data->fp = fp; data->hdr = hdr; data->iter = bam_itr_querys(idx, hdr, region);
data->min_mapQ = min_mq;
bam_mplp_t mplp = bam_mplp_init(1, read_bam, (void **)& data);
const bam_pileup1_t **plp = xalloc(1, sizeof(bam_pileup1_t *), "pileup");
int ret, pos, tid, n_plp;
int n_cols = 0;
size_t buffer_cols = end - start;
plp_data pileup = create_plp_data(n_cols, buffer_cols, featlenclair3, 1, 1, 0);
// get counts
size_t major_col = 0; // index into `pileup` corresponding to pos
n_cols = 0; // number of processed columns (including insertions, which clair3 doesn't have ;))
faidx_t* fai = fai_load(fasta_path);
int len = 0;
char *ref_seq = NULL;
// printf("pos: %s %i %i\n", chr, start, end);
size_t ref_start = max(0, start - mpileup_expand_reference_region);
size_t ref_end = max(0, end + mpileup_expand_reference_region);
ref_seq = faidx_fetch_seq(fai, chr, ref_start, ref_end, &len);
size_t candidates_num = 0;
size_t alt_info_p_size = 512;
char ** alt_info_p = xalloc(alt_info_p_size, sizeof(char*), "alt_info_p");
for (size_t i = 0; i < alt_info_p_size; i++)
alt_info_p[i] = NULL;
size_t pre_pos = 0;
size_t contiguous_flanking_num = 0;
if (gvcf == true) {
pileup->pos_ref_count = xalloc(buffer_cols, sizeof(size_t), "pos_ref_count");
pileup->pos_total_count = xalloc(buffer_cols, sizeof(size_t), "pos_total_count");
memset(pileup->pos_ref_count, 0, buffer_cols * sizeof(size_t));
memset(pileup->pos_total_count, 0, buffer_cols * sizeof(size_t));
}
while ((ret=bam_mplp_auto(mplp, &tid, &pos, &n_plp, plp) > 0)) {
size_t depth = 0;
size_t alt_count = 0;
size_t ref_count = 0;
size_t del_count = 0;
size_t ins_count = 0;
bool pass_af = false;
bool pass_snp_af = false;
bool pass_indel_af = false;
const char *c_name = data->hdr->target_name[tid];
if (strcmp(c_name, chr) != 0) continue;
if (pos < start) continue;
if (pos >= end) break;
n_cols++;
if (pre_pos + 1 != pos || pre_pos == 0)
contiguous_flanking_num = 0;
else
contiguous_flanking_num++;
pre_pos = pos;
//update the deletion buffer in each interation
size_t del_buf_size = 32;
size_t* dels_f = xalloc(del_buf_size, sizeof(size_t), "dels_f");
size_t* dels_r = xalloc(del_buf_size, sizeof(size_t), "dels_r");
memset(dels_f, 0, del_buf_size * sizeof(size_t));
memset(dels_r, 0, del_buf_size * sizeof(size_t));
// we still need this as positions might not be contiguous
pileup->major[major_col / featlenclair3] = pos;
pileup->minor[major_col / featlenclair3] = 0;
// counters for insertion strings
khash_t(KH_COUNTER) *ins_counts_f = kh_init(KH_COUNTER);
khash_t(KH_COUNTER) *ins_counts_r = kh_init(KH_COUNTER);
khash_t(KH_COUNTER) *ins_counts_all = kh_init(KH_COUNTER);
// loop through all reads at this position
for (int i = 0; i < n_plp; ++i) {
const bam_pileup1_t *p = plp[0] + i;
if (p->is_refskip) continue;
if (p->indel < 0) {
// there's a deletion starting on next genomic position,
// record the length here and finalise after the read loop
// - actually deleted bases get recorded in next block
size_t d = (size_t) -1 * p->indel;
if (d >= del_buf_size) {
size_t new_size = max(d, 2 * del_buf_size);
dels_f = xrealloc(dels_f, new_size*sizeof(size_t), "dels_f");
memset(dels_f+del_buf_size, 0, (new_size-del_buf_size) * sizeof(size_t));
dels_r = xrealloc(dels_r, new_size*sizeof(size_t), "dels_r");
memset(dels_r+del_buf_size, 0, (new_size-del_buf_size) * sizeof(size_t));
del_buf_size = new_size;
}
if (bam_is_rev(p->b)) {
dels_r[d - 1] += 1;
} else {
dels_f[d - 1] += 1;
}
}
// handle ref_base/sub/del
int base_i;
if (p->is_del) {
// we've been deleted, +1 to DR
base_i = bam_is_rev(p->b) ? c3_rev_del : c3_fwd_del;
depth++;
} else {
// just a base
int base_j = bam1_seqi(bam1_seq(p->b), p->qpos);
if bam_is_rev(p->b) { base_j += 16; }
base_i = num2countbaseclair3[base_j];
depth++;
}
pileup->matrix[major_col + base_i] += 1;
// handle insertion
// - build insert string then hash
if (p->indel > 0) {
size_t first = p->is_del ? 0 : 1;
char* indel = (char*) xalloc(p->indel + 1, sizeof(char), "indel");
for (size_t i = 0, j = first; j < p->indel + first; ++i, ++j) {
indel[i] = seq_nt16_str[bam1_seqi(bam1_seq(p->b), p->qpos + j)];
}
indel[p->indel] = '\0';
if (bam_is_rev(p->b)) {
kh_counter_increment(ins_counts_r, indel);
} else {
kh_counter_increment(ins_counts_f, indel);
}
kh_counter_increment(ins_counts_all, indel);
free(indel);
}
}
// finalise deletions: DS (all) and D1S (best)
//
// forward
size_t best_count = 0;
size_t all_count = 0;
for (size_t i = 0; i < del_buf_size; ++i) {
size_t d = dels_f[i];
all_count += d;
best_count = max(best_count, d);
}
pileup->matrix[major_col + c3_fwd_del_all] = all_count;
pileup->matrix[major_col + c3_fwd_del_best] = best_count;
del_count += all_count;
// reverse
best_count = 0;
all_count = 0;
for (size_t i = 0; i < del_buf_size; ++i) {
size_t d = dels_r[i];
all_count += d;
best_count = max(best_count, d);
}
pileup->matrix[major_col + c3_rev_del_all] = all_count;
pileup->matrix[major_col + c3_rev_del_best] = best_count;
del_count += all_count;
// finalise IS and I1S
// forward
kh_counter_stats_t stats = kh_counter_stats(ins_counts_f);
pileup->matrix[major_col + c3_fwd_ins_all] = stats.sum;
pileup->matrix[major_col + c3_fwd_ins_best] = stats.max;
ins_count += stats.sum;
kh_counter_destroy(ins_counts_f);
// reverse
stats = kh_counter_stats(ins_counts_r);
pileup->matrix[major_col + c3_rev_ins_all] = stats.sum;
pileup->matrix[major_col + c3_rev_ins_best] = stats.max;
ins_count += stats.sum;
kh_counter_destroy(ins_counts_r);
int offset = pos - ref_start;
char ref_base = upper_base(ref_seq[offset]);
int ref_offset_forward = base2index[ref_base - 'A'];
int ref_offset_reverse = ref_offset_forward + reverse_pos_start;
char major_alt_base = '\0';
size_t forward_sum = 0;
size_t reverse_sum = 0;
size_t all_alt_count = 0;
for (size_t i = 0; i < 4; i++) {
forward_sum += pileup->matrix[major_col + i];
reverse_sum += pileup->matrix[major_col + i + reverse_pos_start];
if (i == ref_offset_forward) {
ref_count = pileup->matrix[major_col + i] + pileup->matrix[major_col + i + reverse_pos_start];
} else {
size_t current_count = pileup->matrix[major_col + i] + pileup->matrix[major_col + i + reverse_pos_start];
if (current_count > alt_count) {
alt_count = current_count;
major_alt_base = plp_bases_clair3[i];
all_alt_count += alt_count;
}
}
}
pileup->matrix[major_col + ref_offset_forward] = -1 * forward_sum;
pileup->matrix[major_col + ref_offset_reverse] = -1 * reverse_sum;
// calculate candidate allele frequency and apply filtering
depth = max(1, depth);
bool pass_min_depth = depth >= min_depth;
bool pass_ref_base_in_acgt = ref_base == 'A' || ref_base == 'C' || ref_base == 'G' || ref_base == 'T';
bool non_ref_base_majority = ref_count < alt_count || ref_count < ins_count || ref_count < del_count;
bool ref_alt_equal_majority = (ref_count > 0 && ref_count == alt_count && ref_base - major_alt_base < 0);
if (call_snp_only == true) {
pass_af = alt_count / (float)depth >= min_snp_af;
} else {
pass_af = non_ref_base_majority || ref_alt_equal_majority || (alt_count / (float)depth >= min_snp_af);
pass_af = pass_af || (del_count / (float)depth >= min_indel_af) || (ins_count / (float)depth >= min_indel_af);
}
pass_af = pass_af && pass_min_depth && pass_ref_base_in_acgt;
pass_af = pass_af && (contiguous_flanking_num >= pileup_flanking_base_num);
// move to next position
if (pass_af) {
if (candidates_num + 1 >= alt_info_p_size) {
alt_info_p_size = alt_info_p_size << 1;
alt_info_p = xrealloc(alt_info_p, alt_info_p_size * sizeof(char*), "alt_info_p");
}
size_t max_alt_length = 64;
char *alt_info_str = xalloc(max_alt_length, sizeof(char), "alt_info_str");
sprintf(alt_info_str, "%i-%i-%c-", pos+1, depth, ref_base);
//snp
for (size_t i = 0; i < 4; i++) {
forward_sum += pileup->matrix[major_col + i];
reverse_sum += pileup->matrix[major_col + i + reverse_pos_start];
size_t alt_sum = pileup->matrix[major_col + i] + pileup->matrix[major_col + i + reverse_pos_start];
if (alt_sum > 0 && i != ref_offset_forward)
sprintf(alt_info_str + strlen(alt_info_str), "X%c %i ", plp_bases_clair3[i], alt_sum);
}
//del
for (size_t i = 0; i < del_buf_size; i++) {
size_t d = dels_f[i] + dels_r[i];
if (d > 0 && i+1 <= max_indel_length) {
// 32 bytes is a safe number for integer to string
if (strlen(alt_info_str) + i + 32 >= max_alt_length) {
while (strlen(alt_info_str) + i + 32 >= max_alt_length)
max_alt_length = max_alt_length << 1;
alt_info_str = xrealloc(alt_info_str, max_alt_length*sizeof(char), "alt_info_str");
}
sprintf(alt_info_str + strlen(alt_info_str), "D%.*s %i ", i+1,ref_seq+offset+1, d);
}
}
// //ins
for (khiter_t k = kh_begin(ins_counts_all); k != kh_end(ins_counts_all); ++k) {
if (kh_exist(ins_counts_all, k)) {
const char *key = kh_key(ins_counts_all, k);
size_t val = kh_val(ins_counts_all, k);
if (strlen(key) <= max_indel_length) {
if (strlen(alt_info_str) + strlen(key) + 32 >= max_alt_length) {
while (strlen(alt_info_str) + strlen(key) + 32 >= max_alt_length)
max_alt_length = max_alt_length << 1;
alt_info_str = xrealloc(alt_info_str, max_alt_length *sizeof(char), "alt_info_str");
}
sprintf(alt_info_str + strlen(alt_info_str), "I%c%s %i ", ref_base, key, val);
}
}
}
// update the alternative information for current candidates here
alt_info_p[candidates_num++] = alt_info_str;
}
if (gvcf == true) {
pileup->pos_ref_count[pos-start] = ref_count;
pileup->pos_total_count[pos-start] = ref_count + all_alt_count + del_count + ins_count;
}
free(dels_f);
free(dels_r);
kh_counter_destroy(ins_counts_all);
major_col += featlenclair3;
}
pileup->all_alt_info = alt_info_p;
pileup->candidates_num = candidates_num;
pileup->n_cols = n_cols;
bam_itr_destroy(data->iter);
bam_mplp_destroy(mplp);
fai_destroy(fai);
free(data);
free(plp);
free(chr);
return pileup;
}
int main()
{
return 0;
}
|
190c0c8b876a6bf4d1e76b511e8a9252ebf7b695
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/arch/luna68k/stand/boot/omron_disklabel.h
|
cbf60fc3d13bea443e0cac91b9449a62698dae9a
|
[] |
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
| 4,811
|
h
|
omron_disklabel.h
|
/* $NetBSD: omron_disklabel.h,v 1.4 2014/01/11 15:51:02 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
*
* This code is derived from software contributed to Berkeley by
* OMRON Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)omron_disklabel.h 8.1 (Berkeley) 6/10/93
*/
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* OMRON Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)omron_disklabel.h 8.1 (Berkeley) 6/10/93
*/
/* omron_dislabel.h from UniOS-B */
/* by A.Fujita, JAN-30-1992 */
#define DKL_MAGIC 0xDABE /* Disk label Magic number */
#define NLPART 8 /* # of logical partition */
struct scd_dk_label {
char dkl_asciilabel[128]; /* for compatibility */
char dkl_pad[512 - (128 + (8 * 8) + (11 * 2) + 4)];
uint16_t dkl_badchk; /* checksum of bad track */
uint32_t dkl_maxblk; /* # of total logical block */
uint16_t dkl_dtype; /* disk drive type */
uint16_t dkl_ndisk; /* # of disk drives */
uint16_t dkl_ncyl; /* # of data cylinders */
uint16_t dkl_acyl; /* # of alternate cylinders */
uint16_t dkl_nhead; /* # of heads in this partition */
uint16_t dkl_nsect; /* # of 512 byte sectors per track */
uint16_t dkl_bhead; /* identifies proper label locations */
uint16_t dkl_ppart; /* physical partition # */
struct dk_map { /* logical partitions */
int32_t dkl_blkno; /* starting block */
int32_t dkl_nblk; /* number of blocks */
} dkl_map[NLPART];
uint16_t dkl_magic; /* identifies this label format */
uint16_t dkl_cksum; /* xor checksum of sector */
};
|
5f5024379a865e73b0ee03f12a11b78072b33303
|
4b15f318ba3332ee946cb0b2838c93e7935b9b89
|
/src/promotion/ops.h
|
41f0593a3abf1af7d57adf207bb57e6b2f133c0a
|
[
"BSD-3-Clause"
] |
permissive
|
Open-CAS/ocf
|
c4f8a5c9c1b254a905fda75be2c19bd7c8ebd450
|
016d7a8ee2822d672c308264e79bae4081e7930e
|
refs/heads/master
| 2023-05-28T08:40:51.328181
| 2023-05-11T08:11:57
| 2023-05-11T08:11:57
| 152,160,836
| 168
| 94
|
BSD-3-Clause
| 2023-09-14T08:01:50
| 2018-10-08T23:46:10
|
C
|
UTF-8
|
C
| false
| false
| 1,413
|
h
|
ops.h
|
/*
* Copyright(c) 2019-2021 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PROMOTION_OPS_H_
#define PROMOTION_OPS_H_
#include "../metadata/metadata.h"
#include "promotion.h"
struct ocf_promotion_policy {
ocf_cache_t owner;
ocf_promotion_t type;
void *config;
/* Pointer to config values stored in cache superblock */
void *ctx;
};
struct promotion_policy_ops {
const char *name;
/*!< Promotion policy name */
void (*setup)(ocf_cache_t cache);
/*!< initialize promotion policy default config */
ocf_error_t (*init)(ocf_cache_t cache);
/*!< Allocate and initialize promotion policy */
void (*deinit)(ocf_promotion_policy_t policy);
/*!< Deinit and free promotion policy */
ocf_error_t (*set_param)(ocf_cache_t cache, uint8_t param_id,
uint32_t param_value);
/*!< Set promotion policy parameter */
ocf_error_t (*get_param)(ocf_cache_t cache, uint8_t param_id,
uint32_t *param_value);
/*!< Get promotion policy parameter */
void (*req_purge)(ocf_promotion_policy_t policy,
struct ocf_request *req);
/*!< Call when request core lines have been inserted or it is
* a discard request */
bool (*req_should_promote)(ocf_promotion_policy_t policy,
struct ocf_request *req);
/*!< Should request lines be inserted into cache */
};
extern struct promotion_policy_ops ocf_promotion_policies[ocf_promotion_max];
#endif /* PROMOTION_OPS_H_ */
|
680dad3a422b9ec535a2b3373cb361ca15ded650
|
31f5cddb9885fc03b5c05fba5f9727b2f775cf47
|
/thirdparty/google/cpuinfo/src/arm/linux/hwcap.c
|
35e9994f6939e3800dba4151e35bda7ff8358fad
|
[
"MIT"
] |
permissive
|
timi-liuliang/echo
|
2935a34b80b598eeb2c2039d686a15d42907d6f7
|
d6e40d83c86431a819c6ef4ebb0f930c1b4d0f24
|
refs/heads/master
| 2023-08-17T05:35:08.104918
| 2023-08-11T18:10:35
| 2023-08-11T18:10:35
| 124,620,874
| 822
| 102
|
MIT
| 2021-06-11T14:29:03
| 2018-03-10T04:07:35
|
C++
|
UTF-8
|
C
| false
| false
| 3,709
|
c
|
hwcap.c
|
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <dlfcn.h>
#include <elf.h>
#if CPUINFO_MOCK
#include <cpuinfo-mock.h>
#endif
#include <cpuinfo.h>
#include <arm/linux/api.h>
#include <cpuinfo/log.h>
#if CPUINFO_ARCH_ARM64 || CPUINFO_ARCH_ARM && !defined(__ANDROID__)
#include <sys/auxv.h>
#else
#define AT_HWCAP 16
#define AT_HWCAP2 26
#endif
#if CPUINFO_MOCK
static uint32_t mock_hwcap = 0;
void cpuinfo_set_hwcap(uint32_t hwcap) {
mock_hwcap = hwcap;
}
static uint32_t mock_hwcap2 = 0;
void cpuinfo_set_hwcap2(uint32_t hwcap2) {
mock_hwcap2 = hwcap2;
}
#endif
#if CPUINFO_ARCH_ARM
typedef unsigned long (*getauxval_function_t)(unsigned long);
bool cpuinfo_arm_linux_hwcap_from_getauxval(
uint32_t hwcap[restrict static 1],
uint32_t hwcap2[restrict static 1])
{
#if CPUINFO_MOCK
*hwcap = mock_hwcap;
*hwcap2 = mock_hwcap2;
return true;
#elif defined(__ANDROID__)
/* Android: dynamically check if getauxval is supported */
void* libc = NULL;
getauxval_function_t getauxval = NULL;
dlerror();
libc = dlopen("libc.so", RTLD_LAZY);
if (libc == NULL) {
cpuinfo_log_warning("failed to load libc.so: %s", dlerror());
goto cleanup;
}
getauxval = (getauxval_function_t) dlsym(libc, "getauxval");
if (getauxval == NULL) {
cpuinfo_log_info("failed to locate getauxval in libc.so: %s", dlerror());
goto cleanup;
}
*hwcap = getauxval(AT_HWCAP);
*hwcap2 = getauxval(AT_HWCAP2);
cleanup:
if (libc != NULL) {
dlclose(libc);
libc = NULL;
}
return getauxval != NULL;
#else
/* GNU/Linux: getauxval is always supported */
*hwcap = getauxval(AT_HWCAP);
*hwcap2 = getauxval(AT_HWCAP2);
return true;
#endif
}
#ifdef __ANDROID__
bool cpuinfo_arm_linux_hwcap_from_procfs(
uint32_t hwcap[restrict static 1],
uint32_t hwcap2[restrict static 1])
{
#if CPUINFO_MOCK
*hwcap = mock_hwcap;
*hwcap2 = mock_hwcap2;
return true;
#else
uint32_t hwcaps[2] = { 0, 0 };
bool result = false;
int file = -1;
file = open("/proc/self/auxv", O_RDONLY);
if (file == -1) {
cpuinfo_log_warning("failed to open /proc/self/auxv: %s", strerror(errno));
goto cleanup;
}
ssize_t bytes_read;
do {
Elf32_auxv_t elf_auxv;
bytes_read = read(file, &elf_auxv, sizeof(Elf32_auxv_t));
if (bytes_read < 0) {
cpuinfo_log_warning("failed to read /proc/self/auxv: %s", strerror(errno));
goto cleanup;
} else if (bytes_read > 0) {
if (bytes_read == sizeof(elf_auxv)) {
switch (elf_auxv.a_type) {
case AT_HWCAP:
hwcaps[0] = (uint32_t) elf_auxv.a_un.a_val;
break;
case AT_HWCAP2:
hwcaps[1] = (uint32_t) elf_auxv.a_un.a_val;
break;
}
} else {
cpuinfo_log_warning(
"failed to read %zu bytes from /proc/self/auxv: %zu bytes available",
sizeof(elf_auxv), (size_t) bytes_read);
goto cleanup;
}
}
} while (bytes_read == sizeof(Elf32_auxv_t));
/* Success, commit results */
*hwcap = hwcaps[0];
*hwcap2 = hwcaps[1];
result = true;
cleanup:
if (file != -1) {
close(file);
file = -1;
}
return result;
#endif
}
#endif /* __ANDROID__ */
#elif CPUINFO_ARCH_ARM64
void cpuinfo_arm_linux_hwcap_from_getauxval(
uint32_t hwcap[restrict static 1],
uint32_t hwcap2[restrict static 1])
{
#if CPUINFO_MOCK
*hwcap = mock_hwcap;
*hwcap2 = mock_hwcap2;
#else
*hwcap = (uint32_t) getauxval(AT_HWCAP);
*hwcap2 = (uint32_t) getauxval(AT_HWCAP2);
return ;
#endif
}
#endif
|
731684dfa0c61552b1e733c1a6c670ec7c5aca53
|
38fff7bdefd8d62a740d51329b50d0e1e49258bb
|
/projects/pidgin/pidgin_xml_fuzzer.c
|
a91034a5e157cae497d1d0ae18eb7f8765cb4485
|
[
"Apache-2.0"
] |
permissive
|
google/oss-fuzz
|
026384c2ada61ef68b147548e830f60730c5e738
|
f0275421f84b8f80ee767fb9230134ac97cb687b
|
refs/heads/master
| 2023-08-31T23:30:28.157702
| 2023-08-31T21:49:30
| 2023-08-31T21:49:30
| 63,809,205
| 9,438
| 2,315
|
Apache-2.0
| 2023-09-14T20:32:19
| 2016-07-20T19:39:50
|
Shell
|
UTF-8
|
C
| false
| false
| 1,607
|
c
|
pidgin_xml_fuzzer.c
|
/*
# Copyright 2021 Google LLC
#
# 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 <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "xmlnode.h"
#include "caps.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
char *malicious_xml = (char *)malloc(size + 1);
if (malicious_xml == NULL) {
return 0;
}
memcpy(malicious_xml, data, size);
malicious_xml[size] = '\0';
xmlnode *isc = xmlnode_from_str(malicious_xml, size+1);
if (isc != NULL) {
xmlnode_set_attrib(isc, "name", "query");
// Parse Jabber caps
JabberCapsClientInfo *info = jabber_caps_parse_client_info(isc);
gchar *got_hash = jabber_caps_calculate_hash(info, ("sha1"));
// Insert a child
xmlnode *child = xmlnode_new_child(isc, "query");
xmlnode_insert_child(isc, child);
// Get data
char *retrieved_data = xmlnode_get_data(isc);
char *retrieved_data_unescaped = xmlnode_get_data_unescaped(isc);
xmlnode_free(isc);
}
free(malicious_xml);
return 0;
}
|
2efbf86637ccab2557f8a5a35b8d25b774ee95c3
|
b9dc55919b29da24c24f8ee367c5618c9532f56f
|
/Code_source/shared/aubio/src/notes/notes.h
|
e93a68515ee04436b2550a2d716c49c5ff0c5f57
|
[
"WTFPL",
"LicenseRef-scancode-unknown-license-reference",
"GPL-3.0-only"
] |
permissive
|
porres/pd-else
|
075e8b7ac7a78f442055fbd30d6602cae49c887e
|
b30e8c13c88bb9752c08f78514d64c6206d6678b
|
refs/heads/master
| 2023-08-18T22:26:31.120893
| 2023-08-18T00:46:59
| 2023-08-18T00:46:59
| 56,870,805
| 238
| 42
|
WTFPL
| 2023-09-12T15:55:56
| 2016-04-22T16:45:29
|
C
|
UTF-8
|
C
| false
| false
| 4,006
|
h
|
notes.h
|
/*
Copyright (C) 2003-2014 Paul Brossier <[email protected]>
This file is part of aubio.
aubio is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
aubio 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 aubio. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
Note detection object
*/
#include <stdio.h>
#ifndef _AUBIO_NOTES_H
#define _AUBIO_NOTES_H
#ifdef __cplusplus
extern "C" {
#endif
/** notes detection object */
typedef struct _aubio_notes_t aubio_notes_t;
/** create notes detection object
\param method notes detection type as specified in specdesc.h
\param buf_size buffer size for phase vocoder
\param hop_size hop size for phase vocoder
\param samplerate sampling rate of the input signal
\return newly created ::aubio_notes_t
*/
aubio_notes_t * new_aubio_notes (const char_t * method,
uint_t buf_size, uint_t hop_size, uint_t samplerate);
/** delete notes detection object
\param o notes detection object to delete
*/
void del_aubio_notes(aubio_notes_t * o);
/** execute note detection on an input signal frame
\param o note detection object as returned by new_aubio_notes()
\param input input signal of size [hop_size]
\param output output notes, fvec of length 3
The notes output is a vector of length 3 containing:
- 0. the midi note value, or 0 if no note was found
- 1. the note velocity
- 2. the midi note to turn off
*/
void aubio_notes_do (aubio_notes_t *o, const fvec_t * input, fvec_t * output);
/** set notes detection silence threshold
\param o notes detection object as returned by new_aubio_notes()
\param silence new silence detection threshold
\return 0 on success, non-zero otherwise
*/
uint_t aubio_notes_set_silence(aubio_notes_t * o, smpl_t silence);
/** get notes detection silence threshold
\param o notes detection object as returned by new_aubio_notes()
\return current silence threshold
*/
smpl_t aubio_notes_get_silence(const aubio_notes_t * o);
/** get notes detection minimum inter-onset interval, in millisecond
\param o notes detection object as returned by new_aubio_notes()
\return current minimum inter onset interval
*/
smpl_t aubio_notes_get_minioi_ms(const aubio_notes_t *o);
/** set notes detection minimum inter-onset interval, in millisecond
\param o notes detection object as returned by new_aubio_notes()
\param minioi_ms new inter-onset interval
\return 0 on success, non-zero otherwise
*/
uint_t aubio_notes_set_minioi_ms (aubio_notes_t *o, smpl_t minioi_ms);
/** get notes object release drop level, in dB
\param o notes detection object as returned by new_aubio_notes()
\return current release drop level, in dB
*/
smpl_t aubio_notes_get_release_drop (const aubio_notes_t *o);
/** set note release drop level, in dB
This function sets the release_drop_level parameter, in dB. When a new note
is found, the current level in dB is measured. If the measured level drops
under that initial level - release_drop_level, then a note-off will be
emitted.
Defaults to `10`, in dB.
\note This parameter was added in version `0.4.8`. Results obtained with
earlier versions can be reproduced by setting this value to `100`, so that
note-off will not be played until the next note.
\param o notes detection object as returned by new_aubio_notes()
\param release_drop new release drop level, in dB
\return 0 on success, non-zero otherwise
*/
uint_t aubio_notes_set_release_drop (aubio_notes_t *o, smpl_t release_drop);
#ifdef __cplusplus
}
#endif
#endif /* _AUBIO_NOTES_H */
|
2d716002b875ab5c9823bd131c991f8ed2465e7e
|
41eb0837713f297134529591b66f3d4d82bcf98e
|
/src/Raine/source/sound/smp16bit.h
|
6edafa97deceb400cfc3412d6d8e4e098c7dc85e
|
[] |
no_license
|
AlexxandreFS/Batocera.PLUS
|
27b196b3cbb781b6fc99e62cad855396d1d5f8f2
|
997ee763ae7135fdf0c34a081e789918bd2eb169
|
refs/heads/master
| 2023-08-17T21:52:39.083687
| 2023-08-17T15:03:44
| 2023-08-17T15:03:44
| 215,869,486
| 135
| 57
| null | 2023-08-14T14:46:14
| 2019-10-17T19:23:42
|
C
|
UTF-8
|
C
| false
| false
| 1,827
|
h
|
smp16bit.h
|
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************/
/* */
/* 16-BIT SAMPLE PLAYBACK (odd samples - nichibutsu dac, cabal adpcm) */
/* */
/******************************************************************************/
#ifndef __SMP16_H__
#define __SMP16_H__
void decode_sample_adpcm(UINT8 *src, UINT32 size, INT16 *dest, int volume);
void decode_sample_8bit(UINT8 *src, UINT32 size, INT16 *dest, int volume);
#define SMP16BF_MAX (2)
#define SMP16BF_CHANNEL (1)
#define SMP16BF_NUMBUF (1)
typedef struct SMP16_ROM
{
UINT8 *data; // pointer to rom
UINT32 size; // size of rom
UINT32 type; // 0 - adpcm
} SMP16_ROM;
struct SMP16buffer_interface
{
int num; // number of chips
int sample_rate[SMP16BF_MAX]; // rate for each chip
SMP16_ROM *rom[SMP16BF_MAX]; // list of roms
};
typedef struct SMP16_SAMPLE
{
UINT32 len; // length (in samples?)
INT16 *data; // sample data (16 bit?)
} SMP16_SAMPLE;
typedef struct SMP16rec
{
int rate; // rate
int command;
unsigned int offset, req_len;
signed short *req_buf;
unsigned int add;
UINT32 samples; // sample count
SMP16_SAMPLE *sample_decode; // decoded info
} SMP16Rec;
int SMP16buffer_sh_start( struct SMP16buffer_interface *interface );
void SMP16buffer_sh_stop( void );
void SMP16buffer_request( int num, int code );
int SMP16buffer_status( int num );
void SMP16buffer_UpdateOne( int num, INT16 *sp, int length );
#endif
/******************************************************************************/
#ifdef __cplusplus
}
#endif
|
9d837918affe89e44cba85a97b54977de2ce8700
|
83b8b30ebb633eecd29ca0a7a20cc43a293c9333
|
/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h
|
47220bb474809230d897de5fb79d35d4ff4c5db5
|
[
"MIT",
"GPL-1.0-or-later"
] |
permissive
|
adafruit/circuitpython
|
430ec895149d1eb814b505db39b4977a35ee88a7
|
506dca71b0cbb7af749bb51f86b01021db5483b3
|
refs/heads/main
| 2023-08-21T16:30:46.781068
| 2023-08-20T00:39:44
| 2023-08-20T00:39:44
| 66,166,069
| 3,806
| 1,560
|
MIT
| 2023-09-14T19:23:51
| 2016-08-20T20:10:40
|
C
|
UTF-8
|
C
| false
| false
| 1,405
|
h
|
mpconfigboard.h
|
#include "nrfx/hal/nrf_gpio.h"
#define MICROPY_HW_BOARD_NAME "Adafruit ItsyBitsy nRF52840 Express"
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_HW_LED_STATUS (&pin_P0_06)
#define MICROPY_HW_APA102_MOSI (&pin_P0_08)
#define MICROPY_HW_APA102_SCK (&pin_P1_09)
#if QSPI_FLASH_FILESYSTEM
#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 21)
#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22)
#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 00)
#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 17)
#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19)
#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 23)
#endif
#if SPI_FLASH_FILESYSTEM
#define SPI_FLASH_MOSI_PIN &pin_P0_21
#define SPI_FLASH_MISO_PIN &pin_P0_22
#define SPI_FLASH_SCK_PIN &pin_P0_19
#define SPI_FLASH_CS_PIN &pin_P0_23
#endif
#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
#define BOARD_HAS_CRYSTAL 1
#define DEFAULT_I2C_BUS_SCL (&pin_P0_14)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_16)
#define DEFAULT_SPI_BUS_SCK (&pin_P0_13)
#define DEFAULT_SPI_BUS_MOSI (&pin_P0_15)
#define DEFAULT_SPI_BUS_MISO (&pin_P0_20)
#define DEFAULT_UART_BUS_RX (&pin_P0_25)
#define DEFAULT_UART_BUS_TX (&pin_P0_24)
|
d6ac46a32b13503a1d725340303c41957ed2e657
|
bec5d52c5185d032b2b81eccd008aa8e4e045790
|
/tuntap/tapwin32-funcs.c
|
bd0f7dc1763da545213336c20f916fa35c26b2da
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
shadowsocks/badvpn
|
2993b0da7c59870f0a550a842cabe3312761d541
|
40a0e5010aa4adb6d3ca1d1418dfde345c50107d
|
refs/heads/shadowsocks-android
| 2021-12-08T06:17:04.546977
| 2021-08-23T04:05:27
| 2021-08-23T04:05:27
| 45,686,048
| 166
| 154
|
NOASSERTION
| 2021-08-23T04:05:28
| 2015-11-06T14:18:20
|
C
|
UTF-8
|
C
| false
| false
| 7,255
|
c
|
tapwin32-funcs.c
|
/**
* @file tapwin32-funcs.c
* @author Ambroz Bizjak <[email protected]>
*
* @section LICENSE
*
* 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 author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <misc/debug.h>
#include <misc/ipaddr.h>
#include <misc/maxalign.h>
#include <misc/strdup.h>
#include "wintap-common.h"
#include <tuntap/tapwin32-funcs.h>
static int split_spec (char *name, char *sep, char **out_fields[], int num_fields)
{
ASSERT(num_fields > 0)
ASSERT(strlen(sep) > 0)
size_t seplen = strlen(sep);
int i = 0;
while (i < num_fields - 1) {
char *s = strstr(name, sep);
if (!s) {
DEBUG("missing separator number %d", (i + 1));
goto fail;
}
if (!(*out_fields[i] = b_strdup_bin(name, s - name))) {
DEBUG("b_strdup_bin failed");
goto fail;
}
name = s + seplen;
i++;
}
if (!(*out_fields[i] = b_strdup(name))) {
DEBUG("b_strdup_bin failed");
goto fail;
}
return 1;
fail:
while (i-- > 0) {
free(*out_fields[i]);
}
return 0;
}
int tapwin32_parse_tap_spec (char *name, char **out_component_id, char **out_human_name)
{
char **out_fields[2];
out_fields[0] = out_component_id;
out_fields[1] = out_human_name;
return split_spec(name, ":", out_fields, 2);
}
int tapwin32_parse_tun_spec (char *name, char **out_component_id, char **out_human_name, uint32_t out_addrs[3])
{
char *addr_strs[3];
char **out_fields[5];
out_fields[0] = out_component_id;
out_fields[1] = out_human_name;
out_fields[2] = &addr_strs[0];
out_fields[3] = &addr_strs[1];
out_fields[4] = &addr_strs[2];
if (!split_spec(name, ":", out_fields, 5)) {
goto fail0;
}
for (int i = 0; i < 3; i++) {
if (!ipaddr_parse_ipv4_addr(MemRef_MakeCstr(addr_strs[i]), &out_addrs[i])) {
goto fail1;
}
}
free(addr_strs[0]);
free(addr_strs[1]);
free(addr_strs[2]);
return 1;
fail1:
free(*out_component_id);
free(*out_human_name);
free(addr_strs[0]);
free(addr_strs[1]);
free(addr_strs[2]);
fail0:
return 0;
}
int tapwin32_find_device (char *device_component_id, char *device_name, char (*device_path)[TAPWIN32_MAX_REG_SIZE])
{
// open adapter key
// used to find all devices with the given ComponentId
HKEY adapter_key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &adapter_key) != ERROR_SUCCESS) {
DEBUG("Error opening adapter key");
return 0;
}
char net_cfg_instance_id[TAPWIN32_MAX_REG_SIZE];
int found = 0;
int pres;
DWORD i;
for (i = 0;; i++) {
DWORD len;
DWORD type;
char key_name[TAPWIN32_MAX_REG_SIZE];
len = sizeof(key_name);
if (RegEnumKeyEx(adapter_key, i, key_name, &len, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
break;
}
char unit_string[TAPWIN32_MAX_REG_SIZE];
pres = _snprintf(unit_string, sizeof(unit_string), "%s\\%s", ADAPTER_KEY, key_name);
if (pres < 0 || pres == sizeof(unit_string)) {
continue;
}
HKEY unit_key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, unit_string, 0, KEY_READ, &unit_key) != ERROR_SUCCESS) {
continue;
}
char component_id[TAPWIN32_MAX_REG_SIZE];
len = sizeof(component_id);
if (RegQueryValueEx(unit_key, "ComponentId", NULL, &type, (LPBYTE)component_id, &len) != ERROR_SUCCESS || type != REG_SZ) {
ASSERT_FORCE(RegCloseKey(unit_key) == ERROR_SUCCESS)
continue;
}
len = sizeof(net_cfg_instance_id);
if (RegQueryValueEx(unit_key, "NetCfgInstanceId", NULL, &type, (LPBYTE)net_cfg_instance_id, &len) != ERROR_SUCCESS || type != REG_SZ) {
ASSERT_FORCE(RegCloseKey(unit_key) == ERROR_SUCCESS)
continue;
}
RegCloseKey(unit_key);
// check if ComponentId matches
if (!strcmp(component_id, device_component_id)) {
// if no name was given, use the first device with the given ComponentId
if (!device_name) {
found = 1;
break;
}
// open connection key
char conn_string[TAPWIN32_MAX_REG_SIZE];
pres = _snprintf(conn_string, sizeof(conn_string), "%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, net_cfg_instance_id);
if (pres < 0 || pres == sizeof(conn_string)) {
continue;
}
HKEY conn_key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, conn_string, 0, KEY_READ, &conn_key) != ERROR_SUCCESS) {
continue;
}
// read name
char name[TAPWIN32_MAX_REG_SIZE];
len = sizeof(name);
if (RegQueryValueEx(conn_key, "Name", NULL, &type, (LPBYTE)name, &len) != ERROR_SUCCESS || type != REG_SZ) {
ASSERT_FORCE(RegCloseKey(conn_key) == ERROR_SUCCESS)
continue;
}
ASSERT_FORCE(RegCloseKey(conn_key) == ERROR_SUCCESS)
// check name
if (!strcmp(name, device_name)) {
found = 1;
break;
}
}
}
ASSERT_FORCE(RegCloseKey(adapter_key) == ERROR_SUCCESS)
if (!found) {
return 0;
}
pres = _snprintf(*device_path, sizeof(*device_path), "\\\\.\\Global\\%s.tap", net_cfg_instance_id);
if (pres < 0 || pres == sizeof(*device_path)) {
return 0;
}
return 1;
}
|
e10d700f509fd6c93195a7441c8fbef604fe4af4
|
fbd6afa22568045d8806ecdda93144d1a6e44af2
|
/Src/Libs/Streaming/Enum.h
|
8b8ddf60f691ec34eefe890ac4b3a6c207cbdb66
|
[
"BSD-2-Clause"
] |
permissive
|
bhuman/BHumanCodeRelease
|
5ccbcc60b968c12f29983992d603ab464a51051b
|
645031c46ff88efcf32129301d21e109857cde3d
|
refs/heads/master
| 2023-05-22T09:49:04.827692
| 2023-03-29T15:27:24
| 2023-03-29T15:27:24
| 15,512,849
| 212
| 151
| null | 2018-04-12T12:36:26
| 2013-12-29T18:24:40
|
C++
|
UTF-8
|
C
| false
| false
| 84,368
|
h
|
Enum.h
|
/**
* @file Streaming/Enum.h
* Defines a macro that declares an enum and provides a function to access the names of its elements.
* Also defines a macro that allows to enumerate over all these elements.
*
* Enums have the following form:
* ENUM(<enum-name>,
* {,
* <comma-separated-enum-list>,
* })
*
* Example:
* ENUM(Fruit,
* {,
* apple,
* banana,
* strawberry,
* });
*
* @author Thomas Röfer
* @author Alexis Tsogias
* @author <a href="mailto:[email protected]">Jesse Richter-Klug</a>
*/
#pragma once
#include "Streaming/AutoStreamable.h"
/**
* Concatenate the two parameters.
*/
#define _ENUM_JOIN(a, b) _ENUM_JOIN_I(a, b)
#define _ENUM_JOIN_I(a, b) _ENUM_JOIN_II(a ## b)
#define _ENUM_JOIN_II(res) res
/**
* Determine the number of entries in a tuple.
*/
#define _ENUM_TUPLE_SIZE(...) _ENUM_TUPLE_SIZE_I((__VA_ARGS__, _ENUM_TUPLE_SIZE_III))
#define _ENUM_TUPLE_SIZE_I(params) _ENUM_TUPLE_SIZE_II params
#define _ENUM_TUPLE_SIZE_II( \
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, \
a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, \
a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, \
a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, \
a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, \
a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, \
a121, a122, a123, a124, a125,...) a125
#define _ENUM_TUPLE_SIZE_III \
125, 124, 123, 122, 121, \
120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, \
100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, \
79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, \
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
#define _ENUM_REMOVELAST_1(a1)
#define _ENUM_REMOVELAST_2(a1, a2) a1
#define _ENUM_REMOVELAST_3(a1, a2, a3) a1, a2
#define _ENUM_REMOVELAST_4(a1, a2, a3, a4) a1, a2, a3
#define _ENUM_REMOVELAST_5(a1, a2, a3, a4, a5) a1, a2, a3, a4
#define _ENUM_REMOVELAST_6(a1, a2, a3, a4, a5, a6) a1, a2, a3, a4, a5
#define _ENUM_REMOVELAST_7(a1, a2, a3, a4, a5, a6, a7) a1, a2, a3, a4, a5, a6
#define _ENUM_REMOVELAST_8(a1, a2, a3, a4, a5, a6, a7, a8) a1, a2, a3, a4, a5, a6, a7
#define _ENUM_REMOVELAST_9(a1, a2, a3, a4, a5, a6, a7, a8, a9) a1, a2, a3, a4, a5, a6, a7, a8
#define _ENUM_REMOVELAST_10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) a1, a2, a3, a4, a5, a6, a7, a8, a9
#define _ENUM_REMOVELAST_11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
#define _ENUM_REMOVELAST_12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11
#define _ENUM_REMOVELAST_13(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12
#define _ENUM_REMOVELAST_14(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13
#define _ENUM_REMOVELAST_15(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14
#define _ENUM_REMOVELAST_16(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15
#define _ENUM_REMOVELAST_17(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16
#define _ENUM_REMOVELAST_18(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17
#define _ENUM_REMOVELAST_19(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18
#define _ENUM_REMOVELAST_20(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19
#define _ENUM_REMOVELAST_21(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20
#define _ENUM_REMOVELAST_22(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21
#define _ENUM_REMOVELAST_23(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22
#define _ENUM_REMOVELAST_24(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23
#define _ENUM_REMOVELAST_25(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24
#define _ENUM_REMOVELAST_26(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25
#define _ENUM_REMOVELAST_27(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26
#define _ENUM_REMOVELAST_28(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27
#define _ENUM_REMOVELAST_29(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28
#define _ENUM_REMOVELAST_30(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29
#define _ENUM_REMOVELAST_31(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30
#define _ENUM_REMOVELAST_32(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31
#define _ENUM_REMOVELAST_33(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32
#define _ENUM_REMOVELAST_34(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33
#define _ENUM_REMOVELAST_35(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34
#define _ENUM_REMOVELAST_36(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35
#define _ENUM_REMOVELAST_37(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36
#define _ENUM_REMOVELAST_38(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37
#define _ENUM_REMOVELAST_39(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38
#define _ENUM_REMOVELAST_40(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39
#define _ENUM_REMOVELAST_41(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40
#define _ENUM_REMOVELAST_42(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41
#define _ENUM_REMOVELAST_43(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42
#define _ENUM_REMOVELAST_44(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43
#define _ENUM_REMOVELAST_45(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44
#define _ENUM_REMOVELAST_46(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45
#define _ENUM_REMOVELAST_47(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46
#define _ENUM_REMOVELAST_48(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47
#define _ENUM_REMOVELAST_49(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48
#define _ENUM_REMOVELAST_50(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49
#define _ENUM_REMOVELAST_51(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50
#define _ENUM_REMOVELAST_52(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51
#define _ENUM_REMOVELAST_53(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52
#define _ENUM_REMOVELAST_54(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53
#define _ENUM_REMOVELAST_55(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54
#define _ENUM_REMOVELAST_56(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55
#define _ENUM_REMOVELAST_57(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56
#define _ENUM_REMOVELAST_58(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57
#define _ENUM_REMOVELAST_59(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58
#define _ENUM_REMOVELAST_60(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59
#define _ENUM_REMOVELAST_61(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60
#define _ENUM_REMOVELAST_62(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61
#define _ENUM_REMOVELAST_63(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62
#define _ENUM_REMOVELAST_64(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63
#define _ENUM_REMOVELAST_65(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64
#define _ENUM_REMOVELAST_66(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65
#define _ENUM_REMOVELAST_67(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66
#define _ENUM_REMOVELAST_68(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67
#define _ENUM_REMOVELAST_69(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68
#define _ENUM_REMOVELAST_70(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69
#define _ENUM_REMOVELAST_71(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70
#define _ENUM_REMOVELAST_72(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71
#define _ENUM_REMOVELAST_73(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72
#define _ENUM_REMOVELAST_74(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73
#define _ENUM_REMOVELAST_75(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74
#define _ENUM_REMOVELAST_76(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75
#define _ENUM_REMOVELAST_77(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76
#define _ENUM_REMOVELAST_78(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77
#define _ENUM_REMOVELAST_79(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78
#define _ENUM_REMOVELAST_80(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79
#define _ENUM_REMOVELAST_81(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80
#define _ENUM_REMOVELAST_82(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81
#define _ENUM_REMOVELAST_83(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82
#define _ENUM_REMOVELAST_84(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83
#define _ENUM_REMOVELAST_85(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84
#define _ENUM_REMOVELAST_86(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85
#define _ENUM_REMOVELAST_87(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86
#define _ENUM_REMOVELAST_88(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87
#define _ENUM_REMOVELAST_89(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88
#define _ENUM_REMOVELAST_90(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89
#define _ENUM_REMOVELAST_91(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90
#define _ENUM_REMOVELAST_92(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91
#define _ENUM_REMOVELAST_93(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92
#define _ENUM_REMOVELAST_94(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93
#define _ENUM_REMOVELAST_95(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94
#define _ENUM_REMOVELAST_96(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95
#define _ENUM_REMOVELAST_97(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96
#define _ENUM_REMOVELAST_98(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97
#define _ENUM_REMOVELAST_99(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98
#define _ENUM_REMOVELAST_100(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99
#define _ENUM_REMOVELAST_101(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100
#define _ENUM_REMOVELAST_102(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101
#define _ENUM_REMOVELAST_103(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102
#define _ENUM_REMOVELAST_104(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103
#define _ENUM_REMOVELAST_105(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104
#define _ENUM_REMOVELAST_106(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105
#define _ENUM_REMOVELAST_107(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106
#define _ENUM_REMOVELAST_108(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107
#define _ENUM_REMOVELAST_109(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108
#define _ENUM_REMOVELAST_110(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109
#define _ENUM_REMOVELAST_111(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110
#define _ENUM_REMOVELAST_112(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111
#define _ENUM_REMOVELAST_113(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112
#define _ENUM_REMOVELAST_114(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113
#define _ENUM_REMOVELAST_115(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114
#define _ENUM_REMOVELAST_116(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115
#define _ENUM_REMOVELAST_117(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116
#define _ENUM_REMOVELAST_118(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117
#define _ENUM_REMOVELAST_119(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118
#define _ENUM_REMOVELAST_120(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119
#define _ENUM_REMOVELAST_121(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120
#define _ENUM_REMOVELAST_122(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121, a122) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121
#define _ENUM_REMOVELAST_123(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121, a122, a123) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121, a122
#define _ENUM_REMOVELAST_124(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121, a122, a123, a124) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121, a122, a123
#define _ENUM_REMOVELAST_125(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121, a122, a123, a124, a125) a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, a120, a121, a122, a123, a124
/**
* Registers a single enumeration constant.
* @param constant The enumeration constant.
*/
#define _ENUM_REG(constant) REG_CONSTANT(constant);
/**
* Defining an enum and a function getName(<Enum>) that can return
* the name of each enum element. The enum will automatically
* contain an element numOf<Enum>s that reflects the number of
* elements defined.
*
* WARNING: Assigning values to enum-elements is not allowed with these enums
* since they are designed for streaming and the type registry expects them to
* have no assignments. The only exception is the assignment of a previous
* enum-element.
* Example:
*
* ENUM(Fruit,
* {,
* strawberry,
* blueberry,
* numOfBerries,
* apple = numOfBerries,
* banana,
* });
*/
#define ENUM(Enum, bracket, ...) _ENUM(_ENUM_TUPLE_SIZE(__VA_ARGS__), Enum, __VA_ARGS__)
#define _ENUM(n, Enum, ...) _ENUM_I(n, Enum, (_ENUM_REMOVELAST_, n), __VA_ARGS__)
#define _ENUM_I(n, Enum, param , ...) _ENUM_II(n, Enum, (_ENUM_REG, __VA_ARGS__), _ENUM_JOIN param (__VA_ARGS__))
#define _ENUM_II(n, Enum, param, ...) \
enum Enum : unsigned char \
{ \
__VA_ARGS__, \
numOf##Enum##s \
}; \
struct Enum##_Info \
{ \
static constexpr Enum numOfElements = numOf##Enum##s; \
static void reg() \
{ \
PUBLISH(reg); \
REG_ENUM(Enum); \
_STREAM_ATTR_##n param \
} \
}
/**
* FOREACH_ENUM(enum, var [ , limit ])
* @param enum The enum type.
* @param var The variable which holds the current enum value inside the loop.
* @param limit Exclusive upper bound of the loop. If not specified, all enum
* constants are enumerated.
*/
#define FOREACH_ENUM(enum, ...) _FOREACH_ENUM_I(enum, _ENUM_TUPLE_SIZE(__VA_ARGS__), __VA_ARGS__)
#define _FOREACH_ENUM_I(enum, n, ...) _FOREACH_ENUM_II((_FOREACH_ENUM_, n), enum, __VA_ARGS__)
#define _FOREACH_ENUM_II(param, ...) _ENUM_JOIN param (__VA_ARGS__)
#define _FOREACH_ENUM_1(enum, var) _FOREACH_ENUM_2(enum, var, enum##_Info::numOfElements)
#define _FOREACH_ENUM_2(enum, var, limit) for(auto var = enum(0); var < limit; var = enum(unsigned(var) + 1))
|
b5a09417697b4fa76cc55b79280e0d8d60d2046e
|
89db60818afeb3dc7c3b7abe9ceae155f074f7f2
|
/src/libmemdraw/draw-stub.c
|
be411011f536aa4922d07653b7502c4217610b73
|
[
"bzip2-1.0.6",
"LPL-1.02",
"MIT"
] |
permissive
|
9fans/plan9port
|
63c3d01928c6f8a8617d3ea6ecc05bac72391132
|
65c090346a38a8c30cb242d345aa71060116340c
|
refs/heads/master
| 2023-08-25T17:14:26.233105
| 2023-08-23T13:21:37
| 2023-08-23T18:47:08
| 26,095,474
| 1,645
| 468
|
NOASSERTION
| 2023-09-05T16:55:41
| 2014-11-02T22:40:13
|
C
|
UTF-8
|
C
| false
| false
| 446
|
c
|
draw-stub.c
|
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <memdraw.h>
void
memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp, Memimage *mask, Point mp, int op)
{
Memdrawparam *par;
if((par = _memimagedrawsetup(dst, r, src, sp, mask, mp, op)) == nil)
return;
_memimagedraw(par);
}
void
memfillcolor(Memimage *m, u32int val)
{
_memfillcolor(m, val);
}
u32int
pixelbits(Memimage *m, Point p)
{
return _pixelbits(m, p);
}
|
c0575b676dde2e147d9282d9415e62518b8cac12
|
4edd539e79d33f7a08a4c928d113771e9dac0740
|
/lib/burger/longtoasc.c
|
6062d5960e42ffc216e2ec278506f48eb9290605
|
[
"MIT"
] |
permissive
|
Olde-Skuul/doom3do
|
84ae4f312e919d070dcb838f7765c5c1ad3f5efd
|
8a5cdae476e09f2bedd2cc4dcd105dae4b35d4af
|
refs/heads/master
| 2023-03-07T19:10:13.752129
| 2023-01-11T22:54:07
| 2023-01-11T22:54:07
| 27,351,671
| 658
| 55
|
MIT
| 2022-11-03T04:07:37
| 2014-11-30T22:02:07
|
C
|
UTF-8
|
C
| false
| false
| 314
|
c
|
longtoasc.c
|
#include "Burger.h"
/****************************************
Converts a signed long number into an ASCII string
****************************************/
void longToAscii(long Input,Byte *AsciiPtr)
{
if (Input<0) {
Input = -Input;
AsciiPtr[0] = '-';
++AsciiPtr;
}
LongWordToAscii(Input,AsciiPtr);
}
|
e4e485e85a3761582947933d656caa7f8c33c131
|
2d11442aa09b51e10c245ee2b64231aeb051744f
|
/platforms/win32/plugins/DropPlugin/sqWin32Drop.c
|
355e3834517677c14cdcb79add3c8503d2b350e2
|
[
"MIT"
] |
permissive
|
OpenSmalltalk/opensmalltalk-vm
|
622b01c10017a93fdff4f1ef2188c45342384c78
|
330d6779ad2ecbce1f07131f53d75cd168165f0b
|
refs/heads/Cog
| 2023-09-04T05:36:54.320281
| 2023-08-17T11:32:52
| 2023-08-31T12:26:44
| 59,481,716
| 556
| 153
|
NOASSERTION
| 2023-06-19T19:58:13
| 2016-05-23T12:40:27
|
C
|
UTF-8
|
C
| false
| false
| 22,774
|
c
|
sqWin32Drop.c
|
/****************************************************************************
* PROJECT: Squeak port for Win32 (NT / Win95)
* FILE: sqWin32Drop.c
* CONTENT: Drag and Drop support from Windows
*
* AUTHOR: Andreas Raab (ar)
* ADDRESS: Walt Disney Imagineering, Glendale, CA
* EMAIL: [email protected]
*
*****************************************************************************/
#include <Windows.h>
#include <ole2.h>
#include "sq.h"
/* Import from VM */
extern struct VirtualMachine *interpreterProxy;
/* Import from generated plugin AioPlugin/AioPlugin.c or FilePlugin/FilePlugin.c or Win32OSProcessPlugin/Win32OSProcessPlugin.c
KNOWN LIMITATION: one and only one of these plugin should be internal... */
usqInt fileRecordSize(void);
void * fileValueOf(sqInt objectPointer);
/* Import from FilePlugin/sqWin32FilePrims.c */
sqInt sqFileOpen(void *f, char* fileNameIndex, sqInt fileNameSize, sqInt writeFlag);
/* Import from sqWin32Window.c */
extern HWND stWindow;
// There appears to be a Windows bug (in at least Windows 10) such that
// if a file is dropped from an Open File Dialog opened by the FileDialogPlugin
// then the GlobalFree below will corrupt the Windows heap. I know; no one
// should do this; but users can be capricious. We would rather risk a storage
// leak than have users deal with unexpected and hard to debug crashes.
extern int okToFreeSTGMEDIUMHGLOBAL = 1;
#if 0
#define DPRINTF(x) printf x
#else
#define DPRINTF(x)
#endif
/***************************************************************************/
/***************************************************************************/
/* File writing helpers */
/***************************************************************************/
/***************************************************************************/
#define BFT_BITMAP 0x4d42 /* 'BM' */
#define SIZEOF_BITMAPFILEHEADER_PACKED ( \
sizeof(WORD) + /* bfType */ \
sizeof(DWORD) + /* bfSize */ \
sizeof(WORD) + /* bfReserved1 */ \
sizeof(WORD) + /* bfReserved2 */ \
sizeof(DWORD)) /* bfOffBits */
/* Macro to determine to round off the given value to the closest byte */
#define WIDTHBYTES(i) ((i+31)/32*4)
WORD DibNumColors (VOID FAR * pv)
{
int bits;
LPBITMAPINFOHEADER lpbi;
LPBITMAPCOREHEADER lpbc;
lpbi = ((LPBITMAPINFOHEADER)pv);
lpbc = ((LPBITMAPCOREHEADER)pv);
if (lpbi->biSize != sizeof(BITMAPCOREHEADER)){
if (lpbi->biClrUsed != 0)
return (WORD)lpbi->biClrUsed;
bits = lpbi->biBitCount;
}
else
bits = lpbc->bcBitCount;
switch (bits) {
case 1: return 2;
case 4: return 16;
case 8: return 256;
default: return 0;
}
}
WORD PaletteSize (VOID FAR * pv)
{
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)pv;
WORD numColors = DibNumColors(lpbi);
if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
return numColors * sizeof(RGBTRIPLE);
else
return numColors * sizeof(RGBQUAD);
}
HANDLE DibFromBitmap (
HBITMAP hbm,
DWORD biStyle,
WORD biBits,
HPALETTE hpal)
{
BITMAP bm;
BITMAPINFOHEADER bi;
BITMAPINFOHEADER FAR *lpbi;
DWORD dwLen;
HANDLE hdib;
HANDLE h;
HDC hdc;
if (!hbm)
return NULL;
if (hpal == NULL)
hpal = GetStockObject(DEFAULT_PALETTE);
GetObject(hbm,sizeof(bm),(LPSTR)&bm);
if (biBits == 0) biBits = bm.bmPlanes * bm.bmBitsPixel;
if (biBits == 16) biBits = 24;
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bm.bmWidth;
bi.biHeight = bm.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = biBits;
bi.biCompression = biStyle;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
dwLen = bi.biSize + PaletteSize(&bi);
hdc = GetDC(NULL);
hpal = SelectPalette(hdc,hpal,FALSE);
RealizePalette(hdc);
hdib = GlobalAlloc(GHND,dwLen);
if (!hdib){
SelectPalette(hdc,hpal,FALSE);
ReleaseDC(NULL,hdc);
return NULL;
}
lpbi = (VOID FAR *)GlobalLock(hdib);
*lpbi = bi;
/* call GetDIBits with a NULL lpBits param, so it will calculate the
* biSizeImage field for us
*/
GetDIBits(hdc, hbm, 0L, (DWORD)bi.biHeight,
(LPBYTE)NULL, (LPBITMAPINFO)lpbi, (DWORD)DIB_RGB_COLORS);
bi = *lpbi;
GlobalUnlock(hdib);
/* If the driver did not fill in the biSizeImage field, make one up */
if (bi.biSizeImage == 0){
bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;
if (biStyle != BI_RGB)
bi.biSizeImage = (bi.biSizeImage * 3) / 2;
}
/* realloc the buffer big enough to hold all the bits */
dwLen = bi.biSize + PaletteSize(&bi) + bi.biSizeImage;
if (h = GlobalReAlloc(hdib,dwLen,0))
hdib = h;
else{
GlobalFree(hdib);
hdib = NULL;
SelectPalette(hdc,hpal,FALSE);
ReleaseDC(NULL,hdc);
return hdib;
}
/* call GetDIBits with a NON-NULL lpBits param, and actualy get the
* bits this time
*/
lpbi = (VOID FAR *)GlobalLock(hdib);
if (GetDIBits( hdc,
hbm,
0L,
(DWORD)bi.biHeight,
(LPBYTE)lpbi + (WORD)lpbi->biSize + PaletteSize(lpbi),
(LPBITMAPINFO)lpbi, (DWORD)DIB_RGB_COLORS) == 0){
GlobalUnlock(hdib);
hdib = NULL;
SelectPalette(hdc,hpal,FALSE);
ReleaseDC(NULL,hdc);
return NULL;
}
bi = *lpbi;
GlobalUnlock(hdib);
SelectPalette(hdc,hpal,FALSE);
ReleaseDC(NULL,hdc);
return hdib;
}
BOOL WriteDIB (
LPCWSTR szFile,
HANDLE hdib)
{
BITMAPFILEHEADER hdr;
LPBITMAPINFOHEADER lpbi;
HANDLE fh;
DWORD nbwritten;
if (!hdib)
return FALSE;
fh = CreateFileW(szFile,
(GENERIC_READ | GENERIC_WRITE) ,
FILE_SHARE_READ ,
NULL, /* No security descriptor */
OPEN_ALWAYS ,
FILE_ATTRIBUTE_NORMAL,
NULL /* No template */);
if (fh == INVALID_HANDLE_VALUE)
return FALSE;
lpbi = (VOID FAR *)GlobalLock (hdib);
/* Fill in the fields of the file header */
hdr.bfType = BFT_BITMAP;
hdr.bfSize = GlobalSize (hdib) + SIZEOF_BITMAPFILEHEADER_PACKED;
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
hdr.bfOffBits = (DWORD) (SIZEOF_BITMAPFILEHEADER_PACKED + lpbi->biSize +
PaletteSize(lpbi));
/* Write the file header */
/* write bfType*/
WriteFile(fh, (LPSTR)&hdr.bfType, (UINT)sizeof (WORD),&nbwritten,NULL);
/* now pass over extra word, and only write next 3 DWORDS!*/
WriteFile(fh, (LPSTR)&hdr.bfSize, sizeof(DWORD) * 3, &nbwritten, NULL);
/* this struct already DWORD aligned!*/
/* Write the DIB header and the bits */
WriteFile(fh, (LPSTR)lpbi, GlobalSize (hdib), &nbwritten, NULL);
GlobalUnlock (hdib);
CloseHandle(fh);
return TRUE;
}
/***************************************************************************/
/***************************************************************************/
/* Win32 COM part of drop support */
/***************************************************************************/
/***************************************************************************/
/* C-Style COM ... */
typedef struct DropTarget {
void **vtbl;
int ref;
} DropTarget;
static DropTarget stDropTarget;
static unsigned int numDropFiles = 0;
static char** dropFiles = NULL;
static void freeDropFiles(void) {
int i;
if (dropFiles) {
for (i=0; i < numDropFiles; i++)
free(dropFiles[i]);
free(dropFiles);
dropFiles = NULL;
numDropFiles = 0;
}
}
/* Implement IUnknown */
STDMETHODIMP DropTarget_QueryInterface(DropTarget *dt,REFIID riid,PVOID *ppv) {
DPRINTF(("DropTarget_QueryInterface\n"));
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG)DropTarget_AddRef(DropTarget *dt) {
DPRINTF(("DropTarget_AddRef\n"));
return ++dt->ref;
}
STDMETHODIMP_(ULONG)DropTarget_Release(DropTarget *dt) {
DPRINTF(("DropTarget_Release\n"));
dt->ref--;
if (dt->ref > 0) return dt->ref;
return 0;
}
void signalDropEnter(POINTL pt)
{
POINT winPt;
winPt.x = pt.x;
winPt.y = pt.y;
ScreenToClient(stWindow, &winPt);
recordDragDropEvent(stWindow, SQDragEnter, winPt.x, winPt.y, 0);
}
STDMETHODIMP DropTarget_DragEnter(DropTarget *dt,
IDataObject *ido,
DWORD keyState,
POINTL pt,
DWORD *effect) {
FORMATETC fmtetc;
HRESULT hRes;
DPRINTF(("DropTarget_DragEnter\n"));
#if 0
/* TODO: Enumerate formats and check if
there's anything interesting. Eventually,
convert graphical stuff into bitmaps and
pass them up to Squeak... */
{
IEnumFORMATETC *fmt;
hRes = ido->lpVtbl->EnumFormatEtc(ido, DATADIR_GET, &fmt);
if (hRes == S_OK) {
DPRINTF(("Enumerating formats\n"));
hRes = fmt->lpVtbl->Reset(fmt);
if (FAILED(hRes)) DPRINTF(("Reset() failed (errCode = %x)\n"));
do {
DWORD num;
FORMATETC fmtEtc[1];
FORMATETC *fmtRec = fmtEtc;
hRes = fmt->lpVtbl->Next(fmt, 1, fmtRec, &num);
if (hRes == S_OK) {
/* got it */
DPRINTF(("New format:\n"));
DPRINTF(("\tCLIPFORMAT: %d ", fmtRec->cfFormat));
switch (fmtRec->cfFormat) {
case CF_TEXT: DPRINTF(("(text)")); break;
case CF_BITMAP: DPRINTF(("(bitmap)")); break;
case CF_METAFILEPICT: DPRINTF(("(metafilepict)")); break;
case CF_SYLK: DPRINTF(("(symbolic link format)")); break;
case CF_DIF: DPRINTF(("(data interchange format)")); break;
case CF_TIFF: DPRINTF(("(tiff)")); break;
case CF_OEMTEXT: DPRINTF(("(oem text)")); break;
case CF_DIB: DPRINTF(("(DIB)")); break;
case CF_PALETTE: DPRINTF(("(palette)")); break;
case CF_PENDATA: DPRINTF(("(pendata)")); break;
case CF_RIFF: DPRINTF(("(RIFF data)")); break;
case CF_WAVE: DPRINTF(("(wave)")); break;
case CF_UNICODETEXT: DPRINTF(("(unicode text)")); break;
case CF_ENHMETAFILE: DPRINTF(("(enhanced metafile)")); break;
case CF_HDROP: DPRINTF(("(drop files)")); break;
case CF_LOCALE: DPRINTF(("(locale)")); break;
case CF_DSPTEXT: DPRINTF(("(private text)")); break;
case CF_DSPBITMAP: DPRINTF(("(private bitmap)")); break;
case CF_DSPMETAFILEPICT: DPRINTF(("(private metafilepict)")); break;
case CF_DSPENHMETAFILE: DPRINTF(("(private enhanced metafile)")); break;
}
DPRINTF(("\n"));
if (fmtRec->ptd) {
char *base = (char*) (fmtRec->ptd);
DPRINTF(("\tDriver name: %s\n",
base+(fmtRec->ptd->tdDriverNameOffset)));
DPRINTF(("\tDevice name: %s\n",
base+(fmtRec->ptd->tdDeviceNameOffset)));
DPRINTF(("\tPort name: %s\n",
base+(fmtRec->ptd->tdPortNameOffset)));
}
DPRINTF(("\tdwAspect: %d ",fmtRec->dwAspect));
if (fmtRec->dwAspect & DVASPECT_CONTENT) DPRINTF(("(content)"));
if (fmtRec->dwAspect & DVASPECT_THUMBNAIL) DPRINTF(("(thumbnail)"));
if (fmtRec->dwAspect & DVASPECT_ICON) DPRINTF(("(icon)"));
if (fmtRec->dwAspect & DVASPECT_DOCPRINT) DPRINTF(("(docprint)"));
}
DPRINTF(("\n"));
DPRINTF(("\tTYMED: %d ", fmtRec->tymed));
if (fmtRec->tymed & TYMED_HGLOBAL) DPRINTF(("(HGLOBAL)"));
if (fmtRec->tymed & TYMED_FILE) DPRINTF(("(FILE)"));
if (fmtRec->tymed & TYMED_ISTREAM) DPRINTF(("(IStream)"));
if (fmtRec->tymed & TYMED_ISTORAGE) DPRINTF(("(IStorage)"));
if (fmtRec->tymed & TYMED_GDI) DPRINTF(("(GDI)"));
if (fmtRec->tymed & TYMED_MFPICT) DPRINTF(("(MFPICT)"));
if (fmtRec->tymed & TYMED_ENHMF) DPRINTF(("(ENHMF)"));
DPRINTF(("\n"));
} while (hRes == S_OK);
if (FAILED(hRes)) {
DPRINTF(("Next() failed (errCode = %x)\n"));
}
hRes = fmt->lpVtbl->Release(fmt);
} else {
DPRINTF(("EnumFormatEtc failed (errCode = %x)\n", hRes));
}
}
#endif
fmtetc.cfFormat = 0;
fmtetc.ptd = NULL;
fmtetc.lindex = -1;
fmtetc.dwAspect = DVASPECT_CONTENT;
DPRINTF(("Looking for file...\n"));
fmtetc.cfFormat = CF_HDROP;
fmtetc.tymed = TYMED_HGLOBAL;
hRes = ido->lpVtbl->QueryGetData(ido, &fmtetc);
if (hRes == S_OK) {
DPRINTF(("That works.\n"));
*effect = DROPEFFECT_COPY; /* that's what we want */
signalDropEnter(pt);
return S_OK;
}
DPRINTF(("Looking for HDIB...\n"));
fmtetc.cfFormat = CF_DIB;
fmtetc.tymed = TYMED_HGLOBAL;
hRes = ido->lpVtbl->QueryGetData(ido, &fmtetc);
if (hRes == S_OK) {
DPRINTF(("That works.\n"));
*effect = DROPEFFECT_COPY; /* that's what we want */
signalDropEnter(pt);
return S_OK;
}
DPRINTF(("Looking for Bitmap...\n"));
fmtetc.cfFormat = CF_BITMAP;
fmtetc.tymed = TYMED_GDI;
hRes = ido->lpVtbl->QueryGetData(ido, &fmtetc);
if (hRes == S_OK) {
DPRINTF(("That works.\n"));
*effect = DROPEFFECT_COPY; /* that's what we want */
signalDropEnter(pt);
return S_OK;
}
DPRINTF(("Looking for ENHMF...\n"));
fmtetc.cfFormat = CF_ENHMETAFILE;
fmtetc.tymed = TYMED_ENHMF;
hRes = ido->lpVtbl->QueryGetData(ido, &fmtetc);
if (hRes == S_OK) {
DPRINTF(("That works.\n"));
*effect = DROPEFFECT_COPY; /* that's what we want */
signalDropEnter(pt);
return S_OK;
}
DPRINTF(("Not found...\n"));
*effect = DROPEFFECT_NONE;
return S_FALSE;
}
STDMETHODIMP DropTarget_DragOver(DropTarget *dt,
DWORD keyState,
POINTL pt,
DWORD *effect) {
DPRINTF(("DropTarget_DragOver\n"));
*effect = DROPEFFECT_COPY; /* that's what we want */
{
POINT winPt;
winPt.x = pt.x;
winPt.y = pt.y;
ScreenToClient(stWindow, &winPt);
recordDragDropEvent(stWindow, SQDragMove, winPt.x, winPt.y, 0);
}
return S_OK;
}
STDMETHODIMP DropTarget_DragLeave(DropTarget *dt) {
DPRINTF(("DropTarget_DragLeave\n"));
recordDragDropEvent(stWindow, SQDragLeave, 0, 0, 0);
return S_OK;
}
void signalDrop(POINTL pt)
{
POINT winPt;
winPt.x = pt.x;
winPt.y = pt.y;
ScreenToClient(stWindow, &winPt);
recordDragDropEvent(stWindow, SQDragDrop, winPt.x, winPt.y, numDropFiles);
}
STDMETHODIMP DropTarget_Drop(DropTarget *dt,
IDataObject *ido,
DWORD keyState,
POINTL pt,
DWORD *effect) {
STGMEDIUM medium;
FORMATETC fmtetc;
HRESULT hRes;
freeDropFiles();
DPRINTF(("DropTarget_Drop\n"));
fmtetc.cfFormat = CF_HDROP;
fmtetc.ptd = NULL;
fmtetc.lindex = -1;
fmtetc.dwAspect = DVASPECT_CONTENT;
fmtetc.tymed = TYMED_HGLOBAL;
DPRINTF(("Looking for file...\n"));
hRes = ido->lpVtbl->GetData(ido, &fmtetc, &medium);
if (hRes == S_OK) {
HGLOBAL hDrop = medium.hGlobal;
DWORD i;
DPRINTF(("Success\n"));
numDropFiles = DragQueryFileW(hDrop, -1, NULL, 0);
dropFiles = calloc(numDropFiles, sizeof(char*));
for (i=0; i<numDropFiles; i++) {
WCHAR *tmpPath;
int len;
len = DragQueryFileW(hDrop, i, NULL, 0);
tmpPath = calloc(len+1, sizeof(WCHAR));
DragQueryFileW(hDrop, i, tmpPath, len+1);
len = WideCharToMultiByte(CP_UTF8, 0, tmpPath, -1, NULL, 0,NULL,NULL);
dropFiles[i] = malloc(len);
WideCharToMultiByte(CP_UTF8,0,tmpPath,-1,dropFiles[i],len,NULL,NULL);
free(tmpPath);
DPRINTF(("File: %s\n", dropFiles[i]));
}
DragFinish(hDrop);
signalDrop(pt);
if (medium.pUnkForRelease == NULL) {
if (okToFreeSTGMEDIUMHGLOBAL)
GlobalFree(hDrop);
} else {
medium.pUnkForRelease->lpVtbl->Release(medium.pUnkForRelease);
}
return S_OK;
}
if (FAILED(hRes)) {
DPRINTF(("GetData failed (errCode = %x)\n", hRes));
}
fmtetc.cfFormat = CF_DIB;
fmtetc.ptd = NULL;
fmtetc.lindex = -1;
fmtetc.dwAspect = DVASPECT_CONTENT;
fmtetc.tymed = TYMED_HGLOBAL;
DPRINTF(("Looking for HDIB...\n"));
hRes = ido->lpVtbl->GetData(ido, &fmtetc, &medium);
if (hRes == S_OK) {
WCHAR tmpNameW[MAX_PATH+1];
HANDLE hDib = medium.hGlobal;
DPRINTF(("Success\n"));
GetTempPathW(MAX_PATH,tmpNameW);
wcscat(tmpNameW,L"$$squeak$$.bmp");
if (WriteDIB(tmpNameW, hDib)) {
char tmpNameA[MAX_PATH_UTF8 + 1];
if (WideCharToMultiByte(CP_UTF8, 0, tmpNameW, -1, tmpNameA, MAX_PATH_UTF8, NULL, NULL)) {
numDropFiles = 1;
dropFiles = calloc(1, sizeof(void*));
dropFiles[0] = _strdup(tmpNameA);
}
}
if (medium.pUnkForRelease == NULL) {
GlobalFree(hDib);
} else {
medium.pUnkForRelease->lpVtbl->Release(medium.pUnkForRelease);
}
signalDrop(pt);
return S_OK;
}
if (FAILED(hRes)) {
DPRINTF(("GetData failed (errCode = %x)\n", hRes));
}
fmtetc.cfFormat = CF_BITMAP;
fmtetc.ptd = NULL;
fmtetc.lindex = -1;
fmtetc.dwAspect = DVASPECT_CONTENT;
fmtetc.tymed = TYMED_HGLOBAL;
DPRINTF(("Looking for bitmap...\n"));
hRes = ido->lpVtbl->GetData(ido, &fmtetc, &medium);
if (hRes == S_OK) {
WCHAR tmpNameW[MAX_PATH+1];
HANDLE hDib;
HBITMAP hBM = medium.hBitmap;
DPRINTF(("Success\n"));
GetTempPathW(MAX_PATH,tmpNameW);
wcscat(tmpNameW,L"$$squeak$$.bmp");
hDib = DibFromBitmap(hBM, BI_RGB, 0, NULL);
if (hDib) {
if (WriteDIB(tmpNameW, hDib)) {
char tmpNameA[MAX_PATH_UTF8 + 1];
if (WideCharToMultiByte(CP_UTF8, 0, tmpNameW, -1, tmpNameA, MAX_PATH_UTF8, NULL, NULL)) {
numDropFiles = 1;
dropFiles = calloc(1, sizeof(void*));
dropFiles[0] = _strdup(tmpNameA);
}
}
DeleteObject(hDib);
}
if (medium.pUnkForRelease == NULL) {
DeleteObject(hBM);
} else {
medium.pUnkForRelease->lpVtbl->Release(medium.pUnkForRelease);
}
signalDrop(pt);
return S_OK;
}
if (FAILED(hRes)) {
DPRINTF(("GetData failed (errCode = %x)\n", hRes));
}
fmtetc.cfFormat = CF_ENHMETAFILE;
fmtetc.ptd = NULL;
fmtetc.lindex = -1;
fmtetc.dwAspect = DVASPECT_CONTENT;
fmtetc.tymed = TYMED_ENHMF;
DPRINTF(("Looking for ENHMF...\n"));
hRes = ido->lpVtbl->GetData(ido, &fmtetc, &medium);
if (hRes == S_OK) {
WCHAR tmpNameW[MAX_PATH+1];
HANDLE hMF = medium.hGlobal;
HANDLE hDib;
BITMAPINFO bmi;
ENHMETAHEADER header;
DPRINTF(("Success\n"));
if (GetEnhMetaFileHeader(hMF, sizeof(header), &header) == 0) {
DPRINTF(("GetEnhMetaFileHeader failed\n"));
}
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biWidth = header.rclBounds.right - header.rclBounds.left;
bmi.bmiHeader.biHeight = header.rclBounds.bottom - header.rclBounds.top;
DPRINTF(("w=%d\nh=%d\n", bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight));
{
HDC hDC, mDC;
HANDLE old, hBM;
RECT rect;
hDC = GetDC(stWindow);
if (!hDC) DPRINTF(("GetDC() failed\n"));
// hDib = CreateDIBitmap(hDC, &bmi, 0, NULL, &bmi, DIB_RGB_COLORS);
hBM = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
if (!hBM) DPRINTF(("CreateDIBSection() failed\n"));
mDC = CreateCompatibleDC(hDC);
if (!mDC) DPRINTF(("CreateCompatibleDC() failed\n"));
old = SelectObject(mDC, hBM);
rect.left = rect.top = 0;
rect.right = bmi.bmiHeader.biWidth;
rect.bottom = bmi.bmiHeader.biHeight;
if (!PlayEnhMetaFile(mDC, hMF, &rect))
DPRINTF(("PlayEnhMetaFile() failed\n"));
SelectObject(mDC, old);
DeleteDC(mDC);
ReleaseDC(stWindow, hDC);
hDib = DibFromBitmap(hBM, BI_RGB, 0, NULL);
DeleteObject(hBM);
}
GetTempPathW(MAX_PATH,tmpNameW);
wcscat(tmpNameW,L"$$squeak$$.bmp");
if (WriteDIB(tmpNameW, hDib)) {
char tmpNameA[MAX_PATH_UTF8 + 1];
if (WideCharToMultiByte(CP_UTF8, 0, tmpNameW, -1, tmpNameA, MAX_PATH_UTF8, NULL, NULL)) {
numDropFiles = 1;
dropFiles = calloc(1, sizeof(void*));
dropFiles[0] = _strdup(tmpNameA);
}
}
GlobalFree(hDib);
if (medium.pUnkForRelease == NULL) {
DeleteObject(hMF);
} else {
medium.pUnkForRelease->lpVtbl->Release(medium.pUnkForRelease);
}
signalDrop(pt);
return S_OK;
}
if (FAILED(hRes)) {
DPRINTF(("GetData failed (errCode = %x)\n", hRes));
}
return S_OK;
}
static void *vtDropTarget[] = {
DropTarget_QueryInterface,
DropTarget_AddRef,
DropTarget_Release,
DropTarget_DragEnter,
DropTarget_DragOver,
DropTarget_DragLeave,
DropTarget_Drop
};
static int isInitialized = 0;
void SetupDragAndDrop(void) {
HRESULT hRes;
#if 0
return;
#endif
if (!isInitialized) {
stDropTarget.vtbl = vtDropTarget;
stDropTarget.ref = 0;
isInitialized = 1;
}
hRes = RegisterDragDrop(stWindow, (LPDROPTARGET)&stDropTarget);
if (hRes == S_OK) {
DPRINTF(("Registered drop target\n"));
} else {
DPRINTF(("Drop registration failed (errCode: %x)\n", hRes));
}
}
void ShutdownDragAndDrop(void) {
if (isInitialized) {
RevokeDragDrop(stWindow);
isInitialized = 0;
}
}
/***************************************************************************/
/***************************************************************************/
/* Squeak part of drop support */
/***************************************************************************/
/***************************************************************************/
/* Pretend this is a drag and drop of the given file */
int dropLaunchFile(char *fileName) {
freeDropFiles();
numDropFiles = 1;
dropFiles = calloc(1, sizeof(void*));
dropFiles[0] = _strdup(fileName);
recordDragDropEvent(stWindow, SQDragDrop, 0, 0, numDropFiles);
return 1;
}
int dropInit(void) {
SetupDragAndDrop();
return 1;
}
int dropShutdown(void) {
freeDropFiles();
ShutdownDragAndDrop();
return 1;
}
char *
dropRequestFileName(int dropIndex) {
DPRINTF(("dropRequestFileName(%d)\n", dropIndex));
if (dropIndex < 1 || dropIndex > numDropFiles) return NULL;
return dropFiles[dropIndex-1];
}
// So far win32 supports only files.
char *
dropRequestURI(int dropIndex) { return NULL; }
sqInt dropRequestFileHandle(sqInt dropIndex) {
sqInt fileHandle;
char *dropName = dropRequestFileName(dropIndex);
if (!dropName)
return interpreterProxy->nilObject();
fileHandle = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), fileRecordSize());
sqFileOpen(fileValueOf(fileHandle),dropName, strlen(dropName), 0);
return fileHandle;
}
|
501b6a44145ed993647dc9c508caca9413d155be
|
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
|
/AKWF-c/AKWF_0009/AKWF_0878.h
|
8d8c9e8391698fd53311209ce945d249f035ed91
|
[
"CC0-1.0"
] |
permissive
|
KristofferKarlAxelEkstrand/AKWF-FREE
|
b2defa1a2d389d309be6dd2e9f968923daf80d1b
|
cf8171df36e9fec25416b5f568b72a6e2cb69194
|
refs/heads/master
| 2023-07-23T18:22:36.939705
| 2023-07-10T17:14:40
| 2023-07-10T17:14:40
| 145,817,187
| 359
| 59
|
CC0-1.0
| 2023-07-10T17:14:41
| 2018-08-23T07:26:56
| null |
UTF-8
|
C
| false
| false
| 4,672
|
h
|
AKWF_0878.h
|
/* Adventure Kid Waveforms (AKWF) converted for use with Teensy Audio Library
*
* Adventure Kid Waveforms(AKWF) Open waveforms library
* https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/
*
* This code is in the public domain, CC0 1.0 Universal (CC0 1.0)
* https://creativecommons.org/publicdomain/zero/1.0/
*
* Converted by Brad Roy, https://github.com/prosper00
*/
/* AKWF_0878 256 samples
+-----------------------------------------------------------------------------------------------------------------+
| ****** ****** |
| ***** ****** |
| ****** **** |
| ***** **** |
| **** *** |
|****** ** |
|* * |
| * |
| * *|
| ** ***|
| *** **** |
| *** **** |
| *** **** |
| **** **** |
| **** **** |
+-----------------------------------------------------------------------------------------------------------------+
*/
const uint16_t AKWF_0878 [] = {
34702, 37365, 38163, 39166, 39689, 40344, 40737, 41213, 41518, 41874, 42107, 42390, 42692, 42927, 43297, 43737,
44323, 44983, 45719, 46438, 47163, 47804, 48397, 48894, 49354, 49751, 50140, 50492, 50855, 51201, 51561, 51915,
52282, 52649, 53026, 53405, 53789, 54179, 54570, 54966, 55362, 55761, 56159, 56563, 56961, 57361, 57759, 58156,
58550, 58943, 59330, 59718, 60098, 60477, 60850, 61219, 61584, 61943, 62293, 62644, 62983, 63323, 63650, 63982,
64298, 64629, 64942, 65324, 65535, 65528, 65535, 65531, 65535, 65532, 65535, 65533, 65535, 65533, 65535, 65533,
65535, 65534, 65535, 65534, 65535, 65534, 65535, 65509, 65185, 64850, 64538, 64230, 63919, 63610, 63291, 62976,
62647, 62326, 61989, 61658, 61314, 60974, 60624, 60273, 59922, 59561, 59209, 58837, 58488, 58102, 57756, 57361,
57020, 56613, 56279, 55864, 55535, 55110, 54724, 54220, 53706, 53032, 52465, 51794, 51117, 50346, 49622, 48956,
48329, 47725, 47048, 46501, 45662, 44934, 43684, 42639, 40632, 39161, 32304, 25883, 24721, 22784, 21844, 20519,
19667, 18602, 17787, 16868, 16066, 15238, 14446, 13680, 12893, 12172, 11397, 10705, 9942, 9269, 8521, 7860,
7126, 6469, 5750, 5088, 4379, 3699, 2989, 2265, 1528, 637, 0, 12, 0, 5, 0, 0,
3, 0, 6, 1, 6, 1, 7, 0, 7, 0, 6, 0, 6, 0, 5, 0,
4, 0, 4, 0, 3, 0, 3, 0, 3, 0, 2, 0, 0, 1, 0, 4,
0, 10, 0, 620, 1434, 2059, 2715, 3301, 3914, 4480, 5073, 5633, 6214, 6768, 7344, 7898,
8469, 9022, 9591, 10147, 10713, 11273, 11836, 12402, 12963, 13535, 14094, 14676, 15233, 15825, 16384, 16985,
17547, 18165, 18732, 19367, 19945, 20604, 21200, 21891, 22520, 23255, 23943, 24753, 25552, 26517, 27587, 29151,
};
|
c0cff80ca9027ed7a17a14f2a97b70ff144457e7
|
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
|
/sys/ufs/ffs/ffs_wapbl.c
|
250a43b29d86d7eb1421f0de57bd04ecfe0a5e96
|
[] |
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
| 25,924
|
c
|
ffs_wapbl.c
|
/* $NetBSD: ffs_wapbl.c,v 1.48 2022/05/22 11:27:36 andvar Exp $ */
/*-
* Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.48 2022/05/22 11:27:36 andvar Exp $");
#define WAPBL_INTERNAL
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/mount.h>
#include <sys/file.h>
#include <sys/disk.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <sys/kauth.h>
#include <sys/wapbl.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/ufs_bswap.h>
#include <ufs/ufs/ufs_extern.h>
#include <ufs/ufs/ufs_wapbl.h>
#include <ufs/ffs/fs.h>
#include <ufs/ffs/ffs_extern.h>
#undef WAPBL_DEBUG
#ifdef WAPBL_DEBUG
int ffs_wapbl_debug = 1;
#define DPRINTF(fmt, args...) \
do { \
if (ffs_wapbl_debug) \
printf("%s:%d "fmt, __func__ , __LINE__, ##args); \
} while (/* CONSTCOND */0)
#else
#define DPRINTF(fmt, args...) \
do { \
/* nothing */ \
} while (/* CONSTCOND */0)
#endif
static int ffs_superblock_layout(struct fs *);
static int wapbl_log_position(struct mount *, struct fs *, struct vnode *,
daddr_t *, size_t *, size_t *, uint64_t *);
static int wapbl_create_infs_log(struct mount *, struct fs *, struct vnode *,
daddr_t *, size_t *, uint64_t *);
static void wapbl_find_log_start(struct mount *, struct vnode *, off_t,
daddr_t *, daddr_t *, size_t *);
static int wapbl_remove_log(struct mount *);
static int wapbl_allocate_log_file(struct mount *, struct vnode *,
daddr_t *, size_t *, uint64_t *);
/*
* Return the super block layout format - UFS1 or UFS2.
* WAPBL only works with UFS2 layout (which is still available
* with FFSv1).
*
* XXX Should this be in ufs/ffs/fs.h? Same style of check is
* also used in ffs_alloc.c in a few places.
*/
static int
ffs_superblock_layout(struct fs *fs)
{
if ((fs->fs_magic == FS_UFS1_MAGIC) &&
((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0))
return 1;
else
return 2;
}
/*
* This function is invoked after a log is replayed to
* disk to perform logical cleanup actions as described by
* the log
*/
void
ffs_wapbl_replay_finish(struct mount *mp)
{
struct wapbl_replay *wr = mp->mnt_wapbl_replay;
int i;
int error;
if (!wr)
return;
KDASSERT((mp->mnt_flag & MNT_RDONLY) == 0);
for (i = 0; i < wr->wr_inodescnt; i++) {
struct vnode *vp;
struct inode *ip;
error = VFS_VGET(mp, wr->wr_inodes[i].wr_inumber,
LK_EXCLUSIVE, &vp);
if (error) {
printf("%s: %s: unable to cleanup inode %" PRIu32 "\n",
__func__, VFSTOUFS(mp)->um_fs->fs_fsmnt,
wr->wr_inodes[i].wr_inumber);
continue;
}
ip = VTOI(vp);
KDASSERT(wr->wr_inodes[i].wr_inumber == ip->i_number);
#ifdef WAPBL_DEBUG
printf("%s%s: %s: cleaning inode %" PRIu64 " size=%" PRIu64
" mode=%o nlink=%d\n",
__func__, VFSTOUFS(mp)->um_fs->fs_fsmnt,
ip->i_number, ip->i_size, ip->i_mode, ip->i_nlink);
#endif
KASSERT(ip->i_nlink == 0);
/*
* The journal may have left partially allocated inodes in mode
* zero. This may occur if a crash occurs between the node
* allocation in ffs_nodeallocg and when the node is properly
* initialized in ufs_makeinode. If so, just deallocate them.
*/
if (ip->i_mode == 0) {
error = UFS_WAPBL_BEGIN(mp);
if (error) {
printf("%s: %s: "
"unable to cleanup inode %" PRIu32 "\n",
__func__, VFSTOUFS(mp)->um_fs->fs_fsmnt,
wr->wr_inodes[i].wr_inumber);
} else {
ffs_vfree(vp, ip->i_number,
wr->wr_inodes[i].wr_imode);
UFS_WAPBL_END(mp);
}
}
vput(vp);
}
wapbl_replay_stop(wr);
wapbl_replay_free(wr);
mp->mnt_wapbl_replay = NULL;
}
/* Callback for wapbl */
void
ffs_wapbl_sync_metadata(struct mount *mp, struct wapbl_dealloc *fdealloc)
{
struct ufsmount *ump = VFSTOUFS(mp);
struct fs *fs = ump->um_fs;
int error __diagused;
struct wapbl_dealloc *wd;
UFS_WAPBL_JLOCK_ASSERT(ump->um_mountp);
for (wd = fdealloc; wd != NULL; wd = TAILQ_NEXT(wd, wd_entries)) {
/*
* blkfree errors are unreported, might silently fail
* if it cannot read the cylinder group block
*/
ffs_blkfree(fs, ump->um_devvp,
FFS_DBTOFSB(fs, wd->wd_blkno), wd->wd_len, -1);
}
if (fs->fs_fmod != 0) {
fs->fs_fmod = 0;
fs->fs_time = time_second;
error = ffs_cgupdate(ump, 0);
KASSERT(error == 0);
}
}
void
ffs_wapbl_abort_sync_metadata(struct mount *mp, struct wapbl_dealloc *fdealloc)
{
struct ufsmount *ump = VFSTOUFS(mp);
struct fs *fs = ump->um_fs;
struct wapbl_dealloc *wd;
for (wd = fdealloc; wd != NULL; wd = TAILQ_NEXT(wd, wd_entries)) {
/*
* Since the above blkfree may have failed, this blkalloc might
* fail as well, so don't check its error. Note that if the
* blkfree succeeded above, then this shouldn't fail because
* the buffer will be locked in the current transaction.
*/
ffs_blkalloc_ump(ump, FFS_DBTOFSB(fs, wd->wd_blkno),
wd->wd_len);
}
}
static int
wapbl_remove_log(struct mount *mp)
{
struct ufsmount *ump = VFSTOUFS(mp);
struct fs *fs = ump->um_fs;
struct vnode *vp;
struct inode *ip;
ino_t log_ino;
int error;
/* If super block layout is too old to support WAPBL, return */
if (ffs_superblock_layout(fs) < 2)
return 0;
/* If all the log locators are 0, just clean up */
if (fs->fs_journallocs[0] == 0 &&
fs->fs_journallocs[1] == 0 &&
fs->fs_journallocs[2] == 0 &&
fs->fs_journallocs[3] == 0) {
DPRINTF("empty locators, just clear\n");
goto done;
}
switch (fs->fs_journal_location) {
case UFS_WAPBL_JOURNALLOC_NONE:
/* nothing! */
DPRINTF("no log\n");
break;
case UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM:
log_ino = fs->fs_journallocs[UFS_WAPBL_INFS_INO];
DPRINTF("in-fs log, ino = %" PRId64 "\n",log_ino);
/* if no existing log inode, just clear all fields and bail */
if (log_ino == 0)
goto done;
error = VFS_VGET(mp, log_ino, LK_EXCLUSIVE, &vp);
if (error != 0) {
printf("%s: %s: vget failed %d\n", __func__,
fs->fs_fsmnt, error);
/* clear out log info on error */
goto done;
}
ip = VTOI(vp);
KASSERT(log_ino == ip->i_number);
if ((ip->i_flags & SF_LOG) == 0) {
printf("%s: %s: try to clear non-log inode "
"%" PRId64 "\n", __func__, fs->fs_fsmnt, log_ino);
vput(vp);
/* clear out log info on error */
goto done;
}
/*
* remove the log inode by setting its link count back
* to zero and bail.
*/
ip->i_nlink = 0;
DIP_ASSIGN(ip, nlink, 0);
vput(vp);
break;
case UFS_WAPBL_JOURNALLOC_END_PARTITION:
DPRINTF("end-of-partition log\n");
/* no extra work required */
break;
default:
printf("%s: %s: unknown journal type %d\n", __func__,
fs->fs_fsmnt, fs->fs_journal_location);
break;
}
done:
/* Clear out all previous knowledge of journal */
fs->fs_journal_version = 0;
fs->fs_journal_location = 0;
fs->fs_journal_flags = 0;
fs->fs_journallocs[0] = 0;
fs->fs_journallocs[1] = 0;
fs->fs_journallocs[2] = 0;
fs->fs_journallocs[3] = 0;
(void) ffs_sbupdate(ump, MNT_WAIT);
return 0;
}
int
ffs_wapbl_start(struct mount *mp)
{
struct ufsmount *ump = VFSTOUFS(mp);
struct fs *fs = ump->um_fs;
struct vnode *devvp = ump->um_devvp;
daddr_t off;
size_t count;
size_t blksize;
uint64_t extradata;
int error;
if (mp->mnt_wapbl == NULL) {
if (fs->fs_journal_flags & UFS_WAPBL_FLAGS_CLEAR_LOG) {
/* Clear out any existing journal file */
error = wapbl_remove_log(mp);
if (error != 0)
return error;
}
if (mp->mnt_flag & MNT_LOG) {
KDASSERT(fs->fs_ronly == 0);
/* WAPBL needs UFS2 format super block */
if (ffs_superblock_layout(fs) < 2) {
printf("%s: %s: fs superblock in old format, "
"not journaling\n", __func__,
VFSTOUFS(mp)->um_fs->fs_fsmnt);
mp->mnt_flag &= ~MNT_LOG;
return EINVAL;
}
error = wapbl_log_position(mp, fs, devvp, &off,
&count, &blksize, &extradata);
if (error)
return error;
/*
* Make sure we don't carry over any delayed write
* buffers when updating to log. Need to turn off
* async termporarily, to prevent ffs_sync() writes
* themselves being turned into delayed writes.
*/
if (mp->mnt_flag & MNT_UPDATE) {
int saveflag = mp->mnt_flag & MNT_ASYNC;
mp->mnt_flag &= ~MNT_ASYNC;
ffs_sync(mp, MNT_WAIT, FSCRED);
mp->mnt_flag |= saveflag;
}
error = wapbl_start(&mp->mnt_wapbl, mp, devvp, off,
count, blksize, mp->mnt_wapbl_replay,
ffs_wapbl_sync_metadata,
ffs_wapbl_abort_sync_metadata);
if (error)
return error;
mp->mnt_wapbl_op = &wapbl_ops;
#ifdef WAPBL_DEBUG
printf("%s: %s: enabling logging\n", __func__,
fs->fs_fsmnt);
#endif
if ((fs->fs_flags & FS_DOWAPBL) == 0) {
fs->fs_flags |= FS_DOWAPBL;
if ((error = UFS_WAPBL_BEGIN(mp)) != 0)
goto out;
error = ffs_sbupdate(ump, MNT_WAIT);
if (error) {
UFS_WAPBL_END(mp);
goto out;
}
UFS_WAPBL_END(mp);
error = wapbl_flush(mp->mnt_wapbl, 1);
if (error)
goto out;
}
/*
* XXX discard interferes with block deallocation
* registration and hence log consistency
*/
if (mp->mnt_flag & MNT_DISCARD) {
CLR(mp->mnt_flag, MNT_DISCARD);
printf("%s: %s: disabling discard to preserve log consistency\n", __func__,
fs->fs_fsmnt);
if (ump->um_discarddata != NULL) {
ffs_discard_finish(ump->um_discarddata,
0);
ump->um_discarddata = NULL;
}
}
} else if (fs->fs_flags & FS_DOWAPBL) {
fs->fs_fmod = 1;
fs->fs_flags &= ~FS_DOWAPBL;
}
}
/*
* It is recommended that you finish replay with logging enabled.
* However, even if logging is not enabled, the remaining log
* replay should be safely recoverable with an fsck, so perform
* it anyway.
*/
if ((fs->fs_ronly == 0) && mp->mnt_wapbl_replay) {
int saveflag = mp->mnt_flag & MNT_RDONLY;
/*
* Make sure MNT_RDONLY is not set so that the inode
* cleanup in ufs_inactive will actually do its work.
*/
mp->mnt_flag &= ~MNT_RDONLY;
ffs_wapbl_replay_finish(mp);
mp->mnt_flag |= saveflag;
KASSERT(fs->fs_ronly == 0);
}
return 0;
out:
ffs_wapbl_stop(mp, MNT_FORCE);
return error;
}
int
ffs_wapbl_stop(struct mount *mp, int force)
{
struct ufsmount *ump = VFSTOUFS(mp);
struct fs *fs = ump->um_fs;
int error;
if (mp->mnt_wapbl) {
KDASSERT(fs->fs_ronly == 0);
/*
* Make sure turning off FS_DOWAPBL is only removed
* as the only change in the final flush since otherwise
* a transaction may reorder writes.
*/
error = wapbl_flush(mp->mnt_wapbl, 1);
if (error && !force)
return error;
if (error && force)
goto forceout;
error = UFS_WAPBL_BEGIN(mp);
if (error && !force)
return error;
if (error && force)
goto forceout;
KASSERT(fs->fs_flags & FS_DOWAPBL);
fs->fs_flags &= ~FS_DOWAPBL;
error = ffs_sbupdate(ump, MNT_WAIT);
KASSERT(error == 0); /* XXX a bit drastic! */
UFS_WAPBL_END(mp);
forceout:
error = wapbl_stop(mp->mnt_wapbl, force);
if (error) {
KASSERT(!force);
fs->fs_flags |= FS_DOWAPBL;
return error;
}
fs->fs_flags &= ~FS_DOWAPBL; /* Repeat in case of forced error */
mp->mnt_wapbl = NULL;
#ifdef WAPBL_DEBUG
printf("%s: %s: disabled logging\n", __func__, fs->fs_fsmnt);
#endif
}
return 0;
}
int
ffs_wapbl_replay_start(struct mount *mp, struct fs *fs, struct vnode *devvp)
{
int error;
daddr_t off;
size_t count;
size_t blksize;
uint64_t extradata;
/*
* WAPBL needs UFS2 format super block, if we got here with a
* UFS1 format super block something is amiss...
*/
if (ffs_superblock_layout(fs) < 2)
return EINVAL;
error = wapbl_log_position(mp, fs, devvp, &off, &count, &blksize,
&extradata);
if (error)
return error;
error = wapbl_replay_start(&mp->mnt_wapbl_replay, devvp, off,
count, blksize);
if (error)
return error;
mp->mnt_wapbl_op = &wapbl_ops;
return 0;
}
/*
* If the superblock doesn't already have a recorded journal location
* then we allocate the journal in one of two positions:
*
* - At the end of the partition after the filesystem if there's
* enough space. "Enough space" is defined as >= 1MB of journal
* per 1GB of filesystem or 64MB, whichever is smaller.
*
* - Inside the filesystem. We try to allocate a contiguous journal
* based on the total filesystem size - the target is 1MB of journal
* per 1GB of filesystem, up to a maximum journal size of 64MB. As
* a worst case allowing for fragmentation, we'll allocate a journal
* 1/4 of the desired size but never smaller than 1MB.
*
* XXX In the future if we allow for non-contiguous journal files we
* can tighten the above restrictions.
*
* XXX
* These seems like a lot of duplication both here and in some of
* the userland tools (fsck_ffs, dumpfs, tunefs) with similar
* "switch (fs_journal_location)" constructs. Can we centralise
* this sort of code somehow/somewhere?
*/
static int
wapbl_log_position(struct mount *mp, struct fs *fs, struct vnode *devvp,
daddr_t *startp, size_t *countp, size_t *blksizep, uint64_t *extradatap)
{
struct ufsmount *ump = VFSTOUFS(mp);
daddr_t logstart, logend, desired_logsize;
uint64_t numsecs;
unsigned secsize;
int error, location;
if (fs->fs_journal_version == UFS_WAPBL_VERSION) {
switch (fs->fs_journal_location) {
case UFS_WAPBL_JOURNALLOC_END_PARTITION:
DPRINTF("found existing end-of-partition log\n");
*startp = fs->fs_journallocs[UFS_WAPBL_EPART_ADDR];
*countp = fs->fs_journallocs[UFS_WAPBL_EPART_COUNT];
*blksizep = fs->fs_journallocs[UFS_WAPBL_EPART_BLKSZ];
DPRINTF(" start = %" PRId64 ", size = %zu, "
"blksize = %zu\n", *startp, *countp, *blksizep);
return 0;
case UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM:
DPRINTF("found existing in-filesystem log\n");
*startp = fs->fs_journallocs[UFS_WAPBL_INFS_ADDR];
*countp = fs->fs_journallocs[UFS_WAPBL_INFS_COUNT];
*blksizep = fs->fs_journallocs[UFS_WAPBL_INFS_BLKSZ];
DPRINTF(" start = %" PRId64 ", size = %zu, "
"blksize = %zu\n", *startp, *countp, *blksizep);
return 0;
default:
printf("%s: %s: unknown journal type %d\n", __func__,
fs->fs_fsmnt, fs->fs_journal_location);
return EINVAL;
}
}
desired_logsize =
ffs_lfragtosize(fs, fs->fs_size) / UFS_WAPBL_JOURNAL_SCALE;
DPRINTF("desired log size = %" PRId64 " kB\n", desired_logsize / 1024);
desired_logsize = uimax(desired_logsize, UFS_WAPBL_MIN_JOURNAL_SIZE);
desired_logsize = uimin(desired_logsize, UFS_WAPBL_MAX_JOURNAL_SIZE);
DPRINTF("adjusted desired log size = %" PRId64 " kB\n",
desired_logsize / 1024);
/* Is there space after after filesystem on partition for log? */
logstart = FFS_FSBTODB(fs, fs->fs_size);
error = getdisksize(devvp, &numsecs, &secsize);
if (error)
return error;
KDASSERT(secsize != 0);
logend = btodb(numsecs * secsize);
if (dbtob(logend - logstart) >= desired_logsize) {
DPRINTF("enough space, use end-of-partition log\n");
location = UFS_WAPBL_JOURNALLOC_END_PARTITION;
*blksizep = secsize;
*startp = logstart;
*countp = (logend - logstart);
*extradatap = 0;
/* convert to physical block numbers */
*startp = dbtob(*startp) / secsize;
*countp = dbtob(*countp) / secsize;
fs->fs_journallocs[UFS_WAPBL_EPART_ADDR] = *startp;
fs->fs_journallocs[UFS_WAPBL_EPART_COUNT] = *countp;
fs->fs_journallocs[UFS_WAPBL_EPART_BLKSZ] = *blksizep;
fs->fs_journallocs[UFS_WAPBL_EPART_UNUSED] = *extradatap;
} else {
DPRINTF("end-of-partition has only %" PRId64 " free\n",
logend - logstart);
location = UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM;
*blksizep = secsize;
error = wapbl_create_infs_log(mp, fs, devvp,
startp, countp, extradatap);
ffs_sync(mp, MNT_WAIT, FSCRED);
/* convert to physical block numbers */
*startp = dbtob(*startp) / secsize;
*countp = dbtob(*countp) / secsize;
fs->fs_journallocs[UFS_WAPBL_INFS_ADDR] = *startp;
fs->fs_journallocs[UFS_WAPBL_INFS_COUNT] = *countp;
fs->fs_journallocs[UFS_WAPBL_INFS_BLKSZ] = *blksizep;
fs->fs_journallocs[UFS_WAPBL_INFS_INO] = *extradatap;
}
if (error == 0) {
/* update superblock with log location */
fs->fs_journal_version = UFS_WAPBL_VERSION;
fs->fs_journal_location = location;
fs->fs_journal_flags = 0;
error = ffs_sbupdate(ump, MNT_WAIT);
}
return error;
}
/*
* Try to create a journal log inside the filesystem.
*/
static int
wapbl_create_infs_log(struct mount *mp, struct fs *fs, struct vnode *devvp,
daddr_t *startp, size_t *countp, uint64_t *extradatap)
{
struct vnode *vp, *rvp;
struct vattr va;
struct inode *ip;
int error;
if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp)) != 0)
return error;
vattr_null(&va);
va.va_type = VREG;
va.va_mode = 0;
error = vcache_new(mp, rvp, &va, NOCRED, NULL, &vp);
vput(rvp);
if (error)
return error;
error = vn_lock(vp, LK_EXCLUSIVE);
if (error) {
vrele(vp);
return error;
}
ip = VTOI(vp);
ip->i_flags = SF_LOG;
DIP_ASSIGN(ip, flags, ip->i_flags);
ip->i_nlink = 1;
DIP_ASSIGN(ip, nlink, 1);
ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
ffs_update(vp, NULL, NULL, UPDATE_WAIT);
if ((error = wapbl_allocate_log_file(mp, vp,
startp, countp, extradatap)) != 0) {
/*
* If we couldn't allocate the space for the log file,
* remove the inode by setting its link count back to
* zero and bail.
*/
ip->i_nlink = 0;
DIP_ASSIGN(ip, nlink, 0);
vput(vp);
return error;
}
/*
* Now that we have the place-holder inode for the journal,
* we don't need the vnode ever again.
*/
vput(vp);
return 0;
}
int
wapbl_allocate_log_file(struct mount *mp, struct vnode *vp,
daddr_t *startp, size_t *countp, uint64_t *extradatap)
{
struct ufsmount *ump = VFSTOUFS(mp);
struct fs *fs = ump->um_fs;
daddr_t addr, indir_addr;
off_t logsize;
size_t size;
int error;
logsize = 0;
/* check if there's a suggested log size */
if (fs->fs_journal_flags & UFS_WAPBL_FLAGS_CREATE_LOG &&
fs->fs_journal_location == UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM)
logsize = fs->fs_journallocs[UFS_WAPBL_INFS_COUNT];
if (vp->v_size > 0) {
printf("%s: %s: file size (%" PRId64 ") non zero\n", __func__,
fs->fs_fsmnt, vp->v_size);
return EEXIST;
}
wapbl_find_log_start(mp, vp, logsize, &addr, &indir_addr, &size);
if (addr == 0) {
printf("%s: %s: log not allocated, largest extent is "
"%" PRId64 "MB\n", __func__, fs->fs_fsmnt,
ffs_lblktosize(fs, size) / (1024 * 1024));
return ENOSPC;
}
logsize = ffs_lblktosize(fs, size); /* final log size */
VTOI(vp)->i_ffs_first_data_blk = addr;
VTOI(vp)->i_ffs_first_indir_blk = indir_addr;
error = GOP_ALLOC(vp, 0, logsize, B_CONTIG, FSCRED);
if (error) {
printf("%s: %s: GOP_ALLOC error %d\n", __func__, fs->fs_fsmnt,
error);
return error;
}
*startp = FFS_FSBTODB(fs, addr);
*countp = btodb(logsize);
*extradatap = VTOI(vp)->i_number;
return 0;
}
/*
* Find a suitable location for the journal in the filesystem.
*
* Our strategy here is to look for a contiguous block of free space
* at least "logfile" MB in size (plus room for any indirect blocks).
* We start at the middle of the filesystem and check each cylinder
* group working outwards. If "logfile" MB is not available as a
* single contigous chunk, then return the address and size of the
* largest chunk found.
*
* XXX
* At what stage does the search fail? Is if the largest space we could
* find is less than a quarter the requested space reasonable? If the
* search fails entirely, return a block address if "0" it indicate this.
*/
static void
wapbl_find_log_start(struct mount *mp, struct vnode *vp, off_t logsize,
daddr_t *addr, daddr_t *indir_addr, size_t *size)
{
struct ufsmount *ump = VFSTOUFS(mp);
struct fs *fs = ump->um_fs;
struct vnode *devvp = ump->um_devvp;
struct cg *cgp;
struct buf *bp;
uint8_t *blksfree;
daddr_t blkno, best_addr, start_addr;
daddr_t desired_blks, min_desired_blks;
daddr_t freeblks, best_blks;
int bpcg, cg, error, fixedsize, indir_blks, n, s;
const int needswap = UFS_FSNEEDSWAP(fs);
if (logsize == 0) {
fixedsize = 0; /* We can adjust the size if tight */
logsize = ffs_lfragtosize(fs, fs->fs_dsize) /
UFS_WAPBL_JOURNAL_SCALE;
DPRINTF("suggested log size = %" PRId64 "\n", logsize);
logsize = uimax(logsize, UFS_WAPBL_MIN_JOURNAL_SIZE);
logsize = uimin(logsize, UFS_WAPBL_MAX_JOURNAL_SIZE);
DPRINTF("adjusted log size = %" PRId64 "\n", logsize);
} else {
fixedsize = 1;
DPRINTF("fixed log size = %" PRId64 "\n", logsize);
}
desired_blks = logsize / fs->fs_bsize;
DPRINTF("desired blocks = %" PRId64 "\n", desired_blks);
/* add in number of indirect blocks needed */
indir_blks = 0;
if (desired_blks >= UFS_NDADDR) {
struct indir indirs[UFS_NIADDR + 2];
int num;
error = ufs_getlbns(vp, desired_blks, indirs, &num);
if (error) {
printf("%s: %s: ufs_getlbns failed, error %d!\n",
__func__, fs->fs_fsmnt, error);
goto bad;
}
switch (num) {
case 2:
indir_blks = 1; /* 1st level indirect */
break;
case 3:
indir_blks = 1 + /* 1st level indirect */
1 + /* 2nd level indirect */
indirs[1].in_off + 1; /* extra 1st level indirect */
break;
default:
printf("%s: %s: unexpected numlevels %d from "
"ufs_getlbns\n", __func__, fs->fs_fsmnt, num);
*size = 0;
goto bad;
}
desired_blks += indir_blks;
}
DPRINTF("desired blocks = %" PRId64 " (including indirect)\n",
desired_blks);
/*
* If a specific size wasn't requested, allow for a smaller log
* if we're really tight for space...
*/
min_desired_blks = desired_blks;
if (!fixedsize)
min_desired_blks = desired_blks / 4;
/* Look at number of blocks per CG. If it's too small, bail early. */
bpcg = ffs_fragstoblks(fs, fs->fs_fpg);
if (min_desired_blks > bpcg) {
printf("%s: %s: cylinder group size of %" PRId64 " MB "
" is not big enough for journal\n", __func__, fs->fs_fsmnt,
ffs_lblktosize(fs, bpcg) / (1024 * 1024));
goto bad;
}
/*
* Start with the middle cylinder group, and search outwards in
* both directions until we either find the requested log size
* or reach the start/end of the file system. If we reach the
* start/end without finding enough space for the full requested
* log size, use the largest extent found if it is large enough
* to satisfy the our minimum size.
*
* XXX
* Can we just use the cluster contigsum stuff (esp on UFS2)
* here to simplify this search code?
*/
best_addr = 0;
best_blks = 0;
for (cg = fs->fs_ncg / 2, s = 0, n = 1;
best_blks < desired_blks && cg >= 0 && cg < fs->fs_ncg;
s++, n = -n, cg += n * s) {
DPRINTF("check cg %d of %d\n", cg, fs->fs_ncg);
error = bread(devvp, FFS_FSBTODB(fs, cgtod(fs, cg)),
fs->fs_cgsize, 0, &bp);
if (error) {
continue;
}
cgp = (struct cg *)bp->b_data;
if (!cg_chkmagic(cgp, UFS_FSNEEDSWAP(fs))) {
brelse(bp, 0);
continue;
}
blksfree = cg_blksfree(cgp, needswap);
for (blkno = 0; blkno < bpcg;) {
/* look for next free block */
/* XXX use scanc() and fragtbl[] here? */
for (; blkno < bpcg - min_desired_blks; blkno++)
if (ffs_isblock(fs, blksfree, blkno))
break;
/* past end of search space in this CG? */
if (blkno >= bpcg - min_desired_blks)
break;
/* count how many free blocks in this extent */
start_addr = blkno;
for (freeblks = 0; blkno < bpcg; blkno++, freeblks++)
if (!ffs_isblock(fs, blksfree, blkno))
break;
if (freeblks > best_blks) {
best_blks = freeblks;
best_addr = ffs_blkstofrags(fs, start_addr) +
cgbase(fs, cg);
if (freeblks >= desired_blks) {
DPRINTF("found len %" PRId64
" at offset %" PRId64 " in gc\n",
freeblks, start_addr);
break;
}
}
}
brelse(bp, 0);
}
DPRINTF("best found len = %" PRId64 ", wanted %" PRId64
" at addr %" PRId64 "\n", best_blks, desired_blks, best_addr);
if (best_blks < min_desired_blks) {
*addr = 0;
*indir_addr = 0;
} else {
/* put indirect blocks at start, and data blocks after */
*addr = best_addr + ffs_blkstofrags(fs, indir_blks);
*indir_addr = best_addr;
}
*size = uimin(desired_blks, best_blks) - indir_blks;
return;
bad:
*addr = 0;
*indir_addr = 0;
*size = 0;
return;
}
|
1d06b2441f629e845439c25341d2d55eb5279ff6
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/third_party/ffmpeg/libavcodec/webvttenc.c
|
4369aacb749e507c6f0591b0c7aae9388757dafa
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"BSD-3-Clause",
"LGPL-2.1-only",
"LGPL-3.0-only",
"GPL-2.0-only",
"LGPL-2.1-or-later",
"GPL-3.0-or-later",
"LGPL-3.0-or-later",
"IJG",
"LicenseRef-scancode-other-permissive",
"GPL-2.0-or-later",
"GPL-3.0-only"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C
| false
| false
| 6,226
|
c
|
webvttenc.c
|
/*
* WebVTT subtitle encoder
* Copyright (c) 2010 Aurelien Jacobs <[email protected]>
* Copyright (c) 2014 Aman Gupta <[email protected]>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdarg.h>
#include "avcodec.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "ass_split.h"
#include "ass.h"
#include "codec_internal.h"
#define WEBVTT_STACK_SIZE 64
typedef struct {
AVCodecContext *avctx;
ASSSplitContext *ass_ctx;
AVBPrint buffer;
unsigned timestamp_end;
int count;
char stack[WEBVTT_STACK_SIZE];
int stack_ptr;
} WebVTTContext;
#ifdef __GNUC__
__attribute__ ((__format__ (__printf__, 2, 3)))
#endif
static void webvtt_print(WebVTTContext *s, const char *str, ...)
{
va_list vargs;
va_start(vargs, str);
av_vbprintf(&s->buffer, str, vargs);
va_end(vargs);
}
static int webvtt_stack_push(WebVTTContext *s, const char c)
{
if (s->stack_ptr >= WEBVTT_STACK_SIZE)
return -1;
s->stack[s->stack_ptr++] = c;
return 0;
}
static char webvtt_stack_pop(WebVTTContext *s)
{
if (s->stack_ptr <= 0)
return 0;
return s->stack[--s->stack_ptr];
}
static int webvtt_stack_find(WebVTTContext *s, const char c)
{
int i;
for (i = s->stack_ptr-1; i >= 0; i--)
if (s->stack[i] == c)
break;
return i;
}
static void webvtt_close_tag(WebVTTContext *s, char tag)
{
webvtt_print(s, "</%c>", tag);
}
static void webvtt_stack_push_pop(WebVTTContext *s, const char c, int close)
{
if (close) {
int i = c ? webvtt_stack_find(s, c) : 0;
if (i < 0)
return;
while (s->stack_ptr != i)
webvtt_close_tag(s, webvtt_stack_pop(s));
} else if (webvtt_stack_push(s, c) < 0)
av_log(s->avctx, AV_LOG_ERROR, "tag stack overflow\n");
}
static void webvtt_style_apply(WebVTTContext *s, const char *style)
{
ASSStyle *st = ff_ass_style_get(s->ass_ctx, style);
if (st) {
if (st->bold != ASS_DEFAULT_BOLD) {
webvtt_print(s, "<b>");
webvtt_stack_push(s, 'b');
}
if (st->italic != ASS_DEFAULT_ITALIC) {
webvtt_print(s, "<i>");
webvtt_stack_push(s, 'i');
}
if (st->underline != ASS_DEFAULT_UNDERLINE) {
webvtt_print(s, "<u>");
webvtt_stack_push(s, 'u');
}
}
}
static void webvtt_text_cb(void *priv, const char *text, int len)
{
WebVTTContext *s = priv;
av_bprint_append_data(&s->buffer, text, len);
}
static void webvtt_new_line_cb(void *priv, int forced)
{
webvtt_print(priv, "\n");
}
static void webvtt_style_cb(void *priv, char style, int close)
{
if (style == 's') // strikethrough unsupported
return;
webvtt_stack_push_pop(priv, style, close);
if (!close)
webvtt_print(priv, "<%c>", style);
}
static void webvtt_cancel_overrides_cb(void *priv, const char *style)
{
webvtt_stack_push_pop(priv, 0, 1);
webvtt_style_apply(priv, style);
}
static void webvtt_end_cb(void *priv)
{
webvtt_stack_push_pop(priv, 0, 1);
}
static const ASSCodesCallbacks webvtt_callbacks = {
.text = webvtt_text_cb,
.new_line = webvtt_new_line_cb,
.style = webvtt_style_cb,
.color = NULL,
.font_name = NULL,
.font_size = NULL,
.alignment = NULL,
.cancel_overrides = webvtt_cancel_overrides_cb,
.move = NULL,
.end = webvtt_end_cb,
};
static int webvtt_encode_frame(AVCodecContext *avctx,
unsigned char *buf, int bufsize, const AVSubtitle *sub)
{
WebVTTContext *s = avctx->priv_data;
ASSDialog *dialog;
int i;
av_bprint_clear(&s->buffer);
for (i=0; i<sub->num_rects; i++) {
const char *ass = sub->rects[i]->ass;
if (sub->rects[i]->type != SUBTITLE_ASS) {
av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
return AVERROR(EINVAL);
}
dialog = ff_ass_split_dialog(s->ass_ctx, ass);
if (!dialog)
return AVERROR(ENOMEM);
webvtt_style_apply(s, dialog->style);
ff_ass_split_override_codes(&webvtt_callbacks, s, dialog->text);
ff_ass_free_dialog(&dialog);
}
if (!av_bprint_is_complete(&s->buffer))
return AVERROR(ENOMEM);
if (!s->buffer.len)
return 0;
if (s->buffer.len > bufsize) {
av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
return AVERROR_BUFFER_TOO_SMALL;
}
memcpy(buf, s->buffer.str, s->buffer.len);
return s->buffer.len;
}
static int webvtt_encode_close(AVCodecContext *avctx)
{
WebVTTContext *s = avctx->priv_data;
ff_ass_split_free(s->ass_ctx);
av_bprint_finalize(&s->buffer, NULL);
return 0;
}
static av_cold int webvtt_encode_init(AVCodecContext *avctx)
{
WebVTTContext *s = avctx->priv_data;
s->avctx = avctx;
s->ass_ctx = ff_ass_split(avctx->subtitle_header);
av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
return s->ass_ctx ? 0 : AVERROR_INVALIDDATA;
}
const FFCodec ff_webvtt_encoder = {
.p.name = "webvtt",
CODEC_LONG_NAME("WebVTT subtitle"),
.p.type = AVMEDIA_TYPE_SUBTITLE,
.p.id = AV_CODEC_ID_WEBVTT,
.priv_data_size = sizeof(WebVTTContext),
.init = webvtt_encode_init,
FF_CODEC_ENCODE_SUB_CB(webvtt_encode_frame),
.close = webvtt_encode_close,
};
|
529848c00207d4f023b677b1747bbea5cec6080b
|
77861deda8b3046bdda221d3cb80b77e84b14523
|
/avx512-remove-spaces/avx512-dump.h
|
54175a2e9d25adb5bc7a091792030e5bc4f3a7ad
|
[
"BSD-2-Clause"
] |
permissive
|
WojciechMula/toys
|
b73f09212ca19f1e76bbf2afaa5ad2efcea95175
|
6110b59de45dc1ce44388b21c6437eff49a7655c
|
refs/heads/master
| 2023-08-18T12:54:25.919406
| 2023-08-05T09:20:14
| 2023-08-05T09:20:14
| 14,905,115
| 302
| 44
|
BSD-2-Clause
| 2020-04-17T17:10:42
| 2013-12-03T20:35:37
|
C++
|
UTF-8
|
C
| false
| false
| 27
|
h
|
avx512-dump.h
|
../000helpers/avx512-dump.h
|
f10c8b178ce91703e4cbae1d8993d78166187920
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/app/xlockmore/win32/xlock95.h
|
8c4676725937420488223c5643036b09db35b406
|
[
"LicenseRef-scancode-other-permissive"
] |
permissive
|
openbsd/xenocara
|
cb392d02ebba06f6ff7d826fd8a89aa3b8401779
|
a012b5de33ea0b977095d77316a521195b26cc6b
|
refs/heads/master
| 2023-08-25T12:16:58.862008
| 2023-08-12T16:16:25
| 2023-08-12T16:16:25
| 66,967,384
| 177
| 66
| null | 2023-07-22T18:12:37
| 2016-08-30T18:36:01
|
C
|
UTF-8
|
C
| false
| false
| 264
|
h
|
xlock95.h
|
#define MODE_BOX 1000
#define MODE_LIST 1010
#define DESC_LABEL 1020
#define DELAY_LABEL 1030
#define DELAY_TEXT 1040
#define COUNT_LABEL 1050
#define COUNT_TEXT 1060
#define CYCLES_LABEL 1070
#define CYCLES_TEXT 1080
#define ENABLE_BUTTON 1090
|
f72f5efb84f0eb720e9246a42043d53eeb0fb608
|
cff4428975e403e4ef02d75498b78cd1a610a01a
|
/src/lib/core/assoc.h
|
2351734614481e99f4dcd3cbe1ad1da24ed47759
|
[
"BSD-2-Clause"
] |
permissive
|
tarantool/tarantool
|
c1f252b642d223af62485dc21165c7f7c3354e7e
|
f58cc96f2798ddc5f492223897d0b77e4f902128
|
refs/heads/master
| 2023-09-03T15:16:29.144171
| 2023-08-31T11:39:28
| 2023-09-01T12:39:29
| 911,980
| 3,205
| 490
|
NOASSERTION
| 2023-09-14T17:58:17
| 2010-09-15T07:59:26
|
Lua
|
UTF-8
|
C
| false
| false
| 4,989
|
h
|
assoc.h
|
/*
* Copyright 2010-2016 Tarantool AUTHORS: please see AUTHORS file.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <stdint.h>
#if defined(__cplusplus)
extern "C" {
#endif /* defined(__cplusplus) */
#if !MH_SOURCE
#define MH_UNDEF
#endif
#include <PMurHash.h>
/*
* Set: (i32)
*/
#define mh_name _i32
#define mh_key_t uint32_t
#define mh_node_t uint32_t
#define mh_arg_t void *
#define mh_hash(a, arg) (*(a))
#define mh_hash_key(a, arg) (a)
#define mh_cmp(a, b, arg) (*(a) != *(b))
#define mh_cmp_key(a, b, arg) ((a) != *(b))
#include "salad/mhash.h"
/*
* Map: (i32) => (void *)
*/
#define mh_name _i32ptr
#define mh_key_t uint32_t
struct mh_i32ptr_node_t {
mh_key_t key;
void *val;
};
#define mh_node_t struct mh_i32ptr_node_t
#define mh_arg_t void *
#define mh_hash(a, arg) (a->key)
#define mh_hash_key(a, arg) (a)
#define mh_cmp(a, b, arg) ((a->key) != (b->key))
#define mh_cmp_key(a, b, arg) ((a) != (b->key))
#include "salad/mhash.h"
/*
* Map: (i64) => (void *)
*/
#define mh_name _i64ptr
#define mh_key_t uint64_t
struct mh_i64ptr_node_t {
mh_key_t key;
void *val;
};
#define mh_node_t struct mh_i64ptr_node_t
#define mh_arg_t void *
#define mh_hash(a, arg) (a->key)
#define mh_hash_key(a, arg) (a)
#define mh_cmp(a, b, arg) ((a->key) != (b->key))
#define mh_cmp_key(a, b, arg) ((a) != (b->key))
#include "salad/mhash.h"
/*
* Map: (char * with length) => (void *)
*/
enum {
MH_STRN_HASH_SEED = 13U
};
static inline uint32_t
mh_strn_hash(const char *str, uint32_t len)
{
uint32_t h = MH_STRN_HASH_SEED;
uint32_t carry = 0;
PMurHash32_Process(&h, &carry, str, len);
return PMurHash32_Result(h, carry, len);
}
#define mh_name _strnptr
struct mh_strnptr_key_t {
const char *str;
uint32_t len;
uint32_t hash;
};
#define mh_key_t struct mh_strnptr_key_t *
struct mh_strnptr_node_t {
const char *str;
uint32_t len;
uint32_t hash;
void *val;
};
#define mh_node_t struct mh_strnptr_node_t
#define mh_arg_t void *
#define mh_hash(a, arg) ((a)->hash)
#define mh_hash_key(a, arg) ((a)->hash)
#define mh_cmp(a, b, arg) ((a)->len != (b)->len || \
strncmp((a)->str, (b)->str, (a)->len))
#define mh_cmp_key(a, b, arg) mh_cmp(a, b, arg)
#include "salad/mhash.h"
static inline mh_int_t
mh_strnptr_find_str(struct mh_strnptr_t *h, const char *str, uint32_t len)
{
uint32_t hash = mh_strn_hash(str, len);
struct mh_strnptr_key_t key = {str, len, hash};
return mh_strnptr_find(h, &key, NULL);
}
/*
* Map: (char * with length) => (uint32_t)
*/
#define mh_name _strnu32
/**
* Key of `mh_strnu32_node_t` hash table.
*/
struct mh_strnu32_key_t {
/* Key string. */
const char *str;
/* Key length. */
size_t len;
/* Key hash calculated using `mh_strn_hash`. */
uint32_t hash;
};
#define mh_key_t struct mh_strnu32_key_t *
/**
* Node of `mh_strnu32_node_t` hash table.
*/
struct mh_strnu32_node_t {
/* Key string. */
const char *str;
/* Key length. */
size_t len;
/* Key hash calculated using `mh_strn_hash`. */
uint32_t hash;
/* Mapped value. */
uint32_t val;
};
#define mh_node_t struct mh_strnu32_node_t
#define mh_arg_t void *
#define mh_hash(a, arg) ((a)->hash)
#define mh_hash_key(a, arg) mh_hash(a, arg)
#define mh_cmp(a, b, arg) ((a)->len != (b)->len || \
memcmp((a)->str, (b)->str, (a)->len))
#define mh_cmp_key(a, b, arg) mh_cmp(a, b, arg)
#include "salad/mhash.h"
/**
* Helper for looking up strings in `mh_strnu32_t` hash table.
*/
static inline mh_int_t
mh_strnu32_find_str(struct mh_strnu32_t *h, const char *str, uint32_t len)
{
uint32_t hash = mh_strn_hash(str, len);
struct mh_strnu32_key_t key = {str, len, hash};
return mh_strnu32_find(h, &key, NULL);
}
#if defined(__cplusplus)
} /* extern "C" */
#endif /* defined(__cplusplus) */
|
8bed16d36dfb64a296705973ed7e35dcfa9707d1
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/libcpu/risc-v/t-head/c906/symbol_analysis.h
|
a9db46ffd39db4435c1e451353ede2ac56586e40
|
[
"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
| 1,721
|
h
|
symbol_analysis.h
|
/*
* Copyright lizhirui
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-05-18 lizhirui the first version
* 2021-05-20 lizhirui add os debug support
*/
#ifndef __SYMBOL_ANALYSIS_H__
#define __SYMBOL_ANALYSIS_H__
#include <rtthread.h>
//osdebug节区头描述结构体
typedef struct os_symtab_header
{
rt_size_t function_table_offset;//函数表的偏移地址(相对于节区起始地址,下同)
rt_size_t function_table_num;//函数表中的符号数量
rt_size_t object_table_offset;//对象表的偏移地址
rt_size_t object_table_num;//对象表中的符号数量
rt_size_t general_symbol_table_offset;//一般符号(指代类型虽为NONE但带有GLOBAL的符号)表的偏移地址
rt_size_t general_symbol_table_num;//一般符号表中的符号数量
rt_size_t string_table_offset;//字符串表的偏移地址
rt_size_t string_table_size;//字符串表的大小(字节为单位)
}os_symtab_header;
//符号描述结构体
typedef struct os_symtab_item
{
rt_size_t name_offset;//符号名称在字符串表中的偏移地址
rt_size_t address;//该符号所代表的地址
rt_size_t size;//该符号所代表的大小
}os_symtab_item;
os_symtab_item *find_symbol_table(rt_size_t symbol_table_addr,rt_size_t symbol_num,rt_size_t address);
const char *get_symbol_name(os_symtab_item *symbol);
void print_symbol(os_symtab_item *symbol,rt_size_t address);
void print_symbol_info(rt_size_t address,rt_bool_t function);
void print_stacktrace(rt_size_t epc,rt_size_t fp);
#endif
|
8ba8cc7e577278842b3f1949dcb0acc7fc4ba21a
|
409d14156eb919757bf1c6ae8c94827520e98667
|
/W5500/Internet/FTPClient/ftpc.h
|
535c1066abc6d335f415350df8860ead76e9ad8c
|
[
"BSD-3-Clause"
] |
permissive
|
Mculover666/HAL_Driver_Lib
|
8fa69e7590802290b1ef8b33dee6585d1c8a51e0
|
2c09811e01fed3ec64c85be50a5565f55fee995d
|
refs/heads/master
| 2023-04-12T03:27:19.326842
| 2023-04-08T14:30:03
| 2023-04-08T14:30:03
| 196,137,750
| 189
| 78
|
BSD-3-Clause
| 2022-06-26T10:39:17
| 2019-07-10T05:33:30
|
C
|
UTF-8
|
C
| false
| false
| 2,518
|
h
|
ftpc.h
|
#ifndef _FTPC_H_
#define _FTPC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <stdarg.h>
#include "stdio_private.h"
#include "socket.h"
#define F_APP_FTPC
/* If your target support a file system, you have to activate this feature and implement. */
//#define F_FILESYSTEM
/* Change to your Chipset Uart function, you have to activate this feature and implement.
* Change!! -> Board_UARTGetCharBlocking()
* Below is an example of a function of lpc_chip library. */
//#define ftp_getc() Board_UARTGetCharBlocking()
#ifdef F_FILESYSTEM
#include "ff.h"
#endif
#ifndef ftp_getc()
#define Need_UARTGetCharBlocking_func
#else
/* Change library
* Change!! -> board_api.h,
* Below is an example of a function of lpc_chip library. */
#include "board_api.h"
#endif
#define LINELEN 100
#ifndef F_FILESYSTEM
#define _MAX_SS 512
#endif
#define CTRL_SOCK 2
#define DATA_SOCK 3
/* FTP Responses */
#define R_150 150 /* File status ok; opening data conn */
#define R_200 200 /* 'Generic' command ok */
#define R_220 220 /* Service ready for new user. */
#define R_226 226 /* Closing data connection. File transfer/abort successful */
#define R_227 227 /* Entering passive mode (h1,h2,h3,h4,p1,p2) */
#define R_230 230 /* User logged in, proceed */
#define R_331 331 /* User name okay, need password. */
#define TransferAscii 'A'
#define TransferBinary 'I'
enum ftpc_type {
ASCII_TYPE,
IMAGE_TYPE,
};
enum ftpc_datasock_state{
DATASOCK_IDLE,
DATASOCK_READY,
DATASOCK_START
};
enum ftpc_datasock_mode{
PASSIVE_MODE,
ACTIVE_MODE
};
enum CommandFirst {
f_nocmd,
f_dir,
f_put,
f_get,
};
enum CommandSecond {
s_nocmd,
s_dir,
s_put,
s_get,
};
struct Command {
enum CommandFirst First;
enum CommandSecond Second;
};
struct ftpc {
uint8_t control; /* Control stream */
uint8_t data; /* Data stream */
enum ftpc_type type; /* Transfer type */
enum ftpc_datasock_state dsock_state;
enum ftpc_datasock_mode dsock_mode;
char workingdir[LINELEN];
char filename[LINELEN];
#ifdef F_FILESYSTEM
FIL fil; // FatFs File objects
FRESULT fr; // FatFs function common result code
#endif
};
#ifndef un_I2cval
typedef union _un_l2cval {
uint32_t lVal;
uint8_t cVal[4];
}un_l2cval;
#endif
void ftpc_init(uint8_t * src_ip);
uint8_t ftpc_run(uint8_t * dbuf);
char proc_ftpc(char * buf);
int pportc(char * arg);
uint8_t* User_Keyboard_MSG();
#ifdef __cplusplus
}
#endif
#endif // _FTPC_H_
|
bc618f3301dcf0f228a349d2f41999baca77600c
|
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
|
/SOFTWARE/A64-TERES/linux-a64/net/netfilter/nf_nat_core.c
|
2bb801e3ee8c488243e7d50cf47057c94fc394d3
|
[
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"Linux-syscall-note",
"GPL-2.0-only",
"GPL-1.0-or-later"
] |
permissive
|
OLIMEX/DIY-LAPTOP
|
ae82f4ee79c641d9aee444db9a75f3f6709afa92
|
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
|
refs/heads/rel3
| 2023-08-04T01:54:19.483792
| 2023-04-03T07:18:12
| 2023-04-03T07:18:12
| 80,094,055
| 507
| 92
|
Apache-2.0
| 2023-04-03T07:05:59
| 2017-01-26T07:25:50
|
C
|
UTF-8
|
C
| false
| false
| 23,803
|
c
|
nf_nat_core.c
|
/*
* (C) 1999-2001 Paul `Rusty' Russell
* (C) 2002-2006 Netfilter Core Team <[email protected]>
* (C) 2011 Patrick McHardy <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/skbuff.h>
#include <linux/gfp.h>
#include <net/xfrm.h>
#include <linux/jhash.h>
#include <linux/rtnetlink.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_core.h>
#include <net/netfilter/nf_nat.h>
#include <net/netfilter/nf_nat_l3proto.h>
#include <net/netfilter/nf_nat_l4proto.h>
#include <net/netfilter/nf_nat_core.h>
#include <net/netfilter/nf_nat_helper.h>
#include <net/netfilter/nf_conntrack_helper.h>
#include <net/netfilter/nf_conntrack_l3proto.h>
#include <net/netfilter/nf_conntrack_zones.h>
#include <linux/netfilter/nf_nat.h>
static DEFINE_SPINLOCK(nf_nat_lock);
static DEFINE_MUTEX(nf_nat_proto_mutex);
static const struct nf_nat_l3proto __rcu *nf_nat_l3protos[NFPROTO_NUMPROTO]
__read_mostly;
static const struct nf_nat_l4proto __rcu **nf_nat_l4protos[NFPROTO_NUMPROTO]
__read_mostly;
inline const struct nf_nat_l3proto *
__nf_nat_l3proto_find(u8 family)
{
return rcu_dereference(nf_nat_l3protos[family]);
}
inline const struct nf_nat_l4proto *
__nf_nat_l4proto_find(u8 family, u8 protonum)
{
return rcu_dereference(nf_nat_l4protos[family][protonum]);
}
EXPORT_SYMBOL_GPL(__nf_nat_l4proto_find);
#ifdef CONFIG_XFRM
static void __nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl)
{
const struct nf_nat_l3proto *l3proto;
const struct nf_conn *ct;
enum ip_conntrack_info ctinfo;
enum ip_conntrack_dir dir;
unsigned long statusbit;
u8 family;
ct = nf_ct_get(skb, &ctinfo);
if (ct == NULL)
return;
family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
rcu_read_lock();
l3proto = __nf_nat_l3proto_find(family);
if (l3proto == NULL)
goto out;
dir = CTINFO2DIR(ctinfo);
if (dir == IP_CT_DIR_ORIGINAL)
statusbit = IPS_DST_NAT;
else
statusbit = IPS_SRC_NAT;
l3proto->decode_session(skb, ct, dir, statusbit, fl);
out:
rcu_read_unlock();
}
int nf_xfrm_me_harder(struct sk_buff *skb, unsigned int family)
{
struct flowi fl;
unsigned int hh_len;
struct dst_entry *dst;
int err;
err = xfrm_decode_session(skb, &fl, family);
if (err < 0)
return err;
dst = skb_dst(skb);
if (dst->xfrm)
dst = ((struct xfrm_dst *)dst)->route;
dst_hold(dst);
dst = xfrm_lookup(dev_net(dst->dev), dst, &fl, skb->sk, 0);
if (IS_ERR(dst))
return PTR_ERR(dst);
skb_dst_drop(skb);
skb_dst_set(skb, dst);
/* Change in oif may mean change in hh_len. */
hh_len = skb_dst(skb)->dev->hard_header_len;
if (skb_headroom(skb) < hh_len &&
pskb_expand_head(skb, hh_len - skb_headroom(skb), 0, GFP_ATOMIC))
return -ENOMEM;
return 0;
}
EXPORT_SYMBOL(nf_xfrm_me_harder);
#endif /* CONFIG_XFRM */
/* We keep an extra hash for each conntrack, for fast searching. */
static inline unsigned int
hash_by_src(const struct net *net, u16 zone,
const struct nf_conntrack_tuple *tuple)
{
unsigned int hash;
/* Original src, to ensure we map it consistently if poss. */
hash = jhash2((u32 *)&tuple->src, sizeof(tuple->src) / sizeof(u32),
tuple->dst.protonum ^ zone ^ nf_conntrack_hash_rnd);
return ((u64)hash * net->ct.nat_htable_size) >> 32;
}
/* Is this tuple already taken? (not by us) */
int
nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
const struct nf_conn *ignored_conntrack)
{
/* Conntrack tracking doesn't keep track of outgoing tuples; only
* incoming ones. NAT means they don't have a fixed mapping,
* so we invert the tuple and look for the incoming reply.
*
* We could keep a separate hash if this proves too slow.
*/
struct nf_conntrack_tuple reply;
nf_ct_invert_tuplepr(&reply, tuple);
return nf_conntrack_tuple_taken(&reply, ignored_conntrack);
}
EXPORT_SYMBOL(nf_nat_used_tuple);
/* If we source map this tuple so reply looks like reply_tuple, will
* that meet the constraints of range.
*/
static int in_range(const struct nf_nat_l3proto *l3proto,
const struct nf_nat_l4proto *l4proto,
const struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range)
{
/* If we are supposed to map IPs, then we must be in the
* range specified, otherwise let this drag us onto a new src IP.
*/
if (range->flags & NF_NAT_RANGE_MAP_IPS &&
!l3proto->in_range(tuple, range))
return 0;
if (!(range->flags & NF_NAT_RANGE_PROTO_SPECIFIED) ||
l4proto->in_range(tuple, NF_NAT_MANIP_SRC,
&range->min_proto, &range->max_proto))
return 1;
return 0;
}
static inline int
same_src(const struct nf_conn *ct,
const struct nf_conntrack_tuple *tuple)
{
const struct nf_conntrack_tuple *t;
t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
return (t->dst.protonum == tuple->dst.protonum &&
nf_inet_addr_cmp(&t->src.u3, &tuple->src.u3) &&
t->src.u.all == tuple->src.u.all);
}
/* Only called for SRC manip */
static int
find_appropriate_src(struct net *net, u16 zone,
const struct nf_nat_l3proto *l3proto,
const struct nf_nat_l4proto *l4proto,
const struct nf_conntrack_tuple *tuple,
struct nf_conntrack_tuple *result,
const struct nf_nat_range *range)
{
unsigned int h = hash_by_src(net, zone, tuple);
const struct nf_conn_nat *nat;
const struct nf_conn *ct;
hlist_for_each_entry_rcu(nat, &net->ct.nat_bysource[h], bysource) {
ct = nat->ct;
if (same_src(ct, tuple) && nf_ct_zone(ct) == zone) {
/* Copy source part from reply tuple. */
nf_ct_invert_tuplepr(result,
&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
result->dst = tuple->dst;
if (in_range(l3proto, l4proto, result, range))
return 1;
}
}
return 0;
}
/* For [FUTURE] fragmentation handling, we want the least-used
* src-ip/dst-ip/proto triple. Fairness doesn't come into it. Thus
* if the range specifies 1.2.3.4 ports 10000-10005 and 1.2.3.5 ports
* 1-65535, we don't do pro-rata allocation based on ports; we choose
* the ip with the lowest src-ip/dst-ip/proto usage.
*/
static void
find_best_ips_proto(u16 zone, struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range,
const struct nf_conn *ct,
enum nf_nat_manip_type maniptype)
{
union nf_inet_addr *var_ipp;
unsigned int i, max;
/* Host order */
u32 minip, maxip, j, dist;
bool full_range;
/* No IP mapping? Do nothing. */
if (!(range->flags & NF_NAT_RANGE_MAP_IPS))
return;
if (maniptype == NF_NAT_MANIP_SRC)
var_ipp = &tuple->src.u3;
else
var_ipp = &tuple->dst.u3;
/* Fast path: only one choice. */
if (nf_inet_addr_cmp(&range->min_addr, &range->max_addr)) {
*var_ipp = range->min_addr;
return;
}
if (nf_ct_l3num(ct) == NFPROTO_IPV4)
max = sizeof(var_ipp->ip) / sizeof(u32) - 1;
else
max = sizeof(var_ipp->ip6) / sizeof(u32) - 1;
/* Hashing source and destination IPs gives a fairly even
* spread in practice (if there are a small number of IPs
* involved, there usually aren't that many connections
* anyway). The consistency means that servers see the same
* client coming from the same IP (some Internet Banking sites
* like this), even across reboots.
*/
j = jhash2((u32 *)&tuple->src.u3, sizeof(tuple->src.u3) / sizeof(u32),
range->flags & NF_NAT_RANGE_PERSISTENT ?
0 : (__force u32)tuple->dst.u3.all[max] ^ zone);
full_range = false;
for (i = 0; i <= max; i++) {
/* If first bytes of the address are at the maximum, use the
* distance. Otherwise use the full range.
*/
if (!full_range) {
minip = ntohl((__force __be32)range->min_addr.all[i]);
maxip = ntohl((__force __be32)range->max_addr.all[i]);
dist = maxip - minip + 1;
} else {
minip = 0;
dist = ~0;
}
var_ipp->all[i] = (__force __u32)
htonl(minip + (((u64)j * dist) >> 32));
if (var_ipp->all[i] != range->max_addr.all[i])
full_range = true;
if (!(range->flags & NF_NAT_RANGE_PERSISTENT))
j ^= (__force u32)tuple->dst.u3.all[i];
}
}
/* Manipulate the tuple into the range given. For NF_INET_POST_ROUTING,
* we change the source to map into the range. For NF_INET_PRE_ROUTING
* and NF_INET_LOCAL_OUT, we change the destination to map into the
* range. It might not be possible to get a unique tuple, but we try.
* At worst (or if we race), we will end up with a final duplicate in
* __ip_conntrack_confirm and drop the packet. */
static void
get_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_conntrack_tuple *orig_tuple,
const struct nf_nat_range *range,
struct nf_conn *ct,
enum nf_nat_manip_type maniptype)
{
const struct nf_nat_l3proto *l3proto;
const struct nf_nat_l4proto *l4proto;
struct net *net = nf_ct_net(ct);
u16 zone = nf_ct_zone(ct);
rcu_read_lock();
l3proto = __nf_nat_l3proto_find(orig_tuple->src.l3num);
l4proto = __nf_nat_l4proto_find(orig_tuple->src.l3num,
orig_tuple->dst.protonum);
/* 1) If this srcip/proto/src-proto-part is currently mapped,
* and that same mapping gives a unique tuple within the given
* range, use that.
*
* This is only required for source (ie. NAT/masq) mappings.
* So far, we don't do local source mappings, so multiple
* manips not an issue.
*/
if (maniptype == NF_NAT_MANIP_SRC &&
!(range->flags & NF_NAT_RANGE_PROTO_RANDOM)) {
/* try the original tuple first */
if (in_range(l3proto, l4proto, orig_tuple, range)) {
if (!nf_nat_used_tuple(orig_tuple, ct)) {
*tuple = *orig_tuple;
goto out;
}
} else if (find_appropriate_src(net, zone, l3proto, l4proto,
orig_tuple, tuple, range)) {
pr_debug("get_unique_tuple: Found current src map\n");
if (!nf_nat_used_tuple(tuple, ct))
goto out;
}
}
/* 2) Select the least-used IP/proto combination in the given range */
*tuple = *orig_tuple;
find_best_ips_proto(zone, tuple, range, ct, maniptype);
/* 3) The per-protocol part of the manip is made to map into
* the range to make a unique tuple.
*/
/* Only bother mapping if it's not already in range and unique */
if (!(range->flags & NF_NAT_RANGE_PROTO_RANDOM)) {
if (range->flags & NF_NAT_RANGE_PROTO_SPECIFIED) {
if (l4proto->in_range(tuple, maniptype,
&range->min_proto,
&range->max_proto) &&
(range->min_proto.all == range->max_proto.all ||
!nf_nat_used_tuple(tuple, ct)))
goto out;
} else if (!nf_nat_used_tuple(tuple, ct)) {
goto out;
}
}
/* Last change: get protocol to try to obtain unique tuple. */
l4proto->unique_tuple(l3proto, tuple, range, maniptype, ct);
out:
rcu_read_unlock();
}
unsigned int
nf_nat_setup_info(struct nf_conn *ct,
const struct nf_nat_range *range,
enum nf_nat_manip_type maniptype)
{
struct net *net = nf_ct_net(ct);
struct nf_conntrack_tuple curr_tuple, new_tuple;
struct nf_conn_nat *nat;
/* nat helper or nfctnetlink also setup binding */
nat = nfct_nat(ct);
if (!nat) {
nat = nf_ct_ext_add(ct, NF_CT_EXT_NAT, GFP_ATOMIC);
if (nat == NULL) {
pr_debug("failed to add NAT extension\n");
return NF_ACCEPT;
}
}
NF_CT_ASSERT(maniptype == NF_NAT_MANIP_SRC ||
maniptype == NF_NAT_MANIP_DST);
BUG_ON(nf_nat_initialized(ct, maniptype));
/* What we've got will look like inverse of reply. Normally
* this is what is in the conntrack, except for prior
* manipulations (future optimization: if num_manips == 0,
* orig_tp = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple)
*/
nf_ct_invert_tuplepr(&curr_tuple,
&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
get_unique_tuple(&new_tuple, &curr_tuple, range, ct, maniptype);
if (!nf_ct_tuple_equal(&new_tuple, &curr_tuple)) {
struct nf_conntrack_tuple reply;
/* Alter conntrack table so will recognize replies. */
nf_ct_invert_tuplepr(&reply, &new_tuple);
nf_conntrack_alter_reply(ct, &reply);
/* Non-atomic: we own this at the moment. */
if (maniptype == NF_NAT_MANIP_SRC)
ct->status |= IPS_SRC_NAT;
else
ct->status |= IPS_DST_NAT;
}
if (maniptype == NF_NAT_MANIP_SRC) {
unsigned int srchash;
srchash = hash_by_src(net, nf_ct_zone(ct),
&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
spin_lock_bh(&nf_nat_lock);
/* nf_conntrack_alter_reply might re-allocate extension aera */
nat = nfct_nat(ct);
nat->ct = ct;
hlist_add_head_rcu(&nat->bysource,
&net->ct.nat_bysource[srchash]);
spin_unlock_bh(&nf_nat_lock);
}
/* It's done. */
if (maniptype == NF_NAT_MANIP_DST)
ct->status |= IPS_DST_NAT_DONE;
else
ct->status |= IPS_SRC_NAT_DONE;
return NF_ACCEPT;
}
EXPORT_SYMBOL(nf_nat_setup_info);
/* Do packet manipulations according to nf_nat_setup_info. */
unsigned int nf_nat_packet(struct nf_conn *ct,
enum ip_conntrack_info ctinfo,
unsigned int hooknum,
struct sk_buff *skb)
{
const struct nf_nat_l3proto *l3proto;
const struct nf_nat_l4proto *l4proto;
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
unsigned long statusbit;
enum nf_nat_manip_type mtype = HOOK2MANIP(hooknum);
if (mtype == NF_NAT_MANIP_SRC)
statusbit = IPS_SRC_NAT;
else
statusbit = IPS_DST_NAT;
/* Invert if this is reply dir. */
if (dir == IP_CT_DIR_REPLY)
statusbit ^= IPS_NAT_MASK;
/* Non-atomic: these bits don't change. */
if (ct->status & statusbit) {
struct nf_conntrack_tuple target;
/* We are aiming to look like inverse of other direction. */
nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
l3proto = __nf_nat_l3proto_find(target.src.l3num);
l4proto = __nf_nat_l4proto_find(target.src.l3num,
target.dst.protonum);
if (!l3proto->manip_pkt(skb, 0, l4proto, &target, mtype))
return NF_DROP;
}
return NF_ACCEPT;
}
EXPORT_SYMBOL_GPL(nf_nat_packet);
struct nf_nat_proto_clean {
u8 l3proto;
u8 l4proto;
};
/* kill conntracks with affected NAT section */
static int nf_nat_proto_remove(struct nf_conn *i, void *data)
{
const struct nf_nat_proto_clean *clean = data;
struct nf_conn_nat *nat = nfct_nat(i);
if (!nat)
return 0;
if ((clean->l3proto && nf_ct_l3num(i) != clean->l3proto) ||
(clean->l4proto && nf_ct_protonum(i) != clean->l4proto))
return 0;
return i->status & IPS_NAT_MASK ? 1 : 0;
}
static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
{
struct nf_conn_nat *nat = nfct_nat(ct);
if (nf_nat_proto_remove(ct, data))
return 1;
if (!nat || !nat->ct)
return 0;
/* This netns is being destroyed, and conntrack has nat null binding.
* Remove it from bysource hash, as the table will be freed soon.
*
* Else, when the conntrack is destoyed, nf_nat_cleanup_conntrack()
* will delete entry from already-freed table.
*/
if (!del_timer(&ct->timeout))
return 1;
spin_lock_bh(&nf_nat_lock);
hlist_del_rcu(&nat->bysource);
ct->status &= ~IPS_NAT_DONE_MASK;
nat->ct = NULL;
spin_unlock_bh(&nf_nat_lock);
add_timer(&ct->timeout);
/* don't delete conntrack. Although that would make things a lot
* simpler, we'd end up flushing all conntracks on nat rmmod.
*/
return 0;
}
static void nf_nat_l4proto_clean(u8 l3proto, u8 l4proto)
{
struct nf_nat_proto_clean clean = {
.l3proto = l3proto,
.l4proto = l4proto,
};
struct net *net;
rtnl_lock();
for_each_net(net)
nf_ct_iterate_cleanup(net, nf_nat_proto_remove, &clean);
rtnl_unlock();
}
static void nf_nat_l3proto_clean(u8 l3proto)
{
struct nf_nat_proto_clean clean = {
.l3proto = l3proto,
};
struct net *net;
rtnl_lock();
for_each_net(net)
nf_ct_iterate_cleanup(net, nf_nat_proto_remove, &clean);
rtnl_unlock();
}
/* Protocol registration. */
int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto)
{
const struct nf_nat_l4proto **l4protos;
unsigned int i;
int ret = 0;
mutex_lock(&nf_nat_proto_mutex);
if (nf_nat_l4protos[l3proto] == NULL) {
l4protos = kmalloc(IPPROTO_MAX * sizeof(struct nf_nat_l4proto *),
GFP_KERNEL);
if (l4protos == NULL) {
ret = -ENOMEM;
goto out;
}
for (i = 0; i < IPPROTO_MAX; i++)
RCU_INIT_POINTER(l4protos[i], &nf_nat_l4proto_unknown);
/* Before making proto_array visible to lockless readers,
* we must make sure its content is committed to memory.
*/
smp_wmb();
nf_nat_l4protos[l3proto] = l4protos;
}
if (rcu_dereference_protected(
nf_nat_l4protos[l3proto][l4proto->l4proto],
lockdep_is_held(&nf_nat_proto_mutex)
) != &nf_nat_l4proto_unknown) {
ret = -EBUSY;
goto out;
}
RCU_INIT_POINTER(nf_nat_l4protos[l3proto][l4proto->l4proto], l4proto);
out:
mutex_unlock(&nf_nat_proto_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(nf_nat_l4proto_register);
/* No one stores the protocol anywhere; simply delete it. */
void nf_nat_l4proto_unregister(u8 l3proto, const struct nf_nat_l4proto *l4proto)
{
mutex_lock(&nf_nat_proto_mutex);
RCU_INIT_POINTER(nf_nat_l4protos[l3proto][l4proto->l4proto],
&nf_nat_l4proto_unknown);
mutex_unlock(&nf_nat_proto_mutex);
synchronize_rcu();
nf_nat_l4proto_clean(l3proto, l4proto->l4proto);
}
EXPORT_SYMBOL_GPL(nf_nat_l4proto_unregister);
int nf_nat_l3proto_register(const struct nf_nat_l3proto *l3proto)
{
int err;
err = nf_ct_l3proto_try_module_get(l3proto->l3proto);
if (err < 0)
return err;
mutex_lock(&nf_nat_proto_mutex);
RCU_INIT_POINTER(nf_nat_l4protos[l3proto->l3proto][IPPROTO_TCP],
&nf_nat_l4proto_tcp);
RCU_INIT_POINTER(nf_nat_l4protos[l3proto->l3proto][IPPROTO_UDP],
&nf_nat_l4proto_udp);
mutex_unlock(&nf_nat_proto_mutex);
RCU_INIT_POINTER(nf_nat_l3protos[l3proto->l3proto], l3proto);
return 0;
}
EXPORT_SYMBOL_GPL(nf_nat_l3proto_register);
void nf_nat_l3proto_unregister(const struct nf_nat_l3proto *l3proto)
{
mutex_lock(&nf_nat_proto_mutex);
RCU_INIT_POINTER(nf_nat_l3protos[l3proto->l3proto], NULL);
mutex_unlock(&nf_nat_proto_mutex);
synchronize_rcu();
nf_nat_l3proto_clean(l3proto->l3proto);
nf_ct_l3proto_module_put(l3proto->l3proto);
}
EXPORT_SYMBOL_GPL(nf_nat_l3proto_unregister);
/* No one using conntrack by the time this called. */
static void nf_nat_cleanup_conntrack(struct nf_conn *ct)
{
struct nf_conn_nat *nat = nf_ct_ext_find(ct, NF_CT_EXT_NAT);
if (nat == NULL || nat->ct == NULL)
return;
NF_CT_ASSERT(nat->ct->status & IPS_SRC_NAT_DONE);
spin_lock_bh(&nf_nat_lock);
hlist_del_rcu(&nat->bysource);
spin_unlock_bh(&nf_nat_lock);
}
static void nf_nat_move_storage(void *new, void *old)
{
struct nf_conn_nat *new_nat = new;
struct nf_conn_nat *old_nat = old;
struct nf_conn *ct = old_nat->ct;
if (!ct || !(ct->status & IPS_SRC_NAT_DONE))
return;
spin_lock_bh(&nf_nat_lock);
hlist_replace_rcu(&old_nat->bysource, &new_nat->bysource);
spin_unlock_bh(&nf_nat_lock);
}
static struct nf_ct_ext_type nat_extend __read_mostly = {
.len = sizeof(struct nf_conn_nat),
.align = __alignof__(struct nf_conn_nat),
.destroy = nf_nat_cleanup_conntrack,
.move = nf_nat_move_storage,
.id = NF_CT_EXT_NAT,
.flags = NF_CT_EXT_F_PREALLOC,
};
#if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nfnetlink_conntrack.h>
static const struct nla_policy protonat_nla_policy[CTA_PROTONAT_MAX+1] = {
[CTA_PROTONAT_PORT_MIN] = { .type = NLA_U16 },
[CTA_PROTONAT_PORT_MAX] = { .type = NLA_U16 },
};
static int nfnetlink_parse_nat_proto(struct nlattr *attr,
const struct nf_conn *ct,
struct nf_nat_range *range)
{
struct nlattr *tb[CTA_PROTONAT_MAX+1];
const struct nf_nat_l4proto *l4proto;
int err;
err = nla_parse_nested(tb, CTA_PROTONAT_MAX, attr, protonat_nla_policy);
if (err < 0)
return err;
l4proto = __nf_nat_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct));
if (l4proto->nlattr_to_range)
err = l4proto->nlattr_to_range(tb, range);
return err;
}
static const struct nla_policy nat_nla_policy[CTA_NAT_MAX+1] = {
[CTA_NAT_V4_MINIP] = { .type = NLA_U32 },
[CTA_NAT_V4_MAXIP] = { .type = NLA_U32 },
[CTA_NAT_V6_MINIP] = { .len = sizeof(struct in6_addr) },
[CTA_NAT_V6_MAXIP] = { .len = sizeof(struct in6_addr) },
[CTA_NAT_PROTO] = { .type = NLA_NESTED },
};
static int
nfnetlink_parse_nat(const struct nlattr *nat,
const struct nf_conn *ct, struct nf_nat_range *range)
{
const struct nf_nat_l3proto *l3proto;
struct nlattr *tb[CTA_NAT_MAX+1];
int err;
memset(range, 0, sizeof(*range));
err = nla_parse_nested(tb, CTA_NAT_MAX, nat, nat_nla_policy);
if (err < 0)
return err;
rcu_read_lock();
l3proto = __nf_nat_l3proto_find(nf_ct_l3num(ct));
if (l3proto == NULL) {
err = -EAGAIN;
goto out;
}
err = l3proto->nlattr_to_range(tb, range);
if (err < 0)
goto out;
if (!tb[CTA_NAT_PROTO])
goto out;
err = nfnetlink_parse_nat_proto(tb[CTA_NAT_PROTO], ct, range);
out:
rcu_read_unlock();
return err;
}
static int
nfnetlink_parse_nat_setup(struct nf_conn *ct,
enum nf_nat_manip_type manip,
const struct nlattr *attr)
{
struct nf_nat_range range;
int err;
err = nfnetlink_parse_nat(attr, ct, &range);
if (err < 0)
return err;
if (nf_nat_initialized(ct, manip))
return -EEXIST;
return nf_nat_setup_info(ct, &range, manip);
}
#else
static int
nfnetlink_parse_nat_setup(struct nf_conn *ct,
enum nf_nat_manip_type manip,
const struct nlattr *attr)
{
return -EOPNOTSUPP;
}
#endif
static int __net_init nf_nat_net_init(struct net *net)
{
/* Leave them the same for the moment. */
net->ct.nat_htable_size = net->ct.htable_size;
net->ct.nat_bysource = nf_ct_alloc_hashtable(&net->ct.nat_htable_size, 0);
if (!net->ct.nat_bysource)
return -ENOMEM;
return 0;
}
static void __net_exit nf_nat_net_exit(struct net *net)
{
struct nf_nat_proto_clean clean = {};
nf_ct_iterate_cleanup(net, nf_nat_proto_clean, &clean);
synchronize_rcu();
nf_ct_free_hashtable(net->ct.nat_bysource, net->ct.nat_htable_size);
}
static struct pernet_operations nf_nat_net_ops = {
.init = nf_nat_net_init,
.exit = nf_nat_net_exit,
};
static struct nf_ct_helper_expectfn follow_master_nat = {
.name = "nat-follow-master",
.expectfn = nf_nat_follow_master,
};
static struct nfq_ct_nat_hook nfq_ct_nat = {
.seq_adjust = nf_nat_tcp_seq_adjust,
};
static int __init nf_nat_init(void)
{
int ret;
ret = nf_ct_extend_register(&nat_extend);
if (ret < 0) {
printk(KERN_ERR "nf_nat_core: Unable to register extension\n");
return ret;
}
ret = register_pernet_subsys(&nf_nat_net_ops);
if (ret < 0)
goto cleanup_extend;
nf_ct_helper_expectfn_register(&follow_master_nat);
/* Initialize fake conntrack so that NAT will skip it */
nf_ct_untracked_status_or(IPS_NAT_DONE_MASK);
BUG_ON(nf_nat_seq_adjust_hook != NULL);
RCU_INIT_POINTER(nf_nat_seq_adjust_hook, nf_nat_seq_adjust);
BUG_ON(nfnetlink_parse_nat_setup_hook != NULL);
RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook,
nfnetlink_parse_nat_setup);
BUG_ON(nf_ct_nat_offset != NULL);
RCU_INIT_POINTER(nf_ct_nat_offset, nf_nat_get_offset);
RCU_INIT_POINTER(nfq_ct_nat_hook, &nfq_ct_nat);
#ifdef CONFIG_XFRM
BUG_ON(nf_nat_decode_session_hook != NULL);
RCU_INIT_POINTER(nf_nat_decode_session_hook, __nf_nat_decode_session);
#endif
return 0;
cleanup_extend:
nf_ct_extend_unregister(&nat_extend);
return ret;
}
static void __exit nf_nat_cleanup(void)
{
unsigned int i;
unregister_pernet_subsys(&nf_nat_net_ops);
nf_ct_extend_unregister(&nat_extend);
nf_ct_helper_expectfn_unregister(&follow_master_nat);
RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL);
RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL);
RCU_INIT_POINTER(nf_ct_nat_offset, NULL);
RCU_INIT_POINTER(nfq_ct_nat_hook, NULL);
#ifdef CONFIG_XFRM
RCU_INIT_POINTER(nf_nat_decode_session_hook, NULL);
#endif
for (i = 0; i < NFPROTO_NUMPROTO; i++)
kfree(nf_nat_l4protos[i]);
synchronize_net();
}
MODULE_LICENSE("GPL");
module_init(nf_nat_init);
module_exit(nf_nat_cleanup);
|
df08286ec099ae37c0ea39d8cd59edc9ee111f78
|
50dd46b8ece33f3cdd174284b15d1d51f89669d4
|
/third_party/edk2/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Package.c
|
caa5cf87d408b282e8a31c3a7c1903e47cebfd8e
|
[
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause",
"OpenSSL"
] |
permissive
|
google/google-ctf
|
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
|
df02323eaf945d15e124801c74abaadca2749dc7
|
refs/heads/master
| 2023-08-31T14:30:27.548081
| 2023-08-29T13:04:20
| 2023-08-29T13:04:20
| 131,317,137
| 4,136
| 607
|
Apache-2.0
| 2023-08-30T22:17:02
| 2018-04-27T15:56:03
|
Go
|
UTF-8
|
C
| false
| false
| 30,008
|
c
|
Package.c
|
/** @file
Implement protocol interface related to package registrations.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "HiiDatabase.h"
#include "HiiHandle.h"
BOOLEAN mInFrameworkHiiNewPack = FALSE;
BOOLEAN mInFrameworkHiiRemovePack = FALSE;
BOOLEAN mInFrameworkUpdatePakcage = FALSE;
UINT64 mGuidCount = 0;
EFI_GUID mGuidBase = { 0x14f95e01, 0xd562, 0x432e, { 0x84, 0x4a, 0x95, 0xa4, 0x39, 0x5, 0x10, 0x7e }};
/**
Get the number of Form, STRING and Font packages in the package list passed in.
@param Packages Package List.
@param IfrPackageCount Number of IFR Packages.
@param StringPackageCount Number of String Packages.
@param FontPackageCount Number of Font Packages.
@retval EFI_INVALID_PARAMETER If the Package List has package with type of
EFI_HII_PACKAGE_KEYBOARD_LAYOUT, EFI_HII_PACKAGE_FONTS, EFI_HII_PACKAGE_IMAGES.
@retval EFI_SUCCESS Successfully get the number of IFR and STRING package.
**/
EFI_STATUS
GetPackageCount (
IN CONST EFI_HII_PACKAGES *Packages,
OUT UINTN *IfrPackageCount,
OUT UINTN *StringPackageCount,
OUT UINTN *FontPackageCount
)
{
UINTN Index;
TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
ASSERT (Packages != NULL);
ASSERT (IfrPackageCount != NULL);
ASSERT (StringPackageCount != NULL);
ASSERT (FontPackageCount != NULL);
*IfrPackageCount = 0;
*StringPackageCount = 0;
*FontPackageCount = 0;
TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) (((UINT8 *) &Packages->GuidId) + sizeof (Packages->GuidId));
for (Index = 0; Index < Packages->NumberOfPackages; Index++) {
//
// The current UEFI HII build tool generate a binary in the format defined by
// TIANO_AUTOGEN_PACKAGES_HEADER. We assume that all packages generated in
// this binary is with same package type. So the returned IfrPackageCount and StringPackageCount
// may not be the exact number of valid package number in the binary generated
// by HII Build tool.
//
switch (TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Type) {
case EFI_HII_IFR:
*IfrPackageCount += 1;
break;
case EFI_HII_STRING:
*StringPackageCount += 1;
break;
case EFI_HII_FONT:
*FontPackageCount += 1;
break;
//
// The following fonts are invalid for a module that using Framework to UEFI thunk layer.
//
default:
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
break;
}
}
return EFI_SUCCESS;
}
/**
Insert the String Package into the Package Lists which has the TAG GUID matching
the PackageListGuid of the String Package.
The Package List must have only IFR Package and no String Package.
Otherwise, ASSERT.
@param Private The HII THUNK driver context data.
@param StringPackageThunkContext The HII THUNK context data.
@param StringPackageListHeader The String Package List Header.
**/
VOID
UpdatePackListWithOnlyIfrPack (
IN HII_THUNK_PRIVATE_DATA *Private,
IN HII_THUNK_CONTEXT *StringPackageThunkContext,
IN CONST EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader
)
{
EFI_STATUS Status;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
Link = GetFirstNode (&Private->ThunkContextListHead);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (StringPackageThunkContext != ThunkContext) {
//
// Skip the String Package Thunk Entry itself.
//
if (CompareGuid (&StringPackageListHeader->PackageListGuid, &ThunkContext->TagGuid)) {
ASSERT (ThunkContext->StringPackageCount == 0 && ThunkContext->IfrPackageCount == 1);
ThunkContext->StringPackageCount = GetPackageCountByType (StringPackageListHeader, EFI_HII_PACKAGE_STRINGS);
Status = mHiiDatabase->UpdatePackageList (
mHiiDatabase,
ThunkContext->UefiHiiHandle,
StringPackageListHeader
);
ASSERT_EFI_ERROR (Status);
ThunkContext->SharingStringPack = TRUE;
StringPackageThunkContext->SharingStringPack = TRUE;
}
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
}
/**
Caculate the size of UEFI Simple Font Package that is needed to
convert all the font a Framework Font Paackage.
ONLY Narrow Font is supported. Wide Font is discarded.
If the Package Header is not of EFI_HII_FONT type, then ASSERT.
@param PackHeader Pointer to Framework Font Package.
@return The size of the UEFI Simple Font Package.
**/
UINTN
GetUefiSimpleFontPackSize (
IN CONST EFI_HII_PACK_HEADER * PackHeader
)
{
UINTN Size;
EFI_HII_FONT_PACK *FwFontPack;
FwFontPack = (EFI_HII_FONT_PACK *) PackHeader;
ASSERT (FwFontPack->Header.Type == EFI_HII_FONT);
Size = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR)
+ (FwFontPack->NumberOfNarrowGlyphs * sizeof (EFI_NARROW_GLYPH));
return Size;
}
/**
Convert Font Package in Framework format to a newly allocated UEFI
Simple Font Package.
ONLY Narrow Font is supported. Wide Font is discarded.
If memory allocation fails, then ASSERT.
@param PackHeader Pointer to Framework Font Package header.
@return UEFI Simple Font Package.
**/
EFI_HII_SIMPLE_FONT_PACKAGE_HDR *
FrameworkFontPackToUefiSimpliedFont (
IN CONST EFI_HII_PACK_HEADER * PackHeader
)
{
EFI_HII_SIMPLE_FONT_PACKAGE_HDR *FontPack;
UINTN Size;
EFI_NARROW_GLYPH *FwNarrowGlyph;
EFI_NARROW_GLYPH *NarrowGlyph;
UINTN Idx;
EFI_HII_FONT_PACK *FwFontPack;
Size = GetUefiSimpleFontPackSize (PackHeader);
FwFontPack = (EFI_HII_FONT_PACK *) PackHeader;
FontPack = AllocateZeroPool (Size);
ASSERT (FontPack != NULL);
//
// Prepare the Header information.
//
FontPack->Header.Length = (UINT32) Size;
FontPack->Header.Type = EFI_HII_PACKAGE_SIMPLE_FONTS;
FontPack->NumberOfNarrowGlyphs = FwFontPack->NumberOfNarrowGlyphs;
//
// ONLY Narrow Font is supported. Wide Font is discarded.
//
FontPack->NumberOfWideGlyphs = 0;
//
// Copy Narrow Glyph
//
NarrowGlyph = (EFI_NARROW_GLYPH *) (FontPack + 1);
FwNarrowGlyph = (EFI_NARROW_GLYPH *) (FwFontPack + 1);
CopyMem (NarrowGlyph, FwNarrowGlyph, sizeof (EFI_NARROW_GLYPH) * FwFontPack->NumberOfNarrowGlyphs);
for (Idx = 0; Idx < FwFontPack->NumberOfNarrowGlyphs; Idx++) {
//
// Clear the GLYPH_NON_BREAKING (EFI_GLYPH_WIDE is used here as they are all 0x02)
// attribute which is not defined in UEFI EFI_NARROW_GLYPH
//
NarrowGlyph[Idx].Attributes = (UINT8) (NarrowGlyph[Idx].Attributes & ~(EFI_GLYPH_WIDE));
}
return FontPack;
}
/**
Prepare a UEFI Package List from a Framework HII package list registered
from a Framework HII NewPack () function.
If either Packages or PackageListGuid is NULL, then ASSERT.
@param Packages The Framework HII Package List.
@param PackageListGuid The Package List GUID.
@return The UEFI Package List.
**/
EFI_HII_PACKAGE_LIST_HEADER *
PrepareUefiPackageListFromFrameworkHiiPackages (
IN CONST EFI_HII_PACKAGES *Packages,
IN CONST EFI_GUID *PackageListGuid
)
{
UINTN NumberOfPackages;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
UINT8 *PackageListData;
UINT32 PackageListLength;
UINT32 PackageLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
UINTN Index;
TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
EFI_HII_SIMPLE_FONT_PACKAGE_HDR *FontPack;
ASSERT (Packages != NULL);
ASSERT (PackageListGuid != NULL);
TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) ((UINT8 *) &Packages->GuidId + sizeof (Packages->GuidId));
NumberOfPackages = Packages->NumberOfPackages;
PackageListLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
for (Index = 0; Index < NumberOfPackages; Index++) {
if (TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Type == EFI_HII_FONT) {
//
// There is no tool to generate Font package in Framework HII's implementation.
// Therefore, Font Package be a C structure defined in Framework HII code.
// Therefore, Font Package will be in Framework HII format defined by EFI_HII_FONT_PACK.
// We need to create a UEFI Simple Font Package and copy over all data. Hence, EFI_HII_FONT
// is handled differently than EFI_HII_IFR and EFI_HII_STRING.
//
PackageListLength = (UINT32) (PackageListLength + GetUefiSimpleFontPackSize (&TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader));
} else {
//
// For EFI_HII_IFR and EFI_HII_STRING, EDK II's VFR Compiler and Build.exe will generate a binary in a format
// defined by TIANO_AUTOGEN_PACKAGES_HEADER. A Framework HII's EFI_HII_PACK_HEADER is inserted before
// the UEFI package data.
//
CopyMem (&PackageLength, &TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Length, sizeof (UINT32));
//
// EFI_HII_PACK_HEADER.FrameworkPackageHeader.Length include the sizeof FrameworkPackageHeader itself.
//
PackageListLength += (PackageLength - sizeof(EFI_HII_PACK_HEADER));
}
}
//
// Include the lenght of EFI_HII_PACKAGE_END
//
PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
PackageListHeader = AllocateZeroPool (PackageListLength);
ASSERT (PackageListHeader != NULL);
CopyMem (&PackageListHeader->PackageListGuid, PackageListGuid, sizeof (EFI_GUID));
PackageListHeader->PackageLength = PackageListLength;
PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
//
// Build the UEFI Package List.
//
for (Index = 0; Index < NumberOfPackages; Index++) {
if (TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Type == EFI_HII_FONT) {
PackageLength = (UINT32) GetUefiSimpleFontPackSize (&TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader);
FontPack = FrameworkFontPackToUefiSimpliedFont (&TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader);
CopyMem (PackageListData, FontPack, PackageLength);
FreePool (FontPack);
} else {
CopyMem (&PackageLength, &(TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Length), sizeof (UINT32));
PackageLength -= sizeof (EFI_HII_PACK_HEADER);
CopyMem (PackageListData, &(TianoAutogenPackageHdrArray[Index]->PackageHeader), PackageLength);
}
PackageListData += PackageLength;
}
//
// Append EFI_HII_PACKAGE_END
//
PackageHeader.Type = EFI_HII_PACKAGE_END;
PackageHeader.Length = sizeof (EFI_HII_PACKAGE_HEADER);
CopyMem (PackageListData, &PackageHeader, PackageHeader.Length);
return PackageListHeader;
}
/**
Generate a Random GUID.
@param Guid On output, a Random GUID will be filled.
**/
VOID
GenerateRandomGuid (
OUT EFI_GUID * Guid
)
{
CopyGuid (Guid, &mGuidBase);
mGuidCount++;
*((UINT64 *) Guid) = *((UINT64 *) Guid) + mGuidCount;
}
/**
Given a Package List with only a IFR package, find the Package List that only has a String Package based on
the TAG GUID. Then export the String Package from the Package List and insert it
to the given IFR package.
This is to handle the case of Framework HII interface which allow String Package
and IFR package to be registered using two different NewPack () calls.
@param Private The HII THUNK driver context data.
@param IfrThunkContext Package List with only a IFR package.
@retval EFI_SUCCESS If the String Package is found and inserted to the
Package List with only a IFR package.
@retval EFI_NOT_FOUND No String Package matching the TAG GUID is found.
**/
EFI_STATUS
FindStringPackAndUpdatePackListWithOnlyIfrPack (
IN HII_THUNK_PRIVATE_DATA *Private,
IN HII_THUNK_CONTEXT *IfrThunkContext
)
{
EFI_STATUS Status;
LIST_ENTRY *Link;
EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader;
UINTN Size;
HII_THUNK_CONTEXT *ThunkContext;
Link = GetFirstNode (&Private->ThunkContextListHead);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (ThunkContext != IfrThunkContext) {
if (CompareGuid (&IfrThunkContext->TagGuid, &ThunkContext->TagGuid) && (ThunkContext->IfrPackageCount == 0)) {
StringPackageListHeader = NULL;
Status = ExportPackageLists (ThunkContext->UefiHiiHandle, &StringPackageListHeader, &Size);
ASSERT_EFI_ERROR (Status);
if (StringPackageListHeader == NULL) {
return EFI_NOT_FOUND;
}
IfrThunkContext->StringPackageCount = GetPackageCountByType (StringPackageListHeader, EFI_HII_PACKAGE_STRINGS);
//
// Add Function to only get only String Packages from the Package List
//
Status = mHiiDatabase->UpdatePackageList (
mHiiDatabase,
IfrThunkContext->UefiHiiHandle,
StringPackageListHeader
);
ASSERT_EFI_ERROR (Status);
FreePool (StringPackageListHeader);
IfrThunkContext->SharingStringPack = TRUE;
ThunkContext->SharingStringPack = TRUE;
return EFI_SUCCESS;
}
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
//
// A Form Package must have a String Package to function.
// If ASSERT here, check the sequence of call to Hii->NewPack.
// String Pack must be registered before Ifr Package is registered.
//
ASSERT (FALSE);
return EFI_NOT_FOUND;
}
/**
Register the Package List passed from the Framework HII NewPack () interface.
The FRAMEWORK_EFI_HII_HANDLE will be returned.
@param This The EFI_HII_PROTOCOL context data. Only used
to call HiiRemovePack.
@param Private The HII THUNK driver context data.
@param Packages Package List.
@param Handle On output, a FRAMEWORK_EFI_HII_HANDLE number is
returned.
@retval EFI_SUCCESS The Package List is registered successfully in
the database.
@retval EFI_UNSUPPORTED The number of IFR package in the package list
is greater than 1.
@retval EFI_OUT_OF_RESOURCE Not enough resouce.
**/
EFI_STATUS
UefiRegisterPackageList (
IN EFI_HII_PROTOCOL *This,
IN HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_PACKAGES *Packages,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
{
EFI_STATUS Status;
UINTN StringPackageCount;
UINTN IfrPackageCount;
UINTN FontPackageCount;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
HII_THUNK_CONTEXT *ThunkContext;
HII_THUNK_CONTEXT *ThunkContextToRemove;
EFI_GUID GuidId;
EFI_HII_PACKAGE_HEADER *IfrPackage;
PackageListHeader = NULL;
Status = GetPackageCount (Packages, &IfrPackageCount, &StringPackageCount, &FontPackageCount);
ASSERT_EFI_ERROR (Status);
if (IfrPackageCount > 1) {
//
// HII Thunk only handle package with 0 or 1 IFR package.
//
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
ThunkContext = CreateThunkContext (Private, StringPackageCount, IfrPackageCount);
if (ThunkContext == NULL) {
return EFI_OUT_OF_RESOURCES;
}
ThunkContext->ByFrameworkHiiNewPack = TRUE;
if (Packages->GuidId == NULL) {
//
// UEFI HII Database require Package List GUID must be unique.
//
// If Packages->GuidId is NULL, the caller of FramworkHii->NewPack is registering
// packages with at least 1 StringPack and 1 IfrPack. Therefore, Packages->GuidId is
// not used as the name of the package list. Formset GUID is used as the Package List
// GUID instead.
//
ASSERT ((StringPackageCount >=1 && IfrPackageCount == 1) || (FontPackageCount > 0));
if (IfrPackageCount > 0) {
IfrPackage = GetIfrPackage (Packages);
if (IfrPackage == NULL) {
Status = EFI_NOT_FOUND;
goto Done;
}
GetFormSetGuid (IfrPackage, &ThunkContext->TagGuid);
} else {
ASSERT (FontPackageCount > 0);
GenerateRandomGuid (&ThunkContext->TagGuid);
}
} else {
ThunkContextToRemove = TagGuidToIfrPackThunkContext (Private, Packages->GuidId);
if (IfrPackageCount > 0 &&
StringPackageCount > 0 &&
(ThunkContextToRemove != NULL)) {
DEBUG((EFI_D_WARN, "Framework code registers HII package list with the same GUID more than once.\n"));
DEBUG((EFI_D_WARN, "Remove the previously registered package list and register the new one.\n"));
HiiRemovePack (This, ThunkContextToRemove->FwHiiHandle);
}
CopyGuid (&ThunkContext->TagGuid, Packages->GuidId);
}
//
// UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
// that Setup Utility can load the Buffer Storage using this protocol. An UEFI VFR can only
// produce IFR package generated with Buffer Storage type and EFI Variable Storage.
// The default EFI_HII_CONFIG_ACCESS_PROTOCOL is used to Get/Set the Buffer Storage.
//
if (IfrPackageCount != 0) {
InstallDefaultConfigAccessProtocol (Packages, ThunkContext);
}
PackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &ThunkContext->TagGuid);
Status = mHiiDatabase->NewPackageList (
mHiiDatabase,
PackageListHeader,
ThunkContext->UefiHiiDriverHandle,
&ThunkContext->UefiHiiHandle
);
if (Status == EFI_INVALID_PARAMETER) {
FreePool (PackageListHeader);
//
// UEFI HII database does not allow two package list with the same GUID.
// In Framework HII implementation, Packages->GuidId is used as an identifier to associate
// a PackageList with only IFR to a Package list the with String package.
//
GenerateRandomGuid (&GuidId);
PackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId);
Status = mHiiDatabase->NewPackageList (
mHiiDatabase,
PackageListHeader,
ThunkContext->UefiHiiDriverHandle,
&ThunkContext->UefiHiiHandle
);
}
//
// BUGBUG: Remove when development is done
//
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
goto Done;
}
if (IfrPackageCount == 0) {
if (StringPackageCount != 0) {
//
// Look for a Package List with only IFR Package with the same TAG GUID name.
// If found one, add the String Packages to the found Package List.
// This is needed because Framework HII Module may not register the String Package
// and IFR Package in one NewPack () call.
//
UpdatePackListWithOnlyIfrPack (
Private,
ThunkContext,
PackageListHeader
);
}
} else {
if (StringPackageCount == 0) {
//
// Look for the String Package with the same TAG GUID name and add
// the found String Package to this Package List.
// This is needed because Framework HII Module may not register the String Package
// and IFR Package in one NewPack () call.
//
Status = FindStringPackAndUpdatePackListWithOnlyIfrPack (
Private,
ThunkContext
);
if (EFI_ERROR (Status)) {
goto Done;
}
}
//
// Parse the Formset. Must be called after FindStringPackAndUpdatePackListWithOnlyIfrPack is called so
// that String Package is ready.
//
ThunkContext->FormSet = ParseFormSet (ThunkContext->UefiHiiHandle);
ASSERT (ThunkContext->FormSet != NULL);
}
Done:
if (EFI_ERROR (Status)) {
DestroyThunkContext (ThunkContext);
} else {
InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);
*Handle = ThunkContext->FwHiiHandle;
}
if (PackageListHeader != NULL) {
FreePool (PackageListHeader);
}
return Status;
}
/**
Registers the various packages that are passed in a Package List.
@param This Pointer of Frameowk HII protocol instance.
@param Packages Pointer of HII packages.
@param Handle Handle value to be returned.
@retval EFI_SUCCESS Packages has added to HII database successfully.
@retval EFI_INVALID_PARAMETER If Handle or Packages is NULL.
**/
EFI_STATUS
EFIAPI
HiiNewPack (
IN EFI_HII_PROTOCOL *This,
IN EFI_HII_PACKAGES *Packages,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
{
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
EFI_TPL OldTpl;
if (Handle == NULL) {
return EFI_INVALID_PARAMETER;
}
if (Packages == NULL) {
return EFI_INVALID_PARAMETER;
}
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
// We use a simple Global variable to inform NewOrAddPackNotify()
// that the package list registered here is already registered
// in the HII Thunk Layer. So NewOrAddPackNotify () does not need to
// call registered the Package List again.
//
mInFrameworkHiiNewPack = TRUE;
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Status = UefiRegisterPackageList (
This,
Private,
Packages,
Handle
);
mInFrameworkHiiNewPack = FALSE;
gBS->RestoreTPL (OldTpl);
return Status;
}
/**
Remove a package from the HII database.
@param This Pointer of Frameowk HII protocol instance.
@param Handle Handle value to be removed.
@retval EFI_SUCCESS Packages has added to HII database successfully.
@retval EFI_INVALID_PARAMETER If Handle or Packages is NULL.
**/
EFI_STATUS
EFIAPI
HiiRemovePack (
IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle
)
{
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_CONTEXT *ThunkContext;
EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
mInFrameworkHiiRemovePack = TRUE;
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
if (ThunkContext != NULL) {
Status = mHiiDatabase->RemovePackageList (
mHiiDatabase,
ThunkContext->UefiHiiHandle
);
ASSERT_EFI_ERROR (Status);
if (ThunkContext->IfrPackageCount != 0) {
UninstallDefaultConfigAccessProtocol (ThunkContext);
}
DestroyThunkContext (ThunkContext);
}else {
Status = EFI_NOT_FOUND;
}
mInFrameworkHiiRemovePack = FALSE;
gBS->RestoreTPL (OldTpl);
return Status;
}
/**
This notification function will be called when a Package List is registered
using UEFI HII interface. The Package List registered need to be recorded in
Framework Thunk module as Thunk Module may need to look for String Package in
the package registered.
If the Package List registered is not either Sting Package or IFR package,
then ASSERT. If the NotifyType is not ADD_PACK or NEW_PACK, then ASSERT.
Both cases means UEFI HII Database itself is buggy.
@param PackageType The Package Type.
@param PackageGuid The Package GUID.
@param Package The Package Header.
@param Handle The HII Handle of this Package List.
@param NotifyType The reason of the notification.
@retval EFI_SUCCESS The notification function is successful.
**/
EFI_STATUS
EFIAPI
NewOrAddPackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
{
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_CONTEXT *ThunkContext;
ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS || PackageType == EFI_HII_PACKAGE_FORMS);
ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_ADD_PACK || NotifyType == EFI_HII_DATABASE_NOTIFY_NEW_PACK);
Status = EFI_SUCCESS;
Private = mHiiThunkPrivateData;
if (mInFrameworkHiiNewPack || mInFrameworkUpdatePakcage) {
return EFI_SUCCESS;
}
//
// We will create a ThunkContext to log the package list only if the
// package is not registered with by Framework HII Thunk module yet.
//
ThunkContext = UefiHiiHandleToThunkContext (Private, Handle);
if (ThunkContext == NULL) {
ThunkContext = CreateThunkContextForUefiHiiHandle (Handle);
ASSERT (ThunkContext != NULL);
InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);
}
if (PackageType == EFI_HII_PACKAGE_FORMS) {
if (ThunkContext->FormSet != NULL) {
DestroyFormSet (ThunkContext->FormSet);
}
//
// Reparse the FormSet.
//
ThunkContext->FormSet = ParseFormSet (ThunkContext->UefiHiiHandle);
}
return Status;
}
/**
This notification function will be called when a Package List is removed
using UEFI HII interface. The Package List removed need to be removed from
Framework Thunk module too.
If the Package List registered is not Sting Package,
then ASSERT. If the NotifyType is not REMOVE_PACK, then ASSERT.
Both cases means UEFI HII Database itself is buggy.
@param PackageType The Package Type.
@param PackageGuid The Package GUID.
@param Package The Package Header.
@param Handle The HII Handle of this Package List.
@param NotifyType The reason of the notification.
@retval EFI_SUCCESS The notification function is successful.
**/
EFI_STATUS
EFIAPI
RemovePackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
{
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_CONTEXT *ThunkContext;
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
UINTN BufferSize;
Status = EFI_SUCCESS;
ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS);
ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK);
if (mInFrameworkHiiRemovePack || mInFrameworkUpdatePakcage) {
return EFI_SUCCESS;
}
Private = mHiiThunkPrivateData;
ThunkContext = UefiHiiHandleToThunkContext (Private, Handle);
//
// BugBug: Change to ASSERT if HII Database fix the bug and to also invoke
// NEW_PACK_NOTIFY for package (String Package) created internally.
//
if (ThunkContext != NULL) {
if (!ThunkContext->ByFrameworkHiiNewPack) {
HiiPackageList = NULL;
Status = ExportPackageLists (Handle, &HiiPackageList, &BufferSize);
ASSERT_EFI_ERROR (Status);
if (HiiPackageList == NULL) {
return EFI_NOT_FOUND;
}
if (GetPackageCountByType (HiiPackageList, EFI_HII_PACKAGE_STRINGS) == 1) {
//
// If the string package will be removed is the last string package
// in the package list, we will remove the HII Thunk entry from the
// database.
//
DestroyThunkContextForUefiHiiHandle (Private, Handle);
}
FreePool (HiiPackageList);
}
}
return Status;
}
|
a41b931b239e84b982ea145bfbaf405d1a8cd402
|
7e41167bfae6d2c38689b7e0993b308e045cbd05
|
/less-34/less/defines.h.in
|
46232c0e451003ca3790fc536ef894f867689174
|
[
"BSD-3-Clause",
"curl",
"GPL-1.0-or-later",
"MIT",
"Python-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause",
"GPL-3.0-or-later"
] |
permissive
|
holzschu/ios_system
|
7b18993dbcb33331c353e0257ca54847a5d1b1bb
|
6a83eb1c6c383a562fbe33a7e97677e88d305b51
|
refs/heads/master
| 2023-08-14T09:11:40.627903
| 2023-04-18T15:12:29
| 2023-04-18T15:12:29
| 113,187,304
| 882
| 155
|
BSD-3-Clause
| 2023-08-19T19:15:35
| 2017-12-05T13:42:50
|
C
|
UTF-8
|
C
| false
| false
| 11,667
|
in
|
defines.h.in
|
/* defines.h.in. Generated from configure.ac by autoheader. */
/* Unix definition file for less. -*- C -*-
*
* This file has 3 sections:
* User preferences.
* Settings always true on Unix.
* Settings automatically determined by configure.
*
* * * * * * WARNING * * * * * *
* If you edit defines.h by hand, do "touch stamp-h" before you run make
* so config.status doesn't overwrite your changes.
*/
/* User preferences. */
/*
* SECURE is 1 if you wish to disable a bunch of features in order to
* be safe to run by unprivileged users.
* SECURE_COMPILE is set by the --with-secure configure option.
*/
#define SECURE SECURE_COMPILE
/*
* SHELL_ESCAPE is 1 if you wish to allow shell escapes.
* (This is possible only if your system supplies the system() function.)
*/
#define SHELL_ESCAPE (!SECURE)
/*
* EXAMINE is 1 if you wish to allow examining files by name from within less.
*/
#define EXAMINE (!SECURE)
/*
* TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
* to complete filenames at prompts.
*/
#define TAB_COMPLETE_FILENAME (!SECURE)
/*
* CMD_HISTORY is 1 if you wish to allow keys to cycle through
* previous commands at prompts.
*/
#define CMD_HISTORY 1
/*
* HILITE_SEARCH is 1 if you wish to have search targets to be
* displayed in standout mode.
*/
#define HILITE_SEARCH 1
/*
* EDITOR is 1 if you wish to allow editor invocation (the "v" command).
* (This is possible only if your system supplies the system() function.)
* EDIT_PGM is the name of the (default) editor to be invoked.
*/
#define EDITOR (!SECURE)
/*
* TAGS is 1 if you wish to support tag files.
*/
#define TAGS (!SECURE)
/*
* USERFILE is 1 if you wish to allow a .less file to specify
* user-defined key bindings.
*/
#define USERFILE (!SECURE)
/*
* GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
* This will generally work if your system provides the "popen" function
* and the "echo" shell command.
*/
#define GLOB (!SECURE)
/*
* PIPEC is 1 if you wish to have the "|" command
* which allows the user to pipe data into a shell command.
*/
#define PIPEC (!SECURE)
/*
* LOGFILE is 1 if you wish to allow the -l option (to create log files).
*/
#define LOGFILE (!SECURE)
/*
* GNU_OPTIONS is 1 if you wish to support the GNU-style command
* line options --help and --version.
*/
#define GNU_OPTIONS 1
/*
* ONLY_RETURN is 1 if you want RETURN to be the only input which
* will continue past an error message.
* Otherwise, any key will continue past an error message.
*/
#define ONLY_RETURN 0
/*
* LESSKEYFILE is the filename of the default lesskey output file
* (in the HOME directory).
* LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
* DEF_LESSKEYINFILE is the filename of the default lesskey input
* (in the HOME directory).
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
#define LESSHISTFILE ".lesshst"
/* Settings always true on Unix. */
/*
* Define MSDOS_COMPILER if compiling under Microsoft C.
*/
#define MSDOS_COMPILER 0
/*
* Pathname separator character.
*/
#define PATHNAME_SEP "/"
/*
* The value returned from tgetent on success.
* Some HP-UX systems return 0 on success.
*/
#define TGETENT_OK 1
/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
#define HAVE_SYS_TYPES_H 1
/*
* Define if you have the <sgstat.h> header file.
*/
#undef HAVE_SGSTAT_H
/*
* HAVE_PERROR is 1 if your system has the perror() call.
* (Actually, if it has sys_errlist, sys_nerr and errno.)
*/
#define HAVE_PERROR 1
/*
* HAVE_TIME is 1 if your system has the time() call.
*/
#define HAVE_TIME 1
/*
* HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
*/
#define HAVE_SHELL 1
/*
* Default shell metacharacters and meta-escape character.
*/
#define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~"
#define DEF_METAESCAPE "\\"
/*
* HAVE_DUP is 1 if your system has the dup() call.
*/
#define HAVE_DUP 1
/* Define to 1 if you have the memcpy() function. */
#define HAVE_MEMCPY 1
/* Define to 1 if you have the strchr() function. */
#define HAVE_STRCHR 1
/* Define to 1 if you have the strstr() function. */
#define HAVE_STRSTR 1
/*
* Sizes of various buffers.
*/
#if 0 /* old sizes for small memory machines */
#define CMDBUF_SIZE 512 /* Buffer for multichar commands */
#define UNGOT_SIZE 100 /* Max chars to unget() */
#define LINEBUF_SIZE 1024 /* Max size of line in input file */
#define OUTBUF_SIZE 1024 /* Output buffer */
#define PROMPT_SIZE 200 /* Max size of prompt string */
#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
#define TAGLINE_SIZE 512 /* Max size of line in tags file */
#define TABSTOP_MAX 32 /* Max number of custom tab stops */
#else /* more reasonable sizes for modern machines */
#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */
#define UNGOT_SIZE 200 /* Max chars to unget() */
#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */
#define OUTBUF_SIZE 1024 /* Output buffer */
#define PROMPT_SIZE 2048 /* Max size of prompt string */
#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
#define TAGLINE_SIZE 1024 /* Max size of line in tags file */
#define TABSTOP_MAX 128 /* Max number of custom tab stops */
#endif
/* Settings automatically determined by configure. */
/* Define EDIT_PGM to your editor. */
#undef EDIT_PGM
/* Define HAVE_CONST if your compiler supports the "const" modifier. */
#undef HAVE_CONST
/* Define to 1 if you have the <ctype.h> header file. */
#undef HAVE_CTYPE_H
/* Define HAVE_ERRNO if you have the errno variable. */
#undef HAVE_ERRNO
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define to 1 if you have the `fchmod' function. */
#undef HAVE_FCHMOD
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define HAVE_FILENO if you have the fileno() macro. */
#undef HAVE_FILENO
/* Define HAVE_FLOAT if your compiler supports the "double" type. */
#undef HAVE_FLOAT
/* Define to 1 if you have the `fsync' function. */
#undef HAVE_FSYNC
/* GNU regex library */
#undef HAVE_GNU_REGEX
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define HAVE_LOCALE if you have locale.h and setlocale. */
#undef HAVE_LOCALE
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define HAVE_OSPEED if your termcap library has the ospeed variable. */
#undef HAVE_OSPEED
/* PCRE (Perl-compatible regular expression) library */
#undef HAVE_PCRE
/* Define to 1 if you have the `popen' function. */
#undef HAVE_POPEN
/* POSIX regcomp() and regex.h */
#undef HAVE_POSIX_REGCOMP
/* System V regcmp() */
#undef HAVE_REGCMP
/* */
#undef HAVE_REGEXEC2
/* BSD re_comp() */
#undef HAVE_RE_COMP
/* Define HAVE_SIGEMPTYSET if you have the sigemptyset macro. */
#undef HAVE_SIGEMPTYSET
/* Define to 1 if you have the `sigprocmask' function. */
#undef HAVE_SIGPROCMASK
/* Define to 1 if you have the `sigsetmask' function. */
#undef HAVE_SIGSETMASK
/* Define to 1 if the system has the type `sigset_t'. */
#undef HAVE_SIGSET_T
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have the `stat' function. */
#undef HAVE_STAT
/* Define HAVE_STAT_INO if your struct stat has st_ino and st_dev. */
#undef HAVE_STAT_INO
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define HAVE_STRERROR if you have the strerror() function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `system' function. */
#undef HAVE_SYSTEM
/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable. */
#undef HAVE_SYS_ERRLIST
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/stream.h> header file. */
#undef HAVE_SYS_STREAM_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <termcap.h> header file. */
#undef HAVE_TERMCAP_H
/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr. */
#undef HAVE_TERMIOS_FUNCS
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
/* Define to 1 if you have the <termio.h> header file. */
#undef HAVE_TERMIO_H
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
/* Define HAVE_TIME_T if your system supports the "time_t" type. */
#undef HAVE_TIME_T
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower. */
#undef HAVE_UPPER_LOWER
/* Henry Spencer V8 regcomp() and regexp.h */
#undef HAVE_V8_REGCOMP
/* Define to 1 if you have the <values.h> header file. */
#undef HAVE_VALUES_H
/* Define HAVE_VOID if your compiler supports the "void" type. */
#undef HAVE_VOID
/* Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower. */
#undef HAVE_WCTYPE
/* Define to 1 if you have the <wctype.h> header file. */
#undef HAVE_WCTYPE_H
/* Define to 1 if you have the `_setjmp' function. */
#undef HAVE__SETJMP
/* Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.
*/
#undef MUST_DEFINE_ERRNO
/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in
termcap.h. */
#undef MUST_DEFINE_OSPEED
/* pattern matching is supported, but without metacharacters. */
#undef NO_REGEX
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* Define SECURE_COMPILE=1 to build a secure version of less. */
#undef SECURE_COMPILE
/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
#undef STAT_MACROS_BROKEN
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
|
5911945090ef154ac2f4ab9417a224d95aa8688c
|
e3cdfae1dd874479c928dad193b33a4e3b8a623e
|
/src/classchg-menuselect.c
|
395a1152a326602bc34dd50972ce58a081622025
|
[] |
no_license
|
FireEmblemUniverse/fireemblem8u
|
11493bf94844617b33254110ba006316defb3510
|
b9ad9bcafd9d4ecb7fc13cc77a464e2a82ac8338
|
refs/heads/master
| 2023-09-05T23:39:53.791339
| 2023-09-04T17:31:47
| 2023-09-04T17:31:47
| 121,802,075
| 118
| 31
| null | 2023-09-11T13:08:37
| 2018-02-16T21:21:50
|
Assembly
|
UTF-8
|
C
| false
| false
| 7,243
|
c
|
classchg-menuselect.c
|
#include "global.h"
#include "classchg.h"
#include "uimenu.h"
#include "fontgrp.h"
#include "bmunit.h"
#include "proc.h"
#include "hardware.h"
#include "bmarch.h"
#include "scene.h"
#include "constants/classes.h"
u32 ClassChgMenuSelOnInit(struct MenuProc *proc)
{
SyncMenuBgs(proc);
return 0;
}
u32 ClassChgMenuSelOnEnd(struct MenuProc *proc)
{
SyncMenuBgs(proc);
return 0;
}
u8 ClassChgMenuItem_OnSelect(struct MenuProc *pmenu, struct MenuItemProc *pmitem) {
struct ProcClassChgMenuSel *parent;
struct ProcPromoSel *gparent;
struct ProcPromoMain *ggparent;
parent = pmenu->proc_parent;
gparent = parent->proc_parent;
ggparent = gparent->proc_parent;
if (gparent->stat == 0) {
struct Unit *unit = GetUnitFromCharId(ggparent->pid);
u8 classnumber = unit->pClassData->number;
if (pmitem->itemNumber <= 1) {
classnumber = gPromoJidLut[classnumber][pmitem->itemNumber];
ggparent->jid = classnumber;
} else {
if (pmitem->itemNumber == 2) {
switch (classnumber) {
case CLASS_JOURNEYMAN:
ggparent->jid = CLASS_JOURNEYMAN_T1;
break;
case CLASS_PUPIL:
ggparent->jid = CLASS_PUPIL_T1;
break;
case CLASS_RECRUIT:
ggparent->jid = CLASS_RECRUIT_T1;
break;
default:
ggparent->jid = classnumber;
break;
}
}
}
switch ((u8) ggparent->jid) {
case CLASS_RANGER:
case CLASS_RANGER_F:
if (unit->state & US_IN_BALLISTA) {
TryRemoveUnitFromBallista(unit);
}
break;
}
InitTextFont(&gFontClassChgMenu, (void *)BG_VRAM + 0x1000, 0x80, 0x5);
TileMap_FillRect(TILEMAP_LOCATED(gBG0TilemapBuffer, 9, 4), 0xA, 0x6, 0);
BG_EnableSyncByMask(BG0_SYNC_BIT);
StartMenuExt(&Menu_PromoSubConfirm, 2, 0, 0, 0, pmenu);
}
return 0;
}
u8 ClassChgMenuSelOnPressB(struct MenuProc *pmenu, struct MenuItemProc *pmitem) {
struct ProcClassChgMenuSel *parent;
struct ProcPromoSel *gparent;
struct ProcPromoMain *ggparent;
struct ProcPromoHandler *gggparent;
parent = pmenu->proc_parent;
gparent = parent->proc_parent;
ggparent = gparent->proc_parent;
gggparent = ggparent->proc_parent;
if (gggparent->bmtype == PROMO_HANDLER_TYPE_TRANINEE)
return 0;
if (gggparent->bmtype == PROMO_HANDLER_TYPE_BM) {
Proc_End(parent);
Proc_Goto(gparent, PROC_CLASSCHG_SEL_2);
return MENU_ACT_SKIPCURSOR | MENU_ACT_END | MENU_ACT_SND6B;
}
if (gggparent->bmtype == PROMO_HANDLER_TYPE_PREP) {
Proc_End(parent);
Proc_Goto(gparent, PROC_CLASSCHG_SEL_2);
return MENU_ACT_SKIPCURSOR | MENU_ACT_END | MENU_ACT_SND6B;;
}
return 0;
}
void ClassChgMenuOnDrawCore(struct MenuProc *pmenu, struct MenuItemProc *pmitem, char *str)
{
u8 unused_stack[32];
u16 *mapbuf;
if (pmitem->def->color)
Text_SetColor(&pmitem->text, pmitem->def->color);
if (pmitem->availability == MENU_DISABLED)
Text_SetColor(&pmitem->text, TEXT_COLOR_SYSTEM_GRAY);
ClearTextPart(&pmitem->text, 0, 20);
Text_SetCursor(&pmitem->text, 8);
Text_DrawString(&pmitem->text, str);
mapbuf = BG_GetMapBuffer(pmenu->frontBg);
PutText(&pmitem->text, &mapbuf[pmitem->yTile * 32 + pmitem->xTile]);
}
int ClassChgMenuItem_OnTextDraw(struct MenuProc *pmenu, struct MenuItemProc *pmitem)
{
u8 unused_stack[0x48];
struct ProcClassChgMenuSel *parent;
struct ProcPromoSel *gparent;
parent = pmenu->proc_parent;
gparent = parent->proc_parent;
ClassChgMenuOnDrawCore(pmenu, pmitem, GetStringFromIndex(GetClassData(gparent->jid[pmitem->itemNumber])->nameTextId));
}
int ClassChgMenuItem_OnChange(struct MenuProc *pmenu, struct MenuItemProc *pmitem)
{
struct ProcClassChgMenuSel *parent;
struct ProcPromoSel *gparent;
parent = pmenu->proc_parent;
gparent = parent->proc_parent;
gparent->stat = 1;
gparent->menu_index = pmitem->itemNumber;
ChangeClassDescription(gparent->msg_desc[gparent->menu_index]);
SetTalkPrintDelay(-1);
}
u8 ClassChgMenuItem_3rdUsability(const struct MenuItemDef * _def, int _number)
{
struct ProcClassChgMenuSel *proc = Proc_Find(ProcScr_ClassChgMenuSel);
struct ProcPromoSel *parent = proc->proc_parent;
struct ProcPromoMain *gparent = parent->proc_parent;
if (Check3rdTraineeEnabled()) {
switch (GetUnitFromCharId(gparent->pid)->pClassData->number) {
case CLASS_JOURNEYMAN:
case CLASS_PUPIL:
case CLASS_RECRUIT:
return MENU_ENABLED;
default:
return MENU_NOTSHOWN;
}
}
return MENU_NOTSHOWN;
}
CONST_DATA struct MenuItemDef gMenuItem_PromoSel[] = {
{
" 第1兵種",
0,
0x6DC, /* Discard items. Important[NL]items cannot be discarded. */
TEXT_COLOR_SYSTEM_WHITE,
0,
MenuAlwaysEnabled,
ClassChgMenuItem_OnTextDraw,
ClassChgMenuItem_OnSelect,
0,
ClassChgMenuItem_OnChange,
0
},
{
" 第2兵種",
0,
0x6DC, /* Discard items. Important[NL]items cannot be discarded. */
TEXT_COLOR_SYSTEM_WHITE,
1,
MenuAlwaysEnabled,
ClassChgMenuItem_OnTextDraw,
ClassChgMenuItem_OnSelect,
0,
ClassChgMenuItem_OnChange,
0
},
{
" 第3兵種",
0,
0x6DC, /* Discard items. Important[NL]items cannot be discarded. */
TEXT_COLOR_SYSTEM_WHITE,
2,
ClassChgMenuItem_3rdUsability,
ClassChgMenuItem_OnTextDraw,
ClassChgMenuItem_OnSelect,
0,
ClassChgMenuItem_OnChange,
0
},
{0}
};
CONST_DATA struct MenuDef gMenuDef_PromoSel = {
.rect = { 16, 2, 8, 0 },
.menuItems = gMenuItem_PromoSel,
.onInit = (void(*)(struct MenuProc*)) ClassChgMenuSelOnInit,
.onEnd = (void(*)(struct MenuProc*)) ClassChgMenuSelOnEnd,
.onBPress = ClassChgMenuSelOnPressB,
};
CONST_DATA struct ProcCmd ProcScr_ClassChgMenuSel[] = {
PROC_SLEEP(6),
PROC_NAME("CCRamifyMenuSelect"),
PROC_CALL(ClassChgMenuExec),
PROC_REPEAT(nullsub_80CDDD4),
PROC_YIELD,
PROC_LABEL(0),
PROC_GOTO(2),
PROC_LABEL(1),
PROC_CALL(nullsub_61),
PROC_LABEL(2),
PROC_END,
};
CONST_DATA struct MenuRect ClassChgMenuRect = {
.x = 1,
.y = 1,
.w = 12,
.h = 0
};
void ClassChgMenuExec(struct ProcClassChgMenuSel *proc)
{
proc->unk4C = 0;
ResetTextFont();
ResetText();
SetTextFontGlyphs(0);
InitTextFont(&gFontClassChg, (void *)BG_VRAM + 0x1400, 160, 5);
SetTextFont(&gFontClassChg);
proc->pmenu = StartMenuCore(
&gMenuDef_PromoSel,
ClassChgMenuRect,
2,
0,
0,
0,
(struct Proc *) proc);
}
void nullsub_80CDDD4(void)
{
return;
}
void nullsub_61(void)
{
return;
}
ProcPtr NewClassChgMenuSelect(ProcPtr parent)
{
return Proc_Start(ProcScr_ClassChgMenuSel, parent);
}
|
605abc54d7a54725b35be30528dbe85af434f829
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/components/utilities/utest/utest.h
|
56a6e0d57eb3255d1e3c24fc13ac62ccac13412b
|
[
"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
| 4,972
|
h
|
utest.h
|
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-19 MurphyZhao the first version
*/
#ifndef __UTEST_H__
#define __UTEST_H__
#include <rtthread.h>
#include <stdint.h>
#include "utest_log.h"
#include "utest_assert.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* utest_error
*
* @brief Test result.
*
* @member UTEST_PASSED Test success.
* @member UTEST_FAILED Test failed.
* @member UTEST_PASSED Test skipped.
*
*/
enum utest_error
{
UTEST_PASSED = 0,
UTEST_FAILED = 1,
UTEST_SKIPPED = 2
};
typedef enum utest_error utest_err_e;
/**
* utest
*
* @brief utest data structure.
*
* @member error Error number from enum `utest_error`.
* @member passed_num Total number of tests passed.
* @member failed_num Total number of tests failed.
*
*/
struct utest
{
utest_err_e error;
uint32_t passed_num;
uint32_t failed_num;
};
typedef struct utest *utest_t;
/**
* utest_tc_export
*
* @brief utest testcase data structure.
* Will export the data to `UtestTcTab` section in flash.
*
* @member name Testcase name.
* @member run_timeout Testcase maximum test time (Time unit: seconds).
* @member init Necessary initialization before executing the test case function.
* @member tc Total number of tests failed.
* @member cleanup Total number of tests failed.
*
*/
struct utest_tc_export {
const char *name;
uint32_t run_timeout;
rt_err_t (*init)(void);
void (*tc)(void);
rt_err_t (*cleanup)(void);
};
typedef struct utest_tc_export *utest_tc_export_t;
/**
* test_unit_func
*
* @brief Unit test handler function pointer.
*
*/
typedef void (*test_unit_func)(void);
/**
* utest_unit_run
*
* @brief Unit test function executor.
* No need for the user to call this function directly
*
* @param func Unit test function.
* @param unit_func_name Unit test function name.
*
* @return void
*
*/
void utest_unit_run(test_unit_func func, const char *unit_func_name);
/**
* utest_handle_get
*
* @brief Get the utest data structure handle.
* No need for the user to call this function directly
*
* @param void
*
* @return utest_t type. (struct utest *)
*
*/
utest_t utest_handle_get(void);
/**
* UTEST_NAME_MAX_LEN
*
* @brief Testcase name maximum length.
*
*/
#define UTEST_NAME_MAX_LEN (128u)
/**
* UTEST_TC_EXPORT
*
* @brief Export testcase function to `UtestTcTab` section in flash.
* Used in application layer.
*
* @param testcase The testcase function.
* @param name The testcase name.
* @param init The initialization function of the test case.
* @param cleanup The cleanup function of the test case.
* @param timeout Testcase maximum test time (Time unit: seconds).
*
* @return None
*
*/
#ifdef _MSC_VER
#pragma section("UtestTcTab$f",read)
#define UTEST_TC_EXPORT(testcase, name, init, cleanup, timeout) \
__declspec(allocate("UtestTcTab$f")) \
static const struct utest_tc_export _utest_testcase = \
{ \
name, \
timeout, \
init, \
testcase, \
cleanup \
}
#pragma comment(linker, "/merge:UtestTcTab=tctext")
#else
#define UTEST_TC_EXPORT(testcase, name, init, cleanup, timeout) \
rt_used static const struct utest_tc_export _utest_testcase \
rt_section("UtestTcTab") = \
{ \
name, \
timeout, \
init, \
testcase, \
cleanup \
}
#endif /* _MSC_VER */
/**
* UTEST_UNIT_RUN
*
* @brief Unit test function executor.
* Used in `testcase` function in application.
*
* @param test_unit_func Unit test function
*
* @return None
*
*/
#define UTEST_UNIT_RUN(test_unit_func) \
utest_unit_run(test_unit_func, #test_unit_func); \
if(utest_handle_get()->failed_num != 0) return;
#ifdef __cplusplus
}
#endif
#endif /* __UTEST_H__ */
|
9112e53da2dfd727bfa50710b1b82f79f3560bc5
|
f25847541dd3dd87d42d78eba81a351b72a4d0af
|
/avbsf/src/avpbs.c
|
1f85bcda8df5b3ade1bd0e70a2c25540ae18850d
|
[
"MIT"
] |
permissive
|
ireader/avcodec
|
a287e7905560d889e930e7a04865317fa00ef9cc
|
f3142ef12b5987d2f4c33ac3f073074798adf131
|
refs/heads/master
| 2023-09-05T16:56:48.006399
| 2023-08-26T10:35:48
| 2023-08-26T10:35:48
| 66,046,851
| 162
| 108
|
MIT
| 2023-02-03T10:32:36
| 2016-08-19T02:40:48
|
C
|
UTF-8
|
C
| false
| false
| 2,549
|
c
|
avpbs.c
|
#include "avpbs.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
static struct avpbs_t* avpbs_common(void);
struct avpbs_t* avpbs_h264(void);
struct avpbs_t* avpbs_h265(void);
struct avpbs_t* avpbs_h266(void);
struct avpbs_t* avpbs_av1(void);
struct avpbs_t* avpbs_vpx(void);
struct avpbs_t* avpbs_aac(void);
struct avpbs_t* avpbs_mp3(void);
struct avpbs_t* avpbs_opus(void);
struct avpbs_t* avpbs_g7xx(void);
struct avpbs_t* avpbs_find(AVPACKET_CODEC_ID codec)
{
switch (codec)
{
// video
case AVCODEC_VIDEO_H264:
return avpbs_h264();
case AVCODEC_VIDEO_H265:
return avpbs_h265();
case AVCODEC_VIDEO_H266:
return avpbs_h266();
case AVCODEC_VIDEO_AV1:
return avpbs_av1();
case AVCODEC_VIDEO_VP8:
case AVCODEC_VIDEO_VP9:
return avpbs_vpx();
// audio
case AVCODEC_AUDIO_AAC:
return avpbs_aac();
case AVCODEC_AUDIO_MP3:
return avpbs_mp3();
case AVCODEC_AUDIO_OPUS:
return avpbs_opus();
case AVCODEC_AUDIO_G711A:
case AVCODEC_AUDIO_G711U:
case AVCODEC_AUDIO_G726:
case AVCODEC_AUDIO_G729:
return avpbs_g7xx();
default:
return avpbs_common();
}
}
struct avpbs_common_t
{
struct avstream_t* stream;
avpbs_onpacket onpacket;
void* param;
};
static int avpbs_common_destroy(void** pp)
{
struct avpbs_common_t* bs;
if (pp && *pp)
{
bs = (struct avpbs_common_t*)*pp;
avstream_release(bs->stream);
free(bs);
*pp = NULL;
}
return 0;
}
static void* avpbs_common_create(int stream, AVPACKET_CODEC_ID codec, const uint8_t* extra, int bytes, avpbs_onpacket onpacket, void* param)
{
struct avpbs_common_t* bs;
bs = calloc(1, sizeof(*bs));
if (!bs) return NULL;
bs->stream = avstream_alloc(bytes);
if (bs->stream)
{
bs->stream->stream = stream;
bs->stream->codecid = codec;
memcpy(bs->stream->extra, extra, bytes);
}
bs->onpacket = onpacket;
bs->param = param;
return bs;
}
static int avpbs_common_input(void* param, int64_t pts, int64_t dts, const uint8_t* data, int bytes, int flags)
{
int r;
struct avpacket_t* pkt;
struct avpbs_common_t* bs;
bs = (struct avpbs_common_t*)param;
pkt = avpacket_alloc(bytes);
if (!pkt) return -(__ERROR__ + ENOMEM);
memcpy(pkt->data, data, bytes);
pkt->pts = pts;
pkt->dts = dts;
pkt->flags = flags;
pkt->stream = bs->stream;
avstream_addref(bs->stream);
r = bs->onpacket(bs->param, pkt);
avpacket_release(pkt);
return r;
}
static struct avpbs_t* avpbs_common(void)
{
static struct avpbs_t bs = {
avpbs_common_create,
avpbs_common_destroy,
avpbs_common_input,
};
return &bs;
}
|
d7415faef72df8b638df797786fd24c2e8e54b19
|
ed98b77f3f09b392e68a0d59c48eec299e883bb9
|
/applications/CycleClustering/src/heur_fuzzyround.c
|
aeb86deced56f31e1c0d4836148e31b74a20ca79
|
[
"Apache-2.0"
] |
permissive
|
scipopt/scip
|
c8ddbe7cdec0a3af5a230c04b74b76ffacbdcc33
|
dc856a4c966ea50bd5f52c58d7be4fea33706f4c
|
refs/heads/master
| 2023-08-19T11:39:12.578790
| 2023-08-15T20:05:58
| 2023-08-15T20:05:58
| 342,522,859
| 262
| 46
|
NOASSERTION
| 2023-08-03T07:37:45
| 2021-02-26T09:16:17
|
C
|
UTF-8
|
C
| false
| false
| 6,150
|
c
|
heur_fuzzyround.c
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the program and library */
/* SCIP --- Solving Constraint Integer Programs */
/* */
/* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* */
/* You should have received a copy of the Apache-2.0 license */
/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file heur_fuzzyround.c
* @brief primal heuristic that constructs a feasible solution from the lp-relaxation. Round only on the state-variables (binvars)
* and then reconstruct the rest of the variables accordingly.
* @author Leon Eifler
*/
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
#include <assert.h>
#include <string.h>
#include "heur_fuzzyround.h"
#include "probdata_cyc.h"
#include "scip/cons_and.h"
#define HEUR_NAME "fuzzyround"
#define HEUR_DESC "primal heuristic that constructs a feasible solution from the lp-relaxation"
#define HEUR_DISPCHAR '&'
#define HEUR_PRIORITY 1000
#define HEUR_FREQ 1
#define HEUR_FREQOFS 0
#define HEUR_MAXDEPTH -1
#define HEUR_TIMING SCIP_HEURTIMING_AFTERNODE
#define HEUR_USESSUBSCIP FALSE /**< does the heuristic use a secondary SCIP instance? */
/*
* Local methods
*/
/** execution method of primal heuristic */
static
SCIP_DECL_HEUREXEC(heurExecFuzzyround)
{ /*lint --e{715}*/
SCIP_VAR*** binvars;
SCIP_SOL* sol;
SCIP_Real** clustering;
SCIP_Real maxlpval;
SCIP_Bool feasible = FALSE;
int* binsincluster;
int nbins;
int ncluster;
int i;
int k;
int maxcluster;
assert(heur != NULL);
assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
assert(scip != NULL);
assert(result != NULL);
*result = SCIP_DIDNOTRUN;
/* only call heuristic, if an optimal LP solution is at hand */
if( SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
return SCIP_OKAY;
/* only call separator, if there are fractional variables */
if( SCIPgetNLPBranchCands(scip) == 0 )
return SCIP_OKAY;
nbins = SCIPcycGetNBins(scip);
ncluster = SCIPcycGetNCluster(scip);
assert(nbins > 0);
assert(ncluster > 0 && ncluster <= nbins);
binvars = SCIPcycGetBinvars(scip);
assert(binvars != NULL);
/* allocate memory */
SCIP_CALL( SCIPallocClearBufferArray(scip, &clustering , nbins) );
SCIP_CALL( SCIPallocClearBufferArray(scip, &binsincluster, ncluster) );
for( i = 0; i < nbins; ++i )
{
SCIP_CALL( SCIPallocClearBufferArray(scip, &clustering[i], ncluster) ); /*lint !e866*/
}
/* for each bin, set the assignment with the highest lp-value to 1, the rest to 0 */
for( i = 0; i < nbins; ++i )
{
assert(NULL != binvars[i]);
maxlpval = 0;
maxcluster = -1;
for (k = 0; k < ncluster; ++k)
{
assert(NULL != binvars[i][k]);
if( SCIPisGT(scip, SCIPvarGetLPSol(binvars[i][k]), maxlpval) )
{
maxlpval = SCIPvarGetLPSol(binvars[i][k]);
maxcluster = k;
binsincluster[k]++;
}
else if( SCIPisEQ(scip, SCIPvarGetLPSol(binvars[i][k]), maxlpval) && maxcluster != -1
&& binsincluster[maxcluster] > binsincluster[k] )
{
binsincluster[maxcluster]--;
binsincluster[k]++;
maxcluster = k;
}
}
assert(maxcluster >= 0);
clustering[i][maxcluster] = 1.0;
}
assert(isPartition(scip, clustering, nbins, ncluster));
SCIP_CALL( SCIPcreateSol(scip, &sol, heur) );
SCIP_CALL( assignVars(scip, sol, clustering, nbins, ncluster) );
SCIP_CALL( SCIPtrySolFree(scip, &sol, FALSE, TRUE, TRUE, TRUE, TRUE, &feasible) );
if( feasible )
*result = SCIP_FOUNDSOL;
else
*result = SCIP_DIDNOTFIND;
/* free allocated memory */
for( i = 0; i < nbins; ++i )
{
SCIPfreeBufferArray(scip, &clustering[i]);
}
SCIPfreeBufferArray(scip, &clustering);
SCIPfreeBufferArray(scip, &binsincluster);
return SCIP_OKAY;
}
/*
* primal heuristic specific interface methods
*/
/** creates the oneopt primal heuristic and includes it in SCIP */
SCIP_RETCODE SCIPincludeHeurFuzzyround(
SCIP* scip /**< SCIP data structure */
)
{
SCIP_HEUR* heur;
/* include primal heuristic */
SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
HEUR_NAME, HEUR_DESC, HEUR_DISPCHAR, HEUR_PRIORITY, HEUR_FREQ, HEUR_FREQOFS,
HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecFuzzyround, NULL) );
assert(heur != NULL);
return SCIP_OKAY;
}
|
c30fee1e5df75db4e7dc8c0c4802dd8dce2605cb
|
765f7b8c2caf2d50da8f431f1332207456ba33ee
|
/libc/locale/setlocale.c
|
411852cca953fe272b3fd929dfdbe5b1cbb11db3
|
[
"BSD-3-Clause",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-commercial-license",
"AGPL-3.0-or-later",
"GPL-1.0-or-later",
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
klange/toaruos
|
a840f8d46993dc7a8850f82b6d04ba0c2af276a9
|
4a31a09ba27904b42ee35e8fb1a3c7f87669a2ef
|
refs/heads/master
| 2023-09-01T02:00:53.151334
| 2023-08-28T00:59:18
| 2023-08-28T00:59:18
| 1,259,258
| 5,557
| 613
|
NCSA
| 2023-02-04T08:24:11
| 2011-01-16T00:59:27
|
C
|
UTF-8
|
C
| false
| false
| 117
|
c
|
setlocale.c
|
#include <stdlib.h>
#include <locale.h>
char * setlocale(int category, const char *locale) {
return "en_US";
}
|
1e048a181206e48b162c6168680f5c18ace2c421
|
8ae25d84fbcf4c0798e8df1add59326f3849d9ac
|
/libopencm3/include/libopencm3/efm32/hg/doc-efm32hg.h
|
c7f13c3b590dcac8d18ebf71d58c9fb3c3265612
|
[
"Apache-2.0",
"LGPL-2.0-or-later",
"LGPL-3.0-or-later"
] |
permissive
|
im-tomu/tomu-quickstart
|
49eb4bc8ff267d5427f6bcb6a64443476891bb1c
|
8d57866605207099a1b449de42bc0063a5f3c1c8
|
refs/heads/master
| 2023-08-15T23:44:26.343414
| 2023-08-05T15:16:34
| 2023-08-05T15:16:34
| 132,818,206
| 146
| 43
|
Apache-2.0
| 2023-08-05T15:16:35
| 2018-05-09T22:13:30
|
C
|
UTF-8
|
C
| false
| false
| 588
|
h
|
doc-efm32hg.h
|
/** @mainpage libopencm3 EFM32 Happy Gecko
@version 1.0.0
@date 28 January 2018
API documentation for Energy Micro EFM32 Happy Gecko Cortex M0+ series.
LGPL License Terms @ref lgpl_license
*/
/** @defgroup EFM32LG EFM32 HappyGecko
Libraries for Energy Micro EFM32 Happy Gecko series.
@version 1.0.0
@date 28 January 2018
LGPL License Terms @ref lgpl_license
*/
/** @defgroup EFM32HG_defines EFM32 Happy Gecko Defines
@brief Defined Constants and Types for the Energy Micro EFM32 Happy Gecko
series
@version 1.0.0
@date 28 January 2018
LGPL License Terms @ref lgpl_license
*/
|
2fabeb89ee01f1c3f5d022b5d72501671e49752b
|
25c64fb97b7cdb30ec1b6ddd2acf9a755fc33adf
|
/src/probe.h
|
a3449198425a181d6833baf9e8facefc6f44bd51
|
[
"MIT"
] |
permissive
|
arminbiere/kissat
|
386c1cfadf43562d36fccc47064c95296c9b812f
|
630d64d4d63c2816fc79a1a0340286b39677e97d
|
refs/heads/master
| 2023-09-04T01:39:44.293487
| 2023-06-24T15:51:43
| 2023-06-24T15:51:43
| 267,257,286
| 350
| 63
|
MIT
| 2022-06-23T12:15:24
| 2020-05-27T07:57:59
|
C
|
UTF-8
|
C
| false
| false
| 174
|
h
|
probe.h
|
#ifndef _probe_h_INCLUDED
#define _probe_h_INCLUDED
#include <stdbool.h>
struct kissat;
bool kissat_probing (struct kissat *);
int kissat_probe (struct kissat *);
#endif
|
3e9dd667e3a05d3a2888db5eac4efd0ee71ea0f3
|
105be9a75408fe7944b60885061d281e7fd9192b
|
/tools/temp_tools/float_example.c
|
671810e3e67d3ccf4f33623afea6dcce1e1f9340
|
[
"MIT"
] |
permissive
|
farisawan-2000/kirby64
|
73146684368b0cbe5e2a41a42625f07817cc91c3
|
9f95c182132771cfb5f439ab1a60b589c6f7d665
|
refs/heads/master
| 2023-08-08T18:19:35.226495
| 2023-07-23T20:37:14
| 2023-07-23T20:37:14
| 265,695,457
| 148
| 18
| null | 2022-12-27T15:23:50
| 2020-05-20T22:03:14
|
Assembly
|
UTF-8
|
C
| false
| false
| 205
|
c
|
float_example.c
|
#include <stdio.h>
int bruh = 0xb3d6bf95;
int main(void) {
printf("%f\n", *(float *)&bruh);
printf("%e\n", *(float *)&bruh);
printf("%.10f\n", *(float *)&bruh);
printf("%.10e\n", *(float *)&bruh);
}
|
6d6557c94fc63c06e111542bb257eb21a919bf44
|
35ae6922fbfe50390b37927ee2eaeab2469c3b46
|
/ulib/axlibc/include/sys/epoll.h
|
bd23bcf46b027f37314498307918408d99b5b6f8
|
[
"Apache-2.0",
"AGPL-3.0-only",
"LicenseRef-scancode-mulanpubl-2.0",
"AGPL-3.0-or-later",
"GPL-3.0-only",
"MulanPSL-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-mulanpsl-2.0-en"
] |
permissive
|
rcore-os/arceos
|
5a4fe111ed186941a0c8f420ae4165494d2bcd77
|
94eeaa3c2eb247f15f8403d5aa614f878077f48b
|
refs/heads/main
| 2023-08-30T21:07:40.133762
| 2023-08-27T14:21:04
| 2023-08-27T14:31:00
| 605,446,225
| 255
| 94
|
Apache-2.0
| 2023-09-13T11:39:29
| 2023-02-23T07:02:40
|
Rust
|
UTF-8
|
C
| false
| false
| 1,204
|
h
|
epoll.h
|
#ifndef _SYS_EPOLL_H
#define _SYS_EPOLL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <fcntl.h>
#include <stdint.h>
#define EPOLL_CLOEXEC O_CLOEXEC
#define EPOLL_NONBLOCK O_NONBLOCK
enum EPOLL_EVENTS { __EPOLL_DUMMY };
#define EPOLLIN 0x001
#define EPOLLPRI 0x002
#define EPOLLOUT 0x004
#define EPOLLRDNORM 0x040
#define EPOLLNVAL 0x020
#define EPOLLRDBAND 0x080
#define EPOLLWRNORM 0x100
#define EPOLLWRBAND 0x200
#define EPOLLMSG 0x400
#define EPOLLERR 0x008
#define EPOLLHUP 0x010
#define EPOLLRDHUP 0x2000
#define EPOLLEXCLUSIVE (1U << 28)
#define EPOLLWAKEUP (1U << 29)
#define EPOLLONESHOT (1U << 30)
#define EPOLLET (1U << 31)
#define EPOLL_CTL_ADD 1
#define EPOLL_CTL_DEL 2
#define EPOLL_CTL_MOD 3
typedef union epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;
struct epoll_event {
uint32_t events;
epoll_data_t data;
}
#ifdef __x86_64__
__attribute__((__packed__))
#endif
;
int epoll_create(int __size);
int epoll_ctl(int, int, int, struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
#ifdef __cplusplus
}
#endif
#endif //_SYS_EPOLL_H
|
58ef7cba027230905cf34fa0f628f362a6e44c52
|
f07e66293cc41a9fe71fc44f765b432fd7a0997c
|
/selfdrive/sensord/libdiag.h
|
ab3ee91b14a0dbbff41847dbe90697bff4ffe83c
|
[
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
kegman/openpilot
|
c9ba96a72d905956f02c684e065091e023942883
|
b35291c91783657a5fc83abfff012d3bb49dd89f
|
refs/heads/kegman-ultimate
| 2022-05-22T17:07:16.656336
| 2021-10-25T13:35:28
| 2021-10-25T13:35:28
| 229,979,925
| 105
| 212
|
MIT
| 2022-03-13T05:47:51
| 2019-12-24T17:27:11
|
C
|
UTF-8
|
C
| false
| false
| 989
|
h
|
libdiag.h
|
#ifndef LIBDIAG_H
#define LIBDIAG_H
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DIAG_MAX_RX_PKT_SIZ 4096
bool Diag_LSM_Init(uint8_t* pIEnv);
bool Diag_LSM_DeInit(void);
// DCI
#define DIAG_CON_APSS 0x001
#define DIAG_CON_MPSS 0x002
#define DIAG_CON_LPASS 0x004
#define DIAG_CON_WCNSS 0x008
enum {
DIAG_DCI_NO_ERROR = 1001,
} diag_dci_error_type;
int diag_register_dci_client(int*, uint16_t*, int, void*);
int diag_log_stream_config(int client_id, int set_mask, uint16_t log_codes_array[], int num_codes);
int diag_register_dci_stream(void (*func_ptr_logs)(unsigned char *ptr, int len), void (*func_ptr_events)(unsigned char *ptr, int len));
int diag_release_dci_client(int*);
int diag_send_dci_async_req(int client_id, unsigned char buf[], int bytes, unsigned char *rsp_ptr, int rsp_len,
void (*func_ptr)(unsigned char *ptr, int len, void *data_ptr), void *data_ptr);
#ifdef __cplusplus
}
#endif
#endif
|
4d737e8c77dd64a21e0603554ca58ab7d5791db4
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/nuvoton/libraries/nu_packages/SSD1963/ssd1963_ebi.c
|
42c3cb9fab3e2bde74795369e2426111d640a85b
|
[
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"MIT",
"BSD-3-Clause",
"X11",
"BSD-4-Clause-UC",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
RT-Thread/rt-thread
|
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
|
3602f891211904a27dcbd51e5ba72fefce7326b2
|
refs/heads/master
| 2023-09-01T04:10:20.295801
| 2023-08-31T16:20:55
| 2023-08-31T16:20:55
| 7,408,108
| 9,599
| 5,805
|
Apache-2.0
| 2023-09-14T13:37:26
| 2013-01-02T14:49:21
|
C
|
UTF-8
|
C
| false
| false
| 3,194
|
c
|
ssd1963_ebi.c
|
/**************************************************************************//**
*
* @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-2-23 Wayne First version
*
******************************************************************************/
#include <rtconfig.h>
#if defined(NU_PKG_USING_SSD1963_EBI)
#include <lcd_ssd1963.h>
#include "drv_pdma.h"
#define SSD1963_ADDR_CMD 0x0
#define SSD1963_ADDR_DATA 0x0
#define ssd1963_reg_write(u32RegAddr) (*((volatile unsigned short *)(g_uint32_ssd1963_base+(SSD1963_ADDR_CMD))) = (u32RegAddr))
#define ssd1963_read_data() (*((volatile unsigned short *)(g_uint32_ssd1963_base+(SSD1963_ADDR_DATA))))
#define ssd1963_write_data(u32Data) (*((volatile unsigned short *)(g_uint32_ssd1963_base+(SSD1963_ADDR_DATA))) = (u32Data))
static rt_uint32_t g_uint32_ssd1963_base = 0;
void ssd1963_send_cmd(rt_uint8_t cmd)
{
CLR_RS;
ssd1963_reg_write(cmd);
SET_RS;
}
void ssd1963_send_cmd_parameter(rt_uint8_t data)
{
ssd1963_write_data(data);
}
void ssd1963_send_pixel_data(rt_uint16_t color)
{
ssd1963_write_data(color);
}
void ssd1963_send_pixels(rt_uint16_t *pixels, int len)
{
int count = len / sizeof(rt_uint16_t);
if (count < 1024)
{
// CPU feed
int i = 0;
while (i < count)
{
ssd1963_write_data(pixels[i]);
i++;
}
}
else
{
// PDMA-M2M feed
nu_pdma_mempush((void *)(g_uint32_ssd1963_base + (SSD1963_ADDR_DATA)), (void *)pixels, 16, count);
}
}
void ssd1963_set_column(uint16_t StartCol, uint16_t EndCol)
{
ssd1963_send_cmd(0x2A);
ssd1963_write_data((StartCol >> 8) & 0xFF);
ssd1963_write_data(StartCol & 0xFF);
ssd1963_write_data((EndCol >> 8) & 0xFF);
ssd1963_write_data(EndCol & 0xFF);
}
void ssd1963_set_page(uint16_t StartPage, uint16_t EndPage)
{
ssd1963_send_cmd(0x2B);
ssd1963_write_data((StartPage >> 8) & 0xFF);
ssd1963_write_data(StartPage & 0xFF);
ssd1963_write_data((EndPage >> 8) & 0xFF);
ssd1963_write_data(EndPage & 0xFF);
}
void ssd1963_lcd_get_pixel(char *color, int x, int y)
{
rt_uint16_t red = 0;
rt_uint16_t green = 0;
rt_uint16_t blue = 0;
if (x >= XSIZE_PHYS || y >= YSIZE_PHYS)
{
*(rt_uint16_t *)color = 0;
return;
}
ssd1963_set_column(x, x);
ssd1963_set_page(y, y);
ssd1963_send_cmd(0x2E);
ssd1963_read_data(); // Dummy
red = ssd1963_read_data(); // Red[4:0]@D15~D11
blue = ssd1963_read_data(); // Blue[4:0]@D15~D11
green = ssd1963_read_data(); // Green[5:0]@D15~D10
//BGR565: B in High byte, R in low byte
//*(rt_uint16_t *)color = (((blue >> 11) << 11) | ((green >> 10) << 5) | (red >> 11));
//RGB565: R in High byte, B in low byte
*(rt_uint16_t *)color = (((red >> 11) << 11) | ((green >> 10) << 5) | (blue >> 11));
}
rt_err_t rt_hw_lcd_ssd1963_ebi_init(rt_uint32_t ssd1963_base)
{
g_uint32_ssd1963_base = ssd1963_base;
return RT_EOK;
}
#endif /* if defined(NU_PKG_USING_SSD1963_EBI) */
|
70ed1d51964fd5f8c4adb8e88c20c015768e2fc5
|
0f5e7c855849f14588168134921632e06a373589
|
/Pods/AudioKit/macOS/AudioKit.framework/Versions/A/Headers/vocwrapper.h
|
32beae3562226192df7999bb6df0bf6b9a489be1
|
[
"MIT"
] |
permissive
|
vanshg/MacAssistant
|
477a743289a6ff34c8127d14c66ccfef4ca92a2c
|
a0c3b4fd6d01815159ca286b0bc135b0b55a5104
|
refs/heads/master
| 2023-03-07T18:11:18.372398
| 2023-03-05T23:23:34
| 2023-03-05T23:23:34
| 89,634,004
| 1,763
| 186
|
MIT
| 2020-09-22T18:54:18
| 2017-04-27T19:40:13
|
Swift
|
UTF-8
|
C
| false
| false
| 378
|
h
|
vocwrapper.h
|
typedef struct {
SPFLOAT freq;
SPFLOAT pos;
SPFLOAT diam;
SPFLOAT tenseness;
SPFLOAT nasal;
sp_voc *voc;
} sp_vocwrapper;
int sp_vocwrapper_create(sp_vocwrapper **p);
int sp_vocwrapper_destroy(sp_vocwrapper **p);
int sp_vocwrapper_init(sp_data *sp, sp_vocwrapper *p);
int sp_vocwrapper_compute(sp_data *sp, sp_vocwrapper *p, SPFLOAT *in, SPFLOAT *out);
|
60e3280e4e43ea8255bf03e497cabd1d0b0d1c0f
|
b452bbb87214f174122f425f6f98f4c3890c3cca
|
/internal/ccall/gvc/gvconfig.c
|
997fffc4ce2fb9a6950dcab96bf511a7887198a6
|
[
"MIT"
] |
permissive
|
goccy/go-graphviz
|
bea9bc86b42734aff7ffae283aeae71702ca588a
|
865af036ddbb745c4424bbd2fdaa9a75668cf0d4
|
refs/heads/master
| 2023-07-20T08:05:39.868377
| 2023-03-21T23:49:44
| 2023-03-21T23:49:44
| 236,740,615
| 511
| 66
|
MIT
| 2023-07-07T13:53:28
| 2020-01-28T13:24:09
|
Go
|
UTF-8
|
C
| false
| false
| 16,977
|
c
|
gvconfig.c
|
/* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */
/*************************************************************************
* Copyright (c) 2011 AT&T Intellectual Property
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: See CVS logs. Details at http://www.graphviz.org/
*************************************************************************/
#include "config.h"
#include "gvconfig.h"
#include <string.h>
#ifndef WIN32
#include <regex.h>
#endif
#ifdef ENABLE_LTDL
#include <sys/types.h>
#ifdef WIN32
#include <windows.h>
#define GLOB_NOSPACE 1 /* Ran out of memory. */
#define GLOB_ABORTED 2 /* Read error. */
#define GLOB_NOMATCH 3 /* No matches found. */
#define GLOB_NOSORT 4
#define DMKEY "Software\\Microsoft" //key to look for library dir
typedef struct {
int gl_pathc; /* count of total paths so far */
int gl_matchc; /* count of paths matching pattern */
int gl_offs; /* reserved at beginning of gl_pathv */
int gl_flags; /* returned flags */
char **gl_pathv; /* list of paths matching pattern */
} glob_t;
static void globfree (glob_t* pglob);
static int glob (GVC_t * gvc, char*, int, int (*errfunc)(const char *, int), glob_t*);
#else
#include <glob.h>
#endif
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
#ifdef __APPLE__
#include <mach-o/dyld.h>
#endif
#include "memory.h"
#include "const.h"
#include "types.h"
#include "gvplugin.h"
#include "gvcjob.h"
#include "gvcint.h"
#include "gvcproc.h"
/* FIXME */
extern Dt_t * textfont_dict_open(GVC_t *gvc);
/*
A config for gvrender is a text file containing a
list of plugin librariess and their capabilities using a tcl-like
syntax
Lines beginning with '#' are ignored as comments
Blank lines are allowed and ignored.
plugin_library_path packagename {
plugin_api {
plugin_type plugin_quality
...
}
...
...
e.g.
/usr/lib/graphviz/libgvplugin_cairo.so cairo {renderer {x 0 png 10 ps -10}}
/usr/lib/graphviz/libgvplugin_gd.so gd {renderer {png 0 gif 0 jpg 0}}
Internally the config is maintained as lists of plugin_types for each plugin_api.
If multiple plugins of the same type are found then the highest quality wins.
If equal quality then the last-one-installed wins (thus giving preference to
external plugins over internal builtins).
*/
static gvplugin_package_t * gvplugin_package_record(GVC_t * gvc, char *path, char *name)
{
gvplugin_package_t *package = gmalloc(sizeof(gvplugin_package_t));
package->path = (path) ? strdup(path) : NULL;
package->name = strdup(name);
package->next = gvc->packages;
gvc->packages = package;
return package;
}
#ifdef ENABLE_LTDL
/*
separator - consume all non-token characters until next token. This includes:
comments: '#' ... '\n'
nesting: '{'
unnesting: '}'
whitespace: ' ','\t','\n'
*nest is changed according to nesting/unnesting processed
*/
static void separator(int *nest, char **tokens)
{
char c, *s;
s = *tokens;
while ((c = *s)) {
/* #->eol = comment */
if (c == '#') {
s++;
while ((c = *s)) {
s++;
if (c == '\n')
break;
}
continue;
}
if (c == '{') {
(*nest)++;
s++;
continue;
}
if (c == '}') {
(*nest)--;
s++;
continue;
}
if (c == ' ' || c == '\n' || c == '\t') {
s++;
continue;
}
break;
}
*tokens = s;
}
/*
token - capture all characters until next separator, then consume separator,
return captured token, leave **tokens pointing to next token.
*/
static char *token(int *nest, char **tokens)
{
char c, *s, *t;
s = t = *tokens;
while ((c = *s)) {
if (c == '#'
|| c == ' ' || c == '\t' || c == '\n' || c == '{' || c == '}')
break;
s++;
}
*tokens = s;
separator(nest, tokens);
*s = '\0';
return t;
}
static int gvconfig_plugin_install_from_config(GVC_t * gvc, char *s)
{
char *path, *name, *api;
const char *type;
api_t gv_api;
int quality, rc;
int nest = 0;
gvplugin_package_t *package;
separator(&nest, &s);
while (*s) {
path = token(&nest, &s);
if (nest == 0)
name = token(&nest, &s);
else
name = "x";
package = gvplugin_package_record(gvc, path, name);
do {
api = token(&nest, &s);
gv_api = gvplugin_api(api);
do {
if (nest == 2) {
type = token(&nest, &s);
if (nest == 2)
quality = atoi(token(&nest, &s));
else
quality = 0;
rc = gvplugin_install (gvc, gv_api,
type, quality, package, NULL);
if (!rc) {
agerr(AGERR, "config error: %s %s %s\n", path, api, type);
return 0;
}
}
} while (nest == 2);
} while (nest == 1);
}
return 1;
}
#endif
void gvconfig_plugin_install_from_library(GVC_t * gvc, char *path, gvplugin_library_t *library)
{
gvplugin_api_t *apis;
gvplugin_installed_t *types;
gvplugin_package_t *package;
int i;
package = gvplugin_package_record(gvc, path, library->packagename);
for (apis = library->apis; (types = apis->types); apis++) {
for (i = 0; types[i].type; i++) {
gvplugin_install(gvc, apis->api, types[i].type,
types[i].quality, package, &types[i]);
}
}
}
static void gvconfig_plugin_install_builtins(GVC_t * gvc)
{
const lt_symlist_t *s;
const char *name;
if (gvc->common.builtins == NULL) return;
for (s = gvc->common.builtins; (name = s->name); s++)
if (name[0] == 'g' && strstr(name, "_LTX_library"))
gvconfig_plugin_install_from_library(gvc, NULL,
(gvplugin_library_t *)(s->address));
}
#ifdef ENABLE_LTDL
static void gvconfig_write_library_config(GVC_t *gvc, char *path, gvplugin_library_t *library, FILE *f)
{
gvplugin_api_t *apis;
gvplugin_installed_t *types;
int i;
fprintf(f, "%s %s {\n", path, library->packagename);
for (apis = library->apis; (types = apis->types); apis++) {
fprintf(f, "\t%s {\n", gvplugin_api_name(apis->api));
for (i = 0; types[i].type; i++) {
/* verify that dependencies are available */
if (! (gvplugin_load(gvc, apis->api, types[i].type)))
fprintf(f, "#FAILS");
fprintf(f, "\t\t%s %d\n", types[i].type, types[i].quality);
}
fputs ("\t}\n", f);
}
fputs ("}\n", f);
}
#define BSZ 1024
#define DOTLIBS "/.libs"
#define STRLEN(s) (sizeof(s)-1)
char * gvconfig_libdir(GVC_t * gvc)
{
static char line[BSZ];
static char *libdir;
static boolean dirShown = 0;
char *tmp;
if (!libdir) {
libdir=getenv("GVBINDIR");
if (!libdir) {
#ifdef WIN32
int r;
char* s;
MEMORY_BASIC_INFORMATION mbi;
if (VirtualQuery (&gvconfig_libdir, &mbi, sizeof(mbi)) == 0) {
agerr(AGERR,"failed to get handle for executable.\n");
return 0;
}
r = GetModuleFileName ((HMODULE)mbi.AllocationBase, line, BSZ);
if (!r || (r == BSZ)) {
agerr(AGERR,"failed to get path for executable.\n");
return 0;
}
s = strrchr(line,'\\');
if (!s) {
agerr(AGERR,"no slash in path %s.\n", line);
return 0;
}
*s = '\0';
libdir = line;
#else
libdir = "graphviz";
#ifdef __APPLE__
uint32_t i, c = _dyld_image_count();
size_t len, ind;
const char* path;
for (i = 0; i < c; ++i) {
path = _dyld_get_image_name(i);
tmp = strstr(path, "/libgvc.");
if (tmp) {
if (tmp > path) {
/* Check for real /lib dir. Don't accept pre-install /.libs */
char* s = tmp-1;
/* back up to previous slash (or head of string) */
while ((*s != '/') && (s > path)) s--;
if (strncmp (s, DOTLIBS, STRLEN(DOTLIBS)) == 0)
continue;
}
ind = tmp - path; /* byte offset */
len = ind + sizeof("/graphviz");
if (len < BSZ)
libdir = line;
else
libdir = gmalloc(len);
bcopy (path, libdir, ind);
/* plugins are in "graphviz" subdirectory */
strcpy(libdir+ind, "/graphviz");
break;
}
}
#else
FILE* f = fopen ("/proc/self/maps", "r");
char* path;
if (f) {
while (!feof (f)) {
if (!fgets (line, sizeof (line), f))
continue;
if (!strstr (line, " r-xp "))
continue;
path = strchr (line, '/');
if (!path)
continue;
tmp = strstr (path, "/libgvc.");
if (tmp) {
*tmp = 0;
/* Check for real /lib dir. Don't accept pre-install /.libs */
if (strcmp(strrchr(path,'/'), "/.libs") == 0)
continue;
strcpy(line, path); /* use line buffer for result */
strcat(line, "/graphviz"); /* plugins are in "graphviz" subdirectory */
libdir = line;
break;
}
}
fclose (f);
}
#endif
#endif
}
}
if (gvc->common.verbose && !dirShown) {
fprintf (stderr, "libdir = \"%s\"\n", (libdir ? libdir : "<null>"));
dirShown = 1;
}
return libdir;
}
#endif
#ifdef ENABLE_LTDL
static void config_rescan(GVC_t *gvc, char *config_path)
{
FILE *f = NULL;
glob_t globbuf;
char *config_glob, *config_re, *path, *libdir;
int i, rc, re_status;
gvplugin_library_t *library;
regex_t re;
#ifndef WIN32
char *plugin_glob = "libgvplugin_*";
#endif
#if defined(DARWIN_DYLIB)
char *plugin_re_beg = "[^0-9]\\.";
char *plugin_re_end = "\\.dylib$";
#elif defined(__MINGW32__)
char *plugin_glob = "libgvplugin_*";
char *plugin_re_beg = "[^0-9]-";
char *plugin_re_end = "\\.dll$";
#elif defined(__CYGWIN__)
plugin_glob = "cyggvplugin_*";
char *plugin_re_beg = "[^0-9]-";
char *plugin_re_end = "\\.dll$";
#elif defined(WIN32)
char *plugin_glob = "gvplugin_*";
char *plugin_re_beg = "[^0-9]";
char *plugin_re_end = "\\.dll$";
#elif ((defined(__hpux__) || defined(__hpux)) && !(defined(__ia64)))
char *plugin_re_beg = "\\.sl\\.";
char *plugin_re_end = "$";
#else
/* Everyone else */
char *plugin_re_beg = "\\.so\\.";
char *plugin_re_end= "$";
#endif
if (config_path) {
f = fopen(config_path,"w");
if (!f) {
agerr(AGERR,"failed to open %s for write.\n", config_path);
exit(1);
}
fprintf(f, "# This file was generated by \"dot -c\" at time of install.\n\n");
fprintf(f, "# You may temporarily disable a plugin by removing or commenting out\n");
fprintf(f, "# a line in this file, or you can modify its \"quality\" value to affect\n");
fprintf(f, "# default plugin selection.\n\n");
fprintf(f, "# Manual edits to this file **will be lost** on upgrade.\n\n");
}
libdir = gvconfig_libdir(gvc);
config_re = gmalloc(strlen(plugin_re_beg) + 20 + strlen(plugin_re_end) + 1);
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
sprintf(config_re,"%s%s", plugin_re_beg, plugin_re_end);
#elif defined(GVPLUGIN_VERSION)
sprintf(config_re,"%s%d%s", plugin_re_beg, GVPLUGIN_VERSION, plugin_re_end);
#else
sprintf(config_re,"%s[0-9]+%s", plugin_re_beg, plugin_re_end);
#endif
if (regcomp(&re, config_re, REG_EXTENDED|REG_NOSUB) != 0) {
agerr(AGERR,"cannot compile regular expression %s", config_re);
}
config_glob = gmalloc(strlen(libdir) + 1 + strlen(plugin_glob) + 1);
strcpy(config_glob, libdir);
strcat(config_glob, DIRSEP);
strcat(config_glob, plugin_glob);
/* load all libraries even if can't save config */
#if defined(WIN32)
rc = glob(gvc, config_glob, GLOB_NOSORT, NULL, &globbuf);
#else
rc = glob(config_glob, GLOB_NOSORT, NULL, &globbuf);
#endif
if (rc == 0) {
for (i = 0; i < globbuf.gl_pathc; i++) {
re_status = regexec(&re, globbuf.gl_pathv[i], (size_t) 0, NULL, 0);
if (re_status == 0) {
library = gvplugin_library_load(gvc, globbuf.gl_pathv[i]);
if (library) {
gvconfig_plugin_install_from_library(gvc, globbuf.gl_pathv[i], library);
}
}
}
/* rescan with all libs loaded to check cross dependencies */
for (i = 0; i < globbuf.gl_pathc; i++) {
re_status = regexec(&re, globbuf.gl_pathv[i], (size_t) 0, NULL, 0);
if (re_status == 0) {
library = gvplugin_library_load(gvc, globbuf.gl_pathv[i]);
if (library) {
path = strrchr(globbuf.gl_pathv[i],DIRSEP[0]);
if (path)
path++;
if (f && path)
gvconfig_write_library_config(gvc, path, library, f);
}
}
}
}
regfree(&re);
globfree(&globbuf);
free(config_glob);
free(config_re);
if (f)
fclose(f);
}
#endif
/*
gvconfig - parse a config file and install the identified plugins
*/
void gvconfig(GVC_t * gvc, boolean rescan)
{
#if 0
gvplugin_library_t **libraryp;
#endif
#ifdef ENABLE_LTDL
int sz, rc;
struct stat config_st, libdir_st;
FILE *f = NULL;
char *config_text = NULL;
char *libdir;
char *config_file_name = GVPLUGIN_CONFIG_FILE;
#define MAX_SZ_CONFIG 100000
#endif
/* builtins don't require LTDL */
gvconfig_plugin_install_builtins(gvc);
gvc->config_found = FALSE;
#ifdef __ENABLE_LTDL__
if (gvc->common.demand_loading) {
/* see if there are any new plugins */
libdir = gvconfig_libdir(gvc);
rc = stat(libdir, &libdir_st);
if (rc == -1) {
gvtextlayout_select(gvc); /* choose best available textlayout plugin immediately */
/* if we fail to stat it then it probably doesn't exist so just fail silently */
return;
}
if (! gvc->config_path) {
gvc->config_path = gmalloc(strlen(libdir) + 1 + strlen(config_file_name) + 1);
strcpy(gvc->config_path, libdir);
strcat(gvc->config_path, DIRSEP);
strcat(gvc->config_path, config_file_name);
}
if (rescan) {
config_rescan(gvc, gvc->config_path);
gvc->config_found = TRUE;
gvtextlayout_select(gvc); /* choose best available textlayout plugin immediately */
return;
}
/* load in the cached plugin library data */
rc = stat(gvc->config_path, &config_st);
if (rc == -1) {
gvtextlayout_select(gvc); /* choose best available textlayout plugin immediately */
/* silently return without setting gvc->config_found = TRUE */
return;
}
else if (config_st.st_size > MAX_SZ_CONFIG) {
agerr(AGERR,"%s is bigger than I can handle.\n", gvc->config_path);
}
else {
f = fopen(gvc->config_path,"r");
if (!f) {
agerr (AGERR,"failed to open %s for read.\n", gvc->config_path);
return;
}
else {
config_text = gmalloc(config_st.st_size + 1);
sz = fread(config_text, 1, config_st.st_size, f);
if (sz == 0) {
agerr(AGERR,"%s is zero sized, or other read error.\n", gvc->config_path);
free(config_text);
}
else {
gvc->config_found = TRUE;
config_text[sz] = '\0'; /* make input into a null terminated string */
rc = gvconfig_plugin_install_from_config(gvc, config_text);
/* NB. config_text not freed because we retain char* into it */
}
}
if (f) {
fclose(f);
}
}
}
#endif
gvtextlayout_select(gvc); /* choose best available textlayout plugin immediately */
textfont_dict_open(gvc); /* initialize font dict */
}
#ifdef ENABLE_LTDL
#ifdef WIN32
/* Emulating windows glob */
/* glob:
* Assumes only GLOB_NOSORT flag given. That is, there is no offset,
* and no previous call to glob.
*/
static int
glob (GVC_t* gvc, char* pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob)
{
char* libdir;
WIN32_FIND_DATA wfd;
HANDLE h;
char** str=0;
int arrsize=0;
int cnt = 0;
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
h = FindFirstFile (pattern, &wfd);
if (h == INVALID_HANDLE_VALUE) return GLOB_NOMATCH;
libdir = gvconfig_libdir(gvc);
do {
if (cnt >= arrsize-1) {
arrsize += 512;
if (str) str = (char**)realloc (str, arrsize*sizeof(char*));
else str = (char**)malloc (arrsize*sizeof(char*));
if (!str) return GLOB_NOSPACE;
}
str[cnt] = (char*)malloc (strlen(libdir)+1+strlen(wfd.cFileName)+1);
if (!str[cnt]) return GLOB_NOSPACE;
strcpy(str[cnt],libdir);
strcat(str[cnt],DIRSEP);
strcat(str[cnt],wfd.cFileName);
cnt++;
} while (FindNextFile (h, &wfd));
str[cnt] = 0;
pglob->gl_pathc = cnt;
pglob->gl_pathv = (char**)realloc(str, (cnt+1)*sizeof(char*));
return 0;
}
static void
globfree (glob_t* pglob)
{
int i;
for (i = 0; i < pglob->gl_pathc; i++)
free (pglob->gl_pathv[i]);
if (pglob->gl_pathv)
free (pglob->gl_pathv);
}
#endif
#endif
|
7f17436668cc6c7df8d55dc31aaca5153920452b
|
7664f318ed04bd0680f3d82321c18896e3ef6ad5
|
/src/overlays/actors/ovl_En_Mk/z_en_mk.c
|
314397a9ff37a13056bbe9cd1a3909e8bc19b8a0
|
[] |
no_license
|
zeldaret/oot
|
9c80ce17f2d8fd61514b375f92ee4739b5ce9d4e
|
2875ab4fcf5c5f81d76353d1ee0024c9ea8d0b23
|
refs/heads/master
| 2023-08-29T05:29:31.356427
| 2023-08-28T22:48:52
| 2023-08-28T22:48:52
| 247,875,738
| 4,401
| 802
| null | 2023-09-14T13:34:38
| 2020-03-17T04:02:19
|
C
|
UTF-8
|
C
| false
| false
| 12,055
|
c
|
z_en_mk.c
|
/*
* File: z_en_mk.c
* Overlay: ovl_En_Mk
* Description: Lakeside Professor
*/
#include "z_en_mk.h"
#include "assets/objects/object_mk/object_mk.h"
#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4)
void EnMk_Init(Actor* thisx, PlayState* play);
void EnMk_Destroy(Actor* thisx, PlayState* play);
void EnMk_Update(Actor* thisx, PlayState* play);
void EnMk_Draw(Actor* thisx, PlayState* play);
void EnMk_Wait(EnMk* this, PlayState* play);
ActorInit En_Mk_InitVars = {
ACTOR_EN_MK,
ACTORCAT_NPC,
FLAGS,
OBJECT_MK,
sizeof(EnMk),
(ActorFunc)EnMk_Init,
(ActorFunc)EnMk_Destroy,
(ActorFunc)EnMk_Update,
(ActorFunc)EnMk_Draw,
};
static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
AT_NONE,
AC_ON | AC_TYPE_ENEMY,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_1,
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0xFFCFFFFF, 0x00, 0x00 },
TOUCH_NONE,
BUMP_ON,
OCELEM_ON,
},
{ 30, 40, 0, { 0, 0, 0 } },
};
void EnMk_Init(Actor* thisx, PlayState* play) {
EnMk* this = (EnMk*)thisx;
s32 swimFlag;
this->actor.minVelocityY = -4.0f;
this->actor.gravity = -1.0f;
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f);
SkelAnime_InitFlex(play, &this->skelAnime, &object_mk_Skel_005DF0, &object_mk_Anim_000D88, this->jointTable,
this->morphTable, 13);
Animation_PlayLoop(&this->skelAnime, &object_mk_Anim_000D88);
Collider_InitCylinder(play, &this->collider);
Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit);
this->actor.colChkInfo.mass = 0xFF;
Actor_SetScale(&this->actor, 0.01f);
this->actionFunc = EnMk_Wait;
this->flags = 0;
this->swimFlag = 0;
this->actor.targetMode = 6;
if (GET_ITEMGETINF(ITEMGETINF_10)) {
this->flags |= 4;
}
}
void EnMk_Destroy(Actor* thisx, PlayState* play) {
EnMk* this = (EnMk*)thisx;
Collider_DestroyCylinder(play, &this->collider);
}
void func_80AACA40(EnMk* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
this->actor.flags &= ~ACTOR_FLAG_16;
this->actionFunc = EnMk_Wait;
}
this->flags |= 1;
}
void func_80AACA94(EnMk* this, PlayState* play) {
if (Actor_HasParent(&this->actor, play) != 0) {
this->actor.parent = NULL;
this->actionFunc = func_80AACA40;
Interface_SetSubTimer(240);
CLEAR_EVENTINF(EVENTINF_MARATHON_ACTIVE);
} else {
Actor_OfferGetItem(&this->actor, play, GI_EYE_DROPS, 10000.0f, 50.0f);
}
}
void func_80AACB14(EnMk* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
this->actionFunc = func_80AACA94;
Actor_OfferGetItem(&this->actor, play, GI_EYE_DROPS, 10000.0f, 50.0f);
}
}
void func_80AACB6C(EnMk* this, PlayState* play) {
if (Actor_ProcessTalkRequest(&this->actor, play)) {
this->actionFunc = func_80AACB14;
}
this->flags |= 1;
}
void func_80AACBAC(EnMk* this, PlayState* play) {
if (this->timer > 0) {
this->timer--;
this->actor.shape.rot.y -= 0x800;
} else {
this->actionFunc = func_80AACB6C;
Message_ContinueTextbox(play, 0x4030);
}
}
void func_80AACC04(EnMk* this, PlayState* play) {
if (this->timer > 0) {
this->timer--;
} else {
this->timer = 16;
this->actionFunc = func_80AACBAC;
Animation_Change(&this->skelAnime, &object_mk_Anim_000D88, 1.0f, 0.0f,
Animation_GetLastFrame(&object_mk_Anim_000D88), ANIMMODE_LOOP, -4.0f);
this->flags &= ~2;
}
}
void func_80AACCA0(EnMk* this, PlayState* play) {
if (this->timer > 0) {
this->timer--;
this->actor.shape.rot.y += 0x800;
} else {
this->timer = 120;
this->actionFunc = func_80AACC04;
Animation_Change(&this->skelAnime, &object_mk_Anim_000724, 1.0f, 0.0f,
Animation_GetLastFrame(&object_mk_Anim_000724), ANIMMODE_LOOP, -4.0f);
this->flags &= ~2;
}
}
void func_80AACD48(EnMk* this, PlayState* play) {
Player* player = GET_PLAYER(play);
if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) {
Message_CloseTextbox(play);
this->actionFunc = func_80AACCA0;
play->msgCtx.msgMode = MSGMODE_PAUSED;
player->exchangeItemId = EXCH_ITEM_NONE;
this->timer = 16;
Animation_Change(&this->skelAnime, &object_mk_Anim_000D88, 1.0f, 0.0f,
Animation_GetLastFrame(&object_mk_Anim_000D88), ANIMMODE_LOOP, -4.0f);
this->flags &= ~2;
}
this->flags |= 1;
}
void func_80AACE2C(EnMk* this, PlayState* play) {
if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) {
Message_ContinueTextbox(play, 0x4001);
Animation_Change(&this->skelAnime, &object_mk_Anim_000AC0, 1.0f, 0.0f,
Animation_GetLastFrame(&object_mk_Anim_000AC0), ANIMMODE_ONCE, -4.0f);
this->flags &= ~2;
this->actionFunc = func_80AACD48;
}
this->flags |= 1;
}
void func_80AACEE8(EnMk* this, PlayState* play) {
if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) {
Message_ContinueTextbox(play, 0x4000);
Animation_Change(&this->skelAnime, &object_mk_Anim_000AC0, 1.0f, 0.0f,
Animation_GetLastFrame(&object_mk_Anim_000AC0), ANIMMODE_LOOP, -4.0f);
this->flags &= ~2;
this->actionFunc = func_80AACE2C;
}
this->flags |= 1;
}
void func_80AACFA0(EnMk* this, PlayState* play) {
if (Actor_HasParent(&this->actor, play)) {
this->actor.parent = NULL;
this->actionFunc = func_80AACA40;
SET_ITEMGETINF(ITEMGETINF_10);
} else {
Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 10000.0f, 50.0f);
}
}
void func_80AAD014(EnMk* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
this->actionFunc = func_80AACFA0;
Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 10000.0f, 50.0f);
}
this->flags |= 1;
}
void EnMk_Wait(EnMk* this, PlayState* play) {
s16 angle;
s32 swimFlag;
Player* player = GET_PLAYER(play);
s32 playerExchangeItem;
if (Actor_ProcessTalkRequest(&this->actor, play)) {
playerExchangeItem = func_8002F368(play);
if (this->actor.textId != 0x4018) {
player->actor.textId = this->actor.textId;
this->actionFunc = func_80AACA40;
} else {
if (INV_CONTENT(ITEM_ODD_MUSHROOM) == ITEM_EYE_DROPS) {
player->actor.textId = 0x4032;
this->actionFunc = func_80AACA40;
} else {
switch (playerExchangeItem) {
case EXCH_ITEM_NONE:
if (this->swimFlag >= 8) {
if (GET_ITEMGETINF(ITEMGETINF_10)) {
player->actor.textId = 0x4075;
this->actionFunc = func_80AACA40;
} else {
player->actor.textId = 0x4074;
this->actionFunc = func_80AAD014;
this->swimFlag = 0;
}
} else {
if (this->swimFlag == 0) {
player->actor.textId = 0x4018;
this->actionFunc = func_80AACA40;
} else {
player->actor.textId = 0x406C + this->swimFlag;
this->actionFunc = func_80AACA40;
}
}
break;
case EXCH_ITEM_EYEBALL_FROG:
player->actor.textId = 0x4019;
this->actionFunc = func_80AACEE8;
Animation_Change(&this->skelAnime, &object_mk_Anim_000368, 1.0f, 0.0f,
Animation_GetLastFrame(&object_mk_Anim_000368), ANIMMODE_ONCE, -4.0f);
this->flags &= ~2;
gSaveContext.subTimerState = SUBTIMER_STATE_OFF;
Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR);
break;
default:
player->actor.textId = 0x4018;
this->actionFunc = func_80AACA40;
break;
}
}
}
} else {
this->actor.textId = Text_GetFaceReaction(play, 0x1A);
if (this->actor.textId == 0) {
this->actor.textId = 0x4018;
}
angle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
if ((ABS(angle) < 0x2151) && (this->actor.xzDistToPlayer < 100.0f)) {
func_8002F298(&this->actor, play, 100.0f, EXCH_ITEM_EYEBALL_FROG);
this->flags |= 1;
}
}
}
void EnMk_Update(Actor* thisx, PlayState* play) {
EnMk* this = (EnMk*)thisx;
s32 pad;
Vec3s vec;
Player* player;
s16 swimFlag;
Collider_UpdateCylinder(&this->actor, &this->collider);
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base);
Actor_MoveXZGravity(&this->actor);
Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2);
if (!(this->flags & 2) && SkelAnime_Update(&this->skelAnime)) {
this->flags |= 2;
}
this->actionFunc(this, play);
if (this->flags & 1) {
Actor_TrackPlayer(play, &this->actor, &this->headRotation, &vec, this->actor.focus.pos);
} else {
Math_SmoothStepToS(&this->headRotation.x, 0, 6, 6200, 100);
Math_SmoothStepToS(&this->headRotation.y, 0, 6, 6200, 100);
}
player = GET_PLAYER(play);
if (this->flags & 8) {
if (!(player->stateFlags2 & PLAYER_STATE2_10)) {
this->flags &= ~8;
}
} else {
if (player->currentBoots == PLAYER_BOOTS_IRON) {
this->flags |= 8;
} else if (player->stateFlags2 & PLAYER_STATE2_10) {
swimFlag = player->actor.yDistToWater;
if (swimFlag > 0) {
if (swimFlag >= 320) {
if (swimFlag >= 355) {
swimFlag = 8;
} else {
swimFlag = 7;
}
} else if (swimFlag < 80) {
swimFlag = 1;
} else {
swimFlag *= 0.025f;
}
if (this->swimFlag < swimFlag) {
this->swimFlag = swimFlag;
if (!(this->flags & 4) && (this->swimFlag >= 8)) {
this->flags |= 4;
Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME);
}
}
}
}
}
}
s32 EnMk_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) {
EnMk* this = (EnMk*)thisx;
if (limbIndex == 11) {
rot->y -= this->headRotation.y;
rot->z += this->headRotation.x;
}
return false;
}
void EnMk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) {
static Vec3f D_80AAD64C = { 1000.0f, -100.0f, 0.0f };
EnMk* this = (EnMk*)thisx;
if (limbIndex == 11) {
Matrix_MultVec3f(&D_80AAD64C, &this->actor.focus.pos);
}
}
void EnMk_Draw(Actor* thisx, PlayState* play) {
EnMk* this = (EnMk*)thisx;
Gfx_SetupDL_37Opa(play->state.gfxCtx);
SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount,
EnMk_OverrideLimbDraw, EnMk_PostLimbDraw, &this->actor);
}
|
84f7ffcac1e5317b16fefef186388f7f8944bc85
|
a5a99f646e371b45974a6fb6ccc06b0a674818f2
|
/GeneratorInterface/AlpgenInterface/interface/AlpgenCommonBlocks.h
|
b766c035d3bc9d2f1e36eaab862fd3c1372c8a14
|
[
"Apache-2.0"
] |
permissive
|
cms-sw/cmssw
|
4ecd2c1105d59c66d385551230542c6615b9ab58
|
19c178740257eb48367778593da55dcad08b7a4f
|
refs/heads/master
| 2023-08-23T21:57:42.491143
| 2023-08-22T20:22:40
| 2023-08-22T20:22:40
| 10,969,551
| 1,006
| 3,696
|
Apache-2.0
| 2023-09-14T19:14:28
| 2013-06-26T14:09:07
|
C++
|
UTF-8
|
C
| false
| false
| 1,346
|
h
|
AlpgenCommonBlocks.h
|
#ifndef GeneratorInterface_AlpgenInterface_AlpgenCommonBlocks_h
#define GeneratorInterface_AlpgenInterface_AlpgenCommonBlocks_h
/// A C/C++ representation of the ALPGEN Common Blocks:
/// AHOPTS, AHPPARA, AHPARS, AHCUTS.
extern "C" {
extern struct AHOPTS {
double etclus; // needs to be set up
double rclus; // needs to be set up
double etaclmax;
int iexc; // needs to be set up
int npfst;
int nplst;
int nljets;
int njstart;
int njlast;
int ickkw;
} ahopts_;
extern struct AHPPARA {
double masses[6]; // mc,mb,mt,mw,mz,mh (set up these)
double ebeam;
int ih1, ih2, ihrd; // ihrd needs to be set up
int itopprc;
int nw, nz, nh, nph;
int ihvy, ihvy2;
int npart, ndns, pdftyp;
} ahppara_;
extern struct AHPARS {
static const unsigned int nparam = 200;
double parval[nparam];
char chpar[nparam][8];
char chpdes[nparam][70];
int parlen[nparam];
int partyp[nparam];
} ahpars_;
extern struct AHCUTS {
double ptjmin, ptjmax;
double etajmax, drjmin;
double ptbmin, ptbmax;
double etabmax, drbmin;
double ptcmin, ptcmax;
double etacmax, drcmin;
double ptphmin;
double etaphmax;
double drphjmin, drphmin, drphlmin;
double ptlmin;
double etalmax, drlmin;
double metmin;
double mllmin, mllmax;
} ahcuts_;
}
#endif // GeneratorInterface_AlpgenInterface_AlpgenCommonBlocks_h
|
8c2ee35d05e5bbf3048fa01770d67fb1b62f5784
|
6601ed1b6c24e8b7e78312aeaadf816262c4bee3
|
/c/libelf/rawdata.c
|
5d9a9f30476eaf5d48bf44df2054fba0740653e3
|
[
"BSD-2-Clause"
] |
permissive
|
t-crest/patmos
|
bb9764c5897ee8bbac2a336cb09d7bb77d54916a
|
c63dadffa3db2ad241c31ae6e952d6fe2298986a
|
refs/heads/master
| 2023-04-11T12:18:37.795018
| 2023-03-25T17:57:33
| 2023-03-25T17:57:33
| 1,500,522
| 108
| 90
|
BSD-2-Clause
| 2023-03-25T17:57:35
| 2011-03-19T17:01:39
|
VHDL
|
UTF-8
|
C
| false
| false
| 2,543
|
c
|
rawdata.c
|
/*
rawdata.c - implementation of the elf_rawdata(3) function.
Copyright (C) 1995 - 2000 Michael Riepe
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <private.h>
#ifndef lint
static const char rcsid[] = "@(#) $Id: rawdata.c,v 1.10 2008/05/23 08:15:35 michael Exp $";
#endif /* lint */
Elf_Data*
elf_rawdata(Elf_Scn *scn, Elf_Data *data) {
Scn_Data *sd;
Elf *elf;
if (!scn) {
return NULL;
}
elf_assert(scn->s_magic == SCN_MAGIC);
elf = scn->s_elf;
elf_assert(elf);
elf_assert(elf->e_magic == ELF_MAGIC);
if (!elf->e_readable) {
return NULL;
}
else if (scn->s_index == SHN_UNDEF || scn->s_type == SHT_NULL) {
seterr(ERROR_NULLSCN);
}
else if (data) {
return NULL;
}
else if ((sd = scn->s_rawdata)) {
elf_assert(sd->sd_magic == DATA_MAGIC);
elf_assert(sd->sd_scn == scn);
return &sd->sd_data;
}
else if (scn->s_offset < 0 || scn->s_offset > elf->e_size) {
seterr(ERROR_OUTSIDE);
}
else if (scn->s_type != SHT_NOBITS
&& scn->s_offset + scn->s_size > elf->e_size) {
seterr(ERROR_TRUNC_SCN);
}
else if (!(sd = (Scn_Data*)malloc(sizeof(*sd)))) {
seterr(ERROR_MEM_SCNDATA);
}
else {
*sd = _elf_data_init;
sd->sd_scn = scn;
sd->sd_freeme = 1;
sd->sd_data.d_size = scn->s_size;
sd->sd_data.d_version = _elf_version;
if (scn->s_type != SHT_NOBITS && scn->s_size) {
if (!(sd->sd_memdata = (char*)malloc(scn->s_size))) {
seterr(ERROR_IO_2BIG);
free(sd);
return NULL;
}
else if (elf->e_rawdata) {
memcpy(sd->sd_memdata, elf->e_rawdata + scn->s_offset, scn->s_size);
}
else if (!_elf_read(elf, sd->sd_memdata, scn->s_offset, scn->s_size)) {
free(sd->sd_memdata);
free(sd);
return NULL;
}
sd->sd_data.d_buf = sd->sd_memdata;
sd->sd_free_data = 1;
}
scn->s_rawdata = sd;
return &sd->sd_data;
}
return NULL;
}
|
fecd799b36237fbf2ef2ebb9ab29491f80038d39
|
e1cddfd754d952134e72dfd03522c5ea4fb6008e
|
/src/svm/fifo_segment.h
|
ec184207269569d1ed825916f91616a0e88debd4
|
[
"Apache-2.0"
] |
permissive
|
FDio/vpp
|
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
|
f234b0d4626d7e686422cc9dfd25958584f4931e
|
refs/heads/master
| 2023-08-31T16:09:04.068646
| 2022-03-14T09:49:15
| 2023-08-31T09:50:00
| 96,556,718
| 1,048
| 630
|
Apache-2.0
| 2023-06-21T05:39:17
| 2017-07-07T16:29:40
|
C
|
UTF-8
|
C
| false
| false
| 11,355
|
h
|
fifo_segment.h
|
/*
* Copyright (c) 2016-2019 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __included_fifo_segment_h__
#define __included_fifo_segment_h__
#include <svm/ssvm.h>
#include <svm/fifo_types.h>
#include <svm/message_queue.h>
#include <svm/svm_fifo.h>
#define FIFO_SEGMENT_ALLOC_OVERHEAD (2 * clib_mem_get_page_size ())
typedef enum
{
FIFO_SEGMENT_FTYPE_NONE = -1,
FIFO_SEGMENT_RX_FIFO = 0,
FIFO_SEGMENT_TX_FIFO,
FIFO_SEGMENT_N_FTYPES
} fifo_segment_ftype_t;
#define FIFO_SEGMENT_MIN_LOG2_FIFO_SIZE 12 /**< 4kB min fifo size */
#define FIFO_SEGMENT_MIN_FIFO_SIZE 4096 /**< 4kB min fifo size */
#define FIFO_SEGMENT_MAX_FIFO_SIZE (2ULL << 30) /**< 2GB max fifo size */
#define FIFO_SEGMENT_ALLOC_BATCH_SIZE 32 /* Allocation quantum */
typedef enum fifo_segment_flags_
{
FIFO_SEGMENT_F_IS_PREALLOCATED = 1 << 0,
FIFO_SEGMENT_F_WILL_DELETE = 1 << 1,
FIFO_SEGMENT_F_MEM_LIMIT = 1 << 2,
FIFO_SEGMENT_F_CUSTOM_USE = 1 << 3,
} fifo_segment_flags_t;
#define foreach_segment_mem_status \
_(NO_PRESSURE, "No pressure") \
_(LOW_PRESSURE, "Low pressure") \
_(HIGH_PRESSURE, "High pressure") \
_(NO_MEMORY, "No memory")
typedef enum
{
#define _(sym,str) MEMORY_PRESSURE_##sym,
foreach_segment_mem_status
#undef _
MEMORY_N_PRESSURE,
} fifo_segment_mem_status_t;
#if 0
typedef enum fifo_segment_mem_status_
{
MEMORY_PRESSURE_NO_PRESSURE,
MEMORY_PRESSURE_LOW_PRESSURE,
MEMORY_PRESSURE_HIGH_PRESSURE,
MEMORY_PRESSURE_NO_MEMORY,
} fifo_segment_mem_status_t;
#endif
typedef struct
{
ssvm_private_t ssvm; /**< ssvm segment data */
fifo_segment_header_t *h; /**< fifo segment data */
fifo_slice_private_t *slices; /**< private slice information */
svm_msg_q_t *mqs; /**< private vec of attached mqs */
uword max_byte_index; /**< max byte index for segment */
u32 sm_index; /**< owner segment manager index */
u32 fs_index; /**< fs index in sm pool */
u8 n_slices; /**< number of fifo segment slices */
u8 flags; /**< private fifo segment flags */
u8 high_watermark; /**< memory pressure watermark high */
u8 low_watermark; /**< memory pressure watermark low */
} fifo_segment_t;
typedef struct
{
fifo_segment_t *segments; /**< pool of fifo segments */
uword next_baseva; /**< Where to put the next one */
u32 timeout_in_seconds; /**< Time to wait during attach */
} fifo_segment_main_t;
typedef struct
{
ssvm_segment_type_t segment_type; /**< type of segment requested */
u32 segment_size; /**< size of the segment */
int memfd_fd; /**< fd for memfd segments */
char *segment_name; /**< segment name */
u32 *new_segment_indices; /**< return vec of new seg indices */
} fifo_segment_create_args_t;
#define fifo_segment_flags(_fs) _fs->flags
int fifo_segment_init (fifo_segment_t * fs);
int fifo_segment_create (fifo_segment_main_t * sm,
fifo_segment_create_args_t * a);
int fifo_segment_attach (fifo_segment_main_t * sm,
fifo_segment_create_args_t * a);
void fifo_segment_delete (fifo_segment_main_t * sm, fifo_segment_t * fs);
void fifo_segment_cleanup (fifo_segment_t *fs);
fifo_segment_t *fifo_segment_get_segment (fifo_segment_main_t * sm,
u32 fs_index);
fifo_segment_t *fifo_segment_get_segment_if_valid (fifo_segment_main_t *sm,
u32 segment_index);
u32 fifo_segment_index (fifo_segment_main_t * sm, fifo_segment_t * fs);
void fifo_segment_info (fifo_segment_t * seg, char **address, size_t * size);
always_inline void *
fifo_segment_ptr (fifo_segment_t *fs, uword offset)
{
return (void *) ((u8 *) fs->h + offset);
}
always_inline uword
fifo_segment_offset (fifo_segment_t *fs, void *p)
{
return (uword) ((u8 *) p - (u8 *) fs->h);
}
/**
* Allocate fifo in fifo segment
*
* @param fs fifo segment for fifo
* @param data_bytes size of default fifo chunk in bytes
* @param ftype fifo type @ref fifo_segment_ftype_t
* @return new fifo or 0 if alloc failed
*/
svm_fifo_t *fifo_segment_alloc_fifo_w_slice (fifo_segment_t * fs,
u32 slice_index,
u32 data_bytes,
fifo_segment_ftype_t ftype);
svm_fifo_t *fifo_segment_alloc_fifo_w_offset (fifo_segment_t *fs,
uword offset);
svm_fifo_t *fifo_segment_duplicate_fifo (fifo_segment_t *fs, svm_fifo_t *f);
/**
* Free fifo allocated in fifo segment
*
* @param fs fifo segment for fifo
* @param f fifo to be freed
*/
void fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f);
/**
* Free fifo allocated by external applications
*
* @params fs fifo segment for fifo
* @param f fifo to be freed
*/
void fifo_segment_free_client_fifo (fifo_segment_t *fs, svm_fifo_t *f);
void fifo_segment_detach_fifo (fifo_segment_t *fs, svm_fifo_t **f);
void fifo_segment_attach_fifo (fifo_segment_t *fs, svm_fifo_t **f,
u32 slice_index);
uword fifo_segment_fifo_offset (svm_fifo_t *f);
/**
* Allocate message queue on segment
*
* @param fs fifo segment for mq
* @param mq_index index in private mqs vector to use to attach
* @param cfg configuration for mq
* @return attached message queue
*/
svm_msg_q_t *fifo_segment_msg_q_alloc (fifo_segment_t *fs, u32 mq_index,
svm_msg_q_cfg_t *cfg);
/**
* Attach message queue at fifo segment offset
*
* @param fs fifo segment for mq
* @param offset offset for shared mq on the segment
* @param mq_index index in private mqs vector to use to attach
* @return attached message queue
*/
svm_msg_q_t *fifo_segment_msg_q_attach (fifo_segment_t *fs, uword offset,
u32 mq_index);
/**
* Discover mqs on mq only segment
*
* @param fs fifo segment for mq
* @param fds array of fds is mqs use eventfds
* @param n_fds number of fds
*/
void fifo_segment_msg_qs_discover (fifo_segment_t *fs, int *fds, u32 n_fds);
/**
* Message queue offset on segment
*
* @param fs fifo segment for mq
* @param mq_index index of mq in private mqs vector
* @return offset of the shared mq the private mq is attached to
*/
uword fifo_segment_msg_q_offset (fifo_segment_t *fs, u32 mq_index);
/**
* Try to preallocate fifo headers
*
* Tries to preallocate fifo headers and adds them to freelist.
*
* @param fs fifo segment
* @param batch_size number of chunks to be allocated
* @return 0 on success, negative number otherwise
*/
int fifo_segment_prealloc_fifo_hdrs (fifo_segment_t * fs, u32 slice_index,
u32 batch_size);
/**
* Try to preallocate fifo chunks on segment
*
* Tries to preallocate chunks of requested size on segment and adds them
* to chunk freelist.
*
* @param fs fifo segment
* @param chunk_size size of chunks to be allocated in bytes
* @param batch_size number of chunks to be allocated
* @return 0 on success, negative number otherwise
*/
int fifo_segment_prealloc_fifo_chunks (fifo_segment_t * fs, u32 slice_index,
u32 chunk_size, u32 batch_size);
/**
* Pre-allocates fifo pairs in fifo segment
*
* The number of fifos pre-allocated is the minimum of the requested number
* of pairs and the maximum number that fit within the segment. If the maximum
* is hit, the number of fifo pairs requested is updated by subtracting the
* number of fifos that have been successfully allocated.
*
* @param fs fifo segment for fifo
* @param rx_fifo_size data size of rx fifos
* @param tx_fifo_size data size of tx fifos
* @param n_fifo_pairs number of pairs requested. Prior to returning, this
* is decremented by the the number of pairs allocated.
*/
void fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs,
u32 rx_fifo_size,
u32 tx_fifo_size,
u32 * n_fifo_pairs);
/**
* Allocate chunks in fifo segment
*
* @param fsh fifo segment header
* @param slice_index slice where chunks should be alocated
* @param chunk_size chunk size needed
* @return chunk (or chunks) that cover at least chunk_size bytes
* on success, 0 on failure.
*/
svm_fifo_chunk_t *fsh_alloc_chunk (fifo_segment_header_t * fsh,
u32 slice_index, u32 chunk_size);
/**
* Return chunks to fifo segment
*
* @param fsh fifo segment header
* @param slice_index slice where chunks should be returned
* @param c pointer to first chunk in 0 terminated linked list
*/
void fsh_collect_chunks (fifo_segment_header_t * fsh, u32 slice_index,
svm_fifo_chunk_t * c);
/**
* Fifo segment reset mem limit flag
*
* @param fs fifo segment
* @param size size requested
* @return pointer to memory allocated or 0
*/
void *fifo_segment_alloc (fifo_segment_t *fs, uword size);
/**
* Fifo segment allocated size
*
* Returns fifo segment's allocated size
*
* @param fs fifo segment
* @return allocated size in bytes
*/
uword fifo_segment_size (fifo_segment_t * fs);
/**
* Fifo segment estimate of number of free bytes
*
* Returns fifo segment's internal estimate of the number of free bytes.
* To force a synchronization between the segment and the underlying
* memory allocator, call @ref fifo_segment_update_free_bytes
*
* @param fs fifo segment
* @return free bytes estimate
*/
uword fifo_segment_free_bytes (fifo_segment_t * fs);
/**
* Fifo segment number of cached bytes
*
* Returns fifo segment's number of cached bytes.
*
* @param fs fifo segment
* @return cached bytes
*/
uword fifo_segment_cached_bytes (fifo_segment_t * fs);
uword fifo_segment_available_bytes (fifo_segment_t * fs);
/**
* Number of bytes on chunk free lists
*
* @param fs fifo segment
* @return free bytes on chunk free lists
*/
uword fifo_segment_fl_chunk_bytes (fifo_segment_t * fs);
u8 fifo_segment_has_fifos (fifo_segment_t * fs);
svm_fifo_t *fifo_segment_get_slice_fifo_list (fifo_segment_t * fs,
u32 slice_index);
u32 fifo_segment_num_fifos (fifo_segment_t * fs);
u32 fifo_segment_num_free_fifos (fifo_segment_t * fs);
svm_fifo_chunk_t *fifo_segment_alloc_chunk_w_slice (fifo_segment_t *fs,
u32 slice_index,
u32 chunk_size);
void fifo_segment_collect_chunk (fifo_segment_t *fs, u32 slice_index,
svm_fifo_chunk_t *c);
uword fifo_segment_chunk_offset (fifo_segment_t *fs, svm_fifo_chunk_t *c);
/**
* Find number of free chunks of given size
*
* @param fs fifo segment
* @param size chunk size of interest or ~0 if all should be counted
* @return number of chunks of given size
*/
u32 fifo_segment_num_free_chunks (fifo_segment_t * fs, u32 size);
u8 fifo_segment_get_mem_usage (fifo_segment_t * fs);
fifo_segment_mem_status_t fifo_segment_get_mem_status (fifo_segment_t * fs);
void fifo_segment_main_init (fifo_segment_main_t * sm, u64 baseva,
u32 timeout_in_seconds);
format_function_t format_fifo_segment;
format_function_t format_fifo_segment_type;
#endif /* __included_fifo_segment_h__ */
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|
debfa438ff2b4b9aa33d58e1177bfe3d2c5af159
|
3bd385b466cb035fecd2b0c11ae054d42bf44fc2
|
/src/match/marksubstring.c
|
bc42e41fe8946f3f13407265fcac171b76bdcf0f
|
[
"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
| 2,992
|
c
|
marksubstring.c
|
/*
Copyright (c) 2011 Stefan Kurtz <[email protected]>
Copyright (c) 2011 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 "core/mathsupport_api.h"
#include "core/unused_api.h"
#include "marksubstring.h"
Gtmarksubstring *gt_marksubstring_new(unsigned int numofchars,
unsigned int kmersize,
bool usesuffix,
unsigned int units)
{
Gtmarksubstring *mark;
mark = gt_malloc(sizeof (*mark));
gt_assert(kmersize >= units);
mark->units = units;
mark->entries = gt_power_for_small_exponents(numofchars,units);
if (usesuffix)
{
mark->shiftright = 0;
mark->mask = (GtCodetype) (mark->entries-1);
} else
{
mark->shiftright = GT_MULT2(kmersize - units);
mark->mask = ~(GtCodetype) 0;
}
GT_INITBITTAB(mark->bits,mark->entries);
mark->size = sizeof (GtBitsequence) * GT_NUMOFINTSFORBITS(mark->entries);
return mark;
}
void gt_marksubstring_delete(Gtmarksubstring *mark,bool withbits)
{
if (mark != NULL)
{
if (withbits)
{
gt_free(mark->bits);
}
gt_free(mark);
}
}
void gt_marksubstring_mark(Gtmarksubstring *mark,GtCodetype code)
{
code = (code >> (GtCodetype) mark->shiftright) & mark->mask;
gt_assert(code < mark->entries);
if (!GT_ISIBITSET(mark->bits,code))
{
GT_SETIBIT(mark->bits,code);
}
}
bool gt_marksubstring_checkmark(const Gtmarksubstring *mark,GtCodetype code)
{
code = (code >> (GtCodetype) mark->shiftright) & mark->mask;
return GT_ISIBITSET(mark->bits,code) ? true : false;
}
unsigned int gt_marksubstring_shiftright(const Gtmarksubstring *mark)
{
return mark->shiftright;
}
GtUword gt_marksubstring_entries(const Gtmarksubstring *mark)
{
return mark->entries;
}
size_t gt_marksubstring_size(const Gtmarksubstring *mark)
{
return mark->size;
}
void gt_marksubstring_bits_null(GT_UNUSED const Gtmarksubstring *mark,bool null)
{
if (null)
{
gt_assert(mark->bits == NULL);
} else
{
gt_assert(mark->bits != NULL);
}
}
GtBitsequence** gt_marksubstring_bits_address(Gtmarksubstring *mark)
{
return &mark->bits;
}
void gt_marksubstring_bits_map(Gtmarksubstring *mark,GtBitsequence *bitsmap)
{
mark->bits = bitsmap;
}
|
f8c9ffef24a827f0e46fdc261460032357185bc5
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/usr.bin/top/screen.c
|
8d0a8ffcd02016bced93b68866f21e1e7b00f44d
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 5,608
|
c
|
screen.c
|
/* $OpenBSD: screen.c,v 1.22 2019/10/08 07:26:59 kn Exp $ */
/*
* Top users/processes display for Unix
* Version 3
*
* Copyright (c) 1984, 1989, William LeFebvre, Rice University
* Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR HIS EMPLOYER 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.
*/
/*
* This file contains the routines that interface to termcap and stty/gtty.
*
* Paul Vixie, February 1987: converted to use ioctl() instead of stty/gtty.
*
* I put in code to turn on the TOSTOP bit while top was running, but I didn't
* really like the results. If you desire it, turn on the preprocessor
* variable "TOStop". --wnl
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <curses.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <term.h>
#include <unistd.h>
#include <stdbool.h>
#include "top.h"
#include "screen.h"
#include "layout.h"
int screen_length, screen_width;
char ch_erase, ch_kill, smart_terminal;
static struct termios old_settings, new_settings;
static char is_a_terminal = false;
void
init_termcap(int interactive)
{
char *term_name;
int status;
/* set defaults in case we aren't smart */
screen_width = MAX_COLS;
screen_length = 0;
if (!interactive) {
/* pretend we have a dumb terminal */
smart_terminal = false;
return;
}
/* assume we have a smart terminal until proven otherwise */
smart_terminal = true;
/* get the terminal name */
term_name = getenv("TERM");
/* if there is no TERM, assume it's a dumb terminal */
/* patch courtesy of Sam Horrocks at telegraph.ics.uci.edu */
if (term_name == NULL) {
smart_terminal = false;
return;
}
/* now get the termcap entry */
if ((status = tgetent(NULL, term_name)) != 1) {
if (status == -1)
warnx("can't open termcap file");
else
warnx("no termcap entry for a `%s' terminal", term_name);
/* pretend it's dumb and proceed */
smart_terminal = false;
return;
}
/* "hardcopy" immediately indicates a very stupid terminal */
if (tgetflag("hc")) {
smart_terminal = false;
return;
}
/* set up common terminal capabilities */
if ((screen_length = tgetnum("li")) <= y_procs) {
screen_length = smart_terminal = 0;
return;
}
/* screen_width is a little different */
if ((screen_width = tgetnum("co")) == -1)
screen_width = 79;
else
screen_width -= 1;
/* get necessary capabilities */
if (tgetstr("cl", NULL) == NULL || tgetstr("cm", NULL) == NULL) {
smart_terminal = false;
return;
}
/* get the actual screen size with an ioctl, if needed */
/*
* This may change screen_width and screen_length, and it always sets
* lower_left.
*/
get_screensize();
/* if stdout is not a terminal, pretend we are a dumb terminal */
if (tcgetattr(STDOUT_FILENO, &old_settings) == -1)
smart_terminal = false;
}
void
init_screen(void)
{
/* get the old settings for safe keeping */
if (tcgetattr(STDOUT_FILENO, &old_settings) != -1) {
/* copy the settings so we can modify them */
new_settings = old_settings;
/* turn off ICANON, character echo and tab expansion */
new_settings.c_lflag &= ~(ICANON | ECHO);
new_settings.c_oflag &= ~(OXTABS);
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
(void) tcsetattr(STDOUT_FILENO, TCSADRAIN, &new_settings);
/* remember the erase and kill characters */
ch_erase = old_settings.c_cc[VERASE];
ch_kill = old_settings.c_cc[VKILL];
is_a_terminal = true;
#if 0
/* send the termcap initialization string */
putcap(terminal_init);
#endif
}
if (!is_a_terminal) {
/* not a terminal at all---consider it dumb */
smart_terminal = false;
}
if (smart_terminal)
initscr();
}
void
end_screen(void)
{
if (smart_terminal) {
move(screen_length-1, 0);
clrtoeol();
refresh();
endwin();
}
if (is_a_terminal)
(void) tcsetattr(STDOUT_FILENO, TCSADRAIN, &old_settings);
}
void
reinit_screen(void)
{
#if 0
/* install our settings if it is a terminal */
if (is_a_terminal)
(void) tcsetattr(STDOUT_FILENO, TCSADRAIN, &new_settings);
/* send init string */
if (smart_terminal)
putcap(terminal_init);
#endif
}
void
get_screensize(void)
{
struct winsize ws;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1) {
if (ws.ws_row != 0)
screen_length = ws.ws_row;
if (ws.ws_col != 0)
screen_width = ws.ws_col - 1;
}
}
void
go_home(void)
{
if (smart_terminal) {
move(0, 0);
refresh();
}
}
|
5f966ff6284e20de8cbf32ac36ea79b9a2173fd3
|
eecd5e4c50d8b78a769bcc2675250576bed34066
|
/src/sys/utils/matheq.c
|
efde66b0c5be67ade0ef1bc26a45190b74bb0c13
|
[
"BSD-2-Clause"
] |
permissive
|
petsc/petsc
|
3b1a04fea71858e0292f9fd4d04ea11618c50969
|
9c5460f9064ca60dd71a234a1f6faf93e7a6b0c9
|
refs/heads/main
| 2023-08-17T20:51:16.507070
| 2023-08-17T16:08:06
| 2023-08-17T16:08:06
| 8,691,401
| 341
| 169
|
NOASSERTION
| 2023-03-29T11:02:58
| 2013-03-10T20:55:21
|
C
|
UTF-8
|
C
| false
| false
| 1,076
|
c
|
matheq.c
|
#include <petscsys.h>
/*@C
PetscEqualReal - Returns whether the two `PetscReal` variables are equal
Input Parameters:
+ a - first real number
- b - second real number
Level: developer
Note:
Equivalent to "a == b". Should be used to prevent compilers from
emitting floating point comparison warnings (e.g. GCC's -Wfloat-equal flag)
in PETSc header files or user code.
.seealso: `PetscIsCloseAtTol()`, `PetscEqualScalar()`
@*/
PetscBool PetscEqualReal(PetscReal a, PetscReal b)
{
return (a == b) ? PETSC_TRUE : PETSC_FALSE;
}
/*@C
PetscEqualScalar - Returns whether the two `PetscScalar` values are equal.
Input Parameters:
+ a - first scalar value
- b - second scalar value
Level: developer
Note:
Equivalent to "a == b". Should be used to prevent compilers from
emitting floating point comparison warnings (e.g. GCC's -Wfloat-equal flag)
in PETSc header files or user code.
.seealso: `PetscIsCloseAtTol()`, `PetscEqualReal()`
@*/
PetscBool PetscEqualScalar(PetscScalar a, PetscScalar b)
{
return (a == b) ? PETSC_TRUE : PETSC_FALSE;
}
|
eb1dfe0c433e443bbec32d399227db42f9a7a0a1
|
aa3befea459382dc5c01c925653d54f435b3fb0f
|
/graphics/nxterm/nxterm_driver.c
|
4367c6d61c354cdbc1f8017cef37fe23c46836bb
|
[
"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
| 12,756
|
c
|
nxterm_driver.c
|
/****************************************************************************
* graphics/nxterm/nxterm_driver.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdbool.h>
#include <string.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/fs/fs.h>
#include "nxterm.h"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int nxterm_open(FAR struct file *filep);
static int nxterm_close(FAR struct file *filep);
static ssize_t nxterm_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
static int nxterm_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int nxterm_unlink(FAR struct inode *inode);
#endif
/****************************************************************************
* Public Data
****************************************************************************/
/* This is the common NX driver file operations */
#ifdef CONFIG_NXTERM_NXKBDIN
const struct file_operations g_nxterm_drvrops =
{
nxterm_open, /* open */
nxterm_close, /* close */
nxterm_read, /* read */
nxterm_write, /* write */
NULL, /* seek */
nxterm_ioctl, /* ioctl */
NULL, /* mmap */
NULL, /* truncate */
nxterm_poll /* poll */
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
, nxterm_unlink /* unlink */
#endif
};
#else /* CONFIG_NXTERM_NXKBDIN */
const struct file_operations g_nxterm_drvrops =
{
nxterm_open, /* open */
nxterm_close, /* close */
NULL, /* read */
nxterm_write, /* write */
NULL, /* seek */
nxterm_ioctl, /* ioctl */
NULL, /* mmap */
NULL, /* truncate */
NULL /* poll */
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
, nxterm_unlink /* unlink */
#endif
};
#endif /* CONFIG_NXTERM_NXKBDIN */
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nxterm_open
****************************************************************************/
static int nxterm_open(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
FAR struct nxterm_state_s *priv = inode->i_private;
DEBUGASSERT(filep && filep->f_inode);
/* Get the driver structure from the inode */
inode = filep->f_inode;
priv = (FAR struct nxterm_state_s *)inode->i_private;
DEBUGASSERT(priv);
/* Verify that the driver is opened for write-only access */
#ifndef CONFIG_NXTERM_NXKBDIN
if ((filep->f_oflags & O_RDOK) != 0)
{
gerr("ERROR: Attempted open with read access\n");
return -EACCES;
}
#endif
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
/* Increment the count of open file reference */
DEBUGASSERT(priv->orefs != UINT8_MAX);
priv->orefs++;
#endif
/* Assign the driver structure to the file */
filep->f_priv = priv;
return OK;
}
/****************************************************************************
* Name: nxterm_close
****************************************************************************/
static int nxterm_close(FAR struct file *filep)
{
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
FAR struct nxterm_state_s *priv;
int ret;
/* Recover our private state structure */
DEBUGASSERT(filep != NULL && filep->f_priv != NULL);
priv = (FAR struct nxterm_state_s *)filep->f_priv;
/* Get exclusive access */
ret = nxmutex_lock(&priv->lock);
if (ret < 0)
{
return ret;
}
/* Has the driver been unlinked? Was this the last open references to the
* terminal driver?
*/
DEBUGASSERT(priv->orefs > 0);
if (priv->unlinked && priv->orefs <= 1)
{
/* Yes.. Unregister the terminal device */
nxmutex_unlock(&priv->lock);
nxterm_unregister(priv);
return OK;
}
else
{
/* No.. Just decrement the count of open file references */
priv->orefs--;
}
nxmutex_unlock(&priv->lock);
#endif
return OK;
}
/****************************************************************************
* Name: nxterm_write
****************************************************************************/
static ssize_t nxterm_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen)
{
FAR struct nxterm_state_s *priv;
enum nxterm_vt100state_e state;
ssize_t remaining;
char ch;
int ret;
/* Recover our private state structure */
DEBUGASSERT(filep != NULL && filep->f_priv != NULL);
priv = (FAR struct nxterm_state_s *)filep->f_priv;
/* Get exclusive access */
ret = nxmutex_lock(&priv->lock);
if (ret < 0)
{
return ret;
}
/* Hide the cursor while we update the display */
nxterm_hidecursor(priv);
/* Loop writing each character to the display */
for (remaining = (ssize_t)buflen; remaining > 0; remaining--)
{
/* Get the next character from the user buffer */
ch = *buffer++;
/* Check if this character is part of a VT100 escape sequence */
do
{
/* Is the character part of a VT100 escape sequnce? */
state = nxterm_vt100(priv, ch);
switch (state)
{
/* Character is not part of a VT100 escape sequence (and no
* characters are buffer.
*/
default:
case VT100_NOT_CONSUMED:
{
/* We can output the character to the window */
nxterm_putc(priv, (uint8_t)ch);
}
break;
/* The full VT100 escape sequence was processed (and the new
* character was consumed)
*/
case VT100_PROCESSED:
/* Character was consumed as part of the VT100 escape processing
* (but the escape sequence is still incomplete.
*/
case VT100_CONSUMED:
{
/* Do nothing... the VT100 logic owns the character */
}
break;
/* Invalid/unsupported character in escape sequence */
case VT100_ABORT:
{
int i;
/* Add the first unhandled character to the window */
nxterm_putc(priv, (uint8_t)priv->seq[0]);
/* Move all buffer characters down one */
for (i = 1; i < priv->nseq; i++)
{
priv->seq[i - 1] = priv->seq[i];
}
priv->nseq--;
/* Then loop again and check if what remains is part of a
* VT100 escape sequence. We could speed this up by
* checking if priv->seq[0] == ASCII_ESC.
*/
}
break;
}
}
while (state == VT100_ABORT);
}
/* Show the cursor at its new position */
nxterm_showcursor(priv);
nxmutex_unlock(&priv->lock);
return (ssize_t)buflen;
}
/****************************************************************************
* Name: nxterm_ioctl
****************************************************************************/
static int nxterm_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
/* NOTE: We don't need driver context here because the NXTERM handle
* provided within each of the NXTERM IOCTL command data. Mutual
* exclusion is similar managed by the IOCTL cmmand handler.
*
* This permits the IOCTL to be called in abnormal context (such as
* from boardctl())
*/
return nxterm_ioctl_tap(cmd, arg);
}
/****************************************************************************
* Name: nxterm_unlink
****************************************************************************/
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int nxterm_unlink(FAR struct inode *inode)
{
FAR struct nxterm_state_s *priv;
int ret;
DEBUGASSERT(inode != NULL && inode->i_private != NULL);
priv = inode->i_private;
/* Get exclusive access */
ret = nxmutex_lock(&priv->lock);
if (ret < 0)
{
return ret;
}
/* Are there open references to the terminal driver? */
if (priv->orefs > 0)
{
/* Yes.. Just mark the driver unlinked. Resources will be cleaned up
* when the final reference is close.
*/
priv->unlinked = true;
}
else
{
/* No.. Unregister the terminal device now */
nxmutex_unlock(&priv->lock);
nxterm_unregister(priv);
return OK;
}
nxmutex_unlock(&priv->lock);
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxterm_ioctl_tap
*
* Description:
* Execute an NXTERM IOCTL command from an external caller.
*
* NOTE: We don't need driver context here because the NXTERM handle
* provided within each of the NXTERM IOCTL command data. Mutual
* exclusion is similar managed by the IOCTL cmmand handler.
*
* This permits the IOCTL to be called in abnormal context (such as
* from boardctl())
*
****************************************************************************/
int nxterm_ioctl_tap(int cmd, uintptr_t arg)
{
int ret;
switch (cmd)
{
/* CMD: NXTERMIOC_NXTERM_REDRAW
* DESCRIPTION: Re-draw a portion of the NX console. This function
* should be called from the appropriate window callback
* logic.
* ARG: A reference readable instance of struct
* nxtermioc_redraw_s
* CONFIGURATION: CONFIG_NXTERM
*/
case NXTERMIOC_NXTERM_REDRAW:
{
FAR struct nxtermioc_redraw_s *redraw =
(FAR struct nxtermioc_redraw_s *)((uintptr_t)arg);
nxterm_redraw(redraw->handle, &redraw->rect, redraw->more);
ret = OK;
}
break;
/* CMD: NXTERMIOC_NXTERM_KBDIN
* DESCRIPTION: Provide NxTerm keyboard input to NX.
* ARG: A reference readable instance of struct
* nxtermioc_kbdin_s
* CONFIGURATION: CONFIG_NXTERM_NXKBDIN
*/
case NXTERMIOC_NXTERM_KBDIN:
{
#ifdef CONFIG_NXTERM_NXKBDIN
FAR struct nxtermioc_kbdin_s *kbdin =
(FAR struct nxtermioc_kbdin_s *)((uintptr_t)arg);
nxterm_kbdin(kbdin->handle, kbdin->buffer, kbdin->buflen);
ret = OK;
#else
ret = -ENOSYS;
#endif
}
break;
/* CMD: NXTERMIOC_NXTERM_RESIZE
* DESCRIPTION: Inform NxTerm keyboard the the size of the window has
* changed
* ARG: A reference readable instance of struct
* nxtermioc_resize_s
* CONFIGURATION: CONFIG_NXTERM
*/
case NXTERMIOC_NXTERM_RESIZE:
{
FAR struct nxtermioc_resize_s *resize =
(FAR struct nxtermioc_resize_s *)((uintptr_t)arg);
ret = nxterm_resize(resize->handle, &resize->size);
}
break;
default:
ret = -ENOTTY;
break;
}
return ret;
}
|
c7d5db6606209c92bbb8b4de7293f5dd46c079fb
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/mail/exim/files/patch-exim_monitor-em_hdr.h
|
a7a496684e17159f468c185ea2c3315fbe8a5edb
|
[
"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
| 284
|
h
|
patch-exim_monitor-em_hdr.h
|
--- exim_monitor/em_hdr.h.orig 2019-12-08 12:53:48 UTC
+++ exim_monitor/em_hdr.h
@@ -95,6 +95,8 @@ this interface so that this kind of kludge isn't neede
#endif
typedef void hctx;
+typedef unsigned long ulong;
+
#include "local_scan.h"
#include "macros.h"
#include "structs.h"
|
840eb9a57432fa67ecf2bf4846f2dbe1de8a54fc
|
2c73a693c2b3c162eae2ab94f649d8c4494878ba
|
/components/multimedia/amr_decode/amr_wb/dec/include/mime_io.h
|
9c040bc8b8db3fb629391eaceaf1e0ba42b379d4
|
[
"MIT"
] |
permissive
|
openLuat/LuatOS
|
185e1e140aed908434168133571ddcafe98f4e12
|
4b29d5121ab4f7133630331e8502c526c7856897
|
refs/heads/master
| 2023-08-23T04:57:23.263539
| 2023-08-23T04:46:46
| 2023-08-23T04:46:46
| 230,403,844
| 378
| 93
|
MIT
| 2021-12-17T02:19:30
| 2019-12-27T08:29:19
|
C
|
UTF-8
|
C
| false
| false
| 3,413
|
h
|
mime_io.h
|
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/****************************************************************************************
Portions of this file are derived from the following 3GPP standard:
3GPP TS 26.173
ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec
Available from http://www.3gpp.org
(C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
Permission to distribute, modify and use this file under the standard license
terms listed above has been obtained from the copyright holder.
****************************************************************************************/
/*
------------------------------------------------------------------------------
Pathname: ./cpp/include/mime_io.h
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef MIME_IO_H
#define MIME_IO_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
----------------------------------------------------------------------------*/
extern const uint8 toc_byte[16];
/* number of speech bits for all modes */
extern const int16 unpacked_size[16];
/* size of packed frame for each mode, excluding TOC byte */
extern const int16 packed_size[16];
/* number of unused speech bits in packed format for each mode */
extern const int16 unused_size[16];
/* sorting tables for all modes */
extern const int16 sort_660[132];
extern const int16 sort_885[177];
extern const int16 sort_1265[253];
extern const int16 sort_1425[285];
extern const int16 sort_1585[317];
extern const int16 sort_1825[365];
extern const int16 sort_1985[397];
extern const int16 sort_2305[461];
extern const int16 sort_2385[477];
extern const int16 sort_SID[35];
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif /* MIME_IO_H */
|
0a9a8305ef13067a7f86d19b838fb3d5a4be41bc
|
62c8d47803da82bc6b7a276e0c54796601c66276
|
/packages/go/HFS_XFer_DA/mytype.h
|
c30e71cbde875d035c18edd8be3e2213c357affa
|
[
"MIT",
"GPL-2.0-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
autc04/executor
|
a01d1c5081251a331067596141422568159a7596
|
ada40683c14d9dfb2a660e52378e9864e0d51357
|
refs/heads/master
| 2023-07-21T14:33:48.612380
| 2023-05-07T21:33:31
| 2023-05-07T21:33:31
| 106,850,181
| 125
| 9
|
MIT
| 2023-07-07T14:12:07
| 2017-10-13T16:48:51
|
C++
|
UTF-8
|
C
| false
| false
| 190
|
h
|
mytype.h
|
typedef char BOOLEAN;
typedef short INTEGER;
typedef long LONGINT;
#define LONGORPTR Ptr
typedef unsigned short ushort;
typedef unsigned long ulong;
#define PRIVATE static
#define PUBLIC
|
5c6813b9e52024ea25a2e0592dff6fb0e7abc670
|
fcc9b5cb92607deaac4b097776ed0490789d8c3e
|
/src/runtime/trace-object.inc
|
cfb36cdb3fb172bcd7962a7b8cb1187ea000e173
|
[
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-public-domain-disclaimer",
"LicenseRef-scancode-public-domain",
"UPL-1.0",
"LicenseRef-scancode-other-permissive",
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-mit-specification-disclaimer",
"MIT"
] |
permissive
|
sbcl/sbcl
|
ef248b5e8614ba7f0a1132c4f2cfcb000a074400
|
85003adf60ef659082c244972e816ea62240b9cb
|
refs/heads/master
| 2023-09-01T05:14:15.225083
| 2023-08-31T20:09:49
| 2023-08-31T20:09:49
| 1,890,957
| 1,737
| 408
|
NOASSERTION
| 2023-08-28T13:05:04
| 2011-06-13T20:33:25
|
Common Lisp
|
UTF-8
|
C
| false
| false
| 6,826
|
inc
|
trace-object.inc
|
// -*- mode: c -*-
#include "weak-hash-pred.inc"
/* TRACE_NAME = Base name for generated tracing functions
* ACTION = Function name to call with every pointer
* STRENGTHEN_WEAK_REFS = Whether to always trace through weak objects as if strong
*/
#if !defined TRACE_NAME || \
!defined ACTION || \
!defined STRENGTHEN_WEAK_REFS || \
!defined HT_ENTRY_LIVENESS_FUN_ARRAY_NAME
#error "Please define all required macros before including trace-object"
#endif
/* Function name to call with weak pointers that have been deferred */
#ifndef WATCH_DEFERRED
#define WATCH_DEFERRED(where, from, to) (void)(0)
#endif
/* Mutex stuff */
#ifndef LOCK
#define LOCK (void)(0)
#define UNLOCK (void)(0)
#endif
/* Generated names */
#define cat2(x, y) x ## y
#define cat(x, y) cat2(x, y)
#define USING_LAYOUT cat(TRACE_NAME, _using_layout)
#define TRACE_PAIR cat(TRACE_NAME, _pair)
#define ORDINARY_SLOT(x) ACTION(x, &x, SOURCE_NORMAL)
static void TRACE_PAIR(lispobj* where)
{
ORDINARY_SLOT(where[0]);
ORDINARY_SLOT(where[1]);
}
static void USING_LAYOUT(lispobj layout, lispobj* where, int nslots)
{
// Apart from the allowance for untagged pointers in lockfree list nodes,
// this contains almost none of the special cases that gencgc does.
if (!layout) return;
ACTION(layout, &layout_of(where), SOURCE_NORMAL);
if (lockfree_list_node_layout_p(LAYOUT(layout))) { // allow untagged 'next'
struct list_node* node = (void*)where;
lispobj next = node->_node_next;
// ignore if 0
if (fixnump(next) && next)
ACTION(next|INSTANCE_POINTER_LOWTAG, &node->_node_next, SOURCE_ZERO_TAG);
}
struct bitmap bitmap = get_layout_bitmap(LAYOUT(layout));
int i;
lispobj* slots = where+1;
for (i=0; i<nslots; ++i)
if (bitmap_logbitp(i, bitmap) && is_lisp_pointer(slots[i]))
ORDINARY_SLOT(slots[i]);
}
static void TRACE_NAME(lispobj* where)
{
lispobj header = *where;
int widetag = header_widetag(header);
if (instanceoid_widetag_p(widetag))
return USING_LAYOUT(layout_of(where), where,
instanceoid_length(header));
sword_t scan_from = 1;
sword_t scan_to = sizetab[widetag](where);
sword_t i;
struct weak_pointer *weakptr;
switch (widetag) {
case SIMPLE_VECTOR_WIDETAG:
#ifdef LISP_FEATURE_UBSAN
if (is_lisp_pointer(where[1])) ORDINARY_SLOT(where[1]);
#endif
/* Would be more precise to only make hash-tables rehash when
* some key actually moves, and we don't really trace large and
* old tables when scavenging properly. So we _don't_ touch
* rehash bits here. */
// non-weak hashtable kv vectors are trivial in fullcgc. Keys don't move
// so the table will not need rehash as a result of gc.
// Ergo, those may be treated just like ordinary simple vectors.
// However, weakness remains as a special case.
if (!STRENGTHEN_WEAK_REFS && vector_flagp(header, VectorWeak)) {
WATCH_DEFERRED(where, 1, scan_to);
if (!vector_flagp(header, VectorHashing)) {
LOCK;
add_to_weak_vector_list(where, header);
UNLOCK;
return;
}
// Ok, we're looking at a weak hash-table.
struct vector* v = (struct vector*)where;
lispobj *plhash_table = &v->data[vector_len(v)-1];
lispobj lhash_table = *plhash_table;
gc_dcheck(instancep(lhash_table));
ACTION(lhash_table, plhash_table, SOURCE_NORMAL);
struct hash_table* hash_table = (void*)native_pointer(lhash_table);
gc_assert(hashtable_weakp(hash_table));
// An object can only be removed from the queue once.
// Therefore the 'next' pointer has got to be nil.
gc_assert((lispobj)hash_table->next_weak_hash_table == NIL);
int weakness = hashtable_weakness(hash_table);
bool defer = 1;
LOCK;
if (weakness != WEAKNESS_KEY_AND_VALUE)
defer = scan_weak_hashtable(hash_table, HT_ENTRY_LIVENESS_FUN_ARRAY_NAME[weakness],
TRACE_PAIR);
if (defer) {
hash_table->next_weak_hash_table = weak_hash_tables;
weak_hash_tables = hash_table;
}
UNLOCK;
return;
}
break;
#if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64) || defined (LISP_FEATURE_ARM64)
/* on x86[-64], closure->fun is a fixnum-qua-pointer. Convert it to a lisp
* pointer to mark it, but not on platforms where it's already a descriptor */
case CLOSURE_WIDETAG: {
lispobj *self = &((struct closure*)where)->fun;
ACTION(fun_taggedptr_from_self(*self), self, SOURCE_CLOSURE);
scan_from = 2;
break; // scan slots normally
}
#endif
case CODE_HEADER_WIDETAG:
scan_to = code_header_words((struct code*)where);
#ifdef LISP_FEATURE_UNTAGGED_FDEFNS
{
struct code* code = (struct code*)where;
lispobj* where = code->constants + code_n_funs(code) * CODE_SLOTS_PER_SIMPLE_FUN;
lispobj* limit = where + code_n_named_calls(code);
for ( ; where < limit ; ++where )
ACTION(*where | OTHER_POINTER_LOWTAG, where, SOURCE_ZERO_TAG);
// Fall into general case. Untagged fdefns will be ignored as fixnums.
}
#endif
break;
case SYMBOL_WIDETAG:
{
struct symbol* s = (void*)where;
ACTION(decode_symbol_name(s->name), &s->name, SOURCE_SYMBOL_NAME);
ORDINARY_SLOT(s->value);
ORDINARY_SLOT(s->info);
ORDINARY_SLOT(s->fdefn);
}
return;
case FDEFN_WIDETAG: {
struct fdefn *fdefn = (struct fdefn*)where;
ACTION(decode_fdefn_rawfun(fdefn), (lispobj*)&fdefn->raw_addr, SOURCE_FDEFN_RAW);
scan_to = 3;
break;
}
case WEAK_POINTER_WIDETAG:
weakptr = (struct weak_pointer*)where;
if (STRENGTHEN_WEAK_REFS) ORDINARY_SLOT(weakptr->value);
else if (weakptr_vectorp(weakptr)) {
WATCH_DEFERRED(where, 1, scan_to);
LOCK;
add_to_weak_vector_list(where, header);
UNLOCK;
} else if (is_lisp_pointer(weakptr->value) && interesting_pointer_p(weakptr->value)) {
/* XXX: This hard-codes the layout of a weak pointer. Make a scalar WATCH_DEFERRED? */
WATCH_DEFERRED(where, 1, 2);
LOCK;
add_to_weak_pointer_chain(weakptr);
UNLOCK;
}
return;
default:
if (leaf_obj_widetag_p(widetag)) return;
}
for(i=scan_from; i<scan_to; ++i)
ORDINARY_SLOT(where[i]);
}
#undef ORDINARY_SLOT
|
91140fde5d3bb40711f99bf72d71d81411318f9b
|
acbd5b5df415c07d0c347a1321580ee8f61f6962
|
/airplay/raop_rtp_mirror.c
|
a2abda42ab630365bfe338f499686555228191cd
|
[
"MIT"
] |
permissive
|
amitv87/PiP
|
6acb1a304a4da36d806062c29e94c73adf175e37
|
544a014eb000bead480d0715f4ded13f539f75cc
|
refs/heads/master
| 2023-07-07T05:27:00.765144
| 2023-07-03T09:12:16
| 2023-07-03T09:12:16
| 113,197,472
| 353
| 23
|
MIT
| 2022-04-27T13:15:59
| 2017-12-05T15:11:52
|
C
|
UTF-8
|
C
| false
| false
| 29,887
|
c
|
raop_rtp_mirror.c
|
/*
* Copyright (c) 2019 dsafa22, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
#include "raop_rtp_mirror.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <netinet/tcp.h>
#include "raop.h"
#include "netutils.h"
#include "compat.h"
#include "logger.h"
#include "byteutils.h"
#include "mirror_buffer.h"
#include "stream.h"
#include "utils.h"
#include "plist/plist.h"
/* for MacOS, where SOL_TCP and TCP_KEEPIDLE are not defined */
#if !defined(SOL_TCP) && defined(IPPROTO_TCP)
#define SOL_TCP IPPROTO_TCP
#endif
#if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE)
#define TCP_KEEPIDLE TCP_KEEPALIVE
#endif
//struct h264codec_s {
// unsigned char compatibility;
// short pps_size;
// short sps_size;
// unsigned char level;
// unsigned char number_of_pps;
// unsigned char* picture_parameter_set;
// unsigned char profile_high;
// unsigned char reserved_3_and_sps;
// unsigned char reserved_6_and_nal;
// unsigned char* sequence_parameter_set;
// unsigned char version;
//};
struct raop_rtp_mirror_s {
logger_t *logger;
raop_callbacks_t callbacks;
raop_ntp_t *ntp;
/* Buffer to handle all resends */
mirror_buffer_t *buffer;
/* Remote address as sockaddr */
struct sockaddr_storage remote_saddr;
socklen_t remote_saddr_len;
/* MUTEX LOCKED VARIABLES START */
/* These variables only edited mutex locked */
int running;
int joined;
int flush;
thread_handle_t thread_mirror;
mutex_handle_t run_mutex;
/* MUTEX LOCKED VARIABLES END */
int mirror_data_sock;
unsigned short mirror_data_lport;
/* switch for displaying client FPS data */
uint8_t show_client_FPS_data;
/* SPS and PPS */
int sps_pps_len;
unsigned char* sps_pps;
bool sps_pps_waiting;
raop_connection_t* conn;
};
static int
raop_rtp_parse_remote(raop_rtp_mirror_t *raop_rtp_mirror, const unsigned char *remote, int remotelen)
{
char current[25];
int family;
int ret;
assert(raop_rtp_mirror);
if (remotelen == 4) {
family = AF_INET;
} else if (remotelen == 16) {
family = AF_INET6;
} else {
return -1;
}
memset(current, 0, sizeof(current));
sprintf(current, "%d.%d.%d.%d", remote[0], remote[1], remote[2], remote[3]);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror parse remote ip = %s", current);
ret = netutils_parse_address(family, current,
&raop_rtp_mirror->remote_saddr,
sizeof(raop_rtp_mirror->remote_saddr));
if (ret < 0) {
return -1;
}
raop_rtp_mirror->remote_saddr_len = ret;
return 0;
}
#define NO_FLUSH (-42)
raop_rtp_mirror_t *raop_rtp_mirror_init(raop_connection_t* conn, logger_t *logger, raop_callbacks_t *callbacks, raop_ntp_t *ntp,
const unsigned char *remote, int remotelen, const unsigned char *aeskey)
{
raop_rtp_mirror_t *raop_rtp_mirror;
assert(logger);
assert(callbacks);
raop_rtp_mirror = calloc(1, sizeof(raop_rtp_mirror_t));
if (!raop_rtp_mirror) {
return NULL;
}
raop_rtp_mirror->conn = conn;
raop_rtp_mirror->logger = logger;
raop_rtp_mirror->ntp = ntp;
raop_rtp_mirror->sps_pps_len = 0;
raop_rtp_mirror->sps_pps = NULL;
raop_rtp_mirror->sps_pps_waiting = false;
memcpy(&raop_rtp_mirror->callbacks, callbacks, sizeof(raop_callbacks_t));
raop_rtp_mirror->buffer = mirror_buffer_init(logger, aeskey);
if (!raop_rtp_mirror->buffer) {
free(raop_rtp_mirror);
return NULL;
}
if (raop_rtp_parse_remote(raop_rtp_mirror, remote, remotelen) < 0) {
free(raop_rtp_mirror);
return NULL;
}
raop_rtp_mirror->running = 0;
raop_rtp_mirror->joined = 1;
raop_rtp_mirror->flush = NO_FLUSH;
MUTEX_CREATE(raop_rtp_mirror->run_mutex);
return raop_rtp_mirror;
}
void
raop_rtp_init_mirror_aes(raop_rtp_mirror_t *raop_rtp_mirror, uint64_t *streamConnectionID)
{
mirror_buffer_init_aes(raop_rtp_mirror->buffer, streamConnectionID);
}
//#define DUMP_H264
#define RAOP_PACKET_LEN 32768
/**
* Mirror
*/
static THREAD_RETVAL
raop_rtp_mirror_thread(void *arg)
{
raop_rtp_mirror_t *raop_rtp_mirror = arg;
assert(raop_rtp_mirror);
int stream_fd = -1;
unsigned char packet[128];
memset(packet, 0 , 128);
unsigned char* payload = NULL;
unsigned int readstart = 0;
bool conn_reset = false;
uint64_t ntp_timestamp_nal = 0;
uint64_t ntp_timestamp_raw = 0;
bool conn_started = false;
unsigned char nal_start_code[4] = { 0x00, 0x00, 0x00, 0x01 };
#ifdef DUMP_H264
// C decrypted
FILE* file = fopen("/home/pi/Airplay.h264", "wb");
// Encrypted source file
FILE* file_source = fopen("/home/pi/Airplay.source", "wb");
FILE* file_len = fopen("/home/pi/Airplay.len", "wb");
#endif
while (1) {
fd_set rfds;
struct timeval tv;
int nfds, ret;
MUTEX_LOCK(raop_rtp_mirror->run_mutex);
if (!raop_rtp_mirror->running) {
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror->running is no longer true");
break;
}
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
/* Set timeout valu to 5ms */
tv.tv_sec = 0;
tv.tv_usec = 5000;
/* Get the correct nfds value and set rfds */
FD_ZERO(&rfds);
if (stream_fd == -1) {
FD_SET(raop_rtp_mirror->mirror_data_sock, &rfds);
nfds = raop_rtp_mirror->mirror_data_sock+1;
} else {
FD_SET(stream_fd, &rfds);
nfds = stream_fd+1;
}
ret = select(nfds, &rfds, NULL, NULL, &tv);
if (ret == 0) {
/* Timeout happened */
continue;
} else if (ret == -1) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror error in select");
break;
}
if (stream_fd == -1 && FD_ISSET(raop_rtp_mirror->mirror_data_sock, &rfds)) {
struct sockaddr_storage saddr;
socklen_t saddrlen;
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror accepting client");
saddrlen = sizeof(saddr);
stream_fd = accept(raop_rtp_mirror->mirror_data_sock, (struct sockaddr *)&saddr, &saddrlen);
if (stream_fd == -1) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror error in accept %d %s", errno, strerror(errno));
break;
}
// We're calling recv for a certain amount of data, so we need a timeout
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 5000;
if (setsockopt(stream_fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror could not set stream socket timeout %d %s", errno, strerror(errno));
break;
}
int option;
option = 1;
if (setsockopt(stream_fd, SOL_SOCKET, SO_KEEPALIVE, &option, sizeof(option)) < 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "raop_rtp_mirror could not set stream socket keepalive %d %s", errno, strerror(errno));
}
option = 60;
if (setsockopt(stream_fd, SOL_TCP, TCP_KEEPIDLE, &option, sizeof(option)) < 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "raop_rtp_mirror could not set stream socket keepalive time %d %s", errno, strerror(errno));
}
option = 10;
if (setsockopt(stream_fd, SOL_TCP, TCP_KEEPINTVL, &option, sizeof(option)) < 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "raop_rtp_mirror could not set stream socket keepalive interval %d %s", errno, strerror(errno));
}
option = 6;
if (setsockopt(stream_fd, SOL_TCP, TCP_KEEPCNT, &option, sizeof(option)) < 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "raop_rtp_mirror could not set stream socket keepalive probes %d %s", errno, strerror(errno));
}
readstart = 0;
}
if (stream_fd != -1 && FD_ISSET(stream_fd, &rfds)) {
// The first 128 bytes are some kind of header for the payload that follows
while (payload == NULL && readstart < 128) {
ret = recv(stream_fd, packet + readstart, 128 - readstart, 0);
if (ret <= 0) break;
readstart = readstart + ret;
}
if (payload == NULL && ret == 0) {
if (conn_started) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror tcp socket is closed, connection ended");
break;
} else {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror tcp socket is closed, got %d bytes of 128 byte header",readstart);
FD_CLR(stream_fd, &rfds);
stream_fd = -1;
continue;
}
} else if (payload == NULL && ret == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) continue; // Timeouts can happen even if the connection is fine
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror error in header recv: %d %s", errno, strerror(errno));
if (errno == ECONNRESET) conn_reset = true;;
break;
}
conn_started = true;
/*packet[0:3] contains the payload size */
int payload_size = byteutils_get_int(packet, 0);
/* packet[4] appears to have one of three possible values: *
* 0x00 : encrypted packet *
* 0x01 : unencrypted packet with a SPS and a PPS NAL, sent initially, and also when *
* a change in video format (e.g., width, height) subsequently occurs *
* 0x05 : unencrypted packet with a "streaming report", sent once per second */
/* encrypted packets have packet[5] = 0x00 or 0x10, and packet[6]= packet[7] = 0x00; *
* encrypted packets immediately following an unencrypted SPS/PPS packet appear to *
* be the only ones with packet[5] = 0x10, and almost always have packet[5] = 0x10, *
* but occasionally have packet[5] = 0x00. */
/* unencrypted SPS/PPS packets have packet[4:7] = 0x01 0x00 0x01 0x16 *
* they are followed by an encrypted packet with the same timestamp in packet[8:15] */
/* "streaming report" packages have packet[4:7] = 0x05 0x00 0x00 0x00, and have no *
* timestamp in packet[8:15] */
//unsigned short payload_type = byteutils_get_short(packet, 4) & 0xff;
//unsigned short payload_option = byteutils_get_short(packet, 6);
if (payload == NULL) {
payload = malloc(payload_size);
readstart = 0;
}
while (readstart < payload_size) {
// Payload data
ret = recv(stream_fd, payload + readstart, payload_size - readstart, 0);
if (ret <= 0) break;
readstart = readstart + ret;
}
if (ret == 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror tcp socket is closed");
break;
} else if (ret == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) continue; // Timeouts can happen even if the connection is fine
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror error in recv: %d %s", errno, strerror(errno));
if (errno == ECONNRESET) conn_reset = true;
break;
}
switch (packet[4]) {
case 0x00:
// Normal video data (VCL NAL)
// Conveniently, the video data is already stamped with the remote wall clock time,
// so no additional clock syncing needed. The only thing odd here is that the video
// ntp time stamps don't include the SECONDS_FROM_1900_TO_1970, so it's really just
// counting micro seconds since last boot.
ntp_timestamp_raw = byteutils_get_long(packet, 8);
uint64_t ntp_timestamp_remote = raop_ntp_timestamp_to_micro_seconds(ntp_timestamp_raw, false);
uint64_t ntp_timestamp = raop_ntp_convert_remote_time(raop_rtp_mirror->ntp, ntp_timestamp_remote);
uint64_t ntp_now = raop_ntp_get_local_time(raop_rtp_mirror->ntp);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror video ntp = %llu, now = %llu, latency = %lld",
ntp_timestamp, ntp_now, ((int64_t) ntp_now) - ((int64_t) ntp_timestamp));
#ifdef DUMP_H264
fwrite(payload, payload_size, 1, file_source);
fwrite(&readstart, sizeof(readstart), 1, file_len);
#endif
unsigned char* payload_out;
unsigned char* payload_decrypted;
if (!raop_rtp_mirror->sps_pps_waiting && packet[5] != 0x00) {
logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "unexpected: packet[5] = %2.2x, but not preceded by SPS+PPS packet", packet[5]);
}
bool prepend_sps_pps = (raop_rtp_mirror->sps_pps_waiting || packet[5] != 0x00);
if (prepend_sps_pps) {
assert(raop_rtp_mirror->sps_pps);
payload_out = (unsigned char*) malloc(payload_size + raop_rtp_mirror->sps_pps_len);
payload_decrypted = payload_out + raop_rtp_mirror->sps_pps_len;
memcpy(payload_out, raop_rtp_mirror->sps_pps, raop_rtp_mirror->sps_pps_len);
raop_rtp_mirror->sps_pps_waiting = false;
} else {
if (packet[5] != 0x00) {
logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "Warning: regular NAL unit, but packet[5] = 0x%2.2x is not 0x00", packet[5]);
}
assert(packet[5] == 0);
payload_out = (unsigned char*) malloc(payload_size);
payload_decrypted = payload_out;
}
// Decrypt data
mirror_buffer_decrypt(raop_rtp_mirror->buffer, payload, payload_decrypted, payload_size);
// It seems the AirPlay protocol prepends NALs with their size, which we're replacing with the 4-byte
// start code for the NAL Byte-Stream Format.
bool valid_data = true;
int nalu_size = 0;
int nalus_count = 0;
int nalu_type; /* 0x01 non-IDR VCL, 0x05 IDR VCL, 0x06 SEI 0x07 SPS, 0x08 PPS */
while (nalu_size < payload_size) {
int nc_len = byteutils_get_int_be(payload_decrypted, nalu_size);
if (nc_len < 0 || nalu_size + 4 > payload_size) {
valid_data = false;
break;
}
memcpy(payload_decrypted + nalu_size, nal_start_code, 4);
nalu_size += 4;
nalus_count++;
if (payload_decrypted[nalu_size] & 0x80) valid_data = false; /* first bit of h264 nalu MUST be 0 ("forbidden_zero_bit") */
nalu_type = payload_decrypted[nalu_size] & 0x1f;
nalu_size += nc_len;
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "nalu_type = %d, nalu_size = %d, processed bytes %d, payloadsize = %d nalus_count = %d",
nalu_type, nc_len, nalu_size, payload_size, nalus_count);
}
if (nalu_size != payload_size) valid_data = false;
if(!valid_data) {
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "nalu marked as invalid");
payload_out[0] = 1; /* mark video data as invalid h264 (failed decryption) */
}
#ifdef DUMP_H264
fwrite(payload_decrypted, payload_size, 1, file);
#endif
payload_decrypted = NULL;
h264_decode_struct h264_data;
h264_data.pts = ntp_timestamp;
h264_data.nal_count = nalus_count; /*nal_count will be the number of nal units in the packet */
h264_data.data_len = payload_size;
h264_data.data = payload_out;
if (prepend_sps_pps) {
h264_data.data_len += raop_rtp_mirror->sps_pps_len;
h264_data.nal_count += 2;
if (ntp_timestamp_raw != ntp_timestamp_nal) {
logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "raop_rtp_mirror: prepended sps_pps timestamp does not match that of video payload");
}
}
raop_rtp_mirror->callbacks.video_process(raop_rtp_mirror->callbacks.cls, raop_rtp_mirror->ntp, &h264_data, raop_rtp_mirror->conn);
free(payload_out);
break;
case 0x01:
// The information in the payload contains an SPS and a PPS NAL
// The sps_pps is not encrypted
ntp_timestamp_nal = byteutils_get_long(packet, 8);
float width = byteutils_get_float(packet, 16);
float height = byteutils_get_float(packet, 20);
float width_source = byteutils_get_float(packet, 40);
float height_source = byteutils_get_float(packet, 44);
if (width != width_source || height != height_source) {
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror: Unexpected : data %f, %f != width_source = %f, height_source = %f",
width, height, width_source, height_source);
}
width = byteutils_get_float(packet, 48);
height = byteutils_get_float(packet, 52);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror: unidentified extra header data %f, %f", width, height);
width = byteutils_get_float(packet, 56);
height = byteutils_get_float(packet, 60);
if (raop_rtp_mirror->callbacks.video_report_size) {
raop_rtp_mirror->callbacks.video_report_size(raop_rtp_mirror->callbacks.cls, &width_source, &height_source, &width, &height, raop_rtp_mirror->conn);
}
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror width_source = %f height_source = %f width = %f height = %f",
width_source, height_source, width, height);
short sps_size = byteutils_get_short_be(payload,6);
unsigned char *sequence_parameter_set = payload + 8;
short pps_size = byteutils_get_short_be(payload, sps_size + 9);
unsigned char *picture_parameter_set = payload + sps_size + 11;
int data_size = 6;
char *str = utils_data_to_string(payload, data_size, 16);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror: sps/pps header size = %d", data_size);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror h264 sps/pps header:\n%s", str);
free(str);
str = utils_data_to_string(sequence_parameter_set, sps_size,16);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror sps size = %d", sps_size);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror h264 Sequence Parameter Set:\n%s", str);
free(str);
str = utils_data_to_string(picture_parameter_set, pps_size, 16);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror pps size = %d", pps_size);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror h264 Picture Parameter Set:\n%s", str);
free(str);
data_size = payload_size - sps_size - pps_size - 11;
if (data_size > 0) {
str = utils_data_to_string (picture_parameter_set + pps_size, data_size, 16);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "remainder size = %d", data_size);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "remainder of sps+pps packet:\n%s", str);
free(str);
} else if (data_size < 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, " pps_sps error: packet remainder size = %d < 0", data_size);
}
// Copy the sps and pps into a buffer to prepend to the next NAL unit.
raop_rtp_mirror->sps_pps_len = sps_size + pps_size + 8;
if (raop_rtp_mirror->sps_pps) {
free(raop_rtp_mirror->sps_pps);
}
raop_rtp_mirror->sps_pps = (unsigned char*) malloc(raop_rtp_mirror->sps_pps_len);
assert(raop_rtp_mirror->sps_pps);
memcpy(raop_rtp_mirror->sps_pps, nal_start_code, 4);
memcpy(raop_rtp_mirror->sps_pps + 4, sequence_parameter_set, sps_size);
memcpy(raop_rtp_mirror->sps_pps + sps_size + 4, nal_start_code, 4);
memcpy(raop_rtp_mirror->sps_pps + sps_size + 8, payload + sps_size + 11, pps_size);
raop_rtp_mirror->sps_pps_waiting = true;
#ifdef DUMP_H264
fwrite(raop_rtp_mirror->sps_pps, raop_rtp_mirror->sps_pps_len, 1, file);
#endif
// h264codec_t h264;
// h264.version = payload[0];
// h264.profile_high = payload[1];
// h264.compatibility = payload[2];
// h264.level = payload[3];
// h264.reserved_6_and_nal = payload[4];
// h264.reserved_3_and_sps = payload[5];
// h264.sps_size = sps_size;
// h264.sequence_parameter_set = malloc(h264.sps_size);
// memcpy(h264.sequence_parameter_set, sequence_parameter_set, sps_size);
// h264.number_of_pps = payload[h264.sps_size + 8];
// h264.pps_size = pps_size;
// h264.picture_parameter_set = malloc(h264.pps_size);
// memcpy(h264.picture_parameter_set, picture_parameter_set, pps_size);
break;
case 0x05:
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "\nReceived video streaming performance info packet from client");
/* payloads with packet[4] = 0x05 have no timestamp, and carry video info from the client as a binary plist *
* Sometimes (e.g, when the client has a locked screen), there is a 25kB trailer attached to the packet. *
* This 25000 Byte trailer with unidentified content seems to be the same data each time it is sent. */
if (payload_size && raop_rtp_mirror->show_client_FPS_data) {
//char *str = utils_data_to_string(packet, 128, 16);
//logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "type 5 video packet header:\n%s", str);
//free (str);
int plist_size = payload_size;
if (payload_size > 25000) {
plist_size = payload_size - 25000;
char *str = utils_data_to_string(payload + plist_size, 16, 16);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "video_info packet had 25kB trailer; first 16 bytes are:\n%s", str);
free(str);
}
if (plist_size) {
char *plist_xml;
uint32_t plist_len;
plist_t root_node = NULL;
plist_from_bin((char *) payload, plist_size, &root_node);
plist_to_xml(root_node, &plist_xml, &plist_len);
logger_log(raop_rtp_mirror->logger, LOGGER_INFO, "%s", plist_xml);
free(plist_xml);
}
}
break;
default:
logger_log(raop_rtp_mirror->logger, LOGGER_WARNING, "\nReceived unexpected TCP packet from client, packet[4] = 0x%2.2x", packet[4]);
break;
}
free(payload);
payload = NULL;
memset(packet, 0, 128);
readstart = 0;
}
}
/* Close the stream file descriptor */
if (stream_fd != -1) {
closesocket(stream_fd);
}
#ifdef DUMP_H264
fclose(file);
fclose(file_source);
fclose(file_len);
#endif
// Ensure running reflects the actual state
MUTEX_LOCK(raop_rtp_mirror->run_mutex);
raop_rtp_mirror->running = false;
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror exiting TCP thread");
if (conn_reset && raop_rtp_mirror->callbacks.conn_reset) {
const bool video_reset = false; /* leave "frozen video" showing */
raop_rtp_mirror->callbacks.conn_reset(raop_rtp_mirror->callbacks.cls, 0, video_reset, raop_rtp_mirror->conn);
}
return 0;
}
static int
raop_rtp_init_mirror_sockets(raop_rtp_mirror_t *raop_rtp_mirror, int use_ipv6)
{
assert(raop_rtp_mirror);
unsigned short dport = raop_rtp_mirror->mirror_data_lport;
int dsock = netutils_init_socket(&dport, use_ipv6, 0);
if (dsock == -1) {
goto sockets_cleanup;
}
/* Listen to the data socket if using TCP */
if (listen(dsock, 1) < 0) {
goto sockets_cleanup;
}
/* Set socket descriptors */
raop_rtp_mirror->mirror_data_sock = dsock;
/* Set port values */
raop_rtp_mirror->mirror_data_lport = dport;
logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, "raop_rtp_mirror local data port socket %d port TCP %d", dsock, dport);
return 0;
sockets_cleanup:
if (dsock != -1) closesocket(dsock);
return -1;
}
void
raop_rtp_start_mirror(raop_rtp_mirror_t *raop_rtp_mirror, int use_udp, unsigned short *mirror_data_lport, uint8_t show_client_FPS_data)
{
logger_log(raop_rtp_mirror->logger, LOGGER_INFO, "raop_rtp_mirror starting mirroring");
int use_ipv6 = 0;
assert(raop_rtp_mirror);
assert(mirror_data_lport);
raop_rtp_mirror->show_client_FPS_data = show_client_FPS_data;
MUTEX_LOCK(raop_rtp_mirror->run_mutex);
if (raop_rtp_mirror->running || !raop_rtp_mirror->joined) {
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
return;
}
if (raop_rtp_mirror->remote_saddr.ss_family == AF_INET6) {
use_ipv6 = 1;
}
use_ipv6 = 0;
raop_rtp_mirror->mirror_data_lport = *mirror_data_lport;
if (raop_rtp_init_mirror_sockets(raop_rtp_mirror, use_ipv6) < 0) {
logger_log(raop_rtp_mirror->logger, LOGGER_ERR, "raop_rtp_mirror initializing sockets failed");
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
return;
}
*mirror_data_lport = raop_rtp_mirror->mirror_data_lport;
/* Create the thread and initialize running values */
raop_rtp_mirror->running = 1;
raop_rtp_mirror->joined = 0;
THREAD_CREATE(raop_rtp_mirror->thread_mirror, raop_rtp_mirror_thread, raop_rtp_mirror);
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
}
void raop_rtp_mirror_stop(raop_rtp_mirror_t *raop_rtp_mirror) {
assert(raop_rtp_mirror);
/* Check that we are running and thread is not
* joined (should never be while still running) */
MUTEX_LOCK(raop_rtp_mirror->run_mutex);
if (!raop_rtp_mirror->running || raop_rtp_mirror->joined) {
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
return;
}
raop_rtp_mirror->running = 0;
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
if (raop_rtp_mirror->mirror_data_sock != -1) {
closesocket(raop_rtp_mirror->mirror_data_sock);
raop_rtp_mirror->mirror_data_sock = -1;
}
/* Join the thread */
THREAD_JOIN(raop_rtp_mirror->thread_mirror);
/* Mark thread as joined */
MUTEX_LOCK(raop_rtp_mirror->run_mutex);
raop_rtp_mirror->joined = 1;
MUTEX_UNLOCK(raop_rtp_mirror->run_mutex);
}
void raop_rtp_mirror_destroy(raop_rtp_mirror_t *raop_rtp_mirror) {
if (raop_rtp_mirror) {
raop_rtp_mirror_stop(raop_rtp_mirror);
MUTEX_DESTROY(raop_rtp_mirror->run_mutex);
mirror_buffer_destroy(raop_rtp_mirror->buffer);
if (raop_rtp_mirror->sps_pps) {
free(raop_rtp_mirror->sps_pps);
}
free(raop_rtp_mirror);
}
}
|
82b2888ff4db2812e2148465035dc18c8489b496
|
e814383d36a10839104efaa4df277996ab220fa3
|
/3rd-party/romio341/adio/ad_gpfs/ad_gpfs_aggrs.h
|
234e5c5b1d80a092b213ef3d76954b61d226dd32
|
[
"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
| 3,557
|
h
|
ad_gpfs_aggrs.h
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
/**
* \file ad_gpfs_aggrs.h
* \brief ???
*/
/*
* File: ad_gpfs_aggrs.h
*
* Declares functions optimized specifically for GPFS parallel I/O solution.
*
*/
#ifndef AD_GPFS_AGGRS_H_INCLUDED
#define AD_GPFS_AGGRS_H_INCLUDED
#include "adio.h"
#include <sys/stat.h>
#ifdef HAVE_GPFS_H
#include <gpfs.h>
#endif
/* overriding ADIOI_Calc_file_domains() to apply 'aligned file domain partitioning'. */
void ADIOI_GPFS_Calc_file_domains(ADIO_File fd,
ADIO_Offset * st_offsets,
ADIO_Offset * end_offsets,
int nprocs,
int nprocs_for_coll,
ADIO_Offset * min_st_offset_ptr,
ADIO_Offset ** fd_start_ptr,
ADIO_Offset ** fd_end_ptr,
ADIO_Offset * fd_size_ptr, void *fs_ptr);
/* overriding ADIOI_Calc_aggregator() for the default implementation is specific for
* static file domain partitioning */
int ADIOI_GPFS_Calc_aggregator(ADIO_File fd,
ADIO_Offset off,
ADIO_Offset min_off,
ADIO_Offset * len,
ADIO_Offset fd_size, ADIO_Offset * fd_start, ADIO_Offset * fd_end);
/* overriding ADIOI_Calc_my_req for the default implementation is specific for
* static file domain partitioning */
void ADIOI_GPFS_Calc_my_req(ADIO_File fd, ADIO_Offset * offset_list, ADIO_Offset * len_list,
int contig_access_count, ADIO_Offset
min_st_offset, ADIO_Offset * fd_start,
ADIO_Offset * fd_end, ADIO_Offset fd_size,
int nprocs,
int *count_my_req_procs_ptr,
int **count_my_req_per_proc_ptr,
ADIOI_Access ** my_req_ptr, MPI_Aint ** buf_idx_ptr);
/*
* ADIOI_Calc_others_req
*
* param[in] count_my_req_procs Number of processes whose file domain my
* request touches.
* param[in] count_my_req_per_proc count_my_req_per_proc[i] gives the no. of
* contig. requests of this process in
* process i's file domain.
* param[in] my_req A structure defining my request
* param[in] nprocs Number of nodes in the block
* param[in] myrank Rank of this node
* param[out] count_others_req_proc_ptr Number of processes whose requests lie in
* my process's file domain (including my
* process itself)
* param[out] others_req_ptr Array of other process' requests that lie
* in my process's file domain
*/
void ADIOI_GPFS_Calc_others_req(ADIO_File fd, int count_my_req_procs,
int *count_my_req_per_proc,
ADIOI_Access * my_req,
int nprocs, int myrank,
int *count_others_req_procs_ptr, ADIOI_Access ** others_req_ptr);
#endif /* AD_GPFS_AGGRS_H_INCLUDED */
|
6781f226ddde106c7358557e78c85d53d1da9755
|
84c498e7a634f1c54c0caaf18ede3f20f8852dc8
|
/NeXAS/pac_pack/Huffman_comp.h
|
70f096f938a0fddbdaf924acc7fdfe1d38adff5f
|
[] |
no_license
|
Yggdrasill-Moe/Niflheim
|
4697e8d5cea5da7e5732f925b190c9d47ef94071
|
51048e7af2ae2c69db772ff59ac26390ab0ea73b
|
refs/heads/master
| 2023-07-19T18:34:26.398212
| 2023-07-17T01:11:04
| 2023-07-17T01:11:04
| 163,126,766
| 103
| 23
| null | null | null | null |
GB18030
|
C
| false
| false
| 7,324
|
h
|
Huffman_comp.h
|
//base on Giga_pac_Assage
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <io.h>
#include <direct.h>
#include <windows.h>
typedef unsigned char unit8;
typedef unsigned short unit16;
typedef unsigned int unit32;
struct bits
{
unsigned long curbits;
unsigned long curbyte;
unsigned char cache;
unsigned char *stream;
unsigned long stream_length;
};
void bits_init(struct bits *bits, unsigned char *stream, unsigned long stream_length)
{
memset(bits, 0, sizeof(*bits));
bits->stream = stream;
bits->stream_length = stream_length;
}
/* 把setval的最低位设置到离最高位最近的地方开始 */
int bit_put_high(struct bits *bits, unsigned char setval)
{
bits->curbits++;
bits->cache |= (setval & 1) << (8 - bits->curbits);
if (bits->curbits == 8)
{
if (bits->curbyte >= bits->stream_length)
return -1;
bits->stream[bits->curbyte++] = bits->cache;
bits->curbits = 0;
bits->cache = 0;
}
return 0;
}
/* 按照从高字节到低字节的顺序把setval中的值设置到离最高位最近的地方开始 */
int bits_put_high(struct bits *bits, unsigned int req_bits, void *setval)
{
unsigned int this_bits;
unsigned int this_byte;
unsigned int i;
this_byte = req_bits / 8;
this_bits = req_bits & 7;
for (int k = (int)this_bits - 1; k >= 0; k--)
{
unsigned char bitval;
bitval = !!(((unsigned char *)setval)[this_byte] & (1 << k));
if (bit_put_high(bits, bitval))
return -1;
}
this_bits = req_bits & ~7;
this_byte--;
for (i = 0; i < this_bits; i++)
{
unsigned char bitval;
bitval = !!(((unsigned char *)setval)[this_byte - i / 8] & (1 << (7 - (i & 7))));
if (bit_put_high(bits, bitval))
return -1;
}
return 0;
}
void bits_flush(struct bits *bits)
{
bits->stream[bits->curbyte] = bits->cache;
}
typedef struct huffman_node
{
unit32 weight;
unit8 ascii;
unit32 code; /* 哈夫曼编码值 */
unit32 code_lengths; /* 哈夫曼编码值的位数 */
struct huffman_node *parent;
struct huffman_node *left_child;
struct huffman_node *right_child;
}huffman_node_t;
static void huffman1_node_encode(huffman_node_t *node, unsigned int code, unsigned int code_lengths)
{
/* 最先编码左下角的叶节点开始 */
if (node->left_child)
{
code <<= 1;
code_lengths++;
huffman1_node_encode(node->left_child, code, code_lengths);
code |= 1;
huffman1_node_encode(node->right_child, code, code_lengths);
}
else
{ /* 页结点 */
node->code = code;
node->code_lengths = code_lengths;
}
}
static int huffman_code_tree_encode(struct bits *bits, huffman_node_t *parent)
{
if (parent->left_child)
{
if (bit_put_high(bits, 1)) /* 表示当前父节点有孩子 */
return -1;
if (huffman_code_tree_encode(bits, parent->left_child))
return -1;
if (huffman_code_tree_encode(bits, parent->right_child))
return -1;
}
else
{ /* 页节点 */
if (bit_put_high(bits, 0)) /* 位0标志表示是页节点 */
return -1;
/* 写入页节点的ascii值 */
if (bits_put_high(bits, 8, (unsigned char *)&parent->ascii))
return -1;
}
return 0;
}
static huffman_node_t *huffman_child_init(huffman_node_t *child_node, unsigned int is_right_child)
{
#ifdef MY_CUSTOM_0
child_node->code = is_right_child; /* 顺便标上编码值(只标明左(0)或右(1)) */
child_node->code_lengths = 1;
#endif
return child_node;
}
static unsigned int huffman_tree_create(huffman_node_t *nodes)
{
huffman_node_t *pnodes[256],*pnode = 0;
int leaves_node; /* 有效的叶结点计数 */
int parent_node; /* 合并时新结点的位置索引 */
int child_node; /* 叶结点位置计数 */
int i;
/* 将出现过的(权值不为0的)叶节点放入队列 */
for (i = 0; nodes[i].weight && i < 256; i++)
pnodes[i] = &nodes[i];
leaves_node = i;
if (leaves_node < 2)
{
printf("有效的叶结点数目过少\n");
return -1;
}
parent_node = leaves_node;
child_node = parent_node - 1;
while (child_node > 0)
{
pnode = &nodes[parent_node++]; /* 合并左右叶结点以后的新结点 */
/* CUSTOM!! */
pnode->left_child = huffman_child_init(pnodes[child_node--], 0); /* 第1个child结点作为左结点 */
pnode->right_child = huffman_child_init(pnodes[child_node--], 1); /* 第2个child结点作为右结点 */
pnode->left_child->parent = pnode->right_child->parent = pnode; /* 新结点成为父结点 */
pnode->weight = pnode->left_child->weight + pnode->right_child->weight;/* 父结点权值为2个孩子的权值之和 */
/* 找到一个合适的插入点, 将父结点插入剩余结点组成的森林中 */
for (i = child_node; i >= 0; i--)
{
/* 找到一个合适的插入点 */
/* custom!! */
if (pnodes[i]->weight >= pnode->weight)
break;
}
/* 将新的节点插入这个位置 */
memmove(pnodes + i + 2, pnodes + i + 1, (child_node - i) * sizeof(huffman_node_t *));
pnodes[i + 1] = pnode;
child_node++;
}
/* pnode就是根结点 */
/* 到了这里,生成了一个按降序排列的2n - 1个结点的队列pnodes */
huffman1_node_encode(pnode, 0, 0);
return leaves_node;
}
/* 按降序排列 */
static int huffman_weight_compare(const void *node1, const void *node2)
{
huffman_node_t *nodes[2] = { (huffman_node_t *)node1, (huffman_node_t *)node2 };
/* 这里比较的前后2项顺序决定了排序是升序或降序 */
return (int)nodes[1]->weight - (int)nodes[0]->weight;
}
static int huffman_ascii_compare(const void *node1, const void *node2)
{
huffman_node_t *nodes[2] = { (huffman_node_t *)node1, (huffman_node_t *)node2 };
return (int)nodes[0]->ascii - (int)nodes[1]->ascii;
}
int huffman_compress(unsigned char *compr, unsigned long *comprlen, unsigned char *uncompr, unsigned long uncomprlen)
{
/* n个叶子的哈夫曼树要经过n-1次合并,产生n-1个新结点。
* 最终求得的哈夫曼树中共有2n-1个结点。*/
huffman_node_t nodes[2 * 256 - 1]; /* huffman树的最大结点数(2 ^ N - 1) */
unsigned int leaves;
unsigned int output_bits;
unsigned long i;
huffman_node_t *root;
struct bits bits;
memset(nodes, 0, sizeof(nodes));
/* 前256个结点(N的最大可能值)用于存放哈夫曼树的叶结点 */
for (i = 0; i < 256; i++)
nodes[i].ascii = (unit8)i; /* for debug: 标记该叶结点所代表的ascii值 */
/* 计算输入的字节数据的出现频度 */
for (i = 0; i < uncomprlen; i++)
nodes[uncompr[i]].weight++;
/* 按照频度(权)降序排序 */
qsort(nodes, 256, sizeof(huffman_node_t), huffman_weight_compare);
/* 创建huffman树 */
leaves = huffman_tree_create(nodes);
root = &nodes[0];
while (root->parent)
root = root->parent;
bits_init(&bits, compr, *comprlen);
if (huffman_code_tree_encode(&bits, root))
return -1;
// sort nodes depending on ascii to can index nodes with its ascii value
// 以便下面进行索引
qsort(nodes, 256, sizeof(huffman_node_t), huffman_ascii_compare);
output_bits = bits.curbyte * 8 + bits.curbits;
for (i = 0; i < uncomprlen; i++)
{
if (bits_put_high(&bits, nodes[uncompr[i]].code_lengths, (unsigned char *)&nodes[uncompr[i]].code))
break;
output_bits += nodes[uncompr[i]].code_lengths;
}
if (i != uncomprlen)
return -1;
*comprlen = ((output_bits + 8 - 1) & ~(8 - 1)) / 8;
bits_flush(&bits);
return 0;
}
|
cf4680486d2d86a2a63e7175559f570bcd61b125
|
0605b9fa82fae8785baa2583e78baffa12e5eb83
|
/src/heap/hh_shared.c
|
3e8ee2e891a9d2bdcad48b03deceb66911fe7734
|
[
"MIT",
"CC-BY-4.0"
] |
permissive
|
facebook/flow
|
18f01601a72f61c1f6736782e992387487689300
|
7b17e57edec4d6a3db43c012ad2d39fafc5b2513
|
refs/heads/main
| 2023-09-01T11:48:01.965821
| 2023-09-01T04:16:56
| 2023-09-01T04:16:56
| 25,880,891
| 21,810
| 2,453
|
MIT
| 2023-09-10T00:33:03
| 2014-10-28T17:17:45
|
OCaml
|
UTF-8
|
C
| false
| false
| 68,317
|
c
|
hh_shared.c
|
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*****************************************************************************/
/* File Implementing the shared memory system for Hack.
*
* THIS CODE ONLY WORKS WITH HACK, IT MAY LOOK LIKE A GENERIC ATOMIC
* HASHTABLE FOR OCAML: IT IS NOT!
* BUT ... YOU WERE GOING TO SAY BUT? BUT ...
* THERE IS NO BUT! DONNY YOU'RE OUT OF YOUR ELEMENT!
*
* The lock-free data structures implemented here only work because of how the
* Hack phases are synchronized.
*
* The hashtable maps string keys to string values. (The strings are really
* serialized / marshalled representations of OCaml structures.) Key observation
* of the table is that data with the same key are considered equivalent, and so
* you can arbitrarily get any copy of it; furthermore if data is missing it can
* be recomputed, so incorrectly saying data is missing when it is being written
* is only a potential perf loss. Note that "equivalent" doesn't necessarily
* mean "identical", e.g., two alpha-converted types are "equivalent" though not
* literally byte- identical. (That said, I'm pretty sure the Hack typechecker
* actually does always write identical data, but the hashtable doesn't need
* quite that strong of an invariant.)
*
* The operations implemented, and their limitations:
*
* -) Concurrent writes: SUPPORTED One will win and the other will get
* dropped on the floor. There is no way to tell which happened. Only promise
* is that after a write, the one thread which did the write will see data in
* the table (though it may be slightly different data than what was written,
* see above about equivalent data).
*
* -) Concurrent reads: SUPPORTED If interleaved with a concurrent write, the
* read will arbitrarily say that there is no data at that slot or return the
* entire new data written by the concurrent writer.
*
* -) Concurrent removes: NOT SUPPORTED Only the master can remove, and can
* only do so if there are no other concurrent operations (reads or writes).
*
* Since the values are variably sized and can get quite large, they are
* stored separately from the hashes in a garbage-collected heap.
*
* Hash collisions are resolved via linear probing.
*/
/*****************************************************************************/
/* define CAML_NAME_SPACE to ensure all the caml imports are prefixed with
* 'caml_' */
#define CAML_NAME_SPACE
#include <caml/alloc.h>
#include <caml/bigarray.h>
#include <caml/callback.h>
#include <caml/fail.h>
#include <caml/intext.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/unixsupport.h>
#ifdef _WIN32
#include <windows.h>
#else
#define _GNU_SOURCE 1
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/errno.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#endif
#include <inttypes.h>
#include <limits.h>
#include <lz4.h>
#include <stdalign.h>
#include <sys/time.h>
#include <time.h>
#include "hh_assert.h"
// Ideally these would live in a handle.h file but our internal build system
// can't support that at the moment. These are shared with handle_stubs.c
#ifdef _WIN32
#define Val_handle(fd) (win_alloc_handle(fd))
#else
#define Handle_val(fd) (Long_val(fd))
#define Val_handle(fd) (Val_long(fd))
#endif
/****************************************************************************
* Quoting the linux manpage: memfd_create() creates an anonymous file
* and returns a file descriptor that refers to it. The file behaves
* like a regular file, and so can be modified, truncated,
* memory-mapped, and so on. However, unlike a regular file, it lives
* in RAM and has a volatile backing storage. Once all references to
* the file are dropped, it is automatically released. Anonymous
* memory is used for all backing pages of the file. Therefore, files
* created by memfd_create() have the same semantics as other
* anonymous memory allocations such as those allocated using mmap(2)
* with the MAP_ANONYMOUS flag. The memfd_create() system call first
* appeared in Linux 3.17.
****************************************************************************/
#ifdef __linux__
#define MEMFD_CREATE 1
// glibc only added support for memfd_create in version 2.27.
#ifndef MFD_CLOEXEC
// Linux version for the architecture must support syscall memfd_create
#ifndef SYS_memfd_create
#if defined(__x86_64__)
#define SYS_memfd_create 319
#elif defined(__powerpc64__)
#define SYS_memfd_create 360
#elif defined(__aarch64__)
#define SYS_memfd_create 385
#else
#error "hh_shared.c requires an architecture that supports memfd_create"
#endif
#endif
#include <asm/unistd.h>
/* Originally this function would call uname(), parse the linux
* kernel release version and make a decision based on whether
* the kernel was >= 3.17 or not. However, syscall will return -1
* with an strerr(errno) of "Function not implemented" if the
* kernel is < 3.17, and that's good enough.
*/
static int memfd_create(const char* name, unsigned int flags) {
return syscall(SYS_memfd_create, name, flags);
}
#endif
#endif
#ifndef MAP_NORESERVE
// This flag was unimplemented in FreeBSD and then later removed
#define MAP_NORESERVE 0
#endif
#ifdef _WIN32
static int win32_getpagesize(void) {
SYSTEM_INFO siSysInfo;
GetSystemInfo(&siSysInfo);
return siSysInfo.dwPageSize;
}
#define getpagesize win32_getpagesize
#endif
/* Too lazy to use getconf */
#define CACHE_LINE_SIZE (1 << 6)
#define WORD_SIZE sizeof(value)
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
#define CACHE_ALIGN(x) ALIGN(x, CACHE_LINE_SIZE)
#define WORD_ALIGN(x) ALIGN(x, WORD_SIZE)
/* Each process reserves a range of values at a time from the shared counter.
* Should be a power of two for more efficient modulo calculation. */
#define COUNTER_RANGE 2048
/*****************************************************************************/
/* Types */
/*****************************************************************************/
/* Convention: bsize = size in bytes, wsize = size in words. */
// Locations in the heap are encoded as byte offsets from the beginning of the
// hash table. Because all data in the heap is word-aligned, these offsets will
// always have 0 in the 3 low bits.
//
// Currently, we rely on the least significant bit being 0 to distinguish these
// addresses from headers. Eventually we may want to rely on the 2 lower bits,
// to represent 4 states in the GC tags instead of 3 (e.g., a gray color state
// for incremental marking.)
//
// Note that the offsets do not start at the beginning of the heap, but the
// start of the hash table. This has two important implications:
//
// 1. The offset 0 will always point to the hash of the first hash table entry,
// which is never a meaningful offset. Because of this, we can take the address
// 0 to be the "null" address.
//
// 2. During garbage collection, it is necessary to point from the heap to the
// hash table itself, since we temporarily store heap headers in the addr field
// of helt_t. By starting the offsets at the beginning of the hash table, we can
// represent offsets into the hash table itself.
typedef uintnat addr_t;
// A field is either an address or a tagged integer, distinguished by low bit.
typedef uintnat field_t;
typedef struct {
/* Layout information, used by workers to create memory mappings. */
size_t locals_bsize;
size_t hashtbl_bsize;
size_t heap_bsize;
size_t shared_mem_bsize;
/* Maximum number of hashtable elements */
size_t hashtbl_slots;
/* Where the heap started (bottom), offset from hashtbl pointer */
addr_t heap_init;
/* Where the heap will end (top), offset from hashtbl pointer */
addr_t heap_max;
uintnat gc_phase;
/* When we start a GC, we record the heap pointer here. We use this to
* identify allocations performed during marking. These objects are not
* explicitly marked, but are treated as reachable during the current
* collection pass.
*
* This address should always fall between info->heap_init and info->heap.
* This invariant is set up in hh_shared_init and maintained in
* hh_start_cycle. */
addr_t gc_end;
/* Bytes which are free (color=Blue). This quantity is initially 0 and
* incremented during the GC sweep phase. The number will increase
* monotonically until compaction, when all free space is reclaimed. */
uintnat free_bsize;
/* Transaction counter. Entities being written by the current transaction will
* have an entity version >= this counter. Committed entities will have a
* version < this counter. */
intnat next_version;
/* Logging level for shared memory statistics
* 0 = nothing
* 1 = log totals, averages, min, max bytes marshalled and unmarshalled
* 2+ = log size of deserialized values in OCaml heap
*/
size_t log_level;
/* Initially 0; set to 1 to signal that workers should cancel */
size_t workers_should_cancel;
/* A counter increasing globally across all forks. */
alignas(128) uintnat counter;
/* The number of nonempty slots in the hashtable. A nonempty slot has a
* non-zero hash. We never clear hashes so this monotonically increases */
alignas(128) uintnat hcounter;
/* The number of nonempty filled slots in the hashtable. A nonempty filled
* slot has a non-zero hash AND a non-null addr. It increments when we write
* data into a slot with addr==NULL and decrements when we clear data from a
* slot */
alignas(128) uintnat hcounter_filled;
/* The top of the heap, offset from hashtbl pointer */
alignas(128) addr_t heap;
/* Head of the mark stack. */
alignas(128) uintnat mark_ptr;
} shmem_info_t;
/* Per-worker data which can be quickly updated non-atomically. Will be placed
* in cache-aligned array in the first few pages of shared memory, indexed by
* worker id.
*
* The first member of this struct is over-aligned to ensure that each element
* of the global locals array is on a separate cache line. */
typedef struct {
alignas(128) uint64_t counter;
} local_t;
// Every heap entry starts with a 64-bit header with the following layout:
//
// 6 3 0 0 0 00
// 3 6 8 7 2 10
// +-------------------------------+--------------------------------+------+--+
// |11111111 11111111 11111111 1111|1111 11111111 11111111 11111111 |111111|11|
// +-------------------------------+--------------------------------+------+--+
// | | | |
// | | | * 0-1
// | | | GC
// | | * 2-7 tag
// | * 31-1 decompress capacity (in words)
// * 63-32 compressed size (in words)
//
// For GC, to distinguish headers from (word-aligned) pointers, the least bits
// are never 00. The remaining 6 bits of the low word are used to encode a tag,
// describing the type of object.
//
// For serialized objects (tag = 0), the remaining 7 bytes of the header word
// encode two sizes, as outlined above, but other kinds of objects can use these
// bytes differently, as long as it's possible to recover the size of the heap
// object -- i.e., implement Obj_wosize, below.
typedef uintnat hh_header_t;
// The reserved header bits contain a tag used to distinguish between different
// object layouts and find pointers within the object.
typedef uintnat hh_tag_t;
// Keep these in sync with "tag" type definition in sharedMem.ml
#define Entity_tag 0
#define Heap_string_tag 13
#define Serialized_tag 19
static _Bool should_scan(hh_tag_t tag) {
// The zero tag represents "entities" which need to be handled specially.
// Callers to this function should first check for 0.
assert(tag != Entity_tag);
// By convention, only tags below Heap_string_tag contain pointers. We can
// exploit this fact to reduce pointer finding to a single branch.
//
// In the future, if we add different layouts with a mixture of pointers and
// other data, scanning for pointers will probably require a jump table.
return tag < Heap_string_tag;
}
#define NULL_ADDR 0
#define Addr_of_ptr(entry) ((char*)(entry) - (char*)hashtbl)
#define Ptr_of_addr(addr) ((char*)hashtbl + (addr))
#define Entry_of_addr(addr) ((heap_entry_t*)Ptr_of_addr(addr))
#define Deref(addr) (*(uintnat*)(Ptr_of_addr(addr))) /* also an l-value */
// During GC, we read words from the heap which might be an addr or a header,
// and we need to distinguish between them.
#define Is_addr(x) (((x)&0b11) == 0)
// The low 2 bits of headers are reserved for GC. The white bit pattern
// denotes an unmarked object, black denotes a marked object, and blue denotes a
// free object.
#define Color_white 0b01
#define Color_black 0b11
#define Color_blue 0b10
#define Color_hd(hd) ((hd)&0b11)
#define Is_white(hd) (Color_hd(hd) == Color_white)
#define Is_black(hd) (Color_hd(hd) == Color_black)
#define Is_blue(hd) (Color_hd(hd) == Color_blue)
#define White_hd(hd) (((hd) & ~0b11) | Color_white)
#define Black_hd(hd) ((hd) | Color_black)
#define Blue_hd(hd) (((hd) & ~0b11) | Color_blue)
// Object headers contain a mark bit, tag, and size information. Objects with
// the serialized tag contain the size information in a slightly different place
// from other objects, so we need to look up the tag to read the size.
#define Obj_tag(hd) (((hd) >> 2) & 0x3F)
#define Obj_wosize_shift(tag) ((tag) < Serialized_tag ? 8 : 36)
#define Obj_wosize_tag(hd, tag) ((hd) >> Obj_wosize_shift(tag))
#define Obj_wosize(hd) (Obj_wosize_tag(hd, Obj_tag(hd)))
#define Obj_whsize(hd) (1 + Obj_wosize(hd))
#define Obj_bosize(hd) (Bsize_wsize(Obj_wosize(hd)))
#define Obj_bhsize(hd) (Bsize_wsize(Obj_whsize(hd)))
// Addrs point to the object header, so field 0 is +1 word. We should consider
// making addrs point to the first field, and accessing the header at a -1 word
// offset instead.
#define Obj_field(addr, i) ((addr) + ((i) + 1) * WORD_SIZE)
// Each heap entry starts with a word-sized header. The header encodes the size
// (in words) of the entry in the heap and the capacity (in words) of the buffer
// needed to decompress the entry.
#define Entry_wsize(header) ((header) >> 36)
#define Entry_decompress_capacity(header) \
(Bsize_wsize(((header) >> 8) & 0xFFFFFFF))
// The distance (in bytes) from one hh_entry_t* to the next. Entries are laid
// out contiguously in memory.
#define Heap_entry_slot_size(header) \
(sizeof(heap_entry_t) + Bsize_wsize(Entry_wsize(header)))
/* Shared memory structures. hh_shared.h typedefs this to heap_entry_t. */
typedef struct {
hh_header_t header;
char data[];
} heap_entry_t;
/* The hash table supports lock-free writes by performing a 16-byte CAS,
* ensuring that the hash and address are written together atomically. */
typedef struct {
uint64_t hash;
addr_t addr;
} helt_t;
/*****************************************************************************/
/* GC */
/*****************************************************************************/
// The possible values of info->gc_phase
#define Phase_idle 0
#define Phase_mark 1
#define Phase_sweep 2
// The max size is explicit to avoid exhausting available memory in the event of
// a programmer error. We should not hit this limit, or come close to it. It
// might become necessary to handle a mark stack overflow without crashing, but
// this is not implemented.
#define MARK_STACK_INIT_SIZE 512 // 4096 KiB
#define MARK_STACK_MAX_SIZE (MARK_STACK_INIT_SIZE << 16) // 256 MiB
// Note: because collection only happens on the master process, the following
// values are only maintained in the master process and updates will not be
// reflected in workers.
// The marking phase treats the shared hash table as GC roots, but these are
// marked incrementally. Because we might modify the hash table between mark
// slices, we insert a write barrier in hh_remove.
static uintnat roots_ptr = 0;
// Holds the current position of the sweep phase between slices.
static addr_t sweep_ptr = NULL_ADDR;
/*****************************************************************************/
/* Globals */
/*****************************************************************************/
/* Shared memory metadata */
static shmem_info_t* info = NULL;
/* Beginning of shared memory */
static char* shared_mem = NULL;
/* Worker-local storage is cache line aligned. */
static local_t* locals = NULL;
/* Base of the mark stack. */
static addr_t* mark_stack = NULL;
/* The hashtable containing the shared values. */
static helt_t* hashtbl = NULL;
/* This should only be used before forking */
static uintnat early_counter = 0;
/* This is a process-local value. The master process is 0, workers are numbered
* starting at 1. This is an offset into the worker local values in the heap. */
static size_t worker_id = 0;
static size_t worker_can_cancel = 1;
CAMLprim value hh_used_heap_size(value unit) {
CAMLparam1(unit);
assert(info != NULL);
CAMLreturn(Val_long(info->heap - info->heap_init));
}
CAMLprim value hh_new_alloc_size(value unit) {
CAMLparam1(unit);
assert(info != NULL);
CAMLreturn(Val_long(info->heap - info->gc_end));
}
CAMLprim value hh_free_heap_size(value unit) {
CAMLparam1(unit);
assert(info != NULL);
CAMLreturn(Val_long(info->free_bsize));
}
CAMLprim value hh_gc_phase(value unit) {
CAMLparam1(unit);
assert(info != NULL);
CAMLreturn(Val_long(info->gc_phase));
}
CAMLprim value hh_log_level(value unit) {
CAMLparam1(unit);
assert(info != NULL);
CAMLreturn(Val_long(info->log_level));
}
CAMLprim value hh_next_version(value unit) {
intnat v = 0;
if (info) {
v = info->next_version;
}
return Val_long(v);
}
CAMLprim value hh_commit_transaction(value unit) {
CAMLparam1(unit);
assert(info != NULL);
info->next_version += 2;
CAMLreturn(Val_unit);
}
CAMLprim value hh_hash_stats(value unit) {
CAMLparam1(unit);
CAMLlocal1(stats);
stats = caml_alloc_tuple(3);
Store_field(stats, 0, Val_long(info->hcounter));
Store_field(stats, 1, Val_long(info->hcounter_filled));
Store_field(stats, 2, Val_long(info->hashtbl_slots));
CAMLreturn(stats);
}
static void raise_failed_memfd_init(int errcode) {
static const value* exn = NULL;
if (!exn)
exn = caml_named_value("failed_memfd_init");
caml_raise_with_arg(*exn, unix_error_of_code(errcode));
}
#ifdef _WIN32
static HANDLE memfd;
/**************************************************************************
* We create an anonymous memory file, whose `handle` might be
* inherited by subprocesses.
*
* This memory file is tagged "reserved" but not "committed". This
* means that the memory space will be reserved in the virtual memory
* table but the pages will not be bound to any physical memory
* yet. Further calls to 'VirtualAlloc' will "commit" pages, meaning
* they will be bound to physical memory.
*
* This is behavior that should reflect the 'MAP_NORESERVE' flag of
* 'mmap' on Unix. But, on Unix, the "commit" is implicit.
*
* Committing the whole shared heap at once would require the same
* amount of free space in memory (or in swap file).
**************************************************************************/
static void memfd_init(size_t shared_mem_size) {
memfd = CreateFileMapping(
INVALID_HANDLE_VALUE,
NULL,
PAGE_READWRITE | SEC_RESERVE,
shared_mem_size >> 32,
shared_mem_size & ((1ll << 32) - 1),
NULL);
if (memfd == NULL) {
win32_maperr(GetLastError());
raise_failed_memfd_init(errno);
}
if (!SetHandleInformation(memfd, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {
win32_maperr(GetLastError());
raise_failed_memfd_init(errno);
}
}
#else
static int memfd = -1;
/**************************************************************************
* The memdfd_init function creates a anonymous memory file that might
* be inherited by `Daemon.spawned` processus (contrary to a simple
* anonymous mmap).
*
* The preferred mechanism is memfd_create(2) (see the upper
* description). Then we try shm_open(3).
*
* The resulting file descriptor should be mmaped with the memfd_map
* function (see below).
****************************************************************************/
static void memfd_init(size_t shared_mem_size) {
#if defined(MEMFD_CREATE)
memfd = memfd_create("fb_heap", 0);
#endif
if (memfd < 0) {
char memname[255];
snprintf(memname, sizeof(memname), "/fb_heap.%d", getpid());
// the ftruncate below will fail with errno EINVAL if you try to
// ftruncate the same sharedmem fd more than once. We're seeing this in
// some tests, which might imply that two flow processes with the same
// pid are starting up. This shm_unlink should prevent that from
// happening. Here's a stackoverflow about it
// http://stackoverflow.com/questions/25502229/ftruncate-not-working-on-posix-shared-memory-in-mac-os-x
shm_unlink(memname);
memfd = shm_open(memname, O_CREAT | O_RDWR, 0666);
if (memfd < 0) {
raise_failed_memfd_init(errno);
}
// shm_open sets FD_CLOEXEC automatically. This is undesirable, because
// we want this fd to be open for other processes, so that they can
// reconnect to the shared memory.
int flags = fcntl(memfd, F_GETFD);
if (flags == -1) {
raise_failed_memfd_init(errno);
}
// Unset close-on-exec
if (fcntl(memfd, F_SETFD, flags & ~FD_CLOEXEC) == -1) {
raise_failed_memfd_init(errno);
};
}
if (ftruncate(memfd, shared_mem_size) == -1) {
raise_failed_memfd_init(errno);
}
}
#endif
#ifdef _WIN32
static char* memfd_map(size_t size) {
char* mem = NULL;
mem = MapViewOfFile(memfd, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (mem == NULL) {
win32_maperr(GetLastError());
uerror("MapViewOfFile", Nothing);
}
return mem;
}
#else
static char* memfd_map(size_t size) {
char* mem = NULL;
/* MAP_NORESERVE is because we want a lot more virtual memory than what
* we are actually going to use.
*/
int flags = MAP_SHARED | MAP_NORESERVE;
int prot = PROT_READ | PROT_WRITE;
mem = (char*)mmap(NULL, size, prot, flags, memfd, 0);
if (mem == MAP_FAILED) {
printf("Error initializing: %s\n", strerror(errno));
exit(2);
}
return mem;
}
#endif
/****************************************************************************
* The function memfd_reserve force allocation of (mem -> mem+sz) in
* the shared heap. This is mandatory on Windows. This is optional on
* Linux but it allows to have explicit "Out of memory" error
* messages. Otherwise, the kernel might terminate the process with
* `SIGBUS`.
****************************************************************************/
static void raise_out_of_shared_memory(void) {
static const value* exn = NULL;
if (!exn)
exn = caml_named_value("out_of_shared_memory");
caml_raise_constant(*exn);
}
#ifdef _WIN32
/* On Linux, memfd_reserve is only used to reserve memory that is mmap'd to the
* memfd file. On Windows, this is required. */
static void memfd_reserve(char* base, char* mem, size_t sz) {
(void)base;
if (!VirtualAlloc(mem, sz, MEM_COMMIT, PAGE_READWRITE)) {
win32_maperr(GetLastError());
raise_out_of_shared_memory();
}
}
#elif defined(__APPLE__)
/* So OSX lacks fallocate, but in general you can do
* fcntl(fd, F_PREALLOCATE, &store)
* however it doesn't seem to work for a shm_open fd, so this function is
* currently a no-op. This means that our OOM handling for OSX is a little
* weaker than the other OS's */
static void memfd_reserve(char* base, char* mem, size_t sz) {
(void)base;
(void)mem;
(void)sz;
}
#else
static void memfd_reserve(char* base, char* mem, size_t sz) {
off_t offset = (off_t)(mem - base);
int err;
do {
err = posix_fallocate(memfd, offset, sz);
} while (err == EINTR);
if (err) {
raise_out_of_shared_memory();
}
}
#endif
static void map_info_page(int page_bsize) {
// The first page of shared memory contains (1) size information describing
// the layout of the rest of the shared file; (2) values which are atomically
// updated by workers, like the heap pointer; and (3) various configuration
// which is convenient to stick here, like the log level.
assert(page_bsize >= sizeof(shmem_info_t));
info = (shmem_info_t*)memfd_map(page_bsize);
}
static void define_mappings(int page_bsize) {
assert(info != NULL);
size_t locals_bsize = info->locals_bsize;
size_t mark_stack_max_bsize = MARK_STACK_MAX_SIZE * sizeof(mark_stack[0]);
shared_mem = memfd_map(info->shared_mem_bsize);
locals = (local_t*)(shared_mem + page_bsize);
mark_stack = (addr_t*)(shared_mem + page_bsize + locals_bsize);
hashtbl =
(helt_t*)(shared_mem + page_bsize + locals_bsize + mark_stack_max_bsize);
}
static value alloc_heap_bigarray(void) {
CAMLparam0();
CAMLlocal1(heap);
int heap_flags = CAML_BA_CHAR | CAML_BA_C_LAYOUT | CAML_BA_EXTERNAL;
intnat heap_dim[1] = {info->hashtbl_bsize + info->heap_bsize};
heap = caml_ba_alloc(heap_flags, 1, hashtbl, heap_dim);
CAMLreturn(heap);
}
/*****************************************************************************/
/* Must be called by the master BEFORE forking the workers! */
/*****************************************************************************/
CAMLprim value hh_shared_init(value config_val, value num_workers_val) {
CAMLparam2(config_val, num_workers_val);
CAMLlocal1(result);
int page_bsize = getpagesize();
/* Calculate layout information. We need to figure out how big the shared file
* needs to be in order to create the file. We will also store enough of the
* layout information in the first page of the shared file so that workers can
* create mappings for the rest of the shared data. */
size_t num_workers = Long_val(num_workers_val);
size_t locals_bsize = CACHE_ALIGN((1 + num_workers) * sizeof(local_t));
size_t hashtbl_slots = 1ul << Long_val(Field(config_val, 1));
size_t mark_stack_max_bsize = MARK_STACK_MAX_SIZE * sizeof(mark_stack[0]);
size_t hashtbl_bsize = CACHE_ALIGN(hashtbl_slots * sizeof(helt_t));
size_t heap_bsize = Long_val(Field(config_val, 0));
/* The total size of the shared file must have space for the info page, local
* data, the mark stack, the hash table, and the heap. */
size_t shared_mem_bsize = page_bsize + locals_bsize + mark_stack_max_bsize +
hashtbl_bsize + heap_bsize;
memfd_init(shared_mem_bsize);
/* The info page contains (1) size information describing the layout of the
* rest of the shared file; (2) values which are atomically updated by
* workers, like the heap pointer; and (3) various configuration which is
* conventient to stick here, like the log level. */
map_info_page(page_bsize);
memfd_reserve((char*)info, (char*)info, page_bsize);
info->locals_bsize = locals_bsize;
info->hashtbl_bsize = hashtbl_bsize;
info->heap_bsize = heap_bsize;
info->shared_mem_bsize = shared_mem_bsize;
info->hashtbl_slots = hashtbl_slots;
info->heap_init = hashtbl_bsize;
info->heap_max = info->heap_init + heap_bsize;
info->gc_phase = Phase_idle;
info->log_level = Long_val(Field(config_val, 2));
// Ensure the global counter starts on a COUNTER_RANGE boundary
info->counter = ALIGN(early_counter + 1, COUNTER_RANGE);
// Initialize top heap pointers
info->heap = info->heap_init;
// Invariant: info->heap_init <= info->gc_end <= info->heap
// See declaration of gc_end
info->gc_end = info->heap;
define_mappings(page_bsize);
// Reserve memory for locals, the initial mark stack, and hashtbl.
// This is required on Windows.
memfd_reserve(shared_mem, (char*)locals, locals_bsize);
memfd_reserve(
shared_mem,
(char*)mark_stack,
MARK_STACK_INIT_SIZE * sizeof(mark_stack[0]));
memfd_reserve(shared_mem, (char*)hashtbl, hashtbl_bsize);
#ifdef MADV_DONTDUMP
// We are unlikely to get much useful information out of the shared heap in
// a core file. Moreover, it can be HUGE, and the extensive work done dumping
// it once for each CPU can mean that the user will reboot their machine
// before the much more useful stack gets dumped!
madvise(hashtbl, hashtbl_bsize + heap_bsize, MADV_DONTDUMP);
#endif
#ifndef _WIN32
// Uninstall ocaml's segfault handler. It's supposed to throw an exception on
// stack overflow, but we don't actually handle that exception, so what
// happens in practice is we terminate at toplevel with an unhandled exception
// and a useless ocaml backtrace. A core dump is actually more useful. Sigh.
struct sigaction sigact = {0};
sigact.sa_handler = SIG_DFL;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(SIGSEGV, &sigact, NULL);
#endif
result = caml_alloc_tuple(2);
Store_field(result, 0, alloc_heap_bigarray());
Store_field(result, 1, Val_handle(memfd));
CAMLreturn(result);
}
/* Must be called by every worker before any operation is performed */
value hh_connect(value handle_val, value worker_id_val) {
CAMLparam2(handle_val, worker_id_val);
memfd = Handle_val(handle_val);
worker_id = Long_val(worker_id_val);
// Avoid confusion with master process, which is designated 0
assert(worker_id > 0);
int page_bsize = getpagesize();
map_info_page(page_bsize);
define_mappings(page_bsize);
CAMLreturn(alloc_heap_bigarray());
}
/*****************************************************************************/
/* Counter
*
* Provides a counter intended to be increasing over the lifetime of the program
* including all forks. Uses a global variable until hh_shared_init is called,
* so it's safe to use in the early init stages of the program (as long as you
* fork after hh_shared_init of course). Wraps around at the maximum value of an
* ocaml int, which is something like 30 or 62 bits on 32 and 64-bit
* architectures respectively.
*/
/*****************************************************************************/
CAMLprim value hh_counter_next(value unit) {
CAMLparam1(unit);
CAMLlocal1(result);
uintptr_t v = 0;
if (info) {
v = locals[worker_id].counter;
if (v % COUNTER_RANGE == 0) {
v = __atomic_fetch_add(&info->counter, COUNTER_RANGE, __ATOMIC_RELAXED);
}
++v;
locals[worker_id].counter = v;
} else {
v = ++early_counter;
}
result = Val_long(v % Max_long); // Wrap around.
CAMLreturn(result);
}
/*****************************************************************************/
/* There are a bunch of operations that only the designated master thread is
* allowed to do. This assert will fail if the current process is not the master
* process
*/
/*****************************************************************************/
static void assert_master(void) {
assert(worker_id == 0);
}
static void assert_not_master(void) {
assert(worker_id != 0);
}
/*****************************************************************************/
CAMLprim value hh_stop_workers(value unit) {
CAMLparam1(unit);
assert_master();
info->workers_should_cancel = 1;
CAMLreturn(Val_unit);
}
CAMLprim value hh_resume_workers(value unit) {
CAMLparam1(unit);
assert_master();
info->workers_should_cancel = 0;
CAMLreturn(Val_unit);
}
CAMLprim value hh_set_can_worker_stop(value val) {
CAMLparam1(val);
worker_can_cancel = Bool_val(val);
CAMLreturn(Val_unit);
}
CAMLprim value hh_get_can_worker_stop(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_bool(worker_can_cancel));
}
static void check_should_cancel(void) {
assert(info != NULL);
if (worker_can_cancel && info->workers_should_cancel) {
static const value* exn = NULL;
if (!exn)
exn = caml_named_value("worker_should_cancel");
caml_raise_constant(*exn);
}
}
CAMLprim value hh_check_should_cancel(value unit) {
CAMLparam1(unit);
check_should_cancel();
CAMLreturn(Val_unit);
}
/*****************************************************************************/
/* GC: Incremental Mark and Sweep
*
* Before compacting the heap, we must first find all live values. We can mark
* all live values in the heap by starting with the root objects in the hash
* table, then traversing the graph of all reachable objects from those roots.
*
* To avoid long pauses, we do this work incrementally. Between commands, we
* perform "slices" of mark and sweep work. After a slice of work, we return
* back to the server, which can either handle another request of perform
* another slice.
*
* Because the program can modify the heap between slices of mark and sweep, we
* need to be careful that all reachable objects are marked. We use a shapshot-
* at-the-beginning approach, which ensures that all reachable objects at the
* beginning of GC pass are marked. We also use an "allocate black" strategy,
* meaning that any new objects allocated during a collection are considered
* reachable.
*
* For snapshot-at-the-beginning, we use a Yuasa style deletion barrier. If a
* field is modified during collection, the "old" reference is added to the mark
* stack. The only modification that happens during a GC pass is hh_remove,
* which is only called from the main server process, meaning we don't need to
* store the mark stack in shared memory.
*
* The "allocate black" strategy is a bit non-standard. Because the shared heap
* is a bump allocator, we don't actually use the black color for new
* allocations. Instead, we record the location of the heap pointer at the
* beginning of a collection. Any addresses below that address need to be
* marked, while any addresses above that address are assumed to be live.
*/
/*****************************************************************************/
// Trigger the start of a new cycle (idle -> mark)
CAMLprim value hh_start_cycle(value unit) {
CAMLparam1(unit);
assert(info->gc_phase == Phase_idle);
info->gc_end = info->heap;
roots_ptr = 0;
sweep_ptr = info->heap_init;
info->gc_phase = Phase_mark;
CAMLreturn(Val_unit);
}
CAMLnoreturn_start static void mark_stack_overflow() CAMLnoreturn_end;
static void mark_stack_overflow() {
caml_failwith("mark_stack_resize: could not allocate space for mark stack");
}
// Check if the mark stack needs to be resized
//
// The mark stack has an initial size of 4KiB. When we reach the end of the mark
// stack, we double the size until we reach the maximum size of 256MiB. Notice
// that the capacity of the mark stack is always a power of 2.
//
// The expression `x & (-x)` returns the least set bit in `x`. When this number
// is equal to `x`, we know that `x` is a power of 2.
//
// Thus, when the mark stack pointer is a power of 2, we know that we are at
// capacity and need to resize. We resize by doubling the capacity.
//
// Note that this operation is idempotent because `memfd_reserve` is idempotent.
static void mark_stack_try_resize(uintnat mark_ptr) {
if (mark_ptr >= MARK_STACK_INIT_SIZE &&
((mark_ptr & (-mark_ptr)) == mark_ptr)) {
if (mark_ptr == MARK_STACK_MAX_SIZE) {
mark_stack_overflow();
}
// Double the size of the mark stack by reserving `mark_ptr` amount of space
// starting at `mark_ptr`.
memfd_reserve(
shared_mem,
(char*)&mark_stack[mark_ptr],
mark_ptr * sizeof(mark_stack[0]));
}
}
// When an address is overwritten during the mark phase, we add the old value to
// the mark stack. This function can be called concurrently from workers when
// they modify the heap.
static void write_barrier(addr_t old) {
if (old != NULL_ADDR && info->gc_phase == Phase_mark && old < info->gc_end) {
hh_header_t hd = Deref(old);
if (Is_white(hd)) {
// Color the object black. Note that two workers might both enter this
// branch for the same value. Both workers will color the object black and
// both workers will add the value to the mark stack.
//
// This is okay, because marking is idempotent.
Deref(old) = Black_hd(hd);
// Add to mark stack. We need a CAS here instead of simply a fetch-add
// because we need to know whether to resize the mark stack.
//
// We resize the mark stack at power-of-2 boundaries. Note that two
// workers might observe the same power-of-2 value for mark_ptr, and both
// try to resize. This is okay because `mark_stack_try_resize` is
// idempotent.
uintnat mark_ptr = __atomic_load_n(&info->mark_ptr, __ATOMIC_ACQUIRE);
while (1) {
mark_stack_try_resize(mark_ptr);
if (__atomic_compare_exchange_n(
&info->mark_ptr,
&mark_ptr,
mark_ptr + 1,
0,
__ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST)) {
mark_stack[mark_ptr] = old;
break;
}
}
}
}
}
// Add a reachable object to the mark stack.
//
// Objects allocated during marking will have an address greater than gc_end
// and are treated as reachable. This is morally an "allocate black" scheme,
// except we allocate white to avoid needing to sweep. Because we allocate
// white and don't sweep these addresses, it's important that they are not
// darkened.
static inline void mark_slice_darken(field_t fld) {
if ((fld & 1) == 0 && fld != NULL_ADDR && fld < info->gc_end) {
hh_header_t hd = Deref(fld);
if (Is_white(hd)) {
Deref(fld) = Black_hd(hd);
uintnat mark_ptr = info->mark_ptr;
mark_stack_try_resize(mark_ptr);
mark_stack[mark_ptr] = fld;
info->mark_ptr = mark_ptr + 1;
}
}
}
// Entities have a committed value and potentially a "latest" value which is
// being written by the current transaction. There are two cases:
//
// 1. entity_version < next_version
//
// The data at `entity_version & 1` is the committed value and is reachable.
// The other slot is unreachable.
//
// 2. entity_version >= next_version
//
// The data at `entity_version & 1` is the latest value and is reachable. The
// other slot is the committed and is also reachable.
static void mark_entity(addr_t v, intnat next_version) {
intnat entity_version = Deref(Obj_field(v, 2));
mark_slice_darken(Deref(Obj_field(v, entity_version & 1)));
if (entity_version >= next_version) {
mark_slice_darken(Deref(Obj_field(v, ~entity_version & 1)));
}
}
// Perform a bounded amount of marking work, incrementally. During the marking
// phase, this function is called repeatedly until marking is complete. Once
// complete, this function will transition to the sweep phase.
//
// This function will mark at most `work` words before returning. This includes
// the hash table and heap.
CAMLprim value hh_mark_slice(value work_val) {
CAMLparam1(work_val);
assert(info->gc_phase == Phase_mark);
// We are able to partially scan an object for pointers and resume scanning in
// a subsequent slice. This is useful in the event of large objects which
// would otherwise cause long pauses if we needed to scan them all at once.
//
// If we stop in the middle of an object, we will store the address of that
// object and the index of the field where we should resume. Otherwise, these
// values will be NULL_ADDR and 0 respectively.
static addr_t current_value = NULL_ADDR;
static uintnat current_index = 0;
intnat work = Long_val(work_val);
intnat hashtbl_slots = info->hashtbl_slots;
intnat next_version = info->next_version;
addr_t v;
hh_header_t hd;
hh_tag_t tag;
uintnat i, size, start, end;
// If the previous slice stopped in the middle of scanning an object, the
// first thing we do in this slice is resume scanning where we left off.
v = current_value;
start = current_index;
// Work through the mark stack, scanning all gray objects for pointers.
// Because roots are colored gray but not added to the mark stack, also walk
// the heap to find marked roots.
while (work > 0) {
if (v == NULL_ADDR && info->mark_ptr > 0) {
v = mark_stack[--info->mark_ptr];
work--; // header word
}
if (v != NULL_ADDR) {
hd = Deref(v);
tag = Obj_tag(hd);
size = Obj_wosize_tag(hd, tag);
if (tag == Entity_tag) {
mark_entity(v, next_version);
v = NULL_ADDR;
start = 0;
work -= size;
} else if (should_scan(tag)) {
// Avoid scanning large objects all at once
end = start + work;
if (size < end) {
end = size;
}
work -= end - start;
for (i = start; i < end; i++) {
mark_slice_darken(Deref(Obj_field(v, i)));
}
if (end < size) {
// We did not finish scanning this object. We will resume scanning
// this object in the next slice.
start = end;
} else {
v = NULL_ADDR;
start = 0;
}
} else {
v = NULL_ADDR;
work -= size;
}
} else if (roots_ptr < hashtbl_slots) {
// Visit roots in shared hash table
mark_slice_darken(hashtbl[roots_ptr++].addr);
work--;
} else {
// Done marking, transition to sweep phase.
info->gc_phase = Phase_sweep;
break;
}
}
current_value = v;
current_index = start;
CAMLreturn(Val_long(work));
}
// Perform a bounded amount of sweeping work, incrementally. During the sweeping
// phase, this function is called repeatedly until sweeping is complete. Once
// complete, this function will transition to the idle phase.
CAMLprim value hh_sweep_slice(value work_val) {
CAMLparam1(work_val);
assert(info->gc_phase == Phase_sweep);
intnat work = Long_val(work_val);
while (work > 0) {
if (sweep_ptr < info->gc_end) {
uintnat hd = Deref(sweep_ptr);
uintnat whsize = Obj_whsize(hd);
uintnat bhsize = Bsize_wsize(whsize);
switch (Color_hd(hd)) {
case Color_white:
Deref(sweep_ptr) = Blue_hd(hd);
info->free_bsize += bhsize;
break;
case Color_black:
Deref(sweep_ptr) = White_hd(hd);
break;
case Color_blue:
break;
}
sweep_ptr += bhsize;
work -= whsize;
} else {
// Done sweeping
info->gc_phase = Phase_idle;
break;
}
}
CAMLreturn(Val_long(work));
}
/*****************************************************************************/
/* GC: Compact
*
* We collect the shared heap by compacting: moving live values "to the left"
* until there is no more free space. We can then continue to bump allocate from
* the end.
*
* The compaction algorithm is a Jonkers collector which performs the compaction
* "in place" without allocating additional memory to maintain state.
*
* The algorithm is published, unfortunately, behind a costly subscription.
* https://doi.org/10.1016/0020-0190(79)90103-0
*
* Happily, an excellent description of the algorithm can be found in a freely
* accessible paper by Benedikt Meurer, along with an extension for interior
* pointers which is unused here:
* https://benediktmeurer.de/files/fast-garbage-compaction-with-interior-pointers.pdf
*
* This particular algorithm has some nice properties, namely:
* - Heap objects can have varying size
* - We can compact the heap in-place without auxiliary storage
* - The compacted heap preserves order, keeping related objects close together
* - Is actually pretty simple, in the sense that it has few moving pieces,
* although pointer reversal can take a moment to "click"
*
* However, there are also downsides to this choice:
* - Is fully stop-the-world and non-incremental
* - Pointer reversal techniques are not cache-friendly, and generally slow
* compared to both contemporary and modern techniques
*
* Happily, the bursty nature of the type checker means that there are long (in
* human scale) periods of down time between requests, so a long pause is not a
* problem as long as it is well timed.
*
* For future work, it might be worthwhile to explore more incremental GC
* strategies, which could spread the work over more small pauses instead.
*/
/*****************************************************************************/
// Threading is the fundamental operation of the GC. Moving objects potentially
// invalidates every address in the heap. Threading makes it possible to update
// those addresses without requiring extra storage.
//
// In a single step, threading replaces a pointer to a value with the value
// itself. Where the value was, we insert a pointer to original pointer. This
// swap is more easily understood when visualized:
//
// P Q
// +---+ +---+
// | * |-->| X |
// +---+ +---+
//
// becomes
//
// P Q
// +---+ +---+
// | X |<--| * |
// +---+ +---+
//
// Performing this single step repeatedly has the effect of replacing multiple
// pointers to a given value with a linked list (or "thread") of pointers to the
// value. For example:
//
// P Q R
// +---+ +---+ +---+
// | * | | * |-->| X |
// +---+ +---+ +---+
// | ^
// +-------------+
//
// becomes (in two steps)
//
// P Q R
// +---+ +---+ +---+
// | X |<--| * |<--| * |
// +---+ +---+ +---+
static void gc_thread(addr_t p) {
field_t q = Deref(p);
if ((q & 1) == 0 && q != NULL_ADDR) {
Deref(p) = Deref(q);
Deref(q) = p;
}
}
// See comment above `mark_entity`
static void gc_scan_entity(addr_t v, intnat next_version) {
intnat entity_version = Deref(Obj_field(v, 2));
gc_thread(Obj_field(v, entity_version & 1));
if (entity_version >= next_version) {
gc_thread(Obj_field(v, ~entity_version & 1));
}
}
// As we walk the heap, we must be sure to thread every pointer to live data, as
// any live object may be relocated.
static void gc_scan(addr_t v, intnat next_version) {
hh_header_t hd = Deref(v);
hh_tag_t tag = Obj_tag(hd);
if (tag == Entity_tag) {
gc_scan_entity(v, next_version);
} else if (should_scan(tag)) {
for (int i = 0; i < Obj_wosize_tag(hd, tag); i++) {
gc_thread(Obj_field(v, i));
}
}
}
// With the heap threaded, we can now relocate "R" to a different known address
// by "unthreading," or following the linked list of pointers until we reach the
// original value X. Each word in the thread is replaced with the new address
// and the original value is copied back into place.
static void gc_update(addr_t src, addr_t dst) {
uintnat p = Deref(src);
while (Is_addr(p)) {
uintnat q = Deref(p);
Deref(p) = dst;
p = q;
}
Deref(src) = p;
}
// Compacting the heap proceeds in three phases:
// 1. Thread the root set
// 2. Walk heap, update forward pointers
// 3. Walk heap, update backward pointers and move objects
CAMLprim value hh_compact(value unit) {
CAMLparam1(unit);
assert_master();
assert(info->gc_phase == Phase_idle);
intnat hashtbl_slots = info->hashtbl_slots;
intnat next_version = info->next_version;
// Step 1: Scan the root set, threading any pointers to the heap. The
// threading performed during this step will be unthreaded in the next step,
// updating the hash table to point to the updated locations.
for (intnat i = 0; i < hashtbl_slots; i++) {
addr_t hashtbl_addr = Addr_of_ptr(&hashtbl[i].addr);
gc_thread(hashtbl_addr);
}
// Step 2: Scan the heap object-by-object from bottom to top. The dst pointer
// keeps track of where objects will move to, but we do not move anything
// during this step.
//
// If we encounter an unmarked header, the object is unreachable, so do not
// update the dst pointer.
//
// If we encounter an address, then this object was reachable via "forward"
// reference, i.e., a pointer stored at a lower address. Because we know where
// the object will move to (dst), we eagerly update the forward references and
// copy the original header back.
//
// If we encounter a marked header, then the object is reachable only via
// "backwards" reference. These backwards references will be handled in the
// next step.
//
// NB: Instead of scanning the entire heap, it may be worthwhile to track the
// min/max live addresses during the marking phase, and only scan that part.
// Possible that the extra marking work would be more expensive than a linear
// memory scan, but worth experimenting.
//
// NB: Also worth experimenting with explicit prefetching.
addr_t src = info->heap_init;
addr_t dst = info->heap_init;
addr_t heap_ptr = info->heap;
while (src < heap_ptr) {
hh_header_t hd = Deref(src);
intnat size;
if (Is_blue(hd)) {
size = Obj_bhsize(hd);
} else {
gc_update(src, dst);
hd = Deref(src);
size = Obj_bhsize(hd);
gc_scan(src, next_version);
dst += size;
}
src += size;
}
// Step 3: Scan the heap object-by-object again, actually moving objects this
// time around.
//
// Unmarked headers still indicate unreachable data and is not moved.
//
// If we encounter an address, then the object was reachable via a "backwards"
// reference from the previous step, and we fix up those references to point
// to the new location and copy the original header back.
//
// Finally we can move the object. We unset the mark bit on the header so that
// future collections can free the space if the object becomes unreachable.
src = info->heap_init;
dst = info->heap_init;
while (src < heap_ptr) {
hh_header_t hd = Deref(src);
intnat size;
if (Is_blue(hd)) {
size = Obj_bhsize(hd);
} else {
gc_update(src, dst);
hd = Deref(src);
size = Obj_bhsize(hd);
if (Obj_tag(hd) == Entity_tag) {
// Move entities manually, resetting the entity version to 0 and writing
// the previous entity data to the correct offset. If the entity version
// is >= the next version, that means we're compacting after a canceled
// recheck, so we must preserve the committed and latest data.
intnat v = Deref(Obj_field(src, 2));
addr_t data0 = Deref(Obj_field(src, v & 1));
addr_t data1 = NULL_ADDR;
if (v >= next_version) {
data1 = Deref(Obj_field(src, ~v & 1));
v = 2;
} else {
v = 0;
}
Deref(dst) = hd;
Deref(Obj_field(dst, 0)) = data0;
Deref(Obj_field(dst, 1)) = data1;
Deref(Obj_field(dst, 2)) = v;
} else {
memmove(Ptr_of_addr(dst), Ptr_of_addr(src), size);
}
dst += size;
}
src += size;
}
// TODO: Space between dst and info->heap is unused, but will almost certainly
// become used again soon. Currently we will never decommit, which may cause
// issues when there is memory pressure.
//
// If the kernel supports it, we might consider using madvise(MADV_FREE),
// which allows the kernel to reclaim the memory lazily under pressure, but
// would not force page faults under healthy operation.
info->heap = dst;
// Invariant: info->heap_init <= info->gc_end <= info->heap
// See declaration of gc_end
info->gc_end = dst;
info->free_bsize = 0;
// All live entities have been reset to version 0, so we can also reset the
// global version counter.
info->next_version = 2;
CAMLreturn(Val_unit);
}
static void raise_heap_full(void) {
static const value* exn = NULL;
if (!exn)
exn = caml_named_value("heap_full");
caml_raise_constant(*exn);
}
/*****************************************************************************/
/* Allocates a slot in the shared heap, given a size (in words). The caller is
* responsible for initializing the allocated space with valid heap objects. */
/*****************************************************************************/
static addr_t hh_alloc(size_t wsize) {
if (wsize == 0)
return info->heap;
size_t slot_size = Bsize_wsize(wsize);
addr_t addr = __sync_fetch_and_add(&info->heap, slot_size);
if (addr + slot_size > info->heap_max) {
raise_heap_full();
}
memfd_reserve(shared_mem, Ptr_of_addr(addr), slot_size);
return addr;
}
CAMLprim value hh_ml_alloc(value wsize) {
CAMLparam1(wsize);
addr_t addr = hh_alloc(Long_val(wsize));
CAMLreturn(Val_long(addr));
}
/*****************************************************************************/
/* Allocates an ocaml value in the shared heap.
* Any ocaml value is valid, except closures. It returns the address of
* the allocated chunk.
*/
/*****************************************************************************/
CAMLprim value hh_store_ocaml(value v, value tag_val) {
CAMLparam1(v);
check_should_cancel();
char *serialized, *compressed;
intnat serialized_size;
int compress_bound, compressed_size;
caml_output_value_to_malloc(
v, Val_int(0) /*flags*/, &serialized, &serialized_size);
// Compress the serialized data. LZ4's maximum input size is ~2GB. If the
// input is larger than that, LZ4_compressBound will return 0 and the
// compression itself will do nothing.
if (serialized_size > LZ4_MAX_INPUT_SIZE) {
caml_invalid_argument("hh_store_ocaml: value larger than max input size");
}
compress_bound = LZ4_compressBound(serialized_size);
compressed = malloc(compress_bound);
compressed_size = LZ4_compress_default(
serialized, compressed, serialized_size, compress_bound);
assert(compressed_size > 0);
// Construct a header to describe the serialized and compressed data:
//
// A header is a single word where The low-order byte is reserved, meaning we
// have 56 bits to store the serialized size and compressed size. Is it
// enough?
//
// In the worst case, we try to compress uncompressible input of
// LZ4_MAX_INPUT_SIZE, consuming the entire compress bound. That would be
// 0x7E7E7E8E bytes compressed size.
//
// NOTE: The compressed size might actually be bigger than the serialized
// size, in a worst case scenario where the input is not compressible. This
// shouldn't happen in practice, but we account for it in the worse case.
//
// If we store the size in words instead of bytes, the max size is 0xFCFCFD2
// words, which fits in 2^28, so we can fit both sizes (in words) in 56 bits.
//
// All this is somewhat academic, since we have bigger problems if we're
// trying to store 2 gig entries.
// The compressed size is not necessarily word sized. To accommodate this, we
// use a trick lifted from OCaml's own representation of strings, which also
// have a header that stores the size in words.
//
// In the last byte of the block, we store a value which we can use to recover
// the exact byte size of the string. If the string is exactly word sized, we
// add another word to hold the final byte.
size_t compressed_wsize = (compressed_size + WORD_SIZE) / WORD_SIZE;
// Similarly, the serialized size might not necessarily be a multiple of the
// word size. To decompress, we only need to provide a buffer that is large
// enough, so we round up to the nearest word.
size_t decompress_capacity = Wsize_bsize(WORD_ALIGN(serialized_size));
// Just in case the math above doesn't check out
assert(compressed_size < 0x10000000);
assert(decompress_capacity < 0x10000000);
// Ensure tag fits in high 6 bits of low bytes
int tag = Long_val(tag_val);
assert(tag < 0x40);
hh_header_t header = compressed_wsize << 36 | decompress_capacity << 8 |
tag << 2 | Color_white;
// Allocate space for the header and compressed data
heap_entry_t* entry = Entry_of_addr(hh_alloc(1 + compressed_wsize));
// Write header and data into allocated space.
entry->header = header;
memcpy(&entry->data, compressed, compressed_size);
// Write offset into final byte for byte size calculation
// See entry_compressed_bsize for how this is used.
size_t offset_index = Bsize_wsize(compressed_wsize) - 1;
entry->data[offset_index] = offset_index - compressed_size;
free(serialized);
free(compressed);
CAMLreturn(Val_long(Addr_of_ptr(entry)));
}
// The final byte of a compressed heap entry contains an offset, which we can
// use to convert the approximate size in words to the precise size in bytes.
static size_t entry_compressed_bsize(heap_entry_t* entry) {
size_t compressed_wsize = Entry_wsize(entry->header);
size_t offset_index = Bsize_wsize(compressed_wsize) - 1;
return offset_index - entry->data[offset_index];
}
/*****************************************************************************/
/* Given an OCaml string, returns the 8 first bytes in an unsigned long.
* The key is generated using MD5, but we only use the first 8 bytes because
* it allows us to use atomic operations.
*/
/*****************************************************************************/
static uint64_t get_hash(value key) {
return *((uint64_t*)String_val(key));
}
static void raise_hash_table_full(void) {
static const value* exn = NULL;
if (!exn)
exn = caml_named_value("hash_table_full");
caml_raise_constant(*exn);
}
/*****************************************************************************/
/* Adds a key value to the hashtable. This code is perf sensitive, please
* check the perf before modifying.
*
* Returns the address associated with this key in the hash table, which may not
* be the same as the address passed in by the caller.
*/
/*****************************************************************************/
CAMLprim value hh_add(value key, value addr) {
CAMLparam2(key, addr);
check_should_cancel();
uint64_t elt_hash = get_hash(key);
addr_t elt_addr = Long_val(addr);
size_t hashtbl_slots = info->hashtbl_slots;
size_t slot = elt_hash & (hashtbl_slots - 1);
size_t init_slot = slot;
while (1) {
uint64_t old_hash = __atomic_load_n(&hashtbl[slot].hash, __ATOMIC_ACQUIRE);
// If this slot looks free, try to take it. If we are racing with another
// thread and lose, the CAS operation will write the current value of the
// hash slot into `old_hash`.
if (old_hash == 0 &&
__atomic_compare_exchange_n(
&hashtbl[slot].hash,
&old_hash,
elt_hash,
0, /* strong */
__ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST)) {
__atomic_fetch_add(&info->hcounter, 1, __ATOMIC_RELAXED);
old_hash = elt_hash; // Try to take the addr slot next
}
if (old_hash == elt_hash) {
// Try to acquire the addr slot if needed. If the slot is already taken or
// we lose a race to acquire it, we want to return the value of the addr
// slot to the caller.
addr_t old_addr = __atomic_load_n(&hashtbl[slot].addr, __ATOMIC_ACQUIRE);
if (old_addr == NULL_ADDR &&
__atomic_compare_exchange_n(
&hashtbl[slot].addr,
&old_addr,
elt_addr,
0, /* strong */
__ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST)) {
__atomic_fetch_add(&info->hcounter_filled, 1, __ATOMIC_RELAXED);
} else {
addr = Val_long(old_addr);
}
break;
}
slot = (slot + 1) & (hashtbl_slots - 1);
if (slot == init_slot) {
// We're never going to find a spot
raise_hash_table_full();
}
}
CAMLreturn(addr);
}
/*****************************************************************************/
/* Finds the slot corresponding to the key in a hash table. The returned slot
* is either free or points to the key.
*/
/*****************************************************************************/
static size_t find_slot(value key, helt_t* elt) {
size_t hashtbl_slots = info->hashtbl_slots;
uint64_t hash = get_hash(key);
size_t slot = hash & (hashtbl_slots - 1);
size_t init_slot = slot;
while (1) {
*elt = hashtbl[slot];
if (elt->hash == hash || elt->hash == 0) {
return slot;
}
slot = (slot + 1) & (hashtbl_slots - 1);
if (slot == init_slot) {
raise_hash_table_full();
}
}
}
/*****************************************************************************/
/* Returns true if the key is present. We need to check both the hash and
* the address of the data. This is due to the fact that we remove by setting
* the address slot to NULL (we never remove a hash from the table, outside
* of garbage collection).
*/
/*****************************************************************************/
CAMLprim value hh_mem(value key) {
CAMLparam1(key);
check_should_cancel();
helt_t elt;
find_slot(key, &elt);
CAMLreturn(Val_bool(elt.hash != 0 && elt.addr != NULL_ADDR));
}
/*****************************************************************************/
/* Deserializes the value at the given address. */
/*****************************************************************************/
CAMLprim value hh_deserialize(value addr_val) {
CAMLparam1(addr_val);
CAMLlocal1(result);
check_should_cancel();
heap_entry_t* entry = Entry_of_addr(Long_val(addr_val));
size_t compressed_bsize = entry_compressed_bsize(entry);
size_t decompress_capacity = Entry_decompress_capacity(entry->header);
char* decompressed = malloc(decompress_capacity);
size_t serialized_size = LZ4_decompress_safe(
entry->data, decompressed, compressed_bsize, decompress_capacity);
result = caml_input_value_from_block(decompressed, serialized_size);
free(decompressed);
CAMLreturn(result);
}
/*****************************************************************************/
/* Returns the address associated to a given key. */
/* The key MUST be present. */
/*****************************************************************************/
CAMLprim value hh_get(value key) {
CAMLparam1(key);
check_should_cancel();
helt_t elt;
find_slot(key, &elt);
CAMLreturn(Val_long(elt.hash == 0 ? NULL_ADDR : elt.addr));
}
/*****************************************************************************/
/* Removes a key from the hash table.
* Only the master can perform this operation.
*/
/*****************************************************************************/
CAMLprim value hh_remove(value key) {
CAMLparam1(key);
assert_master();
helt_t elt;
size_t slot = find_slot(key, &elt);
if (elt.hash != 0 && elt.addr != NULL_ADDR) {
// GC write barrier
if (info->gc_phase == Phase_mark) {
mark_slice_darken(elt.addr);
}
hashtbl[slot].addr = NULL_ADDR;
info->hcounter_filled -= 1;
}
CAMLreturn(Val_unit);
}
/*****************************************************************************/
/* Blits an OCaml string representation into the shared heap.
*
* Note that, like OCaml's heap, the shared heap is word-addressible. Like
* OCaml's strings, strings in the shared heap are encoded with a header
* containing the size in words, where the last byte of the last word contains
* an offset used to calculate the exact bytes size. */
/*****************************************************************************/
CAMLprim value hh_write_string(value addr, value s) {
memcpy(Ptr_of_addr(Long_val(addr)), String_val(s), Bosize_val(s));
return Val_unit;
}
/*****************************************************************************/
/* Blits bytes into the shared heap.
*
* Unlike `hh_write_string` above, which writes the entire string representation
* into shared memory, this function takes `pos`, an offset from the beginning
* of the byte array, and `len`, the number of bytes to write starting at `pos`.
*
* Callers is responsible for ensuring the heap space is allocated and for
* bounds checking the buffer, offset, and length. */
/*****************************************************************************/
CAMLprim value hh_write_bytes(value addr, value buf, value pos, value len) {
memcpy(
Ptr_of_addr(Long_val(addr)),
Bytes_val(buf) + Long_val(pos),
Long_val(len));
return Val_unit;
}
/*****************************************************************************/
/* Reads a string in the shared heap into a the OCaml heap.
*
* Because we store string data in the shared heap in the same format as OCaml
* does for it's own heap, we can simply blit the data directly into the OCaml
* heap, instead of using the designated caml_alloc_string function. */
/*****************************************************************************/
CAMLprim value hh_read_string(value addr, value wsize) {
CAMLparam2(addr, wsize);
CAMLlocal1(s);
s = caml_alloc(Long_val(wsize), String_tag);
memcpy(
(char*)String_val(s),
Ptr_of_addr(Long_val(addr)),
Bsize_wsize(Long_val(wsize)));
CAMLreturn(s);
}
static size_t hh_string_len(addr_t addr, char** ptr) {
*ptr = Ptr_of_addr(Obj_field(addr, 0));
size_t tmp = Obj_bosize(Deref(addr)) - 1;
return tmp - (*ptr)[tmp];
}
CAMLprim value hh_compare_string(value addr1_val, value addr2_val) {
if (addr1_val == addr2_val)
return Val_int(0);
char *ptr1, *ptr2;
size_t len1 = hh_string_len(Long_val(addr1_val), &ptr1);
size_t len2 = hh_string_len(Long_val(addr2_val), &ptr2);
int res = memcmp(ptr1, ptr2, len1 <= len2 ? len1 : len2);
return Val_int(res ? res : len1 - len2);
}
CAMLprim value hh_entity_advance(value entity_val, value data_val) {
CAMLparam2(entity_val, data_val);
addr_t entity = Long_val(entity_val);
addr_t data = Long_val(data_val);
intnat next_version = info->next_version;
intnat entity_version_fld = Obj_field(entity, 2);
intnat entity_version = Deref(entity_version_fld);
intnat slot = entity_version & 1;
if (entity_version < next_version) {
// By updating the version, we are doing a kind of deferred logical deletion
// of the committed data. Once we commit this transaction, the data in
// `slot` will no longer be reachable.
write_barrier(Deref(Obj_field(entity, slot)));
slot = 1 - slot;
Deref(entity_version_fld) = next_version | slot;
}
Deref(Obj_field(entity, slot)) = data;
CAMLreturn(Val_unit);
}
CAMLprim value hh_load_acquire(value addr_val) {
int64_t* ptr = (int64_t*)Ptr_of_addr(Long_val(addr_val));
return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
}
CAMLprim value hh_store_release(value addr_val, int64_t v) {
int64_t* ptr = (int64_t*)Ptr_of_addr(Long_val(addr_val));
__atomic_store_n(ptr, v, __ATOMIC_RELEASE);
return Val_unit;
}
CAMLprim value hh_compare_exchange(
value weak_val,
value addr_val,
int64_t expected,
int64_t desired) {
int64_t* ptr = (int64_t*)Ptr_of_addr(Long_val(addr_val));
return Val_bool(__atomic_compare_exchange_n(
ptr,
&expected,
desired,
Bool_val(weak_val),
__ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST));
}
CAMLprim value hh_compare_modify_addr(
value weak_val,
value addr_val,
value expected_val,
int64_t desired) {
CAMLparam3(weak_val, addr_val, expected_val);
int64_t* ptr = (int64_t*)Ptr_of_addr(Long_val(addr_val));
int64_t expected = Long_val(expected_val);
int success = __atomic_compare_exchange_n(
ptr,
&expected,
desired,
Bool_val(weak_val),
__ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST);
if (success) {
write_barrier(expected);
}
CAMLreturn(Val_bool(success));
}
CAMLprim value hh_load_acquire_byte(value addr_val) {
return caml_copy_int64(hh_load_acquire(addr_val));
}
CAMLprim value hh_store_release_byte(value addr_val, value v) {
return hh_store_release(addr_val, Int64_val(v));
}
CAMLprim value hh_compare_exchange_byte(
value weak_val,
value addr_val,
value expected_val,
value desired_val) {
return hh_compare_exchange(
weak_val, addr_val, Int64_val(expected_val), Int64_val(desired_val));
}
CAMLprim value hh_compare_modify_addr_byte(
value weak_val,
value addr_val,
value expected_val,
value desired_val) {
return hh_compare_modify_addr(
weak_val, addr_val, expected_val, Int64_val(desired_val));
}
|
6f0ea71de581813609f93cd69bf4ef80af00867d
|
fa7ba9dc69c3d1c47f2caab8b6012c4003eff852
|
/source/htslib/htslib/synced_bcf_reader.h
|
2f79a2102ac96893102fabd15df3e84b54c5bb84
|
[
"MIT"
] |
permissive
|
alexdobin/STAR
|
22d6c771b6346b8ec19f89751f21a56fd42549df
|
79affaae7d5e70221287762eab4e40679fad87f7
|
refs/heads/master
| 2023-08-23T07:32:52.945974
| 2023-08-15T19:21:58
| 2023-08-15T19:21:58
| 17,778,869
| 1,686
| 594
|
MIT
| 2023-08-16T15:49:57
| 2014-03-15T15:47:05
|
C
|
UTF-8
|
C
| false
| false
| 10,696
|
h
|
synced_bcf_reader.h
|
/*
The synced_bcf_reader allows to keep multiple VCFs open and stream them
using the next_line iterator in a seamless matter without worrying about
chromosomes and synchronizing the sites. This is used by vcfcheck to
compare multiple VCFs simultaneously and is used also for merging,
creating intersections, etc.
The synced_bcf_reader also provides API for reading indexed BCF/VCF,
hiding differences in BCF/VCF opening, indexing and reading.
Example of usage:
bcf_srs_t *sr = bcf_sr_init();
for (i=0; i<nfiles; i++)
bcf_sr_add_reader(sr,files[i]);
while ( bcf_sr_next_line(sr) )
{
for (i=0; i<nfiles; i++)
{
bcf1_t *line = bcf_sr_get_line(sr,i);
...
}
}
bcf_sr_destroy(sr);
*/
#ifndef SYNCED_BCF_READER_H
#define SYNCED_BCF_READER_H
#include "hts.h"
#include "vcf.h"
#include "tbx.h"
// How should be treated sites with the same position but different alleles
#define COLLAPSE_NONE 0 // require the exact same set of alleles in all files
#define COLLAPSE_SNPS 1 // allow different alleles, as long as they all are SNPs
#define COLLAPSE_INDELS 2 // the same as above, but with indels
#define COLLAPSE_ANY 4 // any combination of alleles can be returned by bcf_sr_next_line()
#define COLLAPSE_SOME 8 // at least some of the ALTs must match
#define COLLAPSE_BOTH (COLLAPSE_SNPS|COLLAPSE_INDELS)
typedef struct _bcf_sr_regions_t
{
// for reading from tabix-indexed file (big data)
tbx_t *tbx; // tabix index
hts_itr_t *itr; // tabix iterator
kstring_t line; // holder of the current line, set only when reading from tabix-indexed files
htsFile *file;
char *fname;
int is_bin; // is open in binary mode (tabix access)
char **als; // parsed alleles if targets_als set and _regions_match_alleles called
kstring_t als_str; // block of parsed alleles
int nals, mals; // number of set alleles and the size of allocated array
int als_type; // alleles type, currently VCF_SNP or VCF_INDEL
// user handler to deal with skipped regions without a counterpart in VCFs
void (*missed_reg_handler)(struct _bcf_sr_regions_t *, void *);
void *missed_reg_data;
// for in-memory regions (small data)
struct _region_t *regs; // the regions
// shared by both tabix-index and in-memory regions
void *seq_hash; // keys: sequence names, values: index to seqs
char **seq_names; // sequence names
int nseqs; // number of sequences (chromosomes) in the file
int iseq; // current position: chr name, index to snames
int start, end; // current position: start, end of the region (0-based)
int prev_seq, prev_start;
}
bcf_sr_regions_t;
typedef struct
{
htsFile *file;
tbx_t *tbx_idx;
hts_idx_t *bcf_idx;
bcf_hdr_t *header;
hts_itr_t *itr;
const char *fname;
bcf1_t **buffer; // cached VCF records. First is the current record synced across the reader
int nbuffer, mbuffer; // number of cached records (including the current record); number of allocated records
int nfilter_ids, *filter_ids; // -1 for ".", otherwise filter id as returned by bcf_id2int
int type;
int *samples, n_smpl; // list of columns in the order consistent with bcf_srs_t.samples
}
bcf_sr_t;
typedef struct
{
// Parameters controlling the logic
int collapse; // How should the duplicate sites be treated. One of the COLLAPSE_* types above.
char *apply_filters; // If set, sites where none of the FILTER strings is listed
// will be skipped. Active only at the time of
// initialization, that is during the add_reader()
// calls. Therefore, each reader can be initialized with different
// filters.
int require_index; // Some tools do not need random access
int max_unpack; // When reading VCFs and knowing some fields will not be needed, boost performance of vcf_parse1
int *has_line; // Corresponds to return value of bcf_sr_next_line but is not limited by sizeof(int). Use bcf_sr_has_line macro to query.
// Auxiliary data
bcf_sr_t *readers;
int nreaders;
int streaming; // reading mode: index-jumping or streaming
int explicit_regs; // was the list of regions se by bcf_sr_set_regions or guessed from tabix index?
char **samples; // List of samples
bcf_sr_regions_t *regions, *targets; // see bcf_sr_set_[targets|regions] for description
int targets_als; // subset to targets not only by position but also by alleles? (todo)
kstring_t tmps;
int n_smpl;
}
bcf_srs_t;
/** Init bcf_srs_t struct */
bcf_srs_t *bcf_sr_init(void);
/** Destroy bcf_srs_t struct */
void bcf_sr_destroy(bcf_srs_t *readers);
/**
* bcf_sr_add_reader() - open new reader
* @readers: holder of the open readers
* @fname: the VCF file
*
* Returns 1 if the call succeeded, or 0 on error.
*
* See also the bcf_srs_t data structure for parameters controlling
* the reader's logic.
*/
int bcf_sr_add_reader(bcf_srs_t *readers, const char *fname);
void bcf_sr_remove_reader(bcf_srs_t *files, int i);
/**
* bcf_sr_next_line() - the iterator
* @readers: holder of the open readers
*
* Returns the number of readers which have the current line
* (bcf_sr_t.buffer[0]) set at this position. Use the bcf_sr_has_line macro to
* determine which of the readers are set.
*/
int bcf_sr_next_line(bcf_srs_t *readers);
#define bcf_sr_has_line(readers, i) (readers)->has_line[i]
#define bcf_sr_get_line(_readers, i) ((_readers)->has_line[i] ? ((_readers)->readers[i].buffer[0]) : NULL)
#define bcf_sr_region_done(_readers,i) (!(_readers)->has_line[i] && !(_readers)->readers[i].nbuffer ? 1 : 0)
/**
* bcf_sr_seek() - set all readers to selected position
* @seq: sequence name; NULL to seek to start
* @pos: 0-based coordinate
*/
int bcf_sr_seek(bcf_srs_t *readers, const char *seq, int pos);
/**
* bcf_sr_set_samples() - sets active samples
* @readers: holder of the open readers
* @samples: this can be one of: file name with one sample per line;
* or column-separated list of samples; or '-' for a list of
* samples shared by all files. If first character is the
* exclamation mark, all but the listed samples are included.
* @is_file: 0: list of samples; 1: file with sample names
*
* Returns 1 if the call succeeded, or 0 on error.
*/
int bcf_sr_set_samples(bcf_srs_t *readers, const char *samples, int is_file);
/**
* bcf_sr_set_targets(), bcf_sr_set_regions() - init targets/regions
* @readers: holder of the open readers
* @targets: list of regions, one-based and inclusive.
* @is_fname: 0: targets is a comma-separated list of regions (chr,chr:from-to)
* 1: targets is a tabix indexed file with a list of regions
* (<chr,pos> or <chr,from,to>)
*
* Returns 0 if the call succeeded, or -1 on error.
*
* Both functions behave the same way, unlisted positions will be skipped by
* bcf_sr_next_line(). However, there is an important difference: regions use
* index to jump to desired positions while targets streams the whole files
* and merely skip unlisted positions.
*
* Moreover, bcf_sr_set_targets() accepts an optional parameter $alleles which
* is intepreted as a 1-based column index in the tab-delimited file where
* alleles are listed. This in principle enables to perform the COLLAPSE_*
* logic also with tab-delimited files. However, the current implementation
* considers the alleles merely as a suggestion for prioritizing one of possibly
* duplicate VCF lines. It is up to the caller to examine targets->als if
* perfect match is sought after. Note that the duplicate positions in targets
* file are currently not supported.
*/
int bcf_sr_set_targets(bcf_srs_t *readers, const char *targets, int is_file, int alleles);
int bcf_sr_set_regions(bcf_srs_t *readers, const char *regions, int is_file);
/*
* bcf_sr_regions_init()
* @regions: regions can be either a comma-separated list of regions
* (chr|chr:pos|chr:from-to|chr:from-) or VCF, BED, or
* tab-delimited file (the default). Uncompressed files
* are stored in memory while bgzip-compressed and tabix-indexed
* region files are streamed.
* @is_file: 0: regions is a comma-separated list of regions
* (chr|chr:pos|chr:from-to|chr:from-)
* 1: VCF, BED or tab-delimited file
* @chr, from, to:
* Column indexes of chromosome, start position and end position
* in the tab-delimited file. The positions are 1-based and
* inclusive.
* These parameters are ignored when reading from VCF, BED or
* tabix-indexed files. When end position column is not present,
* supply 'from' in place of 'to'. When 'to' is negative, first
* abs(to) will be attempted and if that fails, 'from' will be used
* instead.
*/
bcf_sr_regions_t *bcf_sr_regions_init(const char *regions, int is_file, int chr, int from, int to);
void bcf_sr_regions_destroy(bcf_sr_regions_t *regions);
/*
* bcf_sr_regions_seek() - seek to the chromosome block
*
* Returns 0 on success or -1 on failure. Sets reg->seq appropriately and
* reg->start,reg->end to -1.
*/
int bcf_sr_regions_seek(bcf_sr_regions_t *regions, const char *chr);
/*
* bcf_sr_regions_next() - retrieves next region. Returns 0 on success and -1
* when all regions have been read. The fields reg->seq, reg->start and
* reg->end are filled with the genomic coordinates on succes or with
* NULL,-1,-1 when no region is available. The coordinates are 0-based,
* inclusive.
*/
int bcf_sr_regions_next(bcf_sr_regions_t *reg);
/*
* bcf_sr_regions_overlap() - checks if the interval <start,end> overlaps any of
* the regions, the coordinates are 0-based, inclusive. The coordinate queries
* must come in ascending order.
*
* Returns 0 if the position is in regions; -1 if the position is not in the
* regions and more regions exist; -2 if not in the regions and there are no more
* regions left.
*/
int bcf_sr_regions_overlap(bcf_sr_regions_t *reg, const char *seq, int start, int end);
/*
* bcf_sr_regions_flush() - calls repeatedly regs->missed_reg_handler() until
* all remaining records are processed.
*/
void bcf_sr_regions_flush(bcf_sr_regions_t *regs);
#endif
|
b664935f1cfd921e9cdade238d6fb70fdccddec0
|
d2e0fb3fdad7fc2cb70894591d358f40d8db13d2
|
/libc/src/unistd/access.c
|
9017c6f20132c0da47f334dd6b5cc53c371d3363
|
[
"ISC",
"MIT"
] |
permissive
|
dennis95/dennix
|
54c568485862a0799664033eb0717abb028d3924
|
f898bb2d27346f6257df1650a002ee929e66e7fa
|
refs/heads/master
| 2023-08-17T06:54:17.274650
| 2023-07-10T16:06:35
| 2023-07-10T16:06:35
| 55,073,371
| 168
| 15
| null | null | null | null |
UTF-8
|
C
| false
| false
| 1,554
|
c
|
access.c
|
/* Copyright (c) 2016, 2019, 2022 Dennis Wölfing
*
* 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.
*/
/* libc/src/unistd/access.c
* Checks accessibility of a file. (POSIX2008, called from C89)
*/
#define stat __stat
#include <errno.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/stat.h>
int __access(const char* path, int mode) {
struct stat st;
if (stat(path, &st) < 0) {
return -1;
}
bool accessible = true;
if (mode & R_OK) {
accessible &= !!(st.st_mode & (S_IRUSR | S_IRGRP | S_IROTH));
}
if (mode & W_OK) {
accessible &= !!(st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH));
}
if (mode & X_OK) {
accessible &= !!(st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH));
}
if (!accessible) {
errno = EACCES;
return -1;
}
return 0;
}
__weak_alias(__access, access);
|
ebebde530ff0c3ab0dfba3fe047692b5fae0a1db
|
5eff7a36d9a9917dce9111f0c3074375fe6f7656
|
/lib/mesa/src/intel/vulkan/grl/include/affinespace.h
|
36ebae0ede62662a0c7d6c9d4fa78023913d009d
|
[] |
no_license
|
openbsd/xenocara
|
cb392d02ebba06f6ff7d826fd8a89aa3b8401779
|
a012b5de33ea0b977095d77316a521195b26cc6b
|
refs/heads/master
| 2023-08-25T12:16:58.862008
| 2023-08-12T16:16:25
| 2023-08-12T16:16:25
| 66,967,384
| 177
| 66
| null | 2023-07-22T18:12:37
| 2016-08-30T18:36:01
|
C
|
UTF-8
|
C
| false
| false
| 5,391
|
h
|
affinespace.h
|
//
// Copyright (C) 2009-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT
//
//
#pragma once
#include "GRLRTASCommon.h"
GRL_NAMESPACE_BEGIN(GRL)
GRL_NAMESPACE_BEGIN(RTAS)
inline float3 GRL_OVERLOADABLE cross(const float3 a, const float3 b)
{
float3 res = { a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x };
return res;
}
struct LinearSpace3f
{
float3 vx;
float3 vy;
float3 vz;
};
/* compute the determinant of the matrix */
GRL_INLINE struct LinearSpace3f LinearSpace3f_Constructor(const float3 vx, const float3 vy, const float3 vz)
{
struct LinearSpace3f xfm;
xfm.vx = vx;
xfm.vy = vy;
xfm.vz = vz;
return xfm;
}
/* compute the determinant of the matrix */
GRL_INLINE float LinearSpace3f_det(struct LinearSpace3f xfm)
{
return dot(xfm.vx, cross(xfm.vy, xfm.vz));
}
/* compute transposed matrix */
GRL_INLINE struct LinearSpace3f LinearSpace3f_transpose(struct LinearSpace3f in)
{
float3 x = { in.vx.x, in.vy.x, in.vz.x };
float3 y = { in.vx.y, in.vy.y, in.vz.y };
float3 z = { in.vx.z, in.vy.z, in.vz.z };
return LinearSpace3f_Constructor(x,
y,
z);
}
/* compute adjoint matrix */
GRL_INLINE const struct LinearSpace3f LinearSpace3f_adjoint(struct LinearSpace3f in)
{
return LinearSpace3f_transpose(LinearSpace3f_Constructor(cross(in.vy, in.vz),
cross(in.vz, in.vx),
cross(in.vx, in.vy)));
}
/* compute inverse matrix */
GRL_INLINE struct LinearSpace3f LinearSpace3f_invert(struct LinearSpace3f in)
{
const float det = LinearSpace3f_det(in);
const struct LinearSpace3f adj = LinearSpace3f_adjoint(in);
return LinearSpace3f_Constructor(adj.vx / det, adj.vy / det, adj.vz / det);
}
GRL_INLINE float3 GRL_OVERLOADABLE xfmPoint(struct LinearSpace3f xfm, float3 p)
{
return xfm.vx * p.x + xfm.vy * p.y + xfm.vz * p.z;
}
struct AffineSpace3f
{
struct LinearSpace3f l;
float3 p;
};
GRL_INLINE struct AffineSpace3f AffineSpace3f_Constructor(struct LinearSpace3f l, float3 p)
{
struct AffineSpace3f out;
out.l = l;
out.p = p;
return out;
}
GRL_INLINE struct AffineSpace3f AffineSpace3f_load_row_major(const float *in)
{
struct AffineSpace3f out;
out.l.vx.x = in[0];
out.l.vx.y = in[4];
out.l.vx.z = in[8];
out.l.vy.x = in[1];
out.l.vy.y = in[5];
out.l.vy.z = in[9];
out.l.vz.x = in[2];
out.l.vz.y = in[6];
out.l.vz.z = in[10];
out.p.x = in[3];
out.p.y = in[7];
out.p.z = in[11];
return out;
}
// squared proportion of oriented transformed cube to aa box that would contain it.
// the smaller it is the more overhead transformation produces
GRL_INLINE
float transformation_bbox_surf_overhead(const float* Transform)
{
// We use an abs-matrix to transform the AABB extent vector, which is enough to compute the area
// New AABB is center +- Extent.
//
// For derivation see:
// https://zeux.io/2010/10/17/aabb-from-obb-with-component-wise-abs/
//
// take the cube of side 1 and see how big aabb containing it transformed is vs just surface of transformed
float ex = fabs(Transform[0]) + fabs(Transform[1]) + fabs(Transform[2]);
float ey = fabs(Transform[4]) + fabs(Transform[5]) + fabs(Transform[6]);
float ez = fabs(Transform[8]) + fabs(Transform[9]) + fabs(Transform[10]);
// we will compare squared sizes
ex = ex * ex;
ey = ey * ey;
ez = ez * ez;
// surface of aabb containing oriented box;
float aabb_sq_half_surf = ex * ey + ey * ez + ez * ex;
// ^2 lengths of transformed <1,0,0>, <0,1,0>, <0,0,1>
float obx = Transform[0] * Transform[0] + Transform[4] * Transform[4] + Transform[8] * Transform[8];
float oby = Transform[1] * Transform[1] + Transform[5] * Transform[5] + Transform[9] * Transform[9];
float obz = Transform[2] * Transform[2] + Transform[6] * Transform[6] + Transform[10] * Transform[10];
float obb_sq_half_surf = obx * oby + oby * obz + obz * obx;
return obb_sq_half_surf / aabb_sq_half_surf;
// ex = 2.0
// ey = 2.0
// ez = 2.0
// ex = 4.0
// ey = 4.0
// ez = 4.0
// aabb_half_surf = 16+16 *2.0 + 2.0*2.0+ 2.0*2.0; = 12;
// aabb_sq_half_surf = 144;
//
// obx = 4.0;
// oby = 4.0;
// obz = 4.0;
// obb_sq_half_surf = 16 + 16+ 16;
// obb_sq_half_surf = 16.0 *3 = 48
}
GRL_INLINE void load_row_major_from_AffineSpace3f(struct AffineSpace3f in, float* out)
{
out[0] = in.l.vx.x;
out[4] = in.l.vx.y;
out[8] = in.l.vx.z;
out[1] = in.l.vy.x;
out[5] = in.l.vy.y;
out[9] = in.l.vy.z;
out[2] = in.l.vz.x;
out[6] = in.l.vz.y;
out[10] = in.l.vz.z;
out[3] = in.p.x;
out[7] = in.p.y;
out[11] = in.p.z;
}
GRL_INLINE float3 GRL_OVERLOADABLE xfmPoint(struct AffineSpace3f xfm, float3 p)
{
return xfmPoint(xfm.l, p) + xfm.p;
}
/* compute inverse matrix */
GRL_INLINE struct AffineSpace3f AffineSpace3f_invert(struct AffineSpace3f in)
{
const struct LinearSpace3f il = LinearSpace3f_invert(in.l);
float3 ip = -xfmPoint(il, in.p);
return AffineSpace3f_Constructor(il, ip);
}
GRL_NAMESPACE_END(RTAS)
GRL_NAMESPACE_END(GRL)
|
a77f102a36c5de858eede7a19df5f8213a634016
|
e93097f04bb3e49c1c6b326ccf91a59ab2a158e7
|
/petlib/_cffi_src/openssl/openssl_v1_1.c
|
a36bc0f79dd3d0a59fa8c075554ac3fc497b9140
|
[
"BSD-2-Clause"
] |
permissive
|
gdanezis/petlib
|
ce7a4a241e3a72492cfe4af8a5406c5ecd71a62a
|
7aafddb46f5e643c0a1addb1067acc3dc74ce59d
|
refs/heads/master
| 2022-11-06T04:28:44.094953
| 2021-05-11T13:58:48
| 2021-05-11T13:58:48
| 27,001,491
| 123
| 41
|
BSD-2-Clause
| 2022-01-25T12:30:56
| 2014-11-22T14:37:53
|
Python
|
UTF-8
|
C
| false
| false
| 1,435
|
c
|
openssl_v1_1.c
|
#include <openssl/err.h>
#include <openssl/bn.h>
#include <openssl/ec.h>
#include <openssl/evp.h>
#include <openssl/hmac.h>
#include <openssl/ecdsa.h>
#include <openssl/ssl.h>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <openssl/crypto.h>
#include <openssl/conf.h>
#include <openssl/opensslv.h>
#include <pythread.h>
#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
int bn_num_bytes(BIGNUM * a){
return BN_num_bytes(a);
}
int bn_is_odd(BIGNUM * a){
return BN_is_odd(a);
}
void init_ciphers(void){
OPENSSL_config(NULL);
}
void cleanup_ciphers(void){
/* Removes all digests and ciphers */
EVP_cleanup();
/* if you omit the next, a small leak may be left when you make use of the BIO (low level API) for e.g. base64 transformations */
CRYPTO_cleanup_all_ex_data();
/* Remove error strings */
}
/* This line is borrowed from pyca/cryptography.
https://github.com/pyca/cryptography/commit/bc1667791eedfe9d77d56dd9014e26481f571ff5
*/
int (*setup_ssl_threads)(void) = NULL;
/* Version of ECDSA_SIG_set0 that does not take ownership
* of passed variables r and s. */
int ECDSA_SIG_set0_petlib(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) {
BIGNUM *rnew = BN_new();
BIGNUM *snew = BN_new();
BN_copy(rnew, r);
BN_copy(snew, s);
return ECDSA_SIG_set0(sig, rnew, snew);
// NOTE: new values rnew, snew not freed because signature
// takes ownership.
}
|
598a4407fb006c95281563658115fdf45b00a6cd
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/os/board/imxrt1050-evk/include/board.h
|
e17b0735bb2e0d7d90fd30c233c156371943c31c
|
[
"Apache-2.0",
"GPL-1.0-or-later",
"BSD-3-Clause",
"ISC",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 9,958
|
h
|
board.h
|
/* ****************************************************************
*
* Copyright 2019 NXP Semiconductors 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.
*
******************************************************************/
/************************************************************************************
* os/configs/imxrt1050/include/board.h
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <[email protected]>
*
* 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 TinyARA nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
#ifndef __CONFIGS_IMXRT1050_EVK_INCLUDE_BOARD_H
#define __CONFIGS_IMXRT1050_EVK_INCLUDE_BOARD_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <tinyara/config.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Clocking *************************************************************************/
/* Set VDD_SOC to 1.5V */
#define IMXRT_VDD_SOC (0x12)
/* Set Arm PLL (PLL1) to fOut = (24Mhz * ARM_PLL_DIV_SELECT/2) / ARM_PODF_DIVISOR
* 600Mhz = (24Mhz * ARM_PLL_DIV_SELECT/2) / ARM_PODF_DIVISOR
* ARM_PLL_DIV_SELECT = 100
* ARM_PODF_DIVISOR = 2
* 600Mhz = (24Mhz * 100/2) / 2
*
* AHB_CLOCK_ROOT = PLL1fOut / IMXRT_AHB_PODF_DIVIDER
* 1Hz to 600 Mhz = 600Mhz / IMXRT_ARM_CLOCK_DIVIDER
* IMXRT_ARM_CLOCK_DIVIDER = 1
* 600Mhz = 600Mhz / 1
*
* PRE_PERIPH_CLK_SEL = PRE_PERIPH_CLK_SEL_PLL1
* PERIPH_CLK_SEL = 1 (0 select PERIPH_CLK2_PODF, 1 select PRE_PERIPH_CLK_SEL_PLL1)
* PERIPH_CLK = 600Mhz
*
* IPG_CLOCK_ROOT = AHB_CLOCK_ROOT / IMXRT_IPG_PODF_DIVIDER
* IMXRT_IPG_PODF_DIVIDER = 4
* 150Mhz = 600Mhz / 4
*
* PRECLK_CLOCK_ROOT = IPG_CLOCK_ROOT / IMXRT_PERCLK_PODF_DIVIDER
* IMXRT_PERCLK_PODF_DIVIDER = 1
* 150Mhz = 150Mhz / 1
*
* SEMC_CLK_ROOT = 600Mhz / IMXRT_SEMC_PODF_DIVIDER (labeled AIX_PODF in 18.2)
* IMXRT_SEMC_PODF_DIVIDER = 8
* 75Mhz = 600Mhz / 8
*
* Set Sys PLL (PLL2) to fOut = (24Mhz * (20+(2*(DIV_SELECT)))
* 528Mhz = (24Mhz * (20+(2*(1)))
*
* Set USB1 PLL (PLL3) to fOut = (24Mhz * 20)
* 480Mhz = (24Mhz * 20)
*/
#define BOARD_XTAL_FREQUENCY 24000000
#define IMXRT_PRE_PERIPH_CLK_SEL CCM_CBCMR_PRE_PERIPH_CLK_SEL_PLL1
#define IMXRT_PERIPH_CLK_SEL CCM_CBCDR_PERIPH_CLK_SEL_PRE_PERIPH
#define IMXRT_ARM_PLL_DIV_SELECT 100
#define IMXRT_ARM_PODF_DIVIDER 2
#define IMXRT_AHB_PODF_DIVIDER 1
#define IMXRT_IPG_PODF_DIVIDER 4
#define IMXRT_PERCLK_CLK_SEL CCM_CSCMR1_PERCLK_CLK_SEL_IPG_CLK_ROOT
#define IMXRT_PERCLK_PODF_DIVIDER 9
#define IMXRT_SEMC_PODF_DIVIDER 8
#define IMXRT_LPSPI_CLK_SELECT CCM_CBCMR_LPSPI_CLK_SEL_PLL3_PFD0
#define IMXRT_LSPI_PODF_DIVIDER 8
#define IMXRT_USDHC1_CLK_SELECT CCM_CSCMR1_USDHC1_CLK_SEL_PLL2_PFD0
#define IMXRT_USDHC1_PODF_DIVIDER 2
#define IMXRT_SYS_PLL_SELECT CCM_ANALOG_PLL_SYS_DIV_SELECT_22
#define BOARD_CPU_FREQUENCY \
(BOARD_XTAL_FREQUENCY * (IMXRT_ARM_PLL_DIV_SELECT / 2)) / IMXRT_ARM_PODF_DIVIDER
/* LED definitions ******************************************************************/
/* There are four LED status indicators located on the EVK Board. The functions of
* these LEDs include:
*
* - Main Power Supply(D3)
* Green: DC 5V main supply is normal.
* Red: J2 input voltage is over 5.6V.
* Off: The board is not powered.
* - Reset RED LED(D15)
* - OpenSDA LED(D16)
* - USER LED(D18)
*
* Only a single LED, D18, is under software control.
*/
/* LED index values for use with board_userled() */
#define BOARD_USERLED 0
#define BOARD_NLEDS 1
/* LED bits for use with board_userled_all() */
#define BOARD_USERLED_BIT (1 << BOARD_USERLED)
/* This LED is not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/imxrt_autoleds.c. The LED is used to encode
* OS-related events as follows:
*
* -------------------- ----------------------------- ------
* SYMBOL Meaning LED
* -------------------- ----------------------------- ------ */
#define LED_STARTED 0 /* TinyARA has been started OFF */
#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF */
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF */
#define LED_STACKCREATED 1 /* Idle stack created ON */
#define LED_INIRQ 2 /* In an interrupt N/C */
#define LED_SIGNAL 2 /* In a signal handler N/C */
#define LED_ASSERTION 2 /* An assertion failed N/C */
#define LED_PANIC 3 /* The system has crashed FLASH */
#undef LED_IDLE /* Not used */
/* Thus if the LED is statically on, TinyARA has successfully booted and is,
* apparently, running normally. If the LED is flashing at approximately
* 2Hz, then a fatal error has been detected and the system has halted.
*/
/* Button definitions ***************************************************************/
/* The IMXRT board has one external user button
*
* 1. SW8 (IRQ88) GPIO5-00
*/
#define BUTTON_SW8 0
#define BUTTON_SW8_BIT (1 << BUTTON_SW8)
/* PIO Disambiguation ***************************************************************/
/* LPUARTs
*
* Virtual console port provided by OpenSDA:
*
* UART1_TXD GPIO_AD_B0_12 LPUART1_TX
* UART1_RXD GPIO_AD_B0_13 LPUART1_RX
*
* NOTE: There are no alternative pin configurations for LPUART1.
*
* Arduino RS-232 Shield:
*
* J22 D0 UART_RX/D0 GPIO_AD_B1_07 LPUART3_RX
* J22 D1 UART_TX/D1 GPIO_AD_B1_06 LPUART3_TX
*/
#define GPIO_LPUART3_RX GPIO_LPUART3_RX_1 /* GPIO_AD_B1_07 */
#define GPIO_LPUART3_TX GPIO_LPUART3_TX_1 /* GPIO_AD_B1_06 */
/* LPI2Cs
*
* Arduino Connector
*
* J23 A4 A4/ADC4/SDA GPIO_AD_B1_01 LPI2C1_SDA
* J23 A5 A5/ADC5/SCL GPIO_AD_B1_00 LPI2C1_SCL
*/
#define GPIO_LPI2C1_SDA GPIO_LPI2C1_SDA_2 /* GPIO_AD_B1_01 */
#define GPIO_LPI2C1_SCL GPIO_LPI2C1_SCL_2 /* GPIO_AD_B1_00 */
#define GPIO_LPI2C2_SDA GPIO_LPI2C2_SDA_2 /* GPIO_AD_B1_01 */
#define GPIO_LPI2C2_SCL GPIO_LPI2C2_SCL_2 /* GPIO_AD_B1_00 */
#define GPIO_LPI2C3_SDA GPIO_LPI2C3_SDA_2 /* GPIO_AD_B1_01 */
#define GPIO_LPI2C3_SCL GPIO_LPI2C3_SCL_2 /* GPIO_AD_B1_00 */
#define GPIO_LPI2C4_SDA GPIO_LPI2C4_SDA_2 /* GPIO_AD_B1_01 */
#define GPIO_LPI2C4_SCL GPIO_LPI2C4_SCL_2 /* GPIO_AD_B1_00 */
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Functions
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_IMXRT1050_EVK_INCLUDE_BOARD_H */
|
4e170a411644088515dd2ccacdbe2c9d5a65b421
|
6d54a7b26d0eb82152a549a6a9dfde656687752c
|
/src/crypto/tests/DerSigConversion_test_vectors.h
|
533a1a25f1ccf9d0041a175ced21c8a13639f1d0
|
[
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
project-chip/connectedhomeip
|
81a123d675cf527773f70047d1ed1c43be5ffe6d
|
ea3970a7f11cd227ac55917edaa835a2a9bc4fc8
|
refs/heads/master
| 2023-09-01T11:43:37.546040
| 2023-09-01T08:01:32
| 2023-09-01T08:01:32
| 244,694,174
| 6,409
| 1,789
|
Apache-2.0
| 2023-09-14T20:56:31
| 2020-03-03T17:05:10
|
C++
|
UTF-8
|
C
| false
| false
| 13,449
|
h
|
DerSigConversion_test_vectors.h
|
/*
*
* Copyright (c) 2021 Project CHIP 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.
*/
/**
* @file - This file contains HMAC SHA256 test vectors.
*
* See https://tools.ietf.org/html/rfc4231#section-4.7
*/
#pragma once
#include <stddef.h>
#include <stdint.h>
typedef struct
{
const size_t fe_length_bytes;
const uint8_t * r;
const uint8_t * s;
const uint8_t * der_version;
const size_t der_version_length;
const uint8_t * raw_version;
const size_t raw_version_length;
} der_sig_conv_vector;
// CASE 1: MSB not set, all bytes non-zero
const uint8_t kDerSigConvRCase1[] = {
0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
};
const uint8_t kDerSigConvSCase1[] = {
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
};
const uint8_t kDerSigConvRawCase1[] = {
0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
};
const uint8_t kDerSigConvDerCase1[] = {
0x30, 0x44, 0x02, 0x20, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
0x02, 0x20, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
};
static const der_sig_conv_vector kDerSigConvVect1 = { .fe_length_bytes = 32u,
.r = kDerSigConvRCase1,
.s = kDerSigConvSCase1,
.der_version = kDerSigConvDerCase1,
.der_version_length = sizeof(kDerSigConvDerCase1),
.raw_version = kDerSigConvRawCase1,
.raw_version_length = sizeof(kDerSigConvRawCase1) };
// CASE 2: MSB not set, first 16 bytes zero
const uint8_t kDerSigConvRCase2[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
};
const uint8_t kDerSigConvSCase2[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
};
const uint8_t kDerSigConvRawCase2[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
};
const uint8_t kDerSigConvDerCase2[] = {
0x30, 0x26, 0x02, 0x11, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x02, 0x11, 0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
};
static const der_sig_conv_vector kDerSigConvVect2 = { .fe_length_bytes = 32u,
.r = kDerSigConvRCase2,
.s = kDerSigConvSCase2,
.der_version = kDerSigConvDerCase2,
.der_version_length = sizeof(kDerSigConvDerCase2),
.raw_version = kDerSigConvRawCase2,
.raw_version_length = sizeof(kDerSigConvRawCase2) };
// CASE 3: MSB set, full width value (worst case for 256 bit ECDSA)
const uint8_t kDerSigConvRCase3[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
const uint8_t kDerSigConvSCase3[] = {
0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
};
const uint8_t kDerSigConvRawCase3[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
};
const uint8_t kDerSigConvDerCase3[] = {
0x30, 0x46, 0x02, 0x21, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x02, 0x21, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
};
static const der_sig_conv_vector kDerSigConvVect3 = { .fe_length_bytes = 32u,
.r = kDerSigConvRCase3,
.s = kDerSigConvSCase3,
.der_version = kDerSigConvDerCase3,
.der_version_length = sizeof(kDerSigConvDerCase3),
.raw_version = kDerSigConvRawCase3,
.raw_version_length = sizeof(kDerSigConvRawCase3) };
// CASE 4: MSB set, full width value (worst case for 512 bit ECDSA, using 2 bytes length for sequence)
// Overhead here is the max
const uint8_t kDerSigConvRCase4[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
const uint8_t kDerSigConvSCase4[] = {
0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
};
const uint8_t kDerSigConvRawCase4[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
};
const uint8_t kDerSigConvDerCase4[] = {
0x30, 0x81, 0x86, 0x02, 0x41, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x41, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
};
static const der_sig_conv_vector kDerSigConvVect4 = { .fe_length_bytes = 64u,
.r = kDerSigConvRCase4,
.s = kDerSigConvSCase4,
.der_version = kDerSigConvDerCase4,
.der_version_length = sizeof(kDerSigConvDerCase4),
.raw_version = kDerSigConvRawCase4,
.raw_version_length = sizeof(kDerSigConvRawCase4) };
// CASE 5: All zeroes
const uint8_t kDerSigConvRCase5[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const uint8_t kDerSigConvSCase5[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const uint8_t kDerSigConvRawCase5[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const uint8_t kDerSigConvDerCase5[] = {
0x30, 0x06, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00,
};
static const der_sig_conv_vector kDerSigConvVect5 = { .fe_length_bytes = 64u,
.r = kDerSigConvRCase5,
.s = kDerSigConvSCase5,
.der_version = kDerSigConvDerCase5,
.der_version_length = sizeof(kDerSigConvDerCase5),
.raw_version = kDerSigConvRawCase5,
.raw_version_length = sizeof(kDerSigConvRawCase5) };
static const der_sig_conv_vector kDerSigConvTestVectors[] = { kDerSigConvVect1, kDerSigConvVect2, kDerSigConvVect3,
kDerSigConvVect4, kDerSigConvVect5 };
|
d97ce2a5747e874bf2705877bdedbcdcd412be0e
|
8886361e436c7598419f444a52ae587bf94b1fbe
|
/contrib/bitshuffle_neon/Test/bitshuffle_bitunshuffle_test1.c
|
18e6361d97946ab3c2e753e85341e693844ab1ef
|
[
"BSD-3-Clause"
] |
permissive
|
Blosc/c-blosc2
|
d4b69bf735e1440ea1d7e147f434b488f975c8d4
|
6bbade9e13bd166ea0189f8c3b6253c9bbe9bb54
|
refs/heads/main
| 2023-08-31T15:47:35.224132
| 2023-08-31T03:01:37
| 2023-08-31T06:01:40
| 40,355,993
| 358
| 85
|
NOASSERTION
| 2023-09-12T09:26:36
| 2015-08-07T10:51:35
|
C
|
UTF-8
|
C
| false
| false
| 6,974
|
c
|
bitshuffle_bitunshuffle_test1.c
|
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <arm_neon.h>
#include <assert.h>
#define CHECK_MULT_EIGHT(n) if (n % 8) exit(0);
static void printmem8(uint8x8_t buf)
{
printf("%x,%x,%x,%x,%x,%x,%x,%x\n",
buf[7], buf[6], buf[5], buf[4],
buf[3], buf[2], buf[1], buf[0]);
}
static void printmem16(uint8x16_t r0)
{
uint8_t buf[16];
((uint8x16_t *)buf)[0] = r0;
printf("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\n",
buf[15], buf[14], buf[13], buf[12],
buf[11], buf[10], buf[9], buf[8],
buf[7], buf[6], buf[5], buf[4],
buf[3], buf[2], buf[1], buf[0]);
}
static void printmem(uint8_t* buf)
{
printf("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,"
"%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\n",
buf[31], buf[30], buf[29], buf[28],
buf[27], buf[26], buf[25], buf[24],
buf[23], buf[22], buf[21], buf[20],
buf[19], buf[18], buf[17], buf[16],
buf[15], buf[14], buf[13], buf[12],
buf[11], buf[10], buf[9], buf[8],
buf[7], buf[6], buf[5], buf[4],
buf[3], buf[2], buf[1], buf[0]);
}
/* Routine optimized for bit-shuffling a buffer for a type size of 1 byte. */
static void
bitshuffle1_neon(const uint8_t* const src, uint8_t* dest, const size_t nbyte) {
const size_t elem_size = 1;
uint16x8_t x0;
size_t i, j, k;
const int8_t __attribute__ ((aligned (16))) xr[8] = {0,1,2,3,4,5,6,7};
uint8x8_t mask_and = vdup_n_u8(0x01);
int8x8_t mask_shift = vld1_s8(xr);
uint8x8_t lo_x, hi_x, lo, hi;
/* #define CHECK_MULT_EIGHT(n) if (n % 8) exit(0); */
CHECK_MULT_EIGHT(nbyte);
for (i = 0, k = 0; i < nbyte; i += 16, k++) {
/* Load 16-byte groups */
x0 = vld1q_u8(src + k*16);
/* Split in 8-bytes grops */
lo_x = vget_low_u8(x0);
hi_x = vget_high_u8(x0);
for (j = 0; j < 8; j++) {
/* Create mask from the most significant bit of each 8-bit element */
lo = vand_u8(lo_x, mask_and);
lo = vshl_u8(lo, mask_shift);
hi = vand_u8(hi_x, mask_and);
hi = vshl_u8(hi, mask_shift);
lo = vpadd_u8(lo,lo);
lo = vpadd_u8(lo,lo);
lo = vpadd_u8(lo,lo);
hi = vpadd_u8(hi,hi);
hi = vpadd_u8(hi,hi);
hi = vpadd_u8(hi,hi);
/* Shift packed 8-bit */
lo_x = vshr_n_u8(lo_x, 1);
hi_x = vshr_n_u8(hi_x, 1);
/* Store the created mask to the destination vector */
vst1_lane_u8(dest + 2*k + j*nbyte/(8*elem_size), lo, 0);
vst1_lane_u8(dest + 2*k+1 + j*nbyte/(8*elem_size), hi, 0);
}
}
}
/* Routine optimized for bit-unshuffling a buffer for a type size of 1 byte. */
static void
bitunshuffle1_neon(const uint8_t* const src, uint8_t* dest, const size_t nbyte) {
const size_t elem_size = 1;
uint8x8_t lo_x, hi_x, lo, hi;
size_t i, j, k;
const int8_t __attribute__ ((aligned (16))) xr[8] = {0,1,2,3,4,5,6,7};
uint8x8_t mask_and = vdup_n_u8(0x01);
int8x8_t mask_shift = vld1_s8(xr);
/* #define CHECK_MULT_EIGHT(n) if (n % 8) exit(0); */
CHECK_MULT_EIGHT(nbyte);
for (i = 0, k = 0; i < nbyte; i += 16, k++) {
for (j = 0; j < 8; j++) {
/* Load lanes */
lo_x[j] = src[2*k + j*nbyte/(8*elem_size)];
hi_x[j] = src[2*k+1 + j*nbyte/(8*elem_size)];
}
for (j = 0; j < 8; j++) {
/* Create mask from the most significant bit of each 8-bit element */
lo = vand_u8(lo_x, mask_and);
lo = vshl_u8(lo, mask_shift);
hi = vand_u8(hi_x, mask_and);
hi = vshl_u8(hi, mask_shift);
lo = vpadd_u8(lo,lo);
lo = vpadd_u8(lo,lo);
lo = vpadd_u8(lo,lo);
hi = vpadd_u8(hi,hi);
hi = vpadd_u8(hi,hi);
hi = vpadd_u8(hi,hi);
/* Shift packed 8-bit */
lo_x = vshr_n_u8(lo_x, 1);
hi_x = vshr_n_u8(hi_x, 1);
/* Store the created mask to the destination vector */
vst1_lane_u8(dest + j + i, lo, 0);
vst1_lane_u8(dest + 8*elem_size + j + i, hi, 0);
}
}
}
void main()
{
uint8_t *src = "\xcb\xff\xf1\x79\x24\x7c\xb1\x58\x69\xd2\xee\xdd\x99\x9a\x7a\x86"
"\x45\x3e\x5f\xdf\xa2\x43\x41\x25\x77\xae\xfd\x22\x19\x1a\x38\x2b"
"\x56\x93\xab\xc3\x61\xa8\x7d\xfc\xbb\x98\xf6\xd1\x29\xce\xe7\x58"
"\x73\x4c\xd3\x12\x3f\xcf\x46\x94\xba\xfa\x49\x83\x71\x1e\x35\x5f"
"\xbc\x2d\x3f\x7c\xf8\xb4\xb9\xa8\xc9\x9f\x8d\x9d\x11\xc4\xc3\x23"
"\x44\x3a\x11\x4f\xf2\x41\x31\xb8\x19\xbe\xad\x72\xdc\x3a\xbc\x34"
"\x53\xa7\xc6\xb3\x71\xc8\x83\x27\xb3\x45\x82\xd8\x95\x9e\x71\x92"
"\x88\x4f\xdd\x66\xbf\xc5\xd6\x42\x33\x18\x33\xf7\xaf\xab\x42\x47"
"\xcb\xff\xf1\x79\x24\x7c\xb1\x58\x69\xd2\xee\xdd\x99\x9a\x7a\x86"
"\x45\x3e\x5f\xdf\xa2\x43\x41\x25\x77\xae\xfd\x22\x19\x1a\x38\x2b"
"\x56\x93\xab\xc3\x61\xa8\x7d\xfc\xbb\x98\xf6\xd1\x29\xce\xe7\x58"
"\x73\x4c\xd3\x12\x3f\xcf\x46\x94\xba\xfa\x49\x83\x71\x1e\x35\x5f"
"\xbc\x2d\x3f\x7c\xf8\xb4\xb9\xa8\xc9\x9f\x8d\x9d\x11\xc4\xc3\x23"
"\x44\x3a\x11\x4f\xf2\x41\x31\xb8\x19\xbe\xad\x72\xdc\x3a\xbc\x34"
"\x53\xa7\xc6\xb3\x71\xc8\x83\x27\xb3\x45\x82\xd8\x95\x9e\x71\x92"
"\x88\x4f\xdd\x66\xbf\xc5\xd6\x42\x33\x18\x33\xf7\xaf\xab\x42\x47"
"\xcb\xff\xf1\x79\x24\x7c\xb1\x58\x69\xd2\xee\xdd\x99\x9a\x7a\x86"
"\x45\x3e\x5f\xdf\xa2\x43\x41\x25\x77\xae\xfd\x22\x19\x1a\x38\x2b"
"\x56\x93\xab\xc3\x61\xa8\x7d\xfc\xbb\x98\xf6\xd1\x29\xce\xe7\x58"
"\x73\x4c\xd3\x12\x3f\xcf\x46\x94\xba\xfa\x49\x83\x71\x1e\x35\x5f"
"\xbc\x2d\x3f\x7c\xf8\xb4\xb9\xa8\xc9\x9f\x8d\x9d\x11\xc4\xc3\x23"
"\x44\x3a\x11\x4f\xf2\x41\x31\xb8\x19\xbe\xad\x72\xdc\x3a\xbc\x34"
"\x53\xa7\xc6\xb3\x71\xc8\x83\x27\xb3\x45\x82\xd8\x95\x9e\x71\x92"
"\x88\x4f\xdd\x66\xbf\xc5\xd6\x42\x33\x18\x33\xf7\xaf\xab\x42\x47"
"\xcb\xff\xf1\x79\x24\x7c\xb1\x58\x69\xd2\xee\xdd\x99\x9a\x7a\x86"
"\x45\x3e\x5f\xdf\xa2\x43\x41\x25\x77\xae\xfd\x22\x19\x1a\x38\x2b"
"\x56\x93\xab\xc3\x61\xa8\x7d\xfc\xbb\x98\xf6\xd1\x29\xce\xe7\x58"
"\x73\x4c\xd3\x12\x3f\xcf\x46\x94\xba\xfa\x49\x83\x71\x1e\x35\x5f"
"\xbc\x2d\x3f\x7c\xf8\xb4\xb9\xa8\xc9\x9f\x8d\x9d\x11\xc4\xc3\x23"
"\x44\x3a\x11\x4f\xf2\x41\x31\xb8\x19\xbe\xad\x72\xdc\x3a\xbc\x34"
"\x53\xa7\xc6\xb3\x71\xc8\x83\x27\xb3\x45\x82\xd8\x95\x9e\x71\x92"
"\x88\x4f\xdd\x66\xbf\xc5\xd6\x42\x33\x18\x33\xf7\xaf\xab\x42\x47";
size_t i;
uint8_t *dest1 = calloc(512,1);
uint8_t *dest2 = calloc(512,1);
size_t size = 512;
bitshuffle1_neon(src, dest1, size);
bitunshuffle1_neon(dest1, dest2, size);
for (i = 0; i < 256; i++) {
assert(dest2[i] == src[i]);
}
free(dest1);
free(dest2);
}
|
ce7670099550e7d74891da27071f9915c853c438
|
765f7b8c2caf2d50da8f431f1332207456ba33ee
|
/libc/ctype/isalnum.c
|
4ccb614ae49178562069a8e2dff09f6c6182546d
|
[
"BSD-3-Clause",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-commercial-license",
"AGPL-3.0-or-later",
"GPL-1.0-or-later",
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
klange/toaruos
|
a840f8d46993dc7a8850f82b6d04ba0c2af276a9
|
4a31a09ba27904b42ee35e8fb1a3c7f87669a2ef
|
refs/heads/master
| 2023-09-01T02:00:53.151334
| 2023-08-28T00:59:18
| 2023-08-28T00:59:18
| 1,259,258
| 5,557
| 613
|
NCSA
| 2023-02-04T08:24:11
| 2011-01-16T00:59:27
|
C
|
UTF-8
|
C
| false
| false
| 80
|
c
|
isalnum.c
|
#include <ctype.h>
int isalnum(int c) {
return isalpha(c) || isdigit(c);
}
|
10082ff3e194521f4bf38635c74de8b45462dbf9
|
fbe68d84e97262d6d26dd65c704a7b50af2b3943
|
/third_party/virtualbox/src/VBox/Devices/EFI/Firmware/BaseTools/Source/C/GnuGenBootSector/GnuGenBootSector.c
|
851dede51672907c9c768caa5c418add0cfdaf19
|
[
"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",
"BSD-2-Clause"
] |
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
| 11,039
|
c
|
GnuGenBootSector.c
|
/** @file
Reading/writing MBR/DBR.
NOTE:
If we write MBR to disk, we just update the MBR code and the partition table wouldn't be over written.
If we process DBR, we will patch MBR to set first partition active if no active partition exists.
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "CommonLib.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <Common/UefiBaseTypes.h>
#include "ParseInf.h"
#include "EfiUtilityMsgs.h"
//
// Utility Name
//
#define UTILITY_NAME "GnuGenBootSector"
//
// Utility version information
//
#define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 1
#define MAX_DRIVE 26
#define PARTITION_TABLE_OFFSET 0x1BE
#define SIZE_OF_PARTITION_ENTRY 0x10
#define PARTITION_ENTRY_STARTLBA_OFFSET 8
#define PARTITION_ENTRY_NUM 4
#define DRIVE_UNKNOWN 0
#define DRIVE_NO_ROOT_DIR 1
#define DRIVE_REMOVABLE 2
#define DRIVE_FIXED 3
#define DRIVE_REMOTE 4
#define DRIVE_CDROM 5
#define DRIVE_RAMDISK 6
typedef struct _DRIVE_TYPE_DESC {
UINTN Type;
CHAR8 *Description;
} DRIVE_TYPE_DESC;
#define DRIVE_TYPE_ITEM(x) {x, #x}
DRIVE_TYPE_DESC DriveTypeDesc[] = {
DRIVE_TYPE_ITEM (DRIVE_UNKNOWN),
DRIVE_TYPE_ITEM (DRIVE_NO_ROOT_DIR),
DRIVE_TYPE_ITEM (DRIVE_REMOVABLE),
DRIVE_TYPE_ITEM (DRIVE_FIXED),
DRIVE_TYPE_ITEM (DRIVE_REMOTE),
DRIVE_TYPE_ITEM (DRIVE_CDROM),
DRIVE_TYPE_ITEM (DRIVE_RAMDISK),
{(UINTN) -1, NULL}
};
typedef struct _DRIVE_INFO {
CHAR8 VolumeLetter;
DRIVE_TYPE_DESC *DriveType;
UINTN DiskNumber;
} DRIVE_INFO;
typedef enum {
PathUnknown,
PathFile,
PathFloppy,
PathUsb,
PathIde
} PATH_TYPE;
typedef struct _PATH_INFO {
CHAR8 *Path;
CHAR8 PhysicalPath[260];
PATH_TYPE Type;
BOOLEAN Input;
} PATH_INFO;
typedef enum {
ErrorSuccess,
ErrorFileCreate,
ErrorFileReadWrite,
ErrorNoMbr,
ErrorFatType,
ErrorPath,
} ERROR_STATUS;
CHAR8 *ErrorStatusDesc[] = {
"Success",
"Failed to create files",
"Failed to read/write files",
"No MBR exists",
"Failed to detect Fat type",
"Inavlid path"
};
//UnSupported Windows API functions.
UINTN GetLogicalDrives(void) { return 1; }
/**
Get path information, including physical path for Linux platform.
@param PathInfo Point to PATH_INFO structure.
@return whether path is valid.
**/
ERROR_STATUS
GetPathInfo (
PATH_INFO *PathInfo
)
{
FILE *f;
if (strncmp(PathInfo->Path, "/dev/", 5) == 0) {
//
// Process disk path here.
//
// Process floppy disk
if (PathInfo->Path[5] == 'f' && PathInfo->Path[6] == 'd' && PathInfo->Path[8] == '\0') {
PathInfo->Type = PathFloppy;
strcpy (PathInfo->PhysicalPath, PathInfo->Path);
return ErrorSuccess;
} else {
// Other disk types is not supported yet.
fprintf (stderr, "ERROR: It's not a floppy disk!\n");
return ErrorPath;
}
// Try to open the device.
f = fopen (LongFilePath (PathInfo->Path),"r");
if (f == NULL) {
printf ("error :open device failed!\n");
return ErrorPath;
}
fclose (f);
return ErrorSuccess;
}
// Process file path here.
PathInfo->Type = PathFile;
if (PathInfo->Input) {
// If path is file path, check whether file is valid.
printf("Path = %s\n",PathInfo->Path);
f = fopen (LongFilePath (PathInfo->Path), "r");
if (f == NULL) {
fprintf (stderr, "Test error E2003: File was not provided!\n");
return ErrorPath;
}
fclose (f);
}
strcpy(PathInfo->PhysicalPath, PathInfo->Path);
return ErrorSuccess;
}
VOID
ListDrive (
VOID
)
{
printf("-l or -list not supported!\n");
}
/**
Writing or reading boot sector or MBR according to the argument.
@param InputInfo PATH_INFO instance for input path
@param OutputInfo PATH_INFO instance for output path
@param ProcessMbr TRUE is to process MBR, otherwise, processing boot sector
@return ERROR_STATUS
**/
ERROR_STATUS
ProcessBsOrMbr (
PATH_INFO *InputInfo,
PATH_INFO *OutputInfo,
BOOLEAN ProcessMbr
)
{
CHAR8 FirstSector[0x200] = {0};
CHAR8 FirstSectorBackup[0x200] = {0};
FILE *InputFile;
FILE *OutputFile;
InputFile = fopen (LongFilePath (InputInfo->PhysicalPath), "r");
if (InputFile == NULL) {
return ErrorFileReadWrite;
}
if (0x200 != fread(FirstSector, 1, 0x200, InputFile)) {
fclose(InputFile);
return ErrorFileReadWrite;
}
fclose(InputFile);
//Not support USB and IDE.
if (InputInfo->Type == PathUsb) {
printf("USB has not been supported yet!");
return ErrorSuccess;
}
if (InputInfo->Type == PathIde) {
printf("IDE has not been supported yet!");
return ErrorSuccess;
}
//Process Floppy Disk
OutputFile = fopen (LongFilePath (OutputInfo->PhysicalPath), "r+");
if (OutputFile == NULL) {
OutputFile = fopen (LongFilePath (OutputInfo->PhysicalPath), "w");
if (OutputFile == NULL) {
return ErrorFileReadWrite;
}
}
if (OutputInfo->Type != PathFile) {
if (ProcessMbr) {
//
// Use original partition table
//
if (0x200 != fread (FirstSectorBackup, 1, 0x200, OutputFile)) {
fclose(OutputFile);
return ErrorFileReadWrite;
}
memcpy (FirstSector + 0x1BE, FirstSectorBackup + 0x1BE, 0x40);
}
}
if(0x200 != fwrite(FirstSector, 1, 0x200, OutputFile)) {
fclose(OutputFile);
return ErrorFileReadWrite;
}
fclose(OutputFile);
return ErrorSuccess;
}
/**
Displays the standard utility information to SDTOUT
**/
VOID
Version (
VOID
)
{
printf ("%s v%d.%d %s-Utility to retrieve and update the boot sector or MBR.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
printf ("Copyright (c) 2007-2014 Intel Corporation. All rights reserved.\n");
}
VOID
PrintUsage (
VOID
)
{
Version();
printf ("\nUsage: \n\
GenBootSector\n\
[-l, --list list disks]\n\
[-i, --input Filename]\n\
[-o, --output Filename]\n\
[-m, --mbr process the MBR also]\n\
[-v, --verbose]\n\
[--version]\n\
[-q, --quiet disable all messages except fatal errors]\n\
[-d, --debug[#]\n\
[-h, --help]\n");
}
int
main (
int argc,
char *argv[]
)
{
INTN Index;
BOOLEAN ProcessMbr;
ERROR_STATUS Status;
EFI_STATUS EfiStatus;
PATH_INFO InputPathInfo;
PATH_INFO OutputPathInfo;
UINT64 LogLevel;
SetUtilityName (UTILITY_NAME);
ZeroMem(&InputPathInfo, sizeof(PATH_INFO));
ZeroMem(&OutputPathInfo, sizeof(PATH_INFO));
argv ++;
argc --;
ProcessMbr = FALSE;
if (argc == 0) {
PrintUsage();
return 0;
}
//
// Parse command line
//
for (Index = 0; Index < argc; Index ++) {
if ((stricmp (argv[Index], "-l") == 0) || (stricmp (argv[Index], "--list") == 0)) {
ListDrive ();
return 0;
}
if ((stricmp (argv[Index], "-m") == 0) || (stricmp (argv[Index], "--mbr") == 0)) {
ProcessMbr = TRUE;
continue;
}
if ((stricmp (argv[Index], "-i") == 0) || (stricmp (argv[Index], "--input") == 0)) {
InputPathInfo.Path = argv[Index + 1];
InputPathInfo.Input = TRUE;
if (InputPathInfo.Path == NULL) {
Error (NULL, 0, 1003, "Invalid option value", "Input file name can't be NULL");
return 1;
}
if (InputPathInfo.Path[0] == '-') {
Error (NULL, 0, 1003, "Invalid option value", "Input file is missing");
return 1;
}
++Index;
continue;
}
if ((stricmp (argv[Index], "-o") == 0) || (stricmp (argv[Index], "--output") == 0)) {
OutputPathInfo.Path = argv[Index + 1];
OutputPathInfo.Input = FALSE;
if (OutputPathInfo.Path == NULL) {
Error (NULL, 0, 1003, "Invalid option value", "Output file name can't be NULL");
return 1;
}
if (OutputPathInfo.Path[0] == '-') {
Error (NULL, 0, 1003, "Invalid option value", "Output file is missing");
return 1;
}
++Index;
continue;
}
if ((stricmp (argv[Index], "-h") == 0) || (stricmp (argv[Index], "--help") == 0)) {
PrintUsage ();
return 0;
}
if (stricmp (argv[Index], "--version") == 0) {
Version ();
return 0;
}
if ((stricmp (argv[Index], "-v") == 0) || (stricmp (argv[Index], "--verbose") == 0)) {
continue;
}
if ((stricmp (argv[Index], "-q") == 0) || (stricmp (argv[Index], "--quiet") == 0)) {
continue;
}
if ((stricmp (argv[Index], "-d") == 0) || (stricmp (argv[Index], "--debug") == 0)) {
EfiStatus = AsciiStringToUint64 (argv[Index + 1], FALSE, &LogLevel);
if (EFI_ERROR (EfiStatus)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[Index], argv[Index + 1]);
return 1;
}
if (LogLevel > 9) {
Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", (int) LogLevel);
return 1;
}
SetPrintLevel (LogLevel);
DebugMsg (NULL, 0, 9, "Debug Mode Set", "Debug Output Mode Level %s is set!", argv[Index + 1]);
++Index;
continue;
}
//
// Don't recognize the parameter.
//
Error (NULL, 0, 1000, "Unknown option", "%s", argv[Index]);
return 1;
}
if (InputPathInfo.Path == NULL) {
Error (NULL, 0, 1001, "Missing options", "Input file is missing");
return 1;
}
if (OutputPathInfo.Path == NULL) {
Error (NULL, 0, 1001, "Missing options", "Output file is missing");
return 1;
}
if (GetPathInfo(&InputPathInfo) != ErrorSuccess) {
Error (NULL, 0, 1003, "Invalid option value", "Input file can't be found.");
return 1;
}
if (GetPathInfo(&OutputPathInfo) != ErrorSuccess) {
Error (NULL, 0, 1003, "Invalid option value", "Output file can't be found.");
return 1;
}
//
// Process DBR (Patch or Read)
//
Status = ProcessBsOrMbr (&InputPathInfo, &OutputPathInfo, ProcessMbr);
if (Status == ErrorSuccess) {
fprintf (
stdout,
"%s %s: successful!\n",
(OutputPathInfo.Type != PathFile) ? "Write" : "Read",
ProcessMbr ? "MBR" : "DBR"
);
return 0;
} else {
fprintf (
stderr,
"%s: %s %s: failed - %s (LastError: 0x%x)!\n",
(Status == ErrorNoMbr) ? "WARNING" : "ERROR",
(OutputPathInfo.Type != PathFile) ? "Write" : "Read",
ProcessMbr ? "MBR" : "DBR",
ErrorStatusDesc[Status],
errno
);
return 1;
}
}
|
cd19d0c75fc3cc57a0a0dc25e3af4c00f8f26ec5
|
e1d9c54e9925e30e388a255b53a93cccad0b94cb
|
/kubernetes/model/v1_rolling_update_deployment.c
|
f149ba5dbb1ea86852f49981dc798f9a6c98a452
|
[
"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
| 3,980
|
c
|
v1_rolling_update_deployment.c
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "v1_rolling_update_deployment.h"
v1_rolling_update_deployment_t *v1_rolling_update_deployment_create(
int_or_string_t *max_surge,
int_or_string_t *max_unavailable
) {
v1_rolling_update_deployment_t *v1_rolling_update_deployment_local_var = malloc(sizeof(v1_rolling_update_deployment_t));
if (!v1_rolling_update_deployment_local_var) {
return NULL;
}
v1_rolling_update_deployment_local_var->max_surge = max_surge;
v1_rolling_update_deployment_local_var->max_unavailable = max_unavailable;
return v1_rolling_update_deployment_local_var;
}
void v1_rolling_update_deployment_free(v1_rolling_update_deployment_t *v1_rolling_update_deployment) {
if(NULL == v1_rolling_update_deployment){
return ;
}
listEntry_t *listEntry;
if (v1_rolling_update_deployment->max_surge) {
int_or_string_free(v1_rolling_update_deployment->max_surge);
v1_rolling_update_deployment->max_surge = NULL;
}
if (v1_rolling_update_deployment->max_unavailable) {
int_or_string_free(v1_rolling_update_deployment->max_unavailable);
v1_rolling_update_deployment->max_unavailable = NULL;
}
free(v1_rolling_update_deployment);
}
cJSON *v1_rolling_update_deployment_convertToJSON(v1_rolling_update_deployment_t *v1_rolling_update_deployment) {
cJSON *item = cJSON_CreateObject();
// v1_rolling_update_deployment->max_surge
if(v1_rolling_update_deployment->max_surge) {
cJSON *max_surge_local_JSON = int_or_string_convertToJSON(v1_rolling_update_deployment->max_surge);
if(max_surge_local_JSON == NULL) {
goto fail; // custom
}
cJSON_AddItemToObject(item, "maxSurge", max_surge_local_JSON);
if(item->child == NULL) {
goto fail;
}
}
// v1_rolling_update_deployment->max_unavailable
if(v1_rolling_update_deployment->max_unavailable) {
cJSON *max_unavailable_local_JSON = int_or_string_convertToJSON(v1_rolling_update_deployment->max_unavailable);
if(max_unavailable_local_JSON == NULL) {
goto fail; // custom
}
cJSON_AddItemToObject(item, "maxUnavailable", max_unavailable_local_JSON);
if(item->child == NULL) {
goto fail;
}
}
return item;
fail:
if (item) {
cJSON_Delete(item);
}
return NULL;
}
v1_rolling_update_deployment_t *v1_rolling_update_deployment_parseFromJSON(cJSON *v1_rolling_update_deploymentJSON){
v1_rolling_update_deployment_t *v1_rolling_update_deployment_local_var = NULL;
// define the local variable for v1_rolling_update_deployment->max_surge
int_or_string_t *max_surge_local_nonprim = NULL;
// define the local variable for v1_rolling_update_deployment->max_unavailable
int_or_string_t *max_unavailable_local_nonprim = NULL;
// v1_rolling_update_deployment->max_surge
cJSON *max_surge = cJSON_GetObjectItemCaseSensitive(v1_rolling_update_deploymentJSON, "maxSurge");
if (max_surge) {
max_surge_local_nonprim = int_or_string_parseFromJSON(max_surge); //custom
}
// v1_rolling_update_deployment->max_unavailable
cJSON *max_unavailable = cJSON_GetObjectItemCaseSensitive(v1_rolling_update_deploymentJSON, "maxUnavailable");
if (max_unavailable) {
max_unavailable_local_nonprim = int_or_string_parseFromJSON(max_unavailable); //custom
}
v1_rolling_update_deployment_local_var = v1_rolling_update_deployment_create (
max_surge ? max_surge_local_nonprim : NULL,
max_unavailable ? max_unavailable_local_nonprim : NULL
);
return v1_rolling_update_deployment_local_var;
end:
if (max_surge_local_nonprim) {
int_or_string_free(max_surge_local_nonprim);
max_surge_local_nonprim = NULL;
}
if (max_unavailable_local_nonprim) {
int_or_string_free(max_unavailable_local_nonprim);
max_unavailable_local_nonprim = NULL;
}
return NULL;
}
|
2160113ba6387fd897e185b3b9a41311a0cc9814
|
84db8126dfb48122083521bbdeda9fe761f12271
|
/win_utils.c
|
b0ae67faf15cf5a1bb44ad8ab69b085af89a61a6
|
[
"0BSD",
"LicenseRef-scancode-other-permissive"
] |
permissive
|
rhash/RHash
|
b45d064f7d61631b4f716e93c74b8773191eea0c
|
ee1cf8ce8c1a67ca07fabfba6ba3d6c0909b5fed
|
refs/heads/master
| 2023-09-03T18:13:07.107328
| 2023-08-27T21:34:51
| 2023-08-27T21:34:51
| 1,882,998
| 514
| 127
|
0BSD
| 2023-07-12T23:50:04
| 2011-06-12T00:16:27
|
C
|
UTF-8
|
C
| false
| false
| 18,818
|
c
|
win_utils.c
|
/* win_utils.c - utility functions for Windows and CygWin */
#if defined(_WIN32) || defined(__CYGWIN__)
/* Fix #138: require to use MSVCRT implementation of *printf functions */
#define __USE_MINGW_ANSI_STDIO 0
#include "win_utils.h"
#include <windows.h>
/**
* Set process priority and affinity to use any CPU but the first one,
* this improves benchmark results on a multi-core systems.
*/
void set_benchmark_cpu_affinity(void)
{
DWORD_PTR dwProcessMask, dwSysMask, dwDesired;
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
if ( GetProcessAffinityMask(GetCurrentProcess(), &dwProcessMask, &dwSysMask) ) {
dwDesired = dwSysMask & (dwProcessMask & ~1); /* remove the first processor */
dwDesired = (dwDesired ? dwDesired : dwSysMask & ~1);
if (dwDesired != 0) {
SetProcessAffinityMask(GetCurrentProcess(), dwDesired);
}
}
}
#ifdef _WIN32
/* Windows-only (non-CygWin) functions */
#include "file.h"
#include "parse_cmdline.h"
#include <share.h> /* for _SH_DENYWR */
#include <fcntl.h> /* for _O_RDONLY, _O_BINARY */
#include <io.h> /* for isatty */
#include <assert.h>
#include <errno.h>
#include <locale.h>
/* QuickFix for broken output, caused by libintl fwprintf and vfwprintf */
#ifdef fwprintf
# undef fwprintf
#endif
#ifdef vfwprintf
# undef vfwprintf
#endif
struct console_data_t
{
unsigned console_flags;
unsigned saved_cursor_size;
unsigned primary_codepage;
unsigned secondary_codepage;
wchar_t format_buffer[4096];
wchar_t printf_result[65536];
wchar_t program_dir[32768];
};
struct console_data_t console_data;
/**
* Convert a c-string as wide character string using given codepage
* and print it to the given buffer.
*
* @param str the string to convert
* @param codepage the codepage to use
* @param buffer buffer to print the string to
* @param buf_size buffer size in bytes
* @return converted string on success, NULL on fail with error code stored in errno
*/
static wchar_t* cstr_to_wchar_buffer(const char* str, int codepage, wchar_t* buffer, size_t buf_size)
{
if (MultiByteToWideChar(codepage, 0, str, -1, buffer, buf_size / sizeof(wchar_t)) != 0)
return buffer;
set_errno_from_last_file_error();
return NULL; /* conversion failed */
}
/**
* Convert a c-string to wide character string using given codepage.
* The result is allocated with malloc and must be freed by caller.
*
* @param str the string to convert
* @param codepage the codepage to use
* @param exact_conversion non-zero to require exact encoding conversion, 0 otherwise
* @return converted string on success, NULL on fail with error code stored in errno
*/
static wchar_t* cstr_to_wchar(const char* str, int codepage, int exact_conversion)
{
DWORD flags = (exact_conversion ? MB_ERR_INVALID_CHARS : 0);
int size = MultiByteToWideChar(codepage, flags, str, -1, NULL, 0);
if (size != 0) {
wchar_t* buf = (wchar_t*)rsh_malloc(size * sizeof(wchar_t));
if (MultiByteToWideChar(codepage, flags, str, -1, buf, size) != 0)
return buf;
}
set_errno_from_last_file_error();
return NULL; /* conversion failed */
}
/**
* Convert a wide character string to c-string using given codepage.
* The result is allocated with malloc and must be freed by caller.
*
* @param wstr the wide string to convert
* @param codepage the codepage to use
* @param exact_conversion non-zero to require exact encoding conversion, 0 otherwise
* @return converted string on success, NULL on fail with error code stored in errno
*/
static char* wchar_to_cstr(const wchar_t* wstr, int codepage, int exact_conversion)
{
int size;
BOOL bUsedDefChar = FALSE;
BOOL* lpUsedDefaultChar = (exact_conversion && codepage != CP_UTF8 ? &bUsedDefChar : NULL);
if (codepage == -1) {
codepage = (opt.flags & OPT_UTF8 ? CP_UTF8 : (opt.flags & OPT_ENC_DOS) ? CP_OEMCP : CP_ACP);
}
size = WideCharToMultiByte(codepage, 0, wstr, -1, NULL, 0, 0, NULL);
/* size=0 is returned only on fail, cause even an empty string requires buffer size=1 */
if (size != 0) {
char* buf = (char*)rsh_malloc(size);
if (WideCharToMultiByte(codepage, 0, wstr, -1, buf, size, 0, lpUsedDefaultChar) != 0) {
if (!bUsedDefChar)
return buf;
free(buf);
errno = EILSEQ;
return NULL;
}
free(buf);
}
set_errno_from_last_file_error();
return NULL;
}
/**
* Convert c-string to wide string using encoding and transformation specified by flags.
* The result is allocated with malloc and must be freed by caller.
*
* @param str the C-string to convert
* @param flags bit-mask containing the following bits: ConvertToPrimaryEncoding, ConvertToSecondaryEncoding,
* ConvertToUtf8, ConvertToNative, ConvertPath, ConvertExact
* @return converted wide string on success, NULL on fail with error code stored in errno
*/
wchar_t* convert_str_to_wcs(const char* str, unsigned flags)
{
int is_utf8 = flags & (opt.flags & OPT_UTF8 ? (ConvertToUtf8 | ConvertToPrimaryEncoding) : (ConvertToUtf8 | ConvertToSecondaryEncoding));
int codepage = (is_utf8 ? CP_UTF8 : (opt.flags & OPT_ENC_DOS) ? CP_OEMCP : CP_ACP);
wchar_t* wstr = cstr_to_wchar(str, codepage, (flags & ConvertExact));
if (wstr && (flags & ConvertPath)) {
wchar_t* long_path = get_long_path_if_needed(wstr);
if (long_path) {
free(wstr);
return long_path;
}
}
return wstr;
}
/**
* Convert wide string to c-string using encoding and transformation specified by flags.
*
* @param str the C-string to convert
* @param flags bit-mask containing the following bits: ConvertToPrimaryEncoding, ConvertToSecondaryEncoding,
* ConvertToUtf8, ConvertToNative, ConvertPath, ConvertExact
* @return converted wide string on success, NULL on fail with error code stored in errno
*/
char* convert_wcs_to_str(const wchar_t* wstr, unsigned flags)
{
int is_utf8 = flags & (opt.flags & OPT_UTF8 ? (ConvertToUtf8 | ConvertToPrimaryEncoding) : (ConvertToUtf8 | ConvertToSecondaryEncoding));
int codepage = (is_utf8 ? CP_UTF8 : (opt.flags & OPT_ENC_DOS) ? CP_OEMCP : CP_ACP);
/* skip path UNC prefix, if found */
if ((flags & ConvertPath) && IS_UNC_PREFIX(wstr))
wstr += UNC_PREFIX_SIZE;
return wchar_to_cstr(wstr, codepage, (flags & ConvertExact));
}
/**
* Convert c-string encoding, the encoding is specified by flags.
*
* @param str the C-string to convert
* @param flags bit-mask containing the following bits: ConvertToUtf8, ConvertToNative, ConvertExact
* @return converted wide string on success, NULL on fail with error code stored in errno
*/
char* convert_str_encoding(const char* str, unsigned flags)
{
int convert_from = (flags & ConvertToUtf8 ? ConvertNativeToWcs : ConvertUtf8ToWcs) | (flags & ConvertExact);
wchar_t* wstr;
assert((flags & ~(ConvertToUtf8 | ConvertToNative | ConvertExact)) == 0); /* disallow invalid flags */
if ((flags & (ConvertToUtf8 | ConvertToNative)) == 0) {
errno = EINVAL;
return NULL; /* error: no conversion needed */
}
wstr = convert_str_to_wcs(str, convert_from);
if (wstr) {
char* res = convert_wcs_to_str(wstr, flags);
free(wstr);
return res;
}
return NULL;
}
/**
* Allocate a wide string containing long file path with UNC prefix,
* if it is needed to access the path, otherwise return NULL.
*
* @param wpath original file path, can be a relative one
* @return allocated long file path if it is needed to access
* the path, NULL otherwise
*/
wchar_t* get_long_path_if_needed(const wchar_t* wpath)
{
size_t length;
size_t index;
size_t spaces_count = 0;
if (IS_UNC_PREFIX(wpath))
return NULL;
length = wcslen(wpath);
/* Do not end a file or directory name with a space or a period on Windows.
See https://learn.microsoft.com/en-gb/windows/win32/fileio/naming-a-file */
for (index = length; index > 0 && wpath[index - 1] == ' '; --index, ++spaces_count);
if (length > 200 || spaces_count > 0) {
/* get required buffer size, including the terminating null character */
DWORD size = GetFullPathNameW(wpath, 0, NULL, NULL);
if (size > 0) {
size_t buffer_size = (size + spaces_count + UNC_PREFIX_SIZE) * sizeof(wchar_t);
wchar_t* result = (wchar_t*)rsh_malloc(buffer_size);
wcscpy(result, L"\\\\?\\");
/* get path length without the terminating null character */
size = GetFullPathNameW(wpath, size, result + UNC_PREFIX_SIZE, NULL);
if (size > 0) {
if (spaces_count > 0)
wcscpy(result + UNC_PREFIX_SIZE + size, wpath + index);
return result;
}
free(result);
}
}
return NULL;
}
/* the range of error codes for access errors */
#define MIN_EACCES_RANGE ERROR_WRITE_PROTECT
#define MAX_EACCES_RANGE ERROR_SHARING_BUFFER_EXCEEDED
/**
* Convert the GetLastError() value to errno-compatible code.
*
* @return errno-compatible error code
*/
static int convert_last_error_to_errno(void)
{
DWORD error_code = GetLastError();
switch (error_code)
{
case NO_ERROR:
return 0;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
case ERROR_INVALID_DRIVE:
case ERROR_INVALID_NAME:
case ERROR_BAD_NETPATH:
case ERROR_BAD_PATHNAME:
case ERROR_FILENAME_EXCED_RANGE:
return ENOENT;
case ERROR_TOO_MANY_OPEN_FILES:
return EMFILE;
case ERROR_ACCESS_DENIED:
case ERROR_SHARING_VIOLATION:
return EACCES;
case ERROR_NETWORK_ACCESS_DENIED:
case ERROR_FAIL_I24:
case ERROR_SEEK_ON_DEVICE:
return EACCES;
case ERROR_LOCK_VIOLATION:
case ERROR_DRIVE_LOCKED:
case ERROR_NOT_LOCKED:
case ERROR_LOCK_FAILED:
return EACCES;
case ERROR_INVALID_HANDLE:
return EBADF;
case ERROR_NOT_ENOUGH_MEMORY:
case ERROR_INVALID_BLOCK:
case ERROR_NOT_ENOUGH_QUOTA:
case ERROR_INSUFFICIENT_BUFFER:
return ENOMEM;
case ERROR_INVALID_ACCESS:
case ERROR_INVALID_DATA:
case ERROR_INVALID_PARAMETER:
case ERROR_INVALID_FLAGS:
return EINVAL;
case ERROR_BROKEN_PIPE:
case ERROR_NO_DATA:
return EPIPE;
case ERROR_DISK_FULL:
return ENOSPC;
case ERROR_ALREADY_EXISTS:
return EEXIST;
case ERROR_NESTING_NOT_ALLOWED:
return EAGAIN;
case ERROR_NO_UNICODE_TRANSLATION:
return EILSEQ;
}
/* try to detect error by range */
if (MIN_EACCES_RANGE <= error_code && error_code <= MAX_EACCES_RANGE) {
return EACCES;
} else {
return EINVAL;
}
}
/**
* Assign errno to the error value converted from the GetLastError().
*/
void set_errno_from_last_file_error(void)
{
errno = convert_last_error_to_errno();
}
/* functions to setup/restore console */
/**
* Restore console on program exit.
*/
static void restore_cursor(void)
{
CONSOLE_CURSOR_INFO cci;
HANDLE hOut = GetStdHandle(STD_ERROR_HANDLE);
if (hOut != INVALID_HANDLE_VALUE && console_data.saved_cursor_size) {
/* restore cursor size and visibility */
cci.dwSize = console_data.saved_cursor_size;
cci.bVisible = 1;
SetConsoleCursorInfo(hOut, &cci);
}
}
/**
* Hide console cursor.
*/
void hide_cursor(void)
{
CONSOLE_CURSOR_INFO cci;
HANDLE hOut = GetStdHandle(STD_ERROR_HANDLE);
if (hOut != INVALID_HANDLE_VALUE && GetConsoleCursorInfo(hOut, &cci))
{
/* store current cursor size and visibility flag */
console_data.saved_cursor_size = (cci.bVisible ? cci.dwSize : 0);
/* now hide cursor */
cci.bVisible = 0;
SetConsoleCursorInfo(hOut, &cci); /* hide cursor */
rsh_install_exit_handler(restore_cursor);
}
}
/**
* Prepare console on program initialization: change console font codepage
* according to program options and hide cursor.
*/
void setup_console(void)
{
/* the default encoding is UTF-8 */
if ((opt.flags & OPT_ENCODING) == 0)
opt.flags |= OPT_UTF8;
console_data.console_flags = 0;
console_data.saved_cursor_size = 0;
console_data.primary_codepage = (opt.flags & OPT_UTF8 ? CP_UTF8 : (opt.flags & OPT_ENC_DOS) ? CP_OEMCP : CP_ACP);
console_data.secondary_codepage = (!(opt.flags & OPT_UTF8) ? CP_UTF8 : (opt.flags & OPT_ENC_DOS) ? CP_OEMCP : CP_ACP);
/* note: we are using numbers 1 = _fileno(stdout), 2 = _fileno(stderr) */
/* cause _fileno() is undefined, when compiling as strict ansi C. */
if (isatty(1))
console_data.console_flags |= 1;
if (isatty(2))
console_data.console_flags |= 2;
if ((opt.flags & OPT_UTF8) != 0)
{
if (console_data.console_flags & 1)
_setmode(1, _O_U8TEXT);
if (console_data.console_flags & 2)
_setmode(2, _O_U8TEXT);
#ifdef USE_GETTEXT
bind_textdomain_codeset(TEXT_DOMAIN, "utf-8");
#endif /* USE_GETTEXT */
}
else
{
setlocale(LC_CTYPE, opt.flags & OPT_ENC_DOS ? ".OCP" : ".ACP");
}
}
wchar_t* get_program_dir(void)
{
return console_data.program_dir;
}
/**
* Check if the given stream is connected to console.
*
* @param stream the stream to check
* @return 1 if the stream is connected to console, 0 otherwise
*/
int win_is_console_stream(FILE* stream)
{
return ((stream == stdout && (console_data.console_flags & 1))
|| (stream == stderr && (console_data.console_flags & 2)));
}
/**
* Detect the program directory.
*/
void init_program_dir(void)
{
DWORD buf_size = sizeof(console_data.program_dir) / sizeof(console_data.program_dir[0]);
DWORD length;
length = GetModuleFileNameW(NULL, console_data.program_dir, buf_size);
if (length == 0 || length >= buf_size) {
console_data.program_dir[0] = 0;
return;
}
/* remove trailng file name with the last path separator */
for (; length > 0 && !IS_PATH_SEPARATOR_W(console_data.program_dir[length]); length--);
for (; length > 0 && IS_PATH_SEPARATOR_W(console_data.program_dir[length]); length--);
console_data.program_dir[length + 1] = 0;
}
#ifdef USE_GETTEXT
/**
* Check that the path points to an existing directory.
*
* @param path the path to check
* @return 1 if the argument is a directory, 0 otherwise
*/
static int is_directory(const char* path)
{
DWORD res = GetFileAttributesA(path);
return (res != INVALID_FILE_ATTRIBUTES &&
!!(res & FILE_ATTRIBUTE_DIRECTORY));
}
/**
* Set the locale directory relative to ${PROGRAM_DIR}/locale.
*/
void setup_locale_dir(void)
{
wchar_t* short_dir;
char* program_dir = NULL;
char* locale_dir;
DWORD buf_size;
DWORD res;
if (!console_data.program_dir[0]) return;
buf_size = GetShortPathNameW(console_data.program_dir, NULL, 0);
if (!buf_size) return;
short_dir = (wchar_t*)rsh_malloc(sizeof(wchar_t) * buf_size);
res = GetShortPathNameW(console_data.program_dir, short_dir, buf_size);
if (res > 0 && res < buf_size)
program_dir = convert_wcs_to_str(short_dir, ConvertToPrimaryEncoding);
free(short_dir);
if (!program_dir) return;
locale_dir = make_path(program_dir, "locale", 0);
free(program_dir);
if (!locale_dir) return;
if (is_directory(locale_dir))
bindtextdomain(TEXT_DOMAIN, locale_dir);
free(locale_dir);
}
#endif /* USE_GETTEXT */
#define USE_CSTR_ARGS 0
#define USE_WSTR_ARGS 1
/**
* Print formatted data to the specified file descriptor,
* handling proper printing UTF-8 strings to Windows console.
*
* @param out file descriptor
* @param format data format string
* @param str_type wide/c-string type of string arguments
* @param args list of arguments
* @return the number of characters printed, -1 on error
*/
static int win_vfprintf_encoded(FILE* out, const char* format, int str_type, va_list args)
{
int res;
if (!win_is_console_stream(out)) {
return vfprintf(out, (format ? format : "%s"), args);
} else if (str_type == USE_CSTR_ARGS) {
/* thread-unsafe code: using a static buffer */
static char buffer[8192];
res = vsnprintf(buffer, sizeof(buffer) - 1, format, args);
if (res >= 0) {
wchar_t *wstr = cstr_to_wchar_buffer(buffer, console_data.primary_codepage, console_data.printf_result, sizeof(console_data.printf_result));
res = (wstr ? fwprintf(out, L"%s", wstr) : -1);
}
} else {
wchar_t* wformat = (!format || (format[0] == '%' && format[1] == 's' && !format[2]) ? L"%s" :
cstr_to_wchar_buffer(format, console_data.primary_codepage, console_data.format_buffer, sizeof(console_data.format_buffer)));
res = vfwprintf(out, (wformat ? wformat : L"[UTF8 conversion error]\n"), args);
assert(str_type == USE_WSTR_ARGS);
}
/* fix: win7 incorrectly sets _IOERR(=0x20) flag of the stream for UTF-8 encoding, so clear it */
if (res >= 0)
clearerr(out);
return res;
}
/**
* Print formatted data to the specified file descriptor,
* handling proper printing UTF-8 strings to Windows console.
*
* @param out file descriptor
* @param format data format string
* @param args list of arguments
* @return the number of characters printed, -1 on error
*/
int win_vfprintf(FILE* out, const char* format, va_list args)
{
return win_vfprintf_encoded(out, format, USE_CSTR_ARGS, args);
}
/**
* Print formatted data to the specified file descriptor,
* handling proper printing UTF-8 strings to Windows console.
*
* @param out file descriptor
* @param format data format string
* @return the number of characters printed, -1 on error
*/
int win_fprintf(FILE* out, const char* format, ...)
{
int res;
va_list args;
va_start(args, format);
res = win_vfprintf_encoded(out, format, USE_CSTR_ARGS, args);
va_end(args);
return res;
}
/**
* Print formatted data to the specified file descriptor,
* handling proper printing UTF-8 strings to Windows console.
*
* @param out file descriptor
* @param format data format string
* @return the number of characters printed, -1 on error
*/
int win_fprintf_warg(FILE* out, const char* format, ...)
{
int res;
va_list args;
va_start(args, format);
res = win_vfprintf_encoded(out, format, USE_WSTR_ARGS, args);
va_end(args);
return res;
}
/**
* Write a buffer to a stream.
*
* @param ptr pointer to the buffer to write
* @param size size of an items in the buffer
* @param count the number of items to write
* @param out the stream to write to
* @return the number of items written, -1 on error
*/
size_t win_fwrite(const void* ptr, size_t size, size_t count, FILE* out)
{
if (!win_is_console_stream(out))
return fwrite(ptr, size, count, out);
{
size_t i;
const char* buf = (const char*)ptr;
size *= count;
if (!size)
return 0;
for (i = 0; i < size && buf[i] > 0; i++);
if (i == size)
{
wchar_t* wstr = rsh_malloc(sizeof(wchar_t) * (size + 1));
int res;
for (i = 0; i < size; i++)
wstr[i] = (wchar_t)buf[i];
wstr[size] = L'\0';
res = fwprintf(out, L"%s", wstr);
free(wstr);
if (res < 0)
return res;
}
else
{
for (i = 0; (i + 8) <= size; i += 8)
if (fwprintf(out, L"%C%C%C%C%C%C%C%C", buf[i], buf[i + 1], buf[i + 2],
buf[i + 3], buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7]) < 0)
return -1;
for (; i < size; i++)
if (fwprintf(out, L"%C", buf[i]) < 0)
return -1;
}
/* fix: win7 incorrectly sets _IOERR(=0x20) flag of the stream for UTF-8 encoding, so clear it */
clearerr(out);
return count;
}
}
#endif /* _WIN32 */
#else
typedef int dummy_declaration_required_by_strict_iso_c;
#endif /* defined(_WIN32) || defined(__CYGWIN__) */
|
986fe8f11562f6579772157580e81e45eee79c12
|
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
|
/audio/s3mod/files/patch-main.h
|
048263ffdbde12db3b27834fb21dc509465a4e7a
|
[
"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
| 238
|
h
|
patch-main.h
|
--- main.h.orig 1995-10-21 06:56:32 UTC
+++ main.h
@@ -43,7 +43,7 @@ extern uint32 mixspeed;
void help(void);
void get_audio_device(void);
-void main(int argc, char **argv);
+int main(int argc, char **argv);
#endif /* _MAIN_H */
|
41854d8715afa31102eb2567f5aac0224d070576
|
3b955b6c1122d6caea1175b24bea7b22aa5b9069
|
/libs/libgsf/gsf.h
|
4d8197987e755014a195b664c07008507af698ab
|
[] |
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
| 382
|
h
|
gsf.h
|
#include "psftag.h"
#ifndef BYTE
typedef unsigned char BYTE;
#endif
extern void gsfDisplayError (char *, ...);
extern BOOL IsTagPresent (BYTE *);
extern BOOL IsValidGSF (BYTE *);
extern void setupSound(void);
extern int GSFRun(char *);
extern void GSFClose(void) ;
extern BOOL EmulationLoop(void);
extern void GSFSoundChannelsEnable(int channels,bool active);
|
c518fd427c78e71346f893f09ec523f52c8f3ff3
|
131b6d5381fc3bb4403682135b77f9bce91e79f1
|
/nx/include/switch/services/pgl.h
|
5b3a882481525bfde9b29895150ab9bdce0b3e57
|
[
"ISC"
] |
permissive
|
switchbrew/libnx
|
53deb695b9ee6f3981c559125e8fce3bce6852b7
|
4fcdb6eb34b20f1f65eb9791fe513a710a001bea
|
refs/heads/master
| 2023-08-28T17:00:22.025929
| 2023-08-11T04:11:38
| 2023-08-12T14:51:58
| 103,794,142
| 1,286
| 299
|
ISC
| 2023-09-09T12:08:36
| 2017-09-17T01:12:38
|
C
|
UTF-8
|
C
| false
| false
| 2,391
|
h
|
pgl.h
|
/**
* @file pgl.h
* @brief PGL service IPC wrapper.
* @author SciresM
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../sf/service.h"
#include "../sf/tipc.h"
#include "../services/ncm_types.h"
#include "../services/pm.h"
/// LaunchFlag
typedef enum {
PglLaunchFlag_None = 0,
PglLaunchFlag_EnableDetailedCrashReport = BIT(0),
PglLaunchFlag_EnableCrashReportScreenShotForProduction = BIT(1),
PglLaunchFlag_EnableCrashReportScreenShotForDevelop = BIT(2),
} PglLaunchFlag;
/// SnapShotDumpType
typedef enum {
PglSnapShotDumpType_None = 0,
PglSnapShotDumpType_Auto = 1,
PglSnapShotDumpType_Full = 2,
} PglSnapShotDumpType;
typedef struct {
u64 id; ///< Program Id
u32 version; ///< Version
u8 content_type; ///< NcmContentType
u8 id_offset; ///< Id Offset
u8 reserved_0E[2]; ///< Padding
} PglContentMetaInfo;
typedef union {
Service s;
TipcService t;
} PglEventObserver;
/// Initialize pgl.
Result pglInitialize(void);
/// Exit pgl.
void pglExit(void);
/// Gets the Service object for the actual pgl service session. Requires < 12.0.0
Service* pglGetServiceSessionCmif(void);
/// Gets the TipcService object for the actual pgl service session. Requires 12.0.0+
TipcService* pglGetServiceSessionTipc(void);
Result pglLaunchProgram(u64 *out_pid, const NcmProgramLocation *loc, u32 pm_launch_flags, u8 pgl_launch_flags);
Result pglTerminateProcess(u64 pid);
Result pglLaunchProgramFromHost(u64 *out_pid, const char *content_path, u32 pm_launch_flags);
Result pglGetHostContentMetaInfo(PglContentMetaInfo *out, const char *content_path);
Result pglGetApplicationProcessId(u64 *out);
Result pglBoostSystemMemoryResourceLimit(u64 size);
Result pglIsProcessTracked(bool *out, u64 pid);
Result pglEnableApplicationCrashReport(bool en);
Result pglIsApplicationCrashReportEnabled(bool *out);
Result pglEnableApplicationAllThreadDumpOnCrash(bool en);
Result pglTriggerApplicationSnapShotDumper(PglSnapShotDumpType dump_type, const char *arg);
Result pglGetEventObserver(PglEventObserver *out);
Result pglEventObserverGetProcessEvent(PglEventObserver *observer, Event *out);
Result pglEventObserverGetProcessEventInfo(PglEventObserver *observer, PmProcessEventInfo *out);
void pglEventObserverClose(PglEventObserver *observer);
|
dd67380ffb9a9f2b5014cc9f7b3768360acde96b
|
b8a833801aa3f3618a4a68c1936299f8bd270038
|
/src/utilities/fbcpl/stdafx.h
|
85c631f89f0d5185bb06b638dc19f26697c63ba1
|
[] |
no_license
|
FirebirdSQL/firebird
|
039a84a81ea089852ad36339e44256c85dbf5b10
|
1973d01f396196d18f284114bd2905ac4dcfeb94
|
refs/heads/master
| 2023-09-01T21:34:39.835826
| 2023-08-31T20:13:52
| 2023-08-31T20:13:52
| 54,005,538
| 1,192
| 303
| null | 2023-09-14T16:12:28
| 2016-03-16T06:10:37
|
C++
|
UTF-8
|
C
| false
| false
| 1,280
|
h
|
stdafx.h
|
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__A4777E9A_E00D_11D6_9193_0050564001ED__INCLUDED_)
#define AFX_STDAFX_H__A4777E9A_E00D_11D6_9193_0050564001ED__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#undef TRACE // TRACE is used by Firebird too.
#include "firebird.h"
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h>
#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#ifdef HAVE_PTHREAD_H
#include "fb_pthread.h"
#endif
#include "../ibase.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A4777E9A_E00D_11D6_9193_0050564001ED__INCLUDED_)
|
7c09cb99ddd367dc51397cbec3134d495acda737
|
e73547787354afd9b717ea57fe8dd0695d161821
|
/src/world/area_kkj/kkj_01/kkj_01_3_npc.c
|
7e7cdd3fb08c37291ef4e5d60081f6a887a28f68
|
[] |
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
| 15,512
|
c
|
kkj_01_3_npc.c
|
#include "kkj_01.h"
#include "world/common/npc/Toad_Wander.inc.c"
#include "world/common/npc/Toad_Patrol.inc.c"
#include "world/common/npc/Toad_Stationary.inc.c"
#include "world/common/npc/Dryite_Stationary.inc.c"
#include "world/common/npc/Mouser.inc.c"
#include "world/common/npc/Penguin.inc.c"
#include "world/common/npc/Koopa.inc.c"
EvtScript N(EVS_NpcIdle_Dryite) = {
EVT_LOOP(0)
EVT_CALL(GetSelfVar, 1, LVar0)
EVT_IF_EQ(LVar0, 0)
EVT_CALL(SetNpcAnimation, NPC_Dryite, ANIM_Dryite_Yellow_Talk)
EVT_CALL(SetSelfVar, 1, 1)
EVT_ELSE
EVT_CALL(SetNpcAnimation, NPC_Mouser, ANIM_Mouser_Blue_Talk)
EVT_CALL(SetSelfVar, 1, 0)
EVT_END_IF
EVT_CALL(RandInt, 60, LVar0)
EVT_ADD(LVar0, 30)
EVT_WAIT(LVar0)
EVT_CALL(SetNpcAnimation, NPC_Dryite, ANIM_Dryite_Yellow_Idle)
EVT_CALL(SetNpcAnimation, NPC_Mouser, ANIM_Mouser_Blue_Idle)
EVT_WAIT(10)
EVT_END_LOOP
EVT_END
};
EvtScript N(EVS_NpcIdle_MayorPenguin) = {
EVT_LOOP(0)
EVT_CALL(GetSelfVar, 1, LVar0)
EVT_IF_EQ(LVar0, 0)
EVT_CALL(SetNpcAnimation, NPC_MayorPenguin, ANIM_MayorPenguin_Talk)
EVT_CALL(SetSelfVar, 1, 1)
EVT_ELSE
EVT_CALL(SetNpcAnimation, NPC_Koopa, ANIM_Koopa_Talk)
EVT_CALL(SetSelfVar, 1, 0)
EVT_END_IF
EVT_CALL(RandInt, 60, LVar0)
EVT_ADD(LVar0, 30)
EVT_WAIT(LVar0)
EVT_CALL(SetNpcAnimation, NPC_MayorPenguin, ANIM_MayorPenguin_Idle)
EVT_CALL(SetNpcAnimation, NPC_Koopa, ANIM_Koopa_Idle)
EVT_WAIT(10)
EVT_END_LOOP
EVT_END
};
EvtScript N(EVS_NpcIdle_ToadMinister) = {
EVT_WAIT(30)
EVT_LOOP(0)
EVT_WAIT(150)
EVT_LOOP(2)
EVT_CALL(InterpNpcYaw, NPC_SELF, 90, 7)
EVT_WAIT(20)
EVT_CALL(InterpNpcYaw, NPC_SELF, 270, 7)
EVT_WAIT(20)
EVT_END_LOOP
EVT_END_LOOP
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcIdle_Toad_01) = {
EVT_LOOP(0)
EVT_WAIT(150)
EVT_LOOP(2)
EVT_CALL(InterpNpcYaw, NPC_SELF, 90, 7)
EVT_WAIT(15)
EVT_CALL(InterpNpcYaw, NPC_SELF, 270, 7)
EVT_WAIT(15)
EVT_END_LOOP
EVT_END_LOOP
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcIdle_ToadGuard_02) = {
EVT_IF_EQ(AF_KKJ_02, TRUE)
EVT_RETURN
EVT_END_IF
EVT_CALL(GetEntryID, LVar0)
EVT_IF_NE(LVar0, kkj_01_ENTRY_4)
EVT_RETURN
EVT_END_IF
EVT_CALL(WaitForPlayerInputEnabled)
EVT_CALL(DisablePlayerInput, TRUE)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_ToadGuard_Yellow_Talk, ANIM_ToadGuard_Yellow_Idle, 16, MSG_Intro_0042)
EVT_SET(AF_KKJ_02, TRUE)
EVT_CALL(DisablePlayerInput, FALSE)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_ToadMinister) = {
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_ToadMinister_Talk, ANIM_ToadMinister_Idle, 0, MSG_Intro_0033)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_Toad_01) = {
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_Toad_Blue_Talk, ANIM_Toad_Blue_Idle, 16, MSG_Intro_0038)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_Toad_02) = {
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_Toad_Green_Talk, ANIM_Toad_Green_Idle, 16, MSG_Intro_0039)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_Toad_03) = {
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_Toad_Red_Talk, ANIM_Toad_Red_Idle, 16, MSG_Intro_003A)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_Toadette) = {
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_Toadette_Orange_Talk, ANIM_Toadette_Orange_Idle, 16, MSG_Intro_003B)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_ToadGuard_01) = {
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_ToadGuard_Red_Talk, ANIM_ToadGuard_Red_Idle, 16, MSG_Intro_003C)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_ToadGuard_02) = {
EVT_CALL(GetSelfVar, 0, LVar0)
EVT_SWITCH(LVar0)
EVT_CASE_EQ(0)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_ToadGuard_Yellow_Talk, ANIM_ToadGuard_Yellow_Idle, 16, MSG_Intro_003D)
EVT_CASE_EQ(1)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_ToadGuard_Yellow_Talk, ANIM_ToadGuard_Yellow_Idle, 16, MSG_Intro_003E)
EVT_CASE_OR_EQ(2)
EVT_CASE_OR_EQ(3)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_ToadGuard_Yellow_Talk, ANIM_ToadGuard_Yellow_Idle, 16, MSG_Intro_003F)
EVT_END_CASE_GROUP
EVT_CASE_EQ(4)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_ToadGuard_Yellow_Talk, ANIM_ToadGuard_Yellow_Idle, 16, MSG_Intro_0040)
EVT_WAIT(10)
EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
EVT_CALL(SetNpcAnimation, NPC_ToadGuard_02, ANIM_ToadGuard_Yellow_Walk)
EVT_IF_GT(LVar0, 0)
EVT_SET(LVar3, -50)
EVT_ELSE
EVT_SET(LVar3, 50)
EVT_END_IF
EVT_CALL(SetNpcFlagBits, NPC_SELF, NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
EVT_CALL(SetNpcSpeed, NPC_SELF, EVT_FLOAT(2.0))
EVT_CALL(NpcMoveTo, NPC_SELF, LVar3, -245, 0)
EVT_CALL(SetNpcFlagBits, NPC_SELF, NPC_FLAG_IGNORE_PLAYER_COLLISION, FALSE)
EVT_CALL(SetNpcAnimation, NPC_ToadGuard_02, ANIM_ToadGuard_Yellow_Idle)
EVT_CALL(InterpNpcYaw, NPC_SELF, 180, 5)
EVT_SET(AF_KKJ_01, TRUE)
EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExitDoors_kkj_14_0)), TRIGGER_WALL_PRESS_A, COLLIDER_ttn2, 1, 0)
EVT_CASE_DEFAULT
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_ToadGuard_Yellow_Talk, ANIM_ToadGuard_Yellow_Idle, 16, MSG_Intro_0041)
EVT_END_SWITCH
EVT_ADD(LVar0, 1)
EVT_CALL(SetSelfVar, 0, LVar0)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_Dryite) = {
EVT_CALL(SetNpcAnimation, NPC_Mouser, ANIM_Mouser_Blue_Idle)
EVT_CALL(SetNpcAnimation, NPC_Dryite, ANIM_Dryite_Yellow_Idle)
EVT_WAIT(10)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_Dryite_Yellow_Talk, ANIM_Dryite_Yellow_Idle, 16, MSG_Intro_0034)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_Mouser) = {
EVT_CALL(EnableNpcAI, NPC_Dryite, FALSE)
EVT_CALL(SetNpcAnimation, NPC_Mouser, ANIM_Mouser_Blue_Idle)
EVT_CALL(SetNpcAnimation, NPC_Dryite, ANIM_Dryite_Yellow_Idle)
EVT_WAIT(10)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_Mouser_Blue_Talk, ANIM_Mouser_Blue_Idle, 16, MSG_Intro_0035)
EVT_CALL(EnableNpcAI, NPC_Dryite, TRUE)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_MayorPenguin) = {
EVT_CALL(SetNpcAnimation, NPC_MayorPenguin, ANIM_MayorPenguin_Idle)
EVT_CALL(SetNpcAnimation, NPC_Koopa, ANIM_Koopa_Idle)
EVT_WAIT(10)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_MayorPenguin_Talk, ANIM_MayorPenguin_Idle, 16, MSG_Intro_0036)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInteract_Koopa) = {
EVT_CALL(EnableNpcAI, NPC_MayorPenguin, FALSE)
EVT_CALL(SetNpcAnimation, NPC_MayorPenguin, ANIM_MayorPenguin_Idle)
EVT_CALL(SetNpcAnimation, NPC_Koopa, ANIM_Koopa_Idle)
EVT_WAIT(10)
EVT_CALL(SpeakToPlayer, NPC_SELF, ANIM_Koopa_Talk, ANIM_Koopa_Idle, 16, MSG_Intro_0037)
EVT_CALL(EnableNpcAI, NPC_MayorPenguin, TRUE)
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_ToadMinister) = {
EVT_CALL(BindNpcIdle, NPC_SELF, EVT_PTR(N(EVS_NpcIdle_ToadMinister)))
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_ToadMinister)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_Toad_01) = {
EVT_CALL(BindNpcIdle, NPC_SELF, EVT_PTR(N(EVS_NpcIdle_Toad_01)))
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_Toad_01)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_Toad_02) = {
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_Toad_02)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_Toad_03) = {
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_Toad_03)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_Toadette) = {
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_Toadette)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_ToadGuard_01) = {
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_ToadGuard_01)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_ToadGuard_02) = {
EVT_IF_EQ(AF_KKJ_01, TRUE)
EVT_CALL(SetNpcPos, NPC_SELF, -50, 0, -245)
EVT_CALL(SetSelfVar, 0, 5)
EVT_ELSE
EVT_CALL(SetNpcPos, NPC_SELF, 0, 0, -260)
EVT_END_IF
EVT_CALL(BindNpcIdle, NPC_SELF, EVT_PTR(N(EVS_NpcIdle_ToadGuard_02)))
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_ToadGuard_02)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_Dryite) = {
EVT_CALL(BindNpcIdle, NPC_SELF, EVT_PTR(N(EVS_NpcIdle_Dryite)))
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_Dryite)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_Mouser) = {
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_Mouser)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_MayorPenguin) = {
EVT_CALL(BindNpcIdle, NPC_SELF, EVT_PTR(N(EVS_NpcIdle_MayorPenguin)))
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_MayorPenguin)))
EVT_RETURN
EVT_END
};
EvtScript N(EVS_NpcInit_Koopa) = {
EVT_CALL(BindNpcInteract, NPC_SELF, EVT_PTR(N(EVS_NpcInteract_Koopa)))
EVT_RETURN
EVT_END
};
NpcData N(NpcData_ToadMinister)[] = {
{
.id = NPC_ToadMinister,
.pos = { 0.0f, 0.0f, 350.0f },
.yaw = 270,
.init = &N(EVS_NpcInit_ToadMinister),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Toad_Stationary),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING,
.animations = TOAD_MINISTER_ANIMS,
},
{
.id = NPC_Toad_01,
.pos = { 100.0f, 0.0f, 175.0f },
.yaw = 270,
.init = &N(EVS_NpcInit_Toad_01),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Toad_Stationary),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING,
.animations = TOAD_BLUE_ANIMS,
},
{
.id = NPC_Toad_02,
.pos = { 200.0f, 0.0f, 110.0f },
.yaw = 270,
.territory = {
.wander = {
.isFlying = TRUE,
.moveSpeedOverride = NO_OVERRIDE_MOVEMENT_SPEED,
.wanderShape = SHAPE_CYLINDER,
.centerPos = { 200, 0, 110 },
.wanderSize = { 70 },
.detectShape = SHAPE_CYLINDER,
.detectPos = { 200, 0, 110 },
.detectSize = { 70 },
}
},
.init = &N(EVS_NpcInit_Toad_02),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Toad_Wander),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING,
.animations = TOAD_GREEN_ANIMS,
},
{
.id = NPC_Toad_03,
.pos = { -250.0f, 0.0f, 225.0f },
.yaw = 90,
.territory = {
.patrol = {
.isFlying = TRUE,
.moveSpeedOverride = NO_OVERRIDE_MOVEMENT_SPEED,
.numPoints = 2,
.points = {
{ -250, 0, 225 },
{ 300, 0, -50 },
},
.detectShape = SHAPE_CYLINDER,
.detectPos = { -250, 0, 225 },
.detectSize = { 200 },
}
},
.init = &N(EVS_NpcInit_Toad_03),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Toad_Patrol),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING,
.animations = TOAD_RED_ANIMS,
},
{
.id = NPC_Toadette,
.pos = { -170.0f, 0.0f, 100.0f },
.yaw = 90,
.territory = {
.wander = {
.isFlying = TRUE,
.moveSpeedOverride = NO_OVERRIDE_MOVEMENT_SPEED,
.wanderShape = SHAPE_CYLINDER,
.centerPos = { -170, 0, 100 },
.wanderSize = { 70 },
.detectShape = SHAPE_CYLINDER,
.detectPos = { -170, 0, 100 },
.detectSize = { 70 },
}
},
.init = &N(EVS_NpcInit_Toadette),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Toad_Wander),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING,
.animations = TOADETTE_ORANGE_ANIMS,
},
{
.id = NPC_ToadGuard_01,
.pos = { -55.0f, 100.0f, -360.0f },
.yaw = 270,
.init = &N(EVS_NpcInit_ToadGuard_01),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Toad_Stationary),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING,
.animations = TOAD_GUARD_RED_ANIMS,
},
{
.id = NPC_ToadGuard_02,
.pos = { NPC_DISPOSE_LOCATION },
.yaw = 270,
.init = &N(EVS_NpcInit_ToadGuard_02),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Toad_Stationary),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING,
.animations = TOAD_GUARD_YELLOW_ANIMS,
},
{
.id = NPC_Dryite,
.pos = { 170.0f, 0.0f, 345.0f },
.yaw = 90,
.init = &N(EVS_NpcInit_Dryite),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Dryite),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING | ENEMY_FLAG_400000,
.animations = DRYITE_YELLOW_ANIMS,
},
{
.id = NPC_Mouser,
.pos = { 200.0f, 0.0f, 325.0f },
.yaw = 270,
.init = &N(EVS_NpcInit_Mouser),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Mouser),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING | ENEMY_FLAG_400000,
.animations = MOUSER_BLUE_ANIMS,
},
{
.id = NPC_MayorPenguin,
.pos = { -150.0f, 0.0f, 0.0f },
.yaw = 90,
.init = &N(EVS_NpcInit_MayorPenguin),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Penguin),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_ENTITY_COLLISION | ENEMY_FLAG_FLYING | ENEMY_FLAG_400000,
.animations = MAYOR_PENGUIN_ANIMS,
},
{
.id = NPC_Koopa,
.pos = { -120.0f, 0.0f, -15.0f },
.yaw = 270,
.init = &N(EVS_NpcInit_Koopa),
.drops = NO_DROPS,
.settings = &N(NpcSettings_Koopa),
.flags = ENEMY_FLAG_PASSIVE | ENEMY_FLAG_ENABLE_HIT_SCRIPT | ENEMY_FLAG_IGNORE_WORLD_COLLISION | ENEMY_FLAG_FLYING | ENEMY_FLAG_400000,
.animations = KOOPA_ANIMS,
},
};
NpcGroupList N(DefaultNPCs) = {
NPC_GROUP(N(NpcData_ToadMinister)),
{}
};
|
c047f933a120f55079e84583dfa87448dd60f0d6
|
2148c987c4b008453d5034ef33cbce886c241a3b
|
/firmware/blink/main.c
|
29c3807bd51a0fdfdcaa7f35f9d751dffe74d60f
|
[
"Apache-2.0"
] |
permissive
|
ytai/ioio
|
94cebdb9b97163be2fefb6d9a362d184b2d157c2
|
42f156cd676f14c6a503464bb33feb83353484f6
|
refs/heads/master
| 2023-08-30T23:36:00.823993
| 2023-08-24T05:00:03
| 2023-08-24T05:00:03
| 2,272,409
| 477
| 201
|
Apache-2.0
| 2023-09-11T03:26:53
| 2011-08-26T04:59:57
|
C
|
UTF-8
|
C
| false
| false
| 350
|
c
|
main.c
|
#define GetSystemClock() 32000000UL
#define GetPeripheralClock() (GetSystemClock())
#define GetInstructionClock() (GetSystemClock() / 2)
#include "Compiler.h"
#include "timer.h"
#include "platform.h"
int main() {
led_init();
while (1) {
led_on();
DelayMs(500);
led_off();
DelayMs(500);
}
return 0;
}
|
723e224c19632da0c09be0473cc8210553c9f650
|
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
|
/AKWF-c/AKWF_oscchip/AKWF_oscchip_0044.h
|
fa823296c3f535c7ffb9d34e36a034456d1b0fde
|
[
"CC0-1.0"
] |
permissive
|
KristofferKarlAxelEkstrand/AKWF-FREE
|
b2defa1a2d389d309be6dd2e9f968923daf80d1b
|
cf8171df36e9fec25416b5f568b72a6e2cb69194
|
refs/heads/master
| 2023-07-23T18:22:36.939705
| 2023-07-10T17:14:40
| 2023-07-10T17:14:40
| 145,817,187
| 359
| 59
|
CC0-1.0
| 2023-07-10T17:14:41
| 2018-08-23T07:26:56
| null |
UTF-8
|
C
| false
| false
| 4,688
|
h
|
AKWF_oscchip_0044.h
|
/* Adventure Kid Waveforms (AKWF) converted for use with Teensy Audio Library
*
* Adventure Kid Waveforms(AKWF) Open waveforms library
* https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/
*
* This code is in the public domain, CC0 1.0 Universal (CC0 1.0)
* https://creativecommons.org/publicdomain/zero/1.0/
*
* Converted by Brad Roy, https://github.com/prosper00
*/
/* AKWF_oscchip_0044 256 samples
+-----------------------------------------------------------------------------------------------------------------+
| * ******** |
|************************************************* * ***** |
| **************** ******* |
| * |
| **** |
| **** |
| * |
| * |
| * |
| * ****|
| * **** |
| * ***** |
| * * |
| * **** |
| * * |
+-----------------------------------------------------------------------------------------------------------------+
*/
const uint16_t AKWF_oscchip_0044 [] = {
36462, 38792, 37970, 38474, 38122, 38400, 38191, 38363, 38230, 38340, 38261, 38322, 38278, 38306, 38290, 38297,
38297, 38293, 38299, 38294, 38293, 38303, 38272, 38341, 37370, 36610, 36801, 36679, 36766, 36697, 36750, 36707,
36734, 36707, 36725, 36713, 36718, 36712, 36707, 36724, 37009, 37119, 37073, 37103, 37075, 37096, 37077, 37087,
37341, 37505, 37443, 37480, 37450, 37469, 37459, 37402, 37072, 37067, 37053, 37062, 37046, 37060, 37031, 37179,
38418, 38641, 38577, 38609, 38581, 38601, 38582, 38544, 37337, 36949, 37059, 36990, 37038, 36995, 37027, 36991,
37021, 36991, 37014, 36986, 37011, 36980, 37009, 36920, 36622, 36591, 36598, 36590, 36594, 36586, 36587, 36585,
36585, 36581, 36577, 36577, 36576, 36574, 36569, 36567, 36569, 36564, 36565, 36556, 36563, 36552, 36562, 36544,
36558, 36541, 36558, 36534, 36553, 36532, 36550, 36529, 36542, 36526, 36538, 36527, 36526, 36527, 36519, 36531,
36505, 36534, 36492, 36542, 36477, 36549, 36459, 36563, 36440, 36579, 36407, 36609, 36357, 36692, 36146, 38210,
43102, 43056, 43124, 43079, 43097, 43083, 43089, 43023, 42694, 42691, 42673, 42680, 42671, 42659, 42693, 42452,
40582, 40250, 40351, 40274, 40334, 40266, 40327, 40229, 39707, 39427, 39567, 39435, 39559, 39413, 39593, 39054,
37945, 37909, 37930, 37899, 37931, 37878, 37957, 37642, 36415, 36323, 36344, 36319, 36348, 36293, 36382, 36078,
34297, 33864, 34092, 33857, 34130, 33784, 34271, 32743, 30893, 30759, 31013, 30664, 31098, 30561, 31260, 29701,
27637, 27075, 27695, 26972, 27837, 26738, 28411, 22839, 2336, 582, 1166, 747, 1133, 796, 1078, 1227,
5270, 5655, 5701, 5662, 5666, 5793, 5452, 7604, 11407, 11066, 11251, 11208, 11175, 11331, 11064, 11946,
13484, 13728, 13468, 13813, 13427, 13900, 13342, 14431, 16394, 17097, 16511, 17156, 16451, 17316, 16126, 19402,
};
|
948c331da828d5e9e8722aebae1e1e9e628f4b92
|
f8c0a188d1cf8ae5221c4cd11552c221a86e259a
|
/Firmware/bleStack/debug.c
|
cf8fb68af5edcce0ff21a75865ee503b29683c3c
|
[
"CC-BY-3.0",
"BSD-2-Clause"
] |
permissive
|
digitalinteraction/openmovement
|
6310abf35b379655073485e84719cc2521733c0e
|
9c2ee2eeb5eae457673e60699b2842c6df82abb1
|
refs/heads/master
| 2023-08-03T23:48:42.973605
| 2023-07-26T17:52:37
| 2023-07-26T17:52:37
| 27,082,024
| 135
| 86
| null | 2018-06-21T23:32:43
| 2014-11-24T15:38:43
|
C
|
UTF-8
|
C
| false
| false
| 2,611
|
c
|
debug.c
|
/*
* Copyright (c) 2013-2014, Newcastle University, UK.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
// Debugging outputs
// Karim Ladha, 2013-2014
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include "bt config.h"
#include "debug.h"
#include "Utils\util.h"
#if (DBG_ENABLE)
// Allows remapping of default debug channel (e.g. to LCD)
void DBG_printf(const char* file,const char* fmt,...)
{
va_list myargs;
va_start(myargs, fmt);
if(file)fprintf(stderr,"%s: ",file);
vfprintf(stderr, fmt, myargs); // Divert to stderr
va_end(myargs);
}
// Very fast call for small const packets
void DBG_fast(const char* data,unsigned char len)
{
write(2,(void*)data,len);// 2 = stderr
}
inline void DBG_assert(unsigned char condition, const char* file, unsigned short line)
{
if(!condition)
{
DBG_printf(NULL,"ASSERT!: %s, %u\r\n",file,line);
}
}
void DBG_dump(const unsigned char* data, unsigned short len)
{
unsigned short i;
unsigned char trunc = FALSE_;
if(len>24)
{
len = 24; // Clamp dump load
trunc = TRUE_;
}
for(i=0;i<len;i++)
{
DBG_printf(NULL,"%02X ",(unsigned char)data[i]);
}
if(trunc == TRUE_)
DBG_printf(NULL,"..\r\n");
else
DBG_printf(NULL,"\r\n");
}
#endif
|
4de856b578c0e5e12bb4388165f20004b20c05f1
|
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
|
/tool/viz/printpeb.c
|
c1da85b284dc269dc2b7a93487557e9b07843c7d
|
[
"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
| 28,426
|
c
|
printpeb.c
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
╞══════════════════════════════════════════════════════════════════════════════╡
│ Copyright 2020 Justine Alexandra Roberts Tunney │
│ │
│ 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 "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/dce.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/log/log.h"
#include "libc/nt/dll.h"
#include "libc/nt/enum/filetype.h"
#include "libc/nt/enum/startf.h"
#include "libc/nt/files.h"
#include "libc/nt/process.h"
#include "libc/nt/runtime.h"
#include "libc/nt/struct/ldr.h"
#include "libc/nt/struct/ldrdatatableentry.h"
#include "libc/nt/struct/linkedlist.h"
#include "libc/nt/struct/peb.h"
#include "libc/nt/struct/systeminfo.h"
#include "libc/nt/struct/teb.h"
#include "libc/nt/struct/unicodestring.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/madv.h"
#include "libc/sysv/consts/o.h"
#include "libc/time/time.h"
#include "tool/decode/lib/flagger.h"
#include "tool/decode/lib/idname.h"
#if defined(__x86_64__) && SupportsWindows()
char *GetString(const struct NtUnicodeString *s) {
static char buf[1024];
unsigned len = min(sizeof(buf) - 1, s->Length);
for (unsigned i = 0; i < len; ++i) {
buf[i] = (unsigned char)s->Data[i];
}
buf[len] = '\0';
return &buf[0];
}
int NextBestThing(void) {
int64_t fd = open("/proc/self/maps", O_RDONLY);
posix_fadvise(fd, 0, 0, MADV_SEQUENTIAL);
ssize_t wrote;
while ((wrote = copyfd(fd, 1, -1)) != -1) {
if (wrote == 0) break;
}
close(fd);
return 0;
}
const struct IdName kNtStartfFlagNames[] = {
{kNtStartfUseshowwindow, "kNtStartfUseshowwindow"},
{kNtStartfUsesize, "kNtStartfUsesize"},
{kNtStartfUseposition, "kNtStartfUseposition"},
{kNtStartfUsecountchars, "kNtStartfUsecountchars"},
{kNtStartfUsefillattribute, "kNtStartfUsefillattribute"},
{kNtStartfRunfullscreen, "kNtStartfRunfullscreen"},
{kNtStartfForceonfeedback, "kNtStartfForceonfeedback"},
{kNtStartfForceofffeedback, "kNtStartfForceofffeedback"},
{kNtStartfUsestdhandles, "kNtStartfUsestdhandles"},
{kNtStartfUsehotkey, "kNtStartfUsehotkey"},
{kNtStartfTitleislinkname, "kNtStartfTitleislinkname"},
{kNtStartfTitleisappid, "kNtStartfTitleisappid"},
{kNtStartfPreventpinning, "kNtStartfPreventpinning"},
{kNtStartfUntrustedsource, "kNtStartfUntrustedsource"},
{0, 0},
};
dontasan void PrintStartupInfo(void) {
#if 0
printf("\n\
╔──────────────────────────────────────────────────────────────────────────────╗\n\
│ new technology § startup info │\n\
╚──────────────────────────────────────────────────────────────────────────────╝\n\
\n");
#define X(D, F) \
printf("%s.%-22s= " D "\n", "__nt_startupinfo", #F, __nt_startupinfo.F);
X("%u", cb);
X("%p", lpReserved);
X("%hs", lpDesktop);
X("%hs", lpTitle);
X("%u", dwX);
X("%u", dwY);
X("%u", dwXSize);
X("%u", dwYSize);
X("%u", dwXCountChars);
X("%u", dwYCountChars);
X("%u", dwFillAttribute);
printf("%s.%-22s: %s\n", "__nt_startupinfo", "dwFlags",
RecreateFlags(kNtStartfFlagNames, __nt_startupinfo.dwFlags));
X("%hu", wShowWindow);
X("%hu", cbReserved2);
X("%s", lpReserved2);
X("%ld", hStdInput);
X("%ld", hStdOutput);
X("%ld", hStdError);
#undef X
#endif
}
void PrintSystemInfo(void) {
#if 0
printf("\n\
╔──────────────────────────────────────────────────────────────────────────────╗\n\
│ new technology § system info │\n\
╚──────────────────────────────────────────────────────────────────────────────╝\n\
\n");
#define X(D, F) \
printf("%s.%-28s= " D "\n", "__nt_systeminfo", #F, __nt_systeminfo.F);
X("%08x", dwOemId);
X("%04hx", wProcessorArchitecture);
X("%d", dwPageSize);
X("%p", lpMinimumApplicationAddress);
X("%p", lpMaximumApplicationAddress);
X("%p", dwActiveProcessorMask);
X("%u", dwNumberOfProcessors);
X("%u", dwProcessorType);
X("%u", dwAllocationGranularity);
X("%hu", wProcessorLevel);
X("%hu", wProcessorRevision);
#undef X
#endif
}
const char *ft2str(int ft) {
if (ft == kNtFileTypeUnknown) return "kNtFileTypeUnknown";
if (ft == kNtFileTypeDisk) return "kNtFileTypeDisk";
if (ft == kNtFileTypeChar) return "kNtFileTypeChar";
if (ft == kNtFileTypePipe) return "kNtFileTypePipe";
if (ft == kNtFileTypeRemote) return "kNtFileTypeRemote";
return "wut?";
}
void PrintStdioInfo(void) {
printf("\n\
╔──────────────────────────────────────────────────────────────────────────────╗\n\
│ new technology § stdio info │\n\
╚──────────────────────────────────────────────────────────────────────────────╝\n\
\n");
printf("%s: %ld (%s)\n", "g_fds.p[0].handle", g_fds.p[0].handle,
ft2str(GetFileType(g_fds.p[0].handle)));
printf("%s: %ld (%s)\n", "g_fds.p[1].handle", g_fds.p[1].handle,
ft2str(GetFileType(g_fds.p[1].handle)));
printf("%s: %ld (%s)\n", "g_fds.p[2].handle", g_fds.p[2].handle,
ft2str(GetFileType(g_fds.p[2].handle)));
}
dontasan void PrintTeb(void) {
GetCurrentProcessId();
SetLastError(0x1234);
printf("\n\
╔──────────────────────────────────────────────────────────────────────────────╗\n\
│ new technology § teb? │\n\
╚──────────────────────────────────────────────────────────────────────────────╝\n\
\n");
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x00, "NtGetSeh()", _NtGetSeh());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x08, "NtGetStackHigh()",
_NtGetStackHigh());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x10, "NtGetStackLow()",
_NtGetStackLow());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x18, "_NtGetSubsystemTib()",
_NtGetSubsystemTib());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x20, "NtGetFib()", _NtGetFib());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x30, "NtGetTeb()", NtGetTeb());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x38, "NtGetEnv()", _NtGetEnv());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x40, "NtGetPid()", NtGetPid());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x48, "NtGetTid()", NtGetTid());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x50, "NtGetRpc()", _NtGetRpc());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x58, "NtGetTls()", _NtGetTls());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x60, "NtGetPeb()", NtGetPeb());
printf("gs:0x%02x: %-39s = 0x%lx\n", 0x68, "NtGetErr()", NtGetErr());
}
void PrintPeb(void) {
struct NtPeb *peb = NtGetPeb();
printf("\n\
╔──────────────────────────────────────────────────────────────────────────────╗\n\
│ new technology § peb │\n\
╚──────────────────────────────────────────────────────────────────────────────╝\n\
\n");
printf("0x%04x: %-40s = %u\n", offsetof(struct NtPeb, InheritedAddressSpace),
"InheritedAddressSpace", (unsigned)peb->InheritedAddressSpace);
printf("0x%04x: %-40s = %u\n",
offsetof(struct NtPeb, ReadImageFileExecOptions),
"ReadImageFileExecOptions", (unsigned)peb->ReadImageFileExecOptions);
printf("0x%04x: %-40s = %u\n", offsetof(struct NtPeb, BeingDebugged),
"BeingDebugged", (unsigned)peb->BeingDebugged);
printf("0x%04x: %-40s = %u\n", offsetof(struct NtPeb, __wut1), "__wut1",
(unsigned)peb->__wut1);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, Mutant), "Mutant",
peb->Mutant);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, ImageBaseAddress),
"ImageBaseAddress", peb->ImageBaseAddress);
/* struct NtLdr *Ldr; */
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, ProcessParameters),
"ProcessParameters", peb->ProcessParameters);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, SubSystemData),
"SubSystemData", peb->SubSystemData);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, ProcessHeap),
"ProcessHeap", peb->ProcessHeap);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, FastPebLock),
"FastPebLock", peb->FastPebLock);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, __wut3), "__wut3",
peb->__wut3);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, __wut4), "__wut4",
peb->__wut4);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, __wut5), "__wut5",
peb->__wut5);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, KernelCallbackTable),
"KernelCallbackTable", peb->KernelCallbackTable);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, UserSharedInfoPtr),
"UserSharedInfoPtr", peb->UserSharedInfoPtr);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, SystemReserved),
"SystemReserved", peb->SystemReserved);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, __wut6), "__wut6",
peb->__wut6);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, __wut7), "__wut7",
peb->__wut7);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, TlsExpansionCounter),
"TlsExpansionCounter", peb->TlsExpansionCounter);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, TlsBitmap),
"TlsBitmap", peb->TlsBitmap);
printf("0x%04x: %-40s = 0x%x 0x%x\n", offsetof(struct NtPeb, TlsBitmapBits),
"TlsBitmapBits", peb->TlsBitmapBits[0], peb->TlsBitmapBits[1]);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, ReadOnlySharedMemoryBase),
"ReadOnlySharedMemoryBase", peb->ReadOnlySharedMemoryBase);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, __wut8), "__wut8",
peb->__wut8);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, ReadOnlyStaticServerData),
"ReadOnlyStaticServerData", peb->ReadOnlyStaticServerData);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, AnsiCodePageData),
"AnsiCodePageData", peb->AnsiCodePageData);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, OemCodePageData),
"OemCodePageData", peb->OemCodePageData);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, UnicodeCaseTableData), "UnicodeCaseTableData",
peb->UnicodeCaseTableData);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, NumberOfProcessors),
"NumberOfProcessors", peb->NumberOfProcessors);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, NtGlobalFlag),
"NtGlobalFlag", peb->NtGlobalFlag);
printf("0x%04x: %-40s = %ld\n",
offsetof(struct NtPeb, CriticalSectionTimeout),
"CriticalSectionTimeout", peb->CriticalSectionTimeout);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, HeapSegmentReserve),
"HeapSegmentReserve", peb->HeapSegmentReserve);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, HeapSegmentCommit),
"HeapSegmentCommit", peb->HeapSegmentCommit);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, HeapDeCommitTotalFreeThreshold),
"HeapDeCommitTotalFreeThreshold", peb->HeapDeCommitTotalFreeThreshold);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, HeapDeCommitFreeBlockThreshold),
"HeapDeCommitFreeBlockThreshold", peb->HeapDeCommitFreeBlockThreshold);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, NumberOfHeaps),
"NumberOfHeaps", peb->NumberOfHeaps);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, MaximumNumberOfHeaps),
"MaximumNumberOfHeaps", peb->MaximumNumberOfHeaps);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, ProcessHeaps),
"ProcessHeaps", peb->ProcessHeaps);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, GdiSharedHandleTable), "GdiSharedHandleTable",
peb->GdiSharedHandleTable);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, ProcessStarterHelper), "ProcessStarterHelper",
peb->ProcessStarterHelper);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, GdiDCAttributeList),
"GdiDCAttributeList", peb->GdiDCAttributeList);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, LoaderLock),
"LoaderLock", peb->LoaderLock);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, OSMajorVersion),
"OSMajorVersion", peb->OSMajorVersion);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, OSMinorVersion),
"OSMinorVersion", peb->OSMinorVersion);
printf("0x%04x: %-40s = %hu\n", offsetof(struct NtPeb, OSBuildNumber),
"OSBuildNumber", peb->OSBuildNumber);
printf("0x%04x: %-40s = %hu\n", offsetof(struct NtPeb, OSCSDVersion),
"OSCSDVersion", peb->OSCSDVersion);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, OSPlatformId),
"OSPlatformId", peb->OSPlatformId);
printf("0x%04x: %-40s = 0x%x\n", offsetof(struct NtPeb, ImageSubsystem),
"ImageSubsystem", peb->ImageSubsystem);
printf("0x%04x: %-40s = 0x%x\n",
offsetof(struct NtPeb, ImageSubsystemMajorVersion),
"ImageSubsystemMajorVersion", peb->ImageSubsystemMajorVersion);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, ImageSubsystemMinorVersion),
"ImageSubsystemMinorVersion", peb->ImageSubsystemMinorVersion);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, ImageProcessAffinityMask),
"ImageProcessAffinityMask", peb->ImageProcessAffinityMask);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, ActiveProcessAffinityMask),
"ActiveProcessAffinityMask", peb->ActiveProcessAffinityMask);
/* "0x%lx", GdiHandleBuffer[38 - __SIZEOF_POINTER__]; */
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, PostProcessInitRoutine),
"PostProcessInitRoutine", peb->PostProcessInitRoutine);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, TlsExpansionBitmap),
"TlsExpansionBitmap", peb->TlsExpansionBitmap);
/* "0x%x", TlsExpansionBitmapBits[32]; */
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, SessionId),
"SessionId", peb->SessionId);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, AppCompatFlags),
"AppCompatFlags", peb->AppCompatFlags);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, AppCompatFlagsUser),
"AppCompatFlagsUser", peb->AppCompatFlagsUser);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, pShimData),
"pShimData", peb->pShimData);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, AppCompatInfo),
"AppCompatInfo", peb->AppCompatInfo);
printf("0x%04x: %-40s = \"%s\"\n", offsetof(struct NtPeb, CSDVersion),
"CSDVersion", GetString(&peb->CSDVersion));
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, ActivationContextData), "ActivationContextData",
peb->ActivationContextData);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, ProcessAssemblyStorageMap),
"ProcessAssemblyStorageMap", peb->ProcessAssemblyStorageMap);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, SystemDefaultActivationContextData),
"SystemDefaultActivationContextData",
peb->SystemDefaultActivationContextData);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtPeb, SystemAssemblyStorageMap),
"SystemAssemblyStorageMap", peb->SystemAssemblyStorageMap);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtPeb, MinimumStackCommit),
"MinimumStackCommit", peb->MinimumStackCommit);
}
void PrintPebLdr(void) {
printf("\n\
╔──────────────────────────────────────────────────────────────────────────────╗\n\
│ new technology § peb » ldr │\n\
╚──────────────────────────────────────────────────────────────────────────────╝\n\
\n");
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtLdr, SizeOfThis),
"SizeOfThis", NtGetPeb()->Ldr->SizeOfThis);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtLdr, IsInitialized),
"IsInitialized", NtGetPeb()->Ldr->IsInitialized);
printf("0x%04x: %-40s = 0x%lx\n", offsetof(struct NtLdr, SsHandle),
"SsHandle", NtGetPeb()->Ldr->SsHandle);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdr, InLoadOrderModuleList), "InLoadOrderModuleList",
NtGetPeb()->Ldr->InLoadOrderModuleList);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdr, InMemoryOrderModuleList),
"InMemoryOrderModuleList", NtGetPeb()->Ldr->InMemoryOrderModuleList);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdr, InInitOrderModuleList), "InInitOrderModuleList",
NtGetPeb()->Ldr->InInitOrderModuleList);
}
void PrintModulesLoadOrder(void) {
{
printf("\n\
╔──────────────────────────────────────────────────────────────────────────────╗\n\
│ new technology § modules » load order │\n\
╚──────────────────────────────────────────────────────────────────────────────╝\n\
\n");
struct NtLinkedList *head = &NtGetPeb()->Ldr->InLoadOrderModuleList;
struct NtLinkedList *ldr = head->Next;
do {
const struct NtLdrDataTableEntry *dll =
(const struct NtLdrDataTableEntry *)ldr;
/* struct NtLinkedList InLoadOrderLinks; /\* msdn:reserved *\/ */
/* struct NtLinkedList InMemoryOrderLinks; */
/* struct NtLinkedList InInitOrderLinks; /\* msdn:reserved *\/ */
printf("%p\n", ldr);
printf("%p vs. %p\n", dll, GetModuleHandleW(dll->FullDllName.Data));
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdrDataTableEntry, DllBase), "DllBase",
dll->DllBase);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdrDataTableEntry, EntryPoint), "EntryPoint",
dll->EntryPoint);
printf("0x%04x: %-40s = 0x%x\n",
offsetof(struct NtLdrDataTableEntry, SizeOfImage), "SizeOfImage",
dll->SizeOfImage);
printf("0x%04x: %-40s = \"%s\"\n",
offsetof(struct NtLdrDataTableEntry, FullDllName), "FullDllName",
GetString(&dll->FullDllName));
printf("0x%04x: %-40s = \"%s\"\n",
offsetof(struct NtLdrDataTableEntry, BaseDllName), "BaseDllName",
GetString(&dll->BaseDllName));
printf("0x%04x: %-40s = 0x%x\n",
offsetof(struct NtLdrDataTableEntry, Flags), "Flags", dll->Flags);
printf("0x%04x: %-40s = %hu\n",
offsetof(struct NtLdrDataTableEntry, Load_Count), "Load_Count",
dll->Load_Count);
printf("0x%04x: %-40s = %hu\n",
offsetof(struct NtLdrDataTableEntry, TlsIndex), "TlsIndex",
dll->TlsIndex);
/* union { */
/* struct NtLinkedList HashLinks; */
/* struct { */
/* void *SectionPointer; */
/* uint32_t CheckSum; */
/* }; */
/* }; */
/* union { */
/* void *LoadedImports; */
/* uint32_t TimeDateStamp; */
/* }; */
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdrDataTableEntry, EntryPointActivationContext),
"EntryPointActivationContext", dll->EntryPointActivationContext);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdrDataTableEntry, PatchInformation),
"PatchInformation", dll->PatchInformation);
/* struct NtLinkedList ForwarderLinks; */
/* struct NtLinkedList ServiceTagLinks; */
/* struct NtLinkedList StaticLinks; */
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdrDataTableEntry, ContextInformation),
"ContextInformation", dll->ContextInformation);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdrDataTableEntry, OriginalBase), "OriginalBase",
dll->OriginalBase);
printf("0x%04x: %-40s = %ld\n",
offsetof(struct NtLdrDataTableEntry, LoadTime), "LoadTime",
dll->LoadTime);
printf("\n");
} while ((ldr = ldr->Next) && ldr != head);
}
}
void PrintModulesMemoryOrder(void) {
{
printf("\n\
╔──────────────────────────────────────────────────────────────────────────────╗\n\
│ new technology § modules » memory order │\n\
╚──────────────────────────────────────────────────────────────────────────────╝\n\
\n");
struct NtLinkedList *head = &NtGetPeb()->Ldr->InMemoryOrderModuleList;
struct NtLinkedList *ldr = head->Next;
do {
const struct NtLdrDataTableEntry *dll =
(const struct NtLdrDataTableEntry *)ldr;
/* struct NtLinkedList InLoadOrderLinks; /\* msdn:reserved *\/ */
/* struct NtLinkedList InMemoryOrderLinks; */
/* struct NtLinkedList InInitOrderLinks; /\* msdn:reserved *\/ */
printf("%p\n", dll);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdrDataTableEntry, DllBase), "DllBase",
dll->DllBase);
printf("0x%04x: %-40s = 0x%lx\n",
offsetof(struct NtLdrDataTableEntry, EntryPoint), "EntryPoint",
dll->EntryPoint);
printf("0x%04x: %-40s = 0x%x\n",
offsetof(struct NtLdrDataTableEntry, SizeOfImage), "SizeOfImage",
dll->SizeOfImage);
printf("0x%04x: %-40s = \"%s\"\n",
offsetof(struct NtLdrDataTableEntry, FullDllName), "FullDllName",
GetString(&dll->FullDllName));
printf("0x%04x: %-40s = \"%s\"\n",
offsetof(struct NtLdrDataTableEntry, BaseDllName), "BaseDllName",
GetString(&dll->BaseDllName));
printf("0x%04x: %-40s = 0x%x\n",
offsetof(struct NtLdrDataTableEntry, Flags), "Flags", dll->Flags);
printf("0x%04x: %-40s = %hu\n",
offsetof(struct NtLdrDataTableEntry, Load_Count), "Load_Count",
dll->Load_Count);
printf("0x%04x: %-40s = %hu\n",
offsetof(struct NtLdrDataTableEntry, TlsIndex), "TlsIndex",
dll->TlsIndex);
/* /\* union { *\/ */
/* /\* struct NtLinkedList HashLinks; *\/ */
/* /\* struct { *\/ */
/* /\* void *SectionPointer; *\/ */
/* /\* uint32_t CheckSum; *\/ */
/* /\* }; *\/ */
/* /\* }; *\/ */
/* /\* union { *\/ */
/* /\* void *LoadedImports; *\/ */
/* /\* uint32_t TimeDateStamp; *\/ */
/* /\* }; *\/ */
/* printf("0x%04x: %-40s = 0x%lx\n", */
/* offsetof(struct NtLdrDataTableEntry,
* EntryPointActivationContext), */
/* "EntryPointActivationContext",
* dll->EntryPointActivationContext); */
/* printf("0x%04x: %-40s = 0x%lx\n", */
/* offsetof(struct NtLdrDataTableEntry, PatchInformation), */
/* "PatchInformation", dll->PatchInformation); */
/* /\* struct NtLinkedList ForwarderLinks; *\/ */
/* /\* struct NtLinkedList ServiceTagLinks; *\/ */
/* /\* struct NtLinkedList StaticLinks; *\/ */
/* printf("0x%04x: %-40s = 0x%lx\n", */
/* offsetof(struct NtLdrDataTableEntry, ContextInformation), */
/* "ContextInformation", dll->ContextInformation); */
/* printf("0x%04x: %-40s = 0x%lx\n", */
/* offsetof(struct NtLdrDataTableEntry, OriginalBase),
* "OriginalBase", */
/* dll->OriginalBase); */
/* printf("0x%04x: %-40s = %ld\n", */
/* offsetof(struct NtLdrDataTableEntry, LoadTime), "LoadTime", */
/* dll->LoadTime); */
printf("\n");
} while ((ldr = ldr->Next) && ldr != head);
}
}
int main(int argc, char *argv[]) {
if (IsLinux()) {
return NextBestThing();
}
if (!IsWindows()) {
fprintf(stderr, "error: this tool is intended for windows\n");
return 1;
}
PrintStartupInfo();
PrintSystemInfo();
PrintStdioInfo();
PrintTeb();
PrintPeb();
PrintPebLdr();
PrintModulesLoadOrder();
PrintModulesMemoryOrder();
return 0;
}
#else
int main(int argc, char *argv[]) {
fprintf(stderr, "printpeb not supported on this cpu arch or build config\n");
return 1;
}
#endif /* __x86_64__ && SupportsWindows() */
|
96ef715f1ad1a3723d1e166a67c0e63b0dc846db
|
9ceacf33fd96913cac7ef15492c126d96cae6911
|
/sys/arch/hppa/dev/apic.c
|
ee416c6e40e8eb579197d4ac4c6e8cd4bc533f86
|
[] |
no_license
|
openbsd/src
|
ab97ef834fd2d5a7f6729814665e9782b586c130
|
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
|
refs/heads/master
| 2023-09-02T18:54:56.624627
| 2023-09-02T15:16:12
| 2023-09-02T15:16:12
| 66,966,208
| 3,394
| 1,235
| null | 2023-08-08T02:42:25
| 2016-08-30T18:18:25
|
C
|
UTF-8
|
C
| false
| false
| 8,810
|
c
|
apic.c
|
/* $OpenBSD: apic.c,v 1.19 2018/05/14 13:54:39 kettenis Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
* Copyright (c) 2007 Mark Kettenis
* All rights reserved.
*
* 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 MIND, USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/evcount.h>
#include <sys/malloc.h>
#include <machine/autoconf.h>
#include <machine/pdc.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
#include <hppa/dev/elroyreg.h>
#include <hppa/dev/elroyvar.h>
#define APIC_INT_LINE_MASK 0x0000ff00
#define APIC_INT_LINE_SHIFT 8
#define APIC_INT_IRQ_MASK 0x0000001f
#define APIC_INT_LINE(x) (((x) & APIC_INT_LINE_MASK) >> APIC_INT_LINE_SHIFT)
#define APIC_INT_IRQ(x) ((x) & APIC_INT_IRQ_MASK)
/*
* Interrupt types match the Intel MP Specification.
*/
#define MPS_INTPO_DEF 0
#define MPS_INTPO_ACTHI 1
#define MPS_INTPO_ACTLO 3
#define MPS_INTPO_SHIFT 0
#define MPS_INTPO_MASK 3
#define MPS_INTTR_DEF 0
#define MPS_INTTR_EDGE 1
#define MPS_INTTR_LEVEL 3
#define MPS_INTTR_SHIFT 2
#define MPS_INTTR_MASK 3
#define MPS_INT(p,t) \
((((p) & MPS_INTPO_MASK) << MPS_INTPO_SHIFT) | \
(((t) & MPS_INTTR_MASK) << MPS_INTTR_SHIFT))
struct apic_iv {
struct elroy_softc *sc;
pci_intr_handle_t ih;
int (*handler)(void *);
void *arg;
struct apic_iv *next;
struct evcount *cnt;
};
struct apic_iv *apic_intr_list[CPU_NINTS];
void apic_get_int_tbl(struct elroy_softc *);
u_int32_t apic_get_int_ent0(struct elroy_softc *, int);
#ifdef DEBUG
void apic_dump(struct elroy_softc *);
#endif
void apic_write(volatile struct elroy_regs *r, u_int32_t reg,
u_int32_t val);
u_int32_t apic_read(volatile struct elroy_regs *r, u_int32_t reg);
void
apic_write(volatile struct elroy_regs *r, u_int32_t reg, u_int32_t val)
{
elroy_write32(&r->apic_addr, htole32(reg));
elroy_write32(&r->apic_data, htole32(val));
elroy_read32(&r->apic_data);
}
u_int32_t
apic_read(volatile struct elroy_regs *r, u_int32_t reg)
{
elroy_write32(&r->apic_addr, htole32(reg));
return letoh32(elroy_read32(&r->apic_data));
}
void
apic_attach(struct elroy_softc *sc)
{
volatile struct elroy_regs *r = sc->sc_regs;
u_int32_t data;
data = apic_read(r, APIC_VERSION);
sc->sc_nints = (data & APIC_VERSION_NENT) >> APIC_VERSION_NENT_SHIFT;
printf(" APIC ver %x, %d pins",
data & APIC_VERSION_MASK, sc->sc_nints);
sc->sc_irq = mallocarray(sc->sc_nints, sizeof(int), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (sc->sc_irq == NULL)
panic("apic_attach: cannot allocate irq table");
apic_get_int_tbl(sc);
#ifdef DEBUG
apic_dump(sc);
#endif
}
int
apic_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{
struct elroy_softc *sc = pa->pa_pc->_cookie;
pci_chipset_tag_t pc = pa->pa_pc;
pcitag_t tag = pa->pa_tag;
pcireg_t reg;
int line;
reg = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
#ifdef DEBUG
printf(" pin=%d line=%d ", PCI_INTERRUPT_PIN(reg),
PCI_INTERRUPT_LINE(reg));
#endif
line = PCI_INTERRUPT_LINE(reg);
if (sc->sc_irq[line] <= 0) {
if ((sc->sc_irq[line] = cpu_intr_findirq()) == -1)
return 1;
}
*ihp = (line << APIC_INT_LINE_SHIFT) | sc->sc_irq[line];
return (APIC_INT_IRQ(*ihp) == 0);
}
const char *
apic_intr_string(void *v, pci_intr_handle_t ih)
{
static char buf[32];
snprintf(buf, 32, "line %ld irq %ld",
APIC_INT_LINE(ih), APIC_INT_IRQ(ih));
return (buf);
}
void *
apic_intr_establish(void *v, pci_intr_handle_t ih,
int pri, int (*handler)(void *), void *arg, const char *name)
{
struct elroy_softc *sc = v;
volatile struct elroy_regs *r = sc->sc_regs;
hppa_hpa_t hpa = cpu_gethpa(0);
struct evcount *cnt;
struct apic_iv *aiv, *biv;
void *iv;
int irq = APIC_INT_IRQ(ih);
int line = APIC_INT_LINE(ih);
u_int32_t ent0;
/* no mapping or bogus */
if (irq <= 0 || irq > 31)
return (NULL);
aiv = malloc(sizeof(struct apic_iv), M_DEVBUF, M_NOWAIT);
if (aiv == NULL)
return (NULL);
cnt = malloc(sizeof(struct evcount), M_DEVBUF, M_NOWAIT);
if (!cnt) {
free(aiv, M_DEVBUF, sizeof *aiv);
return (NULL);
}
aiv->sc = sc;
aiv->ih = ih;
aiv->handler = handler;
aiv->arg = arg;
aiv->next = NULL;
aiv->cnt = cnt;
evcount_attach(cnt, name, NULL);
if (apic_intr_list[irq]) {
biv = apic_intr_list[irq];
while (biv->next)
biv = biv->next;
biv->next = aiv;
return (arg);
}
if ((iv = cpu_intr_establish(pri, irq, apic_intr, aiv, NULL))) {
ent0 = (31 - irq) & APIC_ENT0_VEC;
ent0 |= apic_get_int_ent0(sc, line);
#if 0
if (cold) {
sc->sc_imr |= (1 << irq);
ent0 |= APIC_ENT0_MASK;
}
#endif
apic_write(sc->sc_regs, APIC_ENT0(line), APIC_ENT0_MASK);
apic_write(sc->sc_regs, APIC_ENT1(line),
((hpa & 0x0ff00000) >> 4) | ((hpa & 0x000ff000) << 12));
apic_write(sc->sc_regs, APIC_ENT0(line), ent0);
/* Signal EOI. */
elroy_write32(&r->apic_eoi,
htole32((31 - irq) & APIC_ENT0_VEC));
apic_intr_list[irq] = aiv;
}
return (arg);
}
void
apic_intr_disestablish(void *v, void *cookie)
{
}
int
apic_intr(void *v)
{
struct apic_iv *iv = v;
struct elroy_softc *sc = iv->sc;
volatile struct elroy_regs *r = sc->sc_regs;
pci_intr_handle_t ih = iv->ih;
int claimed = 0;
while (iv) {
claimed = iv->handler(iv->arg);
if (claimed != 0 && iv->cnt)
iv->cnt->ec_count++;
if (claimed == 1)
break;
iv = iv->next;
}
/* Signal EOI. */
elroy_write32(&r->apic_eoi,
htole32((31 - APIC_INT_IRQ(ih)) & APIC_ENT0_VEC));
return (claimed);
}
/* Maximum number of supported interrupt routing entries. */
#define MAX_INT_TBL_SZ 16
void
apic_get_int_tbl(struct elroy_softc *sc)
{
struct pdc_pat_io_num int_tbl_sz PDC_ALIGNMENT;
struct pdc_pat_pci_rt int_tbl[MAX_INT_TBL_SZ] PDC_ALIGNMENT;
size_t size;
/*
* XXX int_tbl should not be allocated on the stack, but we need a
* 1:1 mapping, and malloc doesn't provide that.
*/
if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL_SZ,
&int_tbl_sz, 0, 0, 0, 0, 0))
return;
if (int_tbl_sz.num > MAX_INT_TBL_SZ)
panic("interrupt routing table too big (%d entries)",
int_tbl_sz.num);
size = int_tbl_sz.num * sizeof(struct pdc_pat_pci_rt);
sc->sc_int_tbl_sz = int_tbl_sz.num;
sc->sc_int_tbl = malloc(size, M_DEVBUF, M_NOWAIT);
if (sc->sc_int_tbl == NULL)
return;
if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL,
&int_tbl_sz, 0, &int_tbl, 0, 0, 0))
return;
memcpy(sc->sc_int_tbl, int_tbl, size);
}
u_int32_t
apic_get_int_ent0(struct elroy_softc *sc, int line)
{
volatile struct elroy_regs *r = sc->sc_regs;
int trigger = MPS_INT(MPS_INTPO_DEF, MPS_INTTR_DEF);
u_int32_t ent0 = APIC_ENT0_LOW | APIC_ENT0_LEV;
int bus, mpspo, mpstr;
int i;
bus = letoh32(elroy_read32(&r->busnum)) & 0xff;
for (i = 0; i < sc->sc_int_tbl_sz; i++) {
if (bus == sc->sc_int_tbl[i].bus &&
line == sc->sc_int_tbl[i].line)
trigger = sc->sc_int_tbl[i].trigger;
}
mpspo = (trigger >> MPS_INTPO_SHIFT) & MPS_INTPO_MASK;
mpstr = (trigger >> MPS_INTTR_SHIFT) & MPS_INTTR_MASK;
switch (mpspo) {
case MPS_INTPO_DEF:
break;
case MPS_INTPO_ACTHI:
ent0 &= ~APIC_ENT0_LOW;
break;
case MPS_INTPO_ACTLO:
ent0 |= APIC_ENT0_LOW;
break;
default:
panic("unknown MPS interrupt polarity %d", mpspo);
}
switch(mpstr) {
case MPS_INTTR_DEF:
break;
case MPS_INTTR_LEVEL:
ent0 |= APIC_ENT0_LEV;
break;
case MPS_INTTR_EDGE:
ent0 &= ~APIC_ENT0_LEV;
break;
default:
panic("unknown MPS interrupt trigger %d", mpstr);
}
return ent0;
}
#ifdef DEBUG
void
apic_dump(struct elroy_softc *sc)
{
int i;
for (i = 0; i < sc->sc_nints; i++)
printf("0x%04x 0x%04x\n", apic_read(sc->sc_regs, APIC_ENT0(i)),
apic_read(sc->sc_regs, APIC_ENT1(i)));
for (i = 0; i < sc->sc_int_tbl_sz; i++) {
printf("type=%x ", sc->sc_int_tbl[i].type);
printf("len=%d ", sc->sc_int_tbl[i].len);
printf("itype=%d ", sc->sc_int_tbl[i].itype);
printf("trigger=%x ", sc->sc_int_tbl[i].trigger);
printf("pin=%x ", sc->sc_int_tbl[i].pin);
printf("bus=%d ", sc->sc_int_tbl[i].bus);
printf("line=%d ", sc->sc_int_tbl[i].line);
printf("addr=%x\n", sc->sc_int_tbl[i].addr);
}
}
#endif
|
5e12d3f8c5cbdddcd625ae378e6003ba0d12860c
|
fa1ad2e2ac7e376fc7cb3b3a6e1bb88eed3e80be
|
/govern/data-security/krb-1.2.1/src/lib/gssapi/generic/gssapi_generic.c
|
c2f98d410ae5334ef687a5068b79a4ce3abd9c42
|
[
"BSD-4-Clause",
"LicenseRef-scancode-generic-export-compliance",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-mit-old-style",
"BSD-4-Clause-UC",
"LicenseRef-scancode-rsa-1990",
"BSD-3-Clause",
"MIT-CMU",
"LicenseRef-scancode-mit-no-advert-export-control",
"CC-BY-SA-3.0",
"LicenseRef-scancode-mit-modification-obligations",
"LicenseRef-scancode-proprietary-license",
"GPL-2.0-or-later",
"LicenseRef-scancode-michigan-disclaimer",
"ISC",
"LicenseRef-scancode-nrl-permission",
"FreeBSD-DOC",
"LicenseRef-scancode-rsa-md4",
"RSA-MD",
"OLDAP-2.8",
"FSFULLRWD",
"BSD-2-Clause",
"LicenseRef-scancode-brian-gladman",
"MIT",
"Apache-2.0"
] |
permissive
|
alldatacenter/alldata
|
7bc7713c9f1d56ad6b8e59ea03206d1073b7e047
|
8d5f9a2d49ab8f9e85ccf058cb02c2fda287afc6
|
refs/heads/master
| 2023-08-05T07:32:25.442740
| 2023-08-03T13:17:24
| 2023-08-03T13:17:24
| 213,321,771
| 774
| 250
|
Apache-2.0
| 2023-09-06T17:35:32
| 2019-10-07T07:36:18
| null |
UTF-8
|
C
| false
| false
| 17,415
|
c
|
gssapi_generic.c
|
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 1993 by OpenVision Technologies, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appears in all copies and
* that both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of OpenVision not be used
* in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. OpenVision makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* $Id$
*/
#include "gssapiP_generic.h"
/*
* See krb5/gssapi_krb5.c for a description of the algorithm for
* encoding an object identifier.
*/
/* Reserved static storage for GSS_oids. Comments are quotes from RFC 2744. */
#define oids ((gss_OID_desc *)const_oids)
static const gss_OID_desc const_oids[] = {
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value */
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x01"},
/* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) user_name(1)}. The constant
* GSS_C_NT_USER_NAME should be initialized to point
* to that gss_OID_desc.
*/
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value */
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x02"},
/* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) machine_uid_name(2)}.
* The constant GSS_C_NT_MACHINE_UID_NAME should be
* initialized to point to that gss_OID_desc.
*/
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value */
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03"},
/* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) string_uid_name(3)}.
* The constant GSS_C_NT_STRING_UID_NAME should be
* initialized to point to that gss_OID_desc.
*/
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value */
{6, (void *)"\x2b\x06\x01\x05\x06\x02"},
/* corresponding to an object-identifier value of
* {iso(1) org(3) dod(6) internet(1) security(5)
* nametypes(6) gss-host-based-services(2)). The constant
* GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point
* to that gss_OID_desc. This is a deprecated OID value, and
* implementations wishing to support hostbased-service names
* should instead use the GSS_C_NT_HOSTBASED_SERVICE OID,
* defined below, to identify such names;
* GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym
* for GSS_C_NT_HOSTBASED_SERVICE when presented as an input
* parameter, but should not be emitted by GSS-API
* implementations
*/
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value */
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04"},
/* corresponding to an object-identifier value of
* {iso(1) member-body(2) Unites States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) service_name(4)}.
* The constant GSS_C_NT_HOSTBASED_SERVICE should be
* initialized to point to that gss_OID_desc.
*/
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value */
{6, (void *)"\x2b\x06\01\x05\x06\x03"},
/* corresponding to an object identifier value of
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
* 6(nametypes), 3(gss-anonymous-name)}. The constant
* and GSS_C_NT_ANONYMOUS should be initialized to point
* to that gss_OID_desc.
*/
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value */
{6, (void *)"\x2b\x06\x01\x05\x06\x04"},
/* corresponding to an object-identifier value of
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
* 6(nametypes), 4(gss-api-exported-name)}. The constant
* GSS_C_NT_EXPORT_NAME should be initialized to point
* to that gss_OID_desc.
*/
{6, (void *)"\x2b\x06\x01\x05\x06\x06"},
/* corresponding to an object-identifier value of
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
* 6(nametypes), 6(gss-composite-export)}. The constant
* GSS_C_NT_COMPOSITE_EXPORT should be initialized to point
* to that gss_OID_desc.
*/
/* GSS_C_INQ_SSPI_SESSION_KEY 1.2.840.113554.1.2.2.5.5 */
{11, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x05\x05"},
/* GSS_C_INQ_NEGOEX_KEY 1.2.840.113554.1.2.2.5.16 */
{11, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x05\x10"},
/* GSS_C_INQ_NEGOEX_VERIFY_KEY 1.2.840.113554.1.2.2.5.17 */
{11, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x05\x11"},
/* RFC 5587 attributes, see below */
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x01"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x02"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x03"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x04"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x05"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x06"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x07"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x08"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x09"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x0a"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x0b"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x0c"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x0d"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x0e"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x0f"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x10"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x11"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x12"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x13"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x14"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x15"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x16"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x17"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x18"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x19"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x1a"},
{7, (void *)"\x2b\x06\x01\x05\x05\x0d\x1b"},
/* GSS_C_MA_NEGOEX_AND_SPNEGO 1.2.840.113554.1.2.2.5.18 */
{11, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x05\x12"},
/*
* GSS_SEC_CONTEXT_SASL_SSF_OID 1.2.840.113554.1.2.2.5.15
* iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) krb5(2) krb5-gssapi-ext(5) sasl-ssf(15)
*/
{11, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x05\x0f"},
};
/* Here are the constants which point to the static structure above.
*
* Constants of the form GSS_C_NT_* are specified by rfc 2744.
*
* Constants of the form gss_nt_* are the original MIT krb5 names
* found in gssapi_generic.h. They are provided for compatibility. */
GSS_DLLIMP gss_OID GSS_C_NT_USER_NAME = oids+0;
GSS_DLLIMP gss_OID gss_nt_user_name = oids+0;
GSS_DLLIMP gss_OID GSS_C_NT_MACHINE_UID_NAME = oids+1;
GSS_DLLIMP gss_OID gss_nt_machine_uid_name = oids+1;
GSS_DLLIMP gss_OID GSS_C_NT_STRING_UID_NAME = oids+2;
GSS_DLLIMP gss_OID gss_nt_string_uid_name = oids+2;
GSS_DLLIMP gss_OID GSS_C_NT_HOSTBASED_SERVICE_X = oids+3;
gss_OID gss_nt_service_name_v2 = oids+3;
GSS_DLLIMP gss_OID GSS_C_NT_HOSTBASED_SERVICE = oids+4;
GSS_DLLIMP gss_OID gss_nt_service_name = oids+4;
GSS_DLLIMP gss_OID GSS_C_NT_ANONYMOUS = oids+5;
GSS_DLLIMP gss_OID GSS_C_NT_EXPORT_NAME = oids+6;
gss_OID gss_nt_exported_name = oids+6;
GSS_DLLIMP gss_OID GSS_C_NT_COMPOSITE_EXPORT = oids+7;
GSS_DLLIMP gss_OID GSS_C_INQ_SSPI_SESSION_KEY = oids+8;
GSS_DLLIMP gss_OID GSS_C_INQ_NEGOEX_KEY = oids+9;
GSS_DLLIMP gss_OID GSS_C_INQ_NEGOEX_VERIFY_KEY = oids+10;
GSS_DLLIMP gss_const_OID GSS_C_MA_MECH_CONCRETE = oids+11;
GSS_DLLIMP gss_const_OID GSS_C_MA_MECH_PSEUDO = oids+12;
GSS_DLLIMP gss_const_OID GSS_C_MA_MECH_COMPOSITE = oids+13;
GSS_DLLIMP gss_const_OID GSS_C_MA_MECH_NEGO = oids+14;
GSS_DLLIMP gss_const_OID GSS_C_MA_MECH_GLUE = oids+15;
GSS_DLLIMP gss_const_OID GSS_C_MA_NOT_MECH = oids+16;
GSS_DLLIMP gss_const_OID GSS_C_MA_DEPRECATED = oids+17;
GSS_DLLIMP gss_const_OID GSS_C_MA_NOT_DFLT_MECH = oids+18;
GSS_DLLIMP gss_const_OID GSS_C_MA_ITOK_FRAMED = oids+19;
GSS_DLLIMP gss_const_OID GSS_C_MA_AUTH_INIT = oids+20;
GSS_DLLIMP gss_const_OID GSS_C_MA_AUTH_TARG = oids+21;
GSS_DLLIMP gss_const_OID GSS_C_MA_AUTH_INIT_INIT = oids+22;
GSS_DLLIMP gss_const_OID GSS_C_MA_AUTH_TARG_INIT = oids+23;
GSS_DLLIMP gss_const_OID GSS_C_MA_AUTH_INIT_ANON = oids+24;
GSS_DLLIMP gss_const_OID GSS_C_MA_AUTH_TARG_ANON = oids+25;
GSS_DLLIMP gss_const_OID GSS_C_MA_DELEG_CRED = oids+26;
GSS_DLLIMP gss_const_OID GSS_C_MA_INTEG_PROT = oids+27;
GSS_DLLIMP gss_const_OID GSS_C_MA_CONF_PROT = oids+28;
GSS_DLLIMP gss_const_OID GSS_C_MA_MIC = oids+29;
GSS_DLLIMP gss_const_OID GSS_C_MA_WRAP = oids+30;
GSS_DLLIMP gss_const_OID GSS_C_MA_PROT_READY = oids+31;
GSS_DLLIMP gss_const_OID GSS_C_MA_REPLAY_DET = oids+32;
GSS_DLLIMP gss_const_OID GSS_C_MA_OOS_DET = oids+33;
GSS_DLLIMP gss_const_OID GSS_C_MA_CBINDINGS = oids+34;
GSS_DLLIMP gss_const_OID GSS_C_MA_PFS = oids+35;
GSS_DLLIMP gss_const_OID GSS_C_MA_COMPRESS = oids+36;
GSS_DLLIMP gss_const_OID GSS_C_MA_CTX_TRANS = oids+37;
GSS_DLLIMP gss_const_OID GSS_C_MA_NEGOEX_AND_SPNEGO = oids+38;
GSS_DLLIMP gss_OID GSS_C_SEC_CONTEXT_SASL_SSF = oids+39;
static gss_OID_set_desc gss_ma_known_attrs_desc = { 28, oids+11 };
gss_OID_set gss_ma_known_attrs = &gss_ma_known_attrs_desc;
static struct mech_attr_info_desc {
gss_OID mech_attr;
const char *name;
const char *short_desc;
const char *long_desc;
} mech_attr_info[] = {
{
oids+11,
"GSS_C_MA_MECH_CONCRETE",
"concrete-mech",
"Mechanism is neither a pseudo-mechanism nor a composite mechanism.",
},
{
oids+12,
"GSS_C_MA_MECH_PSEUDO",
"pseudo-mech",
"Mechanism is a pseudo-mechanism.",
},
{
oids+13,
"GSS_C_MA_MECH_COMPOSITE",
"composite-mech",
"Mechanism is a composite of other mechanisms.",
},
{
oids+14,
"GSS_C_MA_MECH_NEGO",
"mech-negotiation-mech",
"Mechanism negotiates other mechanisms.",
},
{
oids+15,
"GSS_C_MA_MECH_GLUE",
"mech-glue",
"OID is not a mechanism but the GSS-API itself.",
},
{
oids+16,
"GSS_C_MA_NOT_MECH",
"not-mech",
"Known OID but not a mechanism OID.",
},
{
oids+17,
"GSS_C_MA_DEPRECATED",
"mech-deprecated",
"Mechanism is deprecated.",
},
{
oids+18,
"GSS_C_MA_NOT_DFLT_MECH",
"mech-not-default",
"Mechanism must not be used as a default mechanism.",
},
{
oids+19,
"GSS_C_MA_ITOK_FRAMED",
"initial-is-framed",
"Mechanism's initial contexts are properly framed.",
},
{
oids+20,
"GSS_C_MA_AUTH_INIT",
"auth-init-princ",
"Mechanism supports authentication of initiator to acceptor.",
},
{
oids+21,
"GSS_C_MA_AUTH_TARG",
"auth-targ-princ",
"Mechanism supports authentication of acceptor to initiator.",
},
{
oids+22,
"GSS_C_MA_AUTH_INIT_INIT",
"auth-init-princ-initial",
"Mechanism supports authentication of initiator using "
"initial credentials.",
},
{
oids+23,
"GSS_C_MA_AUTH_TARG_INIT",
"auth-target-princ-initial",
"Mechanism supports authentication of acceptor using "
"initial credentials.",
},
{
oids+24,
"GSS_C_MA_AUTH_INIT_ANON",
"auth-init-princ-anon",
"Mechanism supports GSS_C_NT_ANONYMOUS as an initiator name.",
},
{
oids+25,
"GSS_C_MA_AUTH_TARG_ANON",
"auth-targ-princ-anon",
"Mechanism supports GSS_C_NT_ANONYMOUS as an acceptor name.",
},
{
oids+26,
"GSS_C_MA_DELEG_CRED",
"deleg-cred",
"Mechanism supports credential delegation.",
},
{
oids+27,
"GSS_C_MA_INTEG_PROT",
"integ-prot",
"Mechanism supports per-message integrity protection.",
},
{
oids+28,
"GSS_C_MA_CONF_PROT",
"conf-prot",
"Mechanism supports per-message confidentiality protection.",
},
{
oids+29,
"GSS_C_MA_MIC",
"mic",
"Mechanism supports Message Integrity Code (MIC) tokens.",
},
{
oids+30,
"GSS_C_MA_WRAP",
"wrap",
"Mechanism supports wrap tokens.",
},
{
oids+31,
"GSS_C_MA_PROT_READY",
"prot-ready",
"Mechanism supports per-message proteciton prior to "
"full context establishment.",
},
{
oids+32,
"GSS_C_MA_REPLAY_DET",
"replay-detection",
"Mechanism supports replay detection.",
},
{
oids+33,
"GSS_C_MA_OOS_DET",
"oos-detection",
"Mechanism supports out-of-sequence detection.",
},
{
oids+34,
"GSS_C_MA_CBINDINGS",
"channel-bindings",
"Mechanism supports channel bindings.",
},
{
oids+35,
"GSS_C_MA_PFS",
"pfs",
"Mechanism supports Perfect Forward Security.",
},
{
oids+36,
"GSS_C_MA_COMPRESS",
"compress",
"Mechanism supports compression of data inputs to gss_wrap().",
},
{
oids+37,
"GSS_C_MA_CTX_TRANS",
"context-transfer",
"Mechanism supports security context export/import.",
},
{
oids+38,
"GSS_C_MA_NEGOEX_AND_SPNEGO",
"negoex-only",
"NegoEx mechanism should also be negotiable through SPNEGO.",
},
};
OM_uint32
generic_gss_display_mech_attr(
OM_uint32 *minor_status,
gss_const_OID mech_attr,
gss_buffer_t name,
gss_buffer_t short_desc,
gss_buffer_t long_desc)
{
size_t i;
if (minor_status != NULL)
*minor_status = 0;
if (name != GSS_C_NO_BUFFER) {
name->length = 0;
name->value = NULL;
}
if (short_desc != GSS_C_NO_BUFFER) {
short_desc->length = 0;
short_desc->value = NULL;
}
if (long_desc != GSS_C_NO_BUFFER) {
long_desc->length = 0;
long_desc->value = NULL;
}
if (minor_status == NULL)
return GSS_S_CALL_INACCESSIBLE_WRITE;
for (i = 0; i < sizeof(mech_attr_info)/sizeof(mech_attr_info[0]); i++) {
struct mech_attr_info_desc *mai = &mech_attr_info[i];
if (g_OID_equal(mech_attr, mai->mech_attr)) {
if (name != GSS_C_NO_BUFFER &&
!g_make_string_buffer(mai->name, name)) {
*minor_status = ENOMEM;
return GSS_S_FAILURE;
}
if (short_desc != GSS_C_NO_BUFFER &&
!g_make_string_buffer(mai->short_desc, short_desc)) {
*minor_status = ENOMEM;
return GSS_S_FAILURE;
}
if (long_desc != GSS_C_NO_BUFFER &&
!g_make_string_buffer(mai->long_desc, long_desc)) {
*minor_status = ENOMEM;
return GSS_S_FAILURE;
}
return GSS_S_COMPLETE;
}
}
return GSS_S_BAD_MECH_ATTR;
}
static gss_buffer_desc const_attrs[] = {
{ sizeof("local-login-user") - 1,
"local-login-user" },
};
GSS_DLLIMP gss_buffer_t GSS_C_ATTR_LOCAL_LOGIN_USER = &const_attrs[0];
|
bcad0181f977f6bebe9ebdc4cfc6470785e22994
|
de21f9075f55640514c29ef0f1fe3f0690845764
|
/regression/cbmc-concurrency/malloc2/main.c
|
1e5a3f47a8645ffd0daf0fff9f30cc757f60a862
|
[
"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
| 309
|
c
|
main.c
|
#include <stdlib.h>
_Bool set_done;
int *ptr;
void *set_x(void *arg)
{
*(int *)arg = 10;
set_done = 1;
}
int main(int argc, char *argv[])
{
__CPROVER_assume(argc >= sizeof(int));
ptr = malloc(argc);
__CPROVER_ASYNC_1: set_x(ptr);
__CPROVER_assume(set_done);
assert(*ptr == 10);
return 0;
}
|
415d1b86306180fd906af045eed44d84098aaa78
|
e552c5408e825acc3a00ae8ab8e0697beddf7a0a
|
/examples/ex4_echo_server.c
|
2cc617cee7fb0754f6ee79abf67fed85dc88fcc4
|
[
"MIT",
"PostgreSQL",
"ISC",
"BSD-3-Clause",
"BSL-1.0",
"BSD-2-Clause"
] |
permissive
|
xhawk18/s_task
|
f81dda8252bbb0631b564eb8775c8008bc4f5583
|
d1e9a348a570433f0f5655f64c8dd3b94a6d1cbe
|
refs/heads/master
| 2023-08-13T08:11:27.712894
| 2023-04-11T12:29:43
| 2023-04-11T12:29:43
| 242,364,894
| 552
| 88
| null | null | null | null |
UTF-8
|
C
| false
| false
| 6,360
|
c
|
ex4_echo_server.c
|
/* Copyright xhawk, MIT license */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "s_task.h"
#define MAX_CLINETS 100
typedef struct {
uv_loop_t* loop;
uv_tcp_t tcp_server;
bool closed;
size_t client_counts;
s_event_t event;
s_list_t running_clients;
s_list_t stopped_clients;
void* stack[32 * 1024];
void* stack_timer[32 * 1024];
} server_t;
typedef struct {
s_list_t list_node;
server_t* server;
uv_tcp_t stream;
void* stack[32 * 1024];
} client_t;
static server_t g_server;
static void run_client(__async__, void* arg) {
client_t* client = (client_t*)arg;
printf("in run_client\n");
int ret;
/* accept the socket */
ret = uv_tcp_init(client->server->loop, (uv_tcp_t*)&client->stream);
if (ret != 0) {
fprintf(stderr, "uv_tcp_init: %s\n", uv_strerror(ret));
goto out0;
}
ret = uv_accept((uv_stream_t*)&client->server->tcp_server, (uv_stream_t*)&client->stream);
if (ret != 0) {
fprintf(stderr, "uv_accept: %s\n", uv_strerror(ret));
goto out1;
}
if (client->server->client_counts >= MAX_CLINETS) {
fprintf(stderr, "max connection exceeds!");
goto out1;
}
/* increase client accounts */
++client->server->client_counts;
/* run echo service */
while (true) {
char buf[256];
ssize_t nread;
ret = s_uv_read(__await__, (uv_stream_t*)&client->stream, buf, sizeof(buf), &nread);
if (ret != 0)
break;
ret = s_uv_write(__await__, (uv_stream_t*)&client->stream, buf, nread);
if (ret != 0)
break;
}
/* decrease client accounts */
--client->server->client_counts;
out1:;
s_uv_close(__await__, (uv_handle_t*)&client->stream);
out0:;
/* set to be joined a release the memory */
s_list_detach(&client->list_node);
s_list_attach(&client->server->stopped_clients, &client->list_node);
s_event_set(&client->server->event);
}
static void on_connection(uv_stream_t* stream, int status) {
server_t* server = GET_PARENT_ADDR(stream, server_t, tcp_server);
client_t* client;
if (status != 0) {
fprintf(stderr, "Connect error %s\n", uv_err_name(status));
return;
}
client = (client_t*)malloc(sizeof(client_t));
printf("alloc task = %p\n", client);
if (client == NULL) {
fprintf(stderr, "no enough memory %d", __LINE__);
return;
}
client->server = server;
/* s_event_init(&client->event); */
s_list_init(&client->list_node);
s_list_attach(&server->running_clients, &client->list_node);
s_task_create(client->stack, sizeof(client->stack), run_client, (void*)client);
}
void stop_server(server_t* server) {
server->closed = true;
s_task_cancel_wait(server->stack);
s_event_set(&server->event);
}
static void stop_client(client_t* client) {
s_task_cancel_wait(client->stack);
}
static void join_clients(__async__, server_t* server) {
while (true) {
s_list_t* node = s_list_get_next(&server->stopped_clients);
if (node == &server->stopped_clients)
break;
s_list_detach(node);
client_t* client = GET_PARENT_ADDR(node, client_t, list_node);
s_task_join(__await__, client->stack);
printf("free task = %p\n", client);
free(client);
}
}
void run_server(__async__, void *arg) {
server_t* server = (server_t*)arg;
struct sockaddr_in addr;
s_list_t* node;
int ret;
const char *HOST = "0.0.0.0";
const unsigned short PORT = 3333;
/* Initialize server data */
server->closed = false;
server->client_counts = 0;
s_event_init(&server->event);
s_list_init(&server->running_clients);
s_list_init(&server->stopped_clients);
ret = uv_ip4_addr(HOST, PORT, &addr);
if (ret) {
/* TODO: Error codes */
fprintf(stderr, "uv_ip4_addr error: %s\n", uv_strerror(ret));
goto out0;
}
ret = uv_tcp_init(server->loop, &server->tcp_server);
if (ret) {
fprintf(stderr, "Socket creation error: %s\n", uv_strerror(ret));
goto out1;
}
ret = uv_tcp_bind(&server->tcp_server, (const struct sockaddr*) & addr, 0);
if (ret) {
fprintf(stderr, "Bind error: %s\n", uv_strerror(ret));
goto out1;
}
ret = uv_listen((uv_stream_t*)&server->tcp_server, SOMAXCONN, on_connection);
if (ret) {
fprintf(stderr, "Listen error: %s\n", uv_strerror(ret));
goto out1;
}
printf("Listening on port %s:%d\n", HOST, (int)PORT);
while (!server->closed) {
s_event_wait(__await__, &server->event);
/* join the client tasks if there're any */
join_clients(__await__, server);
}
/* stop and wait all clients exit */
for (node = s_list_get_next(&server->running_clients);
node != &server->running_clients;
node = s_list_get_next(node)) {
client_t* client = GET_PARENT_ADDR(node, client_t, list_node);
stop_client(client);
}
while (!s_list_is_empty(&server->running_clients)) {
s_event_wait(__await__, &server->event);
}
/* join the client tasks */
join_clients(__await__, server);
printf("Listen closed\n");
out1:;
s_uv_close(__await__, (uv_handle_t*)&server->tcp_server);
out0:;
}
void run_timer(__async__, void* arg) {
server_t* server = (server_t*)arg;
uint32_t second = 60;
s_task_sleep(__await__, second);
printf("Gracefully close server after %d seconds.", (int)second);
stop_server(server);
}
int main(void) {
uv_loop_t *loop = uv_default_loop();
s_task_init_uv_system(loop);
g_server.loop = loop;
/* Start the server task */
s_task_create(g_server.stack, sizeof(g_server.stack), run_server, (void *)&g_server);
/* Start a new task that will close the server gracefully after 60 seconds. */
s_task_create(g_server.stack_timer, sizeof(g_server.stack_timer), run_timer, (void*)&g_server);
uv_run(loop, UV_RUN_DEFAULT);
printf("all task is over\n");
return 0;
}
|
22363e08d6ffe9d3ea7ada1e6607400a698a9027
|
4fb44fd2eaa39a270897f6fe2da2b968efddf2a0
|
/src/getdevicesize.c
|
cf183a426c35327cd370e50ddbb62f12a531d6ba
|
[] |
no_license
|
kdave/xfstests
|
75226d7dabd3de0c95bd768313852e8e9831c155
|
0ca1d4fbb2e9a492968f2951df101f24477f7991
|
refs/heads/master
| 2023-08-31T00:49:55.808164
| 2023-08-04T21:34:19
| 2023-08-05T13:53:09
| 8,715,288
| 103
| 65
| null | 2022-02-02T21:17:24
| 2013-03-11T23:05:35
|
Shell
|
UTF-8
|
C
| false
| false
| 1,207
|
c
|
getdevicesize.c
|
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2004 Silicon Graphics, Inc.
* All Rights Reserved.
*/
/*
* Test program that uses the same interfaces as mkfs.xfs for
* Linux, dumps out just the device size values from a driver.
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#ifndef BLKGETSIZE64
# define BLKGETSIZE64 _IOR(0x12,114,size_t)
#endif
int main(int argc, char **argv)
{
uint64_t size;
long long sz = -1;
int error, fd;
if (argc != 2) {
fputs("insufficient arguments\n", stderr);
return 1;
}
fd = open(argv[1], O_RDONLY);
if (!fd) {
perror(argv[1]);
return 1;
}
error = ioctl(fd, BLKGETSIZE64, &size);
if (error >= 0) {
/* BLKGETSIZE64 returns size in bytes not 512-byte blocks */
sz = (long long)(size >> 9);
printf("%lld 512 byte blocks (BLKGETSIZE64)\n", sz);
} else {
/* If BLKGETSIZE64 fails, try BLKGETSIZE */
unsigned long tmpsize;
error = ioctl(fd, BLKGETSIZE, &tmpsize);
if (error < 0) {
fprintf(stderr, "can't determine device size");
return 1;
}
sz = (long long)tmpsize;
printf("%lld 512 byte blocks (BLKGETSIZE)\n", sz);
}
return 0;
}
|
c491eef724eda5e272e20ea585a724a34a856dfc
|
0744dcc5394cebf57ebcba343747af6871b67017
|
/os/board/rtl8721csm/src/component/soc/realtek/amebad/swlib/string/strupr.c
|
58be4a1dee44e9f3b2deaf37a29587fbce06e4bb
|
[
"Apache-2.0",
"GPL-1.0-or-later",
"BSD-3-Clause",
"ISC",
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive"
] |
permissive
|
Samsung/TizenRT
|
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
|
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
|
refs/heads/master
| 2023-08-31T08:59:33.327998
| 2023-08-08T06:09:20
| 2023-08-31T04:38:20
| 82,517,252
| 590
| 719
|
Apache-2.0
| 2023-09-14T06:54:49
| 2017-02-20T04:38:30
|
C
|
UTF-8
|
C
| false
| false
| 750
|
c
|
strupr.c
|
/*
* Routines to access hardware
*
* Copyright (c) 2013 Realtek Semiconductor Corp.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*/
#include "basic_types.h"
#include <stdarg.h>
#include <stddef.h> /* Compiler defns such as size_t, NULL etc. */
#include "strproc.h"
#include "section_config.h"
#include "diag.h"
#include "ameba_soc.h"
LIBC_ROM_TEXT_SECTION
_LONG_CALL_ u8*
_strupr(
IN u8 *string
){
u8 *pStr;
const u8 diff = 'a' - 'A';
pStr = string;
while(*pStr){
if ((*pStr >= 'a') && (*pStr <= 'z')){
*pStr -= diff;
}
pStr++;
}
return string;
}
|
436352d0a8a8617b7c891e26d7d0dda3fde713f7
|
ec3d500559e41b0ba0501a3cc565ce70098016c6
|
/ext/numo/narray/gen/tmpl/alloc_func.c
|
f13cb6aaac18c3909b5b71bcdd70a49daa736a3f
|
[
"BSD-3-Clause"
] |
permissive
|
ruby-numo/numo-narray
|
f60dcd79aaea0db6effa30e53ef67fb6ab8db8d4
|
1dd19df10045f992bda6fdca9a696fe85a90aaaf
|
refs/heads/master
| 2023-08-01T19:56:47.840328
| 2022-08-20T10:55:47
| 2022-08-20T10:55:47
| 11,340,157
| 290
| 31
|
BSD-3-Clause
| 2022-11-12T07:01:10
| 2013-07-11T11:22:52
|
C
|
UTF-8
|
C
| false
| false
| 2,584
|
c
|
alloc_func.c
|
static size_t
<%=type_name%>_memsize(const void* ptr)
{
size_t size = sizeof(narray_data_t);
const narray_data_t *na = (const narray_data_t*)ptr;
assert(na->base.type == NARRAY_DATA_T);
if (na->ptr != NULL) {
<% if is_bit %>
size += ((na->base.size-1)/8/sizeof(BIT_DIGIT)+1)*sizeof(BIT_DIGIT);
<% else %>
size += na->base.size * sizeof(dtype);
<% end %>
}
if (na->base.size > 0) {
if (na->base.shape != NULL && na->base.shape != &(na->base.size)) {
size += sizeof(size_t) * na->base.ndim;
}
}
return size;
}
static void
<%=type_name%>_free(void* ptr)
{
narray_data_t *na = (narray_data_t*)ptr;
assert(na->base.type == NARRAY_DATA_T);
if (na->ptr != NULL) {
if (na->owned) {
xfree(na->ptr);
}
na->ptr = NULL;
}
if (na->base.size > 0) {
if (na->base.shape != NULL && na->base.shape != &(na->base.size)) {
xfree(na->base.shape);
na->base.shape = NULL;
}
}
xfree(na);
}
static narray_type_info_t <%=type_name%>_info = {
<% if is_bit %>
1, // element_bits
0, // element_bytes
1, // element_stride (in bits)
<% else %>
0, // element_bits
sizeof(dtype), // element_bytes
sizeof(dtype), // element_stride (in bytes)
<% end %>
};
<% if is_object %>
static void
<%=type_name%>_gc_mark(void *ptr)
{
size_t n, i;
VALUE *a;
narray_data_t *na = ptr;
if (na->ptr) {
a = (VALUE*)(na->ptr);
n = na->base.size;
for (i=0; i<n; i++) {
rb_gc_mark(a[i]);
}
}
}
static const rb_data_type_t <%=type_name%>_data_type = {
"<%=full_class_name%>",
{<%=type_name%>_gc_mark, <%=type_name%>_free, <%=type_name%>_memsize,},
&na_data_type,
&<%=type_name%>_info,
0, // flags
};
<% else %>
static const rb_data_type_t <%=type_name%>_data_type = {
"<%=full_class_name%>",
{0, <%=type_name%>_free, <%=type_name%>_memsize,},
&na_data_type,
&<%=type_name%>_info,
RUBY_TYPED_FROZEN_SHAREABLE, // flags
};
<% end %>
static VALUE
<%=c_func(0)%>(VALUE klass)
{
narray_data_t *na = ALLOC(narray_data_t);
na->base.ndim = 0;
na->base.type = NARRAY_DATA_T;
na->base.flag[0] = NA_FL0_INIT;
na->base.flag[1] = NA_FL1_INIT;
na->base.size = 0;
na->base.shape = NULL;
na->base.reduce = INT2FIX(0);
na->ptr = NULL;
na->owned = FALSE;
return TypedData_Wrap_Struct(klass, &<%=type_name%>_data_type, (void*)na);
}
|
2ebbea5e0b61b11e62ae8337d018eb4b1fd30b0f
|
99bdb3251fecee538e0630f15f6574054dfc1468
|
/bsp/imxrt/libraries/MIMXRT1064/MIMXRT1064/drivers/fsl_tsc.c
|
5ceae13b01a4191f0edbe763eb926123aa405894
|
[
"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
| 6,549
|
c
|
fsl_tsc.c
|
/*
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "fsl_tsc.h"
/* Component ID definition, used by tools. */
#ifndef FSL_COMPONENT_ID
#define FSL_COMPONENT_ID "platform.drivers.tsc"
#endif
/*******************************************************************************
* Prototypes
******************************************************************************/
/*!
* @brief Get instance number for TSC module.
*
* @param base TSC peripheral base address
*/
static uint32_t TSC_GetInstance(TSC_Type *base);
/*******************************************************************************
* Variables
******************************************************************************/
/*! @brief Pointers to TSC bases for each instance. */
static TSC_Type *const s_tscBases[] = TSC_BASE_PTRS;
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
/*! @brief Pointers to ADC clocks for each instance. */
static const clock_ip_name_t s_tscClocks[] = TSC_CLOCKS;
#endif
/*******************************************************************************
* Code
******************************************************************************/
static uint32_t TSC_GetInstance(TSC_Type *base)
{
uint32_t instance;
/* Find the instance index from base address mappings. */
for (instance = 0; instance < ARRAY_SIZE(s_tscBases); instance++)
{
if (s_tscBases[instance] == base)
{
break;
}
}
assert(instance < ARRAY_SIZE(s_tscBases));
return instance;
}
void TSC_Init(TSC_Type *base, const tsc_config_t *config)
{
assert(NULL != config);
assert(config->measureDelayTime <= 0xFFFFFFU);
uint32_t tmp32;
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
/* Enable the TSC clock. */
CLOCK_EnableClock(s_tscClocks[TSC_GetInstance(base)]);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
/* Configure TSC_BASIC_SETTING register. */
tmp32 = TSC_BASIC_SETTING_MEASURE_DELAY_TIME(config->measureDelayTime) |
TSC_BASIC_SETTING__4_5_WIRE(config->detectionMode);
if (config->enableAutoMeasure)
{
tmp32 |= TSC_BASIC_SETTING_AUTO_MEASURE_MASK;
}
base->BASIC_SETTING = tmp32;
/* Configure TSC_PS_INPUT_BUFFER_ADDR register. */
base->PRE_CHARGE_TIME = TSC_PRE_CHARGE_TIME_PRE_CHARGE_TIME(config->prechargeTime);
}
void TSC_Deinit(TSC_Type *base)
{
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
/* Disable the TSC clcok. */
CLOCK_DisableClock(s_tscClocks[TSC_GetInstance(base)]);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
}
void TSC_GetDefaultConfig(tsc_config_t *config)
{
config->enableAutoMeasure = false;
config->measureDelayTime = 0xFFFFU;
config->prechargeTime = 0xFFFFU;
config->detectionMode = kTSC_Detection4WireMode;
}
uint32_t TSC_GetMeasureValue(TSC_Type *base, tsc_corrdinate_value_selection_t selection)
{
uint32_t tmp32 = 0;
if (selection == kTSC_XCoordinateValueSelection)
{
tmp32 = ((base->MEASEURE_VALUE) & TSC_MEASEURE_VALUE_X_VALUE_MASK) >> TSC_MEASEURE_VALUE_X_VALUE_SHIFT;
}
else if (selection == kTSC_YCoordinateValueSelection)
{
tmp32 = ((base->MEASEURE_VALUE) & TSC_MEASEURE_VALUE_Y_VALUE_MASK) >> TSC_MEASEURE_VALUE_Y_VALUE_SHIFT;
}
else
{
}
return tmp32;
}
void TSC_DebugTriggerSignalToADC(TSC_Type *base, tsc_trigger_signal_t hwts, bool enable)
{
if (enable)
{
/* TSC_DEBUG_MODE_EXT_HWTS field should be writed before writing TSC_DEBUG_MODE_TRIGGER field.
If the two fields are writed at the same time, the trigger couldn't work as expect. */
base->DEBUG_MODE &= ~TSC_DEBUG_MODE_EXT_HWTS_MASK;
base->DEBUG_MODE |= TSC_DEBUG_MODE_EXT_HWTS(hwts);
base->DEBUG_MODE |= TSC_DEBUG_MODE_TRIGGER_MASK;
}
else
{
base->DEBUG_MODE &= ~TSC_DEBUG_MODE_TRIGGER_MASK;
}
}
void TSC_DebugEnableDetection(TSC_Type *base, tsc_detection_mode_t detectionMode, bool enable)
{
if (detectionMode == kTSC_Detection4WireMode)
{
if (enable)
{
base->DEBUG_MODE2 |= TSC_DEBUG_MODE2_DETECT_ENABLE_FOUR_WIRE_MASK;
}
else
{
base->DEBUG_MODE2 &= ~TSC_DEBUG_MODE2_DETECT_ENABLE_FOUR_WIRE_MASK;
}
}
else if (detectionMode == kTSC_Detection5WireMode)
{
if (enable)
{
base->DEBUG_MODE2 |= TSC_DEBUG_MODE2_DETECT_ENABLE_FIVE_WIRE_MASK;
}
else
{
base->DEBUG_MODE2 &= ~TSC_DEBUG_MODE2_DETECT_ENABLE_FIVE_WIRE_MASK;
}
}
else
{
}
}
void TSC_DebugSetPortMode(TSC_Type *base, tsc_port_source_t port, tsc_port_mode_t mode)
{
uint32_t tmp32;
tmp32 = base->DEBUG_MODE2;
switch (port)
{
case kTSC_WiperPortSource:
tmp32 &= ~(TSC_DEBUG_MODE2_WIPER_200K_PULL_UP_MASK | TSC_DEBUG_MODE2_WIPER_PULL_UP_MASK |
TSC_DEBUG_MODE2_WIPER_PULL_DOWN_MASK);
tmp32 |= ((uint32_t)mode << TSC_DEBUG_MODE2_WIPER_PULL_DOWN_SHIFT);
break;
case kTSC_YnlrPortSource:
tmp32 &= ~(TSC_DEBUG_MODE2_YNLR_200K_PULL_UP_MASK | TSC_DEBUG_MODE2_YNLR_PULL_UP_MASK |
TSC_DEBUG_MODE2_YNLR_PULL_DOWN_MASK);
tmp32 |= ((uint32_t)mode << TSC_DEBUG_MODE2_YNLR_PULL_DOWN_SHIFT);
break;
case kTSC_YpllPortSource:
tmp32 &= ~(TSC_DEBUG_MODE2_YPLL_200K_PULL_UP_MASK | TSC_DEBUG_MODE2_YPLL_PULL_UP_MASK |
TSC_DEBUG_MODE2_YPLL_PULL_DOWN_MASK);
tmp32 |= ((uint32_t)mode << TSC_DEBUG_MODE2_YPLL_PULL_DOWN_SHIFT);
break;
case kTSC_XnurPortSource:
tmp32 &= ~(TSC_DEBUG_MODE2_XNUR_200K_PULL_UP_MASK | TSC_DEBUG_MODE2_XNUR_PULL_UP_MASK |
TSC_DEBUG_MODE2_XNUR_PULL_DOWN_MASK);
tmp32 |= ((uint32_t)mode << TSC_DEBUG_MODE2_XNUR_PULL_DOWN_SHIFT);
break;
case kTSC_XpulPortSource:
tmp32 &= ~(TSC_DEBUG_MODE2_XPUL_200K_PULL_UP_MASK | TSC_DEBUG_MODE2_XPUL_PULL_UP_MASK |
TSC_DEBUG_MODE2_XPUL_PULL_DOWN_MASK);
tmp32 |= ((uint32_t)mode << TSC_DEBUG_MODE2_XPUL_PULL_DOWN_SHIFT);
break;
default:
break;
}
base->DEBUG_MODE2 = tmp32;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.